3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
8 * Copyright(c) 2015 Intel Corporation.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
21 * Copyright(c) 2015 Intel Corporation.
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
27 * - Redistributions of source code must retain the above copyright
28 * notice, this list of conditions and the following disclaimer.
29 * - Redistributions in binary form must reproduce the above copyright
30 * notice, this list of conditions and the following disclaimer in
31 * the documentation and/or other materials provided with the
33 * - Neither the name of Intel Corporation nor the names of its
34 * contributors may be used to endorse or promote products derived
35 * from this software without specific prior written permission.
37 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
38 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
39 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
40 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
41 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
44 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
45 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
46 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
47 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52 * This file contains all of the code that is specific to the HFI chip
55 #include <linux/pci.h>
56 #include <linux/delay.h>
57 #include <linux/interrupt.h>
58 #include <linux/module.h>
70 #define NUM_IB_PORTS 1
73 module_param_named(kdeth_qp, kdeth_qp, uint, S_IRUGO);
74 MODULE_PARM_DESC(kdeth_qp, "Set the KDETH queue pair prefix");
76 uint num_vls = HFI1_MAX_VLS_SUPPORTED;
77 module_param(num_vls, uint, S_IRUGO);
78 MODULE_PARM_DESC(num_vls, "Set number of Virtual Lanes to use (1-8)");
81 * Default time to aggregate two 10K packets from the idle state
82 * (timer not running). The timer starts at the end of the first packet,
83 * so only the time for one 10K packet and header plus a bit extra is needed.
84 * 10 * 1024 + 64 header byte = 10304 byte
85 * 10304 byte / 12.5 GB/s = 824.32ns
87 uint rcv_intr_timeout = (824 + 16); /* 16 is for coalescing interrupt */
88 module_param(rcv_intr_timeout, uint, S_IRUGO);
89 MODULE_PARM_DESC(rcv_intr_timeout, "Receive interrupt mitigation timeout in ns");
91 uint rcv_intr_count = 16; /* same as qib */
92 module_param(rcv_intr_count, uint, S_IRUGO);
93 MODULE_PARM_DESC(rcv_intr_count, "Receive interrupt mitigation count");
95 ushort link_crc_mask = SUPPORTED_CRCS;
96 module_param(link_crc_mask, ushort, S_IRUGO);
97 MODULE_PARM_DESC(link_crc_mask, "CRCs to use on the link");
100 module_param_named(loopback, loopback, uint, S_IRUGO);
101 MODULE_PARM_DESC(loopback, "Put into loopback mode (1 = serdes, 3 = external cable");
103 /* Other driver tunables */
104 uint rcv_intr_dynamic = 1; /* enable dynamic mode for rcv int mitigation*/
105 static ushort crc_14b_sideband = 1;
106 static uint use_flr = 1;
107 uint quick_linkup; /* skip LNI */
110 u64 flag; /* the flag */
111 char *str; /* description string */
112 u16 extra; /* extra information */
117 /* str must be a string constant */
118 #define FLAG_ENTRY(str, extra, flag) {flag, str, extra}
119 #define FLAG_ENTRY0(str, flag) {flag, str, 0}
121 /* Send Error Consequences */
122 #define SEC_WRITE_DROPPED 0x1
123 #define SEC_PACKET_DROPPED 0x2
124 #define SEC_SC_HALTED 0x4 /* per-context only */
125 #define SEC_SPC_FREEZE 0x8 /* per-HFI only */
127 #define MIN_KERNEL_KCTXTS 2
128 #define FIRST_KERNEL_KCTXT 1
129 #define NUM_MAP_REGS 32
131 /* Bit offset into the GUID which carries HFI id information */
132 #define GUID_HFI_INDEX_SHIFT 39
134 /* extract the emulation revision */
135 #define emulator_rev(dd) ((dd)->irev >> 8)
136 /* parallel and serial emulation versions are 3 and 4 respectively */
137 #define is_emulator_p(dd) ((((dd)->irev) & 0xf) == 3)
138 #define is_emulator_s(dd) ((((dd)->irev) & 0xf) == 4)
143 #define IB_PACKET_TYPE 2ull
144 #define QW_SHIFT 6ull
146 #define QPN_WIDTH 7ull
148 /* LRH.BTH: QW 0, OFFSET 48 - for match */
149 #define LRH_BTH_QW 0ull
150 #define LRH_BTH_BIT_OFFSET 48ull
151 #define LRH_BTH_OFFSET(off) ((LRH_BTH_QW << QW_SHIFT) | (off))
152 #define LRH_BTH_MATCH_OFFSET LRH_BTH_OFFSET(LRH_BTH_BIT_OFFSET)
153 #define LRH_BTH_SELECT
154 #define LRH_BTH_MASK 3ull
155 #define LRH_BTH_VALUE 2ull
157 /* LRH.SC[3..0] QW 0, OFFSET 56 - for match */
158 #define LRH_SC_QW 0ull
159 #define LRH_SC_BIT_OFFSET 56ull
160 #define LRH_SC_OFFSET(off) ((LRH_SC_QW << QW_SHIFT) | (off))
161 #define LRH_SC_MATCH_OFFSET LRH_SC_OFFSET(LRH_SC_BIT_OFFSET)
162 #define LRH_SC_MASK 128ull
163 #define LRH_SC_VALUE 0ull
165 /* SC[n..0] QW 0, OFFSET 60 - for select */
166 #define LRH_SC_SELECT_OFFSET ((LRH_SC_QW << QW_SHIFT) | (60ull))
168 /* QPN[m+n:1] QW 1, OFFSET 1 */
169 #define QPN_SELECT_OFFSET ((1ull << QW_SHIFT) | (1ull))
171 /* defines to build power on SC2VL table */
183 ((u64)(sc0val) << SEND_SC2VLT##num##_SC##sc0##_SHIFT) | \
184 ((u64)(sc1val) << SEND_SC2VLT##num##_SC##sc1##_SHIFT) | \
185 ((u64)(sc2val) << SEND_SC2VLT##num##_SC##sc2##_SHIFT) | \
186 ((u64)(sc3val) << SEND_SC2VLT##num##_SC##sc3##_SHIFT) | \
187 ((u64)(sc4val) << SEND_SC2VLT##num##_SC##sc4##_SHIFT) | \
188 ((u64)(sc5val) << SEND_SC2VLT##num##_SC##sc5##_SHIFT) | \
189 ((u64)(sc6val) << SEND_SC2VLT##num##_SC##sc6##_SHIFT) | \
190 ((u64)(sc7val) << SEND_SC2VLT##num##_SC##sc7##_SHIFT) \
193 #define DC_SC_VL_VAL( \
212 ((u64)(e0val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e0##_SHIFT) | \
213 ((u64)(e1val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e1##_SHIFT) | \
214 ((u64)(e2val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e2##_SHIFT) | \
215 ((u64)(e3val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e3##_SHIFT) | \
216 ((u64)(e4val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e4##_SHIFT) | \
217 ((u64)(e5val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e5##_SHIFT) | \
218 ((u64)(e6val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e6##_SHIFT) | \
219 ((u64)(e7val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e7##_SHIFT) | \
220 ((u64)(e8val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e8##_SHIFT) | \
221 ((u64)(e9val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e9##_SHIFT) | \
222 ((u64)(e10val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e10##_SHIFT) | \
223 ((u64)(e11val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e11##_SHIFT) | \
224 ((u64)(e12val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e12##_SHIFT) | \
225 ((u64)(e13val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e13##_SHIFT) | \
226 ((u64)(e14val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e14##_SHIFT) | \
227 ((u64)(e15val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e15##_SHIFT) \
230 /* all CceStatus sub-block freeze bits */
231 #define ALL_FROZE (CCE_STATUS_SDMA_FROZE_SMASK \
232 | CCE_STATUS_RXE_FROZE_SMASK \
233 | CCE_STATUS_TXE_FROZE_SMASK \
234 | CCE_STATUS_TXE_PIO_FROZE_SMASK)
235 /* all CceStatus sub-block TXE pause bits */
236 #define ALL_TXE_PAUSE (CCE_STATUS_TXE_PIO_PAUSED_SMASK \
237 | CCE_STATUS_TXE_PAUSED_SMASK \
238 | CCE_STATUS_SDMA_PAUSED_SMASK)
239 /* all CceStatus sub-block RXE pause bits */
240 #define ALL_RXE_PAUSE CCE_STATUS_RXE_PAUSED_SMASK
245 static struct flag_table cce_err_status_flags[] = {
246 /* 0*/ FLAG_ENTRY0("CceCsrParityErr",
247 CCE_ERR_STATUS_CCE_CSR_PARITY_ERR_SMASK),
248 /* 1*/ FLAG_ENTRY0("CceCsrReadBadAddrErr",
249 CCE_ERR_STATUS_CCE_CSR_READ_BAD_ADDR_ERR_SMASK),
250 /* 2*/ FLAG_ENTRY0("CceCsrWriteBadAddrErr",
251 CCE_ERR_STATUS_CCE_CSR_WRITE_BAD_ADDR_ERR_SMASK),
252 /* 3*/ FLAG_ENTRY0("CceTrgtAsyncFifoParityErr",
253 CCE_ERR_STATUS_CCE_TRGT_ASYNC_FIFO_PARITY_ERR_SMASK),
254 /* 4*/ FLAG_ENTRY0("CceTrgtAccessErr",
255 CCE_ERR_STATUS_CCE_TRGT_ACCESS_ERR_SMASK),
256 /* 5*/ FLAG_ENTRY0("CceRspdDataParityErr",
257 CCE_ERR_STATUS_CCE_RSPD_DATA_PARITY_ERR_SMASK),
258 /* 6*/ FLAG_ENTRY0("CceCli0AsyncFifoParityErr",
259 CCE_ERR_STATUS_CCE_CLI0_ASYNC_FIFO_PARITY_ERR_SMASK),
260 /* 7*/ FLAG_ENTRY0("CceCsrCfgBusParityErr",
261 CCE_ERR_STATUS_CCE_CSR_CFG_BUS_PARITY_ERR_SMASK),
262 /* 8*/ FLAG_ENTRY0("CceCli2AsyncFifoParityErr",
263 CCE_ERR_STATUS_CCE_CLI2_ASYNC_FIFO_PARITY_ERR_SMASK),
264 /* 9*/ FLAG_ENTRY0("CceCli1AsyncFifoPioCrdtParityErr",
265 CCE_ERR_STATUS_CCE_CLI1_ASYNC_FIFO_PIO_CRDT_PARITY_ERR_SMASK),
266 /*10*/ FLAG_ENTRY0("CceCli1AsyncFifoPioCrdtParityErr",
267 CCE_ERR_STATUS_CCE_CLI1_ASYNC_FIFO_SDMA_HD_PARITY_ERR_SMASK),
268 /*11*/ FLAG_ENTRY0("CceCli1AsyncFifoRxdmaParityError",
269 CCE_ERR_STATUS_CCE_CLI1_ASYNC_FIFO_RXDMA_PARITY_ERROR_SMASK),
270 /*12*/ FLAG_ENTRY0("CceCli1AsyncFifoDbgParityError",
271 CCE_ERR_STATUS_CCE_CLI1_ASYNC_FIFO_DBG_PARITY_ERROR_SMASK),
272 /*13*/ FLAG_ENTRY0("PcicRetryMemCorErr",
273 CCE_ERR_STATUS_PCIC_RETRY_MEM_COR_ERR_SMASK),
274 /*14*/ FLAG_ENTRY0("PcicRetryMemCorErr",
275 CCE_ERR_STATUS_PCIC_RETRY_SOT_MEM_COR_ERR_SMASK),
276 /*15*/ FLAG_ENTRY0("PcicPostHdQCorErr",
277 CCE_ERR_STATUS_PCIC_POST_HD_QCOR_ERR_SMASK),
278 /*16*/ FLAG_ENTRY0("PcicPostHdQCorErr",
279 CCE_ERR_STATUS_PCIC_POST_DAT_QCOR_ERR_SMASK),
280 /*17*/ FLAG_ENTRY0("PcicPostHdQCorErr",
281 CCE_ERR_STATUS_PCIC_CPL_HD_QCOR_ERR_SMASK),
282 /*18*/ FLAG_ENTRY0("PcicCplDatQCorErr",
283 CCE_ERR_STATUS_PCIC_CPL_DAT_QCOR_ERR_SMASK),
284 /*19*/ FLAG_ENTRY0("PcicNPostHQParityErr",
285 CCE_ERR_STATUS_PCIC_NPOST_HQ_PARITY_ERR_SMASK),
286 /*20*/ FLAG_ENTRY0("PcicNPostDatQParityErr",
287 CCE_ERR_STATUS_PCIC_NPOST_DAT_QPARITY_ERR_SMASK),
288 /*21*/ FLAG_ENTRY0("PcicRetryMemUncErr",
289 CCE_ERR_STATUS_PCIC_RETRY_MEM_UNC_ERR_SMASK),
290 /*22*/ FLAG_ENTRY0("PcicRetrySotMemUncErr",
291 CCE_ERR_STATUS_PCIC_RETRY_SOT_MEM_UNC_ERR_SMASK),
292 /*23*/ FLAG_ENTRY0("PcicPostHdQUncErr",
293 CCE_ERR_STATUS_PCIC_POST_HD_QUNC_ERR_SMASK),
294 /*24*/ FLAG_ENTRY0("PcicPostDatQUncErr",
295 CCE_ERR_STATUS_PCIC_POST_DAT_QUNC_ERR_SMASK),
296 /*25*/ FLAG_ENTRY0("PcicCplHdQUncErr",
297 CCE_ERR_STATUS_PCIC_CPL_HD_QUNC_ERR_SMASK),
298 /*26*/ FLAG_ENTRY0("PcicCplDatQUncErr",
299 CCE_ERR_STATUS_PCIC_CPL_DAT_QUNC_ERR_SMASK),
300 /*27*/ FLAG_ENTRY0("PcicTransmitFrontParityErr",
301 CCE_ERR_STATUS_PCIC_TRANSMIT_FRONT_PARITY_ERR_SMASK),
302 /*28*/ FLAG_ENTRY0("PcicTransmitBackParityErr",
303 CCE_ERR_STATUS_PCIC_TRANSMIT_BACK_PARITY_ERR_SMASK),
304 /*29*/ FLAG_ENTRY0("PcicReceiveParityErr",
305 CCE_ERR_STATUS_PCIC_RECEIVE_PARITY_ERR_SMASK),
306 /*30*/ FLAG_ENTRY0("CceTrgtCplTimeoutErr",
307 CCE_ERR_STATUS_CCE_TRGT_CPL_TIMEOUT_ERR_SMASK),
308 /*31*/ FLAG_ENTRY0("LATriggered",
309 CCE_ERR_STATUS_LA_TRIGGERED_SMASK),
310 /*32*/ FLAG_ENTRY0("CceSegReadBadAddrErr",
311 CCE_ERR_STATUS_CCE_SEG_READ_BAD_ADDR_ERR_SMASK),
312 /*33*/ FLAG_ENTRY0("CceSegWriteBadAddrErr",
313 CCE_ERR_STATUS_CCE_SEG_WRITE_BAD_ADDR_ERR_SMASK),
314 /*34*/ FLAG_ENTRY0("CceRcplAsyncFifoParityErr",
315 CCE_ERR_STATUS_CCE_RCPL_ASYNC_FIFO_PARITY_ERR_SMASK),
316 /*35*/ FLAG_ENTRY0("CceRxdmaConvFifoParityErr",
317 CCE_ERR_STATUS_CCE_RXDMA_CONV_FIFO_PARITY_ERR_SMASK),
318 /*36*/ FLAG_ENTRY0("CceMsixTableCorErr",
319 CCE_ERR_STATUS_CCE_MSIX_TABLE_COR_ERR_SMASK),
320 /*37*/ FLAG_ENTRY0("CceMsixTableUncErr",
321 CCE_ERR_STATUS_CCE_MSIX_TABLE_UNC_ERR_SMASK),
322 /*38*/ FLAG_ENTRY0("CceIntMapCorErr",
323 CCE_ERR_STATUS_CCE_INT_MAP_COR_ERR_SMASK),
324 /*39*/ FLAG_ENTRY0("CceIntMapUncErr",
325 CCE_ERR_STATUS_CCE_INT_MAP_UNC_ERR_SMASK),
326 /*40*/ FLAG_ENTRY0("CceMsixCsrParityErr",
327 CCE_ERR_STATUS_CCE_MSIX_CSR_PARITY_ERR_SMASK),
334 #define MES(text) MISC_ERR_STATUS_MISC_##text##_ERR_SMASK
335 static struct flag_table misc_err_status_flags[] = {
336 /* 0*/ FLAG_ENTRY0("CSR_PARITY", MES(CSR_PARITY)),
337 /* 1*/ FLAG_ENTRY0("CSR_READ_BAD_ADDR", MES(CSR_READ_BAD_ADDR)),
338 /* 2*/ FLAG_ENTRY0("CSR_WRITE_BAD_ADDR", MES(CSR_WRITE_BAD_ADDR)),
339 /* 3*/ FLAG_ENTRY0("SBUS_WRITE_FAILED", MES(SBUS_WRITE_FAILED)),
340 /* 4*/ FLAG_ENTRY0("KEY_MISMATCH", MES(KEY_MISMATCH)),
341 /* 5*/ FLAG_ENTRY0("FW_AUTH_FAILED", MES(FW_AUTH_FAILED)),
342 /* 6*/ FLAG_ENTRY0("EFUSE_CSR_PARITY", MES(EFUSE_CSR_PARITY)),
343 /* 7*/ FLAG_ENTRY0("EFUSE_READ_BAD_ADDR", MES(EFUSE_READ_BAD_ADDR)),
344 /* 8*/ FLAG_ENTRY0("EFUSE_WRITE", MES(EFUSE_WRITE)),
345 /* 9*/ FLAG_ENTRY0("EFUSE_DONE_PARITY", MES(EFUSE_DONE_PARITY)),
346 /*10*/ FLAG_ENTRY0("INVALID_EEP_CMD", MES(INVALID_EEP_CMD)),
347 /*11*/ FLAG_ENTRY0("MBIST_FAIL", MES(MBIST_FAIL)),
348 /*12*/ FLAG_ENTRY0("PLL_LOCK_FAIL", MES(PLL_LOCK_FAIL))
352 * TXE PIO Error flags and consequences
354 static struct flag_table pio_err_status_flags[] = {
355 /* 0*/ FLAG_ENTRY("PioWriteBadCtxt",
357 SEND_PIO_ERR_STATUS_PIO_WRITE_BAD_CTXT_ERR_SMASK),
358 /* 1*/ FLAG_ENTRY("PioWriteAddrParity",
360 SEND_PIO_ERR_STATUS_PIO_WRITE_ADDR_PARITY_ERR_SMASK),
361 /* 2*/ FLAG_ENTRY("PioCsrParity",
363 SEND_PIO_ERR_STATUS_PIO_CSR_PARITY_ERR_SMASK),
364 /* 3*/ FLAG_ENTRY("PioSbMemFifo0",
366 SEND_PIO_ERR_STATUS_PIO_SB_MEM_FIFO0_ERR_SMASK),
367 /* 4*/ FLAG_ENTRY("PioSbMemFifo1",
369 SEND_PIO_ERR_STATUS_PIO_SB_MEM_FIFO1_ERR_SMASK),
370 /* 5*/ FLAG_ENTRY("PioPccFifoParity",
372 SEND_PIO_ERR_STATUS_PIO_PCC_FIFO_PARITY_ERR_SMASK),
373 /* 6*/ FLAG_ENTRY("PioPecFifoParity",
375 SEND_PIO_ERR_STATUS_PIO_PEC_FIFO_PARITY_ERR_SMASK),
376 /* 7*/ FLAG_ENTRY("PioSbrdctlCrrelParity",
378 SEND_PIO_ERR_STATUS_PIO_SBRDCTL_CRREL_PARITY_ERR_SMASK),
379 /* 8*/ FLAG_ENTRY("PioSbrdctrlCrrelFifoParity",
381 SEND_PIO_ERR_STATUS_PIO_SBRDCTRL_CRREL_FIFO_PARITY_ERR_SMASK),
382 /* 9*/ FLAG_ENTRY("PioPktEvictFifoParityErr",
384 SEND_PIO_ERR_STATUS_PIO_PKT_EVICT_FIFO_PARITY_ERR_SMASK),
385 /*10*/ FLAG_ENTRY("PioSmPktResetParity",
387 SEND_PIO_ERR_STATUS_PIO_SM_PKT_RESET_PARITY_ERR_SMASK),
388 /*11*/ FLAG_ENTRY("PioVlLenMemBank0Unc",
390 SEND_PIO_ERR_STATUS_PIO_VL_LEN_MEM_BANK0_UNC_ERR_SMASK),
391 /*12*/ FLAG_ENTRY("PioVlLenMemBank1Unc",
393 SEND_PIO_ERR_STATUS_PIO_VL_LEN_MEM_BANK1_UNC_ERR_SMASK),
394 /*13*/ FLAG_ENTRY("PioVlLenMemBank0Cor",
396 SEND_PIO_ERR_STATUS_PIO_VL_LEN_MEM_BANK0_COR_ERR_SMASK),
397 /*14*/ FLAG_ENTRY("PioVlLenMemBank1Cor",
399 SEND_PIO_ERR_STATUS_PIO_VL_LEN_MEM_BANK1_COR_ERR_SMASK),
400 /*15*/ FLAG_ENTRY("PioCreditRetFifoParity",
402 SEND_PIO_ERR_STATUS_PIO_CREDIT_RET_FIFO_PARITY_ERR_SMASK),
403 /*16*/ FLAG_ENTRY("PioPpmcPblFifo",
405 SEND_PIO_ERR_STATUS_PIO_PPMC_PBL_FIFO_ERR_SMASK),
406 /*17*/ FLAG_ENTRY("PioInitSmIn",
408 SEND_PIO_ERR_STATUS_PIO_INIT_SM_IN_ERR_SMASK),
409 /*18*/ FLAG_ENTRY("PioPktEvictSmOrArbSm",
411 SEND_PIO_ERR_STATUS_PIO_PKT_EVICT_SM_OR_ARB_SM_ERR_SMASK),
412 /*19*/ FLAG_ENTRY("PioHostAddrMemUnc",
414 SEND_PIO_ERR_STATUS_PIO_HOST_ADDR_MEM_UNC_ERR_SMASK),
415 /*20*/ FLAG_ENTRY("PioHostAddrMemCor",
417 SEND_PIO_ERR_STATUS_PIO_HOST_ADDR_MEM_COR_ERR_SMASK),
418 /*21*/ FLAG_ENTRY("PioWriteDataParity",
420 SEND_PIO_ERR_STATUS_PIO_WRITE_DATA_PARITY_ERR_SMASK),
421 /*22*/ FLAG_ENTRY("PioStateMachine",
423 SEND_PIO_ERR_STATUS_PIO_STATE_MACHINE_ERR_SMASK),
424 /*23*/ FLAG_ENTRY("PioWriteQwValidParity",
425 SEC_WRITE_DROPPED|SEC_SPC_FREEZE,
426 SEND_PIO_ERR_STATUS_PIO_WRITE_QW_VALID_PARITY_ERR_SMASK),
427 /*24*/ FLAG_ENTRY("PioBlockQwCountParity",
428 SEC_WRITE_DROPPED|SEC_SPC_FREEZE,
429 SEND_PIO_ERR_STATUS_PIO_BLOCK_QW_COUNT_PARITY_ERR_SMASK),
430 /*25*/ FLAG_ENTRY("PioVlfVlLenParity",
432 SEND_PIO_ERR_STATUS_PIO_VLF_VL_LEN_PARITY_ERR_SMASK),
433 /*26*/ FLAG_ENTRY("PioVlfSopParity",
435 SEND_PIO_ERR_STATUS_PIO_VLF_SOP_PARITY_ERR_SMASK),
436 /*27*/ FLAG_ENTRY("PioVlFifoParity",
438 SEND_PIO_ERR_STATUS_PIO_VL_FIFO_PARITY_ERR_SMASK),
439 /*28*/ FLAG_ENTRY("PioPpmcBqcMemParity",
441 SEND_PIO_ERR_STATUS_PIO_PPMC_BQC_MEM_PARITY_ERR_SMASK),
442 /*29*/ FLAG_ENTRY("PioPpmcSopLen",
444 SEND_PIO_ERR_STATUS_PIO_PPMC_SOP_LEN_ERR_SMASK),
446 /*32*/ FLAG_ENTRY("PioCurrentFreeCntParity",
448 SEND_PIO_ERR_STATUS_PIO_CURRENT_FREE_CNT_PARITY_ERR_SMASK),
449 /*33*/ FLAG_ENTRY("PioLastReturnedCntParity",
451 SEND_PIO_ERR_STATUS_PIO_LAST_RETURNED_CNT_PARITY_ERR_SMASK),
452 /*34*/ FLAG_ENTRY("PioPccSopHeadParity",
454 SEND_PIO_ERR_STATUS_PIO_PCC_SOP_HEAD_PARITY_ERR_SMASK),
455 /*35*/ FLAG_ENTRY("PioPecSopHeadParityErr",
457 SEND_PIO_ERR_STATUS_PIO_PEC_SOP_HEAD_PARITY_ERR_SMASK),
461 /* TXE PIO errors that cause an SPC freeze */
462 #define ALL_PIO_FREEZE_ERR \
463 (SEND_PIO_ERR_STATUS_PIO_WRITE_ADDR_PARITY_ERR_SMASK \
464 | SEND_PIO_ERR_STATUS_PIO_CSR_PARITY_ERR_SMASK \
465 | SEND_PIO_ERR_STATUS_PIO_SB_MEM_FIFO0_ERR_SMASK \
466 | SEND_PIO_ERR_STATUS_PIO_SB_MEM_FIFO1_ERR_SMASK \
467 | SEND_PIO_ERR_STATUS_PIO_PCC_FIFO_PARITY_ERR_SMASK \
468 | SEND_PIO_ERR_STATUS_PIO_PEC_FIFO_PARITY_ERR_SMASK \
469 | SEND_PIO_ERR_STATUS_PIO_SBRDCTL_CRREL_PARITY_ERR_SMASK \
470 | SEND_PIO_ERR_STATUS_PIO_SBRDCTRL_CRREL_FIFO_PARITY_ERR_SMASK \
471 | SEND_PIO_ERR_STATUS_PIO_PKT_EVICT_FIFO_PARITY_ERR_SMASK \
472 | SEND_PIO_ERR_STATUS_PIO_SM_PKT_RESET_PARITY_ERR_SMASK \
473 | SEND_PIO_ERR_STATUS_PIO_VL_LEN_MEM_BANK0_UNC_ERR_SMASK \
474 | SEND_PIO_ERR_STATUS_PIO_VL_LEN_MEM_BANK1_UNC_ERR_SMASK \
475 | SEND_PIO_ERR_STATUS_PIO_CREDIT_RET_FIFO_PARITY_ERR_SMASK \
476 | SEND_PIO_ERR_STATUS_PIO_PPMC_PBL_FIFO_ERR_SMASK \
477 | SEND_PIO_ERR_STATUS_PIO_PKT_EVICT_SM_OR_ARB_SM_ERR_SMASK \
478 | SEND_PIO_ERR_STATUS_PIO_HOST_ADDR_MEM_UNC_ERR_SMASK \
479 | SEND_PIO_ERR_STATUS_PIO_WRITE_DATA_PARITY_ERR_SMASK \
480 | SEND_PIO_ERR_STATUS_PIO_STATE_MACHINE_ERR_SMASK \
481 | SEND_PIO_ERR_STATUS_PIO_WRITE_QW_VALID_PARITY_ERR_SMASK \
482 | SEND_PIO_ERR_STATUS_PIO_BLOCK_QW_COUNT_PARITY_ERR_SMASK \
483 | SEND_PIO_ERR_STATUS_PIO_VLF_VL_LEN_PARITY_ERR_SMASK \
484 | SEND_PIO_ERR_STATUS_PIO_VLF_SOP_PARITY_ERR_SMASK \
485 | SEND_PIO_ERR_STATUS_PIO_VL_FIFO_PARITY_ERR_SMASK \
486 | SEND_PIO_ERR_STATUS_PIO_PPMC_BQC_MEM_PARITY_ERR_SMASK \
487 | SEND_PIO_ERR_STATUS_PIO_PPMC_SOP_LEN_ERR_SMASK \
488 | SEND_PIO_ERR_STATUS_PIO_CURRENT_FREE_CNT_PARITY_ERR_SMASK \
489 | SEND_PIO_ERR_STATUS_PIO_LAST_RETURNED_CNT_PARITY_ERR_SMASK \
490 | SEND_PIO_ERR_STATUS_PIO_PCC_SOP_HEAD_PARITY_ERR_SMASK \
491 | SEND_PIO_ERR_STATUS_PIO_PEC_SOP_HEAD_PARITY_ERR_SMASK)
494 * TXE SDMA Error flags
496 static struct flag_table sdma_err_status_flags[] = {
497 /* 0*/ FLAG_ENTRY0("SDmaRpyTagErr",
498 SEND_DMA_ERR_STATUS_SDMA_RPY_TAG_ERR_SMASK),
499 /* 1*/ FLAG_ENTRY0("SDmaCsrParityErr",
500 SEND_DMA_ERR_STATUS_SDMA_CSR_PARITY_ERR_SMASK),
501 /* 2*/ FLAG_ENTRY0("SDmaPcieReqTrackingUncErr",
502 SEND_DMA_ERR_STATUS_SDMA_PCIE_REQ_TRACKING_UNC_ERR_SMASK),
503 /* 3*/ FLAG_ENTRY0("SDmaPcieReqTrackingCorErr",
504 SEND_DMA_ERR_STATUS_SDMA_PCIE_REQ_TRACKING_COR_ERR_SMASK),
508 /* TXE SDMA errors that cause an SPC freeze */
509 #define ALL_SDMA_FREEZE_ERR \
510 (SEND_DMA_ERR_STATUS_SDMA_RPY_TAG_ERR_SMASK \
511 | SEND_DMA_ERR_STATUS_SDMA_CSR_PARITY_ERR_SMASK \
512 | SEND_DMA_ERR_STATUS_SDMA_PCIE_REQ_TRACKING_UNC_ERR_SMASK)
514 /* SendEgressErrInfo bits that correspond to a PortXmitDiscard counter */
515 #define PORT_DISCARD_EGRESS_ERRS \
516 (SEND_EGRESS_ERR_INFO_TOO_LONG_IB_PACKET_ERR_SMASK \
517 | SEND_EGRESS_ERR_INFO_VL_MAPPING_ERR_SMASK \
518 | SEND_EGRESS_ERR_INFO_VL_ERR_SMASK)
521 * TXE Egress Error flags
523 #define SEES(text) SEND_EGRESS_ERR_STATUS_##text##_ERR_SMASK
524 static struct flag_table egress_err_status_flags[] = {
525 /* 0*/ FLAG_ENTRY0("TxPktIntegrityMemCorErr", SEES(TX_PKT_INTEGRITY_MEM_COR)),
526 /* 1*/ FLAG_ENTRY0("TxPktIntegrityMemUncErr", SEES(TX_PKT_INTEGRITY_MEM_UNC)),
528 /* 3*/ FLAG_ENTRY0("TxEgressFifoUnderrunOrParityErr",
529 SEES(TX_EGRESS_FIFO_UNDERRUN_OR_PARITY)),
530 /* 4*/ FLAG_ENTRY0("TxLinkdownErr", SEES(TX_LINKDOWN)),
531 /* 5*/ FLAG_ENTRY0("TxIncorrectLinkStateErr", SEES(TX_INCORRECT_LINK_STATE)),
533 /* 7*/ FLAG_ENTRY0("TxPioLaunchIntfParityErr",
534 SEES(TX_PIO_LAUNCH_INTF_PARITY)),
535 /* 8*/ FLAG_ENTRY0("TxSdmaLaunchIntfParityErr",
536 SEES(TX_SDMA_LAUNCH_INTF_PARITY)),
538 /*11*/ FLAG_ENTRY0("TxSbrdCtlStateMachineParityErr",
539 SEES(TX_SBRD_CTL_STATE_MACHINE_PARITY)),
540 /*12*/ FLAG_ENTRY0("TxIllegalVLErr", SEES(TX_ILLEGAL_VL)),
541 /*13*/ FLAG_ENTRY0("TxLaunchCsrParityErr", SEES(TX_LAUNCH_CSR_PARITY)),
542 /*14*/ FLAG_ENTRY0("TxSbrdCtlCsrParityErr", SEES(TX_SBRD_CTL_CSR_PARITY)),
543 /*15*/ FLAG_ENTRY0("TxConfigParityErr", SEES(TX_CONFIG_PARITY)),
544 /*16*/ FLAG_ENTRY0("TxSdma0DisallowedPacketErr",
545 SEES(TX_SDMA0_DISALLOWED_PACKET)),
546 /*17*/ FLAG_ENTRY0("TxSdma1DisallowedPacketErr",
547 SEES(TX_SDMA1_DISALLOWED_PACKET)),
548 /*18*/ FLAG_ENTRY0("TxSdma2DisallowedPacketErr",
549 SEES(TX_SDMA2_DISALLOWED_PACKET)),
550 /*19*/ FLAG_ENTRY0("TxSdma3DisallowedPacketErr",
551 SEES(TX_SDMA3_DISALLOWED_PACKET)),
552 /*20*/ FLAG_ENTRY0("TxSdma4DisallowedPacketErr",
553 SEES(TX_SDMA4_DISALLOWED_PACKET)),
554 /*21*/ FLAG_ENTRY0("TxSdma5DisallowedPacketErr",
555 SEES(TX_SDMA5_DISALLOWED_PACKET)),
556 /*22*/ FLAG_ENTRY0("TxSdma6DisallowedPacketErr",
557 SEES(TX_SDMA6_DISALLOWED_PACKET)),
558 /*23*/ FLAG_ENTRY0("TxSdma7DisallowedPacketErr",
559 SEES(TX_SDMA7_DISALLOWED_PACKET)),
560 /*24*/ FLAG_ENTRY0("TxSdma8DisallowedPacketErr",
561 SEES(TX_SDMA8_DISALLOWED_PACKET)),
562 /*25*/ FLAG_ENTRY0("TxSdma9DisallowedPacketErr",
563 SEES(TX_SDMA9_DISALLOWED_PACKET)),
564 /*26*/ FLAG_ENTRY0("TxSdma10DisallowedPacketErr",
565 SEES(TX_SDMA10_DISALLOWED_PACKET)),
566 /*27*/ FLAG_ENTRY0("TxSdma11DisallowedPacketErr",
567 SEES(TX_SDMA11_DISALLOWED_PACKET)),
568 /*28*/ FLAG_ENTRY0("TxSdma12DisallowedPacketErr",
569 SEES(TX_SDMA12_DISALLOWED_PACKET)),
570 /*29*/ FLAG_ENTRY0("TxSdma13DisallowedPacketErr",
571 SEES(TX_SDMA13_DISALLOWED_PACKET)),
572 /*30*/ FLAG_ENTRY0("TxSdma14DisallowedPacketErr",
573 SEES(TX_SDMA14_DISALLOWED_PACKET)),
574 /*31*/ FLAG_ENTRY0("TxSdma15DisallowedPacketErr",
575 SEES(TX_SDMA15_DISALLOWED_PACKET)),
576 /*32*/ FLAG_ENTRY0("TxLaunchFifo0UncOrParityErr",
577 SEES(TX_LAUNCH_FIFO0_UNC_OR_PARITY)),
578 /*33*/ FLAG_ENTRY0("TxLaunchFifo1UncOrParityErr",
579 SEES(TX_LAUNCH_FIFO1_UNC_OR_PARITY)),
580 /*34*/ FLAG_ENTRY0("TxLaunchFifo2UncOrParityErr",
581 SEES(TX_LAUNCH_FIFO2_UNC_OR_PARITY)),
582 /*35*/ FLAG_ENTRY0("TxLaunchFifo3UncOrParityErr",
583 SEES(TX_LAUNCH_FIFO3_UNC_OR_PARITY)),
584 /*36*/ FLAG_ENTRY0("TxLaunchFifo4UncOrParityErr",
585 SEES(TX_LAUNCH_FIFO4_UNC_OR_PARITY)),
586 /*37*/ FLAG_ENTRY0("TxLaunchFifo5UncOrParityErr",
587 SEES(TX_LAUNCH_FIFO5_UNC_OR_PARITY)),
588 /*38*/ FLAG_ENTRY0("TxLaunchFifo6UncOrParityErr",
589 SEES(TX_LAUNCH_FIFO6_UNC_OR_PARITY)),
590 /*39*/ FLAG_ENTRY0("TxLaunchFifo7UncOrParityErr",
591 SEES(TX_LAUNCH_FIFO7_UNC_OR_PARITY)),
592 /*40*/ FLAG_ENTRY0("TxLaunchFifo8UncOrParityErr",
593 SEES(TX_LAUNCH_FIFO8_UNC_OR_PARITY)),
594 /*41*/ FLAG_ENTRY0("TxCreditReturnParityErr", SEES(TX_CREDIT_RETURN_PARITY)),
595 /*42*/ FLAG_ENTRY0("TxSbHdrUncErr", SEES(TX_SB_HDR_UNC)),
596 /*43*/ FLAG_ENTRY0("TxReadSdmaMemoryUncErr", SEES(TX_READ_SDMA_MEMORY_UNC)),
597 /*44*/ FLAG_ENTRY0("TxReadPioMemoryUncErr", SEES(TX_READ_PIO_MEMORY_UNC)),
598 /*45*/ FLAG_ENTRY0("TxEgressFifoUncErr", SEES(TX_EGRESS_FIFO_UNC)),
599 /*46*/ FLAG_ENTRY0("TxHcrcInsertionErr", SEES(TX_HCRC_INSERTION)),
600 /*47*/ FLAG_ENTRY0("TxCreditReturnVLErr", SEES(TX_CREDIT_RETURN_VL)),
601 /*48*/ FLAG_ENTRY0("TxLaunchFifo0CorErr", SEES(TX_LAUNCH_FIFO0_COR)),
602 /*49*/ FLAG_ENTRY0("TxLaunchFifo1CorErr", SEES(TX_LAUNCH_FIFO1_COR)),
603 /*50*/ FLAG_ENTRY0("TxLaunchFifo2CorErr", SEES(TX_LAUNCH_FIFO2_COR)),
604 /*51*/ FLAG_ENTRY0("TxLaunchFifo3CorErr", SEES(TX_LAUNCH_FIFO3_COR)),
605 /*52*/ FLAG_ENTRY0("TxLaunchFifo4CorErr", SEES(TX_LAUNCH_FIFO4_COR)),
606 /*53*/ FLAG_ENTRY0("TxLaunchFifo5CorErr", SEES(TX_LAUNCH_FIFO5_COR)),
607 /*54*/ FLAG_ENTRY0("TxLaunchFifo6CorErr", SEES(TX_LAUNCH_FIFO6_COR)),
608 /*55*/ FLAG_ENTRY0("TxLaunchFifo7CorErr", SEES(TX_LAUNCH_FIFO7_COR)),
609 /*56*/ FLAG_ENTRY0("TxLaunchFifo8CorErr", SEES(TX_LAUNCH_FIFO8_COR)),
610 /*57*/ FLAG_ENTRY0("TxCreditOverrunErr", SEES(TX_CREDIT_OVERRUN)),
611 /*58*/ FLAG_ENTRY0("TxSbHdrCorErr", SEES(TX_SB_HDR_COR)),
612 /*59*/ FLAG_ENTRY0("TxReadSdmaMemoryCorErr", SEES(TX_READ_SDMA_MEMORY_COR)),
613 /*60*/ FLAG_ENTRY0("TxReadPioMemoryCorErr", SEES(TX_READ_PIO_MEMORY_COR)),
614 /*61*/ FLAG_ENTRY0("TxEgressFifoCorErr", SEES(TX_EGRESS_FIFO_COR)),
615 /*62*/ FLAG_ENTRY0("TxReadSdmaMemoryCsrUncErr",
616 SEES(TX_READ_SDMA_MEMORY_CSR_UNC)),
617 /*63*/ FLAG_ENTRY0("TxReadPioMemoryCsrUncErr",
618 SEES(TX_READ_PIO_MEMORY_CSR_UNC)),
622 * TXE Egress Error Info flags
624 #define SEEI(text) SEND_EGRESS_ERR_INFO_##text##_ERR_SMASK
625 static struct flag_table egress_err_info_flags[] = {
626 /* 0*/ FLAG_ENTRY0("Reserved", 0ull),
627 /* 1*/ FLAG_ENTRY0("VLErr", SEEI(VL)),
628 /* 2*/ FLAG_ENTRY0("JobKeyErr", SEEI(JOB_KEY)),
629 /* 3*/ FLAG_ENTRY0("JobKeyErr", SEEI(JOB_KEY)),
630 /* 4*/ FLAG_ENTRY0("PartitionKeyErr", SEEI(PARTITION_KEY)),
631 /* 5*/ FLAG_ENTRY0("SLIDErr", SEEI(SLID)),
632 /* 6*/ FLAG_ENTRY0("OpcodeErr", SEEI(OPCODE)),
633 /* 7*/ FLAG_ENTRY0("VLMappingErr", SEEI(VL_MAPPING)),
634 /* 8*/ FLAG_ENTRY0("RawErr", SEEI(RAW)),
635 /* 9*/ FLAG_ENTRY0("RawIPv6Err", SEEI(RAW_IPV6)),
636 /*10*/ FLAG_ENTRY0("GRHErr", SEEI(GRH)),
637 /*11*/ FLAG_ENTRY0("BypassErr", SEEI(BYPASS)),
638 /*12*/ FLAG_ENTRY0("KDETHPacketsErr", SEEI(KDETH_PACKETS)),
639 /*13*/ FLAG_ENTRY0("NonKDETHPacketsErr", SEEI(NON_KDETH_PACKETS)),
640 /*14*/ FLAG_ENTRY0("TooSmallIBPacketsErr", SEEI(TOO_SMALL_IB_PACKETS)),
641 /*15*/ FLAG_ENTRY0("TooSmallBypassPacketsErr", SEEI(TOO_SMALL_BYPASS_PACKETS)),
642 /*16*/ FLAG_ENTRY0("PbcTestErr", SEEI(PBC_TEST)),
643 /*17*/ FLAG_ENTRY0("BadPktLenErr", SEEI(BAD_PKT_LEN)),
644 /*18*/ FLAG_ENTRY0("TooLongIBPacketErr", SEEI(TOO_LONG_IB_PACKET)),
645 /*19*/ FLAG_ENTRY0("TooLongBypassPacketsErr", SEEI(TOO_LONG_BYPASS_PACKETS)),
646 /*20*/ FLAG_ENTRY0("PbcStaticRateControlErr", SEEI(PBC_STATIC_RATE_CONTROL)),
647 /*21*/ FLAG_ENTRY0("BypassBadPktLenErr", SEEI(BAD_PKT_LEN)),
650 /* TXE Egress errors that cause an SPC freeze */
651 #define ALL_TXE_EGRESS_FREEZE_ERR \
652 (SEES(TX_EGRESS_FIFO_UNDERRUN_OR_PARITY) \
653 | SEES(TX_PIO_LAUNCH_INTF_PARITY) \
654 | SEES(TX_SDMA_LAUNCH_INTF_PARITY) \
655 | SEES(TX_SBRD_CTL_STATE_MACHINE_PARITY) \
656 | SEES(TX_LAUNCH_CSR_PARITY) \
657 | SEES(TX_SBRD_CTL_CSR_PARITY) \
658 | SEES(TX_CONFIG_PARITY) \
659 | SEES(TX_LAUNCH_FIFO0_UNC_OR_PARITY) \
660 | SEES(TX_LAUNCH_FIFO1_UNC_OR_PARITY) \
661 | SEES(TX_LAUNCH_FIFO2_UNC_OR_PARITY) \
662 | SEES(TX_LAUNCH_FIFO3_UNC_OR_PARITY) \
663 | SEES(TX_LAUNCH_FIFO4_UNC_OR_PARITY) \
664 | SEES(TX_LAUNCH_FIFO5_UNC_OR_PARITY) \
665 | SEES(TX_LAUNCH_FIFO6_UNC_OR_PARITY) \
666 | SEES(TX_LAUNCH_FIFO7_UNC_OR_PARITY) \
667 | SEES(TX_LAUNCH_FIFO8_UNC_OR_PARITY) \
668 | SEES(TX_CREDIT_RETURN_PARITY))
671 * TXE Send error flags
673 #define SES(name) SEND_ERR_STATUS_SEND_##name##_ERR_SMASK
674 static struct flag_table send_err_status_flags[] = {
675 /* 0*/ FLAG_ENTRY0("SendCsrParityErr", SES(CSR_PARITY)),
676 /* 1*/ FLAG_ENTRY0("SendCsrReadBadAddrErr", SES(CSR_READ_BAD_ADDR)),
677 /* 2*/ FLAG_ENTRY0("SendCsrWriteBadAddrErr", SES(CSR_WRITE_BAD_ADDR))
681 * TXE Send Context Error flags and consequences
683 static struct flag_table sc_err_status_flags[] = {
684 /* 0*/ FLAG_ENTRY("InconsistentSop",
685 SEC_PACKET_DROPPED | SEC_SC_HALTED,
686 SEND_CTXT_ERR_STATUS_PIO_INCONSISTENT_SOP_ERR_SMASK),
687 /* 1*/ FLAG_ENTRY("DisallowedPacket",
688 SEC_PACKET_DROPPED | SEC_SC_HALTED,
689 SEND_CTXT_ERR_STATUS_PIO_DISALLOWED_PACKET_ERR_SMASK),
690 /* 2*/ FLAG_ENTRY("WriteCrossesBoundary",
691 SEC_WRITE_DROPPED | SEC_SC_HALTED,
692 SEND_CTXT_ERR_STATUS_PIO_WRITE_CROSSES_BOUNDARY_ERR_SMASK),
693 /* 3*/ FLAG_ENTRY("WriteOverflow",
694 SEC_WRITE_DROPPED | SEC_SC_HALTED,
695 SEND_CTXT_ERR_STATUS_PIO_WRITE_OVERFLOW_ERR_SMASK),
696 /* 4*/ FLAG_ENTRY("WriteOutOfBounds",
697 SEC_WRITE_DROPPED | SEC_SC_HALTED,
698 SEND_CTXT_ERR_STATUS_PIO_WRITE_OUT_OF_BOUNDS_ERR_SMASK),
703 * RXE Receive Error flags
705 #define RXES(name) RCV_ERR_STATUS_RX_##name##_ERR_SMASK
706 static struct flag_table rxe_err_status_flags[] = {
707 /* 0*/ FLAG_ENTRY0("RxDmaCsrCorErr", RXES(DMA_CSR_COR)),
708 /* 1*/ FLAG_ENTRY0("RxDcIntfParityErr", RXES(DC_INTF_PARITY)),
709 /* 2*/ FLAG_ENTRY0("RxRcvHdrUncErr", RXES(RCV_HDR_UNC)),
710 /* 3*/ FLAG_ENTRY0("RxRcvHdrCorErr", RXES(RCV_HDR_COR)),
711 /* 4*/ FLAG_ENTRY0("RxRcvDataUncErr", RXES(RCV_DATA_UNC)),
712 /* 5*/ FLAG_ENTRY0("RxRcvDataCorErr", RXES(RCV_DATA_COR)),
713 /* 6*/ FLAG_ENTRY0("RxRcvQpMapTableUncErr", RXES(RCV_QP_MAP_TABLE_UNC)),
714 /* 7*/ FLAG_ENTRY0("RxRcvQpMapTableCorErr", RXES(RCV_QP_MAP_TABLE_COR)),
715 /* 8*/ FLAG_ENTRY0("RxRcvCsrParityErr", RXES(RCV_CSR_PARITY)),
716 /* 9*/ FLAG_ENTRY0("RxDcSopEopParityErr", RXES(DC_SOP_EOP_PARITY)),
717 /*10*/ FLAG_ENTRY0("RxDmaFlagUncErr", RXES(DMA_FLAG_UNC)),
718 /*11*/ FLAG_ENTRY0("RxDmaFlagCorErr", RXES(DMA_FLAG_COR)),
719 /*12*/ FLAG_ENTRY0("RxRcvFsmEncodingErr", RXES(RCV_FSM_ENCODING)),
720 /*13*/ FLAG_ENTRY0("RxRbufFreeListUncErr", RXES(RBUF_FREE_LIST_UNC)),
721 /*14*/ FLAG_ENTRY0("RxRbufFreeListCorErr", RXES(RBUF_FREE_LIST_COR)),
722 /*15*/ FLAG_ENTRY0("RxRbufLookupDesRegUncErr", RXES(RBUF_LOOKUP_DES_REG_UNC)),
723 /*16*/ FLAG_ENTRY0("RxRbufLookupDesRegUncCorErr",
724 RXES(RBUF_LOOKUP_DES_REG_UNC_COR)),
725 /*17*/ FLAG_ENTRY0("RxRbufLookupDesUncErr", RXES(RBUF_LOOKUP_DES_UNC)),
726 /*18*/ FLAG_ENTRY0("RxRbufLookupDesCorErr", RXES(RBUF_LOOKUP_DES_COR)),
727 /*19*/ FLAG_ENTRY0("RxRbufBlockListReadUncErr",
728 RXES(RBUF_BLOCK_LIST_READ_UNC)),
729 /*20*/ FLAG_ENTRY0("RxRbufBlockListReadCorErr",
730 RXES(RBUF_BLOCK_LIST_READ_COR)),
731 /*21*/ FLAG_ENTRY0("RxRbufCsrQHeadBufNumParityErr",
732 RXES(RBUF_CSR_QHEAD_BUF_NUM_PARITY)),
733 /*22*/ FLAG_ENTRY0("RxRbufCsrQEntCntParityErr",
734 RXES(RBUF_CSR_QENT_CNT_PARITY)),
735 /*23*/ FLAG_ENTRY0("RxRbufCsrQNextBufParityErr",
736 RXES(RBUF_CSR_QNEXT_BUF_PARITY)),
737 /*24*/ FLAG_ENTRY0("RxRbufCsrQVldBitParityErr",
738 RXES(RBUF_CSR_QVLD_BIT_PARITY)),
739 /*25*/ FLAG_ENTRY0("RxRbufCsrQHdPtrParityErr", RXES(RBUF_CSR_QHD_PTR_PARITY)),
740 /*26*/ FLAG_ENTRY0("RxRbufCsrQTlPtrParityErr", RXES(RBUF_CSR_QTL_PTR_PARITY)),
741 /*27*/ FLAG_ENTRY0("RxRbufCsrQNumOfPktParityErr",
742 RXES(RBUF_CSR_QNUM_OF_PKT_PARITY)),
743 /*28*/ FLAG_ENTRY0("RxRbufCsrQEOPDWParityErr", RXES(RBUF_CSR_QEOPDW_PARITY)),
744 /*29*/ FLAG_ENTRY0("RxRbufCtxIdParityErr", RXES(RBUF_CTX_ID_PARITY)),
745 /*30*/ FLAG_ENTRY0("RxRBufBadLookupErr", RXES(RBUF_BAD_LOOKUP)),
746 /*31*/ FLAG_ENTRY0("RxRbufFullErr", RXES(RBUF_FULL)),
747 /*32*/ FLAG_ENTRY0("RxRbufEmptyErr", RXES(RBUF_EMPTY)),
748 /*33*/ FLAG_ENTRY0("RxRbufFlRdAddrParityErr", RXES(RBUF_FL_RD_ADDR_PARITY)),
749 /*34*/ FLAG_ENTRY0("RxRbufFlWrAddrParityErr", RXES(RBUF_FL_WR_ADDR_PARITY)),
750 /*35*/ FLAG_ENTRY0("RxRbufFlInitdoneParityErr",
751 RXES(RBUF_FL_INITDONE_PARITY)),
752 /*36*/ FLAG_ENTRY0("RxRbufFlInitWrAddrParityErr",
753 RXES(RBUF_FL_INIT_WR_ADDR_PARITY)),
754 /*37*/ FLAG_ENTRY0("RxRbufNextFreeBufUncErr", RXES(RBUF_NEXT_FREE_BUF_UNC)),
755 /*38*/ FLAG_ENTRY0("RxRbufNextFreeBufCorErr", RXES(RBUF_NEXT_FREE_BUF_COR)),
756 /*39*/ FLAG_ENTRY0("RxLookupDesPart1UncErr", RXES(LOOKUP_DES_PART1_UNC)),
757 /*40*/ FLAG_ENTRY0("RxLookupDesPart1UncCorErr",
758 RXES(LOOKUP_DES_PART1_UNC_COR)),
759 /*41*/ FLAG_ENTRY0("RxLookupDesPart2ParityErr",
760 RXES(LOOKUP_DES_PART2_PARITY)),
761 /*42*/ FLAG_ENTRY0("RxLookupRcvArrayUncErr", RXES(LOOKUP_RCV_ARRAY_UNC)),
762 /*43*/ FLAG_ENTRY0("RxLookupRcvArrayCorErr", RXES(LOOKUP_RCV_ARRAY_COR)),
763 /*44*/ FLAG_ENTRY0("RxLookupCsrParityErr", RXES(LOOKUP_CSR_PARITY)),
764 /*45*/ FLAG_ENTRY0("RxHqIntrCsrParityErr", RXES(HQ_INTR_CSR_PARITY)),
765 /*46*/ FLAG_ENTRY0("RxHqIntrFsmErr", RXES(HQ_INTR_FSM)),
766 /*47*/ FLAG_ENTRY0("RxRbufDescPart1UncErr", RXES(RBUF_DESC_PART1_UNC)),
767 /*48*/ FLAG_ENTRY0("RxRbufDescPart1CorErr", RXES(RBUF_DESC_PART1_COR)),
768 /*49*/ FLAG_ENTRY0("RxRbufDescPart2UncErr", RXES(RBUF_DESC_PART2_UNC)),
769 /*50*/ FLAG_ENTRY0("RxRbufDescPart2CorErr", RXES(RBUF_DESC_PART2_COR)),
770 /*51*/ FLAG_ENTRY0("RxDmaHdrFifoRdUncErr", RXES(DMA_HDR_FIFO_RD_UNC)),
771 /*52*/ FLAG_ENTRY0("RxDmaHdrFifoRdCorErr", RXES(DMA_HDR_FIFO_RD_COR)),
772 /*53*/ FLAG_ENTRY0("RxDmaDataFifoRdUncErr", RXES(DMA_DATA_FIFO_RD_UNC)),
773 /*54*/ FLAG_ENTRY0("RxDmaDataFifoRdCorErr", RXES(DMA_DATA_FIFO_RD_COR)),
774 /*55*/ FLAG_ENTRY0("RxRbufDataUncErr", RXES(RBUF_DATA_UNC)),
775 /*56*/ FLAG_ENTRY0("RxRbufDataCorErr", RXES(RBUF_DATA_COR)),
776 /*57*/ FLAG_ENTRY0("RxDmaCsrParityErr", RXES(DMA_CSR_PARITY)),
777 /*58*/ FLAG_ENTRY0("RxDmaEqFsmEncodingErr", RXES(DMA_EQ_FSM_ENCODING)),
778 /*59*/ FLAG_ENTRY0("RxDmaDqFsmEncodingErr", RXES(DMA_DQ_FSM_ENCODING)),
779 /*60*/ FLAG_ENTRY0("RxDmaCsrUncErr", RXES(DMA_CSR_UNC)),
780 /*61*/ FLAG_ENTRY0("RxCsrReadBadAddrErr", RXES(CSR_READ_BAD_ADDR)),
781 /*62*/ FLAG_ENTRY0("RxCsrWriteBadAddrErr", RXES(CSR_WRITE_BAD_ADDR)),
782 /*63*/ FLAG_ENTRY0("RxCsrParityErr", RXES(CSR_PARITY))
785 /* RXE errors that will trigger an SPC freeze */
786 #define ALL_RXE_FREEZE_ERR \
787 (RCV_ERR_STATUS_RX_RCV_QP_MAP_TABLE_UNC_ERR_SMASK \
788 | RCV_ERR_STATUS_RX_RCV_CSR_PARITY_ERR_SMASK \
789 | RCV_ERR_STATUS_RX_DMA_FLAG_UNC_ERR_SMASK \
790 | RCV_ERR_STATUS_RX_RCV_FSM_ENCODING_ERR_SMASK \
791 | RCV_ERR_STATUS_RX_RBUF_FREE_LIST_UNC_ERR_SMASK \
792 | RCV_ERR_STATUS_RX_RBUF_LOOKUP_DES_REG_UNC_ERR_SMASK \
793 | RCV_ERR_STATUS_RX_RBUF_LOOKUP_DES_REG_UNC_COR_ERR_SMASK \
794 | RCV_ERR_STATUS_RX_RBUF_LOOKUP_DES_UNC_ERR_SMASK \
795 | RCV_ERR_STATUS_RX_RBUF_BLOCK_LIST_READ_UNC_ERR_SMASK \
796 | RCV_ERR_STATUS_RX_RBUF_CSR_QHEAD_BUF_NUM_PARITY_ERR_SMASK \
797 | RCV_ERR_STATUS_RX_RBUF_CSR_QENT_CNT_PARITY_ERR_SMASK \
798 | RCV_ERR_STATUS_RX_RBUF_CSR_QNEXT_BUF_PARITY_ERR_SMASK \
799 | RCV_ERR_STATUS_RX_RBUF_CSR_QVLD_BIT_PARITY_ERR_SMASK \
800 | RCV_ERR_STATUS_RX_RBUF_CSR_QHD_PTR_PARITY_ERR_SMASK \
801 | RCV_ERR_STATUS_RX_RBUF_CSR_QTL_PTR_PARITY_ERR_SMASK \
802 | RCV_ERR_STATUS_RX_RBUF_CSR_QNUM_OF_PKT_PARITY_ERR_SMASK \
803 | RCV_ERR_STATUS_RX_RBUF_CSR_QEOPDW_PARITY_ERR_SMASK \
804 | RCV_ERR_STATUS_RX_RBUF_CTX_ID_PARITY_ERR_SMASK \
805 | RCV_ERR_STATUS_RX_RBUF_BAD_LOOKUP_ERR_SMASK \
806 | RCV_ERR_STATUS_RX_RBUF_FULL_ERR_SMASK \
807 | RCV_ERR_STATUS_RX_RBUF_EMPTY_ERR_SMASK \
808 | RCV_ERR_STATUS_RX_RBUF_FL_RD_ADDR_PARITY_ERR_SMASK \
809 | RCV_ERR_STATUS_RX_RBUF_FL_WR_ADDR_PARITY_ERR_SMASK \
810 | RCV_ERR_STATUS_RX_RBUF_FL_INITDONE_PARITY_ERR_SMASK \
811 | RCV_ERR_STATUS_RX_RBUF_FL_INIT_WR_ADDR_PARITY_ERR_SMASK \
812 | RCV_ERR_STATUS_RX_RBUF_NEXT_FREE_BUF_UNC_ERR_SMASK \
813 | RCV_ERR_STATUS_RX_LOOKUP_DES_PART1_UNC_ERR_SMASK \
814 | RCV_ERR_STATUS_RX_LOOKUP_DES_PART1_UNC_COR_ERR_SMASK \
815 | RCV_ERR_STATUS_RX_LOOKUP_DES_PART2_PARITY_ERR_SMASK \
816 | RCV_ERR_STATUS_RX_LOOKUP_RCV_ARRAY_UNC_ERR_SMASK \
817 | RCV_ERR_STATUS_RX_LOOKUP_CSR_PARITY_ERR_SMASK \
818 | RCV_ERR_STATUS_RX_HQ_INTR_CSR_PARITY_ERR_SMASK \
819 | RCV_ERR_STATUS_RX_HQ_INTR_FSM_ERR_SMASK \
820 | RCV_ERR_STATUS_RX_RBUF_DESC_PART1_UNC_ERR_SMASK \
821 | RCV_ERR_STATUS_RX_RBUF_DESC_PART1_COR_ERR_SMASK \
822 | RCV_ERR_STATUS_RX_RBUF_DESC_PART2_UNC_ERR_SMASK \
823 | RCV_ERR_STATUS_RX_DMA_HDR_FIFO_RD_UNC_ERR_SMASK \
824 | RCV_ERR_STATUS_RX_DMA_DATA_FIFO_RD_UNC_ERR_SMASK \
825 | RCV_ERR_STATUS_RX_RBUF_DATA_UNC_ERR_SMASK \
826 | RCV_ERR_STATUS_RX_DMA_CSR_PARITY_ERR_SMASK \
827 | RCV_ERR_STATUS_RX_DMA_EQ_FSM_ENCODING_ERR_SMASK \
828 | RCV_ERR_STATUS_RX_DMA_DQ_FSM_ENCODING_ERR_SMASK \
829 | RCV_ERR_STATUS_RX_DMA_CSR_UNC_ERR_SMASK \
830 | RCV_ERR_STATUS_RX_CSR_PARITY_ERR_SMASK)
832 #define RXE_FREEZE_ABORT_MASK \
833 (RCV_ERR_STATUS_RX_DMA_CSR_UNC_ERR_SMASK | \
834 RCV_ERR_STATUS_RX_DMA_HDR_FIFO_RD_UNC_ERR_SMASK | \
835 RCV_ERR_STATUS_RX_DMA_DATA_FIFO_RD_UNC_ERR_SMASK)
840 #define DCCE(name) DCC_ERR_FLG_##name##_SMASK
841 static struct flag_table dcc_err_flags[] = {
842 FLAG_ENTRY0("bad_l2_err", DCCE(BAD_L2_ERR)),
843 FLAG_ENTRY0("bad_sc_err", DCCE(BAD_SC_ERR)),
844 FLAG_ENTRY0("bad_mid_tail_err", DCCE(BAD_MID_TAIL_ERR)),
845 FLAG_ENTRY0("bad_preemption_err", DCCE(BAD_PREEMPTION_ERR)),
846 FLAG_ENTRY0("preemption_err", DCCE(PREEMPTION_ERR)),
847 FLAG_ENTRY0("preemptionvl15_err", DCCE(PREEMPTIONVL15_ERR)),
848 FLAG_ENTRY0("bad_vl_marker_err", DCCE(BAD_VL_MARKER_ERR)),
849 FLAG_ENTRY0("bad_dlid_target_err", DCCE(BAD_DLID_TARGET_ERR)),
850 FLAG_ENTRY0("bad_lver_err", DCCE(BAD_LVER_ERR)),
851 FLAG_ENTRY0("uncorrectable_err", DCCE(UNCORRECTABLE_ERR)),
852 FLAG_ENTRY0("bad_crdt_ack_err", DCCE(BAD_CRDT_ACK_ERR)),
853 FLAG_ENTRY0("unsup_pkt_type", DCCE(UNSUP_PKT_TYPE)),
854 FLAG_ENTRY0("bad_ctrl_flit_err", DCCE(BAD_CTRL_FLIT_ERR)),
855 FLAG_ENTRY0("event_cntr_parity_err", DCCE(EVENT_CNTR_PARITY_ERR)),
856 FLAG_ENTRY0("event_cntr_rollover_err", DCCE(EVENT_CNTR_ROLLOVER_ERR)),
857 FLAG_ENTRY0("link_err", DCCE(LINK_ERR)),
858 FLAG_ENTRY0("misc_cntr_rollover_err", DCCE(MISC_CNTR_ROLLOVER_ERR)),
859 FLAG_ENTRY0("bad_ctrl_dist_err", DCCE(BAD_CTRL_DIST_ERR)),
860 FLAG_ENTRY0("bad_tail_dist_err", DCCE(BAD_TAIL_DIST_ERR)),
861 FLAG_ENTRY0("bad_head_dist_err", DCCE(BAD_HEAD_DIST_ERR)),
862 FLAG_ENTRY0("nonvl15_state_err", DCCE(NONVL15_STATE_ERR)),
863 FLAG_ENTRY0("vl15_multi_err", DCCE(VL15_MULTI_ERR)),
864 FLAG_ENTRY0("bad_pkt_length_err", DCCE(BAD_PKT_LENGTH_ERR)),
865 FLAG_ENTRY0("unsup_vl_err", DCCE(UNSUP_VL_ERR)),
866 FLAG_ENTRY0("perm_nvl15_err", DCCE(PERM_NVL15_ERR)),
867 FLAG_ENTRY0("slid_zero_err", DCCE(SLID_ZERO_ERR)),
868 FLAG_ENTRY0("dlid_zero_err", DCCE(DLID_ZERO_ERR)),
869 FLAG_ENTRY0("length_mtu_err", DCCE(LENGTH_MTU_ERR)),
870 FLAG_ENTRY0("rx_early_drop_err", DCCE(RX_EARLY_DROP_ERR)),
871 FLAG_ENTRY0("late_short_err", DCCE(LATE_SHORT_ERR)),
872 FLAG_ENTRY0("late_long_err", DCCE(LATE_LONG_ERR)),
873 FLAG_ENTRY0("late_ebp_err", DCCE(LATE_EBP_ERR)),
874 FLAG_ENTRY0("fpe_tx_fifo_ovflw_err", DCCE(FPE_TX_FIFO_OVFLW_ERR)),
875 FLAG_ENTRY0("fpe_tx_fifo_unflw_err", DCCE(FPE_TX_FIFO_UNFLW_ERR)),
876 FLAG_ENTRY0("csr_access_blocked_host", DCCE(CSR_ACCESS_BLOCKED_HOST)),
877 FLAG_ENTRY0("csr_access_blocked_uc", DCCE(CSR_ACCESS_BLOCKED_UC)),
878 FLAG_ENTRY0("tx_ctrl_parity_err", DCCE(TX_CTRL_PARITY_ERR)),
879 FLAG_ENTRY0("tx_ctrl_parity_mbe_err", DCCE(TX_CTRL_PARITY_MBE_ERR)),
880 FLAG_ENTRY0("tx_sc_parity_err", DCCE(TX_SC_PARITY_ERR)),
881 FLAG_ENTRY0("rx_ctrl_parity_mbe_err", DCCE(RX_CTRL_PARITY_MBE_ERR)),
882 FLAG_ENTRY0("csr_parity_err", DCCE(CSR_PARITY_ERR)),
883 FLAG_ENTRY0("csr_inval_addr", DCCE(CSR_INVAL_ADDR)),
884 FLAG_ENTRY0("tx_byte_shft_parity_err", DCCE(TX_BYTE_SHFT_PARITY_ERR)),
885 FLAG_ENTRY0("rx_byte_shft_parity_err", DCCE(RX_BYTE_SHFT_PARITY_ERR)),
886 FLAG_ENTRY0("fmconfig_err", DCCE(FMCONFIG_ERR)),
887 FLAG_ENTRY0("rcvport_err", DCCE(RCVPORT_ERR)),
893 #define LCBE(name) DC_LCB_ERR_FLG_##name##_SMASK
894 static struct flag_table lcb_err_flags[] = {
895 /* 0*/ FLAG_ENTRY0("CSR_PARITY_ERR", LCBE(CSR_PARITY_ERR)),
896 /* 1*/ FLAG_ENTRY0("INVALID_CSR_ADDR", LCBE(INVALID_CSR_ADDR)),
897 /* 2*/ FLAG_ENTRY0("RST_FOR_FAILED_DESKEW", LCBE(RST_FOR_FAILED_DESKEW)),
898 /* 3*/ FLAG_ENTRY0("ALL_LNS_FAILED_REINIT_TEST",
899 LCBE(ALL_LNS_FAILED_REINIT_TEST)),
900 /* 4*/ FLAG_ENTRY0("LOST_REINIT_STALL_OR_TOS", LCBE(LOST_REINIT_STALL_OR_TOS)),
901 /* 5*/ FLAG_ENTRY0("TX_LESS_THAN_FOUR_LNS", LCBE(TX_LESS_THAN_FOUR_LNS)),
902 /* 6*/ FLAG_ENTRY0("RX_LESS_THAN_FOUR_LNS", LCBE(RX_LESS_THAN_FOUR_LNS)),
903 /* 7*/ FLAG_ENTRY0("SEQ_CRC_ERR", LCBE(SEQ_CRC_ERR)),
904 /* 8*/ FLAG_ENTRY0("REINIT_FROM_PEER", LCBE(REINIT_FROM_PEER)),
905 /* 9*/ FLAG_ENTRY0("REINIT_FOR_LN_DEGRADE", LCBE(REINIT_FOR_LN_DEGRADE)),
906 /*10*/ FLAG_ENTRY0("CRC_ERR_CNT_HIT_LIMIT", LCBE(CRC_ERR_CNT_HIT_LIMIT)),
907 /*11*/ FLAG_ENTRY0("RCLK_STOPPED", LCBE(RCLK_STOPPED)),
908 /*12*/ FLAG_ENTRY0("UNEXPECTED_REPLAY_MARKER", LCBE(UNEXPECTED_REPLAY_MARKER)),
909 /*13*/ FLAG_ENTRY0("UNEXPECTED_ROUND_TRIP_MARKER",
910 LCBE(UNEXPECTED_ROUND_TRIP_MARKER)),
911 /*14*/ FLAG_ENTRY0("ILLEGAL_NULL_LTP", LCBE(ILLEGAL_NULL_LTP)),
912 /*15*/ FLAG_ENTRY0("ILLEGAL_FLIT_ENCODING", LCBE(ILLEGAL_FLIT_ENCODING)),
913 /*16*/ FLAG_ENTRY0("FLIT_INPUT_BUF_OFLW", LCBE(FLIT_INPUT_BUF_OFLW)),
914 /*17*/ FLAG_ENTRY0("VL_ACK_INPUT_BUF_OFLW", LCBE(VL_ACK_INPUT_BUF_OFLW)),
915 /*18*/ FLAG_ENTRY0("VL_ACK_INPUT_PARITY_ERR", LCBE(VL_ACK_INPUT_PARITY_ERR)),
916 /*19*/ FLAG_ENTRY0("VL_ACK_INPUT_WRONG_CRC_MODE",
917 LCBE(VL_ACK_INPUT_WRONG_CRC_MODE)),
918 /*20*/ FLAG_ENTRY0("FLIT_INPUT_BUF_MBE", LCBE(FLIT_INPUT_BUF_MBE)),
919 /*21*/ FLAG_ENTRY0("FLIT_INPUT_BUF_SBE", LCBE(FLIT_INPUT_BUF_SBE)),
920 /*22*/ FLAG_ENTRY0("REPLAY_BUF_MBE", LCBE(REPLAY_BUF_MBE)),
921 /*23*/ FLAG_ENTRY0("REPLAY_BUF_SBE", LCBE(REPLAY_BUF_SBE)),
922 /*24*/ FLAG_ENTRY0("CREDIT_RETURN_FLIT_MBE", LCBE(CREDIT_RETURN_FLIT_MBE)),
923 /*25*/ FLAG_ENTRY0("RST_FOR_LINK_TIMEOUT", LCBE(RST_FOR_LINK_TIMEOUT)),
924 /*26*/ FLAG_ENTRY0("RST_FOR_INCOMPLT_RND_TRIP",
925 LCBE(RST_FOR_INCOMPLT_RND_TRIP)),
926 /*27*/ FLAG_ENTRY0("HOLD_REINIT", LCBE(HOLD_REINIT)),
927 /*28*/ FLAG_ENTRY0("NEG_EDGE_LINK_TRANSFER_ACTIVE",
928 LCBE(NEG_EDGE_LINK_TRANSFER_ACTIVE)),
929 /*29*/ FLAG_ENTRY0("REDUNDANT_FLIT_PARITY_ERR",
930 LCBE(REDUNDANT_FLIT_PARITY_ERR))
936 #define D8E(name) DC_DC8051_ERR_FLG_##name##_SMASK
937 static struct flag_table dc8051_err_flags[] = {
938 FLAG_ENTRY0("SET_BY_8051", D8E(SET_BY_8051)),
939 FLAG_ENTRY0("LOST_8051_HEART_BEAT", D8E(LOST_8051_HEART_BEAT)),
940 FLAG_ENTRY0("CRAM_MBE", D8E(CRAM_MBE)),
941 FLAG_ENTRY0("CRAM_SBE", D8E(CRAM_SBE)),
942 FLAG_ENTRY0("DRAM_MBE", D8E(DRAM_MBE)),
943 FLAG_ENTRY0("DRAM_SBE", D8E(DRAM_SBE)),
944 FLAG_ENTRY0("IRAM_MBE", D8E(IRAM_MBE)),
945 FLAG_ENTRY0("IRAM_SBE", D8E(IRAM_SBE)),
946 FLAG_ENTRY0("UNMATCHED_SECURE_MSG_ACROSS_BCC_LANES",
947 D8E(UNMATCHED_SECURE_MSG_ACROSS_BCC_LANES)),
948 FLAG_ENTRY0("INVALID_CSR_ADDR", D8E(INVALID_CSR_ADDR)),
952 * DC8051 Information Error flags
954 * Flags in DC8051_DBG_ERR_INFO_SET_BY_8051.ERROR field.
956 static struct flag_table dc8051_info_err_flags[] = {
957 FLAG_ENTRY0("Spico ROM check failed", SPICO_ROM_FAILED),
958 FLAG_ENTRY0("Unknown frame received", UNKNOWN_FRAME),
959 FLAG_ENTRY0("Target BER not met", TARGET_BER_NOT_MET),
960 FLAG_ENTRY0("Serdes internal loopback failure",
961 FAILED_SERDES_INTERNAL_LOOPBACK),
962 FLAG_ENTRY0("Failed SerDes init", FAILED_SERDES_INIT),
963 FLAG_ENTRY0("Failed LNI(Polling)", FAILED_LNI_POLLING),
964 FLAG_ENTRY0("Failed LNI(Debounce)", FAILED_LNI_DEBOUNCE),
965 FLAG_ENTRY0("Failed LNI(EstbComm)", FAILED_LNI_ESTBCOMM),
966 FLAG_ENTRY0("Failed LNI(OptEq)", FAILED_LNI_OPTEQ),
967 FLAG_ENTRY0("Failed LNI(VerifyCap_1)", FAILED_LNI_VERIFY_CAP1),
968 FLAG_ENTRY0("Failed LNI(VerifyCap_2)", FAILED_LNI_VERIFY_CAP2),
969 FLAG_ENTRY0("Failed LNI(ConfigLT)", FAILED_LNI_CONFIGLT)
973 * DC8051 Information Host Information flags
975 * Flags in DC8051_DBG_ERR_INFO_SET_BY_8051.HOST_MSG field.
977 static struct flag_table dc8051_info_host_msg_flags[] = {
978 FLAG_ENTRY0("Host request done", 0x0001),
979 FLAG_ENTRY0("BC SMA message", 0x0002),
980 FLAG_ENTRY0("BC PWR_MGM message", 0x0004),
981 FLAG_ENTRY0("BC Unknown message (BCC)", 0x0008),
982 FLAG_ENTRY0("BC Unknown message (LCB)", 0x0010),
983 FLAG_ENTRY0("External device config request", 0x0020),
984 FLAG_ENTRY0("VerifyCap all frames received", 0x0040),
985 FLAG_ENTRY0("LinkUp achieved", 0x0080),
986 FLAG_ENTRY0("Link going down", 0x0100),
990 static u32 encoded_size(u32 size);
991 static u32 chip_to_opa_lstate(struct hfi1_devdata *dd, u32 chip_lstate);
992 static int set_physical_link_state(struct hfi1_devdata *dd, u64 state);
993 static void read_vc_remote_phy(struct hfi1_devdata *dd, u8 *power_management,
995 static void read_vc_remote_fabric(struct hfi1_devdata *dd, u8 *vau, u8 *z,
996 u8 *vcu, u16 *vl15buf, u8 *crc_sizes);
997 static void read_vc_remote_link_width(struct hfi1_devdata *dd,
998 u8 *remote_tx_rate, u16 *link_widths);
999 static void read_vc_local_link_width(struct hfi1_devdata *dd, u8 *misc_bits,
1000 u8 *flag_bits, u16 *link_widths);
1001 static void read_remote_device_id(struct hfi1_devdata *dd, u16 *device_id,
1003 static void read_mgmt_allowed(struct hfi1_devdata *dd, u8 *mgmt_allowed);
1004 static void read_local_lni(struct hfi1_devdata *dd, u8 *enable_lane_rx);
1005 static int read_tx_settings(struct hfi1_devdata *dd, u8 *enable_lane_tx,
1006 u8 *tx_polarity_inversion,
1007 u8 *rx_polarity_inversion, u8 *max_rate);
1008 static void handle_sdma_eng_err(struct hfi1_devdata *dd,
1009 unsigned int context, u64 err_status);
1010 static void handle_qsfp_int(struct hfi1_devdata *dd, u32 source, u64 reg);
1011 static void handle_dcc_err(struct hfi1_devdata *dd,
1012 unsigned int context, u64 err_status);
1013 static void handle_lcb_err(struct hfi1_devdata *dd,
1014 unsigned int context, u64 err_status);
1015 static void handle_8051_interrupt(struct hfi1_devdata *dd, u32 unused, u64 reg);
1016 static void handle_cce_err(struct hfi1_devdata *dd, u32 unused, u64 reg);
1017 static void handle_rxe_err(struct hfi1_devdata *dd, u32 unused, u64 reg);
1018 static void handle_misc_err(struct hfi1_devdata *dd, u32 unused, u64 reg);
1019 static void handle_pio_err(struct hfi1_devdata *dd, u32 unused, u64 reg);
1020 static void handle_sdma_err(struct hfi1_devdata *dd, u32 unused, u64 reg);
1021 static void handle_egress_err(struct hfi1_devdata *dd, u32 unused, u64 reg);
1022 static void handle_txe_err(struct hfi1_devdata *dd, u32 unused, u64 reg);
1023 static void set_partition_keys(struct hfi1_pportdata *);
1024 static const char *link_state_name(u32 state);
1025 static const char *link_state_reason_name(struct hfi1_pportdata *ppd,
1027 static int do_8051_command(struct hfi1_devdata *dd, u32 type, u64 in_data,
1029 static int read_idle_sma(struct hfi1_devdata *dd, u64 *data);
1030 static int thermal_init(struct hfi1_devdata *dd);
1032 static int wait_logical_linkstate(struct hfi1_pportdata *ppd, u32 state,
1034 static void read_planned_down_reason_code(struct hfi1_devdata *dd, u8 *pdrrc);
1035 static void handle_temp_err(struct hfi1_devdata *);
1036 static void dc_shutdown(struct hfi1_devdata *);
1037 static void dc_start(struct hfi1_devdata *);
1040 * Error interrupt table entry. This is used as input to the interrupt
1041 * "clear down" routine used for all second tier error interrupt register.
1042 * Second tier interrupt registers have a single bit representing them
1043 * in the top-level CceIntStatus.
1045 struct err_reg_info {
1046 u32 status; /* status CSR offset */
1047 u32 clear; /* clear CSR offset */
1048 u32 mask; /* mask CSR offset */
1049 void (*handler)(struct hfi1_devdata *dd, u32 source, u64 reg);
1053 #define NUM_MISC_ERRS (IS_GENERAL_ERR_END - IS_GENERAL_ERR_START)
1054 #define NUM_DC_ERRS (IS_DC_END - IS_DC_START)
1055 #define NUM_VARIOUS (IS_VARIOUS_END - IS_VARIOUS_START)
1058 * Helpers for building HFI and DC error interrupt table entries. Different
1059 * helpers are needed because of inconsistent register names.
1061 #define EE(reg, handler, desc) \
1062 { reg##_STATUS, reg##_CLEAR, reg##_MASK, \
1064 #define DC_EE1(reg, handler, desc) \
1065 { reg##_FLG, reg##_FLG_CLR, reg##_FLG_EN, handler, desc }
1066 #define DC_EE2(reg, handler, desc) \
1067 { reg##_FLG, reg##_CLR, reg##_EN, handler, desc }
1070 * Table of the "misc" grouping of error interrupts. Each entry refers to
1071 * another register containing more information.
1073 static const struct err_reg_info misc_errs[NUM_MISC_ERRS] = {
1074 /* 0*/ EE(CCE_ERR, handle_cce_err, "CceErr"),
1075 /* 1*/ EE(RCV_ERR, handle_rxe_err, "RxeErr"),
1076 /* 2*/ EE(MISC_ERR, handle_misc_err, "MiscErr"),
1077 /* 3*/ { 0, 0, 0, NULL }, /* reserved */
1078 /* 4*/ EE(SEND_PIO_ERR, handle_pio_err, "PioErr"),
1079 /* 5*/ EE(SEND_DMA_ERR, handle_sdma_err, "SDmaErr"),
1080 /* 6*/ EE(SEND_EGRESS_ERR, handle_egress_err, "EgressErr"),
1081 /* 7*/ EE(SEND_ERR, handle_txe_err, "TxeErr")
1082 /* the rest are reserved */
1086 * Index into the Various section of the interrupt sources
1087 * corresponding to the Critical Temperature interrupt.
1089 #define TCRIT_INT_SOURCE 4
1092 * SDMA error interrupt entry - refers to another register containing more
1095 static const struct err_reg_info sdma_eng_err =
1096 EE(SEND_DMA_ENG_ERR, handle_sdma_eng_err, "SDmaEngErr");
1098 static const struct err_reg_info various_err[NUM_VARIOUS] = {
1099 /* 0*/ { 0, 0, 0, NULL }, /* PbcInt */
1100 /* 1*/ { 0, 0, 0, NULL }, /* GpioAssertInt */
1101 /* 2*/ EE(ASIC_QSFP1, handle_qsfp_int, "QSFP1"),
1102 /* 3*/ EE(ASIC_QSFP2, handle_qsfp_int, "QSFP2"),
1103 /* 4*/ { 0, 0, 0, NULL }, /* TCritInt */
1104 /* rest are reserved */
1108 * The DC encoding of mtu_cap for 10K MTU in the DCC_CFG_PORT_CONFIG
1109 * register can not be derived from the MTU value because 10K is not
1110 * a power of 2. Therefore, we need a constant. Everything else can
1113 #define DCC_CFG_PORT_MTU_CAP_10240 7
1116 * Table of the DC grouping of error interrupts. Each entry refers to
1117 * another register containing more information.
1119 static const struct err_reg_info dc_errs[NUM_DC_ERRS] = {
1120 /* 0*/ DC_EE1(DCC_ERR, handle_dcc_err, "DCC Err"),
1121 /* 1*/ DC_EE2(DC_LCB_ERR, handle_lcb_err, "LCB Err"),
1122 /* 2*/ DC_EE2(DC_DC8051_ERR, handle_8051_interrupt, "DC8051 Interrupt"),
1123 /* 3*/ /* dc_lbm_int - special, see is_dc_int() */
1124 /* the rest are reserved */
1134 * csr to read for name (if applicable)
1139 * offset into dd or ppd to store the counter's value
1149 * accessor for stat element, context either dd or ppd
1151 u64 (*rw_cntr)(const struct cntr_entry *,
1158 #define C_RCV_HDR_OVF_FIRST C_RCV_HDR_OVF_0
1159 #define C_RCV_HDR_OVF_LAST C_RCV_HDR_OVF_159
1161 #define CNTR_ELEM(name, csr, offset, flags, accessor) \
1171 #define RXE32_PORT_CNTR_ELEM(name, counter, flags) \
1173 (counter * 8 + RCV_COUNTER_ARRAY32), \
1174 0, flags | CNTR_32BIT, \
1175 port_access_u32_csr)
1177 #define RXE32_DEV_CNTR_ELEM(name, counter, flags) \
1179 (counter * 8 + RCV_COUNTER_ARRAY32), \
1180 0, flags | CNTR_32BIT, \
1184 #define RXE64_PORT_CNTR_ELEM(name, counter, flags) \
1186 (counter * 8 + RCV_COUNTER_ARRAY64), \
1188 port_access_u64_csr)
1190 #define RXE64_DEV_CNTR_ELEM(name, counter, flags) \
1192 (counter * 8 + RCV_COUNTER_ARRAY64), \
1196 #define OVR_LBL(ctx) C_RCV_HDR_OVF_ ## ctx
1197 #define OVR_ELM(ctx) \
1198 CNTR_ELEM("RcvHdrOvr" #ctx, \
1199 (RCV_HDR_OVFL_CNT + ctx*0x100), \
1200 0, CNTR_NORMAL, port_access_u64_csr)
1203 #define TXE32_PORT_CNTR_ELEM(name, counter, flags) \
1205 (counter * 8 + SEND_COUNTER_ARRAY32), \
1206 0, flags | CNTR_32BIT, \
1207 port_access_u32_csr)
1210 #define TXE64_PORT_CNTR_ELEM(name, counter, flags) \
1212 (counter * 8 + SEND_COUNTER_ARRAY64), \
1214 port_access_u64_csr)
1216 # define TX64_DEV_CNTR_ELEM(name, counter, flags) \
1218 counter * 8 + SEND_COUNTER_ARRAY64, \
1224 #define CCE_PERF_DEV_CNTR_ELEM(name, counter, flags) \
1226 (counter * 8 + CCE_COUNTER_ARRAY32), \
1227 0, flags | CNTR_32BIT, \
1230 #define CCE_INT_DEV_CNTR_ELEM(name, counter, flags) \
1232 (counter * 8 + CCE_INT_COUNTER_ARRAY32), \
1233 0, flags | CNTR_32BIT, \
1237 #define DC_PERF_CNTR(name, counter, flags) \
1244 #define DC_PERF_CNTR_LCB(name, counter, flags) \
1252 #define SW_IBP_CNTR(name, cntr) \
1259 u64 read_csr(const struct hfi1_devdata *dd, u32 offset)
1263 if (dd->flags & HFI1_PRESENT) {
1264 val = readq((void __iomem *)dd->kregbase + offset);
1270 void write_csr(const struct hfi1_devdata *dd, u32 offset, u64 value)
1272 if (dd->flags & HFI1_PRESENT)
1273 writeq(value, (void __iomem *)dd->kregbase + offset);
1276 void __iomem *get_csr_addr(
1277 struct hfi1_devdata *dd,
1280 return (void __iomem *)dd->kregbase + offset;
1283 static inline u64 read_write_csr(const struct hfi1_devdata *dd, u32 csr,
1284 int mode, u64 value)
1289 if (mode == CNTR_MODE_R) {
1290 ret = read_csr(dd, csr);
1291 } else if (mode == CNTR_MODE_W) {
1292 write_csr(dd, csr, value);
1295 dd_dev_err(dd, "Invalid cntr register access mode");
1299 hfi1_cdbg(CNTR, "csr 0x%x val 0x%llx mode %d", csr, ret, mode);
1304 static u64 dev_access_u32_csr(const struct cntr_entry *entry,
1305 void *context, int vl, int mode, u64 data)
1307 struct hfi1_devdata *dd = context;
1308 u64 csr = entry->csr;
1310 if (entry->flags & CNTR_SDMA) {
1311 if (vl == CNTR_INVALID_VL)
1315 if (vl != CNTR_INVALID_VL)
1318 return read_write_csr(dd, csr, mode, data);
1321 static u64 access_sde_err_cnt(const struct cntr_entry *entry,
1322 void *context, int idx, int mode, u64 data)
1324 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1326 if (dd->per_sdma && idx < dd->num_sdma)
1327 return dd->per_sdma[idx].err_cnt;
1331 static u64 access_sde_int_cnt(const struct cntr_entry *entry,
1332 void *context, int idx, int mode, u64 data)
1334 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1336 if (dd->per_sdma && idx < dd->num_sdma)
1337 return dd->per_sdma[idx].sdma_int_cnt;
1341 static u64 access_sde_idle_int_cnt(const struct cntr_entry *entry,
1342 void *context, int idx, int mode, u64 data)
1344 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1346 if (dd->per_sdma && idx < dd->num_sdma)
1347 return dd->per_sdma[idx].idle_int_cnt;
1351 static u64 access_sde_progress_int_cnt(const struct cntr_entry *entry,
1352 void *context, int idx, int mode,
1355 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1357 if (dd->per_sdma && idx < dd->num_sdma)
1358 return dd->per_sdma[idx].progress_int_cnt;
1362 static u64 dev_access_u64_csr(const struct cntr_entry *entry, void *context,
1363 int vl, int mode, u64 data)
1365 struct hfi1_devdata *dd = context;
1368 u64 csr = entry->csr;
1370 if (entry->flags & CNTR_VL) {
1371 if (vl == CNTR_INVALID_VL)
1375 if (vl != CNTR_INVALID_VL)
1379 val = read_write_csr(dd, csr, mode, data);
1383 static u64 dc_access_lcb_cntr(const struct cntr_entry *entry, void *context,
1384 int vl, int mode, u64 data)
1386 struct hfi1_devdata *dd = context;
1387 u32 csr = entry->csr;
1390 if (vl != CNTR_INVALID_VL)
1392 if (mode == CNTR_MODE_R)
1393 ret = read_lcb_csr(dd, csr, &data);
1394 else if (mode == CNTR_MODE_W)
1395 ret = write_lcb_csr(dd, csr, data);
1398 dd_dev_err(dd, "Could not acquire LCB for counter 0x%x", csr);
1402 hfi1_cdbg(CNTR, "csr 0x%x val 0x%llx mode %d", csr, data, mode);
1407 static u64 port_access_u32_csr(const struct cntr_entry *entry, void *context,
1408 int vl, int mode, u64 data)
1410 struct hfi1_pportdata *ppd = context;
1412 if (vl != CNTR_INVALID_VL)
1414 return read_write_csr(ppd->dd, entry->csr, mode, data);
1417 static u64 port_access_u64_csr(const struct cntr_entry *entry,
1418 void *context, int vl, int mode, u64 data)
1420 struct hfi1_pportdata *ppd = context;
1422 u64 csr = entry->csr;
1424 if (entry->flags & CNTR_VL) {
1425 if (vl == CNTR_INVALID_VL)
1429 if (vl != CNTR_INVALID_VL)
1432 val = read_write_csr(ppd->dd, csr, mode, data);
1436 /* Software defined */
1437 static inline u64 read_write_sw(struct hfi1_devdata *dd, u64 *cntr, int mode,
1442 if (mode == CNTR_MODE_R) {
1444 } else if (mode == CNTR_MODE_W) {
1448 dd_dev_err(dd, "Invalid cntr sw access mode");
1452 hfi1_cdbg(CNTR, "val 0x%llx mode %d", ret, mode);
1457 static u64 access_sw_link_dn_cnt(const struct cntr_entry *entry, void *context,
1458 int vl, int mode, u64 data)
1460 struct hfi1_pportdata *ppd = context;
1462 if (vl != CNTR_INVALID_VL)
1464 return read_write_sw(ppd->dd, &ppd->link_downed, mode, data);
1467 static u64 access_sw_link_up_cnt(const struct cntr_entry *entry, void *context,
1468 int vl, int mode, u64 data)
1470 struct hfi1_pportdata *ppd = context;
1472 if (vl != CNTR_INVALID_VL)
1474 return read_write_sw(ppd->dd, &ppd->link_up, mode, data);
1477 static u64 access_sw_unknown_frame_cnt(const struct cntr_entry *entry,
1478 void *context, int vl, int mode,
1481 struct hfi1_pportdata *ppd = (struct hfi1_pportdata *)context;
1483 if (vl != CNTR_INVALID_VL)
1485 return read_write_sw(ppd->dd, &ppd->unknown_frame_count, mode, data);
1488 static u64 access_sw_xmit_discards(const struct cntr_entry *entry,
1489 void *context, int vl, int mode, u64 data)
1491 struct hfi1_pportdata *ppd = (struct hfi1_pportdata *)context;
1495 if (vl == CNTR_INVALID_VL)
1496 counter = &ppd->port_xmit_discards;
1497 else if (vl >= 0 && vl < C_VL_COUNT)
1498 counter = &ppd->port_xmit_discards_vl[vl];
1502 return read_write_sw(ppd->dd, counter, mode, data);
1505 static u64 access_xmit_constraint_errs(const struct cntr_entry *entry,
1506 void *context, int vl, int mode, u64 data)
1508 struct hfi1_pportdata *ppd = context;
1510 if (vl != CNTR_INVALID_VL)
1513 return read_write_sw(ppd->dd, &ppd->port_xmit_constraint_errors,
1517 static u64 access_rcv_constraint_errs(const struct cntr_entry *entry,
1518 void *context, int vl, int mode, u64 data)
1520 struct hfi1_pportdata *ppd = context;
1522 if (vl != CNTR_INVALID_VL)
1525 return read_write_sw(ppd->dd, &ppd->port_rcv_constraint_errors,
1529 u64 get_all_cpu_total(u64 __percpu *cntr)
1534 for_each_possible_cpu(cpu)
1535 counter += *per_cpu_ptr(cntr, cpu);
1539 static u64 read_write_cpu(struct hfi1_devdata *dd, u64 *z_val,
1541 int vl, int mode, u64 data)
1546 if (vl != CNTR_INVALID_VL)
1549 if (mode == CNTR_MODE_R) {
1550 ret = get_all_cpu_total(cntr) - *z_val;
1551 } else if (mode == CNTR_MODE_W) {
1552 /* A write can only zero the counter */
1554 *z_val = get_all_cpu_total(cntr);
1556 dd_dev_err(dd, "Per CPU cntrs can only be zeroed");
1558 dd_dev_err(dd, "Invalid cntr sw cpu access mode");
1565 static u64 access_sw_cpu_intr(const struct cntr_entry *entry,
1566 void *context, int vl, int mode, u64 data)
1568 struct hfi1_devdata *dd = context;
1570 return read_write_cpu(dd, &dd->z_int_counter, dd->int_counter, vl,
1574 static u64 access_sw_cpu_rcv_limit(const struct cntr_entry *entry,
1575 void *context, int vl, int mode, u64 data)
1577 struct hfi1_devdata *dd = context;
1579 return read_write_cpu(dd, &dd->z_rcv_limit, dd->rcv_limit, vl,
1583 static u64 access_sw_pio_wait(const struct cntr_entry *entry,
1584 void *context, int vl, int mode, u64 data)
1586 struct hfi1_devdata *dd = context;
1588 return dd->verbs_dev.n_piowait;
1591 static u64 access_sw_pio_drain(const struct cntr_entry *entry,
1592 void *context, int vl, int mode, u64 data)
1594 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1596 return dd->verbs_dev.n_piodrain;
1599 static u64 access_sw_vtx_wait(const struct cntr_entry *entry,
1600 void *context, int vl, int mode, u64 data)
1602 struct hfi1_devdata *dd = context;
1604 return dd->verbs_dev.n_txwait;
1607 static u64 access_sw_kmem_wait(const struct cntr_entry *entry,
1608 void *context, int vl, int mode, u64 data)
1610 struct hfi1_devdata *dd = context;
1612 return dd->verbs_dev.n_kmem_wait;
1615 static u64 access_sw_send_schedule(const struct cntr_entry *entry,
1616 void *context, int vl, int mode, u64 data)
1618 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1620 return read_write_cpu(dd, &dd->z_send_schedule, dd->send_schedule, vl,
1624 /* Software counters for the error status bits within MISC_ERR_STATUS */
1625 static u64 access_misc_pll_lock_fail_err_cnt(const struct cntr_entry *entry,
1626 void *context, int vl, int mode,
1629 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1631 return dd->misc_err_status_cnt[12];
1634 static u64 access_misc_mbist_fail_err_cnt(const struct cntr_entry *entry,
1635 void *context, int vl, int mode,
1638 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1640 return dd->misc_err_status_cnt[11];
1643 static u64 access_misc_invalid_eep_cmd_err_cnt(const struct cntr_entry *entry,
1644 void *context, int vl, int mode,
1647 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1649 return dd->misc_err_status_cnt[10];
1652 static u64 access_misc_efuse_done_parity_err_cnt(const struct cntr_entry *entry,
1653 void *context, int vl,
1656 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1658 return dd->misc_err_status_cnt[9];
1661 static u64 access_misc_efuse_write_err_cnt(const struct cntr_entry *entry,
1662 void *context, int vl, int mode,
1665 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1667 return dd->misc_err_status_cnt[8];
1670 static u64 access_misc_efuse_read_bad_addr_err_cnt(
1671 const struct cntr_entry *entry,
1672 void *context, int vl, int mode, u64 data)
1674 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1676 return dd->misc_err_status_cnt[7];
1679 static u64 access_misc_efuse_csr_parity_err_cnt(const struct cntr_entry *entry,
1680 void *context, int vl,
1683 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1685 return dd->misc_err_status_cnt[6];
1688 static u64 access_misc_fw_auth_failed_err_cnt(const struct cntr_entry *entry,
1689 void *context, int vl, int mode,
1692 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1694 return dd->misc_err_status_cnt[5];
1697 static u64 access_misc_key_mismatch_err_cnt(const struct cntr_entry *entry,
1698 void *context, int vl, int mode,
1701 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1703 return dd->misc_err_status_cnt[4];
1706 static u64 access_misc_sbus_write_failed_err_cnt(const struct cntr_entry *entry,
1707 void *context, int vl,
1710 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1712 return dd->misc_err_status_cnt[3];
1715 static u64 access_misc_csr_write_bad_addr_err_cnt(
1716 const struct cntr_entry *entry,
1717 void *context, int vl, int mode, u64 data)
1719 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1721 return dd->misc_err_status_cnt[2];
1724 static u64 access_misc_csr_read_bad_addr_err_cnt(const struct cntr_entry *entry,
1725 void *context, int vl,
1728 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1730 return dd->misc_err_status_cnt[1];
1733 static u64 access_misc_csr_parity_err_cnt(const struct cntr_entry *entry,
1734 void *context, int vl, int mode,
1737 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1739 return dd->misc_err_status_cnt[0];
1743 * Software counter for the aggregate of
1744 * individual CceErrStatus counters
1746 static u64 access_sw_cce_err_status_aggregated_cnt(
1747 const struct cntr_entry *entry,
1748 void *context, int vl, int mode, u64 data)
1750 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1752 return dd->sw_cce_err_status_aggregate;
1756 * Software counters corresponding to each of the
1757 * error status bits within CceErrStatus
1759 static u64 access_cce_msix_csr_parity_err_cnt(const struct cntr_entry *entry,
1760 void *context, int vl, int mode,
1763 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1765 return dd->cce_err_status_cnt[40];
1768 static u64 access_cce_int_map_unc_err_cnt(const struct cntr_entry *entry,
1769 void *context, int vl, int mode,
1772 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1774 return dd->cce_err_status_cnt[39];
1777 static u64 access_cce_int_map_cor_err_cnt(const struct cntr_entry *entry,
1778 void *context, int vl, int mode,
1781 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1783 return dd->cce_err_status_cnt[38];
1786 static u64 access_cce_msix_table_unc_err_cnt(const struct cntr_entry *entry,
1787 void *context, int vl, int mode,
1790 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1792 return dd->cce_err_status_cnt[37];
1795 static u64 access_cce_msix_table_cor_err_cnt(const struct cntr_entry *entry,
1796 void *context, int vl, int mode,
1799 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1801 return dd->cce_err_status_cnt[36];
1804 static u64 access_cce_rxdma_conv_fifo_parity_err_cnt(
1805 const struct cntr_entry *entry,
1806 void *context, int vl, int mode, u64 data)
1808 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1810 return dd->cce_err_status_cnt[35];
1813 static u64 access_cce_rcpl_async_fifo_parity_err_cnt(
1814 const struct cntr_entry *entry,
1815 void *context, int vl, int mode, u64 data)
1817 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1819 return dd->cce_err_status_cnt[34];
1822 static u64 access_cce_seg_write_bad_addr_err_cnt(const struct cntr_entry *entry,
1823 void *context, int vl,
1826 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1828 return dd->cce_err_status_cnt[33];
1831 static u64 access_cce_seg_read_bad_addr_err_cnt(const struct cntr_entry *entry,
1832 void *context, int vl, int mode,
1835 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1837 return dd->cce_err_status_cnt[32];
1840 static u64 access_la_triggered_cnt(const struct cntr_entry *entry,
1841 void *context, int vl, int mode, u64 data)
1843 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1845 return dd->cce_err_status_cnt[31];
1848 static u64 access_cce_trgt_cpl_timeout_err_cnt(const struct cntr_entry *entry,
1849 void *context, int vl, int mode,
1852 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1854 return dd->cce_err_status_cnt[30];
1857 static u64 access_pcic_receive_parity_err_cnt(const struct cntr_entry *entry,
1858 void *context, int vl, int mode,
1861 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1863 return dd->cce_err_status_cnt[29];
1866 static u64 access_pcic_transmit_back_parity_err_cnt(
1867 const struct cntr_entry *entry,
1868 void *context, int vl, int mode, u64 data)
1870 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1872 return dd->cce_err_status_cnt[28];
1875 static u64 access_pcic_transmit_front_parity_err_cnt(
1876 const struct cntr_entry *entry,
1877 void *context, int vl, int mode, u64 data)
1879 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1881 return dd->cce_err_status_cnt[27];
1884 static u64 access_pcic_cpl_dat_q_unc_err_cnt(const struct cntr_entry *entry,
1885 void *context, int vl, int mode,
1888 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1890 return dd->cce_err_status_cnt[26];
1893 static u64 access_pcic_cpl_hd_q_unc_err_cnt(const struct cntr_entry *entry,
1894 void *context, int vl, int mode,
1897 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1899 return dd->cce_err_status_cnt[25];
1902 static u64 access_pcic_post_dat_q_unc_err_cnt(const struct cntr_entry *entry,
1903 void *context, int vl, int mode,
1906 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1908 return dd->cce_err_status_cnt[24];
1911 static u64 access_pcic_post_hd_q_unc_err_cnt(const struct cntr_entry *entry,
1912 void *context, int vl, int mode,
1915 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1917 return dd->cce_err_status_cnt[23];
1920 static u64 access_pcic_retry_sot_mem_unc_err_cnt(const struct cntr_entry *entry,
1921 void *context, int vl,
1924 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1926 return dd->cce_err_status_cnt[22];
1929 static u64 access_pcic_retry_mem_unc_err(const struct cntr_entry *entry,
1930 void *context, int vl, int mode,
1933 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1935 return dd->cce_err_status_cnt[21];
1938 static u64 access_pcic_n_post_dat_q_parity_err_cnt(
1939 const struct cntr_entry *entry,
1940 void *context, int vl, int mode, u64 data)
1942 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1944 return dd->cce_err_status_cnt[20];
1947 static u64 access_pcic_n_post_h_q_parity_err_cnt(const struct cntr_entry *entry,
1948 void *context, int vl,
1951 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1953 return dd->cce_err_status_cnt[19];
1956 static u64 access_pcic_cpl_dat_q_cor_err_cnt(const struct cntr_entry *entry,
1957 void *context, int vl, int mode,
1960 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1962 return dd->cce_err_status_cnt[18];
1965 static u64 access_pcic_cpl_hd_q_cor_err_cnt(const struct cntr_entry *entry,
1966 void *context, int vl, int mode,
1969 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1971 return dd->cce_err_status_cnt[17];
1974 static u64 access_pcic_post_dat_q_cor_err_cnt(const struct cntr_entry *entry,
1975 void *context, int vl, int mode,
1978 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1980 return dd->cce_err_status_cnt[16];
1983 static u64 access_pcic_post_hd_q_cor_err_cnt(const struct cntr_entry *entry,
1984 void *context, int vl, int mode,
1987 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1989 return dd->cce_err_status_cnt[15];
1992 static u64 access_pcic_retry_sot_mem_cor_err_cnt(const struct cntr_entry *entry,
1993 void *context, int vl,
1996 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1998 return dd->cce_err_status_cnt[14];
2001 static u64 access_pcic_retry_mem_cor_err_cnt(const struct cntr_entry *entry,
2002 void *context, int vl, int mode,
2005 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2007 return dd->cce_err_status_cnt[13];
2010 static u64 access_cce_cli1_async_fifo_dbg_parity_err_cnt(
2011 const struct cntr_entry *entry,
2012 void *context, int vl, int mode, u64 data)
2014 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2016 return dd->cce_err_status_cnt[12];
2019 static u64 access_cce_cli1_async_fifo_rxdma_parity_err_cnt(
2020 const struct cntr_entry *entry,
2021 void *context, int vl, int mode, u64 data)
2023 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2025 return dd->cce_err_status_cnt[11];
2028 static u64 access_cce_cli1_async_fifo_sdma_hd_parity_err_cnt(
2029 const struct cntr_entry *entry,
2030 void *context, int vl, int mode, u64 data)
2032 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2034 return dd->cce_err_status_cnt[10];
2037 static u64 access_cce_cl1_async_fifo_pio_crdt_parity_err_cnt(
2038 const struct cntr_entry *entry,
2039 void *context, int vl, int mode, u64 data)
2041 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2043 return dd->cce_err_status_cnt[9];
2046 static u64 access_cce_cli2_async_fifo_parity_err_cnt(
2047 const struct cntr_entry *entry,
2048 void *context, int vl, int mode, u64 data)
2050 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2052 return dd->cce_err_status_cnt[8];
2055 static u64 access_cce_csr_cfg_bus_parity_err_cnt(const struct cntr_entry *entry,
2056 void *context, int vl,
2059 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2061 return dd->cce_err_status_cnt[7];
2064 static u64 access_cce_cli0_async_fifo_parity_err_cnt(
2065 const struct cntr_entry *entry,
2066 void *context, int vl, int mode, u64 data)
2068 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2070 return dd->cce_err_status_cnt[6];
2073 static u64 access_cce_rspd_data_parity_err_cnt(const struct cntr_entry *entry,
2074 void *context, int vl, int mode,
2077 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2079 return dd->cce_err_status_cnt[5];
2082 static u64 access_cce_trgt_access_err_cnt(const struct cntr_entry *entry,
2083 void *context, int vl, int mode,
2086 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2088 return dd->cce_err_status_cnt[4];
2091 static u64 access_cce_trgt_async_fifo_parity_err_cnt(
2092 const struct cntr_entry *entry,
2093 void *context, int vl, int mode, u64 data)
2095 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2097 return dd->cce_err_status_cnt[3];
2100 static u64 access_cce_csr_write_bad_addr_err_cnt(const struct cntr_entry *entry,
2101 void *context, int vl,
2104 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2106 return dd->cce_err_status_cnt[2];
2109 static u64 access_cce_csr_read_bad_addr_err_cnt(const struct cntr_entry *entry,
2110 void *context, int vl,
2113 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2115 return dd->cce_err_status_cnt[1];
2118 static u64 access_ccs_csr_parity_err_cnt(const struct cntr_entry *entry,
2119 void *context, int vl, int mode,
2122 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2124 return dd->cce_err_status_cnt[0];
2128 * Software counters corresponding to each of the
2129 * error status bits within RcvErrStatus
2131 static u64 access_rx_csr_parity_err_cnt(const struct cntr_entry *entry,
2132 void *context, int vl, int mode,
2135 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2137 return dd->rcv_err_status_cnt[63];
2140 static u64 access_rx_csr_write_bad_addr_err_cnt(const struct cntr_entry *entry,
2141 void *context, int vl,
2144 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2146 return dd->rcv_err_status_cnt[62];
2149 static u64 access_rx_csr_read_bad_addr_err_cnt(const struct cntr_entry *entry,
2150 void *context, int vl, int mode,
2153 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2155 return dd->rcv_err_status_cnt[61];
2158 static u64 access_rx_dma_csr_unc_err_cnt(const struct cntr_entry *entry,
2159 void *context, int vl, int mode,
2162 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2164 return dd->rcv_err_status_cnt[60];
2167 static u64 access_rx_dma_dq_fsm_encoding_err_cnt(const struct cntr_entry *entry,
2168 void *context, int vl,
2171 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2173 return dd->rcv_err_status_cnt[59];
2176 static u64 access_rx_dma_eq_fsm_encoding_err_cnt(const struct cntr_entry *entry,
2177 void *context, int vl,
2180 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2182 return dd->rcv_err_status_cnt[58];
2185 static u64 access_rx_dma_csr_parity_err_cnt(const struct cntr_entry *entry,
2186 void *context, int vl, int mode,
2189 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2191 return dd->rcv_err_status_cnt[57];
2194 static u64 access_rx_rbuf_data_cor_err_cnt(const struct cntr_entry *entry,
2195 void *context, int vl, int mode,
2198 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2200 return dd->rcv_err_status_cnt[56];
2203 static u64 access_rx_rbuf_data_unc_err_cnt(const struct cntr_entry *entry,
2204 void *context, int vl, int mode,
2207 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2209 return dd->rcv_err_status_cnt[55];
2212 static u64 access_rx_dma_data_fifo_rd_cor_err_cnt(
2213 const struct cntr_entry *entry,
2214 void *context, int vl, int mode, u64 data)
2216 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2218 return dd->rcv_err_status_cnt[54];
2221 static u64 access_rx_dma_data_fifo_rd_unc_err_cnt(
2222 const struct cntr_entry *entry,
2223 void *context, int vl, int mode, u64 data)
2225 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2227 return dd->rcv_err_status_cnt[53];
2230 static u64 access_rx_dma_hdr_fifo_rd_cor_err_cnt(const struct cntr_entry *entry,
2231 void *context, int vl,
2234 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2236 return dd->rcv_err_status_cnt[52];
2239 static u64 access_rx_dma_hdr_fifo_rd_unc_err_cnt(const struct cntr_entry *entry,
2240 void *context, int vl,
2243 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2245 return dd->rcv_err_status_cnt[51];
2248 static u64 access_rx_rbuf_desc_part2_cor_err_cnt(const struct cntr_entry *entry,
2249 void *context, int vl,
2252 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2254 return dd->rcv_err_status_cnt[50];
2257 static u64 access_rx_rbuf_desc_part2_unc_err_cnt(const struct cntr_entry *entry,
2258 void *context, int vl,
2261 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2263 return dd->rcv_err_status_cnt[49];
2266 static u64 access_rx_rbuf_desc_part1_cor_err_cnt(const struct cntr_entry *entry,
2267 void *context, int vl,
2270 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2272 return dd->rcv_err_status_cnt[48];
2275 static u64 access_rx_rbuf_desc_part1_unc_err_cnt(const struct cntr_entry *entry,
2276 void *context, int vl,
2279 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2281 return dd->rcv_err_status_cnt[47];
2284 static u64 access_rx_hq_intr_fsm_err_cnt(const struct cntr_entry *entry,
2285 void *context, int vl, int mode,
2288 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2290 return dd->rcv_err_status_cnt[46];
2293 static u64 access_rx_hq_intr_csr_parity_err_cnt(
2294 const struct cntr_entry *entry,
2295 void *context, int vl, int mode, u64 data)
2297 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2299 return dd->rcv_err_status_cnt[45];
2302 static u64 access_rx_lookup_csr_parity_err_cnt(
2303 const struct cntr_entry *entry,
2304 void *context, int vl, int mode, u64 data)
2306 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2308 return dd->rcv_err_status_cnt[44];
2311 static u64 access_rx_lookup_rcv_array_cor_err_cnt(
2312 const struct cntr_entry *entry,
2313 void *context, int vl, int mode, u64 data)
2315 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2317 return dd->rcv_err_status_cnt[43];
2320 static u64 access_rx_lookup_rcv_array_unc_err_cnt(
2321 const struct cntr_entry *entry,
2322 void *context, int vl, int mode, u64 data)
2324 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2326 return dd->rcv_err_status_cnt[42];
2329 static u64 access_rx_lookup_des_part2_parity_err_cnt(
2330 const struct cntr_entry *entry,
2331 void *context, int vl, int mode, u64 data)
2333 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2335 return dd->rcv_err_status_cnt[41];
2338 static u64 access_rx_lookup_des_part1_unc_cor_err_cnt(
2339 const struct cntr_entry *entry,
2340 void *context, int vl, int mode, u64 data)
2342 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2344 return dd->rcv_err_status_cnt[40];
2347 static u64 access_rx_lookup_des_part1_unc_err_cnt(
2348 const struct cntr_entry *entry,
2349 void *context, int vl, int mode, u64 data)
2351 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2353 return dd->rcv_err_status_cnt[39];
2356 static u64 access_rx_rbuf_next_free_buf_cor_err_cnt(
2357 const struct cntr_entry *entry,
2358 void *context, int vl, int mode, u64 data)
2360 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2362 return dd->rcv_err_status_cnt[38];
2365 static u64 access_rx_rbuf_next_free_buf_unc_err_cnt(
2366 const struct cntr_entry *entry,
2367 void *context, int vl, int mode, u64 data)
2369 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2371 return dd->rcv_err_status_cnt[37];
2374 static u64 access_rbuf_fl_init_wr_addr_parity_err_cnt(
2375 const struct cntr_entry *entry,
2376 void *context, int vl, int mode, u64 data)
2378 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2380 return dd->rcv_err_status_cnt[36];
2383 static u64 access_rx_rbuf_fl_initdone_parity_err_cnt(
2384 const struct cntr_entry *entry,
2385 void *context, int vl, int mode, u64 data)
2387 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2389 return dd->rcv_err_status_cnt[35];
2392 static u64 access_rx_rbuf_fl_write_addr_parity_err_cnt(
2393 const struct cntr_entry *entry,
2394 void *context, int vl, int mode, u64 data)
2396 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2398 return dd->rcv_err_status_cnt[34];
2401 static u64 access_rx_rbuf_fl_rd_addr_parity_err_cnt(
2402 const struct cntr_entry *entry,
2403 void *context, int vl, int mode, u64 data)
2405 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2407 return dd->rcv_err_status_cnt[33];
2410 static u64 access_rx_rbuf_empty_err_cnt(const struct cntr_entry *entry,
2411 void *context, int vl, int mode,
2414 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2416 return dd->rcv_err_status_cnt[32];
2419 static u64 access_rx_rbuf_full_err_cnt(const struct cntr_entry *entry,
2420 void *context, int vl, int mode,
2423 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2425 return dd->rcv_err_status_cnt[31];
2428 static u64 access_rbuf_bad_lookup_err_cnt(const struct cntr_entry *entry,
2429 void *context, int vl, int mode,
2432 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2434 return dd->rcv_err_status_cnt[30];
2437 static u64 access_rbuf_ctx_id_parity_err_cnt(const struct cntr_entry *entry,
2438 void *context, int vl, int mode,
2441 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2443 return dd->rcv_err_status_cnt[29];
2446 static u64 access_rbuf_csr_qeopdw_parity_err_cnt(const struct cntr_entry *entry,
2447 void *context, int vl,
2450 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2452 return dd->rcv_err_status_cnt[28];
2455 static u64 access_rx_rbuf_csr_q_num_of_pkt_parity_err_cnt(
2456 const struct cntr_entry *entry,
2457 void *context, int vl, int mode, u64 data)
2459 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2461 return dd->rcv_err_status_cnt[27];
2464 static u64 access_rx_rbuf_csr_q_t1_ptr_parity_err_cnt(
2465 const struct cntr_entry *entry,
2466 void *context, int vl, int mode, u64 data)
2468 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2470 return dd->rcv_err_status_cnt[26];
2473 static u64 access_rx_rbuf_csr_q_hd_ptr_parity_err_cnt(
2474 const struct cntr_entry *entry,
2475 void *context, int vl, int mode, u64 data)
2477 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2479 return dd->rcv_err_status_cnt[25];
2482 static u64 access_rx_rbuf_csr_q_vld_bit_parity_err_cnt(
2483 const struct cntr_entry *entry,
2484 void *context, int vl, int mode, u64 data)
2486 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2488 return dd->rcv_err_status_cnt[24];
2491 static u64 access_rx_rbuf_csr_q_next_buf_parity_err_cnt(
2492 const struct cntr_entry *entry,
2493 void *context, int vl, int mode, u64 data)
2495 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2497 return dd->rcv_err_status_cnt[23];
2500 static u64 access_rx_rbuf_csr_q_ent_cnt_parity_err_cnt(
2501 const struct cntr_entry *entry,
2502 void *context, int vl, int mode, u64 data)
2504 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2506 return dd->rcv_err_status_cnt[22];
2509 static u64 access_rx_rbuf_csr_q_head_buf_num_parity_err_cnt(
2510 const struct cntr_entry *entry,
2511 void *context, int vl, int mode, u64 data)
2513 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2515 return dd->rcv_err_status_cnt[21];
2518 static u64 access_rx_rbuf_block_list_read_cor_err_cnt(
2519 const struct cntr_entry *entry,
2520 void *context, int vl, int mode, u64 data)
2522 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2524 return dd->rcv_err_status_cnt[20];
2527 static u64 access_rx_rbuf_block_list_read_unc_err_cnt(
2528 const struct cntr_entry *entry,
2529 void *context, int vl, int mode, u64 data)
2531 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2533 return dd->rcv_err_status_cnt[19];
2536 static u64 access_rx_rbuf_lookup_des_cor_err_cnt(const struct cntr_entry *entry,
2537 void *context, int vl,
2540 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2542 return dd->rcv_err_status_cnt[18];
2545 static u64 access_rx_rbuf_lookup_des_unc_err_cnt(const struct cntr_entry *entry,
2546 void *context, int vl,
2549 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2551 return dd->rcv_err_status_cnt[17];
2554 static u64 access_rx_rbuf_lookup_des_reg_unc_cor_err_cnt(
2555 const struct cntr_entry *entry,
2556 void *context, int vl, int mode, u64 data)
2558 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2560 return dd->rcv_err_status_cnt[16];
2563 static u64 access_rx_rbuf_lookup_des_reg_unc_err_cnt(
2564 const struct cntr_entry *entry,
2565 void *context, int vl, int mode, u64 data)
2567 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2569 return dd->rcv_err_status_cnt[15];
2572 static u64 access_rx_rbuf_free_list_cor_err_cnt(const struct cntr_entry *entry,
2573 void *context, int vl,
2576 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2578 return dd->rcv_err_status_cnt[14];
2581 static u64 access_rx_rbuf_free_list_unc_err_cnt(const struct cntr_entry *entry,
2582 void *context, int vl,
2585 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2587 return dd->rcv_err_status_cnt[13];
2590 static u64 access_rx_rcv_fsm_encoding_err_cnt(const struct cntr_entry *entry,
2591 void *context, int vl, int mode,
2594 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2596 return dd->rcv_err_status_cnt[12];
2599 static u64 access_rx_dma_flag_cor_err_cnt(const struct cntr_entry *entry,
2600 void *context, int vl, int mode,
2603 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2605 return dd->rcv_err_status_cnt[11];
2608 static u64 access_rx_dma_flag_unc_err_cnt(const struct cntr_entry *entry,
2609 void *context, int vl, int mode,
2612 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2614 return dd->rcv_err_status_cnt[10];
2617 static u64 access_rx_dc_sop_eop_parity_err_cnt(const struct cntr_entry *entry,
2618 void *context, int vl, int mode,
2621 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2623 return dd->rcv_err_status_cnt[9];
2626 static u64 access_rx_rcv_csr_parity_err_cnt(const struct cntr_entry *entry,
2627 void *context, int vl, int mode,
2630 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2632 return dd->rcv_err_status_cnt[8];
2635 static u64 access_rx_rcv_qp_map_table_cor_err_cnt(
2636 const struct cntr_entry *entry,
2637 void *context, int vl, int mode, u64 data)
2639 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2641 return dd->rcv_err_status_cnt[7];
2644 static u64 access_rx_rcv_qp_map_table_unc_err_cnt(
2645 const struct cntr_entry *entry,
2646 void *context, int vl, int mode, u64 data)
2648 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2650 return dd->rcv_err_status_cnt[6];
2653 static u64 access_rx_rcv_data_cor_err_cnt(const struct cntr_entry *entry,
2654 void *context, int vl, int mode,
2657 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2659 return dd->rcv_err_status_cnt[5];
2662 static u64 access_rx_rcv_data_unc_err_cnt(const struct cntr_entry *entry,
2663 void *context, int vl, int mode,
2666 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2668 return dd->rcv_err_status_cnt[4];
2671 static u64 access_rx_rcv_hdr_cor_err_cnt(const struct cntr_entry *entry,
2672 void *context, int vl, int mode,
2675 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2677 return dd->rcv_err_status_cnt[3];
2680 static u64 access_rx_rcv_hdr_unc_err_cnt(const struct cntr_entry *entry,
2681 void *context, int vl, int mode,
2684 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2686 return dd->rcv_err_status_cnt[2];
2689 static u64 access_rx_dc_intf_parity_err_cnt(const struct cntr_entry *entry,
2690 void *context, int vl, int mode,
2693 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2695 return dd->rcv_err_status_cnt[1];
2698 static u64 access_rx_dma_csr_cor_err_cnt(const struct cntr_entry *entry,
2699 void *context, int vl, int mode,
2702 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2704 return dd->rcv_err_status_cnt[0];
2708 * Software counters corresponding to each of the
2709 * error status bits within SendPioErrStatus
2711 static u64 access_pio_pec_sop_head_parity_err_cnt(
2712 const struct cntr_entry *entry,
2713 void *context, int vl, int mode, u64 data)
2715 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2717 return dd->send_pio_err_status_cnt[35];
2720 static u64 access_pio_pcc_sop_head_parity_err_cnt(
2721 const struct cntr_entry *entry,
2722 void *context, int vl, int mode, u64 data)
2724 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2726 return dd->send_pio_err_status_cnt[34];
2729 static u64 access_pio_last_returned_cnt_parity_err_cnt(
2730 const struct cntr_entry *entry,
2731 void *context, int vl, int mode, u64 data)
2733 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2735 return dd->send_pio_err_status_cnt[33];
2738 static u64 access_pio_current_free_cnt_parity_err_cnt(
2739 const struct cntr_entry *entry,
2740 void *context, int vl, int mode, u64 data)
2742 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2744 return dd->send_pio_err_status_cnt[32];
2747 static u64 access_pio_reserved_31_err_cnt(const struct cntr_entry *entry,
2748 void *context, int vl, int mode,
2751 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2753 return dd->send_pio_err_status_cnt[31];
2756 static u64 access_pio_reserved_30_err_cnt(const struct cntr_entry *entry,
2757 void *context, int vl, int mode,
2760 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2762 return dd->send_pio_err_status_cnt[30];
2765 static u64 access_pio_ppmc_sop_len_err_cnt(const struct cntr_entry *entry,
2766 void *context, int vl, int mode,
2769 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2771 return dd->send_pio_err_status_cnt[29];
2774 static u64 access_pio_ppmc_bqc_mem_parity_err_cnt(
2775 const struct cntr_entry *entry,
2776 void *context, int vl, int mode, u64 data)
2778 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2780 return dd->send_pio_err_status_cnt[28];
2783 static u64 access_pio_vl_fifo_parity_err_cnt(const struct cntr_entry *entry,
2784 void *context, int vl, int mode,
2787 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2789 return dd->send_pio_err_status_cnt[27];
2792 static u64 access_pio_vlf_sop_parity_err_cnt(const struct cntr_entry *entry,
2793 void *context, int vl, int mode,
2796 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2798 return dd->send_pio_err_status_cnt[26];
2801 static u64 access_pio_vlf_v1_len_parity_err_cnt(const struct cntr_entry *entry,
2802 void *context, int vl,
2805 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2807 return dd->send_pio_err_status_cnt[25];
2810 static u64 access_pio_block_qw_count_parity_err_cnt(
2811 const struct cntr_entry *entry,
2812 void *context, int vl, int mode, u64 data)
2814 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2816 return dd->send_pio_err_status_cnt[24];
2819 static u64 access_pio_write_qw_valid_parity_err_cnt(
2820 const struct cntr_entry *entry,
2821 void *context, int vl, int mode, u64 data)
2823 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2825 return dd->send_pio_err_status_cnt[23];
2828 static u64 access_pio_state_machine_err_cnt(const struct cntr_entry *entry,
2829 void *context, int vl, int mode,
2832 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2834 return dd->send_pio_err_status_cnt[22];
2837 static u64 access_pio_write_data_parity_err_cnt(const struct cntr_entry *entry,
2838 void *context, int vl,
2841 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2843 return dd->send_pio_err_status_cnt[21];
2846 static u64 access_pio_host_addr_mem_cor_err_cnt(const struct cntr_entry *entry,
2847 void *context, int vl,
2850 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2852 return dd->send_pio_err_status_cnt[20];
2855 static u64 access_pio_host_addr_mem_unc_err_cnt(const struct cntr_entry *entry,
2856 void *context, int vl,
2859 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2861 return dd->send_pio_err_status_cnt[19];
2864 static u64 access_pio_pkt_evict_sm_or_arb_sm_err_cnt(
2865 const struct cntr_entry *entry,
2866 void *context, int vl, int mode, u64 data)
2868 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2870 return dd->send_pio_err_status_cnt[18];
2873 static u64 access_pio_init_sm_in_err_cnt(const struct cntr_entry *entry,
2874 void *context, int vl, int mode,
2877 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2879 return dd->send_pio_err_status_cnt[17];
2882 static u64 access_pio_ppmc_pbl_fifo_err_cnt(const struct cntr_entry *entry,
2883 void *context, int vl, int mode,
2886 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2888 return dd->send_pio_err_status_cnt[16];
2891 static u64 access_pio_credit_ret_fifo_parity_err_cnt(
2892 const struct cntr_entry *entry,
2893 void *context, int vl, int mode, u64 data)
2895 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2897 return dd->send_pio_err_status_cnt[15];
2900 static u64 access_pio_v1_len_mem_bank1_cor_err_cnt(
2901 const struct cntr_entry *entry,
2902 void *context, int vl, int mode, u64 data)
2904 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2906 return dd->send_pio_err_status_cnt[14];
2909 static u64 access_pio_v1_len_mem_bank0_cor_err_cnt(
2910 const struct cntr_entry *entry,
2911 void *context, int vl, int mode, u64 data)
2913 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2915 return dd->send_pio_err_status_cnt[13];
2918 static u64 access_pio_v1_len_mem_bank1_unc_err_cnt(
2919 const struct cntr_entry *entry,
2920 void *context, int vl, int mode, u64 data)
2922 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2924 return dd->send_pio_err_status_cnt[12];
2927 static u64 access_pio_v1_len_mem_bank0_unc_err_cnt(
2928 const struct cntr_entry *entry,
2929 void *context, int vl, int mode, u64 data)
2931 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2933 return dd->send_pio_err_status_cnt[11];
2936 static u64 access_pio_sm_pkt_reset_parity_err_cnt(
2937 const struct cntr_entry *entry,
2938 void *context, int vl, int mode, u64 data)
2940 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2942 return dd->send_pio_err_status_cnt[10];
2945 static u64 access_pio_pkt_evict_fifo_parity_err_cnt(
2946 const struct cntr_entry *entry,
2947 void *context, int vl, int mode, u64 data)
2949 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2951 return dd->send_pio_err_status_cnt[9];
2954 static u64 access_pio_sbrdctrl_crrel_fifo_parity_err_cnt(
2955 const struct cntr_entry *entry,
2956 void *context, int vl, int mode, u64 data)
2958 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2960 return dd->send_pio_err_status_cnt[8];
2963 static u64 access_pio_sbrdctl_crrel_parity_err_cnt(
2964 const struct cntr_entry *entry,
2965 void *context, int vl, int mode, u64 data)
2967 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2969 return dd->send_pio_err_status_cnt[7];
2972 static u64 access_pio_pec_fifo_parity_err_cnt(const struct cntr_entry *entry,
2973 void *context, int vl, int mode,
2976 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2978 return dd->send_pio_err_status_cnt[6];
2981 static u64 access_pio_pcc_fifo_parity_err_cnt(const struct cntr_entry *entry,
2982 void *context, int vl, int mode,
2985 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2987 return dd->send_pio_err_status_cnt[5];
2990 static u64 access_pio_sb_mem_fifo1_err_cnt(const struct cntr_entry *entry,
2991 void *context, int vl, int mode,
2994 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2996 return dd->send_pio_err_status_cnt[4];
2999 static u64 access_pio_sb_mem_fifo0_err_cnt(const struct cntr_entry *entry,
3000 void *context, int vl, int mode,
3003 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3005 return dd->send_pio_err_status_cnt[3];
3008 static u64 access_pio_csr_parity_err_cnt(const struct cntr_entry *entry,
3009 void *context, int vl, int mode,
3012 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3014 return dd->send_pio_err_status_cnt[2];
3017 static u64 access_pio_write_addr_parity_err_cnt(const struct cntr_entry *entry,
3018 void *context, int vl,
3021 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3023 return dd->send_pio_err_status_cnt[1];
3026 static u64 access_pio_write_bad_ctxt_err_cnt(const struct cntr_entry *entry,
3027 void *context, int vl, int mode,
3030 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3032 return dd->send_pio_err_status_cnt[0];
3036 * Software counters corresponding to each of the
3037 * error status bits within SendDmaErrStatus
3039 static u64 access_sdma_pcie_req_tracking_cor_err_cnt(
3040 const struct cntr_entry *entry,
3041 void *context, int vl, int mode, u64 data)
3043 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3045 return dd->send_dma_err_status_cnt[3];
3048 static u64 access_sdma_pcie_req_tracking_unc_err_cnt(
3049 const struct cntr_entry *entry,
3050 void *context, int vl, int mode, u64 data)
3052 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3054 return dd->send_dma_err_status_cnt[2];
3057 static u64 access_sdma_csr_parity_err_cnt(const struct cntr_entry *entry,
3058 void *context, int vl, int mode,
3061 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3063 return dd->send_dma_err_status_cnt[1];
3066 static u64 access_sdma_rpy_tag_err_cnt(const struct cntr_entry *entry,
3067 void *context, int vl, int mode,
3070 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3072 return dd->send_dma_err_status_cnt[0];
3076 * Software counters corresponding to each of the
3077 * error status bits within SendEgressErrStatus
3079 static u64 access_tx_read_pio_memory_csr_unc_err_cnt(
3080 const struct cntr_entry *entry,
3081 void *context, int vl, int mode, u64 data)
3083 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3085 return dd->send_egress_err_status_cnt[63];
3088 static u64 access_tx_read_sdma_memory_csr_err_cnt(
3089 const struct cntr_entry *entry,
3090 void *context, int vl, int mode, u64 data)
3092 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3094 return dd->send_egress_err_status_cnt[62];
3097 static u64 access_tx_egress_fifo_cor_err_cnt(const struct cntr_entry *entry,
3098 void *context, int vl, int mode,
3101 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3103 return dd->send_egress_err_status_cnt[61];
3106 static u64 access_tx_read_pio_memory_cor_err_cnt(const struct cntr_entry *entry,
3107 void *context, int vl,
3110 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3112 return dd->send_egress_err_status_cnt[60];
3115 static u64 access_tx_read_sdma_memory_cor_err_cnt(
3116 const struct cntr_entry *entry,
3117 void *context, int vl, int mode, u64 data)
3119 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3121 return dd->send_egress_err_status_cnt[59];
3124 static u64 access_tx_sb_hdr_cor_err_cnt(const struct cntr_entry *entry,
3125 void *context, int vl, int mode,
3128 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3130 return dd->send_egress_err_status_cnt[58];
3133 static u64 access_tx_credit_overrun_err_cnt(const struct cntr_entry *entry,
3134 void *context, int vl, int mode,
3137 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3139 return dd->send_egress_err_status_cnt[57];
3142 static u64 access_tx_launch_fifo8_cor_err_cnt(const struct cntr_entry *entry,
3143 void *context, int vl, int mode,
3146 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3148 return dd->send_egress_err_status_cnt[56];
3151 static u64 access_tx_launch_fifo7_cor_err_cnt(const struct cntr_entry *entry,
3152 void *context, int vl, int mode,
3155 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3157 return dd->send_egress_err_status_cnt[55];
3160 static u64 access_tx_launch_fifo6_cor_err_cnt(const struct cntr_entry *entry,
3161 void *context, int vl, int mode,
3164 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3166 return dd->send_egress_err_status_cnt[54];
3169 static u64 access_tx_launch_fifo5_cor_err_cnt(const struct cntr_entry *entry,
3170 void *context, int vl, int mode,
3173 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3175 return dd->send_egress_err_status_cnt[53];
3178 static u64 access_tx_launch_fifo4_cor_err_cnt(const struct cntr_entry *entry,
3179 void *context, int vl, int mode,
3182 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3184 return dd->send_egress_err_status_cnt[52];
3187 static u64 access_tx_launch_fifo3_cor_err_cnt(const struct cntr_entry *entry,
3188 void *context, int vl, int mode,
3191 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3193 return dd->send_egress_err_status_cnt[51];
3196 static u64 access_tx_launch_fifo2_cor_err_cnt(const struct cntr_entry *entry,
3197 void *context, int vl, int mode,
3200 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3202 return dd->send_egress_err_status_cnt[50];
3205 static u64 access_tx_launch_fifo1_cor_err_cnt(const struct cntr_entry *entry,
3206 void *context, int vl, int mode,
3209 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3211 return dd->send_egress_err_status_cnt[49];
3214 static u64 access_tx_launch_fifo0_cor_err_cnt(const struct cntr_entry *entry,
3215 void *context, int vl, int mode,
3218 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3220 return dd->send_egress_err_status_cnt[48];
3223 static u64 access_tx_credit_return_vl_err_cnt(const struct cntr_entry *entry,
3224 void *context, int vl, int mode,
3227 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3229 return dd->send_egress_err_status_cnt[47];
3232 static u64 access_tx_hcrc_insertion_err_cnt(const struct cntr_entry *entry,
3233 void *context, int vl, int mode,
3236 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3238 return dd->send_egress_err_status_cnt[46];
3241 static u64 access_tx_egress_fifo_unc_err_cnt(const struct cntr_entry *entry,
3242 void *context, int vl, int mode,
3245 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3247 return dd->send_egress_err_status_cnt[45];
3250 static u64 access_tx_read_pio_memory_unc_err_cnt(const struct cntr_entry *entry,
3251 void *context, int vl,
3254 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3256 return dd->send_egress_err_status_cnt[44];
3259 static u64 access_tx_read_sdma_memory_unc_err_cnt(
3260 const struct cntr_entry *entry,
3261 void *context, int vl, int mode, u64 data)
3263 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3265 return dd->send_egress_err_status_cnt[43];
3268 static u64 access_tx_sb_hdr_unc_err_cnt(const struct cntr_entry *entry,
3269 void *context, int vl, int mode,
3272 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3274 return dd->send_egress_err_status_cnt[42];
3277 static u64 access_tx_credit_return_partiy_err_cnt(
3278 const struct cntr_entry *entry,
3279 void *context, int vl, int mode, u64 data)
3281 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3283 return dd->send_egress_err_status_cnt[41];
3286 static u64 access_tx_launch_fifo8_unc_or_parity_err_cnt(
3287 const struct cntr_entry *entry,
3288 void *context, int vl, int mode, u64 data)
3290 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3292 return dd->send_egress_err_status_cnt[40];
3295 static u64 access_tx_launch_fifo7_unc_or_parity_err_cnt(
3296 const struct cntr_entry *entry,
3297 void *context, int vl, int mode, u64 data)
3299 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3301 return dd->send_egress_err_status_cnt[39];
3304 static u64 access_tx_launch_fifo6_unc_or_parity_err_cnt(
3305 const struct cntr_entry *entry,
3306 void *context, int vl, int mode, u64 data)
3308 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3310 return dd->send_egress_err_status_cnt[38];
3313 static u64 access_tx_launch_fifo5_unc_or_parity_err_cnt(
3314 const struct cntr_entry *entry,
3315 void *context, int vl, int mode, u64 data)
3317 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3319 return dd->send_egress_err_status_cnt[37];
3322 static u64 access_tx_launch_fifo4_unc_or_parity_err_cnt(
3323 const struct cntr_entry *entry,
3324 void *context, int vl, int mode, u64 data)
3326 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3328 return dd->send_egress_err_status_cnt[36];
3331 static u64 access_tx_launch_fifo3_unc_or_parity_err_cnt(
3332 const struct cntr_entry *entry,
3333 void *context, int vl, int mode, u64 data)
3335 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3337 return dd->send_egress_err_status_cnt[35];
3340 static u64 access_tx_launch_fifo2_unc_or_parity_err_cnt(
3341 const struct cntr_entry *entry,
3342 void *context, int vl, int mode, u64 data)
3344 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3346 return dd->send_egress_err_status_cnt[34];
3349 static u64 access_tx_launch_fifo1_unc_or_parity_err_cnt(
3350 const struct cntr_entry *entry,
3351 void *context, int vl, int mode, u64 data)
3353 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3355 return dd->send_egress_err_status_cnt[33];
3358 static u64 access_tx_launch_fifo0_unc_or_parity_err_cnt(
3359 const struct cntr_entry *entry,
3360 void *context, int vl, int mode, u64 data)
3362 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3364 return dd->send_egress_err_status_cnt[32];
3367 static u64 access_tx_sdma15_disallowed_packet_err_cnt(
3368 const struct cntr_entry *entry,
3369 void *context, int vl, int mode, u64 data)
3371 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3373 return dd->send_egress_err_status_cnt[31];
3376 static u64 access_tx_sdma14_disallowed_packet_err_cnt(
3377 const struct cntr_entry *entry,
3378 void *context, int vl, int mode, u64 data)
3380 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3382 return dd->send_egress_err_status_cnt[30];
3385 static u64 access_tx_sdma13_disallowed_packet_err_cnt(
3386 const struct cntr_entry *entry,
3387 void *context, int vl, int mode, u64 data)
3389 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3391 return dd->send_egress_err_status_cnt[29];
3394 static u64 access_tx_sdma12_disallowed_packet_err_cnt(
3395 const struct cntr_entry *entry,
3396 void *context, int vl, int mode, u64 data)
3398 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3400 return dd->send_egress_err_status_cnt[28];
3403 static u64 access_tx_sdma11_disallowed_packet_err_cnt(
3404 const struct cntr_entry *entry,
3405 void *context, int vl, int mode, u64 data)
3407 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3409 return dd->send_egress_err_status_cnt[27];
3412 static u64 access_tx_sdma10_disallowed_packet_err_cnt(
3413 const struct cntr_entry *entry,
3414 void *context, int vl, int mode, u64 data)
3416 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3418 return dd->send_egress_err_status_cnt[26];
3421 static u64 access_tx_sdma9_disallowed_packet_err_cnt(
3422 const struct cntr_entry *entry,
3423 void *context, int vl, int mode, u64 data)
3425 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3427 return dd->send_egress_err_status_cnt[25];
3430 static u64 access_tx_sdma8_disallowed_packet_err_cnt(
3431 const struct cntr_entry *entry,
3432 void *context, int vl, int mode, u64 data)
3434 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3436 return dd->send_egress_err_status_cnt[24];
3439 static u64 access_tx_sdma7_disallowed_packet_err_cnt(
3440 const struct cntr_entry *entry,
3441 void *context, int vl, int mode, u64 data)
3443 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3445 return dd->send_egress_err_status_cnt[23];
3448 static u64 access_tx_sdma6_disallowed_packet_err_cnt(
3449 const struct cntr_entry *entry,
3450 void *context, int vl, int mode, u64 data)
3452 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3454 return dd->send_egress_err_status_cnt[22];
3457 static u64 access_tx_sdma5_disallowed_packet_err_cnt(
3458 const struct cntr_entry *entry,
3459 void *context, int vl, int mode, u64 data)
3461 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3463 return dd->send_egress_err_status_cnt[21];
3466 static u64 access_tx_sdma4_disallowed_packet_err_cnt(
3467 const struct cntr_entry *entry,
3468 void *context, int vl, int mode, u64 data)
3470 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3472 return dd->send_egress_err_status_cnt[20];
3475 static u64 access_tx_sdma3_disallowed_packet_err_cnt(
3476 const struct cntr_entry *entry,
3477 void *context, int vl, int mode, u64 data)
3479 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3481 return dd->send_egress_err_status_cnt[19];
3484 static u64 access_tx_sdma2_disallowed_packet_err_cnt(
3485 const struct cntr_entry *entry,
3486 void *context, int vl, int mode, u64 data)
3488 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3490 return dd->send_egress_err_status_cnt[18];
3493 static u64 access_tx_sdma1_disallowed_packet_err_cnt(
3494 const struct cntr_entry *entry,
3495 void *context, int vl, int mode, u64 data)
3497 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3499 return dd->send_egress_err_status_cnt[17];
3502 static u64 access_tx_sdma0_disallowed_packet_err_cnt(
3503 const struct cntr_entry *entry,
3504 void *context, int vl, int mode, u64 data)
3506 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3508 return dd->send_egress_err_status_cnt[16];
3511 static u64 access_tx_config_parity_err_cnt(const struct cntr_entry *entry,
3512 void *context, int vl, int mode,
3515 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3517 return dd->send_egress_err_status_cnt[15];
3520 static u64 access_tx_sbrd_ctl_csr_parity_err_cnt(const struct cntr_entry *entry,
3521 void *context, int vl,
3524 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3526 return dd->send_egress_err_status_cnt[14];
3529 static u64 access_tx_launch_csr_parity_err_cnt(const struct cntr_entry *entry,
3530 void *context, int vl, int mode,
3533 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3535 return dd->send_egress_err_status_cnt[13];
3538 static u64 access_tx_illegal_vl_err_cnt(const struct cntr_entry *entry,
3539 void *context, int vl, int mode,
3542 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3544 return dd->send_egress_err_status_cnt[12];
3547 static u64 access_tx_sbrd_ctl_state_machine_parity_err_cnt(
3548 const struct cntr_entry *entry,
3549 void *context, int vl, int mode, u64 data)
3551 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3553 return dd->send_egress_err_status_cnt[11];
3556 static u64 access_egress_reserved_10_err_cnt(const struct cntr_entry *entry,
3557 void *context, int vl, int mode,
3560 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3562 return dd->send_egress_err_status_cnt[10];
3565 static u64 access_egress_reserved_9_err_cnt(const struct cntr_entry *entry,
3566 void *context, int vl, int mode,
3569 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3571 return dd->send_egress_err_status_cnt[9];
3574 static u64 access_tx_sdma_launch_intf_parity_err_cnt(
3575 const struct cntr_entry *entry,
3576 void *context, int vl, int mode, u64 data)
3578 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3580 return dd->send_egress_err_status_cnt[8];
3583 static u64 access_tx_pio_launch_intf_parity_err_cnt(
3584 const struct cntr_entry *entry,
3585 void *context, int vl, int mode, u64 data)
3587 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3589 return dd->send_egress_err_status_cnt[7];
3592 static u64 access_egress_reserved_6_err_cnt(const struct cntr_entry *entry,
3593 void *context, int vl, int mode,
3596 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3598 return dd->send_egress_err_status_cnt[6];
3601 static u64 access_tx_incorrect_link_state_err_cnt(
3602 const struct cntr_entry *entry,
3603 void *context, int vl, int mode, u64 data)
3605 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3607 return dd->send_egress_err_status_cnt[5];
3610 static u64 access_tx_linkdown_err_cnt(const struct cntr_entry *entry,
3611 void *context, int vl, int mode,
3614 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3616 return dd->send_egress_err_status_cnt[4];
3619 static u64 access_tx_egress_fifi_underrun_or_parity_err_cnt(
3620 const struct cntr_entry *entry,
3621 void *context, int vl, int mode, u64 data)
3623 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3625 return dd->send_egress_err_status_cnt[3];
3628 static u64 access_egress_reserved_2_err_cnt(const struct cntr_entry *entry,
3629 void *context, int vl, int mode,
3632 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3634 return dd->send_egress_err_status_cnt[2];
3637 static u64 access_tx_pkt_integrity_mem_unc_err_cnt(
3638 const struct cntr_entry *entry,
3639 void *context, int vl, int mode, u64 data)
3641 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3643 return dd->send_egress_err_status_cnt[1];
3646 static u64 access_tx_pkt_integrity_mem_cor_err_cnt(
3647 const struct cntr_entry *entry,
3648 void *context, int vl, int mode, u64 data)
3650 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3652 return dd->send_egress_err_status_cnt[0];
3656 * Software counters corresponding to each of the
3657 * error status bits within SendErrStatus
3659 static u64 access_send_csr_write_bad_addr_err_cnt(
3660 const struct cntr_entry *entry,
3661 void *context, int vl, int mode, u64 data)
3663 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3665 return dd->send_err_status_cnt[2];
3668 static u64 access_send_csr_read_bad_addr_err_cnt(const struct cntr_entry *entry,
3669 void *context, int vl,
3672 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3674 return dd->send_err_status_cnt[1];
3677 static u64 access_send_csr_parity_cnt(const struct cntr_entry *entry,
3678 void *context, int vl, int mode,
3681 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3683 return dd->send_err_status_cnt[0];
3687 * Software counters corresponding to each of the
3688 * error status bits within SendCtxtErrStatus
3690 static u64 access_pio_write_out_of_bounds_err_cnt(
3691 const struct cntr_entry *entry,
3692 void *context, int vl, int mode, u64 data)
3694 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3696 return dd->sw_ctxt_err_status_cnt[4];
3699 static u64 access_pio_write_overflow_err_cnt(const struct cntr_entry *entry,
3700 void *context, int vl, int mode,
3703 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3705 return dd->sw_ctxt_err_status_cnt[3];
3708 static u64 access_pio_write_crosses_boundary_err_cnt(
3709 const struct cntr_entry *entry,
3710 void *context, int vl, int mode, u64 data)
3712 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3714 return dd->sw_ctxt_err_status_cnt[2];
3717 static u64 access_pio_disallowed_packet_err_cnt(const struct cntr_entry *entry,
3718 void *context, int vl,
3721 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3723 return dd->sw_ctxt_err_status_cnt[1];
3726 static u64 access_pio_inconsistent_sop_err_cnt(const struct cntr_entry *entry,
3727 void *context, int vl, int mode,
3730 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3732 return dd->sw_ctxt_err_status_cnt[0];
3736 * Software counters corresponding to each of the
3737 * error status bits within SendDmaEngErrStatus
3739 static u64 access_sdma_header_request_fifo_cor_err_cnt(
3740 const struct cntr_entry *entry,
3741 void *context, int vl, int mode, u64 data)
3743 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3745 return dd->sw_send_dma_eng_err_status_cnt[23];
3748 static u64 access_sdma_header_storage_cor_err_cnt(
3749 const struct cntr_entry *entry,
3750 void *context, int vl, int mode, u64 data)
3752 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3754 return dd->sw_send_dma_eng_err_status_cnt[22];
3757 static u64 access_sdma_packet_tracking_cor_err_cnt(
3758 const struct cntr_entry *entry,
3759 void *context, int vl, int mode, u64 data)
3761 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3763 return dd->sw_send_dma_eng_err_status_cnt[21];
3766 static u64 access_sdma_assembly_cor_err_cnt(const struct cntr_entry *entry,
3767 void *context, int vl, int mode,
3770 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3772 return dd->sw_send_dma_eng_err_status_cnt[20];
3775 static u64 access_sdma_desc_table_cor_err_cnt(const struct cntr_entry *entry,
3776 void *context, int vl, int mode,
3779 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3781 return dd->sw_send_dma_eng_err_status_cnt[19];
3784 static u64 access_sdma_header_request_fifo_unc_err_cnt(
3785 const struct cntr_entry *entry,
3786 void *context, int vl, int mode, u64 data)
3788 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3790 return dd->sw_send_dma_eng_err_status_cnt[18];
3793 static u64 access_sdma_header_storage_unc_err_cnt(
3794 const struct cntr_entry *entry,
3795 void *context, int vl, int mode, u64 data)
3797 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3799 return dd->sw_send_dma_eng_err_status_cnt[17];
3802 static u64 access_sdma_packet_tracking_unc_err_cnt(
3803 const struct cntr_entry *entry,
3804 void *context, int vl, int mode, u64 data)
3806 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3808 return dd->sw_send_dma_eng_err_status_cnt[16];
3811 static u64 access_sdma_assembly_unc_err_cnt(const struct cntr_entry *entry,
3812 void *context, int vl, int mode,
3815 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3817 return dd->sw_send_dma_eng_err_status_cnt[15];
3820 static u64 access_sdma_desc_table_unc_err_cnt(const struct cntr_entry *entry,
3821 void *context, int vl, int mode,
3824 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3826 return dd->sw_send_dma_eng_err_status_cnt[14];
3829 static u64 access_sdma_timeout_err_cnt(const struct cntr_entry *entry,
3830 void *context, int vl, int mode,
3833 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3835 return dd->sw_send_dma_eng_err_status_cnt[13];
3838 static u64 access_sdma_header_length_err_cnt(const struct cntr_entry *entry,
3839 void *context, int vl, int mode,
3842 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3844 return dd->sw_send_dma_eng_err_status_cnt[12];
3847 static u64 access_sdma_header_address_err_cnt(const struct cntr_entry *entry,
3848 void *context, int vl, int mode,
3851 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3853 return dd->sw_send_dma_eng_err_status_cnt[11];
3856 static u64 access_sdma_header_select_err_cnt(const struct cntr_entry *entry,
3857 void *context, int vl, int mode,
3860 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3862 return dd->sw_send_dma_eng_err_status_cnt[10];
3865 static u64 access_sdma_reserved_9_err_cnt(const struct cntr_entry *entry,
3866 void *context, int vl, int mode,
3869 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3871 return dd->sw_send_dma_eng_err_status_cnt[9];
3874 static u64 access_sdma_packet_desc_overflow_err_cnt(
3875 const struct cntr_entry *entry,
3876 void *context, int vl, int mode, u64 data)
3878 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3880 return dd->sw_send_dma_eng_err_status_cnt[8];
3883 static u64 access_sdma_length_mismatch_err_cnt(const struct cntr_entry *entry,
3884 void *context, int vl,
3887 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3889 return dd->sw_send_dma_eng_err_status_cnt[7];
3892 static u64 access_sdma_halt_err_cnt(const struct cntr_entry *entry,
3893 void *context, int vl, int mode, u64 data)
3895 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3897 return dd->sw_send_dma_eng_err_status_cnt[6];
3900 static u64 access_sdma_mem_read_err_cnt(const struct cntr_entry *entry,
3901 void *context, int vl, int mode,
3904 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3906 return dd->sw_send_dma_eng_err_status_cnt[5];
3909 static u64 access_sdma_first_desc_err_cnt(const struct cntr_entry *entry,
3910 void *context, int vl, int mode,
3913 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3915 return dd->sw_send_dma_eng_err_status_cnt[4];
3918 static u64 access_sdma_tail_out_of_bounds_err_cnt(
3919 const struct cntr_entry *entry,
3920 void *context, int vl, int mode, u64 data)
3922 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3924 return dd->sw_send_dma_eng_err_status_cnt[3];
3927 static u64 access_sdma_too_long_err_cnt(const struct cntr_entry *entry,
3928 void *context, int vl, int mode,
3931 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3933 return dd->sw_send_dma_eng_err_status_cnt[2];
3936 static u64 access_sdma_gen_mismatch_err_cnt(const struct cntr_entry *entry,
3937 void *context, int vl, int mode,
3940 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3942 return dd->sw_send_dma_eng_err_status_cnt[1];
3945 static u64 access_sdma_wrong_dw_err_cnt(const struct cntr_entry *entry,
3946 void *context, int vl, int mode,
3949 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3951 return dd->sw_send_dma_eng_err_status_cnt[0];
3954 #define def_access_sw_cpu(cntr) \
3955 static u64 access_sw_cpu_##cntr(const struct cntr_entry *entry, \
3956 void *context, int vl, int mode, u64 data) \
3958 struct hfi1_pportdata *ppd = (struct hfi1_pportdata *)context; \
3959 return read_write_cpu(ppd->dd, &ppd->ibport_data.rvp.z_ ##cntr, \
3960 ppd->ibport_data.rvp.cntr, vl, \
3964 def_access_sw_cpu(rc_acks);
3965 def_access_sw_cpu(rc_qacks);
3966 def_access_sw_cpu(rc_delayed_comp);
3968 #define def_access_ibp_counter(cntr) \
3969 static u64 access_ibp_##cntr(const struct cntr_entry *entry, \
3970 void *context, int vl, int mode, u64 data) \
3972 struct hfi1_pportdata *ppd = (struct hfi1_pportdata *)context; \
3974 if (vl != CNTR_INVALID_VL) \
3977 return read_write_sw(ppd->dd, &ppd->ibport_data.rvp.n_ ##cntr, \
3981 def_access_ibp_counter(loop_pkts);
3982 def_access_ibp_counter(rc_resends);
3983 def_access_ibp_counter(rnr_naks);
3984 def_access_ibp_counter(other_naks);
3985 def_access_ibp_counter(rc_timeouts);
3986 def_access_ibp_counter(pkt_drops);
3987 def_access_ibp_counter(dmawait);
3988 def_access_ibp_counter(rc_seqnak);
3989 def_access_ibp_counter(rc_dupreq);
3990 def_access_ibp_counter(rdma_seq);
3991 def_access_ibp_counter(unaligned);
3992 def_access_ibp_counter(seq_naks);
3994 static struct cntr_entry dev_cntrs[DEV_CNTR_LAST] = {
3995 [C_RCV_OVF] = RXE32_DEV_CNTR_ELEM(RcvOverflow, RCV_BUF_OVFL_CNT, CNTR_SYNTH),
3996 [C_RX_TID_FULL] = RXE32_DEV_CNTR_ELEM(RxTIDFullEr, RCV_TID_FULL_ERR_CNT,
3998 [C_RX_TID_INVALID] = RXE32_DEV_CNTR_ELEM(RxTIDInvalid, RCV_TID_VALID_ERR_CNT,
4000 [C_RX_TID_FLGMS] = RXE32_DEV_CNTR_ELEM(RxTidFLGMs,
4001 RCV_TID_FLOW_GEN_MISMATCH_CNT,
4003 [C_RX_CTX_EGRS] = RXE32_DEV_CNTR_ELEM(RxCtxEgrS, RCV_CONTEXT_EGR_STALL,
4005 [C_RCV_TID_FLSMS] = RXE32_DEV_CNTR_ELEM(RxTidFLSMs,
4006 RCV_TID_FLOW_SEQ_MISMATCH_CNT, CNTR_NORMAL),
4007 [C_CCE_PCI_CR_ST] = CCE_PERF_DEV_CNTR_ELEM(CcePciCrSt,
4008 CCE_PCIE_POSTED_CRDT_STALL_CNT, CNTR_NORMAL),
4009 [C_CCE_PCI_TR_ST] = CCE_PERF_DEV_CNTR_ELEM(CcePciTrSt, CCE_PCIE_TRGT_STALL_CNT,
4011 [C_CCE_PIO_WR_ST] = CCE_PERF_DEV_CNTR_ELEM(CcePioWrSt, CCE_PIO_WR_STALL_CNT,
4013 [C_CCE_ERR_INT] = CCE_INT_DEV_CNTR_ELEM(CceErrInt, CCE_ERR_INT_CNT,
4015 [C_CCE_SDMA_INT] = CCE_INT_DEV_CNTR_ELEM(CceSdmaInt, CCE_SDMA_INT_CNT,
4017 [C_CCE_MISC_INT] = CCE_INT_DEV_CNTR_ELEM(CceMiscInt, CCE_MISC_INT_CNT,
4019 [C_CCE_RCV_AV_INT] = CCE_INT_DEV_CNTR_ELEM(CceRcvAvInt, CCE_RCV_AVAIL_INT_CNT,
4021 [C_CCE_RCV_URG_INT] = CCE_INT_DEV_CNTR_ELEM(CceRcvUrgInt,
4022 CCE_RCV_URGENT_INT_CNT, CNTR_NORMAL),
4023 [C_CCE_SEND_CR_INT] = CCE_INT_DEV_CNTR_ELEM(CceSndCrInt,
4024 CCE_SEND_CREDIT_INT_CNT, CNTR_NORMAL),
4025 [C_DC_UNC_ERR] = DC_PERF_CNTR(DcUnctblErr, DCC_ERR_UNCORRECTABLE_CNT,
4027 [C_DC_RCV_ERR] = DC_PERF_CNTR(DcRecvErr, DCC_ERR_PORTRCV_ERR_CNT, CNTR_SYNTH),
4028 [C_DC_FM_CFG_ERR] = DC_PERF_CNTR(DcFmCfgErr, DCC_ERR_FMCONFIG_ERR_CNT,
4030 [C_DC_RMT_PHY_ERR] = DC_PERF_CNTR(DcRmtPhyErr, DCC_ERR_RCVREMOTE_PHY_ERR_CNT,
4032 [C_DC_DROPPED_PKT] = DC_PERF_CNTR(DcDroppedPkt, DCC_ERR_DROPPED_PKT_CNT,
4034 [C_DC_MC_XMIT_PKTS] = DC_PERF_CNTR(DcMcXmitPkts,
4035 DCC_PRF_PORT_XMIT_MULTICAST_CNT, CNTR_SYNTH),
4036 [C_DC_MC_RCV_PKTS] = DC_PERF_CNTR(DcMcRcvPkts,
4037 DCC_PRF_PORT_RCV_MULTICAST_PKT_CNT,
4039 [C_DC_XMIT_CERR] = DC_PERF_CNTR(DcXmitCorr,
4040 DCC_PRF_PORT_XMIT_CORRECTABLE_CNT, CNTR_SYNTH),
4041 [C_DC_RCV_CERR] = DC_PERF_CNTR(DcRcvCorrCnt, DCC_PRF_PORT_RCV_CORRECTABLE_CNT,
4043 [C_DC_RCV_FCC] = DC_PERF_CNTR(DcRxFCntl, DCC_PRF_RX_FLOW_CRTL_CNT,
4045 [C_DC_XMIT_FCC] = DC_PERF_CNTR(DcXmitFCntl, DCC_PRF_TX_FLOW_CRTL_CNT,
4047 [C_DC_XMIT_FLITS] = DC_PERF_CNTR(DcXmitFlits, DCC_PRF_PORT_XMIT_DATA_CNT,
4049 [C_DC_RCV_FLITS] = DC_PERF_CNTR(DcRcvFlits, DCC_PRF_PORT_RCV_DATA_CNT,
4051 [C_DC_XMIT_PKTS] = DC_PERF_CNTR(DcXmitPkts, DCC_PRF_PORT_XMIT_PKTS_CNT,
4053 [C_DC_RCV_PKTS] = DC_PERF_CNTR(DcRcvPkts, DCC_PRF_PORT_RCV_PKTS_CNT,
4055 [C_DC_RX_FLIT_VL] = DC_PERF_CNTR(DcRxFlitVl, DCC_PRF_PORT_VL_RCV_DATA_CNT,
4056 CNTR_SYNTH | CNTR_VL),
4057 [C_DC_RX_PKT_VL] = DC_PERF_CNTR(DcRxPktVl, DCC_PRF_PORT_VL_RCV_PKTS_CNT,
4058 CNTR_SYNTH | CNTR_VL),
4059 [C_DC_RCV_FCN] = DC_PERF_CNTR(DcRcvFcn, DCC_PRF_PORT_RCV_FECN_CNT, CNTR_SYNTH),
4060 [C_DC_RCV_FCN_VL] = DC_PERF_CNTR(DcRcvFcnVl, DCC_PRF_PORT_VL_RCV_FECN_CNT,
4061 CNTR_SYNTH | CNTR_VL),
4062 [C_DC_RCV_BCN] = DC_PERF_CNTR(DcRcvBcn, DCC_PRF_PORT_RCV_BECN_CNT, CNTR_SYNTH),
4063 [C_DC_RCV_BCN_VL] = DC_PERF_CNTR(DcRcvBcnVl, DCC_PRF_PORT_VL_RCV_BECN_CNT,
4064 CNTR_SYNTH | CNTR_VL),
4065 [C_DC_RCV_BBL] = DC_PERF_CNTR(DcRcvBbl, DCC_PRF_PORT_RCV_BUBBLE_CNT,
4067 [C_DC_RCV_BBL_VL] = DC_PERF_CNTR(DcRcvBblVl, DCC_PRF_PORT_VL_RCV_BUBBLE_CNT,
4068 CNTR_SYNTH | CNTR_VL),
4069 [C_DC_MARK_FECN] = DC_PERF_CNTR(DcMarkFcn, DCC_PRF_PORT_MARK_FECN_CNT,
4071 [C_DC_MARK_FECN_VL] = DC_PERF_CNTR(DcMarkFcnVl, DCC_PRF_PORT_VL_MARK_FECN_CNT,
4072 CNTR_SYNTH | CNTR_VL),
4074 DC_PERF_CNTR_LCB(DcTotCrc, DC_LCB_ERR_INFO_TOTAL_CRC_ERR,
4076 [C_DC_CRC_LN0] = DC_PERF_CNTR_LCB(DcCrcLn0, DC_LCB_ERR_INFO_CRC_ERR_LN0,
4078 [C_DC_CRC_LN1] = DC_PERF_CNTR_LCB(DcCrcLn1, DC_LCB_ERR_INFO_CRC_ERR_LN1,
4080 [C_DC_CRC_LN2] = DC_PERF_CNTR_LCB(DcCrcLn2, DC_LCB_ERR_INFO_CRC_ERR_LN2,
4082 [C_DC_CRC_LN3] = DC_PERF_CNTR_LCB(DcCrcLn3, DC_LCB_ERR_INFO_CRC_ERR_LN3,
4084 [C_DC_CRC_MULT_LN] =
4085 DC_PERF_CNTR_LCB(DcMultLn, DC_LCB_ERR_INFO_CRC_ERR_MULTI_LN,
4087 [C_DC_TX_REPLAY] = DC_PERF_CNTR_LCB(DcTxReplay, DC_LCB_ERR_INFO_TX_REPLAY_CNT,
4089 [C_DC_RX_REPLAY] = DC_PERF_CNTR_LCB(DcRxReplay, DC_LCB_ERR_INFO_RX_REPLAY_CNT,
4091 [C_DC_SEQ_CRC_CNT] =
4092 DC_PERF_CNTR_LCB(DcLinkSeqCrc, DC_LCB_ERR_INFO_SEQ_CRC_CNT,
4094 [C_DC_ESC0_ONLY_CNT] =
4095 DC_PERF_CNTR_LCB(DcEsc0, DC_LCB_ERR_INFO_ESCAPE_0_ONLY_CNT,
4097 [C_DC_ESC0_PLUS1_CNT] =
4098 DC_PERF_CNTR_LCB(DcEsc1, DC_LCB_ERR_INFO_ESCAPE_0_PLUS1_CNT,
4100 [C_DC_ESC0_PLUS2_CNT] =
4101 DC_PERF_CNTR_LCB(DcEsc0Plus2, DC_LCB_ERR_INFO_ESCAPE_0_PLUS2_CNT,
4103 [C_DC_REINIT_FROM_PEER_CNT] =
4104 DC_PERF_CNTR_LCB(DcReinitPeer, DC_LCB_ERR_INFO_REINIT_FROM_PEER_CNT,
4106 [C_DC_SBE_CNT] = DC_PERF_CNTR_LCB(DcSbe, DC_LCB_ERR_INFO_SBE_CNT,
4108 [C_DC_MISC_FLG_CNT] =
4109 DC_PERF_CNTR_LCB(DcMiscFlg, DC_LCB_ERR_INFO_MISC_FLG_CNT,
4111 [C_DC_PRF_GOOD_LTP_CNT] =
4112 DC_PERF_CNTR_LCB(DcGoodLTP, DC_LCB_PRF_GOOD_LTP_CNT, CNTR_SYNTH),
4113 [C_DC_PRF_ACCEPTED_LTP_CNT] =
4114 DC_PERF_CNTR_LCB(DcAccLTP, DC_LCB_PRF_ACCEPTED_LTP_CNT,
4116 [C_DC_PRF_RX_FLIT_CNT] =
4117 DC_PERF_CNTR_LCB(DcPrfRxFlit, DC_LCB_PRF_RX_FLIT_CNT, CNTR_SYNTH),
4118 [C_DC_PRF_TX_FLIT_CNT] =
4119 DC_PERF_CNTR_LCB(DcPrfTxFlit, DC_LCB_PRF_TX_FLIT_CNT, CNTR_SYNTH),
4120 [C_DC_PRF_CLK_CNTR] =
4121 DC_PERF_CNTR_LCB(DcPrfClk, DC_LCB_PRF_CLK_CNTR, CNTR_SYNTH),
4122 [C_DC_PG_DBG_FLIT_CRDTS_CNT] =
4123 DC_PERF_CNTR_LCB(DcFltCrdts, DC_LCB_PG_DBG_FLIT_CRDTS_CNT, CNTR_SYNTH),
4124 [C_DC_PG_STS_PAUSE_COMPLETE_CNT] =
4125 DC_PERF_CNTR_LCB(DcPauseComp, DC_LCB_PG_STS_PAUSE_COMPLETE_CNT,
4127 [C_DC_PG_STS_TX_SBE_CNT] =
4128 DC_PERF_CNTR_LCB(DcStsTxSbe, DC_LCB_PG_STS_TX_SBE_CNT, CNTR_SYNTH),
4129 [C_DC_PG_STS_TX_MBE_CNT] =
4130 DC_PERF_CNTR_LCB(DcStsTxMbe, DC_LCB_PG_STS_TX_MBE_CNT,
4132 [C_SW_CPU_INTR] = CNTR_ELEM("Intr", 0, 0, CNTR_NORMAL,
4133 access_sw_cpu_intr),
4134 [C_SW_CPU_RCV_LIM] = CNTR_ELEM("RcvLimit", 0, 0, CNTR_NORMAL,
4135 access_sw_cpu_rcv_limit),
4136 [C_SW_VTX_WAIT] = CNTR_ELEM("vTxWait", 0, 0, CNTR_NORMAL,
4137 access_sw_vtx_wait),
4138 [C_SW_PIO_WAIT] = CNTR_ELEM("PioWait", 0, 0, CNTR_NORMAL,
4139 access_sw_pio_wait),
4140 [C_SW_PIO_DRAIN] = CNTR_ELEM("PioDrain", 0, 0, CNTR_NORMAL,
4141 access_sw_pio_drain),
4142 [C_SW_KMEM_WAIT] = CNTR_ELEM("KmemWait", 0, 0, CNTR_NORMAL,
4143 access_sw_kmem_wait),
4144 [C_SW_SEND_SCHED] = CNTR_ELEM("SendSched", 0, 0, CNTR_NORMAL,
4145 access_sw_send_schedule),
4146 [C_SDMA_DESC_FETCHED_CNT] = CNTR_ELEM("SDEDscFdCn",
4147 SEND_DMA_DESC_FETCHED_CNT, 0,
4148 CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
4149 dev_access_u32_csr),
4150 [C_SDMA_INT_CNT] = CNTR_ELEM("SDMAInt", 0, 0,
4151 CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
4152 access_sde_int_cnt),
4153 [C_SDMA_ERR_CNT] = CNTR_ELEM("SDMAErrCt", 0, 0,
4154 CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
4155 access_sde_err_cnt),
4156 [C_SDMA_IDLE_INT_CNT] = CNTR_ELEM("SDMAIdInt", 0, 0,
4157 CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
4158 access_sde_idle_int_cnt),
4159 [C_SDMA_PROGRESS_INT_CNT] = CNTR_ELEM("SDMAPrIntCn", 0, 0,
4160 CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
4161 access_sde_progress_int_cnt),
4162 /* MISC_ERR_STATUS */
4163 [C_MISC_PLL_LOCK_FAIL_ERR] = CNTR_ELEM("MISC_PLL_LOCK_FAIL_ERR", 0, 0,
4165 access_misc_pll_lock_fail_err_cnt),
4166 [C_MISC_MBIST_FAIL_ERR] = CNTR_ELEM("MISC_MBIST_FAIL_ERR", 0, 0,
4168 access_misc_mbist_fail_err_cnt),
4169 [C_MISC_INVALID_EEP_CMD_ERR] = CNTR_ELEM("MISC_INVALID_EEP_CMD_ERR", 0, 0,
4171 access_misc_invalid_eep_cmd_err_cnt),
4172 [C_MISC_EFUSE_DONE_PARITY_ERR] = CNTR_ELEM("MISC_EFUSE_DONE_PARITY_ERR", 0, 0,
4174 access_misc_efuse_done_parity_err_cnt),
4175 [C_MISC_EFUSE_WRITE_ERR] = CNTR_ELEM("MISC_EFUSE_WRITE_ERR", 0, 0,
4177 access_misc_efuse_write_err_cnt),
4178 [C_MISC_EFUSE_READ_BAD_ADDR_ERR] = CNTR_ELEM("MISC_EFUSE_READ_BAD_ADDR_ERR", 0,
4180 access_misc_efuse_read_bad_addr_err_cnt),
4181 [C_MISC_EFUSE_CSR_PARITY_ERR] = CNTR_ELEM("MISC_EFUSE_CSR_PARITY_ERR", 0, 0,
4183 access_misc_efuse_csr_parity_err_cnt),
4184 [C_MISC_FW_AUTH_FAILED_ERR] = CNTR_ELEM("MISC_FW_AUTH_FAILED_ERR", 0, 0,
4186 access_misc_fw_auth_failed_err_cnt),
4187 [C_MISC_KEY_MISMATCH_ERR] = CNTR_ELEM("MISC_KEY_MISMATCH_ERR", 0, 0,
4189 access_misc_key_mismatch_err_cnt),
4190 [C_MISC_SBUS_WRITE_FAILED_ERR] = CNTR_ELEM("MISC_SBUS_WRITE_FAILED_ERR", 0, 0,
4192 access_misc_sbus_write_failed_err_cnt),
4193 [C_MISC_CSR_WRITE_BAD_ADDR_ERR] = CNTR_ELEM("MISC_CSR_WRITE_BAD_ADDR_ERR", 0, 0,
4195 access_misc_csr_write_bad_addr_err_cnt),
4196 [C_MISC_CSR_READ_BAD_ADDR_ERR] = CNTR_ELEM("MISC_CSR_READ_BAD_ADDR_ERR", 0, 0,
4198 access_misc_csr_read_bad_addr_err_cnt),
4199 [C_MISC_CSR_PARITY_ERR] = CNTR_ELEM("MISC_CSR_PARITY_ERR", 0, 0,
4201 access_misc_csr_parity_err_cnt),
4203 [C_CCE_ERR_STATUS_AGGREGATED_CNT] = CNTR_ELEM("CceErrStatusAggregatedCnt", 0, 0,
4205 access_sw_cce_err_status_aggregated_cnt),
4206 [C_CCE_MSIX_CSR_PARITY_ERR] = CNTR_ELEM("CceMsixCsrParityErr", 0, 0,
4208 access_cce_msix_csr_parity_err_cnt),
4209 [C_CCE_INT_MAP_UNC_ERR] = CNTR_ELEM("CceIntMapUncErr", 0, 0,
4211 access_cce_int_map_unc_err_cnt),
4212 [C_CCE_INT_MAP_COR_ERR] = CNTR_ELEM("CceIntMapCorErr", 0, 0,
4214 access_cce_int_map_cor_err_cnt),
4215 [C_CCE_MSIX_TABLE_UNC_ERR] = CNTR_ELEM("CceMsixTableUncErr", 0, 0,
4217 access_cce_msix_table_unc_err_cnt),
4218 [C_CCE_MSIX_TABLE_COR_ERR] = CNTR_ELEM("CceMsixTableCorErr", 0, 0,
4220 access_cce_msix_table_cor_err_cnt),
4221 [C_CCE_RXDMA_CONV_FIFO_PARITY_ERR] = CNTR_ELEM("CceRxdmaConvFifoParityErr", 0,
4223 access_cce_rxdma_conv_fifo_parity_err_cnt),
4224 [C_CCE_RCPL_ASYNC_FIFO_PARITY_ERR] = CNTR_ELEM("CceRcplAsyncFifoParityErr", 0,
4226 access_cce_rcpl_async_fifo_parity_err_cnt),
4227 [C_CCE_SEG_WRITE_BAD_ADDR_ERR] = CNTR_ELEM("CceSegWriteBadAddrErr", 0, 0,
4229 access_cce_seg_write_bad_addr_err_cnt),
4230 [C_CCE_SEG_READ_BAD_ADDR_ERR] = CNTR_ELEM("CceSegReadBadAddrErr", 0, 0,
4232 access_cce_seg_read_bad_addr_err_cnt),
4233 [C_LA_TRIGGERED] = CNTR_ELEM("Cce LATriggered", 0, 0,
4235 access_la_triggered_cnt),
4236 [C_CCE_TRGT_CPL_TIMEOUT_ERR] = CNTR_ELEM("CceTrgtCplTimeoutErr", 0, 0,
4238 access_cce_trgt_cpl_timeout_err_cnt),
4239 [C_PCIC_RECEIVE_PARITY_ERR] = CNTR_ELEM("PcicReceiveParityErr", 0, 0,
4241 access_pcic_receive_parity_err_cnt),
4242 [C_PCIC_TRANSMIT_BACK_PARITY_ERR] = CNTR_ELEM("PcicTransmitBackParityErr", 0, 0,
4244 access_pcic_transmit_back_parity_err_cnt),
4245 [C_PCIC_TRANSMIT_FRONT_PARITY_ERR] = CNTR_ELEM("PcicTransmitFrontParityErr", 0,
4247 access_pcic_transmit_front_parity_err_cnt),
4248 [C_PCIC_CPL_DAT_Q_UNC_ERR] = CNTR_ELEM("PcicCplDatQUncErr", 0, 0,
4250 access_pcic_cpl_dat_q_unc_err_cnt),
4251 [C_PCIC_CPL_HD_Q_UNC_ERR] = CNTR_ELEM("PcicCplHdQUncErr", 0, 0,
4253 access_pcic_cpl_hd_q_unc_err_cnt),
4254 [C_PCIC_POST_DAT_Q_UNC_ERR] = CNTR_ELEM("PcicPostDatQUncErr", 0, 0,
4256 access_pcic_post_dat_q_unc_err_cnt),
4257 [C_PCIC_POST_HD_Q_UNC_ERR] = CNTR_ELEM("PcicPostHdQUncErr", 0, 0,
4259 access_pcic_post_hd_q_unc_err_cnt),
4260 [C_PCIC_RETRY_SOT_MEM_UNC_ERR] = CNTR_ELEM("PcicRetrySotMemUncErr", 0, 0,
4262 access_pcic_retry_sot_mem_unc_err_cnt),
4263 [C_PCIC_RETRY_MEM_UNC_ERR] = CNTR_ELEM("PcicRetryMemUncErr", 0, 0,
4265 access_pcic_retry_mem_unc_err),
4266 [C_PCIC_N_POST_DAT_Q_PARITY_ERR] = CNTR_ELEM("PcicNPostDatQParityErr", 0, 0,
4268 access_pcic_n_post_dat_q_parity_err_cnt),
4269 [C_PCIC_N_POST_H_Q_PARITY_ERR] = CNTR_ELEM("PcicNPostHQParityErr", 0, 0,
4271 access_pcic_n_post_h_q_parity_err_cnt),
4272 [C_PCIC_CPL_DAT_Q_COR_ERR] = CNTR_ELEM("PcicCplDatQCorErr", 0, 0,
4274 access_pcic_cpl_dat_q_cor_err_cnt),
4275 [C_PCIC_CPL_HD_Q_COR_ERR] = CNTR_ELEM("PcicCplHdQCorErr", 0, 0,
4277 access_pcic_cpl_hd_q_cor_err_cnt),
4278 [C_PCIC_POST_DAT_Q_COR_ERR] = CNTR_ELEM("PcicPostDatQCorErr", 0, 0,
4280 access_pcic_post_dat_q_cor_err_cnt),
4281 [C_PCIC_POST_HD_Q_COR_ERR] = CNTR_ELEM("PcicPostHdQCorErr", 0, 0,
4283 access_pcic_post_hd_q_cor_err_cnt),
4284 [C_PCIC_RETRY_SOT_MEM_COR_ERR] = CNTR_ELEM("PcicRetrySotMemCorErr", 0, 0,
4286 access_pcic_retry_sot_mem_cor_err_cnt),
4287 [C_PCIC_RETRY_MEM_COR_ERR] = CNTR_ELEM("PcicRetryMemCorErr", 0, 0,
4289 access_pcic_retry_mem_cor_err_cnt),
4290 [C_CCE_CLI1_ASYNC_FIFO_DBG_PARITY_ERR] = CNTR_ELEM(
4291 "CceCli1AsyncFifoDbgParityError", 0, 0,
4293 access_cce_cli1_async_fifo_dbg_parity_err_cnt),
4294 [C_CCE_CLI1_ASYNC_FIFO_RXDMA_PARITY_ERR] = CNTR_ELEM(
4295 "CceCli1AsyncFifoRxdmaParityError", 0, 0,
4297 access_cce_cli1_async_fifo_rxdma_parity_err_cnt
4299 [C_CCE_CLI1_ASYNC_FIFO_SDMA_HD_PARITY_ERR] = CNTR_ELEM(
4300 "CceCli1AsyncFifoSdmaHdParityErr", 0, 0,
4302 access_cce_cli1_async_fifo_sdma_hd_parity_err_cnt),
4303 [C_CCE_CLI1_ASYNC_FIFO_PIO_CRDT_PARITY_ERR] = CNTR_ELEM(
4304 "CceCli1AsyncFifoPioCrdtParityErr", 0, 0,
4306 access_cce_cl1_async_fifo_pio_crdt_parity_err_cnt),
4307 [C_CCE_CLI2_ASYNC_FIFO_PARITY_ERR] = CNTR_ELEM("CceCli2AsyncFifoParityErr", 0,
4309 access_cce_cli2_async_fifo_parity_err_cnt),
4310 [C_CCE_CSR_CFG_BUS_PARITY_ERR] = CNTR_ELEM("CceCsrCfgBusParityErr", 0, 0,
4312 access_cce_csr_cfg_bus_parity_err_cnt),
4313 [C_CCE_CLI0_ASYNC_FIFO_PARTIY_ERR] = CNTR_ELEM("CceCli0AsyncFifoParityErr", 0,
4315 access_cce_cli0_async_fifo_parity_err_cnt),
4316 [C_CCE_RSPD_DATA_PARITY_ERR] = CNTR_ELEM("CceRspdDataParityErr", 0, 0,
4318 access_cce_rspd_data_parity_err_cnt),
4319 [C_CCE_TRGT_ACCESS_ERR] = CNTR_ELEM("CceTrgtAccessErr", 0, 0,
4321 access_cce_trgt_access_err_cnt),
4322 [C_CCE_TRGT_ASYNC_FIFO_PARITY_ERR] = CNTR_ELEM("CceTrgtAsyncFifoParityErr", 0,
4324 access_cce_trgt_async_fifo_parity_err_cnt),
4325 [C_CCE_CSR_WRITE_BAD_ADDR_ERR] = CNTR_ELEM("CceCsrWriteBadAddrErr", 0, 0,
4327 access_cce_csr_write_bad_addr_err_cnt),
4328 [C_CCE_CSR_READ_BAD_ADDR_ERR] = CNTR_ELEM("CceCsrReadBadAddrErr", 0, 0,
4330 access_cce_csr_read_bad_addr_err_cnt),
4331 [C_CCE_CSR_PARITY_ERR] = CNTR_ELEM("CceCsrParityErr", 0, 0,
4333 access_ccs_csr_parity_err_cnt),
4336 [C_RX_CSR_PARITY_ERR] = CNTR_ELEM("RxCsrParityErr", 0, 0,
4338 access_rx_csr_parity_err_cnt),
4339 [C_RX_CSR_WRITE_BAD_ADDR_ERR] = CNTR_ELEM("RxCsrWriteBadAddrErr", 0, 0,
4341 access_rx_csr_write_bad_addr_err_cnt),
4342 [C_RX_CSR_READ_BAD_ADDR_ERR] = CNTR_ELEM("RxCsrReadBadAddrErr", 0, 0,
4344 access_rx_csr_read_bad_addr_err_cnt),
4345 [C_RX_DMA_CSR_UNC_ERR] = CNTR_ELEM("RxDmaCsrUncErr", 0, 0,
4347 access_rx_dma_csr_unc_err_cnt),
4348 [C_RX_DMA_DQ_FSM_ENCODING_ERR] = CNTR_ELEM("RxDmaDqFsmEncodingErr", 0, 0,
4350 access_rx_dma_dq_fsm_encoding_err_cnt),
4351 [C_RX_DMA_EQ_FSM_ENCODING_ERR] = CNTR_ELEM("RxDmaEqFsmEncodingErr", 0, 0,
4353 access_rx_dma_eq_fsm_encoding_err_cnt),
4354 [C_RX_DMA_CSR_PARITY_ERR] = CNTR_ELEM("RxDmaCsrParityErr", 0, 0,
4356 access_rx_dma_csr_parity_err_cnt),
4357 [C_RX_RBUF_DATA_COR_ERR] = CNTR_ELEM("RxRbufDataCorErr", 0, 0,
4359 access_rx_rbuf_data_cor_err_cnt),
4360 [C_RX_RBUF_DATA_UNC_ERR] = CNTR_ELEM("RxRbufDataUncErr", 0, 0,
4362 access_rx_rbuf_data_unc_err_cnt),
4363 [C_RX_DMA_DATA_FIFO_RD_COR_ERR] = CNTR_ELEM("RxDmaDataFifoRdCorErr", 0, 0,
4365 access_rx_dma_data_fifo_rd_cor_err_cnt),
4366 [C_RX_DMA_DATA_FIFO_RD_UNC_ERR] = CNTR_ELEM("RxDmaDataFifoRdUncErr", 0, 0,
4368 access_rx_dma_data_fifo_rd_unc_err_cnt),
4369 [C_RX_DMA_HDR_FIFO_RD_COR_ERR] = CNTR_ELEM("RxDmaHdrFifoRdCorErr", 0, 0,
4371 access_rx_dma_hdr_fifo_rd_cor_err_cnt),
4372 [C_RX_DMA_HDR_FIFO_RD_UNC_ERR] = CNTR_ELEM("RxDmaHdrFifoRdUncErr", 0, 0,
4374 access_rx_dma_hdr_fifo_rd_unc_err_cnt),
4375 [C_RX_RBUF_DESC_PART2_COR_ERR] = CNTR_ELEM("RxRbufDescPart2CorErr", 0, 0,
4377 access_rx_rbuf_desc_part2_cor_err_cnt),
4378 [C_RX_RBUF_DESC_PART2_UNC_ERR] = CNTR_ELEM("RxRbufDescPart2UncErr", 0, 0,
4380 access_rx_rbuf_desc_part2_unc_err_cnt),
4381 [C_RX_RBUF_DESC_PART1_COR_ERR] = CNTR_ELEM("RxRbufDescPart1CorErr", 0, 0,
4383 access_rx_rbuf_desc_part1_cor_err_cnt),
4384 [C_RX_RBUF_DESC_PART1_UNC_ERR] = CNTR_ELEM("RxRbufDescPart1UncErr", 0, 0,
4386 access_rx_rbuf_desc_part1_unc_err_cnt),
4387 [C_RX_HQ_INTR_FSM_ERR] = CNTR_ELEM("RxHqIntrFsmErr", 0, 0,
4389 access_rx_hq_intr_fsm_err_cnt),
4390 [C_RX_HQ_INTR_CSR_PARITY_ERR] = CNTR_ELEM("RxHqIntrCsrParityErr", 0, 0,
4392 access_rx_hq_intr_csr_parity_err_cnt),
4393 [C_RX_LOOKUP_CSR_PARITY_ERR] = CNTR_ELEM("RxLookupCsrParityErr", 0, 0,
4395 access_rx_lookup_csr_parity_err_cnt),
4396 [C_RX_LOOKUP_RCV_ARRAY_COR_ERR] = CNTR_ELEM("RxLookupRcvArrayCorErr", 0, 0,
4398 access_rx_lookup_rcv_array_cor_err_cnt),
4399 [C_RX_LOOKUP_RCV_ARRAY_UNC_ERR] = CNTR_ELEM("RxLookupRcvArrayUncErr", 0, 0,
4401 access_rx_lookup_rcv_array_unc_err_cnt),
4402 [C_RX_LOOKUP_DES_PART2_PARITY_ERR] = CNTR_ELEM("RxLookupDesPart2ParityErr", 0,
4404 access_rx_lookup_des_part2_parity_err_cnt),
4405 [C_RX_LOOKUP_DES_PART1_UNC_COR_ERR] = CNTR_ELEM("RxLookupDesPart1UncCorErr", 0,
4407 access_rx_lookup_des_part1_unc_cor_err_cnt),
4408 [C_RX_LOOKUP_DES_PART1_UNC_ERR] = CNTR_ELEM("RxLookupDesPart1UncErr", 0, 0,
4410 access_rx_lookup_des_part1_unc_err_cnt),
4411 [C_RX_RBUF_NEXT_FREE_BUF_COR_ERR] = CNTR_ELEM("RxRbufNextFreeBufCorErr", 0, 0,
4413 access_rx_rbuf_next_free_buf_cor_err_cnt),
4414 [C_RX_RBUF_NEXT_FREE_BUF_UNC_ERR] = CNTR_ELEM("RxRbufNextFreeBufUncErr", 0, 0,
4416 access_rx_rbuf_next_free_buf_unc_err_cnt),
4417 [C_RX_RBUF_FL_INIT_WR_ADDR_PARITY_ERR] = CNTR_ELEM(
4418 "RxRbufFlInitWrAddrParityErr", 0, 0,
4420 access_rbuf_fl_init_wr_addr_parity_err_cnt),
4421 [C_RX_RBUF_FL_INITDONE_PARITY_ERR] = CNTR_ELEM("RxRbufFlInitdoneParityErr", 0,
4423 access_rx_rbuf_fl_initdone_parity_err_cnt),
4424 [C_RX_RBUF_FL_WRITE_ADDR_PARITY_ERR] = CNTR_ELEM("RxRbufFlWrAddrParityErr", 0,
4426 access_rx_rbuf_fl_write_addr_parity_err_cnt),
4427 [C_RX_RBUF_FL_RD_ADDR_PARITY_ERR] = CNTR_ELEM("RxRbufFlRdAddrParityErr", 0, 0,
4429 access_rx_rbuf_fl_rd_addr_parity_err_cnt),
4430 [C_RX_RBUF_EMPTY_ERR] = CNTR_ELEM("RxRbufEmptyErr", 0, 0,
4432 access_rx_rbuf_empty_err_cnt),
4433 [C_RX_RBUF_FULL_ERR] = CNTR_ELEM("RxRbufFullErr", 0, 0,
4435 access_rx_rbuf_full_err_cnt),
4436 [C_RX_RBUF_BAD_LOOKUP_ERR] = CNTR_ELEM("RxRBufBadLookupErr", 0, 0,
4438 access_rbuf_bad_lookup_err_cnt),
4439 [C_RX_RBUF_CTX_ID_PARITY_ERR] = CNTR_ELEM("RxRbufCtxIdParityErr", 0, 0,
4441 access_rbuf_ctx_id_parity_err_cnt),
4442 [C_RX_RBUF_CSR_QEOPDW_PARITY_ERR] = CNTR_ELEM("RxRbufCsrQEOPDWParityErr", 0, 0,
4444 access_rbuf_csr_qeopdw_parity_err_cnt),
4445 [C_RX_RBUF_CSR_Q_NUM_OF_PKT_PARITY_ERR] = CNTR_ELEM(
4446 "RxRbufCsrQNumOfPktParityErr", 0, 0,
4448 access_rx_rbuf_csr_q_num_of_pkt_parity_err_cnt),
4449 [C_RX_RBUF_CSR_Q_T1_PTR_PARITY_ERR] = CNTR_ELEM(
4450 "RxRbufCsrQTlPtrParityErr", 0, 0,
4452 access_rx_rbuf_csr_q_t1_ptr_parity_err_cnt),
4453 [C_RX_RBUF_CSR_Q_HD_PTR_PARITY_ERR] = CNTR_ELEM("RxRbufCsrQHdPtrParityErr", 0,
4455 access_rx_rbuf_csr_q_hd_ptr_parity_err_cnt),
4456 [C_RX_RBUF_CSR_Q_VLD_BIT_PARITY_ERR] = CNTR_ELEM("RxRbufCsrQVldBitParityErr", 0,
4458 access_rx_rbuf_csr_q_vld_bit_parity_err_cnt),
4459 [C_RX_RBUF_CSR_Q_NEXT_BUF_PARITY_ERR] = CNTR_ELEM("RxRbufCsrQNextBufParityErr",
4461 access_rx_rbuf_csr_q_next_buf_parity_err_cnt),
4462 [C_RX_RBUF_CSR_Q_ENT_CNT_PARITY_ERR] = CNTR_ELEM("RxRbufCsrQEntCntParityErr", 0,
4464 access_rx_rbuf_csr_q_ent_cnt_parity_err_cnt),
4465 [C_RX_RBUF_CSR_Q_HEAD_BUF_NUM_PARITY_ERR] = CNTR_ELEM(
4466 "RxRbufCsrQHeadBufNumParityErr", 0, 0,
4468 access_rx_rbuf_csr_q_head_buf_num_parity_err_cnt),
4469 [C_RX_RBUF_BLOCK_LIST_READ_COR_ERR] = CNTR_ELEM("RxRbufBlockListReadCorErr", 0,
4471 access_rx_rbuf_block_list_read_cor_err_cnt),
4472 [C_RX_RBUF_BLOCK_LIST_READ_UNC_ERR] = CNTR_ELEM("RxRbufBlockListReadUncErr", 0,
4474 access_rx_rbuf_block_list_read_unc_err_cnt),
4475 [C_RX_RBUF_LOOKUP_DES_COR_ERR] = CNTR_ELEM("RxRbufLookupDesCorErr", 0, 0,
4477 access_rx_rbuf_lookup_des_cor_err_cnt),
4478 [C_RX_RBUF_LOOKUP_DES_UNC_ERR] = CNTR_ELEM("RxRbufLookupDesUncErr", 0, 0,
4480 access_rx_rbuf_lookup_des_unc_err_cnt),
4481 [C_RX_RBUF_LOOKUP_DES_REG_UNC_COR_ERR] = CNTR_ELEM(
4482 "RxRbufLookupDesRegUncCorErr", 0, 0,
4484 access_rx_rbuf_lookup_des_reg_unc_cor_err_cnt),
4485 [C_RX_RBUF_LOOKUP_DES_REG_UNC_ERR] = CNTR_ELEM("RxRbufLookupDesRegUncErr", 0, 0,
4487 access_rx_rbuf_lookup_des_reg_unc_err_cnt),
4488 [C_RX_RBUF_FREE_LIST_COR_ERR] = CNTR_ELEM("RxRbufFreeListCorErr", 0, 0,
4490 access_rx_rbuf_free_list_cor_err_cnt),
4491 [C_RX_RBUF_FREE_LIST_UNC_ERR] = CNTR_ELEM("RxRbufFreeListUncErr", 0, 0,
4493 access_rx_rbuf_free_list_unc_err_cnt),
4494 [C_RX_RCV_FSM_ENCODING_ERR] = CNTR_ELEM("RxRcvFsmEncodingErr", 0, 0,
4496 access_rx_rcv_fsm_encoding_err_cnt),
4497 [C_RX_DMA_FLAG_COR_ERR] = CNTR_ELEM("RxDmaFlagCorErr", 0, 0,
4499 access_rx_dma_flag_cor_err_cnt),
4500 [C_RX_DMA_FLAG_UNC_ERR] = CNTR_ELEM("RxDmaFlagUncErr", 0, 0,
4502 access_rx_dma_flag_unc_err_cnt),
4503 [C_RX_DC_SOP_EOP_PARITY_ERR] = CNTR_ELEM("RxDcSopEopParityErr", 0, 0,
4505 access_rx_dc_sop_eop_parity_err_cnt),
4506 [C_RX_RCV_CSR_PARITY_ERR] = CNTR_ELEM("RxRcvCsrParityErr", 0, 0,
4508 access_rx_rcv_csr_parity_err_cnt),
4509 [C_RX_RCV_QP_MAP_TABLE_COR_ERR] = CNTR_ELEM("RxRcvQpMapTableCorErr", 0, 0,
4511 access_rx_rcv_qp_map_table_cor_err_cnt),
4512 [C_RX_RCV_QP_MAP_TABLE_UNC_ERR] = CNTR_ELEM("RxRcvQpMapTableUncErr", 0, 0,
4514 access_rx_rcv_qp_map_table_unc_err_cnt),
4515 [C_RX_RCV_DATA_COR_ERR] = CNTR_ELEM("RxRcvDataCorErr", 0, 0,
4517 access_rx_rcv_data_cor_err_cnt),
4518 [C_RX_RCV_DATA_UNC_ERR] = CNTR_ELEM("RxRcvDataUncErr", 0, 0,
4520 access_rx_rcv_data_unc_err_cnt),
4521 [C_RX_RCV_HDR_COR_ERR] = CNTR_ELEM("RxRcvHdrCorErr", 0, 0,
4523 access_rx_rcv_hdr_cor_err_cnt),
4524 [C_RX_RCV_HDR_UNC_ERR] = CNTR_ELEM("RxRcvHdrUncErr", 0, 0,
4526 access_rx_rcv_hdr_unc_err_cnt),
4527 [C_RX_DC_INTF_PARITY_ERR] = CNTR_ELEM("RxDcIntfParityErr", 0, 0,
4529 access_rx_dc_intf_parity_err_cnt),
4530 [C_RX_DMA_CSR_COR_ERR] = CNTR_ELEM("RxDmaCsrCorErr", 0, 0,
4532 access_rx_dma_csr_cor_err_cnt),
4533 /* SendPioErrStatus */
4534 [C_PIO_PEC_SOP_HEAD_PARITY_ERR] = CNTR_ELEM("PioPecSopHeadParityErr", 0, 0,
4536 access_pio_pec_sop_head_parity_err_cnt),
4537 [C_PIO_PCC_SOP_HEAD_PARITY_ERR] = CNTR_ELEM("PioPccSopHeadParityErr", 0, 0,
4539 access_pio_pcc_sop_head_parity_err_cnt),
4540 [C_PIO_LAST_RETURNED_CNT_PARITY_ERR] = CNTR_ELEM("PioLastReturnedCntParityErr",
4542 access_pio_last_returned_cnt_parity_err_cnt),
4543 [C_PIO_CURRENT_FREE_CNT_PARITY_ERR] = CNTR_ELEM("PioCurrentFreeCntParityErr", 0,
4545 access_pio_current_free_cnt_parity_err_cnt),
4546 [C_PIO_RSVD_31_ERR] = CNTR_ELEM("Pio Reserved 31", 0, 0,
4548 access_pio_reserved_31_err_cnt),
4549 [C_PIO_RSVD_30_ERR] = CNTR_ELEM("Pio Reserved 30", 0, 0,
4551 access_pio_reserved_30_err_cnt),
4552 [C_PIO_PPMC_SOP_LEN_ERR] = CNTR_ELEM("PioPpmcSopLenErr", 0, 0,
4554 access_pio_ppmc_sop_len_err_cnt),
4555 [C_PIO_PPMC_BQC_MEM_PARITY_ERR] = CNTR_ELEM("PioPpmcBqcMemParityErr", 0, 0,
4557 access_pio_ppmc_bqc_mem_parity_err_cnt),
4558 [C_PIO_VL_FIFO_PARITY_ERR] = CNTR_ELEM("PioVlFifoParityErr", 0, 0,
4560 access_pio_vl_fifo_parity_err_cnt),
4561 [C_PIO_VLF_SOP_PARITY_ERR] = CNTR_ELEM("PioVlfSopParityErr", 0, 0,
4563 access_pio_vlf_sop_parity_err_cnt),
4564 [C_PIO_VLF_V1_LEN_PARITY_ERR] = CNTR_ELEM("PioVlfVlLenParityErr", 0, 0,
4566 access_pio_vlf_v1_len_parity_err_cnt),
4567 [C_PIO_BLOCK_QW_COUNT_PARITY_ERR] = CNTR_ELEM("PioBlockQwCountParityErr", 0, 0,
4569 access_pio_block_qw_count_parity_err_cnt),
4570 [C_PIO_WRITE_QW_VALID_PARITY_ERR] = CNTR_ELEM("PioWriteQwValidParityErr", 0, 0,
4572 access_pio_write_qw_valid_parity_err_cnt),
4573 [C_PIO_STATE_MACHINE_ERR] = CNTR_ELEM("PioStateMachineErr", 0, 0,
4575 access_pio_state_machine_err_cnt),
4576 [C_PIO_WRITE_DATA_PARITY_ERR] = CNTR_ELEM("PioWriteDataParityErr", 0, 0,
4578 access_pio_write_data_parity_err_cnt),
4579 [C_PIO_HOST_ADDR_MEM_COR_ERR] = CNTR_ELEM("PioHostAddrMemCorErr", 0, 0,
4581 access_pio_host_addr_mem_cor_err_cnt),
4582 [C_PIO_HOST_ADDR_MEM_UNC_ERR] = CNTR_ELEM("PioHostAddrMemUncErr", 0, 0,
4584 access_pio_host_addr_mem_unc_err_cnt),
4585 [C_PIO_PKT_EVICT_SM_OR_ARM_SM_ERR] = CNTR_ELEM("PioPktEvictSmOrArbSmErr", 0, 0,
4587 access_pio_pkt_evict_sm_or_arb_sm_err_cnt),
4588 [C_PIO_INIT_SM_IN_ERR] = CNTR_ELEM("PioInitSmInErr", 0, 0,
4590 access_pio_init_sm_in_err_cnt),
4591 [C_PIO_PPMC_PBL_FIFO_ERR] = CNTR_ELEM("PioPpmcPblFifoErr", 0, 0,
4593 access_pio_ppmc_pbl_fifo_err_cnt),
4594 [C_PIO_CREDIT_RET_FIFO_PARITY_ERR] = CNTR_ELEM("PioCreditRetFifoParityErr", 0,
4596 access_pio_credit_ret_fifo_parity_err_cnt),
4597 [C_PIO_V1_LEN_MEM_BANK1_COR_ERR] = CNTR_ELEM("PioVlLenMemBank1CorErr", 0, 0,
4599 access_pio_v1_len_mem_bank1_cor_err_cnt),
4600 [C_PIO_V1_LEN_MEM_BANK0_COR_ERR] = CNTR_ELEM("PioVlLenMemBank0CorErr", 0, 0,
4602 access_pio_v1_len_mem_bank0_cor_err_cnt),
4603 [C_PIO_V1_LEN_MEM_BANK1_UNC_ERR] = CNTR_ELEM("PioVlLenMemBank1UncErr", 0, 0,
4605 access_pio_v1_len_mem_bank1_unc_err_cnt),
4606 [C_PIO_V1_LEN_MEM_BANK0_UNC_ERR] = CNTR_ELEM("PioVlLenMemBank0UncErr", 0, 0,
4608 access_pio_v1_len_mem_bank0_unc_err_cnt),
4609 [C_PIO_SM_PKT_RESET_PARITY_ERR] = CNTR_ELEM("PioSmPktResetParityErr", 0, 0,
4611 access_pio_sm_pkt_reset_parity_err_cnt),
4612 [C_PIO_PKT_EVICT_FIFO_PARITY_ERR] = CNTR_ELEM("PioPktEvictFifoParityErr", 0, 0,
4614 access_pio_pkt_evict_fifo_parity_err_cnt),
4615 [C_PIO_SBRDCTRL_CRREL_FIFO_PARITY_ERR] = CNTR_ELEM(
4616 "PioSbrdctrlCrrelFifoParityErr", 0, 0,
4618 access_pio_sbrdctrl_crrel_fifo_parity_err_cnt),
4619 [C_PIO_SBRDCTL_CRREL_PARITY_ERR] = CNTR_ELEM("PioSbrdctlCrrelParityErr", 0, 0,
4621 access_pio_sbrdctl_crrel_parity_err_cnt),
4622 [C_PIO_PEC_FIFO_PARITY_ERR] = CNTR_ELEM("PioPecFifoParityErr", 0, 0,
4624 access_pio_pec_fifo_parity_err_cnt),
4625 [C_PIO_PCC_FIFO_PARITY_ERR] = CNTR_ELEM("PioPccFifoParityErr", 0, 0,
4627 access_pio_pcc_fifo_parity_err_cnt),
4628 [C_PIO_SB_MEM_FIFO1_ERR] = CNTR_ELEM("PioSbMemFifo1Err", 0, 0,
4630 access_pio_sb_mem_fifo1_err_cnt),
4631 [C_PIO_SB_MEM_FIFO0_ERR] = CNTR_ELEM("PioSbMemFifo0Err", 0, 0,
4633 access_pio_sb_mem_fifo0_err_cnt),
4634 [C_PIO_CSR_PARITY_ERR] = CNTR_ELEM("PioCsrParityErr", 0, 0,
4636 access_pio_csr_parity_err_cnt),
4637 [C_PIO_WRITE_ADDR_PARITY_ERR] = CNTR_ELEM("PioWriteAddrParityErr", 0, 0,
4639 access_pio_write_addr_parity_err_cnt),
4640 [C_PIO_WRITE_BAD_CTXT_ERR] = CNTR_ELEM("PioWriteBadCtxtErr", 0, 0,
4642 access_pio_write_bad_ctxt_err_cnt),
4643 /* SendDmaErrStatus */
4644 [C_SDMA_PCIE_REQ_TRACKING_COR_ERR] = CNTR_ELEM("SDmaPcieReqTrackingCorErr", 0,
4646 access_sdma_pcie_req_tracking_cor_err_cnt),
4647 [C_SDMA_PCIE_REQ_TRACKING_UNC_ERR] = CNTR_ELEM("SDmaPcieReqTrackingUncErr", 0,
4649 access_sdma_pcie_req_tracking_unc_err_cnt),
4650 [C_SDMA_CSR_PARITY_ERR] = CNTR_ELEM("SDmaCsrParityErr", 0, 0,
4652 access_sdma_csr_parity_err_cnt),
4653 [C_SDMA_RPY_TAG_ERR] = CNTR_ELEM("SDmaRpyTagErr", 0, 0,
4655 access_sdma_rpy_tag_err_cnt),
4656 /* SendEgressErrStatus */
4657 [C_TX_READ_PIO_MEMORY_CSR_UNC_ERR] = CNTR_ELEM("TxReadPioMemoryCsrUncErr", 0, 0,
4659 access_tx_read_pio_memory_csr_unc_err_cnt),
4660 [C_TX_READ_SDMA_MEMORY_CSR_UNC_ERR] = CNTR_ELEM("TxReadSdmaMemoryCsrUncErr", 0,
4662 access_tx_read_sdma_memory_csr_err_cnt),
4663 [C_TX_EGRESS_FIFO_COR_ERR] = CNTR_ELEM("TxEgressFifoCorErr", 0, 0,
4665 access_tx_egress_fifo_cor_err_cnt),
4666 [C_TX_READ_PIO_MEMORY_COR_ERR] = CNTR_ELEM("TxReadPioMemoryCorErr", 0, 0,
4668 access_tx_read_pio_memory_cor_err_cnt),
4669 [C_TX_READ_SDMA_MEMORY_COR_ERR] = CNTR_ELEM("TxReadSdmaMemoryCorErr", 0, 0,
4671 access_tx_read_sdma_memory_cor_err_cnt),
4672 [C_TX_SB_HDR_COR_ERR] = CNTR_ELEM("TxSbHdrCorErr", 0, 0,
4674 access_tx_sb_hdr_cor_err_cnt),
4675 [C_TX_CREDIT_OVERRUN_ERR] = CNTR_ELEM("TxCreditOverrunErr", 0, 0,
4677 access_tx_credit_overrun_err_cnt),
4678 [C_TX_LAUNCH_FIFO8_COR_ERR] = CNTR_ELEM("TxLaunchFifo8CorErr", 0, 0,
4680 access_tx_launch_fifo8_cor_err_cnt),
4681 [C_TX_LAUNCH_FIFO7_COR_ERR] = CNTR_ELEM("TxLaunchFifo7CorErr", 0, 0,
4683 access_tx_launch_fifo7_cor_err_cnt),
4684 [C_TX_LAUNCH_FIFO6_COR_ERR] = CNTR_ELEM("TxLaunchFifo6CorErr", 0, 0,
4686 access_tx_launch_fifo6_cor_err_cnt),
4687 [C_TX_LAUNCH_FIFO5_COR_ERR] = CNTR_ELEM("TxLaunchFifo5CorErr", 0, 0,
4689 access_tx_launch_fifo5_cor_err_cnt),
4690 [C_TX_LAUNCH_FIFO4_COR_ERR] = CNTR_ELEM("TxLaunchFifo4CorErr", 0, 0,
4692 access_tx_launch_fifo4_cor_err_cnt),
4693 [C_TX_LAUNCH_FIFO3_COR_ERR] = CNTR_ELEM("TxLaunchFifo3CorErr", 0, 0,
4695 access_tx_launch_fifo3_cor_err_cnt),
4696 [C_TX_LAUNCH_FIFO2_COR_ERR] = CNTR_ELEM("TxLaunchFifo2CorErr", 0, 0,
4698 access_tx_launch_fifo2_cor_err_cnt),
4699 [C_TX_LAUNCH_FIFO1_COR_ERR] = CNTR_ELEM("TxLaunchFifo1CorErr", 0, 0,
4701 access_tx_launch_fifo1_cor_err_cnt),
4702 [C_TX_LAUNCH_FIFO0_COR_ERR] = CNTR_ELEM("TxLaunchFifo0CorErr", 0, 0,
4704 access_tx_launch_fifo0_cor_err_cnt),
4705 [C_TX_CREDIT_RETURN_VL_ERR] = CNTR_ELEM("TxCreditReturnVLErr", 0, 0,
4707 access_tx_credit_return_vl_err_cnt),
4708 [C_TX_HCRC_INSERTION_ERR] = CNTR_ELEM("TxHcrcInsertionErr", 0, 0,
4710 access_tx_hcrc_insertion_err_cnt),
4711 [C_TX_EGRESS_FIFI_UNC_ERR] = CNTR_ELEM("TxEgressFifoUncErr", 0, 0,
4713 access_tx_egress_fifo_unc_err_cnt),
4714 [C_TX_READ_PIO_MEMORY_UNC_ERR] = CNTR_ELEM("TxReadPioMemoryUncErr", 0, 0,
4716 access_tx_read_pio_memory_unc_err_cnt),
4717 [C_TX_READ_SDMA_MEMORY_UNC_ERR] = CNTR_ELEM("TxReadSdmaMemoryUncErr", 0, 0,
4719 access_tx_read_sdma_memory_unc_err_cnt),
4720 [C_TX_SB_HDR_UNC_ERR] = CNTR_ELEM("TxSbHdrUncErr", 0, 0,
4722 access_tx_sb_hdr_unc_err_cnt),
4723 [C_TX_CREDIT_RETURN_PARITY_ERR] = CNTR_ELEM("TxCreditReturnParityErr", 0, 0,
4725 access_tx_credit_return_partiy_err_cnt),
4726 [C_TX_LAUNCH_FIFO8_UNC_OR_PARITY_ERR] = CNTR_ELEM("TxLaunchFifo8UncOrParityErr",
4728 access_tx_launch_fifo8_unc_or_parity_err_cnt),
4729 [C_TX_LAUNCH_FIFO7_UNC_OR_PARITY_ERR] = CNTR_ELEM("TxLaunchFifo7UncOrParityErr",
4731 access_tx_launch_fifo7_unc_or_parity_err_cnt),
4732 [C_TX_LAUNCH_FIFO6_UNC_OR_PARITY_ERR] = CNTR_ELEM("TxLaunchFifo6UncOrParityErr",
4734 access_tx_launch_fifo6_unc_or_parity_err_cnt),
4735 [C_TX_LAUNCH_FIFO5_UNC_OR_PARITY_ERR] = CNTR_ELEM("TxLaunchFifo5UncOrParityErr",
4737 access_tx_launch_fifo5_unc_or_parity_err_cnt),
4738 [C_TX_LAUNCH_FIFO4_UNC_OR_PARITY_ERR] = CNTR_ELEM("TxLaunchFifo4UncOrParityErr",
4740 access_tx_launch_fifo4_unc_or_parity_err_cnt),
4741 [C_TX_LAUNCH_FIFO3_UNC_OR_PARITY_ERR] = CNTR_ELEM("TxLaunchFifo3UncOrParityErr",
4743 access_tx_launch_fifo3_unc_or_parity_err_cnt),
4744 [C_TX_LAUNCH_FIFO2_UNC_OR_PARITY_ERR] = CNTR_ELEM("TxLaunchFifo2UncOrParityErr",
4746 access_tx_launch_fifo2_unc_or_parity_err_cnt),
4747 [C_TX_LAUNCH_FIFO1_UNC_OR_PARITY_ERR] = CNTR_ELEM("TxLaunchFifo1UncOrParityErr",
4749 access_tx_launch_fifo1_unc_or_parity_err_cnt),
4750 [C_TX_LAUNCH_FIFO0_UNC_OR_PARITY_ERR] = CNTR_ELEM("TxLaunchFifo0UncOrParityErr",
4752 access_tx_launch_fifo0_unc_or_parity_err_cnt),
4753 [C_TX_SDMA15_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma15DisallowedPacketErr",
4755 access_tx_sdma15_disallowed_packet_err_cnt),
4756 [C_TX_SDMA14_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma14DisallowedPacketErr",
4758 access_tx_sdma14_disallowed_packet_err_cnt),
4759 [C_TX_SDMA13_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma13DisallowedPacketErr",
4761 access_tx_sdma13_disallowed_packet_err_cnt),
4762 [C_TX_SDMA12_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma12DisallowedPacketErr",
4764 access_tx_sdma12_disallowed_packet_err_cnt),
4765 [C_TX_SDMA11_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma11DisallowedPacketErr",
4767 access_tx_sdma11_disallowed_packet_err_cnt),
4768 [C_TX_SDMA10_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma10DisallowedPacketErr",
4770 access_tx_sdma10_disallowed_packet_err_cnt),
4771 [C_TX_SDMA9_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma9DisallowedPacketErr",
4773 access_tx_sdma9_disallowed_packet_err_cnt),
4774 [C_TX_SDMA8_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma8DisallowedPacketErr",
4776 access_tx_sdma8_disallowed_packet_err_cnt),
4777 [C_TX_SDMA7_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma7DisallowedPacketErr",
4779 access_tx_sdma7_disallowed_packet_err_cnt),
4780 [C_TX_SDMA6_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma6DisallowedPacketErr",
4782 access_tx_sdma6_disallowed_packet_err_cnt),
4783 [C_TX_SDMA5_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma5DisallowedPacketErr",
4785 access_tx_sdma5_disallowed_packet_err_cnt),
4786 [C_TX_SDMA4_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma4DisallowedPacketErr",
4788 access_tx_sdma4_disallowed_packet_err_cnt),
4789 [C_TX_SDMA3_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma3DisallowedPacketErr",
4791 access_tx_sdma3_disallowed_packet_err_cnt),
4792 [C_TX_SDMA2_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma2DisallowedPacketErr",
4794 access_tx_sdma2_disallowed_packet_err_cnt),
4795 [C_TX_SDMA1_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma1DisallowedPacketErr",
4797 access_tx_sdma1_disallowed_packet_err_cnt),
4798 [C_TX_SDMA0_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma0DisallowedPacketErr",
4800 access_tx_sdma0_disallowed_packet_err_cnt),
4801 [C_TX_CONFIG_PARITY_ERR] = CNTR_ELEM("TxConfigParityErr", 0, 0,
4803 access_tx_config_parity_err_cnt),
4804 [C_TX_SBRD_CTL_CSR_PARITY_ERR] = CNTR_ELEM("TxSbrdCtlCsrParityErr", 0, 0,
4806 access_tx_sbrd_ctl_csr_parity_err_cnt),
4807 [C_TX_LAUNCH_CSR_PARITY_ERR] = CNTR_ELEM("TxLaunchCsrParityErr", 0, 0,
4809 access_tx_launch_csr_parity_err_cnt),
4810 [C_TX_ILLEGAL_CL_ERR] = CNTR_ELEM("TxIllegalVLErr", 0, 0,
4812 access_tx_illegal_vl_err_cnt),
4813 [C_TX_SBRD_CTL_STATE_MACHINE_PARITY_ERR] = CNTR_ELEM(
4814 "TxSbrdCtlStateMachineParityErr", 0, 0,
4816 access_tx_sbrd_ctl_state_machine_parity_err_cnt),
4817 [C_TX_RESERVED_10] = CNTR_ELEM("Tx Egress Reserved 10", 0, 0,
4819 access_egress_reserved_10_err_cnt),
4820 [C_TX_RESERVED_9] = CNTR_ELEM("Tx Egress Reserved 9", 0, 0,
4822 access_egress_reserved_9_err_cnt),
4823 [C_TX_SDMA_LAUNCH_INTF_PARITY_ERR] = CNTR_ELEM("TxSdmaLaunchIntfParityErr",
4825 access_tx_sdma_launch_intf_parity_err_cnt),
4826 [C_TX_PIO_LAUNCH_INTF_PARITY_ERR] = CNTR_ELEM("TxPioLaunchIntfParityErr", 0, 0,
4828 access_tx_pio_launch_intf_parity_err_cnt),
4829 [C_TX_RESERVED_6] = CNTR_ELEM("Tx Egress Reserved 6", 0, 0,
4831 access_egress_reserved_6_err_cnt),
4832 [C_TX_INCORRECT_LINK_STATE_ERR] = CNTR_ELEM("TxIncorrectLinkStateErr", 0, 0,
4834 access_tx_incorrect_link_state_err_cnt),
4835 [C_TX_LINK_DOWN_ERR] = CNTR_ELEM("TxLinkdownErr", 0, 0,
4837 access_tx_linkdown_err_cnt),
4838 [C_TX_EGRESS_FIFO_UNDERRUN_OR_PARITY_ERR] = CNTR_ELEM(
4839 "EgressFifoUnderrunOrParityErr", 0, 0,
4841 access_tx_egress_fifi_underrun_or_parity_err_cnt),
4842 [C_TX_RESERVED_2] = CNTR_ELEM("Tx Egress Reserved 2", 0, 0,
4844 access_egress_reserved_2_err_cnt),
4845 [C_TX_PKT_INTEGRITY_MEM_UNC_ERR] = CNTR_ELEM("TxPktIntegrityMemUncErr", 0, 0,
4847 access_tx_pkt_integrity_mem_unc_err_cnt),
4848 [C_TX_PKT_INTEGRITY_MEM_COR_ERR] = CNTR_ELEM("TxPktIntegrityMemCorErr", 0, 0,
4850 access_tx_pkt_integrity_mem_cor_err_cnt),
4852 [C_SEND_CSR_WRITE_BAD_ADDR_ERR] = CNTR_ELEM("SendCsrWriteBadAddrErr", 0, 0,
4854 access_send_csr_write_bad_addr_err_cnt),
4855 [C_SEND_CSR_READ_BAD_ADD_ERR] = CNTR_ELEM("SendCsrReadBadAddrErr", 0, 0,
4857 access_send_csr_read_bad_addr_err_cnt),
4858 [C_SEND_CSR_PARITY_ERR] = CNTR_ELEM("SendCsrParityErr", 0, 0,
4860 access_send_csr_parity_cnt),
4861 /* SendCtxtErrStatus */
4862 [C_PIO_WRITE_OUT_OF_BOUNDS_ERR] = CNTR_ELEM("PioWriteOutOfBoundsErr", 0, 0,
4864 access_pio_write_out_of_bounds_err_cnt),
4865 [C_PIO_WRITE_OVERFLOW_ERR] = CNTR_ELEM("PioWriteOverflowErr", 0, 0,
4867 access_pio_write_overflow_err_cnt),
4868 [C_PIO_WRITE_CROSSES_BOUNDARY_ERR] = CNTR_ELEM("PioWriteCrossesBoundaryErr",
4870 access_pio_write_crosses_boundary_err_cnt),
4871 [C_PIO_DISALLOWED_PACKET_ERR] = CNTR_ELEM("PioDisallowedPacketErr", 0, 0,
4873 access_pio_disallowed_packet_err_cnt),
4874 [C_PIO_INCONSISTENT_SOP_ERR] = CNTR_ELEM("PioInconsistentSopErr", 0, 0,
4876 access_pio_inconsistent_sop_err_cnt),
4877 /* SendDmaEngErrStatus */
4878 [C_SDMA_HEADER_REQUEST_FIFO_COR_ERR] = CNTR_ELEM("SDmaHeaderRequestFifoCorErr",
4880 access_sdma_header_request_fifo_cor_err_cnt),
4881 [C_SDMA_HEADER_STORAGE_COR_ERR] = CNTR_ELEM("SDmaHeaderStorageCorErr", 0, 0,
4883 access_sdma_header_storage_cor_err_cnt),
4884 [C_SDMA_PACKET_TRACKING_COR_ERR] = CNTR_ELEM("SDmaPacketTrackingCorErr", 0, 0,
4886 access_sdma_packet_tracking_cor_err_cnt),
4887 [C_SDMA_ASSEMBLY_COR_ERR] = CNTR_ELEM("SDmaAssemblyCorErr", 0, 0,
4889 access_sdma_assembly_cor_err_cnt),
4890 [C_SDMA_DESC_TABLE_COR_ERR] = CNTR_ELEM("SDmaDescTableCorErr", 0, 0,
4892 access_sdma_desc_table_cor_err_cnt),
4893 [C_SDMA_HEADER_REQUEST_FIFO_UNC_ERR] = CNTR_ELEM("SDmaHeaderRequestFifoUncErr",
4895 access_sdma_header_request_fifo_unc_err_cnt),
4896 [C_SDMA_HEADER_STORAGE_UNC_ERR] = CNTR_ELEM("SDmaHeaderStorageUncErr", 0, 0,
4898 access_sdma_header_storage_unc_err_cnt),
4899 [C_SDMA_PACKET_TRACKING_UNC_ERR] = CNTR_ELEM("SDmaPacketTrackingUncErr", 0, 0,
4901 access_sdma_packet_tracking_unc_err_cnt),
4902 [C_SDMA_ASSEMBLY_UNC_ERR] = CNTR_ELEM("SDmaAssemblyUncErr", 0, 0,
4904 access_sdma_assembly_unc_err_cnt),
4905 [C_SDMA_DESC_TABLE_UNC_ERR] = CNTR_ELEM("SDmaDescTableUncErr", 0, 0,
4907 access_sdma_desc_table_unc_err_cnt),
4908 [C_SDMA_TIMEOUT_ERR] = CNTR_ELEM("SDmaTimeoutErr", 0, 0,
4910 access_sdma_timeout_err_cnt),
4911 [C_SDMA_HEADER_LENGTH_ERR] = CNTR_ELEM("SDmaHeaderLengthErr", 0, 0,
4913 access_sdma_header_length_err_cnt),
4914 [C_SDMA_HEADER_ADDRESS_ERR] = CNTR_ELEM("SDmaHeaderAddressErr", 0, 0,
4916 access_sdma_header_address_err_cnt),
4917 [C_SDMA_HEADER_SELECT_ERR] = CNTR_ELEM("SDmaHeaderSelectErr", 0, 0,
4919 access_sdma_header_select_err_cnt),
4920 [C_SMDA_RESERVED_9] = CNTR_ELEM("SDma Reserved 9", 0, 0,
4922 access_sdma_reserved_9_err_cnt),
4923 [C_SDMA_PACKET_DESC_OVERFLOW_ERR] = CNTR_ELEM("SDmaPacketDescOverflowErr", 0, 0,
4925 access_sdma_packet_desc_overflow_err_cnt),
4926 [C_SDMA_LENGTH_MISMATCH_ERR] = CNTR_ELEM("SDmaLengthMismatchErr", 0, 0,
4928 access_sdma_length_mismatch_err_cnt),
4929 [C_SDMA_HALT_ERR] = CNTR_ELEM("SDmaHaltErr", 0, 0,
4931 access_sdma_halt_err_cnt),
4932 [C_SDMA_MEM_READ_ERR] = CNTR_ELEM("SDmaMemReadErr", 0, 0,
4934 access_sdma_mem_read_err_cnt),
4935 [C_SDMA_FIRST_DESC_ERR] = CNTR_ELEM("SDmaFirstDescErr", 0, 0,
4937 access_sdma_first_desc_err_cnt),
4938 [C_SDMA_TAIL_OUT_OF_BOUNDS_ERR] = CNTR_ELEM("SDmaTailOutOfBoundsErr", 0, 0,
4940 access_sdma_tail_out_of_bounds_err_cnt),
4941 [C_SDMA_TOO_LONG_ERR] = CNTR_ELEM("SDmaTooLongErr", 0, 0,
4943 access_sdma_too_long_err_cnt),
4944 [C_SDMA_GEN_MISMATCH_ERR] = CNTR_ELEM("SDmaGenMismatchErr", 0, 0,
4946 access_sdma_gen_mismatch_err_cnt),
4947 [C_SDMA_WRONG_DW_ERR] = CNTR_ELEM("SDmaWrongDwErr", 0, 0,
4949 access_sdma_wrong_dw_err_cnt),
4952 static struct cntr_entry port_cntrs[PORT_CNTR_LAST] = {
4953 [C_TX_UNSUP_VL] = TXE32_PORT_CNTR_ELEM(TxUnVLErr, SEND_UNSUP_VL_ERR_CNT,
4955 [C_TX_INVAL_LEN] = TXE32_PORT_CNTR_ELEM(TxInvalLen, SEND_LEN_ERR_CNT,
4957 [C_TX_MM_LEN_ERR] = TXE32_PORT_CNTR_ELEM(TxMMLenErr, SEND_MAX_MIN_LEN_ERR_CNT,
4959 [C_TX_UNDERRUN] = TXE32_PORT_CNTR_ELEM(TxUnderrun, SEND_UNDERRUN_CNT,
4961 [C_TX_FLOW_STALL] = TXE32_PORT_CNTR_ELEM(TxFlowStall, SEND_FLOW_STALL_CNT,
4963 [C_TX_DROPPED] = TXE32_PORT_CNTR_ELEM(TxDropped, SEND_DROPPED_PKT_CNT,
4965 [C_TX_HDR_ERR] = TXE32_PORT_CNTR_ELEM(TxHdrErr, SEND_HEADERS_ERR_CNT,
4967 [C_TX_PKT] = TXE64_PORT_CNTR_ELEM(TxPkt, SEND_DATA_PKT_CNT, CNTR_NORMAL),
4968 [C_TX_WORDS] = TXE64_PORT_CNTR_ELEM(TxWords, SEND_DWORD_CNT, CNTR_NORMAL),
4969 [C_TX_WAIT] = TXE64_PORT_CNTR_ELEM(TxWait, SEND_WAIT_CNT, CNTR_SYNTH),
4970 [C_TX_FLIT_VL] = TXE64_PORT_CNTR_ELEM(TxFlitVL, SEND_DATA_VL0_CNT,
4971 CNTR_SYNTH | CNTR_VL),
4972 [C_TX_PKT_VL] = TXE64_PORT_CNTR_ELEM(TxPktVL, SEND_DATA_PKT_VL0_CNT,
4973 CNTR_SYNTH | CNTR_VL),
4974 [C_TX_WAIT_VL] = TXE64_PORT_CNTR_ELEM(TxWaitVL, SEND_WAIT_VL0_CNT,
4975 CNTR_SYNTH | CNTR_VL),
4976 [C_RX_PKT] = RXE64_PORT_CNTR_ELEM(RxPkt, RCV_DATA_PKT_CNT, CNTR_NORMAL),
4977 [C_RX_WORDS] = RXE64_PORT_CNTR_ELEM(RxWords, RCV_DWORD_CNT, CNTR_NORMAL),
4978 [C_SW_LINK_DOWN] = CNTR_ELEM("SwLinkDown", 0, 0, CNTR_SYNTH | CNTR_32BIT,
4979 access_sw_link_dn_cnt),
4980 [C_SW_LINK_UP] = CNTR_ELEM("SwLinkUp", 0, 0, CNTR_SYNTH | CNTR_32BIT,
4981 access_sw_link_up_cnt),
4982 [C_SW_UNKNOWN_FRAME] = CNTR_ELEM("UnknownFrame", 0, 0, CNTR_NORMAL,
4983 access_sw_unknown_frame_cnt),
4984 [C_SW_XMIT_DSCD] = CNTR_ELEM("XmitDscd", 0, 0, CNTR_SYNTH | CNTR_32BIT,
4985 access_sw_xmit_discards),
4986 [C_SW_XMIT_DSCD_VL] = CNTR_ELEM("XmitDscdVl", 0, 0,
4987 CNTR_SYNTH | CNTR_32BIT | CNTR_VL,
4988 access_sw_xmit_discards),
4989 [C_SW_XMIT_CSTR_ERR] = CNTR_ELEM("XmitCstrErr", 0, 0, CNTR_SYNTH,
4990 access_xmit_constraint_errs),
4991 [C_SW_RCV_CSTR_ERR] = CNTR_ELEM("RcvCstrErr", 0, 0, CNTR_SYNTH,
4992 access_rcv_constraint_errs),
4993 [C_SW_IBP_LOOP_PKTS] = SW_IBP_CNTR(LoopPkts, loop_pkts),
4994 [C_SW_IBP_RC_RESENDS] = SW_IBP_CNTR(RcResend, rc_resends),
4995 [C_SW_IBP_RNR_NAKS] = SW_IBP_CNTR(RnrNak, rnr_naks),
4996 [C_SW_IBP_OTHER_NAKS] = SW_IBP_CNTR(OtherNak, other_naks),
4997 [C_SW_IBP_RC_TIMEOUTS] = SW_IBP_CNTR(RcTimeOut, rc_timeouts),
4998 [C_SW_IBP_PKT_DROPS] = SW_IBP_CNTR(PktDrop, pkt_drops),
4999 [C_SW_IBP_DMA_WAIT] = SW_IBP_CNTR(DmaWait, dmawait),
5000 [C_SW_IBP_RC_SEQNAK] = SW_IBP_CNTR(RcSeqNak, rc_seqnak),
5001 [C_SW_IBP_RC_DUPREQ] = SW_IBP_CNTR(RcDupRew, rc_dupreq),
5002 [C_SW_IBP_RDMA_SEQ] = SW_IBP_CNTR(RdmaSeq, rdma_seq),
5003 [C_SW_IBP_UNALIGNED] = SW_IBP_CNTR(Unaligned, unaligned),
5004 [C_SW_IBP_SEQ_NAK] = SW_IBP_CNTR(SeqNak, seq_naks),
5005 [C_SW_CPU_RC_ACKS] = CNTR_ELEM("RcAcks", 0, 0, CNTR_NORMAL,
5006 access_sw_cpu_rc_acks),
5007 [C_SW_CPU_RC_QACKS] = CNTR_ELEM("RcQacks", 0, 0, CNTR_NORMAL,
5008 access_sw_cpu_rc_qacks),
5009 [C_SW_CPU_RC_DELAYED_COMP] = CNTR_ELEM("RcDelayComp", 0, 0, CNTR_NORMAL,
5010 access_sw_cpu_rc_delayed_comp),
5011 [OVR_LBL(0)] = OVR_ELM(0), [OVR_LBL(1)] = OVR_ELM(1),
5012 [OVR_LBL(2)] = OVR_ELM(2), [OVR_LBL(3)] = OVR_ELM(3),
5013 [OVR_LBL(4)] = OVR_ELM(4), [OVR_LBL(5)] = OVR_ELM(5),
5014 [OVR_LBL(6)] = OVR_ELM(6), [OVR_LBL(7)] = OVR_ELM(7),
5015 [OVR_LBL(8)] = OVR_ELM(8), [OVR_LBL(9)] = OVR_ELM(9),
5016 [OVR_LBL(10)] = OVR_ELM(10), [OVR_LBL(11)] = OVR_ELM(11),
5017 [OVR_LBL(12)] = OVR_ELM(12), [OVR_LBL(13)] = OVR_ELM(13),
5018 [OVR_LBL(14)] = OVR_ELM(14), [OVR_LBL(15)] = OVR_ELM(15),
5019 [OVR_LBL(16)] = OVR_ELM(16), [OVR_LBL(17)] = OVR_ELM(17),
5020 [OVR_LBL(18)] = OVR_ELM(18), [OVR_LBL(19)] = OVR_ELM(19),
5021 [OVR_LBL(20)] = OVR_ELM(20), [OVR_LBL(21)] = OVR_ELM(21),
5022 [OVR_LBL(22)] = OVR_ELM(22), [OVR_LBL(23)] = OVR_ELM(23),
5023 [OVR_LBL(24)] = OVR_ELM(24), [OVR_LBL(25)] = OVR_ELM(25),
5024 [OVR_LBL(26)] = OVR_ELM(26), [OVR_LBL(27)] = OVR_ELM(27),
5025 [OVR_LBL(28)] = OVR_ELM(28), [OVR_LBL(29)] = OVR_ELM(29),
5026 [OVR_LBL(30)] = OVR_ELM(30), [OVR_LBL(31)] = OVR_ELM(31),
5027 [OVR_LBL(32)] = OVR_ELM(32), [OVR_LBL(33)] = OVR_ELM(33),
5028 [OVR_LBL(34)] = OVR_ELM(34), [OVR_LBL(35)] = OVR_ELM(35),
5029 [OVR_LBL(36)] = OVR_ELM(36), [OVR_LBL(37)] = OVR_ELM(37),
5030 [OVR_LBL(38)] = OVR_ELM(38), [OVR_LBL(39)] = OVR_ELM(39),
5031 [OVR_LBL(40)] = OVR_ELM(40), [OVR_LBL(41)] = OVR_ELM(41),
5032 [OVR_LBL(42)] = OVR_ELM(42), [OVR_LBL(43)] = OVR_ELM(43),
5033 [OVR_LBL(44)] = OVR_ELM(44), [OVR_LBL(45)] = OVR_ELM(45),
5034 [OVR_LBL(46)] = OVR_ELM(46), [OVR_LBL(47)] = OVR_ELM(47),
5035 [OVR_LBL(48)] = OVR_ELM(48), [OVR_LBL(49)] = OVR_ELM(49),
5036 [OVR_LBL(50)] = OVR_ELM(50), [OVR_LBL(51)] = OVR_ELM(51),
5037 [OVR_LBL(52)] = OVR_ELM(52), [OVR_LBL(53)] = OVR_ELM(53),
5038 [OVR_LBL(54)] = OVR_ELM(54), [OVR_LBL(55)] = OVR_ELM(55),
5039 [OVR_LBL(56)] = OVR_ELM(56), [OVR_LBL(57)] = OVR_ELM(57),
5040 [OVR_LBL(58)] = OVR_ELM(58), [OVR_LBL(59)] = OVR_ELM(59),
5041 [OVR_LBL(60)] = OVR_ELM(60), [OVR_LBL(61)] = OVR_ELM(61),
5042 [OVR_LBL(62)] = OVR_ELM(62), [OVR_LBL(63)] = OVR_ELM(63),
5043 [OVR_LBL(64)] = OVR_ELM(64), [OVR_LBL(65)] = OVR_ELM(65),
5044 [OVR_LBL(66)] = OVR_ELM(66), [OVR_LBL(67)] = OVR_ELM(67),
5045 [OVR_LBL(68)] = OVR_ELM(68), [OVR_LBL(69)] = OVR_ELM(69),
5046 [OVR_LBL(70)] = OVR_ELM(70), [OVR_LBL(71)] = OVR_ELM(71),
5047 [OVR_LBL(72)] = OVR_ELM(72), [OVR_LBL(73)] = OVR_ELM(73),
5048 [OVR_LBL(74)] = OVR_ELM(74), [OVR_LBL(75)] = OVR_ELM(75),
5049 [OVR_LBL(76)] = OVR_ELM(76), [OVR_LBL(77)] = OVR_ELM(77),
5050 [OVR_LBL(78)] = OVR_ELM(78), [OVR_LBL(79)] = OVR_ELM(79),
5051 [OVR_LBL(80)] = OVR_ELM(80), [OVR_LBL(81)] = OVR_ELM(81),
5052 [OVR_LBL(82)] = OVR_ELM(82), [OVR_LBL(83)] = OVR_ELM(83),
5053 [OVR_LBL(84)] = OVR_ELM(84), [OVR_LBL(85)] = OVR_ELM(85),
5054 [OVR_LBL(86)] = OVR_ELM(86), [OVR_LBL(87)] = OVR_ELM(87),
5055 [OVR_LBL(88)] = OVR_ELM(88), [OVR_LBL(89)] = OVR_ELM(89),
5056 [OVR_LBL(90)] = OVR_ELM(90), [OVR_LBL(91)] = OVR_ELM(91),
5057 [OVR_LBL(92)] = OVR_ELM(92), [OVR_LBL(93)] = OVR_ELM(93),
5058 [OVR_LBL(94)] = OVR_ELM(94), [OVR_LBL(95)] = OVR_ELM(95),
5059 [OVR_LBL(96)] = OVR_ELM(96), [OVR_LBL(97)] = OVR_ELM(97),
5060 [OVR_LBL(98)] = OVR_ELM(98), [OVR_LBL(99)] = OVR_ELM(99),
5061 [OVR_LBL(100)] = OVR_ELM(100), [OVR_LBL(101)] = OVR_ELM(101),
5062 [OVR_LBL(102)] = OVR_ELM(102), [OVR_LBL(103)] = OVR_ELM(103),
5063 [OVR_LBL(104)] = OVR_ELM(104), [OVR_LBL(105)] = OVR_ELM(105),
5064 [OVR_LBL(106)] = OVR_ELM(106), [OVR_LBL(107)] = OVR_ELM(107),
5065 [OVR_LBL(108)] = OVR_ELM(108), [OVR_LBL(109)] = OVR_ELM(109),
5066 [OVR_LBL(110)] = OVR_ELM(110), [OVR_LBL(111)] = OVR_ELM(111),
5067 [OVR_LBL(112)] = OVR_ELM(112), [OVR_LBL(113)] = OVR_ELM(113),
5068 [OVR_LBL(114)] = OVR_ELM(114), [OVR_LBL(115)] = OVR_ELM(115),
5069 [OVR_LBL(116)] = OVR_ELM(116), [OVR_LBL(117)] = OVR_ELM(117),
5070 [OVR_LBL(118)] = OVR_ELM(118), [OVR_LBL(119)] = OVR_ELM(119),
5071 [OVR_LBL(120)] = OVR_ELM(120), [OVR_LBL(121)] = OVR_ELM(121),
5072 [OVR_LBL(122)] = OVR_ELM(122), [OVR_LBL(123)] = OVR_ELM(123),
5073 [OVR_LBL(124)] = OVR_ELM(124), [OVR_LBL(125)] = OVR_ELM(125),
5074 [OVR_LBL(126)] = OVR_ELM(126), [OVR_LBL(127)] = OVR_ELM(127),
5075 [OVR_LBL(128)] = OVR_ELM(128), [OVR_LBL(129)] = OVR_ELM(129),
5076 [OVR_LBL(130)] = OVR_ELM(130), [OVR_LBL(131)] = OVR_ELM(131),
5077 [OVR_LBL(132)] = OVR_ELM(132), [OVR_LBL(133)] = OVR_ELM(133),
5078 [OVR_LBL(134)] = OVR_ELM(134), [OVR_LBL(135)] = OVR_ELM(135),
5079 [OVR_LBL(136)] = OVR_ELM(136), [OVR_LBL(137)] = OVR_ELM(137),
5080 [OVR_LBL(138)] = OVR_ELM(138), [OVR_LBL(139)] = OVR_ELM(139),
5081 [OVR_LBL(140)] = OVR_ELM(140), [OVR_LBL(141)] = OVR_ELM(141),
5082 [OVR_LBL(142)] = OVR_ELM(142), [OVR_LBL(143)] = OVR_ELM(143),
5083 [OVR_LBL(144)] = OVR_ELM(144), [OVR_LBL(145)] = OVR_ELM(145),
5084 [OVR_LBL(146)] = OVR_ELM(146), [OVR_LBL(147)] = OVR_ELM(147),
5085 [OVR_LBL(148)] = OVR_ELM(148), [OVR_LBL(149)] = OVR_ELM(149),
5086 [OVR_LBL(150)] = OVR_ELM(150), [OVR_LBL(151)] = OVR_ELM(151),
5087 [OVR_LBL(152)] = OVR_ELM(152), [OVR_LBL(153)] = OVR_ELM(153),
5088 [OVR_LBL(154)] = OVR_ELM(154), [OVR_LBL(155)] = OVR_ELM(155),
5089 [OVR_LBL(156)] = OVR_ELM(156), [OVR_LBL(157)] = OVR_ELM(157),
5090 [OVR_LBL(158)] = OVR_ELM(158), [OVR_LBL(159)] = OVR_ELM(159),
5093 /* ======================================================================== */
5095 /* return true if this is chip revision revision a */
5096 int is_ax(struct hfi1_devdata *dd)
5099 dd->revision >> CCE_REVISION_CHIP_REV_MINOR_SHIFT
5100 & CCE_REVISION_CHIP_REV_MINOR_MASK;
5101 return (chip_rev_minor & 0xf0) == 0;
5104 /* return true if this is chip revision revision b */
5105 int is_bx(struct hfi1_devdata *dd)
5108 dd->revision >> CCE_REVISION_CHIP_REV_MINOR_SHIFT
5109 & CCE_REVISION_CHIP_REV_MINOR_MASK;
5110 return (chip_rev_minor & 0xF0) == 0x10;
5114 * Append string s to buffer buf. Arguments curp and len are the current
5115 * position and remaining length, respectively.
5117 * return 0 on success, 1 on out of room
5119 static int append_str(char *buf, char **curp, int *lenp, const char *s)
5123 int result = 0; /* success */
5126 /* add a comma, if first in the buffer */
5129 result = 1; /* out of room */
5136 /* copy the string */
5137 while ((c = *s++) != 0) {
5139 result = 1; /* out of room */
5147 /* write return values */
5155 * Using the given flag table, print a comma separated string into
5156 * the buffer. End in '*' if the buffer is too short.
5158 static char *flag_string(char *buf, int buf_len, u64 flags,
5159 struct flag_table *table, int table_size)
5167 /* make sure there is at least 2 so we can form "*" */
5171 len--; /* leave room for a nul */
5172 for (i = 0; i < table_size; i++) {
5173 if (flags & table[i].flag) {
5174 no_room = append_str(buf, &p, &len, table[i].str);
5177 flags &= ~table[i].flag;
5181 /* any undocumented bits left? */
5182 if (!no_room && flags) {
5183 snprintf(extra, sizeof(extra), "bits 0x%llx", flags);
5184 no_room = append_str(buf, &p, &len, extra);
5187 /* add * if ran out of room */
5189 /* may need to back up to add space for a '*' */
5195 /* add final nul - space already allocated above */
5200 /* first 8 CCE error interrupt source names */
5201 static const char * const cce_misc_names[] = {
5202 "CceErrInt", /* 0 */
5203 "RxeErrInt", /* 1 */
5204 "MiscErrInt", /* 2 */
5205 "Reserved3", /* 3 */
5206 "PioErrInt", /* 4 */
5207 "SDmaErrInt", /* 5 */
5208 "EgressErrInt", /* 6 */
5213 * Return the miscellaneous error interrupt name.
5215 static char *is_misc_err_name(char *buf, size_t bsize, unsigned int source)
5217 if (source < ARRAY_SIZE(cce_misc_names))
5218 strncpy(buf, cce_misc_names[source], bsize);
5223 source + IS_GENERAL_ERR_START);
5229 * Return the SDMA engine error interrupt name.
5231 static char *is_sdma_eng_err_name(char *buf, size_t bsize, unsigned int source)
5233 snprintf(buf, bsize, "SDmaEngErrInt%u", source);
5238 * Return the send context error interrupt name.
5240 static char *is_sendctxt_err_name(char *buf, size_t bsize, unsigned int source)
5242 snprintf(buf, bsize, "SendCtxtErrInt%u", source);
5246 static const char * const various_names[] = {
5255 * Return the various interrupt name.
5257 static char *is_various_name(char *buf, size_t bsize, unsigned int source)
5259 if (source < ARRAY_SIZE(various_names))
5260 strncpy(buf, various_names[source], bsize);
5262 snprintf(buf, bsize, "Reserved%u", source+IS_VARIOUS_START);
5267 * Return the DC interrupt name.
5269 static char *is_dc_name(char *buf, size_t bsize, unsigned int source)
5271 static const char * const dc_int_names[] = {
5275 "lbm" /* local block merge */
5278 if (source < ARRAY_SIZE(dc_int_names))
5279 snprintf(buf, bsize, "dc_%s_int", dc_int_names[source]);
5281 snprintf(buf, bsize, "DCInt%u", source);
5285 static const char * const sdma_int_names[] = {
5292 * Return the SDMA engine interrupt name.
5294 static char *is_sdma_eng_name(char *buf, size_t bsize, unsigned int source)
5296 /* what interrupt */
5297 unsigned int what = source / TXE_NUM_SDMA_ENGINES;
5299 unsigned int which = source % TXE_NUM_SDMA_ENGINES;
5301 if (likely(what < 3))
5302 snprintf(buf, bsize, "%s%u", sdma_int_names[what], which);
5304 snprintf(buf, bsize, "Invalid SDMA interrupt %u", source);
5309 * Return the receive available interrupt name.
5311 static char *is_rcv_avail_name(char *buf, size_t bsize, unsigned int source)
5313 snprintf(buf, bsize, "RcvAvailInt%u", source);
5318 * Return the receive urgent interrupt name.
5320 static char *is_rcv_urgent_name(char *buf, size_t bsize, unsigned int source)
5322 snprintf(buf, bsize, "RcvUrgentInt%u", source);
5327 * Return the send credit interrupt name.
5329 static char *is_send_credit_name(char *buf, size_t bsize, unsigned int source)
5331 snprintf(buf, bsize, "SendCreditInt%u", source);
5336 * Return the reserved interrupt name.
5338 static char *is_reserved_name(char *buf, size_t bsize, unsigned int source)
5340 snprintf(buf, bsize, "Reserved%u", source + IS_RESERVED_START);
5344 static char *cce_err_status_string(char *buf, int buf_len, u64 flags)
5346 return flag_string(buf, buf_len, flags,
5347 cce_err_status_flags, ARRAY_SIZE(cce_err_status_flags));
5350 static char *rxe_err_status_string(char *buf, int buf_len, u64 flags)
5352 return flag_string(buf, buf_len, flags,
5353 rxe_err_status_flags, ARRAY_SIZE(rxe_err_status_flags));
5356 static char *misc_err_status_string(char *buf, int buf_len, u64 flags)
5358 return flag_string(buf, buf_len, flags, misc_err_status_flags,
5359 ARRAY_SIZE(misc_err_status_flags));
5362 static char *pio_err_status_string(char *buf, int buf_len, u64 flags)
5364 return flag_string(buf, buf_len, flags,
5365 pio_err_status_flags, ARRAY_SIZE(pio_err_status_flags));
5368 static char *sdma_err_status_string(char *buf, int buf_len, u64 flags)
5370 return flag_string(buf, buf_len, flags,
5371 sdma_err_status_flags,
5372 ARRAY_SIZE(sdma_err_status_flags));
5375 static char *egress_err_status_string(char *buf, int buf_len, u64 flags)
5377 return flag_string(buf, buf_len, flags,
5378 egress_err_status_flags, ARRAY_SIZE(egress_err_status_flags));
5381 static char *egress_err_info_string(char *buf, int buf_len, u64 flags)
5383 return flag_string(buf, buf_len, flags,
5384 egress_err_info_flags, ARRAY_SIZE(egress_err_info_flags));
5387 static char *send_err_status_string(char *buf, int buf_len, u64 flags)
5389 return flag_string(buf, buf_len, flags,
5390 send_err_status_flags,
5391 ARRAY_SIZE(send_err_status_flags));
5394 static void handle_cce_err(struct hfi1_devdata *dd, u32 unused, u64 reg)
5400 * For most these errors, there is nothing that can be done except
5401 * report or record it.
5403 dd_dev_info(dd, "CCE Error: %s\n",
5404 cce_err_status_string(buf, sizeof(buf), reg));
5406 if ((reg & CCE_ERR_STATUS_CCE_CLI2_ASYNC_FIFO_PARITY_ERR_SMASK) &&
5407 is_ax(dd) && (dd->icode != ICODE_FUNCTIONAL_SIMULATOR)) {
5408 /* this error requires a manual drop into SPC freeze mode */
5410 start_freeze_handling(dd->pport, FREEZE_SELF);
5413 for (i = 0; i < NUM_CCE_ERR_STATUS_COUNTERS; i++) {
5414 if (reg & (1ull << i)) {
5415 incr_cntr64(&dd->cce_err_status_cnt[i]);
5416 /* maintain a counter over all cce_err_status errors */
5417 incr_cntr64(&dd->sw_cce_err_status_aggregate);
5423 * Check counters for receive errors that do not have an interrupt
5424 * associated with them.
5426 #define RCVERR_CHECK_TIME 10
5427 static void update_rcverr_timer(unsigned long opaque)
5429 struct hfi1_devdata *dd = (struct hfi1_devdata *)opaque;
5430 struct hfi1_pportdata *ppd = dd->pport;
5431 u32 cur_ovfl_cnt = read_dev_cntr(dd, C_RCV_OVF, CNTR_INVALID_VL);
5433 if (dd->rcv_ovfl_cnt < cur_ovfl_cnt &&
5434 ppd->port_error_action & OPA_PI_MASK_EX_BUFFER_OVERRUN) {
5435 dd_dev_info(dd, "%s: PortErrorAction bounce\n", __func__);
5436 set_link_down_reason(ppd,
5437 OPA_LINKDOWN_REASON_EXCESSIVE_BUFFER_OVERRUN, 0,
5438 OPA_LINKDOWN_REASON_EXCESSIVE_BUFFER_OVERRUN);
5439 queue_work(ppd->hfi1_wq, &ppd->link_bounce_work);
5441 dd->rcv_ovfl_cnt = (u32) cur_ovfl_cnt;
5443 mod_timer(&dd->rcverr_timer, jiffies + HZ * RCVERR_CHECK_TIME);
5446 static int init_rcverr(struct hfi1_devdata *dd)
5448 setup_timer(&dd->rcverr_timer, update_rcverr_timer, (unsigned long)dd);
5449 /* Assume the hardware counter has been reset */
5450 dd->rcv_ovfl_cnt = 0;
5451 return mod_timer(&dd->rcverr_timer, jiffies + HZ * RCVERR_CHECK_TIME);
5454 static void free_rcverr(struct hfi1_devdata *dd)
5456 if (dd->rcverr_timer.data)
5457 del_timer_sync(&dd->rcverr_timer);
5458 dd->rcverr_timer.data = 0;
5461 static void handle_rxe_err(struct hfi1_devdata *dd, u32 unused, u64 reg)
5466 dd_dev_info(dd, "Receive Error: %s\n",
5467 rxe_err_status_string(buf, sizeof(buf), reg));
5469 if (reg & ALL_RXE_FREEZE_ERR) {
5473 * Freeze mode recovery is disabled for the errors
5474 * in RXE_FREEZE_ABORT_MASK
5476 if (is_ax(dd) && (reg & RXE_FREEZE_ABORT_MASK))
5477 flags = FREEZE_ABORT;
5479 start_freeze_handling(dd->pport, flags);
5482 for (i = 0; i < NUM_RCV_ERR_STATUS_COUNTERS; i++) {
5483 if (reg & (1ull << i))
5484 incr_cntr64(&dd->rcv_err_status_cnt[i]);
5488 static void handle_misc_err(struct hfi1_devdata *dd, u32 unused, u64 reg)
5493 dd_dev_info(dd, "Misc Error: %s",
5494 misc_err_status_string(buf, sizeof(buf), reg));
5495 for (i = 0; i < NUM_MISC_ERR_STATUS_COUNTERS; i++) {
5496 if (reg & (1ull << i))
5497 incr_cntr64(&dd->misc_err_status_cnt[i]);
5501 static void handle_pio_err(struct hfi1_devdata *dd, u32 unused, u64 reg)
5506 dd_dev_info(dd, "PIO Error: %s\n",
5507 pio_err_status_string(buf, sizeof(buf), reg));
5509 if (reg & ALL_PIO_FREEZE_ERR)
5510 start_freeze_handling(dd->pport, 0);
5512 for (i = 0; i < NUM_SEND_PIO_ERR_STATUS_COUNTERS; i++) {
5513 if (reg & (1ull << i))
5514 incr_cntr64(&dd->send_pio_err_status_cnt[i]);
5518 static void handle_sdma_err(struct hfi1_devdata *dd, u32 unused, u64 reg)
5523 dd_dev_info(dd, "SDMA Error: %s\n",
5524 sdma_err_status_string(buf, sizeof(buf), reg));
5526 if (reg & ALL_SDMA_FREEZE_ERR)
5527 start_freeze_handling(dd->pport, 0);
5529 for (i = 0; i < NUM_SEND_DMA_ERR_STATUS_COUNTERS; i++) {
5530 if (reg & (1ull << i))
5531 incr_cntr64(&dd->send_dma_err_status_cnt[i]);
5535 static inline void __count_port_discards(struct hfi1_pportdata *ppd)
5537 incr_cntr64(&ppd->port_xmit_discards);
5540 static void count_port_inactive(struct hfi1_devdata *dd)
5542 __count_port_discards(dd->pport);
5546 * We have had a "disallowed packet" error during egress. Determine the
5547 * integrity check which failed, and update relevant error counter, etc.
5549 * Note that the SEND_EGRESS_ERR_INFO register has only a single
5550 * bit of state per integrity check, and so we can miss the reason for an
5551 * egress error if more than one packet fails the same integrity check
5552 * since we cleared the corresponding bit in SEND_EGRESS_ERR_INFO.
5554 static void handle_send_egress_err_info(struct hfi1_devdata *dd,
5557 struct hfi1_pportdata *ppd = dd->pport;
5558 u64 src = read_csr(dd, SEND_EGRESS_ERR_SOURCE); /* read first */
5559 u64 info = read_csr(dd, SEND_EGRESS_ERR_INFO);
5562 /* clear down all observed info as quickly as possible after read */
5563 write_csr(dd, SEND_EGRESS_ERR_INFO, info);
5566 "Egress Error Info: 0x%llx, %s Egress Error Src 0x%llx\n",
5567 info, egress_err_info_string(buf, sizeof(buf), info), src);
5569 /* Eventually add other counters for each bit */
5570 if (info & PORT_DISCARD_EGRESS_ERRS) {
5574 * Count all, in case multiple bits are set. Reminder:
5575 * since there is only one info register for many sources,
5576 * these may be attributed to the wrong VL if they occur
5577 * too close together.
5579 weight = hweight64(info);
5580 for (i = 0; i < weight; i++) {
5581 __count_port_discards(ppd);
5582 if (vl >= 0 && vl < TXE_NUM_DATA_VL)
5583 incr_cntr64(&ppd->port_xmit_discards_vl[vl]);
5585 incr_cntr64(&ppd->port_xmit_discards_vl
5592 * Input value is a bit position within the SEND_EGRESS_ERR_STATUS
5593 * register. Does it represent a 'port inactive' error?
5595 static inline int port_inactive_err(u64 posn)
5597 return (posn >= SEES(TX_LINKDOWN) &&
5598 posn <= SEES(TX_INCORRECT_LINK_STATE));
5602 * Input value is a bit position within the SEND_EGRESS_ERR_STATUS
5603 * register. Does it represent a 'disallowed packet' error?
5605 static inline int disallowed_pkt_err(int posn)
5607 return (posn >= SEES(TX_SDMA0_DISALLOWED_PACKET) &&
5608 posn <= SEES(TX_SDMA15_DISALLOWED_PACKET));
5612 * Input value is a bit position of one of the SDMA engine disallowed
5613 * packet errors. Return which engine. Use of this must be guarded by
5614 * disallowed_pkt_err().
5616 static inline int disallowed_pkt_engine(int posn)
5618 return posn - SEES(TX_SDMA0_DISALLOWED_PACKET);
5622 * Translate an SDMA engine to a VL. Return -1 if the tranlation cannot
5625 static int engine_to_vl(struct hfi1_devdata *dd, int engine)
5627 struct sdma_vl_map *m;
5631 if (engine < 0 || engine >= TXE_NUM_SDMA_ENGINES)
5635 m = rcu_dereference(dd->sdma_map);
5636 vl = m->engine_to_vl[engine];
5643 * Translate the send context (sofware index) into a VL. Return -1 if the
5644 * translation cannot be done.
5646 static int sc_to_vl(struct hfi1_devdata *dd, int sw_index)
5648 struct send_context_info *sci;
5649 struct send_context *sc;
5652 sci = &dd->send_contexts[sw_index];
5654 /* there is no information for user (PSM) and ack contexts */
5655 if (sci->type != SC_KERNEL)
5661 if (dd->vld[15].sc == sc)
5663 for (i = 0; i < num_vls; i++)
5664 if (dd->vld[i].sc == sc)
5670 static void handle_egress_err(struct hfi1_devdata *dd, u32 unused, u64 reg)
5672 u64 reg_copy = reg, handled = 0;
5676 if (reg & ALL_TXE_EGRESS_FREEZE_ERR)
5677 start_freeze_handling(dd->pport, 0);
5678 else if (is_ax(dd) &&
5679 (reg & SEND_EGRESS_ERR_STATUS_TX_CREDIT_RETURN_VL_ERR_SMASK) &&
5680 (dd->icode != ICODE_FUNCTIONAL_SIMULATOR))
5681 start_freeze_handling(dd->pport, 0);
5684 int posn = fls64(reg_copy);
5685 /* fls64() returns a 1-based offset, we want it zero based */
5686 int shift = posn - 1;
5687 u64 mask = 1ULL << shift;
5689 if (port_inactive_err(shift)) {
5690 count_port_inactive(dd);
5692 } else if (disallowed_pkt_err(shift)) {
5693 int vl = engine_to_vl(dd, disallowed_pkt_engine(shift));
5695 handle_send_egress_err_info(dd, vl);
5704 dd_dev_info(dd, "Egress Error: %s\n",
5705 egress_err_status_string(buf, sizeof(buf), reg));
5707 for (i = 0; i < NUM_SEND_EGRESS_ERR_STATUS_COUNTERS; i++) {
5708 if (reg & (1ull << i))
5709 incr_cntr64(&dd->send_egress_err_status_cnt[i]);
5713 static void handle_txe_err(struct hfi1_devdata *dd, u32 unused, u64 reg)
5718 dd_dev_info(dd, "Send Error: %s\n",
5719 send_err_status_string(buf, sizeof(buf), reg));
5721 for (i = 0; i < NUM_SEND_ERR_STATUS_COUNTERS; i++) {
5722 if (reg & (1ull << i))
5723 incr_cntr64(&dd->send_err_status_cnt[i]);
5728 * The maximum number of times the error clear down will loop before
5729 * blocking a repeating error. This value is arbitrary.
5731 #define MAX_CLEAR_COUNT 20
5734 * Clear and handle an error register. All error interrupts are funneled
5735 * through here to have a central location to correctly handle single-
5736 * or multi-shot errors.
5738 * For non per-context registers, call this routine with a context value
5739 * of 0 so the per-context offset is zero.
5741 * If the handler loops too many times, assume that something is wrong
5742 * and can't be fixed, so mask the error bits.
5744 static void interrupt_clear_down(struct hfi1_devdata *dd,
5746 const struct err_reg_info *eri)
5751 /* read in a loop until no more errors are seen */
5754 reg = read_kctxt_csr(dd, context, eri->status);
5757 write_kctxt_csr(dd, context, eri->clear, reg);
5758 if (likely(eri->handler))
5759 eri->handler(dd, context, reg);
5761 if (count > MAX_CLEAR_COUNT) {
5764 dd_dev_err(dd, "Repeating %s bits 0x%llx - masking\n",
5767 * Read-modify-write so any other masked bits
5770 mask = read_kctxt_csr(dd, context, eri->mask);
5772 write_kctxt_csr(dd, context, eri->mask, mask);
5779 * CCE block "misc" interrupt. Source is < 16.
5781 static void is_misc_err_int(struct hfi1_devdata *dd, unsigned int source)
5783 const struct err_reg_info *eri = &misc_errs[source];
5786 interrupt_clear_down(dd, 0, eri);
5788 dd_dev_err(dd, "Unexpected misc interrupt (%u) - reserved\n",
5793 static char *send_context_err_status_string(char *buf, int buf_len, u64 flags)
5795 return flag_string(buf, buf_len, flags,
5796 sc_err_status_flags, ARRAY_SIZE(sc_err_status_flags));
5800 * Send context error interrupt. Source (hw_context) is < 160.
5802 * All send context errors cause the send context to halt. The normal
5803 * clear-down mechanism cannot be used because we cannot clear the
5804 * error bits until several other long-running items are done first.
5805 * This is OK because with the context halted, nothing else is going
5806 * to happen on it anyway.
5808 static void is_sendctxt_err_int(struct hfi1_devdata *dd,
5809 unsigned int hw_context)
5811 struct send_context_info *sci;
5812 struct send_context *sc;
5818 sw_index = dd->hw_to_sw[hw_context];
5819 if (sw_index >= dd->num_send_contexts) {
5821 "out of range sw index %u for send context %u\n",
5822 sw_index, hw_context);
5825 sci = &dd->send_contexts[sw_index];
5828 dd_dev_err(dd, "%s: context %u(%u): no sc?\n", __func__,
5829 sw_index, hw_context);
5833 /* tell the software that a halt has begun */
5834 sc_stop(sc, SCF_HALTED);
5836 status = read_kctxt_csr(dd, hw_context, SEND_CTXT_ERR_STATUS);
5838 dd_dev_info(dd, "Send Context %u(%u) Error: %s\n", sw_index, hw_context,
5839 send_context_err_status_string(flags, sizeof(flags), status));
5841 if (status & SEND_CTXT_ERR_STATUS_PIO_DISALLOWED_PACKET_ERR_SMASK)
5842 handle_send_egress_err_info(dd, sc_to_vl(dd, sw_index));
5845 * Automatically restart halted kernel contexts out of interrupt
5846 * context. User contexts must ask the driver to restart the context.
5848 if (sc->type != SC_USER)
5849 queue_work(dd->pport->hfi1_wq, &sc->halt_work);
5852 * Update the counters for the corresponding status bits.
5853 * Note that these particular counters are aggregated over all
5856 for (i = 0; i < NUM_SEND_CTXT_ERR_STATUS_COUNTERS; i++) {
5857 if (status & (1ull << i))
5858 incr_cntr64(&dd->sw_ctxt_err_status_cnt[i]);
5862 static void handle_sdma_eng_err(struct hfi1_devdata *dd,
5863 unsigned int source, u64 status)
5865 struct sdma_engine *sde;
5868 sde = &dd->per_sdma[source];
5869 #ifdef CONFIG_SDMA_VERBOSITY
5870 dd_dev_err(sde->dd, "CONFIG SDMA(%u) %s:%d %s()\n", sde->this_idx,
5871 slashstrip(__FILE__), __LINE__, __func__);
5872 dd_dev_err(sde->dd, "CONFIG SDMA(%u) source: %u status 0x%llx\n",
5873 sde->this_idx, source, (unsigned long long)status);
5876 sdma_engine_error(sde, status);
5879 * Update the counters for the corresponding status bits.
5880 * Note that these particular counters are aggregated over
5881 * all 16 DMA engines.
5883 for (i = 0; i < NUM_SEND_DMA_ENG_ERR_STATUS_COUNTERS; i++) {
5884 if (status & (1ull << i))
5885 incr_cntr64(&dd->sw_send_dma_eng_err_status_cnt[i]);
5890 * CCE block SDMA error interrupt. Source is < 16.
5892 static void is_sdma_eng_err_int(struct hfi1_devdata *dd, unsigned int source)
5894 #ifdef CONFIG_SDMA_VERBOSITY
5895 struct sdma_engine *sde = &dd->per_sdma[source];
5897 dd_dev_err(dd, "CONFIG SDMA(%u) %s:%d %s()\n", sde->this_idx,
5898 slashstrip(__FILE__), __LINE__, __func__);
5899 dd_dev_err(dd, "CONFIG SDMA(%u) source: %u\n", sde->this_idx,
5901 sdma_dumpstate(sde);
5903 interrupt_clear_down(dd, source, &sdma_eng_err);
5907 * CCE block "various" interrupt. Source is < 8.
5909 static void is_various_int(struct hfi1_devdata *dd, unsigned int source)
5911 const struct err_reg_info *eri = &various_err[source];
5914 * TCritInt cannot go through interrupt_clear_down()
5915 * because it is not a second tier interrupt. The handler
5916 * should be called directly.
5918 if (source == TCRIT_INT_SOURCE)
5919 handle_temp_err(dd);
5920 else if (eri->handler)
5921 interrupt_clear_down(dd, 0, eri);
5924 "%s: Unimplemented/reserved interrupt %d\n",
5928 static void handle_qsfp_int(struct hfi1_devdata *dd, u32 src_ctx, u64 reg)
5930 /* src_ctx is always zero */
5931 struct hfi1_pportdata *ppd = dd->pport;
5932 unsigned long flags;
5933 u64 qsfp_int_mgmt = (u64)(QSFP_HFI0_INT_N | QSFP_HFI0_MODPRST_N);
5935 if (reg & QSFP_HFI0_MODPRST_N) {
5937 dd_dev_info(dd, "%s: ModPresent triggered QSFP interrupt\n",
5940 if (!qsfp_mod_present(ppd)) {
5941 ppd->driver_link_ready = 0;
5943 * Cable removed, reset all our information about the
5944 * cache and cable capabilities
5947 spin_lock_irqsave(&ppd->qsfp_info.qsfp_lock, flags);
5949 * We don't set cache_refresh_required here as we expect
5950 * an interrupt when a cable is inserted
5952 ppd->qsfp_info.cache_valid = 0;
5953 ppd->qsfp_info.reset_needed = 0;
5954 ppd->qsfp_info.limiting_active = 0;
5955 spin_unlock_irqrestore(&ppd->qsfp_info.qsfp_lock,
5957 /* Invert the ModPresent pin now to detect plug-in */
5958 write_csr(dd, dd->hfi1_id ? ASIC_QSFP2_INVERT :
5959 ASIC_QSFP1_INVERT, qsfp_int_mgmt);
5961 if ((ppd->offline_disabled_reason >
5963 OPA_LINKDOWN_REASON_LOCAL_MEDIA_NOT_INSTALLED)) ||
5964 (ppd->offline_disabled_reason ==
5965 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_NONE)))
5966 ppd->offline_disabled_reason =
5968 OPA_LINKDOWN_REASON_LOCAL_MEDIA_NOT_INSTALLED);
5970 if (ppd->host_link_state == HLS_DN_POLL) {
5972 * The link is still in POLL. This means
5973 * that the normal link down processing
5974 * will not happen. We have to do it here
5975 * before turning the DC off.
5977 queue_work(ppd->hfi1_wq, &ppd->link_down_work);
5980 spin_lock_irqsave(&ppd->qsfp_info.qsfp_lock, flags);
5981 ppd->qsfp_info.cache_valid = 0;
5982 ppd->qsfp_info.cache_refresh_required = 1;
5983 spin_unlock_irqrestore(&ppd->qsfp_info.qsfp_lock,
5987 * Stop inversion of ModPresent pin to detect
5988 * removal of the cable
5990 qsfp_int_mgmt &= ~(u64)QSFP_HFI0_MODPRST_N;
5991 write_csr(dd, dd->hfi1_id ? ASIC_QSFP2_INVERT :
5992 ASIC_QSFP1_INVERT, qsfp_int_mgmt);
5994 ppd->offline_disabled_reason =
5995 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_TRANSIENT);
5999 if (reg & QSFP_HFI0_INT_N) {
6001 dd_dev_info(dd, "%s: IntN triggered QSFP interrupt\n",
6003 spin_lock_irqsave(&ppd->qsfp_info.qsfp_lock, flags);
6004 ppd->qsfp_info.check_interrupt_flags = 1;
6005 spin_unlock_irqrestore(&ppd->qsfp_info.qsfp_lock, flags);
6008 /* Schedule the QSFP work only if there is a cable attached. */
6009 if (qsfp_mod_present(ppd))
6010 queue_work(ppd->hfi1_wq, &ppd->qsfp_info.qsfp_work);
6013 static int request_host_lcb_access(struct hfi1_devdata *dd)
6017 ret = do_8051_command(dd, HCMD_MISC,
6018 (u64)HCMD_MISC_REQUEST_LCB_ACCESS << LOAD_DATA_FIELD_ID_SHIFT,
6020 if (ret != HCMD_SUCCESS) {
6021 dd_dev_err(dd, "%s: command failed with error %d\n",
6024 return ret == HCMD_SUCCESS ? 0 : -EBUSY;
6027 static int request_8051_lcb_access(struct hfi1_devdata *dd)
6031 ret = do_8051_command(dd, HCMD_MISC,
6032 (u64)HCMD_MISC_GRANT_LCB_ACCESS << LOAD_DATA_FIELD_ID_SHIFT,
6034 if (ret != HCMD_SUCCESS) {
6035 dd_dev_err(dd, "%s: command failed with error %d\n",
6038 return ret == HCMD_SUCCESS ? 0 : -EBUSY;
6042 * Set the LCB selector - allow host access. The DCC selector always
6043 * points to the host.
6045 static inline void set_host_lcb_access(struct hfi1_devdata *dd)
6047 write_csr(dd, DC_DC8051_CFG_CSR_ACCESS_SEL,
6048 DC_DC8051_CFG_CSR_ACCESS_SEL_DCC_SMASK
6049 | DC_DC8051_CFG_CSR_ACCESS_SEL_LCB_SMASK);
6053 * Clear the LCB selector - allow 8051 access. The DCC selector always
6054 * points to the host.
6056 static inline void set_8051_lcb_access(struct hfi1_devdata *dd)
6058 write_csr(dd, DC_DC8051_CFG_CSR_ACCESS_SEL,
6059 DC_DC8051_CFG_CSR_ACCESS_SEL_DCC_SMASK);
6063 * Acquire LCB access from the 8051. If the host already has access,
6064 * just increment a counter. Otherwise, inform the 8051 that the
6065 * host is taking access.
6069 * -EBUSY if the 8051 has control and cannot be disturbed
6070 * -errno if unable to acquire access from the 8051
6072 int acquire_lcb_access(struct hfi1_devdata *dd, int sleep_ok)
6074 struct hfi1_pportdata *ppd = dd->pport;
6078 * Use the host link state lock so the operation of this routine
6079 * { link state check, selector change, count increment } can occur
6080 * as a unit against a link state change. Otherwise there is a
6081 * race between the state change and the count increment.
6084 mutex_lock(&ppd->hls_lock);
6086 while (!mutex_trylock(&ppd->hls_lock))
6090 /* this access is valid only when the link is up */
6091 if ((ppd->host_link_state & HLS_UP) == 0) {
6092 dd_dev_info(dd, "%s: link state %s not up\n",
6093 __func__, link_state_name(ppd->host_link_state));
6098 if (dd->lcb_access_count == 0) {
6099 ret = request_host_lcb_access(dd);
6102 "%s: unable to acquire LCB access, err %d\n",
6106 set_host_lcb_access(dd);
6108 dd->lcb_access_count++;
6110 mutex_unlock(&ppd->hls_lock);
6115 * Release LCB access by decrementing the use count. If the count is moving
6116 * from 1 to 0, inform 8051 that it has control back.
6120 * -errno if unable to release access to the 8051
6122 int release_lcb_access(struct hfi1_devdata *dd, int sleep_ok)
6127 * Use the host link state lock because the acquire needed it.
6128 * Here, we only need to keep { selector change, count decrement }
6132 mutex_lock(&dd->pport->hls_lock);
6134 while (!mutex_trylock(&dd->pport->hls_lock))
6138 if (dd->lcb_access_count == 0) {
6139 dd_dev_err(dd, "%s: LCB access count is zero. Skipping.\n",
6144 if (dd->lcb_access_count == 1) {
6145 set_8051_lcb_access(dd);
6146 ret = request_8051_lcb_access(dd);
6149 "%s: unable to release LCB access, err %d\n",
6151 /* restore host access if the grant didn't work */
6152 set_host_lcb_access(dd);
6156 dd->lcb_access_count--;
6158 mutex_unlock(&dd->pport->hls_lock);
6163 * Initialize LCB access variables and state. Called during driver load,
6164 * after most of the initialization is finished.
6166 * The DC default is LCB access on for the host. The driver defaults to
6167 * leaving access to the 8051. Assign access now - this constrains the call
6168 * to this routine to be after all LCB set-up is done. In particular, after
6169 * hf1_init_dd() -> set_up_interrupts() -> clear_all_interrupts()
6171 static void init_lcb_access(struct hfi1_devdata *dd)
6173 dd->lcb_access_count = 0;
6177 * Write a response back to a 8051 request.
6179 static void hreq_response(struct hfi1_devdata *dd, u8 return_code, u16 rsp_data)
6181 write_csr(dd, DC_DC8051_CFG_EXT_DEV_0,
6182 DC_DC8051_CFG_EXT_DEV_0_COMPLETED_SMASK
6183 | (u64)return_code << DC_DC8051_CFG_EXT_DEV_0_RETURN_CODE_SHIFT
6184 | (u64)rsp_data << DC_DC8051_CFG_EXT_DEV_0_RSP_DATA_SHIFT);
6188 * Handle host requests from the 8051.
6190 * This is a work-queue function outside of the interrupt.
6192 void handle_8051_request(struct work_struct *work)
6194 struct hfi1_pportdata *ppd = container_of(work, struct hfi1_pportdata,
6196 struct hfi1_devdata *dd = ppd->dd;
6199 u8 type, i, lanes, *cache = ppd->qsfp_info.cache;
6200 u8 cdr_ctrl_byte = cache[QSFP_CDR_CTRL_BYTE_OFFS];
6202 reg = read_csr(dd, DC_DC8051_CFG_EXT_DEV_1);
6203 if ((reg & DC_DC8051_CFG_EXT_DEV_1_REQ_NEW_SMASK) == 0)
6204 return; /* no request */
6206 /* zero out COMPLETED so the response is seen */
6207 write_csr(dd, DC_DC8051_CFG_EXT_DEV_0, 0);
6209 /* extract request details */
6210 type = (reg >> DC_DC8051_CFG_EXT_DEV_1_REQ_TYPE_SHIFT)
6211 & DC_DC8051_CFG_EXT_DEV_1_REQ_TYPE_MASK;
6212 data = (reg >> DC_DC8051_CFG_EXT_DEV_1_REQ_DATA_SHIFT)
6213 & DC_DC8051_CFG_EXT_DEV_1_REQ_DATA_MASK;
6216 case HREQ_LOAD_CONFIG:
6217 case HREQ_SAVE_CONFIG:
6218 case HREQ_READ_CONFIG:
6219 case HREQ_SET_TX_EQ_ABS:
6220 case HREQ_SET_TX_EQ_REL:
6221 dd_dev_info(dd, "8051 request: request 0x%x not supported\n",
6223 hreq_response(dd, HREQ_NOT_SUPPORTED, 0);
6228 for (i = 0; lanes; lanes >>= 1, i++) {
6233 if (cache[QSFP_MOD_PWR_OFFS] & 0x8 &&
6234 cache[QSFP_CDR_INFO_OFFS] & 0x80)
6235 cdr_ctrl_byte |= (1 << (i + 4));
6237 /* disable TX CDR */
6238 if (cache[QSFP_MOD_PWR_OFFS] & 0x8 &&
6239 cache[QSFP_CDR_INFO_OFFS] & 0x80)
6240 cdr_ctrl_byte &= ~(1 << (i + 4));
6245 if (cache[QSFP_MOD_PWR_OFFS] & 0x4 &&
6246 cache[QSFP_CDR_INFO_OFFS] & 0x40)
6247 cdr_ctrl_byte |= (1 << i);
6249 /* disable RX CDR */
6250 if (cache[QSFP_MOD_PWR_OFFS] & 0x4 &&
6251 cache[QSFP_CDR_INFO_OFFS] & 0x40)
6252 cdr_ctrl_byte &= ~(1 << i);
6255 qsfp_write(ppd, ppd->dd->hfi1_id, QSFP_CDR_CTRL_BYTE_OFFS,
6257 hreq_response(dd, HREQ_SUCCESS, data);
6258 refresh_qsfp_cache(ppd, &ppd->qsfp_info);
6261 case HREQ_CONFIG_DONE:
6262 hreq_response(dd, HREQ_SUCCESS, 0);
6265 case HREQ_INTERFACE_TEST:
6266 hreq_response(dd, HREQ_SUCCESS, data);
6270 dd_dev_err(dd, "8051 request: unknown request 0x%x\n", type);
6271 hreq_response(dd, HREQ_NOT_SUPPORTED, 0);
6276 static void write_global_credit(struct hfi1_devdata *dd,
6277 u8 vau, u16 total, u16 shared)
6279 write_csr(dd, SEND_CM_GLOBAL_CREDIT,
6281 << SEND_CM_GLOBAL_CREDIT_TOTAL_CREDIT_LIMIT_SHIFT)
6283 << SEND_CM_GLOBAL_CREDIT_SHARED_LIMIT_SHIFT)
6284 | ((u64)vau << SEND_CM_GLOBAL_CREDIT_AU_SHIFT));
6288 * Set up initial VL15 credits of the remote. Assumes the rest of
6289 * the CM credit registers are zero from a previous global or credit reset .
6291 void set_up_vl15(struct hfi1_devdata *dd, u8 vau, u16 vl15buf)
6293 /* leave shared count at zero for both global and VL15 */
6294 write_global_credit(dd, vau, vl15buf, 0);
6296 /* We may need some credits for another VL when sending packets
6297 * with the snoop interface. Dividing it down the middle for VL15
6298 * and VL0 should suffice.
6300 if (unlikely(dd->hfi1_snoop.mode_flag == HFI1_PORT_SNOOP_MODE)) {
6301 write_csr(dd, SEND_CM_CREDIT_VL15, (u64)(vl15buf >> 1)
6302 << SEND_CM_CREDIT_VL15_DEDICATED_LIMIT_VL_SHIFT);
6303 write_csr(dd, SEND_CM_CREDIT_VL, (u64)(vl15buf >> 1)
6304 << SEND_CM_CREDIT_VL_DEDICATED_LIMIT_VL_SHIFT);
6306 write_csr(dd, SEND_CM_CREDIT_VL15, (u64)vl15buf
6307 << SEND_CM_CREDIT_VL15_DEDICATED_LIMIT_VL_SHIFT);
6312 * Zero all credit details from the previous connection and
6313 * reset the CM manager's internal counters.
6315 void reset_link_credits(struct hfi1_devdata *dd)
6319 /* remove all previous VL credit limits */
6320 for (i = 0; i < TXE_NUM_DATA_VL; i++)
6321 write_csr(dd, SEND_CM_CREDIT_VL + (8*i), 0);
6322 write_csr(dd, SEND_CM_CREDIT_VL15, 0);
6323 write_global_credit(dd, 0, 0, 0);
6324 /* reset the CM block */
6325 pio_send_control(dd, PSC_CM_RESET);
6328 /* convert a vCU to a CU */
6329 static u32 vcu_to_cu(u8 vcu)
6334 /* convert a CU to a vCU */
6335 static u8 cu_to_vcu(u32 cu)
6340 /* convert a vAU to an AU */
6341 static u32 vau_to_au(u8 vau)
6343 return 8 * (1 << vau);
6346 static void set_linkup_defaults(struct hfi1_pportdata *ppd)
6348 ppd->sm_trap_qp = 0x0;
6353 * Graceful LCB shutdown. This leaves the LCB FIFOs in reset.
6355 static void lcb_shutdown(struct hfi1_devdata *dd, int abort)
6359 /* clear lcb run: LCB_CFG_RUN.EN = 0 */
6360 write_csr(dd, DC_LCB_CFG_RUN, 0);
6361 /* set tx fifo reset: LCB_CFG_TX_FIFOS_RESET.VAL = 1 */
6362 write_csr(dd, DC_LCB_CFG_TX_FIFOS_RESET,
6363 1ull << DC_LCB_CFG_TX_FIFOS_RESET_VAL_SHIFT);
6364 /* set dcc reset csr: DCC_CFG_RESET.{reset_lcb,reset_rx_fpe} = 1 */
6365 dd->lcb_err_en = read_csr(dd, DC_LCB_ERR_EN);
6366 reg = read_csr(dd, DCC_CFG_RESET);
6367 write_csr(dd, DCC_CFG_RESET,
6369 | (1ull << DCC_CFG_RESET_RESET_LCB_SHIFT)
6370 | (1ull << DCC_CFG_RESET_RESET_RX_FPE_SHIFT));
6371 (void) read_csr(dd, DCC_CFG_RESET); /* make sure the write completed */
6373 udelay(1); /* must hold for the longer of 16cclks or 20ns */
6374 write_csr(dd, DCC_CFG_RESET, reg);
6375 write_csr(dd, DC_LCB_ERR_EN, dd->lcb_err_en);
6380 * This routine should be called after the link has been transitioned to
6381 * OFFLINE (OFFLINE state has the side effect of putting the SerDes into
6384 * The expectation is that the caller of this routine would have taken
6385 * care of properly transitioning the link into the correct state.
6387 static void dc_shutdown(struct hfi1_devdata *dd)
6389 unsigned long flags;
6391 spin_lock_irqsave(&dd->dc8051_lock, flags);
6392 if (dd->dc_shutdown) {
6393 spin_unlock_irqrestore(&dd->dc8051_lock, flags);
6396 dd->dc_shutdown = 1;
6397 spin_unlock_irqrestore(&dd->dc8051_lock, flags);
6398 /* Shutdown the LCB */
6399 lcb_shutdown(dd, 1);
6400 /* Going to OFFLINE would have causes the 8051 to put the
6401 * SerDes into reset already. Just need to shut down the 8051,
6403 write_csr(dd, DC_DC8051_CFG_RST, 0x1);
6406 /* Calling this after the DC has been brought out of reset should not
6408 static void dc_start(struct hfi1_devdata *dd)
6410 unsigned long flags;
6413 spin_lock_irqsave(&dd->dc8051_lock, flags);
6414 if (!dd->dc_shutdown)
6416 spin_unlock_irqrestore(&dd->dc8051_lock, flags);
6417 /* Take the 8051 out of reset */
6418 write_csr(dd, DC_DC8051_CFG_RST, 0ull);
6419 /* Wait until 8051 is ready */
6420 ret = wait_fm_ready(dd, TIMEOUT_8051_START);
6422 dd_dev_err(dd, "%s: timeout starting 8051 firmware\n",
6425 /* Take away reset for LCB and RX FPE (set in lcb_shutdown). */
6426 write_csr(dd, DCC_CFG_RESET, 0x10);
6427 /* lcb_shutdown() with abort=1 does not restore these */
6428 write_csr(dd, DC_LCB_ERR_EN, dd->lcb_err_en);
6429 spin_lock_irqsave(&dd->dc8051_lock, flags);
6430 dd->dc_shutdown = 0;
6432 spin_unlock_irqrestore(&dd->dc8051_lock, flags);
6436 * These LCB adjustments are for the Aurora SerDes core in the FPGA.
6438 static void adjust_lcb_for_fpga_serdes(struct hfi1_devdata *dd)
6440 u64 rx_radr, tx_radr;
6443 if (dd->icode != ICODE_FPGA_EMULATION)
6447 * These LCB defaults on emulator _s are good, nothing to do here:
6448 * LCB_CFG_TX_FIFOS_RADR
6449 * LCB_CFG_RX_FIFOS_RADR
6451 * LCB_CFG_IGNORE_LOST_RCLK
6453 if (is_emulator_s(dd))
6455 /* else this is _p */
6457 version = emulator_rev(dd);
6459 version = 0x2d; /* all B0 use 0x2d or higher settings */
6461 if (version <= 0x12) {
6462 /* release 0x12 and below */
6465 * LCB_CFG_RX_FIFOS_RADR.RST_VAL = 0x9
6466 * LCB_CFG_RX_FIFOS_RADR.OK_TO_JUMP_VAL = 0x9
6467 * LCB_CFG_RX_FIFOS_RADR.DO_NOT_JUMP_VAL = 0xa
6470 0xaull << DC_LCB_CFG_RX_FIFOS_RADR_DO_NOT_JUMP_VAL_SHIFT
6471 | 0x9ull << DC_LCB_CFG_RX_FIFOS_RADR_OK_TO_JUMP_VAL_SHIFT
6472 | 0x9ull << DC_LCB_CFG_RX_FIFOS_RADR_RST_VAL_SHIFT;
6474 * LCB_CFG_TX_FIFOS_RADR.ON_REINIT = 0 (default)
6475 * LCB_CFG_TX_FIFOS_RADR.RST_VAL = 6
6477 tx_radr = 6ull << DC_LCB_CFG_TX_FIFOS_RADR_RST_VAL_SHIFT;
6478 } else if (version <= 0x18) {
6479 /* release 0x13 up to 0x18 */
6480 /* LCB_CFG_RX_FIFOS_RADR = 0x988 */
6482 0x9ull << DC_LCB_CFG_RX_FIFOS_RADR_DO_NOT_JUMP_VAL_SHIFT
6483 | 0x8ull << DC_LCB_CFG_RX_FIFOS_RADR_OK_TO_JUMP_VAL_SHIFT
6484 | 0x8ull << DC_LCB_CFG_RX_FIFOS_RADR_RST_VAL_SHIFT;
6485 tx_radr = 7ull << DC_LCB_CFG_TX_FIFOS_RADR_RST_VAL_SHIFT;
6486 } else if (version == 0x19) {
6488 /* LCB_CFG_RX_FIFOS_RADR = 0xa99 */
6490 0xAull << DC_LCB_CFG_RX_FIFOS_RADR_DO_NOT_JUMP_VAL_SHIFT
6491 | 0x9ull << DC_LCB_CFG_RX_FIFOS_RADR_OK_TO_JUMP_VAL_SHIFT
6492 | 0x9ull << DC_LCB_CFG_RX_FIFOS_RADR_RST_VAL_SHIFT;
6493 tx_radr = 3ull << DC_LCB_CFG_TX_FIFOS_RADR_RST_VAL_SHIFT;
6494 } else if (version == 0x1a) {
6496 /* LCB_CFG_RX_FIFOS_RADR = 0x988 */
6498 0x9ull << DC_LCB_CFG_RX_FIFOS_RADR_DO_NOT_JUMP_VAL_SHIFT
6499 | 0x8ull << DC_LCB_CFG_RX_FIFOS_RADR_OK_TO_JUMP_VAL_SHIFT
6500 | 0x8ull << DC_LCB_CFG_RX_FIFOS_RADR_RST_VAL_SHIFT;
6501 tx_radr = 7ull << DC_LCB_CFG_TX_FIFOS_RADR_RST_VAL_SHIFT;
6502 write_csr(dd, DC_LCB_CFG_LN_DCLK, 1ull);
6504 /* release 0x1b and higher */
6505 /* LCB_CFG_RX_FIFOS_RADR = 0x877 */
6507 0x8ull << DC_LCB_CFG_RX_FIFOS_RADR_DO_NOT_JUMP_VAL_SHIFT
6508 | 0x7ull << DC_LCB_CFG_RX_FIFOS_RADR_OK_TO_JUMP_VAL_SHIFT
6509 | 0x7ull << DC_LCB_CFG_RX_FIFOS_RADR_RST_VAL_SHIFT;
6510 tx_radr = 3ull << DC_LCB_CFG_TX_FIFOS_RADR_RST_VAL_SHIFT;
6513 write_csr(dd, DC_LCB_CFG_RX_FIFOS_RADR, rx_radr);
6514 /* LCB_CFG_IGNORE_LOST_RCLK.EN = 1 */
6515 write_csr(dd, DC_LCB_CFG_IGNORE_LOST_RCLK,
6516 DC_LCB_CFG_IGNORE_LOST_RCLK_EN_SMASK);
6517 write_csr(dd, DC_LCB_CFG_TX_FIFOS_RADR, tx_radr);
6521 * Handle a SMA idle message
6523 * This is a work-queue function outside of the interrupt.
6525 void handle_sma_message(struct work_struct *work)
6527 struct hfi1_pportdata *ppd = container_of(work, struct hfi1_pportdata,
6529 struct hfi1_devdata *dd = ppd->dd;
6533 /* msg is bytes 1-4 of the 40-bit idle message - the command code
6535 ret = read_idle_sma(dd, &msg);
6538 dd_dev_info(dd, "%s: SMA message 0x%llx\n", __func__, msg);
6540 * React to the SMA message. Byte[1] (0 for us) is the command.
6542 switch (msg & 0xff) {
6545 * See OPAv1 table 9-14 - HFI and External Switch Ports Key
6548 * Only expected in INIT or ARMED, discard otherwise.
6550 if (ppd->host_link_state & (HLS_UP_INIT | HLS_UP_ARMED))
6551 ppd->neighbor_normal = 1;
6553 case SMA_IDLE_ACTIVE:
6555 * See OPAv1 table 9-14 - HFI and External Switch Ports Key
6558 * Can activate the node. Discard otherwise.
6560 if (ppd->host_link_state == HLS_UP_ARMED
6561 && ppd->is_active_optimize_enabled) {
6562 ppd->neighbor_normal = 1;
6563 ret = set_link_state(ppd, HLS_UP_ACTIVE);
6567 "%s: received Active SMA idle message, couldn't set link to Active\n",
6573 "%s: received unexpected SMA idle message 0x%llx\n",
6579 static void adjust_rcvctrl(struct hfi1_devdata *dd, u64 add, u64 clear)
6582 unsigned long flags;
6584 spin_lock_irqsave(&dd->rcvctrl_lock, flags);
6585 rcvctrl = read_csr(dd, RCV_CTRL);
6588 write_csr(dd, RCV_CTRL, rcvctrl);
6589 spin_unlock_irqrestore(&dd->rcvctrl_lock, flags);
6592 static inline void add_rcvctrl(struct hfi1_devdata *dd, u64 add)
6594 adjust_rcvctrl(dd, add, 0);
6597 static inline void clear_rcvctrl(struct hfi1_devdata *dd, u64 clear)
6599 adjust_rcvctrl(dd, 0, clear);
6603 * Called from all interrupt handlers to start handling an SPC freeze.
6605 void start_freeze_handling(struct hfi1_pportdata *ppd, int flags)
6607 struct hfi1_devdata *dd = ppd->dd;
6608 struct send_context *sc;
6611 if (flags & FREEZE_SELF)
6612 write_csr(dd, CCE_CTRL, CCE_CTRL_SPC_FREEZE_SMASK);
6614 /* enter frozen mode */
6615 dd->flags |= HFI1_FROZEN;
6617 /* notify all SDMA engines that they are going into a freeze */
6618 sdma_freeze_notify(dd, !!(flags & FREEZE_LINK_DOWN));
6620 /* do halt pre-handling on all enabled send contexts */
6621 for (i = 0; i < dd->num_send_contexts; i++) {
6622 sc = dd->send_contexts[i].sc;
6623 if (sc && (sc->flags & SCF_ENABLED))
6624 sc_stop(sc, SCF_FROZEN | SCF_HALTED);
6627 /* Send context are frozen. Notify user space */
6628 hfi1_set_uevent_bits(ppd, _HFI1_EVENT_FROZEN_BIT);
6630 if (flags & FREEZE_ABORT) {
6632 "Aborted freeze recovery. Please REBOOT system\n");
6635 /* queue non-interrupt handler */
6636 queue_work(ppd->hfi1_wq, &ppd->freeze_work);
6640 * Wait until all 4 sub-blocks indicate that they have frozen or unfrozen,
6641 * depending on the "freeze" parameter.
6643 * No need to return an error if it times out, our only option
6644 * is to proceed anyway.
6646 static void wait_for_freeze_status(struct hfi1_devdata *dd, int freeze)
6648 unsigned long timeout;
6651 timeout = jiffies + msecs_to_jiffies(FREEZE_STATUS_TIMEOUT);
6653 reg = read_csr(dd, CCE_STATUS);
6655 /* waiting until all indicators are set */
6656 if ((reg & ALL_FROZE) == ALL_FROZE)
6657 return; /* all done */
6659 /* waiting until all indicators are clear */
6660 if ((reg & ALL_FROZE) == 0)
6661 return; /* all done */
6664 if (time_after(jiffies, timeout)) {
6666 "Time out waiting for SPC %sfreeze, bits 0x%llx, expecting 0x%llx, continuing",
6669 freeze ? ALL_FROZE : 0ull);
6672 usleep_range(80, 120);
6677 * Do all freeze handling for the RXE block.
6679 static void rxe_freeze(struct hfi1_devdata *dd)
6684 clear_rcvctrl(dd, RCV_CTRL_RCV_PORT_ENABLE_SMASK);
6686 /* disable all receive contexts */
6687 for (i = 0; i < dd->num_rcv_contexts; i++)
6688 hfi1_rcvctrl(dd, HFI1_RCVCTRL_CTXT_DIS, i);
6692 * Unfreeze handling for the RXE block - kernel contexts only.
6693 * This will also enable the port. User contexts will do unfreeze
6694 * handling on a per-context basis as they call into the driver.
6697 static void rxe_kernel_unfreeze(struct hfi1_devdata *dd)
6702 /* enable all kernel contexts */
6703 for (i = 0; i < dd->n_krcv_queues; i++) {
6704 rcvmask = HFI1_RCVCTRL_CTXT_ENB;
6705 /* HFI1_RCVCTRL_TAILUPD_[ENB|DIS] needs to be set explicitly */
6706 rcvmask |= HFI1_CAP_KGET_MASK(dd->rcd[i]->flags, DMA_RTAIL) ?
6707 HFI1_RCVCTRL_TAILUPD_ENB : HFI1_RCVCTRL_TAILUPD_DIS;
6708 hfi1_rcvctrl(dd, rcvmask, i);
6712 add_rcvctrl(dd, RCV_CTRL_RCV_PORT_ENABLE_SMASK);
6716 * Non-interrupt SPC freeze handling.
6718 * This is a work-queue function outside of the triggering interrupt.
6720 void handle_freeze(struct work_struct *work)
6722 struct hfi1_pportdata *ppd = container_of(work, struct hfi1_pportdata,
6724 struct hfi1_devdata *dd = ppd->dd;
6726 /* wait for freeze indicators on all affected blocks */
6727 wait_for_freeze_status(dd, 1);
6729 /* SPC is now frozen */
6731 /* do send PIO freeze steps */
6734 /* do send DMA freeze steps */
6737 /* do send egress freeze steps - nothing to do */
6739 /* do receive freeze steps */
6743 * Unfreeze the hardware - clear the freeze, wait for each
6744 * block's frozen bit to clear, then clear the frozen flag.
6746 write_csr(dd, CCE_CTRL, CCE_CTRL_SPC_UNFREEZE_SMASK);
6747 wait_for_freeze_status(dd, 0);
6750 write_csr(dd, CCE_CTRL, CCE_CTRL_SPC_FREEZE_SMASK);
6751 wait_for_freeze_status(dd, 1);
6752 write_csr(dd, CCE_CTRL, CCE_CTRL_SPC_UNFREEZE_SMASK);
6753 wait_for_freeze_status(dd, 0);
6756 /* do send PIO unfreeze steps for kernel contexts */
6757 pio_kernel_unfreeze(dd);
6759 /* do send DMA unfreeze steps */
6762 /* do send egress unfreeze steps - nothing to do */
6764 /* do receive unfreeze steps for kernel contexts */
6765 rxe_kernel_unfreeze(dd);
6768 * The unfreeze procedure touches global device registers when
6769 * it disables and re-enables RXE. Mark the device unfrozen
6770 * after all that is done so other parts of the driver waiting
6771 * for the device to unfreeze don't do things out of order.
6773 * The above implies that the meaning of HFI1_FROZEN flag is
6774 * "Device has gone into freeze mode and freeze mode handling
6775 * is still in progress."
6777 * The flag will be removed when freeze mode processing has
6780 dd->flags &= ~HFI1_FROZEN;
6781 wake_up(&dd->event_queue);
6783 /* no longer frozen */
6787 * Handle a link up interrupt from the 8051.
6789 * This is a work-queue function outside of the interrupt.
6791 void handle_link_up(struct work_struct *work)
6793 struct hfi1_pportdata *ppd = container_of(work, struct hfi1_pportdata,
6795 set_link_state(ppd, HLS_UP_INIT);
6797 /* cache the read of DC_LCB_STS_ROUND_TRIP_LTP_CNT */
6798 read_ltp_rtt(ppd->dd);
6800 * OPA specifies that certain counters are cleared on a transition
6801 * to link up, so do that.
6803 clear_linkup_counters(ppd->dd);
6805 * And (re)set link up default values.
6807 set_linkup_defaults(ppd);
6809 /* enforce link speed enabled */
6810 if ((ppd->link_speed_active & ppd->link_speed_enabled) == 0) {
6811 /* oops - current speed is not enabled, bounce */
6813 "Link speed active 0x%x is outside enabled 0x%x, downing link\n",
6814 ppd->link_speed_active, ppd->link_speed_enabled);
6815 set_link_down_reason(ppd, OPA_LINKDOWN_REASON_SPEED_POLICY, 0,
6816 OPA_LINKDOWN_REASON_SPEED_POLICY);
6817 set_link_state(ppd, HLS_DN_OFFLINE);
6823 /* Several pieces of LNI information were cached for SMA in ppd.
6824 * Reset these on link down */
6825 static void reset_neighbor_info(struct hfi1_pportdata *ppd)
6827 ppd->neighbor_guid = 0;
6828 ppd->neighbor_port_number = 0;
6829 ppd->neighbor_type = 0;
6830 ppd->neighbor_fm_security = 0;
6834 * Handle a link down interrupt from the 8051.
6836 * This is a work-queue function outside of the interrupt.
6838 void handle_link_down(struct work_struct *work)
6840 u8 lcl_reason, neigh_reason = 0;
6841 struct hfi1_pportdata *ppd = container_of(work, struct hfi1_pportdata,
6844 if ((ppd->host_link_state &
6845 (HLS_DN_POLL | HLS_VERIFY_CAP | HLS_GOING_UP)) &&
6846 ppd->port_type == PORT_TYPE_FIXED)
6847 ppd->offline_disabled_reason =
6848 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_NOT_INSTALLED);
6850 /* Go offline first, then deal with reading/writing through 8051 */
6851 set_link_state(ppd, HLS_DN_OFFLINE);
6854 read_planned_down_reason_code(ppd->dd, &neigh_reason);
6857 * If no reason, assume peer-initiated but missed
6858 * LinkGoingDown idle flits.
6860 if (neigh_reason == 0)
6861 lcl_reason = OPA_LINKDOWN_REASON_NEIGHBOR_UNKNOWN;
6863 set_link_down_reason(ppd, lcl_reason, neigh_reason, 0);
6865 reset_neighbor_info(ppd);
6867 /* disable the port */
6868 clear_rcvctrl(ppd->dd, RCV_CTRL_RCV_PORT_ENABLE_SMASK);
6870 /* If there is no cable attached, turn the DC off. Otherwise,
6871 * start the link bring up. */
6872 if (!qsfp_mod_present(ppd)) {
6873 dc_shutdown(ppd->dd);
6880 void handle_link_bounce(struct work_struct *work)
6882 struct hfi1_pportdata *ppd = container_of(work, struct hfi1_pportdata,
6886 * Only do something if the link is currently up.
6888 if (ppd->host_link_state & HLS_UP) {
6889 set_link_state(ppd, HLS_DN_OFFLINE);
6893 dd_dev_info(ppd->dd, "%s: link not up (%s), nothing to do\n",
6894 __func__, link_state_name(ppd->host_link_state));
6899 * Mask conversion: Capability exchange to Port LTP. The capability
6900 * exchange has an implicit 16b CRC that is mandatory.
6902 static int cap_to_port_ltp(int cap)
6904 int port_ltp = PORT_LTP_CRC_MODE_16; /* this mode is mandatory */
6906 if (cap & CAP_CRC_14B)
6907 port_ltp |= PORT_LTP_CRC_MODE_14;
6908 if (cap & CAP_CRC_48B)
6909 port_ltp |= PORT_LTP_CRC_MODE_48;
6910 if (cap & CAP_CRC_12B_16B_PER_LANE)
6911 port_ltp |= PORT_LTP_CRC_MODE_PER_LANE;
6917 * Convert an OPA Port LTP mask to capability mask
6919 int port_ltp_to_cap(int port_ltp)
6923 if (port_ltp & PORT_LTP_CRC_MODE_14)
6924 cap_mask |= CAP_CRC_14B;
6925 if (port_ltp & PORT_LTP_CRC_MODE_48)
6926 cap_mask |= CAP_CRC_48B;
6927 if (port_ltp & PORT_LTP_CRC_MODE_PER_LANE)
6928 cap_mask |= CAP_CRC_12B_16B_PER_LANE;
6934 * Convert a single DC LCB CRC mode to an OPA Port LTP mask.
6936 static int lcb_to_port_ltp(int lcb_crc)
6940 if (lcb_crc == LCB_CRC_12B_16B_PER_LANE)
6941 port_ltp = PORT_LTP_CRC_MODE_PER_LANE;
6942 else if (lcb_crc == LCB_CRC_48B)
6943 port_ltp = PORT_LTP_CRC_MODE_48;
6944 else if (lcb_crc == LCB_CRC_14B)
6945 port_ltp = PORT_LTP_CRC_MODE_14;
6947 port_ltp = PORT_LTP_CRC_MODE_16;
6953 * Our neighbor has indicated that we are allowed to act as a fabric
6954 * manager, so place the full management partition key in the second
6955 * (0-based) pkey array position (see OPAv1, section 20.2.2.6.8). Note
6956 * that we should already have the limited management partition key in
6957 * array element 1, and also that the port is not yet up when
6958 * add_full_mgmt_pkey() is invoked.
6960 static void add_full_mgmt_pkey(struct hfi1_pportdata *ppd)
6962 struct hfi1_devdata *dd = ppd->dd;
6964 /* Sanity check - ppd->pkeys[2] should be 0, or already initalized */
6965 if (!((ppd->pkeys[2] == 0) || (ppd->pkeys[2] == FULL_MGMT_P_KEY)))
6966 dd_dev_warn(dd, "%s pkey[2] already set to 0x%x, resetting it to 0x%x\n",
6967 __func__, ppd->pkeys[2], FULL_MGMT_P_KEY);
6968 ppd->pkeys[2] = FULL_MGMT_P_KEY;
6969 (void)hfi1_set_ib_cfg(ppd, HFI1_IB_CFG_PKEYS, 0);
6973 * Convert the given link width to the OPA link width bitmask.
6975 static u16 link_width_to_bits(struct hfi1_devdata *dd, u16 width)
6980 * Simulator and quick linkup do not set the width.
6981 * Just set it to 4x without complaint.
6983 if (dd->icode == ICODE_FUNCTIONAL_SIMULATOR || quick_linkup)
6984 return OPA_LINK_WIDTH_4X;
6985 return 0; /* no lanes up */
6986 case 1: return OPA_LINK_WIDTH_1X;
6987 case 2: return OPA_LINK_WIDTH_2X;
6988 case 3: return OPA_LINK_WIDTH_3X;
6990 dd_dev_info(dd, "%s: invalid width %d, using 4\n",
6993 case 4: return OPA_LINK_WIDTH_4X;
6998 * Do a population count on the bottom nibble.
7000 static const u8 bit_counts[16] = {
7001 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4
7003 static inline u8 nibble_to_count(u8 nibble)
7005 return bit_counts[nibble & 0xf];
7009 * Read the active lane information from the 8051 registers and return
7012 * Active lane information is found in these 8051 registers:
7016 static void get_link_widths(struct hfi1_devdata *dd, u16 *tx_width,
7022 u8 tx_polarity_inversion;
7023 u8 rx_polarity_inversion;
7026 /* read the active lanes */
7027 read_tx_settings(dd, &enable_lane_tx, &tx_polarity_inversion,
7028 &rx_polarity_inversion, &max_rate);
7029 read_local_lni(dd, &enable_lane_rx);
7031 /* convert to counts */
7032 tx = nibble_to_count(enable_lane_tx);
7033 rx = nibble_to_count(enable_lane_rx);
7036 * Set link_speed_active here, overriding what was set in
7037 * handle_verify_cap(). The ASIC 8051 firmware does not correctly
7038 * set the max_rate field in handle_verify_cap until v0.19.
7040 if ((dd->icode == ICODE_RTL_SILICON)
7041 && (dd->dc8051_ver < dc8051_ver(0, 19))) {
7042 /* max_rate: 0 = 12.5G, 1 = 25G */
7045 dd->pport[0].link_speed_active = OPA_LINK_SPEED_12_5G;
7049 "%s: unexpected max rate %d, using 25Gb\n",
7050 __func__, (int)max_rate);
7053 dd->pport[0].link_speed_active = OPA_LINK_SPEED_25G;
7059 "Fabric active lanes (width): tx 0x%x (%d), rx 0x%x (%d)\n",
7060 enable_lane_tx, tx, enable_lane_rx, rx);
7061 *tx_width = link_width_to_bits(dd, tx);
7062 *rx_width = link_width_to_bits(dd, rx);
7066 * Read verify_cap_local_fm_link_width[1] to obtain the link widths.
7067 * Valid after the end of VerifyCap and during LinkUp. Does not change
7068 * after link up. I.e. look elsewhere for downgrade information.
7071 * + bits [7:4] contain the number of active transmitters
7072 * + bits [3:0] contain the number of active receivers
7073 * These are numbers 1 through 4 and can be different values if the
7074 * link is asymmetric.
7076 * verify_cap_local_fm_link_width[0] retains its original value.
7078 static void get_linkup_widths(struct hfi1_devdata *dd, u16 *tx_width,
7082 u8 misc_bits, local_flags;
7083 u16 active_tx, active_rx;
7085 read_vc_local_link_width(dd, &misc_bits, &local_flags, &widths);
7087 rx = (widths >> 8) & 0xf;
7089 *tx_width = link_width_to_bits(dd, tx);
7090 *rx_width = link_width_to_bits(dd, rx);
7092 /* print the active widths */
7093 get_link_widths(dd, &active_tx, &active_rx);
7097 * Set ppd->link_width_active and ppd->link_width_downgrade_active using
7098 * hardware information when the link first comes up.
7100 * The link width is not available until after VerifyCap.AllFramesReceived
7101 * (the trigger for handle_verify_cap), so this is outside that routine
7102 * and should be called when the 8051 signals linkup.
7104 void get_linkup_link_widths(struct hfi1_pportdata *ppd)
7106 u16 tx_width, rx_width;
7108 /* get end-of-LNI link widths */
7109 get_linkup_widths(ppd->dd, &tx_width, &rx_width);
7111 /* use tx_width as the link is supposed to be symmetric on link up */
7112 ppd->link_width_active = tx_width;
7113 /* link width downgrade active (LWD.A) starts out matching LW.A */
7114 ppd->link_width_downgrade_tx_active = ppd->link_width_active;
7115 ppd->link_width_downgrade_rx_active = ppd->link_width_active;
7116 /* per OPA spec, on link up LWD.E resets to LWD.S */
7117 ppd->link_width_downgrade_enabled = ppd->link_width_downgrade_supported;
7118 /* cache the active egress rate (units {10^6 bits/sec]) */
7119 ppd->current_egress_rate = active_egress_rate(ppd);
7123 * Handle a verify capabilities interrupt from the 8051.
7125 * This is a work-queue function outside of the interrupt.
7127 void handle_verify_cap(struct work_struct *work)
7129 struct hfi1_pportdata *ppd = container_of(work, struct hfi1_pportdata,
7131 struct hfi1_devdata *dd = ppd->dd;
7133 u8 power_management;
7143 u16 active_tx, active_rx;
7144 u8 partner_supported_crc;
7148 set_link_state(ppd, HLS_VERIFY_CAP);
7150 lcb_shutdown(dd, 0);
7151 adjust_lcb_for_fpga_serdes(dd);
7154 * These are now valid:
7155 * remote VerifyCap fields in the general LNI config
7156 * CSR DC8051_STS_REMOTE_GUID
7157 * CSR DC8051_STS_REMOTE_NODE_TYPE
7158 * CSR DC8051_STS_REMOTE_FM_SECURITY
7159 * CSR DC8051_STS_REMOTE_PORT_NO
7162 read_vc_remote_phy(dd, &power_management, &continious);
7163 read_vc_remote_fabric(
7169 &partner_supported_crc);
7170 read_vc_remote_link_width(dd, &remote_tx_rate, &link_widths);
7171 read_remote_device_id(dd, &device_id, &device_rev);
7173 * And the 'MgmtAllowed' information, which is exchanged during
7174 * LNI, is also be available at this point.
7176 read_mgmt_allowed(dd, &ppd->mgmt_allowed);
7177 /* print the active widths */
7178 get_link_widths(dd, &active_tx, &active_rx);
7180 "Peer PHY: power management 0x%x, continuous updates 0x%x\n",
7181 (int)power_management, (int)continious);
7183 "Peer Fabric: vAU %d, Z %d, vCU %d, vl15 credits 0x%x, CRC sizes 0x%x\n",
7188 (int)partner_supported_crc);
7189 dd_dev_info(dd, "Peer Link Width: tx rate 0x%x, widths 0x%x\n",
7190 (u32)remote_tx_rate, (u32)link_widths);
7191 dd_dev_info(dd, "Peer Device ID: 0x%04x, Revision 0x%02x\n",
7192 (u32)device_id, (u32)device_rev);
7194 * The peer vAU value just read is the peer receiver value. HFI does
7195 * not support a transmit vAU of 0 (AU == 8). We advertised that
7196 * with Z=1 in the fabric capabilities sent to the peer. The peer
7197 * will see our Z=1, and, if it advertised a vAU of 0, will move its
7198 * receive to vAU of 1 (AU == 16). Do the same here. We do not care
7199 * about the peer Z value - our sent vAU is 3 (hardwired) and is not
7200 * subject to the Z value exception.
7204 set_up_vl15(dd, vau, vl15buf);
7206 /* set up the LCB CRC mode */
7207 crc_mask = ppd->port_crc_mode_enabled & partner_supported_crc;
7209 /* order is important: use the lowest bit in common */
7210 if (crc_mask & CAP_CRC_14B)
7211 crc_val = LCB_CRC_14B;
7212 else if (crc_mask & CAP_CRC_48B)
7213 crc_val = LCB_CRC_48B;
7214 else if (crc_mask & CAP_CRC_12B_16B_PER_LANE)
7215 crc_val = LCB_CRC_12B_16B_PER_LANE;
7217 crc_val = LCB_CRC_16B;
7219 dd_dev_info(dd, "Final LCB CRC mode: %d\n", (int)crc_val);
7220 write_csr(dd, DC_LCB_CFG_CRC_MODE,
7221 (u64)crc_val << DC_LCB_CFG_CRC_MODE_TX_VAL_SHIFT);
7223 /* set (14b only) or clear sideband credit */
7224 reg = read_csr(dd, SEND_CM_CTRL);
7225 if (crc_val == LCB_CRC_14B && crc_14b_sideband) {
7226 write_csr(dd, SEND_CM_CTRL,
7227 reg | SEND_CM_CTRL_FORCE_CREDIT_MODE_SMASK);
7229 write_csr(dd, SEND_CM_CTRL,
7230 reg & ~SEND_CM_CTRL_FORCE_CREDIT_MODE_SMASK);
7233 ppd->link_speed_active = 0; /* invalid value */
7234 if (dd->dc8051_ver < dc8051_ver(0, 20)) {
7235 /* remote_tx_rate: 0 = 12.5G, 1 = 25G */
7236 switch (remote_tx_rate) {
7238 ppd->link_speed_active = OPA_LINK_SPEED_12_5G;
7241 ppd->link_speed_active = OPA_LINK_SPEED_25G;
7245 /* actual rate is highest bit of the ANDed rates */
7246 u8 rate = remote_tx_rate & ppd->local_tx_rate;
7249 ppd->link_speed_active = OPA_LINK_SPEED_25G;
7251 ppd->link_speed_active = OPA_LINK_SPEED_12_5G;
7253 if (ppd->link_speed_active == 0) {
7254 dd_dev_err(dd, "%s: unexpected remote tx rate %d, using 25Gb\n",
7255 __func__, (int)remote_tx_rate);
7256 ppd->link_speed_active = OPA_LINK_SPEED_25G;
7260 * Cache the values of the supported, enabled, and active
7261 * LTP CRC modes to return in 'portinfo' queries. But the bit
7262 * flags that are returned in the portinfo query differ from
7263 * what's in the link_crc_mask, crc_sizes, and crc_val
7264 * variables. Convert these here.
7266 ppd->port_ltp_crc_mode = cap_to_port_ltp(link_crc_mask) << 8;
7267 /* supported crc modes */
7268 ppd->port_ltp_crc_mode |=
7269 cap_to_port_ltp(ppd->port_crc_mode_enabled) << 4;
7270 /* enabled crc modes */
7271 ppd->port_ltp_crc_mode |= lcb_to_port_ltp(crc_val);
7272 /* active crc mode */
7274 /* set up the remote credit return table */
7275 assign_remote_cm_au_table(dd, vcu);
7278 * The LCB is reset on entry to handle_verify_cap(), so this must
7279 * be applied on every link up.
7281 * Adjust LCB error kill enable to kill the link if
7282 * these RBUF errors are seen:
7283 * REPLAY_BUF_MBE_SMASK
7284 * FLIT_INPUT_BUF_MBE_SMASK
7286 if (is_ax(dd)) { /* fixed in B0 */
7287 reg = read_csr(dd, DC_LCB_CFG_LINK_KILL_EN);
7288 reg |= DC_LCB_CFG_LINK_KILL_EN_REPLAY_BUF_MBE_SMASK
7289 | DC_LCB_CFG_LINK_KILL_EN_FLIT_INPUT_BUF_MBE_SMASK;
7290 write_csr(dd, DC_LCB_CFG_LINK_KILL_EN, reg);
7293 /* pull LCB fifos out of reset - all fifo clocks must be stable */
7294 write_csr(dd, DC_LCB_CFG_TX_FIFOS_RESET, 0);
7296 /* give 8051 access to the LCB CSRs */
7297 write_csr(dd, DC_LCB_ERR_EN, 0); /* mask LCB errors */
7298 set_8051_lcb_access(dd);
7300 ppd->neighbor_guid =
7301 read_csr(dd, DC_DC8051_STS_REMOTE_GUID);
7302 ppd->neighbor_port_number = read_csr(dd, DC_DC8051_STS_REMOTE_PORT_NO) &
7303 DC_DC8051_STS_REMOTE_PORT_NO_VAL_SMASK;
7304 ppd->neighbor_type =
7305 read_csr(dd, DC_DC8051_STS_REMOTE_NODE_TYPE) &
7306 DC_DC8051_STS_REMOTE_NODE_TYPE_VAL_MASK;
7307 ppd->neighbor_fm_security =
7308 read_csr(dd, DC_DC8051_STS_REMOTE_FM_SECURITY) &
7309 DC_DC8051_STS_LOCAL_FM_SECURITY_DISABLED_MASK;
7311 "Neighbor Guid: %llx Neighbor type %d MgmtAllowed %d FM security bypass %d\n",
7312 ppd->neighbor_guid, ppd->neighbor_type,
7313 ppd->mgmt_allowed, ppd->neighbor_fm_security);
7314 if (ppd->mgmt_allowed)
7315 add_full_mgmt_pkey(ppd);
7317 /* tell the 8051 to go to LinkUp */
7318 set_link_state(ppd, HLS_GOING_UP);
7322 * Apply the link width downgrade enabled policy against the current active
7325 * Called when the enabled policy changes or the active link widths change.
7327 void apply_link_downgrade_policy(struct hfi1_pportdata *ppd, int refresh_widths)
7334 /* use the hls lock to avoid a race with actual link up */
7337 mutex_lock(&ppd->hls_lock);
7338 /* only apply if the link is up */
7339 if (!(ppd->host_link_state & HLS_UP)) {
7340 /* still going up..wait and retry */
7341 if (ppd->host_link_state & HLS_GOING_UP) {
7342 if (++tries < 1000) {
7343 mutex_unlock(&ppd->hls_lock);
7344 usleep_range(100, 120); /* arbitrary */
7348 "%s: giving up waiting for link state change\n",
7354 lwde = ppd->link_width_downgrade_enabled;
7356 if (refresh_widths) {
7357 get_link_widths(ppd->dd, &tx, &rx);
7358 ppd->link_width_downgrade_tx_active = tx;
7359 ppd->link_width_downgrade_rx_active = rx;
7363 /* downgrade is disabled */
7365 /* bounce if not at starting active width */
7366 if ((ppd->link_width_active !=
7367 ppd->link_width_downgrade_tx_active)
7368 || (ppd->link_width_active !=
7369 ppd->link_width_downgrade_rx_active)) {
7371 "Link downgrade is disabled and link has downgraded, downing link\n");
7373 " original 0x%x, tx active 0x%x, rx active 0x%x\n",
7374 ppd->link_width_active,
7375 ppd->link_width_downgrade_tx_active,
7376 ppd->link_width_downgrade_rx_active);
7379 } else if ((lwde & ppd->link_width_downgrade_tx_active) == 0
7380 || (lwde & ppd->link_width_downgrade_rx_active) == 0) {
7381 /* Tx or Rx is outside the enabled policy */
7383 "Link is outside of downgrade allowed, downing link\n");
7385 " enabled 0x%x, tx active 0x%x, rx active 0x%x\n",
7387 ppd->link_width_downgrade_tx_active,
7388 ppd->link_width_downgrade_rx_active);
7393 mutex_unlock(&ppd->hls_lock);
7396 set_link_down_reason(ppd, OPA_LINKDOWN_REASON_WIDTH_POLICY, 0,
7397 OPA_LINKDOWN_REASON_WIDTH_POLICY);
7398 set_link_state(ppd, HLS_DN_OFFLINE);
7405 * Handle a link downgrade interrupt from the 8051.
7407 * This is a work-queue function outside of the interrupt.
7409 void handle_link_downgrade(struct work_struct *work)
7411 struct hfi1_pportdata *ppd = container_of(work, struct hfi1_pportdata,
7412 link_downgrade_work);
7414 dd_dev_info(ppd->dd, "8051: Link width downgrade\n");
7415 apply_link_downgrade_policy(ppd, 1);
7418 static char *dcc_err_string(char *buf, int buf_len, u64 flags)
7420 return flag_string(buf, buf_len, flags, dcc_err_flags,
7421 ARRAY_SIZE(dcc_err_flags));
7424 static char *lcb_err_string(char *buf, int buf_len, u64 flags)
7426 return flag_string(buf, buf_len, flags, lcb_err_flags,
7427 ARRAY_SIZE(lcb_err_flags));
7430 static char *dc8051_err_string(char *buf, int buf_len, u64 flags)
7432 return flag_string(buf, buf_len, flags, dc8051_err_flags,
7433 ARRAY_SIZE(dc8051_err_flags));
7436 static char *dc8051_info_err_string(char *buf, int buf_len, u64 flags)
7438 return flag_string(buf, buf_len, flags, dc8051_info_err_flags,
7439 ARRAY_SIZE(dc8051_info_err_flags));
7442 static char *dc8051_info_host_msg_string(char *buf, int buf_len, u64 flags)
7444 return flag_string(buf, buf_len, flags, dc8051_info_host_msg_flags,
7445 ARRAY_SIZE(dc8051_info_host_msg_flags));
7448 static void handle_8051_interrupt(struct hfi1_devdata *dd, u32 unused, u64 reg)
7450 struct hfi1_pportdata *ppd = dd->pport;
7451 u64 info, err, host_msg;
7452 int queue_link_down = 0;
7455 /* look at the flags */
7456 if (reg & DC_DC8051_ERR_FLG_SET_BY_8051_SMASK) {
7457 /* 8051 information set by firmware */
7458 /* read DC8051_DBG_ERR_INFO_SET_BY_8051 for details */
7459 info = read_csr(dd, DC_DC8051_DBG_ERR_INFO_SET_BY_8051);
7460 err = (info >> DC_DC8051_DBG_ERR_INFO_SET_BY_8051_ERROR_SHIFT)
7461 & DC_DC8051_DBG_ERR_INFO_SET_BY_8051_ERROR_MASK;
7463 DC_DC8051_DBG_ERR_INFO_SET_BY_8051_HOST_MSG_SHIFT)
7464 & DC_DC8051_DBG_ERR_INFO_SET_BY_8051_HOST_MSG_MASK;
7467 * Handle error flags.
7469 if (err & FAILED_LNI) {
7471 * LNI error indications are cleared by the 8051
7472 * only when starting polling. Only pay attention
7473 * to them when in the states that occur during
7476 if (ppd->host_link_state
7477 & (HLS_DN_POLL | HLS_VERIFY_CAP | HLS_GOING_UP)) {
7478 queue_link_down = 1;
7479 dd_dev_info(dd, "Link error: %s\n",
7480 dc8051_info_err_string(buf,
7484 err &= ~(u64)FAILED_LNI;
7486 /* unknown frames can happen durning LNI, just count */
7487 if (err & UNKNOWN_FRAME) {
7488 ppd->unknown_frame_count++;
7489 err &= ~(u64)UNKNOWN_FRAME;
7492 /* report remaining errors, but do not do anything */
7493 dd_dev_err(dd, "8051 info error: %s\n",
7494 dc8051_info_err_string(buf, sizeof(buf), err));
7498 * Handle host message flags.
7500 if (host_msg & HOST_REQ_DONE) {
7502 * Presently, the driver does a busy wait for
7503 * host requests to complete. This is only an
7504 * informational message.
7505 * NOTE: The 8051 clears the host message
7506 * information *on the next 8051 command*.
7507 * Therefore, when linkup is achieved,
7508 * this flag will still be set.
7510 host_msg &= ~(u64)HOST_REQ_DONE;
7512 if (host_msg & BC_SMA_MSG) {
7513 queue_work(ppd->hfi1_wq, &ppd->sma_message_work);
7514 host_msg &= ~(u64)BC_SMA_MSG;
7516 if (host_msg & LINKUP_ACHIEVED) {
7517 dd_dev_info(dd, "8051: Link up\n");
7518 queue_work(ppd->hfi1_wq, &ppd->link_up_work);
7519 host_msg &= ~(u64)LINKUP_ACHIEVED;
7521 if (host_msg & EXT_DEVICE_CFG_REQ) {
7522 queue_work(ppd->hfi1_wq, &ppd->dc_host_req_work);
7523 host_msg &= ~(u64)EXT_DEVICE_CFG_REQ;
7525 if (host_msg & VERIFY_CAP_FRAME) {
7526 queue_work(ppd->hfi1_wq, &ppd->link_vc_work);
7527 host_msg &= ~(u64)VERIFY_CAP_FRAME;
7529 if (host_msg & LINK_GOING_DOWN) {
7530 const char *extra = "";
7531 /* no downgrade action needed if going down */
7532 if (host_msg & LINK_WIDTH_DOWNGRADED) {
7533 host_msg &= ~(u64)LINK_WIDTH_DOWNGRADED;
7534 extra = " (ignoring downgrade)";
7536 dd_dev_info(dd, "8051: Link down%s\n", extra);
7537 queue_link_down = 1;
7538 host_msg &= ~(u64)LINK_GOING_DOWN;
7540 if (host_msg & LINK_WIDTH_DOWNGRADED) {
7541 queue_work(ppd->hfi1_wq, &ppd->link_downgrade_work);
7542 host_msg &= ~(u64)LINK_WIDTH_DOWNGRADED;
7545 /* report remaining messages, but do not do anything */
7546 dd_dev_info(dd, "8051 info host message: %s\n",
7547 dc8051_info_host_msg_string(buf, sizeof(buf),
7551 reg &= ~DC_DC8051_ERR_FLG_SET_BY_8051_SMASK;
7553 if (reg & DC_DC8051_ERR_FLG_LOST_8051_HEART_BEAT_SMASK) {
7555 * Lost the 8051 heartbeat. If this happens, we
7556 * receive constant interrupts about it. Disable
7557 * the interrupt after the first.
7559 dd_dev_err(dd, "Lost 8051 heartbeat\n");
7560 write_csr(dd, DC_DC8051_ERR_EN,
7561 read_csr(dd, DC_DC8051_ERR_EN)
7562 & ~DC_DC8051_ERR_EN_LOST_8051_HEART_BEAT_SMASK);
7564 reg &= ~DC_DC8051_ERR_FLG_LOST_8051_HEART_BEAT_SMASK;
7567 /* report the error, but do not do anything */
7568 dd_dev_err(dd, "8051 error: %s\n",
7569 dc8051_err_string(buf, sizeof(buf), reg));
7572 if (queue_link_down) {
7573 /* if the link is already going down or disabled, do not
7575 if ((ppd->host_link_state
7576 & (HLS_GOING_OFFLINE|HLS_LINK_COOLDOWN))
7577 || ppd->link_enabled == 0) {
7578 dd_dev_info(dd, "%s: not queuing link down\n",
7581 queue_work(ppd->hfi1_wq, &ppd->link_down_work);
7586 static const char * const fm_config_txt[] = {
7588 "BadHeadDist: Distance violation between two head flits",
7590 "BadTailDist: Distance violation between two tail flits",
7592 "BadCtrlDist: Distance violation between two credit control flits",
7594 "BadCrdAck: Credits return for unsupported VL",
7596 "UnsupportedVLMarker: Received VL Marker",
7598 "BadPreempt: Exceeded the preemption nesting level",
7600 "BadControlFlit: Received unsupported control flit",
7603 "UnsupportedVLMarker: Received VL Marker for unconfigured or disabled VL",
7606 static const char * const port_rcv_txt[] = {
7608 "BadPktLen: Illegal PktLen",
7610 "PktLenTooLong: Packet longer than PktLen",
7612 "PktLenTooShort: Packet shorter than PktLen",
7614 "BadSLID: Illegal SLID (0, using multicast as SLID, does not include security validation of SLID)",
7616 "BadDLID: Illegal DLID (0, doesn't match HFI)",
7618 "BadL2: Illegal L2 opcode",
7620 "BadSC: Unsupported SC",
7622 "BadRC: Illegal RC",
7624 "PreemptError: Preempting with same VL",
7626 "PreemptVL15: Preempting a VL15 packet",
7629 #define OPA_LDR_FMCONFIG_OFFSET 16
7630 #define OPA_LDR_PORTRCV_OFFSET 0
7631 static void handle_dcc_err(struct hfi1_devdata *dd, u32 unused, u64 reg)
7633 u64 info, hdr0, hdr1;
7636 struct hfi1_pportdata *ppd = dd->pport;
7640 if (reg & DCC_ERR_FLG_UNCORRECTABLE_ERR_SMASK) {
7641 if (!(dd->err_info_uncorrectable & OPA_EI_STATUS_SMASK)) {
7642 info = read_csr(dd, DCC_ERR_INFO_UNCORRECTABLE);
7643 dd->err_info_uncorrectable = info & OPA_EI_CODE_SMASK;
7644 /* set status bit */
7645 dd->err_info_uncorrectable |= OPA_EI_STATUS_SMASK;
7647 reg &= ~DCC_ERR_FLG_UNCORRECTABLE_ERR_SMASK;
7650 if (reg & DCC_ERR_FLG_LINK_ERR_SMASK) {
7651 struct hfi1_pportdata *ppd = dd->pport;
7652 /* this counter saturates at (2^32) - 1 */
7653 if (ppd->link_downed < (u32)UINT_MAX)
7655 reg &= ~DCC_ERR_FLG_LINK_ERR_SMASK;
7658 if (reg & DCC_ERR_FLG_FMCONFIG_ERR_SMASK) {
7659 u8 reason_valid = 1;
7661 info = read_csr(dd, DCC_ERR_INFO_FMCONFIG);
7662 if (!(dd->err_info_fmconfig & OPA_EI_STATUS_SMASK)) {
7663 dd->err_info_fmconfig = info & OPA_EI_CODE_SMASK;
7664 /* set status bit */
7665 dd->err_info_fmconfig |= OPA_EI_STATUS_SMASK;
7675 extra = fm_config_txt[info];
7678 extra = fm_config_txt[info];
7679 if (ppd->port_error_action &
7680 OPA_PI_MASK_FM_CFG_UNSUPPORTED_VL_MARKER) {
7683 * lcl_reason cannot be derived from info
7687 OPA_LINKDOWN_REASON_UNSUPPORTED_VL_MARKER;
7692 snprintf(buf, sizeof(buf), "reserved%lld", info);
7697 if (reason_valid && !do_bounce) {
7698 do_bounce = ppd->port_error_action &
7699 (1 << (OPA_LDR_FMCONFIG_OFFSET + info));
7700 lcl_reason = info + OPA_LINKDOWN_REASON_BAD_HEAD_DIST;
7703 /* just report this */
7704 dd_dev_info(dd, "DCC Error: fmconfig error: %s\n", extra);
7705 reg &= ~DCC_ERR_FLG_FMCONFIG_ERR_SMASK;
7708 if (reg & DCC_ERR_FLG_RCVPORT_ERR_SMASK) {
7709 u8 reason_valid = 1;
7711 info = read_csr(dd, DCC_ERR_INFO_PORTRCV);
7712 hdr0 = read_csr(dd, DCC_ERR_INFO_PORTRCV_HDR0);
7713 hdr1 = read_csr(dd, DCC_ERR_INFO_PORTRCV_HDR1);
7714 if (!(dd->err_info_rcvport.status_and_code &
7715 OPA_EI_STATUS_SMASK)) {
7716 dd->err_info_rcvport.status_and_code =
7717 info & OPA_EI_CODE_SMASK;
7718 /* set status bit */
7719 dd->err_info_rcvport.status_and_code |=
7720 OPA_EI_STATUS_SMASK;
7721 /* save first 2 flits in the packet that caused
7723 dd->err_info_rcvport.packet_flit1 = hdr0;
7724 dd->err_info_rcvport.packet_flit2 = hdr1;
7737 extra = port_rcv_txt[info];
7741 snprintf(buf, sizeof(buf), "reserved%lld", info);
7746 if (reason_valid && !do_bounce) {
7747 do_bounce = ppd->port_error_action &
7748 (1 << (OPA_LDR_PORTRCV_OFFSET + info));
7749 lcl_reason = info + OPA_LINKDOWN_REASON_RCV_ERROR_0;
7752 /* just report this */
7753 dd_dev_info(dd, "DCC Error: PortRcv error: %s\n", extra);
7754 dd_dev_info(dd, " hdr0 0x%llx, hdr1 0x%llx\n",
7757 reg &= ~DCC_ERR_FLG_RCVPORT_ERR_SMASK;
7760 if (reg & DCC_ERR_FLG_EN_CSR_ACCESS_BLOCKED_UC_SMASK) {
7761 /* informative only */
7762 dd_dev_info(dd, "8051 access to LCB blocked\n");
7763 reg &= ~DCC_ERR_FLG_EN_CSR_ACCESS_BLOCKED_UC_SMASK;
7765 if (reg & DCC_ERR_FLG_EN_CSR_ACCESS_BLOCKED_HOST_SMASK) {
7766 /* informative only */
7767 dd_dev_info(dd, "host access to LCB blocked\n");
7768 reg &= ~DCC_ERR_FLG_EN_CSR_ACCESS_BLOCKED_HOST_SMASK;
7771 /* report any remaining errors */
7773 dd_dev_info(dd, "DCC Error: %s\n",
7774 dcc_err_string(buf, sizeof(buf), reg));
7776 if (lcl_reason == 0)
7777 lcl_reason = OPA_LINKDOWN_REASON_UNKNOWN;
7780 dd_dev_info(dd, "%s: PortErrorAction bounce\n", __func__);
7781 set_link_down_reason(ppd, lcl_reason, 0, lcl_reason);
7782 queue_work(ppd->hfi1_wq, &ppd->link_bounce_work);
7786 static void handle_lcb_err(struct hfi1_devdata *dd, u32 unused, u64 reg)
7790 dd_dev_info(dd, "LCB Error: %s\n",
7791 lcb_err_string(buf, sizeof(buf), reg));
7795 * CCE block DC interrupt. Source is < 8.
7797 static void is_dc_int(struct hfi1_devdata *dd, unsigned int source)
7799 const struct err_reg_info *eri = &dc_errs[source];
7802 interrupt_clear_down(dd, 0, eri);
7803 } else if (source == 3 /* dc_lbm_int */) {
7805 * This indicates that a parity error has occurred on the
7806 * address/control lines presented to the LBM. The error
7807 * is a single pulse, there is no associated error flag,
7808 * and it is non-maskable. This is because if a parity
7809 * error occurs on the request the request is dropped.
7810 * This should never occur, but it is nice to know if it
7813 dd_dev_err(dd, "Parity error in DC LBM block\n");
7815 dd_dev_err(dd, "Invalid DC interrupt %u\n", source);
7820 * TX block send credit interrupt. Source is < 160.
7822 static void is_send_credit_int(struct hfi1_devdata *dd, unsigned int source)
7824 sc_group_release_update(dd, source);
7828 * TX block SDMA interrupt. Source is < 48.
7830 * SDMA interrupts are grouped by type:
7833 * N - 2N-1 = SDmaProgress
7834 * 2N - 3N-1 = SDmaIdle
7836 static void is_sdma_eng_int(struct hfi1_devdata *dd, unsigned int source)
7838 /* what interrupt */
7839 unsigned int what = source / TXE_NUM_SDMA_ENGINES;
7841 unsigned int which = source % TXE_NUM_SDMA_ENGINES;
7843 #ifdef CONFIG_SDMA_VERBOSITY
7844 dd_dev_err(dd, "CONFIG SDMA(%u) %s:%d %s()\n", which,
7845 slashstrip(__FILE__), __LINE__, __func__);
7846 sdma_dumpstate(&dd->per_sdma[which]);
7849 if (likely(what < 3 && which < dd->num_sdma)) {
7850 sdma_engine_interrupt(&dd->per_sdma[which], 1ull << source);
7852 /* should not happen */
7853 dd_dev_err(dd, "Invalid SDMA interrupt 0x%x\n", source);
7858 * RX block receive available interrupt. Source is < 160.
7860 static void is_rcv_avail_int(struct hfi1_devdata *dd, unsigned int source)
7862 struct hfi1_ctxtdata *rcd;
7865 if (likely(source < dd->num_rcv_contexts)) {
7866 rcd = dd->rcd[source];
7868 if (source < dd->first_user_ctxt)
7869 rcd->do_interrupt(rcd, 0);
7871 handle_user_interrupt(rcd);
7874 /* received an interrupt, but no rcd */
7875 err_detail = "dataless";
7877 /* received an interrupt, but are not using that context */
7878 err_detail = "out of range";
7880 dd_dev_err(dd, "unexpected %s receive available context interrupt %u\n",
7881 err_detail, source);
7885 * RX block receive urgent interrupt. Source is < 160.
7887 static void is_rcv_urgent_int(struct hfi1_devdata *dd, unsigned int source)
7889 struct hfi1_ctxtdata *rcd;
7892 if (likely(source < dd->num_rcv_contexts)) {
7893 rcd = dd->rcd[source];
7895 /* only pay attention to user urgent interrupts */
7896 if (source >= dd->first_user_ctxt)
7897 handle_user_interrupt(rcd);
7900 /* received an interrupt, but no rcd */
7901 err_detail = "dataless";
7903 /* received an interrupt, but are not using that context */
7904 err_detail = "out of range";
7906 dd_dev_err(dd, "unexpected %s receive urgent context interrupt %u\n",
7907 err_detail, source);
7911 * Reserved range interrupt. Should not be called in normal operation.
7913 static void is_reserved_int(struct hfi1_devdata *dd, unsigned int source)
7917 dd_dev_err(dd, "unexpected %s interrupt\n",
7918 is_reserved_name(name, sizeof(name), source));
7921 static const struct is_table is_table[] = {
7923 name func interrupt func */
7924 { IS_GENERAL_ERR_START, IS_GENERAL_ERR_END,
7925 is_misc_err_name, is_misc_err_int },
7926 { IS_SDMAENG_ERR_START, IS_SDMAENG_ERR_END,
7927 is_sdma_eng_err_name, is_sdma_eng_err_int },
7928 { IS_SENDCTXT_ERR_START, IS_SENDCTXT_ERR_END,
7929 is_sendctxt_err_name, is_sendctxt_err_int },
7930 { IS_SDMA_START, IS_SDMA_END,
7931 is_sdma_eng_name, is_sdma_eng_int },
7932 { IS_VARIOUS_START, IS_VARIOUS_END,
7933 is_various_name, is_various_int },
7934 { IS_DC_START, IS_DC_END,
7935 is_dc_name, is_dc_int },
7936 { IS_RCVAVAIL_START, IS_RCVAVAIL_END,
7937 is_rcv_avail_name, is_rcv_avail_int },
7938 { IS_RCVURGENT_START, IS_RCVURGENT_END,
7939 is_rcv_urgent_name, is_rcv_urgent_int },
7940 { IS_SENDCREDIT_START, IS_SENDCREDIT_END,
7941 is_send_credit_name, is_send_credit_int},
7942 { IS_RESERVED_START, IS_RESERVED_END,
7943 is_reserved_name, is_reserved_int},
7947 * Interrupt source interrupt - called when the given source has an interrupt.
7948 * Source is a bit index into an array of 64-bit integers.
7950 static void is_interrupt(struct hfi1_devdata *dd, unsigned int source)
7952 const struct is_table *entry;
7954 /* avoids a double compare by walking the table in-order */
7955 for (entry = &is_table[0]; entry->is_name; entry++) {
7956 if (source < entry->end) {
7957 trace_hfi1_interrupt(dd, entry, source);
7958 entry->is_int(dd, source - entry->start);
7962 /* fell off the end */
7963 dd_dev_err(dd, "invalid interrupt source %u\n", source);
7967 * General interrupt handler. This is able to correctly handle
7968 * all interrupts in case INTx is used.
7970 static irqreturn_t general_interrupt(int irq, void *data)
7972 struct hfi1_devdata *dd = data;
7973 u64 regs[CCE_NUM_INT_CSRS];
7977 this_cpu_inc(*dd->int_counter);
7979 /* phase 1: scan and clear all handled interrupts */
7980 for (i = 0; i < CCE_NUM_INT_CSRS; i++) {
7981 if (dd->gi_mask[i] == 0) {
7982 regs[i] = 0; /* used later */
7985 regs[i] = read_csr(dd, CCE_INT_STATUS + (8 * i)) &
7987 /* only clear if anything is set */
7989 write_csr(dd, CCE_INT_CLEAR + (8 * i), regs[i]);
7992 /* phase 2: call the appropriate handler */
7993 for_each_set_bit(bit, (unsigned long *)®s[0],
7994 CCE_NUM_INT_CSRS*64) {
7995 is_interrupt(dd, bit);
8001 static irqreturn_t sdma_interrupt(int irq, void *data)
8003 struct sdma_engine *sde = data;
8004 struct hfi1_devdata *dd = sde->dd;
8007 #ifdef CONFIG_SDMA_VERBOSITY
8008 dd_dev_err(dd, "CONFIG SDMA(%u) %s:%d %s()\n", sde->this_idx,
8009 slashstrip(__FILE__), __LINE__, __func__);
8010 sdma_dumpstate(sde);
8013 this_cpu_inc(*dd->int_counter);
8015 /* This read_csr is really bad in the hot path */
8016 status = read_csr(dd,
8017 CCE_INT_STATUS + (8*(IS_SDMA_START/64)))
8019 if (likely(status)) {
8020 /* clear the interrupt(s) */
8022 CCE_INT_CLEAR + (8*(IS_SDMA_START/64)),
8025 /* handle the interrupt(s) */
8026 sdma_engine_interrupt(sde, status);
8028 dd_dev_err(dd, "SDMA engine %u interrupt, but no status bits set\n",
8035 * Clear the receive interrupt. Use a read of the interrupt clear CSR
8036 * to insure that the write completed. This does NOT guarantee that
8037 * queued DMA writes to memory from the chip are pushed.
8039 static inline void clear_recv_intr(struct hfi1_ctxtdata *rcd)
8041 struct hfi1_devdata *dd = rcd->dd;
8042 u32 addr = CCE_INT_CLEAR + (8 * rcd->ireg);
8044 mmiowb(); /* make sure everything before is written */
8045 write_csr(dd, addr, rcd->imask);
8046 /* force the above write on the chip and get a value back */
8047 (void)read_csr(dd, addr);
8050 /* force the receive interrupt */
8051 void force_recv_intr(struct hfi1_ctxtdata *rcd)
8053 write_csr(rcd->dd, CCE_INT_FORCE + (8 * rcd->ireg), rcd->imask);
8057 * Return non-zero if a packet is present.
8059 * This routine is called when rechecking for packets after the RcvAvail
8060 * interrupt has been cleared down. First, do a quick check of memory for
8061 * a packet present. If not found, use an expensive CSR read of the context
8062 * tail to determine the actual tail. The CSR read is necessary because there
8063 * is no method to push pending DMAs to memory other than an interrupt and we
8064 * are trying to determine if we need to force an interrupt.
8066 static inline int check_packet_present(struct hfi1_ctxtdata *rcd)
8071 if (!HFI1_CAP_IS_KSET(DMA_RTAIL))
8072 present = (rcd->seq_cnt ==
8073 rhf_rcv_seq(rhf_to_cpu(get_rhf_addr(rcd))));
8074 else /* is RDMA rtail */
8075 present = (rcd->head != get_rcvhdrtail(rcd));
8080 /* fall back to a CSR read, correct indpendent of DMA_RTAIL */
8081 tail = (u32)read_uctxt_csr(rcd->dd, rcd->ctxt, RCV_HDR_TAIL);
8082 return rcd->head != tail;
8086 * Receive packet IRQ handler. This routine expects to be on its own IRQ.
8087 * This routine will try to handle packets immediately (latency), but if
8088 * it finds too many, it will invoke the thread handler (bandwitdh). The
8089 * chip receive interupt is *not* cleared down until this or the thread (if
8090 * invoked) is finished. The intent is to avoid extra interrupts while we
8091 * are processing packets anyway.
8093 static irqreturn_t receive_context_interrupt(int irq, void *data)
8095 struct hfi1_ctxtdata *rcd = data;
8096 struct hfi1_devdata *dd = rcd->dd;
8100 trace_hfi1_receive_interrupt(dd, rcd->ctxt);
8101 this_cpu_inc(*dd->int_counter);
8102 aspm_ctx_disable(rcd);
8104 /* receive interrupt remains blocked while processing packets */
8105 disposition = rcd->do_interrupt(rcd, 0);
8108 * Too many packets were seen while processing packets in this
8109 * IRQ handler. Invoke the handler thread. The receive interrupt
8112 if (disposition == RCV_PKT_LIMIT)
8113 return IRQ_WAKE_THREAD;
8116 * The packet processor detected no more packets. Clear the receive
8117 * interrupt and recheck for a packet packet that may have arrived
8118 * after the previous check and interrupt clear. If a packet arrived,
8119 * force another interrupt.
8121 clear_recv_intr(rcd);
8122 present = check_packet_present(rcd);
8124 force_recv_intr(rcd);
8130 * Receive packet thread handler. This expects to be invoked with the
8131 * receive interrupt still blocked.
8133 static irqreturn_t receive_context_thread(int irq, void *data)
8135 struct hfi1_ctxtdata *rcd = data;
8138 /* receive interrupt is still blocked from the IRQ handler */
8139 (void)rcd->do_interrupt(rcd, 1);
8142 * The packet processor will only return if it detected no more
8143 * packets. Hold IRQs here so we can safely clear the interrupt and
8144 * recheck for a packet that may have arrived after the previous
8145 * check and the interrupt clear. If a packet arrived, force another
8148 local_irq_disable();
8149 clear_recv_intr(rcd);
8150 present = check_packet_present(rcd);
8152 force_recv_intr(rcd);
8158 /* ========================================================================= */
8160 u32 read_physical_state(struct hfi1_devdata *dd)
8164 reg = read_csr(dd, DC_DC8051_STS_CUR_STATE);
8165 return (reg >> DC_DC8051_STS_CUR_STATE_PORT_SHIFT)
8166 & DC_DC8051_STS_CUR_STATE_PORT_MASK;
8169 u32 read_logical_state(struct hfi1_devdata *dd)
8173 reg = read_csr(dd, DCC_CFG_PORT_CONFIG);
8174 return (reg >> DCC_CFG_PORT_CONFIG_LINK_STATE_SHIFT)
8175 & DCC_CFG_PORT_CONFIG_LINK_STATE_MASK;
8178 static void set_logical_state(struct hfi1_devdata *dd, u32 chip_lstate)
8182 reg = read_csr(dd, DCC_CFG_PORT_CONFIG);
8183 /* clear current state, set new state */
8184 reg &= ~DCC_CFG_PORT_CONFIG_LINK_STATE_SMASK;
8185 reg |= (u64)chip_lstate << DCC_CFG_PORT_CONFIG_LINK_STATE_SHIFT;
8186 write_csr(dd, DCC_CFG_PORT_CONFIG, reg);
8190 * Use the 8051 to read a LCB CSR.
8192 static int read_lcb_via_8051(struct hfi1_devdata *dd, u32 addr, u64 *data)
8197 if (dd->icode == ICODE_FUNCTIONAL_SIMULATOR) {
8198 if (acquire_lcb_access(dd, 0) == 0) {
8199 *data = read_csr(dd, addr);
8200 release_lcb_access(dd, 0);
8206 /* register is an index of LCB registers: (offset - base) / 8 */
8207 regno = (addr - DC_LCB_CFG_RUN) >> 3;
8208 ret = do_8051_command(dd, HCMD_READ_LCB_CSR, regno, data);
8209 if (ret != HCMD_SUCCESS)
8215 * Read an LCB CSR. Access may not be in host control, so check.
8216 * Return 0 on success, -EBUSY on failure.
8218 int read_lcb_csr(struct hfi1_devdata *dd, u32 addr, u64 *data)
8220 struct hfi1_pportdata *ppd = dd->pport;
8222 /* if up, go through the 8051 for the value */
8223 if (ppd->host_link_state & HLS_UP)
8224 return read_lcb_via_8051(dd, addr, data);
8225 /* if going up or down, no access */
8226 if (ppd->host_link_state & (HLS_GOING_UP | HLS_GOING_OFFLINE))
8228 /* otherwise, host has access */
8229 *data = read_csr(dd, addr);
8234 * Use the 8051 to write a LCB CSR.
8236 static int write_lcb_via_8051(struct hfi1_devdata *dd, u32 addr, u64 data)
8241 if (dd->icode == ICODE_FUNCTIONAL_SIMULATOR ||
8242 (dd->dc8051_ver < dc8051_ver(0, 20))) {
8243 if (acquire_lcb_access(dd, 0) == 0) {
8244 write_csr(dd, addr, data);
8245 release_lcb_access(dd, 0);
8251 /* register is an index of LCB registers: (offset - base) / 8 */
8252 regno = (addr - DC_LCB_CFG_RUN) >> 3;
8253 ret = do_8051_command(dd, HCMD_WRITE_LCB_CSR, regno, &data);
8254 if (ret != HCMD_SUCCESS)
8260 * Write an LCB CSR. Access may not be in host control, so check.
8261 * Return 0 on success, -EBUSY on failure.
8263 int write_lcb_csr(struct hfi1_devdata *dd, u32 addr, u64 data)
8265 struct hfi1_pportdata *ppd = dd->pport;
8267 /* if up, go through the 8051 for the value */
8268 if (ppd->host_link_state & HLS_UP)
8269 return write_lcb_via_8051(dd, addr, data);
8270 /* if going up or down, no access */
8271 if (ppd->host_link_state & (HLS_GOING_UP | HLS_GOING_OFFLINE))
8273 /* otherwise, host has access */
8274 write_csr(dd, addr, data);
8280 * < 0 = Linux error, not able to get access
8281 * > 0 = 8051 command RETURN_CODE
8283 static int do_8051_command(
8284 struct hfi1_devdata *dd,
8291 unsigned long flags;
8292 unsigned long timeout;
8294 hfi1_cdbg(DC8051, "type %d, data 0x%012llx", type, in_data);
8297 * Alternative to holding the lock for a long time:
8298 * - keep busy wait - have other users bounce off
8300 spin_lock_irqsave(&dd->dc8051_lock, flags);
8302 /* We can't send any commands to the 8051 if it's in reset */
8303 if (dd->dc_shutdown) {
8304 return_code = -ENODEV;
8309 * If an 8051 host command timed out previously, then the 8051 is
8312 * On first timeout, attempt to reset and restart the entire DC
8313 * block (including 8051). (Is this too big of a hammer?)
8315 * If the 8051 times out a second time, the reset did not bring it
8316 * back to healthy life. In that case, fail any subsequent commands.
8318 if (dd->dc8051_timed_out) {
8319 if (dd->dc8051_timed_out > 1) {
8321 "Previous 8051 host command timed out, skipping command %u\n",
8323 return_code = -ENXIO;
8326 spin_unlock_irqrestore(&dd->dc8051_lock, flags);
8329 spin_lock_irqsave(&dd->dc8051_lock, flags);
8333 * If there is no timeout, then the 8051 command interface is
8334 * waiting for a command.
8338 * When writing a LCB CSR, out_data contains the full value to
8339 * to be written, while in_data contains the relative LCB
8340 * address in 7:0. Do the work here, rather than the caller,
8341 * of distrubting the write data to where it needs to go:
8344 * 39:00 -> in_data[47:8]
8345 * 47:40 -> DC8051_CFG_EXT_DEV_0.RETURN_CODE
8346 * 63:48 -> DC8051_CFG_EXT_DEV_0.RSP_DATA
8348 if (type == HCMD_WRITE_LCB_CSR) {
8349 in_data |= ((*out_data) & 0xffffffffffull) << 8;
8350 reg = ((((*out_data) >> 40) & 0xff) <<
8351 DC_DC8051_CFG_EXT_DEV_0_RETURN_CODE_SHIFT)
8352 | ((((*out_data) >> 48) & 0xffff) <<
8353 DC_DC8051_CFG_EXT_DEV_0_RSP_DATA_SHIFT);
8354 write_csr(dd, DC_DC8051_CFG_EXT_DEV_0, reg);
8358 * Do two writes: the first to stabilize the type and req_data, the
8359 * second to activate.
8361 reg = ((u64)type & DC_DC8051_CFG_HOST_CMD_0_REQ_TYPE_MASK)
8362 << DC_DC8051_CFG_HOST_CMD_0_REQ_TYPE_SHIFT
8363 | (in_data & DC_DC8051_CFG_HOST_CMD_0_REQ_DATA_MASK)
8364 << DC_DC8051_CFG_HOST_CMD_0_REQ_DATA_SHIFT;
8365 write_csr(dd, DC_DC8051_CFG_HOST_CMD_0, reg);
8366 reg |= DC_DC8051_CFG_HOST_CMD_0_REQ_NEW_SMASK;
8367 write_csr(dd, DC_DC8051_CFG_HOST_CMD_0, reg);
8369 /* wait for completion, alternate: interrupt */
8370 timeout = jiffies + msecs_to_jiffies(DC8051_COMMAND_TIMEOUT);
8372 reg = read_csr(dd, DC_DC8051_CFG_HOST_CMD_1);
8373 completed = reg & DC_DC8051_CFG_HOST_CMD_1_COMPLETED_SMASK;
8376 if (time_after(jiffies, timeout)) {
8377 dd->dc8051_timed_out++;
8378 dd_dev_err(dd, "8051 host command %u timeout\n", type);
8381 return_code = -ETIMEDOUT;
8388 *out_data = (reg >> DC_DC8051_CFG_HOST_CMD_1_RSP_DATA_SHIFT)
8389 & DC_DC8051_CFG_HOST_CMD_1_RSP_DATA_MASK;
8390 if (type == HCMD_READ_LCB_CSR) {
8391 /* top 16 bits are in a different register */
8392 *out_data |= (read_csr(dd, DC_DC8051_CFG_EXT_DEV_1)
8393 & DC_DC8051_CFG_EXT_DEV_1_REQ_DATA_SMASK)
8395 - DC_DC8051_CFG_EXT_DEV_1_REQ_DATA_SHIFT);
8398 return_code = (reg >> DC_DC8051_CFG_HOST_CMD_1_RETURN_CODE_SHIFT)
8399 & DC_DC8051_CFG_HOST_CMD_1_RETURN_CODE_MASK;
8400 dd->dc8051_timed_out = 0;
8402 * Clear command for next user.
8404 write_csr(dd, DC_DC8051_CFG_HOST_CMD_0, 0);
8407 spin_unlock_irqrestore(&dd->dc8051_lock, flags);
8412 static int set_physical_link_state(struct hfi1_devdata *dd, u64 state)
8414 return do_8051_command(dd, HCMD_CHANGE_PHY_STATE, state, NULL);
8417 int load_8051_config(struct hfi1_devdata *dd, u8 field_id,
8418 u8 lane_id, u32 config_data)
8423 data = (u64)field_id << LOAD_DATA_FIELD_ID_SHIFT
8424 | (u64)lane_id << LOAD_DATA_LANE_ID_SHIFT
8425 | (u64)config_data << LOAD_DATA_DATA_SHIFT;
8426 ret = do_8051_command(dd, HCMD_LOAD_CONFIG_DATA, data, NULL);
8427 if (ret != HCMD_SUCCESS) {
8429 "load 8051 config: field id %d, lane %d, err %d\n",
8430 (int)field_id, (int)lane_id, ret);
8436 * Read the 8051 firmware "registers". Use the RAM directly. Always
8437 * set the result, even on error.
8438 * Return 0 on success, -errno on failure
8440 int read_8051_config(struct hfi1_devdata *dd, u8 field_id, u8 lane_id,
8447 /* address start depends on the lane_id */
8449 addr = (4 * NUM_GENERAL_FIELDS)
8450 + (lane_id * 4 * NUM_LANE_FIELDS);
8453 addr += field_id * 4;
8455 /* read is in 8-byte chunks, hardware will truncate the address down */
8456 ret = read_8051_data(dd, addr, 8, &big_data);
8459 /* extract the 4 bytes we want */
8461 *result = (u32)(big_data >> 32);
8463 *result = (u32)big_data;
8466 dd_dev_err(dd, "%s: direct read failed, lane %d, field %d!\n",
8467 __func__, lane_id, field_id);
8473 static int write_vc_local_phy(struct hfi1_devdata *dd, u8 power_management,
8478 frame = continuous << CONTINIOUS_REMOTE_UPDATE_SUPPORT_SHIFT
8479 | power_management << POWER_MANAGEMENT_SHIFT;
8480 return load_8051_config(dd, VERIFY_CAP_LOCAL_PHY,
8481 GENERAL_CONFIG, frame);
8484 static int write_vc_local_fabric(struct hfi1_devdata *dd, u8 vau, u8 z, u8 vcu,
8485 u16 vl15buf, u8 crc_sizes)
8489 frame = (u32)vau << VAU_SHIFT
8491 | (u32)vcu << VCU_SHIFT
8492 | (u32)vl15buf << VL15BUF_SHIFT
8493 | (u32)crc_sizes << CRC_SIZES_SHIFT;
8494 return load_8051_config(dd, VERIFY_CAP_LOCAL_FABRIC,
8495 GENERAL_CONFIG, frame);
8498 static void read_vc_local_link_width(struct hfi1_devdata *dd, u8 *misc_bits,
8499 u8 *flag_bits, u16 *link_widths)
8503 read_8051_config(dd, VERIFY_CAP_LOCAL_LINK_WIDTH, GENERAL_CONFIG,
8505 *misc_bits = (frame >> MISC_CONFIG_BITS_SHIFT) & MISC_CONFIG_BITS_MASK;
8506 *flag_bits = (frame >> LOCAL_FLAG_BITS_SHIFT) & LOCAL_FLAG_BITS_MASK;
8507 *link_widths = (frame >> LINK_WIDTH_SHIFT) & LINK_WIDTH_MASK;
8510 static int write_vc_local_link_width(struct hfi1_devdata *dd,
8517 frame = (u32)misc_bits << MISC_CONFIG_BITS_SHIFT
8518 | (u32)flag_bits << LOCAL_FLAG_BITS_SHIFT
8519 | (u32)link_widths << LINK_WIDTH_SHIFT;
8520 return load_8051_config(dd, VERIFY_CAP_LOCAL_LINK_WIDTH, GENERAL_CONFIG,
8524 static int write_local_device_id(struct hfi1_devdata *dd, u16 device_id,
8529 frame = ((u32)device_id << LOCAL_DEVICE_ID_SHIFT)
8530 | ((u32)device_rev << LOCAL_DEVICE_REV_SHIFT);
8531 return load_8051_config(dd, LOCAL_DEVICE_ID, GENERAL_CONFIG, frame);
8534 static void read_remote_device_id(struct hfi1_devdata *dd, u16 *device_id,
8539 read_8051_config(dd, REMOTE_DEVICE_ID, GENERAL_CONFIG, &frame);
8540 *device_id = (frame >> REMOTE_DEVICE_ID_SHIFT) & REMOTE_DEVICE_ID_MASK;
8541 *device_rev = (frame >> REMOTE_DEVICE_REV_SHIFT)
8542 & REMOTE_DEVICE_REV_MASK;
8545 void read_misc_status(struct hfi1_devdata *dd, u8 *ver_a, u8 *ver_b)
8549 read_8051_config(dd, MISC_STATUS, GENERAL_CONFIG, &frame);
8550 *ver_a = (frame >> STS_FM_VERSION_A_SHIFT) & STS_FM_VERSION_A_MASK;
8551 *ver_b = (frame >> STS_FM_VERSION_B_SHIFT) & STS_FM_VERSION_B_MASK;
8554 static void read_vc_remote_phy(struct hfi1_devdata *dd, u8 *power_management,
8559 read_8051_config(dd, VERIFY_CAP_REMOTE_PHY, GENERAL_CONFIG, &frame);
8560 *power_management = (frame >> POWER_MANAGEMENT_SHIFT)
8561 & POWER_MANAGEMENT_MASK;
8562 *continuous = (frame >> CONTINIOUS_REMOTE_UPDATE_SUPPORT_SHIFT)
8563 & CONTINIOUS_REMOTE_UPDATE_SUPPORT_MASK;
8566 static void read_vc_remote_fabric(struct hfi1_devdata *dd, u8 *vau, u8 *z,
8567 u8 *vcu, u16 *vl15buf, u8 *crc_sizes)
8571 read_8051_config(dd, VERIFY_CAP_REMOTE_FABRIC, GENERAL_CONFIG, &frame);
8572 *vau = (frame >> VAU_SHIFT) & VAU_MASK;
8573 *z = (frame >> Z_SHIFT) & Z_MASK;
8574 *vcu = (frame >> VCU_SHIFT) & VCU_MASK;
8575 *vl15buf = (frame >> VL15BUF_SHIFT) & VL15BUF_MASK;
8576 *crc_sizes = (frame >> CRC_SIZES_SHIFT) & CRC_SIZES_MASK;
8579 static void read_vc_remote_link_width(struct hfi1_devdata *dd,
8585 read_8051_config(dd, VERIFY_CAP_REMOTE_LINK_WIDTH, GENERAL_CONFIG,
8587 *remote_tx_rate = (frame >> REMOTE_TX_RATE_SHIFT)
8588 & REMOTE_TX_RATE_MASK;
8589 *link_widths = (frame >> LINK_WIDTH_SHIFT) & LINK_WIDTH_MASK;
8592 static void read_local_lni(struct hfi1_devdata *dd, u8 *enable_lane_rx)
8596 read_8051_config(dd, LOCAL_LNI_INFO, GENERAL_CONFIG, &frame);
8597 *enable_lane_rx = (frame >> ENABLE_LANE_RX_SHIFT) & ENABLE_LANE_RX_MASK;
8600 static void read_mgmt_allowed(struct hfi1_devdata *dd, u8 *mgmt_allowed)
8604 read_8051_config(dd, REMOTE_LNI_INFO, GENERAL_CONFIG, &frame);
8605 *mgmt_allowed = (frame >> MGMT_ALLOWED_SHIFT) & MGMT_ALLOWED_MASK;
8608 static void read_last_local_state(struct hfi1_devdata *dd, u32 *lls)
8610 read_8051_config(dd, LAST_LOCAL_STATE_COMPLETE, GENERAL_CONFIG, lls);
8613 static void read_last_remote_state(struct hfi1_devdata *dd, u32 *lrs)
8615 read_8051_config(dd, LAST_REMOTE_STATE_COMPLETE, GENERAL_CONFIG, lrs);
8618 void hfi1_read_link_quality(struct hfi1_devdata *dd, u8 *link_quality)
8624 if (dd->pport->host_link_state & HLS_UP) {
8625 ret = read_8051_config(dd, LINK_QUALITY_INFO, GENERAL_CONFIG,
8628 *link_quality = (frame >> LINK_QUALITY_SHIFT)
8629 & LINK_QUALITY_MASK;
8633 static void read_planned_down_reason_code(struct hfi1_devdata *dd, u8 *pdrrc)
8637 read_8051_config(dd, LINK_QUALITY_INFO, GENERAL_CONFIG, &frame);
8638 *pdrrc = (frame >> DOWN_REMOTE_REASON_SHIFT) & DOWN_REMOTE_REASON_MASK;
8641 static int read_tx_settings(struct hfi1_devdata *dd,
8643 u8 *tx_polarity_inversion,
8644 u8 *rx_polarity_inversion,
8650 ret = read_8051_config(dd, TX_SETTINGS, GENERAL_CONFIG, &frame);
8651 *enable_lane_tx = (frame >> ENABLE_LANE_TX_SHIFT)
8652 & ENABLE_LANE_TX_MASK;
8653 *tx_polarity_inversion = (frame >> TX_POLARITY_INVERSION_SHIFT)
8654 & TX_POLARITY_INVERSION_MASK;
8655 *rx_polarity_inversion = (frame >> RX_POLARITY_INVERSION_SHIFT)
8656 & RX_POLARITY_INVERSION_MASK;
8657 *max_rate = (frame >> MAX_RATE_SHIFT) & MAX_RATE_MASK;
8661 static int write_tx_settings(struct hfi1_devdata *dd,
8663 u8 tx_polarity_inversion,
8664 u8 rx_polarity_inversion,
8669 /* no need to mask, all variable sizes match field widths */
8670 frame = enable_lane_tx << ENABLE_LANE_TX_SHIFT
8671 | tx_polarity_inversion << TX_POLARITY_INVERSION_SHIFT
8672 | rx_polarity_inversion << RX_POLARITY_INVERSION_SHIFT
8673 | max_rate << MAX_RATE_SHIFT;
8674 return load_8051_config(dd, TX_SETTINGS, GENERAL_CONFIG, frame);
8677 static void check_fabric_firmware_versions(struct hfi1_devdata *dd)
8679 u32 frame, version, prod_id;
8683 for (lane = 0; lane < 4; lane++) {
8684 ret = read_8051_config(dd, SPICO_FW_VERSION, lane, &frame);
8688 "Unable to read lane %d firmware details\n",
8692 version = (frame >> SPICO_ROM_VERSION_SHIFT)
8693 & SPICO_ROM_VERSION_MASK;
8694 prod_id = (frame >> SPICO_ROM_PROD_ID_SHIFT)
8695 & SPICO_ROM_PROD_ID_MASK;
8697 "Lane %d firmware: version 0x%04x, prod_id 0x%04x\n",
8698 lane, version, prod_id);
8703 * Read an idle LCB message.
8705 * Returns 0 on success, -EINVAL on error
8707 static int read_idle_message(struct hfi1_devdata *dd, u64 type, u64 *data_out)
8711 ret = do_8051_command(dd, HCMD_READ_LCB_IDLE_MSG,
8713 if (ret != HCMD_SUCCESS) {
8714 dd_dev_err(dd, "read idle message: type %d, err %d\n",
8718 dd_dev_info(dd, "%s: read idle message 0x%llx\n", __func__, *data_out);
8719 /* return only the payload as we already know the type */
8720 *data_out >>= IDLE_PAYLOAD_SHIFT;
8725 * Read an idle SMA message. To be done in response to a notification from
8728 * Returns 0 on success, -EINVAL on error
8730 static int read_idle_sma(struct hfi1_devdata *dd, u64 *data)
8732 return read_idle_message(dd,
8733 (u64)IDLE_SMA << IDLE_MSG_TYPE_SHIFT, data);
8737 * Send an idle LCB message.
8739 * Returns 0 on success, -EINVAL on error
8741 static int send_idle_message(struct hfi1_devdata *dd, u64 data)
8745 dd_dev_info(dd, "%s: sending idle message 0x%llx\n", __func__, data);
8746 ret = do_8051_command(dd, HCMD_SEND_LCB_IDLE_MSG, data, NULL);
8747 if (ret != HCMD_SUCCESS) {
8748 dd_dev_err(dd, "send idle message: data 0x%llx, err %d\n",
8756 * Send an idle SMA message.
8758 * Returns 0 on success, -EINVAL on error
8760 int send_idle_sma(struct hfi1_devdata *dd, u64 message)
8764 data = ((message & IDLE_PAYLOAD_MASK) << IDLE_PAYLOAD_SHIFT)
8765 | ((u64)IDLE_SMA << IDLE_MSG_TYPE_SHIFT);
8766 return send_idle_message(dd, data);
8770 * Initialize the LCB then do a quick link up. This may or may not be
8773 * return 0 on success, -errno on error
8775 static int do_quick_linkup(struct hfi1_devdata *dd)
8778 unsigned long timeout;
8781 lcb_shutdown(dd, 0);
8784 /* LCB_CFG_LOOPBACK.VAL = 2 */
8785 /* LCB_CFG_LANE_WIDTH.VAL = 0 */
8786 write_csr(dd, DC_LCB_CFG_LOOPBACK,
8787 IB_PACKET_TYPE << DC_LCB_CFG_LOOPBACK_VAL_SHIFT);
8788 write_csr(dd, DC_LCB_CFG_LANE_WIDTH, 0);
8791 /* start the LCBs */
8792 /* LCB_CFG_TX_FIFOS_RESET.VAL = 0 */
8793 write_csr(dd, DC_LCB_CFG_TX_FIFOS_RESET, 0);
8795 /* simulator only loopback steps */
8796 if (loopback && dd->icode == ICODE_FUNCTIONAL_SIMULATOR) {
8797 /* LCB_CFG_RUN.EN = 1 */
8798 write_csr(dd, DC_LCB_CFG_RUN,
8799 1ull << DC_LCB_CFG_RUN_EN_SHIFT);
8801 /* watch LCB_STS_LINK_TRANSFER_ACTIVE */
8802 timeout = jiffies + msecs_to_jiffies(10);
8805 DC_LCB_STS_LINK_TRANSFER_ACTIVE);
8808 if (time_after(jiffies, timeout)) {
8810 "timeout waiting for LINK_TRANSFER_ACTIVE\n");
8816 write_csr(dd, DC_LCB_CFG_ALLOW_LINK_UP,
8817 1ull << DC_LCB_CFG_ALLOW_LINK_UP_VAL_SHIFT);
8822 * When doing quick linkup and not in loopback, both
8823 * sides must be done with LCB set-up before either
8824 * starts the quick linkup. Put a delay here so that
8825 * both sides can be started and have a chance to be
8826 * done with LCB set up before resuming.
8829 "Pausing for peer to be finished with LCB set up\n");
8832 "Continuing with quick linkup\n");
8835 write_csr(dd, DC_LCB_ERR_EN, 0); /* mask LCB errors */
8836 set_8051_lcb_access(dd);
8839 * State "quick" LinkUp request sets the physical link state to
8840 * LinkUp without a verify capability sequence.
8841 * This state is in simulator v37 and later.
8843 ret = set_physical_link_state(dd, PLS_QUICK_LINKUP);
8844 if (ret != HCMD_SUCCESS) {
8846 "%s: set physical link state to quick LinkUp failed with return %d\n",
8849 set_host_lcb_access(dd);
8850 write_csr(dd, DC_LCB_ERR_EN, ~0ull); /* watch LCB errors */
8857 return 0; /* success */
8861 * Set the SerDes to internal loopback mode.
8862 * Returns 0 on success, -errno on error.
8864 static int set_serdes_loopback_mode(struct hfi1_devdata *dd)
8868 ret = set_physical_link_state(dd, PLS_INTERNAL_SERDES_LOOPBACK);
8869 if (ret == HCMD_SUCCESS)
8872 "Set physical link state to SerDes Loopback failed with return %d\n",
8880 * Do all special steps to set up loopback.
8882 static int init_loopback(struct hfi1_devdata *dd)
8884 dd_dev_info(dd, "Entering loopback mode\n");
8886 /* all loopbacks should disable self GUID check */
8887 write_csr(dd, DC_DC8051_CFG_MODE,
8888 (read_csr(dd, DC_DC8051_CFG_MODE) | DISABLE_SELF_GUID_CHECK));
8891 * The simulator has only one loopback option - LCB. Switch
8892 * to that option, which includes quick link up.
8894 * Accept all valid loopback values.
8896 if ((dd->icode == ICODE_FUNCTIONAL_SIMULATOR)
8897 && (loopback == LOOPBACK_SERDES
8898 || loopback == LOOPBACK_LCB
8899 || loopback == LOOPBACK_CABLE)) {
8900 loopback = LOOPBACK_LCB;
8905 /* handle serdes loopback */
8906 if (loopback == LOOPBACK_SERDES) {
8907 /* internal serdes loopack needs quick linkup on RTL */
8908 if (dd->icode == ICODE_RTL_SILICON)
8910 return set_serdes_loopback_mode(dd);
8913 /* LCB loopback - handled at poll time */
8914 if (loopback == LOOPBACK_LCB) {
8915 quick_linkup = 1; /* LCB is always quick linkup */
8917 /* not supported in emulation due to emulation RTL changes */
8918 if (dd->icode == ICODE_FPGA_EMULATION) {
8920 "LCB loopback not supported in emulation\n");
8926 /* external cable loopback requires no extra steps */
8927 if (loopback == LOOPBACK_CABLE)
8930 dd_dev_err(dd, "Invalid loopback mode %d\n", loopback);
8935 * Translate from the OPA_LINK_WIDTH handed to us by the FM to bits
8936 * used in the Verify Capability link width attribute.
8938 static u16 opa_to_vc_link_widths(u16 opa_widths)
8943 static const struct link_bits {
8946 } opa_link_xlate[] = {
8947 { OPA_LINK_WIDTH_1X, 1 << (1-1) },
8948 { OPA_LINK_WIDTH_2X, 1 << (2-1) },
8949 { OPA_LINK_WIDTH_3X, 1 << (3-1) },
8950 { OPA_LINK_WIDTH_4X, 1 << (4-1) },
8953 for (i = 0; i < ARRAY_SIZE(opa_link_xlate); i++) {
8954 if (opa_widths & opa_link_xlate[i].from)
8955 result |= opa_link_xlate[i].to;
8961 * Set link attributes before moving to polling.
8963 static int set_local_link_attributes(struct hfi1_pportdata *ppd)
8965 struct hfi1_devdata *dd = ppd->dd;
8967 u8 tx_polarity_inversion;
8968 u8 rx_polarity_inversion;
8971 /* reset our fabric serdes to clear any lingering problems */
8972 fabric_serdes_reset(dd);
8974 /* set the local tx rate - need to read-modify-write */
8975 ret = read_tx_settings(dd, &enable_lane_tx, &tx_polarity_inversion,
8976 &rx_polarity_inversion, &ppd->local_tx_rate);
8978 goto set_local_link_attributes_fail;
8980 if (dd->dc8051_ver < dc8051_ver(0, 20)) {
8981 /* set the tx rate to the fastest enabled */
8982 if (ppd->link_speed_enabled & OPA_LINK_SPEED_25G)
8983 ppd->local_tx_rate = 1;
8985 ppd->local_tx_rate = 0;
8987 /* set the tx rate to all enabled */
8988 ppd->local_tx_rate = 0;
8989 if (ppd->link_speed_enabled & OPA_LINK_SPEED_25G)
8990 ppd->local_tx_rate |= 2;
8991 if (ppd->link_speed_enabled & OPA_LINK_SPEED_12_5G)
8992 ppd->local_tx_rate |= 1;
8995 enable_lane_tx = 0xF; /* enable all four lanes */
8996 ret = write_tx_settings(dd, enable_lane_tx, tx_polarity_inversion,
8997 rx_polarity_inversion, ppd->local_tx_rate);
8998 if (ret != HCMD_SUCCESS)
8999 goto set_local_link_attributes_fail;
9002 * DC supports continuous updates.
9004 ret = write_vc_local_phy(dd, 0 /* no power management */,
9005 1 /* continuous updates */);
9006 if (ret != HCMD_SUCCESS)
9007 goto set_local_link_attributes_fail;
9009 /* z=1 in the next call: AU of 0 is not supported by the hardware */
9010 ret = write_vc_local_fabric(dd, dd->vau, 1, dd->vcu, dd->vl15_init,
9011 ppd->port_crc_mode_enabled);
9012 if (ret != HCMD_SUCCESS)
9013 goto set_local_link_attributes_fail;
9015 ret = write_vc_local_link_width(dd, 0, 0,
9016 opa_to_vc_link_widths(ppd->link_width_enabled));
9017 if (ret != HCMD_SUCCESS)
9018 goto set_local_link_attributes_fail;
9020 /* let peer know who we are */
9021 ret = write_local_device_id(dd, dd->pcidev->device, dd->minrev);
9022 if (ret == HCMD_SUCCESS)
9025 set_local_link_attributes_fail:
9027 "Failed to set local link attributes, return 0x%x\n",
9033 * Call this to start the link. Schedule a retry if the cable is not
9034 * present or if unable to start polling. Do not do anything if the
9035 * link is disabled. Returns 0 if link is disabled or moved to polling
9037 int start_link(struct hfi1_pportdata *ppd)
9039 if (!ppd->link_enabled) {
9040 dd_dev_info(ppd->dd,
9041 "%s: stopping link start because link is disabled\n",
9045 if (!ppd->driver_link_ready) {
9046 dd_dev_info(ppd->dd,
9047 "%s: stopping link start because driver is not ready\n",
9052 if (qsfp_mod_present(ppd) || loopback == LOOPBACK_SERDES ||
9053 loopback == LOOPBACK_LCB ||
9054 ppd->dd->icode == ICODE_FUNCTIONAL_SIMULATOR)
9055 return set_link_state(ppd, HLS_DN_POLL);
9057 dd_dev_info(ppd->dd,
9058 "%s: stopping link start because no cable is present\n",
9063 static void wait_for_qsfp_init(struct hfi1_pportdata *ppd)
9065 struct hfi1_devdata *dd = ppd->dd;
9067 unsigned long timeout;
9070 * Check for QSFP interrupt for t_init (SFF 8679)
9072 timeout = jiffies + msecs_to_jiffies(2000);
9074 mask = read_csr(dd, dd->hfi1_id ?
9075 ASIC_QSFP2_IN : ASIC_QSFP1_IN);
9076 if (!(mask & QSFP_HFI0_INT_N)) {
9077 write_csr(dd, dd->hfi1_id ? ASIC_QSFP2_CLEAR :
9078 ASIC_QSFP1_CLEAR, QSFP_HFI0_INT_N);
9081 if (time_after(jiffies, timeout)) {
9082 dd_dev_info(dd, "%s: No IntN detected, reset complete\n",
9090 static void set_qsfp_int_n(struct hfi1_pportdata *ppd, u8 enable)
9092 struct hfi1_devdata *dd = ppd->dd;
9095 mask = read_csr(dd, dd->hfi1_id ? ASIC_QSFP2_MASK : ASIC_QSFP1_MASK);
9097 mask |= (u64)QSFP_HFI0_INT_N;
9099 mask &= ~(u64)QSFP_HFI0_INT_N;
9100 write_csr(dd, dd->hfi1_id ? ASIC_QSFP2_MASK : ASIC_QSFP1_MASK, mask);
9103 void reset_qsfp(struct hfi1_pportdata *ppd)
9105 struct hfi1_devdata *dd = ppd->dd;
9106 u64 mask, qsfp_mask;
9108 /* Disable INT_N from triggering QSFP interrupts */
9109 set_qsfp_int_n(ppd, 0);
9111 /* Reset the QSFP */
9112 mask = (u64)QSFP_HFI0_RESET_N;
9113 qsfp_mask = read_csr(dd, dd->hfi1_id ? ASIC_QSFP2_OE : ASIC_QSFP1_OE);
9116 dd->hfi1_id ? ASIC_QSFP2_OE : ASIC_QSFP1_OE, qsfp_mask);
9118 qsfp_mask = read_csr(dd, dd->hfi1_id ?
9119 ASIC_QSFP2_OUT : ASIC_QSFP1_OUT);
9122 dd->hfi1_id ? ASIC_QSFP2_OUT : ASIC_QSFP1_OUT, qsfp_mask);
9128 dd->hfi1_id ? ASIC_QSFP2_OUT : ASIC_QSFP1_OUT, qsfp_mask);
9130 wait_for_qsfp_init(ppd);
9133 * Allow INT_N to trigger the QSFP interrupt to watch
9134 * for alarms and warnings
9136 set_qsfp_int_n(ppd, 1);
9139 static int handle_qsfp_error_conditions(struct hfi1_pportdata *ppd,
9140 u8 *qsfp_interrupt_status)
9142 struct hfi1_devdata *dd = ppd->dd;
9144 if ((qsfp_interrupt_status[0] & QSFP_HIGH_TEMP_ALARM) ||
9145 (qsfp_interrupt_status[0] & QSFP_HIGH_TEMP_WARNING))
9147 "%s: QSFP cable on fire\n",
9150 if ((qsfp_interrupt_status[0] & QSFP_LOW_TEMP_ALARM) ||
9151 (qsfp_interrupt_status[0] & QSFP_LOW_TEMP_WARNING))
9153 "%s: QSFP cable temperature too low\n",
9156 if ((qsfp_interrupt_status[1] & QSFP_HIGH_VCC_ALARM) ||
9157 (qsfp_interrupt_status[1] & QSFP_HIGH_VCC_WARNING))
9159 "%s: QSFP supply voltage too high\n",
9162 if ((qsfp_interrupt_status[1] & QSFP_LOW_VCC_ALARM) ||
9163 (qsfp_interrupt_status[1] & QSFP_LOW_VCC_WARNING))
9165 "%s: QSFP supply voltage too low\n",
9168 /* Byte 2 is vendor specific */
9170 if ((qsfp_interrupt_status[3] & QSFP_HIGH_POWER_ALARM) ||
9171 (qsfp_interrupt_status[3] & QSFP_HIGH_POWER_WARNING))
9173 "%s: Cable RX channel 1/2 power too high\n",
9176 if ((qsfp_interrupt_status[3] & QSFP_LOW_POWER_ALARM) ||
9177 (qsfp_interrupt_status[3] & QSFP_LOW_POWER_WARNING))
9179 "%s: Cable RX channel 1/2 power too low\n",
9182 if ((qsfp_interrupt_status[4] & QSFP_HIGH_POWER_ALARM) ||
9183 (qsfp_interrupt_status[4] & QSFP_HIGH_POWER_WARNING))
9185 "%s: Cable RX channel 3/4 power too high\n",
9188 if ((qsfp_interrupt_status[4] & QSFP_LOW_POWER_ALARM) ||
9189 (qsfp_interrupt_status[4] & QSFP_LOW_POWER_WARNING))
9191 "%s: Cable RX channel 3/4 power too low\n",
9194 if ((qsfp_interrupt_status[5] & QSFP_HIGH_BIAS_ALARM) ||
9195 (qsfp_interrupt_status[5] & QSFP_HIGH_BIAS_WARNING))
9197 "%s: Cable TX channel 1/2 bias too high\n",
9200 if ((qsfp_interrupt_status[5] & QSFP_LOW_BIAS_ALARM) ||
9201 (qsfp_interrupt_status[5] & QSFP_LOW_BIAS_WARNING))
9203 "%s: Cable TX channel 1/2 bias too low\n",
9206 if ((qsfp_interrupt_status[6] & QSFP_HIGH_BIAS_ALARM) ||
9207 (qsfp_interrupt_status[6] & QSFP_HIGH_BIAS_WARNING))
9209 "%s: Cable TX channel 3/4 bias too high\n",
9212 if ((qsfp_interrupt_status[6] & QSFP_LOW_BIAS_ALARM) ||
9213 (qsfp_interrupt_status[6] & QSFP_LOW_BIAS_WARNING))
9215 "%s: Cable TX channel 3/4 bias too low\n",
9218 if ((qsfp_interrupt_status[7] & QSFP_HIGH_POWER_ALARM) ||
9219 (qsfp_interrupt_status[7] & QSFP_HIGH_POWER_WARNING))
9221 "%s: Cable TX channel 1/2 power too high\n",
9224 if ((qsfp_interrupt_status[7] & QSFP_LOW_POWER_ALARM) ||
9225 (qsfp_interrupt_status[7] & QSFP_LOW_POWER_WARNING))
9227 "%s: Cable TX channel 1/2 power too low\n",
9230 if ((qsfp_interrupt_status[8] & QSFP_HIGH_POWER_ALARM) ||
9231 (qsfp_interrupt_status[8] & QSFP_HIGH_POWER_WARNING))
9233 "%s: Cable TX channel 3/4 power too high\n",
9236 if ((qsfp_interrupt_status[8] & QSFP_LOW_POWER_ALARM) ||
9237 (qsfp_interrupt_status[8] & QSFP_LOW_POWER_WARNING))
9239 "%s: Cable TX channel 3/4 power too low\n",
9242 /* Bytes 9-10 and 11-12 are reserved */
9243 /* Bytes 13-15 are vendor specific */
9248 /* This routine will only be scheduled if the QSFP module is present */
9249 void qsfp_event(struct work_struct *work)
9251 struct qsfp_data *qd;
9252 struct hfi1_pportdata *ppd;
9253 struct hfi1_devdata *dd;
9255 qd = container_of(work, struct qsfp_data, qsfp_work);
9260 if (!qsfp_mod_present(ppd))
9264 * Turn DC back on after cables has been
9265 * re-inserted. Up until now, the DC has been in
9266 * reset to save power.
9270 if (qd->cache_refresh_required) {
9272 set_qsfp_int_n(ppd, 0);
9274 wait_for_qsfp_init(ppd);
9277 * Allow INT_N to trigger the QSFP interrupt to watch
9278 * for alarms and warnings
9280 set_qsfp_int_n(ppd, 1);
9287 if (qd->check_interrupt_flags) {
9288 u8 qsfp_interrupt_status[16] = {0,};
9290 if (qsfp_read(ppd, dd->hfi1_id, 6,
9291 &qsfp_interrupt_status[0], 16) != 16) {
9293 "%s: Failed to read status of QSFP module\n",
9296 unsigned long flags;
9298 handle_qsfp_error_conditions(
9299 ppd, qsfp_interrupt_status);
9300 spin_lock_irqsave(&ppd->qsfp_info.qsfp_lock, flags);
9301 ppd->qsfp_info.check_interrupt_flags = 0;
9302 spin_unlock_irqrestore(&ppd->qsfp_info.qsfp_lock,
9308 static void init_qsfp_int(struct hfi1_devdata *dd)
9310 struct hfi1_pportdata *ppd = dd->pport;
9311 u64 qsfp_mask, cce_int_mask;
9312 const int qsfp1_int_smask = QSFP1_INT % 64;
9313 const int qsfp2_int_smask = QSFP2_INT % 64;
9316 * disable QSFP1 interrupts for HFI1, QSFP2 interrupts for HFI0
9317 * Qsfp1Int and Qsfp2Int are adjacent bits in the same CSR,
9318 * therefore just one of QSFP1_INT/QSFP2_INT can be used to find
9319 * the index of the appropriate CSR in the CCEIntMask CSR array
9321 cce_int_mask = read_csr(dd, CCE_INT_MASK +
9322 (8 * (QSFP1_INT / 64)));
9324 cce_int_mask &= ~((u64)1 << qsfp1_int_smask);
9325 write_csr(dd, CCE_INT_MASK + (8 * (QSFP1_INT / 64)),
9328 cce_int_mask &= ~((u64)1 << qsfp2_int_smask);
9329 write_csr(dd, CCE_INT_MASK + (8 * (QSFP2_INT / 64)),
9333 qsfp_mask = (u64)(QSFP_HFI0_INT_N | QSFP_HFI0_MODPRST_N);
9334 /* Clear current status to avoid spurious interrupts */
9335 write_csr(dd, dd->hfi1_id ? ASIC_QSFP2_CLEAR : ASIC_QSFP1_CLEAR,
9337 write_csr(dd, dd->hfi1_id ? ASIC_QSFP2_MASK : ASIC_QSFP1_MASK,
9340 set_qsfp_int_n(ppd, 0);
9342 /* Handle active low nature of INT_N and MODPRST_N pins */
9343 if (qsfp_mod_present(ppd))
9344 qsfp_mask &= ~(u64)QSFP_HFI0_MODPRST_N;
9346 dd->hfi1_id ? ASIC_QSFP2_INVERT : ASIC_QSFP1_INVERT,
9351 * Do a one-time initialize of the LCB block.
9353 static void init_lcb(struct hfi1_devdata *dd)
9355 /* simulator does not correctly handle LCB cclk loopback, skip */
9356 if (dd->icode == ICODE_FUNCTIONAL_SIMULATOR)
9359 /* the DC has been reset earlier in the driver load */
9361 /* set LCB for cclk loopback on the port */
9362 write_csr(dd, DC_LCB_CFG_TX_FIFOS_RESET, 0x01);
9363 write_csr(dd, DC_LCB_CFG_LANE_WIDTH, 0x00);
9364 write_csr(dd, DC_LCB_CFG_REINIT_AS_SLAVE, 0x00);
9365 write_csr(dd, DC_LCB_CFG_CNT_FOR_SKIP_STALL, 0x110);
9366 write_csr(dd, DC_LCB_CFG_CLK_CNTR, 0x08);
9367 write_csr(dd, DC_LCB_CFG_LOOPBACK, 0x02);
9368 write_csr(dd, DC_LCB_CFG_TX_FIFOS_RESET, 0x00);
9371 int bringup_serdes(struct hfi1_pportdata *ppd)
9373 struct hfi1_devdata *dd = ppd->dd;
9377 if (HFI1_CAP_IS_KSET(EXTENDED_PSN))
9378 add_rcvctrl(dd, RCV_CTRL_RCV_EXTENDED_PSN_ENABLE_SMASK);
9383 guid = dd->base_guid + ppd->port - 1;
9387 /* Set linkinit_reason on power up per OPA spec */
9388 ppd->linkinit_reason = OPA_LINKINIT_REASON_LINKUP;
9390 /* one-time init of the LCB */
9394 ret = init_loopback(dd);
9399 /* tune the SERDES to a ballpark setting for
9400 * optimal signal and bit error rate
9401 * Needs to be done before starting the link
9405 return start_link(ppd);
9408 void hfi1_quiet_serdes(struct hfi1_pportdata *ppd)
9410 struct hfi1_devdata *dd = ppd->dd;
9413 * Shut down the link and keep it down. First turn off that the
9414 * driver wants to allow the link to be up (driver_link_ready).
9415 * Then make sure the link is not automatically restarted
9416 * (link_enabled). Cancel any pending restart. And finally
9419 ppd->driver_link_ready = 0;
9420 ppd->link_enabled = 0;
9422 ppd->offline_disabled_reason =
9423 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_SMA_DISABLED);
9424 set_link_down_reason(ppd, OPA_LINKDOWN_REASON_SMA_DISABLED, 0,
9425 OPA_LINKDOWN_REASON_SMA_DISABLED);
9426 set_link_state(ppd, HLS_DN_OFFLINE);
9428 /* disable the port */
9429 clear_rcvctrl(dd, RCV_CTRL_RCV_PORT_ENABLE_SMASK);
9432 static inline int init_cpu_counters(struct hfi1_devdata *dd)
9434 struct hfi1_pportdata *ppd;
9437 ppd = (struct hfi1_pportdata *)(dd + 1);
9438 for (i = 0; i < dd->num_pports; i++, ppd++) {
9439 ppd->ibport_data.rvp.rc_acks = NULL;
9440 ppd->ibport_data.rvp.rc_qacks = NULL;
9441 ppd->ibport_data.rvp.rc_acks = alloc_percpu(u64);
9442 ppd->ibport_data.rvp.rc_qacks = alloc_percpu(u64);
9443 ppd->ibport_data.rvp.rc_delayed_comp = alloc_percpu(u64);
9444 if (!ppd->ibport_data.rvp.rc_acks ||
9445 !ppd->ibport_data.rvp.rc_delayed_comp ||
9446 !ppd->ibport_data.rvp.rc_qacks)
9453 static const char * const pt_names[] = {
9459 static const char *pt_name(u32 type)
9461 return type >= ARRAY_SIZE(pt_names) ? "unknown" : pt_names[type];
9465 * index is the index into the receive array
9467 void hfi1_put_tid(struct hfi1_devdata *dd, u32 index,
9468 u32 type, unsigned long pa, u16 order)
9471 void __iomem *base = (dd->rcvarray_wc ? dd->rcvarray_wc :
9472 (dd->kregbase + RCV_ARRAY));
9474 if (!(dd->flags & HFI1_PRESENT))
9477 if (type == PT_INVALID) {
9479 } else if (type > PT_INVALID) {
9481 "unexpected receive array type %u for index %u, not handled\n",
9486 hfi1_cdbg(TID, "type %s, index 0x%x, pa 0x%lx, bsize 0x%lx",
9487 pt_name(type), index, pa, (unsigned long)order);
9489 #define RT_ADDR_SHIFT 12 /* 4KB kernel address boundary */
9490 reg = RCV_ARRAY_RT_WRITE_ENABLE_SMASK
9491 | (u64)order << RCV_ARRAY_RT_BUF_SIZE_SHIFT
9492 | ((pa >> RT_ADDR_SHIFT) & RCV_ARRAY_RT_ADDR_MASK)
9493 << RCV_ARRAY_RT_ADDR_SHIFT;
9494 writeq(reg, base + (index * 8));
9496 if (type == PT_EAGER)
9498 * Eager entries are written one-by-one so we have to push them
9499 * after we write the entry.
9506 void hfi1_clear_tids(struct hfi1_ctxtdata *rcd)
9508 struct hfi1_devdata *dd = rcd->dd;
9511 /* this could be optimized */
9512 for (i = rcd->eager_base; i < rcd->eager_base +
9513 rcd->egrbufs.alloced; i++)
9514 hfi1_put_tid(dd, i, PT_INVALID, 0, 0);
9516 for (i = rcd->expected_base;
9517 i < rcd->expected_base + rcd->expected_count; i++)
9518 hfi1_put_tid(dd, i, PT_INVALID, 0, 0);
9521 int hfi1_get_base_kinfo(struct hfi1_ctxtdata *rcd,
9522 struct hfi1_ctxt_info *kinfo)
9524 kinfo->runtime_flags = (HFI1_MISC_GET() << HFI1_CAP_USER_SHIFT) |
9525 HFI1_CAP_UGET(MASK) | HFI1_CAP_KGET(K2U);
9529 struct hfi1_message_header *hfi1_get_msgheader(
9530 struct hfi1_devdata *dd, __le32 *rhf_addr)
9532 u32 offset = rhf_hdrq_offset(rhf_to_cpu(rhf_addr));
9534 return (struct hfi1_message_header *)
9535 (rhf_addr - dd->rhf_offset + offset);
9538 static const char * const ib_cfg_name_strings[] = {
9539 "HFI1_IB_CFG_LIDLMC",
9540 "HFI1_IB_CFG_LWID_DG_ENB",
9541 "HFI1_IB_CFG_LWID_ENB",
9543 "HFI1_IB_CFG_SPD_ENB",
9545 "HFI1_IB_CFG_RXPOL_ENB",
9546 "HFI1_IB_CFG_LREV_ENB",
9547 "HFI1_IB_CFG_LINKLATENCY",
9548 "HFI1_IB_CFG_HRTBT",
9549 "HFI1_IB_CFG_OP_VLS",
9550 "HFI1_IB_CFG_VL_HIGH_CAP",
9551 "HFI1_IB_CFG_VL_LOW_CAP",
9552 "HFI1_IB_CFG_OVERRUN_THRESH",
9553 "HFI1_IB_CFG_PHYERR_THRESH",
9554 "HFI1_IB_CFG_LINKDEFAULT",
9555 "HFI1_IB_CFG_PKEYS",
9557 "HFI1_IB_CFG_LSTATE",
9558 "HFI1_IB_CFG_VL_HIGH_LIMIT",
9559 "HFI1_IB_CFG_PMA_TICKS",
9563 static const char *ib_cfg_name(int which)
9565 if (which < 0 || which >= ARRAY_SIZE(ib_cfg_name_strings))
9567 return ib_cfg_name_strings[which];
9570 int hfi1_get_ib_cfg(struct hfi1_pportdata *ppd, int which)
9572 struct hfi1_devdata *dd = ppd->dd;
9576 case HFI1_IB_CFG_LWID_ENB: /* allowed Link-width */
9577 val = ppd->link_width_enabled;
9579 case HFI1_IB_CFG_LWID: /* currently active Link-width */
9580 val = ppd->link_width_active;
9582 case HFI1_IB_CFG_SPD_ENB: /* allowed Link speeds */
9583 val = ppd->link_speed_enabled;
9585 case HFI1_IB_CFG_SPD: /* current Link speed */
9586 val = ppd->link_speed_active;
9589 case HFI1_IB_CFG_RXPOL_ENB: /* Auto-RX-polarity enable */
9590 case HFI1_IB_CFG_LREV_ENB: /* Auto-Lane-reversal enable */
9591 case HFI1_IB_CFG_LINKLATENCY:
9594 case HFI1_IB_CFG_OP_VLS:
9595 val = ppd->vls_operational;
9597 case HFI1_IB_CFG_VL_HIGH_CAP: /* VL arb high priority table size */
9598 val = VL_ARB_HIGH_PRIO_TABLE_SIZE;
9600 case HFI1_IB_CFG_VL_LOW_CAP: /* VL arb low priority table size */
9601 val = VL_ARB_LOW_PRIO_TABLE_SIZE;
9603 case HFI1_IB_CFG_OVERRUN_THRESH: /* IB overrun threshold */
9604 val = ppd->overrun_threshold;
9606 case HFI1_IB_CFG_PHYERR_THRESH: /* IB PHY error threshold */
9607 val = ppd->phy_error_threshold;
9609 case HFI1_IB_CFG_LINKDEFAULT: /* IB link default (sleep/poll) */
9610 val = dd->link_default;
9613 case HFI1_IB_CFG_HRTBT: /* Heartbeat off/enable/auto */
9614 case HFI1_IB_CFG_PMA_TICKS:
9617 if (HFI1_CAP_IS_KSET(PRINT_UNIMPL))
9620 "%s: which %s: not implemented\n",
9622 ib_cfg_name(which));
9630 * The largest MAD packet size.
9632 #define MAX_MAD_PACKET 2048
9635 * Return the maximum header bytes that can go on the _wire_
9636 * for this device. This count includes the ICRC which is
9637 * not part of the packet held in memory but it is appended
9639 * This is dependent on the device's receive header entry size.
9640 * HFI allows this to be set per-receive context, but the
9641 * driver presently enforces a global value.
9643 u32 lrh_max_header_bytes(struct hfi1_devdata *dd)
9646 * The maximum non-payload (MTU) bytes in LRH.PktLen are
9647 * the Receive Header Entry Size minus the PBC (or RHF) size
9648 * plus one DW for the ICRC appended by HW.
9650 * dd->rcd[0].rcvhdrqentsize is in DW.
9651 * We use rcd[0] as all context will have the same value. Also,
9652 * the first kernel context would have been allocated by now so
9653 * we are guaranteed a valid value.
9655 return (dd->rcd[0]->rcvhdrqentsize - 2/*PBC/RHF*/ + 1/*ICRC*/) << 2;
9660 * @ppd - per port data
9662 * Set the MTU by limiting how many DWs may be sent. The SendLenCheck*
9663 * registers compare against LRH.PktLen, so use the max bytes included
9666 * This routine changes all VL values except VL15, which it maintains at
9669 static void set_send_length(struct hfi1_pportdata *ppd)
9671 struct hfi1_devdata *dd = ppd->dd;
9672 u32 max_hb = lrh_max_header_bytes(dd), dcmtu;
9673 u32 maxvlmtu = dd->vld[15].mtu;
9674 u64 len1 = 0, len2 = (((dd->vld[15].mtu + max_hb) >> 2)
9675 & SEND_LEN_CHECK1_LEN_VL15_MASK) <<
9676 SEND_LEN_CHECK1_LEN_VL15_SHIFT;
9679 for (i = 0; i < ppd->vls_supported; i++) {
9680 if (dd->vld[i].mtu > maxvlmtu)
9681 maxvlmtu = dd->vld[i].mtu;
9683 len1 |= (((dd->vld[i].mtu + max_hb) >> 2)
9684 & SEND_LEN_CHECK0_LEN_VL0_MASK) <<
9685 ((i % 4) * SEND_LEN_CHECK0_LEN_VL1_SHIFT);
9687 len2 |= (((dd->vld[i].mtu + max_hb) >> 2)
9688 & SEND_LEN_CHECK1_LEN_VL4_MASK) <<
9689 ((i % 4) * SEND_LEN_CHECK1_LEN_VL5_SHIFT);
9691 write_csr(dd, SEND_LEN_CHECK0, len1);
9692 write_csr(dd, SEND_LEN_CHECK1, len2);
9693 /* adjust kernel credit return thresholds based on new MTUs */
9694 /* all kernel receive contexts have the same hdrqentsize */
9695 for (i = 0; i < ppd->vls_supported; i++) {
9696 sc_set_cr_threshold(dd->vld[i].sc,
9697 sc_mtu_to_threshold(dd->vld[i].sc, dd->vld[i].mtu,
9698 dd->rcd[0]->rcvhdrqentsize));
9700 sc_set_cr_threshold(dd->vld[15].sc,
9701 sc_mtu_to_threshold(dd->vld[15].sc, dd->vld[15].mtu,
9702 dd->rcd[0]->rcvhdrqentsize));
9704 /* Adjust maximum MTU for the port in DC */
9705 dcmtu = maxvlmtu == 10240 ? DCC_CFG_PORT_MTU_CAP_10240 :
9706 (ilog2(maxvlmtu >> 8) + 1);
9707 len1 = read_csr(ppd->dd, DCC_CFG_PORT_CONFIG);
9708 len1 &= ~DCC_CFG_PORT_CONFIG_MTU_CAP_SMASK;
9709 len1 |= ((u64)dcmtu & DCC_CFG_PORT_CONFIG_MTU_CAP_MASK) <<
9710 DCC_CFG_PORT_CONFIG_MTU_CAP_SHIFT;
9711 write_csr(ppd->dd, DCC_CFG_PORT_CONFIG, len1);
9714 static void set_lidlmc(struct hfi1_pportdata *ppd)
9718 struct hfi1_devdata *dd = ppd->dd;
9719 u32 mask = ~((1U << ppd->lmc) - 1);
9720 u64 c1 = read_csr(ppd->dd, DCC_CFG_PORT_CONFIG1);
9722 if (dd->hfi1_snoop.mode_flag)
9723 dd_dev_info(dd, "Set lid/lmc while snooping");
9725 c1 &= ~(DCC_CFG_PORT_CONFIG1_TARGET_DLID_SMASK
9726 | DCC_CFG_PORT_CONFIG1_DLID_MASK_SMASK);
9727 c1 |= ((ppd->lid & DCC_CFG_PORT_CONFIG1_TARGET_DLID_MASK)
9728 << DCC_CFG_PORT_CONFIG1_TARGET_DLID_SHIFT)|
9729 ((mask & DCC_CFG_PORT_CONFIG1_DLID_MASK_MASK)
9730 << DCC_CFG_PORT_CONFIG1_DLID_MASK_SHIFT);
9731 write_csr(ppd->dd, DCC_CFG_PORT_CONFIG1, c1);
9734 * Iterate over all the send contexts and set their SLID check
9736 sreg = ((mask & SEND_CTXT_CHECK_SLID_MASK_MASK) <<
9737 SEND_CTXT_CHECK_SLID_MASK_SHIFT) |
9738 (((ppd->lid & mask) & SEND_CTXT_CHECK_SLID_VALUE_MASK) <<
9739 SEND_CTXT_CHECK_SLID_VALUE_SHIFT);
9741 for (i = 0; i < dd->chip_send_contexts; i++) {
9742 hfi1_cdbg(LINKVERB, "SendContext[%d].SLID_CHECK = 0x%x",
9744 write_kctxt_csr(dd, i, SEND_CTXT_CHECK_SLID, sreg);
9747 /* Now we have to do the same thing for the sdma engines */
9748 sdma_update_lmc(dd, mask, ppd->lid);
9751 static int wait_phy_linkstate(struct hfi1_devdata *dd, u32 state, u32 msecs)
9753 unsigned long timeout;
9756 timeout = jiffies + msecs_to_jiffies(msecs);
9758 curr_state = read_physical_state(dd);
9759 if (curr_state == state)
9761 if (time_after(jiffies, timeout)) {
9763 "timeout waiting for phy link state 0x%x, current state is 0x%x\n",
9767 usleep_range(1950, 2050); /* sleep 2ms-ish */
9774 * Helper for set_link_state(). Do not call except from that routine.
9775 * Expects ppd->hls_mutex to be held.
9777 * @rem_reason value to be sent to the neighbor
9779 * LinkDownReasons only set if transition succeeds.
9781 static int goto_offline(struct hfi1_pportdata *ppd, u8 rem_reason)
9783 struct hfi1_devdata *dd = ppd->dd;
9784 u32 pstate, previous_state;
9785 u32 last_local_state;
9786 u32 last_remote_state;
9791 previous_state = ppd->host_link_state;
9792 ppd->host_link_state = HLS_GOING_OFFLINE;
9793 pstate = read_physical_state(dd);
9794 if (pstate == PLS_OFFLINE) {
9795 do_transition = 0; /* in right state */
9796 do_wait = 0; /* ...no need to wait */
9797 } else if ((pstate & 0xff) == PLS_OFFLINE) {
9798 do_transition = 0; /* in an offline transient state */
9799 do_wait = 1; /* ...wait for it to settle */
9801 do_transition = 1; /* need to move to offline */
9802 do_wait = 1; /* ...will need to wait */
9805 if (do_transition) {
9806 ret = set_physical_link_state(dd,
9807 PLS_OFFLINE | (rem_reason << 8));
9809 if (ret != HCMD_SUCCESS) {
9811 "Failed to transition to Offline link state, return %d\n",
9815 if (ppd->offline_disabled_reason ==
9816 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_NONE))
9817 ppd->offline_disabled_reason =
9818 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_TRANSIENT);
9822 /* it can take a while for the link to go down */
9823 ret = wait_phy_linkstate(dd, PLS_OFFLINE, 10000);
9828 /* make sure the logical state is also down */
9829 wait_logical_linkstate(ppd, IB_PORT_DOWN, 1000);
9832 * Now in charge of LCB - must be after the physical state is
9833 * offline.quiet and before host_link_state is changed.
9835 set_host_lcb_access(dd);
9836 write_csr(dd, DC_LCB_ERR_EN, ~0ull); /* watch LCB errors */
9837 ppd->host_link_state = HLS_LINK_COOLDOWN; /* LCB access allowed */
9839 if (ppd->port_type == PORT_TYPE_QSFP &&
9840 ppd->qsfp_info.limiting_active &&
9841 qsfp_mod_present(ppd)) {
9842 set_qsfp_tx(ppd, 0);
9846 * The LNI has a mandatory wait time after the physical state
9847 * moves to Offline.Quiet. The wait time may be different
9848 * depending on how the link went down. The 8051 firmware
9849 * will observe the needed wait time and only move to ready
9850 * when that is completed. The largest of the quiet timeouts
9851 * is 6s, so wait that long and then at least 0.5s more for
9852 * other transitions, and another 0.5s for a buffer.
9854 ret = wait_fm_ready(dd, 7000);
9857 "After going offline, timed out waiting for the 8051 to become ready to accept host requests\n");
9858 /* state is really offline, so make it so */
9859 ppd->host_link_state = HLS_DN_OFFLINE;
9864 * The state is now offline and the 8051 is ready to accept host
9866 * - change our state
9867 * - notify others if we were previously in a linkup state
9869 ppd->host_link_state = HLS_DN_OFFLINE;
9870 if (previous_state & HLS_UP) {
9871 /* went down while link was up */
9872 handle_linkup_change(dd, 0);
9873 } else if (previous_state
9874 & (HLS_DN_POLL | HLS_VERIFY_CAP | HLS_GOING_UP)) {
9875 /* went down while attempting link up */
9876 /* byte 1 of last_*_state is the failure reason */
9877 read_last_local_state(dd, &last_local_state);
9878 read_last_remote_state(dd, &last_remote_state);
9880 "LNI failure last states: local 0x%08x, remote 0x%08x\n",
9881 last_local_state, last_remote_state);
9884 /* the active link width (downgrade) is 0 on link down */
9885 ppd->link_width_active = 0;
9886 ppd->link_width_downgrade_tx_active = 0;
9887 ppd->link_width_downgrade_rx_active = 0;
9888 ppd->current_egress_rate = 0;
9892 /* return the link state name */
9893 static const char *link_state_name(u32 state)
9896 int n = ilog2(state);
9897 static const char * const names[] = {
9898 [__HLS_UP_INIT_BP] = "INIT",
9899 [__HLS_UP_ARMED_BP] = "ARMED",
9900 [__HLS_UP_ACTIVE_BP] = "ACTIVE",
9901 [__HLS_DN_DOWNDEF_BP] = "DOWNDEF",
9902 [__HLS_DN_POLL_BP] = "POLL",
9903 [__HLS_DN_DISABLE_BP] = "DISABLE",
9904 [__HLS_DN_OFFLINE_BP] = "OFFLINE",
9905 [__HLS_VERIFY_CAP_BP] = "VERIFY_CAP",
9906 [__HLS_GOING_UP_BP] = "GOING_UP",
9907 [__HLS_GOING_OFFLINE_BP] = "GOING_OFFLINE",
9908 [__HLS_LINK_COOLDOWN_BP] = "LINK_COOLDOWN"
9911 name = n < ARRAY_SIZE(names) ? names[n] : NULL;
9912 return name ? name : "unknown";
9915 /* return the link state reason name */
9916 static const char *link_state_reason_name(struct hfi1_pportdata *ppd, u32 state)
9918 if (state == HLS_UP_INIT) {
9919 switch (ppd->linkinit_reason) {
9920 case OPA_LINKINIT_REASON_LINKUP:
9922 case OPA_LINKINIT_REASON_FLAPPING:
9923 return "(FLAPPING)";
9924 case OPA_LINKINIT_OUTSIDE_POLICY:
9925 return "(OUTSIDE_POLICY)";
9926 case OPA_LINKINIT_QUARANTINED:
9927 return "(QUARANTINED)";
9928 case OPA_LINKINIT_INSUFIC_CAPABILITY:
9929 return "(INSUFIC_CAPABILITY)";
9938 * driver_physical_state - convert the driver's notion of a port's
9939 * state (an HLS_*) into a physical state (a {IB,OPA}_PORTPHYSSTATE_*).
9940 * Return -1 (converted to a u32) to indicate error.
9942 u32 driver_physical_state(struct hfi1_pportdata *ppd)
9944 switch (ppd->host_link_state) {
9948 return IB_PORTPHYSSTATE_LINKUP;
9950 return IB_PORTPHYSSTATE_POLLING;
9951 case HLS_DN_DISABLE:
9952 return IB_PORTPHYSSTATE_DISABLED;
9953 case HLS_DN_OFFLINE:
9954 return OPA_PORTPHYSSTATE_OFFLINE;
9955 case HLS_VERIFY_CAP:
9956 return IB_PORTPHYSSTATE_POLLING;
9958 return IB_PORTPHYSSTATE_POLLING;
9959 case HLS_GOING_OFFLINE:
9960 return OPA_PORTPHYSSTATE_OFFLINE;
9961 case HLS_LINK_COOLDOWN:
9962 return OPA_PORTPHYSSTATE_OFFLINE;
9963 case HLS_DN_DOWNDEF:
9965 dd_dev_err(ppd->dd, "invalid host_link_state 0x%x\n",
9966 ppd->host_link_state);
9972 * driver_logical_state - convert the driver's notion of a port's
9973 * state (an HLS_*) into a logical state (a IB_PORT_*). Return -1
9974 * (converted to a u32) to indicate error.
9976 u32 driver_logical_state(struct hfi1_pportdata *ppd)
9978 if (ppd->host_link_state && !(ppd->host_link_state & HLS_UP))
9979 return IB_PORT_DOWN;
9981 switch (ppd->host_link_state & HLS_UP) {
9983 return IB_PORT_INIT;
9985 return IB_PORT_ARMED;
9987 return IB_PORT_ACTIVE;
9989 dd_dev_err(ppd->dd, "invalid host_link_state 0x%x\n",
9990 ppd->host_link_state);
9995 void set_link_down_reason(struct hfi1_pportdata *ppd, u8 lcl_reason,
9996 u8 neigh_reason, u8 rem_reason)
9998 if (ppd->local_link_down_reason.latest == 0 &&
9999 ppd->neigh_link_down_reason.latest == 0) {
10000 ppd->local_link_down_reason.latest = lcl_reason;
10001 ppd->neigh_link_down_reason.latest = neigh_reason;
10002 ppd->remote_link_down_reason = rem_reason;
10007 * Change the physical and/or logical link state.
10009 * Do not call this routine while inside an interrupt. It contains
10010 * calls to routines that can take multiple seconds to finish.
10012 * Returns 0 on success, -errno on failure.
10014 int set_link_state(struct hfi1_pportdata *ppd, u32 state)
10016 struct hfi1_devdata *dd = ppd->dd;
10017 struct ib_event event = {.device = NULL};
10019 int was_up, is_down;
10020 int orig_new_state, poll_bounce;
10022 mutex_lock(&ppd->hls_lock);
10024 orig_new_state = state;
10025 if (state == HLS_DN_DOWNDEF)
10026 state = dd->link_default;
10028 /* interpret poll -> poll as a link bounce */
10029 poll_bounce = ppd->host_link_state == HLS_DN_POLL
10030 && state == HLS_DN_POLL;
10032 dd_dev_info(dd, "%s: current %s, new %s %s%s\n", __func__,
10033 link_state_name(ppd->host_link_state),
10034 link_state_name(orig_new_state),
10035 poll_bounce ? "(bounce) " : "",
10036 link_state_reason_name(ppd, state));
10038 was_up = !!(ppd->host_link_state & HLS_UP);
10041 * If we're going to a (HLS_*) link state that implies the logical
10042 * link state is neither of (IB_PORT_ARMED, IB_PORT_ACTIVE), then
10043 * reset is_sm_config_started to 0.
10045 if (!(state & (HLS_UP_ARMED | HLS_UP_ACTIVE)))
10046 ppd->is_sm_config_started = 0;
10049 * Do nothing if the states match. Let a poll to poll link bounce
10052 if (ppd->host_link_state == state && !poll_bounce)
10057 if (ppd->host_link_state == HLS_DN_POLL && (quick_linkup
10058 || dd->icode == ICODE_FUNCTIONAL_SIMULATOR)) {
10060 * Quick link up jumps from polling to here.
10062 * Whether in normal or loopback mode, the
10063 * simulator jumps from polling to link up.
10064 * Accept that here.
10067 } else if (ppd->host_link_state != HLS_GOING_UP) {
10071 ppd->host_link_state = HLS_UP_INIT;
10072 ret = wait_logical_linkstate(ppd, IB_PORT_INIT, 1000);
10074 /* logical state didn't change, stay at going_up */
10075 ppd->host_link_state = HLS_GOING_UP;
10077 "%s: logical state did not change to INIT\n",
10080 /* clear old transient LINKINIT_REASON code */
10081 if (ppd->linkinit_reason >= OPA_LINKINIT_REASON_CLEAR)
10082 ppd->linkinit_reason =
10083 OPA_LINKINIT_REASON_LINKUP;
10085 /* enable the port */
10086 add_rcvctrl(dd, RCV_CTRL_RCV_PORT_ENABLE_SMASK);
10088 handle_linkup_change(dd, 1);
10092 if (ppd->host_link_state != HLS_UP_INIT)
10095 ppd->host_link_state = HLS_UP_ARMED;
10096 set_logical_state(dd, LSTATE_ARMED);
10097 ret = wait_logical_linkstate(ppd, IB_PORT_ARMED, 1000);
10099 /* logical state didn't change, stay at init */
10100 ppd->host_link_state = HLS_UP_INIT;
10102 "%s: logical state did not change to ARMED\n",
10106 * The simulator does not currently implement SMA messages,
10107 * so neighbor_normal is not set. Set it here when we first
10110 if (dd->icode == ICODE_FUNCTIONAL_SIMULATOR)
10111 ppd->neighbor_normal = 1;
10113 case HLS_UP_ACTIVE:
10114 if (ppd->host_link_state != HLS_UP_ARMED)
10117 ppd->host_link_state = HLS_UP_ACTIVE;
10118 set_logical_state(dd, LSTATE_ACTIVE);
10119 ret = wait_logical_linkstate(ppd, IB_PORT_ACTIVE, 1000);
10121 /* logical state didn't change, stay at armed */
10122 ppd->host_link_state = HLS_UP_ARMED;
10124 "%s: logical state did not change to ACTIVE\n",
10128 /* tell all engines to go running */
10129 sdma_all_running(dd);
10131 /* Signal the IB layer that the port has went active */
10132 event.device = &dd->verbs_dev.rdi.ibdev;
10133 event.element.port_num = ppd->port;
10134 event.event = IB_EVENT_PORT_ACTIVE;
10138 if ((ppd->host_link_state == HLS_DN_DISABLE ||
10139 ppd->host_link_state == HLS_DN_OFFLINE) &&
10142 /* Hand LED control to the DC */
10143 write_csr(dd, DCC_CFG_LED_CNTRL, 0);
10145 if (ppd->host_link_state != HLS_DN_OFFLINE) {
10146 u8 tmp = ppd->link_enabled;
10148 ret = goto_offline(ppd, ppd->remote_link_down_reason);
10150 ppd->link_enabled = tmp;
10153 ppd->remote_link_down_reason = 0;
10155 if (ppd->driver_link_ready)
10156 ppd->link_enabled = 1;
10159 set_all_slowpath(ppd->dd);
10160 ret = set_local_link_attributes(ppd);
10164 ppd->port_error_action = 0;
10165 ppd->host_link_state = HLS_DN_POLL;
10167 if (quick_linkup) {
10168 /* quick linkup does not go into polling */
10169 ret = do_quick_linkup(dd);
10171 ret1 = set_physical_link_state(dd, PLS_POLLING);
10172 if (ret1 != HCMD_SUCCESS) {
10174 "Failed to transition to Polling link state, return 0x%x\n",
10179 ppd->offline_disabled_reason =
10180 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_NONE);
10182 * If an error occurred above, go back to offline. The
10183 * caller may reschedule another attempt.
10186 goto_offline(ppd, 0);
10188 case HLS_DN_DISABLE:
10189 /* link is disabled */
10190 ppd->link_enabled = 0;
10192 /* allow any state to transition to disabled */
10194 /* must transition to offline first */
10195 if (ppd->host_link_state != HLS_DN_OFFLINE) {
10196 ret = goto_offline(ppd, ppd->remote_link_down_reason);
10199 ppd->remote_link_down_reason = 0;
10202 ret1 = set_physical_link_state(dd, PLS_DISABLED);
10203 if (ret1 != HCMD_SUCCESS) {
10205 "Failed to transition to Disabled link state, return 0x%x\n",
10210 ppd->host_link_state = HLS_DN_DISABLE;
10213 case HLS_DN_OFFLINE:
10214 if (ppd->host_link_state == HLS_DN_DISABLE)
10217 /* allow any state to transition to offline */
10218 ret = goto_offline(ppd, ppd->remote_link_down_reason);
10220 ppd->remote_link_down_reason = 0;
10222 case HLS_VERIFY_CAP:
10223 if (ppd->host_link_state != HLS_DN_POLL)
10225 ppd->host_link_state = HLS_VERIFY_CAP;
10228 if (ppd->host_link_state != HLS_VERIFY_CAP)
10231 ret1 = set_physical_link_state(dd, PLS_LINKUP);
10232 if (ret1 != HCMD_SUCCESS) {
10234 "Failed to transition to link up state, return 0x%x\n",
10239 ppd->host_link_state = HLS_GOING_UP;
10242 case HLS_GOING_OFFLINE: /* transient within goto_offline() */
10243 case HLS_LINK_COOLDOWN: /* transient within goto_offline() */
10245 dd_dev_info(dd, "%s: state 0x%x: not supported\n",
10251 is_down = !!(ppd->host_link_state & (HLS_DN_POLL |
10252 HLS_DN_DISABLE | HLS_DN_OFFLINE));
10254 if (was_up && is_down && ppd->local_link_down_reason.sma == 0 &&
10255 ppd->neigh_link_down_reason.sma == 0) {
10256 ppd->local_link_down_reason.sma =
10257 ppd->local_link_down_reason.latest;
10258 ppd->neigh_link_down_reason.sma =
10259 ppd->neigh_link_down_reason.latest;
10265 dd_dev_err(dd, "%s: unexpected state transition from %s to %s\n",
10266 __func__, link_state_name(ppd->host_link_state),
10267 link_state_name(state));
10271 mutex_unlock(&ppd->hls_lock);
10274 ib_dispatch_event(&event);
10279 int hfi1_set_ib_cfg(struct hfi1_pportdata *ppd, int which, u32 val)
10285 case HFI1_IB_CFG_LIDLMC:
10288 case HFI1_IB_CFG_VL_HIGH_LIMIT:
10290 * The VL Arbitrator high limit is sent in units of 4k
10291 * bytes, while HFI stores it in units of 64 bytes.
10294 reg = ((u64)val & SEND_HIGH_PRIORITY_LIMIT_LIMIT_MASK)
10295 << SEND_HIGH_PRIORITY_LIMIT_LIMIT_SHIFT;
10296 write_csr(ppd->dd, SEND_HIGH_PRIORITY_LIMIT, reg);
10298 case HFI1_IB_CFG_LINKDEFAULT: /* IB link default (sleep/poll) */
10299 /* HFI only supports POLL as the default link down state */
10300 if (val != HLS_DN_POLL)
10303 case HFI1_IB_CFG_OP_VLS:
10304 if (ppd->vls_operational != val) {
10305 ppd->vls_operational = val;
10311 * For link width, link width downgrade, and speed enable, always AND
10312 * the setting with what is actually supported. This has two benefits.
10313 * First, enabled can't have unsupported values, no matter what the
10314 * SM or FM might want. Second, the ALL_SUPPORTED wildcards that mean
10315 * "fill in with your supported value" have all the bits in the
10316 * field set, so simply ANDing with supported has the desired result.
10318 case HFI1_IB_CFG_LWID_ENB: /* set allowed Link-width */
10319 ppd->link_width_enabled = val & ppd->link_width_supported;
10321 case HFI1_IB_CFG_LWID_DG_ENB: /* set allowed link width downgrade */
10322 ppd->link_width_downgrade_enabled =
10323 val & ppd->link_width_downgrade_supported;
10325 case HFI1_IB_CFG_SPD_ENB: /* allowed Link speeds */
10326 ppd->link_speed_enabled = val & ppd->link_speed_supported;
10328 case HFI1_IB_CFG_OVERRUN_THRESH: /* IB overrun threshold */
10330 * HFI does not follow IB specs, save this value
10331 * so we can report it, if asked.
10333 ppd->overrun_threshold = val;
10335 case HFI1_IB_CFG_PHYERR_THRESH: /* IB PHY error threshold */
10337 * HFI does not follow IB specs, save this value
10338 * so we can report it, if asked.
10340 ppd->phy_error_threshold = val;
10343 case HFI1_IB_CFG_MTU:
10344 set_send_length(ppd);
10347 case HFI1_IB_CFG_PKEYS:
10348 if (HFI1_CAP_IS_KSET(PKEY_CHECK))
10349 set_partition_keys(ppd);
10353 if (HFI1_CAP_IS_KSET(PRINT_UNIMPL))
10354 dd_dev_info(ppd->dd,
10355 "%s: which %s, val 0x%x: not implemented\n",
10356 __func__, ib_cfg_name(which), val);
10362 /* begin functions related to vl arbitration table caching */
10363 static void init_vl_arb_caches(struct hfi1_pportdata *ppd)
10367 BUILD_BUG_ON(VL_ARB_TABLE_SIZE !=
10368 VL_ARB_LOW_PRIO_TABLE_SIZE);
10369 BUILD_BUG_ON(VL_ARB_TABLE_SIZE !=
10370 VL_ARB_HIGH_PRIO_TABLE_SIZE);
10373 * Note that we always return values directly from the
10374 * 'vl_arb_cache' (and do no CSR reads) in response to a
10375 * 'Get(VLArbTable)'. This is obviously correct after a
10376 * 'Set(VLArbTable)', since the cache will then be up to
10377 * date. But it's also correct prior to any 'Set(VLArbTable)'
10378 * since then both the cache, and the relevant h/w registers
10382 for (i = 0; i < MAX_PRIO_TABLE; i++)
10383 spin_lock_init(&ppd->vl_arb_cache[i].lock);
10387 * vl_arb_lock_cache
10389 * All other vl_arb_* functions should be called only after locking
10392 static inline struct vl_arb_cache *
10393 vl_arb_lock_cache(struct hfi1_pportdata *ppd, int idx)
10395 if (idx != LO_PRIO_TABLE && idx != HI_PRIO_TABLE)
10397 spin_lock(&ppd->vl_arb_cache[idx].lock);
10398 return &ppd->vl_arb_cache[idx];
10401 static inline void vl_arb_unlock_cache(struct hfi1_pportdata *ppd, int idx)
10403 spin_unlock(&ppd->vl_arb_cache[idx].lock);
10406 static void vl_arb_get_cache(struct vl_arb_cache *cache,
10407 struct ib_vl_weight_elem *vl)
10409 memcpy(vl, cache->table, VL_ARB_TABLE_SIZE * sizeof(*vl));
10412 static void vl_arb_set_cache(struct vl_arb_cache *cache,
10413 struct ib_vl_weight_elem *vl)
10415 memcpy(cache->table, vl, VL_ARB_TABLE_SIZE * sizeof(*vl));
10418 static int vl_arb_match_cache(struct vl_arb_cache *cache,
10419 struct ib_vl_weight_elem *vl)
10421 return !memcmp(cache->table, vl, VL_ARB_TABLE_SIZE * sizeof(*vl));
10423 /* end functions related to vl arbitration table caching */
10425 static int set_vl_weights(struct hfi1_pportdata *ppd, u32 target,
10426 u32 size, struct ib_vl_weight_elem *vl)
10428 struct hfi1_devdata *dd = ppd->dd;
10430 unsigned int i, is_up = 0;
10431 int drain, ret = 0;
10433 mutex_lock(&ppd->hls_lock);
10435 if (ppd->host_link_state & HLS_UP)
10438 drain = !is_ax(dd) && is_up;
10442 * Before adjusting VL arbitration weights, empty per-VL
10443 * FIFOs, otherwise a packet whose VL weight is being
10444 * set to 0 could get stuck in a FIFO with no chance to
10447 ret = stop_drain_data_vls(dd);
10452 "%s: cannot stop/drain VLs - refusing to change VL arbitration weights\n",
10457 for (i = 0; i < size; i++, vl++) {
10459 * NOTE: The low priority shift and mask are used here, but
10460 * they are the same for both the low and high registers.
10462 reg = (((u64)vl->vl & SEND_LOW_PRIORITY_LIST_VL_MASK)
10463 << SEND_LOW_PRIORITY_LIST_VL_SHIFT)
10464 | (((u64)vl->weight
10465 & SEND_LOW_PRIORITY_LIST_WEIGHT_MASK)
10466 << SEND_LOW_PRIORITY_LIST_WEIGHT_SHIFT);
10467 write_csr(dd, target + (i * 8), reg);
10469 pio_send_control(dd, PSC_GLOBAL_VLARB_ENABLE);
10472 open_fill_data_vls(dd); /* reopen all VLs */
10475 mutex_unlock(&ppd->hls_lock);
10481 * Read one credit merge VL register.
10483 static void read_one_cm_vl(struct hfi1_devdata *dd, u32 csr,
10484 struct vl_limit *vll)
10486 u64 reg = read_csr(dd, csr);
10488 vll->dedicated = cpu_to_be16(
10489 (reg >> SEND_CM_CREDIT_VL_DEDICATED_LIMIT_VL_SHIFT)
10490 & SEND_CM_CREDIT_VL_DEDICATED_LIMIT_VL_MASK);
10491 vll->shared = cpu_to_be16(
10492 (reg >> SEND_CM_CREDIT_VL_SHARED_LIMIT_VL_SHIFT)
10493 & SEND_CM_CREDIT_VL_SHARED_LIMIT_VL_MASK);
10497 * Read the current credit merge limits.
10499 static int get_buffer_control(struct hfi1_devdata *dd,
10500 struct buffer_control *bc, u16 *overall_limit)
10505 /* not all entries are filled in */
10506 memset(bc, 0, sizeof(*bc));
10508 /* OPA and HFI have a 1-1 mapping */
10509 for (i = 0; i < TXE_NUM_DATA_VL; i++)
10510 read_one_cm_vl(dd, SEND_CM_CREDIT_VL + (8*i), &bc->vl[i]);
10512 /* NOTE: assumes that VL* and VL15 CSRs are bit-wise identical */
10513 read_one_cm_vl(dd, SEND_CM_CREDIT_VL15, &bc->vl[15]);
10515 reg = read_csr(dd, SEND_CM_GLOBAL_CREDIT);
10516 bc->overall_shared_limit = cpu_to_be16(
10517 (reg >> SEND_CM_GLOBAL_CREDIT_SHARED_LIMIT_SHIFT)
10518 & SEND_CM_GLOBAL_CREDIT_SHARED_LIMIT_MASK);
10520 *overall_limit = (reg
10521 >> SEND_CM_GLOBAL_CREDIT_TOTAL_CREDIT_LIMIT_SHIFT)
10522 & SEND_CM_GLOBAL_CREDIT_TOTAL_CREDIT_LIMIT_MASK;
10523 return sizeof(struct buffer_control);
10526 static int get_sc2vlnt(struct hfi1_devdata *dd, struct sc2vlnt *dp)
10531 /* each register contains 16 SC->VLnt mappings, 4 bits each */
10532 reg = read_csr(dd, DCC_CFG_SC_VL_TABLE_15_0);
10533 for (i = 0; i < sizeof(u64); i++) {
10534 u8 byte = *(((u8 *)®) + i);
10536 dp->vlnt[2 * i] = byte & 0xf;
10537 dp->vlnt[(2 * i) + 1] = (byte & 0xf0) >> 4;
10540 reg = read_csr(dd, DCC_CFG_SC_VL_TABLE_31_16);
10541 for (i = 0; i < sizeof(u64); i++) {
10542 u8 byte = *(((u8 *)®) + i);
10544 dp->vlnt[16 + (2 * i)] = byte & 0xf;
10545 dp->vlnt[16 + (2 * i) + 1] = (byte & 0xf0) >> 4;
10547 return sizeof(struct sc2vlnt);
10550 static void get_vlarb_preempt(struct hfi1_devdata *dd, u32 nelems,
10551 struct ib_vl_weight_elem *vl)
10555 for (i = 0; i < nelems; i++, vl++) {
10561 static void set_sc2vlnt(struct hfi1_devdata *dd, struct sc2vlnt *dp)
10563 write_csr(dd, DCC_CFG_SC_VL_TABLE_15_0,
10565 0, dp->vlnt[0] & 0xf,
10566 1, dp->vlnt[1] & 0xf,
10567 2, dp->vlnt[2] & 0xf,
10568 3, dp->vlnt[3] & 0xf,
10569 4, dp->vlnt[4] & 0xf,
10570 5, dp->vlnt[5] & 0xf,
10571 6, dp->vlnt[6] & 0xf,
10572 7, dp->vlnt[7] & 0xf,
10573 8, dp->vlnt[8] & 0xf,
10574 9, dp->vlnt[9] & 0xf,
10575 10, dp->vlnt[10] & 0xf,
10576 11, dp->vlnt[11] & 0xf,
10577 12, dp->vlnt[12] & 0xf,
10578 13, dp->vlnt[13] & 0xf,
10579 14, dp->vlnt[14] & 0xf,
10580 15, dp->vlnt[15] & 0xf));
10581 write_csr(dd, DCC_CFG_SC_VL_TABLE_31_16,
10582 DC_SC_VL_VAL(31_16,
10583 16, dp->vlnt[16] & 0xf,
10584 17, dp->vlnt[17] & 0xf,
10585 18, dp->vlnt[18] & 0xf,
10586 19, dp->vlnt[19] & 0xf,
10587 20, dp->vlnt[20] & 0xf,
10588 21, dp->vlnt[21] & 0xf,
10589 22, dp->vlnt[22] & 0xf,
10590 23, dp->vlnt[23] & 0xf,
10591 24, dp->vlnt[24] & 0xf,
10592 25, dp->vlnt[25] & 0xf,
10593 26, dp->vlnt[26] & 0xf,
10594 27, dp->vlnt[27] & 0xf,
10595 28, dp->vlnt[28] & 0xf,
10596 29, dp->vlnt[29] & 0xf,
10597 30, dp->vlnt[30] & 0xf,
10598 31, dp->vlnt[31] & 0xf));
10601 static void nonzero_msg(struct hfi1_devdata *dd, int idx, const char *what,
10605 dd_dev_info(dd, "Invalid %s limit %d on VL %d, ignoring\n",
10606 what, (int)limit, idx);
10609 /* change only the shared limit portion of SendCmGLobalCredit */
10610 static void set_global_shared(struct hfi1_devdata *dd, u16 limit)
10614 reg = read_csr(dd, SEND_CM_GLOBAL_CREDIT);
10615 reg &= ~SEND_CM_GLOBAL_CREDIT_SHARED_LIMIT_SMASK;
10616 reg |= (u64)limit << SEND_CM_GLOBAL_CREDIT_SHARED_LIMIT_SHIFT;
10617 write_csr(dd, SEND_CM_GLOBAL_CREDIT, reg);
10620 /* change only the total credit limit portion of SendCmGLobalCredit */
10621 static void set_global_limit(struct hfi1_devdata *dd, u16 limit)
10625 reg = read_csr(dd, SEND_CM_GLOBAL_CREDIT);
10626 reg &= ~SEND_CM_GLOBAL_CREDIT_TOTAL_CREDIT_LIMIT_SMASK;
10627 reg |= (u64)limit << SEND_CM_GLOBAL_CREDIT_TOTAL_CREDIT_LIMIT_SHIFT;
10628 write_csr(dd, SEND_CM_GLOBAL_CREDIT, reg);
10631 /* set the given per-VL shared limit */
10632 static void set_vl_shared(struct hfi1_devdata *dd, int vl, u16 limit)
10637 if (vl < TXE_NUM_DATA_VL)
10638 addr = SEND_CM_CREDIT_VL + (8 * vl);
10640 addr = SEND_CM_CREDIT_VL15;
10642 reg = read_csr(dd, addr);
10643 reg &= ~SEND_CM_CREDIT_VL_SHARED_LIMIT_VL_SMASK;
10644 reg |= (u64)limit << SEND_CM_CREDIT_VL_SHARED_LIMIT_VL_SHIFT;
10645 write_csr(dd, addr, reg);
10648 /* set the given per-VL dedicated limit */
10649 static void set_vl_dedicated(struct hfi1_devdata *dd, int vl, u16 limit)
10654 if (vl < TXE_NUM_DATA_VL)
10655 addr = SEND_CM_CREDIT_VL + (8 * vl);
10657 addr = SEND_CM_CREDIT_VL15;
10659 reg = read_csr(dd, addr);
10660 reg &= ~SEND_CM_CREDIT_VL_DEDICATED_LIMIT_VL_SMASK;
10661 reg |= (u64)limit << SEND_CM_CREDIT_VL_DEDICATED_LIMIT_VL_SHIFT;
10662 write_csr(dd, addr, reg);
10665 /* spin until the given per-VL status mask bits clear */
10666 static void wait_for_vl_status_clear(struct hfi1_devdata *dd, u64 mask,
10669 unsigned long timeout;
10672 timeout = jiffies + msecs_to_jiffies(VL_STATUS_CLEAR_TIMEOUT);
10674 reg = read_csr(dd, SEND_CM_CREDIT_USED_STATUS) & mask;
10677 return; /* success */
10678 if (time_after(jiffies, timeout))
10679 break; /* timed out */
10684 "%s credit change status not clearing after %dms, mask 0x%llx, not clear 0x%llx\n",
10685 which, VL_STATUS_CLEAR_TIMEOUT, mask, reg);
10687 * If this occurs, it is likely there was a credit loss on the link.
10688 * The only recovery from that is a link bounce.
10691 "Continuing anyway. A credit loss may occur. Suggest a link bounce\n");
10695 * The number of credits on the VLs may be changed while everything
10696 * is "live", but the following algorithm must be followed due to
10697 * how the hardware is actually implemented. In particular,
10698 * Return_Credit_Status[] is the only correct status check.
10700 * if (reducing Global_Shared_Credit_Limit or any shared limit changing)
10701 * set Global_Shared_Credit_Limit = 0
10703 * mask0 = all VLs that are changing either dedicated or shared limits
10704 * set Shared_Limit[mask0] = 0
10705 * spin until Return_Credit_Status[use_all_vl ? all VL : mask0] == 0
10706 * if (changing any dedicated limit)
10707 * mask1 = all VLs that are lowering dedicated limits
10708 * lower Dedicated_Limit[mask1]
10709 * spin until Return_Credit_Status[mask1] == 0
10710 * raise Dedicated_Limits
10711 * raise Shared_Limits
10712 * raise Global_Shared_Credit_Limit
10714 * lower = if the new limit is lower, set the limit to the new value
10715 * raise = if the new limit is higher than the current value (may be changed
10716 * earlier in the algorithm), set the new limit to the new value
10718 int set_buffer_control(struct hfi1_pportdata *ppd,
10719 struct buffer_control *new_bc)
10721 struct hfi1_devdata *dd = ppd->dd;
10722 u64 changing_mask, ld_mask, stat_mask;
10724 int i, use_all_mask;
10725 int this_shared_changing;
10726 int vl_count = 0, ret;
10728 * A0: add the variable any_shared_limit_changing below and in the
10729 * algorithm above. If removing A0 support, it can be removed.
10731 int any_shared_limit_changing;
10732 struct buffer_control cur_bc;
10733 u8 changing[OPA_MAX_VLS];
10734 u8 lowering_dedicated[OPA_MAX_VLS];
10737 const u64 all_mask =
10738 SEND_CM_CREDIT_USED_STATUS_VL0_RETURN_CREDIT_STATUS_SMASK
10739 | SEND_CM_CREDIT_USED_STATUS_VL1_RETURN_CREDIT_STATUS_SMASK
10740 | SEND_CM_CREDIT_USED_STATUS_VL2_RETURN_CREDIT_STATUS_SMASK
10741 | SEND_CM_CREDIT_USED_STATUS_VL3_RETURN_CREDIT_STATUS_SMASK
10742 | SEND_CM_CREDIT_USED_STATUS_VL4_RETURN_CREDIT_STATUS_SMASK
10743 | SEND_CM_CREDIT_USED_STATUS_VL5_RETURN_CREDIT_STATUS_SMASK
10744 | SEND_CM_CREDIT_USED_STATUS_VL6_RETURN_CREDIT_STATUS_SMASK
10745 | SEND_CM_CREDIT_USED_STATUS_VL7_RETURN_CREDIT_STATUS_SMASK
10746 | SEND_CM_CREDIT_USED_STATUS_VL15_RETURN_CREDIT_STATUS_SMASK;
10748 #define valid_vl(idx) ((idx) < TXE_NUM_DATA_VL || (idx) == 15)
10749 #define NUM_USABLE_VLS 16 /* look at VL15 and less */
10752 /* find the new total credits, do sanity check on unused VLs */
10753 for (i = 0; i < OPA_MAX_VLS; i++) {
10755 new_total += be16_to_cpu(new_bc->vl[i].dedicated);
10758 nonzero_msg(dd, i, "dedicated",
10759 be16_to_cpu(new_bc->vl[i].dedicated));
10760 nonzero_msg(dd, i, "shared",
10761 be16_to_cpu(new_bc->vl[i].shared));
10762 new_bc->vl[i].dedicated = 0;
10763 new_bc->vl[i].shared = 0;
10765 new_total += be16_to_cpu(new_bc->overall_shared_limit);
10767 /* fetch the current values */
10768 get_buffer_control(dd, &cur_bc, &cur_total);
10771 * Create the masks we will use.
10773 memset(changing, 0, sizeof(changing));
10774 memset(lowering_dedicated, 0, sizeof(lowering_dedicated));
10775 /* NOTE: Assumes that the individual VL bits are adjacent and in
10776 increasing order */
10778 SEND_CM_CREDIT_USED_STATUS_VL0_RETURN_CREDIT_STATUS_SMASK;
10782 any_shared_limit_changing = 0;
10783 for (i = 0; i < NUM_USABLE_VLS; i++, stat_mask <<= 1) {
10786 this_shared_changing = new_bc->vl[i].shared
10787 != cur_bc.vl[i].shared;
10788 if (this_shared_changing)
10789 any_shared_limit_changing = 1;
10790 if (new_bc->vl[i].dedicated != cur_bc.vl[i].dedicated
10791 || this_shared_changing) {
10793 changing_mask |= stat_mask;
10796 if (be16_to_cpu(new_bc->vl[i].dedicated) <
10797 be16_to_cpu(cur_bc.vl[i].dedicated)) {
10798 lowering_dedicated[i] = 1;
10799 ld_mask |= stat_mask;
10803 /* bracket the credit change with a total adjustment */
10804 if (new_total > cur_total)
10805 set_global_limit(dd, new_total);
10808 * Start the credit change algorithm.
10811 if ((be16_to_cpu(new_bc->overall_shared_limit) <
10812 be16_to_cpu(cur_bc.overall_shared_limit)) ||
10813 (is_ax(dd) && any_shared_limit_changing)) {
10814 set_global_shared(dd, 0);
10815 cur_bc.overall_shared_limit = 0;
10819 for (i = 0; i < NUM_USABLE_VLS; i++) {
10824 set_vl_shared(dd, i, 0);
10825 cur_bc.vl[i].shared = 0;
10829 wait_for_vl_status_clear(dd, use_all_mask ? all_mask : changing_mask,
10832 if (change_count > 0) {
10833 for (i = 0; i < NUM_USABLE_VLS; i++) {
10837 if (lowering_dedicated[i]) {
10838 set_vl_dedicated(dd, i,
10839 be16_to_cpu(new_bc->vl[i].dedicated));
10840 cur_bc.vl[i].dedicated =
10841 new_bc->vl[i].dedicated;
10845 wait_for_vl_status_clear(dd, ld_mask, "dedicated");
10847 /* now raise all dedicated that are going up */
10848 for (i = 0; i < NUM_USABLE_VLS; i++) {
10852 if (be16_to_cpu(new_bc->vl[i].dedicated) >
10853 be16_to_cpu(cur_bc.vl[i].dedicated))
10854 set_vl_dedicated(dd, i,
10855 be16_to_cpu(new_bc->vl[i].dedicated));
10859 /* next raise all shared that are going up */
10860 for (i = 0; i < NUM_USABLE_VLS; i++) {
10864 if (be16_to_cpu(new_bc->vl[i].shared) >
10865 be16_to_cpu(cur_bc.vl[i].shared))
10866 set_vl_shared(dd, i, be16_to_cpu(new_bc->vl[i].shared));
10869 /* finally raise the global shared */
10870 if (be16_to_cpu(new_bc->overall_shared_limit) >
10871 be16_to_cpu(cur_bc.overall_shared_limit))
10872 set_global_shared(dd,
10873 be16_to_cpu(new_bc->overall_shared_limit));
10875 /* bracket the credit change with a total adjustment */
10876 if (new_total < cur_total)
10877 set_global_limit(dd, new_total);
10880 * Determine the actual number of operational VLS using the number of
10881 * dedicated and shared credits for each VL.
10883 if (change_count > 0) {
10884 for (i = 0; i < TXE_NUM_DATA_VL; i++)
10885 if (be16_to_cpu(new_bc->vl[i].dedicated) > 0 ||
10886 be16_to_cpu(new_bc->vl[i].shared) > 0)
10888 ppd->actual_vls_operational = vl_count;
10889 ret = sdma_map_init(dd, ppd->port - 1, vl_count ?
10890 ppd->actual_vls_operational :
10891 ppd->vls_operational,
10894 ret = pio_map_init(dd, ppd->port - 1, vl_count ?
10895 ppd->actual_vls_operational :
10896 ppd->vls_operational, NULL);
10904 * Read the given fabric manager table. Return the size of the
10905 * table (in bytes) on success, and a negative error code on
10908 int fm_get_table(struct hfi1_pportdata *ppd, int which, void *t)
10912 struct vl_arb_cache *vlc;
10915 case FM_TBL_VL_HIGH_ARB:
10918 * OPA specifies 128 elements (of 2 bytes each), though
10919 * HFI supports only 16 elements in h/w.
10921 vlc = vl_arb_lock_cache(ppd, HI_PRIO_TABLE);
10922 vl_arb_get_cache(vlc, t);
10923 vl_arb_unlock_cache(ppd, HI_PRIO_TABLE);
10925 case FM_TBL_VL_LOW_ARB:
10928 * OPA specifies 128 elements (of 2 bytes each), though
10929 * HFI supports only 16 elements in h/w.
10931 vlc = vl_arb_lock_cache(ppd, LO_PRIO_TABLE);
10932 vl_arb_get_cache(vlc, t);
10933 vl_arb_unlock_cache(ppd, LO_PRIO_TABLE);
10935 case FM_TBL_BUFFER_CONTROL:
10936 size = get_buffer_control(ppd->dd, t, NULL);
10938 case FM_TBL_SC2VLNT:
10939 size = get_sc2vlnt(ppd->dd, t);
10941 case FM_TBL_VL_PREEMPT_ELEMS:
10943 /* OPA specifies 128 elements, of 2 bytes each */
10944 get_vlarb_preempt(ppd->dd, OPA_MAX_VLS, t);
10946 case FM_TBL_VL_PREEMPT_MATRIX:
10949 * OPA specifies that this is the same size as the VL
10950 * arbitration tables (i.e., 256 bytes).
10960 * Write the given fabric manager table.
10962 int fm_set_table(struct hfi1_pportdata *ppd, int which, void *t)
10965 struct vl_arb_cache *vlc;
10968 case FM_TBL_VL_HIGH_ARB:
10969 vlc = vl_arb_lock_cache(ppd, HI_PRIO_TABLE);
10970 if (vl_arb_match_cache(vlc, t)) {
10971 vl_arb_unlock_cache(ppd, HI_PRIO_TABLE);
10974 vl_arb_set_cache(vlc, t);
10975 vl_arb_unlock_cache(ppd, HI_PRIO_TABLE);
10976 ret = set_vl_weights(ppd, SEND_HIGH_PRIORITY_LIST,
10977 VL_ARB_HIGH_PRIO_TABLE_SIZE, t);
10979 case FM_TBL_VL_LOW_ARB:
10980 vlc = vl_arb_lock_cache(ppd, LO_PRIO_TABLE);
10981 if (vl_arb_match_cache(vlc, t)) {
10982 vl_arb_unlock_cache(ppd, LO_PRIO_TABLE);
10985 vl_arb_set_cache(vlc, t);
10986 vl_arb_unlock_cache(ppd, LO_PRIO_TABLE);
10987 ret = set_vl_weights(ppd, SEND_LOW_PRIORITY_LIST,
10988 VL_ARB_LOW_PRIO_TABLE_SIZE, t);
10990 case FM_TBL_BUFFER_CONTROL:
10991 ret = set_buffer_control(ppd, t);
10993 case FM_TBL_SC2VLNT:
10994 set_sc2vlnt(ppd->dd, t);
11003 * Disable all data VLs.
11005 * Return 0 if disabled, non-zero if the VLs cannot be disabled.
11007 static int disable_data_vls(struct hfi1_devdata *dd)
11012 pio_send_control(dd, PSC_DATA_VL_DISABLE);
11018 * open_fill_data_vls() - the counterpart to stop_drain_data_vls().
11019 * Just re-enables all data VLs (the "fill" part happens
11020 * automatically - the name was chosen for symmetry with
11021 * stop_drain_data_vls()).
11023 * Return 0 if successful, non-zero if the VLs cannot be enabled.
11025 int open_fill_data_vls(struct hfi1_devdata *dd)
11030 pio_send_control(dd, PSC_DATA_VL_ENABLE);
11036 * drain_data_vls() - assumes that disable_data_vls() has been called,
11037 * wait for occupancy (of per-VL FIFOs) for all contexts, and SDMA
11038 * engines to drop to 0.
11040 static void drain_data_vls(struct hfi1_devdata *dd)
11044 pause_for_credit_return(dd);
11048 * stop_drain_data_vls() - disable, then drain all per-VL fifos.
11050 * Use open_fill_data_vls() to resume using data VLs. This pair is
11051 * meant to be used like this:
11053 * stop_drain_data_vls(dd);
11054 * // do things with per-VL resources
11055 * open_fill_data_vls(dd);
11057 int stop_drain_data_vls(struct hfi1_devdata *dd)
11061 ret = disable_data_vls(dd);
11063 drain_data_vls(dd);
11069 * Convert a nanosecond time to a cclock count. No matter how slow
11070 * the cclock, a non-zero ns will always have a non-zero result.
11072 u32 ns_to_cclock(struct hfi1_devdata *dd, u32 ns)
11076 if (dd->icode == ICODE_FPGA_EMULATION)
11077 cclocks = (ns * 1000) / FPGA_CCLOCK_PS;
11078 else /* simulation pretends to be ASIC */
11079 cclocks = (ns * 1000) / ASIC_CCLOCK_PS;
11080 if (ns && !cclocks) /* if ns nonzero, must be at least 1 */
11086 * Convert a cclock count to nanoseconds. Not matter how slow
11087 * the cclock, a non-zero cclocks will always have a non-zero result.
11089 u32 cclock_to_ns(struct hfi1_devdata *dd, u32 cclocks)
11093 if (dd->icode == ICODE_FPGA_EMULATION)
11094 ns = (cclocks * FPGA_CCLOCK_PS) / 1000;
11095 else /* simulation pretends to be ASIC */
11096 ns = (cclocks * ASIC_CCLOCK_PS) / 1000;
11097 if (cclocks && !ns)
11103 * Dynamically adjust the receive interrupt timeout for a context based on
11104 * incoming packet rate.
11106 * NOTE: Dynamic adjustment does not allow rcv_intr_count to be zero.
11108 static void adjust_rcv_timeout(struct hfi1_ctxtdata *rcd, u32 npkts)
11110 struct hfi1_devdata *dd = rcd->dd;
11111 u32 timeout = rcd->rcvavail_timeout;
11114 * This algorithm doubles or halves the timeout depending on whether
11115 * the number of packets received in this interrupt were less than or
11116 * greater equal the interrupt count.
11118 * The calculations below do not allow a steady state to be achieved.
11119 * Only at the endpoints it is possible to have an unchanging
11122 if (npkts < rcv_intr_count) {
11124 * Not enough packets arrived before the timeout, adjust
11125 * timeout downward.
11127 if (timeout < 2) /* already at minimum? */
11132 * More than enough packets arrived before the timeout, adjust
11135 if (timeout >= dd->rcv_intr_timeout_csr) /* already at max? */
11137 timeout = min(timeout << 1, dd->rcv_intr_timeout_csr);
11140 rcd->rcvavail_timeout = timeout;
11141 /* timeout cannot be larger than rcv_intr_timeout_csr which has already
11142 been verified to be in range */
11143 write_kctxt_csr(dd, rcd->ctxt, RCV_AVAIL_TIME_OUT,
11144 (u64)timeout << RCV_AVAIL_TIME_OUT_TIME_OUT_RELOAD_SHIFT);
11147 void update_usrhead(struct hfi1_ctxtdata *rcd, u32 hd, u32 updegr, u32 egrhd,
11148 u32 intr_adjust, u32 npkts)
11150 struct hfi1_devdata *dd = rcd->dd;
11152 u32 ctxt = rcd->ctxt;
11155 * Need to write timeout register before updating RcvHdrHead to ensure
11156 * that a new value is used when the HW decides to restart counting.
11159 adjust_rcv_timeout(rcd, npkts);
11161 reg = (egrhd & RCV_EGR_INDEX_HEAD_HEAD_MASK)
11162 << RCV_EGR_INDEX_HEAD_HEAD_SHIFT;
11163 write_uctxt_csr(dd, ctxt, RCV_EGR_INDEX_HEAD, reg);
11166 reg = ((u64)rcv_intr_count << RCV_HDR_HEAD_COUNTER_SHIFT) |
11167 (((u64)hd & RCV_HDR_HEAD_HEAD_MASK)
11168 << RCV_HDR_HEAD_HEAD_SHIFT);
11169 write_uctxt_csr(dd, ctxt, RCV_HDR_HEAD, reg);
11173 u32 hdrqempty(struct hfi1_ctxtdata *rcd)
11177 head = (read_uctxt_csr(rcd->dd, rcd->ctxt, RCV_HDR_HEAD)
11178 & RCV_HDR_HEAD_HEAD_SMASK) >> RCV_HDR_HEAD_HEAD_SHIFT;
11180 if (rcd->rcvhdrtail_kvaddr)
11181 tail = get_rcvhdrtail(rcd);
11183 tail = read_uctxt_csr(rcd->dd, rcd->ctxt, RCV_HDR_TAIL);
11185 return head == tail;
11189 * Context Control and Receive Array encoding for buffer size:
11198 * 0x8 512 KB (Receive Array only)
11199 * 0x9 1 MB (Receive Array only)
11200 * 0xa 2 MB (Receive Array only)
11202 * 0xB-0xF - reserved (Receive Array only)
11205 * This routine assumes that the value has already been sanity checked.
11207 static u32 encoded_size(u32 size)
11210 case 4*1024: return 0x1;
11211 case 8*1024: return 0x2;
11212 case 16*1024: return 0x3;
11213 case 32*1024: return 0x4;
11214 case 64*1024: return 0x5;
11215 case 128*1024: return 0x6;
11216 case 256*1024: return 0x7;
11217 case 512*1024: return 0x8;
11218 case 1*1024*1024: return 0x9;
11219 case 2*1024*1024: return 0xa;
11221 return 0x1; /* if invalid, go with the minimum size */
11224 void hfi1_rcvctrl(struct hfi1_devdata *dd, unsigned int op, int ctxt)
11226 struct hfi1_ctxtdata *rcd;
11228 int did_enable = 0;
11230 rcd = dd->rcd[ctxt];
11234 hfi1_cdbg(RCVCTRL, "ctxt %d op 0x%x", ctxt, op);
11236 rcvctrl = read_kctxt_csr(dd, ctxt, RCV_CTXT_CTRL);
11237 /* if the context already enabled, don't do the extra steps */
11238 if ((op & HFI1_RCVCTRL_CTXT_ENB)
11239 && !(rcvctrl & RCV_CTXT_CTRL_ENABLE_SMASK)) {
11240 /* reset the tail and hdr addresses, and sequence count */
11241 write_kctxt_csr(dd, ctxt, RCV_HDR_ADDR,
11242 rcd->rcvhdrq_phys);
11243 if (HFI1_CAP_KGET_MASK(rcd->flags, DMA_RTAIL))
11244 write_kctxt_csr(dd, ctxt, RCV_HDR_TAIL_ADDR,
11245 rcd->rcvhdrqtailaddr_phys);
11248 /* reset the cached receive header queue head value */
11252 * Zero the receive header queue so we don't get false
11253 * positives when checking the sequence number. The
11254 * sequence numbers could land exactly on the same spot.
11255 * E.g. a rcd restart before the receive header wrapped.
11257 memset(rcd->rcvhdrq, 0, rcd->rcvhdrq_size);
11259 /* starting timeout */
11260 rcd->rcvavail_timeout = dd->rcv_intr_timeout_csr;
11262 /* enable the context */
11263 rcvctrl |= RCV_CTXT_CTRL_ENABLE_SMASK;
11265 /* clean the egr buffer size first */
11266 rcvctrl &= ~RCV_CTXT_CTRL_EGR_BUF_SIZE_SMASK;
11267 rcvctrl |= ((u64)encoded_size(rcd->egrbufs.rcvtid_size)
11268 & RCV_CTXT_CTRL_EGR_BUF_SIZE_MASK)
11269 << RCV_CTXT_CTRL_EGR_BUF_SIZE_SHIFT;
11271 /* zero RcvHdrHead - set RcvHdrHead.Counter after enable */
11272 write_uctxt_csr(dd, ctxt, RCV_HDR_HEAD, 0);
11275 /* zero RcvEgrIndexHead */
11276 write_uctxt_csr(dd, ctxt, RCV_EGR_INDEX_HEAD, 0);
11278 /* set eager count and base index */
11279 reg = (((u64)(rcd->egrbufs.alloced >> RCV_SHIFT)
11280 & RCV_EGR_CTRL_EGR_CNT_MASK)
11281 << RCV_EGR_CTRL_EGR_CNT_SHIFT) |
11282 (((rcd->eager_base >> RCV_SHIFT)
11283 & RCV_EGR_CTRL_EGR_BASE_INDEX_MASK)
11284 << RCV_EGR_CTRL_EGR_BASE_INDEX_SHIFT);
11285 write_kctxt_csr(dd, ctxt, RCV_EGR_CTRL, reg);
11288 * Set TID (expected) count and base index.
11289 * rcd->expected_count is set to individual RcvArray entries,
11290 * not pairs, and the CSR takes a pair-count in groups of
11291 * four, so divide by 8.
11293 reg = (((rcd->expected_count >> RCV_SHIFT)
11294 & RCV_TID_CTRL_TID_PAIR_CNT_MASK)
11295 << RCV_TID_CTRL_TID_PAIR_CNT_SHIFT) |
11296 (((rcd->expected_base >> RCV_SHIFT)
11297 & RCV_TID_CTRL_TID_BASE_INDEX_MASK)
11298 << RCV_TID_CTRL_TID_BASE_INDEX_SHIFT);
11299 write_kctxt_csr(dd, ctxt, RCV_TID_CTRL, reg);
11300 if (ctxt == HFI1_CTRL_CTXT)
11301 write_csr(dd, RCV_VL15, HFI1_CTRL_CTXT);
11303 if (op & HFI1_RCVCTRL_CTXT_DIS) {
11304 write_csr(dd, RCV_VL15, 0);
11306 * When receive context is being disabled turn on tail
11307 * update with a dummy tail address and then disable
11310 if (dd->rcvhdrtail_dummy_physaddr) {
11311 write_kctxt_csr(dd, ctxt, RCV_HDR_TAIL_ADDR,
11312 dd->rcvhdrtail_dummy_physaddr);
11313 /* Enabling RcvCtxtCtrl.TailUpd is intentional. */
11314 rcvctrl |= RCV_CTXT_CTRL_TAIL_UPD_SMASK;
11317 rcvctrl &= ~RCV_CTXT_CTRL_ENABLE_SMASK;
11319 if (op & HFI1_RCVCTRL_INTRAVAIL_ENB)
11320 rcvctrl |= RCV_CTXT_CTRL_INTR_AVAIL_SMASK;
11321 if (op & HFI1_RCVCTRL_INTRAVAIL_DIS)
11322 rcvctrl &= ~RCV_CTXT_CTRL_INTR_AVAIL_SMASK;
11323 if (op & HFI1_RCVCTRL_TAILUPD_ENB && rcd->rcvhdrqtailaddr_phys)
11324 rcvctrl |= RCV_CTXT_CTRL_TAIL_UPD_SMASK;
11325 if (op & HFI1_RCVCTRL_TAILUPD_DIS) {
11326 /* See comment on RcvCtxtCtrl.TailUpd above */
11327 if (!(op & HFI1_RCVCTRL_CTXT_DIS))
11328 rcvctrl &= ~RCV_CTXT_CTRL_TAIL_UPD_SMASK;
11330 if (op & HFI1_RCVCTRL_TIDFLOW_ENB)
11331 rcvctrl |= RCV_CTXT_CTRL_TID_FLOW_ENABLE_SMASK;
11332 if (op & HFI1_RCVCTRL_TIDFLOW_DIS)
11333 rcvctrl &= ~RCV_CTXT_CTRL_TID_FLOW_ENABLE_SMASK;
11334 if (op & HFI1_RCVCTRL_ONE_PKT_EGR_ENB) {
11335 /* In one-packet-per-eager mode, the size comes from
11336 the RcvArray entry. */
11337 rcvctrl &= ~RCV_CTXT_CTRL_EGR_BUF_SIZE_SMASK;
11338 rcvctrl |= RCV_CTXT_CTRL_ONE_PACKET_PER_EGR_BUFFER_SMASK;
11340 if (op & HFI1_RCVCTRL_ONE_PKT_EGR_DIS)
11341 rcvctrl &= ~RCV_CTXT_CTRL_ONE_PACKET_PER_EGR_BUFFER_SMASK;
11342 if (op & HFI1_RCVCTRL_NO_RHQ_DROP_ENB)
11343 rcvctrl |= RCV_CTXT_CTRL_DONT_DROP_RHQ_FULL_SMASK;
11344 if (op & HFI1_RCVCTRL_NO_RHQ_DROP_DIS)
11345 rcvctrl &= ~RCV_CTXT_CTRL_DONT_DROP_RHQ_FULL_SMASK;
11346 if (op & HFI1_RCVCTRL_NO_EGR_DROP_ENB)
11347 rcvctrl |= RCV_CTXT_CTRL_DONT_DROP_EGR_FULL_SMASK;
11348 if (op & HFI1_RCVCTRL_NO_EGR_DROP_DIS)
11349 rcvctrl &= ~RCV_CTXT_CTRL_DONT_DROP_EGR_FULL_SMASK;
11350 rcd->rcvctrl = rcvctrl;
11351 hfi1_cdbg(RCVCTRL, "ctxt %d rcvctrl 0x%llx\n", ctxt, rcvctrl);
11352 write_kctxt_csr(dd, ctxt, RCV_CTXT_CTRL, rcd->rcvctrl);
11354 /* work around sticky RcvCtxtStatus.BlockedRHQFull */
11356 && (rcvctrl & RCV_CTXT_CTRL_DONT_DROP_RHQ_FULL_SMASK)) {
11357 reg = read_kctxt_csr(dd, ctxt, RCV_CTXT_STATUS);
11359 dd_dev_info(dd, "ctxt %d status %lld (blocked)\n",
11361 read_uctxt_csr(dd, ctxt, RCV_HDR_HEAD);
11362 write_uctxt_csr(dd, ctxt, RCV_HDR_HEAD, 0x10);
11363 write_uctxt_csr(dd, ctxt, RCV_HDR_HEAD, 0x00);
11364 read_uctxt_csr(dd, ctxt, RCV_HDR_HEAD);
11365 reg = read_kctxt_csr(dd, ctxt, RCV_CTXT_STATUS);
11366 dd_dev_info(dd, "ctxt %d status %lld (%s blocked)\n",
11367 ctxt, reg, reg == 0 ? "not" : "still");
11373 * The interrupt timeout and count must be set after
11374 * the context is enabled to take effect.
11376 /* set interrupt timeout */
11377 write_kctxt_csr(dd, ctxt, RCV_AVAIL_TIME_OUT,
11378 (u64)rcd->rcvavail_timeout <<
11379 RCV_AVAIL_TIME_OUT_TIME_OUT_RELOAD_SHIFT);
11381 /* set RcvHdrHead.Counter, zero RcvHdrHead.Head (again) */
11382 reg = (u64)rcv_intr_count << RCV_HDR_HEAD_COUNTER_SHIFT;
11383 write_uctxt_csr(dd, ctxt, RCV_HDR_HEAD, reg);
11386 if (op & (HFI1_RCVCTRL_TAILUPD_DIS | HFI1_RCVCTRL_CTXT_DIS))
11388 * If the context has been disabled and the Tail Update has
11389 * been cleared, set the RCV_HDR_TAIL_ADDR CSR to dummy address
11390 * so it doesn't contain an address that is invalid.
11392 write_kctxt_csr(dd, ctxt, RCV_HDR_TAIL_ADDR,
11393 dd->rcvhdrtail_dummy_physaddr);
11396 u32 hfi1_read_cntrs(struct hfi1_devdata *dd, loff_t pos, char **namep,
11403 ret = dd->cntrnameslen;
11405 dd_dev_err(dd, "read_cntrs does not support indexing");
11408 *namep = dd->cntrnames;
11410 const struct cntr_entry *entry;
11413 ret = (dd->ndevcntrs) * sizeof(u64);
11415 dd_dev_err(dd, "read_cntrs does not support indexing");
11419 /* Get the start of the block of counters */
11420 *cntrp = dd->cntrs;
11423 * Now go and fill in each counter in the block.
11425 for (i = 0; i < DEV_CNTR_LAST; i++) {
11426 entry = &dev_cntrs[i];
11427 hfi1_cdbg(CNTR, "reading %s", entry->name);
11428 if (entry->flags & CNTR_DISABLED) {
11430 hfi1_cdbg(CNTR, "\tDisabled\n");
11432 if (entry->flags & CNTR_VL) {
11433 hfi1_cdbg(CNTR, "\tPer VL\n");
11434 for (j = 0; j < C_VL_COUNT; j++) {
11435 val = entry->rw_cntr(entry,
11441 "\t\tRead 0x%llx for %d\n",
11443 dd->cntrs[entry->offset + j] =
11446 } else if (entry->flags & CNTR_SDMA) {
11448 "\t Per SDMA Engine\n");
11449 for (j = 0; j < dd->chip_sdma_engines;
11452 entry->rw_cntr(entry, dd, j,
11455 "\t\tRead 0x%llx for %d\n",
11457 dd->cntrs[entry->offset + j] =
11461 val = entry->rw_cntr(entry, dd,
11464 dd->cntrs[entry->offset] = val;
11465 hfi1_cdbg(CNTR, "\tRead 0x%llx", val);
11474 * Used by sysfs to create files for hfi stats to read
11476 u32 hfi1_read_portcntrs(struct hfi1_devdata *dd, loff_t pos, u32 port,
11477 char **namep, u64 **cntrp)
11483 ret = dd->portcntrnameslen;
11485 dd_dev_err(dd, "index not supported");
11488 *namep = dd->portcntrnames;
11490 const struct cntr_entry *entry;
11491 struct hfi1_pportdata *ppd;
11494 ret = (dd->nportcntrs) * sizeof(u64);
11496 dd_dev_err(dd, "indexing not supported");
11499 ppd = (struct hfi1_pportdata *)(dd + 1 + port);
11500 *cntrp = ppd->cntrs;
11502 for (i = 0; i < PORT_CNTR_LAST; i++) {
11503 entry = &port_cntrs[i];
11504 hfi1_cdbg(CNTR, "reading %s", entry->name);
11505 if (entry->flags & CNTR_DISABLED) {
11507 hfi1_cdbg(CNTR, "\tDisabled\n");
11511 if (entry->flags & CNTR_VL) {
11512 hfi1_cdbg(CNTR, "\tPer VL");
11513 for (j = 0; j < C_VL_COUNT; j++) {
11514 val = entry->rw_cntr(entry, ppd, j,
11519 "\t\tRead 0x%llx for %d",
11521 ppd->cntrs[entry->offset + j] = val;
11524 val = entry->rw_cntr(entry, ppd,
11528 ppd->cntrs[entry->offset] = val;
11529 hfi1_cdbg(CNTR, "\tRead 0x%llx", val);
11536 static void free_cntrs(struct hfi1_devdata *dd)
11538 struct hfi1_pportdata *ppd;
11541 if (dd->synth_stats_timer.data)
11542 del_timer_sync(&dd->synth_stats_timer);
11543 dd->synth_stats_timer.data = 0;
11544 ppd = (struct hfi1_pportdata *)(dd + 1);
11545 for (i = 0; i < dd->num_pports; i++, ppd++) {
11547 kfree(ppd->scntrs);
11548 free_percpu(ppd->ibport_data.rvp.rc_acks);
11549 free_percpu(ppd->ibport_data.rvp.rc_qacks);
11550 free_percpu(ppd->ibport_data.rvp.rc_delayed_comp);
11552 ppd->scntrs = NULL;
11553 ppd->ibport_data.rvp.rc_acks = NULL;
11554 ppd->ibport_data.rvp.rc_qacks = NULL;
11555 ppd->ibport_data.rvp.rc_delayed_comp = NULL;
11557 kfree(dd->portcntrnames);
11558 dd->portcntrnames = NULL;
11563 kfree(dd->cntrnames);
11564 dd->cntrnames = NULL;
11567 #define CNTR_MAX 0xFFFFFFFFFFFFFFFFULL
11568 #define CNTR_32BIT_MAX 0x00000000FFFFFFFF
11570 static u64 read_dev_port_cntr(struct hfi1_devdata *dd, struct cntr_entry *entry,
11571 u64 *psval, void *context, int vl)
11576 if (entry->flags & CNTR_DISABLED) {
11577 dd_dev_err(dd, "Counter %s not enabled", entry->name);
11581 hfi1_cdbg(CNTR, "cntr: %s vl %d psval 0x%llx", entry->name, vl, *psval);
11583 val = entry->rw_cntr(entry, context, vl, CNTR_MODE_R, 0);
11585 /* If its a synthetic counter there is more work we need to do */
11586 if (entry->flags & CNTR_SYNTH) {
11587 if (sval == CNTR_MAX) {
11588 /* No need to read already saturated */
11592 if (entry->flags & CNTR_32BIT) {
11593 /* 32bit counters can wrap multiple times */
11594 u64 upper = sval >> 32;
11595 u64 lower = (sval << 32) >> 32;
11597 if (lower > val) { /* hw wrapped */
11598 if (upper == CNTR_32BIT_MAX)
11604 if (val != CNTR_MAX)
11605 val = (upper << 32) | val;
11608 /* If we rolled we are saturated */
11609 if ((val < sval) || (val > CNTR_MAX))
11616 hfi1_cdbg(CNTR, "\tNew val=0x%llx", val);
11621 static u64 write_dev_port_cntr(struct hfi1_devdata *dd,
11622 struct cntr_entry *entry,
11623 u64 *psval, void *context, int vl, u64 data)
11627 if (entry->flags & CNTR_DISABLED) {
11628 dd_dev_err(dd, "Counter %s not enabled", entry->name);
11632 hfi1_cdbg(CNTR, "cntr: %s vl %d psval 0x%llx", entry->name, vl, *psval);
11634 if (entry->flags & CNTR_SYNTH) {
11636 if (entry->flags & CNTR_32BIT) {
11637 val = entry->rw_cntr(entry, context, vl, CNTR_MODE_W,
11638 (data << 32) >> 32);
11639 val = data; /* return the full 64bit value */
11641 val = entry->rw_cntr(entry, context, vl, CNTR_MODE_W,
11645 val = entry->rw_cntr(entry, context, vl, CNTR_MODE_W, data);
11650 hfi1_cdbg(CNTR, "\tNew val=0x%llx", val);
11655 u64 read_dev_cntr(struct hfi1_devdata *dd, int index, int vl)
11657 struct cntr_entry *entry;
11660 entry = &dev_cntrs[index];
11661 sval = dd->scntrs + entry->offset;
11663 if (vl != CNTR_INVALID_VL)
11666 return read_dev_port_cntr(dd, entry, sval, dd, vl);
11669 u64 write_dev_cntr(struct hfi1_devdata *dd, int index, int vl, u64 data)
11671 struct cntr_entry *entry;
11674 entry = &dev_cntrs[index];
11675 sval = dd->scntrs + entry->offset;
11677 if (vl != CNTR_INVALID_VL)
11680 return write_dev_port_cntr(dd, entry, sval, dd, vl, data);
11683 u64 read_port_cntr(struct hfi1_pportdata *ppd, int index, int vl)
11685 struct cntr_entry *entry;
11688 entry = &port_cntrs[index];
11689 sval = ppd->scntrs + entry->offset;
11691 if (vl != CNTR_INVALID_VL)
11694 if ((index >= C_RCV_HDR_OVF_FIRST + ppd->dd->num_rcv_contexts) &&
11695 (index <= C_RCV_HDR_OVF_LAST)) {
11696 /* We do not want to bother for disabled contexts */
11700 return read_dev_port_cntr(ppd->dd, entry, sval, ppd, vl);
11703 u64 write_port_cntr(struct hfi1_pportdata *ppd, int index, int vl, u64 data)
11705 struct cntr_entry *entry;
11708 entry = &port_cntrs[index];
11709 sval = ppd->scntrs + entry->offset;
11711 if (vl != CNTR_INVALID_VL)
11714 if ((index >= C_RCV_HDR_OVF_FIRST + ppd->dd->num_rcv_contexts) &&
11715 (index <= C_RCV_HDR_OVF_LAST)) {
11716 /* We do not want to bother for disabled contexts */
11720 return write_dev_port_cntr(ppd->dd, entry, sval, ppd, vl, data);
11723 static void update_synth_timer(unsigned long opaque)
11730 struct hfi1_pportdata *ppd;
11731 struct cntr_entry *entry;
11733 struct hfi1_devdata *dd = (struct hfi1_devdata *)opaque;
11736 * Rather than keep beating on the CSRs pick a minimal set that we can
11737 * check to watch for potential roll over. We can do this by looking at
11738 * the number of flits sent/recv. If the total flits exceeds 32bits then
11739 * we have to iterate all the counters and update.
11741 entry = &dev_cntrs[C_DC_RCV_FLITS];
11742 cur_rx = entry->rw_cntr(entry, dd, CNTR_INVALID_VL, CNTR_MODE_R, 0);
11744 entry = &dev_cntrs[C_DC_XMIT_FLITS];
11745 cur_tx = entry->rw_cntr(entry, dd, CNTR_INVALID_VL, CNTR_MODE_R, 0);
11749 "[%d] curr tx=0x%llx rx=0x%llx :: last tx=0x%llx rx=0x%llx\n",
11750 dd->unit, cur_tx, cur_rx, dd->last_tx, dd->last_rx);
11752 if ((cur_tx < dd->last_tx) || (cur_rx < dd->last_rx)) {
11754 * May not be strictly necessary to update but it won't hurt and
11755 * simplifies the logic here.
11758 hfi1_cdbg(CNTR, "[%d] Tripwire counter rolled, updating",
11761 total_flits = (cur_tx - dd->last_tx) + (cur_rx - dd->last_rx);
11763 "[%d] total flits 0x%llx limit 0x%llx\n", dd->unit,
11764 total_flits, (u64)CNTR_32BIT_MAX);
11765 if (total_flits >= CNTR_32BIT_MAX) {
11766 hfi1_cdbg(CNTR, "[%d] 32bit limit hit, updating",
11773 hfi1_cdbg(CNTR, "[%d] Updating dd and ppd counters", dd->unit);
11774 for (i = 0; i < DEV_CNTR_LAST; i++) {
11775 entry = &dev_cntrs[i];
11776 if (entry->flags & CNTR_VL) {
11777 for (vl = 0; vl < C_VL_COUNT; vl++)
11778 read_dev_cntr(dd, i, vl);
11780 read_dev_cntr(dd, i, CNTR_INVALID_VL);
11783 ppd = (struct hfi1_pportdata *)(dd + 1);
11784 for (i = 0; i < dd->num_pports; i++, ppd++) {
11785 for (j = 0; j < PORT_CNTR_LAST; j++) {
11786 entry = &port_cntrs[j];
11787 if (entry->flags & CNTR_VL) {
11788 for (vl = 0; vl < C_VL_COUNT; vl++)
11789 read_port_cntr(ppd, j, vl);
11791 read_port_cntr(ppd, j, CNTR_INVALID_VL);
11797 * We want the value in the register. The goal is to keep track
11798 * of the number of "ticks" not the counter value. In other
11799 * words if the register rolls we want to notice it and go ahead
11800 * and force an update.
11802 entry = &dev_cntrs[C_DC_XMIT_FLITS];
11803 dd->last_tx = entry->rw_cntr(entry, dd, CNTR_INVALID_VL,
11806 entry = &dev_cntrs[C_DC_RCV_FLITS];
11807 dd->last_rx = entry->rw_cntr(entry, dd, CNTR_INVALID_VL,
11810 hfi1_cdbg(CNTR, "[%d] setting last tx/rx to 0x%llx 0x%llx",
11811 dd->unit, dd->last_tx, dd->last_rx);
11814 hfi1_cdbg(CNTR, "[%d] No update necessary", dd->unit);
11817 mod_timer(&dd->synth_stats_timer, jiffies + HZ * SYNTH_CNT_TIME);
11820 #define C_MAX_NAME 13 /* 12 chars + one for /0 */
11821 static int init_cntrs(struct hfi1_devdata *dd)
11823 int i, rcv_ctxts, j;
11826 char name[C_MAX_NAME];
11827 struct hfi1_pportdata *ppd;
11828 const char *bit_type_32 = ",32";
11829 const int bit_type_32_sz = strlen(bit_type_32);
11831 /* set up the stats timer; the add_timer is done at the end */
11832 setup_timer(&dd->synth_stats_timer, update_synth_timer,
11833 (unsigned long)dd);
11835 /***********************/
11836 /* per device counters */
11837 /***********************/
11839 /* size names and determine how many we have*/
11843 for (i = 0; i < DEV_CNTR_LAST; i++) {
11844 if (dev_cntrs[i].flags & CNTR_DISABLED) {
11845 hfi1_dbg_early("\tSkipping %s\n", dev_cntrs[i].name);
11849 if (dev_cntrs[i].flags & CNTR_VL) {
11850 dev_cntrs[i].offset = dd->ndevcntrs;
11851 for (j = 0; j < C_VL_COUNT; j++) {
11852 snprintf(name, C_MAX_NAME, "%s%d",
11855 sz += strlen(name);
11856 /* Add ",32" for 32-bit counters */
11857 if (dev_cntrs[i].flags & CNTR_32BIT)
11858 sz += bit_type_32_sz;
11862 } else if (dev_cntrs[i].flags & CNTR_SDMA) {
11863 dev_cntrs[i].offset = dd->ndevcntrs;
11864 for (j = 0; j < dd->chip_sdma_engines; j++) {
11865 snprintf(name, C_MAX_NAME, "%s%d",
11866 dev_cntrs[i].name, j);
11867 sz += strlen(name);
11868 /* Add ",32" for 32-bit counters */
11869 if (dev_cntrs[i].flags & CNTR_32BIT)
11870 sz += bit_type_32_sz;
11875 /* +1 for newline. */
11876 sz += strlen(dev_cntrs[i].name) + 1;
11877 /* Add ",32" for 32-bit counters */
11878 if (dev_cntrs[i].flags & CNTR_32BIT)
11879 sz += bit_type_32_sz;
11880 dev_cntrs[i].offset = dd->ndevcntrs;
11885 /* allocate space for the counter values */
11886 dd->cntrs = kcalloc(dd->ndevcntrs, sizeof(u64), GFP_KERNEL);
11890 dd->scntrs = kcalloc(dd->ndevcntrs, sizeof(u64), GFP_KERNEL);
11895 /* allocate space for the counter names */
11896 dd->cntrnameslen = sz;
11897 dd->cntrnames = kmalloc(sz, GFP_KERNEL);
11898 if (!dd->cntrnames)
11901 /* fill in the names */
11902 for (p = dd->cntrnames, i = 0; i < DEV_CNTR_LAST; i++) {
11903 if (dev_cntrs[i].flags & CNTR_DISABLED) {
11905 } else if (dev_cntrs[i].flags & CNTR_VL) {
11906 for (j = 0; j < C_VL_COUNT; j++) {
11907 snprintf(name, C_MAX_NAME, "%s%d",
11910 memcpy(p, name, strlen(name));
11913 /* Counter is 32 bits */
11914 if (dev_cntrs[i].flags & CNTR_32BIT) {
11915 memcpy(p, bit_type_32, bit_type_32_sz);
11916 p += bit_type_32_sz;
11921 } else if (dev_cntrs[i].flags & CNTR_SDMA) {
11922 for (j = 0; j < dd->chip_sdma_engines; j++) {
11923 snprintf(name, C_MAX_NAME, "%s%d",
11924 dev_cntrs[i].name, j);
11925 memcpy(p, name, strlen(name));
11928 /* Counter is 32 bits */
11929 if (dev_cntrs[i].flags & CNTR_32BIT) {
11930 memcpy(p, bit_type_32, bit_type_32_sz);
11931 p += bit_type_32_sz;
11937 memcpy(p, dev_cntrs[i].name, strlen(dev_cntrs[i].name));
11938 p += strlen(dev_cntrs[i].name);
11940 /* Counter is 32 bits */
11941 if (dev_cntrs[i].flags & CNTR_32BIT) {
11942 memcpy(p, bit_type_32, bit_type_32_sz);
11943 p += bit_type_32_sz;
11950 /*********************/
11951 /* per port counters */
11952 /*********************/
11955 * Go through the counters for the overflows and disable the ones we
11956 * don't need. This varies based on platform so we need to do it
11957 * dynamically here.
11959 rcv_ctxts = dd->num_rcv_contexts;
11960 for (i = C_RCV_HDR_OVF_FIRST + rcv_ctxts;
11961 i <= C_RCV_HDR_OVF_LAST; i++) {
11962 port_cntrs[i].flags |= CNTR_DISABLED;
11965 /* size port counter names and determine how many we have*/
11967 dd->nportcntrs = 0;
11968 for (i = 0; i < PORT_CNTR_LAST; i++) {
11969 if (port_cntrs[i].flags & CNTR_DISABLED) {
11970 hfi1_dbg_early("\tSkipping %s\n", port_cntrs[i].name);
11974 if (port_cntrs[i].flags & CNTR_VL) {
11975 port_cntrs[i].offset = dd->nportcntrs;
11976 for (j = 0; j < C_VL_COUNT; j++) {
11977 snprintf(name, C_MAX_NAME, "%s%d",
11978 port_cntrs[i].name,
11980 sz += strlen(name);
11981 /* Add ",32" for 32-bit counters */
11982 if (port_cntrs[i].flags & CNTR_32BIT)
11983 sz += bit_type_32_sz;
11988 /* +1 for newline */
11989 sz += strlen(port_cntrs[i].name) + 1;
11990 /* Add ",32" for 32-bit counters */
11991 if (port_cntrs[i].flags & CNTR_32BIT)
11992 sz += bit_type_32_sz;
11993 port_cntrs[i].offset = dd->nportcntrs;
11998 /* allocate space for the counter names */
11999 dd->portcntrnameslen = sz;
12000 dd->portcntrnames = kmalloc(sz, GFP_KERNEL);
12001 if (!dd->portcntrnames)
12004 /* fill in port cntr names */
12005 for (p = dd->portcntrnames, i = 0; i < PORT_CNTR_LAST; i++) {
12006 if (port_cntrs[i].flags & CNTR_DISABLED)
12009 if (port_cntrs[i].flags & CNTR_VL) {
12010 for (j = 0; j < C_VL_COUNT; j++) {
12011 snprintf(name, C_MAX_NAME, "%s%d",
12012 port_cntrs[i].name,
12014 memcpy(p, name, strlen(name));
12017 /* Counter is 32 bits */
12018 if (port_cntrs[i].flags & CNTR_32BIT) {
12019 memcpy(p, bit_type_32, bit_type_32_sz);
12020 p += bit_type_32_sz;
12026 memcpy(p, port_cntrs[i].name,
12027 strlen(port_cntrs[i].name));
12028 p += strlen(port_cntrs[i].name);
12030 /* Counter is 32 bits */
12031 if (port_cntrs[i].flags & CNTR_32BIT) {
12032 memcpy(p, bit_type_32, bit_type_32_sz);
12033 p += bit_type_32_sz;
12040 /* allocate per port storage for counter values */
12041 ppd = (struct hfi1_pportdata *)(dd + 1);
12042 for (i = 0; i < dd->num_pports; i++, ppd++) {
12043 ppd->cntrs = kcalloc(dd->nportcntrs, sizeof(u64), GFP_KERNEL);
12047 ppd->scntrs = kcalloc(dd->nportcntrs, sizeof(u64), GFP_KERNEL);
12052 /* CPU counters need to be allocated and zeroed */
12053 if (init_cpu_counters(dd))
12056 mod_timer(&dd->synth_stats_timer, jiffies + HZ * SYNTH_CNT_TIME);
12064 static u32 chip_to_opa_lstate(struct hfi1_devdata *dd, u32 chip_lstate)
12066 switch (chip_lstate) {
12069 "Unknown logical state 0x%x, reporting IB_PORT_DOWN\n",
12073 return IB_PORT_DOWN;
12075 return IB_PORT_INIT;
12077 return IB_PORT_ARMED;
12078 case LSTATE_ACTIVE:
12079 return IB_PORT_ACTIVE;
12083 u32 chip_to_opa_pstate(struct hfi1_devdata *dd, u32 chip_pstate)
12085 /* look at the HFI meta-states only */
12086 switch (chip_pstate & 0xf0) {
12088 dd_dev_err(dd, "Unexpected chip physical state of 0x%x\n",
12092 return IB_PORTPHYSSTATE_DISABLED;
12094 return OPA_PORTPHYSSTATE_OFFLINE;
12096 return IB_PORTPHYSSTATE_POLLING;
12097 case PLS_CONFIGPHY:
12098 return IB_PORTPHYSSTATE_TRAINING;
12100 return IB_PORTPHYSSTATE_LINKUP;
12102 return IB_PORTPHYSSTATE_PHY_TEST;
12106 /* return the OPA port logical state name */
12107 const char *opa_lstate_name(u32 lstate)
12109 static const char * const port_logical_names[] = {
12115 "PORT_ACTIVE_DEFER",
12117 if (lstate < ARRAY_SIZE(port_logical_names))
12118 return port_logical_names[lstate];
12122 /* return the OPA port physical state name */
12123 const char *opa_pstate_name(u32 pstate)
12125 static const char * const port_physical_names[] = {
12132 "PHYS_LINK_ERR_RECOVER",
12139 if (pstate < ARRAY_SIZE(port_physical_names))
12140 return port_physical_names[pstate];
12145 * Read the hardware link state and set the driver's cached value of it.
12146 * Return the (new) current value.
12148 u32 get_logical_state(struct hfi1_pportdata *ppd)
12152 new_state = chip_to_opa_lstate(ppd->dd, read_logical_state(ppd->dd));
12153 if (new_state != ppd->lstate) {
12154 dd_dev_info(ppd->dd, "logical state changed to %s (0x%x)\n",
12155 opa_lstate_name(new_state), new_state);
12156 ppd->lstate = new_state;
12159 * Set port status flags in the page mapped into userspace
12160 * memory. Do it here to ensure a reliable state - this is
12161 * the only function called by all state handling code.
12162 * Always set the flags due to the fact that the cache value
12163 * might have been changed explicitly outside of this
12166 if (ppd->statusp) {
12167 switch (ppd->lstate) {
12170 *ppd->statusp &= ~(HFI1_STATUS_IB_CONF |
12171 HFI1_STATUS_IB_READY);
12173 case IB_PORT_ARMED:
12174 *ppd->statusp |= HFI1_STATUS_IB_CONF;
12176 case IB_PORT_ACTIVE:
12177 *ppd->statusp |= HFI1_STATUS_IB_READY;
12181 return ppd->lstate;
12185 * wait_logical_linkstate - wait for an IB link state change to occur
12186 * @ppd: port device
12187 * @state: the state to wait for
12188 * @msecs: the number of milliseconds to wait
12190 * Wait up to msecs milliseconds for IB link state change to occur.
12191 * For now, take the easy polling route.
12192 * Returns 0 if state reached, otherwise -ETIMEDOUT.
12194 static int wait_logical_linkstate(struct hfi1_pportdata *ppd, u32 state,
12197 unsigned long timeout;
12199 timeout = jiffies + msecs_to_jiffies(msecs);
12201 if (get_logical_state(ppd) == state)
12203 if (time_after(jiffies, timeout))
12207 dd_dev_err(ppd->dd, "timeout waiting for link state 0x%x\n", state);
12212 u8 hfi1_ibphys_portstate(struct hfi1_pportdata *ppd)
12217 pstate = read_physical_state(ppd->dd);
12218 ib_pstate = chip_to_opa_pstate(ppd->dd, pstate);
12219 if (ppd->last_pstate != ib_pstate) {
12220 dd_dev_info(ppd->dd,
12221 "%s: physical state changed to %s (0x%x), phy 0x%x\n",
12222 __func__, opa_pstate_name(ib_pstate), ib_pstate,
12224 ppd->last_pstate = ib_pstate;
12230 * Read/modify/write ASIC_QSFP register bits as selected by mask
12231 * data: 0 or 1 in the positions depending on what needs to be written
12232 * dir: 0 for read, 1 for write
12233 * mask: select by setting
12237 u64 hfi1_gpio_mod(struct hfi1_devdata *dd, u32 target, u32 data, u32 dir,
12240 u64 qsfp_oe, target_oe;
12242 target_oe = target ? ASIC_QSFP2_OE : ASIC_QSFP1_OE;
12244 /* We are writing register bits, so lock access */
12248 qsfp_oe = read_csr(dd, target_oe);
12249 qsfp_oe = (qsfp_oe & ~(u64)mask) | (u64)dir;
12250 write_csr(dd, target_oe, qsfp_oe);
12252 /* We are exclusively reading bits here, but it is unlikely
12253 * we'll get valid data when we set the direction of the pin
12254 * in the same call, so read should call this function again
12255 * to get valid data
12257 return read_csr(dd, target ? ASIC_QSFP2_IN : ASIC_QSFP1_IN);
12260 #define CLEAR_STATIC_RATE_CONTROL_SMASK(r) \
12261 (r &= ~SEND_CTXT_CHECK_ENABLE_DISALLOW_PBC_STATIC_RATE_CONTROL_SMASK)
12263 #define SET_STATIC_RATE_CONTROL_SMASK(r) \
12264 (r |= SEND_CTXT_CHECK_ENABLE_DISALLOW_PBC_STATIC_RATE_CONTROL_SMASK)
12266 int hfi1_init_ctxt(struct send_context *sc)
12269 struct hfi1_devdata *dd = sc->dd;
12271 u8 set = (sc->type == SC_USER ?
12272 HFI1_CAP_IS_USET(STATIC_RATE_CTRL) :
12273 HFI1_CAP_IS_KSET(STATIC_RATE_CTRL));
12274 reg = read_kctxt_csr(dd, sc->hw_context,
12275 SEND_CTXT_CHECK_ENABLE);
12277 CLEAR_STATIC_RATE_CONTROL_SMASK(reg);
12279 SET_STATIC_RATE_CONTROL_SMASK(reg);
12280 write_kctxt_csr(dd, sc->hw_context,
12281 SEND_CTXT_CHECK_ENABLE, reg);
12286 int hfi1_tempsense_rd(struct hfi1_devdata *dd, struct hfi1_temp *temp)
12291 if (dd->icode != ICODE_RTL_SILICON) {
12292 if (HFI1_CAP_IS_KSET(PRINT_UNIMPL))
12293 dd_dev_info(dd, "%s: tempsense not supported by HW\n",
12297 reg = read_csr(dd, ASIC_STS_THERM);
12298 temp->curr = ((reg >> ASIC_STS_THERM_CURR_TEMP_SHIFT) &
12299 ASIC_STS_THERM_CURR_TEMP_MASK);
12300 temp->lo_lim = ((reg >> ASIC_STS_THERM_LO_TEMP_SHIFT) &
12301 ASIC_STS_THERM_LO_TEMP_MASK);
12302 temp->hi_lim = ((reg >> ASIC_STS_THERM_HI_TEMP_SHIFT) &
12303 ASIC_STS_THERM_HI_TEMP_MASK);
12304 temp->crit_lim = ((reg >> ASIC_STS_THERM_CRIT_TEMP_SHIFT) &
12305 ASIC_STS_THERM_CRIT_TEMP_MASK);
12306 /* triggers is a 3-bit value - 1 bit per trigger. */
12307 temp->triggers = (u8)((reg >> ASIC_STS_THERM_LOW_SHIFT) & 0x7);
12312 /* ========================================================================= */
12315 * Enable/disable chip from delivering interrupts.
12317 void set_intr_state(struct hfi1_devdata *dd, u32 enable)
12322 * In HFI, the mask needs to be 1 to allow interrupts.
12325 /* enable all interrupts */
12326 for (i = 0; i < CCE_NUM_INT_CSRS; i++)
12327 write_csr(dd, CCE_INT_MASK + (8*i), ~(u64)0);
12331 for (i = 0; i < CCE_NUM_INT_CSRS; i++)
12332 write_csr(dd, CCE_INT_MASK + (8*i), 0ull);
12337 * Clear all interrupt sources on the chip.
12339 static void clear_all_interrupts(struct hfi1_devdata *dd)
12343 for (i = 0; i < CCE_NUM_INT_CSRS; i++)
12344 write_csr(dd, CCE_INT_CLEAR + (8*i), ~(u64)0);
12346 write_csr(dd, CCE_ERR_CLEAR, ~(u64)0);
12347 write_csr(dd, MISC_ERR_CLEAR, ~(u64)0);
12348 write_csr(dd, RCV_ERR_CLEAR, ~(u64)0);
12349 write_csr(dd, SEND_ERR_CLEAR, ~(u64)0);
12350 write_csr(dd, SEND_PIO_ERR_CLEAR, ~(u64)0);
12351 write_csr(dd, SEND_DMA_ERR_CLEAR, ~(u64)0);
12352 write_csr(dd, SEND_EGRESS_ERR_CLEAR, ~(u64)0);
12353 for (i = 0; i < dd->chip_send_contexts; i++)
12354 write_kctxt_csr(dd, i, SEND_CTXT_ERR_CLEAR, ~(u64)0);
12355 for (i = 0; i < dd->chip_sdma_engines; i++)
12356 write_kctxt_csr(dd, i, SEND_DMA_ENG_ERR_CLEAR, ~(u64)0);
12358 write_csr(dd, DCC_ERR_FLG_CLR, ~(u64)0);
12359 write_csr(dd, DC_LCB_ERR_CLR, ~(u64)0);
12360 write_csr(dd, DC_DC8051_ERR_CLR, ~(u64)0);
12363 /* Move to pcie.c? */
12364 static void disable_intx(struct pci_dev *pdev)
12369 static void clean_up_interrupts(struct hfi1_devdata *dd)
12373 /* remove irqs - must happen before disabling/turning off */
12374 if (dd->num_msix_entries) {
12376 struct hfi1_msix_entry *me = dd->msix_entries;
12378 for (i = 0; i < dd->num_msix_entries; i++, me++) {
12379 if (me->arg == NULL) /* => no irq, no affinity */
12381 hfi1_put_irq_affinity(dd, &dd->msix_entries[i]);
12382 free_irq(me->msix.vector, me->arg);
12386 if (dd->requested_intx_irq) {
12387 free_irq(dd->pcidev->irq, dd);
12388 dd->requested_intx_irq = 0;
12392 /* turn off interrupts */
12393 if (dd->num_msix_entries) {
12395 pci_disable_msix(dd->pcidev);
12398 disable_intx(dd->pcidev);
12401 /* clean structures */
12402 kfree(dd->msix_entries);
12403 dd->msix_entries = NULL;
12404 dd->num_msix_entries = 0;
12408 * Remap the interrupt source from the general handler to the given MSI-X
12411 static void remap_intr(struct hfi1_devdata *dd, int isrc, int msix_intr)
12416 /* clear from the handled mask of the general interrupt */
12419 dd->gi_mask[m] &= ~((u64)1 << n);
12421 /* direct the chip source to the given MSI-X interrupt */
12424 reg = read_csr(dd, CCE_INT_MAP + (8*m));
12425 reg &= ~((u64)0xff << (8*n));
12426 reg |= ((u64)msix_intr & 0xff) << (8*n);
12427 write_csr(dd, CCE_INT_MAP + (8*m), reg);
12430 static void remap_sdma_interrupts(struct hfi1_devdata *dd,
12431 int engine, int msix_intr)
12434 * SDMA engine interrupt sources grouped by type, rather than
12435 * engine. Per-engine interrupts are as follows:
12440 remap_intr(dd, IS_SDMA_START + 0*TXE_NUM_SDMA_ENGINES + engine,
12442 remap_intr(dd, IS_SDMA_START + 1*TXE_NUM_SDMA_ENGINES + engine,
12444 remap_intr(dd, IS_SDMA_START + 2*TXE_NUM_SDMA_ENGINES + engine,
12448 static int request_intx_irq(struct hfi1_devdata *dd)
12452 snprintf(dd->intx_name, sizeof(dd->intx_name), DRIVER_NAME "_%d",
12454 ret = request_irq(dd->pcidev->irq, general_interrupt,
12455 IRQF_SHARED, dd->intx_name, dd);
12457 dd_dev_err(dd, "unable to request INTx interrupt, err %d\n",
12460 dd->requested_intx_irq = 1;
12464 static int request_msix_irqs(struct hfi1_devdata *dd)
12466 int first_general, last_general;
12467 int first_sdma, last_sdma;
12468 int first_rx, last_rx;
12471 /* calculate the ranges we are going to use */
12473 first_sdma = last_general = first_general + 1;
12474 first_rx = last_sdma = first_sdma + dd->num_sdma;
12475 last_rx = first_rx + dd->n_krcv_queues;
12478 * Sanity check - the code expects all SDMA chip source
12479 * interrupts to be in the same CSR, starting at bit 0. Verify
12480 * that this is true by checking the bit location of the start.
12482 BUILD_BUG_ON(IS_SDMA_START % 64);
12484 for (i = 0; i < dd->num_msix_entries; i++) {
12485 struct hfi1_msix_entry *me = &dd->msix_entries[i];
12486 const char *err_info;
12487 irq_handler_t handler;
12488 irq_handler_t thread = NULL;
12491 struct hfi1_ctxtdata *rcd = NULL;
12492 struct sdma_engine *sde = NULL;
12494 /* obtain the arguments to request_irq */
12495 if (first_general <= i && i < last_general) {
12496 idx = i - first_general;
12497 handler = general_interrupt;
12499 snprintf(me->name, sizeof(me->name),
12500 DRIVER_NAME "_%d", dd->unit);
12501 err_info = "general";
12502 me->type = IRQ_GENERAL;
12503 } else if (first_sdma <= i && i < last_sdma) {
12504 idx = i - first_sdma;
12505 sde = &dd->per_sdma[idx];
12506 handler = sdma_interrupt;
12508 snprintf(me->name, sizeof(me->name),
12509 DRIVER_NAME "_%d sdma%d", dd->unit, idx);
12511 remap_sdma_interrupts(dd, idx, i);
12512 me->type = IRQ_SDMA;
12513 } else if (first_rx <= i && i < last_rx) {
12514 idx = i - first_rx;
12515 rcd = dd->rcd[idx];
12516 /* no interrupt if no rcd */
12520 * Set the interrupt register and mask for this
12521 * context's interrupt.
12523 rcd->ireg = (IS_RCVAVAIL_START+idx) / 64;
12524 rcd->imask = ((u64)1) <<
12525 ((IS_RCVAVAIL_START+idx) % 64);
12526 handler = receive_context_interrupt;
12527 thread = receive_context_thread;
12529 snprintf(me->name, sizeof(me->name),
12530 DRIVER_NAME "_%d kctxt%d", dd->unit, idx);
12531 err_info = "receive context";
12532 remap_intr(dd, IS_RCVAVAIL_START + idx, i);
12533 me->type = IRQ_RCVCTXT;
12535 /* not in our expected range - complain, then
12538 "Unexpected extra MSI-X interrupt %d\n", i);
12541 /* no argument, no interrupt */
12544 /* make sure the name is terminated */
12545 me->name[sizeof(me->name)-1] = 0;
12547 ret = request_threaded_irq(me->msix.vector, handler, thread, 0,
12551 "unable to allocate %s interrupt, vector %d, index %d, err %d\n",
12552 err_info, me->msix.vector, idx, ret);
12556 * assign arg after request_irq call, so it will be
12561 ret = hfi1_get_irq_affinity(dd, me);
12564 "unable to pin IRQ %d\n", ret);
12571 * Set the general handler to accept all interrupts, remap all
12572 * chip interrupts back to MSI-X 0.
12574 static void reset_interrupts(struct hfi1_devdata *dd)
12578 /* all interrupts handled by the general handler */
12579 for (i = 0; i < CCE_NUM_INT_CSRS; i++)
12580 dd->gi_mask[i] = ~(u64)0;
12582 /* all chip interrupts map to MSI-X 0 */
12583 for (i = 0; i < CCE_NUM_INT_MAP_CSRS; i++)
12584 write_csr(dd, CCE_INT_MAP + (8*i), 0);
12587 static int set_up_interrupts(struct hfi1_devdata *dd)
12589 struct hfi1_msix_entry *entries;
12590 u32 total, request;
12592 int single_interrupt = 0; /* we expect to have all the interrupts */
12596 * 1 general, "slow path" interrupt (includes the SDMA engines
12597 * slow source, SDMACleanupDone)
12598 * N interrupts - one per used SDMA engine
12599 * M interrupt - one per kernel receive context
12601 total = 1 + dd->num_sdma + dd->n_krcv_queues;
12603 entries = kcalloc(total, sizeof(*entries), GFP_KERNEL);
12608 /* 1-1 MSI-X entry assignment */
12609 for (i = 0; i < total; i++)
12610 entries[i].msix.entry = i;
12612 /* ask for MSI-X interrupts */
12614 request_msix(dd, &request, entries);
12616 if (request == 0) {
12618 /* dd->num_msix_entries already zero */
12620 single_interrupt = 1;
12621 dd_dev_err(dd, "MSI-X failed, using INTx interrupts\n");
12624 dd->num_msix_entries = request;
12625 dd->msix_entries = entries;
12627 if (request != total) {
12628 /* using MSI-X, with reduced interrupts */
12631 "cannot handle reduced interrupt case, want %u, got %u\n",
12636 dd_dev_info(dd, "%u MSI-X interrupts allocated\n", total);
12639 /* mask all interrupts */
12640 set_intr_state(dd, 0);
12641 /* clear all pending interrupts */
12642 clear_all_interrupts(dd);
12644 /* reset general handler mask, chip MSI-X mappings */
12645 reset_interrupts(dd);
12647 if (single_interrupt)
12648 ret = request_intx_irq(dd);
12650 ret = request_msix_irqs(dd);
12657 clean_up_interrupts(dd);
12662 * Set up context values in dd. Sets:
12664 * num_rcv_contexts - number of contexts being used
12665 * n_krcv_queues - number of kernel contexts
12666 * first_user_ctxt - first non-kernel context in array of contexts
12667 * freectxts - number of free user contexts
12668 * num_send_contexts - number of PIO send contexts being used
12670 static int set_up_context_variables(struct hfi1_devdata *dd)
12672 int num_kernel_contexts;
12673 int total_contexts;
12678 * Kernel contexts: (to be fixed later):
12679 * - min or 2 or 1 context/numa
12680 * - Context 0 - control context (VL15/multicast/error)
12681 * - Context 1 - default context
12685 * Don't count context 0 in n_krcvqs since
12686 * is isn't used for normal verbs traffic.
12688 * krcvqs will reflect number of kernel
12689 * receive contexts above 0.
12691 num_kernel_contexts = n_krcvqs + MIN_KERNEL_KCTXTS - 1;
12693 num_kernel_contexts = num_online_nodes() + 1;
12694 num_kernel_contexts =
12695 max_t(int, MIN_KERNEL_KCTXTS, num_kernel_contexts);
12697 * Every kernel receive context needs an ACK send context.
12698 * one send context is allocated for each VL{0-7} and VL15
12700 if (num_kernel_contexts > (dd->chip_send_contexts - num_vls - 1)) {
12702 "Reducing # kernel rcv contexts to: %d, from %d\n",
12703 (int)(dd->chip_send_contexts - num_vls - 1),
12704 (int)num_kernel_contexts);
12705 num_kernel_contexts = dd->chip_send_contexts - num_vls - 1;
12708 * User contexts: (to be fixed later)
12709 * - default to 1 user context per CPU if num_user_contexts is
12712 if (num_user_contexts < 0)
12713 num_user_contexts = num_online_cpus();
12715 total_contexts = num_kernel_contexts + num_user_contexts;
12718 * Adjust the counts given a global max.
12720 if (total_contexts > dd->chip_rcv_contexts) {
12722 "Reducing # user receive contexts to: %d, from %d\n",
12723 (int)(dd->chip_rcv_contexts - num_kernel_contexts),
12724 (int)num_user_contexts);
12725 num_user_contexts = dd->chip_rcv_contexts - num_kernel_contexts;
12727 total_contexts = num_kernel_contexts + num_user_contexts;
12730 /* the first N are kernel contexts, the rest are user contexts */
12731 dd->num_rcv_contexts = total_contexts;
12732 dd->n_krcv_queues = num_kernel_contexts;
12733 dd->first_user_ctxt = num_kernel_contexts;
12734 dd->num_user_contexts = num_user_contexts;
12735 dd->freectxts = num_user_contexts;
12737 "rcv contexts: chip %d, used %d (kernel %d, user %d)\n",
12738 (int)dd->chip_rcv_contexts,
12739 (int)dd->num_rcv_contexts,
12740 (int)dd->n_krcv_queues,
12741 (int)dd->num_rcv_contexts - dd->n_krcv_queues);
12744 * Receive array allocation:
12745 * All RcvArray entries are divided into groups of 8. This
12746 * is required by the hardware and will speed up writes to
12747 * consecutive entries by using write-combining of the entire
12750 * The number of groups are evenly divided among all contexts.
12751 * any left over groups will be given to the first N user
12754 dd->rcv_entries.group_size = RCV_INCREMENT;
12755 ngroups = dd->chip_rcv_array_count / dd->rcv_entries.group_size;
12756 dd->rcv_entries.ngroups = ngroups / dd->num_rcv_contexts;
12757 dd->rcv_entries.nctxt_extra = ngroups -
12758 (dd->num_rcv_contexts * dd->rcv_entries.ngroups);
12759 dd_dev_info(dd, "RcvArray groups %u, ctxts extra %u\n",
12760 dd->rcv_entries.ngroups,
12761 dd->rcv_entries.nctxt_extra);
12762 if (dd->rcv_entries.ngroups * dd->rcv_entries.group_size >
12763 MAX_EAGER_ENTRIES * 2) {
12764 dd->rcv_entries.ngroups = (MAX_EAGER_ENTRIES * 2) /
12765 dd->rcv_entries.group_size;
12767 "RcvArray group count too high, change to %u\n",
12768 dd->rcv_entries.ngroups);
12769 dd->rcv_entries.nctxt_extra = 0;
12772 * PIO send contexts
12774 ret = init_sc_pools_and_sizes(dd);
12775 if (ret >= 0) { /* success */
12776 dd->num_send_contexts = ret;
12779 "send contexts: chip %d, used %d (kernel %d, ack %d, user %d)\n",
12780 dd->chip_send_contexts,
12781 dd->num_send_contexts,
12782 dd->sc_sizes[SC_KERNEL].count,
12783 dd->sc_sizes[SC_ACK].count,
12784 dd->sc_sizes[SC_USER].count);
12785 ret = 0; /* success */
12792 * Set the device/port partition key table. The MAD code
12793 * will ensure that, at least, the partial management
12794 * partition key is present in the table.
12796 static void set_partition_keys(struct hfi1_pportdata *ppd)
12798 struct hfi1_devdata *dd = ppd->dd;
12802 dd_dev_info(dd, "Setting partition keys\n");
12803 for (i = 0; i < hfi1_get_npkeys(dd); i++) {
12804 reg |= (ppd->pkeys[i] &
12805 RCV_PARTITION_KEY_PARTITION_KEY_A_MASK) <<
12807 RCV_PARTITION_KEY_PARTITION_KEY_B_SHIFT);
12808 /* Each register holds 4 PKey values. */
12809 if ((i % 4) == 3) {
12810 write_csr(dd, RCV_PARTITION_KEY +
12811 ((i - 3) * 2), reg);
12816 /* Always enable HW pkeys check when pkeys table is set */
12817 add_rcvctrl(dd, RCV_CTRL_RCV_PARTITION_KEY_ENABLE_SMASK);
12821 * These CSRs and memories are uninitialized on reset and must be
12822 * written before reading to set the ECC/parity bits.
12824 * NOTE: All user context CSRs that are not mmaped write-only
12825 * (e.g. the TID flows) must be initialized even if the driver never
12828 static void write_uninitialized_csrs_and_memories(struct hfi1_devdata *dd)
12833 for (i = 0; i < CCE_NUM_INT_MAP_CSRS; i++)
12834 write_csr(dd, CCE_INT_MAP+(8*i), 0);
12836 /* SendCtxtCreditReturnAddr */
12837 for (i = 0; i < dd->chip_send_contexts; i++)
12838 write_kctxt_csr(dd, i, SEND_CTXT_CREDIT_RETURN_ADDR, 0);
12840 /* PIO Send buffers */
12841 /* SDMA Send buffers */
12842 /* These are not normally read, and (presently) have no method
12843 to be read, so are not pre-initialized */
12846 /* RcvHdrTailAddr */
12847 /* RcvTidFlowTable */
12848 for (i = 0; i < dd->chip_rcv_contexts; i++) {
12849 write_kctxt_csr(dd, i, RCV_HDR_ADDR, 0);
12850 write_kctxt_csr(dd, i, RCV_HDR_TAIL_ADDR, 0);
12851 for (j = 0; j < RXE_NUM_TID_FLOWS; j++)
12852 write_uctxt_csr(dd, i, RCV_TID_FLOW_TABLE+(8*j), 0);
12856 for (i = 0; i < dd->chip_rcv_array_count; i++)
12857 write_csr(dd, RCV_ARRAY + (8*i),
12858 RCV_ARRAY_RT_WRITE_ENABLE_SMASK);
12860 /* RcvQPMapTable */
12861 for (i = 0; i < 32; i++)
12862 write_csr(dd, RCV_QP_MAP_TABLE + (8 * i), 0);
12866 * Use the ctrl_bits in CceCtrl to clear the status_bits in CceStatus.
12868 static void clear_cce_status(struct hfi1_devdata *dd, u64 status_bits,
12871 unsigned long timeout;
12874 /* is the condition present? */
12875 reg = read_csr(dd, CCE_STATUS);
12876 if ((reg & status_bits) == 0)
12879 /* clear the condition */
12880 write_csr(dd, CCE_CTRL, ctrl_bits);
12882 /* wait for the condition to clear */
12883 timeout = jiffies + msecs_to_jiffies(CCE_STATUS_TIMEOUT);
12885 reg = read_csr(dd, CCE_STATUS);
12886 if ((reg & status_bits) == 0)
12888 if (time_after(jiffies, timeout)) {
12890 "Timeout waiting for CceStatus to clear bits 0x%llx, remaining 0x%llx\n",
12891 status_bits, reg & status_bits);
12898 /* set CCE CSRs to chip reset defaults */
12899 static void reset_cce_csrs(struct hfi1_devdata *dd)
12903 /* CCE_REVISION read-only */
12904 /* CCE_REVISION2 read-only */
12905 /* CCE_CTRL - bits clear automatically */
12906 /* CCE_STATUS read-only, use CceCtrl to clear */
12907 clear_cce_status(dd, ALL_FROZE, CCE_CTRL_SPC_UNFREEZE_SMASK);
12908 clear_cce_status(dd, ALL_TXE_PAUSE, CCE_CTRL_TXE_RESUME_SMASK);
12909 clear_cce_status(dd, ALL_RXE_PAUSE, CCE_CTRL_RXE_RESUME_SMASK);
12910 for (i = 0; i < CCE_NUM_SCRATCH; i++)
12911 write_csr(dd, CCE_SCRATCH + (8 * i), 0);
12912 /* CCE_ERR_STATUS read-only */
12913 write_csr(dd, CCE_ERR_MASK, 0);
12914 write_csr(dd, CCE_ERR_CLEAR, ~0ull);
12915 /* CCE_ERR_FORCE leave alone */
12916 for (i = 0; i < CCE_NUM_32_BIT_COUNTERS; i++)
12917 write_csr(dd, CCE_COUNTER_ARRAY32 + (8 * i), 0);
12918 write_csr(dd, CCE_DC_CTRL, CCE_DC_CTRL_RESETCSR);
12919 /* CCE_PCIE_CTRL leave alone */
12920 for (i = 0; i < CCE_NUM_MSIX_VECTORS; i++) {
12921 write_csr(dd, CCE_MSIX_TABLE_LOWER + (8 * i), 0);
12922 write_csr(dd, CCE_MSIX_TABLE_UPPER + (8 * i),
12923 CCE_MSIX_TABLE_UPPER_RESETCSR);
12925 for (i = 0; i < CCE_NUM_MSIX_PBAS; i++) {
12926 /* CCE_MSIX_PBA read-only */
12927 write_csr(dd, CCE_MSIX_INT_GRANTED, ~0ull);
12928 write_csr(dd, CCE_MSIX_VEC_CLR_WITHOUT_INT, ~0ull);
12930 for (i = 0; i < CCE_NUM_INT_MAP_CSRS; i++)
12931 write_csr(dd, CCE_INT_MAP, 0);
12932 for (i = 0; i < CCE_NUM_INT_CSRS; i++) {
12933 /* CCE_INT_STATUS read-only */
12934 write_csr(dd, CCE_INT_MASK + (8 * i), 0);
12935 write_csr(dd, CCE_INT_CLEAR + (8 * i), ~0ull);
12936 /* CCE_INT_FORCE leave alone */
12937 /* CCE_INT_BLOCKED read-only */
12939 for (i = 0; i < CCE_NUM_32_BIT_INT_COUNTERS; i++)
12940 write_csr(dd, CCE_INT_COUNTER_ARRAY32 + (8 * i), 0);
12943 /* set ASIC CSRs to chip reset defaults */
12944 static void reset_asic_csrs(struct hfi1_devdata *dd)
12949 * If the HFIs are shared between separate nodes or VMs,
12950 * then more will need to be done here. One idea is a module
12951 * parameter that returns early, letting the first power-on or
12952 * a known first load do the reset and blocking all others.
12955 if (!(dd->flags & HFI1_DO_INIT_ASIC))
12958 if (dd->icode != ICODE_FPGA_EMULATION) {
12959 /* emulation does not have an SBus - leave these alone */
12961 * All writes to ASIC_CFG_SBUS_REQUEST do something.
12963 * o The reset is not zero if aimed at the core. See the
12964 * SBus documentation for details.
12965 * o If the SBus firmware has been updated (e.g. by the BIOS),
12966 * will the reset revert that?
12968 /* ASIC_CFG_SBUS_REQUEST leave alone */
12969 write_csr(dd, ASIC_CFG_SBUS_EXECUTE, 0);
12971 /* ASIC_SBUS_RESULT read-only */
12972 write_csr(dd, ASIC_STS_SBUS_COUNTERS, 0);
12973 for (i = 0; i < ASIC_NUM_SCRATCH; i++)
12974 write_csr(dd, ASIC_CFG_SCRATCH + (8 * i), 0);
12975 write_csr(dd, ASIC_CFG_MUTEX, 0); /* this will clear it */
12977 /* We might want to retain this state across FLR if we ever use it */
12978 write_csr(dd, ASIC_CFG_DRV_STR, 0);
12980 /* ASIC_CFG_THERM_POLL_EN leave alone */
12981 /* ASIC_STS_THERM read-only */
12982 /* ASIC_CFG_RESET leave alone */
12984 write_csr(dd, ASIC_PCIE_SD_HOST_CMD, 0);
12985 /* ASIC_PCIE_SD_HOST_STATUS read-only */
12986 write_csr(dd, ASIC_PCIE_SD_INTRPT_DATA_CODE, 0);
12987 write_csr(dd, ASIC_PCIE_SD_INTRPT_ENABLE, 0);
12988 /* ASIC_PCIE_SD_INTRPT_PROGRESS read-only */
12989 write_csr(dd, ASIC_PCIE_SD_INTRPT_STATUS, ~0ull); /* clear */
12990 /* ASIC_HFI0_PCIE_SD_INTRPT_RSPD_DATA read-only */
12991 /* ASIC_HFI1_PCIE_SD_INTRPT_RSPD_DATA read-only */
12992 for (i = 0; i < 16; i++)
12993 write_csr(dd, ASIC_PCIE_SD_INTRPT_LIST + (8 * i), 0);
12995 /* ASIC_GPIO_IN read-only */
12996 write_csr(dd, ASIC_GPIO_OE, 0);
12997 write_csr(dd, ASIC_GPIO_INVERT, 0);
12998 write_csr(dd, ASIC_GPIO_OUT, 0);
12999 write_csr(dd, ASIC_GPIO_MASK, 0);
13000 /* ASIC_GPIO_STATUS read-only */
13001 write_csr(dd, ASIC_GPIO_CLEAR, ~0ull);
13002 /* ASIC_GPIO_FORCE leave alone */
13004 /* ASIC_QSFP1_IN read-only */
13005 write_csr(dd, ASIC_QSFP1_OE, 0);
13006 write_csr(dd, ASIC_QSFP1_INVERT, 0);
13007 write_csr(dd, ASIC_QSFP1_OUT, 0);
13008 write_csr(dd, ASIC_QSFP1_MASK, 0);
13009 /* ASIC_QSFP1_STATUS read-only */
13010 write_csr(dd, ASIC_QSFP1_CLEAR, ~0ull);
13011 /* ASIC_QSFP1_FORCE leave alone */
13013 /* ASIC_QSFP2_IN read-only */
13014 write_csr(dd, ASIC_QSFP2_OE, 0);
13015 write_csr(dd, ASIC_QSFP2_INVERT, 0);
13016 write_csr(dd, ASIC_QSFP2_OUT, 0);
13017 write_csr(dd, ASIC_QSFP2_MASK, 0);
13018 /* ASIC_QSFP2_STATUS read-only */
13019 write_csr(dd, ASIC_QSFP2_CLEAR, ~0ull);
13020 /* ASIC_QSFP2_FORCE leave alone */
13022 write_csr(dd, ASIC_EEP_CTL_STAT, ASIC_EEP_CTL_STAT_RESETCSR);
13023 /* this also writes a NOP command, clearing paging mode */
13024 write_csr(dd, ASIC_EEP_ADDR_CMD, 0);
13025 write_csr(dd, ASIC_EEP_DATA, 0);
13028 /* set MISC CSRs to chip reset defaults */
13029 static void reset_misc_csrs(struct hfi1_devdata *dd)
13033 for (i = 0; i < 32; i++) {
13034 write_csr(dd, MISC_CFG_RSA_R2 + (8 * i), 0);
13035 write_csr(dd, MISC_CFG_RSA_SIGNATURE + (8 * i), 0);
13036 write_csr(dd, MISC_CFG_RSA_MODULUS + (8 * i), 0);
13038 /* MISC_CFG_SHA_PRELOAD leave alone - always reads 0 and can
13039 only be written 128-byte chunks */
13040 /* init RSA engine to clear lingering errors */
13041 write_csr(dd, MISC_CFG_RSA_CMD, 1);
13042 write_csr(dd, MISC_CFG_RSA_MU, 0);
13043 write_csr(dd, MISC_CFG_FW_CTRL, 0);
13044 /* MISC_STS_8051_DIGEST read-only */
13045 /* MISC_STS_SBM_DIGEST read-only */
13046 /* MISC_STS_PCIE_DIGEST read-only */
13047 /* MISC_STS_FAB_DIGEST read-only */
13048 /* MISC_ERR_STATUS read-only */
13049 write_csr(dd, MISC_ERR_MASK, 0);
13050 write_csr(dd, MISC_ERR_CLEAR, ~0ull);
13051 /* MISC_ERR_FORCE leave alone */
13054 /* set TXE CSRs to chip reset defaults */
13055 static void reset_txe_csrs(struct hfi1_devdata *dd)
13062 write_csr(dd, SEND_CTRL, 0);
13063 __cm_reset(dd, 0); /* reset CM internal state */
13064 /* SEND_CONTEXTS read-only */
13065 /* SEND_DMA_ENGINES read-only */
13066 /* SEND_PIO_MEM_SIZE read-only */
13067 /* SEND_DMA_MEM_SIZE read-only */
13068 write_csr(dd, SEND_HIGH_PRIORITY_LIMIT, 0);
13069 pio_reset_all(dd); /* SEND_PIO_INIT_CTXT */
13070 /* SEND_PIO_ERR_STATUS read-only */
13071 write_csr(dd, SEND_PIO_ERR_MASK, 0);
13072 write_csr(dd, SEND_PIO_ERR_CLEAR, ~0ull);
13073 /* SEND_PIO_ERR_FORCE leave alone */
13074 /* SEND_DMA_ERR_STATUS read-only */
13075 write_csr(dd, SEND_DMA_ERR_MASK, 0);
13076 write_csr(dd, SEND_DMA_ERR_CLEAR, ~0ull);
13077 /* SEND_DMA_ERR_FORCE leave alone */
13078 /* SEND_EGRESS_ERR_STATUS read-only */
13079 write_csr(dd, SEND_EGRESS_ERR_MASK, 0);
13080 write_csr(dd, SEND_EGRESS_ERR_CLEAR, ~0ull);
13081 /* SEND_EGRESS_ERR_FORCE leave alone */
13082 write_csr(dd, SEND_BTH_QP, 0);
13083 write_csr(dd, SEND_STATIC_RATE_CONTROL, 0);
13084 write_csr(dd, SEND_SC2VLT0, 0);
13085 write_csr(dd, SEND_SC2VLT1, 0);
13086 write_csr(dd, SEND_SC2VLT2, 0);
13087 write_csr(dd, SEND_SC2VLT3, 0);
13088 write_csr(dd, SEND_LEN_CHECK0, 0);
13089 write_csr(dd, SEND_LEN_CHECK1, 0);
13090 /* SEND_ERR_STATUS read-only */
13091 write_csr(dd, SEND_ERR_MASK, 0);
13092 write_csr(dd, SEND_ERR_CLEAR, ~0ull);
13093 /* SEND_ERR_FORCE read-only */
13094 for (i = 0; i < VL_ARB_LOW_PRIO_TABLE_SIZE; i++)
13095 write_csr(dd, SEND_LOW_PRIORITY_LIST + (8*i), 0);
13096 for (i = 0; i < VL_ARB_HIGH_PRIO_TABLE_SIZE; i++)
13097 write_csr(dd, SEND_HIGH_PRIORITY_LIST + (8*i), 0);
13098 for (i = 0; i < dd->chip_send_contexts/NUM_CONTEXTS_PER_SET; i++)
13099 write_csr(dd, SEND_CONTEXT_SET_CTRL + (8*i), 0);
13100 for (i = 0; i < TXE_NUM_32_BIT_COUNTER; i++)
13101 write_csr(dd, SEND_COUNTER_ARRAY32 + (8*i), 0);
13102 for (i = 0; i < TXE_NUM_64_BIT_COUNTER; i++)
13103 write_csr(dd, SEND_COUNTER_ARRAY64 + (8*i), 0);
13104 write_csr(dd, SEND_CM_CTRL, SEND_CM_CTRL_RESETCSR);
13105 write_csr(dd, SEND_CM_GLOBAL_CREDIT,
13106 SEND_CM_GLOBAL_CREDIT_RESETCSR);
13107 /* SEND_CM_CREDIT_USED_STATUS read-only */
13108 write_csr(dd, SEND_CM_TIMER_CTRL, 0);
13109 write_csr(dd, SEND_CM_LOCAL_AU_TABLE0_TO3, 0);
13110 write_csr(dd, SEND_CM_LOCAL_AU_TABLE4_TO7, 0);
13111 write_csr(dd, SEND_CM_REMOTE_AU_TABLE0_TO3, 0);
13112 write_csr(dd, SEND_CM_REMOTE_AU_TABLE4_TO7, 0);
13113 for (i = 0; i < TXE_NUM_DATA_VL; i++)
13114 write_csr(dd, SEND_CM_CREDIT_VL + (8*i), 0);
13115 write_csr(dd, SEND_CM_CREDIT_VL15, 0);
13116 /* SEND_CM_CREDIT_USED_VL read-only */
13117 /* SEND_CM_CREDIT_USED_VL15 read-only */
13118 /* SEND_EGRESS_CTXT_STATUS read-only */
13119 /* SEND_EGRESS_SEND_DMA_STATUS read-only */
13120 write_csr(dd, SEND_EGRESS_ERR_INFO, ~0ull);
13121 /* SEND_EGRESS_ERR_INFO read-only */
13122 /* SEND_EGRESS_ERR_SOURCE read-only */
13125 * TXE Per-Context CSRs
13127 for (i = 0; i < dd->chip_send_contexts; i++) {
13128 write_kctxt_csr(dd, i, SEND_CTXT_CTRL, 0);
13129 write_kctxt_csr(dd, i, SEND_CTXT_CREDIT_CTRL, 0);
13130 write_kctxt_csr(dd, i, SEND_CTXT_CREDIT_RETURN_ADDR, 0);
13131 write_kctxt_csr(dd, i, SEND_CTXT_CREDIT_FORCE, 0);
13132 write_kctxt_csr(dd, i, SEND_CTXT_ERR_MASK, 0);
13133 write_kctxt_csr(dd, i, SEND_CTXT_ERR_CLEAR, ~0ull);
13134 write_kctxt_csr(dd, i, SEND_CTXT_CHECK_ENABLE, 0);
13135 write_kctxt_csr(dd, i, SEND_CTXT_CHECK_VL, 0);
13136 write_kctxt_csr(dd, i, SEND_CTXT_CHECK_JOB_KEY, 0);
13137 write_kctxt_csr(dd, i, SEND_CTXT_CHECK_PARTITION_KEY, 0);
13138 write_kctxt_csr(dd, i, SEND_CTXT_CHECK_SLID, 0);
13139 write_kctxt_csr(dd, i, SEND_CTXT_CHECK_OPCODE, 0);
13143 * TXE Per-SDMA CSRs
13145 for (i = 0; i < dd->chip_sdma_engines; i++) {
13146 write_kctxt_csr(dd, i, SEND_DMA_CTRL, 0);
13147 /* SEND_DMA_STATUS read-only */
13148 write_kctxt_csr(dd, i, SEND_DMA_BASE_ADDR, 0);
13149 write_kctxt_csr(dd, i, SEND_DMA_LEN_GEN, 0);
13150 write_kctxt_csr(dd, i, SEND_DMA_TAIL, 0);
13151 /* SEND_DMA_HEAD read-only */
13152 write_kctxt_csr(dd, i, SEND_DMA_HEAD_ADDR, 0);
13153 write_kctxt_csr(dd, i, SEND_DMA_PRIORITY_THLD, 0);
13154 /* SEND_DMA_IDLE_CNT read-only */
13155 write_kctxt_csr(dd, i, SEND_DMA_RELOAD_CNT, 0);
13156 write_kctxt_csr(dd, i, SEND_DMA_DESC_CNT, 0);
13157 /* SEND_DMA_DESC_FETCHED_CNT read-only */
13158 /* SEND_DMA_ENG_ERR_STATUS read-only */
13159 write_kctxt_csr(dd, i, SEND_DMA_ENG_ERR_MASK, 0);
13160 write_kctxt_csr(dd, i, SEND_DMA_ENG_ERR_CLEAR, ~0ull);
13161 /* SEND_DMA_ENG_ERR_FORCE leave alone */
13162 write_kctxt_csr(dd, i, SEND_DMA_CHECK_ENABLE, 0);
13163 write_kctxt_csr(dd, i, SEND_DMA_CHECK_VL, 0);
13164 write_kctxt_csr(dd, i, SEND_DMA_CHECK_JOB_KEY, 0);
13165 write_kctxt_csr(dd, i, SEND_DMA_CHECK_PARTITION_KEY, 0);
13166 write_kctxt_csr(dd, i, SEND_DMA_CHECK_SLID, 0);
13167 write_kctxt_csr(dd, i, SEND_DMA_CHECK_OPCODE, 0);
13168 write_kctxt_csr(dd, i, SEND_DMA_MEMORY, 0);
13174 * o Packet ingress is disabled, i.e. RcvCtrl.RcvPortEnable == 0
13176 static void init_rbufs(struct hfi1_devdata *dd)
13182 * Wait for DMA to stop: RxRbufPktPending and RxPktInProgress are
13187 reg = read_csr(dd, RCV_STATUS);
13188 if ((reg & (RCV_STATUS_RX_RBUF_PKT_PENDING_SMASK
13189 | RCV_STATUS_RX_PKT_IN_PROGRESS_SMASK)) == 0)
13192 * Give up after 1ms - maximum wait time.
13194 * RBuf size is 148KiB. Slowest possible is PCIe Gen1 x1 at
13195 * 250MB/s bandwidth. Lower rate to 66% for overhead to get:
13196 * 148 KB / (66% * 250MB/s) = 920us
13198 if (count++ > 500) {
13200 "%s: in-progress DMA not clearing: RcvStatus 0x%llx, continuing\n",
13204 udelay(2); /* do not busy-wait the CSR */
13207 /* start the init - expect RcvCtrl to be 0 */
13208 write_csr(dd, RCV_CTRL, RCV_CTRL_RX_RBUF_INIT_SMASK);
13211 * Read to force the write of Rcvtrl.RxRbufInit. There is a brief
13212 * period after the write before RcvStatus.RxRbufInitDone is valid.
13213 * The delay in the first run through the loop below is sufficient and
13214 * required before the first read of RcvStatus.RxRbufInintDone.
13216 read_csr(dd, RCV_CTRL);
13218 /* wait for the init to finish */
13221 /* delay is required first time through - see above */
13222 udelay(2); /* do not busy-wait the CSR */
13223 reg = read_csr(dd, RCV_STATUS);
13224 if (reg & (RCV_STATUS_RX_RBUF_INIT_DONE_SMASK))
13227 /* give up after 100us - slowest possible at 33MHz is 73us */
13228 if (count++ > 50) {
13230 "%s: RcvStatus.RxRbufInit not set, continuing\n",
13237 /* set RXE CSRs to chip reset defaults */
13238 static void reset_rxe_csrs(struct hfi1_devdata *dd)
13245 write_csr(dd, RCV_CTRL, 0);
13247 /* RCV_STATUS read-only */
13248 /* RCV_CONTEXTS read-only */
13249 /* RCV_ARRAY_CNT read-only */
13250 /* RCV_BUF_SIZE read-only */
13251 write_csr(dd, RCV_BTH_QP, 0);
13252 write_csr(dd, RCV_MULTICAST, 0);
13253 write_csr(dd, RCV_BYPASS, 0);
13254 write_csr(dd, RCV_VL15, 0);
13255 /* this is a clear-down */
13256 write_csr(dd, RCV_ERR_INFO,
13257 RCV_ERR_INFO_RCV_EXCESS_BUFFER_OVERRUN_SMASK);
13258 /* RCV_ERR_STATUS read-only */
13259 write_csr(dd, RCV_ERR_MASK, 0);
13260 write_csr(dd, RCV_ERR_CLEAR, ~0ull);
13261 /* RCV_ERR_FORCE leave alone */
13262 for (i = 0; i < 32; i++)
13263 write_csr(dd, RCV_QP_MAP_TABLE + (8 * i), 0);
13264 for (i = 0; i < 4; i++)
13265 write_csr(dd, RCV_PARTITION_KEY + (8 * i), 0);
13266 for (i = 0; i < RXE_NUM_32_BIT_COUNTERS; i++)
13267 write_csr(dd, RCV_COUNTER_ARRAY32 + (8 * i), 0);
13268 for (i = 0; i < RXE_NUM_64_BIT_COUNTERS; i++)
13269 write_csr(dd, RCV_COUNTER_ARRAY64 + (8 * i), 0);
13270 for (i = 0; i < RXE_NUM_RSM_INSTANCES; i++) {
13271 write_csr(dd, RCV_RSM_CFG + (8 * i), 0);
13272 write_csr(dd, RCV_RSM_SELECT + (8 * i), 0);
13273 write_csr(dd, RCV_RSM_MATCH + (8 * i), 0);
13275 for (i = 0; i < 32; i++)
13276 write_csr(dd, RCV_RSM_MAP_TABLE + (8 * i), 0);
13279 * RXE Kernel and User Per-Context CSRs
13281 for (i = 0; i < dd->chip_rcv_contexts; i++) {
13283 write_kctxt_csr(dd, i, RCV_CTXT_CTRL, 0);
13284 /* RCV_CTXT_STATUS read-only */
13285 write_kctxt_csr(dd, i, RCV_EGR_CTRL, 0);
13286 write_kctxt_csr(dd, i, RCV_TID_CTRL, 0);
13287 write_kctxt_csr(dd, i, RCV_KEY_CTRL, 0);
13288 write_kctxt_csr(dd, i, RCV_HDR_ADDR, 0);
13289 write_kctxt_csr(dd, i, RCV_HDR_CNT, 0);
13290 write_kctxt_csr(dd, i, RCV_HDR_ENT_SIZE, 0);
13291 write_kctxt_csr(dd, i, RCV_HDR_SIZE, 0);
13292 write_kctxt_csr(dd, i, RCV_HDR_TAIL_ADDR, 0);
13293 write_kctxt_csr(dd, i, RCV_AVAIL_TIME_OUT, 0);
13294 write_kctxt_csr(dd, i, RCV_HDR_OVFL_CNT, 0);
13297 /* RCV_HDR_TAIL read-only */
13298 write_uctxt_csr(dd, i, RCV_HDR_HEAD, 0);
13299 /* RCV_EGR_INDEX_TAIL read-only */
13300 write_uctxt_csr(dd, i, RCV_EGR_INDEX_HEAD, 0);
13301 /* RCV_EGR_OFFSET_TAIL read-only */
13302 for (j = 0; j < RXE_NUM_TID_FLOWS; j++) {
13303 write_uctxt_csr(dd, i, RCV_TID_FLOW_TABLE + (8 * j),
13310 * Set sc2vl tables.
13312 * They power on to zeros, so to avoid send context errors
13313 * they need to be set:
13315 * SC 0-7 -> VL 0-7 (respectively)
13320 static void init_sc2vl_tables(struct hfi1_devdata *dd)
13323 /* init per architecture spec, constrained by hardware capability */
13325 /* HFI maps sent packets */
13326 write_csr(dd, SEND_SC2VLT0, SC2VL_VAL(
13332 write_csr(dd, SEND_SC2VLT1, SC2VL_VAL(
13338 write_csr(dd, SEND_SC2VLT2, SC2VL_VAL(
13344 write_csr(dd, SEND_SC2VLT3, SC2VL_VAL(
13351 /* DC maps received packets */
13352 write_csr(dd, DCC_CFG_SC_VL_TABLE_15_0, DC_SC_VL_VAL(
13354 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7,
13355 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 15));
13356 write_csr(dd, DCC_CFG_SC_VL_TABLE_31_16, DC_SC_VL_VAL(
13358 16, 0, 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0,
13359 24, 0, 25, 0, 26, 0, 27, 0, 28, 0, 29, 0, 30, 0, 31, 0));
13361 /* initialize the cached sc2vl values consistently with h/w */
13362 for (i = 0; i < 32; i++) {
13363 if (i < 8 || i == 15)
13364 *((u8 *)(dd->sc2vl) + i) = (u8)i;
13366 *((u8 *)(dd->sc2vl) + i) = 0;
13371 * Read chip sizes and then reset parts to sane, disabled, values. We cannot
13372 * depend on the chip going through a power-on reset - a driver may be loaded
13373 * and unloaded many times.
13375 * Do not write any CSR values to the chip in this routine - there may be
13376 * a reset following the (possible) FLR in this routine.
13379 static void init_chip(struct hfi1_devdata *dd)
13384 * Put the HFI CSRs in a known state.
13385 * Combine this with a DC reset.
13387 * Stop the device from doing anything while we do a
13388 * reset. We know there are no other active users of
13389 * the device since we are now in charge. Turn off
13390 * off all outbound and inbound traffic and make sure
13391 * the device does not generate any interrupts.
13394 /* disable send contexts and SDMA engines */
13395 write_csr(dd, SEND_CTRL, 0);
13396 for (i = 0; i < dd->chip_send_contexts; i++)
13397 write_kctxt_csr(dd, i, SEND_CTXT_CTRL, 0);
13398 for (i = 0; i < dd->chip_sdma_engines; i++)
13399 write_kctxt_csr(dd, i, SEND_DMA_CTRL, 0);
13400 /* disable port (turn off RXE inbound traffic) and contexts */
13401 write_csr(dd, RCV_CTRL, 0);
13402 for (i = 0; i < dd->chip_rcv_contexts; i++)
13403 write_csr(dd, RCV_CTXT_CTRL, 0);
13404 /* mask all interrupt sources */
13405 for (i = 0; i < CCE_NUM_INT_CSRS; i++)
13406 write_csr(dd, CCE_INT_MASK + (8*i), 0ull);
13409 * DC Reset: do a full DC reset before the register clear.
13410 * A recommended length of time to hold is one CSR read,
13411 * so reread the CceDcCtrl. Then, hold the DC in reset
13412 * across the clear.
13414 write_csr(dd, CCE_DC_CTRL, CCE_DC_CTRL_DC_RESET_SMASK);
13415 (void) read_csr(dd, CCE_DC_CTRL);
13419 * A FLR will reset the SPC core and part of the PCIe.
13420 * The parts that need to be restored have already been
13423 dd_dev_info(dd, "Resetting CSRs with FLR\n");
13425 /* do the FLR, the DC reset will remain */
13428 /* restore command and BARs */
13429 restore_pci_variables(dd);
13432 dd_dev_info(dd, "Resetting CSRs with FLR\n");
13434 restore_pci_variables(dd);
13437 reset_asic_csrs(dd);
13439 dd_dev_info(dd, "Resetting CSRs with writes\n");
13440 reset_cce_csrs(dd);
13441 reset_txe_csrs(dd);
13442 reset_rxe_csrs(dd);
13443 reset_asic_csrs(dd);
13444 reset_misc_csrs(dd);
13446 /* clear the DC reset */
13447 write_csr(dd, CCE_DC_CTRL, 0);
13449 /* Set the LED off */
13453 * Clear the QSFP reset.
13454 * An FLR enforces a 0 on all out pins. The driver does not touch
13455 * ASIC_QSFPn_OUT otherwise. This leaves RESET_N low and
13456 * anything plugged constantly in reset, if it pays attention
13458 * Prime examples of this are optical cables. Set all pins high.
13459 * I2CCLK and I2CDAT will change per direction, and INT_N and
13460 * MODPRS_N are input only and their value is ignored.
13462 write_csr(dd, ASIC_QSFP1_OUT, 0x1f);
13463 write_csr(dd, ASIC_QSFP2_OUT, 0x1f);
13466 static void init_early_variables(struct hfi1_devdata *dd)
13470 /* assign link credit variables */
13472 dd->link_credits = CM_GLOBAL_CREDITS;
13474 dd->link_credits--;
13475 dd->vcu = cu_to_vcu(hfi1_cu);
13476 /* enough room for 8 MAD packets plus header - 17K */
13477 dd->vl15_init = (8 * (2048 + 128)) / vau_to_au(dd->vau);
13478 if (dd->vl15_init > dd->link_credits)
13479 dd->vl15_init = dd->link_credits;
13481 write_uninitialized_csrs_and_memories(dd);
13483 if (HFI1_CAP_IS_KSET(PKEY_CHECK))
13484 for (i = 0; i < dd->num_pports; i++) {
13485 struct hfi1_pportdata *ppd = &dd->pport[i];
13487 set_partition_keys(ppd);
13489 init_sc2vl_tables(dd);
13492 static void init_kdeth_qp(struct hfi1_devdata *dd)
13494 /* user changed the KDETH_QP */
13495 if (kdeth_qp != 0 && kdeth_qp >= 0xff) {
13496 /* out of range or illegal value */
13497 dd_dev_err(dd, "Invalid KDETH queue pair prefix, ignoring");
13500 if (kdeth_qp == 0) /* not set, or failed range check */
13501 kdeth_qp = DEFAULT_KDETH_QP;
13503 write_csr(dd, SEND_BTH_QP,
13504 (kdeth_qp & SEND_BTH_QP_KDETH_QP_MASK)
13505 << SEND_BTH_QP_KDETH_QP_SHIFT);
13507 write_csr(dd, RCV_BTH_QP,
13508 (kdeth_qp & RCV_BTH_QP_KDETH_QP_MASK)
13509 << RCV_BTH_QP_KDETH_QP_SHIFT);
13514 * @dd - device data
13515 * @first_ctxt - first context
13516 * @last_ctxt - first context
13518 * This return sets the qpn mapping table that
13519 * is indexed by qpn[8:1].
13521 * The routine will round robin the 256 settings
13522 * from first_ctxt to last_ctxt.
13524 * The first/last looks ahead to having specialized
13525 * receive contexts for mgmt and bypass. Normal
13526 * verbs traffic will assumed to be on a range
13527 * of receive contexts.
13529 static void init_qpmap_table(struct hfi1_devdata *dd,
13534 u64 regno = RCV_QP_MAP_TABLE;
13536 u64 ctxt = first_ctxt;
13538 for (i = 0; i < 256;) {
13539 reg |= ctxt << (8 * (i % 8));
13542 if (ctxt > last_ctxt)
13545 write_csr(dd, regno, reg);
13551 write_csr(dd, regno, reg);
13553 add_rcvctrl(dd, RCV_CTRL_RCV_QP_MAP_ENABLE_SMASK
13554 | RCV_CTRL_RCV_BYPASS_ENABLE_SMASK);
13558 * init_qos - init RX qos
13559 * @dd - device data
13562 * This routine initializes Rule 0 and the
13563 * RSM map table to implement qos.
13565 * If all of the limit tests succeed,
13566 * qos is applied based on the array
13567 * interpretation of krcvqs where
13570 * The number of vl bits (n) and the number of qpn
13571 * bits (m) are computed to feed both the RSM map table
13572 * and the single rule.
13575 static void init_qos(struct hfi1_devdata *dd, u32 first_ctxt)
13578 unsigned qpns_per_vl, ctxt, i, qpn, n = 1, m;
13581 u8 rxcontext = is_ax(dd) ? 0 : 0xff; /* 0 is default if a0 ver. */
13584 if (dd->n_krcv_queues <= MIN_KERNEL_KCTXTS ||
13588 for (i = 0; i < min_t(unsigned, num_vls, krcvqsset); i++)
13589 if (krcvqs[i] > max_by_vl)
13590 max_by_vl = krcvqs[i];
13591 if (max_by_vl > 32)
13593 qpns_per_vl = __roundup_pow_of_two(max_by_vl);
13594 /* determine bits vl */
13595 n = ilog2(num_vls);
13596 /* determine bits for qpn */
13597 m = ilog2(qpns_per_vl);
13600 if (num_vls * qpns_per_vl > dd->chip_rcv_contexts)
13602 rsmmap = kmalloc_array(NUM_MAP_REGS, sizeof(u64), GFP_KERNEL);
13605 memset(rsmmap, rxcontext, NUM_MAP_REGS * sizeof(u64));
13606 /* init the local copy of the table */
13607 for (i = 0, ctxt = first_ctxt; i < num_vls; i++) {
13610 for (qpn = 0, tctxt = ctxt;
13611 krcvqs[i] && qpn < qpns_per_vl; qpn++) {
13612 unsigned idx, regoff, regidx;
13614 /* generate index <= 128 */
13615 idx = (qpn << n) ^ i;
13616 regoff = (idx % 8) * 8;
13618 reg = rsmmap[regidx];
13619 /* replace 0xff with context number */
13620 reg &= ~(RCV_RSM_MAP_TABLE_RCV_CONTEXT_A_MASK
13622 reg |= (u64)(tctxt++) << regoff;
13623 rsmmap[regidx] = reg;
13624 if (tctxt == ctxt + krcvqs[i])
13629 /* flush cached copies to chip */
13630 for (i = 0; i < NUM_MAP_REGS; i++)
13631 write_csr(dd, RCV_RSM_MAP_TABLE + (8 * i), rsmmap[i]);
13633 write_csr(dd, RCV_RSM_CFG /* + (8 * 0) */,
13634 RCV_RSM_CFG_ENABLE_OR_CHAIN_RSM0_MASK
13635 << RCV_RSM_CFG_ENABLE_OR_CHAIN_RSM0_SHIFT |
13636 2ull << RCV_RSM_CFG_PACKET_TYPE_SHIFT);
13637 write_csr(dd, RCV_RSM_SELECT /* + (8 * 0) */,
13638 LRH_BTH_MATCH_OFFSET
13639 << RCV_RSM_SELECT_FIELD1_OFFSET_SHIFT |
13640 LRH_SC_MATCH_OFFSET << RCV_RSM_SELECT_FIELD2_OFFSET_SHIFT |
13641 LRH_SC_SELECT_OFFSET << RCV_RSM_SELECT_INDEX1_OFFSET_SHIFT |
13642 ((u64)n) << RCV_RSM_SELECT_INDEX1_WIDTH_SHIFT |
13643 QPN_SELECT_OFFSET << RCV_RSM_SELECT_INDEX2_OFFSET_SHIFT |
13644 ((u64)m + (u64)n) << RCV_RSM_SELECT_INDEX2_WIDTH_SHIFT);
13645 write_csr(dd, RCV_RSM_MATCH /* + (8 * 0) */,
13646 LRH_BTH_MASK << RCV_RSM_MATCH_MASK1_SHIFT |
13647 LRH_BTH_VALUE << RCV_RSM_MATCH_VALUE1_SHIFT |
13648 LRH_SC_MASK << RCV_RSM_MATCH_MASK2_SHIFT |
13649 LRH_SC_VALUE << RCV_RSM_MATCH_VALUE2_SHIFT);
13651 add_rcvctrl(dd, RCV_CTRL_RCV_RSM_ENABLE_SMASK);
13653 /* map everything else to first context */
13654 init_qpmap_table(dd, FIRST_KERNEL_KCTXT, MIN_KERNEL_KCTXTS - 1);
13655 dd->qos_shift = n + 1;
13659 init_qpmap_table(dd, FIRST_KERNEL_KCTXT, dd->n_krcv_queues - 1);
13662 static void init_rxe(struct hfi1_devdata *dd)
13664 /* enable all receive errors */
13665 write_csr(dd, RCV_ERR_MASK, ~0ull);
13666 /* setup QPN map table - start where VL15 context leaves off */
13669 dd->n_krcv_queues > MIN_KERNEL_KCTXTS ? MIN_KERNEL_KCTXTS : 0);
13671 * make sure RcvCtrl.RcvWcb <= PCIe Device Control
13672 * Register Max_Payload_Size (PCI_EXP_DEVCTL in Linux PCIe config
13673 * space, PciCfgCap2.MaxPayloadSize in HFI). There is only one
13674 * invalid configuration: RcvCtrl.RcvWcb set to its max of 256 and
13675 * Max_PayLoad_Size set to its minimum of 128.
13677 * Presently, RcvCtrl.RcvWcb is not modified from its default of 0
13678 * (64 bytes). Max_Payload_Size is possibly modified upward in
13679 * tune_pcie_caps() which is called after this routine.
13683 static void init_other(struct hfi1_devdata *dd)
13685 /* enable all CCE errors */
13686 write_csr(dd, CCE_ERR_MASK, ~0ull);
13687 /* enable *some* Misc errors */
13688 write_csr(dd, MISC_ERR_MASK, DRIVER_MISC_MASK);
13689 /* enable all DC errors, except LCB */
13690 write_csr(dd, DCC_ERR_FLG_EN, ~0ull);
13691 write_csr(dd, DC_DC8051_ERR_EN, ~0ull);
13695 * Fill out the given AU table using the given CU. A CU is defined in terms
13696 * AUs. The table is a an encoding: given the index, how many AUs does that
13699 * NOTE: Assumes that the register layout is the same for the
13700 * local and remote tables.
13702 static void assign_cm_au_table(struct hfi1_devdata *dd, u32 cu,
13703 u32 csr0to3, u32 csr4to7)
13705 write_csr(dd, csr0to3,
13707 SEND_CM_LOCAL_AU_TABLE0_TO3_LOCAL_AU_TABLE0_SHIFT
13709 SEND_CM_LOCAL_AU_TABLE0_TO3_LOCAL_AU_TABLE1_SHIFT
13711 SEND_CM_LOCAL_AU_TABLE0_TO3_LOCAL_AU_TABLE2_SHIFT
13713 SEND_CM_LOCAL_AU_TABLE0_TO3_LOCAL_AU_TABLE3_SHIFT);
13714 write_csr(dd, csr4to7,
13716 SEND_CM_LOCAL_AU_TABLE4_TO7_LOCAL_AU_TABLE4_SHIFT
13718 SEND_CM_LOCAL_AU_TABLE4_TO7_LOCAL_AU_TABLE5_SHIFT
13720 SEND_CM_LOCAL_AU_TABLE4_TO7_LOCAL_AU_TABLE6_SHIFT
13722 SEND_CM_LOCAL_AU_TABLE4_TO7_LOCAL_AU_TABLE7_SHIFT);
13726 static void assign_local_cm_au_table(struct hfi1_devdata *dd, u8 vcu)
13728 assign_cm_au_table(dd, vcu_to_cu(vcu), SEND_CM_LOCAL_AU_TABLE0_TO3,
13729 SEND_CM_LOCAL_AU_TABLE4_TO7);
13732 void assign_remote_cm_au_table(struct hfi1_devdata *dd, u8 vcu)
13734 assign_cm_au_table(dd, vcu_to_cu(vcu), SEND_CM_REMOTE_AU_TABLE0_TO3,
13735 SEND_CM_REMOTE_AU_TABLE4_TO7);
13738 static void init_txe(struct hfi1_devdata *dd)
13742 /* enable all PIO, SDMA, general, and Egress errors */
13743 write_csr(dd, SEND_PIO_ERR_MASK, ~0ull);
13744 write_csr(dd, SEND_DMA_ERR_MASK, ~0ull);
13745 write_csr(dd, SEND_ERR_MASK, ~0ull);
13746 write_csr(dd, SEND_EGRESS_ERR_MASK, ~0ull);
13748 /* enable all per-context and per-SDMA engine errors */
13749 for (i = 0; i < dd->chip_send_contexts; i++)
13750 write_kctxt_csr(dd, i, SEND_CTXT_ERR_MASK, ~0ull);
13751 for (i = 0; i < dd->chip_sdma_engines; i++)
13752 write_kctxt_csr(dd, i, SEND_DMA_ENG_ERR_MASK, ~0ull);
13754 /* set the local CU to AU mapping */
13755 assign_local_cm_au_table(dd, dd->vcu);
13758 * Set reasonable default for Credit Return Timer
13759 * Don't set on Simulator - causes it to choke.
13761 if (dd->icode != ICODE_FUNCTIONAL_SIMULATOR)
13762 write_csr(dd, SEND_CM_TIMER_CTRL, HFI1_CREDIT_RETURN_RATE);
13765 int hfi1_set_ctxt_jkey(struct hfi1_devdata *dd, unsigned ctxt, u16 jkey)
13767 struct hfi1_ctxtdata *rcd = dd->rcd[ctxt];
13772 if (!rcd || !rcd->sc) {
13776 sctxt = rcd->sc->hw_context;
13777 reg = SEND_CTXT_CHECK_JOB_KEY_MASK_SMASK | /* mask is always 1's */
13778 ((jkey & SEND_CTXT_CHECK_JOB_KEY_VALUE_MASK) <<
13779 SEND_CTXT_CHECK_JOB_KEY_VALUE_SHIFT);
13780 /* JOB_KEY_ALLOW_PERMISSIVE is not allowed by default */
13781 if (HFI1_CAP_KGET_MASK(rcd->flags, ALLOW_PERM_JKEY))
13782 reg |= SEND_CTXT_CHECK_JOB_KEY_ALLOW_PERMISSIVE_SMASK;
13783 write_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_JOB_KEY, reg);
13785 * Enable send-side J_KEY integrity check, unless this is A0 h/w
13788 reg = read_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_ENABLE);
13789 reg |= SEND_CTXT_CHECK_ENABLE_CHECK_JOB_KEY_SMASK;
13790 write_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_ENABLE, reg);
13793 /* Enable J_KEY check on receive context. */
13794 reg = RCV_KEY_CTRL_JOB_KEY_ENABLE_SMASK |
13795 ((jkey & RCV_KEY_CTRL_JOB_KEY_VALUE_MASK) <<
13796 RCV_KEY_CTRL_JOB_KEY_VALUE_SHIFT);
13797 write_kctxt_csr(dd, ctxt, RCV_KEY_CTRL, reg);
13802 int hfi1_clear_ctxt_jkey(struct hfi1_devdata *dd, unsigned ctxt)
13804 struct hfi1_ctxtdata *rcd = dd->rcd[ctxt];
13809 if (!rcd || !rcd->sc) {
13813 sctxt = rcd->sc->hw_context;
13814 write_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_JOB_KEY, 0);
13816 * Disable send-side J_KEY integrity check, unless this is A0 h/w.
13817 * This check would not have been enabled for A0 h/w, see
13821 reg = read_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_ENABLE);
13822 reg &= ~SEND_CTXT_CHECK_ENABLE_CHECK_JOB_KEY_SMASK;
13823 write_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_ENABLE, reg);
13825 /* Turn off the J_KEY on the receive side */
13826 write_kctxt_csr(dd, ctxt, RCV_KEY_CTRL, 0);
13831 int hfi1_set_ctxt_pkey(struct hfi1_devdata *dd, unsigned ctxt, u16 pkey)
13833 struct hfi1_ctxtdata *rcd;
13838 if (ctxt < dd->num_rcv_contexts)
13839 rcd = dd->rcd[ctxt];
13844 if (!rcd || !rcd->sc) {
13848 sctxt = rcd->sc->hw_context;
13849 reg = ((u64)pkey & SEND_CTXT_CHECK_PARTITION_KEY_VALUE_MASK) <<
13850 SEND_CTXT_CHECK_PARTITION_KEY_VALUE_SHIFT;
13851 write_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_PARTITION_KEY, reg);
13852 reg = read_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_ENABLE);
13853 reg |= SEND_CTXT_CHECK_ENABLE_CHECK_PARTITION_KEY_SMASK;
13854 write_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_ENABLE, reg);
13859 int hfi1_clear_ctxt_pkey(struct hfi1_devdata *dd, unsigned ctxt)
13861 struct hfi1_ctxtdata *rcd;
13866 if (ctxt < dd->num_rcv_contexts)
13867 rcd = dd->rcd[ctxt];
13872 if (!rcd || !rcd->sc) {
13876 sctxt = rcd->sc->hw_context;
13877 reg = read_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_ENABLE);
13878 reg &= ~SEND_CTXT_CHECK_ENABLE_CHECK_PARTITION_KEY_SMASK;
13879 write_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_ENABLE, reg);
13880 write_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_PARTITION_KEY, 0);
13886 * Start doing the clean up the the chip. Our clean up happens in multiple
13887 * stages and this is just the first.
13889 void hfi1_start_cleanup(struct hfi1_devdata *dd)
13894 clean_up_interrupts(dd);
13897 #define HFI_BASE_GUID(dev) \
13898 ((dev)->base_guid & ~(1ULL << GUID_HFI_INDEX_SHIFT))
13901 * Certain chip functions need to be initialized only once per asic
13902 * instead of per-device. This function finds the peer device and
13903 * checks whether that chip initialization needs to be done by this
13906 static void asic_should_init(struct hfi1_devdata *dd)
13908 unsigned long flags;
13909 struct hfi1_devdata *tmp, *peer = NULL;
13911 spin_lock_irqsave(&hfi1_devs_lock, flags);
13912 /* Find our peer device */
13913 list_for_each_entry(tmp, &hfi1_dev_list, list) {
13914 if ((HFI_BASE_GUID(dd) == HFI_BASE_GUID(tmp)) &&
13915 dd->unit != tmp->unit) {
13922 * "Claim" the ASIC for initialization if it hasn't been
13925 if (!peer || !(peer->flags & HFI1_DO_INIT_ASIC))
13926 dd->flags |= HFI1_DO_INIT_ASIC;
13927 spin_unlock_irqrestore(&hfi1_devs_lock, flags);
13931 * Set dd->boardname. Use a generic name if a name is not returned from
13932 * EFI variable space.
13934 * Return 0 on success, -ENOMEM if space could not be allocated.
13936 static int obtain_boardname(struct hfi1_devdata *dd)
13938 /* generic board description */
13939 const char generic[] =
13940 "Intel Omni-Path Host Fabric Interface Adapter 100 Series";
13941 unsigned long size;
13944 ret = read_hfi1_efi_var(dd, "description", &size,
13945 (void **)&dd->boardname);
13947 dd_dev_info(dd, "Board description not found\n");
13948 /* use generic description */
13949 dd->boardname = kstrdup(generic, GFP_KERNEL);
13950 if (!dd->boardname)
13957 * Allocate and initialize the device structure for the hfi.
13958 * @dev: the pci_dev for hfi1_ib device
13959 * @ent: pci_device_id struct for this dev
13961 * Also allocates, initializes, and returns the devdata struct for this
13964 * This is global, and is called directly at init to set up the
13965 * chip-specific function pointers for later use.
13967 struct hfi1_devdata *hfi1_init_dd(struct pci_dev *pdev,
13968 const struct pci_device_id *ent)
13970 struct hfi1_devdata *dd;
13971 struct hfi1_pportdata *ppd;
13974 static const char * const inames[] = { /* implementation names */
13976 "RTL VCS simulation",
13977 "RTL FPGA emulation",
13978 "Functional simulator"
13981 dd = hfi1_alloc_devdata(pdev,
13982 NUM_IB_PORTS * sizeof(struct hfi1_pportdata));
13986 for (i = 0; i < dd->num_pports; i++, ppd++) {
13988 /* init common fields */
13989 hfi1_init_pportdata(pdev, ppd, dd, 0, 1);
13990 /* DC supports 4 link widths */
13991 ppd->link_width_supported =
13992 OPA_LINK_WIDTH_1X | OPA_LINK_WIDTH_2X |
13993 OPA_LINK_WIDTH_3X | OPA_LINK_WIDTH_4X;
13994 ppd->link_width_downgrade_supported =
13995 ppd->link_width_supported;
13996 /* start out enabling only 4X */
13997 ppd->link_width_enabled = OPA_LINK_WIDTH_4X;
13998 ppd->link_width_downgrade_enabled =
13999 ppd->link_width_downgrade_supported;
14000 /* link width active is 0 when link is down */
14001 /* link width downgrade active is 0 when link is down */
14003 if (num_vls < HFI1_MIN_VLS_SUPPORTED
14004 || num_vls > HFI1_MAX_VLS_SUPPORTED) {
14005 hfi1_early_err(&pdev->dev,
14006 "Invalid num_vls %u, using %u VLs\n",
14007 num_vls, HFI1_MAX_VLS_SUPPORTED);
14008 num_vls = HFI1_MAX_VLS_SUPPORTED;
14010 ppd->vls_supported = num_vls;
14011 ppd->vls_operational = ppd->vls_supported;
14012 ppd->actual_vls_operational = ppd->vls_supported;
14013 /* Set the default MTU. */
14014 for (vl = 0; vl < num_vls; vl++)
14015 dd->vld[vl].mtu = hfi1_max_mtu;
14016 dd->vld[15].mtu = MAX_MAD_PACKET;
14018 * Set the initial values to reasonable default, will be set
14019 * for real when link is up.
14021 ppd->lstate = IB_PORT_DOWN;
14022 ppd->overrun_threshold = 0x4;
14023 ppd->phy_error_threshold = 0xf;
14024 ppd->port_crc_mode_enabled = link_crc_mask;
14025 /* initialize supported LTP CRC mode */
14026 ppd->port_ltp_crc_mode = cap_to_port_ltp(link_crc_mask) << 8;
14027 /* initialize enabled LTP CRC mode */
14028 ppd->port_ltp_crc_mode |= cap_to_port_ltp(link_crc_mask) << 4;
14029 /* start in offline */
14030 ppd->host_link_state = HLS_DN_OFFLINE;
14031 init_vl_arb_caches(ppd);
14032 ppd->last_pstate = 0xff; /* invalid value */
14035 dd->link_default = HLS_DN_POLL;
14038 * Do remaining PCIe setup and save PCIe values in dd.
14039 * Any error printing is already done by the init code.
14040 * On return, we have the chip mapped.
14042 ret = hfi1_pcie_ddinit(dd, pdev, ent);
14046 /* verify that reads actually work, save revision for reset check */
14047 dd->revision = read_csr(dd, CCE_REVISION);
14048 if (dd->revision == ~(u64)0) {
14049 dd_dev_err(dd, "cannot read chip CSRs\n");
14053 dd->majrev = (dd->revision >> CCE_REVISION_CHIP_REV_MAJOR_SHIFT)
14054 & CCE_REVISION_CHIP_REV_MAJOR_MASK;
14055 dd->minrev = (dd->revision >> CCE_REVISION_CHIP_REV_MINOR_SHIFT)
14056 & CCE_REVISION_CHIP_REV_MINOR_MASK;
14058 /* obtain the hardware ID - NOT related to unit, which is a
14059 software enumeration */
14060 reg = read_csr(dd, CCE_REVISION2);
14061 dd->hfi1_id = (reg >> CCE_REVISION2_HFI_ID_SHIFT)
14062 & CCE_REVISION2_HFI_ID_MASK;
14063 /* the variable size will remove unwanted bits */
14064 dd->icode = reg >> CCE_REVISION2_IMPL_CODE_SHIFT;
14065 dd->irev = reg >> CCE_REVISION2_IMPL_REVISION_SHIFT;
14066 dd_dev_info(dd, "Implementation: %s, revision 0x%x\n",
14067 dd->icode < ARRAY_SIZE(inames) ? inames[dd->icode] : "unknown",
14070 /* speeds the hardware can support */
14071 dd->pport->link_speed_supported = OPA_LINK_SPEED_25G;
14072 /* speeds allowed to run at */
14073 dd->pport->link_speed_enabled = dd->pport->link_speed_supported;
14074 /* give a reasonable active value, will be set on link up */
14075 dd->pport->link_speed_active = OPA_LINK_SPEED_25G;
14077 dd->chip_rcv_contexts = read_csr(dd, RCV_CONTEXTS);
14078 dd->chip_send_contexts = read_csr(dd, SEND_CONTEXTS);
14079 dd->chip_sdma_engines = read_csr(dd, SEND_DMA_ENGINES);
14080 dd->chip_pio_mem_size = read_csr(dd, SEND_PIO_MEM_SIZE);
14081 dd->chip_sdma_mem_size = read_csr(dd, SEND_DMA_MEM_SIZE);
14082 /* fix up link widths for emulation _p */
14084 if (dd->icode == ICODE_FPGA_EMULATION && is_emulator_p(dd)) {
14085 ppd->link_width_supported =
14086 ppd->link_width_enabled =
14087 ppd->link_width_downgrade_supported =
14088 ppd->link_width_downgrade_enabled =
14091 /* insure num_vls isn't larger than number of sdma engines */
14092 if (HFI1_CAP_IS_KSET(SDMA) && num_vls > dd->chip_sdma_engines) {
14093 dd_dev_err(dd, "num_vls %u too large, using %u VLs\n",
14094 num_vls, dd->chip_sdma_engines);
14095 num_vls = dd->chip_sdma_engines;
14096 ppd->vls_supported = dd->chip_sdma_engines;
14097 ppd->vls_operational = ppd->vls_supported;
14101 * Convert the ns parameter to the 64 * cclocks used in the CSR.
14102 * Limit the max if larger than the field holds. If timeout is
14103 * non-zero, then the calculated field will be at least 1.
14105 * Must be after icode is set up - the cclock rate depends
14106 * on knowing the hardware being used.
14108 dd->rcv_intr_timeout_csr = ns_to_cclock(dd, rcv_intr_timeout) / 64;
14109 if (dd->rcv_intr_timeout_csr >
14110 RCV_AVAIL_TIME_OUT_TIME_OUT_RELOAD_MASK)
14111 dd->rcv_intr_timeout_csr =
14112 RCV_AVAIL_TIME_OUT_TIME_OUT_RELOAD_MASK;
14113 else if (dd->rcv_intr_timeout_csr == 0 && rcv_intr_timeout)
14114 dd->rcv_intr_timeout_csr = 1;
14116 /* needs to be done before we look for the peer device */
14119 /* should this device init the ASIC block? */
14120 asic_should_init(dd);
14122 /* obtain chip sizes, reset chip CSRs */
14125 /* read in the PCIe link speed information */
14126 ret = pcie_speeds(dd);
14130 /* Needs to be called before hfi1_firmware_init */
14131 get_platform_config(dd);
14133 /* read in firmware */
14134 ret = hfi1_firmware_init(dd);
14139 * In general, the PCIe Gen3 transition must occur after the
14140 * chip has been idled (so it won't initiate any PCIe transactions
14141 * e.g. an interrupt) and before the driver changes any registers
14142 * (the transition will reset the registers).
14144 * In particular, place this call after:
14145 * - init_chip() - the chip will not initiate any PCIe transactions
14146 * - pcie_speeds() - reads the current link speed
14147 * - hfi1_firmware_init() - the needed firmware is ready to be
14150 ret = do_pcie_gen3_transition(dd);
14154 /* start setting dd values and adjusting CSRs */
14155 init_early_variables(dd);
14157 parse_platform_config(dd);
14159 ret = obtain_boardname(dd);
14163 snprintf(dd->boardversion, BOARD_VERS_MAX,
14164 "ChipABI %u.%u, ChipRev %u.%u, SW Compat %llu\n",
14165 HFI1_CHIP_VERS_MAJ, HFI1_CHIP_VERS_MIN,
14168 (dd->revision >> CCE_REVISION_SW_SHIFT)
14169 & CCE_REVISION_SW_MASK);
14171 ret = set_up_context_variables(dd);
14175 /* set initial RXE CSRs */
14177 /* set initial TXE CSRs */
14179 /* set initial non-RXE, non-TXE CSRs */
14181 /* set up KDETH QP prefix in both RX and TX CSRs */
14184 ret = hfi1_dev_affinity_init(dd);
14188 /* send contexts must be set up before receive contexts */
14189 ret = init_send_contexts(dd);
14193 ret = hfi1_create_ctxts(dd);
14197 dd->rcvhdrsize = DEFAULT_RCVHDRSIZE;
14199 * rcd[0] is guaranteed to be valid by this point. Also, all
14200 * context are using the same value, as per the module parameter.
14202 dd->rhf_offset = dd->rcd[0]->rcvhdrqentsize - sizeof(u64) / sizeof(u32);
14204 ret = init_pervl_scs(dd);
14209 for (i = 0; i < dd->num_pports; ++i) {
14210 ret = sdma_init(dd, i);
14215 /* use contexts created by hfi1_create_ctxts */
14216 ret = set_up_interrupts(dd);
14220 /* set up LCB access - must be after set_up_interrupts() */
14221 init_lcb_access(dd);
14223 snprintf(dd->serial, SERIAL_MAX, "0x%08llx\n",
14224 dd->base_guid & 0xFFFFFF);
14226 dd->oui1 = dd->base_guid >> 56 & 0xFF;
14227 dd->oui2 = dd->base_guid >> 48 & 0xFF;
14228 dd->oui3 = dd->base_guid >> 40 & 0xFF;
14230 ret = load_firmware(dd); /* asymmetric with dispose_firmware() */
14232 goto bail_clear_intr;
14233 check_fabric_firmware_versions(dd);
14237 ret = init_cntrs(dd);
14239 goto bail_clear_intr;
14241 ret = init_rcverr(dd);
14243 goto bail_free_cntrs;
14245 ret = eprom_init(dd);
14247 goto bail_free_rcverr;
14256 clean_up_interrupts(dd);
14258 hfi1_pcie_ddcleanup(dd);
14260 hfi1_free_devdata(dd);
14266 static u16 delay_cycles(struct hfi1_pportdata *ppd, u32 desired_egress_rate,
14270 u32 current_egress_rate = ppd->current_egress_rate;
14271 /* rates here are in units of 10^6 bits/sec */
14273 if (desired_egress_rate == -1)
14274 return 0; /* shouldn't happen */
14276 if (desired_egress_rate >= current_egress_rate)
14277 return 0; /* we can't help go faster, only slower */
14279 delta_cycles = egress_cycles(dw_len * 4, desired_egress_rate) -
14280 egress_cycles(dw_len * 4, current_egress_rate);
14282 return (u16)delta_cycles;
14287 * create_pbc - build a pbc for transmission
14288 * @flags: special case flags or-ed in built pbc
14289 * @srate: static rate
14291 * @dwlen: dword length (header words + data words + pbc words)
14293 * Create a PBC with the given flags, rate, VL, and length.
14295 * NOTE: The PBC created will not insert any HCRC - all callers but one are
14296 * for verbs, which does not use this PSM feature. The lone other caller
14297 * is for the diagnostic interface which calls this if the user does not
14298 * supply their own PBC.
14300 u64 create_pbc(struct hfi1_pportdata *ppd, u64 flags, int srate_mbs, u32 vl,
14303 u64 pbc, delay = 0;
14305 if (unlikely(srate_mbs))
14306 delay = delay_cycles(ppd, srate_mbs, dw_len);
14309 | (delay << PBC_STATIC_RATE_CONTROL_COUNT_SHIFT)
14310 | ((u64)PBC_IHCRC_NONE << PBC_INSERT_HCRC_SHIFT)
14311 | (vl & PBC_VL_MASK) << PBC_VL_SHIFT
14312 | (dw_len & PBC_LENGTH_DWS_MASK)
14313 << PBC_LENGTH_DWS_SHIFT;
14318 #define SBUS_THERMAL 0x4f
14319 #define SBUS_THERM_MONITOR_MODE 0x1
14321 #define THERM_FAILURE(dev, ret, reason) \
14323 "Thermal sensor initialization failed: %s (%d)\n", \
14327 * Initialize the Avago Thermal sensor.
14329 * After initialization, enable polling of thermal sensor through
14330 * SBus interface. In order for this to work, the SBus Master
14331 * firmware has to be loaded due to the fact that the HW polling
14332 * logic uses SBus interrupts, which are not supported with
14333 * default firmware. Otherwise, no data will be returned through
14334 * the ASIC_STS_THERM CSR.
14336 static int thermal_init(struct hfi1_devdata *dd)
14340 if (dd->icode != ICODE_RTL_SILICON ||
14341 !(dd->flags & HFI1_DO_INIT_ASIC))
14344 acquire_hw_mutex(dd);
14345 dd_dev_info(dd, "Initializing thermal sensor\n");
14346 /* Disable polling of thermal readings */
14347 write_csr(dd, ASIC_CFG_THERM_POLL_EN, 0x0);
14349 /* Thermal Sensor Initialization */
14350 /* Step 1: Reset the Thermal SBus Receiver */
14351 ret = sbus_request_slow(dd, SBUS_THERMAL, 0x0,
14352 RESET_SBUS_RECEIVER, 0);
14354 THERM_FAILURE(dd, ret, "Bus Reset");
14357 /* Step 2: Set Reset bit in Thermal block */
14358 ret = sbus_request_slow(dd, SBUS_THERMAL, 0x0,
14359 WRITE_SBUS_RECEIVER, 0x1);
14361 THERM_FAILURE(dd, ret, "Therm Block Reset");
14364 /* Step 3: Write clock divider value (100MHz -> 2MHz) */
14365 ret = sbus_request_slow(dd, SBUS_THERMAL, 0x1,
14366 WRITE_SBUS_RECEIVER, 0x32);
14368 THERM_FAILURE(dd, ret, "Write Clock Div");
14371 /* Step 4: Select temperature mode */
14372 ret = sbus_request_slow(dd, SBUS_THERMAL, 0x3,
14373 WRITE_SBUS_RECEIVER,
14374 SBUS_THERM_MONITOR_MODE);
14376 THERM_FAILURE(dd, ret, "Write Mode Sel");
14379 /* Step 5: De-assert block reset and start conversion */
14380 ret = sbus_request_slow(dd, SBUS_THERMAL, 0x0,
14381 WRITE_SBUS_RECEIVER, 0x2);
14383 THERM_FAILURE(dd, ret, "Write Reset Deassert");
14386 /* Step 5.1: Wait for first conversion (21.5ms per spec) */
14389 /* Enable polling of thermal readings */
14390 write_csr(dd, ASIC_CFG_THERM_POLL_EN, 0x1);
14392 release_hw_mutex(dd);
14396 static void handle_temp_err(struct hfi1_devdata *dd)
14398 struct hfi1_pportdata *ppd = &dd->pport[0];
14400 * Thermal Critical Interrupt
14401 * Put the device into forced freeze mode, take link down to
14402 * offline, and put DC into reset.
14405 "Critical temperature reached! Forcing device into freeze mode!\n");
14406 dd->flags |= HFI1_FORCED_FREEZE;
14407 start_freeze_handling(ppd, FREEZE_SELF|FREEZE_ABORT);
14409 * Shut DC down as much and as quickly as possible.
14411 * Step 1: Take the link down to OFFLINE. This will cause the
14412 * 8051 to put the Serdes in reset. However, we don't want to
14413 * go through the entire link state machine since we want to
14414 * shutdown ASAP. Furthermore, this is not a graceful shutdown
14415 * but rather an attempt to save the chip.
14416 * Code below is almost the same as quiet_serdes() but avoids
14417 * all the extra work and the sleeps.
14419 ppd->driver_link_ready = 0;
14420 ppd->link_enabled = 0;
14421 set_physical_link_state(dd, PLS_OFFLINE |
14422 (OPA_LINKDOWN_REASON_SMA_DISABLED << 8));
14424 * Step 2: Shutdown LCB and 8051
14425 * After shutdown, do not restore DC_CFG_RESET value.