2 * Copyright(c) 2015, 2016 Intel Corporation.
4 * This file is provided under a dual BSD/GPLv2 license. When using or
5 * redistributing this file, you may do so under either license.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
20 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions
24 * - Redistributions of source code must retain the above copyright
25 * notice, this list of conditions and the following disclaimer.
26 * - Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in
28 * the documentation and/or other materials provided with the
30 * - Neither the name of Intel Corporation nor the names of its
31 * contributors may be used to endorse or promote products derived
32 * from this software without specific prior written permission.
34 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
35 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
36 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
37 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
38 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
39 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
40 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
41 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
42 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
43 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
44 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49 * This file contains all of the code that is specific to the HFI chip
52 #include <linux/pci.h>
53 #include <linux/delay.h>
54 #include <linux/interrupt.h>
55 #include <linux/module.h>
67 #define NUM_IB_PORTS 1
70 module_param_named(kdeth_qp, kdeth_qp, uint, S_IRUGO);
71 MODULE_PARM_DESC(kdeth_qp, "Set the KDETH queue pair prefix");
73 uint num_vls = HFI1_MAX_VLS_SUPPORTED;
74 module_param(num_vls, uint, S_IRUGO);
75 MODULE_PARM_DESC(num_vls, "Set number of Virtual Lanes to use (1-8)");
78 * Default time to aggregate two 10K packets from the idle state
79 * (timer not running). The timer starts at the end of the first packet,
80 * so only the time for one 10K packet and header plus a bit extra is needed.
81 * 10 * 1024 + 64 header byte = 10304 byte
82 * 10304 byte / 12.5 GB/s = 824.32ns
84 uint rcv_intr_timeout = (824 + 16); /* 16 is for coalescing interrupt */
85 module_param(rcv_intr_timeout, uint, S_IRUGO);
86 MODULE_PARM_DESC(rcv_intr_timeout, "Receive interrupt mitigation timeout in ns");
88 uint rcv_intr_count = 16; /* same as qib */
89 module_param(rcv_intr_count, uint, S_IRUGO);
90 MODULE_PARM_DESC(rcv_intr_count, "Receive interrupt mitigation count");
92 ushort link_crc_mask = SUPPORTED_CRCS;
93 module_param(link_crc_mask, ushort, S_IRUGO);
94 MODULE_PARM_DESC(link_crc_mask, "CRCs to use on the link");
97 module_param_named(loopback, loopback, uint, S_IRUGO);
98 MODULE_PARM_DESC(loopback, "Put into loopback mode (1 = serdes, 3 = external cable");
100 /* Other driver tunables */
101 uint rcv_intr_dynamic = 1; /* enable dynamic mode for rcv int mitigation*/
102 static ushort crc_14b_sideband = 1;
103 static uint use_flr = 1;
104 uint quick_linkup; /* skip LNI */
107 u64 flag; /* the flag */
108 char *str; /* description string */
109 u16 extra; /* extra information */
114 /* str must be a string constant */
115 #define FLAG_ENTRY(str, extra, flag) {flag, str, extra}
116 #define FLAG_ENTRY0(str, flag) {flag, str, 0}
118 /* Send Error Consequences */
119 #define SEC_WRITE_DROPPED 0x1
120 #define SEC_PACKET_DROPPED 0x2
121 #define SEC_SC_HALTED 0x4 /* per-context only */
122 #define SEC_SPC_FREEZE 0x8 /* per-HFI only */
124 #define MIN_KERNEL_KCTXTS 2
125 #define FIRST_KERNEL_KCTXT 1
126 /* sizes for both the QP and RSM map tables */
127 #define NUM_MAP_ENTRIES 256
128 #define NUM_MAP_REGS 32
130 /* Bit offset into the GUID which carries HFI id information */
131 #define GUID_HFI_INDEX_SHIFT 39
133 /* extract the emulation revision */
134 #define emulator_rev(dd) ((dd)->irev >> 8)
135 /* parallel and serial emulation versions are 3 and 4 respectively */
136 #define is_emulator_p(dd) ((((dd)->irev) & 0xf) == 3)
137 #define is_emulator_s(dd) ((((dd)->irev) & 0xf) == 4)
142 #define IB_PACKET_TYPE 2ull
143 #define QW_SHIFT 6ull
145 #define QPN_WIDTH 7ull
147 /* LRH.BTH: QW 0, OFFSET 48 - for match */
148 #define LRH_BTH_QW 0ull
149 #define LRH_BTH_BIT_OFFSET 48ull
150 #define LRH_BTH_OFFSET(off) ((LRH_BTH_QW << QW_SHIFT) | (off))
151 #define LRH_BTH_MATCH_OFFSET LRH_BTH_OFFSET(LRH_BTH_BIT_OFFSET)
152 #define LRH_BTH_SELECT
153 #define LRH_BTH_MASK 3ull
154 #define LRH_BTH_VALUE 2ull
156 /* LRH.SC[3..0] QW 0, OFFSET 56 - for match */
157 #define LRH_SC_QW 0ull
158 #define LRH_SC_BIT_OFFSET 56ull
159 #define LRH_SC_OFFSET(off) ((LRH_SC_QW << QW_SHIFT) | (off))
160 #define LRH_SC_MATCH_OFFSET LRH_SC_OFFSET(LRH_SC_BIT_OFFSET)
161 #define LRH_SC_MASK 128ull
162 #define LRH_SC_VALUE 0ull
164 /* SC[n..0] QW 0, OFFSET 60 - for select */
165 #define LRH_SC_SELECT_OFFSET ((LRH_SC_QW << QW_SHIFT) | (60ull))
167 /* QPN[m+n:1] QW 1, OFFSET 1 */
168 #define QPN_SELECT_OFFSET ((1ull << QW_SHIFT) | (1ull))
170 /* defines to build power on SC2VL table */
182 ((u64)(sc0val) << SEND_SC2VLT##num##_SC##sc0##_SHIFT) | \
183 ((u64)(sc1val) << SEND_SC2VLT##num##_SC##sc1##_SHIFT) | \
184 ((u64)(sc2val) << SEND_SC2VLT##num##_SC##sc2##_SHIFT) | \
185 ((u64)(sc3val) << SEND_SC2VLT##num##_SC##sc3##_SHIFT) | \
186 ((u64)(sc4val) << SEND_SC2VLT##num##_SC##sc4##_SHIFT) | \
187 ((u64)(sc5val) << SEND_SC2VLT##num##_SC##sc5##_SHIFT) | \
188 ((u64)(sc6val) << SEND_SC2VLT##num##_SC##sc6##_SHIFT) | \
189 ((u64)(sc7val) << SEND_SC2VLT##num##_SC##sc7##_SHIFT) \
192 #define DC_SC_VL_VAL( \
211 ((u64)(e0val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e0##_SHIFT) | \
212 ((u64)(e1val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e1##_SHIFT) | \
213 ((u64)(e2val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e2##_SHIFT) | \
214 ((u64)(e3val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e3##_SHIFT) | \
215 ((u64)(e4val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e4##_SHIFT) | \
216 ((u64)(e5val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e5##_SHIFT) | \
217 ((u64)(e6val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e6##_SHIFT) | \
218 ((u64)(e7val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e7##_SHIFT) | \
219 ((u64)(e8val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e8##_SHIFT) | \
220 ((u64)(e9val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e9##_SHIFT) | \
221 ((u64)(e10val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e10##_SHIFT) | \
222 ((u64)(e11val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e11##_SHIFT) | \
223 ((u64)(e12val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e12##_SHIFT) | \
224 ((u64)(e13val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e13##_SHIFT) | \
225 ((u64)(e14val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e14##_SHIFT) | \
226 ((u64)(e15val) << DCC_CFG_SC_VL_TABLE_##range##_ENTRY##e15##_SHIFT) \
229 /* all CceStatus sub-block freeze bits */
230 #define ALL_FROZE (CCE_STATUS_SDMA_FROZE_SMASK \
231 | CCE_STATUS_RXE_FROZE_SMASK \
232 | CCE_STATUS_TXE_FROZE_SMASK \
233 | CCE_STATUS_TXE_PIO_FROZE_SMASK)
234 /* all CceStatus sub-block TXE pause bits */
235 #define ALL_TXE_PAUSE (CCE_STATUS_TXE_PIO_PAUSED_SMASK \
236 | CCE_STATUS_TXE_PAUSED_SMASK \
237 | CCE_STATUS_SDMA_PAUSED_SMASK)
238 /* all CceStatus sub-block RXE pause bits */
239 #define ALL_RXE_PAUSE CCE_STATUS_RXE_PAUSED_SMASK
244 static struct flag_table cce_err_status_flags[] = {
245 /* 0*/ FLAG_ENTRY0("CceCsrParityErr",
246 CCE_ERR_STATUS_CCE_CSR_PARITY_ERR_SMASK),
247 /* 1*/ FLAG_ENTRY0("CceCsrReadBadAddrErr",
248 CCE_ERR_STATUS_CCE_CSR_READ_BAD_ADDR_ERR_SMASK),
249 /* 2*/ FLAG_ENTRY0("CceCsrWriteBadAddrErr",
250 CCE_ERR_STATUS_CCE_CSR_WRITE_BAD_ADDR_ERR_SMASK),
251 /* 3*/ FLAG_ENTRY0("CceTrgtAsyncFifoParityErr",
252 CCE_ERR_STATUS_CCE_TRGT_ASYNC_FIFO_PARITY_ERR_SMASK),
253 /* 4*/ FLAG_ENTRY0("CceTrgtAccessErr",
254 CCE_ERR_STATUS_CCE_TRGT_ACCESS_ERR_SMASK),
255 /* 5*/ FLAG_ENTRY0("CceRspdDataParityErr",
256 CCE_ERR_STATUS_CCE_RSPD_DATA_PARITY_ERR_SMASK),
257 /* 6*/ FLAG_ENTRY0("CceCli0AsyncFifoParityErr",
258 CCE_ERR_STATUS_CCE_CLI0_ASYNC_FIFO_PARITY_ERR_SMASK),
259 /* 7*/ FLAG_ENTRY0("CceCsrCfgBusParityErr",
260 CCE_ERR_STATUS_CCE_CSR_CFG_BUS_PARITY_ERR_SMASK),
261 /* 8*/ FLAG_ENTRY0("CceCli2AsyncFifoParityErr",
262 CCE_ERR_STATUS_CCE_CLI2_ASYNC_FIFO_PARITY_ERR_SMASK),
263 /* 9*/ FLAG_ENTRY0("CceCli1AsyncFifoPioCrdtParityErr",
264 CCE_ERR_STATUS_CCE_CLI1_ASYNC_FIFO_PIO_CRDT_PARITY_ERR_SMASK),
265 /*10*/ FLAG_ENTRY0("CceCli1AsyncFifoPioCrdtParityErr",
266 CCE_ERR_STATUS_CCE_CLI1_ASYNC_FIFO_SDMA_HD_PARITY_ERR_SMASK),
267 /*11*/ FLAG_ENTRY0("CceCli1AsyncFifoRxdmaParityError",
268 CCE_ERR_STATUS_CCE_CLI1_ASYNC_FIFO_RXDMA_PARITY_ERROR_SMASK),
269 /*12*/ FLAG_ENTRY0("CceCli1AsyncFifoDbgParityError",
270 CCE_ERR_STATUS_CCE_CLI1_ASYNC_FIFO_DBG_PARITY_ERROR_SMASK),
271 /*13*/ FLAG_ENTRY0("PcicRetryMemCorErr",
272 CCE_ERR_STATUS_PCIC_RETRY_MEM_COR_ERR_SMASK),
273 /*14*/ FLAG_ENTRY0("PcicRetryMemCorErr",
274 CCE_ERR_STATUS_PCIC_RETRY_SOT_MEM_COR_ERR_SMASK),
275 /*15*/ FLAG_ENTRY0("PcicPostHdQCorErr",
276 CCE_ERR_STATUS_PCIC_POST_HD_QCOR_ERR_SMASK),
277 /*16*/ FLAG_ENTRY0("PcicPostHdQCorErr",
278 CCE_ERR_STATUS_PCIC_POST_DAT_QCOR_ERR_SMASK),
279 /*17*/ FLAG_ENTRY0("PcicPostHdQCorErr",
280 CCE_ERR_STATUS_PCIC_CPL_HD_QCOR_ERR_SMASK),
281 /*18*/ FLAG_ENTRY0("PcicCplDatQCorErr",
282 CCE_ERR_STATUS_PCIC_CPL_DAT_QCOR_ERR_SMASK),
283 /*19*/ FLAG_ENTRY0("PcicNPostHQParityErr",
284 CCE_ERR_STATUS_PCIC_NPOST_HQ_PARITY_ERR_SMASK),
285 /*20*/ FLAG_ENTRY0("PcicNPostDatQParityErr",
286 CCE_ERR_STATUS_PCIC_NPOST_DAT_QPARITY_ERR_SMASK),
287 /*21*/ FLAG_ENTRY0("PcicRetryMemUncErr",
288 CCE_ERR_STATUS_PCIC_RETRY_MEM_UNC_ERR_SMASK),
289 /*22*/ FLAG_ENTRY0("PcicRetrySotMemUncErr",
290 CCE_ERR_STATUS_PCIC_RETRY_SOT_MEM_UNC_ERR_SMASK),
291 /*23*/ FLAG_ENTRY0("PcicPostHdQUncErr",
292 CCE_ERR_STATUS_PCIC_POST_HD_QUNC_ERR_SMASK),
293 /*24*/ FLAG_ENTRY0("PcicPostDatQUncErr",
294 CCE_ERR_STATUS_PCIC_POST_DAT_QUNC_ERR_SMASK),
295 /*25*/ FLAG_ENTRY0("PcicCplHdQUncErr",
296 CCE_ERR_STATUS_PCIC_CPL_HD_QUNC_ERR_SMASK),
297 /*26*/ FLAG_ENTRY0("PcicCplDatQUncErr",
298 CCE_ERR_STATUS_PCIC_CPL_DAT_QUNC_ERR_SMASK),
299 /*27*/ FLAG_ENTRY0("PcicTransmitFrontParityErr",
300 CCE_ERR_STATUS_PCIC_TRANSMIT_FRONT_PARITY_ERR_SMASK),
301 /*28*/ FLAG_ENTRY0("PcicTransmitBackParityErr",
302 CCE_ERR_STATUS_PCIC_TRANSMIT_BACK_PARITY_ERR_SMASK),
303 /*29*/ FLAG_ENTRY0("PcicReceiveParityErr",
304 CCE_ERR_STATUS_PCIC_RECEIVE_PARITY_ERR_SMASK),
305 /*30*/ FLAG_ENTRY0("CceTrgtCplTimeoutErr",
306 CCE_ERR_STATUS_CCE_TRGT_CPL_TIMEOUT_ERR_SMASK),
307 /*31*/ FLAG_ENTRY0("LATriggered",
308 CCE_ERR_STATUS_LA_TRIGGERED_SMASK),
309 /*32*/ FLAG_ENTRY0("CceSegReadBadAddrErr",
310 CCE_ERR_STATUS_CCE_SEG_READ_BAD_ADDR_ERR_SMASK),
311 /*33*/ FLAG_ENTRY0("CceSegWriteBadAddrErr",
312 CCE_ERR_STATUS_CCE_SEG_WRITE_BAD_ADDR_ERR_SMASK),
313 /*34*/ FLAG_ENTRY0("CceRcplAsyncFifoParityErr",
314 CCE_ERR_STATUS_CCE_RCPL_ASYNC_FIFO_PARITY_ERR_SMASK),
315 /*35*/ FLAG_ENTRY0("CceRxdmaConvFifoParityErr",
316 CCE_ERR_STATUS_CCE_RXDMA_CONV_FIFO_PARITY_ERR_SMASK),
317 /*36*/ FLAG_ENTRY0("CceMsixTableCorErr",
318 CCE_ERR_STATUS_CCE_MSIX_TABLE_COR_ERR_SMASK),
319 /*37*/ FLAG_ENTRY0("CceMsixTableUncErr",
320 CCE_ERR_STATUS_CCE_MSIX_TABLE_UNC_ERR_SMASK),
321 /*38*/ FLAG_ENTRY0("CceIntMapCorErr",
322 CCE_ERR_STATUS_CCE_INT_MAP_COR_ERR_SMASK),
323 /*39*/ FLAG_ENTRY0("CceIntMapUncErr",
324 CCE_ERR_STATUS_CCE_INT_MAP_UNC_ERR_SMASK),
325 /*40*/ FLAG_ENTRY0("CceMsixCsrParityErr",
326 CCE_ERR_STATUS_CCE_MSIX_CSR_PARITY_ERR_SMASK),
333 #define MES(text) MISC_ERR_STATUS_MISC_##text##_ERR_SMASK
334 static struct flag_table misc_err_status_flags[] = {
335 /* 0*/ FLAG_ENTRY0("CSR_PARITY", MES(CSR_PARITY)),
336 /* 1*/ FLAG_ENTRY0("CSR_READ_BAD_ADDR", MES(CSR_READ_BAD_ADDR)),
337 /* 2*/ FLAG_ENTRY0("CSR_WRITE_BAD_ADDR", MES(CSR_WRITE_BAD_ADDR)),
338 /* 3*/ FLAG_ENTRY0("SBUS_WRITE_FAILED", MES(SBUS_WRITE_FAILED)),
339 /* 4*/ FLAG_ENTRY0("KEY_MISMATCH", MES(KEY_MISMATCH)),
340 /* 5*/ FLAG_ENTRY0("FW_AUTH_FAILED", MES(FW_AUTH_FAILED)),
341 /* 6*/ FLAG_ENTRY0("EFUSE_CSR_PARITY", MES(EFUSE_CSR_PARITY)),
342 /* 7*/ FLAG_ENTRY0("EFUSE_READ_BAD_ADDR", MES(EFUSE_READ_BAD_ADDR)),
343 /* 8*/ FLAG_ENTRY0("EFUSE_WRITE", MES(EFUSE_WRITE)),
344 /* 9*/ FLAG_ENTRY0("EFUSE_DONE_PARITY", MES(EFUSE_DONE_PARITY)),
345 /*10*/ FLAG_ENTRY0("INVALID_EEP_CMD", MES(INVALID_EEP_CMD)),
346 /*11*/ FLAG_ENTRY0("MBIST_FAIL", MES(MBIST_FAIL)),
347 /*12*/ FLAG_ENTRY0("PLL_LOCK_FAIL", MES(PLL_LOCK_FAIL))
351 * TXE PIO Error flags and consequences
353 static struct flag_table pio_err_status_flags[] = {
354 /* 0*/ FLAG_ENTRY("PioWriteBadCtxt",
356 SEND_PIO_ERR_STATUS_PIO_WRITE_BAD_CTXT_ERR_SMASK),
357 /* 1*/ FLAG_ENTRY("PioWriteAddrParity",
359 SEND_PIO_ERR_STATUS_PIO_WRITE_ADDR_PARITY_ERR_SMASK),
360 /* 2*/ FLAG_ENTRY("PioCsrParity",
362 SEND_PIO_ERR_STATUS_PIO_CSR_PARITY_ERR_SMASK),
363 /* 3*/ FLAG_ENTRY("PioSbMemFifo0",
365 SEND_PIO_ERR_STATUS_PIO_SB_MEM_FIFO0_ERR_SMASK),
366 /* 4*/ FLAG_ENTRY("PioSbMemFifo1",
368 SEND_PIO_ERR_STATUS_PIO_SB_MEM_FIFO1_ERR_SMASK),
369 /* 5*/ FLAG_ENTRY("PioPccFifoParity",
371 SEND_PIO_ERR_STATUS_PIO_PCC_FIFO_PARITY_ERR_SMASK),
372 /* 6*/ FLAG_ENTRY("PioPecFifoParity",
374 SEND_PIO_ERR_STATUS_PIO_PEC_FIFO_PARITY_ERR_SMASK),
375 /* 7*/ FLAG_ENTRY("PioSbrdctlCrrelParity",
377 SEND_PIO_ERR_STATUS_PIO_SBRDCTL_CRREL_PARITY_ERR_SMASK),
378 /* 8*/ FLAG_ENTRY("PioSbrdctrlCrrelFifoParity",
380 SEND_PIO_ERR_STATUS_PIO_SBRDCTRL_CRREL_FIFO_PARITY_ERR_SMASK),
381 /* 9*/ FLAG_ENTRY("PioPktEvictFifoParityErr",
383 SEND_PIO_ERR_STATUS_PIO_PKT_EVICT_FIFO_PARITY_ERR_SMASK),
384 /*10*/ FLAG_ENTRY("PioSmPktResetParity",
386 SEND_PIO_ERR_STATUS_PIO_SM_PKT_RESET_PARITY_ERR_SMASK),
387 /*11*/ FLAG_ENTRY("PioVlLenMemBank0Unc",
389 SEND_PIO_ERR_STATUS_PIO_VL_LEN_MEM_BANK0_UNC_ERR_SMASK),
390 /*12*/ FLAG_ENTRY("PioVlLenMemBank1Unc",
392 SEND_PIO_ERR_STATUS_PIO_VL_LEN_MEM_BANK1_UNC_ERR_SMASK),
393 /*13*/ FLAG_ENTRY("PioVlLenMemBank0Cor",
395 SEND_PIO_ERR_STATUS_PIO_VL_LEN_MEM_BANK0_COR_ERR_SMASK),
396 /*14*/ FLAG_ENTRY("PioVlLenMemBank1Cor",
398 SEND_PIO_ERR_STATUS_PIO_VL_LEN_MEM_BANK1_COR_ERR_SMASK),
399 /*15*/ FLAG_ENTRY("PioCreditRetFifoParity",
401 SEND_PIO_ERR_STATUS_PIO_CREDIT_RET_FIFO_PARITY_ERR_SMASK),
402 /*16*/ FLAG_ENTRY("PioPpmcPblFifo",
404 SEND_PIO_ERR_STATUS_PIO_PPMC_PBL_FIFO_ERR_SMASK),
405 /*17*/ FLAG_ENTRY("PioInitSmIn",
407 SEND_PIO_ERR_STATUS_PIO_INIT_SM_IN_ERR_SMASK),
408 /*18*/ FLAG_ENTRY("PioPktEvictSmOrArbSm",
410 SEND_PIO_ERR_STATUS_PIO_PKT_EVICT_SM_OR_ARB_SM_ERR_SMASK),
411 /*19*/ FLAG_ENTRY("PioHostAddrMemUnc",
413 SEND_PIO_ERR_STATUS_PIO_HOST_ADDR_MEM_UNC_ERR_SMASK),
414 /*20*/ FLAG_ENTRY("PioHostAddrMemCor",
416 SEND_PIO_ERR_STATUS_PIO_HOST_ADDR_MEM_COR_ERR_SMASK),
417 /*21*/ FLAG_ENTRY("PioWriteDataParity",
419 SEND_PIO_ERR_STATUS_PIO_WRITE_DATA_PARITY_ERR_SMASK),
420 /*22*/ FLAG_ENTRY("PioStateMachine",
422 SEND_PIO_ERR_STATUS_PIO_STATE_MACHINE_ERR_SMASK),
423 /*23*/ FLAG_ENTRY("PioWriteQwValidParity",
424 SEC_WRITE_DROPPED | SEC_SPC_FREEZE,
425 SEND_PIO_ERR_STATUS_PIO_WRITE_QW_VALID_PARITY_ERR_SMASK),
426 /*24*/ FLAG_ENTRY("PioBlockQwCountParity",
427 SEC_WRITE_DROPPED | SEC_SPC_FREEZE,
428 SEND_PIO_ERR_STATUS_PIO_BLOCK_QW_COUNT_PARITY_ERR_SMASK),
429 /*25*/ FLAG_ENTRY("PioVlfVlLenParity",
431 SEND_PIO_ERR_STATUS_PIO_VLF_VL_LEN_PARITY_ERR_SMASK),
432 /*26*/ FLAG_ENTRY("PioVlfSopParity",
434 SEND_PIO_ERR_STATUS_PIO_VLF_SOP_PARITY_ERR_SMASK),
435 /*27*/ FLAG_ENTRY("PioVlFifoParity",
437 SEND_PIO_ERR_STATUS_PIO_VL_FIFO_PARITY_ERR_SMASK),
438 /*28*/ FLAG_ENTRY("PioPpmcBqcMemParity",
440 SEND_PIO_ERR_STATUS_PIO_PPMC_BQC_MEM_PARITY_ERR_SMASK),
441 /*29*/ FLAG_ENTRY("PioPpmcSopLen",
443 SEND_PIO_ERR_STATUS_PIO_PPMC_SOP_LEN_ERR_SMASK),
445 /*32*/ FLAG_ENTRY("PioCurrentFreeCntParity",
447 SEND_PIO_ERR_STATUS_PIO_CURRENT_FREE_CNT_PARITY_ERR_SMASK),
448 /*33*/ FLAG_ENTRY("PioLastReturnedCntParity",
450 SEND_PIO_ERR_STATUS_PIO_LAST_RETURNED_CNT_PARITY_ERR_SMASK),
451 /*34*/ FLAG_ENTRY("PioPccSopHeadParity",
453 SEND_PIO_ERR_STATUS_PIO_PCC_SOP_HEAD_PARITY_ERR_SMASK),
454 /*35*/ FLAG_ENTRY("PioPecSopHeadParityErr",
456 SEND_PIO_ERR_STATUS_PIO_PEC_SOP_HEAD_PARITY_ERR_SMASK),
460 /* TXE PIO errors that cause an SPC freeze */
461 #define ALL_PIO_FREEZE_ERR \
462 (SEND_PIO_ERR_STATUS_PIO_WRITE_ADDR_PARITY_ERR_SMASK \
463 | SEND_PIO_ERR_STATUS_PIO_CSR_PARITY_ERR_SMASK \
464 | SEND_PIO_ERR_STATUS_PIO_SB_MEM_FIFO0_ERR_SMASK \
465 | SEND_PIO_ERR_STATUS_PIO_SB_MEM_FIFO1_ERR_SMASK \
466 | SEND_PIO_ERR_STATUS_PIO_PCC_FIFO_PARITY_ERR_SMASK \
467 | SEND_PIO_ERR_STATUS_PIO_PEC_FIFO_PARITY_ERR_SMASK \
468 | SEND_PIO_ERR_STATUS_PIO_SBRDCTL_CRREL_PARITY_ERR_SMASK \
469 | SEND_PIO_ERR_STATUS_PIO_SBRDCTRL_CRREL_FIFO_PARITY_ERR_SMASK \
470 | SEND_PIO_ERR_STATUS_PIO_PKT_EVICT_FIFO_PARITY_ERR_SMASK \
471 | SEND_PIO_ERR_STATUS_PIO_SM_PKT_RESET_PARITY_ERR_SMASK \
472 | SEND_PIO_ERR_STATUS_PIO_VL_LEN_MEM_BANK0_UNC_ERR_SMASK \
473 | SEND_PIO_ERR_STATUS_PIO_VL_LEN_MEM_BANK1_UNC_ERR_SMASK \
474 | SEND_PIO_ERR_STATUS_PIO_CREDIT_RET_FIFO_PARITY_ERR_SMASK \
475 | SEND_PIO_ERR_STATUS_PIO_PPMC_PBL_FIFO_ERR_SMASK \
476 | SEND_PIO_ERR_STATUS_PIO_PKT_EVICT_SM_OR_ARB_SM_ERR_SMASK \
477 | SEND_PIO_ERR_STATUS_PIO_HOST_ADDR_MEM_UNC_ERR_SMASK \
478 | SEND_PIO_ERR_STATUS_PIO_WRITE_DATA_PARITY_ERR_SMASK \
479 | SEND_PIO_ERR_STATUS_PIO_STATE_MACHINE_ERR_SMASK \
480 | SEND_PIO_ERR_STATUS_PIO_WRITE_QW_VALID_PARITY_ERR_SMASK \
481 | SEND_PIO_ERR_STATUS_PIO_BLOCK_QW_COUNT_PARITY_ERR_SMASK \
482 | SEND_PIO_ERR_STATUS_PIO_VLF_VL_LEN_PARITY_ERR_SMASK \
483 | SEND_PIO_ERR_STATUS_PIO_VLF_SOP_PARITY_ERR_SMASK \
484 | SEND_PIO_ERR_STATUS_PIO_VL_FIFO_PARITY_ERR_SMASK \
485 | SEND_PIO_ERR_STATUS_PIO_PPMC_BQC_MEM_PARITY_ERR_SMASK \
486 | SEND_PIO_ERR_STATUS_PIO_PPMC_SOP_LEN_ERR_SMASK \
487 | SEND_PIO_ERR_STATUS_PIO_CURRENT_FREE_CNT_PARITY_ERR_SMASK \
488 | SEND_PIO_ERR_STATUS_PIO_LAST_RETURNED_CNT_PARITY_ERR_SMASK \
489 | SEND_PIO_ERR_STATUS_PIO_PCC_SOP_HEAD_PARITY_ERR_SMASK \
490 | SEND_PIO_ERR_STATUS_PIO_PEC_SOP_HEAD_PARITY_ERR_SMASK)
493 * TXE SDMA Error flags
495 static struct flag_table sdma_err_status_flags[] = {
496 /* 0*/ FLAG_ENTRY0("SDmaRpyTagErr",
497 SEND_DMA_ERR_STATUS_SDMA_RPY_TAG_ERR_SMASK),
498 /* 1*/ FLAG_ENTRY0("SDmaCsrParityErr",
499 SEND_DMA_ERR_STATUS_SDMA_CSR_PARITY_ERR_SMASK),
500 /* 2*/ FLAG_ENTRY0("SDmaPcieReqTrackingUncErr",
501 SEND_DMA_ERR_STATUS_SDMA_PCIE_REQ_TRACKING_UNC_ERR_SMASK),
502 /* 3*/ FLAG_ENTRY0("SDmaPcieReqTrackingCorErr",
503 SEND_DMA_ERR_STATUS_SDMA_PCIE_REQ_TRACKING_COR_ERR_SMASK),
507 /* TXE SDMA errors that cause an SPC freeze */
508 #define ALL_SDMA_FREEZE_ERR \
509 (SEND_DMA_ERR_STATUS_SDMA_RPY_TAG_ERR_SMASK \
510 | SEND_DMA_ERR_STATUS_SDMA_CSR_PARITY_ERR_SMASK \
511 | SEND_DMA_ERR_STATUS_SDMA_PCIE_REQ_TRACKING_UNC_ERR_SMASK)
513 /* SendEgressErrInfo bits that correspond to a PortXmitDiscard counter */
514 #define PORT_DISCARD_EGRESS_ERRS \
515 (SEND_EGRESS_ERR_INFO_TOO_LONG_IB_PACKET_ERR_SMASK \
516 | SEND_EGRESS_ERR_INFO_VL_MAPPING_ERR_SMASK \
517 | SEND_EGRESS_ERR_INFO_VL_ERR_SMASK)
520 * TXE Egress Error flags
522 #define SEES(text) SEND_EGRESS_ERR_STATUS_##text##_ERR_SMASK
523 static struct flag_table egress_err_status_flags[] = {
524 /* 0*/ FLAG_ENTRY0("TxPktIntegrityMemCorErr", SEES(TX_PKT_INTEGRITY_MEM_COR)),
525 /* 1*/ FLAG_ENTRY0("TxPktIntegrityMemUncErr", SEES(TX_PKT_INTEGRITY_MEM_UNC)),
527 /* 3*/ FLAG_ENTRY0("TxEgressFifoUnderrunOrParityErr",
528 SEES(TX_EGRESS_FIFO_UNDERRUN_OR_PARITY)),
529 /* 4*/ FLAG_ENTRY0("TxLinkdownErr", SEES(TX_LINKDOWN)),
530 /* 5*/ FLAG_ENTRY0("TxIncorrectLinkStateErr", SEES(TX_INCORRECT_LINK_STATE)),
532 /* 7*/ FLAG_ENTRY0("TxPioLaunchIntfParityErr",
533 SEES(TX_PIO_LAUNCH_INTF_PARITY)),
534 /* 8*/ FLAG_ENTRY0("TxSdmaLaunchIntfParityErr",
535 SEES(TX_SDMA_LAUNCH_INTF_PARITY)),
537 /*11*/ FLAG_ENTRY0("TxSbrdCtlStateMachineParityErr",
538 SEES(TX_SBRD_CTL_STATE_MACHINE_PARITY)),
539 /*12*/ FLAG_ENTRY0("TxIllegalVLErr", SEES(TX_ILLEGAL_VL)),
540 /*13*/ FLAG_ENTRY0("TxLaunchCsrParityErr", SEES(TX_LAUNCH_CSR_PARITY)),
541 /*14*/ FLAG_ENTRY0("TxSbrdCtlCsrParityErr", SEES(TX_SBRD_CTL_CSR_PARITY)),
542 /*15*/ FLAG_ENTRY0("TxConfigParityErr", SEES(TX_CONFIG_PARITY)),
543 /*16*/ FLAG_ENTRY0("TxSdma0DisallowedPacketErr",
544 SEES(TX_SDMA0_DISALLOWED_PACKET)),
545 /*17*/ FLAG_ENTRY0("TxSdma1DisallowedPacketErr",
546 SEES(TX_SDMA1_DISALLOWED_PACKET)),
547 /*18*/ FLAG_ENTRY0("TxSdma2DisallowedPacketErr",
548 SEES(TX_SDMA2_DISALLOWED_PACKET)),
549 /*19*/ FLAG_ENTRY0("TxSdma3DisallowedPacketErr",
550 SEES(TX_SDMA3_DISALLOWED_PACKET)),
551 /*20*/ FLAG_ENTRY0("TxSdma4DisallowedPacketErr",
552 SEES(TX_SDMA4_DISALLOWED_PACKET)),
553 /*21*/ FLAG_ENTRY0("TxSdma5DisallowedPacketErr",
554 SEES(TX_SDMA5_DISALLOWED_PACKET)),
555 /*22*/ FLAG_ENTRY0("TxSdma6DisallowedPacketErr",
556 SEES(TX_SDMA6_DISALLOWED_PACKET)),
557 /*23*/ FLAG_ENTRY0("TxSdma7DisallowedPacketErr",
558 SEES(TX_SDMA7_DISALLOWED_PACKET)),
559 /*24*/ FLAG_ENTRY0("TxSdma8DisallowedPacketErr",
560 SEES(TX_SDMA8_DISALLOWED_PACKET)),
561 /*25*/ FLAG_ENTRY0("TxSdma9DisallowedPacketErr",
562 SEES(TX_SDMA9_DISALLOWED_PACKET)),
563 /*26*/ FLAG_ENTRY0("TxSdma10DisallowedPacketErr",
564 SEES(TX_SDMA10_DISALLOWED_PACKET)),
565 /*27*/ FLAG_ENTRY0("TxSdma11DisallowedPacketErr",
566 SEES(TX_SDMA11_DISALLOWED_PACKET)),
567 /*28*/ FLAG_ENTRY0("TxSdma12DisallowedPacketErr",
568 SEES(TX_SDMA12_DISALLOWED_PACKET)),
569 /*29*/ FLAG_ENTRY0("TxSdma13DisallowedPacketErr",
570 SEES(TX_SDMA13_DISALLOWED_PACKET)),
571 /*30*/ FLAG_ENTRY0("TxSdma14DisallowedPacketErr",
572 SEES(TX_SDMA14_DISALLOWED_PACKET)),
573 /*31*/ FLAG_ENTRY0("TxSdma15DisallowedPacketErr",
574 SEES(TX_SDMA15_DISALLOWED_PACKET)),
575 /*32*/ FLAG_ENTRY0("TxLaunchFifo0UncOrParityErr",
576 SEES(TX_LAUNCH_FIFO0_UNC_OR_PARITY)),
577 /*33*/ FLAG_ENTRY0("TxLaunchFifo1UncOrParityErr",
578 SEES(TX_LAUNCH_FIFO1_UNC_OR_PARITY)),
579 /*34*/ FLAG_ENTRY0("TxLaunchFifo2UncOrParityErr",
580 SEES(TX_LAUNCH_FIFO2_UNC_OR_PARITY)),
581 /*35*/ FLAG_ENTRY0("TxLaunchFifo3UncOrParityErr",
582 SEES(TX_LAUNCH_FIFO3_UNC_OR_PARITY)),
583 /*36*/ FLAG_ENTRY0("TxLaunchFifo4UncOrParityErr",
584 SEES(TX_LAUNCH_FIFO4_UNC_OR_PARITY)),
585 /*37*/ FLAG_ENTRY0("TxLaunchFifo5UncOrParityErr",
586 SEES(TX_LAUNCH_FIFO5_UNC_OR_PARITY)),
587 /*38*/ FLAG_ENTRY0("TxLaunchFifo6UncOrParityErr",
588 SEES(TX_LAUNCH_FIFO6_UNC_OR_PARITY)),
589 /*39*/ FLAG_ENTRY0("TxLaunchFifo7UncOrParityErr",
590 SEES(TX_LAUNCH_FIFO7_UNC_OR_PARITY)),
591 /*40*/ FLAG_ENTRY0("TxLaunchFifo8UncOrParityErr",
592 SEES(TX_LAUNCH_FIFO8_UNC_OR_PARITY)),
593 /*41*/ FLAG_ENTRY0("TxCreditReturnParityErr", SEES(TX_CREDIT_RETURN_PARITY)),
594 /*42*/ FLAG_ENTRY0("TxSbHdrUncErr", SEES(TX_SB_HDR_UNC)),
595 /*43*/ FLAG_ENTRY0("TxReadSdmaMemoryUncErr", SEES(TX_READ_SDMA_MEMORY_UNC)),
596 /*44*/ FLAG_ENTRY0("TxReadPioMemoryUncErr", SEES(TX_READ_PIO_MEMORY_UNC)),
597 /*45*/ FLAG_ENTRY0("TxEgressFifoUncErr", SEES(TX_EGRESS_FIFO_UNC)),
598 /*46*/ FLAG_ENTRY0("TxHcrcInsertionErr", SEES(TX_HCRC_INSERTION)),
599 /*47*/ FLAG_ENTRY0("TxCreditReturnVLErr", SEES(TX_CREDIT_RETURN_VL)),
600 /*48*/ FLAG_ENTRY0("TxLaunchFifo0CorErr", SEES(TX_LAUNCH_FIFO0_COR)),
601 /*49*/ FLAG_ENTRY0("TxLaunchFifo1CorErr", SEES(TX_LAUNCH_FIFO1_COR)),
602 /*50*/ FLAG_ENTRY0("TxLaunchFifo2CorErr", SEES(TX_LAUNCH_FIFO2_COR)),
603 /*51*/ FLAG_ENTRY0("TxLaunchFifo3CorErr", SEES(TX_LAUNCH_FIFO3_COR)),
604 /*52*/ FLAG_ENTRY0("TxLaunchFifo4CorErr", SEES(TX_LAUNCH_FIFO4_COR)),
605 /*53*/ FLAG_ENTRY0("TxLaunchFifo5CorErr", SEES(TX_LAUNCH_FIFO5_COR)),
606 /*54*/ FLAG_ENTRY0("TxLaunchFifo6CorErr", SEES(TX_LAUNCH_FIFO6_COR)),
607 /*55*/ FLAG_ENTRY0("TxLaunchFifo7CorErr", SEES(TX_LAUNCH_FIFO7_COR)),
608 /*56*/ FLAG_ENTRY0("TxLaunchFifo8CorErr", SEES(TX_LAUNCH_FIFO8_COR)),
609 /*57*/ FLAG_ENTRY0("TxCreditOverrunErr", SEES(TX_CREDIT_OVERRUN)),
610 /*58*/ FLAG_ENTRY0("TxSbHdrCorErr", SEES(TX_SB_HDR_COR)),
611 /*59*/ FLAG_ENTRY0("TxReadSdmaMemoryCorErr", SEES(TX_READ_SDMA_MEMORY_COR)),
612 /*60*/ FLAG_ENTRY0("TxReadPioMemoryCorErr", SEES(TX_READ_PIO_MEMORY_COR)),
613 /*61*/ FLAG_ENTRY0("TxEgressFifoCorErr", SEES(TX_EGRESS_FIFO_COR)),
614 /*62*/ FLAG_ENTRY0("TxReadSdmaMemoryCsrUncErr",
615 SEES(TX_READ_SDMA_MEMORY_CSR_UNC)),
616 /*63*/ FLAG_ENTRY0("TxReadPioMemoryCsrUncErr",
617 SEES(TX_READ_PIO_MEMORY_CSR_UNC)),
621 * TXE Egress Error Info flags
623 #define SEEI(text) SEND_EGRESS_ERR_INFO_##text##_ERR_SMASK
624 static struct flag_table egress_err_info_flags[] = {
625 /* 0*/ FLAG_ENTRY0("Reserved", 0ull),
626 /* 1*/ FLAG_ENTRY0("VLErr", SEEI(VL)),
627 /* 2*/ FLAG_ENTRY0("JobKeyErr", SEEI(JOB_KEY)),
628 /* 3*/ FLAG_ENTRY0("JobKeyErr", SEEI(JOB_KEY)),
629 /* 4*/ FLAG_ENTRY0("PartitionKeyErr", SEEI(PARTITION_KEY)),
630 /* 5*/ FLAG_ENTRY0("SLIDErr", SEEI(SLID)),
631 /* 6*/ FLAG_ENTRY0("OpcodeErr", SEEI(OPCODE)),
632 /* 7*/ FLAG_ENTRY0("VLMappingErr", SEEI(VL_MAPPING)),
633 /* 8*/ FLAG_ENTRY0("RawErr", SEEI(RAW)),
634 /* 9*/ FLAG_ENTRY0("RawIPv6Err", SEEI(RAW_IPV6)),
635 /*10*/ FLAG_ENTRY0("GRHErr", SEEI(GRH)),
636 /*11*/ FLAG_ENTRY0("BypassErr", SEEI(BYPASS)),
637 /*12*/ FLAG_ENTRY0("KDETHPacketsErr", SEEI(KDETH_PACKETS)),
638 /*13*/ FLAG_ENTRY0("NonKDETHPacketsErr", SEEI(NON_KDETH_PACKETS)),
639 /*14*/ FLAG_ENTRY0("TooSmallIBPacketsErr", SEEI(TOO_SMALL_IB_PACKETS)),
640 /*15*/ FLAG_ENTRY0("TooSmallBypassPacketsErr", SEEI(TOO_SMALL_BYPASS_PACKETS)),
641 /*16*/ FLAG_ENTRY0("PbcTestErr", SEEI(PBC_TEST)),
642 /*17*/ FLAG_ENTRY0("BadPktLenErr", SEEI(BAD_PKT_LEN)),
643 /*18*/ FLAG_ENTRY0("TooLongIBPacketErr", SEEI(TOO_LONG_IB_PACKET)),
644 /*19*/ FLAG_ENTRY0("TooLongBypassPacketsErr", SEEI(TOO_LONG_BYPASS_PACKETS)),
645 /*20*/ FLAG_ENTRY0("PbcStaticRateControlErr", SEEI(PBC_STATIC_RATE_CONTROL)),
646 /*21*/ FLAG_ENTRY0("BypassBadPktLenErr", SEEI(BAD_PKT_LEN)),
649 /* TXE Egress errors that cause an SPC freeze */
650 #define ALL_TXE_EGRESS_FREEZE_ERR \
651 (SEES(TX_EGRESS_FIFO_UNDERRUN_OR_PARITY) \
652 | SEES(TX_PIO_LAUNCH_INTF_PARITY) \
653 | SEES(TX_SDMA_LAUNCH_INTF_PARITY) \
654 | SEES(TX_SBRD_CTL_STATE_MACHINE_PARITY) \
655 | SEES(TX_LAUNCH_CSR_PARITY) \
656 | SEES(TX_SBRD_CTL_CSR_PARITY) \
657 | SEES(TX_CONFIG_PARITY) \
658 | SEES(TX_LAUNCH_FIFO0_UNC_OR_PARITY) \
659 | SEES(TX_LAUNCH_FIFO1_UNC_OR_PARITY) \
660 | SEES(TX_LAUNCH_FIFO2_UNC_OR_PARITY) \
661 | SEES(TX_LAUNCH_FIFO3_UNC_OR_PARITY) \
662 | SEES(TX_LAUNCH_FIFO4_UNC_OR_PARITY) \
663 | SEES(TX_LAUNCH_FIFO5_UNC_OR_PARITY) \
664 | SEES(TX_LAUNCH_FIFO6_UNC_OR_PARITY) \
665 | SEES(TX_LAUNCH_FIFO7_UNC_OR_PARITY) \
666 | SEES(TX_LAUNCH_FIFO8_UNC_OR_PARITY) \
667 | SEES(TX_CREDIT_RETURN_PARITY))
670 * TXE Send error flags
672 #define SES(name) SEND_ERR_STATUS_SEND_##name##_ERR_SMASK
673 static struct flag_table send_err_status_flags[] = {
674 /* 0*/ FLAG_ENTRY0("SendCsrParityErr", SES(CSR_PARITY)),
675 /* 1*/ FLAG_ENTRY0("SendCsrReadBadAddrErr", SES(CSR_READ_BAD_ADDR)),
676 /* 2*/ FLAG_ENTRY0("SendCsrWriteBadAddrErr", SES(CSR_WRITE_BAD_ADDR))
680 * TXE Send Context Error flags and consequences
682 static struct flag_table sc_err_status_flags[] = {
683 /* 0*/ FLAG_ENTRY("InconsistentSop",
684 SEC_PACKET_DROPPED | SEC_SC_HALTED,
685 SEND_CTXT_ERR_STATUS_PIO_INCONSISTENT_SOP_ERR_SMASK),
686 /* 1*/ FLAG_ENTRY("DisallowedPacket",
687 SEC_PACKET_DROPPED | SEC_SC_HALTED,
688 SEND_CTXT_ERR_STATUS_PIO_DISALLOWED_PACKET_ERR_SMASK),
689 /* 2*/ FLAG_ENTRY("WriteCrossesBoundary",
690 SEC_WRITE_DROPPED | SEC_SC_HALTED,
691 SEND_CTXT_ERR_STATUS_PIO_WRITE_CROSSES_BOUNDARY_ERR_SMASK),
692 /* 3*/ FLAG_ENTRY("WriteOverflow",
693 SEC_WRITE_DROPPED | SEC_SC_HALTED,
694 SEND_CTXT_ERR_STATUS_PIO_WRITE_OVERFLOW_ERR_SMASK),
695 /* 4*/ FLAG_ENTRY("WriteOutOfBounds",
696 SEC_WRITE_DROPPED | SEC_SC_HALTED,
697 SEND_CTXT_ERR_STATUS_PIO_WRITE_OUT_OF_BOUNDS_ERR_SMASK),
702 * RXE Receive Error flags
704 #define RXES(name) RCV_ERR_STATUS_RX_##name##_ERR_SMASK
705 static struct flag_table rxe_err_status_flags[] = {
706 /* 0*/ FLAG_ENTRY0("RxDmaCsrCorErr", RXES(DMA_CSR_COR)),
707 /* 1*/ FLAG_ENTRY0("RxDcIntfParityErr", RXES(DC_INTF_PARITY)),
708 /* 2*/ FLAG_ENTRY0("RxRcvHdrUncErr", RXES(RCV_HDR_UNC)),
709 /* 3*/ FLAG_ENTRY0("RxRcvHdrCorErr", RXES(RCV_HDR_COR)),
710 /* 4*/ FLAG_ENTRY0("RxRcvDataUncErr", RXES(RCV_DATA_UNC)),
711 /* 5*/ FLAG_ENTRY0("RxRcvDataCorErr", RXES(RCV_DATA_COR)),
712 /* 6*/ FLAG_ENTRY0("RxRcvQpMapTableUncErr", RXES(RCV_QP_MAP_TABLE_UNC)),
713 /* 7*/ FLAG_ENTRY0("RxRcvQpMapTableCorErr", RXES(RCV_QP_MAP_TABLE_COR)),
714 /* 8*/ FLAG_ENTRY0("RxRcvCsrParityErr", RXES(RCV_CSR_PARITY)),
715 /* 9*/ FLAG_ENTRY0("RxDcSopEopParityErr", RXES(DC_SOP_EOP_PARITY)),
716 /*10*/ FLAG_ENTRY0("RxDmaFlagUncErr", RXES(DMA_FLAG_UNC)),
717 /*11*/ FLAG_ENTRY0("RxDmaFlagCorErr", RXES(DMA_FLAG_COR)),
718 /*12*/ FLAG_ENTRY0("RxRcvFsmEncodingErr", RXES(RCV_FSM_ENCODING)),
719 /*13*/ FLAG_ENTRY0("RxRbufFreeListUncErr", RXES(RBUF_FREE_LIST_UNC)),
720 /*14*/ FLAG_ENTRY0("RxRbufFreeListCorErr", RXES(RBUF_FREE_LIST_COR)),
721 /*15*/ FLAG_ENTRY0("RxRbufLookupDesRegUncErr", RXES(RBUF_LOOKUP_DES_REG_UNC)),
722 /*16*/ FLAG_ENTRY0("RxRbufLookupDesRegUncCorErr",
723 RXES(RBUF_LOOKUP_DES_REG_UNC_COR)),
724 /*17*/ FLAG_ENTRY0("RxRbufLookupDesUncErr", RXES(RBUF_LOOKUP_DES_UNC)),
725 /*18*/ FLAG_ENTRY0("RxRbufLookupDesCorErr", RXES(RBUF_LOOKUP_DES_COR)),
726 /*19*/ FLAG_ENTRY0("RxRbufBlockListReadUncErr",
727 RXES(RBUF_BLOCK_LIST_READ_UNC)),
728 /*20*/ FLAG_ENTRY0("RxRbufBlockListReadCorErr",
729 RXES(RBUF_BLOCK_LIST_READ_COR)),
730 /*21*/ FLAG_ENTRY0("RxRbufCsrQHeadBufNumParityErr",
731 RXES(RBUF_CSR_QHEAD_BUF_NUM_PARITY)),
732 /*22*/ FLAG_ENTRY0("RxRbufCsrQEntCntParityErr",
733 RXES(RBUF_CSR_QENT_CNT_PARITY)),
734 /*23*/ FLAG_ENTRY0("RxRbufCsrQNextBufParityErr",
735 RXES(RBUF_CSR_QNEXT_BUF_PARITY)),
736 /*24*/ FLAG_ENTRY0("RxRbufCsrQVldBitParityErr",
737 RXES(RBUF_CSR_QVLD_BIT_PARITY)),
738 /*25*/ FLAG_ENTRY0("RxRbufCsrQHdPtrParityErr", RXES(RBUF_CSR_QHD_PTR_PARITY)),
739 /*26*/ FLAG_ENTRY0("RxRbufCsrQTlPtrParityErr", RXES(RBUF_CSR_QTL_PTR_PARITY)),
740 /*27*/ FLAG_ENTRY0("RxRbufCsrQNumOfPktParityErr",
741 RXES(RBUF_CSR_QNUM_OF_PKT_PARITY)),
742 /*28*/ FLAG_ENTRY0("RxRbufCsrQEOPDWParityErr", RXES(RBUF_CSR_QEOPDW_PARITY)),
743 /*29*/ FLAG_ENTRY0("RxRbufCtxIdParityErr", RXES(RBUF_CTX_ID_PARITY)),
744 /*30*/ FLAG_ENTRY0("RxRBufBadLookupErr", RXES(RBUF_BAD_LOOKUP)),
745 /*31*/ FLAG_ENTRY0("RxRbufFullErr", RXES(RBUF_FULL)),
746 /*32*/ FLAG_ENTRY0("RxRbufEmptyErr", RXES(RBUF_EMPTY)),
747 /*33*/ FLAG_ENTRY0("RxRbufFlRdAddrParityErr", RXES(RBUF_FL_RD_ADDR_PARITY)),
748 /*34*/ FLAG_ENTRY0("RxRbufFlWrAddrParityErr", RXES(RBUF_FL_WR_ADDR_PARITY)),
749 /*35*/ FLAG_ENTRY0("RxRbufFlInitdoneParityErr",
750 RXES(RBUF_FL_INITDONE_PARITY)),
751 /*36*/ FLAG_ENTRY0("RxRbufFlInitWrAddrParityErr",
752 RXES(RBUF_FL_INIT_WR_ADDR_PARITY)),
753 /*37*/ FLAG_ENTRY0("RxRbufNextFreeBufUncErr", RXES(RBUF_NEXT_FREE_BUF_UNC)),
754 /*38*/ FLAG_ENTRY0("RxRbufNextFreeBufCorErr", RXES(RBUF_NEXT_FREE_BUF_COR)),
755 /*39*/ FLAG_ENTRY0("RxLookupDesPart1UncErr", RXES(LOOKUP_DES_PART1_UNC)),
756 /*40*/ FLAG_ENTRY0("RxLookupDesPart1UncCorErr",
757 RXES(LOOKUP_DES_PART1_UNC_COR)),
758 /*41*/ FLAG_ENTRY0("RxLookupDesPart2ParityErr",
759 RXES(LOOKUP_DES_PART2_PARITY)),
760 /*42*/ FLAG_ENTRY0("RxLookupRcvArrayUncErr", RXES(LOOKUP_RCV_ARRAY_UNC)),
761 /*43*/ FLAG_ENTRY0("RxLookupRcvArrayCorErr", RXES(LOOKUP_RCV_ARRAY_COR)),
762 /*44*/ FLAG_ENTRY0("RxLookupCsrParityErr", RXES(LOOKUP_CSR_PARITY)),
763 /*45*/ FLAG_ENTRY0("RxHqIntrCsrParityErr", RXES(HQ_INTR_CSR_PARITY)),
764 /*46*/ FLAG_ENTRY0("RxHqIntrFsmErr", RXES(HQ_INTR_FSM)),
765 /*47*/ FLAG_ENTRY0("RxRbufDescPart1UncErr", RXES(RBUF_DESC_PART1_UNC)),
766 /*48*/ FLAG_ENTRY0("RxRbufDescPart1CorErr", RXES(RBUF_DESC_PART1_COR)),
767 /*49*/ FLAG_ENTRY0("RxRbufDescPart2UncErr", RXES(RBUF_DESC_PART2_UNC)),
768 /*50*/ FLAG_ENTRY0("RxRbufDescPart2CorErr", RXES(RBUF_DESC_PART2_COR)),
769 /*51*/ FLAG_ENTRY0("RxDmaHdrFifoRdUncErr", RXES(DMA_HDR_FIFO_RD_UNC)),
770 /*52*/ FLAG_ENTRY0("RxDmaHdrFifoRdCorErr", RXES(DMA_HDR_FIFO_RD_COR)),
771 /*53*/ FLAG_ENTRY0("RxDmaDataFifoRdUncErr", RXES(DMA_DATA_FIFO_RD_UNC)),
772 /*54*/ FLAG_ENTRY0("RxDmaDataFifoRdCorErr", RXES(DMA_DATA_FIFO_RD_COR)),
773 /*55*/ FLAG_ENTRY0("RxRbufDataUncErr", RXES(RBUF_DATA_UNC)),
774 /*56*/ FLAG_ENTRY0("RxRbufDataCorErr", RXES(RBUF_DATA_COR)),
775 /*57*/ FLAG_ENTRY0("RxDmaCsrParityErr", RXES(DMA_CSR_PARITY)),
776 /*58*/ FLAG_ENTRY0("RxDmaEqFsmEncodingErr", RXES(DMA_EQ_FSM_ENCODING)),
777 /*59*/ FLAG_ENTRY0("RxDmaDqFsmEncodingErr", RXES(DMA_DQ_FSM_ENCODING)),
778 /*60*/ FLAG_ENTRY0("RxDmaCsrUncErr", RXES(DMA_CSR_UNC)),
779 /*61*/ FLAG_ENTRY0("RxCsrReadBadAddrErr", RXES(CSR_READ_BAD_ADDR)),
780 /*62*/ FLAG_ENTRY0("RxCsrWriteBadAddrErr", RXES(CSR_WRITE_BAD_ADDR)),
781 /*63*/ FLAG_ENTRY0("RxCsrParityErr", RXES(CSR_PARITY))
784 /* RXE errors that will trigger an SPC freeze */
785 #define ALL_RXE_FREEZE_ERR \
786 (RCV_ERR_STATUS_RX_RCV_QP_MAP_TABLE_UNC_ERR_SMASK \
787 | RCV_ERR_STATUS_RX_RCV_CSR_PARITY_ERR_SMASK \
788 | RCV_ERR_STATUS_RX_DMA_FLAG_UNC_ERR_SMASK \
789 | RCV_ERR_STATUS_RX_RCV_FSM_ENCODING_ERR_SMASK \
790 | RCV_ERR_STATUS_RX_RBUF_FREE_LIST_UNC_ERR_SMASK \
791 | RCV_ERR_STATUS_RX_RBUF_LOOKUP_DES_REG_UNC_ERR_SMASK \
792 | RCV_ERR_STATUS_RX_RBUF_LOOKUP_DES_REG_UNC_COR_ERR_SMASK \
793 | RCV_ERR_STATUS_RX_RBUF_LOOKUP_DES_UNC_ERR_SMASK \
794 | RCV_ERR_STATUS_RX_RBUF_BLOCK_LIST_READ_UNC_ERR_SMASK \
795 | RCV_ERR_STATUS_RX_RBUF_CSR_QHEAD_BUF_NUM_PARITY_ERR_SMASK \
796 | RCV_ERR_STATUS_RX_RBUF_CSR_QENT_CNT_PARITY_ERR_SMASK \
797 | RCV_ERR_STATUS_RX_RBUF_CSR_QNEXT_BUF_PARITY_ERR_SMASK \
798 | RCV_ERR_STATUS_RX_RBUF_CSR_QVLD_BIT_PARITY_ERR_SMASK \
799 | RCV_ERR_STATUS_RX_RBUF_CSR_QHD_PTR_PARITY_ERR_SMASK \
800 | RCV_ERR_STATUS_RX_RBUF_CSR_QTL_PTR_PARITY_ERR_SMASK \
801 | RCV_ERR_STATUS_RX_RBUF_CSR_QNUM_OF_PKT_PARITY_ERR_SMASK \
802 | RCV_ERR_STATUS_RX_RBUF_CSR_QEOPDW_PARITY_ERR_SMASK \
803 | RCV_ERR_STATUS_RX_RBUF_CTX_ID_PARITY_ERR_SMASK \
804 | RCV_ERR_STATUS_RX_RBUF_BAD_LOOKUP_ERR_SMASK \
805 | RCV_ERR_STATUS_RX_RBUF_FULL_ERR_SMASK \
806 | RCV_ERR_STATUS_RX_RBUF_EMPTY_ERR_SMASK \
807 | RCV_ERR_STATUS_RX_RBUF_FL_RD_ADDR_PARITY_ERR_SMASK \
808 | RCV_ERR_STATUS_RX_RBUF_FL_WR_ADDR_PARITY_ERR_SMASK \
809 | RCV_ERR_STATUS_RX_RBUF_FL_INITDONE_PARITY_ERR_SMASK \
810 | RCV_ERR_STATUS_RX_RBUF_FL_INIT_WR_ADDR_PARITY_ERR_SMASK \
811 | RCV_ERR_STATUS_RX_RBUF_NEXT_FREE_BUF_UNC_ERR_SMASK \
812 | RCV_ERR_STATUS_RX_LOOKUP_DES_PART1_UNC_ERR_SMASK \
813 | RCV_ERR_STATUS_RX_LOOKUP_DES_PART1_UNC_COR_ERR_SMASK \
814 | RCV_ERR_STATUS_RX_LOOKUP_DES_PART2_PARITY_ERR_SMASK \
815 | RCV_ERR_STATUS_RX_LOOKUP_RCV_ARRAY_UNC_ERR_SMASK \
816 | RCV_ERR_STATUS_RX_LOOKUP_CSR_PARITY_ERR_SMASK \
817 | RCV_ERR_STATUS_RX_HQ_INTR_CSR_PARITY_ERR_SMASK \
818 | RCV_ERR_STATUS_RX_HQ_INTR_FSM_ERR_SMASK \
819 | RCV_ERR_STATUS_RX_RBUF_DESC_PART1_UNC_ERR_SMASK \
820 | RCV_ERR_STATUS_RX_RBUF_DESC_PART1_COR_ERR_SMASK \
821 | RCV_ERR_STATUS_RX_RBUF_DESC_PART2_UNC_ERR_SMASK \
822 | RCV_ERR_STATUS_RX_DMA_HDR_FIFO_RD_UNC_ERR_SMASK \
823 | RCV_ERR_STATUS_RX_DMA_DATA_FIFO_RD_UNC_ERR_SMASK \
824 | RCV_ERR_STATUS_RX_RBUF_DATA_UNC_ERR_SMASK \
825 | RCV_ERR_STATUS_RX_DMA_CSR_PARITY_ERR_SMASK \
826 | RCV_ERR_STATUS_RX_DMA_EQ_FSM_ENCODING_ERR_SMASK \
827 | RCV_ERR_STATUS_RX_DMA_DQ_FSM_ENCODING_ERR_SMASK \
828 | RCV_ERR_STATUS_RX_DMA_CSR_UNC_ERR_SMASK \
829 | RCV_ERR_STATUS_RX_CSR_PARITY_ERR_SMASK)
831 #define RXE_FREEZE_ABORT_MASK \
832 (RCV_ERR_STATUS_RX_DMA_CSR_UNC_ERR_SMASK | \
833 RCV_ERR_STATUS_RX_DMA_HDR_FIFO_RD_UNC_ERR_SMASK | \
834 RCV_ERR_STATUS_RX_DMA_DATA_FIFO_RD_UNC_ERR_SMASK)
839 #define DCCE(name) DCC_ERR_FLG_##name##_SMASK
840 static struct flag_table dcc_err_flags[] = {
841 FLAG_ENTRY0("bad_l2_err", DCCE(BAD_L2_ERR)),
842 FLAG_ENTRY0("bad_sc_err", DCCE(BAD_SC_ERR)),
843 FLAG_ENTRY0("bad_mid_tail_err", DCCE(BAD_MID_TAIL_ERR)),
844 FLAG_ENTRY0("bad_preemption_err", DCCE(BAD_PREEMPTION_ERR)),
845 FLAG_ENTRY0("preemption_err", DCCE(PREEMPTION_ERR)),
846 FLAG_ENTRY0("preemptionvl15_err", DCCE(PREEMPTIONVL15_ERR)),
847 FLAG_ENTRY0("bad_vl_marker_err", DCCE(BAD_VL_MARKER_ERR)),
848 FLAG_ENTRY0("bad_dlid_target_err", DCCE(BAD_DLID_TARGET_ERR)),
849 FLAG_ENTRY0("bad_lver_err", DCCE(BAD_LVER_ERR)),
850 FLAG_ENTRY0("uncorrectable_err", DCCE(UNCORRECTABLE_ERR)),
851 FLAG_ENTRY0("bad_crdt_ack_err", DCCE(BAD_CRDT_ACK_ERR)),
852 FLAG_ENTRY0("unsup_pkt_type", DCCE(UNSUP_PKT_TYPE)),
853 FLAG_ENTRY0("bad_ctrl_flit_err", DCCE(BAD_CTRL_FLIT_ERR)),
854 FLAG_ENTRY0("event_cntr_parity_err", DCCE(EVENT_CNTR_PARITY_ERR)),
855 FLAG_ENTRY0("event_cntr_rollover_err", DCCE(EVENT_CNTR_ROLLOVER_ERR)),
856 FLAG_ENTRY0("link_err", DCCE(LINK_ERR)),
857 FLAG_ENTRY0("misc_cntr_rollover_err", DCCE(MISC_CNTR_ROLLOVER_ERR)),
858 FLAG_ENTRY0("bad_ctrl_dist_err", DCCE(BAD_CTRL_DIST_ERR)),
859 FLAG_ENTRY0("bad_tail_dist_err", DCCE(BAD_TAIL_DIST_ERR)),
860 FLAG_ENTRY0("bad_head_dist_err", DCCE(BAD_HEAD_DIST_ERR)),
861 FLAG_ENTRY0("nonvl15_state_err", DCCE(NONVL15_STATE_ERR)),
862 FLAG_ENTRY0("vl15_multi_err", DCCE(VL15_MULTI_ERR)),
863 FLAG_ENTRY0("bad_pkt_length_err", DCCE(BAD_PKT_LENGTH_ERR)),
864 FLAG_ENTRY0("unsup_vl_err", DCCE(UNSUP_VL_ERR)),
865 FLAG_ENTRY0("perm_nvl15_err", DCCE(PERM_NVL15_ERR)),
866 FLAG_ENTRY0("slid_zero_err", DCCE(SLID_ZERO_ERR)),
867 FLAG_ENTRY0("dlid_zero_err", DCCE(DLID_ZERO_ERR)),
868 FLAG_ENTRY0("length_mtu_err", DCCE(LENGTH_MTU_ERR)),
869 FLAG_ENTRY0("rx_early_drop_err", DCCE(RX_EARLY_DROP_ERR)),
870 FLAG_ENTRY0("late_short_err", DCCE(LATE_SHORT_ERR)),
871 FLAG_ENTRY0("late_long_err", DCCE(LATE_LONG_ERR)),
872 FLAG_ENTRY0("late_ebp_err", DCCE(LATE_EBP_ERR)),
873 FLAG_ENTRY0("fpe_tx_fifo_ovflw_err", DCCE(FPE_TX_FIFO_OVFLW_ERR)),
874 FLAG_ENTRY0("fpe_tx_fifo_unflw_err", DCCE(FPE_TX_FIFO_UNFLW_ERR)),
875 FLAG_ENTRY0("csr_access_blocked_host", DCCE(CSR_ACCESS_BLOCKED_HOST)),
876 FLAG_ENTRY0("csr_access_blocked_uc", DCCE(CSR_ACCESS_BLOCKED_UC)),
877 FLAG_ENTRY0("tx_ctrl_parity_err", DCCE(TX_CTRL_PARITY_ERR)),
878 FLAG_ENTRY0("tx_ctrl_parity_mbe_err", DCCE(TX_CTRL_PARITY_MBE_ERR)),
879 FLAG_ENTRY0("tx_sc_parity_err", DCCE(TX_SC_PARITY_ERR)),
880 FLAG_ENTRY0("rx_ctrl_parity_mbe_err", DCCE(RX_CTRL_PARITY_MBE_ERR)),
881 FLAG_ENTRY0("csr_parity_err", DCCE(CSR_PARITY_ERR)),
882 FLAG_ENTRY0("csr_inval_addr", DCCE(CSR_INVAL_ADDR)),
883 FLAG_ENTRY0("tx_byte_shft_parity_err", DCCE(TX_BYTE_SHFT_PARITY_ERR)),
884 FLAG_ENTRY0("rx_byte_shft_parity_err", DCCE(RX_BYTE_SHFT_PARITY_ERR)),
885 FLAG_ENTRY0("fmconfig_err", DCCE(FMCONFIG_ERR)),
886 FLAG_ENTRY0("rcvport_err", DCCE(RCVPORT_ERR)),
892 #define LCBE(name) DC_LCB_ERR_FLG_##name##_SMASK
893 static struct flag_table lcb_err_flags[] = {
894 /* 0*/ FLAG_ENTRY0("CSR_PARITY_ERR", LCBE(CSR_PARITY_ERR)),
895 /* 1*/ FLAG_ENTRY0("INVALID_CSR_ADDR", LCBE(INVALID_CSR_ADDR)),
896 /* 2*/ FLAG_ENTRY0("RST_FOR_FAILED_DESKEW", LCBE(RST_FOR_FAILED_DESKEW)),
897 /* 3*/ FLAG_ENTRY0("ALL_LNS_FAILED_REINIT_TEST",
898 LCBE(ALL_LNS_FAILED_REINIT_TEST)),
899 /* 4*/ FLAG_ENTRY0("LOST_REINIT_STALL_OR_TOS", LCBE(LOST_REINIT_STALL_OR_TOS)),
900 /* 5*/ FLAG_ENTRY0("TX_LESS_THAN_FOUR_LNS", LCBE(TX_LESS_THAN_FOUR_LNS)),
901 /* 6*/ FLAG_ENTRY0("RX_LESS_THAN_FOUR_LNS", LCBE(RX_LESS_THAN_FOUR_LNS)),
902 /* 7*/ FLAG_ENTRY0("SEQ_CRC_ERR", LCBE(SEQ_CRC_ERR)),
903 /* 8*/ FLAG_ENTRY0("REINIT_FROM_PEER", LCBE(REINIT_FROM_PEER)),
904 /* 9*/ FLAG_ENTRY0("REINIT_FOR_LN_DEGRADE", LCBE(REINIT_FOR_LN_DEGRADE)),
905 /*10*/ FLAG_ENTRY0("CRC_ERR_CNT_HIT_LIMIT", LCBE(CRC_ERR_CNT_HIT_LIMIT)),
906 /*11*/ FLAG_ENTRY0("RCLK_STOPPED", LCBE(RCLK_STOPPED)),
907 /*12*/ FLAG_ENTRY0("UNEXPECTED_REPLAY_MARKER", LCBE(UNEXPECTED_REPLAY_MARKER)),
908 /*13*/ FLAG_ENTRY0("UNEXPECTED_ROUND_TRIP_MARKER",
909 LCBE(UNEXPECTED_ROUND_TRIP_MARKER)),
910 /*14*/ FLAG_ENTRY0("ILLEGAL_NULL_LTP", LCBE(ILLEGAL_NULL_LTP)),
911 /*15*/ FLAG_ENTRY0("ILLEGAL_FLIT_ENCODING", LCBE(ILLEGAL_FLIT_ENCODING)),
912 /*16*/ FLAG_ENTRY0("FLIT_INPUT_BUF_OFLW", LCBE(FLIT_INPUT_BUF_OFLW)),
913 /*17*/ FLAG_ENTRY0("VL_ACK_INPUT_BUF_OFLW", LCBE(VL_ACK_INPUT_BUF_OFLW)),
914 /*18*/ FLAG_ENTRY0("VL_ACK_INPUT_PARITY_ERR", LCBE(VL_ACK_INPUT_PARITY_ERR)),
915 /*19*/ FLAG_ENTRY0("VL_ACK_INPUT_WRONG_CRC_MODE",
916 LCBE(VL_ACK_INPUT_WRONG_CRC_MODE)),
917 /*20*/ FLAG_ENTRY0("FLIT_INPUT_BUF_MBE", LCBE(FLIT_INPUT_BUF_MBE)),
918 /*21*/ FLAG_ENTRY0("FLIT_INPUT_BUF_SBE", LCBE(FLIT_INPUT_BUF_SBE)),
919 /*22*/ FLAG_ENTRY0("REPLAY_BUF_MBE", LCBE(REPLAY_BUF_MBE)),
920 /*23*/ FLAG_ENTRY0("REPLAY_BUF_SBE", LCBE(REPLAY_BUF_SBE)),
921 /*24*/ FLAG_ENTRY0("CREDIT_RETURN_FLIT_MBE", LCBE(CREDIT_RETURN_FLIT_MBE)),
922 /*25*/ FLAG_ENTRY0("RST_FOR_LINK_TIMEOUT", LCBE(RST_FOR_LINK_TIMEOUT)),
923 /*26*/ FLAG_ENTRY0("RST_FOR_INCOMPLT_RND_TRIP",
924 LCBE(RST_FOR_INCOMPLT_RND_TRIP)),
925 /*27*/ FLAG_ENTRY0("HOLD_REINIT", LCBE(HOLD_REINIT)),
926 /*28*/ FLAG_ENTRY0("NEG_EDGE_LINK_TRANSFER_ACTIVE",
927 LCBE(NEG_EDGE_LINK_TRANSFER_ACTIVE)),
928 /*29*/ FLAG_ENTRY0("REDUNDANT_FLIT_PARITY_ERR",
929 LCBE(REDUNDANT_FLIT_PARITY_ERR))
935 #define D8E(name) DC_DC8051_ERR_FLG_##name##_SMASK
936 static struct flag_table dc8051_err_flags[] = {
937 FLAG_ENTRY0("SET_BY_8051", D8E(SET_BY_8051)),
938 FLAG_ENTRY0("LOST_8051_HEART_BEAT", D8E(LOST_8051_HEART_BEAT)),
939 FLAG_ENTRY0("CRAM_MBE", D8E(CRAM_MBE)),
940 FLAG_ENTRY0("CRAM_SBE", D8E(CRAM_SBE)),
941 FLAG_ENTRY0("DRAM_MBE", D8E(DRAM_MBE)),
942 FLAG_ENTRY0("DRAM_SBE", D8E(DRAM_SBE)),
943 FLAG_ENTRY0("IRAM_MBE", D8E(IRAM_MBE)),
944 FLAG_ENTRY0("IRAM_SBE", D8E(IRAM_SBE)),
945 FLAG_ENTRY0("UNMATCHED_SECURE_MSG_ACROSS_BCC_LANES",
946 D8E(UNMATCHED_SECURE_MSG_ACROSS_BCC_LANES)),
947 FLAG_ENTRY0("INVALID_CSR_ADDR", D8E(INVALID_CSR_ADDR)),
951 * DC8051 Information Error flags
953 * Flags in DC8051_DBG_ERR_INFO_SET_BY_8051.ERROR field.
955 static struct flag_table dc8051_info_err_flags[] = {
956 FLAG_ENTRY0("Spico ROM check failed", SPICO_ROM_FAILED),
957 FLAG_ENTRY0("Unknown frame received", UNKNOWN_FRAME),
958 FLAG_ENTRY0("Target BER not met", TARGET_BER_NOT_MET),
959 FLAG_ENTRY0("Serdes internal loopback failure",
960 FAILED_SERDES_INTERNAL_LOOPBACK),
961 FLAG_ENTRY0("Failed SerDes init", FAILED_SERDES_INIT),
962 FLAG_ENTRY0("Failed LNI(Polling)", FAILED_LNI_POLLING),
963 FLAG_ENTRY0("Failed LNI(Debounce)", FAILED_LNI_DEBOUNCE),
964 FLAG_ENTRY0("Failed LNI(EstbComm)", FAILED_LNI_ESTBCOMM),
965 FLAG_ENTRY0("Failed LNI(OptEq)", FAILED_LNI_OPTEQ),
966 FLAG_ENTRY0("Failed LNI(VerifyCap_1)", FAILED_LNI_VERIFY_CAP1),
967 FLAG_ENTRY0("Failed LNI(VerifyCap_2)", FAILED_LNI_VERIFY_CAP2),
968 FLAG_ENTRY0("Failed LNI(ConfigLT)", FAILED_LNI_CONFIGLT),
969 FLAG_ENTRY0("Host Handshake Timeout", HOST_HANDSHAKE_TIMEOUT)
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),
989 static u32 encoded_size(u32 size);
990 static u32 chip_to_opa_lstate(struct hfi1_devdata *dd, u32 chip_lstate);
991 static int set_physical_link_state(struct hfi1_devdata *dd, u64 state);
992 static void read_vc_remote_phy(struct hfi1_devdata *dd, u8 *power_management,
994 static void read_vc_remote_fabric(struct hfi1_devdata *dd, u8 *vau, u8 *z,
995 u8 *vcu, u16 *vl15buf, u8 *crc_sizes);
996 static void read_vc_remote_link_width(struct hfi1_devdata *dd,
997 u8 *remote_tx_rate, u16 *link_widths);
998 static void read_vc_local_link_width(struct hfi1_devdata *dd, u8 *misc_bits,
999 u8 *flag_bits, u16 *link_widths);
1000 static void read_remote_device_id(struct hfi1_devdata *dd, u16 *device_id,
1002 static void read_mgmt_allowed(struct hfi1_devdata *dd, u8 *mgmt_allowed);
1003 static void read_local_lni(struct hfi1_devdata *dd, u8 *enable_lane_rx);
1004 static int read_tx_settings(struct hfi1_devdata *dd, u8 *enable_lane_tx,
1005 u8 *tx_polarity_inversion,
1006 u8 *rx_polarity_inversion, u8 *max_rate);
1007 static void handle_sdma_eng_err(struct hfi1_devdata *dd,
1008 unsigned int context, u64 err_status);
1009 static void handle_qsfp_int(struct hfi1_devdata *dd, u32 source, u64 reg);
1010 static void handle_dcc_err(struct hfi1_devdata *dd,
1011 unsigned int context, u64 err_status);
1012 static void handle_lcb_err(struct hfi1_devdata *dd,
1013 unsigned int context, u64 err_status);
1014 static void handle_8051_interrupt(struct hfi1_devdata *dd, u32 unused, u64 reg);
1015 static void handle_cce_err(struct hfi1_devdata *dd, u32 unused, u64 reg);
1016 static void handle_rxe_err(struct hfi1_devdata *dd, u32 unused, u64 reg);
1017 static void handle_misc_err(struct hfi1_devdata *dd, u32 unused, u64 reg);
1018 static void handle_pio_err(struct hfi1_devdata *dd, u32 unused, u64 reg);
1019 static void handle_sdma_err(struct hfi1_devdata *dd, u32 unused, u64 reg);
1020 static void handle_egress_err(struct hfi1_devdata *dd, u32 unused, u64 reg);
1021 static void handle_txe_err(struct hfi1_devdata *dd, u32 unused, u64 reg);
1022 static void set_partition_keys(struct hfi1_pportdata *);
1023 static const char *link_state_name(u32 state);
1024 static const char *link_state_reason_name(struct hfi1_pportdata *ppd,
1026 static int do_8051_command(struct hfi1_devdata *dd, u32 type, u64 in_data,
1028 static int read_idle_sma(struct hfi1_devdata *dd, u64 *data);
1029 static int thermal_init(struct hfi1_devdata *dd);
1031 static int wait_logical_linkstate(struct hfi1_pportdata *ppd, u32 state,
1033 static void read_planned_down_reason_code(struct hfi1_devdata *dd, u8 *pdrrc);
1034 static void handle_temp_err(struct hfi1_devdata *);
1035 static void dc_shutdown(struct hfi1_devdata *);
1036 static void dc_start(struct hfi1_devdata *);
1039 * Error interrupt table entry. This is used as input to the interrupt
1040 * "clear down" routine used for all second tier error interrupt register.
1041 * Second tier interrupt registers have a single bit representing them
1042 * in the top-level CceIntStatus.
1044 struct err_reg_info {
1045 u32 status; /* status CSR offset */
1046 u32 clear; /* clear CSR offset */
1047 u32 mask; /* mask CSR offset */
1048 void (*handler)(struct hfi1_devdata *dd, u32 source, u64 reg);
1052 #define NUM_MISC_ERRS (IS_GENERAL_ERR_END - IS_GENERAL_ERR_START)
1053 #define NUM_DC_ERRS (IS_DC_END - IS_DC_START)
1054 #define NUM_VARIOUS (IS_VARIOUS_END - IS_VARIOUS_START)
1057 * Helpers for building HFI and DC error interrupt table entries. Different
1058 * helpers are needed because of inconsistent register names.
1060 #define EE(reg, handler, desc) \
1061 { reg##_STATUS, reg##_CLEAR, reg##_MASK, \
1063 #define DC_EE1(reg, handler, desc) \
1064 { reg##_FLG, reg##_FLG_CLR, reg##_FLG_EN, handler, desc }
1065 #define DC_EE2(reg, handler, desc) \
1066 { reg##_FLG, reg##_CLR, reg##_EN, handler, desc }
1069 * Table of the "misc" grouping of error interrupts. Each entry refers to
1070 * another register containing more information.
1072 static const struct err_reg_info misc_errs[NUM_MISC_ERRS] = {
1073 /* 0*/ EE(CCE_ERR, handle_cce_err, "CceErr"),
1074 /* 1*/ EE(RCV_ERR, handle_rxe_err, "RxeErr"),
1075 /* 2*/ EE(MISC_ERR, handle_misc_err, "MiscErr"),
1076 /* 3*/ { 0, 0, 0, NULL }, /* reserved */
1077 /* 4*/ EE(SEND_PIO_ERR, handle_pio_err, "PioErr"),
1078 /* 5*/ EE(SEND_DMA_ERR, handle_sdma_err, "SDmaErr"),
1079 /* 6*/ EE(SEND_EGRESS_ERR, handle_egress_err, "EgressErr"),
1080 /* 7*/ EE(SEND_ERR, handle_txe_err, "TxeErr")
1081 /* the rest are reserved */
1085 * Index into the Various section of the interrupt sources
1086 * corresponding to the Critical Temperature interrupt.
1088 #define TCRIT_INT_SOURCE 4
1091 * SDMA error interrupt entry - refers to another register containing more
1094 static const struct err_reg_info sdma_eng_err =
1095 EE(SEND_DMA_ENG_ERR, handle_sdma_eng_err, "SDmaEngErr");
1097 static const struct err_reg_info various_err[NUM_VARIOUS] = {
1098 /* 0*/ { 0, 0, 0, NULL }, /* PbcInt */
1099 /* 1*/ { 0, 0, 0, NULL }, /* GpioAssertInt */
1100 /* 2*/ EE(ASIC_QSFP1, handle_qsfp_int, "QSFP1"),
1101 /* 3*/ EE(ASIC_QSFP2, handle_qsfp_int, "QSFP2"),
1102 /* 4*/ { 0, 0, 0, NULL }, /* TCritInt */
1103 /* rest are reserved */
1107 * The DC encoding of mtu_cap for 10K MTU in the DCC_CFG_PORT_CONFIG
1108 * register can not be derived from the MTU value because 10K is not
1109 * a power of 2. Therefore, we need a constant. Everything else can
1112 #define DCC_CFG_PORT_MTU_CAP_10240 7
1115 * Table of the DC grouping of error interrupts. Each entry refers to
1116 * another register containing more information.
1118 static const struct err_reg_info dc_errs[NUM_DC_ERRS] = {
1119 /* 0*/ DC_EE1(DCC_ERR, handle_dcc_err, "DCC Err"),
1120 /* 1*/ DC_EE2(DC_LCB_ERR, handle_lcb_err, "LCB Err"),
1121 /* 2*/ DC_EE2(DC_DC8051_ERR, handle_8051_interrupt, "DC8051 Interrupt"),
1122 /* 3*/ /* dc_lbm_int - special, see is_dc_int() */
1123 /* the rest are reserved */
1133 * csr to read for name (if applicable)
1138 * offset into dd or ppd to store the counter's value
1148 * accessor for stat element, context either dd or ppd
1150 u64 (*rw_cntr)(const struct cntr_entry *, void *context, int vl,
1151 int mode, u64 data);
1154 #define C_RCV_HDR_OVF_FIRST C_RCV_HDR_OVF_0
1155 #define C_RCV_HDR_OVF_LAST C_RCV_HDR_OVF_159
1157 #define CNTR_ELEM(name, csr, offset, flags, accessor) \
1167 #define RXE32_PORT_CNTR_ELEM(name, counter, flags) \
1169 (counter * 8 + RCV_COUNTER_ARRAY32), \
1170 0, flags | CNTR_32BIT, \
1171 port_access_u32_csr)
1173 #define RXE32_DEV_CNTR_ELEM(name, counter, flags) \
1175 (counter * 8 + RCV_COUNTER_ARRAY32), \
1176 0, flags | CNTR_32BIT, \
1180 #define RXE64_PORT_CNTR_ELEM(name, counter, flags) \
1182 (counter * 8 + RCV_COUNTER_ARRAY64), \
1184 port_access_u64_csr)
1186 #define RXE64_DEV_CNTR_ELEM(name, counter, flags) \
1188 (counter * 8 + RCV_COUNTER_ARRAY64), \
1192 #define OVR_LBL(ctx) C_RCV_HDR_OVF_ ## ctx
1193 #define OVR_ELM(ctx) \
1194 CNTR_ELEM("RcvHdrOvr" #ctx, \
1195 (RCV_HDR_OVFL_CNT + ctx * 0x100), \
1196 0, CNTR_NORMAL, port_access_u64_csr)
1199 #define TXE32_PORT_CNTR_ELEM(name, counter, flags) \
1201 (counter * 8 + SEND_COUNTER_ARRAY32), \
1202 0, flags | CNTR_32BIT, \
1203 port_access_u32_csr)
1206 #define TXE64_PORT_CNTR_ELEM(name, counter, flags) \
1208 (counter * 8 + SEND_COUNTER_ARRAY64), \
1210 port_access_u64_csr)
1212 # define TX64_DEV_CNTR_ELEM(name, counter, flags) \
1214 counter * 8 + SEND_COUNTER_ARRAY64, \
1220 #define CCE_PERF_DEV_CNTR_ELEM(name, counter, flags) \
1222 (counter * 8 + CCE_COUNTER_ARRAY32), \
1223 0, flags | CNTR_32BIT, \
1226 #define CCE_INT_DEV_CNTR_ELEM(name, counter, flags) \
1228 (counter * 8 + CCE_INT_COUNTER_ARRAY32), \
1229 0, flags | CNTR_32BIT, \
1233 #define DC_PERF_CNTR(name, counter, flags) \
1240 #define DC_PERF_CNTR_LCB(name, counter, flags) \
1248 #define SW_IBP_CNTR(name, cntr) \
1255 u64 read_csr(const struct hfi1_devdata *dd, u32 offset)
1257 if (dd->flags & HFI1_PRESENT) {
1258 return readq((void __iomem *)dd->kregbase + offset);
1263 void write_csr(const struct hfi1_devdata *dd, u32 offset, u64 value)
1265 if (dd->flags & HFI1_PRESENT)
1266 writeq(value, (void __iomem *)dd->kregbase + offset);
1269 void __iomem *get_csr_addr(
1270 struct hfi1_devdata *dd,
1273 return (void __iomem *)dd->kregbase + offset;
1276 static inline u64 read_write_csr(const struct hfi1_devdata *dd, u32 csr,
1277 int mode, u64 value)
1281 if (mode == CNTR_MODE_R) {
1282 ret = read_csr(dd, csr);
1283 } else if (mode == CNTR_MODE_W) {
1284 write_csr(dd, csr, value);
1287 dd_dev_err(dd, "Invalid cntr register access mode");
1291 hfi1_cdbg(CNTR, "csr 0x%x val 0x%llx mode %d", csr, ret, mode);
1296 static u64 dev_access_u32_csr(const struct cntr_entry *entry,
1297 void *context, int vl, int mode, u64 data)
1299 struct hfi1_devdata *dd = context;
1300 u64 csr = entry->csr;
1302 if (entry->flags & CNTR_SDMA) {
1303 if (vl == CNTR_INVALID_VL)
1307 if (vl != CNTR_INVALID_VL)
1310 return read_write_csr(dd, csr, mode, data);
1313 static u64 access_sde_err_cnt(const struct cntr_entry *entry,
1314 void *context, int idx, int mode, u64 data)
1316 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1318 if (dd->per_sdma && idx < dd->num_sdma)
1319 return dd->per_sdma[idx].err_cnt;
1323 static u64 access_sde_int_cnt(const struct cntr_entry *entry,
1324 void *context, int idx, int mode, u64 data)
1326 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1328 if (dd->per_sdma && idx < dd->num_sdma)
1329 return dd->per_sdma[idx].sdma_int_cnt;
1333 static u64 access_sde_idle_int_cnt(const struct cntr_entry *entry,
1334 void *context, int idx, int mode, u64 data)
1336 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1338 if (dd->per_sdma && idx < dd->num_sdma)
1339 return dd->per_sdma[idx].idle_int_cnt;
1343 static u64 access_sde_progress_int_cnt(const struct cntr_entry *entry,
1344 void *context, int idx, int mode,
1347 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1349 if (dd->per_sdma && idx < dd->num_sdma)
1350 return dd->per_sdma[idx].progress_int_cnt;
1354 static u64 dev_access_u64_csr(const struct cntr_entry *entry, void *context,
1355 int vl, int mode, u64 data)
1357 struct hfi1_devdata *dd = context;
1360 u64 csr = entry->csr;
1362 if (entry->flags & CNTR_VL) {
1363 if (vl == CNTR_INVALID_VL)
1367 if (vl != CNTR_INVALID_VL)
1371 val = read_write_csr(dd, csr, mode, data);
1375 static u64 dc_access_lcb_cntr(const struct cntr_entry *entry, void *context,
1376 int vl, int mode, u64 data)
1378 struct hfi1_devdata *dd = context;
1379 u32 csr = entry->csr;
1382 if (vl != CNTR_INVALID_VL)
1384 if (mode == CNTR_MODE_R)
1385 ret = read_lcb_csr(dd, csr, &data);
1386 else if (mode == CNTR_MODE_W)
1387 ret = write_lcb_csr(dd, csr, data);
1390 dd_dev_err(dd, "Could not acquire LCB for counter 0x%x", csr);
1394 hfi1_cdbg(CNTR, "csr 0x%x val 0x%llx mode %d", csr, data, mode);
1399 static u64 port_access_u32_csr(const struct cntr_entry *entry, void *context,
1400 int vl, int mode, u64 data)
1402 struct hfi1_pportdata *ppd = context;
1404 if (vl != CNTR_INVALID_VL)
1406 return read_write_csr(ppd->dd, entry->csr, mode, data);
1409 static u64 port_access_u64_csr(const struct cntr_entry *entry,
1410 void *context, int vl, int mode, u64 data)
1412 struct hfi1_pportdata *ppd = context;
1414 u64 csr = entry->csr;
1416 if (entry->flags & CNTR_VL) {
1417 if (vl == CNTR_INVALID_VL)
1421 if (vl != CNTR_INVALID_VL)
1424 val = read_write_csr(ppd->dd, csr, mode, data);
1428 /* Software defined */
1429 static inline u64 read_write_sw(struct hfi1_devdata *dd, u64 *cntr, int mode,
1434 if (mode == CNTR_MODE_R) {
1436 } else if (mode == CNTR_MODE_W) {
1440 dd_dev_err(dd, "Invalid cntr sw access mode");
1444 hfi1_cdbg(CNTR, "val 0x%llx mode %d", ret, mode);
1449 static u64 access_sw_link_dn_cnt(const struct cntr_entry *entry, void *context,
1450 int vl, int mode, u64 data)
1452 struct hfi1_pportdata *ppd = context;
1454 if (vl != CNTR_INVALID_VL)
1456 return read_write_sw(ppd->dd, &ppd->link_downed, mode, data);
1459 static u64 access_sw_link_up_cnt(const struct cntr_entry *entry, void *context,
1460 int vl, int mode, u64 data)
1462 struct hfi1_pportdata *ppd = context;
1464 if (vl != CNTR_INVALID_VL)
1466 return read_write_sw(ppd->dd, &ppd->link_up, mode, data);
1469 static u64 access_sw_unknown_frame_cnt(const struct cntr_entry *entry,
1470 void *context, int vl, int mode,
1473 struct hfi1_pportdata *ppd = (struct hfi1_pportdata *)context;
1475 if (vl != CNTR_INVALID_VL)
1477 return read_write_sw(ppd->dd, &ppd->unknown_frame_count, mode, data);
1480 static u64 access_sw_xmit_discards(const struct cntr_entry *entry,
1481 void *context, int vl, int mode, u64 data)
1483 struct hfi1_pportdata *ppd = (struct hfi1_pportdata *)context;
1487 if (vl == CNTR_INVALID_VL)
1488 counter = &ppd->port_xmit_discards;
1489 else if (vl >= 0 && vl < C_VL_COUNT)
1490 counter = &ppd->port_xmit_discards_vl[vl];
1494 return read_write_sw(ppd->dd, counter, mode, data);
1497 static u64 access_xmit_constraint_errs(const struct cntr_entry *entry,
1498 void *context, int vl, int mode,
1501 struct hfi1_pportdata *ppd = context;
1503 if (vl != CNTR_INVALID_VL)
1506 return read_write_sw(ppd->dd, &ppd->port_xmit_constraint_errors,
1510 static u64 access_rcv_constraint_errs(const struct cntr_entry *entry,
1511 void *context, int vl, int mode, u64 data)
1513 struct hfi1_pportdata *ppd = context;
1515 if (vl != CNTR_INVALID_VL)
1518 return read_write_sw(ppd->dd, &ppd->port_rcv_constraint_errors,
1522 u64 get_all_cpu_total(u64 __percpu *cntr)
1527 for_each_possible_cpu(cpu)
1528 counter += *per_cpu_ptr(cntr, cpu);
1532 static u64 read_write_cpu(struct hfi1_devdata *dd, u64 *z_val,
1534 int vl, int mode, u64 data)
1538 if (vl != CNTR_INVALID_VL)
1541 if (mode == CNTR_MODE_R) {
1542 ret = get_all_cpu_total(cntr) - *z_val;
1543 } else if (mode == CNTR_MODE_W) {
1544 /* A write can only zero the counter */
1546 *z_val = get_all_cpu_total(cntr);
1548 dd_dev_err(dd, "Per CPU cntrs can only be zeroed");
1550 dd_dev_err(dd, "Invalid cntr sw cpu access mode");
1557 static u64 access_sw_cpu_intr(const struct cntr_entry *entry,
1558 void *context, int vl, int mode, u64 data)
1560 struct hfi1_devdata *dd = context;
1562 return read_write_cpu(dd, &dd->z_int_counter, dd->int_counter, vl,
1566 static u64 access_sw_cpu_rcv_limit(const struct cntr_entry *entry,
1567 void *context, int vl, int mode, u64 data)
1569 struct hfi1_devdata *dd = context;
1571 return read_write_cpu(dd, &dd->z_rcv_limit, dd->rcv_limit, vl,
1575 static u64 access_sw_pio_wait(const struct cntr_entry *entry,
1576 void *context, int vl, int mode, u64 data)
1578 struct hfi1_devdata *dd = context;
1580 return dd->verbs_dev.n_piowait;
1583 static u64 access_sw_pio_drain(const struct cntr_entry *entry,
1584 void *context, int vl, int mode, u64 data)
1586 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1588 return dd->verbs_dev.n_piodrain;
1591 static u64 access_sw_vtx_wait(const struct cntr_entry *entry,
1592 void *context, int vl, int mode, u64 data)
1594 struct hfi1_devdata *dd = context;
1596 return dd->verbs_dev.n_txwait;
1599 static u64 access_sw_kmem_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_kmem_wait;
1607 static u64 access_sw_send_schedule(const struct cntr_entry *entry,
1608 void *context, int vl, int mode, u64 data)
1610 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1612 return read_write_cpu(dd, &dd->z_send_schedule, dd->send_schedule, vl,
1616 /* Software counters for the error status bits within MISC_ERR_STATUS */
1617 static u64 access_misc_pll_lock_fail_err_cnt(const struct cntr_entry *entry,
1618 void *context, int vl, int mode,
1621 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1623 return dd->misc_err_status_cnt[12];
1626 static u64 access_misc_mbist_fail_err_cnt(const struct cntr_entry *entry,
1627 void *context, int vl, int mode,
1630 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1632 return dd->misc_err_status_cnt[11];
1635 static u64 access_misc_invalid_eep_cmd_err_cnt(const struct cntr_entry *entry,
1636 void *context, int vl, int mode,
1639 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1641 return dd->misc_err_status_cnt[10];
1644 static u64 access_misc_efuse_done_parity_err_cnt(const struct cntr_entry *entry,
1645 void *context, int vl,
1648 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1650 return dd->misc_err_status_cnt[9];
1653 static u64 access_misc_efuse_write_err_cnt(const struct cntr_entry *entry,
1654 void *context, int vl, int mode,
1657 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1659 return dd->misc_err_status_cnt[8];
1662 static u64 access_misc_efuse_read_bad_addr_err_cnt(
1663 const struct cntr_entry *entry,
1664 void *context, int vl, int mode, u64 data)
1666 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1668 return dd->misc_err_status_cnt[7];
1671 static u64 access_misc_efuse_csr_parity_err_cnt(const struct cntr_entry *entry,
1672 void *context, int vl,
1675 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1677 return dd->misc_err_status_cnt[6];
1680 static u64 access_misc_fw_auth_failed_err_cnt(const struct cntr_entry *entry,
1681 void *context, int vl, int mode,
1684 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1686 return dd->misc_err_status_cnt[5];
1689 static u64 access_misc_key_mismatch_err_cnt(const struct cntr_entry *entry,
1690 void *context, int vl, int mode,
1693 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1695 return dd->misc_err_status_cnt[4];
1698 static u64 access_misc_sbus_write_failed_err_cnt(const struct cntr_entry *entry,
1699 void *context, int vl,
1702 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1704 return dd->misc_err_status_cnt[3];
1707 static u64 access_misc_csr_write_bad_addr_err_cnt(
1708 const struct cntr_entry *entry,
1709 void *context, int vl, int mode, u64 data)
1711 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1713 return dd->misc_err_status_cnt[2];
1716 static u64 access_misc_csr_read_bad_addr_err_cnt(const struct cntr_entry *entry,
1717 void *context, int vl,
1720 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1722 return dd->misc_err_status_cnt[1];
1725 static u64 access_misc_csr_parity_err_cnt(const struct cntr_entry *entry,
1726 void *context, int vl, int mode,
1729 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1731 return dd->misc_err_status_cnt[0];
1735 * Software counter for the aggregate of
1736 * individual CceErrStatus counters
1738 static u64 access_sw_cce_err_status_aggregated_cnt(
1739 const struct cntr_entry *entry,
1740 void *context, int vl, int mode, u64 data)
1742 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1744 return dd->sw_cce_err_status_aggregate;
1748 * Software counters corresponding to each of the
1749 * error status bits within CceErrStatus
1751 static u64 access_cce_msix_csr_parity_err_cnt(const struct cntr_entry *entry,
1752 void *context, int vl, int mode,
1755 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1757 return dd->cce_err_status_cnt[40];
1760 static u64 access_cce_int_map_unc_err_cnt(const struct cntr_entry *entry,
1761 void *context, int vl, int mode,
1764 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1766 return dd->cce_err_status_cnt[39];
1769 static u64 access_cce_int_map_cor_err_cnt(const struct cntr_entry *entry,
1770 void *context, int vl, int mode,
1773 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1775 return dd->cce_err_status_cnt[38];
1778 static u64 access_cce_msix_table_unc_err_cnt(const struct cntr_entry *entry,
1779 void *context, int vl, int mode,
1782 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1784 return dd->cce_err_status_cnt[37];
1787 static u64 access_cce_msix_table_cor_err_cnt(const struct cntr_entry *entry,
1788 void *context, int vl, int mode,
1791 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1793 return dd->cce_err_status_cnt[36];
1796 static u64 access_cce_rxdma_conv_fifo_parity_err_cnt(
1797 const struct cntr_entry *entry,
1798 void *context, int vl, int mode, u64 data)
1800 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1802 return dd->cce_err_status_cnt[35];
1805 static u64 access_cce_rcpl_async_fifo_parity_err_cnt(
1806 const struct cntr_entry *entry,
1807 void *context, int vl, int mode, u64 data)
1809 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1811 return dd->cce_err_status_cnt[34];
1814 static u64 access_cce_seg_write_bad_addr_err_cnt(const struct cntr_entry *entry,
1815 void *context, int vl,
1818 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1820 return dd->cce_err_status_cnt[33];
1823 static u64 access_cce_seg_read_bad_addr_err_cnt(const struct cntr_entry *entry,
1824 void *context, int vl, int mode,
1827 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1829 return dd->cce_err_status_cnt[32];
1832 static u64 access_la_triggered_cnt(const struct cntr_entry *entry,
1833 void *context, int vl, int mode, u64 data)
1835 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1837 return dd->cce_err_status_cnt[31];
1840 static u64 access_cce_trgt_cpl_timeout_err_cnt(const struct cntr_entry *entry,
1841 void *context, int vl, int mode,
1844 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1846 return dd->cce_err_status_cnt[30];
1849 static u64 access_pcic_receive_parity_err_cnt(const struct cntr_entry *entry,
1850 void *context, int vl, int mode,
1853 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1855 return dd->cce_err_status_cnt[29];
1858 static u64 access_pcic_transmit_back_parity_err_cnt(
1859 const struct cntr_entry *entry,
1860 void *context, int vl, int mode, u64 data)
1862 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1864 return dd->cce_err_status_cnt[28];
1867 static u64 access_pcic_transmit_front_parity_err_cnt(
1868 const struct cntr_entry *entry,
1869 void *context, int vl, int mode, u64 data)
1871 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1873 return dd->cce_err_status_cnt[27];
1876 static u64 access_pcic_cpl_dat_q_unc_err_cnt(const struct cntr_entry *entry,
1877 void *context, int vl, int mode,
1880 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1882 return dd->cce_err_status_cnt[26];
1885 static u64 access_pcic_cpl_hd_q_unc_err_cnt(const struct cntr_entry *entry,
1886 void *context, int vl, int mode,
1889 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1891 return dd->cce_err_status_cnt[25];
1894 static u64 access_pcic_post_dat_q_unc_err_cnt(const struct cntr_entry *entry,
1895 void *context, int vl, int mode,
1898 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1900 return dd->cce_err_status_cnt[24];
1903 static u64 access_pcic_post_hd_q_unc_err_cnt(const struct cntr_entry *entry,
1904 void *context, int vl, int mode,
1907 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1909 return dd->cce_err_status_cnt[23];
1912 static u64 access_pcic_retry_sot_mem_unc_err_cnt(const struct cntr_entry *entry,
1913 void *context, int vl,
1916 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1918 return dd->cce_err_status_cnt[22];
1921 static u64 access_pcic_retry_mem_unc_err(const struct cntr_entry *entry,
1922 void *context, int vl, int mode,
1925 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1927 return dd->cce_err_status_cnt[21];
1930 static u64 access_pcic_n_post_dat_q_parity_err_cnt(
1931 const struct cntr_entry *entry,
1932 void *context, int vl, int mode, u64 data)
1934 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1936 return dd->cce_err_status_cnt[20];
1939 static u64 access_pcic_n_post_h_q_parity_err_cnt(const struct cntr_entry *entry,
1940 void *context, int vl,
1943 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1945 return dd->cce_err_status_cnt[19];
1948 static u64 access_pcic_cpl_dat_q_cor_err_cnt(const struct cntr_entry *entry,
1949 void *context, int vl, int mode,
1952 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1954 return dd->cce_err_status_cnt[18];
1957 static u64 access_pcic_cpl_hd_q_cor_err_cnt(const struct cntr_entry *entry,
1958 void *context, int vl, int mode,
1961 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1963 return dd->cce_err_status_cnt[17];
1966 static u64 access_pcic_post_dat_q_cor_err_cnt(const struct cntr_entry *entry,
1967 void *context, int vl, int mode,
1970 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1972 return dd->cce_err_status_cnt[16];
1975 static u64 access_pcic_post_hd_q_cor_err_cnt(const struct cntr_entry *entry,
1976 void *context, int vl, int mode,
1979 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1981 return dd->cce_err_status_cnt[15];
1984 static u64 access_pcic_retry_sot_mem_cor_err_cnt(const struct cntr_entry *entry,
1985 void *context, int vl,
1988 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1990 return dd->cce_err_status_cnt[14];
1993 static u64 access_pcic_retry_mem_cor_err_cnt(const struct cntr_entry *entry,
1994 void *context, int vl, int mode,
1997 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
1999 return dd->cce_err_status_cnt[13];
2002 static u64 access_cce_cli1_async_fifo_dbg_parity_err_cnt(
2003 const struct cntr_entry *entry,
2004 void *context, int vl, int mode, u64 data)
2006 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2008 return dd->cce_err_status_cnt[12];
2011 static u64 access_cce_cli1_async_fifo_rxdma_parity_err_cnt(
2012 const struct cntr_entry *entry,
2013 void *context, int vl, int mode, u64 data)
2015 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2017 return dd->cce_err_status_cnt[11];
2020 static u64 access_cce_cli1_async_fifo_sdma_hd_parity_err_cnt(
2021 const struct cntr_entry *entry,
2022 void *context, int vl, int mode, u64 data)
2024 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2026 return dd->cce_err_status_cnt[10];
2029 static u64 access_cce_cl1_async_fifo_pio_crdt_parity_err_cnt(
2030 const struct cntr_entry *entry,
2031 void *context, int vl, int mode, u64 data)
2033 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2035 return dd->cce_err_status_cnt[9];
2038 static u64 access_cce_cli2_async_fifo_parity_err_cnt(
2039 const struct cntr_entry *entry,
2040 void *context, int vl, int mode, u64 data)
2042 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2044 return dd->cce_err_status_cnt[8];
2047 static u64 access_cce_csr_cfg_bus_parity_err_cnt(const struct cntr_entry *entry,
2048 void *context, int vl,
2051 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2053 return dd->cce_err_status_cnt[7];
2056 static u64 access_cce_cli0_async_fifo_parity_err_cnt(
2057 const struct cntr_entry *entry,
2058 void *context, int vl, int mode, u64 data)
2060 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2062 return dd->cce_err_status_cnt[6];
2065 static u64 access_cce_rspd_data_parity_err_cnt(const struct cntr_entry *entry,
2066 void *context, int vl, int mode,
2069 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2071 return dd->cce_err_status_cnt[5];
2074 static u64 access_cce_trgt_access_err_cnt(const struct cntr_entry *entry,
2075 void *context, int vl, int mode,
2078 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2080 return dd->cce_err_status_cnt[4];
2083 static u64 access_cce_trgt_async_fifo_parity_err_cnt(
2084 const struct cntr_entry *entry,
2085 void *context, int vl, int mode, u64 data)
2087 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2089 return dd->cce_err_status_cnt[3];
2092 static u64 access_cce_csr_write_bad_addr_err_cnt(const struct cntr_entry *entry,
2093 void *context, int vl,
2096 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2098 return dd->cce_err_status_cnt[2];
2101 static u64 access_cce_csr_read_bad_addr_err_cnt(const struct cntr_entry *entry,
2102 void *context, int vl,
2105 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2107 return dd->cce_err_status_cnt[1];
2110 static u64 access_ccs_csr_parity_err_cnt(const struct cntr_entry *entry,
2111 void *context, int vl, int mode,
2114 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2116 return dd->cce_err_status_cnt[0];
2120 * Software counters corresponding to each of the
2121 * error status bits within RcvErrStatus
2123 static u64 access_rx_csr_parity_err_cnt(const struct cntr_entry *entry,
2124 void *context, int vl, int mode,
2127 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2129 return dd->rcv_err_status_cnt[63];
2132 static u64 access_rx_csr_write_bad_addr_err_cnt(const struct cntr_entry *entry,
2133 void *context, int vl,
2136 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2138 return dd->rcv_err_status_cnt[62];
2141 static u64 access_rx_csr_read_bad_addr_err_cnt(const struct cntr_entry *entry,
2142 void *context, int vl, int mode,
2145 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2147 return dd->rcv_err_status_cnt[61];
2150 static u64 access_rx_dma_csr_unc_err_cnt(const struct cntr_entry *entry,
2151 void *context, int vl, int mode,
2154 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2156 return dd->rcv_err_status_cnt[60];
2159 static u64 access_rx_dma_dq_fsm_encoding_err_cnt(const struct cntr_entry *entry,
2160 void *context, int vl,
2163 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2165 return dd->rcv_err_status_cnt[59];
2168 static u64 access_rx_dma_eq_fsm_encoding_err_cnt(const struct cntr_entry *entry,
2169 void *context, int vl,
2172 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2174 return dd->rcv_err_status_cnt[58];
2177 static u64 access_rx_dma_csr_parity_err_cnt(const struct cntr_entry *entry,
2178 void *context, int vl, int mode,
2181 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2183 return dd->rcv_err_status_cnt[57];
2186 static u64 access_rx_rbuf_data_cor_err_cnt(const struct cntr_entry *entry,
2187 void *context, int vl, int mode,
2190 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2192 return dd->rcv_err_status_cnt[56];
2195 static u64 access_rx_rbuf_data_unc_err_cnt(const struct cntr_entry *entry,
2196 void *context, int vl, int mode,
2199 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2201 return dd->rcv_err_status_cnt[55];
2204 static u64 access_rx_dma_data_fifo_rd_cor_err_cnt(
2205 const struct cntr_entry *entry,
2206 void *context, int vl, int mode, u64 data)
2208 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2210 return dd->rcv_err_status_cnt[54];
2213 static u64 access_rx_dma_data_fifo_rd_unc_err_cnt(
2214 const struct cntr_entry *entry,
2215 void *context, int vl, int mode, u64 data)
2217 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2219 return dd->rcv_err_status_cnt[53];
2222 static u64 access_rx_dma_hdr_fifo_rd_cor_err_cnt(const struct cntr_entry *entry,
2223 void *context, int vl,
2226 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2228 return dd->rcv_err_status_cnt[52];
2231 static u64 access_rx_dma_hdr_fifo_rd_unc_err_cnt(const struct cntr_entry *entry,
2232 void *context, int vl,
2235 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2237 return dd->rcv_err_status_cnt[51];
2240 static u64 access_rx_rbuf_desc_part2_cor_err_cnt(const struct cntr_entry *entry,
2241 void *context, int vl,
2244 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2246 return dd->rcv_err_status_cnt[50];
2249 static u64 access_rx_rbuf_desc_part2_unc_err_cnt(const struct cntr_entry *entry,
2250 void *context, int vl,
2253 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2255 return dd->rcv_err_status_cnt[49];
2258 static u64 access_rx_rbuf_desc_part1_cor_err_cnt(const struct cntr_entry *entry,
2259 void *context, int vl,
2262 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2264 return dd->rcv_err_status_cnt[48];
2267 static u64 access_rx_rbuf_desc_part1_unc_err_cnt(const struct cntr_entry *entry,
2268 void *context, int vl,
2271 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2273 return dd->rcv_err_status_cnt[47];
2276 static u64 access_rx_hq_intr_fsm_err_cnt(const struct cntr_entry *entry,
2277 void *context, int vl, int mode,
2280 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2282 return dd->rcv_err_status_cnt[46];
2285 static u64 access_rx_hq_intr_csr_parity_err_cnt(
2286 const struct cntr_entry *entry,
2287 void *context, int vl, int mode, u64 data)
2289 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2291 return dd->rcv_err_status_cnt[45];
2294 static u64 access_rx_lookup_csr_parity_err_cnt(
2295 const struct cntr_entry *entry,
2296 void *context, int vl, int mode, u64 data)
2298 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2300 return dd->rcv_err_status_cnt[44];
2303 static u64 access_rx_lookup_rcv_array_cor_err_cnt(
2304 const struct cntr_entry *entry,
2305 void *context, int vl, int mode, u64 data)
2307 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2309 return dd->rcv_err_status_cnt[43];
2312 static u64 access_rx_lookup_rcv_array_unc_err_cnt(
2313 const struct cntr_entry *entry,
2314 void *context, int vl, int mode, u64 data)
2316 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2318 return dd->rcv_err_status_cnt[42];
2321 static u64 access_rx_lookup_des_part2_parity_err_cnt(
2322 const struct cntr_entry *entry,
2323 void *context, int vl, int mode, u64 data)
2325 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2327 return dd->rcv_err_status_cnt[41];
2330 static u64 access_rx_lookup_des_part1_unc_cor_err_cnt(
2331 const struct cntr_entry *entry,
2332 void *context, int vl, int mode, u64 data)
2334 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2336 return dd->rcv_err_status_cnt[40];
2339 static u64 access_rx_lookup_des_part1_unc_err_cnt(
2340 const struct cntr_entry *entry,
2341 void *context, int vl, int mode, u64 data)
2343 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2345 return dd->rcv_err_status_cnt[39];
2348 static u64 access_rx_rbuf_next_free_buf_cor_err_cnt(
2349 const struct cntr_entry *entry,
2350 void *context, int vl, int mode, u64 data)
2352 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2354 return dd->rcv_err_status_cnt[38];
2357 static u64 access_rx_rbuf_next_free_buf_unc_err_cnt(
2358 const struct cntr_entry *entry,
2359 void *context, int vl, int mode, u64 data)
2361 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2363 return dd->rcv_err_status_cnt[37];
2366 static u64 access_rbuf_fl_init_wr_addr_parity_err_cnt(
2367 const struct cntr_entry *entry,
2368 void *context, int vl, int mode, u64 data)
2370 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2372 return dd->rcv_err_status_cnt[36];
2375 static u64 access_rx_rbuf_fl_initdone_parity_err_cnt(
2376 const struct cntr_entry *entry,
2377 void *context, int vl, int mode, u64 data)
2379 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2381 return dd->rcv_err_status_cnt[35];
2384 static u64 access_rx_rbuf_fl_write_addr_parity_err_cnt(
2385 const struct cntr_entry *entry,
2386 void *context, int vl, int mode, u64 data)
2388 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2390 return dd->rcv_err_status_cnt[34];
2393 static u64 access_rx_rbuf_fl_rd_addr_parity_err_cnt(
2394 const struct cntr_entry *entry,
2395 void *context, int vl, int mode, u64 data)
2397 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2399 return dd->rcv_err_status_cnt[33];
2402 static u64 access_rx_rbuf_empty_err_cnt(const struct cntr_entry *entry,
2403 void *context, int vl, int mode,
2406 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2408 return dd->rcv_err_status_cnt[32];
2411 static u64 access_rx_rbuf_full_err_cnt(const struct cntr_entry *entry,
2412 void *context, int vl, int mode,
2415 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2417 return dd->rcv_err_status_cnt[31];
2420 static u64 access_rbuf_bad_lookup_err_cnt(const struct cntr_entry *entry,
2421 void *context, int vl, int mode,
2424 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2426 return dd->rcv_err_status_cnt[30];
2429 static u64 access_rbuf_ctx_id_parity_err_cnt(const struct cntr_entry *entry,
2430 void *context, int vl, int mode,
2433 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2435 return dd->rcv_err_status_cnt[29];
2438 static u64 access_rbuf_csr_qeopdw_parity_err_cnt(const struct cntr_entry *entry,
2439 void *context, int vl,
2442 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2444 return dd->rcv_err_status_cnt[28];
2447 static u64 access_rx_rbuf_csr_q_num_of_pkt_parity_err_cnt(
2448 const struct cntr_entry *entry,
2449 void *context, int vl, int mode, u64 data)
2451 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2453 return dd->rcv_err_status_cnt[27];
2456 static u64 access_rx_rbuf_csr_q_t1_ptr_parity_err_cnt(
2457 const struct cntr_entry *entry,
2458 void *context, int vl, int mode, u64 data)
2460 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2462 return dd->rcv_err_status_cnt[26];
2465 static u64 access_rx_rbuf_csr_q_hd_ptr_parity_err_cnt(
2466 const struct cntr_entry *entry,
2467 void *context, int vl, int mode, u64 data)
2469 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2471 return dd->rcv_err_status_cnt[25];
2474 static u64 access_rx_rbuf_csr_q_vld_bit_parity_err_cnt(
2475 const struct cntr_entry *entry,
2476 void *context, int vl, int mode, u64 data)
2478 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2480 return dd->rcv_err_status_cnt[24];
2483 static u64 access_rx_rbuf_csr_q_next_buf_parity_err_cnt(
2484 const struct cntr_entry *entry,
2485 void *context, int vl, int mode, u64 data)
2487 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2489 return dd->rcv_err_status_cnt[23];
2492 static u64 access_rx_rbuf_csr_q_ent_cnt_parity_err_cnt(
2493 const struct cntr_entry *entry,
2494 void *context, int vl, int mode, u64 data)
2496 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2498 return dd->rcv_err_status_cnt[22];
2501 static u64 access_rx_rbuf_csr_q_head_buf_num_parity_err_cnt(
2502 const struct cntr_entry *entry,
2503 void *context, int vl, int mode, u64 data)
2505 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2507 return dd->rcv_err_status_cnt[21];
2510 static u64 access_rx_rbuf_block_list_read_cor_err_cnt(
2511 const struct cntr_entry *entry,
2512 void *context, int vl, int mode, u64 data)
2514 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2516 return dd->rcv_err_status_cnt[20];
2519 static u64 access_rx_rbuf_block_list_read_unc_err_cnt(
2520 const struct cntr_entry *entry,
2521 void *context, int vl, int mode, u64 data)
2523 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2525 return dd->rcv_err_status_cnt[19];
2528 static u64 access_rx_rbuf_lookup_des_cor_err_cnt(const struct cntr_entry *entry,
2529 void *context, int vl,
2532 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2534 return dd->rcv_err_status_cnt[18];
2537 static u64 access_rx_rbuf_lookup_des_unc_err_cnt(const struct cntr_entry *entry,
2538 void *context, int vl,
2541 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2543 return dd->rcv_err_status_cnt[17];
2546 static u64 access_rx_rbuf_lookup_des_reg_unc_cor_err_cnt(
2547 const struct cntr_entry *entry,
2548 void *context, int vl, int mode, u64 data)
2550 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2552 return dd->rcv_err_status_cnt[16];
2555 static u64 access_rx_rbuf_lookup_des_reg_unc_err_cnt(
2556 const struct cntr_entry *entry,
2557 void *context, int vl, int mode, u64 data)
2559 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2561 return dd->rcv_err_status_cnt[15];
2564 static u64 access_rx_rbuf_free_list_cor_err_cnt(const struct cntr_entry *entry,
2565 void *context, int vl,
2568 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2570 return dd->rcv_err_status_cnt[14];
2573 static u64 access_rx_rbuf_free_list_unc_err_cnt(const struct cntr_entry *entry,
2574 void *context, int vl,
2577 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2579 return dd->rcv_err_status_cnt[13];
2582 static u64 access_rx_rcv_fsm_encoding_err_cnt(const struct cntr_entry *entry,
2583 void *context, int vl, int mode,
2586 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2588 return dd->rcv_err_status_cnt[12];
2591 static u64 access_rx_dma_flag_cor_err_cnt(const struct cntr_entry *entry,
2592 void *context, int vl, int mode,
2595 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2597 return dd->rcv_err_status_cnt[11];
2600 static u64 access_rx_dma_flag_unc_err_cnt(const struct cntr_entry *entry,
2601 void *context, int vl, int mode,
2604 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2606 return dd->rcv_err_status_cnt[10];
2609 static u64 access_rx_dc_sop_eop_parity_err_cnt(const struct cntr_entry *entry,
2610 void *context, int vl, int mode,
2613 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2615 return dd->rcv_err_status_cnt[9];
2618 static u64 access_rx_rcv_csr_parity_err_cnt(const struct cntr_entry *entry,
2619 void *context, int vl, int mode,
2622 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2624 return dd->rcv_err_status_cnt[8];
2627 static u64 access_rx_rcv_qp_map_table_cor_err_cnt(
2628 const struct cntr_entry *entry,
2629 void *context, int vl, int mode, u64 data)
2631 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2633 return dd->rcv_err_status_cnt[7];
2636 static u64 access_rx_rcv_qp_map_table_unc_err_cnt(
2637 const struct cntr_entry *entry,
2638 void *context, int vl, int mode, u64 data)
2640 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2642 return dd->rcv_err_status_cnt[6];
2645 static u64 access_rx_rcv_data_cor_err_cnt(const struct cntr_entry *entry,
2646 void *context, int vl, int mode,
2649 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2651 return dd->rcv_err_status_cnt[5];
2654 static u64 access_rx_rcv_data_unc_err_cnt(const struct cntr_entry *entry,
2655 void *context, int vl, int mode,
2658 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2660 return dd->rcv_err_status_cnt[4];
2663 static u64 access_rx_rcv_hdr_cor_err_cnt(const struct cntr_entry *entry,
2664 void *context, int vl, int mode,
2667 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2669 return dd->rcv_err_status_cnt[3];
2672 static u64 access_rx_rcv_hdr_unc_err_cnt(const struct cntr_entry *entry,
2673 void *context, int vl, int mode,
2676 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2678 return dd->rcv_err_status_cnt[2];
2681 static u64 access_rx_dc_intf_parity_err_cnt(const struct cntr_entry *entry,
2682 void *context, int vl, int mode,
2685 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2687 return dd->rcv_err_status_cnt[1];
2690 static u64 access_rx_dma_csr_cor_err_cnt(const struct cntr_entry *entry,
2691 void *context, int vl, int mode,
2694 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2696 return dd->rcv_err_status_cnt[0];
2700 * Software counters corresponding to each of the
2701 * error status bits within SendPioErrStatus
2703 static u64 access_pio_pec_sop_head_parity_err_cnt(
2704 const struct cntr_entry *entry,
2705 void *context, int vl, int mode, u64 data)
2707 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2709 return dd->send_pio_err_status_cnt[35];
2712 static u64 access_pio_pcc_sop_head_parity_err_cnt(
2713 const struct cntr_entry *entry,
2714 void *context, int vl, int mode, u64 data)
2716 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2718 return dd->send_pio_err_status_cnt[34];
2721 static u64 access_pio_last_returned_cnt_parity_err_cnt(
2722 const struct cntr_entry *entry,
2723 void *context, int vl, int mode, u64 data)
2725 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2727 return dd->send_pio_err_status_cnt[33];
2730 static u64 access_pio_current_free_cnt_parity_err_cnt(
2731 const struct cntr_entry *entry,
2732 void *context, int vl, int mode, u64 data)
2734 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2736 return dd->send_pio_err_status_cnt[32];
2739 static u64 access_pio_reserved_31_err_cnt(const struct cntr_entry *entry,
2740 void *context, int vl, int mode,
2743 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2745 return dd->send_pio_err_status_cnt[31];
2748 static u64 access_pio_reserved_30_err_cnt(const struct cntr_entry *entry,
2749 void *context, int vl, int mode,
2752 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2754 return dd->send_pio_err_status_cnt[30];
2757 static u64 access_pio_ppmc_sop_len_err_cnt(const struct cntr_entry *entry,
2758 void *context, int vl, int mode,
2761 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2763 return dd->send_pio_err_status_cnt[29];
2766 static u64 access_pio_ppmc_bqc_mem_parity_err_cnt(
2767 const struct cntr_entry *entry,
2768 void *context, int vl, int mode, u64 data)
2770 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2772 return dd->send_pio_err_status_cnt[28];
2775 static u64 access_pio_vl_fifo_parity_err_cnt(const struct cntr_entry *entry,
2776 void *context, int vl, int mode,
2779 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2781 return dd->send_pio_err_status_cnt[27];
2784 static u64 access_pio_vlf_sop_parity_err_cnt(const struct cntr_entry *entry,
2785 void *context, int vl, int mode,
2788 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2790 return dd->send_pio_err_status_cnt[26];
2793 static u64 access_pio_vlf_v1_len_parity_err_cnt(const struct cntr_entry *entry,
2794 void *context, int vl,
2797 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2799 return dd->send_pio_err_status_cnt[25];
2802 static u64 access_pio_block_qw_count_parity_err_cnt(
2803 const struct cntr_entry *entry,
2804 void *context, int vl, int mode, u64 data)
2806 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2808 return dd->send_pio_err_status_cnt[24];
2811 static u64 access_pio_write_qw_valid_parity_err_cnt(
2812 const struct cntr_entry *entry,
2813 void *context, int vl, int mode, u64 data)
2815 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2817 return dd->send_pio_err_status_cnt[23];
2820 static u64 access_pio_state_machine_err_cnt(const struct cntr_entry *entry,
2821 void *context, int vl, int mode,
2824 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2826 return dd->send_pio_err_status_cnt[22];
2829 static u64 access_pio_write_data_parity_err_cnt(const struct cntr_entry *entry,
2830 void *context, int vl,
2833 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2835 return dd->send_pio_err_status_cnt[21];
2838 static u64 access_pio_host_addr_mem_cor_err_cnt(const struct cntr_entry *entry,
2839 void *context, int vl,
2842 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2844 return dd->send_pio_err_status_cnt[20];
2847 static u64 access_pio_host_addr_mem_unc_err_cnt(const struct cntr_entry *entry,
2848 void *context, int vl,
2851 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2853 return dd->send_pio_err_status_cnt[19];
2856 static u64 access_pio_pkt_evict_sm_or_arb_sm_err_cnt(
2857 const struct cntr_entry *entry,
2858 void *context, int vl, int mode, u64 data)
2860 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2862 return dd->send_pio_err_status_cnt[18];
2865 static u64 access_pio_init_sm_in_err_cnt(const struct cntr_entry *entry,
2866 void *context, int vl, int mode,
2869 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2871 return dd->send_pio_err_status_cnt[17];
2874 static u64 access_pio_ppmc_pbl_fifo_err_cnt(const struct cntr_entry *entry,
2875 void *context, int vl, int mode,
2878 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2880 return dd->send_pio_err_status_cnt[16];
2883 static u64 access_pio_credit_ret_fifo_parity_err_cnt(
2884 const struct cntr_entry *entry,
2885 void *context, int vl, int mode, u64 data)
2887 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2889 return dd->send_pio_err_status_cnt[15];
2892 static u64 access_pio_v1_len_mem_bank1_cor_err_cnt(
2893 const struct cntr_entry *entry,
2894 void *context, int vl, int mode, u64 data)
2896 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2898 return dd->send_pio_err_status_cnt[14];
2901 static u64 access_pio_v1_len_mem_bank0_cor_err_cnt(
2902 const struct cntr_entry *entry,
2903 void *context, int vl, int mode, u64 data)
2905 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2907 return dd->send_pio_err_status_cnt[13];
2910 static u64 access_pio_v1_len_mem_bank1_unc_err_cnt(
2911 const struct cntr_entry *entry,
2912 void *context, int vl, int mode, u64 data)
2914 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2916 return dd->send_pio_err_status_cnt[12];
2919 static u64 access_pio_v1_len_mem_bank0_unc_err_cnt(
2920 const struct cntr_entry *entry,
2921 void *context, int vl, int mode, u64 data)
2923 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2925 return dd->send_pio_err_status_cnt[11];
2928 static u64 access_pio_sm_pkt_reset_parity_err_cnt(
2929 const struct cntr_entry *entry,
2930 void *context, int vl, int mode, u64 data)
2932 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2934 return dd->send_pio_err_status_cnt[10];
2937 static u64 access_pio_pkt_evict_fifo_parity_err_cnt(
2938 const struct cntr_entry *entry,
2939 void *context, int vl, int mode, u64 data)
2941 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2943 return dd->send_pio_err_status_cnt[9];
2946 static u64 access_pio_sbrdctrl_crrel_fifo_parity_err_cnt(
2947 const struct cntr_entry *entry,
2948 void *context, int vl, int mode, u64 data)
2950 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2952 return dd->send_pio_err_status_cnt[8];
2955 static u64 access_pio_sbrdctl_crrel_parity_err_cnt(
2956 const struct cntr_entry *entry,
2957 void *context, int vl, int mode, u64 data)
2959 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2961 return dd->send_pio_err_status_cnt[7];
2964 static u64 access_pio_pec_fifo_parity_err_cnt(const struct cntr_entry *entry,
2965 void *context, int vl, int mode,
2968 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2970 return dd->send_pio_err_status_cnt[6];
2973 static u64 access_pio_pcc_fifo_parity_err_cnt(const struct cntr_entry *entry,
2974 void *context, int vl, int mode,
2977 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2979 return dd->send_pio_err_status_cnt[5];
2982 static u64 access_pio_sb_mem_fifo1_err_cnt(const struct cntr_entry *entry,
2983 void *context, int vl, int mode,
2986 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2988 return dd->send_pio_err_status_cnt[4];
2991 static u64 access_pio_sb_mem_fifo0_err_cnt(const struct cntr_entry *entry,
2992 void *context, int vl, int mode,
2995 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
2997 return dd->send_pio_err_status_cnt[3];
3000 static u64 access_pio_csr_parity_err_cnt(const struct cntr_entry *entry,
3001 void *context, int vl, int mode,
3004 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3006 return dd->send_pio_err_status_cnt[2];
3009 static u64 access_pio_write_addr_parity_err_cnt(const struct cntr_entry *entry,
3010 void *context, int vl,
3013 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3015 return dd->send_pio_err_status_cnt[1];
3018 static u64 access_pio_write_bad_ctxt_err_cnt(const struct cntr_entry *entry,
3019 void *context, int vl, int mode,
3022 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3024 return dd->send_pio_err_status_cnt[0];
3028 * Software counters corresponding to each of the
3029 * error status bits within SendDmaErrStatus
3031 static u64 access_sdma_pcie_req_tracking_cor_err_cnt(
3032 const struct cntr_entry *entry,
3033 void *context, int vl, int mode, u64 data)
3035 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3037 return dd->send_dma_err_status_cnt[3];
3040 static u64 access_sdma_pcie_req_tracking_unc_err_cnt(
3041 const struct cntr_entry *entry,
3042 void *context, int vl, int mode, u64 data)
3044 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3046 return dd->send_dma_err_status_cnt[2];
3049 static u64 access_sdma_csr_parity_err_cnt(const struct cntr_entry *entry,
3050 void *context, int vl, int mode,
3053 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3055 return dd->send_dma_err_status_cnt[1];
3058 static u64 access_sdma_rpy_tag_err_cnt(const struct cntr_entry *entry,
3059 void *context, int vl, int mode,
3062 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3064 return dd->send_dma_err_status_cnt[0];
3068 * Software counters corresponding to each of the
3069 * error status bits within SendEgressErrStatus
3071 static u64 access_tx_read_pio_memory_csr_unc_err_cnt(
3072 const struct cntr_entry *entry,
3073 void *context, int vl, int mode, u64 data)
3075 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3077 return dd->send_egress_err_status_cnt[63];
3080 static u64 access_tx_read_sdma_memory_csr_err_cnt(
3081 const struct cntr_entry *entry,
3082 void *context, int vl, int mode, u64 data)
3084 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3086 return dd->send_egress_err_status_cnt[62];
3089 static u64 access_tx_egress_fifo_cor_err_cnt(const struct cntr_entry *entry,
3090 void *context, int vl, int mode,
3093 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3095 return dd->send_egress_err_status_cnt[61];
3098 static u64 access_tx_read_pio_memory_cor_err_cnt(const struct cntr_entry *entry,
3099 void *context, int vl,
3102 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3104 return dd->send_egress_err_status_cnt[60];
3107 static u64 access_tx_read_sdma_memory_cor_err_cnt(
3108 const struct cntr_entry *entry,
3109 void *context, int vl, int mode, u64 data)
3111 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3113 return dd->send_egress_err_status_cnt[59];
3116 static u64 access_tx_sb_hdr_cor_err_cnt(const struct cntr_entry *entry,
3117 void *context, int vl, int mode,
3120 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3122 return dd->send_egress_err_status_cnt[58];
3125 static u64 access_tx_credit_overrun_err_cnt(const struct cntr_entry *entry,
3126 void *context, int vl, int mode,
3129 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3131 return dd->send_egress_err_status_cnt[57];
3134 static u64 access_tx_launch_fifo8_cor_err_cnt(const struct cntr_entry *entry,
3135 void *context, int vl, int mode,
3138 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3140 return dd->send_egress_err_status_cnt[56];
3143 static u64 access_tx_launch_fifo7_cor_err_cnt(const struct cntr_entry *entry,
3144 void *context, int vl, int mode,
3147 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3149 return dd->send_egress_err_status_cnt[55];
3152 static u64 access_tx_launch_fifo6_cor_err_cnt(const struct cntr_entry *entry,
3153 void *context, int vl, int mode,
3156 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3158 return dd->send_egress_err_status_cnt[54];
3161 static u64 access_tx_launch_fifo5_cor_err_cnt(const struct cntr_entry *entry,
3162 void *context, int vl, int mode,
3165 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3167 return dd->send_egress_err_status_cnt[53];
3170 static u64 access_tx_launch_fifo4_cor_err_cnt(const struct cntr_entry *entry,
3171 void *context, int vl, int mode,
3174 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3176 return dd->send_egress_err_status_cnt[52];
3179 static u64 access_tx_launch_fifo3_cor_err_cnt(const struct cntr_entry *entry,
3180 void *context, int vl, int mode,
3183 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3185 return dd->send_egress_err_status_cnt[51];
3188 static u64 access_tx_launch_fifo2_cor_err_cnt(const struct cntr_entry *entry,
3189 void *context, int vl, int mode,
3192 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3194 return dd->send_egress_err_status_cnt[50];
3197 static u64 access_tx_launch_fifo1_cor_err_cnt(const struct cntr_entry *entry,
3198 void *context, int vl, int mode,
3201 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3203 return dd->send_egress_err_status_cnt[49];
3206 static u64 access_tx_launch_fifo0_cor_err_cnt(const struct cntr_entry *entry,
3207 void *context, int vl, int mode,
3210 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3212 return dd->send_egress_err_status_cnt[48];
3215 static u64 access_tx_credit_return_vl_err_cnt(const struct cntr_entry *entry,
3216 void *context, int vl, int mode,
3219 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3221 return dd->send_egress_err_status_cnt[47];
3224 static u64 access_tx_hcrc_insertion_err_cnt(const struct cntr_entry *entry,
3225 void *context, int vl, int mode,
3228 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3230 return dd->send_egress_err_status_cnt[46];
3233 static u64 access_tx_egress_fifo_unc_err_cnt(const struct cntr_entry *entry,
3234 void *context, int vl, int mode,
3237 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3239 return dd->send_egress_err_status_cnt[45];
3242 static u64 access_tx_read_pio_memory_unc_err_cnt(const struct cntr_entry *entry,
3243 void *context, int vl,
3246 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3248 return dd->send_egress_err_status_cnt[44];
3251 static u64 access_tx_read_sdma_memory_unc_err_cnt(
3252 const struct cntr_entry *entry,
3253 void *context, int vl, int mode, u64 data)
3255 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3257 return dd->send_egress_err_status_cnt[43];
3260 static u64 access_tx_sb_hdr_unc_err_cnt(const struct cntr_entry *entry,
3261 void *context, int vl, int mode,
3264 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3266 return dd->send_egress_err_status_cnt[42];
3269 static u64 access_tx_credit_return_partiy_err_cnt(
3270 const struct cntr_entry *entry,
3271 void *context, int vl, int mode, u64 data)
3273 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3275 return dd->send_egress_err_status_cnt[41];
3278 static u64 access_tx_launch_fifo8_unc_or_parity_err_cnt(
3279 const struct cntr_entry *entry,
3280 void *context, int vl, int mode, u64 data)
3282 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3284 return dd->send_egress_err_status_cnt[40];
3287 static u64 access_tx_launch_fifo7_unc_or_parity_err_cnt(
3288 const struct cntr_entry *entry,
3289 void *context, int vl, int mode, u64 data)
3291 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3293 return dd->send_egress_err_status_cnt[39];
3296 static u64 access_tx_launch_fifo6_unc_or_parity_err_cnt(
3297 const struct cntr_entry *entry,
3298 void *context, int vl, int mode, u64 data)
3300 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3302 return dd->send_egress_err_status_cnt[38];
3305 static u64 access_tx_launch_fifo5_unc_or_parity_err_cnt(
3306 const struct cntr_entry *entry,
3307 void *context, int vl, int mode, u64 data)
3309 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3311 return dd->send_egress_err_status_cnt[37];
3314 static u64 access_tx_launch_fifo4_unc_or_parity_err_cnt(
3315 const struct cntr_entry *entry,
3316 void *context, int vl, int mode, u64 data)
3318 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3320 return dd->send_egress_err_status_cnt[36];
3323 static u64 access_tx_launch_fifo3_unc_or_parity_err_cnt(
3324 const struct cntr_entry *entry,
3325 void *context, int vl, int mode, u64 data)
3327 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3329 return dd->send_egress_err_status_cnt[35];
3332 static u64 access_tx_launch_fifo2_unc_or_parity_err_cnt(
3333 const struct cntr_entry *entry,
3334 void *context, int vl, int mode, u64 data)
3336 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3338 return dd->send_egress_err_status_cnt[34];
3341 static u64 access_tx_launch_fifo1_unc_or_parity_err_cnt(
3342 const struct cntr_entry *entry,
3343 void *context, int vl, int mode, u64 data)
3345 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3347 return dd->send_egress_err_status_cnt[33];
3350 static u64 access_tx_launch_fifo0_unc_or_parity_err_cnt(
3351 const struct cntr_entry *entry,
3352 void *context, int vl, int mode, u64 data)
3354 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3356 return dd->send_egress_err_status_cnt[32];
3359 static u64 access_tx_sdma15_disallowed_packet_err_cnt(
3360 const struct cntr_entry *entry,
3361 void *context, int vl, int mode, u64 data)
3363 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3365 return dd->send_egress_err_status_cnt[31];
3368 static u64 access_tx_sdma14_disallowed_packet_err_cnt(
3369 const struct cntr_entry *entry,
3370 void *context, int vl, int mode, u64 data)
3372 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3374 return dd->send_egress_err_status_cnt[30];
3377 static u64 access_tx_sdma13_disallowed_packet_err_cnt(
3378 const struct cntr_entry *entry,
3379 void *context, int vl, int mode, u64 data)
3381 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3383 return dd->send_egress_err_status_cnt[29];
3386 static u64 access_tx_sdma12_disallowed_packet_err_cnt(
3387 const struct cntr_entry *entry,
3388 void *context, int vl, int mode, u64 data)
3390 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3392 return dd->send_egress_err_status_cnt[28];
3395 static u64 access_tx_sdma11_disallowed_packet_err_cnt(
3396 const struct cntr_entry *entry,
3397 void *context, int vl, int mode, u64 data)
3399 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3401 return dd->send_egress_err_status_cnt[27];
3404 static u64 access_tx_sdma10_disallowed_packet_err_cnt(
3405 const struct cntr_entry *entry,
3406 void *context, int vl, int mode, u64 data)
3408 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3410 return dd->send_egress_err_status_cnt[26];
3413 static u64 access_tx_sdma9_disallowed_packet_err_cnt(
3414 const struct cntr_entry *entry,
3415 void *context, int vl, int mode, u64 data)
3417 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3419 return dd->send_egress_err_status_cnt[25];
3422 static u64 access_tx_sdma8_disallowed_packet_err_cnt(
3423 const struct cntr_entry *entry,
3424 void *context, int vl, int mode, u64 data)
3426 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3428 return dd->send_egress_err_status_cnt[24];
3431 static u64 access_tx_sdma7_disallowed_packet_err_cnt(
3432 const struct cntr_entry *entry,
3433 void *context, int vl, int mode, u64 data)
3435 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3437 return dd->send_egress_err_status_cnt[23];
3440 static u64 access_tx_sdma6_disallowed_packet_err_cnt(
3441 const struct cntr_entry *entry,
3442 void *context, int vl, int mode, u64 data)
3444 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3446 return dd->send_egress_err_status_cnt[22];
3449 static u64 access_tx_sdma5_disallowed_packet_err_cnt(
3450 const struct cntr_entry *entry,
3451 void *context, int vl, int mode, u64 data)
3453 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3455 return dd->send_egress_err_status_cnt[21];
3458 static u64 access_tx_sdma4_disallowed_packet_err_cnt(
3459 const struct cntr_entry *entry,
3460 void *context, int vl, int mode, u64 data)
3462 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3464 return dd->send_egress_err_status_cnt[20];
3467 static u64 access_tx_sdma3_disallowed_packet_err_cnt(
3468 const struct cntr_entry *entry,
3469 void *context, int vl, int mode, u64 data)
3471 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3473 return dd->send_egress_err_status_cnt[19];
3476 static u64 access_tx_sdma2_disallowed_packet_err_cnt(
3477 const struct cntr_entry *entry,
3478 void *context, int vl, int mode, u64 data)
3480 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3482 return dd->send_egress_err_status_cnt[18];
3485 static u64 access_tx_sdma1_disallowed_packet_err_cnt(
3486 const struct cntr_entry *entry,
3487 void *context, int vl, int mode, u64 data)
3489 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3491 return dd->send_egress_err_status_cnt[17];
3494 static u64 access_tx_sdma0_disallowed_packet_err_cnt(
3495 const struct cntr_entry *entry,
3496 void *context, int vl, int mode, u64 data)
3498 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3500 return dd->send_egress_err_status_cnt[16];
3503 static u64 access_tx_config_parity_err_cnt(const struct cntr_entry *entry,
3504 void *context, int vl, int mode,
3507 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3509 return dd->send_egress_err_status_cnt[15];
3512 static u64 access_tx_sbrd_ctl_csr_parity_err_cnt(const struct cntr_entry *entry,
3513 void *context, int vl,
3516 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3518 return dd->send_egress_err_status_cnt[14];
3521 static u64 access_tx_launch_csr_parity_err_cnt(const struct cntr_entry *entry,
3522 void *context, int vl, int mode,
3525 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3527 return dd->send_egress_err_status_cnt[13];
3530 static u64 access_tx_illegal_vl_err_cnt(const struct cntr_entry *entry,
3531 void *context, int vl, int mode,
3534 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3536 return dd->send_egress_err_status_cnt[12];
3539 static u64 access_tx_sbrd_ctl_state_machine_parity_err_cnt(
3540 const struct cntr_entry *entry,
3541 void *context, int vl, int mode, u64 data)
3543 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3545 return dd->send_egress_err_status_cnt[11];
3548 static u64 access_egress_reserved_10_err_cnt(const struct cntr_entry *entry,
3549 void *context, int vl, int mode,
3552 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3554 return dd->send_egress_err_status_cnt[10];
3557 static u64 access_egress_reserved_9_err_cnt(const struct cntr_entry *entry,
3558 void *context, int vl, int mode,
3561 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3563 return dd->send_egress_err_status_cnt[9];
3566 static u64 access_tx_sdma_launch_intf_parity_err_cnt(
3567 const struct cntr_entry *entry,
3568 void *context, int vl, int mode, u64 data)
3570 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3572 return dd->send_egress_err_status_cnt[8];
3575 static u64 access_tx_pio_launch_intf_parity_err_cnt(
3576 const struct cntr_entry *entry,
3577 void *context, int vl, int mode, u64 data)
3579 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3581 return dd->send_egress_err_status_cnt[7];
3584 static u64 access_egress_reserved_6_err_cnt(const struct cntr_entry *entry,
3585 void *context, int vl, int mode,
3588 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3590 return dd->send_egress_err_status_cnt[6];
3593 static u64 access_tx_incorrect_link_state_err_cnt(
3594 const struct cntr_entry *entry,
3595 void *context, int vl, int mode, u64 data)
3597 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3599 return dd->send_egress_err_status_cnt[5];
3602 static u64 access_tx_linkdown_err_cnt(const struct cntr_entry *entry,
3603 void *context, int vl, int mode,
3606 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3608 return dd->send_egress_err_status_cnt[4];
3611 static u64 access_tx_egress_fifi_underrun_or_parity_err_cnt(
3612 const struct cntr_entry *entry,
3613 void *context, int vl, int mode, u64 data)
3615 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3617 return dd->send_egress_err_status_cnt[3];
3620 static u64 access_egress_reserved_2_err_cnt(const struct cntr_entry *entry,
3621 void *context, int vl, int mode,
3624 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3626 return dd->send_egress_err_status_cnt[2];
3629 static u64 access_tx_pkt_integrity_mem_unc_err_cnt(
3630 const struct cntr_entry *entry,
3631 void *context, int vl, int mode, u64 data)
3633 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3635 return dd->send_egress_err_status_cnt[1];
3638 static u64 access_tx_pkt_integrity_mem_cor_err_cnt(
3639 const struct cntr_entry *entry,
3640 void *context, int vl, int mode, u64 data)
3642 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3644 return dd->send_egress_err_status_cnt[0];
3648 * Software counters corresponding to each of the
3649 * error status bits within SendErrStatus
3651 static u64 access_send_csr_write_bad_addr_err_cnt(
3652 const struct cntr_entry *entry,
3653 void *context, int vl, int mode, u64 data)
3655 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3657 return dd->send_err_status_cnt[2];
3660 static u64 access_send_csr_read_bad_addr_err_cnt(const struct cntr_entry *entry,
3661 void *context, int vl,
3664 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3666 return dd->send_err_status_cnt[1];
3669 static u64 access_send_csr_parity_cnt(const struct cntr_entry *entry,
3670 void *context, int vl, int mode,
3673 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3675 return dd->send_err_status_cnt[0];
3679 * Software counters corresponding to each of the
3680 * error status bits within SendCtxtErrStatus
3682 static u64 access_pio_write_out_of_bounds_err_cnt(
3683 const struct cntr_entry *entry,
3684 void *context, int vl, int mode, u64 data)
3686 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3688 return dd->sw_ctxt_err_status_cnt[4];
3691 static u64 access_pio_write_overflow_err_cnt(const struct cntr_entry *entry,
3692 void *context, int vl, int mode,
3695 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3697 return dd->sw_ctxt_err_status_cnt[3];
3700 static u64 access_pio_write_crosses_boundary_err_cnt(
3701 const struct cntr_entry *entry,
3702 void *context, int vl, int mode, u64 data)
3704 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3706 return dd->sw_ctxt_err_status_cnt[2];
3709 static u64 access_pio_disallowed_packet_err_cnt(const struct cntr_entry *entry,
3710 void *context, int vl,
3713 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3715 return dd->sw_ctxt_err_status_cnt[1];
3718 static u64 access_pio_inconsistent_sop_err_cnt(const struct cntr_entry *entry,
3719 void *context, int vl, int mode,
3722 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3724 return dd->sw_ctxt_err_status_cnt[0];
3728 * Software counters corresponding to each of the
3729 * error status bits within SendDmaEngErrStatus
3731 static u64 access_sdma_header_request_fifo_cor_err_cnt(
3732 const struct cntr_entry *entry,
3733 void *context, int vl, int mode, u64 data)
3735 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3737 return dd->sw_send_dma_eng_err_status_cnt[23];
3740 static u64 access_sdma_header_storage_cor_err_cnt(
3741 const struct cntr_entry *entry,
3742 void *context, int vl, int mode, u64 data)
3744 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3746 return dd->sw_send_dma_eng_err_status_cnt[22];
3749 static u64 access_sdma_packet_tracking_cor_err_cnt(
3750 const struct cntr_entry *entry,
3751 void *context, int vl, int mode, u64 data)
3753 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3755 return dd->sw_send_dma_eng_err_status_cnt[21];
3758 static u64 access_sdma_assembly_cor_err_cnt(const struct cntr_entry *entry,
3759 void *context, int vl, int mode,
3762 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3764 return dd->sw_send_dma_eng_err_status_cnt[20];
3767 static u64 access_sdma_desc_table_cor_err_cnt(const struct cntr_entry *entry,
3768 void *context, int vl, int mode,
3771 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3773 return dd->sw_send_dma_eng_err_status_cnt[19];
3776 static u64 access_sdma_header_request_fifo_unc_err_cnt(
3777 const struct cntr_entry *entry,
3778 void *context, int vl, int mode, u64 data)
3780 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3782 return dd->sw_send_dma_eng_err_status_cnt[18];
3785 static u64 access_sdma_header_storage_unc_err_cnt(
3786 const struct cntr_entry *entry,
3787 void *context, int vl, int mode, u64 data)
3789 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3791 return dd->sw_send_dma_eng_err_status_cnt[17];
3794 static u64 access_sdma_packet_tracking_unc_err_cnt(
3795 const struct cntr_entry *entry,
3796 void *context, int vl, int mode, u64 data)
3798 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3800 return dd->sw_send_dma_eng_err_status_cnt[16];
3803 static u64 access_sdma_assembly_unc_err_cnt(const struct cntr_entry *entry,
3804 void *context, int vl, int mode,
3807 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3809 return dd->sw_send_dma_eng_err_status_cnt[15];
3812 static u64 access_sdma_desc_table_unc_err_cnt(const struct cntr_entry *entry,
3813 void *context, int vl, int mode,
3816 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3818 return dd->sw_send_dma_eng_err_status_cnt[14];
3821 static u64 access_sdma_timeout_err_cnt(const struct cntr_entry *entry,
3822 void *context, int vl, int mode,
3825 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3827 return dd->sw_send_dma_eng_err_status_cnt[13];
3830 static u64 access_sdma_header_length_err_cnt(const struct cntr_entry *entry,
3831 void *context, int vl, int mode,
3834 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3836 return dd->sw_send_dma_eng_err_status_cnt[12];
3839 static u64 access_sdma_header_address_err_cnt(const struct cntr_entry *entry,
3840 void *context, int vl, int mode,
3843 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3845 return dd->sw_send_dma_eng_err_status_cnt[11];
3848 static u64 access_sdma_header_select_err_cnt(const struct cntr_entry *entry,
3849 void *context, int vl, int mode,
3852 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3854 return dd->sw_send_dma_eng_err_status_cnt[10];
3857 static u64 access_sdma_reserved_9_err_cnt(const struct cntr_entry *entry,
3858 void *context, int vl, int mode,
3861 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3863 return dd->sw_send_dma_eng_err_status_cnt[9];
3866 static u64 access_sdma_packet_desc_overflow_err_cnt(
3867 const struct cntr_entry *entry,
3868 void *context, int vl, int mode, u64 data)
3870 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3872 return dd->sw_send_dma_eng_err_status_cnt[8];
3875 static u64 access_sdma_length_mismatch_err_cnt(const struct cntr_entry *entry,
3876 void *context, int vl,
3879 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3881 return dd->sw_send_dma_eng_err_status_cnt[7];
3884 static u64 access_sdma_halt_err_cnt(const struct cntr_entry *entry,
3885 void *context, int vl, int mode, u64 data)
3887 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3889 return dd->sw_send_dma_eng_err_status_cnt[6];
3892 static u64 access_sdma_mem_read_err_cnt(const struct cntr_entry *entry,
3893 void *context, int vl, int mode,
3896 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3898 return dd->sw_send_dma_eng_err_status_cnt[5];
3901 static u64 access_sdma_first_desc_err_cnt(const struct cntr_entry *entry,
3902 void *context, int vl, int mode,
3905 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3907 return dd->sw_send_dma_eng_err_status_cnt[4];
3910 static u64 access_sdma_tail_out_of_bounds_err_cnt(
3911 const struct cntr_entry *entry,
3912 void *context, int vl, int mode, u64 data)
3914 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3916 return dd->sw_send_dma_eng_err_status_cnt[3];
3919 static u64 access_sdma_too_long_err_cnt(const struct cntr_entry *entry,
3920 void *context, int vl, int mode,
3923 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3925 return dd->sw_send_dma_eng_err_status_cnt[2];
3928 static u64 access_sdma_gen_mismatch_err_cnt(const struct cntr_entry *entry,
3929 void *context, int vl, int mode,
3932 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3934 return dd->sw_send_dma_eng_err_status_cnt[1];
3937 static u64 access_sdma_wrong_dw_err_cnt(const struct cntr_entry *entry,
3938 void *context, int vl, int mode,
3941 struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
3943 return dd->sw_send_dma_eng_err_status_cnt[0];
3946 #define def_access_sw_cpu(cntr) \
3947 static u64 access_sw_cpu_##cntr(const struct cntr_entry *entry, \
3948 void *context, int vl, int mode, u64 data) \
3950 struct hfi1_pportdata *ppd = (struct hfi1_pportdata *)context; \
3951 return read_write_cpu(ppd->dd, &ppd->ibport_data.rvp.z_ ##cntr, \
3952 ppd->ibport_data.rvp.cntr, vl, \
3956 def_access_sw_cpu(rc_acks);
3957 def_access_sw_cpu(rc_qacks);
3958 def_access_sw_cpu(rc_delayed_comp);
3960 #define def_access_ibp_counter(cntr) \
3961 static u64 access_ibp_##cntr(const struct cntr_entry *entry, \
3962 void *context, int vl, int mode, u64 data) \
3964 struct hfi1_pportdata *ppd = (struct hfi1_pportdata *)context; \
3966 if (vl != CNTR_INVALID_VL) \
3969 return read_write_sw(ppd->dd, &ppd->ibport_data.rvp.n_ ##cntr, \
3973 def_access_ibp_counter(loop_pkts);
3974 def_access_ibp_counter(rc_resends);
3975 def_access_ibp_counter(rnr_naks);
3976 def_access_ibp_counter(other_naks);
3977 def_access_ibp_counter(rc_timeouts);
3978 def_access_ibp_counter(pkt_drops);
3979 def_access_ibp_counter(dmawait);
3980 def_access_ibp_counter(rc_seqnak);
3981 def_access_ibp_counter(rc_dupreq);
3982 def_access_ibp_counter(rdma_seq);
3983 def_access_ibp_counter(unaligned);
3984 def_access_ibp_counter(seq_naks);
3986 static struct cntr_entry dev_cntrs[DEV_CNTR_LAST] = {
3987 [C_RCV_OVF] = RXE32_DEV_CNTR_ELEM(RcvOverflow, RCV_BUF_OVFL_CNT, CNTR_SYNTH),
3988 [C_RX_TID_FULL] = RXE32_DEV_CNTR_ELEM(RxTIDFullEr, RCV_TID_FULL_ERR_CNT,
3990 [C_RX_TID_INVALID] = RXE32_DEV_CNTR_ELEM(RxTIDInvalid, RCV_TID_VALID_ERR_CNT,
3992 [C_RX_TID_FLGMS] = RXE32_DEV_CNTR_ELEM(RxTidFLGMs,
3993 RCV_TID_FLOW_GEN_MISMATCH_CNT,
3995 [C_RX_CTX_EGRS] = RXE32_DEV_CNTR_ELEM(RxCtxEgrS, RCV_CONTEXT_EGR_STALL,
3997 [C_RCV_TID_FLSMS] = RXE32_DEV_CNTR_ELEM(RxTidFLSMs,
3998 RCV_TID_FLOW_SEQ_MISMATCH_CNT, CNTR_NORMAL),
3999 [C_CCE_PCI_CR_ST] = CCE_PERF_DEV_CNTR_ELEM(CcePciCrSt,
4000 CCE_PCIE_POSTED_CRDT_STALL_CNT, CNTR_NORMAL),
4001 [C_CCE_PCI_TR_ST] = CCE_PERF_DEV_CNTR_ELEM(CcePciTrSt, CCE_PCIE_TRGT_STALL_CNT,
4003 [C_CCE_PIO_WR_ST] = CCE_PERF_DEV_CNTR_ELEM(CcePioWrSt, CCE_PIO_WR_STALL_CNT,
4005 [C_CCE_ERR_INT] = CCE_INT_DEV_CNTR_ELEM(CceErrInt, CCE_ERR_INT_CNT,
4007 [C_CCE_SDMA_INT] = CCE_INT_DEV_CNTR_ELEM(CceSdmaInt, CCE_SDMA_INT_CNT,
4009 [C_CCE_MISC_INT] = CCE_INT_DEV_CNTR_ELEM(CceMiscInt, CCE_MISC_INT_CNT,
4011 [C_CCE_RCV_AV_INT] = CCE_INT_DEV_CNTR_ELEM(CceRcvAvInt, CCE_RCV_AVAIL_INT_CNT,
4013 [C_CCE_RCV_URG_INT] = CCE_INT_DEV_CNTR_ELEM(CceRcvUrgInt,
4014 CCE_RCV_URGENT_INT_CNT, CNTR_NORMAL),
4015 [C_CCE_SEND_CR_INT] = CCE_INT_DEV_CNTR_ELEM(CceSndCrInt,
4016 CCE_SEND_CREDIT_INT_CNT, CNTR_NORMAL),
4017 [C_DC_UNC_ERR] = DC_PERF_CNTR(DcUnctblErr, DCC_ERR_UNCORRECTABLE_CNT,
4019 [C_DC_RCV_ERR] = DC_PERF_CNTR(DcRecvErr, DCC_ERR_PORTRCV_ERR_CNT, CNTR_SYNTH),
4020 [C_DC_FM_CFG_ERR] = DC_PERF_CNTR(DcFmCfgErr, DCC_ERR_FMCONFIG_ERR_CNT,
4022 [C_DC_RMT_PHY_ERR] = DC_PERF_CNTR(DcRmtPhyErr, DCC_ERR_RCVREMOTE_PHY_ERR_CNT,
4024 [C_DC_DROPPED_PKT] = DC_PERF_CNTR(DcDroppedPkt, DCC_ERR_DROPPED_PKT_CNT,
4026 [C_DC_MC_XMIT_PKTS] = DC_PERF_CNTR(DcMcXmitPkts,
4027 DCC_PRF_PORT_XMIT_MULTICAST_CNT, CNTR_SYNTH),
4028 [C_DC_MC_RCV_PKTS] = DC_PERF_CNTR(DcMcRcvPkts,
4029 DCC_PRF_PORT_RCV_MULTICAST_PKT_CNT,
4031 [C_DC_XMIT_CERR] = DC_PERF_CNTR(DcXmitCorr,
4032 DCC_PRF_PORT_XMIT_CORRECTABLE_CNT, CNTR_SYNTH),
4033 [C_DC_RCV_CERR] = DC_PERF_CNTR(DcRcvCorrCnt, DCC_PRF_PORT_RCV_CORRECTABLE_CNT,
4035 [C_DC_RCV_FCC] = DC_PERF_CNTR(DcRxFCntl, DCC_PRF_RX_FLOW_CRTL_CNT,
4037 [C_DC_XMIT_FCC] = DC_PERF_CNTR(DcXmitFCntl, DCC_PRF_TX_FLOW_CRTL_CNT,
4039 [C_DC_XMIT_FLITS] = DC_PERF_CNTR(DcXmitFlits, DCC_PRF_PORT_XMIT_DATA_CNT,
4041 [C_DC_RCV_FLITS] = DC_PERF_CNTR(DcRcvFlits, DCC_PRF_PORT_RCV_DATA_CNT,
4043 [C_DC_XMIT_PKTS] = DC_PERF_CNTR(DcXmitPkts, DCC_PRF_PORT_XMIT_PKTS_CNT,
4045 [C_DC_RCV_PKTS] = DC_PERF_CNTR(DcRcvPkts, DCC_PRF_PORT_RCV_PKTS_CNT,
4047 [C_DC_RX_FLIT_VL] = DC_PERF_CNTR(DcRxFlitVl, DCC_PRF_PORT_VL_RCV_DATA_CNT,
4048 CNTR_SYNTH | CNTR_VL),
4049 [C_DC_RX_PKT_VL] = DC_PERF_CNTR(DcRxPktVl, DCC_PRF_PORT_VL_RCV_PKTS_CNT,
4050 CNTR_SYNTH | CNTR_VL),
4051 [C_DC_RCV_FCN] = DC_PERF_CNTR(DcRcvFcn, DCC_PRF_PORT_RCV_FECN_CNT, CNTR_SYNTH),
4052 [C_DC_RCV_FCN_VL] = DC_PERF_CNTR(DcRcvFcnVl, DCC_PRF_PORT_VL_RCV_FECN_CNT,
4053 CNTR_SYNTH | CNTR_VL),
4054 [C_DC_RCV_BCN] = DC_PERF_CNTR(DcRcvBcn, DCC_PRF_PORT_RCV_BECN_CNT, CNTR_SYNTH),
4055 [C_DC_RCV_BCN_VL] = DC_PERF_CNTR(DcRcvBcnVl, DCC_PRF_PORT_VL_RCV_BECN_CNT,
4056 CNTR_SYNTH | CNTR_VL),
4057 [C_DC_RCV_BBL] = DC_PERF_CNTR(DcRcvBbl, DCC_PRF_PORT_RCV_BUBBLE_CNT,
4059 [C_DC_RCV_BBL_VL] = DC_PERF_CNTR(DcRcvBblVl, DCC_PRF_PORT_VL_RCV_BUBBLE_CNT,
4060 CNTR_SYNTH | CNTR_VL),
4061 [C_DC_MARK_FECN] = DC_PERF_CNTR(DcMarkFcn, DCC_PRF_PORT_MARK_FECN_CNT,
4063 [C_DC_MARK_FECN_VL] = DC_PERF_CNTR(DcMarkFcnVl, DCC_PRF_PORT_VL_MARK_FECN_CNT,
4064 CNTR_SYNTH | CNTR_VL),
4066 DC_PERF_CNTR_LCB(DcTotCrc, DC_LCB_ERR_INFO_TOTAL_CRC_ERR,
4068 [C_DC_CRC_LN0] = DC_PERF_CNTR_LCB(DcCrcLn0, DC_LCB_ERR_INFO_CRC_ERR_LN0,
4070 [C_DC_CRC_LN1] = DC_PERF_CNTR_LCB(DcCrcLn1, DC_LCB_ERR_INFO_CRC_ERR_LN1,
4072 [C_DC_CRC_LN2] = DC_PERF_CNTR_LCB(DcCrcLn2, DC_LCB_ERR_INFO_CRC_ERR_LN2,
4074 [C_DC_CRC_LN3] = DC_PERF_CNTR_LCB(DcCrcLn3, DC_LCB_ERR_INFO_CRC_ERR_LN3,
4076 [C_DC_CRC_MULT_LN] =
4077 DC_PERF_CNTR_LCB(DcMultLn, DC_LCB_ERR_INFO_CRC_ERR_MULTI_LN,
4079 [C_DC_TX_REPLAY] = DC_PERF_CNTR_LCB(DcTxReplay, DC_LCB_ERR_INFO_TX_REPLAY_CNT,
4081 [C_DC_RX_REPLAY] = DC_PERF_CNTR_LCB(DcRxReplay, DC_LCB_ERR_INFO_RX_REPLAY_CNT,
4083 [C_DC_SEQ_CRC_CNT] =
4084 DC_PERF_CNTR_LCB(DcLinkSeqCrc, DC_LCB_ERR_INFO_SEQ_CRC_CNT,
4086 [C_DC_ESC0_ONLY_CNT] =
4087 DC_PERF_CNTR_LCB(DcEsc0, DC_LCB_ERR_INFO_ESCAPE_0_ONLY_CNT,
4089 [C_DC_ESC0_PLUS1_CNT] =
4090 DC_PERF_CNTR_LCB(DcEsc1, DC_LCB_ERR_INFO_ESCAPE_0_PLUS1_CNT,
4092 [C_DC_ESC0_PLUS2_CNT] =
4093 DC_PERF_CNTR_LCB(DcEsc0Plus2, DC_LCB_ERR_INFO_ESCAPE_0_PLUS2_CNT,
4095 [C_DC_REINIT_FROM_PEER_CNT] =
4096 DC_PERF_CNTR_LCB(DcReinitPeer, DC_LCB_ERR_INFO_REINIT_FROM_PEER_CNT,
4098 [C_DC_SBE_CNT] = DC_PERF_CNTR_LCB(DcSbe, DC_LCB_ERR_INFO_SBE_CNT,
4100 [C_DC_MISC_FLG_CNT] =
4101 DC_PERF_CNTR_LCB(DcMiscFlg, DC_LCB_ERR_INFO_MISC_FLG_CNT,
4103 [C_DC_PRF_GOOD_LTP_CNT] =
4104 DC_PERF_CNTR_LCB(DcGoodLTP, DC_LCB_PRF_GOOD_LTP_CNT, CNTR_SYNTH),
4105 [C_DC_PRF_ACCEPTED_LTP_CNT] =
4106 DC_PERF_CNTR_LCB(DcAccLTP, DC_LCB_PRF_ACCEPTED_LTP_CNT,
4108 [C_DC_PRF_RX_FLIT_CNT] =
4109 DC_PERF_CNTR_LCB(DcPrfRxFlit, DC_LCB_PRF_RX_FLIT_CNT, CNTR_SYNTH),
4110 [C_DC_PRF_TX_FLIT_CNT] =
4111 DC_PERF_CNTR_LCB(DcPrfTxFlit, DC_LCB_PRF_TX_FLIT_CNT, CNTR_SYNTH),
4112 [C_DC_PRF_CLK_CNTR] =
4113 DC_PERF_CNTR_LCB(DcPrfClk, DC_LCB_PRF_CLK_CNTR, CNTR_SYNTH),
4114 [C_DC_PG_DBG_FLIT_CRDTS_CNT] =
4115 DC_PERF_CNTR_LCB(DcFltCrdts, DC_LCB_PG_DBG_FLIT_CRDTS_CNT, CNTR_SYNTH),
4116 [C_DC_PG_STS_PAUSE_COMPLETE_CNT] =
4117 DC_PERF_CNTR_LCB(DcPauseComp, DC_LCB_PG_STS_PAUSE_COMPLETE_CNT,
4119 [C_DC_PG_STS_TX_SBE_CNT] =
4120 DC_PERF_CNTR_LCB(DcStsTxSbe, DC_LCB_PG_STS_TX_SBE_CNT, CNTR_SYNTH),
4121 [C_DC_PG_STS_TX_MBE_CNT] =
4122 DC_PERF_CNTR_LCB(DcStsTxMbe, DC_LCB_PG_STS_TX_MBE_CNT,
4124 [C_SW_CPU_INTR] = CNTR_ELEM("Intr", 0, 0, CNTR_NORMAL,
4125 access_sw_cpu_intr),
4126 [C_SW_CPU_RCV_LIM] = CNTR_ELEM("RcvLimit", 0, 0, CNTR_NORMAL,
4127 access_sw_cpu_rcv_limit),
4128 [C_SW_VTX_WAIT] = CNTR_ELEM("vTxWait", 0, 0, CNTR_NORMAL,
4129 access_sw_vtx_wait),
4130 [C_SW_PIO_WAIT] = CNTR_ELEM("PioWait", 0, 0, CNTR_NORMAL,
4131 access_sw_pio_wait),
4132 [C_SW_PIO_DRAIN] = CNTR_ELEM("PioDrain", 0, 0, CNTR_NORMAL,
4133 access_sw_pio_drain),
4134 [C_SW_KMEM_WAIT] = CNTR_ELEM("KmemWait", 0, 0, CNTR_NORMAL,
4135 access_sw_kmem_wait),
4136 [C_SW_SEND_SCHED] = CNTR_ELEM("SendSched", 0, 0, CNTR_NORMAL,
4137 access_sw_send_schedule),
4138 [C_SDMA_DESC_FETCHED_CNT] = CNTR_ELEM("SDEDscFdCn",
4139 SEND_DMA_DESC_FETCHED_CNT, 0,
4140 CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
4141 dev_access_u32_csr),
4142 [C_SDMA_INT_CNT] = CNTR_ELEM("SDMAInt", 0, 0,
4143 CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
4144 access_sde_int_cnt),
4145 [C_SDMA_ERR_CNT] = CNTR_ELEM("SDMAErrCt", 0, 0,
4146 CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
4147 access_sde_err_cnt),
4148 [C_SDMA_IDLE_INT_CNT] = CNTR_ELEM("SDMAIdInt", 0, 0,
4149 CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
4150 access_sde_idle_int_cnt),
4151 [C_SDMA_PROGRESS_INT_CNT] = CNTR_ELEM("SDMAPrIntCn", 0, 0,
4152 CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
4153 access_sde_progress_int_cnt),
4154 /* MISC_ERR_STATUS */
4155 [C_MISC_PLL_LOCK_FAIL_ERR] = CNTR_ELEM("MISC_PLL_LOCK_FAIL_ERR", 0, 0,
4157 access_misc_pll_lock_fail_err_cnt),
4158 [C_MISC_MBIST_FAIL_ERR] = CNTR_ELEM("MISC_MBIST_FAIL_ERR", 0, 0,
4160 access_misc_mbist_fail_err_cnt),
4161 [C_MISC_INVALID_EEP_CMD_ERR] = CNTR_ELEM("MISC_INVALID_EEP_CMD_ERR", 0, 0,
4163 access_misc_invalid_eep_cmd_err_cnt),
4164 [C_MISC_EFUSE_DONE_PARITY_ERR] = CNTR_ELEM("MISC_EFUSE_DONE_PARITY_ERR", 0, 0,
4166 access_misc_efuse_done_parity_err_cnt),
4167 [C_MISC_EFUSE_WRITE_ERR] = CNTR_ELEM("MISC_EFUSE_WRITE_ERR", 0, 0,
4169 access_misc_efuse_write_err_cnt),
4170 [C_MISC_EFUSE_READ_BAD_ADDR_ERR] = CNTR_ELEM("MISC_EFUSE_READ_BAD_ADDR_ERR", 0,
4172 access_misc_efuse_read_bad_addr_err_cnt),
4173 [C_MISC_EFUSE_CSR_PARITY_ERR] = CNTR_ELEM("MISC_EFUSE_CSR_PARITY_ERR", 0, 0,
4175 access_misc_efuse_csr_parity_err_cnt),
4176 [C_MISC_FW_AUTH_FAILED_ERR] = CNTR_ELEM("MISC_FW_AUTH_FAILED_ERR", 0, 0,
4178 access_misc_fw_auth_failed_err_cnt),
4179 [C_MISC_KEY_MISMATCH_ERR] = CNTR_ELEM("MISC_KEY_MISMATCH_ERR", 0, 0,
4181 access_misc_key_mismatch_err_cnt),
4182 [C_MISC_SBUS_WRITE_FAILED_ERR] = CNTR_ELEM("MISC_SBUS_WRITE_FAILED_ERR", 0, 0,
4184 access_misc_sbus_write_failed_err_cnt),
4185 [C_MISC_CSR_WRITE_BAD_ADDR_ERR] = CNTR_ELEM("MISC_CSR_WRITE_BAD_ADDR_ERR", 0, 0,
4187 access_misc_csr_write_bad_addr_err_cnt),
4188 [C_MISC_CSR_READ_BAD_ADDR_ERR] = CNTR_ELEM("MISC_CSR_READ_BAD_ADDR_ERR", 0, 0,
4190 access_misc_csr_read_bad_addr_err_cnt),
4191 [C_MISC_CSR_PARITY_ERR] = CNTR_ELEM("MISC_CSR_PARITY_ERR", 0, 0,
4193 access_misc_csr_parity_err_cnt),
4195 [C_CCE_ERR_STATUS_AGGREGATED_CNT] = CNTR_ELEM("CceErrStatusAggregatedCnt", 0, 0,
4197 access_sw_cce_err_status_aggregated_cnt),
4198 [C_CCE_MSIX_CSR_PARITY_ERR] = CNTR_ELEM("CceMsixCsrParityErr", 0, 0,
4200 access_cce_msix_csr_parity_err_cnt),
4201 [C_CCE_INT_MAP_UNC_ERR] = CNTR_ELEM("CceIntMapUncErr", 0, 0,
4203 access_cce_int_map_unc_err_cnt),
4204 [C_CCE_INT_MAP_COR_ERR] = CNTR_ELEM("CceIntMapCorErr", 0, 0,
4206 access_cce_int_map_cor_err_cnt),
4207 [C_CCE_MSIX_TABLE_UNC_ERR] = CNTR_ELEM("CceMsixTableUncErr", 0, 0,
4209 access_cce_msix_table_unc_err_cnt),
4210 [C_CCE_MSIX_TABLE_COR_ERR] = CNTR_ELEM("CceMsixTableCorErr", 0, 0,
4212 access_cce_msix_table_cor_err_cnt),
4213 [C_CCE_RXDMA_CONV_FIFO_PARITY_ERR] = CNTR_ELEM("CceRxdmaConvFifoParityErr", 0,
4215 access_cce_rxdma_conv_fifo_parity_err_cnt),
4216 [C_CCE_RCPL_ASYNC_FIFO_PARITY_ERR] = CNTR_ELEM("CceRcplAsyncFifoParityErr", 0,
4218 access_cce_rcpl_async_fifo_parity_err_cnt),
4219 [C_CCE_SEG_WRITE_BAD_ADDR_ERR] = CNTR_ELEM("CceSegWriteBadAddrErr", 0, 0,
4221 access_cce_seg_write_bad_addr_err_cnt),
4222 [C_CCE_SEG_READ_BAD_ADDR_ERR] = CNTR_ELEM("CceSegReadBadAddrErr", 0, 0,
4224 access_cce_seg_read_bad_addr_err_cnt),
4225 [C_LA_TRIGGERED] = CNTR_ELEM("Cce LATriggered", 0, 0,
4227 access_la_triggered_cnt),
4228 [C_CCE_TRGT_CPL_TIMEOUT_ERR] = CNTR_ELEM("CceTrgtCplTimeoutErr", 0, 0,
4230 access_cce_trgt_cpl_timeout_err_cnt),
4231 [C_PCIC_RECEIVE_PARITY_ERR] = CNTR_ELEM("PcicReceiveParityErr", 0, 0,
4233 access_pcic_receive_parity_err_cnt),
4234 [C_PCIC_TRANSMIT_BACK_PARITY_ERR] = CNTR_ELEM("PcicTransmitBackParityErr", 0, 0,
4236 access_pcic_transmit_back_parity_err_cnt),
4237 [C_PCIC_TRANSMIT_FRONT_PARITY_ERR] = CNTR_ELEM("PcicTransmitFrontParityErr", 0,
4239 access_pcic_transmit_front_parity_err_cnt),
4240 [C_PCIC_CPL_DAT_Q_UNC_ERR] = CNTR_ELEM("PcicCplDatQUncErr", 0, 0,
4242 access_pcic_cpl_dat_q_unc_err_cnt),
4243 [C_PCIC_CPL_HD_Q_UNC_ERR] = CNTR_ELEM("PcicCplHdQUncErr", 0, 0,
4245 access_pcic_cpl_hd_q_unc_err_cnt),
4246 [C_PCIC_POST_DAT_Q_UNC_ERR] = CNTR_ELEM("PcicPostDatQUncErr", 0, 0,
4248 access_pcic_post_dat_q_unc_err_cnt),
4249 [C_PCIC_POST_HD_Q_UNC_ERR] = CNTR_ELEM("PcicPostHdQUncErr", 0, 0,
4251 access_pcic_post_hd_q_unc_err_cnt),
4252 [C_PCIC_RETRY_SOT_MEM_UNC_ERR] = CNTR_ELEM("PcicRetrySotMemUncErr", 0, 0,
4254 access_pcic_retry_sot_mem_unc_err_cnt),
4255 [C_PCIC_RETRY_MEM_UNC_ERR] = CNTR_ELEM("PcicRetryMemUncErr", 0, 0,
4257 access_pcic_retry_mem_unc_err),
4258 [C_PCIC_N_POST_DAT_Q_PARITY_ERR] = CNTR_ELEM("PcicNPostDatQParityErr", 0, 0,
4260 access_pcic_n_post_dat_q_parity_err_cnt),
4261 [C_PCIC_N_POST_H_Q_PARITY_ERR] = CNTR_ELEM("PcicNPostHQParityErr", 0, 0,
4263 access_pcic_n_post_h_q_parity_err_cnt),
4264 [C_PCIC_CPL_DAT_Q_COR_ERR] = CNTR_ELEM("PcicCplDatQCorErr", 0, 0,
4266 access_pcic_cpl_dat_q_cor_err_cnt),
4267 [C_PCIC_CPL_HD_Q_COR_ERR] = CNTR_ELEM("PcicCplHdQCorErr", 0, 0,
4269 access_pcic_cpl_hd_q_cor_err_cnt),
4270 [C_PCIC_POST_DAT_Q_COR_ERR] = CNTR_ELEM("PcicPostDatQCorErr", 0, 0,
4272 access_pcic_post_dat_q_cor_err_cnt),
4273 [C_PCIC_POST_HD_Q_COR_ERR] = CNTR_ELEM("PcicPostHdQCorErr", 0, 0,
4275 access_pcic_post_hd_q_cor_err_cnt),
4276 [C_PCIC_RETRY_SOT_MEM_COR_ERR] = CNTR_ELEM("PcicRetrySotMemCorErr", 0, 0,
4278 access_pcic_retry_sot_mem_cor_err_cnt),
4279 [C_PCIC_RETRY_MEM_COR_ERR] = CNTR_ELEM("PcicRetryMemCorErr", 0, 0,
4281 access_pcic_retry_mem_cor_err_cnt),
4282 [C_CCE_CLI1_ASYNC_FIFO_DBG_PARITY_ERR] = CNTR_ELEM(
4283 "CceCli1AsyncFifoDbgParityError", 0, 0,
4285 access_cce_cli1_async_fifo_dbg_parity_err_cnt),
4286 [C_CCE_CLI1_ASYNC_FIFO_RXDMA_PARITY_ERR] = CNTR_ELEM(
4287 "CceCli1AsyncFifoRxdmaParityError", 0, 0,
4289 access_cce_cli1_async_fifo_rxdma_parity_err_cnt
4291 [C_CCE_CLI1_ASYNC_FIFO_SDMA_HD_PARITY_ERR] = CNTR_ELEM(
4292 "CceCli1AsyncFifoSdmaHdParityErr", 0, 0,
4294 access_cce_cli1_async_fifo_sdma_hd_parity_err_cnt),
4295 [C_CCE_CLI1_ASYNC_FIFO_PIO_CRDT_PARITY_ERR] = CNTR_ELEM(
4296 "CceCli1AsyncFifoPioCrdtParityErr", 0, 0,
4298 access_cce_cl1_async_fifo_pio_crdt_parity_err_cnt),
4299 [C_CCE_CLI2_ASYNC_FIFO_PARITY_ERR] = CNTR_ELEM("CceCli2AsyncFifoParityErr", 0,
4301 access_cce_cli2_async_fifo_parity_err_cnt),
4302 [C_CCE_CSR_CFG_BUS_PARITY_ERR] = CNTR_ELEM("CceCsrCfgBusParityErr", 0, 0,
4304 access_cce_csr_cfg_bus_parity_err_cnt),
4305 [C_CCE_CLI0_ASYNC_FIFO_PARTIY_ERR] = CNTR_ELEM("CceCli0AsyncFifoParityErr", 0,
4307 access_cce_cli0_async_fifo_parity_err_cnt),
4308 [C_CCE_RSPD_DATA_PARITY_ERR] = CNTR_ELEM("CceRspdDataParityErr", 0, 0,
4310 access_cce_rspd_data_parity_err_cnt),
4311 [C_CCE_TRGT_ACCESS_ERR] = CNTR_ELEM("CceTrgtAccessErr", 0, 0,
4313 access_cce_trgt_access_err_cnt),
4314 [C_CCE_TRGT_ASYNC_FIFO_PARITY_ERR] = CNTR_ELEM("CceTrgtAsyncFifoParityErr", 0,
4316 access_cce_trgt_async_fifo_parity_err_cnt),
4317 [C_CCE_CSR_WRITE_BAD_ADDR_ERR] = CNTR_ELEM("CceCsrWriteBadAddrErr", 0, 0,
4319 access_cce_csr_write_bad_addr_err_cnt),
4320 [C_CCE_CSR_READ_BAD_ADDR_ERR] = CNTR_ELEM("CceCsrReadBadAddrErr", 0, 0,
4322 access_cce_csr_read_bad_addr_err_cnt),
4323 [C_CCE_CSR_PARITY_ERR] = CNTR_ELEM("CceCsrParityErr", 0, 0,
4325 access_ccs_csr_parity_err_cnt),
4328 [C_RX_CSR_PARITY_ERR] = CNTR_ELEM("RxCsrParityErr", 0, 0,
4330 access_rx_csr_parity_err_cnt),
4331 [C_RX_CSR_WRITE_BAD_ADDR_ERR] = CNTR_ELEM("RxCsrWriteBadAddrErr", 0, 0,
4333 access_rx_csr_write_bad_addr_err_cnt),
4334 [C_RX_CSR_READ_BAD_ADDR_ERR] = CNTR_ELEM("RxCsrReadBadAddrErr", 0, 0,
4336 access_rx_csr_read_bad_addr_err_cnt),
4337 [C_RX_DMA_CSR_UNC_ERR] = CNTR_ELEM("RxDmaCsrUncErr", 0, 0,
4339 access_rx_dma_csr_unc_err_cnt),
4340 [C_RX_DMA_DQ_FSM_ENCODING_ERR] = CNTR_ELEM("RxDmaDqFsmEncodingErr", 0, 0,
4342 access_rx_dma_dq_fsm_encoding_err_cnt),
4343 [C_RX_DMA_EQ_FSM_ENCODING_ERR] = CNTR_ELEM("RxDmaEqFsmEncodingErr", 0, 0,
4345 access_rx_dma_eq_fsm_encoding_err_cnt),
4346 [C_RX_DMA_CSR_PARITY_ERR] = CNTR_ELEM("RxDmaCsrParityErr", 0, 0,
4348 access_rx_dma_csr_parity_err_cnt),
4349 [C_RX_RBUF_DATA_COR_ERR] = CNTR_ELEM("RxRbufDataCorErr", 0, 0,
4351 access_rx_rbuf_data_cor_err_cnt),
4352 [C_RX_RBUF_DATA_UNC_ERR] = CNTR_ELEM("RxRbufDataUncErr", 0, 0,
4354 access_rx_rbuf_data_unc_err_cnt),
4355 [C_RX_DMA_DATA_FIFO_RD_COR_ERR] = CNTR_ELEM("RxDmaDataFifoRdCorErr", 0, 0,
4357 access_rx_dma_data_fifo_rd_cor_err_cnt),
4358 [C_RX_DMA_DATA_FIFO_RD_UNC_ERR] = CNTR_ELEM("RxDmaDataFifoRdUncErr", 0, 0,
4360 access_rx_dma_data_fifo_rd_unc_err_cnt),
4361 [C_RX_DMA_HDR_FIFO_RD_COR_ERR] = CNTR_ELEM("RxDmaHdrFifoRdCorErr", 0, 0,
4363 access_rx_dma_hdr_fifo_rd_cor_err_cnt),
4364 [C_RX_DMA_HDR_FIFO_RD_UNC_ERR] = CNTR_ELEM("RxDmaHdrFifoRdUncErr", 0, 0,
4366 access_rx_dma_hdr_fifo_rd_unc_err_cnt),
4367 [C_RX_RBUF_DESC_PART2_COR_ERR] = CNTR_ELEM("RxRbufDescPart2CorErr", 0, 0,
4369 access_rx_rbuf_desc_part2_cor_err_cnt),
4370 [C_RX_RBUF_DESC_PART2_UNC_ERR] = CNTR_ELEM("RxRbufDescPart2UncErr", 0, 0,
4372 access_rx_rbuf_desc_part2_unc_err_cnt),
4373 [C_RX_RBUF_DESC_PART1_COR_ERR] = CNTR_ELEM("RxRbufDescPart1CorErr", 0, 0,
4375 access_rx_rbuf_desc_part1_cor_err_cnt),
4376 [C_RX_RBUF_DESC_PART1_UNC_ERR] = CNTR_ELEM("RxRbufDescPart1UncErr", 0, 0,
4378 access_rx_rbuf_desc_part1_unc_err_cnt),
4379 [C_RX_HQ_INTR_FSM_ERR] = CNTR_ELEM("RxHqIntrFsmErr", 0, 0,
4381 access_rx_hq_intr_fsm_err_cnt),
4382 [C_RX_HQ_INTR_CSR_PARITY_ERR] = CNTR_ELEM("RxHqIntrCsrParityErr", 0, 0,
4384 access_rx_hq_intr_csr_parity_err_cnt),
4385 [C_RX_LOOKUP_CSR_PARITY_ERR] = CNTR_ELEM("RxLookupCsrParityErr", 0, 0,
4387 access_rx_lookup_csr_parity_err_cnt),
4388 [C_RX_LOOKUP_RCV_ARRAY_COR_ERR] = CNTR_ELEM("RxLookupRcvArrayCorErr", 0, 0,
4390 access_rx_lookup_rcv_array_cor_err_cnt),
4391 [C_RX_LOOKUP_RCV_ARRAY_UNC_ERR] = CNTR_ELEM("RxLookupRcvArrayUncErr", 0, 0,
4393 access_rx_lookup_rcv_array_unc_err_cnt),
4394 [C_RX_LOOKUP_DES_PART2_PARITY_ERR] = CNTR_ELEM("RxLookupDesPart2ParityErr", 0,
4396 access_rx_lookup_des_part2_parity_err_cnt),
4397 [C_RX_LOOKUP_DES_PART1_UNC_COR_ERR] = CNTR_ELEM("RxLookupDesPart1UncCorErr", 0,
4399 access_rx_lookup_des_part1_unc_cor_err_cnt),
4400 [C_RX_LOOKUP_DES_PART1_UNC_ERR] = CNTR_ELEM("RxLookupDesPart1UncErr", 0, 0,
4402 access_rx_lookup_des_part1_unc_err_cnt),
4403 [C_RX_RBUF_NEXT_FREE_BUF_COR_ERR] = CNTR_ELEM("RxRbufNextFreeBufCorErr", 0, 0,
4405 access_rx_rbuf_next_free_buf_cor_err_cnt),
4406 [C_RX_RBUF_NEXT_FREE_BUF_UNC_ERR] = CNTR_ELEM("RxRbufNextFreeBufUncErr", 0, 0,
4408 access_rx_rbuf_next_free_buf_unc_err_cnt),
4409 [C_RX_RBUF_FL_INIT_WR_ADDR_PARITY_ERR] = CNTR_ELEM(
4410 "RxRbufFlInitWrAddrParityErr", 0, 0,
4412 access_rbuf_fl_init_wr_addr_parity_err_cnt),
4413 [C_RX_RBUF_FL_INITDONE_PARITY_ERR] = CNTR_ELEM("RxRbufFlInitdoneParityErr", 0,
4415 access_rx_rbuf_fl_initdone_parity_err_cnt),
4416 [C_RX_RBUF_FL_WRITE_ADDR_PARITY_ERR] = CNTR_ELEM("RxRbufFlWrAddrParityErr", 0,
4418 access_rx_rbuf_fl_write_addr_parity_err_cnt),
4419 [C_RX_RBUF_FL_RD_ADDR_PARITY_ERR] = CNTR_ELEM("RxRbufFlRdAddrParityErr", 0, 0,
4421 access_rx_rbuf_fl_rd_addr_parity_err_cnt),
4422 [C_RX_RBUF_EMPTY_ERR] = CNTR_ELEM("RxRbufEmptyErr", 0, 0,
4424 access_rx_rbuf_empty_err_cnt),
4425 [C_RX_RBUF_FULL_ERR] = CNTR_ELEM("RxRbufFullErr", 0, 0,
4427 access_rx_rbuf_full_err_cnt),
4428 [C_RX_RBUF_BAD_LOOKUP_ERR] = CNTR_ELEM("RxRBufBadLookupErr", 0, 0,
4430 access_rbuf_bad_lookup_err_cnt),
4431 [C_RX_RBUF_CTX_ID_PARITY_ERR] = CNTR_ELEM("RxRbufCtxIdParityErr", 0, 0,
4433 access_rbuf_ctx_id_parity_err_cnt),
4434 [C_RX_RBUF_CSR_QEOPDW_PARITY_ERR] = CNTR_ELEM("RxRbufCsrQEOPDWParityErr", 0, 0,
4436 access_rbuf_csr_qeopdw_parity_err_cnt),
4437 [C_RX_RBUF_CSR_Q_NUM_OF_PKT_PARITY_ERR] = CNTR_ELEM(
4438 "RxRbufCsrQNumOfPktParityErr", 0, 0,
4440 access_rx_rbuf_csr_q_num_of_pkt_parity_err_cnt),
4441 [C_RX_RBUF_CSR_Q_T1_PTR_PARITY_ERR] = CNTR_ELEM(
4442 "RxRbufCsrQTlPtrParityErr", 0, 0,
4444 access_rx_rbuf_csr_q_t1_ptr_parity_err_cnt),
4445 [C_RX_RBUF_CSR_Q_HD_PTR_PARITY_ERR] = CNTR_ELEM("RxRbufCsrQHdPtrParityErr", 0,
4447 access_rx_rbuf_csr_q_hd_ptr_parity_err_cnt),
4448 [C_RX_RBUF_CSR_Q_VLD_BIT_PARITY_ERR] = CNTR_ELEM("RxRbufCsrQVldBitParityErr", 0,
4450 access_rx_rbuf_csr_q_vld_bit_parity_err_cnt),
4451 [C_RX_RBUF_CSR_Q_NEXT_BUF_PARITY_ERR] = CNTR_ELEM("RxRbufCsrQNextBufParityErr",
4453 access_rx_rbuf_csr_q_next_buf_parity_err_cnt),
4454 [C_RX_RBUF_CSR_Q_ENT_CNT_PARITY_ERR] = CNTR_ELEM("RxRbufCsrQEntCntParityErr", 0,
4456 access_rx_rbuf_csr_q_ent_cnt_parity_err_cnt),
4457 [C_RX_RBUF_CSR_Q_HEAD_BUF_NUM_PARITY_ERR] = CNTR_ELEM(
4458 "RxRbufCsrQHeadBufNumParityErr", 0, 0,
4460 access_rx_rbuf_csr_q_head_buf_num_parity_err_cnt),
4461 [C_RX_RBUF_BLOCK_LIST_READ_COR_ERR] = CNTR_ELEM("RxRbufBlockListReadCorErr", 0,
4463 access_rx_rbuf_block_list_read_cor_err_cnt),
4464 [C_RX_RBUF_BLOCK_LIST_READ_UNC_ERR] = CNTR_ELEM("RxRbufBlockListReadUncErr", 0,
4466 access_rx_rbuf_block_list_read_unc_err_cnt),
4467 [C_RX_RBUF_LOOKUP_DES_COR_ERR] = CNTR_ELEM("RxRbufLookupDesCorErr", 0, 0,
4469 access_rx_rbuf_lookup_des_cor_err_cnt),
4470 [C_RX_RBUF_LOOKUP_DES_UNC_ERR] = CNTR_ELEM("RxRbufLookupDesUncErr", 0, 0,
4472 access_rx_rbuf_lookup_des_unc_err_cnt),
4473 [C_RX_RBUF_LOOKUP_DES_REG_UNC_COR_ERR] = CNTR_ELEM(
4474 "RxRbufLookupDesRegUncCorErr", 0, 0,
4476 access_rx_rbuf_lookup_des_reg_unc_cor_err_cnt),
4477 [C_RX_RBUF_LOOKUP_DES_REG_UNC_ERR] = CNTR_ELEM("RxRbufLookupDesRegUncErr", 0, 0,
4479 access_rx_rbuf_lookup_des_reg_unc_err_cnt),
4480 [C_RX_RBUF_FREE_LIST_COR_ERR] = CNTR_ELEM("RxRbufFreeListCorErr", 0, 0,
4482 access_rx_rbuf_free_list_cor_err_cnt),
4483 [C_RX_RBUF_FREE_LIST_UNC_ERR] = CNTR_ELEM("RxRbufFreeListUncErr", 0, 0,
4485 access_rx_rbuf_free_list_unc_err_cnt),
4486 [C_RX_RCV_FSM_ENCODING_ERR] = CNTR_ELEM("RxRcvFsmEncodingErr", 0, 0,
4488 access_rx_rcv_fsm_encoding_err_cnt),
4489 [C_RX_DMA_FLAG_COR_ERR] = CNTR_ELEM("RxDmaFlagCorErr", 0, 0,
4491 access_rx_dma_flag_cor_err_cnt),
4492 [C_RX_DMA_FLAG_UNC_ERR] = CNTR_ELEM("RxDmaFlagUncErr", 0, 0,
4494 access_rx_dma_flag_unc_err_cnt),
4495 [C_RX_DC_SOP_EOP_PARITY_ERR] = CNTR_ELEM("RxDcSopEopParityErr", 0, 0,
4497 access_rx_dc_sop_eop_parity_err_cnt),
4498 [C_RX_RCV_CSR_PARITY_ERR] = CNTR_ELEM("RxRcvCsrParityErr", 0, 0,
4500 access_rx_rcv_csr_parity_err_cnt),
4501 [C_RX_RCV_QP_MAP_TABLE_COR_ERR] = CNTR_ELEM("RxRcvQpMapTableCorErr", 0, 0,
4503 access_rx_rcv_qp_map_table_cor_err_cnt),
4504 [C_RX_RCV_QP_MAP_TABLE_UNC_ERR] = CNTR_ELEM("RxRcvQpMapTableUncErr", 0, 0,
4506 access_rx_rcv_qp_map_table_unc_err_cnt),
4507 [C_RX_RCV_DATA_COR_ERR] = CNTR_ELEM("RxRcvDataCorErr", 0, 0,
4509 access_rx_rcv_data_cor_err_cnt),
4510 [C_RX_RCV_DATA_UNC_ERR] = CNTR_ELEM("RxRcvDataUncErr", 0, 0,
4512 access_rx_rcv_data_unc_err_cnt),
4513 [C_RX_RCV_HDR_COR_ERR] = CNTR_ELEM("RxRcvHdrCorErr", 0, 0,
4515 access_rx_rcv_hdr_cor_err_cnt),
4516 [C_RX_RCV_HDR_UNC_ERR] = CNTR_ELEM("RxRcvHdrUncErr", 0, 0,
4518 access_rx_rcv_hdr_unc_err_cnt),
4519 [C_RX_DC_INTF_PARITY_ERR] = CNTR_ELEM("RxDcIntfParityErr", 0, 0,
4521 access_rx_dc_intf_parity_err_cnt),
4522 [C_RX_DMA_CSR_COR_ERR] = CNTR_ELEM("RxDmaCsrCorErr", 0, 0,
4524 access_rx_dma_csr_cor_err_cnt),
4525 /* SendPioErrStatus */
4526 [C_PIO_PEC_SOP_HEAD_PARITY_ERR] = CNTR_ELEM("PioPecSopHeadParityErr", 0, 0,
4528 access_pio_pec_sop_head_parity_err_cnt),
4529 [C_PIO_PCC_SOP_HEAD_PARITY_ERR] = CNTR_ELEM("PioPccSopHeadParityErr", 0, 0,
4531 access_pio_pcc_sop_head_parity_err_cnt),
4532 [C_PIO_LAST_RETURNED_CNT_PARITY_ERR] = CNTR_ELEM("PioLastReturnedCntParityErr",
4534 access_pio_last_returned_cnt_parity_err_cnt),
4535 [C_PIO_CURRENT_FREE_CNT_PARITY_ERR] = CNTR_ELEM("PioCurrentFreeCntParityErr", 0,
4537 access_pio_current_free_cnt_parity_err_cnt),
4538 [C_PIO_RSVD_31_ERR] = CNTR_ELEM("Pio Reserved 31", 0, 0,
4540 access_pio_reserved_31_err_cnt),
4541 [C_PIO_RSVD_30_ERR] = CNTR_ELEM("Pio Reserved 30", 0, 0,
4543 access_pio_reserved_30_err_cnt),
4544 [C_PIO_PPMC_SOP_LEN_ERR] = CNTR_ELEM("PioPpmcSopLenErr", 0, 0,
4546 access_pio_ppmc_sop_len_err_cnt),
4547 [C_PIO_PPMC_BQC_MEM_PARITY_ERR] = CNTR_ELEM("PioPpmcBqcMemParityErr", 0, 0,
4549 access_pio_ppmc_bqc_mem_parity_err_cnt),
4550 [C_PIO_VL_FIFO_PARITY_ERR] = CNTR_ELEM("PioVlFifoParityErr", 0, 0,
4552 access_pio_vl_fifo_parity_err_cnt),
4553 [C_PIO_VLF_SOP_PARITY_ERR] = CNTR_ELEM("PioVlfSopParityErr", 0, 0,
4555 access_pio_vlf_sop_parity_err_cnt),
4556 [C_PIO_VLF_V1_LEN_PARITY_ERR] = CNTR_ELEM("PioVlfVlLenParityErr", 0, 0,
4558 access_pio_vlf_v1_len_parity_err_cnt),
4559 [C_PIO_BLOCK_QW_COUNT_PARITY_ERR] = CNTR_ELEM("PioBlockQwCountParityErr", 0, 0,
4561 access_pio_block_qw_count_parity_err_cnt),
4562 [C_PIO_WRITE_QW_VALID_PARITY_ERR] = CNTR_ELEM("PioWriteQwValidParityErr", 0, 0,
4564 access_pio_write_qw_valid_parity_err_cnt),
4565 [C_PIO_STATE_MACHINE_ERR] = CNTR_ELEM("PioStateMachineErr", 0, 0,
4567 access_pio_state_machine_err_cnt),
4568 [C_PIO_WRITE_DATA_PARITY_ERR] = CNTR_ELEM("PioWriteDataParityErr", 0, 0,
4570 access_pio_write_data_parity_err_cnt),
4571 [C_PIO_HOST_ADDR_MEM_COR_ERR] = CNTR_ELEM("PioHostAddrMemCorErr", 0, 0,
4573 access_pio_host_addr_mem_cor_err_cnt),
4574 [C_PIO_HOST_ADDR_MEM_UNC_ERR] = CNTR_ELEM("PioHostAddrMemUncErr", 0, 0,
4576 access_pio_host_addr_mem_unc_err_cnt),
4577 [C_PIO_PKT_EVICT_SM_OR_ARM_SM_ERR] = CNTR_ELEM("PioPktEvictSmOrArbSmErr", 0, 0,
4579 access_pio_pkt_evict_sm_or_arb_sm_err_cnt),
4580 [C_PIO_INIT_SM_IN_ERR] = CNTR_ELEM("PioInitSmInErr", 0, 0,
4582 access_pio_init_sm_in_err_cnt),
4583 [C_PIO_PPMC_PBL_FIFO_ERR] = CNTR_ELEM("PioPpmcPblFifoErr", 0, 0,
4585 access_pio_ppmc_pbl_fifo_err_cnt),
4586 [C_PIO_CREDIT_RET_FIFO_PARITY_ERR] = CNTR_ELEM("PioCreditRetFifoParityErr", 0,
4588 access_pio_credit_ret_fifo_parity_err_cnt),
4589 [C_PIO_V1_LEN_MEM_BANK1_COR_ERR] = CNTR_ELEM("PioVlLenMemBank1CorErr", 0, 0,
4591 access_pio_v1_len_mem_bank1_cor_err_cnt),
4592 [C_PIO_V1_LEN_MEM_BANK0_COR_ERR] = CNTR_ELEM("PioVlLenMemBank0CorErr", 0, 0,
4594 access_pio_v1_len_mem_bank0_cor_err_cnt),
4595 [C_PIO_V1_LEN_MEM_BANK1_UNC_ERR] = CNTR_ELEM("PioVlLenMemBank1UncErr", 0, 0,
4597 access_pio_v1_len_mem_bank1_unc_err_cnt),
4598 [C_PIO_V1_LEN_MEM_BANK0_UNC_ERR] = CNTR_ELEM("PioVlLenMemBank0UncErr", 0, 0,
4600 access_pio_v1_len_mem_bank0_unc_err_cnt),
4601 [C_PIO_SM_PKT_RESET_PARITY_ERR] = CNTR_ELEM("PioSmPktResetParityErr", 0, 0,
4603 access_pio_sm_pkt_reset_parity_err_cnt),
4604 [C_PIO_PKT_EVICT_FIFO_PARITY_ERR] = CNTR_ELEM("PioPktEvictFifoParityErr", 0, 0,
4606 access_pio_pkt_evict_fifo_parity_err_cnt),
4607 [C_PIO_SBRDCTRL_CRREL_FIFO_PARITY_ERR] = CNTR_ELEM(
4608 "PioSbrdctrlCrrelFifoParityErr", 0, 0,
4610 access_pio_sbrdctrl_crrel_fifo_parity_err_cnt),
4611 [C_PIO_SBRDCTL_CRREL_PARITY_ERR] = CNTR_ELEM("PioSbrdctlCrrelParityErr", 0, 0,
4613 access_pio_sbrdctl_crrel_parity_err_cnt),
4614 [C_PIO_PEC_FIFO_PARITY_ERR] = CNTR_ELEM("PioPecFifoParityErr", 0, 0,
4616 access_pio_pec_fifo_parity_err_cnt),
4617 [C_PIO_PCC_FIFO_PARITY_ERR] = CNTR_ELEM("PioPccFifoParityErr", 0, 0,
4619 access_pio_pcc_fifo_parity_err_cnt),
4620 [C_PIO_SB_MEM_FIFO1_ERR] = CNTR_ELEM("PioSbMemFifo1Err", 0, 0,
4622 access_pio_sb_mem_fifo1_err_cnt),
4623 [C_PIO_SB_MEM_FIFO0_ERR] = CNTR_ELEM("PioSbMemFifo0Err", 0, 0,
4625 access_pio_sb_mem_fifo0_err_cnt),
4626 [C_PIO_CSR_PARITY_ERR] = CNTR_ELEM("PioCsrParityErr", 0, 0,
4628 access_pio_csr_parity_err_cnt),
4629 [C_PIO_WRITE_ADDR_PARITY_ERR] = CNTR_ELEM("PioWriteAddrParityErr", 0, 0,
4631 access_pio_write_addr_parity_err_cnt),
4632 [C_PIO_WRITE_BAD_CTXT_ERR] = CNTR_ELEM("PioWriteBadCtxtErr", 0, 0,
4634 access_pio_write_bad_ctxt_err_cnt),
4635 /* SendDmaErrStatus */
4636 [C_SDMA_PCIE_REQ_TRACKING_COR_ERR] = CNTR_ELEM("SDmaPcieReqTrackingCorErr", 0,
4638 access_sdma_pcie_req_tracking_cor_err_cnt),
4639 [C_SDMA_PCIE_REQ_TRACKING_UNC_ERR] = CNTR_ELEM("SDmaPcieReqTrackingUncErr", 0,
4641 access_sdma_pcie_req_tracking_unc_err_cnt),
4642 [C_SDMA_CSR_PARITY_ERR] = CNTR_ELEM("SDmaCsrParityErr", 0, 0,
4644 access_sdma_csr_parity_err_cnt),
4645 [C_SDMA_RPY_TAG_ERR] = CNTR_ELEM("SDmaRpyTagErr", 0, 0,
4647 access_sdma_rpy_tag_err_cnt),
4648 /* SendEgressErrStatus */
4649 [C_TX_READ_PIO_MEMORY_CSR_UNC_ERR] = CNTR_ELEM("TxReadPioMemoryCsrUncErr", 0, 0,
4651 access_tx_read_pio_memory_csr_unc_err_cnt),
4652 [C_TX_READ_SDMA_MEMORY_CSR_UNC_ERR] = CNTR_ELEM("TxReadSdmaMemoryCsrUncErr", 0,
4654 access_tx_read_sdma_memory_csr_err_cnt),
4655 [C_TX_EGRESS_FIFO_COR_ERR] = CNTR_ELEM("TxEgressFifoCorErr", 0, 0,
4657 access_tx_egress_fifo_cor_err_cnt),
4658 [C_TX_READ_PIO_MEMORY_COR_ERR] = CNTR_ELEM("TxReadPioMemoryCorErr", 0, 0,
4660 access_tx_read_pio_memory_cor_err_cnt),
4661 [C_TX_READ_SDMA_MEMORY_COR_ERR] = CNTR_ELEM("TxReadSdmaMemoryCorErr", 0, 0,
4663 access_tx_read_sdma_memory_cor_err_cnt),
4664 [C_TX_SB_HDR_COR_ERR] = CNTR_ELEM("TxSbHdrCorErr", 0, 0,
4666 access_tx_sb_hdr_cor_err_cnt),
4667 [C_TX_CREDIT_OVERRUN_ERR] = CNTR_ELEM("TxCreditOverrunErr", 0, 0,
4669 access_tx_credit_overrun_err_cnt),
4670 [C_TX_LAUNCH_FIFO8_COR_ERR] = CNTR_ELEM("TxLaunchFifo8CorErr", 0, 0,
4672 access_tx_launch_fifo8_cor_err_cnt),
4673 [C_TX_LAUNCH_FIFO7_COR_ERR] = CNTR_ELEM("TxLaunchFifo7CorErr", 0, 0,
4675 access_tx_launch_fifo7_cor_err_cnt),
4676 [C_TX_LAUNCH_FIFO6_COR_ERR] = CNTR_ELEM("TxLaunchFifo6CorErr", 0, 0,
4678 access_tx_launch_fifo6_cor_err_cnt),
4679 [C_TX_LAUNCH_FIFO5_COR_ERR] = CNTR_ELEM("TxLaunchFifo5CorErr", 0, 0,
4681 access_tx_launch_fifo5_cor_err_cnt),
4682 [C_TX_LAUNCH_FIFO4_COR_ERR] = CNTR_ELEM("TxLaunchFifo4CorErr", 0, 0,
4684 access_tx_launch_fifo4_cor_err_cnt),
4685 [C_TX_LAUNCH_FIFO3_COR_ERR] = CNTR_ELEM("TxLaunchFifo3CorErr", 0, 0,
4687 access_tx_launch_fifo3_cor_err_cnt),
4688 [C_TX_LAUNCH_FIFO2_COR_ERR] = CNTR_ELEM("TxLaunchFifo2CorErr", 0, 0,
4690 access_tx_launch_fifo2_cor_err_cnt),
4691 [C_TX_LAUNCH_FIFO1_COR_ERR] = CNTR_ELEM("TxLaunchFifo1CorErr", 0, 0,
4693 access_tx_launch_fifo1_cor_err_cnt),
4694 [C_TX_LAUNCH_FIFO0_COR_ERR] = CNTR_ELEM("TxLaunchFifo0CorErr", 0, 0,
4696 access_tx_launch_fifo0_cor_err_cnt),
4697 [C_TX_CREDIT_RETURN_VL_ERR] = CNTR_ELEM("TxCreditReturnVLErr", 0, 0,
4699 access_tx_credit_return_vl_err_cnt),
4700 [C_TX_HCRC_INSERTION_ERR] = CNTR_ELEM("TxHcrcInsertionErr", 0, 0,
4702 access_tx_hcrc_insertion_err_cnt),
4703 [C_TX_EGRESS_FIFI_UNC_ERR] = CNTR_ELEM("TxEgressFifoUncErr", 0, 0,
4705 access_tx_egress_fifo_unc_err_cnt),
4706 [C_TX_READ_PIO_MEMORY_UNC_ERR] = CNTR_ELEM("TxReadPioMemoryUncErr", 0, 0,
4708 access_tx_read_pio_memory_unc_err_cnt),
4709 [C_TX_READ_SDMA_MEMORY_UNC_ERR] = CNTR_ELEM("TxReadSdmaMemoryUncErr", 0, 0,
4711 access_tx_read_sdma_memory_unc_err_cnt),
4712 [C_TX_SB_HDR_UNC_ERR] = CNTR_ELEM("TxSbHdrUncErr", 0, 0,
4714 access_tx_sb_hdr_unc_err_cnt),
4715 [C_TX_CREDIT_RETURN_PARITY_ERR] = CNTR_ELEM("TxCreditReturnParityErr", 0, 0,
4717 access_tx_credit_return_partiy_err_cnt),
4718 [C_TX_LAUNCH_FIFO8_UNC_OR_PARITY_ERR] = CNTR_ELEM("TxLaunchFifo8UncOrParityErr",
4720 access_tx_launch_fifo8_unc_or_parity_err_cnt),
4721 [C_TX_LAUNCH_FIFO7_UNC_OR_PARITY_ERR] = CNTR_ELEM("TxLaunchFifo7UncOrParityErr",
4723 access_tx_launch_fifo7_unc_or_parity_err_cnt),
4724 [C_TX_LAUNCH_FIFO6_UNC_OR_PARITY_ERR] = CNTR_ELEM("TxLaunchFifo6UncOrParityErr",
4726 access_tx_launch_fifo6_unc_or_parity_err_cnt),
4727 [C_TX_LAUNCH_FIFO5_UNC_OR_PARITY_ERR] = CNTR_ELEM("TxLaunchFifo5UncOrParityErr",
4729 access_tx_launch_fifo5_unc_or_parity_err_cnt),
4730 [C_TX_LAUNCH_FIFO4_UNC_OR_PARITY_ERR] = CNTR_ELEM("TxLaunchFifo4UncOrParityErr",
4732 access_tx_launch_fifo4_unc_or_parity_err_cnt),
4733 [C_TX_LAUNCH_FIFO3_UNC_OR_PARITY_ERR] = CNTR_ELEM("TxLaunchFifo3UncOrParityErr",
4735 access_tx_launch_fifo3_unc_or_parity_err_cnt),
4736 [C_TX_LAUNCH_FIFO2_UNC_OR_PARITY_ERR] = CNTR_ELEM("TxLaunchFifo2UncOrParityErr",
4738 access_tx_launch_fifo2_unc_or_parity_err_cnt),
4739 [C_TX_LAUNCH_FIFO1_UNC_OR_PARITY_ERR] = CNTR_ELEM("TxLaunchFifo1UncOrParityErr",
4741 access_tx_launch_fifo1_unc_or_parity_err_cnt),
4742 [C_TX_LAUNCH_FIFO0_UNC_OR_PARITY_ERR] = CNTR_ELEM("TxLaunchFifo0UncOrParityErr",
4744 access_tx_launch_fifo0_unc_or_parity_err_cnt),
4745 [C_TX_SDMA15_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma15DisallowedPacketErr",
4747 access_tx_sdma15_disallowed_packet_err_cnt),
4748 [C_TX_SDMA14_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma14DisallowedPacketErr",
4750 access_tx_sdma14_disallowed_packet_err_cnt),
4751 [C_TX_SDMA13_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma13DisallowedPacketErr",
4753 access_tx_sdma13_disallowed_packet_err_cnt),
4754 [C_TX_SDMA12_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma12DisallowedPacketErr",
4756 access_tx_sdma12_disallowed_packet_err_cnt),
4757 [C_TX_SDMA11_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma11DisallowedPacketErr",
4759 access_tx_sdma11_disallowed_packet_err_cnt),
4760 [C_TX_SDMA10_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma10DisallowedPacketErr",
4762 access_tx_sdma10_disallowed_packet_err_cnt),
4763 [C_TX_SDMA9_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma9DisallowedPacketErr",
4765 access_tx_sdma9_disallowed_packet_err_cnt),
4766 [C_TX_SDMA8_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma8DisallowedPacketErr",
4768 access_tx_sdma8_disallowed_packet_err_cnt),
4769 [C_TX_SDMA7_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma7DisallowedPacketErr",
4771 access_tx_sdma7_disallowed_packet_err_cnt),
4772 [C_TX_SDMA6_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma6DisallowedPacketErr",
4774 access_tx_sdma6_disallowed_packet_err_cnt),
4775 [C_TX_SDMA5_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma5DisallowedPacketErr",
4777 access_tx_sdma5_disallowed_packet_err_cnt),
4778 [C_TX_SDMA4_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma4DisallowedPacketErr",
4780 access_tx_sdma4_disallowed_packet_err_cnt),
4781 [C_TX_SDMA3_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma3DisallowedPacketErr",
4783 access_tx_sdma3_disallowed_packet_err_cnt),
4784 [C_TX_SDMA2_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma2DisallowedPacketErr",
4786 access_tx_sdma2_disallowed_packet_err_cnt),
4787 [C_TX_SDMA1_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma1DisallowedPacketErr",
4789 access_tx_sdma1_disallowed_packet_err_cnt),
4790 [C_TX_SDMA0_DISALLOWED_PACKET_ERR] = CNTR_ELEM("TxSdma0DisallowedPacketErr",
4792 access_tx_sdma0_disallowed_packet_err_cnt),
4793 [C_TX_CONFIG_PARITY_ERR] = CNTR_ELEM("TxConfigParityErr", 0, 0,
4795 access_tx_config_parity_err_cnt),
4796 [C_TX_SBRD_CTL_CSR_PARITY_ERR] = CNTR_ELEM("TxSbrdCtlCsrParityErr", 0, 0,
4798 access_tx_sbrd_ctl_csr_parity_err_cnt),
4799 [C_TX_LAUNCH_CSR_PARITY_ERR] = CNTR_ELEM("TxLaunchCsrParityErr", 0, 0,
4801 access_tx_launch_csr_parity_err_cnt),
4802 [C_TX_ILLEGAL_CL_ERR] = CNTR_ELEM("TxIllegalVLErr", 0, 0,
4804 access_tx_illegal_vl_err_cnt),
4805 [C_TX_SBRD_CTL_STATE_MACHINE_PARITY_ERR] = CNTR_ELEM(
4806 "TxSbrdCtlStateMachineParityErr", 0, 0,
4808 access_tx_sbrd_ctl_state_machine_parity_err_cnt),
4809 [C_TX_RESERVED_10] = CNTR_ELEM("Tx Egress Reserved 10", 0, 0,
4811 access_egress_reserved_10_err_cnt),
4812 [C_TX_RESERVED_9] = CNTR_ELEM("Tx Egress Reserved 9", 0, 0,
4814 access_egress_reserved_9_err_cnt),
4815 [C_TX_SDMA_LAUNCH_INTF_PARITY_ERR] = CNTR_ELEM("TxSdmaLaunchIntfParityErr",
4817 access_tx_sdma_launch_intf_parity_err_cnt),
4818 [C_TX_PIO_LAUNCH_INTF_PARITY_ERR] = CNTR_ELEM("TxPioLaunchIntfParityErr", 0, 0,
4820 access_tx_pio_launch_intf_parity_err_cnt),
4821 [C_TX_RESERVED_6] = CNTR_ELEM("Tx Egress Reserved 6", 0, 0,
4823 access_egress_reserved_6_err_cnt),
4824 [C_TX_INCORRECT_LINK_STATE_ERR] = CNTR_ELEM("TxIncorrectLinkStateErr", 0, 0,
4826 access_tx_incorrect_link_state_err_cnt),
4827 [C_TX_LINK_DOWN_ERR] = CNTR_ELEM("TxLinkdownErr", 0, 0,
4829 access_tx_linkdown_err_cnt),
4830 [C_TX_EGRESS_FIFO_UNDERRUN_OR_PARITY_ERR] = CNTR_ELEM(
4831 "EgressFifoUnderrunOrParityErr", 0, 0,
4833 access_tx_egress_fifi_underrun_or_parity_err_cnt),
4834 [C_TX_RESERVED_2] = CNTR_ELEM("Tx Egress Reserved 2", 0, 0,
4836 access_egress_reserved_2_err_cnt),
4837 [C_TX_PKT_INTEGRITY_MEM_UNC_ERR] = CNTR_ELEM("TxPktIntegrityMemUncErr", 0, 0,
4839 access_tx_pkt_integrity_mem_unc_err_cnt),
4840 [C_TX_PKT_INTEGRITY_MEM_COR_ERR] = CNTR_ELEM("TxPktIntegrityMemCorErr", 0, 0,
4842 access_tx_pkt_integrity_mem_cor_err_cnt),
4844 [C_SEND_CSR_WRITE_BAD_ADDR_ERR] = CNTR_ELEM("SendCsrWriteBadAddrErr", 0, 0,
4846 access_send_csr_write_bad_addr_err_cnt),
4847 [C_SEND_CSR_READ_BAD_ADD_ERR] = CNTR_ELEM("SendCsrReadBadAddrErr", 0, 0,
4849 access_send_csr_read_bad_addr_err_cnt),
4850 [C_SEND_CSR_PARITY_ERR] = CNTR_ELEM("SendCsrParityErr", 0, 0,
4852 access_send_csr_parity_cnt),
4853 /* SendCtxtErrStatus */
4854 [C_PIO_WRITE_OUT_OF_BOUNDS_ERR] = CNTR_ELEM("PioWriteOutOfBoundsErr", 0, 0,
4856 access_pio_write_out_of_bounds_err_cnt),
4857 [C_PIO_WRITE_OVERFLOW_ERR] = CNTR_ELEM("PioWriteOverflowErr", 0, 0,
4859 access_pio_write_overflow_err_cnt),
4860 [C_PIO_WRITE_CROSSES_BOUNDARY_ERR] = CNTR_ELEM("PioWriteCrossesBoundaryErr",
4862 access_pio_write_crosses_boundary_err_cnt),
4863 [C_PIO_DISALLOWED_PACKET_ERR] = CNTR_ELEM("PioDisallowedPacketErr", 0, 0,
4865 access_pio_disallowed_packet_err_cnt),
4866 [C_PIO_INCONSISTENT_SOP_ERR] = CNTR_ELEM("PioInconsistentSopErr", 0, 0,
4868 access_pio_inconsistent_sop_err_cnt),
4869 /* SendDmaEngErrStatus */
4870 [C_SDMA_HEADER_REQUEST_FIFO_COR_ERR] = CNTR_ELEM("SDmaHeaderRequestFifoCorErr",
4872 access_sdma_header_request_fifo_cor_err_cnt),
4873 [C_SDMA_HEADER_STORAGE_COR_ERR] = CNTR_ELEM("SDmaHeaderStorageCorErr", 0, 0,
4875 access_sdma_header_storage_cor_err_cnt),
4876 [C_SDMA_PACKET_TRACKING_COR_ERR] = CNTR_ELEM("SDmaPacketTrackingCorErr", 0, 0,
4878 access_sdma_packet_tracking_cor_err_cnt),
4879 [C_SDMA_ASSEMBLY_COR_ERR] = CNTR_ELEM("SDmaAssemblyCorErr", 0, 0,
4881 access_sdma_assembly_cor_err_cnt),
4882 [C_SDMA_DESC_TABLE_COR_ERR] = CNTR_ELEM("SDmaDescTableCorErr", 0, 0,
4884 access_sdma_desc_table_cor_err_cnt),
4885 [C_SDMA_HEADER_REQUEST_FIFO_UNC_ERR] = CNTR_ELEM("SDmaHeaderRequestFifoUncErr",
4887 access_sdma_header_request_fifo_unc_err_cnt),
4888 [C_SDMA_HEADER_STORAGE_UNC_ERR] = CNTR_ELEM("SDmaHeaderStorageUncErr", 0, 0,
4890 access_sdma_header_storage_unc_err_cnt),
4891 [C_SDMA_PACKET_TRACKING_UNC_ERR] = CNTR_ELEM("SDmaPacketTrackingUncErr", 0, 0,
4893 access_sdma_packet_tracking_unc_err_cnt),
4894 [C_SDMA_ASSEMBLY_UNC_ERR] = CNTR_ELEM("SDmaAssemblyUncErr", 0, 0,
4896 access_sdma_assembly_unc_err_cnt),
4897 [C_SDMA_DESC_TABLE_UNC_ERR] = CNTR_ELEM("SDmaDescTableUncErr", 0, 0,
4899 access_sdma_desc_table_unc_err_cnt),
4900 [C_SDMA_TIMEOUT_ERR] = CNTR_ELEM("SDmaTimeoutErr", 0, 0,
4902 access_sdma_timeout_err_cnt),
4903 [C_SDMA_HEADER_LENGTH_ERR] = CNTR_ELEM("SDmaHeaderLengthErr", 0, 0,
4905 access_sdma_header_length_err_cnt),
4906 [C_SDMA_HEADER_ADDRESS_ERR] = CNTR_ELEM("SDmaHeaderAddressErr", 0, 0,
4908 access_sdma_header_address_err_cnt),
4909 [C_SDMA_HEADER_SELECT_ERR] = CNTR_ELEM("SDmaHeaderSelectErr", 0, 0,
4911 access_sdma_header_select_err_cnt),
4912 [C_SMDA_RESERVED_9] = CNTR_ELEM("SDma Reserved 9", 0, 0,
4914 access_sdma_reserved_9_err_cnt),
4915 [C_SDMA_PACKET_DESC_OVERFLOW_ERR] = CNTR_ELEM("SDmaPacketDescOverflowErr", 0, 0,
4917 access_sdma_packet_desc_overflow_err_cnt),
4918 [C_SDMA_LENGTH_MISMATCH_ERR] = CNTR_ELEM("SDmaLengthMismatchErr", 0, 0,
4920 access_sdma_length_mismatch_err_cnt),
4921 [C_SDMA_HALT_ERR] = CNTR_ELEM("SDmaHaltErr", 0, 0,
4923 access_sdma_halt_err_cnt),
4924 [C_SDMA_MEM_READ_ERR] = CNTR_ELEM("SDmaMemReadErr", 0, 0,
4926 access_sdma_mem_read_err_cnt),
4927 [C_SDMA_FIRST_DESC_ERR] = CNTR_ELEM("SDmaFirstDescErr", 0, 0,
4929 access_sdma_first_desc_err_cnt),
4930 [C_SDMA_TAIL_OUT_OF_BOUNDS_ERR] = CNTR_ELEM("SDmaTailOutOfBoundsErr", 0, 0,
4932 access_sdma_tail_out_of_bounds_err_cnt),
4933 [C_SDMA_TOO_LONG_ERR] = CNTR_ELEM("SDmaTooLongErr", 0, 0,
4935 access_sdma_too_long_err_cnt),
4936 [C_SDMA_GEN_MISMATCH_ERR] = CNTR_ELEM("SDmaGenMismatchErr", 0, 0,
4938 access_sdma_gen_mismatch_err_cnt),
4939 [C_SDMA_WRONG_DW_ERR] = CNTR_ELEM("SDmaWrongDwErr", 0, 0,
4941 access_sdma_wrong_dw_err_cnt),
4944 static struct cntr_entry port_cntrs[PORT_CNTR_LAST] = {
4945 [C_TX_UNSUP_VL] = TXE32_PORT_CNTR_ELEM(TxUnVLErr, SEND_UNSUP_VL_ERR_CNT,
4947 [C_TX_INVAL_LEN] = TXE32_PORT_CNTR_ELEM(TxInvalLen, SEND_LEN_ERR_CNT,
4949 [C_TX_MM_LEN_ERR] = TXE32_PORT_CNTR_ELEM(TxMMLenErr, SEND_MAX_MIN_LEN_ERR_CNT,
4951 [C_TX_UNDERRUN] = TXE32_PORT_CNTR_ELEM(TxUnderrun, SEND_UNDERRUN_CNT,
4953 [C_TX_FLOW_STALL] = TXE32_PORT_CNTR_ELEM(TxFlowStall, SEND_FLOW_STALL_CNT,
4955 [C_TX_DROPPED] = TXE32_PORT_CNTR_ELEM(TxDropped, SEND_DROPPED_PKT_CNT,
4957 [C_TX_HDR_ERR] = TXE32_PORT_CNTR_ELEM(TxHdrErr, SEND_HEADERS_ERR_CNT,
4959 [C_TX_PKT] = TXE64_PORT_CNTR_ELEM(TxPkt, SEND_DATA_PKT_CNT, CNTR_NORMAL),
4960 [C_TX_WORDS] = TXE64_PORT_CNTR_ELEM(TxWords, SEND_DWORD_CNT, CNTR_NORMAL),
4961 [C_TX_WAIT] = TXE64_PORT_CNTR_ELEM(TxWait, SEND_WAIT_CNT, CNTR_SYNTH),
4962 [C_TX_FLIT_VL] = TXE64_PORT_CNTR_ELEM(TxFlitVL, SEND_DATA_VL0_CNT,
4963 CNTR_SYNTH | CNTR_VL),
4964 [C_TX_PKT_VL] = TXE64_PORT_CNTR_ELEM(TxPktVL, SEND_DATA_PKT_VL0_CNT,
4965 CNTR_SYNTH | CNTR_VL),
4966 [C_TX_WAIT_VL] = TXE64_PORT_CNTR_ELEM(TxWaitVL, SEND_WAIT_VL0_CNT,
4967 CNTR_SYNTH | CNTR_VL),
4968 [C_RX_PKT] = RXE64_PORT_CNTR_ELEM(RxPkt, RCV_DATA_PKT_CNT, CNTR_NORMAL),
4969 [C_RX_WORDS] = RXE64_PORT_CNTR_ELEM(RxWords, RCV_DWORD_CNT, CNTR_NORMAL),
4970 [C_SW_LINK_DOWN] = CNTR_ELEM("SwLinkDown", 0, 0, CNTR_SYNTH | CNTR_32BIT,
4971 access_sw_link_dn_cnt),
4972 [C_SW_LINK_UP] = CNTR_ELEM("SwLinkUp", 0, 0, CNTR_SYNTH | CNTR_32BIT,
4973 access_sw_link_up_cnt),
4974 [C_SW_UNKNOWN_FRAME] = CNTR_ELEM("UnknownFrame", 0, 0, CNTR_NORMAL,
4975 access_sw_unknown_frame_cnt),
4976 [C_SW_XMIT_DSCD] = CNTR_ELEM("XmitDscd", 0, 0, CNTR_SYNTH | CNTR_32BIT,
4977 access_sw_xmit_discards),
4978 [C_SW_XMIT_DSCD_VL] = CNTR_ELEM("XmitDscdVl", 0, 0,
4979 CNTR_SYNTH | CNTR_32BIT | CNTR_VL,
4980 access_sw_xmit_discards),
4981 [C_SW_XMIT_CSTR_ERR] = CNTR_ELEM("XmitCstrErr", 0, 0, CNTR_SYNTH,
4982 access_xmit_constraint_errs),
4983 [C_SW_RCV_CSTR_ERR] = CNTR_ELEM("RcvCstrErr", 0, 0, CNTR_SYNTH,
4984 access_rcv_constraint_errs),
4985 [C_SW_IBP_LOOP_PKTS] = SW_IBP_CNTR(LoopPkts, loop_pkts),
4986 [C_SW_IBP_RC_RESENDS] = SW_IBP_CNTR(RcResend, rc_resends),
4987 [C_SW_IBP_RNR_NAKS] = SW_IBP_CNTR(RnrNak, rnr_naks),
4988 [C_SW_IBP_OTHER_NAKS] = SW_IBP_CNTR(OtherNak, other_naks),
4989 [C_SW_IBP_RC_TIMEOUTS] = SW_IBP_CNTR(RcTimeOut, rc_timeouts),
4990 [C_SW_IBP_PKT_DROPS] = SW_IBP_CNTR(PktDrop, pkt_drops),
4991 [C_SW_IBP_DMA_WAIT] = SW_IBP_CNTR(DmaWait, dmawait),
4992 [C_SW_IBP_RC_SEQNAK] = SW_IBP_CNTR(RcSeqNak, rc_seqnak),
4993 [C_SW_IBP_RC_DUPREQ] = SW_IBP_CNTR(RcDupRew, rc_dupreq),
4994 [C_SW_IBP_RDMA_SEQ] = SW_IBP_CNTR(RdmaSeq, rdma_seq),
4995 [C_SW_IBP_UNALIGNED] = SW_IBP_CNTR(Unaligned, unaligned),
4996 [C_SW_IBP_SEQ_NAK] = SW_IBP_CNTR(SeqNak, seq_naks),
4997 [C_SW_CPU_RC_ACKS] = CNTR_ELEM("RcAcks", 0, 0, CNTR_NORMAL,
4998 access_sw_cpu_rc_acks),
4999 [C_SW_CPU_RC_QACKS] = CNTR_ELEM("RcQacks", 0, 0, CNTR_NORMAL,
5000 access_sw_cpu_rc_qacks),
5001 [C_SW_CPU_RC_DELAYED_COMP] = CNTR_ELEM("RcDelayComp", 0, 0, CNTR_NORMAL,
5002 access_sw_cpu_rc_delayed_comp),
5003 [OVR_LBL(0)] = OVR_ELM(0), [OVR_LBL(1)] = OVR_ELM(1),
5004 [OVR_LBL(2)] = OVR_ELM(2), [OVR_LBL(3)] = OVR_ELM(3),
5005 [OVR_LBL(4)] = OVR_ELM(4), [OVR_LBL(5)] = OVR_ELM(5),
5006 [OVR_LBL(6)] = OVR_ELM(6), [OVR_LBL(7)] = OVR_ELM(7),
5007 [OVR_LBL(8)] = OVR_ELM(8), [OVR_LBL(9)] = OVR_ELM(9),
5008 [OVR_LBL(10)] = OVR_ELM(10), [OVR_LBL(11)] = OVR_ELM(11),
5009 [OVR_LBL(12)] = OVR_ELM(12), [OVR_LBL(13)] = OVR_ELM(13),
5010 [OVR_LBL(14)] = OVR_ELM(14), [OVR_LBL(15)] = OVR_ELM(15),
5011 [OVR_LBL(16)] = OVR_ELM(16), [OVR_LBL(17)] = OVR_ELM(17),
5012 [OVR_LBL(18)] = OVR_ELM(18), [OVR_LBL(19)] = OVR_ELM(19),
5013 [OVR_LBL(20)] = OVR_ELM(20), [OVR_LBL(21)] = OVR_ELM(21),
5014 [OVR_LBL(22)] = OVR_ELM(22), [OVR_LBL(23)] = OVR_ELM(23),
5015 [OVR_LBL(24)] = OVR_ELM(24), [OVR_LBL(25)] = OVR_ELM(25),
5016 [OVR_LBL(26)] = OVR_ELM(26), [OVR_LBL(27)] = OVR_ELM(27),
5017 [OVR_LBL(28)] = OVR_ELM(28), [OVR_LBL(29)] = OVR_ELM(29),
5018 [OVR_LBL(30)] = OVR_ELM(30), [OVR_LBL(31)] = OVR_ELM(31),
5019 [OVR_LBL(32)] = OVR_ELM(32), [OVR_LBL(33)] = OVR_ELM(33),
5020 [OVR_LBL(34)] = OVR_ELM(34), [OVR_LBL(35)] = OVR_ELM(35),
5021 [OVR_LBL(36)] = OVR_ELM(36), [OVR_LBL(37)] = OVR_ELM(37),
5022 [OVR_LBL(38)] = OVR_ELM(38), [OVR_LBL(39)] = OVR_ELM(39),
5023 [OVR_LBL(40)] = OVR_ELM(40), [OVR_LBL(41)] = OVR_ELM(41),
5024 [OVR_LBL(42)] = OVR_ELM(42), [OVR_LBL(43)] = OVR_ELM(43),
5025 [OVR_LBL(44)] = OVR_ELM(44), [OVR_LBL(45)] = OVR_ELM(45),
5026 [OVR_LBL(46)] = OVR_ELM(46), [OVR_LBL(47)] = OVR_ELM(47),
5027 [OVR_LBL(48)] = OVR_ELM(48), [OVR_LBL(49)] = OVR_ELM(49),
5028 [OVR_LBL(50)] = OVR_ELM(50), [OVR_LBL(51)] = OVR_ELM(51),
5029 [OVR_LBL(52)] = OVR_ELM(52), [OVR_LBL(53)] = OVR_ELM(53),
5030 [OVR_LBL(54)] = OVR_ELM(54), [OVR_LBL(55)] = OVR_ELM(55),
5031 [OVR_LBL(56)] = OVR_ELM(56), [OVR_LBL(57)] = OVR_ELM(57),
5032 [OVR_LBL(58)] = OVR_ELM(58), [OVR_LBL(59)] = OVR_ELM(59),
5033 [OVR_LBL(60)] = OVR_ELM(60), [OVR_LBL(61)] = OVR_ELM(61),
5034 [OVR_LBL(62)] = OVR_ELM(62), [OVR_LBL(63)] = OVR_ELM(63),
5035 [OVR_LBL(64)] = OVR_ELM(64), [OVR_LBL(65)] = OVR_ELM(65),
5036 [OVR_LBL(66)] = OVR_ELM(66), [OVR_LBL(67)] = OVR_ELM(67),
5037 [OVR_LBL(68)] = OVR_ELM(68), [OVR_LBL(69)] = OVR_ELM(69),
5038 [OVR_LBL(70)] = OVR_ELM(70), [OVR_LBL(71)] = OVR_ELM(71),
5039 [OVR_LBL(72)] = OVR_ELM(72), [OVR_LBL(73)] = OVR_ELM(73),
5040 [OVR_LBL(74)] = OVR_ELM(74), [OVR_LBL(75)] = OVR_ELM(75),
5041 [OVR_LBL(76)] = OVR_ELM(76), [OVR_LBL(77)] = OVR_ELM(77),
5042 [OVR_LBL(78)] = OVR_ELM(78), [OVR_LBL(79)] = OVR_ELM(79),
5043 [OVR_LBL(80)] = OVR_ELM(80), [OVR_LBL(81)] = OVR_ELM(81),
5044 [OVR_LBL(82)] = OVR_ELM(82), [OVR_LBL(83)] = OVR_ELM(83),
5045 [OVR_LBL(84)] = OVR_ELM(84), [OVR_LBL(85)] = OVR_ELM(85),
5046 [OVR_LBL(86)] = OVR_ELM(86), [OVR_LBL(87)] = OVR_ELM(87),
5047 [OVR_LBL(88)] = OVR_ELM(88), [OVR_LBL(89)] = OVR_ELM(89),
5048 [OVR_LBL(90)] = OVR_ELM(90), [OVR_LBL(91)] = OVR_ELM(91),
5049 [OVR_LBL(92)] = OVR_ELM(92), [OVR_LBL(93)] = OVR_ELM(93),
5050 [OVR_LBL(94)] = OVR_ELM(94), [OVR_LBL(95)] = OVR_ELM(95),
5051 [OVR_LBL(96)] = OVR_ELM(96), [OVR_LBL(97)] = OVR_ELM(97),
5052 [OVR_LBL(98)] = OVR_ELM(98), [OVR_LBL(99)] = OVR_ELM(99),
5053 [OVR_LBL(100)] = OVR_ELM(100), [OVR_LBL(101)] = OVR_ELM(101),
5054 [OVR_LBL(102)] = OVR_ELM(102), [OVR_LBL(103)] = OVR_ELM(103),
5055 [OVR_LBL(104)] = OVR_ELM(104), [OVR_LBL(105)] = OVR_ELM(105),
5056 [OVR_LBL(106)] = OVR_ELM(106), [OVR_LBL(107)] = OVR_ELM(107),
5057 [OVR_LBL(108)] = OVR_ELM(108), [OVR_LBL(109)] = OVR_ELM(109),
5058 [OVR_LBL(110)] = OVR_ELM(110), [OVR_LBL(111)] = OVR_ELM(111),
5059 [OVR_LBL(112)] = OVR_ELM(112), [OVR_LBL(113)] = OVR_ELM(113),
5060 [OVR_LBL(114)] = OVR_ELM(114), [OVR_LBL(115)] = OVR_ELM(115),
5061 [OVR_LBL(116)] = OVR_ELM(116), [OVR_LBL(117)] = OVR_ELM(117),
5062 [OVR_LBL(118)] = OVR_ELM(118), [OVR_LBL(119)] = OVR_ELM(119),
5063 [OVR_LBL(120)] = OVR_ELM(120), [OVR_LBL(121)] = OVR_ELM(121),
5064 [OVR_LBL(122)] = OVR_ELM(122), [OVR_LBL(123)] = OVR_ELM(123),
5065 [OVR_LBL(124)] = OVR_ELM(124), [OVR_LBL(125)] = OVR_ELM(125),
5066 [OVR_LBL(126)] = OVR_ELM(126), [OVR_LBL(127)] = OVR_ELM(127),
5067 [OVR_LBL(128)] = OVR_ELM(128), [OVR_LBL(129)] = OVR_ELM(129),
5068 [OVR_LBL(130)] = OVR_ELM(130), [OVR_LBL(131)] = OVR_ELM(131),
5069 [OVR_LBL(132)] = OVR_ELM(132), [OVR_LBL(133)] = OVR_ELM(133),
5070 [OVR_LBL(134)] = OVR_ELM(134), [OVR_LBL(135)] = OVR_ELM(135),
5071 [OVR_LBL(136)] = OVR_ELM(136), [OVR_LBL(137)] = OVR_ELM(137),
5072 [OVR_LBL(138)] = OVR_ELM(138), [OVR_LBL(139)] = OVR_ELM(139),
5073 [OVR_LBL(140)] = OVR_ELM(140), [OVR_LBL(141)] = OVR_ELM(141),
5074 [OVR_LBL(142)] = OVR_ELM(142), [OVR_LBL(143)] = OVR_ELM(143),
5075 [OVR_LBL(144)] = OVR_ELM(144), [OVR_LBL(145)] = OVR_ELM(145),
5076 [OVR_LBL(146)] = OVR_ELM(146), [OVR_LBL(147)] = OVR_ELM(147),
5077 [OVR_LBL(148)] = OVR_ELM(148), [OVR_LBL(149)] = OVR_ELM(149),
5078 [OVR_LBL(150)] = OVR_ELM(150), [OVR_LBL(151)] = OVR_ELM(151),
5079 [OVR_LBL(152)] = OVR_ELM(152), [OVR_LBL(153)] = OVR_ELM(153),
5080 [OVR_LBL(154)] = OVR_ELM(154), [OVR_LBL(155)] = OVR_ELM(155),
5081 [OVR_LBL(156)] = OVR_ELM(156), [OVR_LBL(157)] = OVR_ELM(157),
5082 [OVR_LBL(158)] = OVR_ELM(158), [OVR_LBL(159)] = OVR_ELM(159),
5085 /* ======================================================================== */
5087 /* return true if this is chip revision revision a */
5088 int is_ax(struct hfi1_devdata *dd)
5091 dd->revision >> CCE_REVISION_CHIP_REV_MINOR_SHIFT
5092 & CCE_REVISION_CHIP_REV_MINOR_MASK;
5093 return (chip_rev_minor & 0xf0) == 0;
5096 /* return true if this is chip revision revision b */
5097 int is_bx(struct hfi1_devdata *dd)
5100 dd->revision >> CCE_REVISION_CHIP_REV_MINOR_SHIFT
5101 & CCE_REVISION_CHIP_REV_MINOR_MASK;
5102 return (chip_rev_minor & 0xF0) == 0x10;
5106 * Append string s to buffer buf. Arguments curp and len are the current
5107 * position and remaining length, respectively.
5109 * return 0 on success, 1 on out of room
5111 static int append_str(char *buf, char **curp, int *lenp, const char *s)
5115 int result = 0; /* success */
5118 /* add a comma, if first in the buffer */
5121 result = 1; /* out of room */
5128 /* copy the string */
5129 while ((c = *s++) != 0) {
5131 result = 1; /* out of room */
5139 /* write return values */
5147 * Using the given flag table, print a comma separated string into
5148 * the buffer. End in '*' if the buffer is too short.
5150 static char *flag_string(char *buf, int buf_len, u64 flags,
5151 struct flag_table *table, int table_size)
5159 /* make sure there is at least 2 so we can form "*" */
5163 len--; /* leave room for a nul */
5164 for (i = 0; i < table_size; i++) {
5165 if (flags & table[i].flag) {
5166 no_room = append_str(buf, &p, &len, table[i].str);
5169 flags &= ~table[i].flag;
5173 /* any undocumented bits left? */
5174 if (!no_room && flags) {
5175 snprintf(extra, sizeof(extra), "bits 0x%llx", flags);
5176 no_room = append_str(buf, &p, &len, extra);
5179 /* add * if ran out of room */
5181 /* may need to back up to add space for a '*' */
5187 /* add final nul - space already allocated above */
5192 /* first 8 CCE error interrupt source names */
5193 static const char * const cce_misc_names[] = {
5194 "CceErrInt", /* 0 */
5195 "RxeErrInt", /* 1 */
5196 "MiscErrInt", /* 2 */
5197 "Reserved3", /* 3 */
5198 "PioErrInt", /* 4 */
5199 "SDmaErrInt", /* 5 */
5200 "EgressErrInt", /* 6 */
5205 * Return the miscellaneous error interrupt name.
5207 static char *is_misc_err_name(char *buf, size_t bsize, unsigned int source)
5209 if (source < ARRAY_SIZE(cce_misc_names))
5210 strncpy(buf, cce_misc_names[source], bsize);
5212 snprintf(buf, bsize, "Reserved%u",
5213 source + IS_GENERAL_ERR_START);
5219 * Return the SDMA engine error interrupt name.
5221 static char *is_sdma_eng_err_name(char *buf, size_t bsize, unsigned int source)
5223 snprintf(buf, bsize, "SDmaEngErrInt%u", source);
5228 * Return the send context error interrupt name.
5230 static char *is_sendctxt_err_name(char *buf, size_t bsize, unsigned int source)
5232 snprintf(buf, bsize, "SendCtxtErrInt%u", source);
5236 static const char * const various_names[] = {
5245 * Return the various interrupt name.
5247 static char *is_various_name(char *buf, size_t bsize, unsigned int source)
5249 if (source < ARRAY_SIZE(various_names))
5250 strncpy(buf, various_names[source], bsize);
5252 snprintf(buf, bsize, "Reserved%u", source + IS_VARIOUS_START);
5257 * Return the DC interrupt name.
5259 static char *is_dc_name(char *buf, size_t bsize, unsigned int source)
5261 static const char * const dc_int_names[] = {
5265 "lbm" /* local block merge */
5268 if (source < ARRAY_SIZE(dc_int_names))
5269 snprintf(buf, bsize, "dc_%s_int", dc_int_names[source]);
5271 snprintf(buf, bsize, "DCInt%u", source);
5275 static const char * const sdma_int_names[] = {
5282 * Return the SDMA engine interrupt name.
5284 static char *is_sdma_eng_name(char *buf, size_t bsize, unsigned int source)
5286 /* what interrupt */
5287 unsigned int what = source / TXE_NUM_SDMA_ENGINES;
5289 unsigned int which = source % TXE_NUM_SDMA_ENGINES;
5291 if (likely(what < 3))
5292 snprintf(buf, bsize, "%s%u", sdma_int_names[what], which);
5294 snprintf(buf, bsize, "Invalid SDMA interrupt %u", source);
5299 * Return the receive available interrupt name.
5301 static char *is_rcv_avail_name(char *buf, size_t bsize, unsigned int source)
5303 snprintf(buf, bsize, "RcvAvailInt%u", source);
5308 * Return the receive urgent interrupt name.
5310 static char *is_rcv_urgent_name(char *buf, size_t bsize, unsigned int source)
5312 snprintf(buf, bsize, "RcvUrgentInt%u", source);
5317 * Return the send credit interrupt name.
5319 static char *is_send_credit_name(char *buf, size_t bsize, unsigned int source)
5321 snprintf(buf, bsize, "SendCreditInt%u", source);
5326 * Return the reserved interrupt name.
5328 static char *is_reserved_name(char *buf, size_t bsize, unsigned int source)
5330 snprintf(buf, bsize, "Reserved%u", source + IS_RESERVED_START);
5334 static char *cce_err_status_string(char *buf, int buf_len, u64 flags)
5336 return flag_string(buf, buf_len, flags,
5337 cce_err_status_flags,
5338 ARRAY_SIZE(cce_err_status_flags));
5341 static char *rxe_err_status_string(char *buf, int buf_len, u64 flags)
5343 return flag_string(buf, buf_len, flags,
5344 rxe_err_status_flags,
5345 ARRAY_SIZE(rxe_err_status_flags));
5348 static char *misc_err_status_string(char *buf, int buf_len, u64 flags)
5350 return flag_string(buf, buf_len, flags, misc_err_status_flags,
5351 ARRAY_SIZE(misc_err_status_flags));
5354 static char *pio_err_status_string(char *buf, int buf_len, u64 flags)
5356 return flag_string(buf, buf_len, flags,
5357 pio_err_status_flags,
5358 ARRAY_SIZE(pio_err_status_flags));
5361 static char *sdma_err_status_string(char *buf, int buf_len, u64 flags)
5363 return flag_string(buf, buf_len, flags,
5364 sdma_err_status_flags,
5365 ARRAY_SIZE(sdma_err_status_flags));
5368 static char *egress_err_status_string(char *buf, int buf_len, u64 flags)
5370 return flag_string(buf, buf_len, flags,
5371 egress_err_status_flags,
5372 ARRAY_SIZE(egress_err_status_flags));
5375 static char *egress_err_info_string(char *buf, int buf_len, u64 flags)
5377 return flag_string(buf, buf_len, flags,
5378 egress_err_info_flags,
5379 ARRAY_SIZE(egress_err_info_flags));
5382 static char *send_err_status_string(char *buf, int buf_len, u64 flags)
5384 return flag_string(buf, buf_len, flags,
5385 send_err_status_flags,
5386 ARRAY_SIZE(send_err_status_flags));
5389 static void handle_cce_err(struct hfi1_devdata *dd, u32 unused, u64 reg)
5395 * For most these errors, there is nothing that can be done except
5396 * report or record it.
5398 dd_dev_info(dd, "CCE Error: %s\n",
5399 cce_err_status_string(buf, sizeof(buf), reg));
5401 if ((reg & CCE_ERR_STATUS_CCE_CLI2_ASYNC_FIFO_PARITY_ERR_SMASK) &&
5402 is_ax(dd) && (dd->icode != ICODE_FUNCTIONAL_SIMULATOR)) {
5403 /* this error requires a manual drop into SPC freeze mode */
5405 start_freeze_handling(dd->pport, FREEZE_SELF);
5408 for (i = 0; i < NUM_CCE_ERR_STATUS_COUNTERS; i++) {
5409 if (reg & (1ull << i)) {
5410 incr_cntr64(&dd->cce_err_status_cnt[i]);
5411 /* maintain a counter over all cce_err_status errors */
5412 incr_cntr64(&dd->sw_cce_err_status_aggregate);
5418 * Check counters for receive errors that do not have an interrupt
5419 * associated with them.
5421 #define RCVERR_CHECK_TIME 10
5422 static void update_rcverr_timer(unsigned long opaque)
5424 struct hfi1_devdata *dd = (struct hfi1_devdata *)opaque;
5425 struct hfi1_pportdata *ppd = dd->pport;
5426 u32 cur_ovfl_cnt = read_dev_cntr(dd, C_RCV_OVF, CNTR_INVALID_VL);
5428 if (dd->rcv_ovfl_cnt < cur_ovfl_cnt &&
5429 ppd->port_error_action & OPA_PI_MASK_EX_BUFFER_OVERRUN) {
5430 dd_dev_info(dd, "%s: PortErrorAction bounce\n", __func__);
5431 set_link_down_reason(
5432 ppd, OPA_LINKDOWN_REASON_EXCESSIVE_BUFFER_OVERRUN, 0,
5433 OPA_LINKDOWN_REASON_EXCESSIVE_BUFFER_OVERRUN);
5434 queue_work(ppd->hfi1_wq, &ppd->link_bounce_work);
5436 dd->rcv_ovfl_cnt = (u32)cur_ovfl_cnt;
5438 mod_timer(&dd->rcverr_timer, jiffies + HZ * RCVERR_CHECK_TIME);
5441 static int init_rcverr(struct hfi1_devdata *dd)
5443 setup_timer(&dd->rcverr_timer, update_rcverr_timer, (unsigned long)dd);
5444 /* Assume the hardware counter has been reset */
5445 dd->rcv_ovfl_cnt = 0;
5446 return mod_timer(&dd->rcverr_timer, jiffies + HZ * RCVERR_CHECK_TIME);
5449 static void free_rcverr(struct hfi1_devdata *dd)
5451 if (dd->rcverr_timer.data)
5452 del_timer_sync(&dd->rcverr_timer);
5453 dd->rcverr_timer.data = 0;
5456 static void handle_rxe_err(struct hfi1_devdata *dd, u32 unused, u64 reg)
5461 dd_dev_info(dd, "Receive Error: %s\n",
5462 rxe_err_status_string(buf, sizeof(buf), reg));
5464 if (reg & ALL_RXE_FREEZE_ERR) {
5468 * Freeze mode recovery is disabled for the errors
5469 * in RXE_FREEZE_ABORT_MASK
5471 if (is_ax(dd) && (reg & RXE_FREEZE_ABORT_MASK))
5472 flags = FREEZE_ABORT;
5474 start_freeze_handling(dd->pport, flags);
5477 for (i = 0; i < NUM_RCV_ERR_STATUS_COUNTERS; i++) {
5478 if (reg & (1ull << i))
5479 incr_cntr64(&dd->rcv_err_status_cnt[i]);
5483 static void handle_misc_err(struct hfi1_devdata *dd, u32 unused, u64 reg)
5488 dd_dev_info(dd, "Misc Error: %s",
5489 misc_err_status_string(buf, sizeof(buf), reg));
5490 for (i = 0; i < NUM_MISC_ERR_STATUS_COUNTERS; i++) {
5491 if (reg & (1ull << i))
5492 incr_cntr64(&dd->misc_err_status_cnt[i]);
5496 static void handle_pio_err(struct hfi1_devdata *dd, u32 unused, u64 reg)
5501 dd_dev_info(dd, "PIO Error: %s\n",
5502 pio_err_status_string(buf, sizeof(buf), reg));
5504 if (reg & ALL_PIO_FREEZE_ERR)
5505 start_freeze_handling(dd->pport, 0);
5507 for (i = 0; i < NUM_SEND_PIO_ERR_STATUS_COUNTERS; i++) {
5508 if (reg & (1ull << i))
5509 incr_cntr64(&dd->send_pio_err_status_cnt[i]);
5513 static void handle_sdma_err(struct hfi1_devdata *dd, u32 unused, u64 reg)
5518 dd_dev_info(dd, "SDMA Error: %s\n",
5519 sdma_err_status_string(buf, sizeof(buf), reg));
5521 if (reg & ALL_SDMA_FREEZE_ERR)
5522 start_freeze_handling(dd->pport, 0);
5524 for (i = 0; i < NUM_SEND_DMA_ERR_STATUS_COUNTERS; i++) {
5525 if (reg & (1ull << i))
5526 incr_cntr64(&dd->send_dma_err_status_cnt[i]);
5530 static inline void __count_port_discards(struct hfi1_pportdata *ppd)
5532 incr_cntr64(&ppd->port_xmit_discards);
5535 static void count_port_inactive(struct hfi1_devdata *dd)
5537 __count_port_discards(dd->pport);
5541 * We have had a "disallowed packet" error during egress. Determine the
5542 * integrity check which failed, and update relevant error counter, etc.
5544 * Note that the SEND_EGRESS_ERR_INFO register has only a single
5545 * bit of state per integrity check, and so we can miss the reason for an
5546 * egress error if more than one packet fails the same integrity check
5547 * since we cleared the corresponding bit in SEND_EGRESS_ERR_INFO.
5549 static void handle_send_egress_err_info(struct hfi1_devdata *dd,
5552 struct hfi1_pportdata *ppd = dd->pport;
5553 u64 src = read_csr(dd, SEND_EGRESS_ERR_SOURCE); /* read first */
5554 u64 info = read_csr(dd, SEND_EGRESS_ERR_INFO);
5557 /* clear down all observed info as quickly as possible after read */
5558 write_csr(dd, SEND_EGRESS_ERR_INFO, info);
5561 "Egress Error Info: 0x%llx, %s Egress Error Src 0x%llx\n",
5562 info, egress_err_info_string(buf, sizeof(buf), info), src);
5564 /* Eventually add other counters for each bit */
5565 if (info & PORT_DISCARD_EGRESS_ERRS) {
5569 * Count all applicable bits as individual errors and
5570 * attribute them to the packet that triggered this handler.
5571 * This may not be completely accurate due to limitations
5572 * on the available hardware error information. There is
5573 * a single information register and any number of error
5574 * packets may have occurred and contributed to it before
5575 * this routine is called. This means that:
5576 * a) If multiple packets with the same error occur before
5577 * this routine is called, earlier packets are missed.
5578 * There is only a single bit for each error type.
5579 * b) Errors may not be attributed to the correct VL.
5580 * The driver is attributing all bits in the info register
5581 * to the packet that triggered this call, but bits
5582 * could be an accumulation of different packets with
5584 * c) A single error packet may have multiple counts attached
5585 * to it. There is no way for the driver to know if
5586 * multiple bits set in the info register are due to a
5587 * single packet or multiple packets. The driver assumes
5590 weight = hweight64(info & PORT_DISCARD_EGRESS_ERRS);
5591 for (i = 0; i < weight; i++) {
5592 __count_port_discards(ppd);
5593 if (vl >= 0 && vl < TXE_NUM_DATA_VL)
5594 incr_cntr64(&ppd->port_xmit_discards_vl[vl]);
5596 incr_cntr64(&ppd->port_xmit_discards_vl
5603 * Input value is a bit position within the SEND_EGRESS_ERR_STATUS
5604 * register. Does it represent a 'port inactive' error?
5606 static inline int port_inactive_err(u64 posn)
5608 return (posn >= SEES(TX_LINKDOWN) &&
5609 posn <= SEES(TX_INCORRECT_LINK_STATE));
5613 * Input value is a bit position within the SEND_EGRESS_ERR_STATUS
5614 * register. Does it represent a 'disallowed packet' error?
5616 static inline int disallowed_pkt_err(int posn)
5618 return (posn >= SEES(TX_SDMA0_DISALLOWED_PACKET) &&
5619 posn <= SEES(TX_SDMA15_DISALLOWED_PACKET));
5623 * Input value is a bit position of one of the SDMA engine disallowed
5624 * packet errors. Return which engine. Use of this must be guarded by
5625 * disallowed_pkt_err().
5627 static inline int disallowed_pkt_engine(int posn)
5629 return posn - SEES(TX_SDMA0_DISALLOWED_PACKET);
5633 * Translate an SDMA engine to a VL. Return -1 if the tranlation cannot
5636 static int engine_to_vl(struct hfi1_devdata *dd, int engine)
5638 struct sdma_vl_map *m;
5642 if (engine < 0 || engine >= TXE_NUM_SDMA_ENGINES)
5646 m = rcu_dereference(dd->sdma_map);
5647 vl = m->engine_to_vl[engine];
5654 * Translate the send context (sofware index) into a VL. Return -1 if the
5655 * translation cannot be done.
5657 static int sc_to_vl(struct hfi1_devdata *dd, int sw_index)
5659 struct send_context_info *sci;
5660 struct send_context *sc;
5663 sci = &dd->send_contexts[sw_index];
5665 /* there is no information for user (PSM) and ack contexts */
5666 if ((sci->type != SC_KERNEL) && (sci->type != SC_VL15))
5672 if (dd->vld[15].sc == sc)
5674 for (i = 0; i < num_vls; i++)
5675 if (dd->vld[i].sc == sc)
5681 static void handle_egress_err(struct hfi1_devdata *dd, u32 unused, u64 reg)
5683 u64 reg_copy = reg, handled = 0;
5687 if (reg & ALL_TXE_EGRESS_FREEZE_ERR)
5688 start_freeze_handling(dd->pport, 0);
5689 else if (is_ax(dd) &&
5690 (reg & SEND_EGRESS_ERR_STATUS_TX_CREDIT_RETURN_VL_ERR_SMASK) &&
5691 (dd->icode != ICODE_FUNCTIONAL_SIMULATOR))
5692 start_freeze_handling(dd->pport, 0);
5695 int posn = fls64(reg_copy);
5696 /* fls64() returns a 1-based offset, we want it zero based */
5697 int shift = posn - 1;
5698 u64 mask = 1ULL << shift;
5700 if (port_inactive_err(shift)) {
5701 count_port_inactive(dd);
5703 } else if (disallowed_pkt_err(shift)) {
5704 int vl = engine_to_vl(dd, disallowed_pkt_engine(shift));
5706 handle_send_egress_err_info(dd, vl);
5715 dd_dev_info(dd, "Egress Error: %s\n",
5716 egress_err_status_string(buf, sizeof(buf), reg));
5718 for (i = 0; i < NUM_SEND_EGRESS_ERR_STATUS_COUNTERS; i++) {
5719 if (reg & (1ull << i))
5720 incr_cntr64(&dd->send_egress_err_status_cnt[i]);
5724 static void handle_txe_err(struct hfi1_devdata *dd, u32 unused, u64 reg)
5729 dd_dev_info(dd, "Send Error: %s\n",
5730 send_err_status_string(buf, sizeof(buf), reg));
5732 for (i = 0; i < NUM_SEND_ERR_STATUS_COUNTERS; i++) {
5733 if (reg & (1ull << i))
5734 incr_cntr64(&dd->send_err_status_cnt[i]);
5739 * The maximum number of times the error clear down will loop before
5740 * blocking a repeating error. This value is arbitrary.
5742 #define MAX_CLEAR_COUNT 20
5745 * Clear and handle an error register. All error interrupts are funneled
5746 * through here to have a central location to correctly handle single-
5747 * or multi-shot errors.
5749 * For non per-context registers, call this routine with a context value
5750 * of 0 so the per-context offset is zero.
5752 * If the handler loops too many times, assume that something is wrong
5753 * and can't be fixed, so mask the error bits.
5755 static void interrupt_clear_down(struct hfi1_devdata *dd,
5757 const struct err_reg_info *eri)
5762 /* read in a loop until no more errors are seen */
5765 reg = read_kctxt_csr(dd, context, eri->status);
5768 write_kctxt_csr(dd, context, eri->clear, reg);
5769 if (likely(eri->handler))
5770 eri->handler(dd, context, reg);
5772 if (count > MAX_CLEAR_COUNT) {
5775 dd_dev_err(dd, "Repeating %s bits 0x%llx - masking\n",
5778 * Read-modify-write so any other masked bits
5781 mask = read_kctxt_csr(dd, context, eri->mask);
5783 write_kctxt_csr(dd, context, eri->mask, mask);
5790 * CCE block "misc" interrupt. Source is < 16.
5792 static void is_misc_err_int(struct hfi1_devdata *dd, unsigned int source)
5794 const struct err_reg_info *eri = &misc_errs[source];
5797 interrupt_clear_down(dd, 0, eri);
5799 dd_dev_err(dd, "Unexpected misc interrupt (%u) - reserved\n",
5804 static char *send_context_err_status_string(char *buf, int buf_len, u64 flags)
5806 return flag_string(buf, buf_len, flags,
5807 sc_err_status_flags,
5808 ARRAY_SIZE(sc_err_status_flags));
5812 * Send context error interrupt. Source (hw_context) is < 160.
5814 * All send context errors cause the send context to halt. The normal
5815 * clear-down mechanism cannot be used because we cannot clear the
5816 * error bits until several other long-running items are done first.
5817 * This is OK because with the context halted, nothing else is going
5818 * to happen on it anyway.
5820 static void is_sendctxt_err_int(struct hfi1_devdata *dd,
5821 unsigned int hw_context)
5823 struct send_context_info *sci;
5824 struct send_context *sc;
5830 sw_index = dd->hw_to_sw[hw_context];
5831 if (sw_index >= dd->num_send_contexts) {
5833 "out of range sw index %u for send context %u\n",
5834 sw_index, hw_context);
5837 sci = &dd->send_contexts[sw_index];
5840 dd_dev_err(dd, "%s: context %u(%u): no sc?\n", __func__,
5841 sw_index, hw_context);
5845 /* tell the software that a halt has begun */
5846 sc_stop(sc, SCF_HALTED);
5848 status = read_kctxt_csr(dd, hw_context, SEND_CTXT_ERR_STATUS);
5850 dd_dev_info(dd, "Send Context %u(%u) Error: %s\n", sw_index, hw_context,
5851 send_context_err_status_string(flags, sizeof(flags),
5854 if (status & SEND_CTXT_ERR_STATUS_PIO_DISALLOWED_PACKET_ERR_SMASK)
5855 handle_send_egress_err_info(dd, sc_to_vl(dd, sw_index));
5858 * Automatically restart halted kernel contexts out of interrupt
5859 * context. User contexts must ask the driver to restart the context.
5861 if (sc->type != SC_USER)
5862 queue_work(dd->pport->hfi1_wq, &sc->halt_work);
5865 * Update the counters for the corresponding status bits.
5866 * Note that these particular counters are aggregated over all
5869 for (i = 0; i < NUM_SEND_CTXT_ERR_STATUS_COUNTERS; i++) {
5870 if (status & (1ull << i))
5871 incr_cntr64(&dd->sw_ctxt_err_status_cnt[i]);
5875 static void handle_sdma_eng_err(struct hfi1_devdata *dd,
5876 unsigned int source, u64 status)
5878 struct sdma_engine *sde;
5881 sde = &dd->per_sdma[source];
5882 #ifdef CONFIG_SDMA_VERBOSITY
5883 dd_dev_err(sde->dd, "CONFIG SDMA(%u) %s:%d %s()\n", sde->this_idx,
5884 slashstrip(__FILE__), __LINE__, __func__);
5885 dd_dev_err(sde->dd, "CONFIG SDMA(%u) source: %u status 0x%llx\n",
5886 sde->this_idx, source, (unsigned long long)status);
5889 sdma_engine_error(sde, status);
5892 * Update the counters for the corresponding status bits.
5893 * Note that these particular counters are aggregated over
5894 * all 16 DMA engines.
5896 for (i = 0; i < NUM_SEND_DMA_ENG_ERR_STATUS_COUNTERS; i++) {
5897 if (status & (1ull << i))
5898 incr_cntr64(&dd->sw_send_dma_eng_err_status_cnt[i]);
5903 * CCE block SDMA error interrupt. Source is < 16.
5905 static void is_sdma_eng_err_int(struct hfi1_devdata *dd, unsigned int source)
5907 #ifdef CONFIG_SDMA_VERBOSITY
5908 struct sdma_engine *sde = &dd->per_sdma[source];
5910 dd_dev_err(dd, "CONFIG SDMA(%u) %s:%d %s()\n", sde->this_idx,
5911 slashstrip(__FILE__), __LINE__, __func__);
5912 dd_dev_err(dd, "CONFIG SDMA(%u) source: %u\n", sde->this_idx,
5914 sdma_dumpstate(sde);
5916 interrupt_clear_down(dd, source, &sdma_eng_err);
5920 * CCE block "various" interrupt. Source is < 8.
5922 static void is_various_int(struct hfi1_devdata *dd, unsigned int source)
5924 const struct err_reg_info *eri = &various_err[source];
5927 * TCritInt cannot go through interrupt_clear_down()
5928 * because it is not a second tier interrupt. The handler
5929 * should be called directly.
5931 if (source == TCRIT_INT_SOURCE)
5932 handle_temp_err(dd);
5933 else if (eri->handler)
5934 interrupt_clear_down(dd, 0, eri);
5937 "%s: Unimplemented/reserved interrupt %d\n",
5941 static void handle_qsfp_int(struct hfi1_devdata *dd, u32 src_ctx, u64 reg)
5943 /* src_ctx is always zero */
5944 struct hfi1_pportdata *ppd = dd->pport;
5945 unsigned long flags;
5946 u64 qsfp_int_mgmt = (u64)(QSFP_HFI0_INT_N | QSFP_HFI0_MODPRST_N);
5948 if (reg & QSFP_HFI0_MODPRST_N) {
5949 if (!qsfp_mod_present(ppd)) {
5950 dd_dev_info(dd, "%s: QSFP module removed\n",
5953 ppd->driver_link_ready = 0;
5955 * Cable removed, reset all our information about the
5956 * cache and cable capabilities
5959 spin_lock_irqsave(&ppd->qsfp_info.qsfp_lock, flags);
5961 * We don't set cache_refresh_required here as we expect
5962 * an interrupt when a cable is inserted
5964 ppd->qsfp_info.cache_valid = 0;
5965 ppd->qsfp_info.reset_needed = 0;
5966 ppd->qsfp_info.limiting_active = 0;
5967 spin_unlock_irqrestore(&ppd->qsfp_info.qsfp_lock,
5969 /* Invert the ModPresent pin now to detect plug-in */
5970 write_csr(dd, dd->hfi1_id ? ASIC_QSFP2_INVERT :
5971 ASIC_QSFP1_INVERT, qsfp_int_mgmt);
5973 if ((ppd->offline_disabled_reason >
5975 OPA_LINKDOWN_REASON_LOCAL_MEDIA_NOT_INSTALLED)) ||
5976 (ppd->offline_disabled_reason ==
5977 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_NONE)))
5978 ppd->offline_disabled_reason =
5980 OPA_LINKDOWN_REASON_LOCAL_MEDIA_NOT_INSTALLED);
5982 if (ppd->host_link_state == HLS_DN_POLL) {
5984 * The link is still in POLL. This means
5985 * that the normal link down processing
5986 * will not happen. We have to do it here
5987 * before turning the DC off.
5989 queue_work(ppd->hfi1_wq, &ppd->link_down_work);
5992 dd_dev_info(dd, "%s: QSFP module inserted\n",
5995 spin_lock_irqsave(&ppd->qsfp_info.qsfp_lock, flags);
5996 ppd->qsfp_info.cache_valid = 0;
5997 ppd->qsfp_info.cache_refresh_required = 1;
5998 spin_unlock_irqrestore(&ppd->qsfp_info.qsfp_lock,
6002 * Stop inversion of ModPresent pin to detect
6003 * removal of the cable
6005 qsfp_int_mgmt &= ~(u64)QSFP_HFI0_MODPRST_N;
6006 write_csr(dd, dd->hfi1_id ? ASIC_QSFP2_INVERT :
6007 ASIC_QSFP1_INVERT, qsfp_int_mgmt);
6009 ppd->offline_disabled_reason =
6010 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_TRANSIENT);
6014 if (reg & QSFP_HFI0_INT_N) {
6015 dd_dev_info(dd, "%s: Interrupt received from QSFP module\n",
6017 spin_lock_irqsave(&ppd->qsfp_info.qsfp_lock, flags);
6018 ppd->qsfp_info.check_interrupt_flags = 1;
6019 spin_unlock_irqrestore(&ppd->qsfp_info.qsfp_lock, flags);
6022 /* Schedule the QSFP work only if there is a cable attached. */
6023 if (qsfp_mod_present(ppd))
6024 queue_work(ppd->hfi1_wq, &ppd->qsfp_info.qsfp_work);
6027 static int request_host_lcb_access(struct hfi1_devdata *dd)
6031 ret = do_8051_command(dd, HCMD_MISC,
6032 (u64)HCMD_MISC_REQUEST_LCB_ACCESS <<
6033 LOAD_DATA_FIELD_ID_SHIFT, NULL);
6034 if (ret != HCMD_SUCCESS) {
6035 dd_dev_err(dd, "%s: command failed with error %d\n",
6038 return ret == HCMD_SUCCESS ? 0 : -EBUSY;
6041 static int request_8051_lcb_access(struct hfi1_devdata *dd)
6045 ret = do_8051_command(dd, HCMD_MISC,
6046 (u64)HCMD_MISC_GRANT_LCB_ACCESS <<
6047 LOAD_DATA_FIELD_ID_SHIFT, NULL);
6048 if (ret != HCMD_SUCCESS) {
6049 dd_dev_err(dd, "%s: command failed with error %d\n",
6052 return ret == HCMD_SUCCESS ? 0 : -EBUSY;
6056 * Set the LCB selector - allow host access. The DCC selector always
6057 * points to the host.
6059 static inline void set_host_lcb_access(struct hfi1_devdata *dd)
6061 write_csr(dd, DC_DC8051_CFG_CSR_ACCESS_SEL,
6062 DC_DC8051_CFG_CSR_ACCESS_SEL_DCC_SMASK |
6063 DC_DC8051_CFG_CSR_ACCESS_SEL_LCB_SMASK);
6067 * Clear the LCB selector - allow 8051 access. The DCC selector always
6068 * points to the host.
6070 static inline void set_8051_lcb_access(struct hfi1_devdata *dd)
6072 write_csr(dd, DC_DC8051_CFG_CSR_ACCESS_SEL,
6073 DC_DC8051_CFG_CSR_ACCESS_SEL_DCC_SMASK);
6077 * Acquire LCB access from the 8051. If the host already has access,
6078 * just increment a counter. Otherwise, inform the 8051 that the
6079 * host is taking access.
6083 * -EBUSY if the 8051 has control and cannot be disturbed
6084 * -errno if unable to acquire access from the 8051
6086 int acquire_lcb_access(struct hfi1_devdata *dd, int sleep_ok)
6088 struct hfi1_pportdata *ppd = dd->pport;
6092 * Use the host link state lock so the operation of this routine
6093 * { link state check, selector change, count increment } can occur
6094 * as a unit against a link state change. Otherwise there is a
6095 * race between the state change and the count increment.
6098 mutex_lock(&ppd->hls_lock);
6100 while (!mutex_trylock(&ppd->hls_lock))
6104 /* this access is valid only when the link is up */
6105 if ((ppd->host_link_state & HLS_UP) == 0) {
6106 dd_dev_info(dd, "%s: link state %s not up\n",
6107 __func__, link_state_name(ppd->host_link_state));
6112 if (dd->lcb_access_count == 0) {
6113 ret = request_host_lcb_access(dd);
6116 "%s: unable to acquire LCB access, err %d\n",
6120 set_host_lcb_access(dd);
6122 dd->lcb_access_count++;
6124 mutex_unlock(&ppd->hls_lock);
6129 * Release LCB access by decrementing the use count. If the count is moving
6130 * from 1 to 0, inform 8051 that it has control back.
6134 * -errno if unable to release access to the 8051
6136 int release_lcb_access(struct hfi1_devdata *dd, int sleep_ok)
6141 * Use the host link state lock because the acquire needed it.
6142 * Here, we only need to keep { selector change, count decrement }
6146 mutex_lock(&dd->pport->hls_lock);
6148 while (!mutex_trylock(&dd->pport->hls_lock))
6152 if (dd->lcb_access_count == 0) {
6153 dd_dev_err(dd, "%s: LCB access count is zero. Skipping.\n",
6158 if (dd->lcb_access_count == 1) {
6159 set_8051_lcb_access(dd);
6160 ret = request_8051_lcb_access(dd);
6163 "%s: unable to release LCB access, err %d\n",
6165 /* restore host access if the grant didn't work */
6166 set_host_lcb_access(dd);
6170 dd->lcb_access_count--;
6172 mutex_unlock(&dd->pport->hls_lock);
6177 * Initialize LCB access variables and state. Called during driver load,
6178 * after most of the initialization is finished.
6180 * The DC default is LCB access on for the host. The driver defaults to
6181 * leaving access to the 8051. Assign access now - this constrains the call
6182 * to this routine to be after all LCB set-up is done. In particular, after
6183 * hf1_init_dd() -> set_up_interrupts() -> clear_all_interrupts()
6185 static void init_lcb_access(struct hfi1_devdata *dd)
6187 dd->lcb_access_count = 0;
6191 * Write a response back to a 8051 request.
6193 static void hreq_response(struct hfi1_devdata *dd, u8 return_code, u16 rsp_data)
6195 write_csr(dd, DC_DC8051_CFG_EXT_DEV_0,
6196 DC_DC8051_CFG_EXT_DEV_0_COMPLETED_SMASK |
6198 DC_DC8051_CFG_EXT_DEV_0_RETURN_CODE_SHIFT |
6199 (u64)rsp_data << DC_DC8051_CFG_EXT_DEV_0_RSP_DATA_SHIFT);
6203 * Handle host requests from the 8051.
6205 static void handle_8051_request(struct hfi1_pportdata *ppd)
6207 struct hfi1_devdata *dd = ppd->dd;
6212 reg = read_csr(dd, DC_DC8051_CFG_EXT_DEV_1);
6213 if ((reg & DC_DC8051_CFG_EXT_DEV_1_REQ_NEW_SMASK) == 0)
6214 return; /* no request */
6216 /* zero out COMPLETED so the response is seen */
6217 write_csr(dd, DC_DC8051_CFG_EXT_DEV_0, 0);
6219 /* extract request details */
6220 type = (reg >> DC_DC8051_CFG_EXT_DEV_1_REQ_TYPE_SHIFT)
6221 & DC_DC8051_CFG_EXT_DEV_1_REQ_TYPE_MASK;
6222 data = (reg >> DC_DC8051_CFG_EXT_DEV_1_REQ_DATA_SHIFT)
6223 & DC_DC8051_CFG_EXT_DEV_1_REQ_DATA_MASK;
6226 case HREQ_LOAD_CONFIG:
6227 case HREQ_SAVE_CONFIG:
6228 case HREQ_READ_CONFIG:
6229 case HREQ_SET_TX_EQ_ABS:
6230 case HREQ_SET_TX_EQ_REL:
6232 dd_dev_info(dd, "8051 request: request 0x%x not supported\n",
6234 hreq_response(dd, HREQ_NOT_SUPPORTED, 0);
6236 case HREQ_CONFIG_DONE:
6237 hreq_response(dd, HREQ_SUCCESS, 0);
6240 case HREQ_INTERFACE_TEST:
6241 hreq_response(dd, HREQ_SUCCESS, data);
6244 dd_dev_err(dd, "8051 request: unknown request 0x%x\n", type);
6245 hreq_response(dd, HREQ_NOT_SUPPORTED, 0);
6250 static void write_global_credit(struct hfi1_devdata *dd,
6251 u8 vau, u16 total, u16 shared)
6253 write_csr(dd, SEND_CM_GLOBAL_CREDIT,
6255 SEND_CM_GLOBAL_CREDIT_TOTAL_CREDIT_LIMIT_SHIFT) |
6257 SEND_CM_GLOBAL_CREDIT_SHARED_LIMIT_SHIFT) |
6258 ((u64)vau << SEND_CM_GLOBAL_CREDIT_AU_SHIFT));
6262 * Set up initial VL15 credits of the remote. Assumes the rest of
6263 * the CM credit registers are zero from a previous global or credit reset .
6265 void set_up_vl15(struct hfi1_devdata *dd, u8 vau, u16 vl15buf)
6267 /* leave shared count at zero for both global and VL15 */
6268 write_global_credit(dd, vau, vl15buf, 0);
6270 /* We may need some credits for another VL when sending packets
6271 * with the snoop interface. Dividing it down the middle for VL15
6272 * and VL0 should suffice.
6274 if (unlikely(dd->hfi1_snoop.mode_flag == HFI1_PORT_SNOOP_MODE)) {
6275 write_csr(dd, SEND_CM_CREDIT_VL15, (u64)(vl15buf >> 1)
6276 << SEND_CM_CREDIT_VL15_DEDICATED_LIMIT_VL_SHIFT);
6277 write_csr(dd, SEND_CM_CREDIT_VL, (u64)(vl15buf >> 1)
6278 << SEND_CM_CREDIT_VL_DEDICATED_LIMIT_VL_SHIFT);
6280 write_csr(dd, SEND_CM_CREDIT_VL15, (u64)vl15buf
6281 << SEND_CM_CREDIT_VL15_DEDICATED_LIMIT_VL_SHIFT);
6286 * Zero all credit details from the previous connection and
6287 * reset the CM manager's internal counters.
6289 void reset_link_credits(struct hfi1_devdata *dd)
6293 /* remove all previous VL credit limits */
6294 for (i = 0; i < TXE_NUM_DATA_VL; i++)
6295 write_csr(dd, SEND_CM_CREDIT_VL + (8 * i), 0);
6296 write_csr(dd, SEND_CM_CREDIT_VL15, 0);
6297 write_global_credit(dd, 0, 0, 0);
6298 /* reset the CM block */
6299 pio_send_control(dd, PSC_CM_RESET);
6302 /* convert a vCU to a CU */
6303 static u32 vcu_to_cu(u8 vcu)
6308 /* convert a CU to a vCU */
6309 static u8 cu_to_vcu(u32 cu)
6314 /* convert a vAU to an AU */
6315 static u32 vau_to_au(u8 vau)
6317 return 8 * (1 << vau);
6320 static void set_linkup_defaults(struct hfi1_pportdata *ppd)
6322 ppd->sm_trap_qp = 0x0;
6327 * Graceful LCB shutdown. This leaves the LCB FIFOs in reset.
6329 static void lcb_shutdown(struct hfi1_devdata *dd, int abort)
6333 /* clear lcb run: LCB_CFG_RUN.EN = 0 */
6334 write_csr(dd, DC_LCB_CFG_RUN, 0);
6335 /* set tx fifo reset: LCB_CFG_TX_FIFOS_RESET.VAL = 1 */
6336 write_csr(dd, DC_LCB_CFG_TX_FIFOS_RESET,
6337 1ull << DC_LCB_CFG_TX_FIFOS_RESET_VAL_SHIFT);
6338 /* set dcc reset csr: DCC_CFG_RESET.{reset_lcb,reset_rx_fpe} = 1 */
6339 dd->lcb_err_en = read_csr(dd, DC_LCB_ERR_EN);
6340 reg = read_csr(dd, DCC_CFG_RESET);
6341 write_csr(dd, DCC_CFG_RESET, reg |
6342 (1ull << DCC_CFG_RESET_RESET_LCB_SHIFT) |
6343 (1ull << DCC_CFG_RESET_RESET_RX_FPE_SHIFT));
6344 (void)read_csr(dd, DCC_CFG_RESET); /* make sure the write completed */
6346 udelay(1); /* must hold for the longer of 16cclks or 20ns */
6347 write_csr(dd, DCC_CFG_RESET, reg);
6348 write_csr(dd, DC_LCB_ERR_EN, dd->lcb_err_en);
6353 * This routine should be called after the link has been transitioned to
6354 * OFFLINE (OFFLINE state has the side effect of putting the SerDes into
6357 * The expectation is that the caller of this routine would have taken
6358 * care of properly transitioning the link into the correct state.
6360 static void dc_shutdown(struct hfi1_devdata *dd)
6362 unsigned long flags;
6364 spin_lock_irqsave(&dd->dc8051_lock, flags);
6365 if (dd->dc_shutdown) {
6366 spin_unlock_irqrestore(&dd->dc8051_lock, flags);
6369 dd->dc_shutdown = 1;
6370 spin_unlock_irqrestore(&dd->dc8051_lock, flags);
6371 /* Shutdown the LCB */
6372 lcb_shutdown(dd, 1);
6374 * Going to OFFLINE would have causes the 8051 to put the
6375 * SerDes into reset already. Just need to shut down the 8051,
6378 write_csr(dd, DC_DC8051_CFG_RST, 0x1);
6382 * Calling this after the DC has been brought out of reset should not
6385 static void dc_start(struct hfi1_devdata *dd)
6387 unsigned long flags;
6390 spin_lock_irqsave(&dd->dc8051_lock, flags);
6391 if (!dd->dc_shutdown)
6393 spin_unlock_irqrestore(&dd->dc8051_lock, flags);
6394 /* Take the 8051 out of reset */
6395 write_csr(dd, DC_DC8051_CFG_RST, 0ull);
6396 /* Wait until 8051 is ready */
6397 ret = wait_fm_ready(dd, TIMEOUT_8051_START);
6399 dd_dev_err(dd, "%s: timeout starting 8051 firmware\n",
6402 /* Take away reset for LCB and RX FPE (set in lcb_shutdown). */
6403 write_csr(dd, DCC_CFG_RESET, 0x10);
6404 /* lcb_shutdown() with abort=1 does not restore these */
6405 write_csr(dd, DC_LCB_ERR_EN, dd->lcb_err_en);
6406 spin_lock_irqsave(&dd->dc8051_lock, flags);
6407 dd->dc_shutdown = 0;
6409 spin_unlock_irqrestore(&dd->dc8051_lock, flags);
6413 * These LCB adjustments are for the Aurora SerDes core in the FPGA.
6415 static void adjust_lcb_for_fpga_serdes(struct hfi1_devdata *dd)
6417 u64 rx_radr, tx_radr;
6420 if (dd->icode != ICODE_FPGA_EMULATION)
6424 * These LCB defaults on emulator _s are good, nothing to do here:
6425 * LCB_CFG_TX_FIFOS_RADR
6426 * LCB_CFG_RX_FIFOS_RADR
6428 * LCB_CFG_IGNORE_LOST_RCLK
6430 if (is_emulator_s(dd))
6432 /* else this is _p */
6434 version = emulator_rev(dd);
6436 version = 0x2d; /* all B0 use 0x2d or higher settings */
6438 if (version <= 0x12) {
6439 /* release 0x12 and below */
6442 * LCB_CFG_RX_FIFOS_RADR.RST_VAL = 0x9
6443 * LCB_CFG_RX_FIFOS_RADR.OK_TO_JUMP_VAL = 0x9
6444 * LCB_CFG_RX_FIFOS_RADR.DO_NOT_JUMP_VAL = 0xa
6447 0xaull << DC_LCB_CFG_RX_FIFOS_RADR_DO_NOT_JUMP_VAL_SHIFT
6448 | 0x9ull << DC_LCB_CFG_RX_FIFOS_RADR_OK_TO_JUMP_VAL_SHIFT
6449 | 0x9ull << DC_LCB_CFG_RX_FIFOS_RADR_RST_VAL_SHIFT;
6451 * LCB_CFG_TX_FIFOS_RADR.ON_REINIT = 0 (default)
6452 * LCB_CFG_TX_FIFOS_RADR.RST_VAL = 6
6454 tx_radr = 6ull << DC_LCB_CFG_TX_FIFOS_RADR_RST_VAL_SHIFT;
6455 } else if (version <= 0x18) {
6456 /* release 0x13 up to 0x18 */
6457 /* LCB_CFG_RX_FIFOS_RADR = 0x988 */
6459 0x9ull << DC_LCB_CFG_RX_FIFOS_RADR_DO_NOT_JUMP_VAL_SHIFT
6460 | 0x8ull << DC_LCB_CFG_RX_FIFOS_RADR_OK_TO_JUMP_VAL_SHIFT
6461 | 0x8ull << DC_LCB_CFG_RX_FIFOS_RADR_RST_VAL_SHIFT;
6462 tx_radr = 7ull << DC_LCB_CFG_TX_FIFOS_RADR_RST_VAL_SHIFT;
6463 } else if (version == 0x19) {
6465 /* LCB_CFG_RX_FIFOS_RADR = 0xa99 */
6467 0xAull << DC_LCB_CFG_RX_FIFOS_RADR_DO_NOT_JUMP_VAL_SHIFT
6468 | 0x9ull << DC_LCB_CFG_RX_FIFOS_RADR_OK_TO_JUMP_VAL_SHIFT
6469 | 0x9ull << DC_LCB_CFG_RX_FIFOS_RADR_RST_VAL_SHIFT;
6470 tx_radr = 3ull << DC_LCB_CFG_TX_FIFOS_RADR_RST_VAL_SHIFT;
6471 } else if (version == 0x1a) {
6473 /* LCB_CFG_RX_FIFOS_RADR = 0x988 */
6475 0x9ull << DC_LCB_CFG_RX_FIFOS_RADR_DO_NOT_JUMP_VAL_SHIFT
6476 | 0x8ull << DC_LCB_CFG_RX_FIFOS_RADR_OK_TO_JUMP_VAL_SHIFT
6477 | 0x8ull << DC_LCB_CFG_RX_FIFOS_RADR_RST_VAL_SHIFT;
6478 tx_radr = 7ull << DC_LCB_CFG_TX_FIFOS_RADR_RST_VAL_SHIFT;
6479 write_csr(dd, DC_LCB_CFG_LN_DCLK, 1ull);
6481 /* release 0x1b and higher */
6482 /* LCB_CFG_RX_FIFOS_RADR = 0x877 */
6484 0x8ull << DC_LCB_CFG_RX_FIFOS_RADR_DO_NOT_JUMP_VAL_SHIFT
6485 | 0x7ull << DC_LCB_CFG_RX_FIFOS_RADR_OK_TO_JUMP_VAL_SHIFT
6486 | 0x7ull << DC_LCB_CFG_RX_FIFOS_RADR_RST_VAL_SHIFT;
6487 tx_radr = 3ull << DC_LCB_CFG_TX_FIFOS_RADR_RST_VAL_SHIFT;
6490 write_csr(dd, DC_LCB_CFG_RX_FIFOS_RADR, rx_radr);
6491 /* LCB_CFG_IGNORE_LOST_RCLK.EN = 1 */
6492 write_csr(dd, DC_LCB_CFG_IGNORE_LOST_RCLK,
6493 DC_LCB_CFG_IGNORE_LOST_RCLK_EN_SMASK);
6494 write_csr(dd, DC_LCB_CFG_TX_FIFOS_RADR, tx_radr);
6498 * Handle a SMA idle message
6500 * This is a work-queue function outside of the interrupt.
6502 void handle_sma_message(struct work_struct *work)
6504 struct hfi1_pportdata *ppd = container_of(work, struct hfi1_pportdata,
6506 struct hfi1_devdata *dd = ppd->dd;
6511 * msg is bytes 1-4 of the 40-bit idle message - the command code
6514 ret = read_idle_sma(dd, &msg);
6517 dd_dev_info(dd, "%s: SMA message 0x%llx\n", __func__, msg);
6519 * React to the SMA message. Byte[1] (0 for us) is the command.
6521 switch (msg & 0xff) {
6524 * See OPAv1 table 9-14 - HFI and External Switch Ports Key
6527 * Only expected in INIT or ARMED, discard otherwise.
6529 if (ppd->host_link_state & (HLS_UP_INIT | HLS_UP_ARMED))
6530 ppd->neighbor_normal = 1;
6532 case SMA_IDLE_ACTIVE:
6534 * See OPAv1 table 9-14 - HFI and External Switch Ports Key
6537 * Can activate the node. Discard otherwise.
6539 if (ppd->host_link_state == HLS_UP_ARMED &&
6540 ppd->is_active_optimize_enabled) {
6541 ppd->neighbor_normal = 1;
6542 ret = set_link_state(ppd, HLS_UP_ACTIVE);
6546 "%s: received Active SMA idle message, couldn't set link to Active\n",
6552 "%s: received unexpected SMA idle message 0x%llx\n",
6558 static void adjust_rcvctrl(struct hfi1_devdata *dd, u64 add, u64 clear)
6561 unsigned long flags;
6563 spin_lock_irqsave(&dd->rcvctrl_lock, flags);
6564 rcvctrl = read_csr(dd, RCV_CTRL);
6567 write_csr(dd, RCV_CTRL, rcvctrl);
6568 spin_unlock_irqrestore(&dd->rcvctrl_lock, flags);
6571 static inline void add_rcvctrl(struct hfi1_devdata *dd, u64 add)
6573 adjust_rcvctrl(dd, add, 0);
6576 static inline void clear_rcvctrl(struct hfi1_devdata *dd, u64 clear)
6578 adjust_rcvctrl(dd, 0, clear);
6582 * Called from all interrupt handlers to start handling an SPC freeze.
6584 void start_freeze_handling(struct hfi1_pportdata *ppd, int flags)
6586 struct hfi1_devdata *dd = ppd->dd;
6587 struct send_context *sc;
6590 if (flags & FREEZE_SELF)
6591 write_csr(dd, CCE_CTRL, CCE_CTRL_SPC_FREEZE_SMASK);
6593 /* enter frozen mode */
6594 dd->flags |= HFI1_FROZEN;
6596 /* notify all SDMA engines that they are going into a freeze */
6597 sdma_freeze_notify(dd, !!(flags & FREEZE_LINK_DOWN));
6599 /* do halt pre-handling on all enabled send contexts */
6600 for (i = 0; i < dd->num_send_contexts; i++) {
6601 sc = dd->send_contexts[i].sc;
6602 if (sc && (sc->flags & SCF_ENABLED))
6603 sc_stop(sc, SCF_FROZEN | SCF_HALTED);
6606 /* Send context are frozen. Notify user space */
6607 hfi1_set_uevent_bits(ppd, _HFI1_EVENT_FROZEN_BIT);
6609 if (flags & FREEZE_ABORT) {
6611 "Aborted freeze recovery. Please REBOOT system\n");
6614 /* queue non-interrupt handler */
6615 queue_work(ppd->hfi1_wq, &ppd->freeze_work);
6619 * Wait until all 4 sub-blocks indicate that they have frozen or unfrozen,
6620 * depending on the "freeze" parameter.
6622 * No need to return an error if it times out, our only option
6623 * is to proceed anyway.
6625 static void wait_for_freeze_status(struct hfi1_devdata *dd, int freeze)
6627 unsigned long timeout;
6630 timeout = jiffies + msecs_to_jiffies(FREEZE_STATUS_TIMEOUT);
6632 reg = read_csr(dd, CCE_STATUS);
6634 /* waiting until all indicators are set */
6635 if ((reg & ALL_FROZE) == ALL_FROZE)
6636 return; /* all done */
6638 /* waiting until all indicators are clear */
6639 if ((reg & ALL_FROZE) == 0)
6640 return; /* all done */
6643 if (time_after(jiffies, timeout)) {
6645 "Time out waiting for SPC %sfreeze, bits 0x%llx, expecting 0x%llx, continuing",
6646 freeze ? "" : "un", reg & ALL_FROZE,
6647 freeze ? ALL_FROZE : 0ull);
6650 usleep_range(80, 120);
6655 * Do all freeze handling for the RXE block.
6657 static void rxe_freeze(struct hfi1_devdata *dd)
6662 clear_rcvctrl(dd, RCV_CTRL_RCV_PORT_ENABLE_SMASK);
6664 /* disable all receive contexts */
6665 for (i = 0; i < dd->num_rcv_contexts; i++)
6666 hfi1_rcvctrl(dd, HFI1_RCVCTRL_CTXT_DIS, i);
6670 * Unfreeze handling for the RXE block - kernel contexts only.
6671 * This will also enable the port. User contexts will do unfreeze
6672 * handling on a per-context basis as they call into the driver.
6675 static void rxe_kernel_unfreeze(struct hfi1_devdata *dd)
6680 /* enable all kernel contexts */
6681 for (i = 0; i < dd->n_krcv_queues; i++) {
6682 rcvmask = HFI1_RCVCTRL_CTXT_ENB;
6683 /* HFI1_RCVCTRL_TAILUPD_[ENB|DIS] needs to be set explicitly */
6684 rcvmask |= HFI1_CAP_KGET_MASK(dd->rcd[i]->flags, DMA_RTAIL) ?
6685 HFI1_RCVCTRL_TAILUPD_ENB : HFI1_RCVCTRL_TAILUPD_DIS;
6686 hfi1_rcvctrl(dd, rcvmask, i);
6690 add_rcvctrl(dd, RCV_CTRL_RCV_PORT_ENABLE_SMASK);
6694 * Non-interrupt SPC freeze handling.
6696 * This is a work-queue function outside of the triggering interrupt.
6698 void handle_freeze(struct work_struct *work)
6700 struct hfi1_pportdata *ppd = container_of(work, struct hfi1_pportdata,
6702 struct hfi1_devdata *dd = ppd->dd;
6704 /* wait for freeze indicators on all affected blocks */
6705 wait_for_freeze_status(dd, 1);
6707 /* SPC is now frozen */
6709 /* do send PIO freeze steps */
6712 /* do send DMA freeze steps */
6715 /* do send egress freeze steps - nothing to do */
6717 /* do receive freeze steps */
6721 * Unfreeze the hardware - clear the freeze, wait for each
6722 * block's frozen bit to clear, then clear the frozen flag.
6724 write_csr(dd, CCE_CTRL, CCE_CTRL_SPC_UNFREEZE_SMASK);
6725 wait_for_freeze_status(dd, 0);
6728 write_csr(dd, CCE_CTRL, CCE_CTRL_SPC_FREEZE_SMASK);
6729 wait_for_freeze_status(dd, 1);
6730 write_csr(dd, CCE_CTRL, CCE_CTRL_SPC_UNFREEZE_SMASK);
6731 wait_for_freeze_status(dd, 0);
6734 /* do send PIO unfreeze steps for kernel contexts */
6735 pio_kernel_unfreeze(dd);
6737 /* do send DMA unfreeze steps */
6740 /* do send egress unfreeze steps - nothing to do */
6742 /* do receive unfreeze steps for kernel contexts */
6743 rxe_kernel_unfreeze(dd);
6746 * The unfreeze procedure touches global device registers when
6747 * it disables and re-enables RXE. Mark the device unfrozen
6748 * after all that is done so other parts of the driver waiting
6749 * for the device to unfreeze don't do things out of order.
6751 * The above implies that the meaning of HFI1_FROZEN flag is
6752 * "Device has gone into freeze mode and freeze mode handling
6753 * is still in progress."
6755 * The flag will be removed when freeze mode processing has
6758 dd->flags &= ~HFI1_FROZEN;
6759 wake_up(&dd->event_queue);
6761 /* no longer frozen */
6765 * Handle a link up interrupt from the 8051.
6767 * This is a work-queue function outside of the interrupt.
6769 void handle_link_up(struct work_struct *work)
6771 struct hfi1_pportdata *ppd = container_of(work, struct hfi1_pportdata,
6773 set_link_state(ppd, HLS_UP_INIT);
6775 /* cache the read of DC_LCB_STS_ROUND_TRIP_LTP_CNT */
6776 read_ltp_rtt(ppd->dd);
6778 * OPA specifies that certain counters are cleared on a transition
6779 * to link up, so do that.
6781 clear_linkup_counters(ppd->dd);
6783 * And (re)set link up default values.
6785 set_linkup_defaults(ppd);
6787 /* enforce link speed enabled */
6788 if ((ppd->link_speed_active & ppd->link_speed_enabled) == 0) {
6789 /* oops - current speed is not enabled, bounce */
6791 "Link speed active 0x%x is outside enabled 0x%x, downing link\n",
6792 ppd->link_speed_active, ppd->link_speed_enabled);
6793 set_link_down_reason(ppd, OPA_LINKDOWN_REASON_SPEED_POLICY, 0,
6794 OPA_LINKDOWN_REASON_SPEED_POLICY);
6795 set_link_state(ppd, HLS_DN_OFFLINE);
6802 * Several pieces of LNI information were cached for SMA in ppd.
6803 * Reset these on link down
6805 static void reset_neighbor_info(struct hfi1_pportdata *ppd)
6807 ppd->neighbor_guid = 0;
6808 ppd->neighbor_port_number = 0;
6809 ppd->neighbor_type = 0;
6810 ppd->neighbor_fm_security = 0;
6814 * Handle a link down interrupt from the 8051.
6816 * This is a work-queue function outside of the interrupt.
6818 void handle_link_down(struct work_struct *work)
6820 u8 lcl_reason, neigh_reason = 0;
6821 struct hfi1_pportdata *ppd = container_of(work, struct hfi1_pportdata,
6824 if ((ppd->host_link_state &
6825 (HLS_DN_POLL | HLS_VERIFY_CAP | HLS_GOING_UP)) &&
6826 ppd->port_type == PORT_TYPE_FIXED)
6827 ppd->offline_disabled_reason =
6828 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_NOT_INSTALLED);
6830 /* Go offline first, then deal with reading/writing through 8051 */
6831 set_link_state(ppd, HLS_DN_OFFLINE);
6834 read_planned_down_reason_code(ppd->dd, &neigh_reason);
6837 * If no reason, assume peer-initiated but missed
6838 * LinkGoingDown idle flits.
6840 if (neigh_reason == 0)
6841 lcl_reason = OPA_LINKDOWN_REASON_NEIGHBOR_UNKNOWN;
6843 set_link_down_reason(ppd, lcl_reason, neigh_reason, 0);
6845 reset_neighbor_info(ppd);
6847 /* disable the port */
6848 clear_rcvctrl(ppd->dd, RCV_CTRL_RCV_PORT_ENABLE_SMASK);
6851 * If there is no cable attached, turn the DC off. Otherwise,
6852 * start the link bring up.
6854 if (ppd->port_type == PORT_TYPE_QSFP && !qsfp_mod_present(ppd)) {
6855 dc_shutdown(ppd->dd);
6862 void handle_link_bounce(struct work_struct *work)
6864 struct hfi1_pportdata *ppd = container_of(work, struct hfi1_pportdata,
6868 * Only do something if the link is currently up.
6870 if (ppd->host_link_state & HLS_UP) {
6871 set_link_state(ppd, HLS_DN_OFFLINE);
6875 dd_dev_info(ppd->dd, "%s: link not up (%s), nothing to do\n",
6876 __func__, link_state_name(ppd->host_link_state));
6881 * Mask conversion: Capability exchange to Port LTP. The capability
6882 * exchange has an implicit 16b CRC that is mandatory.
6884 static int cap_to_port_ltp(int cap)
6886 int port_ltp = PORT_LTP_CRC_MODE_16; /* this mode is mandatory */
6888 if (cap & CAP_CRC_14B)
6889 port_ltp |= PORT_LTP_CRC_MODE_14;
6890 if (cap & CAP_CRC_48B)
6891 port_ltp |= PORT_LTP_CRC_MODE_48;
6892 if (cap & CAP_CRC_12B_16B_PER_LANE)
6893 port_ltp |= PORT_LTP_CRC_MODE_PER_LANE;
6899 * Convert an OPA Port LTP mask to capability mask
6901 int port_ltp_to_cap(int port_ltp)
6905 if (port_ltp & PORT_LTP_CRC_MODE_14)
6906 cap_mask |= CAP_CRC_14B;
6907 if (port_ltp & PORT_LTP_CRC_MODE_48)
6908 cap_mask |= CAP_CRC_48B;
6909 if (port_ltp & PORT_LTP_CRC_MODE_PER_LANE)
6910 cap_mask |= CAP_CRC_12B_16B_PER_LANE;
6916 * Convert a single DC LCB CRC mode to an OPA Port LTP mask.
6918 static int lcb_to_port_ltp(int lcb_crc)
6922 if (lcb_crc == LCB_CRC_12B_16B_PER_LANE)
6923 port_ltp = PORT_LTP_CRC_MODE_PER_LANE;
6924 else if (lcb_crc == LCB_CRC_48B)
6925 port_ltp = PORT_LTP_CRC_MODE_48;
6926 else if (lcb_crc == LCB_CRC_14B)
6927 port_ltp = PORT_LTP_CRC_MODE_14;
6929 port_ltp = PORT_LTP_CRC_MODE_16;
6935 * Our neighbor has indicated that we are allowed to act as a fabric
6936 * manager, so place the full management partition key in the second
6937 * (0-based) pkey array position (see OPAv1, section 20.2.2.6.8). Note
6938 * that we should already have the limited management partition key in
6939 * array element 1, and also that the port is not yet up when
6940 * add_full_mgmt_pkey() is invoked.
6942 static void add_full_mgmt_pkey(struct hfi1_pportdata *ppd)
6944 struct hfi1_devdata *dd = ppd->dd;
6946 /* Sanity check - ppd->pkeys[2] should be 0, or already initalized */
6947 if (!((ppd->pkeys[2] == 0) || (ppd->pkeys[2] == FULL_MGMT_P_KEY)))
6948 dd_dev_warn(dd, "%s pkey[2] already set to 0x%x, resetting it to 0x%x\n",
6949 __func__, ppd->pkeys[2], FULL_MGMT_P_KEY);
6950 ppd->pkeys[2] = FULL_MGMT_P_KEY;
6951 (void)hfi1_set_ib_cfg(ppd, HFI1_IB_CFG_PKEYS, 0);
6955 * Convert the given link width to the OPA link width bitmask.
6957 static u16 link_width_to_bits(struct hfi1_devdata *dd, u16 width)
6962 * Simulator and quick linkup do not set the width.
6963 * Just set it to 4x without complaint.
6965 if (dd->icode == ICODE_FUNCTIONAL_SIMULATOR || quick_linkup)
6966 return OPA_LINK_WIDTH_4X;
6967 return 0; /* no lanes up */
6968 case 1: return OPA_LINK_WIDTH_1X;
6969 case 2: return OPA_LINK_WIDTH_2X;
6970 case 3: return OPA_LINK_WIDTH_3X;
6972 dd_dev_info(dd, "%s: invalid width %d, using 4\n",
6975 case 4: return OPA_LINK_WIDTH_4X;
6980 * Do a population count on the bottom nibble.
6982 static const u8 bit_counts[16] = {
6983 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4
6986 static inline u8 nibble_to_count(u8 nibble)
6988 return bit_counts[nibble & 0xf];
6992 * Read the active lane information from the 8051 registers and return
6995 * Active lane information is found in these 8051 registers:
6999 static void get_link_widths(struct hfi1_devdata *dd, u16 *tx_width,
7005 u8 tx_polarity_inversion;
7006 u8 rx_polarity_inversion;
7009 /* read the active lanes */
7010 read_tx_settings(dd, &enable_lane_tx, &tx_polarity_inversion,
7011 &rx_polarity_inversion, &max_rate);
7012 read_local_lni(dd, &enable_lane_rx);
7014 /* convert to counts */
7015 tx = nibble_to_count(enable_lane_tx);
7016 rx = nibble_to_count(enable_lane_rx);
7019 * Set link_speed_active here, overriding what was set in
7020 * handle_verify_cap(). The ASIC 8051 firmware does not correctly
7021 * set the max_rate field in handle_verify_cap until v0.19.
7023 if ((dd->icode == ICODE_RTL_SILICON) &&
7024 (dd->dc8051_ver < dc8051_ver(0, 19))) {
7025 /* max_rate: 0 = 12.5G, 1 = 25G */
7028 dd->pport[0].link_speed_active = OPA_LINK_SPEED_12_5G;
7032 "%s: unexpected max rate %d, using 25Gb\n",
7033 __func__, (int)max_rate);
7036 dd->pport[0].link_speed_active = OPA_LINK_SPEED_25G;
7042 "Fabric active lanes (width): tx 0x%x (%d), rx 0x%x (%d)\n",
7043 enable_lane_tx, tx, enable_lane_rx, rx);
7044 *tx_width = link_width_to_bits(dd, tx);
7045 *rx_width = link_width_to_bits(dd, rx);
7049 * Read verify_cap_local_fm_link_width[1] to obtain the link widths.
7050 * Valid after the end of VerifyCap and during LinkUp. Does not change
7051 * after link up. I.e. look elsewhere for downgrade information.
7054 * + bits [7:4] contain the number of active transmitters
7055 * + bits [3:0] contain the number of active receivers
7056 * These are numbers 1 through 4 and can be different values if the
7057 * link is asymmetric.
7059 * verify_cap_local_fm_link_width[0] retains its original value.
7061 static void get_linkup_widths(struct hfi1_devdata *dd, u16 *tx_width,
7065 u8 misc_bits, local_flags;
7066 u16 active_tx, active_rx;
7068 read_vc_local_link_width(dd, &misc_bits, &local_flags, &widths);
7070 rx = (widths >> 8) & 0xf;
7072 *tx_width = link_width_to_bits(dd, tx);
7073 *rx_width = link_width_to_bits(dd, rx);
7075 /* print the active widths */
7076 get_link_widths(dd, &active_tx, &active_rx);
7080 * Set ppd->link_width_active and ppd->link_width_downgrade_active using
7081 * hardware information when the link first comes up.
7083 * The link width is not available until after VerifyCap.AllFramesReceived
7084 * (the trigger for handle_verify_cap), so this is outside that routine
7085 * and should be called when the 8051 signals linkup.
7087 void get_linkup_link_widths(struct hfi1_pportdata *ppd)
7089 u16 tx_width, rx_width;
7091 /* get end-of-LNI link widths */
7092 get_linkup_widths(ppd->dd, &tx_width, &rx_width);
7094 /* use tx_width as the link is supposed to be symmetric on link up */
7095 ppd->link_width_active = tx_width;
7096 /* link width downgrade active (LWD.A) starts out matching LW.A */
7097 ppd->link_width_downgrade_tx_active = ppd->link_width_active;
7098 ppd->link_width_downgrade_rx_active = ppd->link_width_active;
7099 /* per OPA spec, on link up LWD.E resets to LWD.S */
7100 ppd->link_width_downgrade_enabled = ppd->link_width_downgrade_supported;
7101 /* cache the active egress rate (units {10^6 bits/sec]) */
7102 ppd->current_egress_rate = active_egress_rate(ppd);
7106 * Handle a verify capabilities interrupt from the 8051.
7108 * This is a work-queue function outside of the interrupt.
7110 void handle_verify_cap(struct work_struct *work)
7112 struct hfi1_pportdata *ppd = container_of(work, struct hfi1_pportdata,
7114 struct hfi1_devdata *dd = ppd->dd;
7116 u8 power_management;
7126 u16 active_tx, active_rx;
7127 u8 partner_supported_crc;
7131 set_link_state(ppd, HLS_VERIFY_CAP);
7133 lcb_shutdown(dd, 0);
7134 adjust_lcb_for_fpga_serdes(dd);
7137 * These are now valid:
7138 * remote VerifyCap fields in the general LNI config
7139 * CSR DC8051_STS_REMOTE_GUID
7140 * CSR DC8051_STS_REMOTE_NODE_TYPE
7141 * CSR DC8051_STS_REMOTE_FM_SECURITY
7142 * CSR DC8051_STS_REMOTE_PORT_NO
7145 read_vc_remote_phy(dd, &power_management, &continious);
7146 read_vc_remote_fabric(dd, &vau, &z, &vcu, &vl15buf,
7147 &partner_supported_crc);
7148 read_vc_remote_link_width(dd, &remote_tx_rate, &link_widths);
7149 read_remote_device_id(dd, &device_id, &device_rev);
7151 * And the 'MgmtAllowed' information, which is exchanged during
7152 * LNI, is also be available at this point.
7154 read_mgmt_allowed(dd, &ppd->mgmt_allowed);
7155 /* print the active widths */
7156 get_link_widths(dd, &active_tx, &active_rx);
7158 "Peer PHY: power management 0x%x, continuous updates 0x%x\n",
7159 (int)power_management, (int)continious);
7161 "Peer Fabric: vAU %d, Z %d, vCU %d, vl15 credits 0x%x, CRC sizes 0x%x\n",
7162 (int)vau, (int)z, (int)vcu, (int)vl15buf,
7163 (int)partner_supported_crc);
7164 dd_dev_info(dd, "Peer Link Width: tx rate 0x%x, widths 0x%x\n",
7165 (u32)remote_tx_rate, (u32)link_widths);
7166 dd_dev_info(dd, "Peer Device ID: 0x%04x, Revision 0x%02x\n",
7167 (u32)device_id, (u32)device_rev);
7169 * The peer vAU value just read is the peer receiver value. HFI does
7170 * not support a transmit vAU of 0 (AU == 8). We advertised that
7171 * with Z=1 in the fabric capabilities sent to the peer. The peer
7172 * will see our Z=1, and, if it advertised a vAU of 0, will move its
7173 * receive to vAU of 1 (AU == 16). Do the same here. We do not care
7174 * about the peer Z value - our sent vAU is 3 (hardwired) and is not
7175 * subject to the Z value exception.
7179 set_up_vl15(dd, vau, vl15buf);
7181 /* set up the LCB CRC mode */
7182 crc_mask = ppd->port_crc_mode_enabled & partner_supported_crc;
7184 /* order is important: use the lowest bit in common */
7185 if (crc_mask & CAP_CRC_14B)
7186 crc_val = LCB_CRC_14B;
7187 else if (crc_mask & CAP_CRC_48B)
7188 crc_val = LCB_CRC_48B;
7189 else if (crc_mask & CAP_CRC_12B_16B_PER_LANE)
7190 crc_val = LCB_CRC_12B_16B_PER_LANE;
7192 crc_val = LCB_CRC_16B;
7194 dd_dev_info(dd, "Final LCB CRC mode: %d\n", (int)crc_val);
7195 write_csr(dd, DC_LCB_CFG_CRC_MODE,
7196 (u64)crc_val << DC_LCB_CFG_CRC_MODE_TX_VAL_SHIFT);
7198 /* set (14b only) or clear sideband credit */
7199 reg = read_csr(dd, SEND_CM_CTRL);
7200 if (crc_val == LCB_CRC_14B && crc_14b_sideband) {
7201 write_csr(dd, SEND_CM_CTRL,
7202 reg | SEND_CM_CTRL_FORCE_CREDIT_MODE_SMASK);
7204 write_csr(dd, SEND_CM_CTRL,
7205 reg & ~SEND_CM_CTRL_FORCE_CREDIT_MODE_SMASK);
7208 ppd->link_speed_active = 0; /* invalid value */
7209 if (dd->dc8051_ver < dc8051_ver(0, 20)) {
7210 /* remote_tx_rate: 0 = 12.5G, 1 = 25G */
7211 switch (remote_tx_rate) {
7213 ppd->link_speed_active = OPA_LINK_SPEED_12_5G;
7216 ppd->link_speed_active = OPA_LINK_SPEED_25G;
7220 /* actual rate is highest bit of the ANDed rates */
7221 u8 rate = remote_tx_rate & ppd->local_tx_rate;
7224 ppd->link_speed_active = OPA_LINK_SPEED_25G;
7226 ppd->link_speed_active = OPA_LINK_SPEED_12_5G;
7228 if (ppd->link_speed_active == 0) {
7229 dd_dev_err(dd, "%s: unexpected remote tx rate %d, using 25Gb\n",
7230 __func__, (int)remote_tx_rate);
7231 ppd->link_speed_active = OPA_LINK_SPEED_25G;
7235 * Cache the values of the supported, enabled, and active
7236 * LTP CRC modes to return in 'portinfo' queries. But the bit
7237 * flags that are returned in the portinfo query differ from
7238 * what's in the link_crc_mask, crc_sizes, and crc_val
7239 * variables. Convert these here.
7241 ppd->port_ltp_crc_mode = cap_to_port_ltp(link_crc_mask) << 8;
7242 /* supported crc modes */
7243 ppd->port_ltp_crc_mode |=
7244 cap_to_port_ltp(ppd->port_crc_mode_enabled) << 4;
7245 /* enabled crc modes */
7246 ppd->port_ltp_crc_mode |= lcb_to_port_ltp(crc_val);
7247 /* active crc mode */
7249 /* set up the remote credit return table */
7250 assign_remote_cm_au_table(dd, vcu);
7253 * The LCB is reset on entry to handle_verify_cap(), so this must
7254 * be applied on every link up.
7256 * Adjust LCB error kill enable to kill the link if
7257 * these RBUF errors are seen:
7258 * REPLAY_BUF_MBE_SMASK
7259 * FLIT_INPUT_BUF_MBE_SMASK
7261 if (is_ax(dd)) { /* fixed in B0 */
7262 reg = read_csr(dd, DC_LCB_CFG_LINK_KILL_EN);
7263 reg |= DC_LCB_CFG_LINK_KILL_EN_REPLAY_BUF_MBE_SMASK
7264 | DC_LCB_CFG_LINK_KILL_EN_FLIT_INPUT_BUF_MBE_SMASK;
7265 write_csr(dd, DC_LCB_CFG_LINK_KILL_EN, reg);
7268 /* pull LCB fifos out of reset - all fifo clocks must be stable */
7269 write_csr(dd, DC_LCB_CFG_TX_FIFOS_RESET, 0);
7271 /* give 8051 access to the LCB CSRs */
7272 write_csr(dd, DC_LCB_ERR_EN, 0); /* mask LCB errors */
7273 set_8051_lcb_access(dd);
7275 ppd->neighbor_guid =
7276 read_csr(dd, DC_DC8051_STS_REMOTE_GUID);
7277 ppd->neighbor_port_number = read_csr(dd, DC_DC8051_STS_REMOTE_PORT_NO) &
7278 DC_DC8051_STS_REMOTE_PORT_NO_VAL_SMASK;
7279 ppd->neighbor_type =
7280 read_csr(dd, DC_DC8051_STS_REMOTE_NODE_TYPE) &
7281 DC_DC8051_STS_REMOTE_NODE_TYPE_VAL_MASK;
7282 ppd->neighbor_fm_security =
7283 read_csr(dd, DC_DC8051_STS_REMOTE_FM_SECURITY) &
7284 DC_DC8051_STS_LOCAL_FM_SECURITY_DISABLED_MASK;
7286 "Neighbor Guid: %llx Neighbor type %d MgmtAllowed %d FM security bypass %d\n",
7287 ppd->neighbor_guid, ppd->neighbor_type,
7288 ppd->mgmt_allowed, ppd->neighbor_fm_security);
7289 if (ppd->mgmt_allowed)
7290 add_full_mgmt_pkey(ppd);
7292 /* tell the 8051 to go to LinkUp */
7293 set_link_state(ppd, HLS_GOING_UP);
7297 * Apply the link width downgrade enabled policy against the current active
7300 * Called when the enabled policy changes or the active link widths change.
7302 void apply_link_downgrade_policy(struct hfi1_pportdata *ppd, int refresh_widths)
7309 /* use the hls lock to avoid a race with actual link up */
7312 mutex_lock(&ppd->hls_lock);
7313 /* only apply if the link is up */
7314 if (!(ppd->host_link_state & HLS_UP)) {
7315 /* still going up..wait and retry */
7316 if (ppd->host_link_state & HLS_GOING_UP) {
7317 if (++tries < 1000) {
7318 mutex_unlock(&ppd->hls_lock);
7319 usleep_range(100, 120); /* arbitrary */
7323 "%s: giving up waiting for link state change\n",
7329 lwde = ppd->link_width_downgrade_enabled;
7331 if (refresh_widths) {
7332 get_link_widths(ppd->dd, &tx, &rx);
7333 ppd->link_width_downgrade_tx_active = tx;
7334 ppd->link_width_downgrade_rx_active = rx;
7338 /* downgrade is disabled */
7340 /* bounce if not at starting active width */
7341 if ((ppd->link_width_active !=
7342 ppd->link_width_downgrade_tx_active) ||
7343 (ppd->link_width_active !=
7344 ppd->link_width_downgrade_rx_active)) {
7346 "Link downgrade is disabled and link has downgraded, downing link\n");
7348 " original 0x%x, tx active 0x%x, rx active 0x%x\n",
7349 ppd->link_width_active,
7350 ppd->link_width_downgrade_tx_active,
7351 ppd->link_width_downgrade_rx_active);
7354 } else if ((lwde & ppd->link_width_downgrade_tx_active) == 0 ||
7355 (lwde & ppd->link_width_downgrade_rx_active) == 0) {
7356 /* Tx or Rx is outside the enabled policy */
7358 "Link is outside of downgrade allowed, downing link\n");
7360 " enabled 0x%x, tx active 0x%x, rx active 0x%x\n",
7361 lwde, ppd->link_width_downgrade_tx_active,
7362 ppd->link_width_downgrade_rx_active);
7367 mutex_unlock(&ppd->hls_lock);
7370 set_link_down_reason(ppd, OPA_LINKDOWN_REASON_WIDTH_POLICY, 0,
7371 OPA_LINKDOWN_REASON_WIDTH_POLICY);
7372 set_link_state(ppd, HLS_DN_OFFLINE);
7379 * Handle a link downgrade interrupt from the 8051.
7381 * This is a work-queue function outside of the interrupt.
7383 void handle_link_downgrade(struct work_struct *work)
7385 struct hfi1_pportdata *ppd = container_of(work, struct hfi1_pportdata,
7386 link_downgrade_work);
7388 dd_dev_info(ppd->dd, "8051: Link width downgrade\n");
7389 apply_link_downgrade_policy(ppd, 1);
7392 static char *dcc_err_string(char *buf, int buf_len, u64 flags)
7394 return flag_string(buf, buf_len, flags, dcc_err_flags,
7395 ARRAY_SIZE(dcc_err_flags));
7398 static char *lcb_err_string(char *buf, int buf_len, u64 flags)
7400 return flag_string(buf, buf_len, flags, lcb_err_flags,
7401 ARRAY_SIZE(lcb_err_flags));
7404 static char *dc8051_err_string(char *buf, int buf_len, u64 flags)
7406 return flag_string(buf, buf_len, flags, dc8051_err_flags,
7407 ARRAY_SIZE(dc8051_err_flags));
7410 static char *dc8051_info_err_string(char *buf, int buf_len, u64 flags)
7412 return flag_string(buf, buf_len, flags, dc8051_info_err_flags,
7413 ARRAY_SIZE(dc8051_info_err_flags));
7416 static char *dc8051_info_host_msg_string(char *buf, int buf_len, u64 flags)
7418 return flag_string(buf, buf_len, flags, dc8051_info_host_msg_flags,
7419 ARRAY_SIZE(dc8051_info_host_msg_flags));
7422 static void handle_8051_interrupt(struct hfi1_devdata *dd, u32 unused, u64 reg)
7424 struct hfi1_pportdata *ppd = dd->pport;
7425 u64 info, err, host_msg;
7426 int queue_link_down = 0;
7429 /* look at the flags */
7430 if (reg & DC_DC8051_ERR_FLG_SET_BY_8051_SMASK) {
7431 /* 8051 information set by firmware */
7432 /* read DC8051_DBG_ERR_INFO_SET_BY_8051 for details */
7433 info = read_csr(dd, DC_DC8051_DBG_ERR_INFO_SET_BY_8051);
7434 err = (info >> DC_DC8051_DBG_ERR_INFO_SET_BY_8051_ERROR_SHIFT)
7435 & DC_DC8051_DBG_ERR_INFO_SET_BY_8051_ERROR_MASK;
7437 DC_DC8051_DBG_ERR_INFO_SET_BY_8051_HOST_MSG_SHIFT)
7438 & DC_DC8051_DBG_ERR_INFO_SET_BY_8051_HOST_MSG_MASK;
7441 * Handle error flags.
7443 if (err & FAILED_LNI) {
7445 * LNI error indications are cleared by the 8051
7446 * only when starting polling. Only pay attention
7447 * to them when in the states that occur during
7450 if (ppd->host_link_state
7451 & (HLS_DN_POLL | HLS_VERIFY_CAP | HLS_GOING_UP)) {
7452 queue_link_down = 1;
7453 dd_dev_info(dd, "Link error: %s\n",
7454 dc8051_info_err_string(buf,
7459 err &= ~(u64)FAILED_LNI;
7461 /* unknown frames can happen durning LNI, just count */
7462 if (err & UNKNOWN_FRAME) {
7463 ppd->unknown_frame_count++;
7464 err &= ~(u64)UNKNOWN_FRAME;
7467 /* report remaining errors, but do not do anything */
7468 dd_dev_err(dd, "8051 info error: %s\n",
7469 dc8051_info_err_string(buf, sizeof(buf),
7474 * Handle host message flags.
7476 if (host_msg & HOST_REQ_DONE) {
7478 * Presently, the driver does a busy wait for
7479 * host requests to complete. This is only an
7480 * informational message.
7481 * NOTE: The 8051 clears the host message
7482 * information *on the next 8051 command*.
7483 * Therefore, when linkup is achieved,
7484 * this flag will still be set.
7486 host_msg &= ~(u64)HOST_REQ_DONE;
7488 if (host_msg & BC_SMA_MSG) {
7489 queue_work(ppd->hfi1_wq, &ppd->sma_message_work);
7490 host_msg &= ~(u64)BC_SMA_MSG;
7492 if (host_msg & LINKUP_ACHIEVED) {
7493 dd_dev_info(dd, "8051: Link up\n");
7494 queue_work(ppd->hfi1_wq, &ppd->link_up_work);
7495 host_msg &= ~(u64)LINKUP_ACHIEVED;
7497 if (host_msg & EXT_DEVICE_CFG_REQ) {
7498 handle_8051_request(ppd);
7499 host_msg &= ~(u64)EXT_DEVICE_CFG_REQ;
7501 if (host_msg & VERIFY_CAP_FRAME) {
7502 queue_work(ppd->hfi1_wq, &ppd->link_vc_work);
7503 host_msg &= ~(u64)VERIFY_CAP_FRAME;
7505 if (host_msg & LINK_GOING_DOWN) {
7506 const char *extra = "";
7507 /* no downgrade action needed if going down */
7508 if (host_msg & LINK_WIDTH_DOWNGRADED) {
7509 host_msg &= ~(u64)LINK_WIDTH_DOWNGRADED;
7510 extra = " (ignoring downgrade)";
7512 dd_dev_info(dd, "8051: Link down%s\n", extra);
7513 queue_link_down = 1;
7514 host_msg &= ~(u64)LINK_GOING_DOWN;
7516 if (host_msg & LINK_WIDTH_DOWNGRADED) {
7517 queue_work(ppd->hfi1_wq, &ppd->link_downgrade_work);
7518 host_msg &= ~(u64)LINK_WIDTH_DOWNGRADED;
7521 /* report remaining messages, but do not do anything */
7522 dd_dev_info(dd, "8051 info host message: %s\n",
7523 dc8051_info_host_msg_string(buf,
7528 reg &= ~DC_DC8051_ERR_FLG_SET_BY_8051_SMASK;
7530 if (reg & DC_DC8051_ERR_FLG_LOST_8051_HEART_BEAT_SMASK) {
7532 * Lost the 8051 heartbeat. If this happens, we
7533 * receive constant interrupts about it. Disable
7534 * the interrupt after the first.
7536 dd_dev_err(dd, "Lost 8051 heartbeat\n");
7537 write_csr(dd, DC_DC8051_ERR_EN,
7538 read_csr(dd, DC_DC8051_ERR_EN) &
7539 ~DC_DC8051_ERR_EN_LOST_8051_HEART_BEAT_SMASK);
7541 reg &= ~DC_DC8051_ERR_FLG_LOST_8051_HEART_BEAT_SMASK;
7544 /* report the error, but do not do anything */
7545 dd_dev_err(dd, "8051 error: %s\n",
7546 dc8051_err_string(buf, sizeof(buf), reg));
7549 if (queue_link_down) {
7551 * if the link is already going down or disabled, do not
7554 if ((ppd->host_link_state &
7555 (HLS_GOING_OFFLINE | HLS_LINK_COOLDOWN)) ||
7556 ppd->link_enabled == 0) {
7557 dd_dev_info(dd, "%s: not queuing link down\n",
7560 queue_work(ppd->hfi1_wq, &ppd->link_down_work);
7565 static const char * const fm_config_txt[] = {
7567 "BadHeadDist: Distance violation between two head flits",
7569 "BadTailDist: Distance violation between two tail flits",
7571 "BadCtrlDist: Distance violation between two credit control flits",
7573 "BadCrdAck: Credits return for unsupported VL",
7575 "UnsupportedVLMarker: Received VL Marker",
7577 "BadPreempt: Exceeded the preemption nesting level",
7579 "BadControlFlit: Received unsupported control flit",
7582 "UnsupportedVLMarker: Received VL Marker for unconfigured or disabled VL",
7585 static const char * const port_rcv_txt[] = {
7587 "BadPktLen: Illegal PktLen",
7589 "PktLenTooLong: Packet longer than PktLen",
7591 "PktLenTooShort: Packet shorter than PktLen",
7593 "BadSLID: Illegal SLID (0, using multicast as SLID, does not include security validation of SLID)",
7595 "BadDLID: Illegal DLID (0, doesn't match HFI)",
7597 "BadL2: Illegal L2 opcode",
7599 "BadSC: Unsupported SC",
7601 "BadRC: Illegal RC",
7603 "PreemptError: Preempting with same VL",
7605 "PreemptVL15: Preempting a VL15 packet",
7608 #define OPA_LDR_FMCONFIG_OFFSET 16
7609 #define OPA_LDR_PORTRCV_OFFSET 0
7610 static void handle_dcc_err(struct hfi1_devdata *dd, u32 unused, u64 reg)
7612 u64 info, hdr0, hdr1;
7615 struct hfi1_pportdata *ppd = dd->pport;
7619 if (reg & DCC_ERR_FLG_UNCORRECTABLE_ERR_SMASK) {
7620 if (!(dd->err_info_uncorrectable & OPA_EI_STATUS_SMASK)) {
7621 info = read_csr(dd, DCC_ERR_INFO_UNCORRECTABLE);
7622 dd->err_info_uncorrectable = info & OPA_EI_CODE_SMASK;
7623 /* set status bit */
7624 dd->err_info_uncorrectable |= OPA_EI_STATUS_SMASK;
7626 reg &= ~DCC_ERR_FLG_UNCORRECTABLE_ERR_SMASK;
7629 if (reg & DCC_ERR_FLG_LINK_ERR_SMASK) {
7630 struct hfi1_pportdata *ppd = dd->pport;
7631 /* this counter saturates at (2^32) - 1 */
7632 if (ppd->link_downed < (u32)UINT_MAX)
7634 reg &= ~DCC_ERR_FLG_LINK_ERR_SMASK;
7637 if (reg & DCC_ERR_FLG_FMCONFIG_ERR_SMASK) {
7638 u8 reason_valid = 1;
7640 info = read_csr(dd, DCC_ERR_INFO_FMCONFIG);
7641 if (!(dd->err_info_fmconfig & OPA_EI_STATUS_SMASK)) {
7642 dd->err_info_fmconfig = info & OPA_EI_CODE_SMASK;
7643 /* set status bit */
7644 dd->err_info_fmconfig |= OPA_EI_STATUS_SMASK;
7654 extra = fm_config_txt[info];
7657 extra = fm_config_txt[info];
7658 if (ppd->port_error_action &
7659 OPA_PI_MASK_FM_CFG_UNSUPPORTED_VL_MARKER) {
7662 * lcl_reason cannot be derived from info
7666 OPA_LINKDOWN_REASON_UNSUPPORTED_VL_MARKER;
7671 snprintf(buf, sizeof(buf), "reserved%lld", info);
7676 if (reason_valid && !do_bounce) {
7677 do_bounce = ppd->port_error_action &
7678 (1 << (OPA_LDR_FMCONFIG_OFFSET + info));
7679 lcl_reason = info + OPA_LINKDOWN_REASON_BAD_HEAD_DIST;
7682 /* just report this */
7683 dd_dev_info(dd, "DCC Error: fmconfig error: %s\n", extra);
7684 reg &= ~DCC_ERR_FLG_FMCONFIG_ERR_SMASK;
7687 if (reg & DCC_ERR_FLG_RCVPORT_ERR_SMASK) {
7688 u8 reason_valid = 1;
7690 info = read_csr(dd, DCC_ERR_INFO_PORTRCV);
7691 hdr0 = read_csr(dd, DCC_ERR_INFO_PORTRCV_HDR0);
7692 hdr1 = read_csr(dd, DCC_ERR_INFO_PORTRCV_HDR1);
7693 if (!(dd->err_info_rcvport.status_and_code &
7694 OPA_EI_STATUS_SMASK)) {
7695 dd->err_info_rcvport.status_and_code =
7696 info & OPA_EI_CODE_SMASK;
7697 /* set status bit */
7698 dd->err_info_rcvport.status_and_code |=
7699 OPA_EI_STATUS_SMASK;
7701 * save first 2 flits in the packet that caused
7704 dd->err_info_rcvport.packet_flit1 = hdr0;
7705 dd->err_info_rcvport.packet_flit2 = hdr1;
7718 extra = port_rcv_txt[info];
7722 snprintf(buf, sizeof(buf), "reserved%lld", info);
7727 if (reason_valid && !do_bounce) {
7728 do_bounce = ppd->port_error_action &
7729 (1 << (OPA_LDR_PORTRCV_OFFSET + info));
7730 lcl_reason = info + OPA_LINKDOWN_REASON_RCV_ERROR_0;
7733 /* just report this */
7734 dd_dev_info(dd, "DCC Error: PortRcv error: %s\n", extra);
7735 dd_dev_info(dd, " hdr0 0x%llx, hdr1 0x%llx\n",
7738 reg &= ~DCC_ERR_FLG_RCVPORT_ERR_SMASK;
7741 if (reg & DCC_ERR_FLG_EN_CSR_ACCESS_BLOCKED_UC_SMASK) {
7742 /* informative only */
7743 dd_dev_info(dd, "8051 access to LCB blocked\n");
7744 reg &= ~DCC_ERR_FLG_EN_CSR_ACCESS_BLOCKED_UC_SMASK;
7746 if (reg & DCC_ERR_FLG_EN_CSR_ACCESS_BLOCKED_HOST_SMASK) {
7747 /* informative only */
7748 dd_dev_info(dd, "host access to LCB blocked\n");
7749 reg &= ~DCC_ERR_FLG_EN_CSR_ACCESS_BLOCKED_HOST_SMASK;
7752 /* report any remaining errors */
7754 dd_dev_info(dd, "DCC Error: %s\n",
7755 dcc_err_string(buf, sizeof(buf), reg));
7757 if (lcl_reason == 0)
7758 lcl_reason = OPA_LINKDOWN_REASON_UNKNOWN;
7761 dd_dev_info(dd, "%s: PortErrorAction bounce\n", __func__);
7762 set_link_down_reason(ppd, lcl_reason, 0, lcl_reason);
7763 queue_work(ppd->hfi1_wq, &ppd->link_bounce_work);
7767 static void handle_lcb_err(struct hfi1_devdata *dd, u32 unused, u64 reg)
7771 dd_dev_info(dd, "LCB Error: %s\n",
7772 lcb_err_string(buf, sizeof(buf), reg));
7776 * CCE block DC interrupt. Source is < 8.
7778 static void is_dc_int(struct hfi1_devdata *dd, unsigned int source)
7780 const struct err_reg_info *eri = &dc_errs[source];
7783 interrupt_clear_down(dd, 0, eri);
7784 } else if (source == 3 /* dc_lbm_int */) {
7786 * This indicates that a parity error has occurred on the
7787 * address/control lines presented to the LBM. The error
7788 * is a single pulse, there is no associated error flag,
7789 * and it is non-maskable. This is because if a parity
7790 * error occurs on the request the request is dropped.
7791 * This should never occur, but it is nice to know if it
7794 dd_dev_err(dd, "Parity error in DC LBM block\n");
7796 dd_dev_err(dd, "Invalid DC interrupt %u\n", source);
7801 * TX block send credit interrupt. Source is < 160.
7803 static void is_send_credit_int(struct hfi1_devdata *dd, unsigned int source)
7805 sc_group_release_update(dd, source);
7809 * TX block SDMA interrupt. Source is < 48.
7811 * SDMA interrupts are grouped by type:
7814 * N - 2N-1 = SDmaProgress
7815 * 2N - 3N-1 = SDmaIdle
7817 static void is_sdma_eng_int(struct hfi1_devdata *dd, unsigned int source)
7819 /* what interrupt */
7820 unsigned int what = source / TXE_NUM_SDMA_ENGINES;
7822 unsigned int which = source % TXE_NUM_SDMA_ENGINES;
7824 #ifdef CONFIG_SDMA_VERBOSITY
7825 dd_dev_err(dd, "CONFIG SDMA(%u) %s:%d %s()\n", which,
7826 slashstrip(__FILE__), __LINE__, __func__);
7827 sdma_dumpstate(&dd->per_sdma[which]);
7830 if (likely(what < 3 && which < dd->num_sdma)) {
7831 sdma_engine_interrupt(&dd->per_sdma[which], 1ull << source);
7833 /* should not happen */
7834 dd_dev_err(dd, "Invalid SDMA interrupt 0x%x\n", source);
7839 * RX block receive available interrupt. Source is < 160.
7841 static void is_rcv_avail_int(struct hfi1_devdata *dd, unsigned int source)
7843 struct hfi1_ctxtdata *rcd;
7846 if (likely(source < dd->num_rcv_contexts)) {
7847 rcd = dd->rcd[source];
7849 if (source < dd->first_user_ctxt)
7850 rcd->do_interrupt(rcd, 0);
7852 handle_user_interrupt(rcd);
7855 /* received an interrupt, but no rcd */
7856 err_detail = "dataless";
7858 /* received an interrupt, but are not using that context */
7859 err_detail = "out of range";
7861 dd_dev_err(dd, "unexpected %s receive available context interrupt %u\n",
7862 err_detail, source);
7866 * RX block receive urgent interrupt. Source is < 160.
7868 static void is_rcv_urgent_int(struct hfi1_devdata *dd, unsigned int source)
7870 struct hfi1_ctxtdata *rcd;
7873 if (likely(source < dd->num_rcv_contexts)) {
7874 rcd = dd->rcd[source];
7876 /* only pay attention to user urgent interrupts */
7877 if (source >= dd->first_user_ctxt)
7878 handle_user_interrupt(rcd);
7881 /* received an interrupt, but no rcd */
7882 err_detail = "dataless";
7884 /* received an interrupt, but are not using that context */
7885 err_detail = "out of range";
7887 dd_dev_err(dd, "unexpected %s receive urgent context interrupt %u\n",
7888 err_detail, source);
7892 * Reserved range interrupt. Should not be called in normal operation.
7894 static void is_reserved_int(struct hfi1_devdata *dd, unsigned int source)
7898 dd_dev_err(dd, "unexpected %s interrupt\n",
7899 is_reserved_name(name, sizeof(name), source));
7902 static const struct is_table is_table[] = {
7905 * name func interrupt func
7907 { IS_GENERAL_ERR_START, IS_GENERAL_ERR_END,
7908 is_misc_err_name, is_misc_err_int },
7909 { IS_SDMAENG_ERR_START, IS_SDMAENG_ERR_END,
7910 is_sdma_eng_err_name, is_sdma_eng_err_int },
7911 { IS_SENDCTXT_ERR_START, IS_SENDCTXT_ERR_END,
7912 is_sendctxt_err_name, is_sendctxt_err_int },
7913 { IS_SDMA_START, IS_SDMA_END,
7914 is_sdma_eng_name, is_sdma_eng_int },
7915 { IS_VARIOUS_START, IS_VARIOUS_END,
7916 is_various_name, is_various_int },
7917 { IS_DC_START, IS_DC_END,
7918 is_dc_name, is_dc_int },
7919 { IS_RCVAVAIL_START, IS_RCVAVAIL_END,
7920 is_rcv_avail_name, is_rcv_avail_int },
7921 { IS_RCVURGENT_START, IS_RCVURGENT_END,
7922 is_rcv_urgent_name, is_rcv_urgent_int },
7923 { IS_SENDCREDIT_START, IS_SENDCREDIT_END,
7924 is_send_credit_name, is_send_credit_int},
7925 { IS_RESERVED_START, IS_RESERVED_END,
7926 is_reserved_name, is_reserved_int},
7930 * Interrupt source interrupt - called when the given source has an interrupt.
7931 * Source is a bit index into an array of 64-bit integers.
7933 static void is_interrupt(struct hfi1_devdata *dd, unsigned int source)
7935 const struct is_table *entry;
7937 /* avoids a double compare by walking the table in-order */
7938 for (entry = &is_table[0]; entry->is_name; entry++) {
7939 if (source < entry->end) {
7940 trace_hfi1_interrupt(dd, entry, source);
7941 entry->is_int(dd, source - entry->start);
7945 /* fell off the end */
7946 dd_dev_err(dd, "invalid interrupt source %u\n", source);
7950 * General interrupt handler. This is able to correctly handle
7951 * all interrupts in case INTx is used.
7953 static irqreturn_t general_interrupt(int irq, void *data)
7955 struct hfi1_devdata *dd = data;
7956 u64 regs[CCE_NUM_INT_CSRS];
7960 this_cpu_inc(*dd->int_counter);
7962 /* phase 1: scan and clear all handled interrupts */
7963 for (i = 0; i < CCE_NUM_INT_CSRS; i++) {
7964 if (dd->gi_mask[i] == 0) {
7965 regs[i] = 0; /* used later */
7968 regs[i] = read_csr(dd, CCE_INT_STATUS + (8 * i)) &
7970 /* only clear if anything is set */
7972 write_csr(dd, CCE_INT_CLEAR + (8 * i), regs[i]);
7975 /* phase 2: call the appropriate handler */
7976 for_each_set_bit(bit, (unsigned long *)®s[0],
7977 CCE_NUM_INT_CSRS * 64) {
7978 is_interrupt(dd, bit);
7984 static irqreturn_t sdma_interrupt(int irq, void *data)
7986 struct sdma_engine *sde = data;
7987 struct hfi1_devdata *dd = sde->dd;
7990 #ifdef CONFIG_SDMA_VERBOSITY
7991 dd_dev_err(dd, "CONFIG SDMA(%u) %s:%d %s()\n", sde->this_idx,
7992 slashstrip(__FILE__), __LINE__, __func__);
7993 sdma_dumpstate(sde);
7996 this_cpu_inc(*dd->int_counter);
7998 /* This read_csr is really bad in the hot path */
7999 status = read_csr(dd,
8000 CCE_INT_STATUS + (8 * (IS_SDMA_START / 64)))
8002 if (likely(status)) {
8003 /* clear the interrupt(s) */
8005 CCE_INT_CLEAR + (8 * (IS_SDMA_START / 64)),
8008 /* handle the interrupt(s) */
8009 sdma_engine_interrupt(sde, status);
8011 dd_dev_err(dd, "SDMA engine %u interrupt, but no status bits set\n",
8018 * Clear the receive interrupt. Use a read of the interrupt clear CSR
8019 * to insure that the write completed. This does NOT guarantee that
8020 * queued DMA writes to memory from the chip are pushed.
8022 static inline void clear_recv_intr(struct hfi1_ctxtdata *rcd)
8024 struct hfi1_devdata *dd = rcd->dd;
8025 u32 addr = CCE_INT_CLEAR + (8 * rcd->ireg);
8027 mmiowb(); /* make sure everything before is written */
8028 write_csr(dd, addr, rcd->imask);
8029 /* force the above write on the chip and get a value back */
8030 (void)read_csr(dd, addr);
8033 /* force the receive interrupt */
8034 void force_recv_intr(struct hfi1_ctxtdata *rcd)
8036 write_csr(rcd->dd, CCE_INT_FORCE + (8 * rcd->ireg), rcd->imask);
8040 * Return non-zero if a packet is present.
8042 * This routine is called when rechecking for packets after the RcvAvail
8043 * interrupt has been cleared down. First, do a quick check of memory for
8044 * a packet present. If not found, use an expensive CSR read of the context
8045 * tail to determine the actual tail. The CSR read is necessary because there
8046 * is no method to push pending DMAs to memory other than an interrupt and we
8047 * are trying to determine if we need to force an interrupt.
8049 static inline int check_packet_present(struct hfi1_ctxtdata *rcd)
8054 if (!HFI1_CAP_IS_KSET(DMA_RTAIL))
8055 present = (rcd->seq_cnt ==
8056 rhf_rcv_seq(rhf_to_cpu(get_rhf_addr(rcd))));
8057 else /* is RDMA rtail */
8058 present = (rcd->head != get_rcvhdrtail(rcd));
8063 /* fall back to a CSR read, correct indpendent of DMA_RTAIL */
8064 tail = (u32)read_uctxt_csr(rcd->dd, rcd->ctxt, RCV_HDR_TAIL);
8065 return rcd->head != tail;
8069 * Receive packet IRQ handler. This routine expects to be on its own IRQ.
8070 * This routine will try to handle packets immediately (latency), but if
8071 * it finds too many, it will invoke the thread handler (bandwitdh). The
8072 * chip receive interrupt is *not* cleared down until this or the thread (if
8073 * invoked) is finished. The intent is to avoid extra interrupts while we
8074 * are processing packets anyway.
8076 static irqreturn_t receive_context_interrupt(int irq, void *data)
8078 struct hfi1_ctxtdata *rcd = data;
8079 struct hfi1_devdata *dd = rcd->dd;
8083 trace_hfi1_receive_interrupt(dd, rcd->ctxt);
8084 this_cpu_inc(*dd->int_counter);
8085 aspm_ctx_disable(rcd);
8087 /* receive interrupt remains blocked while processing packets */
8088 disposition = rcd->do_interrupt(rcd, 0);
8091 * Too many packets were seen while processing packets in this
8092 * IRQ handler. Invoke the handler thread. The receive interrupt
8095 if (disposition == RCV_PKT_LIMIT)
8096 return IRQ_WAKE_THREAD;
8099 * The packet processor detected no more packets. Clear the receive
8100 * interrupt and recheck for a packet packet that may have arrived
8101 * after the previous check and interrupt clear. If a packet arrived,
8102 * force another interrupt.
8104 clear_recv_intr(rcd);
8105 present = check_packet_present(rcd);
8107 force_recv_intr(rcd);
8113 * Receive packet thread handler. This expects to be invoked with the
8114 * receive interrupt still blocked.
8116 static irqreturn_t receive_context_thread(int irq, void *data)
8118 struct hfi1_ctxtdata *rcd = data;
8121 /* receive interrupt is still blocked from the IRQ handler */
8122 (void)rcd->do_interrupt(rcd, 1);
8125 * The packet processor will only return if it detected no more
8126 * packets. Hold IRQs here so we can safely clear the interrupt and
8127 * recheck for a packet that may have arrived after the previous
8128 * check and the interrupt clear. If a packet arrived, force another
8131 local_irq_disable();
8132 clear_recv_intr(rcd);
8133 present = check_packet_present(rcd);
8135 force_recv_intr(rcd);
8141 /* ========================================================================= */
8143 u32 read_physical_state(struct hfi1_devdata *dd)
8147 reg = read_csr(dd, DC_DC8051_STS_CUR_STATE);
8148 return (reg >> DC_DC8051_STS_CUR_STATE_PORT_SHIFT)
8149 & DC_DC8051_STS_CUR_STATE_PORT_MASK;
8152 u32 read_logical_state(struct hfi1_devdata *dd)
8156 reg = read_csr(dd, DCC_CFG_PORT_CONFIG);
8157 return (reg >> DCC_CFG_PORT_CONFIG_LINK_STATE_SHIFT)
8158 & DCC_CFG_PORT_CONFIG_LINK_STATE_MASK;
8161 static void set_logical_state(struct hfi1_devdata *dd, u32 chip_lstate)
8165 reg = read_csr(dd, DCC_CFG_PORT_CONFIG);
8166 /* clear current state, set new state */
8167 reg &= ~DCC_CFG_PORT_CONFIG_LINK_STATE_SMASK;
8168 reg |= (u64)chip_lstate << DCC_CFG_PORT_CONFIG_LINK_STATE_SHIFT;
8169 write_csr(dd, DCC_CFG_PORT_CONFIG, reg);
8173 * Use the 8051 to read a LCB CSR.
8175 static int read_lcb_via_8051(struct hfi1_devdata *dd, u32 addr, u64 *data)
8180 if (dd->icode == ICODE_FUNCTIONAL_SIMULATOR) {
8181 if (acquire_lcb_access(dd, 0) == 0) {
8182 *data = read_csr(dd, addr);
8183 release_lcb_access(dd, 0);
8189 /* register is an index of LCB registers: (offset - base) / 8 */
8190 regno = (addr - DC_LCB_CFG_RUN) >> 3;
8191 ret = do_8051_command(dd, HCMD_READ_LCB_CSR, regno, data);
8192 if (ret != HCMD_SUCCESS)
8198 * Read an LCB CSR. Access may not be in host control, so check.
8199 * Return 0 on success, -EBUSY on failure.
8201 int read_lcb_csr(struct hfi1_devdata *dd, u32 addr, u64 *data)
8203 struct hfi1_pportdata *ppd = dd->pport;
8205 /* if up, go through the 8051 for the value */
8206 if (ppd->host_link_state & HLS_UP)
8207 return read_lcb_via_8051(dd, addr, data);
8208 /* if going up or down, no access */
8209 if (ppd->host_link_state & (HLS_GOING_UP | HLS_GOING_OFFLINE))
8211 /* otherwise, host has access */
8212 *data = read_csr(dd, addr);
8217 * Use the 8051 to write a LCB CSR.
8219 static int write_lcb_via_8051(struct hfi1_devdata *dd, u32 addr, u64 data)
8224 if (dd->icode == ICODE_FUNCTIONAL_SIMULATOR ||
8225 (dd->dc8051_ver < dc8051_ver(0, 20))) {
8226 if (acquire_lcb_access(dd, 0) == 0) {
8227 write_csr(dd, addr, data);
8228 release_lcb_access(dd, 0);
8234 /* register is an index of LCB registers: (offset - base) / 8 */
8235 regno = (addr - DC_LCB_CFG_RUN) >> 3;
8236 ret = do_8051_command(dd, HCMD_WRITE_LCB_CSR, regno, &data);
8237 if (ret != HCMD_SUCCESS)
8243 * Write an LCB CSR. Access may not be in host control, so check.
8244 * Return 0 on success, -EBUSY on failure.
8246 int write_lcb_csr(struct hfi1_devdata *dd, u32 addr, u64 data)
8248 struct hfi1_pportdata *ppd = dd->pport;
8250 /* if up, go through the 8051 for the value */
8251 if (ppd->host_link_state & HLS_UP)
8252 return write_lcb_via_8051(dd, addr, data);
8253 /* if going up or down, no access */
8254 if (ppd->host_link_state & (HLS_GOING_UP | HLS_GOING_OFFLINE))
8256 /* otherwise, host has access */
8257 write_csr(dd, addr, data);
8263 * < 0 = Linux error, not able to get access
8264 * > 0 = 8051 command RETURN_CODE
8266 static int do_8051_command(
8267 struct hfi1_devdata *dd,
8274 unsigned long flags;
8275 unsigned long timeout;
8277 hfi1_cdbg(DC8051, "type %d, data 0x%012llx", type, in_data);
8280 * Alternative to holding the lock for a long time:
8281 * - keep busy wait - have other users bounce off
8283 spin_lock_irqsave(&dd->dc8051_lock, flags);
8285 /* We can't send any commands to the 8051 if it's in reset */
8286 if (dd->dc_shutdown) {
8287 return_code = -ENODEV;
8292 * If an 8051 host command timed out previously, then the 8051 is
8295 * On first timeout, attempt to reset and restart the entire DC
8296 * block (including 8051). (Is this too big of a hammer?)
8298 * If the 8051 times out a second time, the reset did not bring it
8299 * back to healthy life. In that case, fail any subsequent commands.
8301 if (dd->dc8051_timed_out) {
8302 if (dd->dc8051_timed_out > 1) {
8304 "Previous 8051 host command timed out, skipping command %u\n",
8306 return_code = -ENXIO;
8309 spin_unlock_irqrestore(&dd->dc8051_lock, flags);
8312 spin_lock_irqsave(&dd->dc8051_lock, flags);
8316 * If there is no timeout, then the 8051 command interface is
8317 * waiting for a command.
8321 * When writing a LCB CSR, out_data contains the full value to
8322 * to be written, while in_data contains the relative LCB
8323 * address in 7:0. Do the work here, rather than the caller,
8324 * of distrubting the write data to where it needs to go:
8327 * 39:00 -> in_data[47:8]
8328 * 47:40 -> DC8051_CFG_EXT_DEV_0.RETURN_CODE
8329 * 63:48 -> DC8051_CFG_EXT_DEV_0.RSP_DATA
8331 if (type == HCMD_WRITE_LCB_CSR) {
8332 in_data |= ((*out_data) & 0xffffffffffull) << 8;
8333 reg = ((((*out_data) >> 40) & 0xff) <<
8334 DC_DC8051_CFG_EXT_DEV_0_RETURN_CODE_SHIFT)
8335 | ((((*out_data) >> 48) & 0xffff) <<
8336 DC_DC8051_CFG_EXT_DEV_0_RSP_DATA_SHIFT);
8337 write_csr(dd, DC_DC8051_CFG_EXT_DEV_0, reg);
8341 * Do two writes: the first to stabilize the type and req_data, the
8342 * second to activate.
8344 reg = ((u64)type & DC_DC8051_CFG_HOST_CMD_0_REQ_TYPE_MASK)
8345 << DC_DC8051_CFG_HOST_CMD_0_REQ_TYPE_SHIFT
8346 | (in_data & DC_DC8051_CFG_HOST_CMD_0_REQ_DATA_MASK)
8347 << DC_DC8051_CFG_HOST_CMD_0_REQ_DATA_SHIFT;
8348 write_csr(dd, DC_DC8051_CFG_HOST_CMD_0, reg);
8349 reg |= DC_DC8051_CFG_HOST_CMD_0_REQ_NEW_SMASK;
8350 write_csr(dd, DC_DC8051_CFG_HOST_CMD_0, reg);
8352 /* wait for completion, alternate: interrupt */
8353 timeout = jiffies + msecs_to_jiffies(DC8051_COMMAND_TIMEOUT);
8355 reg = read_csr(dd, DC_DC8051_CFG_HOST_CMD_1);
8356 completed = reg & DC_DC8051_CFG_HOST_CMD_1_COMPLETED_SMASK;
8359 if (time_after(jiffies, timeout)) {
8360 dd->dc8051_timed_out++;
8361 dd_dev_err(dd, "8051 host command %u timeout\n", type);
8364 return_code = -ETIMEDOUT;
8371 *out_data = (reg >> DC_DC8051_CFG_HOST_CMD_1_RSP_DATA_SHIFT)
8372 & DC_DC8051_CFG_HOST_CMD_1_RSP_DATA_MASK;
8373 if (type == HCMD_READ_LCB_CSR) {
8374 /* top 16 bits are in a different register */
8375 *out_data |= (read_csr(dd, DC_DC8051_CFG_EXT_DEV_1)
8376 & DC_DC8051_CFG_EXT_DEV_1_REQ_DATA_SMASK)
8378 - DC_DC8051_CFG_EXT_DEV_1_REQ_DATA_SHIFT);
8381 return_code = (reg >> DC_DC8051_CFG_HOST_CMD_1_RETURN_CODE_SHIFT)
8382 & DC_DC8051_CFG_HOST_CMD_1_RETURN_CODE_MASK;
8383 dd->dc8051_timed_out = 0;
8385 * Clear command for next user.
8387 write_csr(dd, DC_DC8051_CFG_HOST_CMD_0, 0);
8390 spin_unlock_irqrestore(&dd->dc8051_lock, flags);
8395 static int set_physical_link_state(struct hfi1_devdata *dd, u64 state)
8397 return do_8051_command(dd, HCMD_CHANGE_PHY_STATE, state, NULL);
8400 int load_8051_config(struct hfi1_devdata *dd, u8 field_id,
8401 u8 lane_id, u32 config_data)
8406 data = (u64)field_id << LOAD_DATA_FIELD_ID_SHIFT
8407 | (u64)lane_id << LOAD_DATA_LANE_ID_SHIFT
8408 | (u64)config_data << LOAD_DATA_DATA_SHIFT;
8409 ret = do_8051_command(dd, HCMD_LOAD_CONFIG_DATA, data, NULL);
8410 if (ret != HCMD_SUCCESS) {
8412 "load 8051 config: field id %d, lane %d, err %d\n",
8413 (int)field_id, (int)lane_id, ret);
8419 * Read the 8051 firmware "registers". Use the RAM directly. Always
8420 * set the result, even on error.
8421 * Return 0 on success, -errno on failure
8423 int read_8051_config(struct hfi1_devdata *dd, u8 field_id, u8 lane_id,
8430 /* address start depends on the lane_id */
8432 addr = (4 * NUM_GENERAL_FIELDS)
8433 + (lane_id * 4 * NUM_LANE_FIELDS);
8436 addr += field_id * 4;
8438 /* read is in 8-byte chunks, hardware will truncate the address down */
8439 ret = read_8051_data(dd, addr, 8, &big_data);
8442 /* extract the 4 bytes we want */
8444 *result = (u32)(big_data >> 32);
8446 *result = (u32)big_data;
8449 dd_dev_err(dd, "%s: direct read failed, lane %d, field %d!\n",
8450 __func__, lane_id, field_id);
8456 static int write_vc_local_phy(struct hfi1_devdata *dd, u8 power_management,
8461 frame = continuous << CONTINIOUS_REMOTE_UPDATE_SUPPORT_SHIFT
8462 | power_management << POWER_MANAGEMENT_SHIFT;
8463 return load_8051_config(dd, VERIFY_CAP_LOCAL_PHY,
8464 GENERAL_CONFIG, frame);
8467 static int write_vc_local_fabric(struct hfi1_devdata *dd, u8 vau, u8 z, u8 vcu,
8468 u16 vl15buf, u8 crc_sizes)
8472 frame = (u32)vau << VAU_SHIFT
8474 | (u32)vcu << VCU_SHIFT
8475 | (u32)vl15buf << VL15BUF_SHIFT
8476 | (u32)crc_sizes << CRC_SIZES_SHIFT;
8477 return load_8051_config(dd, VERIFY_CAP_LOCAL_FABRIC,
8478 GENERAL_CONFIG, frame);
8481 static void read_vc_local_link_width(struct hfi1_devdata *dd, u8 *misc_bits,
8482 u8 *flag_bits, u16 *link_widths)
8486 read_8051_config(dd, VERIFY_CAP_LOCAL_LINK_WIDTH, GENERAL_CONFIG,
8488 *misc_bits = (frame >> MISC_CONFIG_BITS_SHIFT) & MISC_CONFIG_BITS_MASK;
8489 *flag_bits = (frame >> LOCAL_FLAG_BITS_SHIFT) & LOCAL_FLAG_BITS_MASK;
8490 *link_widths = (frame >> LINK_WIDTH_SHIFT) & LINK_WIDTH_MASK;
8493 static int write_vc_local_link_width(struct hfi1_devdata *dd,
8500 frame = (u32)misc_bits << MISC_CONFIG_BITS_SHIFT
8501 | (u32)flag_bits << LOCAL_FLAG_BITS_SHIFT
8502 | (u32)link_widths << LINK_WIDTH_SHIFT;
8503 return load_8051_config(dd, VERIFY_CAP_LOCAL_LINK_WIDTH, GENERAL_CONFIG,
8507 static int write_local_device_id(struct hfi1_devdata *dd, u16 device_id,
8512 frame = ((u32)device_id << LOCAL_DEVICE_ID_SHIFT)
8513 | ((u32)device_rev << LOCAL_DEVICE_REV_SHIFT);
8514 return load_8051_config(dd, LOCAL_DEVICE_ID, GENERAL_CONFIG, frame);
8517 static void read_remote_device_id(struct hfi1_devdata *dd, u16 *device_id,
8522 read_8051_config(dd, REMOTE_DEVICE_ID, GENERAL_CONFIG, &frame);
8523 *device_id = (frame >> REMOTE_DEVICE_ID_SHIFT) & REMOTE_DEVICE_ID_MASK;
8524 *device_rev = (frame >> REMOTE_DEVICE_REV_SHIFT)
8525 & REMOTE_DEVICE_REV_MASK;
8528 void read_misc_status(struct hfi1_devdata *dd, u8 *ver_a, u8 *ver_b)
8532 read_8051_config(dd, MISC_STATUS, GENERAL_CONFIG, &frame);
8533 *ver_a = (frame >> STS_FM_VERSION_A_SHIFT) & STS_FM_VERSION_A_MASK;
8534 *ver_b = (frame >> STS_FM_VERSION_B_SHIFT) & STS_FM_VERSION_B_MASK;
8537 static void read_vc_remote_phy(struct hfi1_devdata *dd, u8 *power_management,
8542 read_8051_config(dd, VERIFY_CAP_REMOTE_PHY, GENERAL_CONFIG, &frame);
8543 *power_management = (frame >> POWER_MANAGEMENT_SHIFT)
8544 & POWER_MANAGEMENT_MASK;
8545 *continuous = (frame >> CONTINIOUS_REMOTE_UPDATE_SUPPORT_SHIFT)
8546 & CONTINIOUS_REMOTE_UPDATE_SUPPORT_MASK;
8549 static void read_vc_remote_fabric(struct hfi1_devdata *dd, u8 *vau, u8 *z,
8550 u8 *vcu, u16 *vl15buf, u8 *crc_sizes)
8554 read_8051_config(dd, VERIFY_CAP_REMOTE_FABRIC, GENERAL_CONFIG, &frame);
8555 *vau = (frame >> VAU_SHIFT) & VAU_MASK;
8556 *z = (frame >> Z_SHIFT) & Z_MASK;
8557 *vcu = (frame >> VCU_SHIFT) & VCU_MASK;
8558 *vl15buf = (frame >> VL15BUF_SHIFT) & VL15BUF_MASK;
8559 *crc_sizes = (frame >> CRC_SIZES_SHIFT) & CRC_SIZES_MASK;
8562 static void read_vc_remote_link_width(struct hfi1_devdata *dd,
8568 read_8051_config(dd, VERIFY_CAP_REMOTE_LINK_WIDTH, GENERAL_CONFIG,
8570 *remote_tx_rate = (frame >> REMOTE_TX_RATE_SHIFT)
8571 & REMOTE_TX_RATE_MASK;
8572 *link_widths = (frame >> LINK_WIDTH_SHIFT) & LINK_WIDTH_MASK;
8575 static void read_local_lni(struct hfi1_devdata *dd, u8 *enable_lane_rx)
8579 read_8051_config(dd, LOCAL_LNI_INFO, GENERAL_CONFIG, &frame);
8580 *enable_lane_rx = (frame >> ENABLE_LANE_RX_SHIFT) & ENABLE_LANE_RX_MASK;
8583 static void read_mgmt_allowed(struct hfi1_devdata *dd, u8 *mgmt_allowed)
8587 read_8051_config(dd, REMOTE_LNI_INFO, GENERAL_CONFIG, &frame);
8588 *mgmt_allowed = (frame >> MGMT_ALLOWED_SHIFT) & MGMT_ALLOWED_MASK;
8591 static void read_last_local_state(struct hfi1_devdata *dd, u32 *lls)
8593 read_8051_config(dd, LAST_LOCAL_STATE_COMPLETE, GENERAL_CONFIG, lls);
8596 static void read_last_remote_state(struct hfi1_devdata *dd, u32 *lrs)
8598 read_8051_config(dd, LAST_REMOTE_STATE_COMPLETE, GENERAL_CONFIG, lrs);
8601 void hfi1_read_link_quality(struct hfi1_devdata *dd, u8 *link_quality)
8607 if (dd->pport->host_link_state & HLS_UP) {
8608 ret = read_8051_config(dd, LINK_QUALITY_INFO, GENERAL_CONFIG,
8611 *link_quality = (frame >> LINK_QUALITY_SHIFT)
8612 & LINK_QUALITY_MASK;
8616 static void read_planned_down_reason_code(struct hfi1_devdata *dd, u8 *pdrrc)
8620 read_8051_config(dd, LINK_QUALITY_INFO, GENERAL_CONFIG, &frame);
8621 *pdrrc = (frame >> DOWN_REMOTE_REASON_SHIFT) & DOWN_REMOTE_REASON_MASK;
8624 static int read_tx_settings(struct hfi1_devdata *dd,
8626 u8 *tx_polarity_inversion,
8627 u8 *rx_polarity_inversion,
8633 ret = read_8051_config(dd, TX_SETTINGS, GENERAL_CONFIG, &frame);
8634 *enable_lane_tx = (frame >> ENABLE_LANE_TX_SHIFT)
8635 & ENABLE_LANE_TX_MASK;
8636 *tx_polarity_inversion = (frame >> TX_POLARITY_INVERSION_SHIFT)
8637 & TX_POLARITY_INVERSION_MASK;
8638 *rx_polarity_inversion = (frame >> RX_POLARITY_INVERSION_SHIFT)
8639 & RX_POLARITY_INVERSION_MASK;
8640 *max_rate = (frame >> MAX_RATE_SHIFT) & MAX_RATE_MASK;
8644 static int write_tx_settings(struct hfi1_devdata *dd,
8646 u8 tx_polarity_inversion,
8647 u8 rx_polarity_inversion,
8652 /* no need to mask, all variable sizes match field widths */
8653 frame = enable_lane_tx << ENABLE_LANE_TX_SHIFT
8654 | tx_polarity_inversion << TX_POLARITY_INVERSION_SHIFT
8655 | rx_polarity_inversion << RX_POLARITY_INVERSION_SHIFT
8656 | max_rate << MAX_RATE_SHIFT;
8657 return load_8051_config(dd, TX_SETTINGS, GENERAL_CONFIG, frame);
8660 static void check_fabric_firmware_versions(struct hfi1_devdata *dd)
8662 u32 frame, version, prod_id;
8666 for (lane = 0; lane < 4; lane++) {
8667 ret = read_8051_config(dd, SPICO_FW_VERSION, lane, &frame);
8670 "Unable to read lane %d firmware details\n",
8674 version = (frame >> SPICO_ROM_VERSION_SHIFT)
8675 & SPICO_ROM_VERSION_MASK;
8676 prod_id = (frame >> SPICO_ROM_PROD_ID_SHIFT)
8677 & SPICO_ROM_PROD_ID_MASK;
8679 "Lane %d firmware: version 0x%04x, prod_id 0x%04x\n",
8680 lane, version, prod_id);
8685 * Read an idle LCB message.
8687 * Returns 0 on success, -EINVAL on error
8689 static int read_idle_message(struct hfi1_devdata *dd, u64 type, u64 *data_out)
8693 ret = do_8051_command(dd, HCMD_READ_LCB_IDLE_MSG, type, data_out);
8694 if (ret != HCMD_SUCCESS) {
8695 dd_dev_err(dd, "read idle message: type %d, err %d\n",
8699 dd_dev_info(dd, "%s: read idle message 0x%llx\n", __func__, *data_out);
8700 /* return only the payload as we already know the type */
8701 *data_out >>= IDLE_PAYLOAD_SHIFT;
8706 * Read an idle SMA message. To be done in response to a notification from
8709 * Returns 0 on success, -EINVAL on error
8711 static int read_idle_sma(struct hfi1_devdata *dd, u64 *data)
8713 return read_idle_message(dd, (u64)IDLE_SMA << IDLE_MSG_TYPE_SHIFT,
8718 * Send an idle LCB message.
8720 * Returns 0 on success, -EINVAL on error
8722 static int send_idle_message(struct hfi1_devdata *dd, u64 data)
8726 dd_dev_info(dd, "%s: sending idle message 0x%llx\n", __func__, data);
8727 ret = do_8051_command(dd, HCMD_SEND_LCB_IDLE_MSG, data, NULL);
8728 if (ret != HCMD_SUCCESS) {
8729 dd_dev_err(dd, "send idle message: data 0x%llx, err %d\n",
8737 * Send an idle SMA message.
8739 * Returns 0 on success, -EINVAL on error
8741 int send_idle_sma(struct hfi1_devdata *dd, u64 message)
8745 data = ((message & IDLE_PAYLOAD_MASK) << IDLE_PAYLOAD_SHIFT) |
8746 ((u64)IDLE_SMA << IDLE_MSG_TYPE_SHIFT);
8747 return send_idle_message(dd, data);
8751 * Initialize the LCB then do a quick link up. This may or may not be
8754 * return 0 on success, -errno on error
8756 static int do_quick_linkup(struct hfi1_devdata *dd)
8759 unsigned long timeout;
8762 lcb_shutdown(dd, 0);
8765 /* LCB_CFG_LOOPBACK.VAL = 2 */
8766 /* LCB_CFG_LANE_WIDTH.VAL = 0 */
8767 write_csr(dd, DC_LCB_CFG_LOOPBACK,
8768 IB_PACKET_TYPE << DC_LCB_CFG_LOOPBACK_VAL_SHIFT);
8769 write_csr(dd, DC_LCB_CFG_LANE_WIDTH, 0);
8772 /* start the LCBs */
8773 /* LCB_CFG_TX_FIFOS_RESET.VAL = 0 */
8774 write_csr(dd, DC_LCB_CFG_TX_FIFOS_RESET, 0);
8776 /* simulator only loopback steps */
8777 if (loopback && dd->icode == ICODE_FUNCTIONAL_SIMULATOR) {
8778 /* LCB_CFG_RUN.EN = 1 */
8779 write_csr(dd, DC_LCB_CFG_RUN,
8780 1ull << DC_LCB_CFG_RUN_EN_SHIFT);
8782 /* watch LCB_STS_LINK_TRANSFER_ACTIVE */
8783 timeout = jiffies + msecs_to_jiffies(10);
8785 reg = read_csr(dd, DC_LCB_STS_LINK_TRANSFER_ACTIVE);
8788 if (time_after(jiffies, timeout)) {
8790 "timeout waiting for LINK_TRANSFER_ACTIVE\n");
8796 write_csr(dd, DC_LCB_CFG_ALLOW_LINK_UP,
8797 1ull << DC_LCB_CFG_ALLOW_LINK_UP_VAL_SHIFT);
8802 * When doing quick linkup and not in loopback, both
8803 * sides must be done with LCB set-up before either
8804 * starts the quick linkup. Put a delay here so that
8805 * both sides can be started and have a chance to be
8806 * done with LCB set up before resuming.
8809 "Pausing for peer to be finished with LCB set up\n");
8811 dd_dev_err(dd, "Continuing with quick linkup\n");
8814 write_csr(dd, DC_LCB_ERR_EN, 0); /* mask LCB errors */
8815 set_8051_lcb_access(dd);
8818 * State "quick" LinkUp request sets the physical link state to
8819 * LinkUp without a verify capability sequence.
8820 * This state is in simulator v37 and later.
8822 ret = set_physical_link_state(dd, PLS_QUICK_LINKUP);
8823 if (ret != HCMD_SUCCESS) {
8825 "%s: set physical link state to quick LinkUp failed with return %d\n",
8828 set_host_lcb_access(dd);
8829 write_csr(dd, DC_LCB_ERR_EN, ~0ull); /* watch LCB errors */
8836 return 0; /* success */
8840 * Set the SerDes to internal loopback mode.
8841 * Returns 0 on success, -errno on error.
8843 static int set_serdes_loopback_mode(struct hfi1_devdata *dd)
8847 ret = set_physical_link_state(dd, PLS_INTERNAL_SERDES_LOOPBACK);
8848 if (ret == HCMD_SUCCESS)
8851 "Set physical link state to SerDes Loopback failed with return %d\n",
8859 * Do all special steps to set up loopback.
8861 static int init_loopback(struct hfi1_devdata *dd)
8863 dd_dev_info(dd, "Entering loopback mode\n");
8865 /* all loopbacks should disable self GUID check */
8866 write_csr(dd, DC_DC8051_CFG_MODE,
8867 (read_csr(dd, DC_DC8051_CFG_MODE) | DISABLE_SELF_GUID_CHECK));
8870 * The simulator has only one loopback option - LCB. Switch
8871 * to that option, which includes quick link up.
8873 * Accept all valid loopback values.
8875 if ((dd->icode == ICODE_FUNCTIONAL_SIMULATOR) &&
8876 (loopback == LOOPBACK_SERDES || loopback == LOOPBACK_LCB ||
8877 loopback == LOOPBACK_CABLE)) {
8878 loopback = LOOPBACK_LCB;
8883 /* handle serdes loopback */
8884 if (loopback == LOOPBACK_SERDES) {
8885 /* internal serdes loopack needs quick linkup on RTL */
8886 if (dd->icode == ICODE_RTL_SILICON)
8888 return set_serdes_loopback_mode(dd);
8891 /* LCB loopback - handled at poll time */
8892 if (loopback == LOOPBACK_LCB) {
8893 quick_linkup = 1; /* LCB is always quick linkup */
8895 /* not supported in emulation due to emulation RTL changes */
8896 if (dd->icode == ICODE_FPGA_EMULATION) {
8898 "LCB loopback not supported in emulation\n");
8904 /* external cable loopback requires no extra steps */
8905 if (loopback == LOOPBACK_CABLE)
8908 dd_dev_err(dd, "Invalid loopback mode %d\n", loopback);
8913 * Translate from the OPA_LINK_WIDTH handed to us by the FM to bits
8914 * used in the Verify Capability link width attribute.
8916 static u16 opa_to_vc_link_widths(u16 opa_widths)
8921 static const struct link_bits {
8924 } opa_link_xlate[] = {
8925 { OPA_LINK_WIDTH_1X, 1 << (1 - 1) },
8926 { OPA_LINK_WIDTH_2X, 1 << (2 - 1) },
8927 { OPA_LINK_WIDTH_3X, 1 << (3 - 1) },
8928 { OPA_LINK_WIDTH_4X, 1 << (4 - 1) },
8931 for (i = 0; i < ARRAY_SIZE(opa_link_xlate); i++) {
8932 if (opa_widths & opa_link_xlate[i].from)
8933 result |= opa_link_xlate[i].to;
8939 * Set link attributes before moving to polling.
8941 static int set_local_link_attributes(struct hfi1_pportdata *ppd)
8943 struct hfi1_devdata *dd = ppd->dd;
8945 u8 tx_polarity_inversion;
8946 u8 rx_polarity_inversion;
8949 /* reset our fabric serdes to clear any lingering problems */
8950 fabric_serdes_reset(dd);
8952 /* set the local tx rate - need to read-modify-write */
8953 ret = read_tx_settings(dd, &enable_lane_tx, &tx_polarity_inversion,
8954 &rx_polarity_inversion, &ppd->local_tx_rate);
8956 goto set_local_link_attributes_fail;
8958 if (dd->dc8051_ver < dc8051_ver(0, 20)) {
8959 /* set the tx rate to the fastest enabled */
8960 if (ppd->link_speed_enabled & OPA_LINK_SPEED_25G)
8961 ppd->local_tx_rate = 1;
8963 ppd->local_tx_rate = 0;
8965 /* set the tx rate to all enabled */
8966 ppd->local_tx_rate = 0;
8967 if (ppd->link_speed_enabled & OPA_LINK_SPEED_25G)
8968 ppd->local_tx_rate |= 2;
8969 if (ppd->link_speed_enabled & OPA_LINK_SPEED_12_5G)
8970 ppd->local_tx_rate |= 1;
8973 enable_lane_tx = 0xF; /* enable all four lanes */
8974 ret = write_tx_settings(dd, enable_lane_tx, tx_polarity_inversion,
8975 rx_polarity_inversion, ppd->local_tx_rate);
8976 if (ret != HCMD_SUCCESS)
8977 goto set_local_link_attributes_fail;
8980 * DC supports continuous updates.
8982 ret = write_vc_local_phy(dd,
8983 0 /* no power management */,
8984 1 /* continuous updates */);
8985 if (ret != HCMD_SUCCESS)
8986 goto set_local_link_attributes_fail;
8988 /* z=1 in the next call: AU of 0 is not supported by the hardware */
8989 ret = write_vc_local_fabric(dd, dd->vau, 1, dd->vcu, dd->vl15_init,
8990 ppd->port_crc_mode_enabled);
8991 if (ret != HCMD_SUCCESS)
8992 goto set_local_link_attributes_fail;
8994 ret = write_vc_local_link_width(dd, 0, 0,
8995 opa_to_vc_link_widths(
8996 ppd->link_width_enabled));
8997 if (ret != HCMD_SUCCESS)
8998 goto set_local_link_attributes_fail;
9000 /* let peer know who we are */
9001 ret = write_local_device_id(dd, dd->pcidev->device, dd->minrev);
9002 if (ret == HCMD_SUCCESS)
9005 set_local_link_attributes_fail:
9007 "Failed to set local link attributes, return 0x%x\n",
9013 * Call this to start the link.
9014 * Do not do anything if the link is disabled.
9015 * Returns 0 if link is disabled, moved to polling, or the driver is not ready.
9017 int start_link(struct hfi1_pportdata *ppd)
9019 if (!ppd->link_enabled) {
9020 dd_dev_info(ppd->dd,
9021 "%s: stopping link start because link is disabled\n",
9025 if (!ppd->driver_link_ready) {
9026 dd_dev_info(ppd->dd,
9027 "%s: stopping link start because driver is not ready\n",
9032 return set_link_state(ppd, HLS_DN_POLL);
9035 static void wait_for_qsfp_init(struct hfi1_pportdata *ppd)
9037 struct hfi1_devdata *dd = ppd->dd;
9039 unsigned long timeout;
9042 * Check for QSFP interrupt for t_init (SFF 8679)
9044 timeout = jiffies + msecs_to_jiffies(2000);
9046 mask = read_csr(dd, dd->hfi1_id ?
9047 ASIC_QSFP2_IN : ASIC_QSFP1_IN);
9048 if (!(mask & QSFP_HFI0_INT_N)) {
9049 write_csr(dd, dd->hfi1_id ? ASIC_QSFP2_CLEAR :
9050 ASIC_QSFP1_CLEAR, QSFP_HFI0_INT_N);
9053 if (time_after(jiffies, timeout)) {
9054 dd_dev_info(dd, "%s: No IntN detected, reset complete\n",
9062 static void set_qsfp_int_n(struct hfi1_pportdata *ppd, u8 enable)
9064 struct hfi1_devdata *dd = ppd->dd;
9067 mask = read_csr(dd, dd->hfi1_id ? ASIC_QSFP2_MASK : ASIC_QSFP1_MASK);
9069 mask |= (u64)QSFP_HFI0_INT_N;
9071 mask &= ~(u64)QSFP_HFI0_INT_N;
9072 write_csr(dd, dd->hfi1_id ? ASIC_QSFP2_MASK : ASIC_QSFP1_MASK, mask);
9075 void reset_qsfp(struct hfi1_pportdata *ppd)
9077 struct hfi1_devdata *dd = ppd->dd;
9078 u64 mask, qsfp_mask;
9080 /* Disable INT_N from triggering QSFP interrupts */
9081 set_qsfp_int_n(ppd, 0);
9083 /* Reset the QSFP */
9084 mask = (u64)QSFP_HFI0_RESET_N;
9085 qsfp_mask = read_csr(dd, dd->hfi1_id ? ASIC_QSFP2_OE : ASIC_QSFP1_OE);
9087 write_csr(dd, dd->hfi1_id ? ASIC_QSFP2_OE : ASIC_QSFP1_OE, qsfp_mask);
9089 qsfp_mask = read_csr(dd,
9090 dd->hfi1_id ? ASIC_QSFP2_OUT : ASIC_QSFP1_OUT);
9093 dd->hfi1_id ? ASIC_QSFP2_OUT : ASIC_QSFP1_OUT, qsfp_mask);
9099 dd->hfi1_id ? ASIC_QSFP2_OUT : ASIC_QSFP1_OUT, qsfp_mask);
9101 wait_for_qsfp_init(ppd);
9104 * Allow INT_N to trigger the QSFP interrupt to watch
9105 * for alarms and warnings
9107 set_qsfp_int_n(ppd, 1);
9110 static int handle_qsfp_error_conditions(struct hfi1_pportdata *ppd,
9111 u8 *qsfp_interrupt_status)
9113 struct hfi1_devdata *dd = ppd->dd;
9115 if ((qsfp_interrupt_status[0] & QSFP_HIGH_TEMP_ALARM) ||
9116 (qsfp_interrupt_status[0] & QSFP_HIGH_TEMP_WARNING))
9117 dd_dev_info(dd, "%s: QSFP cable on fire\n",
9120 if ((qsfp_interrupt_status[0] & QSFP_LOW_TEMP_ALARM) ||
9121 (qsfp_interrupt_status[0] & QSFP_LOW_TEMP_WARNING))
9122 dd_dev_info(dd, "%s: QSFP cable temperature too low\n",
9125 if ((qsfp_interrupt_status[1] & QSFP_HIGH_VCC_ALARM) ||
9126 (qsfp_interrupt_status[1] & QSFP_HIGH_VCC_WARNING))
9127 dd_dev_info(dd, "%s: QSFP supply voltage too high\n",
9130 if ((qsfp_interrupt_status[1] & QSFP_LOW_VCC_ALARM) ||
9131 (qsfp_interrupt_status[1] & QSFP_LOW_VCC_WARNING))
9132 dd_dev_info(dd, "%s: QSFP supply voltage too low\n",
9135 /* Byte 2 is vendor specific */
9137 if ((qsfp_interrupt_status[3] & QSFP_HIGH_POWER_ALARM) ||
9138 (qsfp_interrupt_status[3] & QSFP_HIGH_POWER_WARNING))
9139 dd_dev_info(dd, "%s: Cable RX channel 1/2 power too high\n",
9142 if ((qsfp_interrupt_status[3] & QSFP_LOW_POWER_ALARM) ||
9143 (qsfp_interrupt_status[3] & QSFP_LOW_POWER_WARNING))
9144 dd_dev_info(dd, "%s: Cable RX channel 1/2 power too low\n",
9147 if ((qsfp_interrupt_status[4] & QSFP_HIGH_POWER_ALARM) ||
9148 (qsfp_interrupt_status[4] & QSFP_HIGH_POWER_WARNING))
9149 dd_dev_info(dd, "%s: Cable RX channel 3/4 power too high\n",
9152 if ((qsfp_interrupt_status[4] & QSFP_LOW_POWER_ALARM) ||
9153 (qsfp_interrupt_status[4] & QSFP_LOW_POWER_WARNING))
9154 dd_dev_info(dd, "%s: Cable RX channel 3/4 power too low\n",
9157 if ((qsfp_interrupt_status[5] & QSFP_HIGH_BIAS_ALARM) ||
9158 (qsfp_interrupt_status[5] & QSFP_HIGH_BIAS_WARNING))
9159 dd_dev_info(dd, "%s: Cable TX channel 1/2 bias too high\n",
9162 if ((qsfp_interrupt_status[5] & QSFP_LOW_BIAS_ALARM) ||
9163 (qsfp_interrupt_status[5] & QSFP_LOW_BIAS_WARNING))
9164 dd_dev_info(dd, "%s: Cable TX channel 1/2 bias too low\n",
9167 if ((qsfp_interrupt_status[6] & QSFP_HIGH_BIAS_ALARM) ||
9168 (qsfp_interrupt_status[6] & QSFP_HIGH_BIAS_WARNING))
9169 dd_dev_info(dd, "%s: Cable TX channel 3/4 bias too high\n",
9172 if ((qsfp_interrupt_status[6] & QSFP_LOW_BIAS_ALARM) ||
9173 (qsfp_interrupt_status[6] & QSFP_LOW_BIAS_WARNING))
9174 dd_dev_info(dd, "%s: Cable TX channel 3/4 bias too low\n",
9177 if ((qsfp_interrupt_status[7] & QSFP_HIGH_POWER_ALARM) ||
9178 (qsfp_interrupt_status[7] & QSFP_HIGH_POWER_WARNING))
9179 dd_dev_info(dd, "%s: Cable TX channel 1/2 power too high\n",
9182 if ((qsfp_interrupt_status[7] & QSFP_LOW_POWER_ALARM) ||
9183 (qsfp_interrupt_status[7] & QSFP_LOW_POWER_WARNING))
9184 dd_dev_info(dd, "%s: Cable TX channel 1/2 power too low\n",
9187 if ((qsfp_interrupt_status[8] & QSFP_HIGH_POWER_ALARM) ||
9188 (qsfp_interrupt_status[8] & QSFP_HIGH_POWER_WARNING))
9189 dd_dev_info(dd, "%s: Cable TX channel 3/4 power too high\n",
9192 if ((qsfp_interrupt_status[8] & QSFP_LOW_POWER_ALARM) ||
9193 (qsfp_interrupt_status[8] & QSFP_LOW_POWER_WARNING))
9194 dd_dev_info(dd, "%s: Cable TX channel 3/4 power too low\n",
9197 /* Bytes 9-10 and 11-12 are reserved */
9198 /* Bytes 13-15 are vendor specific */
9203 /* This routine will only be scheduled if the QSFP module present is asserted */
9204 void qsfp_event(struct work_struct *work)
9206 struct qsfp_data *qd;
9207 struct hfi1_pportdata *ppd;
9208 struct hfi1_devdata *dd;
9210 qd = container_of(work, struct qsfp_data, qsfp_work);
9215 if (!qsfp_mod_present(ppd))
9219 * Turn DC back on after cables has been
9220 * re-inserted. Up until now, the DC has been in
9221 * reset to save power.
9225 if (qd->cache_refresh_required) {
9226 set_qsfp_int_n(ppd, 0);
9228 wait_for_qsfp_init(ppd);
9231 * Allow INT_N to trigger the QSFP interrupt to watch
9232 * for alarms and warnings
9234 set_qsfp_int_n(ppd, 1);
9241 if (qd->check_interrupt_flags) {
9242 u8 qsfp_interrupt_status[16] = {0,};
9244 if (one_qsfp_read(ppd, dd->hfi1_id, 6,
9245 &qsfp_interrupt_status[0], 16) != 16) {
9247 "%s: Failed to read status of QSFP module\n",
9250 unsigned long flags;
9252 handle_qsfp_error_conditions(
9253 ppd, qsfp_interrupt_status);
9254 spin_lock_irqsave(&ppd->qsfp_info.qsfp_lock, flags);
9255 ppd->qsfp_info.check_interrupt_flags = 0;
9256 spin_unlock_irqrestore(&ppd->qsfp_info.qsfp_lock,
9262 static void init_qsfp_int(struct hfi1_devdata *dd)
9264 struct hfi1_pportdata *ppd = dd->pport;
9265 u64 qsfp_mask, cce_int_mask;
9266 const int qsfp1_int_smask = QSFP1_INT % 64;
9267 const int qsfp2_int_smask = QSFP2_INT % 64;
9270 * disable QSFP1 interrupts for HFI1, QSFP2 interrupts for HFI0
9271 * Qsfp1Int and Qsfp2Int are adjacent bits in the same CSR,
9272 * therefore just one of QSFP1_INT/QSFP2_INT can be used to find
9273 * the index of the appropriate CSR in the CCEIntMask CSR array
9275 cce_int_mask = read_csr(dd, CCE_INT_MASK +
9276 (8 * (QSFP1_INT / 64)));
9278 cce_int_mask &= ~((u64)1 << qsfp1_int_smask);
9279 write_csr(dd, CCE_INT_MASK + (8 * (QSFP1_INT / 64)),
9282 cce_int_mask &= ~((u64)1 << qsfp2_int_smask);
9283 write_csr(dd, CCE_INT_MASK + (8 * (QSFP2_INT / 64)),
9287 qsfp_mask = (u64)(QSFP_HFI0_INT_N | QSFP_HFI0_MODPRST_N);
9288 /* Clear current status to avoid spurious interrupts */
9289 write_csr(dd, dd->hfi1_id ? ASIC_QSFP2_CLEAR : ASIC_QSFP1_CLEAR,
9291 write_csr(dd, dd->hfi1_id ? ASIC_QSFP2_MASK : ASIC_QSFP1_MASK,
9294 set_qsfp_int_n(ppd, 0);
9296 /* Handle active low nature of INT_N and MODPRST_N pins */
9297 if (qsfp_mod_present(ppd))
9298 qsfp_mask &= ~(u64)QSFP_HFI0_MODPRST_N;
9300 dd->hfi1_id ? ASIC_QSFP2_INVERT : ASIC_QSFP1_INVERT,
9305 * Do a one-time initialize of the LCB block.
9307 static void init_lcb(struct hfi1_devdata *dd)
9309 /* simulator does not correctly handle LCB cclk loopback, skip */
9310 if (dd->icode == ICODE_FUNCTIONAL_SIMULATOR)
9313 /* the DC has been reset earlier in the driver load */
9315 /* set LCB for cclk loopback on the port */
9316 write_csr(dd, DC_LCB_CFG_TX_FIFOS_RESET, 0x01);
9317 write_csr(dd, DC_LCB_CFG_LANE_WIDTH, 0x00);
9318 write_csr(dd, DC_LCB_CFG_REINIT_AS_SLAVE, 0x00);
9319 write_csr(dd, DC_LCB_CFG_CNT_FOR_SKIP_STALL, 0x110);
9320 write_csr(dd, DC_LCB_CFG_CLK_CNTR, 0x08);
9321 write_csr(dd, DC_LCB_CFG_LOOPBACK, 0x02);
9322 write_csr(dd, DC_LCB_CFG_TX_FIFOS_RESET, 0x00);
9325 int bringup_serdes(struct hfi1_pportdata *ppd)
9327 struct hfi1_devdata *dd = ppd->dd;
9331 if (HFI1_CAP_IS_KSET(EXTENDED_PSN))
9332 add_rcvctrl(dd, RCV_CTRL_RCV_EXTENDED_PSN_ENABLE_SMASK);
9337 guid = dd->base_guid + ppd->port - 1;
9341 /* Set linkinit_reason on power up per OPA spec */
9342 ppd->linkinit_reason = OPA_LINKINIT_REASON_LINKUP;
9344 /* one-time init of the LCB */
9348 ret = init_loopback(dd);
9353 /* tune the SERDES to a ballpark setting for
9354 * optimal signal and bit error rate
9355 * Needs to be done before starting the link
9359 return start_link(ppd);
9362 void hfi1_quiet_serdes(struct hfi1_pportdata *ppd)
9364 struct hfi1_devdata *dd = ppd->dd;
9367 * Shut down the link and keep it down. First turn off that the
9368 * driver wants to allow the link to be up (driver_link_ready).
9369 * Then make sure the link is not automatically restarted
9370 * (link_enabled). Cancel any pending restart. And finally
9373 ppd->driver_link_ready = 0;
9374 ppd->link_enabled = 0;
9376 ppd->offline_disabled_reason =
9377 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_SMA_DISABLED);
9378 set_link_down_reason(ppd, OPA_LINKDOWN_REASON_SMA_DISABLED, 0,
9379 OPA_LINKDOWN_REASON_SMA_DISABLED);
9380 set_link_state(ppd, HLS_DN_OFFLINE);
9382 /* disable the port */
9383 clear_rcvctrl(dd, RCV_CTRL_RCV_PORT_ENABLE_SMASK);
9386 static inline int init_cpu_counters(struct hfi1_devdata *dd)
9388 struct hfi1_pportdata *ppd;
9391 ppd = (struct hfi1_pportdata *)(dd + 1);
9392 for (i = 0; i < dd->num_pports; i++, ppd++) {
9393 ppd->ibport_data.rvp.rc_acks = NULL;
9394 ppd->ibport_data.rvp.rc_qacks = NULL;
9395 ppd->ibport_data.rvp.rc_acks = alloc_percpu(u64);
9396 ppd->ibport_data.rvp.rc_qacks = alloc_percpu(u64);
9397 ppd->ibport_data.rvp.rc_delayed_comp = alloc_percpu(u64);
9398 if (!ppd->ibport_data.rvp.rc_acks ||
9399 !ppd->ibport_data.rvp.rc_delayed_comp ||
9400 !ppd->ibport_data.rvp.rc_qacks)
9407 static const char * const pt_names[] = {
9413 static const char *pt_name(u32 type)
9415 return type >= ARRAY_SIZE(pt_names) ? "unknown" : pt_names[type];
9419 * index is the index into the receive array
9421 void hfi1_put_tid(struct hfi1_devdata *dd, u32 index,
9422 u32 type, unsigned long pa, u16 order)
9425 void __iomem *base = (dd->rcvarray_wc ? dd->rcvarray_wc :
9426 (dd->kregbase + RCV_ARRAY));
9428 if (!(dd->flags & HFI1_PRESENT))
9431 if (type == PT_INVALID) {
9433 } else if (type > PT_INVALID) {
9435 "unexpected receive array type %u for index %u, not handled\n",
9440 hfi1_cdbg(TID, "type %s, index 0x%x, pa 0x%lx, bsize 0x%lx",
9441 pt_name(type), index, pa, (unsigned long)order);
9443 #define RT_ADDR_SHIFT 12 /* 4KB kernel address boundary */
9444 reg = RCV_ARRAY_RT_WRITE_ENABLE_SMASK
9445 | (u64)order << RCV_ARRAY_RT_BUF_SIZE_SHIFT
9446 | ((pa >> RT_ADDR_SHIFT) & RCV_ARRAY_RT_ADDR_MASK)
9447 << RCV_ARRAY_RT_ADDR_SHIFT;
9448 writeq(reg, base + (index * 8));
9450 if (type == PT_EAGER)
9452 * Eager entries are written one-by-one so we have to push them
9453 * after we write the entry.
9460 void hfi1_clear_tids(struct hfi1_ctxtdata *rcd)
9462 struct hfi1_devdata *dd = rcd->dd;
9465 /* this could be optimized */
9466 for (i = rcd->eager_base; i < rcd->eager_base +
9467 rcd->egrbufs.alloced; i++)
9468 hfi1_put_tid(dd, i, PT_INVALID, 0, 0);
9470 for (i = rcd->expected_base;
9471 i < rcd->expected_base + rcd->expected_count; i++)
9472 hfi1_put_tid(dd, i, PT_INVALID, 0, 0);
9475 int hfi1_get_base_kinfo(struct hfi1_ctxtdata *rcd,
9476 struct hfi1_ctxt_info *kinfo)
9478 kinfo->runtime_flags = (HFI1_MISC_GET() << HFI1_CAP_USER_SHIFT) |
9479 HFI1_CAP_UGET(MASK) | HFI1_CAP_KGET(K2U);
9483 struct hfi1_message_header *hfi1_get_msgheader(
9484 struct hfi1_devdata *dd, __le32 *rhf_addr)
9486 u32 offset = rhf_hdrq_offset(rhf_to_cpu(rhf_addr));
9488 return (struct hfi1_message_header *)
9489 (rhf_addr - dd->rhf_offset + offset);
9492 static const char * const ib_cfg_name_strings[] = {
9493 "HFI1_IB_CFG_LIDLMC",
9494 "HFI1_IB_CFG_LWID_DG_ENB",
9495 "HFI1_IB_CFG_LWID_ENB",
9497 "HFI1_IB_CFG_SPD_ENB",
9499 "HFI1_IB_CFG_RXPOL_ENB",
9500 "HFI1_IB_CFG_LREV_ENB",
9501 "HFI1_IB_CFG_LINKLATENCY",
9502 "HFI1_IB_CFG_HRTBT",
9503 "HFI1_IB_CFG_OP_VLS",
9504 "HFI1_IB_CFG_VL_HIGH_CAP",
9505 "HFI1_IB_CFG_VL_LOW_CAP",
9506 "HFI1_IB_CFG_OVERRUN_THRESH",
9507 "HFI1_IB_CFG_PHYERR_THRESH",
9508 "HFI1_IB_CFG_LINKDEFAULT",
9509 "HFI1_IB_CFG_PKEYS",
9511 "HFI1_IB_CFG_LSTATE",
9512 "HFI1_IB_CFG_VL_HIGH_LIMIT",
9513 "HFI1_IB_CFG_PMA_TICKS",
9517 static const char *ib_cfg_name(int which)
9519 if (which < 0 || which >= ARRAY_SIZE(ib_cfg_name_strings))
9521 return ib_cfg_name_strings[which];
9524 int hfi1_get_ib_cfg(struct hfi1_pportdata *ppd, int which)
9526 struct hfi1_devdata *dd = ppd->dd;
9530 case HFI1_IB_CFG_LWID_ENB: /* allowed Link-width */
9531 val = ppd->link_width_enabled;
9533 case HFI1_IB_CFG_LWID: /* currently active Link-width */
9534 val = ppd->link_width_active;
9536 case HFI1_IB_CFG_SPD_ENB: /* allowed Link speeds */
9537 val = ppd->link_speed_enabled;
9539 case HFI1_IB_CFG_SPD: /* current Link speed */
9540 val = ppd->link_speed_active;
9543 case HFI1_IB_CFG_RXPOL_ENB: /* Auto-RX-polarity enable */
9544 case HFI1_IB_CFG_LREV_ENB: /* Auto-Lane-reversal enable */
9545 case HFI1_IB_CFG_LINKLATENCY:
9548 case HFI1_IB_CFG_OP_VLS:
9549 val = ppd->vls_operational;
9551 case HFI1_IB_CFG_VL_HIGH_CAP: /* VL arb high priority table size */
9552 val = VL_ARB_HIGH_PRIO_TABLE_SIZE;
9554 case HFI1_IB_CFG_VL_LOW_CAP: /* VL arb low priority table size */
9555 val = VL_ARB_LOW_PRIO_TABLE_SIZE;
9557 case HFI1_IB_CFG_OVERRUN_THRESH: /* IB overrun threshold */
9558 val = ppd->overrun_threshold;
9560 case HFI1_IB_CFG_PHYERR_THRESH: /* IB PHY error threshold */
9561 val = ppd->phy_error_threshold;
9563 case HFI1_IB_CFG_LINKDEFAULT: /* IB link default (sleep/poll) */
9564 val = dd->link_default;
9567 case HFI1_IB_CFG_HRTBT: /* Heartbeat off/enable/auto */
9568 case HFI1_IB_CFG_PMA_TICKS:
9571 if (HFI1_CAP_IS_KSET(PRINT_UNIMPL))
9574 "%s: which %s: not implemented\n",
9576 ib_cfg_name(which));
9584 * The largest MAD packet size.
9586 #define MAX_MAD_PACKET 2048
9589 * Return the maximum header bytes that can go on the _wire_
9590 * for this device. This count includes the ICRC which is
9591 * not part of the packet held in memory but it is appended
9593 * This is dependent on the device's receive header entry size.
9594 * HFI allows this to be set per-receive context, but the
9595 * driver presently enforces a global value.
9597 u32 lrh_max_header_bytes(struct hfi1_devdata *dd)
9600 * The maximum non-payload (MTU) bytes in LRH.PktLen are
9601 * the Receive Header Entry Size minus the PBC (or RHF) size
9602 * plus one DW for the ICRC appended by HW.
9604 * dd->rcd[0].rcvhdrqentsize is in DW.
9605 * We use rcd[0] as all context will have the same value. Also,
9606 * the first kernel context would have been allocated by now so
9607 * we are guaranteed a valid value.
9609 return (dd->rcd[0]->rcvhdrqentsize - 2/*PBC/RHF*/ + 1/*ICRC*/) << 2;
9614 * @ppd - per port data
9616 * Set the MTU by limiting how many DWs may be sent. The SendLenCheck*
9617 * registers compare against LRH.PktLen, so use the max bytes included
9620 * This routine changes all VL values except VL15, which it maintains at
9623 static void set_send_length(struct hfi1_pportdata *ppd)
9625 struct hfi1_devdata *dd = ppd->dd;
9626 u32 max_hb = lrh_max_header_bytes(dd), dcmtu;
9627 u32 maxvlmtu = dd->vld[15].mtu;
9628 u64 len1 = 0, len2 = (((dd->vld[15].mtu + max_hb) >> 2)
9629 & SEND_LEN_CHECK1_LEN_VL15_MASK) <<
9630 SEND_LEN_CHECK1_LEN_VL15_SHIFT;
9634 for (i = 0; i < ppd->vls_supported; i++) {
9635 if (dd->vld[i].mtu > maxvlmtu)
9636 maxvlmtu = dd->vld[i].mtu;
9638 len1 |= (((dd->vld[i].mtu + max_hb) >> 2)
9639 & SEND_LEN_CHECK0_LEN_VL0_MASK) <<
9640 ((i % 4) * SEND_LEN_CHECK0_LEN_VL1_SHIFT);
9642 len2 |= (((dd->vld[i].mtu + max_hb) >> 2)
9643 & SEND_LEN_CHECK1_LEN_VL4_MASK) <<
9644 ((i % 4) * SEND_LEN_CHECK1_LEN_VL5_SHIFT);
9646 write_csr(dd, SEND_LEN_CHECK0, len1);
9647 write_csr(dd, SEND_LEN_CHECK1, len2);
9648 /* adjust kernel credit return thresholds based on new MTUs */
9649 /* all kernel receive contexts have the same hdrqentsize */
9650 for (i = 0; i < ppd->vls_supported; i++) {
9651 thres = min(sc_percent_to_threshold(dd->vld[i].sc, 50),
9652 sc_mtu_to_threshold(dd->vld[i].sc,
9654 dd->rcd[0]->rcvhdrqentsize));
9655 sc_set_cr_threshold(dd->vld[i].sc, thres);
9657 thres = min(sc_percent_to_threshold(dd->vld[15].sc, 50),
9658 sc_mtu_to_threshold(dd->vld[15].sc,
9660 dd->rcd[0]->rcvhdrqentsize));
9661 sc_set_cr_threshold(dd->vld[15].sc, thres);
9663 /* Adjust maximum MTU for the port in DC */
9664 dcmtu = maxvlmtu == 10240 ? DCC_CFG_PORT_MTU_CAP_10240 :
9665 (ilog2(maxvlmtu >> 8) + 1);
9666 len1 = read_csr(ppd->dd, DCC_CFG_PORT_CONFIG);
9667 len1 &= ~DCC_CFG_PORT_CONFIG_MTU_CAP_SMASK;
9668 len1 |= ((u64)dcmtu & DCC_CFG_PORT_CONFIG_MTU_CAP_MASK) <<
9669 DCC_CFG_PORT_CONFIG_MTU_CAP_SHIFT;
9670 write_csr(ppd->dd, DCC_CFG_PORT_CONFIG, len1);
9673 static void set_lidlmc(struct hfi1_pportdata *ppd)
9677 struct hfi1_devdata *dd = ppd->dd;
9678 u32 mask = ~((1U << ppd->lmc) - 1);
9679 u64 c1 = read_csr(ppd->dd, DCC_CFG_PORT_CONFIG1);
9681 if (dd->hfi1_snoop.mode_flag)
9682 dd_dev_info(dd, "Set lid/lmc while snooping");
9684 c1 &= ~(DCC_CFG_PORT_CONFIG1_TARGET_DLID_SMASK
9685 | DCC_CFG_PORT_CONFIG1_DLID_MASK_SMASK);
9686 c1 |= ((ppd->lid & DCC_CFG_PORT_CONFIG1_TARGET_DLID_MASK)
9687 << DCC_CFG_PORT_CONFIG1_TARGET_DLID_SHIFT) |
9688 ((mask & DCC_CFG_PORT_CONFIG1_DLID_MASK_MASK)
9689 << DCC_CFG_PORT_CONFIG1_DLID_MASK_SHIFT);
9690 write_csr(ppd->dd, DCC_CFG_PORT_CONFIG1, c1);
9693 * Iterate over all the send contexts and set their SLID check
9695 sreg = ((mask & SEND_CTXT_CHECK_SLID_MASK_MASK) <<
9696 SEND_CTXT_CHECK_SLID_MASK_SHIFT) |
9697 (((ppd->lid & mask) & SEND_CTXT_CHECK_SLID_VALUE_MASK) <<
9698 SEND_CTXT_CHECK_SLID_VALUE_SHIFT);
9700 for (i = 0; i < dd->chip_send_contexts; i++) {
9701 hfi1_cdbg(LINKVERB, "SendContext[%d].SLID_CHECK = 0x%x",
9703 write_kctxt_csr(dd, i, SEND_CTXT_CHECK_SLID, sreg);
9706 /* Now we have to do the same thing for the sdma engines */
9707 sdma_update_lmc(dd, mask, ppd->lid);
9710 static int wait_phy_linkstate(struct hfi1_devdata *dd, u32 state, u32 msecs)
9712 unsigned long timeout;
9715 timeout = jiffies + msecs_to_jiffies(msecs);
9717 curr_state = read_physical_state(dd);
9718 if (curr_state == state)
9720 if (time_after(jiffies, timeout)) {
9722 "timeout waiting for phy link state 0x%x, current state is 0x%x\n",
9726 usleep_range(1950, 2050); /* sleep 2ms-ish */
9733 * Helper for set_link_state(). Do not call except from that routine.
9734 * Expects ppd->hls_mutex to be held.
9736 * @rem_reason value to be sent to the neighbor
9738 * LinkDownReasons only set if transition succeeds.
9740 static int goto_offline(struct hfi1_pportdata *ppd, u8 rem_reason)
9742 struct hfi1_devdata *dd = ppd->dd;
9743 u32 pstate, previous_state;
9744 u32 last_local_state;
9745 u32 last_remote_state;
9750 previous_state = ppd->host_link_state;
9751 ppd->host_link_state = HLS_GOING_OFFLINE;
9752 pstate = read_physical_state(dd);
9753 if (pstate == PLS_OFFLINE) {
9754 do_transition = 0; /* in right state */
9755 do_wait = 0; /* ...no need to wait */
9756 } else if ((pstate & 0xff) == PLS_OFFLINE) {
9757 do_transition = 0; /* in an offline transient state */
9758 do_wait = 1; /* ...wait for it to settle */
9760 do_transition = 1; /* need to move to offline */
9761 do_wait = 1; /* ...will need to wait */
9764 if (do_transition) {
9765 ret = set_physical_link_state(dd,
9766 (rem_reason << 8) | PLS_OFFLINE);
9768 if (ret != HCMD_SUCCESS) {
9770 "Failed to transition to Offline link state, return %d\n",
9774 if (ppd->offline_disabled_reason ==
9775 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_NONE))
9776 ppd->offline_disabled_reason =
9777 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_TRANSIENT);
9781 /* it can take a while for the link to go down */
9782 ret = wait_phy_linkstate(dd, PLS_OFFLINE, 10000);
9787 /* make sure the logical state is also down */
9788 wait_logical_linkstate(ppd, IB_PORT_DOWN, 1000);
9791 * Now in charge of LCB - must be after the physical state is
9792 * offline.quiet and before host_link_state is changed.
9794 set_host_lcb_access(dd);
9795 write_csr(dd, DC_LCB_ERR_EN, ~0ull); /* watch LCB errors */
9796 ppd->host_link_state = HLS_LINK_COOLDOWN; /* LCB access allowed */
9798 if (ppd->port_type == PORT_TYPE_QSFP &&
9799 ppd->qsfp_info.limiting_active &&
9800 qsfp_mod_present(ppd)) {
9803 ret = acquire_chip_resource(dd, qsfp_resource(dd), QSFP_WAIT);
9805 set_qsfp_tx(ppd, 0);
9806 release_chip_resource(dd, qsfp_resource(dd));
9808 /* not fatal, but should warn */
9810 "Unable to acquire lock to turn off QSFP TX\n");
9815 * The LNI has a mandatory wait time after the physical state
9816 * moves to Offline.Quiet. The wait time may be different
9817 * depending on how the link went down. The 8051 firmware
9818 * will observe the needed wait time and only move to ready
9819 * when that is completed. The largest of the quiet timeouts
9820 * is 6s, so wait that long and then at least 0.5s more for
9821 * other transitions, and another 0.5s for a buffer.
9823 ret = wait_fm_ready(dd, 7000);
9826 "After going offline, timed out waiting for the 8051 to become ready to accept host requests\n");
9827 /* state is really offline, so make it so */
9828 ppd->host_link_state = HLS_DN_OFFLINE;
9833 * The state is now offline and the 8051 is ready to accept host
9835 * - change our state
9836 * - notify others if we were previously in a linkup state
9838 ppd->host_link_state = HLS_DN_OFFLINE;
9839 if (previous_state & HLS_UP) {
9840 /* went down while link was up */
9841 handle_linkup_change(dd, 0);
9842 } else if (previous_state
9843 & (HLS_DN_POLL | HLS_VERIFY_CAP | HLS_GOING_UP)) {
9844 /* went down while attempting link up */
9845 /* byte 1 of last_*_state is the failure reason */
9846 read_last_local_state(dd, &last_local_state);
9847 read_last_remote_state(dd, &last_remote_state);
9849 "LNI failure last states: local 0x%08x, remote 0x%08x\n",
9850 last_local_state, last_remote_state);
9853 /* the active link width (downgrade) is 0 on link down */
9854 ppd->link_width_active = 0;
9855 ppd->link_width_downgrade_tx_active = 0;
9856 ppd->link_width_downgrade_rx_active = 0;
9857 ppd->current_egress_rate = 0;
9861 /* return the link state name */
9862 static const char *link_state_name(u32 state)
9865 int n = ilog2(state);
9866 static const char * const names[] = {
9867 [__HLS_UP_INIT_BP] = "INIT",
9868 [__HLS_UP_ARMED_BP] = "ARMED",
9869 [__HLS_UP_ACTIVE_BP] = "ACTIVE",
9870 [__HLS_DN_DOWNDEF_BP] = "DOWNDEF",
9871 [__HLS_DN_POLL_BP] = "POLL",
9872 [__HLS_DN_DISABLE_BP] = "DISABLE",
9873 [__HLS_DN_OFFLINE_BP] = "OFFLINE",
9874 [__HLS_VERIFY_CAP_BP] = "VERIFY_CAP",
9875 [__HLS_GOING_UP_BP] = "GOING_UP",
9876 [__HLS_GOING_OFFLINE_BP] = "GOING_OFFLINE",
9877 [__HLS_LINK_COOLDOWN_BP] = "LINK_COOLDOWN"
9880 name = n < ARRAY_SIZE(names) ? names[n] : NULL;
9881 return name ? name : "unknown";
9884 /* return the link state reason name */
9885 static const char *link_state_reason_name(struct hfi1_pportdata *ppd, u32 state)
9887 if (state == HLS_UP_INIT) {
9888 switch (ppd->linkinit_reason) {
9889 case OPA_LINKINIT_REASON_LINKUP:
9891 case OPA_LINKINIT_REASON_FLAPPING:
9892 return "(FLAPPING)";
9893 case OPA_LINKINIT_OUTSIDE_POLICY:
9894 return "(OUTSIDE_POLICY)";
9895 case OPA_LINKINIT_QUARANTINED:
9896 return "(QUARANTINED)";
9897 case OPA_LINKINIT_INSUFIC_CAPABILITY:
9898 return "(INSUFIC_CAPABILITY)";
9907 * driver_physical_state - convert the driver's notion of a port's
9908 * state (an HLS_*) into a physical state (a {IB,OPA}_PORTPHYSSTATE_*).
9909 * Return -1 (converted to a u32) to indicate error.
9911 u32 driver_physical_state(struct hfi1_pportdata *ppd)
9913 switch (ppd->host_link_state) {
9917 return IB_PORTPHYSSTATE_LINKUP;
9919 return IB_PORTPHYSSTATE_POLLING;
9920 case HLS_DN_DISABLE:
9921 return IB_PORTPHYSSTATE_DISABLED;
9922 case HLS_DN_OFFLINE:
9923 return OPA_PORTPHYSSTATE_OFFLINE;
9924 case HLS_VERIFY_CAP:
9925 return IB_PORTPHYSSTATE_POLLING;
9927 return IB_PORTPHYSSTATE_POLLING;
9928 case HLS_GOING_OFFLINE:
9929 return OPA_PORTPHYSSTATE_OFFLINE;
9930 case HLS_LINK_COOLDOWN:
9931 return OPA_PORTPHYSSTATE_OFFLINE;
9932 case HLS_DN_DOWNDEF:
9934 dd_dev_err(ppd->dd, "invalid host_link_state 0x%x\n",
9935 ppd->host_link_state);
9941 * driver_logical_state - convert the driver's notion of a port's
9942 * state (an HLS_*) into a logical state (a IB_PORT_*). Return -1
9943 * (converted to a u32) to indicate error.
9945 u32 driver_logical_state(struct hfi1_pportdata *ppd)
9947 if (ppd->host_link_state && !(ppd->host_link_state & HLS_UP))
9948 return IB_PORT_DOWN;
9950 switch (ppd->host_link_state & HLS_UP) {
9952 return IB_PORT_INIT;
9954 return IB_PORT_ARMED;
9956 return IB_PORT_ACTIVE;
9958 dd_dev_err(ppd->dd, "invalid host_link_state 0x%x\n",
9959 ppd->host_link_state);
9964 void set_link_down_reason(struct hfi1_pportdata *ppd, u8 lcl_reason,
9965 u8 neigh_reason, u8 rem_reason)
9967 if (ppd->local_link_down_reason.latest == 0 &&
9968 ppd->neigh_link_down_reason.latest == 0) {
9969 ppd->local_link_down_reason.latest = lcl_reason;
9970 ppd->neigh_link_down_reason.latest = neigh_reason;
9971 ppd->remote_link_down_reason = rem_reason;
9976 * Change the physical and/or logical link state.
9978 * Do not call this routine while inside an interrupt. It contains
9979 * calls to routines that can take multiple seconds to finish.
9981 * Returns 0 on success, -errno on failure.
9983 int set_link_state(struct hfi1_pportdata *ppd, u32 state)
9985 struct hfi1_devdata *dd = ppd->dd;
9986 struct ib_event event = {.device = NULL};
9988 int was_up, is_down;
9989 int orig_new_state, poll_bounce;
9991 mutex_lock(&ppd->hls_lock);
9993 orig_new_state = state;
9994 if (state == HLS_DN_DOWNDEF)
9995 state = dd->link_default;
9997 /* interpret poll -> poll as a link bounce */
9998 poll_bounce = ppd->host_link_state == HLS_DN_POLL &&
9999 state == HLS_DN_POLL;
10001 dd_dev_info(dd, "%s: current %s, new %s %s%s\n", __func__,
10002 link_state_name(ppd->host_link_state),
10003 link_state_name(orig_new_state),
10004 poll_bounce ? "(bounce) " : "",
10005 link_state_reason_name(ppd, state));
10007 was_up = !!(ppd->host_link_state & HLS_UP);
10010 * If we're going to a (HLS_*) link state that implies the logical
10011 * link state is neither of (IB_PORT_ARMED, IB_PORT_ACTIVE), then
10012 * reset is_sm_config_started to 0.
10014 if (!(state & (HLS_UP_ARMED | HLS_UP_ACTIVE)))
10015 ppd->is_sm_config_started = 0;
10018 * Do nothing if the states match. Let a poll to poll link bounce
10021 if (ppd->host_link_state == state && !poll_bounce)
10026 if (ppd->host_link_state == HLS_DN_POLL &&
10027 (quick_linkup || dd->icode == ICODE_FUNCTIONAL_SIMULATOR)) {
10029 * Quick link up jumps from polling to here.
10031 * Whether in normal or loopback mode, the
10032 * simulator jumps from polling to link up.
10033 * Accept that here.
10036 } else if (ppd->host_link_state != HLS_GOING_UP) {
10040 ppd->host_link_state = HLS_UP_INIT;
10041 ret = wait_logical_linkstate(ppd, IB_PORT_INIT, 1000);
10043 /* logical state didn't change, stay at going_up */
10044 ppd->host_link_state = HLS_GOING_UP;
10046 "%s: logical state did not change to INIT\n",
10049 /* clear old transient LINKINIT_REASON code */
10050 if (ppd->linkinit_reason >= OPA_LINKINIT_REASON_CLEAR)
10051 ppd->linkinit_reason =
10052 OPA_LINKINIT_REASON_LINKUP;
10054 /* enable the port */
10055 add_rcvctrl(dd, RCV_CTRL_RCV_PORT_ENABLE_SMASK);
10057 handle_linkup_change(dd, 1);
10061 if (ppd->host_link_state != HLS_UP_INIT)
10064 ppd->host_link_state = HLS_UP_ARMED;
10065 set_logical_state(dd, LSTATE_ARMED);
10066 ret = wait_logical_linkstate(ppd, IB_PORT_ARMED, 1000);
10068 /* logical state didn't change, stay at init */
10069 ppd->host_link_state = HLS_UP_INIT;
10071 "%s: logical state did not change to ARMED\n",
10075 * The simulator does not currently implement SMA messages,
10076 * so neighbor_normal is not set. Set it here when we first
10079 if (dd->icode == ICODE_FUNCTIONAL_SIMULATOR)
10080 ppd->neighbor_normal = 1;
10082 case HLS_UP_ACTIVE:
10083 if (ppd->host_link_state != HLS_UP_ARMED)
10086 ppd->host_link_state = HLS_UP_ACTIVE;
10087 set_logical_state(dd, LSTATE_ACTIVE);
10088 ret = wait_logical_linkstate(ppd, IB_PORT_ACTIVE, 1000);
10090 /* logical state didn't change, stay at armed */
10091 ppd->host_link_state = HLS_UP_ARMED;
10093 "%s: logical state did not change to ACTIVE\n",
10096 /* tell all engines to go running */
10097 sdma_all_running(dd);
10099 /* Signal the IB layer that the port has went active */
10100 event.device = &dd->verbs_dev.rdi.ibdev;
10101 event.element.port_num = ppd->port;
10102 event.event = IB_EVENT_PORT_ACTIVE;
10106 if ((ppd->host_link_state == HLS_DN_DISABLE ||
10107 ppd->host_link_state == HLS_DN_OFFLINE) &&
10110 /* Hand LED control to the DC */
10111 write_csr(dd, DCC_CFG_LED_CNTRL, 0);
10113 if (ppd->host_link_state != HLS_DN_OFFLINE) {
10114 u8 tmp = ppd->link_enabled;
10116 ret = goto_offline(ppd, ppd->remote_link_down_reason);
10118 ppd->link_enabled = tmp;
10121 ppd->remote_link_down_reason = 0;
10123 if (ppd->driver_link_ready)
10124 ppd->link_enabled = 1;
10127 set_all_slowpath(ppd->dd);
10128 ret = set_local_link_attributes(ppd);
10132 ppd->port_error_action = 0;
10133 ppd->host_link_state = HLS_DN_POLL;
10135 if (quick_linkup) {
10136 /* quick linkup does not go into polling */
10137 ret = do_quick_linkup(dd);
10139 ret1 = set_physical_link_state(dd, PLS_POLLING);
10140 if (ret1 != HCMD_SUCCESS) {
10142 "Failed to transition to Polling link state, return 0x%x\n",
10147 ppd->offline_disabled_reason =
10148 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_NONE);
10150 * If an error occurred above, go back to offline. The
10151 * caller may reschedule another attempt.
10154 goto_offline(ppd, 0);
10156 case HLS_DN_DISABLE:
10157 /* link is disabled */
10158 ppd->link_enabled = 0;
10160 /* allow any state to transition to disabled */
10162 /* must transition to offline first */
10163 if (ppd->host_link_state != HLS_DN_OFFLINE) {
10164 ret = goto_offline(ppd, ppd->remote_link_down_reason);
10167 ppd->remote_link_down_reason = 0;
10170 ret1 = set_physical_link_state(dd, PLS_DISABLED);
10171 if (ret1 != HCMD_SUCCESS) {
10173 "Failed to transition to Disabled link state, return 0x%x\n",
10178 ppd->host_link_state = HLS_DN_DISABLE;
10181 case HLS_DN_OFFLINE:
10182 if (ppd->host_link_state == HLS_DN_DISABLE)
10185 /* allow any state to transition to offline */
10186 ret = goto_offline(ppd, ppd->remote_link_down_reason);
10188 ppd->remote_link_down_reason = 0;
10190 case HLS_VERIFY_CAP:
10191 if (ppd->host_link_state != HLS_DN_POLL)
10193 ppd->host_link_state = HLS_VERIFY_CAP;
10196 if (ppd->host_link_state != HLS_VERIFY_CAP)
10199 ret1 = set_physical_link_state(dd, PLS_LINKUP);
10200 if (ret1 != HCMD_SUCCESS) {
10202 "Failed to transition to link up state, return 0x%x\n",
10207 ppd->host_link_state = HLS_GOING_UP;
10210 case HLS_GOING_OFFLINE: /* transient within goto_offline() */
10211 case HLS_LINK_COOLDOWN: /* transient within goto_offline() */
10213 dd_dev_info(dd, "%s: state 0x%x: not supported\n",
10219 is_down = !!(ppd->host_link_state & (HLS_DN_POLL |
10220 HLS_DN_DISABLE | HLS_DN_OFFLINE));
10222 if (was_up && is_down && ppd->local_link_down_reason.sma == 0 &&
10223 ppd->neigh_link_down_reason.sma == 0) {
10224 ppd->local_link_down_reason.sma =
10225 ppd->local_link_down_reason.latest;
10226 ppd->neigh_link_down_reason.sma =
10227 ppd->neigh_link_down_reason.latest;
10233 dd_dev_err(dd, "%s: unexpected state transition from %s to %s\n",
10234 __func__, link_state_name(ppd->host_link_state),
10235 link_state_name(state));
10239 mutex_unlock(&ppd->hls_lock);
10242 ib_dispatch_event(&event);
10247 int hfi1_set_ib_cfg(struct hfi1_pportdata *ppd, int which, u32 val)
10253 case HFI1_IB_CFG_LIDLMC:
10256 case HFI1_IB_CFG_VL_HIGH_LIMIT:
10258 * The VL Arbitrator high limit is sent in units of 4k
10259 * bytes, while HFI stores it in units of 64 bytes.
10262 reg = ((u64)val & SEND_HIGH_PRIORITY_LIMIT_LIMIT_MASK)
10263 << SEND_HIGH_PRIORITY_LIMIT_LIMIT_SHIFT;
10264 write_csr(ppd->dd, SEND_HIGH_PRIORITY_LIMIT, reg);
10266 case HFI1_IB_CFG_LINKDEFAULT: /* IB link default (sleep/poll) */
10267 /* HFI only supports POLL as the default link down state */
10268 if (val != HLS_DN_POLL)
10271 case HFI1_IB_CFG_OP_VLS:
10272 if (ppd->vls_operational != val) {
10273 ppd->vls_operational = val;
10279 * For link width, link width downgrade, and speed enable, always AND
10280 * the setting with what is actually supported. This has two benefits.
10281 * First, enabled can't have unsupported values, no matter what the
10282 * SM or FM might want. Second, the ALL_SUPPORTED wildcards that mean
10283 * "fill in with your supported value" have all the bits in the
10284 * field set, so simply ANDing with supported has the desired result.
10286 case HFI1_IB_CFG_LWID_ENB: /* set allowed Link-width */
10287 ppd->link_width_enabled = val & ppd->link_width_supported;
10289 case HFI1_IB_CFG_LWID_DG_ENB: /* set allowed link width downgrade */
10290 ppd->link_width_downgrade_enabled =
10291 val & ppd->link_width_downgrade_supported;
10293 case HFI1_IB_CFG_SPD_ENB: /* allowed Link speeds */
10294 ppd->link_speed_enabled = val & ppd->link_speed_supported;
10296 case HFI1_IB_CFG_OVERRUN_THRESH: /* IB overrun threshold */
10298 * HFI does not follow IB specs, save this value
10299 * so we can report it, if asked.
10301 ppd->overrun_threshold = val;
10303 case HFI1_IB_CFG_PHYERR_THRESH: /* IB PHY error threshold */
10305 * HFI does not follow IB specs, save this value
10306 * so we can report it, if asked.
10308 ppd->phy_error_threshold = val;
10311 case HFI1_IB_CFG_MTU:
10312 set_send_length(ppd);
10315 case HFI1_IB_CFG_PKEYS:
10316 if (HFI1_CAP_IS_KSET(PKEY_CHECK))
10317 set_partition_keys(ppd);
10321 if (HFI1_CAP_IS_KSET(PRINT_UNIMPL))
10322 dd_dev_info(ppd->dd,
10323 "%s: which %s, val 0x%x: not implemented\n",
10324 __func__, ib_cfg_name(which), val);
10330 /* begin functions related to vl arbitration table caching */
10331 static void init_vl_arb_caches(struct hfi1_pportdata *ppd)
10335 BUILD_BUG_ON(VL_ARB_TABLE_SIZE !=
10336 VL_ARB_LOW_PRIO_TABLE_SIZE);
10337 BUILD_BUG_ON(VL_ARB_TABLE_SIZE !=
10338 VL_ARB_HIGH_PRIO_TABLE_SIZE);
10341 * Note that we always return values directly from the
10342 * 'vl_arb_cache' (and do no CSR reads) in response to a
10343 * 'Get(VLArbTable)'. This is obviously correct after a
10344 * 'Set(VLArbTable)', since the cache will then be up to
10345 * date. But it's also correct prior to any 'Set(VLArbTable)'
10346 * since then both the cache, and the relevant h/w registers
10350 for (i = 0; i < MAX_PRIO_TABLE; i++)
10351 spin_lock_init(&ppd->vl_arb_cache[i].lock);
10355 * vl_arb_lock_cache
10357 * All other vl_arb_* functions should be called only after locking
10360 static inline struct vl_arb_cache *
10361 vl_arb_lock_cache(struct hfi1_pportdata *ppd, int idx)
10363 if (idx != LO_PRIO_TABLE && idx != HI_PRIO_TABLE)
10365 spin_lock(&ppd->vl_arb_cache[idx].lock);
10366 return &ppd->vl_arb_cache[idx];
10369 static inline void vl_arb_unlock_cache(struct hfi1_pportdata *ppd, int idx)
10371 spin_unlock(&ppd->vl_arb_cache[idx].lock);
10374 static void vl_arb_get_cache(struct vl_arb_cache *cache,
10375 struct ib_vl_weight_elem *vl)
10377 memcpy(vl, cache->table, VL_ARB_TABLE_SIZE * sizeof(*vl));
10380 static void vl_arb_set_cache(struct vl_arb_cache *cache,
10381 struct ib_vl_weight_elem *vl)
10383 memcpy(cache->table, vl, VL_ARB_TABLE_SIZE * sizeof(*vl));
10386 static int vl_arb_match_cache(struct vl_arb_cache *cache,
10387 struct ib_vl_weight_elem *vl)
10389 return !memcmp(cache->table, vl, VL_ARB_TABLE_SIZE * sizeof(*vl));
10392 /* end functions related to vl arbitration table caching */
10394 static int set_vl_weights(struct hfi1_pportdata *ppd, u32 target,
10395 u32 size, struct ib_vl_weight_elem *vl)
10397 struct hfi1_devdata *dd = ppd->dd;
10399 unsigned int i, is_up = 0;
10400 int drain, ret = 0;
10402 mutex_lock(&ppd->hls_lock);
10404 if (ppd->host_link_state & HLS_UP)
10407 drain = !is_ax(dd) && is_up;
10411 * Before adjusting VL arbitration weights, empty per-VL
10412 * FIFOs, otherwise a packet whose VL weight is being
10413 * set to 0 could get stuck in a FIFO with no chance to
10416 ret = stop_drain_data_vls(dd);
10421 "%s: cannot stop/drain VLs - refusing to change VL arbitration weights\n",
10426 for (i = 0; i < size; i++, vl++) {
10428 * NOTE: The low priority shift and mask are used here, but
10429 * they are the same for both the low and high registers.
10431 reg = (((u64)vl->vl & SEND_LOW_PRIORITY_LIST_VL_MASK)
10432 << SEND_LOW_PRIORITY_LIST_VL_SHIFT)
10433 | (((u64)vl->weight
10434 & SEND_LOW_PRIORITY_LIST_WEIGHT_MASK)
10435 << SEND_LOW_PRIORITY_LIST_WEIGHT_SHIFT);
10436 write_csr(dd, target + (i * 8), reg);
10438 pio_send_control(dd, PSC_GLOBAL_VLARB_ENABLE);
10441 open_fill_data_vls(dd); /* reopen all VLs */
10444 mutex_unlock(&ppd->hls_lock);
10450 * Read one credit merge VL register.
10452 static void read_one_cm_vl(struct hfi1_devdata *dd, u32 csr,
10453 struct vl_limit *vll)
10455 u64 reg = read_csr(dd, csr);
10457 vll->dedicated = cpu_to_be16(
10458 (reg >> SEND_CM_CREDIT_VL_DEDICATED_LIMIT_VL_SHIFT)
10459 & SEND_CM_CREDIT_VL_DEDICATED_LIMIT_VL_MASK);
10460 vll->shared = cpu_to_be16(
10461 (reg >> SEND_CM_CREDIT_VL_SHARED_LIMIT_VL_SHIFT)
10462 & SEND_CM_CREDIT_VL_SHARED_LIMIT_VL_MASK);
10466 * Read the current credit merge limits.
10468 static int get_buffer_control(struct hfi1_devdata *dd,
10469 struct buffer_control *bc, u16 *overall_limit)
10474 /* not all entries are filled in */
10475 memset(bc, 0, sizeof(*bc));
10477 /* OPA and HFI have a 1-1 mapping */
10478 for (i = 0; i < TXE_NUM_DATA_VL; i++)
10479 read_one_cm_vl(dd, SEND_CM_CREDIT_VL + (8 * i), &bc->vl[i]);
10481 /* NOTE: assumes that VL* and VL15 CSRs are bit-wise identical */
10482 read_one_cm_vl(dd, SEND_CM_CREDIT_VL15, &bc->vl[15]);
10484 reg = read_csr(dd, SEND_CM_GLOBAL_CREDIT);
10485 bc->overall_shared_limit = cpu_to_be16(
10486 (reg >> SEND_CM_GLOBAL_CREDIT_SHARED_LIMIT_SHIFT)
10487 & SEND_CM_GLOBAL_CREDIT_SHARED_LIMIT_MASK);
10489 *overall_limit = (reg
10490 >> SEND_CM_GLOBAL_CREDIT_TOTAL_CREDIT_LIMIT_SHIFT)
10491 & SEND_CM_GLOBAL_CREDIT_TOTAL_CREDIT_LIMIT_MASK;
10492 return sizeof(struct buffer_control);
10495 static int get_sc2vlnt(struct hfi1_devdata *dd, struct sc2vlnt *dp)
10500 /* each register contains 16 SC->VLnt mappings, 4 bits each */
10501 reg = read_csr(dd, DCC_CFG_SC_VL_TABLE_15_0);
10502 for (i = 0; i < sizeof(u64); i++) {
10503 u8 byte = *(((u8 *)®) + i);
10505 dp->vlnt[2 * i] = byte & 0xf;
10506 dp->vlnt[(2 * i) + 1] = (byte & 0xf0) >> 4;
10509 reg = read_csr(dd, DCC_CFG_SC_VL_TABLE_31_16);
10510 for (i = 0; i < sizeof(u64); i++) {
10511 u8 byte = *(((u8 *)®) + i);
10513 dp->vlnt[16 + (2 * i)] = byte & 0xf;
10514 dp->vlnt[16 + (2 * i) + 1] = (byte & 0xf0) >> 4;
10516 return sizeof(struct sc2vlnt);
10519 static void get_vlarb_preempt(struct hfi1_devdata *dd, u32 nelems,
10520 struct ib_vl_weight_elem *vl)
10524 for (i = 0; i < nelems; i++, vl++) {
10530 static void set_sc2vlnt(struct hfi1_devdata *dd, struct sc2vlnt *dp)
10532 write_csr(dd, DCC_CFG_SC_VL_TABLE_15_0,
10534 0, dp->vlnt[0] & 0xf,
10535 1, dp->vlnt[1] & 0xf,
10536 2, dp->vlnt[2] & 0xf,
10537 3, dp->vlnt[3] & 0xf,
10538 4, dp->vlnt[4] & 0xf,
10539 5, dp->vlnt[5] & 0xf,
10540 6, dp->vlnt[6] & 0xf,
10541 7, dp->vlnt[7] & 0xf,
10542 8, dp->vlnt[8] & 0xf,
10543 9, dp->vlnt[9] & 0xf,
10544 10, dp->vlnt[10] & 0xf,
10545 11, dp->vlnt[11] & 0xf,
10546 12, dp->vlnt[12] & 0xf,
10547 13, dp->vlnt[13] & 0xf,
10548 14, dp->vlnt[14] & 0xf,
10549 15, dp->vlnt[15] & 0xf));
10550 write_csr(dd, DCC_CFG_SC_VL_TABLE_31_16,
10551 DC_SC_VL_VAL(31_16,
10552 16, dp->vlnt[16] & 0xf,
10553 17, dp->vlnt[17] & 0xf,
10554 18, dp->vlnt[18] & 0xf,
10555 19, dp->vlnt[19] & 0xf,
10556 20, dp->vlnt[20] & 0xf,
10557 21, dp->vlnt[21] & 0xf,
10558 22, dp->vlnt[22] & 0xf,
10559 23, dp->vlnt[23] & 0xf,
10560 24, dp->vlnt[24] & 0xf,
10561 25, dp->vlnt[25] & 0xf,
10562 26, dp->vlnt[26] & 0xf,
10563 27, dp->vlnt[27] & 0xf,
10564 28, dp->vlnt[28] & 0xf,
10565 29, dp->vlnt[29] & 0xf,
10566 30, dp->vlnt[30] & 0xf,
10567 31, dp->vlnt[31] & 0xf));
10570 static void nonzero_msg(struct hfi1_devdata *dd, int idx, const char *what,
10574 dd_dev_info(dd, "Invalid %s limit %d on VL %d, ignoring\n",
10575 what, (int)limit, idx);
10578 /* change only the shared limit portion of SendCmGLobalCredit */
10579 static void set_global_shared(struct hfi1_devdata *dd, u16 limit)
10583 reg = read_csr(dd, SEND_CM_GLOBAL_CREDIT);
10584 reg &= ~SEND_CM_GLOBAL_CREDIT_SHARED_LIMIT_SMASK;
10585 reg |= (u64)limit << SEND_CM_GLOBAL_CREDIT_SHARED_LIMIT_SHIFT;
10586 write_csr(dd, SEND_CM_GLOBAL_CREDIT, reg);
10589 /* change only the total credit limit portion of SendCmGLobalCredit */
10590 static void set_global_limit(struct hfi1_devdata *dd, u16 limit)
10594 reg = read_csr(dd, SEND_CM_GLOBAL_CREDIT);
10595 reg &= ~SEND_CM_GLOBAL_CREDIT_TOTAL_CREDIT_LIMIT_SMASK;
10596 reg |= (u64)limit << SEND_CM_GLOBAL_CREDIT_TOTAL_CREDIT_LIMIT_SHIFT;
10597 write_csr(dd, SEND_CM_GLOBAL_CREDIT, reg);
10600 /* set the given per-VL shared limit */
10601 static void set_vl_shared(struct hfi1_devdata *dd, int vl, u16 limit)
10606 if (vl < TXE_NUM_DATA_VL)
10607 addr = SEND_CM_CREDIT_VL + (8 * vl);
10609 addr = SEND_CM_CREDIT_VL15;
10611 reg = read_csr(dd, addr);
10612 reg &= ~SEND_CM_CREDIT_VL_SHARED_LIMIT_VL_SMASK;
10613 reg |= (u64)limit << SEND_CM_CREDIT_VL_SHARED_LIMIT_VL_SHIFT;
10614 write_csr(dd, addr, reg);
10617 /* set the given per-VL dedicated limit */
10618 static void set_vl_dedicated(struct hfi1_devdata *dd, int vl, u16 limit)
10623 if (vl < TXE_NUM_DATA_VL)
10624 addr = SEND_CM_CREDIT_VL + (8 * vl);
10626 addr = SEND_CM_CREDIT_VL15;
10628 reg = read_csr(dd, addr);
10629 reg &= ~SEND_CM_CREDIT_VL_DEDICATED_LIMIT_VL_SMASK;
10630 reg |= (u64)limit << SEND_CM_CREDIT_VL_DEDICATED_LIMIT_VL_SHIFT;
10631 write_csr(dd, addr, reg);
10634 /* spin until the given per-VL status mask bits clear */
10635 static void wait_for_vl_status_clear(struct hfi1_devdata *dd, u64 mask,
10638 unsigned long timeout;
10641 timeout = jiffies + msecs_to_jiffies(VL_STATUS_CLEAR_TIMEOUT);
10643 reg = read_csr(dd, SEND_CM_CREDIT_USED_STATUS) & mask;
10646 return; /* success */
10647 if (time_after(jiffies, timeout))
10648 break; /* timed out */
10653 "%s credit change status not clearing after %dms, mask 0x%llx, not clear 0x%llx\n",
10654 which, VL_STATUS_CLEAR_TIMEOUT, mask, reg);
10656 * If this occurs, it is likely there was a credit loss on the link.
10657 * The only recovery from that is a link bounce.
10660 "Continuing anyway. A credit loss may occur. Suggest a link bounce\n");
10664 * The number of credits on the VLs may be changed while everything
10665 * is "live", but the following algorithm must be followed due to
10666 * how the hardware is actually implemented. In particular,
10667 * Return_Credit_Status[] is the only correct status check.
10669 * if (reducing Global_Shared_Credit_Limit or any shared limit changing)
10670 * set Global_Shared_Credit_Limit = 0
10672 * mask0 = all VLs that are changing either dedicated or shared limits
10673 * set Shared_Limit[mask0] = 0
10674 * spin until Return_Credit_Status[use_all_vl ? all VL : mask0] == 0
10675 * if (changing any dedicated limit)
10676 * mask1 = all VLs that are lowering dedicated limits
10677 * lower Dedicated_Limit[mask1]
10678 * spin until Return_Credit_Status[mask1] == 0
10679 * raise Dedicated_Limits
10680 * raise Shared_Limits
10681 * raise Global_Shared_Credit_Limit
10683 * lower = if the new limit is lower, set the limit to the new value
10684 * raise = if the new limit is higher than the current value (may be changed
10685 * earlier in the algorithm), set the new limit to the new value
10687 int set_buffer_control(struct hfi1_pportdata *ppd,
10688 struct buffer_control *new_bc)
10690 struct hfi1_devdata *dd = ppd->dd;
10691 u64 changing_mask, ld_mask, stat_mask;
10693 int i, use_all_mask;
10694 int this_shared_changing;
10695 int vl_count = 0, ret;
10697 * A0: add the variable any_shared_limit_changing below and in the
10698 * algorithm above. If removing A0 support, it can be removed.
10700 int any_shared_limit_changing;
10701 struct buffer_control cur_bc;
10702 u8 changing[OPA_MAX_VLS];
10703 u8 lowering_dedicated[OPA_MAX_VLS];
10706 const u64 all_mask =
10707 SEND_CM_CREDIT_USED_STATUS_VL0_RETURN_CREDIT_STATUS_SMASK
10708 | SEND_CM_CREDIT_USED_STATUS_VL1_RETURN_CREDIT_STATUS_SMASK
10709 | SEND_CM_CREDIT_USED_STATUS_VL2_RETURN_CREDIT_STATUS_SMASK
10710 | SEND_CM_CREDIT_USED_STATUS_VL3_RETURN_CREDIT_STATUS_SMASK
10711 | SEND_CM_CREDIT_USED_STATUS_VL4_RETURN_CREDIT_STATUS_SMASK
10712 | SEND_CM_CREDIT_USED_STATUS_VL5_RETURN_CREDIT_STATUS_SMASK
10713 | SEND_CM_CREDIT_USED_STATUS_VL6_RETURN_CREDIT_STATUS_SMASK
10714 | SEND_CM_CREDIT_USED_STATUS_VL7_RETURN_CREDIT_STATUS_SMASK
10715 | SEND_CM_CREDIT_USED_STATUS_VL15_RETURN_CREDIT_STATUS_SMASK;
10717 #define valid_vl(idx) ((idx) < TXE_NUM_DATA_VL || (idx) == 15)
10718 #define NUM_USABLE_VLS 16 /* look at VL15 and less */
10720 /* find the new total credits, do sanity check on unused VLs */
10721 for (i = 0; i < OPA_MAX_VLS; i++) {
10723 new_total += be16_to_cpu(new_bc->vl[i].dedicated);
10726 nonzero_msg(dd, i, "dedicated",
10727 be16_to_cpu(new_bc->vl[i].dedicated));
10728 nonzero_msg(dd, i, "shared",
10729 be16_to_cpu(new_bc->vl[i].shared));
10730 new_bc->vl[i].dedicated = 0;
10731 new_bc->vl[i].shared = 0;
10733 new_total += be16_to_cpu(new_bc->overall_shared_limit);
10735 /* fetch the current values */
10736 get_buffer_control(dd, &cur_bc, &cur_total);
10739 * Create the masks we will use.
10741 memset(changing, 0, sizeof(changing));
10742 memset(lowering_dedicated, 0, sizeof(lowering_dedicated));
10744 * NOTE: Assumes that the individual VL bits are adjacent and in
10748 SEND_CM_CREDIT_USED_STATUS_VL0_RETURN_CREDIT_STATUS_SMASK;
10752 any_shared_limit_changing = 0;
10753 for (i = 0; i < NUM_USABLE_VLS; i++, stat_mask <<= 1) {
10756 this_shared_changing = new_bc->vl[i].shared
10757 != cur_bc.vl[i].shared;
10758 if (this_shared_changing)
10759 any_shared_limit_changing = 1;
10760 if (new_bc->vl[i].dedicated != cur_bc.vl[i].dedicated ||
10761 this_shared_changing) {
10763 changing_mask |= stat_mask;
10766 if (be16_to_cpu(new_bc->vl[i].dedicated) <
10767 be16_to_cpu(cur_bc.vl[i].dedicated)) {
10768 lowering_dedicated[i] = 1;
10769 ld_mask |= stat_mask;
10773 /* bracket the credit change with a total adjustment */
10774 if (new_total > cur_total)
10775 set_global_limit(dd, new_total);
10778 * Start the credit change algorithm.
10781 if ((be16_to_cpu(new_bc->overall_shared_limit) <
10782 be16_to_cpu(cur_bc.overall_shared_limit)) ||
10783 (is_ax(dd) && any_shared_limit_changing)) {
10784 set_global_shared(dd, 0);
10785 cur_bc.overall_shared_limit = 0;
10789 for (i = 0; i < NUM_USABLE_VLS; i++) {
10794 set_vl_shared(dd, i, 0);
10795 cur_bc.vl[i].shared = 0;
10799 wait_for_vl_status_clear(dd, use_all_mask ? all_mask : changing_mask,
10802 if (change_count > 0) {
10803 for (i = 0; i < NUM_USABLE_VLS; i++) {
10807 if (lowering_dedicated[i]) {
10808 set_vl_dedicated(dd, i,
10809 be16_to_cpu(new_bc->
10811 cur_bc.vl[i].dedicated =
10812 new_bc->vl[i].dedicated;
10816 wait_for_vl_status_clear(dd, ld_mask, "dedicated");
10818 /* now raise all dedicated that are going up */
10819 for (i = 0; i < NUM_USABLE_VLS; i++) {
10823 if (be16_to_cpu(new_bc->vl[i].dedicated) >
10824 be16_to_cpu(cur_bc.vl[i].dedicated))
10825 set_vl_dedicated(dd, i,
10826 be16_to_cpu(new_bc->
10831 /* next raise all shared that are going up */
10832 for (i = 0; i < NUM_USABLE_VLS; i++) {
10836 if (be16_to_cpu(new_bc->vl[i].shared) >
10837 be16_to_cpu(cur_bc.vl[i].shared))
10838 set_vl_shared(dd, i, be16_to_cpu(new_bc->vl[i].shared));
10841 /* finally raise the global shared */
10842 if (be16_to_cpu(new_bc->overall_shared_limit) >
10843 be16_to_cpu(cur_bc.overall_shared_limit))
10844 set_global_shared(dd,
10845 be16_to_cpu(new_bc->overall_shared_limit));
10847 /* bracket the credit change with a total adjustment */
10848 if (new_total < cur_total)
10849 set_global_limit(dd, new_total);
10852 * Determine the actual number of operational VLS using the number of
10853 * dedicated and shared credits for each VL.
10855 if (change_count > 0) {
10856 for (i = 0; i < TXE_NUM_DATA_VL; i++)
10857 if (be16_to_cpu(new_bc->vl[i].dedicated) > 0 ||
10858 be16_to_cpu(new_bc->vl[i].shared) > 0)
10860 ppd->actual_vls_operational = vl_count;
10861 ret = sdma_map_init(dd, ppd->port - 1, vl_count ?
10862 ppd->actual_vls_operational :
10863 ppd->vls_operational,
10866 ret = pio_map_init(dd, ppd->port - 1, vl_count ?
10867 ppd->actual_vls_operational :
10868 ppd->vls_operational, NULL);
10876 * Read the given fabric manager table. Return the size of the
10877 * table (in bytes) on success, and a negative error code on
10880 int fm_get_table(struct hfi1_pportdata *ppd, int which, void *t)
10884 struct vl_arb_cache *vlc;
10887 case FM_TBL_VL_HIGH_ARB:
10890 * OPA specifies 128 elements (of 2 bytes each), though
10891 * HFI supports only 16 elements in h/w.
10893 vlc = vl_arb_lock_cache(ppd, HI_PRIO_TABLE);
10894 vl_arb_get_cache(vlc, t);
10895 vl_arb_unlock_cache(ppd, HI_PRIO_TABLE);
10897 case FM_TBL_VL_LOW_ARB:
10900 * OPA specifies 128 elements (of 2 bytes each), though
10901 * HFI supports only 16 elements in h/w.
10903 vlc = vl_arb_lock_cache(ppd, LO_PRIO_TABLE);
10904 vl_arb_get_cache(vlc, t);
10905 vl_arb_unlock_cache(ppd, LO_PRIO_TABLE);
10907 case FM_TBL_BUFFER_CONTROL:
10908 size = get_buffer_control(ppd->dd, t, NULL);
10910 case FM_TBL_SC2VLNT:
10911 size = get_sc2vlnt(ppd->dd, t);
10913 case FM_TBL_VL_PREEMPT_ELEMS:
10915 /* OPA specifies 128 elements, of 2 bytes each */
10916 get_vlarb_preempt(ppd->dd, OPA_MAX_VLS, t);
10918 case FM_TBL_VL_PREEMPT_MATRIX:
10921 * OPA specifies that this is the same size as the VL
10922 * arbitration tables (i.e., 256 bytes).
10932 * Write the given fabric manager table.
10934 int fm_set_table(struct hfi1_pportdata *ppd, int which, void *t)
10937 struct vl_arb_cache *vlc;
10940 case FM_TBL_VL_HIGH_ARB:
10941 vlc = vl_arb_lock_cache(ppd, HI_PRIO_TABLE);
10942 if (vl_arb_match_cache(vlc, t)) {
10943 vl_arb_unlock_cache(ppd, HI_PRIO_TABLE);
10946 vl_arb_set_cache(vlc, t);
10947 vl_arb_unlock_cache(ppd, HI_PRIO_TABLE);
10948 ret = set_vl_weights(ppd, SEND_HIGH_PRIORITY_LIST,
10949 VL_ARB_HIGH_PRIO_TABLE_SIZE, t);
10951 case FM_TBL_VL_LOW_ARB:
10952 vlc = vl_arb_lock_cache(ppd, LO_PRIO_TABLE);
10953 if (vl_arb_match_cache(vlc, t)) {
10954 vl_arb_unlock_cache(ppd, LO_PRIO_TABLE);
10957 vl_arb_set_cache(vlc, t);
10958 vl_arb_unlock_cache(ppd, LO_PRIO_TABLE);
10959 ret = set_vl_weights(ppd, SEND_LOW_PRIORITY_LIST,
10960 VL_ARB_LOW_PRIO_TABLE_SIZE, t);
10962 case FM_TBL_BUFFER_CONTROL:
10963 ret = set_buffer_control(ppd, t);
10965 case FM_TBL_SC2VLNT:
10966 set_sc2vlnt(ppd->dd, t);
10975 * Disable all data VLs.
10977 * Return 0 if disabled, non-zero if the VLs cannot be disabled.
10979 static int disable_data_vls(struct hfi1_devdata *dd)
10984 pio_send_control(dd, PSC_DATA_VL_DISABLE);
10990 * open_fill_data_vls() - the counterpart to stop_drain_data_vls().
10991 * Just re-enables all data VLs (the "fill" part happens
10992 * automatically - the name was chosen for symmetry with
10993 * stop_drain_data_vls()).
10995 * Return 0 if successful, non-zero if the VLs cannot be enabled.
10997 int open_fill_data_vls(struct hfi1_devdata *dd)
11002 pio_send_control(dd, PSC_DATA_VL_ENABLE);
11008 * drain_data_vls() - assumes that disable_data_vls() has been called,
11009 * wait for occupancy (of per-VL FIFOs) for all contexts, and SDMA
11010 * engines to drop to 0.
11012 static void drain_data_vls(struct hfi1_devdata *dd)
11016 pause_for_credit_return(dd);
11020 * stop_drain_data_vls() - disable, then drain all per-VL fifos.
11022 * Use open_fill_data_vls() to resume using data VLs. This pair is
11023 * meant to be used like this:
11025 * stop_drain_data_vls(dd);
11026 * // do things with per-VL resources
11027 * open_fill_data_vls(dd);
11029 int stop_drain_data_vls(struct hfi1_devdata *dd)
11033 ret = disable_data_vls(dd);
11035 drain_data_vls(dd);
11041 * Convert a nanosecond time to a cclock count. No matter how slow
11042 * the cclock, a non-zero ns will always have a non-zero result.
11044 u32 ns_to_cclock(struct hfi1_devdata *dd, u32 ns)
11048 if (dd->icode == ICODE_FPGA_EMULATION)
11049 cclocks = (ns * 1000) / FPGA_CCLOCK_PS;
11050 else /* simulation pretends to be ASIC */
11051 cclocks = (ns * 1000) / ASIC_CCLOCK_PS;
11052 if (ns && !cclocks) /* if ns nonzero, must be at least 1 */
11058 * Convert a cclock count to nanoseconds. Not matter how slow
11059 * the cclock, a non-zero cclocks will always have a non-zero result.
11061 u32 cclock_to_ns(struct hfi1_devdata *dd, u32 cclocks)
11065 if (dd->icode == ICODE_FPGA_EMULATION)
11066 ns = (cclocks * FPGA_CCLOCK_PS) / 1000;
11067 else /* simulation pretends to be ASIC */
11068 ns = (cclocks * ASIC_CCLOCK_PS) / 1000;
11069 if (cclocks && !ns)
11075 * Dynamically adjust the receive interrupt timeout for a context based on
11076 * incoming packet rate.
11078 * NOTE: Dynamic adjustment does not allow rcv_intr_count to be zero.
11080 static void adjust_rcv_timeout(struct hfi1_ctxtdata *rcd, u32 npkts)
11082 struct hfi1_devdata *dd = rcd->dd;
11083 u32 timeout = rcd->rcvavail_timeout;
11086 * This algorithm doubles or halves the timeout depending on whether
11087 * the number of packets received in this interrupt were less than or
11088 * greater equal the interrupt count.
11090 * The calculations below do not allow a steady state to be achieved.
11091 * Only at the endpoints it is possible to have an unchanging
11094 if (npkts < rcv_intr_count) {
11096 * Not enough packets arrived before the timeout, adjust
11097 * timeout downward.
11099 if (timeout < 2) /* already at minimum? */
11104 * More than enough packets arrived before the timeout, adjust
11107 if (timeout >= dd->rcv_intr_timeout_csr) /* already at max? */
11109 timeout = min(timeout << 1, dd->rcv_intr_timeout_csr);
11112 rcd->rcvavail_timeout = timeout;
11114 * timeout cannot be larger than rcv_intr_timeout_csr which has already
11115 * been verified to be in range
11117 write_kctxt_csr(dd, rcd->ctxt, RCV_AVAIL_TIME_OUT,
11119 RCV_AVAIL_TIME_OUT_TIME_OUT_RELOAD_SHIFT);
11122 void update_usrhead(struct hfi1_ctxtdata *rcd, u32 hd, u32 updegr, u32 egrhd,
11123 u32 intr_adjust, u32 npkts)
11125 struct hfi1_devdata *dd = rcd->dd;
11127 u32 ctxt = rcd->ctxt;
11130 * Need to write timeout register before updating RcvHdrHead to ensure
11131 * that a new value is used when the HW decides to restart counting.
11134 adjust_rcv_timeout(rcd, npkts);
11136 reg = (egrhd & RCV_EGR_INDEX_HEAD_HEAD_MASK)
11137 << RCV_EGR_INDEX_HEAD_HEAD_SHIFT;
11138 write_uctxt_csr(dd, ctxt, RCV_EGR_INDEX_HEAD, reg);
11141 reg = ((u64)rcv_intr_count << RCV_HDR_HEAD_COUNTER_SHIFT) |
11142 (((u64)hd & RCV_HDR_HEAD_HEAD_MASK)
11143 << RCV_HDR_HEAD_HEAD_SHIFT);
11144 write_uctxt_csr(dd, ctxt, RCV_HDR_HEAD, reg);
11148 u32 hdrqempty(struct hfi1_ctxtdata *rcd)
11152 head = (read_uctxt_csr(rcd->dd, rcd->ctxt, RCV_HDR_HEAD)
11153 & RCV_HDR_HEAD_HEAD_SMASK) >> RCV_HDR_HEAD_HEAD_SHIFT;
11155 if (rcd->rcvhdrtail_kvaddr)
11156 tail = get_rcvhdrtail(rcd);
11158 tail = read_uctxt_csr(rcd->dd, rcd->ctxt, RCV_HDR_TAIL);
11160 return head == tail;
11164 * Context Control and Receive Array encoding for buffer size:
11173 * 0x8 512 KB (Receive Array only)
11174 * 0x9 1 MB (Receive Array only)
11175 * 0xa 2 MB (Receive Array only)
11177 * 0xB-0xF - reserved (Receive Array only)
11180 * This routine assumes that the value has already been sanity checked.
11182 static u32 encoded_size(u32 size)
11185 case 4 * 1024: return 0x1;
11186 case 8 * 1024: return 0x2;
11187 case 16 * 1024: return 0x3;
11188 case 32 * 1024: return 0x4;
11189 case 64 * 1024: return 0x5;
11190 case 128 * 1024: return 0x6;
11191 case 256 * 1024: return 0x7;
11192 case 512 * 1024: return 0x8;
11193 case 1 * 1024 * 1024: return 0x9;
11194 case 2 * 1024 * 1024: return 0xa;
11196 return 0x1; /* if invalid, go with the minimum size */
11199 void hfi1_rcvctrl(struct hfi1_devdata *dd, unsigned int op, int ctxt)
11201 struct hfi1_ctxtdata *rcd;
11203 int did_enable = 0;
11205 rcd = dd->rcd[ctxt];
11209 hfi1_cdbg(RCVCTRL, "ctxt %d op 0x%x", ctxt, op);
11211 rcvctrl = read_kctxt_csr(dd, ctxt, RCV_CTXT_CTRL);
11212 /* if the context already enabled, don't do the extra steps */
11213 if ((op & HFI1_RCVCTRL_CTXT_ENB) &&
11214 !(rcvctrl & RCV_CTXT_CTRL_ENABLE_SMASK)) {
11215 /* reset the tail and hdr addresses, and sequence count */
11216 write_kctxt_csr(dd, ctxt, RCV_HDR_ADDR,
11217 rcd->rcvhdrq_phys);
11218 if (HFI1_CAP_KGET_MASK(rcd->flags, DMA_RTAIL))
11219 write_kctxt_csr(dd, ctxt, RCV_HDR_TAIL_ADDR,
11220 rcd->rcvhdrqtailaddr_phys);
11223 /* reset the cached receive header queue head value */
11227 * Zero the receive header queue so we don't get false
11228 * positives when checking the sequence number. The
11229 * sequence numbers could land exactly on the same spot.
11230 * E.g. a rcd restart before the receive header wrapped.
11232 memset(rcd->rcvhdrq, 0, rcd->rcvhdrq_size);
11234 /* starting timeout */
11235 rcd->rcvavail_timeout = dd->rcv_intr_timeout_csr;
11237 /* enable the context */
11238 rcvctrl |= RCV_CTXT_CTRL_ENABLE_SMASK;
11240 /* clean the egr buffer size first */
11241 rcvctrl &= ~RCV_CTXT_CTRL_EGR_BUF_SIZE_SMASK;
11242 rcvctrl |= ((u64)encoded_size(rcd->egrbufs.rcvtid_size)
11243 & RCV_CTXT_CTRL_EGR_BUF_SIZE_MASK)
11244 << RCV_CTXT_CTRL_EGR_BUF_SIZE_SHIFT;
11246 /* zero RcvHdrHead - set RcvHdrHead.Counter after enable */
11247 write_uctxt_csr(dd, ctxt, RCV_HDR_HEAD, 0);
11250 /* zero RcvEgrIndexHead */
11251 write_uctxt_csr(dd, ctxt, RCV_EGR_INDEX_HEAD, 0);
11253 /* set eager count and base index */
11254 reg = (((u64)(rcd->egrbufs.alloced >> RCV_SHIFT)
11255 & RCV_EGR_CTRL_EGR_CNT_MASK)
11256 << RCV_EGR_CTRL_EGR_CNT_SHIFT) |
11257 (((rcd->eager_base >> RCV_SHIFT)
11258 & RCV_EGR_CTRL_EGR_BASE_INDEX_MASK)
11259 << RCV_EGR_CTRL_EGR_BASE_INDEX_SHIFT);
11260 write_kctxt_csr(dd, ctxt, RCV_EGR_CTRL, reg);
11263 * Set TID (expected) count and base index.
11264 * rcd->expected_count is set to individual RcvArray entries,
11265 * not pairs, and the CSR takes a pair-count in groups of
11266 * four, so divide by 8.
11268 reg = (((rcd->expected_count >> RCV_SHIFT)
11269 & RCV_TID_CTRL_TID_PAIR_CNT_MASK)
11270 << RCV_TID_CTRL_TID_PAIR_CNT_SHIFT) |
11271 (((rcd->expected_base >> RCV_SHIFT)
11272 & RCV_TID_CTRL_TID_BASE_INDEX_MASK)
11273 << RCV_TID_CTRL_TID_BASE_INDEX_SHIFT);
11274 write_kctxt_csr(dd, ctxt, RCV_TID_CTRL, reg);
11275 if (ctxt == HFI1_CTRL_CTXT)
11276 write_csr(dd, RCV_VL15, HFI1_CTRL_CTXT);
11278 if (op & HFI1_RCVCTRL_CTXT_DIS) {
11279 write_csr(dd, RCV_VL15, 0);
11281 * When receive context is being disabled turn on tail
11282 * update with a dummy tail address and then disable
11285 if (dd->rcvhdrtail_dummy_physaddr) {
11286 write_kctxt_csr(dd, ctxt, RCV_HDR_TAIL_ADDR,
11287 dd->rcvhdrtail_dummy_physaddr);
11288 /* Enabling RcvCtxtCtrl.TailUpd is intentional. */
11289 rcvctrl |= RCV_CTXT_CTRL_TAIL_UPD_SMASK;
11292 rcvctrl &= ~RCV_CTXT_CTRL_ENABLE_SMASK;
11294 if (op & HFI1_RCVCTRL_INTRAVAIL_ENB)
11295 rcvctrl |= RCV_CTXT_CTRL_INTR_AVAIL_SMASK;
11296 if (op & HFI1_RCVCTRL_INTRAVAIL_DIS)
11297 rcvctrl &= ~RCV_CTXT_CTRL_INTR_AVAIL_SMASK;
11298 if (op & HFI1_RCVCTRL_TAILUPD_ENB && rcd->rcvhdrqtailaddr_phys)
11299 rcvctrl |= RCV_CTXT_CTRL_TAIL_UPD_SMASK;
11300 if (op & HFI1_RCVCTRL_TAILUPD_DIS) {
11301 /* See comment on RcvCtxtCtrl.TailUpd above */
11302 if (!(op & HFI1_RCVCTRL_CTXT_DIS))
11303 rcvctrl &= ~RCV_CTXT_CTRL_TAIL_UPD_SMASK;
11305 if (op & HFI1_RCVCTRL_TIDFLOW_ENB)
11306 rcvctrl |= RCV_CTXT_CTRL_TID_FLOW_ENABLE_SMASK;
11307 if (op & HFI1_RCVCTRL_TIDFLOW_DIS)
11308 rcvctrl &= ~RCV_CTXT_CTRL_TID_FLOW_ENABLE_SMASK;
11309 if (op & HFI1_RCVCTRL_ONE_PKT_EGR_ENB) {
11311 * In one-packet-per-eager mode, the size comes from
11312 * the RcvArray entry.
11314 rcvctrl &= ~RCV_CTXT_CTRL_EGR_BUF_SIZE_SMASK;
11315 rcvctrl |= RCV_CTXT_CTRL_ONE_PACKET_PER_EGR_BUFFER_SMASK;
11317 if (op & HFI1_RCVCTRL_ONE_PKT_EGR_DIS)
11318 rcvctrl &= ~RCV_CTXT_CTRL_ONE_PACKET_PER_EGR_BUFFER_SMASK;
11319 if (op & HFI1_RCVCTRL_NO_RHQ_DROP_ENB)
11320 rcvctrl |= RCV_CTXT_CTRL_DONT_DROP_RHQ_FULL_SMASK;
11321 if (op & HFI1_RCVCTRL_NO_RHQ_DROP_DIS)
11322 rcvctrl &= ~RCV_CTXT_CTRL_DONT_DROP_RHQ_FULL_SMASK;
11323 if (op & HFI1_RCVCTRL_NO_EGR_DROP_ENB)
11324 rcvctrl |= RCV_CTXT_CTRL_DONT_DROP_EGR_FULL_SMASK;
11325 if (op & HFI1_RCVCTRL_NO_EGR_DROP_DIS)
11326 rcvctrl &= ~RCV_CTXT_CTRL_DONT_DROP_EGR_FULL_SMASK;
11327 rcd->rcvctrl = rcvctrl;
11328 hfi1_cdbg(RCVCTRL, "ctxt %d rcvctrl 0x%llx\n", ctxt, rcvctrl);
11329 write_kctxt_csr(dd, ctxt, RCV_CTXT_CTRL, rcd->rcvctrl);
11331 /* work around sticky RcvCtxtStatus.BlockedRHQFull */
11333 (rcvctrl & RCV_CTXT_CTRL_DONT_DROP_RHQ_FULL_SMASK)) {
11334 reg = read_kctxt_csr(dd, ctxt, RCV_CTXT_STATUS);
11336 dd_dev_info(dd, "ctxt %d status %lld (blocked)\n",
11338 read_uctxt_csr(dd, ctxt, RCV_HDR_HEAD);
11339 write_uctxt_csr(dd, ctxt, RCV_HDR_HEAD, 0x10);
11340 write_uctxt_csr(dd, ctxt, RCV_HDR_HEAD, 0x00);
11341 read_uctxt_csr(dd, ctxt, RCV_HDR_HEAD);
11342 reg = read_kctxt_csr(dd, ctxt, RCV_CTXT_STATUS);
11343 dd_dev_info(dd, "ctxt %d status %lld (%s blocked)\n",
11344 ctxt, reg, reg == 0 ? "not" : "still");
11350 * The interrupt timeout and count must be set after
11351 * the context is enabled to take effect.
11353 /* set interrupt timeout */
11354 write_kctxt_csr(dd, ctxt, RCV_AVAIL_TIME_OUT,
11355 (u64)rcd->rcvavail_timeout <<
11356 RCV_AVAIL_TIME_OUT_TIME_OUT_RELOAD_SHIFT);
11358 /* set RcvHdrHead.Counter, zero RcvHdrHead.Head (again) */
11359 reg = (u64)rcv_intr_count << RCV_HDR_HEAD_COUNTER_SHIFT;
11360 write_uctxt_csr(dd, ctxt, RCV_HDR_HEAD, reg);
11363 if (op & (HFI1_RCVCTRL_TAILUPD_DIS | HFI1_RCVCTRL_CTXT_DIS))
11365 * If the context has been disabled and the Tail Update has
11366 * been cleared, set the RCV_HDR_TAIL_ADDR CSR to dummy address
11367 * so it doesn't contain an address that is invalid.
11369 write_kctxt_csr(dd, ctxt, RCV_HDR_TAIL_ADDR,
11370 dd->rcvhdrtail_dummy_physaddr);
11373 u32 hfi1_read_cntrs(struct hfi1_devdata *dd, char **namep, u64 **cntrp)
11379 ret = dd->cntrnameslen;
11380 *namep = dd->cntrnames;
11382 const struct cntr_entry *entry;
11385 ret = (dd->ndevcntrs) * sizeof(u64);
11387 /* Get the start of the block of counters */
11388 *cntrp = dd->cntrs;
11391 * Now go and fill in each counter in the block.
11393 for (i = 0; i < DEV_CNTR_LAST; i++) {
11394 entry = &dev_cntrs[i];
11395 hfi1_cdbg(CNTR, "reading %s", entry->name);
11396 if (entry->flags & CNTR_DISABLED) {
11398 hfi1_cdbg(CNTR, "\tDisabled\n");
11400 if (entry->flags & CNTR_VL) {
11401 hfi1_cdbg(CNTR, "\tPer VL\n");
11402 for (j = 0; j < C_VL_COUNT; j++) {
11403 val = entry->rw_cntr(entry,
11409 "\t\tRead 0x%llx for %d\n",
11411 dd->cntrs[entry->offset + j] =
11414 } else if (entry->flags & CNTR_SDMA) {
11416 "\t Per SDMA Engine\n");
11417 for (j = 0; j < dd->chip_sdma_engines;
11420 entry->rw_cntr(entry, dd, j,
11423 "\t\tRead 0x%llx for %d\n",
11425 dd->cntrs[entry->offset + j] =
11429 val = entry->rw_cntr(entry, dd,
11432 dd->cntrs[entry->offset] = val;
11433 hfi1_cdbg(CNTR, "\tRead 0x%llx", val);
11442 * Used by sysfs to create files for hfi stats to read
11444 u32 hfi1_read_portcntrs(struct hfi1_pportdata *ppd, char **namep, u64 **cntrp)
11450 ret = ppd->dd->portcntrnameslen;
11451 *namep = ppd->dd->portcntrnames;
11453 const struct cntr_entry *entry;
11456 ret = ppd->dd->nportcntrs * sizeof(u64);
11457 *cntrp = ppd->cntrs;
11459 for (i = 0; i < PORT_CNTR_LAST; i++) {
11460 entry = &port_cntrs[i];
11461 hfi1_cdbg(CNTR, "reading %s", entry->name);
11462 if (entry->flags & CNTR_DISABLED) {
11464 hfi1_cdbg(CNTR, "\tDisabled\n");
11468 if (entry->flags & CNTR_VL) {
11469 hfi1_cdbg(CNTR, "\tPer VL");
11470 for (j = 0; j < C_VL_COUNT; j++) {
11471 val = entry->rw_cntr(entry, ppd, j,
11476 "\t\tRead 0x%llx for %d",
11478 ppd->cntrs[entry->offset + j] = val;
11481 val = entry->rw_cntr(entry, ppd,
11485 ppd->cntrs[entry->offset] = val;
11486 hfi1_cdbg(CNTR, "\tRead 0x%llx", val);
11493 static void free_cntrs(struct hfi1_devdata *dd)
11495 struct hfi1_pportdata *ppd;
11498 if (dd->synth_stats_timer.data)
11499 del_timer_sync(&dd->synth_stats_timer);
11500 dd->synth_stats_timer.data = 0;
11501 ppd = (struct hfi1_pportdata *)(dd + 1);
11502 for (i = 0; i < dd->num_pports; i++, ppd++) {
11504 kfree(ppd->scntrs);
11505 free_percpu(ppd->ibport_data.rvp.rc_acks);
11506 free_percpu(ppd->ibport_data.rvp.rc_qacks);
11507 free_percpu(ppd->ibport_data.rvp.rc_delayed_comp);
11509 ppd->scntrs = NULL;
11510 ppd->ibport_data.rvp.rc_acks = NULL;
11511 ppd->ibport_data.rvp.rc_qacks = NULL;
11512 ppd->ibport_data.rvp.rc_delayed_comp = NULL;
11514 kfree(dd->portcntrnames);
11515 dd->portcntrnames = NULL;
11520 kfree(dd->cntrnames);
11521 dd->cntrnames = NULL;
11524 #define CNTR_MAX 0xFFFFFFFFFFFFFFFFULL
11525 #define CNTR_32BIT_MAX 0x00000000FFFFFFFF
11527 static u64 read_dev_port_cntr(struct hfi1_devdata *dd, struct cntr_entry *entry,
11528 u64 *psval, void *context, int vl)
11533 if (entry->flags & CNTR_DISABLED) {
11534 dd_dev_err(dd, "Counter %s not enabled", entry->name);
11538 hfi1_cdbg(CNTR, "cntr: %s vl %d psval 0x%llx", entry->name, vl, *psval);
11540 val = entry->rw_cntr(entry, context, vl, CNTR_MODE_R, 0);
11542 /* If its a synthetic counter there is more work we need to do */
11543 if (entry->flags & CNTR_SYNTH) {
11544 if (sval == CNTR_MAX) {
11545 /* No need to read already saturated */
11549 if (entry->flags & CNTR_32BIT) {
11550 /* 32bit counters can wrap multiple times */
11551 u64 upper = sval >> 32;
11552 u64 lower = (sval << 32) >> 32;
11554 if (lower > val) { /* hw wrapped */
11555 if (upper == CNTR_32BIT_MAX)
11561 if (val != CNTR_MAX)
11562 val = (upper << 32) | val;
11565 /* If we rolled we are saturated */
11566 if ((val < sval) || (val > CNTR_MAX))
11573 hfi1_cdbg(CNTR, "\tNew val=0x%llx", val);
11578 static u64 write_dev_port_cntr(struct hfi1_devdata *dd,
11579 struct cntr_entry *entry,
11580 u64 *psval, void *context, int vl, u64 data)
11584 if (entry->flags & CNTR_DISABLED) {
11585 dd_dev_err(dd, "Counter %s not enabled", entry->name);
11589 hfi1_cdbg(CNTR, "cntr: %s vl %d psval 0x%llx", entry->name, vl, *psval);
11591 if (entry->flags & CNTR_SYNTH) {
11593 if (entry->flags & CNTR_32BIT) {
11594 val = entry->rw_cntr(entry, context, vl, CNTR_MODE_W,
11595 (data << 32) >> 32);
11596 val = data; /* return the full 64bit value */
11598 val = entry->rw_cntr(entry, context, vl, CNTR_MODE_W,
11602 val = entry->rw_cntr(entry, context, vl, CNTR_MODE_W, data);
11607 hfi1_cdbg(CNTR, "\tNew val=0x%llx", val);
11612 u64 read_dev_cntr(struct hfi1_devdata *dd, int index, int vl)
11614 struct cntr_entry *entry;
11617 entry = &dev_cntrs[index];
11618 sval = dd->scntrs + entry->offset;
11620 if (vl != CNTR_INVALID_VL)
11623 return read_dev_port_cntr(dd, entry, sval, dd, vl);
11626 u64 write_dev_cntr(struct hfi1_devdata *dd, int index, int vl, u64 data)
11628 struct cntr_entry *entry;
11631 entry = &dev_cntrs[index];
11632 sval = dd->scntrs + entry->offset;
11634 if (vl != CNTR_INVALID_VL)
11637 return write_dev_port_cntr(dd, entry, sval, dd, vl, data);
11640 u64 read_port_cntr(struct hfi1_pportdata *ppd, int index, int vl)
11642 struct cntr_entry *entry;
11645 entry = &port_cntrs[index];
11646 sval = ppd->scntrs + entry->offset;
11648 if (vl != CNTR_INVALID_VL)
11651 if ((index >= C_RCV_HDR_OVF_FIRST + ppd->dd->num_rcv_contexts) &&
11652 (index <= C_RCV_HDR_OVF_LAST)) {
11653 /* We do not want to bother for disabled contexts */
11657 return read_dev_port_cntr(ppd->dd, entry, sval, ppd, vl);
11660 u64 write_port_cntr(struct hfi1_pportdata *ppd, int index, int vl, u64 data)
11662 struct cntr_entry *entry;
11665 entry = &port_cntrs[index];
11666 sval = ppd->scntrs + entry->offset;
11668 if (vl != CNTR_INVALID_VL)
11671 if ((index >= C_RCV_HDR_OVF_FIRST + ppd->dd->num_rcv_contexts) &&
11672 (index <= C_RCV_HDR_OVF_LAST)) {
11673 /* We do not want to bother for disabled contexts */
11677 return write_dev_port_cntr(ppd->dd, entry, sval, ppd, vl, data);
11680 static void update_synth_timer(unsigned long opaque)
11687 struct hfi1_pportdata *ppd;
11688 struct cntr_entry *entry;
11690 struct hfi1_devdata *dd = (struct hfi1_devdata *)opaque;
11693 * Rather than keep beating on the CSRs pick a minimal set that we can
11694 * check to watch for potential roll over. We can do this by looking at
11695 * the number of flits sent/recv. If the total flits exceeds 32bits then
11696 * we have to iterate all the counters and update.
11698 entry = &dev_cntrs[C_DC_RCV_FLITS];
11699 cur_rx = entry->rw_cntr(entry, dd, CNTR_INVALID_VL, CNTR_MODE_R, 0);
11701 entry = &dev_cntrs[C_DC_XMIT_FLITS];
11702 cur_tx = entry->rw_cntr(entry, dd, CNTR_INVALID_VL, CNTR_MODE_R, 0);
11706 "[%d] curr tx=0x%llx rx=0x%llx :: last tx=0x%llx rx=0x%llx\n",
11707 dd->unit, cur_tx, cur_rx, dd->last_tx, dd->last_rx);
11709 if ((cur_tx < dd->last_tx) || (cur_rx < dd->last_rx)) {
11711 * May not be strictly necessary to update but it won't hurt and
11712 * simplifies the logic here.
11715 hfi1_cdbg(CNTR, "[%d] Tripwire counter rolled, updating",
11718 total_flits = (cur_tx - dd->last_tx) + (cur_rx - dd->last_rx);
11720 "[%d] total flits 0x%llx limit 0x%llx\n", dd->unit,
11721 total_flits, (u64)CNTR_32BIT_MAX);
11722 if (total_flits >= CNTR_32BIT_MAX) {
11723 hfi1_cdbg(CNTR, "[%d] 32bit limit hit, updating",
11730 hfi1_cdbg(CNTR, "[%d] Updating dd and ppd counters", dd->unit);
11731 for (i = 0; i < DEV_CNTR_LAST; i++) {
11732 entry = &dev_cntrs[i];
11733 if (entry->flags & CNTR_VL) {
11734 for (vl = 0; vl < C_VL_COUNT; vl++)
11735 read_dev_cntr(dd, i, vl);
11737 read_dev_cntr(dd, i, CNTR_INVALID_VL);
11740 ppd = (struct hfi1_pportdata *)(dd + 1);
11741 for (i = 0; i < dd->num_pports; i++, ppd++) {
11742 for (j = 0; j < PORT_CNTR_LAST; j++) {
11743 entry = &port_cntrs[j];
11744 if (entry->flags & CNTR_VL) {
11745 for (vl = 0; vl < C_VL_COUNT; vl++)
11746 read_port_cntr(ppd, j, vl);
11748 read_port_cntr(ppd, j, CNTR_INVALID_VL);
11754 * We want the value in the register. The goal is to keep track
11755 * of the number of "ticks" not the counter value. In other
11756 * words if the register rolls we want to notice it and go ahead
11757 * and force an update.
11759 entry = &dev_cntrs[C_DC_XMIT_FLITS];
11760 dd->last_tx = entry->rw_cntr(entry, dd, CNTR_INVALID_VL,
11763 entry = &dev_cntrs[C_DC_RCV_FLITS];
11764 dd->last_rx = entry->rw_cntr(entry, dd, CNTR_INVALID_VL,
11767 hfi1_cdbg(CNTR, "[%d] setting last tx/rx to 0x%llx 0x%llx",
11768 dd->unit, dd->last_tx, dd->last_rx);
11771 hfi1_cdbg(CNTR, "[%d] No update necessary", dd->unit);
11774 mod_timer(&dd->synth_stats_timer, jiffies + HZ * SYNTH_CNT_TIME);
11777 #define C_MAX_NAME 13 /* 12 chars + one for /0 */
11778 static int init_cntrs(struct hfi1_devdata *dd)
11780 int i, rcv_ctxts, j;
11783 char name[C_MAX_NAME];
11784 struct hfi1_pportdata *ppd;
11785 const char *bit_type_32 = ",32";
11786 const int bit_type_32_sz = strlen(bit_type_32);
11788 /* set up the stats timer; the add_timer is done at the end */
11789 setup_timer(&dd->synth_stats_timer, update_synth_timer,
11790 (unsigned long)dd);
11792 /***********************/
11793 /* per device counters */
11794 /***********************/
11796 /* size names and determine how many we have*/
11800 for (i = 0; i < DEV_CNTR_LAST; i++) {
11801 if (dev_cntrs[i].flags & CNTR_DISABLED) {
11802 hfi1_dbg_early("\tSkipping %s\n", dev_cntrs[i].name);
11806 if (dev_cntrs[i].flags & CNTR_VL) {
11807 dev_cntrs[i].offset = dd->ndevcntrs;
11808 for (j = 0; j < C_VL_COUNT; j++) {
11809 snprintf(name, C_MAX_NAME, "%s%d",
11810 dev_cntrs[i].name, vl_from_idx(j));
11811 sz += strlen(name);
11812 /* Add ",32" for 32-bit counters */
11813 if (dev_cntrs[i].flags & CNTR_32BIT)
11814 sz += bit_type_32_sz;
11818 } else if (dev_cntrs[i].flags & CNTR_SDMA) {
11819 dev_cntrs[i].offset = dd->ndevcntrs;
11820 for (j = 0; j < dd->chip_sdma_engines; j++) {
11821 snprintf(name, C_MAX_NAME, "%s%d",
11822 dev_cntrs[i].name, j);
11823 sz += strlen(name);
11824 /* Add ",32" for 32-bit counters */
11825 if (dev_cntrs[i].flags & CNTR_32BIT)
11826 sz += bit_type_32_sz;
11831 /* +1 for newline. */
11832 sz += strlen(dev_cntrs[i].name) + 1;
11833 /* Add ",32" for 32-bit counters */
11834 if (dev_cntrs[i].flags & CNTR_32BIT)
11835 sz += bit_type_32_sz;
11836 dev_cntrs[i].offset = dd->ndevcntrs;
11841 /* allocate space for the counter values */
11842 dd->cntrs = kcalloc(dd->ndevcntrs, sizeof(u64), GFP_KERNEL);
11846 dd->scntrs = kcalloc(dd->ndevcntrs, sizeof(u64), GFP_KERNEL);
11850 /* allocate space for the counter names */
11851 dd->cntrnameslen = sz;
11852 dd->cntrnames = kmalloc(sz, GFP_KERNEL);
11853 if (!dd->cntrnames)
11856 /* fill in the names */
11857 for (p = dd->cntrnames, i = 0; i < DEV_CNTR_LAST; i++) {
11858 if (dev_cntrs[i].flags & CNTR_DISABLED) {
11860 } else if (dev_cntrs[i].flags & CNTR_VL) {
11861 for (j = 0; j < C_VL_COUNT; j++) {
11862 snprintf(name, C_MAX_NAME, "%s%d",
11865 memcpy(p, name, strlen(name));
11868 /* Counter is 32 bits */
11869 if (dev_cntrs[i].flags & CNTR_32BIT) {
11870 memcpy(p, bit_type_32, bit_type_32_sz);
11871 p += bit_type_32_sz;
11876 } else if (dev_cntrs[i].flags & CNTR_SDMA) {
11877 for (j = 0; j < dd->chip_sdma_engines; j++) {
11878 snprintf(name, C_MAX_NAME, "%s%d",
11879 dev_cntrs[i].name, j);
11880 memcpy(p, name, strlen(name));
11883 /* Counter is 32 bits */
11884 if (dev_cntrs[i].flags & CNTR_32BIT) {
11885 memcpy(p, bit_type_32, bit_type_32_sz);
11886 p += bit_type_32_sz;
11892 memcpy(p, dev_cntrs[i].name, strlen(dev_cntrs[i].name));
11893 p += strlen(dev_cntrs[i].name);
11895 /* Counter is 32 bits */
11896 if (dev_cntrs[i].flags & CNTR_32BIT) {
11897 memcpy(p, bit_type_32, bit_type_32_sz);
11898 p += bit_type_32_sz;
11905 /*********************/
11906 /* per port counters */
11907 /*********************/
11910 * Go through the counters for the overflows and disable the ones we
11911 * don't need. This varies based on platform so we need to do it
11912 * dynamically here.
11914 rcv_ctxts = dd->num_rcv_contexts;
11915 for (i = C_RCV_HDR_OVF_FIRST + rcv_ctxts;
11916 i <= C_RCV_HDR_OVF_LAST; i++) {
11917 port_cntrs[i].flags |= CNTR_DISABLED;
11920 /* size port counter names and determine how many we have*/
11922 dd->nportcntrs = 0;
11923 for (i = 0; i < PORT_CNTR_LAST; i++) {
11924 if (port_cntrs[i].flags & CNTR_DISABLED) {
11925 hfi1_dbg_early("\tSkipping %s\n", port_cntrs[i].name);
11929 if (port_cntrs[i].flags & CNTR_VL) {
11930 port_cntrs[i].offset = dd->nportcntrs;
11931 for (j = 0; j < C_VL_COUNT; j++) {
11932 snprintf(name, C_MAX_NAME, "%s%d",
11933 port_cntrs[i].name, vl_from_idx(j));
11934 sz += strlen(name);
11935 /* Add ",32" for 32-bit counters */
11936 if (port_cntrs[i].flags & CNTR_32BIT)
11937 sz += bit_type_32_sz;
11942 /* +1 for newline */
11943 sz += strlen(port_cntrs[i].name) + 1;
11944 /* Add ",32" for 32-bit counters */
11945 if (port_cntrs[i].flags & CNTR_32BIT)
11946 sz += bit_type_32_sz;
11947 port_cntrs[i].offset = dd->nportcntrs;
11952 /* allocate space for the counter names */
11953 dd->portcntrnameslen = sz;
11954 dd->portcntrnames = kmalloc(sz, GFP_KERNEL);
11955 if (!dd->portcntrnames)
11958 /* fill in port cntr names */
11959 for (p = dd->portcntrnames, i = 0; i < PORT_CNTR_LAST; i++) {
11960 if (port_cntrs[i].flags & CNTR_DISABLED)
11963 if (port_cntrs[i].flags & CNTR_VL) {
11964 for (j = 0; j < C_VL_COUNT; j++) {
11965 snprintf(name, C_MAX_NAME, "%s%d",
11966 port_cntrs[i].name, vl_from_idx(j));
11967 memcpy(p, name, strlen(name));
11970 /* Counter is 32 bits */
11971 if (port_cntrs[i].flags & CNTR_32BIT) {
11972 memcpy(p, bit_type_32, bit_type_32_sz);
11973 p += bit_type_32_sz;
11979 memcpy(p, port_cntrs[i].name,
11980 strlen(port_cntrs[i].name));
11981 p += strlen(port_cntrs[i].name);
11983 /* Counter is 32 bits */
11984 if (port_cntrs[i].flags & CNTR_32BIT) {
11985 memcpy(p, bit_type_32, bit_type_32_sz);
11986 p += bit_type_32_sz;
11993 /* allocate per port storage for counter values */
11994 ppd = (struct hfi1_pportdata *)(dd + 1);
11995 for (i = 0; i < dd->num_pports; i++, ppd++) {
11996 ppd->cntrs = kcalloc(dd->nportcntrs, sizeof(u64), GFP_KERNEL);
12000 ppd->scntrs = kcalloc(dd->nportcntrs, sizeof(u64), GFP_KERNEL);
12005 /* CPU counters need to be allocated and zeroed */
12006 if (init_cpu_counters(dd))
12009 mod_timer(&dd->synth_stats_timer, jiffies + HZ * SYNTH_CNT_TIME);
12016 static u32 chip_to_opa_lstate(struct hfi1_devdata *dd, u32 chip_lstate)
12018 switch (chip_lstate) {
12021 "Unknown logical state 0x%x, reporting IB_PORT_DOWN\n",
12025 return IB_PORT_DOWN;
12027 return IB_PORT_INIT;
12029 return IB_PORT_ARMED;
12030 case LSTATE_ACTIVE:
12031 return IB_PORT_ACTIVE;
12035 u32 chip_to_opa_pstate(struct hfi1_devdata *dd, u32 chip_pstate)
12037 /* look at the HFI meta-states only */
12038 switch (chip_pstate & 0xf0) {
12040 dd_dev_err(dd, "Unexpected chip physical state of 0x%x\n",
12044 return IB_PORTPHYSSTATE_DISABLED;
12046 return OPA_PORTPHYSSTATE_OFFLINE;
12048 return IB_PORTPHYSSTATE_POLLING;
12049 case PLS_CONFIGPHY:
12050 return IB_PORTPHYSSTATE_TRAINING;
12052 return IB_PORTPHYSSTATE_LINKUP;
12054 return IB_PORTPHYSSTATE_PHY_TEST;
12058 /* return the OPA port logical state name */
12059 const char *opa_lstate_name(u32 lstate)
12061 static const char * const port_logical_names[] = {
12067 "PORT_ACTIVE_DEFER",
12069 if (lstate < ARRAY_SIZE(port_logical_names))
12070 return port_logical_names[lstate];
12074 /* return the OPA port physical state name */
12075 const char *opa_pstate_name(u32 pstate)
12077 static const char * const port_physical_names[] = {
12084 "PHYS_LINK_ERR_RECOVER",
12091 if (pstate < ARRAY_SIZE(port_physical_names))
12092 return port_physical_names[pstate];
12097 * Read the hardware link state and set the driver's cached value of it.
12098 * Return the (new) current value.
12100 u32 get_logical_state(struct hfi1_pportdata *ppd)
12104 new_state = chip_to_opa_lstate(ppd->dd, read_logical_state(ppd->dd));
12105 if (new_state != ppd->lstate) {
12106 dd_dev_info(ppd->dd, "logical state changed to %s (0x%x)\n",
12107 opa_lstate_name(new_state), new_state);
12108 ppd->lstate = new_state;
12111 * Set port status flags in the page mapped into userspace
12112 * memory. Do it here to ensure a reliable state - this is
12113 * the only function called by all state handling code.
12114 * Always set the flags due to the fact that the cache value
12115 * might have been changed explicitly outside of this
12118 if (ppd->statusp) {
12119 switch (ppd->lstate) {
12122 *ppd->statusp &= ~(HFI1_STATUS_IB_CONF |
12123 HFI1_STATUS_IB_READY);
12125 case IB_PORT_ARMED:
12126 *ppd->statusp |= HFI1_STATUS_IB_CONF;
12128 case IB_PORT_ACTIVE:
12129 *ppd->statusp |= HFI1_STATUS_IB_READY;
12133 return ppd->lstate;
12137 * wait_logical_linkstate - wait for an IB link state change to occur
12138 * @ppd: port device
12139 * @state: the state to wait for
12140 * @msecs: the number of milliseconds to wait
12142 * Wait up to msecs milliseconds for IB link state change to occur.
12143 * For now, take the easy polling route.
12144 * Returns 0 if state reached, otherwise -ETIMEDOUT.
12146 static int wait_logical_linkstate(struct hfi1_pportdata *ppd, u32 state,
12149 unsigned long timeout;
12151 timeout = jiffies + msecs_to_jiffies(msecs);
12153 if (get_logical_state(ppd) == state)
12155 if (time_after(jiffies, timeout))
12159 dd_dev_err(ppd->dd, "timeout waiting for link state 0x%x\n", state);
12164 u8 hfi1_ibphys_portstate(struct hfi1_pportdata *ppd)
12169 pstate = read_physical_state(ppd->dd);
12170 ib_pstate = chip_to_opa_pstate(ppd->dd, pstate);
12171 if (ppd->last_pstate != ib_pstate) {
12172 dd_dev_info(ppd->dd,
12173 "%s: physical state changed to %s (0x%x), phy 0x%x\n",
12174 __func__, opa_pstate_name(ib_pstate), ib_pstate,
12176 ppd->last_pstate = ib_pstate;
12182 * Read/modify/write ASIC_QSFP register bits as selected by mask
12183 * data: 0 or 1 in the positions depending on what needs to be written
12184 * dir: 0 for read, 1 for write
12185 * mask: select by setting
12189 u64 hfi1_gpio_mod(struct hfi1_devdata *dd, u32 target, u32 data, u32 dir,
12192 u64 qsfp_oe, target_oe;
12194 target_oe = target ? ASIC_QSFP2_OE : ASIC_QSFP1_OE;
12196 /* We are writing register bits, so lock access */
12200 qsfp_oe = read_csr(dd, target_oe);
12201 qsfp_oe = (qsfp_oe & ~(u64)mask) | (u64)dir;
12202 write_csr(dd, target_oe, qsfp_oe);
12204 /* We are exclusively reading bits here, but it is unlikely
12205 * we'll get valid data when we set the direction of the pin
12206 * in the same call, so read should call this function again
12207 * to get valid data
12209 return read_csr(dd, target ? ASIC_QSFP2_IN : ASIC_QSFP1_IN);
12212 #define CLEAR_STATIC_RATE_CONTROL_SMASK(r) \
12213 (r &= ~SEND_CTXT_CHECK_ENABLE_DISALLOW_PBC_STATIC_RATE_CONTROL_SMASK)
12215 #define SET_STATIC_RATE_CONTROL_SMASK(r) \
12216 (r |= SEND_CTXT_CHECK_ENABLE_DISALLOW_PBC_STATIC_RATE_CONTROL_SMASK)
12218 int hfi1_init_ctxt(struct send_context *sc)
12221 struct hfi1_devdata *dd = sc->dd;
12223 u8 set = (sc->type == SC_USER ?
12224 HFI1_CAP_IS_USET(STATIC_RATE_CTRL) :
12225 HFI1_CAP_IS_KSET(STATIC_RATE_CTRL));
12226 reg = read_kctxt_csr(dd, sc->hw_context,
12227 SEND_CTXT_CHECK_ENABLE);
12229 CLEAR_STATIC_RATE_CONTROL_SMASK(reg);
12231 SET_STATIC_RATE_CONTROL_SMASK(reg);
12232 write_kctxt_csr(dd, sc->hw_context,
12233 SEND_CTXT_CHECK_ENABLE, reg);
12238 int hfi1_tempsense_rd(struct hfi1_devdata *dd, struct hfi1_temp *temp)
12243 if (dd->icode != ICODE_RTL_SILICON) {
12244 if (HFI1_CAP_IS_KSET(PRINT_UNIMPL))
12245 dd_dev_info(dd, "%s: tempsense not supported by HW\n",
12249 reg = read_csr(dd, ASIC_STS_THERM);
12250 temp->curr = ((reg >> ASIC_STS_THERM_CURR_TEMP_SHIFT) &
12251 ASIC_STS_THERM_CURR_TEMP_MASK);
12252 temp->lo_lim = ((reg >> ASIC_STS_THERM_LO_TEMP_SHIFT) &
12253 ASIC_STS_THERM_LO_TEMP_MASK);
12254 temp->hi_lim = ((reg >> ASIC_STS_THERM_HI_TEMP_SHIFT) &
12255 ASIC_STS_THERM_HI_TEMP_MASK);
12256 temp->crit_lim = ((reg >> ASIC_STS_THERM_CRIT_TEMP_SHIFT) &
12257 ASIC_STS_THERM_CRIT_TEMP_MASK);
12258 /* triggers is a 3-bit value - 1 bit per trigger. */
12259 temp->triggers = (u8)((reg >> ASIC_STS_THERM_LOW_SHIFT) & 0x7);
12264 /* ========================================================================= */
12267 * Enable/disable chip from delivering interrupts.
12269 void set_intr_state(struct hfi1_devdata *dd, u32 enable)
12274 * In HFI, the mask needs to be 1 to allow interrupts.
12277 /* enable all interrupts */
12278 for (i = 0; i < CCE_NUM_INT_CSRS; i++)
12279 write_csr(dd, CCE_INT_MASK + (8 * i), ~(u64)0);
12283 for (i = 0; i < CCE_NUM_INT_CSRS; i++)
12284 write_csr(dd, CCE_INT_MASK + (8 * i), 0ull);
12289 * Clear all interrupt sources on the chip.
12291 static void clear_all_interrupts(struct hfi1_devdata *dd)
12295 for (i = 0; i < CCE_NUM_INT_CSRS; i++)
12296 write_csr(dd, CCE_INT_CLEAR + (8 * i), ~(u64)0);
12298 write_csr(dd, CCE_ERR_CLEAR, ~(u64)0);
12299 write_csr(dd, MISC_ERR_CLEAR, ~(u64)0);
12300 write_csr(dd, RCV_ERR_CLEAR, ~(u64)0);
12301 write_csr(dd, SEND_ERR_CLEAR, ~(u64)0);
12302 write_csr(dd, SEND_PIO_ERR_CLEAR, ~(u64)0);
12303 write_csr(dd, SEND_DMA_ERR_CLEAR, ~(u64)0);
12304 write_csr(dd, SEND_EGRESS_ERR_CLEAR, ~(u64)0);
12305 for (i = 0; i < dd->chip_send_contexts; i++)
12306 write_kctxt_csr(dd, i, SEND_CTXT_ERR_CLEAR, ~(u64)0);
12307 for (i = 0; i < dd->chip_sdma_engines; i++)
12308 write_kctxt_csr(dd, i, SEND_DMA_ENG_ERR_CLEAR, ~(u64)0);
12310 write_csr(dd, DCC_ERR_FLG_CLR, ~(u64)0);
12311 write_csr(dd, DC_LCB_ERR_CLR, ~(u64)0);
12312 write_csr(dd, DC_DC8051_ERR_CLR, ~(u64)0);
12315 /* Move to pcie.c? */
12316 static void disable_intx(struct pci_dev *pdev)
12321 static void clean_up_interrupts(struct hfi1_devdata *dd)
12325 /* remove irqs - must happen before disabling/turning off */
12326 if (dd->num_msix_entries) {
12328 struct hfi1_msix_entry *me = dd->msix_entries;
12330 for (i = 0; i < dd->num_msix_entries; i++, me++) {
12331 if (!me->arg) /* => no irq, no affinity */
12333 hfi1_put_irq_affinity(dd, &dd->msix_entries[i]);
12334 free_irq(me->msix.vector, me->arg);
12338 if (dd->requested_intx_irq) {
12339 free_irq(dd->pcidev->irq, dd);
12340 dd->requested_intx_irq = 0;
12344 /* turn off interrupts */
12345 if (dd->num_msix_entries) {
12347 pci_disable_msix(dd->pcidev);
12350 disable_intx(dd->pcidev);
12353 /* clean structures */
12354 kfree(dd->msix_entries);
12355 dd->msix_entries = NULL;
12356 dd->num_msix_entries = 0;
12360 * Remap the interrupt source from the general handler to the given MSI-X
12363 static void remap_intr(struct hfi1_devdata *dd, int isrc, int msix_intr)
12368 /* clear from the handled mask of the general interrupt */
12371 dd->gi_mask[m] &= ~((u64)1 << n);
12373 /* direct the chip source to the given MSI-X interrupt */
12376 reg = read_csr(dd, CCE_INT_MAP + (8 * m));
12377 reg &= ~((u64)0xff << (8 * n));
12378 reg |= ((u64)msix_intr & 0xff) << (8 * n);
12379 write_csr(dd, CCE_INT_MAP + (8 * m), reg);
12382 static void remap_sdma_interrupts(struct hfi1_devdata *dd,
12383 int engine, int msix_intr)
12386 * SDMA engine interrupt sources grouped by type, rather than
12387 * engine. Per-engine interrupts are as follows:
12392 remap_intr(dd, IS_SDMA_START + 0 * TXE_NUM_SDMA_ENGINES + engine,
12394 remap_intr(dd, IS_SDMA_START + 1 * TXE_NUM_SDMA_ENGINES + engine,
12396 remap_intr(dd, IS_SDMA_START + 2 * TXE_NUM_SDMA_ENGINES + engine,
12400 static int request_intx_irq(struct hfi1_devdata *dd)
12404 snprintf(dd->intx_name, sizeof(dd->intx_name), DRIVER_NAME "_%d",
12406 ret = request_irq(dd->pcidev->irq, general_interrupt,
12407 IRQF_SHARED, dd->intx_name, dd);
12409 dd_dev_err(dd, "unable to request INTx interrupt, err %d\n",
12412 dd->requested_intx_irq = 1;
12416 static int request_msix_irqs(struct hfi1_devdata *dd)
12418 int first_general, last_general;
12419 int first_sdma, last_sdma;
12420 int first_rx, last_rx;
12423 /* calculate the ranges we are going to use */
12425 last_general = first_general + 1;
12426 first_sdma = last_general;
12427 last_sdma = first_sdma + dd->num_sdma;
12428 first_rx = last_sdma;
12429 last_rx = first_rx + dd->n_krcv_queues;
12432 * Sanity check - the code expects all SDMA chip source
12433 * interrupts to be in the same CSR, starting at bit 0. Verify
12434 * that this is true by checking the bit location of the start.
12436 BUILD_BUG_ON(IS_SDMA_START % 64);
12438 for (i = 0; i < dd->num_msix_entries; i++) {
12439 struct hfi1_msix_entry *me = &dd->msix_entries[i];
12440 const char *err_info;
12441 irq_handler_t handler;
12442 irq_handler_t thread = NULL;
12445 struct hfi1_ctxtdata *rcd = NULL;
12446 struct sdma_engine *sde = NULL;
12448 /* obtain the arguments to request_irq */
12449 if (first_general <= i && i < last_general) {
12450 idx = i - first_general;
12451 handler = general_interrupt;
12453 snprintf(me->name, sizeof(me->name),
12454 DRIVER_NAME "_%d", dd->unit);
12455 err_info = "general";
12456 me->type = IRQ_GENERAL;
12457 } else if (first_sdma <= i && i < last_sdma) {
12458 idx = i - first_sdma;
12459 sde = &dd->per_sdma[idx];
12460 handler = sdma_interrupt;
12462 snprintf(me->name, sizeof(me->name),
12463 DRIVER_NAME "_%d sdma%d", dd->unit, idx);
12465 remap_sdma_interrupts(dd, idx, i);
12466 me->type = IRQ_SDMA;
12467 } else if (first_rx <= i && i < last_rx) {
12468 idx = i - first_rx;
12469 rcd = dd->rcd[idx];
12470 /* no interrupt if no rcd */
12474 * Set the interrupt register and mask for this
12475 * context's interrupt.
12477 rcd->ireg = (IS_RCVAVAIL_START + idx) / 64;
12478 rcd->imask = ((u64)1) <<
12479 ((IS_RCVAVAIL_START + idx) % 64);
12480 handler = receive_context_interrupt;
12481 thread = receive_context_thread;
12483 snprintf(me->name, sizeof(me->name),
12484 DRIVER_NAME "_%d kctxt%d", dd->unit, idx);
12485 err_info = "receive context";
12486 remap_intr(dd, IS_RCVAVAIL_START + idx, i);
12487 me->type = IRQ_RCVCTXT;
12489 /* not in our expected range - complain, then
12493 "Unexpected extra MSI-X interrupt %d\n", i);
12496 /* no argument, no interrupt */
12499 /* make sure the name is terminated */
12500 me->name[sizeof(me->name) - 1] = 0;
12502 ret = request_threaded_irq(me->msix.vector, handler, thread, 0,
12506 "unable to allocate %s interrupt, vector %d, index %d, err %d\n",
12507 err_info, me->msix.vector, idx, ret);
12511 * assign arg after request_irq call, so it will be
12516 ret = hfi1_get_irq_affinity(dd, me);
12519 "unable to pin IRQ %d\n", ret);
12526 * Set the general handler to accept all interrupts, remap all
12527 * chip interrupts back to MSI-X 0.
12529 static void reset_interrupts(struct hfi1_devdata *dd)
12533 /* all interrupts handled by the general handler */
12534 for (i = 0; i < CCE_NUM_INT_CSRS; i++)
12535 dd->gi_mask[i] = ~(u64)0;
12537 /* all chip interrupts map to MSI-X 0 */
12538 for (i = 0; i < CCE_NUM_INT_MAP_CSRS; i++)
12539 write_csr(dd, CCE_INT_MAP + (8 * i), 0);
12542 static int set_up_interrupts(struct hfi1_devdata *dd)
12544 struct hfi1_msix_entry *entries;
12545 u32 total, request;
12547 int single_interrupt = 0; /* we expect to have all the interrupts */
12551 * 1 general, "slow path" interrupt (includes the SDMA engines
12552 * slow source, SDMACleanupDone)
12553 * N interrupts - one per used SDMA engine
12554 * M interrupt - one per kernel receive context
12556 total = 1 + dd->num_sdma + dd->n_krcv_queues;
12558 entries = kcalloc(total, sizeof(*entries), GFP_KERNEL);
12563 /* 1-1 MSI-X entry assignment */
12564 for (i = 0; i < total; i++)
12565 entries[i].msix.entry = i;
12567 /* ask for MSI-X interrupts */
12569 request_msix(dd, &request, entries);
12571 if (request == 0) {
12573 /* dd->num_msix_entries already zero */
12575 single_interrupt = 1;
12576 dd_dev_err(dd, "MSI-X failed, using INTx interrupts\n");
12579 dd->num_msix_entries = request;
12580 dd->msix_entries = entries;
12582 if (request != total) {
12583 /* using MSI-X, with reduced interrupts */
12586 "cannot handle reduced interrupt case, want %u, got %u\n",
12591 dd_dev_info(dd, "%u MSI-X interrupts allocated\n", total);
12594 /* mask all interrupts */
12595 set_intr_state(dd, 0);
12596 /* clear all pending interrupts */
12597 clear_all_interrupts(dd);
12599 /* reset general handler mask, chip MSI-X mappings */
12600 reset_interrupts(dd);
12602 if (single_interrupt)
12603 ret = request_intx_irq(dd);
12605 ret = request_msix_irqs(dd);
12612 clean_up_interrupts(dd);
12617 * Set up context values in dd. Sets:
12619 * num_rcv_contexts - number of contexts being used
12620 * n_krcv_queues - number of kernel contexts
12621 * first_user_ctxt - first non-kernel context in array of contexts
12622 * freectxts - number of free user contexts
12623 * num_send_contexts - number of PIO send contexts being used
12625 static int set_up_context_variables(struct hfi1_devdata *dd)
12627 int num_kernel_contexts;
12628 int total_contexts;
12633 * Kernel receive contexts:
12634 * - min of 2 or 1 context/numa (excluding control context)
12635 * - Context 0 - control context (VL15/multicast/error)
12636 * - Context 1 - first kernel context
12637 * - Context 2 - second kernel context
12642 * n_krcvqs is the sum of module parameter kernel receive
12643 * contexts, krcvqs[]. It does not include the control
12644 * context, so add that.
12646 num_kernel_contexts = n_krcvqs + 1;
12648 num_kernel_contexts = num_online_nodes() + 1;
12649 num_kernel_contexts =
12650 max_t(int, MIN_KERNEL_KCTXTS, num_kernel_contexts);
12652 * Every kernel receive context needs an ACK send context.
12653 * one send context is allocated for each VL{0-7} and VL15
12655 if (num_kernel_contexts > (dd->chip_send_contexts - num_vls - 1)) {
12657 "Reducing # kernel rcv contexts to: %d, from %d\n",
12658 (int)(dd->chip_send_contexts - num_vls - 1),
12659 (int)num_kernel_contexts);
12660 num_kernel_contexts = dd->chip_send_contexts - num_vls - 1;
12664 * - default to 1 user context per real (non-HT) CPU core if
12665 * num_user_contexts is negative
12667 if (num_user_contexts < 0)
12668 num_user_contexts =
12669 cpumask_weight(&dd->affinity->real_cpu_mask);
12671 total_contexts = num_kernel_contexts + num_user_contexts;
12674 * Adjust the counts given a global max.
12676 if (total_contexts > dd->chip_rcv_contexts) {
12678 "Reducing # user receive contexts to: %d, from %d\n",
12679 (int)(dd->chip_rcv_contexts - num_kernel_contexts),
12680 (int)num_user_contexts);
12681 num_user_contexts = dd->chip_rcv_contexts - num_kernel_contexts;
12683 total_contexts = num_kernel_contexts + num_user_contexts;
12686 /* the first N are kernel contexts, the rest are user contexts */
12687 dd->num_rcv_contexts = total_contexts;
12688 dd->n_krcv_queues = num_kernel_contexts;
12689 dd->first_user_ctxt = num_kernel_contexts;
12690 dd->num_user_contexts = num_user_contexts;
12691 dd->freectxts = num_user_contexts;
12693 "rcv contexts: chip %d, used %d (kernel %d, user %d)\n",
12694 (int)dd->chip_rcv_contexts,
12695 (int)dd->num_rcv_contexts,
12696 (int)dd->n_krcv_queues,
12697 (int)dd->num_rcv_contexts - dd->n_krcv_queues);
12700 * Receive array allocation:
12701 * All RcvArray entries are divided into groups of 8. This
12702 * is required by the hardware and will speed up writes to
12703 * consecutive entries by using write-combining of the entire
12706 * The number of groups are evenly divided among all contexts.
12707 * any left over groups will be given to the first N user
12710 dd->rcv_entries.group_size = RCV_INCREMENT;
12711 ngroups = dd->chip_rcv_array_count / dd->rcv_entries.group_size;
12712 dd->rcv_entries.ngroups = ngroups / dd->num_rcv_contexts;
12713 dd->rcv_entries.nctxt_extra = ngroups -
12714 (dd->num_rcv_contexts * dd->rcv_entries.ngroups);
12715 dd_dev_info(dd, "RcvArray groups %u, ctxts extra %u\n",
12716 dd->rcv_entries.ngroups,
12717 dd->rcv_entries.nctxt_extra);
12718 if (dd->rcv_entries.ngroups * dd->rcv_entries.group_size >
12719 MAX_EAGER_ENTRIES * 2) {
12720 dd->rcv_entries.ngroups = (MAX_EAGER_ENTRIES * 2) /
12721 dd->rcv_entries.group_size;
12723 "RcvArray group count too high, change to %u\n",
12724 dd->rcv_entries.ngroups);
12725 dd->rcv_entries.nctxt_extra = 0;
12728 * PIO send contexts
12730 ret = init_sc_pools_and_sizes(dd);
12731 if (ret >= 0) { /* success */
12732 dd->num_send_contexts = ret;
12735 "send contexts: chip %d, used %d (kernel %d, ack %d, user %d, vl15 %d)\n",
12736 dd->chip_send_contexts,
12737 dd->num_send_contexts,
12738 dd->sc_sizes[SC_KERNEL].count,
12739 dd->sc_sizes[SC_ACK].count,
12740 dd->sc_sizes[SC_USER].count,
12741 dd->sc_sizes[SC_VL15].count);
12742 ret = 0; /* success */
12749 * Set the device/port partition key table. The MAD code
12750 * will ensure that, at least, the partial management
12751 * partition key is present in the table.
12753 static void set_partition_keys(struct hfi1_pportdata *ppd)
12755 struct hfi1_devdata *dd = ppd->dd;
12759 dd_dev_info(dd, "Setting partition keys\n");
12760 for (i = 0; i < hfi1_get_npkeys(dd); i++) {
12761 reg |= (ppd->pkeys[i] &
12762 RCV_PARTITION_KEY_PARTITION_KEY_A_MASK) <<
12764 RCV_PARTITION_KEY_PARTITION_KEY_B_SHIFT);
12765 /* Each register holds 4 PKey values. */
12766 if ((i % 4) == 3) {
12767 write_csr(dd, RCV_PARTITION_KEY +
12768 ((i - 3) * 2), reg);
12773 /* Always enable HW pkeys check when pkeys table is set */
12774 add_rcvctrl(dd, RCV_CTRL_RCV_PARTITION_KEY_ENABLE_SMASK);
12778 * These CSRs and memories are uninitialized on reset and must be
12779 * written before reading to set the ECC/parity bits.
12781 * NOTE: All user context CSRs that are not mmaped write-only
12782 * (e.g. the TID flows) must be initialized even if the driver never
12785 static void write_uninitialized_csrs_and_memories(struct hfi1_devdata *dd)
12790 for (i = 0; i < CCE_NUM_INT_MAP_CSRS; i++)
12791 write_csr(dd, CCE_INT_MAP + (8 * i), 0);
12793 /* SendCtxtCreditReturnAddr */
12794 for (i = 0; i < dd->chip_send_contexts; i++)
12795 write_kctxt_csr(dd, i, SEND_CTXT_CREDIT_RETURN_ADDR, 0);
12797 /* PIO Send buffers */
12798 /* SDMA Send buffers */
12800 * These are not normally read, and (presently) have no method
12801 * to be read, so are not pre-initialized
12805 /* RcvHdrTailAddr */
12806 /* RcvTidFlowTable */
12807 for (i = 0; i < dd->chip_rcv_contexts; i++) {
12808 write_kctxt_csr(dd, i, RCV_HDR_ADDR, 0);
12809 write_kctxt_csr(dd, i, RCV_HDR_TAIL_ADDR, 0);
12810 for (j = 0; j < RXE_NUM_TID_FLOWS; j++)
12811 write_uctxt_csr(dd, i, RCV_TID_FLOW_TABLE + (8 * j), 0);
12815 for (i = 0; i < dd->chip_rcv_array_count; i++)
12816 write_csr(dd, RCV_ARRAY + (8 * i),
12817 RCV_ARRAY_RT_WRITE_ENABLE_SMASK);
12819 /* RcvQPMapTable */
12820 for (i = 0; i < 32; i++)
12821 write_csr(dd, RCV_QP_MAP_TABLE + (8 * i), 0);
12825 * Use the ctrl_bits in CceCtrl to clear the status_bits in CceStatus.
12827 static void clear_cce_status(struct hfi1_devdata *dd, u64 status_bits,
12830 unsigned long timeout;
12833 /* is the condition present? */
12834 reg = read_csr(dd, CCE_STATUS);
12835 if ((reg & status_bits) == 0)
12838 /* clear the condition */
12839 write_csr(dd, CCE_CTRL, ctrl_bits);
12841 /* wait for the condition to clear */
12842 timeout = jiffies + msecs_to_jiffies(CCE_STATUS_TIMEOUT);
12844 reg = read_csr(dd, CCE_STATUS);
12845 if ((reg & status_bits) == 0)
12847 if (time_after(jiffies, timeout)) {
12849 "Timeout waiting for CceStatus to clear bits 0x%llx, remaining 0x%llx\n",
12850 status_bits, reg & status_bits);
12857 /* set CCE CSRs to chip reset defaults */
12858 static void reset_cce_csrs(struct hfi1_devdata *dd)
12862 /* CCE_REVISION read-only */
12863 /* CCE_REVISION2 read-only */
12864 /* CCE_CTRL - bits clear automatically */
12865 /* CCE_STATUS read-only, use CceCtrl to clear */
12866 clear_cce_status(dd, ALL_FROZE, CCE_CTRL_SPC_UNFREEZE_SMASK);
12867 clear_cce_status(dd, ALL_TXE_PAUSE, CCE_CTRL_TXE_RESUME_SMASK);
12868 clear_cce_status(dd, ALL_RXE_PAUSE, CCE_CTRL_RXE_RESUME_SMASK);
12869 for (i = 0; i < CCE_NUM_SCRATCH; i++)
12870 write_csr(dd, CCE_SCRATCH + (8 * i), 0);
12871 /* CCE_ERR_STATUS read-only */
12872 write_csr(dd, CCE_ERR_MASK, 0);
12873 write_csr(dd, CCE_ERR_CLEAR, ~0ull);
12874 /* CCE_ERR_FORCE leave alone */
12875 for (i = 0; i < CCE_NUM_32_BIT_COUNTERS; i++)
12876 write_csr(dd, CCE_COUNTER_ARRAY32 + (8 * i), 0);
12877 write_csr(dd, CCE_DC_CTRL, CCE_DC_CTRL_RESETCSR);
12878 /* CCE_PCIE_CTRL leave alone */
12879 for (i = 0; i < CCE_NUM_MSIX_VECTORS; i++) {
12880 write_csr(dd, CCE_MSIX_TABLE_LOWER + (8 * i), 0);
12881 write_csr(dd, CCE_MSIX_TABLE_UPPER + (8 * i),
12882 CCE_MSIX_TABLE_UPPER_RESETCSR);
12884 for (i = 0; i < CCE_NUM_MSIX_PBAS; i++) {
12885 /* CCE_MSIX_PBA read-only */
12886 write_csr(dd, CCE_MSIX_INT_GRANTED, ~0ull);
12887 write_csr(dd, CCE_MSIX_VEC_CLR_WITHOUT_INT, ~0ull);
12889 for (i = 0; i < CCE_NUM_INT_MAP_CSRS; i++)
12890 write_csr(dd, CCE_INT_MAP, 0);
12891 for (i = 0; i < CCE_NUM_INT_CSRS; i++) {
12892 /* CCE_INT_STATUS read-only */
12893 write_csr(dd, CCE_INT_MASK + (8 * i), 0);
12894 write_csr(dd, CCE_INT_CLEAR + (8 * i), ~0ull);
12895 /* CCE_INT_FORCE leave alone */
12896 /* CCE_INT_BLOCKED read-only */
12898 for (i = 0; i < CCE_NUM_32_BIT_INT_COUNTERS; i++)
12899 write_csr(dd, CCE_INT_COUNTER_ARRAY32 + (8 * i), 0);
12902 /* set MISC CSRs to chip reset defaults */
12903 static void reset_misc_csrs(struct hfi1_devdata *dd)
12907 for (i = 0; i < 32; i++) {
12908 write_csr(dd, MISC_CFG_RSA_R2 + (8 * i), 0);
12909 write_csr(dd, MISC_CFG_RSA_SIGNATURE + (8 * i), 0);
12910 write_csr(dd, MISC_CFG_RSA_MODULUS + (8 * i), 0);
12913 * MISC_CFG_SHA_PRELOAD leave alone - always reads 0 and can
12914 * only be written 128-byte chunks
12916 /* init RSA engine to clear lingering errors */
12917 write_csr(dd, MISC_CFG_RSA_CMD, 1);
12918 write_csr(dd, MISC_CFG_RSA_MU, 0);
12919 write_csr(dd, MISC_CFG_FW_CTRL, 0);
12920 /* MISC_STS_8051_DIGEST read-only */
12921 /* MISC_STS_SBM_DIGEST read-only */
12922 /* MISC_STS_PCIE_DIGEST read-only */
12923 /* MISC_STS_FAB_DIGEST read-only */
12924 /* MISC_ERR_STATUS read-only */
12925 write_csr(dd, MISC_ERR_MASK, 0);
12926 write_csr(dd, MISC_ERR_CLEAR, ~0ull);
12927 /* MISC_ERR_FORCE leave alone */
12930 /* set TXE CSRs to chip reset defaults */
12931 static void reset_txe_csrs(struct hfi1_devdata *dd)
12938 write_csr(dd, SEND_CTRL, 0);
12939 __cm_reset(dd, 0); /* reset CM internal state */
12940 /* SEND_CONTEXTS read-only */
12941 /* SEND_DMA_ENGINES read-only */
12942 /* SEND_PIO_MEM_SIZE read-only */
12943 /* SEND_DMA_MEM_SIZE read-only */
12944 write_csr(dd, SEND_HIGH_PRIORITY_LIMIT, 0);
12945 pio_reset_all(dd); /* SEND_PIO_INIT_CTXT */
12946 /* SEND_PIO_ERR_STATUS read-only */
12947 write_csr(dd, SEND_PIO_ERR_MASK, 0);
12948 write_csr(dd, SEND_PIO_ERR_CLEAR, ~0ull);
12949 /* SEND_PIO_ERR_FORCE leave alone */
12950 /* SEND_DMA_ERR_STATUS read-only */
12951 write_csr(dd, SEND_DMA_ERR_MASK, 0);
12952 write_csr(dd, SEND_DMA_ERR_CLEAR, ~0ull);
12953 /* SEND_DMA_ERR_FORCE leave alone */
12954 /* SEND_EGRESS_ERR_STATUS read-only */
12955 write_csr(dd, SEND_EGRESS_ERR_MASK, 0);
12956 write_csr(dd, SEND_EGRESS_ERR_CLEAR, ~0ull);
12957 /* SEND_EGRESS_ERR_FORCE leave alone */
12958 write_csr(dd, SEND_BTH_QP, 0);
12959 write_csr(dd, SEND_STATIC_RATE_CONTROL, 0);
12960 write_csr(dd, SEND_SC2VLT0, 0);
12961 write_csr(dd, SEND_SC2VLT1, 0);
12962 write_csr(dd, SEND_SC2VLT2, 0);
12963 write_csr(dd, SEND_SC2VLT3, 0);
12964 write_csr(dd, SEND_LEN_CHECK0, 0);
12965 write_csr(dd, SEND_LEN_CHECK1, 0);
12966 /* SEND_ERR_STATUS read-only */
12967 write_csr(dd, SEND_ERR_MASK, 0);
12968 write_csr(dd, SEND_ERR_CLEAR, ~0ull);
12969 /* SEND_ERR_FORCE read-only */
12970 for (i = 0; i < VL_ARB_LOW_PRIO_TABLE_SIZE; i++)
12971 write_csr(dd, SEND_LOW_PRIORITY_LIST + (8 * i), 0);
12972 for (i = 0; i < VL_ARB_HIGH_PRIO_TABLE_SIZE; i++)
12973 write_csr(dd, SEND_HIGH_PRIORITY_LIST + (8 * i), 0);
12974 for (i = 0; i < dd->chip_send_contexts / NUM_CONTEXTS_PER_SET; i++)
12975 write_csr(dd, SEND_CONTEXT_SET_CTRL + (8 * i), 0);
12976 for (i = 0; i < TXE_NUM_32_BIT_COUNTER; i++)
12977 write_csr(dd, SEND_COUNTER_ARRAY32 + (8 * i), 0);
12978 for (i = 0; i < TXE_NUM_64_BIT_COUNTER; i++)
12979 write_csr(dd, SEND_COUNTER_ARRAY64 + (8 * i), 0);
12980 write_csr(dd, SEND_CM_CTRL, SEND_CM_CTRL_RESETCSR);
12981 write_csr(dd, SEND_CM_GLOBAL_CREDIT, SEND_CM_GLOBAL_CREDIT_RESETCSR);
12982 /* SEND_CM_CREDIT_USED_STATUS read-only */
12983 write_csr(dd, SEND_CM_TIMER_CTRL, 0);
12984 write_csr(dd, SEND_CM_LOCAL_AU_TABLE0_TO3, 0);
12985 write_csr(dd, SEND_CM_LOCAL_AU_TABLE4_TO7, 0);
12986 write_csr(dd, SEND_CM_REMOTE_AU_TABLE0_TO3, 0);
12987 write_csr(dd, SEND_CM_REMOTE_AU_TABLE4_TO7, 0);
12988 for (i = 0; i < TXE_NUM_DATA_VL; i++)
12989 write_csr(dd, SEND_CM_CREDIT_VL + (8 * i), 0);
12990 write_csr(dd, SEND_CM_CREDIT_VL15, 0);
12991 /* SEND_CM_CREDIT_USED_VL read-only */
12992 /* SEND_CM_CREDIT_USED_VL15 read-only */
12993 /* SEND_EGRESS_CTXT_STATUS read-only */
12994 /* SEND_EGRESS_SEND_DMA_STATUS read-only */
12995 write_csr(dd, SEND_EGRESS_ERR_INFO, ~0ull);
12996 /* SEND_EGRESS_ERR_INFO read-only */
12997 /* SEND_EGRESS_ERR_SOURCE read-only */
13000 * TXE Per-Context CSRs
13002 for (i = 0; i < dd->chip_send_contexts; i++) {
13003 write_kctxt_csr(dd, i, SEND_CTXT_CTRL, 0);
13004 write_kctxt_csr(dd, i, SEND_CTXT_CREDIT_CTRL, 0);
13005 write_kctxt_csr(dd, i, SEND_CTXT_CREDIT_RETURN_ADDR, 0);
13006 write_kctxt_csr(dd, i, SEND_CTXT_CREDIT_FORCE, 0);
13007 write_kctxt_csr(dd, i, SEND_CTXT_ERR_MASK, 0);
13008 write_kctxt_csr(dd, i, SEND_CTXT_ERR_CLEAR, ~0ull);
13009 write_kctxt_csr(dd, i, SEND_CTXT_CHECK_ENABLE, 0);
13010 write_kctxt_csr(dd, i, SEND_CTXT_CHECK_VL, 0);
13011 write_kctxt_csr(dd, i, SEND_CTXT_CHECK_JOB_KEY, 0);
13012 write_kctxt_csr(dd, i, SEND_CTXT_CHECK_PARTITION_KEY, 0);
13013 write_kctxt_csr(dd, i, SEND_CTXT_CHECK_SLID, 0);
13014 write_kctxt_csr(dd, i, SEND_CTXT_CHECK_OPCODE, 0);
13018 * TXE Per-SDMA CSRs
13020 for (i = 0; i < dd->chip_sdma_engines; i++) {
13021 write_kctxt_csr(dd, i, SEND_DMA_CTRL, 0);
13022 /* SEND_DMA_STATUS read-only */
13023 write_kctxt_csr(dd, i, SEND_DMA_BASE_ADDR, 0);
13024 write_kctxt_csr(dd, i, SEND_DMA_LEN_GEN, 0);
13025 write_kctxt_csr(dd, i, SEND_DMA_TAIL, 0);
13026 /* SEND_DMA_HEAD read-only */
13027 write_kctxt_csr(dd, i, SEND_DMA_HEAD_ADDR, 0);
13028 write_kctxt_csr(dd, i, SEND_DMA_PRIORITY_THLD, 0);
13029 /* SEND_DMA_IDLE_CNT read-only */
13030 write_kctxt_csr(dd, i, SEND_DMA_RELOAD_CNT, 0);
13031 write_kctxt_csr(dd, i, SEND_DMA_DESC_CNT, 0);
13032 /* SEND_DMA_DESC_FETCHED_CNT read-only */
13033 /* SEND_DMA_ENG_ERR_STATUS read-only */
13034 write_kctxt_csr(dd, i, SEND_DMA_ENG_ERR_MASK, 0);
13035 write_kctxt_csr(dd, i, SEND_DMA_ENG_ERR_CLEAR, ~0ull);
13036 /* SEND_DMA_ENG_ERR_FORCE leave alone */
13037 write_kctxt_csr(dd, i, SEND_DMA_CHECK_ENABLE, 0);
13038 write_kctxt_csr(dd, i, SEND_DMA_CHECK_VL, 0);
13039 write_kctxt_csr(dd, i, SEND_DMA_CHECK_JOB_KEY, 0);
13040 write_kctxt_csr(dd, i, SEND_DMA_CHECK_PARTITION_KEY, 0);
13041 write_kctxt_csr(dd, i, SEND_DMA_CHECK_SLID, 0);
13042 write_kctxt_csr(dd, i, SEND_DMA_CHECK_OPCODE, 0);
13043 write_kctxt_csr(dd, i, SEND_DMA_MEMORY, 0);
13049 * o Packet ingress is disabled, i.e. RcvCtrl.RcvPortEnable == 0
13051 static void init_rbufs(struct hfi1_devdata *dd)
13057 * Wait for DMA to stop: RxRbufPktPending and RxPktInProgress are
13062 reg = read_csr(dd, RCV_STATUS);
13063 if ((reg & (RCV_STATUS_RX_RBUF_PKT_PENDING_SMASK
13064 | RCV_STATUS_RX_PKT_IN_PROGRESS_SMASK)) == 0)
13067 * Give up after 1ms - maximum wait time.
13069 * RBuf size is 148KiB. Slowest possible is PCIe Gen1 x1 at
13070 * 250MB/s bandwidth. Lower rate to 66% for overhead to get:
13071 * 148 KB / (66% * 250MB/s) = 920us
13073 if (count++ > 500) {
13075 "%s: in-progress DMA not clearing: RcvStatus 0x%llx, continuing\n",
13079 udelay(2); /* do not busy-wait the CSR */
13082 /* start the init - expect RcvCtrl to be 0 */
13083 write_csr(dd, RCV_CTRL, RCV_CTRL_RX_RBUF_INIT_SMASK);
13086 * Read to force the write of Rcvtrl.RxRbufInit. There is a brief
13087 * period after the write before RcvStatus.RxRbufInitDone is valid.
13088 * The delay in the first run through the loop below is sufficient and
13089 * required before the first read of RcvStatus.RxRbufInintDone.
13091 read_csr(dd, RCV_CTRL);
13093 /* wait for the init to finish */
13096 /* delay is required first time through - see above */
13097 udelay(2); /* do not busy-wait the CSR */
13098 reg = read_csr(dd, RCV_STATUS);
13099 if (reg & (RCV_STATUS_RX_RBUF_INIT_DONE_SMASK))
13102 /* give up after 100us - slowest possible at 33MHz is 73us */
13103 if (count++ > 50) {
13105 "%s: RcvStatus.RxRbufInit not set, continuing\n",
13112 /* set RXE CSRs to chip reset defaults */
13113 static void reset_rxe_csrs(struct hfi1_devdata *dd)
13120 write_csr(dd, RCV_CTRL, 0);
13122 /* RCV_STATUS read-only */
13123 /* RCV_CONTEXTS read-only */
13124 /* RCV_ARRAY_CNT read-only */
13125 /* RCV_BUF_SIZE read-only */
13126 write_csr(dd, RCV_BTH_QP, 0);
13127 write_csr(dd, RCV_MULTICAST, 0);
13128 write_csr(dd, RCV_BYPASS, 0);
13129 write_csr(dd, RCV_VL15, 0);
13130 /* this is a clear-down */
13131 write_csr(dd, RCV_ERR_INFO,
13132 RCV_ERR_INFO_RCV_EXCESS_BUFFER_OVERRUN_SMASK);
13133 /* RCV_ERR_STATUS read-only */
13134 write_csr(dd, RCV_ERR_MASK, 0);
13135 write_csr(dd, RCV_ERR_CLEAR, ~0ull);
13136 /* RCV_ERR_FORCE leave alone */
13137 for (i = 0; i < 32; i++)
13138 write_csr(dd, RCV_QP_MAP_TABLE + (8 * i), 0);
13139 for (i = 0; i < 4; i++)
13140 write_csr(dd, RCV_PARTITION_KEY + (8 * i), 0);
13141 for (i = 0; i < RXE_NUM_32_BIT_COUNTERS; i++)
13142 write_csr(dd, RCV_COUNTER_ARRAY32 + (8 * i), 0);
13143 for (i = 0; i < RXE_NUM_64_BIT_COUNTERS; i++)
13144 write_csr(dd, RCV_COUNTER_ARRAY64 + (8 * i), 0);
13145 for (i = 0; i < RXE_NUM_RSM_INSTANCES; i++) {
13146 write_csr(dd, RCV_RSM_CFG + (8 * i), 0);
13147 write_csr(dd, RCV_RSM_SELECT + (8 * i), 0);
13148 write_csr(dd, RCV_RSM_MATCH + (8 * i), 0);
13150 for (i = 0; i < 32; i++)
13151 write_csr(dd, RCV_RSM_MAP_TABLE + (8 * i), 0);
13154 * RXE Kernel and User Per-Context CSRs
13156 for (i = 0; i < dd->chip_rcv_contexts; i++) {
13158 write_kctxt_csr(dd, i, RCV_CTXT_CTRL, 0);
13159 /* RCV_CTXT_STATUS read-only */
13160 write_kctxt_csr(dd, i, RCV_EGR_CTRL, 0);
13161 write_kctxt_csr(dd, i, RCV_TID_CTRL, 0);
13162 write_kctxt_csr(dd, i, RCV_KEY_CTRL, 0);
13163 write_kctxt_csr(dd, i, RCV_HDR_ADDR, 0);
13164 write_kctxt_csr(dd, i, RCV_HDR_CNT, 0);
13165 write_kctxt_csr(dd, i, RCV_HDR_ENT_SIZE, 0);
13166 write_kctxt_csr(dd, i, RCV_HDR_SIZE, 0);
13167 write_kctxt_csr(dd, i, RCV_HDR_TAIL_ADDR, 0);
13168 write_kctxt_csr(dd, i, RCV_AVAIL_TIME_OUT, 0);
13169 write_kctxt_csr(dd, i, RCV_HDR_OVFL_CNT, 0);
13172 /* RCV_HDR_TAIL read-only */
13173 write_uctxt_csr(dd, i, RCV_HDR_HEAD, 0);
13174 /* RCV_EGR_INDEX_TAIL read-only */
13175 write_uctxt_csr(dd, i, RCV_EGR_INDEX_HEAD, 0);
13176 /* RCV_EGR_OFFSET_TAIL read-only */
13177 for (j = 0; j < RXE_NUM_TID_FLOWS; j++) {
13178 write_uctxt_csr(dd, i,
13179 RCV_TID_FLOW_TABLE + (8 * j), 0);
13185 * Set sc2vl tables.
13187 * They power on to zeros, so to avoid send context errors
13188 * they need to be set:
13190 * SC 0-7 -> VL 0-7 (respectively)
13195 static void init_sc2vl_tables(struct hfi1_devdata *dd)
13198 /* init per architecture spec, constrained by hardware capability */
13200 /* HFI maps sent packets */
13201 write_csr(dd, SEND_SC2VLT0, SC2VL_VAL(
13207 write_csr(dd, SEND_SC2VLT1, SC2VL_VAL(
13213 write_csr(dd, SEND_SC2VLT2, SC2VL_VAL(
13219 write_csr(dd, SEND_SC2VLT3, SC2VL_VAL(
13226 /* DC maps received packets */
13227 write_csr(dd, DCC_CFG_SC_VL_TABLE_15_0, DC_SC_VL_VAL(
13229 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7,
13230 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 15));
13231 write_csr(dd, DCC_CFG_SC_VL_TABLE_31_16, DC_SC_VL_VAL(
13233 16, 0, 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0,
13234 24, 0, 25, 0, 26, 0, 27, 0, 28, 0, 29, 0, 30, 0, 31, 0));
13236 /* initialize the cached sc2vl values consistently with h/w */
13237 for (i = 0; i < 32; i++) {
13238 if (i < 8 || i == 15)
13239 *((u8 *)(dd->sc2vl) + i) = (u8)i;
13241 *((u8 *)(dd->sc2vl) + i) = 0;
13246 * Read chip sizes and then reset parts to sane, disabled, values. We cannot
13247 * depend on the chip going through a power-on reset - a driver may be loaded
13248 * and unloaded many times.
13250 * Do not write any CSR values to the chip in this routine - there may be
13251 * a reset following the (possible) FLR in this routine.
13254 static void init_chip(struct hfi1_devdata *dd)
13259 * Put the HFI CSRs in a known state.
13260 * Combine this with a DC reset.
13262 * Stop the device from doing anything while we do a
13263 * reset. We know there are no other active users of
13264 * the device since we are now in charge. Turn off
13265 * off all outbound and inbound traffic and make sure
13266 * the device does not generate any interrupts.
13269 /* disable send contexts and SDMA engines */
13270 write_csr(dd, SEND_CTRL, 0);
13271 for (i = 0; i < dd->chip_send_contexts; i++)
13272 write_kctxt_csr(dd, i, SEND_CTXT_CTRL, 0);
13273 for (i = 0; i < dd->chip_sdma_engines; i++)
13274 write_kctxt_csr(dd, i, SEND_DMA_CTRL, 0);
13275 /* disable port (turn off RXE inbound traffic) and contexts */
13276 write_csr(dd, RCV_CTRL, 0);
13277 for (i = 0; i < dd->chip_rcv_contexts; i++)
13278 write_csr(dd, RCV_CTXT_CTRL, 0);
13279 /* mask all interrupt sources */
13280 for (i = 0; i < CCE_NUM_INT_CSRS; i++)
13281 write_csr(dd, CCE_INT_MASK + (8 * i), 0ull);
13284 * DC Reset: do a full DC reset before the register clear.
13285 * A recommended length of time to hold is one CSR read,
13286 * so reread the CceDcCtrl. Then, hold the DC in reset
13287 * across the clear.
13289 write_csr(dd, CCE_DC_CTRL, CCE_DC_CTRL_DC_RESET_SMASK);
13290 (void)read_csr(dd, CCE_DC_CTRL);
13294 * A FLR will reset the SPC core and part of the PCIe.
13295 * The parts that need to be restored have already been
13298 dd_dev_info(dd, "Resetting CSRs with FLR\n");
13300 /* do the FLR, the DC reset will remain */
13303 /* restore command and BARs */
13304 restore_pci_variables(dd);
13307 dd_dev_info(dd, "Resetting CSRs with FLR\n");
13309 restore_pci_variables(dd);
13312 dd_dev_info(dd, "Resetting CSRs with writes\n");
13313 reset_cce_csrs(dd);
13314 reset_txe_csrs(dd);
13315 reset_rxe_csrs(dd);
13316 reset_misc_csrs(dd);
13318 /* clear the DC reset */
13319 write_csr(dd, CCE_DC_CTRL, 0);
13321 /* Set the LED off */
13325 * Clear the QSFP reset.
13326 * An FLR enforces a 0 on all out pins. The driver does not touch
13327 * ASIC_QSFPn_OUT otherwise. This leaves RESET_N low and
13328 * anything plugged constantly in reset, if it pays attention
13330 * Prime examples of this are optical cables. Set all pins high.
13331 * I2CCLK and I2CDAT will change per direction, and INT_N and
13332 * MODPRS_N are input only and their value is ignored.
13334 write_csr(dd, ASIC_QSFP1_OUT, 0x1f);
13335 write_csr(dd, ASIC_QSFP2_OUT, 0x1f);
13336 init_chip_resources(dd);
13339 static void init_early_variables(struct hfi1_devdata *dd)
13343 /* assign link credit variables */
13345 dd->link_credits = CM_GLOBAL_CREDITS;
13347 dd->link_credits--;
13348 dd->vcu = cu_to_vcu(hfi1_cu);
13349 /* enough room for 8 MAD packets plus header - 17K */
13350 dd->vl15_init = (8 * (2048 + 128)) / vau_to_au(dd->vau);
13351 if (dd->vl15_init > dd->link_credits)
13352 dd->vl15_init = dd->link_credits;
13354 write_uninitialized_csrs_and_memories(dd);
13356 if (HFI1_CAP_IS_KSET(PKEY_CHECK))
13357 for (i = 0; i < dd->num_pports; i++) {
13358 struct hfi1_pportdata *ppd = &dd->pport[i];
13360 set_partition_keys(ppd);
13362 init_sc2vl_tables(dd);
13365 static void init_kdeth_qp(struct hfi1_devdata *dd)
13367 /* user changed the KDETH_QP */
13368 if (kdeth_qp != 0 && kdeth_qp >= 0xff) {
13369 /* out of range or illegal value */
13370 dd_dev_err(dd, "Invalid KDETH queue pair prefix, ignoring");
13373 if (kdeth_qp == 0) /* not set, or failed range check */
13374 kdeth_qp = DEFAULT_KDETH_QP;
13376 write_csr(dd, SEND_BTH_QP,
13377 (kdeth_qp & SEND_BTH_QP_KDETH_QP_MASK) <<
13378 SEND_BTH_QP_KDETH_QP_SHIFT);
13380 write_csr(dd, RCV_BTH_QP,
13381 (kdeth_qp & RCV_BTH_QP_KDETH_QP_MASK) <<
13382 RCV_BTH_QP_KDETH_QP_SHIFT);
13387 * @dd - device data
13388 * @first_ctxt - first context
13389 * @last_ctxt - first context
13391 * This return sets the qpn mapping table that
13392 * is indexed by qpn[8:1].
13394 * The routine will round robin the 256 settings
13395 * from first_ctxt to last_ctxt.
13397 * The first/last looks ahead to having specialized
13398 * receive contexts for mgmt and bypass. Normal
13399 * verbs traffic will assumed to be on a range
13400 * of receive contexts.
13402 static void init_qpmap_table(struct hfi1_devdata *dd,
13407 u64 regno = RCV_QP_MAP_TABLE;
13409 u64 ctxt = first_ctxt;
13411 for (i = 0; i < 256; i++) {
13412 reg |= ctxt << (8 * (i % 8));
13414 if (ctxt > last_ctxt)
13417 write_csr(dd, regno, reg);
13423 add_rcvctrl(dd, RCV_CTRL_RCV_QP_MAP_ENABLE_SMASK
13424 | RCV_CTRL_RCV_BYPASS_ENABLE_SMASK);
13427 struct rsm_map_table {
13428 u64 map[NUM_MAP_REGS];
13433 * Return an initialized RMT map table for users to fill in. OK if it
13434 * returns NULL, indicating no table.
13436 static struct rsm_map_table *alloc_rsm_map_table(struct hfi1_devdata *dd)
13438 struct rsm_map_table *rmt;
13439 u8 rxcontext = is_ax(dd) ? 0 : 0xff; /* 0 is default if a0 ver. */
13441 rmt = kmalloc(sizeof(*rmt), GFP_KERNEL);
13443 memset(rmt->map, rxcontext, sizeof(rmt->map));
13451 * Write the final RMT map table to the chip and free the table. OK if
13454 static void complete_rsm_map_table(struct hfi1_devdata *dd,
13455 struct rsm_map_table *rmt)
13460 /* write table to chip */
13461 for (i = 0; i < NUM_MAP_REGS; i++)
13462 write_csr(dd, RCV_RSM_MAP_TABLE + (8 * i), rmt->map[i]);
13465 add_rcvctrl(dd, RCV_CTRL_RCV_RSM_ENABLE_SMASK);
13470 * init_qos - init RX qos
13471 * @dd - device data
13472 * @rmt - RSM map table
13474 * This routine initializes Rule 0 and the RSM map table to implement
13475 * quality of service (qos).
13477 * If all of the limit tests succeed, qos is applied based on the array
13478 * interpretation of krcvqs where entry 0 is VL0.
13480 * The number of vl bits (n) and the number of qpn bits (m) are computed to
13481 * feed both the RSM map table and the single rule.
13483 static void init_qos(struct hfi1_devdata *dd, struct rsm_map_table *rmt)
13486 unsigned qpns_per_vl, ctxt, i, qpn, n = 1, m;
13487 unsigned int rmt_entries;
13492 dd->n_krcv_queues <= MIN_KERNEL_KCTXTS ||
13496 for (i = 0; i < min_t(unsigned, num_vls, krcvqsset); i++)
13497 if (krcvqs[i] > max_by_vl)
13498 max_by_vl = krcvqs[i];
13499 if (max_by_vl > 32)
13501 qpns_per_vl = __roundup_pow_of_two(max_by_vl);
13502 /* determine bits vl */
13503 n = ilog2(__roundup_pow_of_two(num_vls));
13504 /* determine bits for qpn */
13505 m = ilog2(qpns_per_vl);
13508 /* enough room in the map table? */
13509 rmt_entries = 1 << (m + n);
13510 if (rmt->used + rmt_entries >= NUM_MAP_ENTRIES)
13512 /* add qos entries to the the RSM map table */
13513 for (i = 0, ctxt = FIRST_KERNEL_KCTXT; i < num_vls; i++) {
13516 for (qpn = 0, tctxt = ctxt;
13517 krcvqs[i] && qpn < qpns_per_vl; qpn++) {
13518 unsigned idx, regoff, regidx;
13520 /* generate the index the hardware will produce */
13521 idx = rmt->used + ((qpn << n) ^ i);
13522 regoff = (idx % 8) * 8;
13524 /* replace default with context number */
13525 reg = rmt->map[regidx];
13526 reg &= ~(RCV_RSM_MAP_TABLE_RCV_CONTEXT_A_MASK
13528 reg |= (u64)(tctxt++) << regoff;
13529 rmt->map[regidx] = reg;
13530 if (tctxt == ctxt + krcvqs[i])
13536 write_csr(dd, RCV_RSM_CFG /* + (8 * 0) */,
13537 (u64)rmt->used << RCV_RSM_CFG_OFFSET_SHIFT |
13538 RCV_RSM_CFG_ENABLE_OR_CHAIN_RSM0_MASK <<
13539 RCV_RSM_CFG_ENABLE_OR_CHAIN_RSM0_SHIFT |
13540 2ull << RCV_RSM_CFG_PACKET_TYPE_SHIFT);
13541 write_csr(dd, RCV_RSM_SELECT /* + (8 * 0) */,
13542 LRH_BTH_MATCH_OFFSET << RCV_RSM_SELECT_FIELD1_OFFSET_SHIFT |
13543 LRH_SC_MATCH_OFFSET << RCV_RSM_SELECT_FIELD2_OFFSET_SHIFT |
13544 LRH_SC_SELECT_OFFSET << RCV_RSM_SELECT_INDEX1_OFFSET_SHIFT |
13545 ((u64)n) << RCV_RSM_SELECT_INDEX1_WIDTH_SHIFT |
13546 QPN_SELECT_OFFSET << RCV_RSM_SELECT_INDEX2_OFFSET_SHIFT |
13547 ((u64)m + (u64)n) << RCV_RSM_SELECT_INDEX2_WIDTH_SHIFT);
13548 write_csr(dd, RCV_RSM_MATCH /* + (8 * 0) */,
13549 LRH_BTH_MASK << RCV_RSM_MATCH_MASK1_SHIFT |
13550 LRH_BTH_VALUE << RCV_RSM_MATCH_VALUE1_SHIFT |
13551 LRH_SC_MASK << RCV_RSM_MATCH_MASK2_SHIFT |
13552 LRH_SC_VALUE << RCV_RSM_MATCH_VALUE2_SHIFT);
13553 /* mark RSM map entries as used */
13554 rmt->used += rmt_entries;
13555 /* map everything else to the mcast/err/vl15 context */
13556 init_qpmap_table(dd, HFI1_CTRL_CTXT, HFI1_CTRL_CTXT);
13557 dd->qos_shift = n + 1;
13561 init_qpmap_table(dd, FIRST_KERNEL_KCTXT, dd->n_krcv_queues - 1);
13564 static void init_rxe(struct hfi1_devdata *dd)
13566 struct rsm_map_table *rmt;
13568 /* enable all receive errors */
13569 write_csr(dd, RCV_ERR_MASK, ~0ull);
13571 rmt = alloc_rsm_map_table(dd);
13572 /* set up QOS, including the QPN map table */
13574 complete_rsm_map_table(dd, rmt);
13578 * make sure RcvCtrl.RcvWcb <= PCIe Device Control
13579 * Register Max_Payload_Size (PCI_EXP_DEVCTL in Linux PCIe config
13580 * space, PciCfgCap2.MaxPayloadSize in HFI). There is only one
13581 * invalid configuration: RcvCtrl.RcvWcb set to its max of 256 and
13582 * Max_PayLoad_Size set to its minimum of 128.
13584 * Presently, RcvCtrl.RcvWcb is not modified from its default of 0
13585 * (64 bytes). Max_Payload_Size is possibly modified upward in
13586 * tune_pcie_caps() which is called after this routine.
13590 static void init_other(struct hfi1_devdata *dd)
13592 /* enable all CCE errors */
13593 write_csr(dd, CCE_ERR_MASK, ~0ull);
13594 /* enable *some* Misc errors */
13595 write_csr(dd, MISC_ERR_MASK, DRIVER_MISC_MASK);
13596 /* enable all DC errors, except LCB */
13597 write_csr(dd, DCC_ERR_FLG_EN, ~0ull);
13598 write_csr(dd, DC_DC8051_ERR_EN, ~0ull);
13602 * Fill out the given AU table using the given CU. A CU is defined in terms
13603 * AUs. The table is a an encoding: given the index, how many AUs does that
13606 * NOTE: Assumes that the register layout is the same for the
13607 * local and remote tables.
13609 static void assign_cm_au_table(struct hfi1_devdata *dd, u32 cu,
13610 u32 csr0to3, u32 csr4to7)
13612 write_csr(dd, csr0to3,
13613 0ull << SEND_CM_LOCAL_AU_TABLE0_TO3_LOCAL_AU_TABLE0_SHIFT |
13614 1ull << SEND_CM_LOCAL_AU_TABLE0_TO3_LOCAL_AU_TABLE1_SHIFT |
13616 SEND_CM_LOCAL_AU_TABLE0_TO3_LOCAL_AU_TABLE2_SHIFT |
13618 SEND_CM_LOCAL_AU_TABLE0_TO3_LOCAL_AU_TABLE3_SHIFT);
13619 write_csr(dd, csr4to7,
13621 SEND_CM_LOCAL_AU_TABLE4_TO7_LOCAL_AU_TABLE4_SHIFT |
13623 SEND_CM_LOCAL_AU_TABLE4_TO7_LOCAL_AU_TABLE5_SHIFT |
13625 SEND_CM_LOCAL_AU_TABLE4_TO7_LOCAL_AU_TABLE6_SHIFT |
13627 SEND_CM_LOCAL_AU_TABLE4_TO7_LOCAL_AU_TABLE7_SHIFT);
13630 static void assign_local_cm_au_table(struct hfi1_devdata *dd, u8 vcu)
13632 assign_cm_au_table(dd, vcu_to_cu(vcu), SEND_CM_LOCAL_AU_TABLE0_TO3,
13633 SEND_CM_LOCAL_AU_TABLE4_TO7);
13636 void assign_remote_cm_au_table(struct hfi1_devdata *dd, u8 vcu)
13638 assign_cm_au_table(dd, vcu_to_cu(vcu), SEND_CM_REMOTE_AU_TABLE0_TO3,
13639 SEND_CM_REMOTE_AU_TABLE4_TO7);
13642 static void init_txe(struct hfi1_devdata *dd)
13646 /* enable all PIO, SDMA, general, and Egress errors */
13647 write_csr(dd, SEND_PIO_ERR_MASK, ~0ull);
13648 write_csr(dd, SEND_DMA_ERR_MASK, ~0ull);
13649 write_csr(dd, SEND_ERR_MASK, ~0ull);
13650 write_csr(dd, SEND_EGRESS_ERR_MASK, ~0ull);
13652 /* enable all per-context and per-SDMA engine errors */
13653 for (i = 0; i < dd->chip_send_contexts; i++)
13654 write_kctxt_csr(dd, i, SEND_CTXT_ERR_MASK, ~0ull);
13655 for (i = 0; i < dd->chip_sdma_engines; i++)
13656 write_kctxt_csr(dd, i, SEND_DMA_ENG_ERR_MASK, ~0ull);
13658 /* set the local CU to AU mapping */
13659 assign_local_cm_au_table(dd, dd->vcu);
13662 * Set reasonable default for Credit Return Timer
13663 * Don't set on Simulator - causes it to choke.
13665 if (dd->icode != ICODE_FUNCTIONAL_SIMULATOR)
13666 write_csr(dd, SEND_CM_TIMER_CTRL, HFI1_CREDIT_RETURN_RATE);
13669 int hfi1_set_ctxt_jkey(struct hfi1_devdata *dd, unsigned ctxt, u16 jkey)
13671 struct hfi1_ctxtdata *rcd = dd->rcd[ctxt];
13676 if (!rcd || !rcd->sc) {
13680 sctxt = rcd->sc->hw_context;
13681 reg = SEND_CTXT_CHECK_JOB_KEY_MASK_SMASK | /* mask is always 1's */
13682 ((jkey & SEND_CTXT_CHECK_JOB_KEY_VALUE_MASK) <<
13683 SEND_CTXT_CHECK_JOB_KEY_VALUE_SHIFT);
13684 /* JOB_KEY_ALLOW_PERMISSIVE is not allowed by default */
13685 if (HFI1_CAP_KGET_MASK(rcd->flags, ALLOW_PERM_JKEY))
13686 reg |= SEND_CTXT_CHECK_JOB_KEY_ALLOW_PERMISSIVE_SMASK;
13687 write_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_JOB_KEY, reg);
13689 * Enable send-side J_KEY integrity check, unless this is A0 h/w
13692 reg = read_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_ENABLE);
13693 reg |= SEND_CTXT_CHECK_ENABLE_CHECK_JOB_KEY_SMASK;
13694 write_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_ENABLE, reg);
13697 /* Enable J_KEY check on receive context. */
13698 reg = RCV_KEY_CTRL_JOB_KEY_ENABLE_SMASK |
13699 ((jkey & RCV_KEY_CTRL_JOB_KEY_VALUE_MASK) <<
13700 RCV_KEY_CTRL_JOB_KEY_VALUE_SHIFT);
13701 write_kctxt_csr(dd, ctxt, RCV_KEY_CTRL, reg);
13706 int hfi1_clear_ctxt_jkey(struct hfi1_devdata *dd, unsigned ctxt)
13708 struct hfi1_ctxtdata *rcd = dd->rcd[ctxt];
13713 if (!rcd || !rcd->sc) {
13717 sctxt = rcd->sc->hw_context;
13718 write_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_JOB_KEY, 0);
13720 * Disable send-side J_KEY integrity check, unless this is A0 h/w.
13721 * This check would not have been enabled for A0 h/w, see
13725 reg = read_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_ENABLE);
13726 reg &= ~SEND_CTXT_CHECK_ENABLE_CHECK_JOB_KEY_SMASK;
13727 write_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_ENABLE, reg);
13729 /* Turn off the J_KEY on the receive side */
13730 write_kctxt_csr(dd, ctxt, RCV_KEY_CTRL, 0);
13735 int hfi1_set_ctxt_pkey(struct hfi1_devdata *dd, unsigned ctxt, u16 pkey)
13737 struct hfi1_ctxtdata *rcd;
13742 if (ctxt < dd->num_rcv_contexts) {
13743 rcd = dd->rcd[ctxt];
13748 if (!rcd || !rcd->sc) {
13752 sctxt = rcd->sc->hw_context;
13753 reg = ((u64)pkey & SEND_CTXT_CHECK_PARTITION_KEY_VALUE_MASK) <<
13754 SEND_CTXT_CHECK_PARTITION_KEY_VALUE_SHIFT;
13755 write_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_PARTITION_KEY, reg);
13756 reg = read_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_ENABLE);
13757 reg |= SEND_CTXT_CHECK_ENABLE_CHECK_PARTITION_KEY_SMASK;
13758 reg &= ~SEND_CTXT_CHECK_ENABLE_DISALLOW_KDETH_PACKETS_SMASK;
13759 write_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_ENABLE, reg);
13764 int hfi1_clear_ctxt_pkey(struct hfi1_devdata *dd, unsigned ctxt)
13766 struct hfi1_ctxtdata *rcd;
13771 if (ctxt < dd->num_rcv_contexts) {
13772 rcd = dd->rcd[ctxt];
13777 if (!rcd || !rcd->sc) {
13781 sctxt = rcd->sc->hw_context;
13782 reg = read_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_ENABLE);
13783 reg &= ~SEND_CTXT_CHECK_ENABLE_CHECK_PARTITION_KEY_SMASK;
13784 write_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_ENABLE, reg);
13785 write_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_PARTITION_KEY, 0);
13791 * Start doing the clean up the the chip. Our clean up happens in multiple
13792 * stages and this is just the first.
13794 void hfi1_start_cleanup(struct hfi1_devdata *dd)
13799 clean_up_interrupts(dd);
13800 finish_chip_resources(dd);
13803 #define HFI_BASE_GUID(dev) \
13804 ((dev)->base_guid & ~(1ULL << GUID_HFI_INDEX_SHIFT))
13807 * Information can be shared between the two HFIs on the same ASIC
13808 * in the same OS. This function finds the peer device and sets
13809 * up a shared structure.
13811 static int init_asic_data(struct hfi1_devdata *dd)
13813 unsigned long flags;
13814 struct hfi1_devdata *tmp, *peer = NULL;
13817 spin_lock_irqsave(&hfi1_devs_lock, flags);
13818 /* Find our peer device */
13819 list_for_each_entry(tmp, &hfi1_dev_list, list) {
13820 if ((HFI_BASE_GUID(dd) == HFI_BASE_GUID(tmp)) &&
13821 dd->unit != tmp->unit) {
13828 dd->asic_data = peer->asic_data;
13830 dd->asic_data = kzalloc(sizeof(*dd->asic_data), GFP_KERNEL);
13831 if (!dd->asic_data) {
13835 mutex_init(&dd->asic_data->asic_resource_mutex);
13837 dd->asic_data->dds[dd->hfi1_id] = dd; /* self back-pointer */
13840 spin_unlock_irqrestore(&hfi1_devs_lock, flags);
13845 * Set dd->boardname. Use a generic name if a name is not returned from
13846 * EFI variable space.
13848 * Return 0 on success, -ENOMEM if space could not be allocated.
13850 static int obtain_boardname(struct hfi1_devdata *dd)
13852 /* generic board description */
13853 const char generic[] =
13854 "Intel Omni-Path Host Fabric Interface Adapter 100 Series";
13855 unsigned long size;
13858 ret = read_hfi1_efi_var(dd, "description", &size,
13859 (void **)&dd->boardname);
13861 dd_dev_info(dd, "Board description not found\n");
13862 /* use generic description */
13863 dd->boardname = kstrdup(generic, GFP_KERNEL);
13864 if (!dd->boardname)
13871 * Check the interrupt registers to make sure that they are mapped correctly.
13872 * It is intended to help user identify any mismapping by VMM when the driver
13873 * is running in a VM. This function should only be called before interrupt
13874 * is set up properly.
13876 * Return 0 on success, -EINVAL on failure.
13878 static int check_int_registers(struct hfi1_devdata *dd)
13881 u64 all_bits = ~(u64)0;
13884 /* Clear CceIntMask[0] to avoid raising any interrupts */
13885 mask = read_csr(dd, CCE_INT_MASK);
13886 write_csr(dd, CCE_INT_MASK, 0ull);
13887 reg = read_csr(dd, CCE_INT_MASK);
13891 /* Clear all interrupt status bits */
13892 write_csr(dd, CCE_INT_CLEAR, all_bits);
13893 reg = read_csr(dd, CCE_INT_STATUS);
13897 /* Set all interrupt status bits */
13898 write_csr(dd, CCE_INT_FORCE, all_bits);
13899 reg = read_csr(dd, CCE_INT_STATUS);
13900 if (reg != all_bits)
13903 /* Restore the interrupt mask */
13904 write_csr(dd, CCE_INT_CLEAR, all_bits);
13905 write_csr(dd, CCE_INT_MASK, mask);
13909 write_csr(dd, CCE_INT_MASK, mask);
13910 dd_dev_err(dd, "Interrupt registers not properly mapped by VMM\n");
13915 * Allocate and initialize the device structure for the hfi.
13916 * @dev: the pci_dev for hfi1_ib device
13917 * @ent: pci_device_id struct for this dev
13919 * Also allocates, initializes, and returns the devdata struct for this
13922 * This is global, and is called directly at init to set up the
13923 * chip-specific function pointers for later use.
13925 struct hfi1_devdata *hfi1_init_dd(struct pci_dev *pdev,
13926 const struct pci_device_id *ent)
13928 struct hfi1_devdata *dd;
13929 struct hfi1_pportdata *ppd;
13932 static const char * const inames[] = { /* implementation names */
13934 "RTL VCS simulation",
13935 "RTL FPGA emulation",
13936 "Functional simulator"
13938 struct pci_dev *parent = pdev->bus->self;
13940 dd = hfi1_alloc_devdata(pdev, NUM_IB_PORTS *
13941 sizeof(struct hfi1_pportdata));
13945 for (i = 0; i < dd->num_pports; i++, ppd++) {
13947 /* init common fields */
13948 hfi1_init_pportdata(pdev, ppd, dd, 0, 1);
13949 /* DC supports 4 link widths */
13950 ppd->link_width_supported =
13951 OPA_LINK_WIDTH_1X | OPA_LINK_WIDTH_2X |
13952 OPA_LINK_WIDTH_3X | OPA_LINK_WIDTH_4X;
13953 ppd->link_width_downgrade_supported =
13954 ppd->link_width_supported;
13955 /* start out enabling only 4X */
13956 ppd->link_width_enabled = OPA_LINK_WIDTH_4X;
13957 ppd->link_width_downgrade_enabled =
13958 ppd->link_width_downgrade_supported;
13959 /* link width active is 0 when link is down */
13960 /* link width downgrade active is 0 when link is down */
13962 if (num_vls < HFI1_MIN_VLS_SUPPORTED ||
13963 num_vls > HFI1_MAX_VLS_SUPPORTED) {
13964 hfi1_early_err(&pdev->dev,
13965 "Invalid num_vls %u, using %u VLs\n",
13966 num_vls, HFI1_MAX_VLS_SUPPORTED);
13967 num_vls = HFI1_MAX_VLS_SUPPORTED;
13969 ppd->vls_supported = num_vls;
13970 ppd->vls_operational = ppd->vls_supported;
13971 ppd->actual_vls_operational = ppd->vls_supported;
13972 /* Set the default MTU. */
13973 for (vl = 0; vl < num_vls; vl++)
13974 dd->vld[vl].mtu = hfi1_max_mtu;
13975 dd->vld[15].mtu = MAX_MAD_PACKET;
13977 * Set the initial values to reasonable default, will be set
13978 * for real when link is up.
13980 ppd->lstate = IB_PORT_DOWN;
13981 ppd->overrun_threshold = 0x4;
13982 ppd->phy_error_threshold = 0xf;
13983 ppd->port_crc_mode_enabled = link_crc_mask;
13984 /* initialize supported LTP CRC mode */
13985 ppd->port_ltp_crc_mode = cap_to_port_ltp(link_crc_mask) << 8;
13986 /* initialize enabled LTP CRC mode */
13987 ppd->port_ltp_crc_mode |= cap_to_port_ltp(link_crc_mask) << 4;
13988 /* start in offline */
13989 ppd->host_link_state = HLS_DN_OFFLINE;
13990 init_vl_arb_caches(ppd);
13991 ppd->last_pstate = 0xff; /* invalid value */
13994 dd->link_default = HLS_DN_POLL;
13997 * Do remaining PCIe setup and save PCIe values in dd.
13998 * Any error printing is already done by the init code.
13999 * On return, we have the chip mapped.
14001 ret = hfi1_pcie_ddinit(dd, pdev, ent);
14005 /* verify that reads actually work, save revision for reset check */
14006 dd->revision = read_csr(dd, CCE_REVISION);
14007 if (dd->revision == ~(u64)0) {
14008 dd_dev_err(dd, "cannot read chip CSRs\n");
14012 dd->majrev = (dd->revision >> CCE_REVISION_CHIP_REV_MAJOR_SHIFT)
14013 & CCE_REVISION_CHIP_REV_MAJOR_MASK;
14014 dd->minrev = (dd->revision >> CCE_REVISION_CHIP_REV_MINOR_SHIFT)
14015 & CCE_REVISION_CHIP_REV_MINOR_MASK;
14018 * Check interrupt registers mapping if the driver has no access to
14019 * the upstream component. In this case, it is likely that the driver
14020 * is running in a VM.
14023 ret = check_int_registers(dd);
14029 * obtain the hardware ID - NOT related to unit, which is a
14030 * software enumeration
14032 reg = read_csr(dd, CCE_REVISION2);
14033 dd->hfi1_id = (reg >> CCE_REVISION2_HFI_ID_SHIFT)
14034 & CCE_REVISION2_HFI_ID_MASK;
14035 /* the variable size will remove unwanted bits */
14036 dd->icode = reg >> CCE_REVISION2_IMPL_CODE_SHIFT;
14037 dd->irev = reg >> CCE_REVISION2_IMPL_REVISION_SHIFT;
14038 dd_dev_info(dd, "Implementation: %s, revision 0x%x\n",
14039 dd->icode < ARRAY_SIZE(inames) ?
14040 inames[dd->icode] : "unknown", (int)dd->irev);
14042 /* speeds the hardware can support */
14043 dd->pport->link_speed_supported = OPA_LINK_SPEED_25G;
14044 /* speeds allowed to run at */
14045 dd->pport->link_speed_enabled = dd->pport->link_speed_supported;
14046 /* give a reasonable active value, will be set on link up */
14047 dd->pport->link_speed_active = OPA_LINK_SPEED_25G;
14049 dd->chip_rcv_contexts = read_csr(dd, RCV_CONTEXTS);
14050 dd->chip_send_contexts = read_csr(dd, SEND_CONTEXTS);
14051 dd->chip_sdma_engines = read_csr(dd, SEND_DMA_ENGINES);
14052 dd->chip_pio_mem_size = read_csr(dd, SEND_PIO_MEM_SIZE);
14053 dd->chip_sdma_mem_size = read_csr(dd, SEND_DMA_MEM_SIZE);
14054 /* fix up link widths for emulation _p */
14056 if (dd->icode == ICODE_FPGA_EMULATION && is_emulator_p(dd)) {
14057 ppd->link_width_supported =
14058 ppd->link_width_enabled =
14059 ppd->link_width_downgrade_supported =
14060 ppd->link_width_downgrade_enabled =
14063 /* insure num_vls isn't larger than number of sdma engines */
14064 if (HFI1_CAP_IS_KSET(SDMA) && num_vls > dd->chip_sdma_engines) {
14065 dd_dev_err(dd, "num_vls %u too large, using %u VLs\n",
14066 num_vls, dd->chip_sdma_engines);
14067 num_vls = dd->chip_sdma_engines;
14068 ppd->vls_supported = dd->chip_sdma_engines;
14069 ppd->vls_operational = ppd->vls_supported;
14073 * Convert the ns parameter to the 64 * cclocks used in the CSR.
14074 * Limit the max if larger than the field holds. If timeout is
14075 * non-zero, then the calculated field will be at least 1.
14077 * Must be after icode is set up - the cclock rate depends
14078 * on knowing the hardware being used.
14080 dd->rcv_intr_timeout_csr = ns_to_cclock(dd, rcv_intr_timeout) / 64;
14081 if (dd->rcv_intr_timeout_csr >
14082 RCV_AVAIL_TIME_OUT_TIME_OUT_RELOAD_MASK)
14083 dd->rcv_intr_timeout_csr =
14084 RCV_AVAIL_TIME_OUT_TIME_OUT_RELOAD_MASK;
14085 else if (dd->rcv_intr_timeout_csr == 0 && rcv_intr_timeout)
14086 dd->rcv_intr_timeout_csr = 1;
14088 /* needs to be done before we look for the peer device */
14091 /* set up shared ASIC data with peer device */
14092 ret = init_asic_data(dd);
14096 /* obtain chip sizes, reset chip CSRs */
14099 /* read in the PCIe link speed information */
14100 ret = pcie_speeds(dd);
14104 /* Needs to be called before hfi1_firmware_init */
14105 get_platform_config(dd);
14107 /* read in firmware */
14108 ret = hfi1_firmware_init(dd);
14113 * In general, the PCIe Gen3 transition must occur after the
14114 * chip has been idled (so it won't initiate any PCIe transactions
14115 * e.g. an interrupt) and before the driver changes any registers
14116 * (the transition will reset the registers).
14118 * In particular, place this call after:
14119 * - init_chip() - the chip will not initiate any PCIe transactions
14120 * - pcie_speeds() - reads the current link speed
14121 * - hfi1_firmware_init() - the needed firmware is ready to be
14124 ret = do_pcie_gen3_transition(dd);
14128 /* start setting dd values and adjusting CSRs */
14129 init_early_variables(dd);
14131 parse_platform_config(dd);
14133 ret = obtain_boardname(dd);
14137 snprintf(dd->boardversion, BOARD_VERS_MAX,
14138 "ChipABI %u.%u, ChipRev %u.%u, SW Compat %llu\n",
14139 HFI1_CHIP_VERS_MAJ, HFI1_CHIP_VERS_MIN,
14142 (dd->revision >> CCE_REVISION_SW_SHIFT)
14143 & CCE_REVISION_SW_MASK);
14146 * The real cpu mask is part of the affinity struct but has to be
14147 * initialized earlier than the rest of the affinity struct because it
14148 * is needed to calculate the number of user contexts in
14149 * set_up_context_variables(). However, hfi1_dev_affinity_init(),
14150 * which initializes the rest of the affinity struct members,
14151 * depends on set_up_context_variables() for the number of kernel
14152 * contexts, so it cannot be called before set_up_context_variables().
14154 ret = init_real_cpu_mask(dd);
14158 ret = set_up_context_variables(dd);
14162 /* set initial RXE CSRs */
14164 /* set initial TXE CSRs */
14166 /* set initial non-RXE, non-TXE CSRs */
14168 /* set up KDETH QP prefix in both RX and TX CSRs */
14171 hfi1_dev_affinity_init(dd);
14173 /* send contexts must be set up before receive contexts */
14174 ret = init_send_contexts(dd);
14178 ret = hfi1_create_ctxts(dd);
14182 dd->rcvhdrsize = DEFAULT_RCVHDRSIZE;
14184 * rcd[0] is guaranteed to be valid by this point. Also, all
14185 * context are using the same value, as per the module parameter.
14187 dd->rhf_offset = dd->rcd[0]->rcvhdrqentsize - sizeof(u64) / sizeof(u32);
14189 ret = init_pervl_scs(dd);
14194 for (i = 0; i < dd->num_pports; ++i) {
14195 ret = sdma_init(dd, i);
14200 /* use contexts created by hfi1_create_ctxts */
14201 ret = set_up_interrupts(dd);
14205 /* set up LCB access - must be after set_up_interrupts() */
14206 init_lcb_access(dd);
14208 snprintf(dd->serial, SERIAL_MAX, "0x%08llx\n",
14209 dd->base_guid & 0xFFFFFF);
14211 dd->oui1 = dd->base_guid >> 56 & 0xFF;
14212 dd->oui2 = dd->base_guid >> 48 & 0xFF;
14213 dd->oui3 = dd->base_guid >> 40 & 0xFF;
14215 ret = load_firmware(dd); /* asymmetric with dispose_firmware() */
14217 goto bail_clear_intr;
14218 check_fabric_firmware_versions(dd);
14222 ret = init_cntrs(dd);
14224 goto bail_clear_intr;
14226 ret = init_rcverr(dd);
14228 goto bail_free_cntrs;
14230 ret = eprom_init(dd);
14232 goto bail_free_rcverr;
14241 clean_up_interrupts(dd);
14243 hfi1_pcie_ddcleanup(dd);
14245 hfi1_free_devdata(dd);
14251 static u16 delay_cycles(struct hfi1_pportdata *ppd, u32 desired_egress_rate,
14255 u32 current_egress_rate = ppd->current_egress_rate;
14256 /* rates here are in units of 10^6 bits/sec */
14258 if (desired_egress_rate == -1)
14259 return 0; /* shouldn't happen */
14261 if (desired_egress_rate >= current_egress_rate)
14262 return 0; /* we can't help go faster, only slower */
14264 delta_cycles = egress_cycles(dw_len * 4, desired_egress_rate) -
14265 egress_cycles(dw_len * 4, current_egress_rate);
14267 return (u16)delta_cycles;
14271 * create_pbc - build a pbc for transmission
14272 * @flags: special case flags or-ed in built pbc
14273 * @srate: static rate
14275 * @dwlen: dword length (header words + data words + pbc words)
14277 * Create a PBC with the given flags, rate, VL, and length.
14279 * NOTE: The PBC created will not insert any HCRC - all callers but one are
14280 * for verbs, which does not use this PSM feature. The lone other caller
14281 * is for the diagnostic interface which calls this if the user does not
14282 * supply their own PBC.
14284 u64 create_pbc(struct hfi1_pportdata *ppd, u64 flags, int srate_mbs, u32 vl,
14287 u64 pbc, delay = 0;
14289 if (unlikely(srate_mbs))
14290 delay = delay_cycles(ppd, srate_mbs, dw_len);
14293 | (delay << PBC_STATIC_RATE_CONTROL_COUNT_SHIFT)
14294 | ((u64)PBC_IHCRC_NONE << PBC_INSERT_HCRC_SHIFT)
14295 | (vl & PBC_VL_MASK) << PBC_VL_SHIFT
14296 | (dw_len & PBC_LENGTH_DWS_MASK)
14297 << PBC_LENGTH_DWS_SHIFT;
14302 #define SBUS_THERMAL 0x4f
14303 #define SBUS_THERM_MONITOR_MODE 0x1
14305 #define THERM_FAILURE(dev, ret, reason) \
14307 "Thermal sensor initialization failed: %s (%d)\n", \
14311 * Initialize the Avago Thermal sensor.
14313 * After initialization, enable polling of thermal sensor through
14314 * SBus interface. In order for this to work, the SBus Master
14315 * firmware has to be loaded due to the fact that the HW polling
14316 * logic uses SBus interrupts, which are not supported with
14317 * default firmware. Otherwise, no data will be returned through
14318 * the ASIC_STS_THERM CSR.
14320 static int thermal_init(struct hfi1_devdata *dd)
14324 if (dd->icode != ICODE_RTL_SILICON ||
14325 check_chip_resource(dd, CR_THERM_INIT, NULL))
14328 ret = acquire_chip_resource(dd, CR_SBUS, SBUS_TIMEOUT);
14330 THERM_FAILURE(dd, ret, "Acquire SBus");
14334 dd_dev_info(dd, "Initializing thermal sensor\n");
14335 /* Disable polling of thermal readings */
14336 write_csr(dd, ASIC_CFG_THERM_POLL_EN, 0x0);
14338 /* Thermal Sensor Initialization */
14339 /* Step 1: Reset the Thermal SBus Receiver */
14340 ret = sbus_request_slow(dd, SBUS_THERMAL, 0x0,
14341 RESET_SBUS_RECEIVER, 0);
14343 THERM_FAILURE(dd, ret, "Bus Reset");
14346 /* Step 2: Set Reset bit in Thermal block */
14347 ret = sbus_request_slow(dd, SBUS_THERMAL, 0x0,
14348 WRITE_SBUS_RECEIVER, 0x1);
14350 THERM_FAILURE(dd, ret, "Therm Block Reset");
14353 /* Step 3: Write clock divider value (100MHz -> 2MHz) */
14354 ret = sbus_request_slow(dd, SBUS_THERMAL, 0x1,
14355 WRITE_SBUS_RECEIVER, 0x32);
14357 THERM_FAILURE(dd, ret, "Write Clock Div");
14360 /* Step 4: Select temperature mode */
14361 ret = sbus_request_slow(dd, SBUS_THERMAL, 0x3,
14362 WRITE_SBUS_RECEIVER,
14363 SBUS_THERM_MONITOR_MODE);
14365 THERM_FAILURE(dd, ret, "Write Mode Sel");
14368 /* Step 5: De-assert block reset and start conversion */
14369 ret = sbus_request_slow(dd, SBUS_THERMAL, 0x0,
14370 WRITE_SBUS_RECEIVER, 0x2);
14372 THERM_FAILURE(dd, ret, "Write Reset Deassert");
14375 /* Step 5.1: Wait for first conversion (21.5ms per spec) */
14378 /* Enable polling of thermal readings */
14379 write_csr(dd, ASIC_CFG_THERM_POLL_EN, 0x1);
14381 /* Set initialized flag */
14382 ret = acquire_chip_resource(dd, CR_THERM_INIT, 0);
14384 THERM_FAILURE(dd, ret, "Unable to set thermal init flag");
14387 release_chip_resource(dd, CR_SBUS);
14391 static void handle_temp_err(struct hfi1_devdata *dd)
14393 struct hfi1_pportdata *ppd = &dd->pport[0];
14395 * Thermal Critical Interrupt
14396 * Put the device into forced freeze mode, take link down to
14397 * offline, and put DC into reset.
14400 "Critical temperature reached! Forcing device into freeze mode!\n");
14401 dd->flags |= HFI1_FORCED_FREEZE;
14402 start_freeze_handling(ppd, FREEZE_SELF | FREEZE_ABORT);
14404 * Shut DC down as much and as quickly as possible.
14406 * Step 1: Take the link down to OFFLINE. This will cause the
14407 * 8051 to put the Serdes in reset. However, we don't want to
14408 * go through the entire link state machine since we want to
14409 * shutdown ASAP. Furthermore, this is not a graceful shutdown
14410 * but rather an attempt to save the chip.
14411 * Code below is almost the same as quiet_serdes() but avoids
14412 * all the extra work and the sleeps.
14414 ppd->driver_link_ready = 0;
14415 ppd->link_enabled = 0;
14416 set_physical_link_state(dd, (OPA_LINKDOWN_REASON_SMA_DISABLED << 8) |
14419 * Step 2: Shutdown LCB and 8051
14420 * After shutdown, do not restore DC_CFG_RESET value.