2 * Copyright (c) 2016 QLogic Corporation.
6 * See LICENSE.qede_pmd for copyright and licensing details.
11 #include "ecore_spq.h"
13 #include "ecore_gtt_reg_addr.h"
14 #include "ecore_init_ops.h"
15 #include "ecore_rt_defs.h"
16 #include "ecore_int.h"
19 #include "ecore_sriov.h"
21 #include "ecore_hw_defs.h"
22 #include "ecore_hsi_common.h"
23 #include "ecore_mcp.h"
24 #include "ecore_attn_values.h"
26 struct ecore_pi_info {
27 ecore_int_comp_cb_t comp_cb;
28 void *cookie; /* Will be sent to the compl cb function */
31 struct ecore_sb_sp_info {
32 struct ecore_sb_info sb_info;
33 /* per protocol index data */
34 struct ecore_pi_info pi_info_arr[PIS_PER_SB];
37 enum ecore_attention_type {
39 ECORE_ATTN_TYPE_PARITY,
42 #define SB_ATTN_ALIGNED_SIZE(p_hwfn) \
43 ALIGNED_TYPE_SIZE(struct atten_status_block, p_hwfn)
45 struct aeu_invert_reg_bit {
48 #define ATTENTION_PARITY (1 << 0)
50 #define ATTENTION_LENGTH_MASK (0x00000ff0)
51 #define ATTENTION_LENGTH_SHIFT (4)
52 #define ATTENTION_LENGTH(flags) (((flags) & ATTENTION_LENGTH_MASK) >> \
53 ATTENTION_LENGTH_SHIFT)
54 #define ATTENTION_SINGLE (1 << ATTENTION_LENGTH_SHIFT)
55 #define ATTENTION_PAR (ATTENTION_SINGLE | ATTENTION_PARITY)
56 #define ATTENTION_PAR_INT ((2 << ATTENTION_LENGTH_SHIFT) | \
59 /* Multiple bits start with this offset */
60 #define ATTENTION_OFFSET_MASK (0x000ff000)
61 #define ATTENTION_OFFSET_SHIFT (12)
63 #define ATTENTION_CLEAR_ENABLE (1 << 28)
64 #define ATTENTION_FW_DUMP (1 << 29)
65 #define ATTENTION_PANIC_DUMP (1 << 30)
68 /* Callback to call if attention will be triggered */
69 enum _ecore_status_t (*cb)(struct ecore_hwfn *p_hwfn);
71 enum block_id block_index;
74 struct aeu_invert_reg {
75 struct aeu_invert_reg_bit bits[32];
78 #define MAX_ATTN_GRPS (8)
79 #define NUM_ATTN_REGS (9)
81 static enum _ecore_status_t ecore_mcp_attn_cb(struct ecore_hwfn *p_hwfn)
83 u32 tmp = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt, MCP_REG_CPU_STATE);
85 DP_INFO(p_hwfn->p_dev, "MCP_REG_CPU_STATE: %08x - Masking...\n", tmp);
86 ecore_wr(p_hwfn, p_hwfn->p_dpc_ptt, MCP_REG_CPU_EVENT_MASK, 0xffffffff);
91 #define ECORE_PSWHST_ATTENTION_DISABLED_PF_MASK (0x3c000)
92 #define ECORE_PSWHST_ATTENTION_DISABLED_PF_SHIFT (14)
93 #define ECORE_PSWHST_ATTENTION_DISABLED_VF_MASK (0x03fc0)
94 #define ECORE_PSWHST_ATTENTION_DISABLED_VF_SHIFT (6)
95 #define ECORE_PSWHST_ATTENTION_DISABLED_VALID_MASK (0x00020)
96 #define ECORE_PSWHST_ATTENTION_DISABLED_VALID_SHIFT (5)
97 #define ECORE_PSWHST_ATTENTION_DISABLED_CLIENT_MASK (0x0001e)
98 #define ECORE_PSWHST_ATTENTION_DISABLED_CLIENT_SHIFT (1)
99 #define ECORE_PSWHST_ATTENTION_DISABLED_WRITE_MASK (0x1)
100 #define ECORE_PSWHST_ATTNETION_DISABLED_WRITE_SHIFT (0)
101 #define ECORE_PSWHST_ATTENTION_VF_DISABLED (0x1)
102 #define ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS (0x1)
103 #define ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_WR_MASK (0x1)
104 #define ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_WR_SHIFT (0)
105 #define ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_CLIENT_MASK (0x1e)
106 #define ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_CLIENT_SHIFT (1)
107 #define ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_VF_VALID_MASK (0x20)
108 #define ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_VF_VALID_SHIFT (5)
109 #define ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_VF_ID_MASK (0x3fc0)
110 #define ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_VF_ID_SHIFT (6)
111 #define ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_PF_ID_MASK (0x3c000)
112 #define ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_PF_ID_SHIFT (14)
113 #define ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_BYTE_EN_MASK (0x3fc0000)
114 #define ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_BYTE_EN_SHIFT (18)
115 static enum _ecore_status_t ecore_pswhst_attn_cb(struct ecore_hwfn *p_hwfn)
118 ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
119 PSWHST_REG_VF_DISABLED_ERROR_VALID);
121 /* Disabled VF access */
122 if (tmp & ECORE_PSWHST_ATTENTION_VF_DISABLED) {
125 addr = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
126 PSWHST_REG_VF_DISABLED_ERROR_ADDRESS);
127 data = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
128 PSWHST_REG_VF_DISABLED_ERROR_DATA);
129 DP_INFO(p_hwfn->p_dev,
130 "PF[0x%02x] VF [0x%02x] [Valid 0x%02x] Client [0x%02x]"
131 " Write [0x%02x] Addr [0x%08x]\n",
132 (u8)((data & ECORE_PSWHST_ATTENTION_DISABLED_PF_MASK)
133 >> ECORE_PSWHST_ATTENTION_DISABLED_PF_SHIFT),
134 (u8)((data & ECORE_PSWHST_ATTENTION_DISABLED_VF_MASK)
135 >> ECORE_PSWHST_ATTENTION_DISABLED_VF_SHIFT),
137 ECORE_PSWHST_ATTENTION_DISABLED_VALID_MASK) >>
138 ECORE_PSWHST_ATTENTION_DISABLED_VALID_SHIFT),
140 ECORE_PSWHST_ATTENTION_DISABLED_CLIENT_MASK) >>
141 ECORE_PSWHST_ATTENTION_DISABLED_CLIENT_SHIFT),
143 ECORE_PSWHST_ATTENTION_DISABLED_WRITE_MASK) >>
144 ECORE_PSWHST_ATTNETION_DISABLED_WRITE_SHIFT),
148 tmp = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
149 PSWHST_REG_INCORRECT_ACCESS_VALID);
150 if (tmp & ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS) {
151 u32 addr, data, length;
153 addr = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
154 PSWHST_REG_INCORRECT_ACCESS_ADDRESS);
155 data = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
156 PSWHST_REG_INCORRECT_ACCESS_DATA);
157 length = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
158 PSWHST_REG_INCORRECT_ACCESS_LENGTH);
160 DP_INFO(p_hwfn->p_dev,
161 "Incorrect access to %08x of length %08x - PF [%02x]"
162 " VF [%04x] [valid %02x] client [%02x] write [%02x]"
163 " Byte-Enable [%04x] [%08x]\n",
166 ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_PF_ID_MASK) >>
167 ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_PF_ID_SHIFT),
169 ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_VF_ID_MASK) >>
170 ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_VF_ID_SHIFT),
172 ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_VF_VALID_MASK) >>
173 ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_VF_VALID_SHIFT),
175 ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_CLIENT_MASK) >>
176 ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_CLIENT_SHIFT),
178 ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_WR_MASK) >>
179 ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_WR_SHIFT),
181 ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_BYTE_EN_MASK) >>
182 ECORE_PSWHST_ATTENTION_INCORRECT_ACCESS_BYTE_EN_SHIFT),
186 /* TODO - We know 'some' of these are legal due to virtualization,
187 * but is it true for all of them?
189 return ECORE_SUCCESS;
192 #define ECORE_GRC_ATTENTION_VALID_BIT (1 << 0)
193 #define ECORE_GRC_ATTENTION_ADDRESS_MASK (0x7fffff << 0)
194 #define ECORE_GRC_ATTENTION_RDWR_BIT (1 << 23)
195 #define ECORE_GRC_ATTENTION_MASTER_MASK (0xf << 24)
196 #define ECORE_GRC_ATTENTION_MASTER_SHIFT (24)
197 #define ECORE_GRC_ATTENTION_PF_MASK (0xf)
198 #define ECORE_GRC_ATTENTION_VF_MASK (0xff << 4)
199 #define ECORE_GRC_ATTENTION_VF_SHIFT (4)
200 #define ECORE_GRC_ATTENTION_PRIV_MASK (0x3 << 14)
201 #define ECORE_GRC_ATTENTION_PRIV_SHIFT (14)
202 #define ECORE_GRC_ATTENTION_PRIV_VF (0)
203 static const char *grc_timeout_attn_master_to_str(u8 master)
231 static enum _ecore_status_t ecore_grc_attn_cb(struct ecore_hwfn *p_hwfn)
235 /* We've already cleared the timeout interrupt register, so we learn
236 * of interrupts via the validity register
238 tmp = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
239 GRC_REG_TIMEOUT_ATTN_ACCESS_VALID);
240 if (!(tmp & ECORE_GRC_ATTENTION_VALID_BIT))
243 /* Read the GRC timeout information */
244 tmp = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
245 GRC_REG_TIMEOUT_ATTN_ACCESS_DATA_0);
246 tmp2 = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
247 GRC_REG_TIMEOUT_ATTN_ACCESS_DATA_1);
249 DP_INFO(p_hwfn->p_dev,
250 "GRC timeout [%08x:%08x] - %s Address [%08x] [Master %s]"
251 " [PF: %02x %s %02x]\n",
253 (tmp & ECORE_GRC_ATTENTION_RDWR_BIT) ? "Write to" : "Read from",
254 (tmp & ECORE_GRC_ATTENTION_ADDRESS_MASK) << 2,
255 grc_timeout_attn_master_to_str((tmp &
256 ECORE_GRC_ATTENTION_MASTER_MASK) >>
257 ECORE_GRC_ATTENTION_MASTER_SHIFT),
258 (tmp2 & ECORE_GRC_ATTENTION_PF_MASK),
259 (((tmp2 & ECORE_GRC_ATTENTION_PRIV_MASK) >>
260 ECORE_GRC_ATTENTION_PRIV_SHIFT) ==
261 ECORE_GRC_ATTENTION_PRIV_VF) ? "VF" : "(Irrelevant:)",
262 (tmp2 & ECORE_GRC_ATTENTION_VF_MASK) >>
263 ECORE_GRC_ATTENTION_VF_SHIFT);
266 /* Regardles of anything else, clean the validity bit */
267 ecore_wr(p_hwfn, p_hwfn->p_dpc_ptt,
268 GRC_REG_TIMEOUT_ATTN_ACCESS_VALID, 0);
269 return ECORE_SUCCESS;
272 #define ECORE_PGLUE_ATTENTION_VALID (1 << 29)
273 #define ECORE_PGLUE_ATTENTION_RD_VALID (1 << 26)
274 #define ECORE_PGLUE_ATTENTION_DETAILS_PFID_MASK (0xf << 20)
275 #define ECORE_PGLUE_ATTENTION_DETAILS_PFID_SHIFT (20)
276 #define ECORE_PGLUE_ATTENTION_DETAILS_VF_VALID (1 << 19)
277 #define ECORE_PGLUE_ATTENTION_DETAILS_VFID_MASK (0xff << 24)
278 #define ECORE_PGLUE_ATTENTION_DETAILS_VFID_SHIFT (24)
279 #define ECORE_PGLUE_ATTENTION_DETAILS2_WAS_ERR (1 << 21)
280 #define ECORE_PGLUE_ATTENTION_DETAILS2_BME (1 << 22)
281 #define ECORE_PGLUE_ATTENTION_DETAILS2_FID_EN (1 << 23)
282 #define ECORE_PGLUE_ATTENTION_ICPL_VALID (1 << 23)
283 #define ECORE_PGLUE_ATTENTION_ZLR_VALID (1 << 25)
284 #define ECORE_PGLUE_ATTENTION_ILT_VALID (1 << 23)
285 static enum _ecore_status_t ecore_pglub_rbc_attn_cb(struct ecore_hwfn *p_hwfn)
289 tmp = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
290 PGLUE_B_REG_TX_ERR_WR_DETAILS2);
291 if (tmp & ECORE_PGLUE_ATTENTION_VALID) {
292 u32 addr_lo, addr_hi, details;
294 addr_lo = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
295 PGLUE_B_REG_TX_ERR_WR_ADD_31_0);
296 addr_hi = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
297 PGLUE_B_REG_TX_ERR_WR_ADD_63_32);
298 details = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
299 PGLUE_B_REG_TX_ERR_WR_DETAILS);
302 "Illegal write by chip to [%08x:%08x] blocked."
303 "Details: %08x [PFID %02x, VFID %02x, VF_VALID %02x]"
304 " Details2 %08x [Was_error %02x BME deassert %02x"
305 " FID_enable deassert %02x]\n",
306 addr_hi, addr_lo, details,
308 ECORE_PGLUE_ATTENTION_DETAILS_PFID_MASK) >>
309 ECORE_PGLUE_ATTENTION_DETAILS_PFID_SHIFT),
311 ECORE_PGLUE_ATTENTION_DETAILS_VFID_MASK) >>
312 ECORE_PGLUE_ATTENTION_DETAILS_VFID_SHIFT),
313 (u8)((details & ECORE_PGLUE_ATTENTION_DETAILS_VF_VALID)
315 (u8)((tmp & ECORE_PGLUE_ATTENTION_DETAILS2_WAS_ERR) ? 1
317 (u8)((tmp & ECORE_PGLUE_ATTENTION_DETAILS2_BME) ? 1 :
319 (u8)((tmp & ECORE_PGLUE_ATTENTION_DETAILS2_FID_EN) ? 1
323 tmp = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
324 PGLUE_B_REG_TX_ERR_RD_DETAILS2);
325 if (tmp & ECORE_PGLUE_ATTENTION_RD_VALID) {
326 u32 addr_lo, addr_hi, details;
328 addr_lo = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
329 PGLUE_B_REG_TX_ERR_RD_ADD_31_0);
330 addr_hi = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
331 PGLUE_B_REG_TX_ERR_RD_ADD_63_32);
332 details = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
333 PGLUE_B_REG_TX_ERR_RD_DETAILS);
336 "Illegal read by chip from [%08x:%08x] blocked."
337 " Details: %08x [PFID %02x, VFID %02x, VF_VALID %02x]"
338 " Details2 %08x [Was_error %02x BME deassert %02x"
339 " FID_enable deassert %02x]\n",
340 addr_hi, addr_lo, details,
342 ECORE_PGLUE_ATTENTION_DETAILS_PFID_MASK) >>
343 ECORE_PGLUE_ATTENTION_DETAILS_PFID_SHIFT),
345 ECORE_PGLUE_ATTENTION_DETAILS_VFID_MASK) >>
346 ECORE_PGLUE_ATTENTION_DETAILS_VFID_SHIFT),
347 (u8)((details & ECORE_PGLUE_ATTENTION_DETAILS_VF_VALID)
349 (u8)((tmp & ECORE_PGLUE_ATTENTION_DETAILS2_WAS_ERR) ? 1
351 (u8)((tmp & ECORE_PGLUE_ATTENTION_DETAILS2_BME) ? 1 :
353 (u8)((tmp & ECORE_PGLUE_ATTENTION_DETAILS2_FID_EN) ? 1
357 tmp = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
358 PGLUE_B_REG_TX_ERR_WR_DETAILS_ICPL);
359 if (tmp & ECORE_PGLUE_ATTENTION_ICPL_VALID)
360 DP_INFO(p_hwfn, "ICPL error - %08x\n", tmp);
362 tmp = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
363 PGLUE_B_REG_MASTER_ZLR_ERR_DETAILS);
364 if (tmp & ECORE_PGLUE_ATTENTION_ZLR_VALID) {
365 u32 addr_hi, addr_lo;
367 addr_lo = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
368 PGLUE_B_REG_MASTER_ZLR_ERR_ADD_31_0);
369 addr_hi = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
370 PGLUE_B_REG_MASTER_ZLR_ERR_ADD_63_32);
372 DP_INFO(p_hwfn, "ICPL error - %08x [Address %08x:%08x]\n",
373 tmp, addr_hi, addr_lo);
376 tmp = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
377 PGLUE_B_REG_VF_ILT_ERR_DETAILS2);
378 if (tmp & ECORE_PGLUE_ATTENTION_ILT_VALID) {
379 u32 addr_hi, addr_lo, details;
381 addr_lo = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
382 PGLUE_B_REG_VF_ILT_ERR_ADD_31_0);
383 addr_hi = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
384 PGLUE_B_REG_VF_ILT_ERR_ADD_63_32);
385 details = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
386 PGLUE_B_REG_VF_ILT_ERR_DETAILS);
389 "ILT error - Details %08x Details2 %08x"
390 " [Address %08x:%08x]\n",
391 details, tmp, addr_hi, addr_lo);
394 /* Clear the indications */
395 ecore_wr(p_hwfn, p_hwfn->p_dpc_ptt,
396 PGLUE_B_REG_LATCHED_ERRORS_CLR, (1 << 2));
398 return ECORE_SUCCESS;
401 static enum _ecore_status_t ecore_fw_assertion(struct ecore_hwfn *p_hwfn)
403 DP_NOTICE(p_hwfn, false, "FW assertion!\n");
405 ecore_hw_err_notify(p_hwfn, ECORE_HW_ERR_FW_ASSERT);
410 static enum _ecore_status_t
411 ecore_general_attention_35(struct ecore_hwfn *p_hwfn)
413 DP_INFO(p_hwfn, "General attention 35!\n");
415 return ECORE_SUCCESS;
418 #define ECORE_DORQ_ATTENTION_REASON_MASK (0xfffff)
419 #define ECORE_DORQ_ATTENTION_OPAQUE_MASK (0xffff)
420 #define ECORE_DORQ_ATTENTION_SIZE_MASK (0x7f)
421 #define ECORE_DORQ_ATTENTION_SIZE_SHIFT (16)
423 static enum _ecore_status_t ecore_dorq_attn_cb(struct ecore_hwfn *p_hwfn)
427 reason = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt, DORQ_REG_DB_DROP_REASON) &
428 ECORE_DORQ_ATTENTION_REASON_MASK;
430 u32 details = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
431 DORQ_REG_DB_DROP_DETAILS);
433 DP_INFO(p_hwfn->p_dev,
434 "DORQ db_drop: address 0x%08x Opaque FID 0x%04x"
435 " Size [bytes] 0x%08x Reason: 0x%08x\n",
436 ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
437 DORQ_REG_DB_DROP_DETAILS_ADDRESS),
438 (u16)(details & ECORE_DORQ_ATTENTION_OPAQUE_MASK),
439 ((details & ECORE_DORQ_ATTENTION_SIZE_MASK) >>
440 ECORE_DORQ_ATTENTION_SIZE_SHIFT) * 4, reason);
446 static enum _ecore_status_t ecore_tm_attn_cb(struct ecore_hwfn *p_hwfn)
449 if (CHIP_REV_IS_EMUL_B0(p_hwfn->p_dev)) {
450 u32 val = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
453 if (val & ~(TM_REG_INT_STS_1_PEND_TASK_SCAN |
454 TM_REG_INT_STS_1_PEND_CONN_SCAN))
457 if (val & (TM_REG_INT_STS_1_PEND_TASK_SCAN |
458 TM_REG_INT_STS_1_PEND_CONN_SCAN))
460 "TM attention on emulation - most likely"
461 " results of clock-ratios\n");
462 val = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt, TM_REG_INT_MASK_1);
463 val |= TM_REG_INT_MASK_1_PEND_CONN_SCAN |
464 TM_REG_INT_MASK_1_PEND_TASK_SCAN;
465 ecore_wr(p_hwfn, p_hwfn->p_dpc_ptt, TM_REG_INT_MASK_1, val);
467 return ECORE_SUCCESS;
474 /* Notice aeu_invert_reg must be defined in the same order of bits as HW; */
475 static struct aeu_invert_reg aeu_descs[NUM_ATTN_REGS] = {
477 { /* After Invert 1 */
478 {"GPIO0 function%d", (32 << ATTENTION_LENGTH_SHIFT), OSAL_NULL,
484 { /* After Invert 2 */
485 {"PGLUE config_space", ATTENTION_SINGLE, OSAL_NULL, MAX_BLOCK_ID},
486 {"PGLUE misc_flr", ATTENTION_SINGLE, OSAL_NULL, MAX_BLOCK_ID},
487 {"PGLUE B RBC", ATTENTION_PAR_INT, ecore_pglub_rbc_attn_cb,
489 {"PGLUE misc_mctp", ATTENTION_SINGLE, OSAL_NULL, MAX_BLOCK_ID},
490 {"Flash event", ATTENTION_SINGLE, OSAL_NULL, MAX_BLOCK_ID},
491 {"SMB event", ATTENTION_SINGLE, OSAL_NULL, MAX_BLOCK_ID},
492 {"Main Power", ATTENTION_SINGLE, OSAL_NULL, MAX_BLOCK_ID},
494 (8 << ATTENTION_LENGTH_SHIFT) | (1 << ATTENTION_OFFSET_SHIFT),
495 OSAL_NULL, MAX_BLOCK_ID},
496 {"PCIE glue/PXP VPD %d", (16 << ATTENTION_LENGTH_SHIFT), OSAL_NULL,
502 { /* After Invert 3 */
503 {"General Attention %d", (32 << ATTENTION_LENGTH_SHIFT), OSAL_NULL,
509 { /* After Invert 4 */
510 {"General Attention 32", ATTENTION_SINGLE | ATTENTION_CLEAR_ENABLE,
511 ecore_fw_assertion, MAX_BLOCK_ID},
512 {"General Attention %d",
513 (2 << ATTENTION_LENGTH_SHIFT) | (33 << ATTENTION_OFFSET_SHIFT),
514 OSAL_NULL, MAX_BLOCK_ID},
515 {"General Attention 35", ATTENTION_SINGLE | ATTENTION_CLEAR_ENABLE,
516 ecore_general_attention_35, MAX_BLOCK_ID},
517 {"CNIG port %d", (4 << ATTENTION_LENGTH_SHIFT), OSAL_NULL,
519 {"MCP CPU", ATTENTION_SINGLE, ecore_mcp_attn_cb, MAX_BLOCK_ID},
520 {"MCP Watchdog timer", ATTENTION_SINGLE, OSAL_NULL, MAX_BLOCK_ID},
521 {"MCP M2P", ATTENTION_SINGLE, OSAL_NULL, MAX_BLOCK_ID},
522 {"AVS stop status ready", ATTENTION_SINGLE, OSAL_NULL, MAX_BLOCK_ID},
523 {"MSTAT", ATTENTION_PAR_INT, OSAL_NULL, MAX_BLOCK_ID},
524 {"MSTAT per-path", ATTENTION_PAR_INT, OSAL_NULL, MAX_BLOCK_ID},
525 {"Reserved %d", (6 << ATTENTION_LENGTH_SHIFT), OSAL_NULL,
527 {"NIG", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_NIG},
528 {"BMB/OPTE/MCP", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_BMB},
529 {"BTB", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_BTB},
530 {"BRB", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_BRB},
531 {"PRS", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_PRS},
536 { /* After Invert 5 */
537 {"SRC", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_SRC},
538 {"PB Client1", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_PBF_PB1},
539 {"PB Client2", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_PBF_PB2},
540 {"RPB", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_RPB},
541 {"PBF", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_PBF},
542 {"QM", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_QM},
543 {"TM", ATTENTION_PAR_INT, ecore_tm_attn_cb, BLOCK_TM},
544 {"MCM", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_MCM},
545 {"MSDM", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_MSDM},
546 {"MSEM", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_MSEM},
547 {"PCM", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_PCM},
548 {"PSDM", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_PSDM},
549 {"PSEM", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_PSEM},
550 {"TCM", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_TCM},
551 {"TSDM", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_TSDM},
552 {"TSEM", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_TSEM},
557 { /* After Invert 6 */
558 {"UCM", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_UCM},
559 {"USDM", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_USDM},
560 {"USEM", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_USEM},
561 {"XCM", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_XCM},
562 {"XSDM", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_XSDM},
563 {"XSEM", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_XSEM},
564 {"YCM", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_YCM},
565 {"YSDM", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_YSDM},
566 {"YSEM", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_YSEM},
567 {"XYLD", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_XYLD},
568 {"TMLD", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_TMLD},
569 {"MYLD", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_MULD},
570 {"YULD", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_YULD},
571 {"DORQ", ATTENTION_PAR_INT, ecore_dorq_attn_cb, BLOCK_DORQ},
572 {"DBG", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_DBG},
573 {"IPC", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_IPC},
578 { /* After Invert 7 */
579 {"CCFC", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_CCFC},
580 {"CDU", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_CDU},
581 {"DMAE", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_DMAE},
582 {"IGU", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_IGU},
583 {"ATC", ATTENTION_PAR_INT, OSAL_NULL, MAX_BLOCK_ID},
584 {"CAU", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_CAU},
585 {"PTU", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_PTU},
586 {"PRM", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_PRM},
587 {"TCFC", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_TCFC},
588 {"RDIF", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_RDIF},
589 {"TDIF", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_TDIF},
590 {"RSS", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_RSS},
591 {"MISC", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_MISC},
592 {"MISCS", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_MISCS},
593 {"PCIE", ATTENTION_PAR, OSAL_NULL, BLOCK_PCIE},
594 {"Vaux PCI core", ATTENTION_SINGLE, OSAL_NULL, BLOCK_PGLCS},
595 {"PSWRQ", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_PSWRQ},
600 { /* After Invert 8 */
601 {"PSWRQ (pci_clk)", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_PSWRQ2},
602 {"PSWWR", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_PSWWR},
603 {"PSWWR (pci_clk)", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_PSWWR2},
604 {"PSWRD", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_PSWRD},
605 {"PSWRD (pci_clk)", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_PSWRD2},
606 {"PSWHST", ATTENTION_PAR_INT, ecore_pswhst_attn_cb, BLOCK_PSWHST},
607 {"PSWHST (pci_clk)", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_PSWHST2},
608 {"GRC", ATTENTION_PAR_INT, ecore_grc_attn_cb, BLOCK_GRC},
609 {"CPMU", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_CPMU},
610 {"NCSI", ATTENTION_PAR_INT, OSAL_NULL, BLOCK_NCSI},
611 {"MSEM PRAM", ATTENTION_PAR, OSAL_NULL, MAX_BLOCK_ID},
612 {"PSEM PRAM", ATTENTION_PAR, OSAL_NULL, MAX_BLOCK_ID},
613 {"TSEM PRAM", ATTENTION_PAR, OSAL_NULL, MAX_BLOCK_ID},
614 {"USEM PRAM", ATTENTION_PAR, OSAL_NULL, MAX_BLOCK_ID},
615 {"XSEM PRAM", ATTENTION_PAR, OSAL_NULL, MAX_BLOCK_ID},
616 {"YSEM PRAM", ATTENTION_PAR, OSAL_NULL, MAX_BLOCK_ID},
617 {"pxp_misc_mps", ATTENTION_PAR, OSAL_NULL, BLOCK_PGLCS},
618 {"PCIE glue/PXP Exp. ROM", ATTENTION_SINGLE, OSAL_NULL, BLOCK_PGLCS},
619 {"PERST_B assertion", ATTENTION_SINGLE, OSAL_NULL, MAX_BLOCK_ID},
620 {"PERST_B deassertion", ATTENTION_SINGLE, OSAL_NULL, MAX_BLOCK_ID},
621 {"Reserved %d", (2 << ATTENTION_LENGTH_SHIFT), OSAL_NULL,
627 { /* After Invert 9 */
628 {"MCP Latched memory", ATTENTION_PAR, OSAL_NULL, MAX_BLOCK_ID},
629 {"MCP Latched scratchpad cache", ATTENTION_SINGLE, OSAL_NULL,
631 {"MCP Latched ump_tx", ATTENTION_PAR, OSAL_NULL, MAX_BLOCK_ID},
632 {"MCP Latched scratchpad", ATTENTION_PAR, OSAL_NULL, MAX_BLOCK_ID},
633 {"Reserved %d", (28 << ATTENTION_LENGTH_SHIFT), OSAL_NULL,
640 #define ATTN_STATE_BITS (0xfff)
641 #define ATTN_BITS_MASKABLE (0x3ff)
642 struct ecore_sb_attn_info {
643 /* Virtual & Physical address of the SB */
644 struct atten_status_block *sb_attn;
647 /* Last seen running index */
650 /* A mask of the AEU bits resulting in a parity error */
651 u32 parity_mask[NUM_ATTN_REGS];
653 /* A pointer to the attention description structure */
654 struct aeu_invert_reg *p_aeu_desc;
656 /* Previously asserted attentions, which are still unasserted */
659 /* Cleanup address for the link's general hw attention */
663 static u16 ecore_attn_update_idx(struct ecore_hwfn *p_hwfn,
664 struct ecore_sb_attn_info *p_sb_desc)
668 OSAL_MMIOWB(p_hwfn->p_dev);
670 index = OSAL_LE16_TO_CPU(p_sb_desc->sb_attn->sb_index);
671 if (p_sb_desc->index != index) {
672 p_sb_desc->index = index;
673 rc = ECORE_SB_ATT_IDX;
676 OSAL_MMIOWB(p_hwfn->p_dev);
682 * @brief ecore_int_assertion - handles asserted attention bits
685 * @param asserted_bits newly asserted bits
686 * @return enum _ecore_status_t
688 static enum _ecore_status_t ecore_int_assertion(struct ecore_hwfn *p_hwfn,
691 struct ecore_sb_attn_info *sb_attn_sw = p_hwfn->p_sb_attn;
694 /* Mask the source of the attention in the IGU */
695 igu_mask = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
696 IGU_REG_ATTENTION_ENABLE);
697 DP_VERBOSE(p_hwfn, ECORE_MSG_INTR, "IGU mask: 0x%08x --> 0x%08x\n",
698 igu_mask, igu_mask & ~(asserted_bits & ATTN_BITS_MASKABLE));
699 igu_mask &= ~(asserted_bits & ATTN_BITS_MASKABLE);
700 ecore_wr(p_hwfn, p_hwfn->p_dpc_ptt, IGU_REG_ATTENTION_ENABLE, igu_mask);
702 DP_VERBOSE(p_hwfn, ECORE_MSG_INTR,
703 "inner known ATTN state: 0x%04x --> 0x%04x\n",
704 sb_attn_sw->known_attn,
705 sb_attn_sw->known_attn | asserted_bits);
706 sb_attn_sw->known_attn |= asserted_bits;
708 /* Handle MCP events */
709 if (asserted_bits & 0x100) {
710 ecore_mcp_handle_events(p_hwfn, p_hwfn->p_dpc_ptt);
711 /* Clean the MCP attention */
712 ecore_wr(p_hwfn, p_hwfn->p_dpc_ptt,
713 sb_attn_sw->mfw_attn_addr, 0);
716 /* FIXME - this will change once we'll have GOOD gtt definitions */
717 DIRECT_REG_WR(p_hwfn,
718 (u8 OSAL_IOMEM *) p_hwfn->regview +
719 GTT_BAR0_MAP_REG_IGU_CMD +
720 ((IGU_CMD_ATTN_BIT_SET_UPPER -
721 IGU_CMD_INT_ACK_BASE) << 3), (u32)asserted_bits);
723 DP_VERBOSE(p_hwfn, ECORE_MSG_INTR, "set cmd IGU: 0x%04x\n",
726 return ECORE_SUCCESS;
729 static void ecore_int_deassertion_print_bit(struct ecore_hwfn *p_hwfn,
730 struct attn_hw_reg *p_reg_desc,
731 struct attn_hw_block *p_block,
732 enum ecore_attention_type type,
737 const char **description;
739 if (type == ECORE_ATTN_TYPE_ATTN)
740 description = p_block->int_desc;
742 description = p_block->prty_desc;
745 for (j = 0; j < p_reg_desc->num_of_bits; j++) {
746 if (val & (1 << j)) {
748 DP_NOTICE(p_hwfn, false,
749 "%s (%s): %s [reg %d [0x%08x], bit %d]%s\n",
751 type == ECORE_ATTN_TYPE_ATTN ? "Interrupt" :
753 description[p_reg_desc->bit_attn_idx[j]],
755 p_reg_desc->sts_addr, j,
756 (mask & (1 << j)) ? " [MASKED]" : "");
758 DP_NOTICE(p_hwfn->p_dev, false,
759 "%s (%s): [reg %d [0x%08x], bit %d]%s\n",
761 type == ECORE_ATTN_TYPE_ATTN ? "Interrupt" :
764 p_reg_desc->sts_addr, j,
765 (mask & (1 << j)) ? " [MASKED]" : "");
772 * @brief ecore_int_deassertion_aeu_bit - handles the effects of a single
773 * cause of the attention
776 * @param p_aeu - descriptor of an AEU bit which caused the attention
777 * @param aeu_en_reg - register offset of the AEU enable reg. which configured
778 * this bit to this group.
779 * @param bit_index - index of this bit in the aeu_en_reg
781 * @return enum _ecore_status_t
783 static enum _ecore_status_t
784 ecore_int_deassertion_aeu_bit(struct ecore_hwfn *p_hwfn,
785 struct aeu_invert_reg_bit *p_aeu,
787 const char *p_bit_name,
790 enum _ecore_status_t rc = ECORE_INVAL;
794 u32 interrupts[20]; /* TODO- change into HSI define once supplied */
796 OSAL_MEMSET(interrupts, 0, sizeof(u32) * 20); /* FIXME real size) */
799 DP_INFO(p_hwfn, "Deasserted attention `%s'[%08x]\n",
800 p_bit_name, bitmask);
802 /* Call callback before clearing the interrupt status */
804 DP_INFO(p_hwfn, "`%s (attention)': Calling Callback function\n",
806 rc = p_aeu->cb(p_hwfn);
809 /* Print HW block interrupt registers */
810 if (p_aeu->block_index != MAX_BLOCK_ID)
811 DP_NOTICE(p_hwfn->p_dev, false, "[block_id %d type %d]\n",
812 p_aeu->block_index, ATTN_TYPE_INTERRUPT);
814 /* Reach assertion if attention is fatal */
815 if (rc != ECORE_SUCCESS) {
816 DP_NOTICE(p_hwfn, true, "`%s': Fatal attention\n",
819 ecore_hw_err_notify(p_hwfn, ECORE_HW_ERR_HW_ATTN);
822 /* Prevent this Attention from being asserted in the future */
823 if (p_aeu->flags & ATTENTION_CLEAR_ENABLE) {
826 val = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt, aeu_en_reg);
827 ecore_wr(p_hwfn, p_hwfn->p_dpc_ptt, aeu_en_reg, (val & mask));
828 DP_INFO(p_hwfn, "`%s' - Disabled future attentions\n",
832 if (p_aeu->flags & (ATTENTION_FW_DUMP | ATTENTION_PANIC_DUMP)) {
833 /* @@@TODO - what to dump? <yuvalmin 04/02/13> */
834 DP_ERR(p_hwfn->p_dev, "`%s' - Dumps aren't implemented yet\n",
836 return ECORE_NOTIMPL;
843 * @brief ecore_int_deassertion_parity - handle a single parity AEU source
846 * @param p_aeu - descriptor of an AEU bit which caused the
850 static void ecore_int_deassertion_parity(struct ecore_hwfn *p_hwfn,
851 struct aeu_invert_reg_bit *p_aeu,
854 u32 block_id = p_aeu->block_index;
856 DP_INFO(p_hwfn->p_dev, "%s[%d] parity attention is set\n",
857 p_aeu->bit_name, bit_index);
859 if (block_id != MAX_BLOCK_ID)
862 /* In A0, there's a single parity bit for several blocks */
863 if (block_id == BLOCK_BTB) {
864 DP_NOTICE(p_hwfn->p_dev, false, "[block_id %d type %d]\n",
865 BLOCK_OPTE, ATTN_TYPE_PARITY);
866 DP_NOTICE(p_hwfn->p_dev, false, "[block_id %d type %d]\n",
867 BLOCK_MCP, ATTN_TYPE_PARITY);
872 * @brief - handles deassertion of previously asserted attentions.
875 * @param deasserted_bits - newly deasserted bits
876 * @return enum _ecore_status_t
879 static enum _ecore_status_t ecore_int_deassertion(struct ecore_hwfn *p_hwfn,
882 struct ecore_sb_attn_info *sb_attn_sw = p_hwfn->p_sb_attn;
883 u32 aeu_inv_arr[NUM_ATTN_REGS], aeu_mask;
884 bool b_parity = false;
886 enum _ecore_status_t rc = ECORE_SUCCESS;
888 /* Read the attention registers in the AEU */
889 for (i = 0; i < NUM_ATTN_REGS; i++) {
890 aeu_inv_arr[i] = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
891 MISC_REG_AEU_AFTER_INVERT_1_IGU +
893 DP_VERBOSE(p_hwfn, ECORE_MSG_INTR,
894 "Deasserted bits [%d]: %08x\n", i, aeu_inv_arr[i]);
897 /* Handle parity attentions first */
898 for (i = 0; i < NUM_ATTN_REGS; i++) {
899 struct aeu_invert_reg *p_aeu = &sb_attn_sw->p_aeu_desc[i];
900 u32 en = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
901 MISC_REG_AEU_ENABLE1_IGU_OUT_0 +
904 u32 parities = sb_attn_sw->parity_mask[i] & aeu_inv_arr[i] & en;
906 /* Skip register in which no parity bit is currently set */
910 for (j = 0, bit_idx = 0; bit_idx < 32; j++) {
911 struct aeu_invert_reg_bit *p_bit = &p_aeu->bits[j];
913 if ((p_bit->flags & ATTENTION_PARITY) &&
914 !!(parities & (1 << bit_idx))) {
915 ecore_int_deassertion_parity(p_hwfn, p_bit,
920 bit_idx += ATTENTION_LENGTH(p_bit->flags);
924 /* Find non-parity cause for attention and act */
925 for (k = 0; k < MAX_ATTN_GRPS; k++) {
926 struct aeu_invert_reg_bit *p_aeu;
928 /* Handle only groups whose attention is currently deasserted */
929 if (!(deasserted_bits & (1 << k)))
932 for (i = 0; i < NUM_ATTN_REGS; i++) {
933 u32 aeu_en = MISC_REG_AEU_ENABLE1_IGU_OUT_0 +
934 i * sizeof(u32) + k * sizeof(u32) * NUM_ATTN_REGS;
935 u32 en = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt, aeu_en);
936 u32 bits = aeu_inv_arr[i] & en;
938 /* Skip if no bit from this group is currently set */
942 /* Find all set bits from current register which belong
943 * to current group, making them responsible for the
944 * previous assertion.
946 for (j = 0, bit_idx = 0; bit_idx < 32; j++) {
947 unsigned long bitmask;
950 p_aeu = &sb_attn_sw->p_aeu_desc[i].bits[j];
952 /* No need to handle attention-only bits */
953 if (p_aeu->flags == ATTENTION_PAR)
957 bit_len = ATTENTION_LENGTH(p_aeu->flags);
958 if (p_aeu->flags & ATTENTION_PAR_INT) {
964 bitmask = bits & (((1 << bit_len) - 1) << bit);
966 u32 flags = p_aeu->flags;
969 bit = (u8)OSAL_FIND_FIRST_BIT(&bitmask,
972 /* Some bits represent more than a
973 * a single interrupt. Correctly print
976 if (ATTENTION_LENGTH(flags) > 2 ||
977 ((flags & ATTENTION_PAR_INT) &&
978 ATTENTION_LENGTH(flags) > 1))
979 OSAL_SNPRINTF(bit_name, 30,
983 OSAL_STRNCPY(bit_name,
986 /* Handle source of the attention */
987 ecore_int_deassertion_aeu_bit(p_hwfn,
994 bit_idx += ATTENTION_LENGTH(p_aeu->flags);
999 /* Clear IGU indication for the deasserted bits */
1000 /* FIXME - this will change once we'll have GOOD gtt definitions */
1001 DIRECT_REG_WR(p_hwfn,
1002 (u8 OSAL_IOMEM *) p_hwfn->regview +
1003 GTT_BAR0_MAP_REG_IGU_CMD +
1004 ((IGU_CMD_ATTN_BIT_CLR_UPPER -
1005 IGU_CMD_INT_ACK_BASE) << 3), ~((u32)deasserted_bits));
1007 /* Unmask deasserted attentions in IGU */
1008 aeu_mask = ecore_rd(p_hwfn, p_hwfn->p_dpc_ptt,
1009 IGU_REG_ATTENTION_ENABLE);
1010 aeu_mask |= (deasserted_bits & ATTN_BITS_MASKABLE);
1011 ecore_wr(p_hwfn, p_hwfn->p_dpc_ptt, IGU_REG_ATTENTION_ENABLE, aeu_mask);
1013 /* Clear deassertion from inner state */
1014 sb_attn_sw->known_attn &= ~deasserted_bits;
1019 static enum _ecore_status_t ecore_int_attentions(struct ecore_hwfn *p_hwfn)
1021 struct ecore_sb_attn_info *p_sb_attn_sw = p_hwfn->p_sb_attn;
1022 struct atten_status_block *p_sb_attn = p_sb_attn_sw->sb_attn;
1023 u16 index = 0, asserted_bits, deasserted_bits;
1024 enum _ecore_status_t rc = ECORE_SUCCESS;
1025 u32 attn_bits = 0, attn_acks = 0;
1027 /* Read current attention bits/acks - safeguard against attentions
1028 * by guaranting work on a synchronized timeframe
1031 index = OSAL_LE16_TO_CPU(p_sb_attn->sb_index);
1032 attn_bits = OSAL_LE32_TO_CPU(p_sb_attn->atten_bits);
1033 attn_acks = OSAL_LE32_TO_CPU(p_sb_attn->atten_ack);
1034 } while (index != OSAL_LE16_TO_CPU(p_sb_attn->sb_index));
1035 p_sb_attn->sb_index = index;
1037 /* Attention / Deassertion are meaningful (and in correct state)
1038 * only when they differ and consistent with known state - deassertion
1039 * when previous attention & current ack, and assertion when current
1040 * attention with no previous attention
1042 asserted_bits = (attn_bits & ~attn_acks & ATTN_STATE_BITS) &
1043 ~p_sb_attn_sw->known_attn;
1044 deasserted_bits = (~attn_bits & attn_acks & ATTN_STATE_BITS) &
1045 p_sb_attn_sw->known_attn;
1047 if ((asserted_bits & ~0x100) || (deasserted_bits & ~0x100))
1049 "Attention: Index: 0x%04x, Bits: 0x%08x, Acks: 0x%08x, asserted: 0x%04x, De-asserted 0x%04x [Prev. known: 0x%04x]\n",
1050 index, attn_bits, attn_acks, asserted_bits,
1051 deasserted_bits, p_sb_attn_sw->known_attn);
1052 else if (asserted_bits == 0x100)
1053 DP_INFO(p_hwfn, "MFW indication via attention\n");
1055 DP_VERBOSE(p_hwfn, ECORE_MSG_INTR,
1056 "MFW indication [deassertion]\n");
1058 if (asserted_bits) {
1059 rc = ecore_int_assertion(p_hwfn, asserted_bits);
1064 if (deasserted_bits)
1065 rc = ecore_int_deassertion(p_hwfn, deasserted_bits);
1070 static void ecore_sb_ack_attn(struct ecore_hwfn *p_hwfn,
1071 void OSAL_IOMEM *igu_addr, u32 ack_cons)
1073 struct igu_prod_cons_update igu_ack = { 0 };
1075 igu_ack.sb_id_and_flags =
1076 ((ack_cons << IGU_PROD_CONS_UPDATE_SB_INDEX_SHIFT) |
1077 (1 << IGU_PROD_CONS_UPDATE_UPDATE_FLAG_SHIFT) |
1078 (IGU_INT_NOP << IGU_PROD_CONS_UPDATE_ENABLE_INT_SHIFT) |
1079 (IGU_SEG_ACCESS_ATTN <<
1080 IGU_PROD_CONS_UPDATE_SEGMENT_ACCESS_SHIFT));
1082 DIRECT_REG_WR(p_hwfn, igu_addr, igu_ack.sb_id_and_flags);
1084 /* Both segments (interrupts & acks) are written to same place address;
1085 * Need to guarantee all commands will be received (in-order) by HW.
1087 OSAL_MMIOWB(p_hwfn->p_dev);
1088 OSAL_BARRIER(p_hwfn->p_dev);
1091 void ecore_int_sp_dpc(osal_int_ptr_t hwfn_cookie)
1093 struct ecore_hwfn *p_hwfn = (struct ecore_hwfn *)hwfn_cookie;
1094 struct ecore_pi_info *pi_info = OSAL_NULL;
1095 struct ecore_sb_attn_info *sb_attn;
1096 struct ecore_sb_info *sb_info;
1097 static int arr_size;
1101 DP_ERR(p_hwfn->p_dev, "DPC called - no hwfn!\n");
1105 if (!p_hwfn->p_sp_sb) {
1106 DP_ERR(p_hwfn->p_dev, "DPC called - no p_sp_sb\n");
1110 sb_info = &p_hwfn->p_sp_sb->sb_info;
1111 arr_size = OSAL_ARRAY_SIZE(p_hwfn->p_sp_sb->pi_info_arr);
1113 DP_ERR(p_hwfn->p_dev,
1114 "Status block is NULL - cannot ack interrupts\n");
1118 if (!p_hwfn->p_sb_attn) {
1119 DP_ERR(p_hwfn->p_dev, "DPC called - no p_sb_attn");
1122 sb_attn = p_hwfn->p_sb_attn;
1124 DP_VERBOSE(p_hwfn, ECORE_MSG_INTR, "DPC Called! (hwfn %p %d)\n",
1125 p_hwfn, p_hwfn->my_id);
1127 /* Disable ack for def status block. Required both for msix +
1128 * inta in non-mask mode, in inta does no harm.
1130 ecore_sb_ack(sb_info, IGU_INT_DISABLE, 0);
1132 /* Gather Interrupts/Attentions information */
1133 if (!sb_info->sb_virt) {
1134 DP_ERR(p_hwfn->p_dev,
1135 "Interrupt Status block is NULL -"
1136 " cannot check for new interrupts!\n");
1138 u32 tmp_index = sb_info->sb_ack;
1139 rc = ecore_sb_update_sb_idx(sb_info);
1140 DP_VERBOSE(p_hwfn->p_dev, ECORE_MSG_INTR,
1141 "Interrupt indices: 0x%08x --> 0x%08x\n",
1142 tmp_index, sb_info->sb_ack);
1145 if (!sb_attn || !sb_attn->sb_attn) {
1146 DP_ERR(p_hwfn->p_dev,
1147 "Attentions Status block is NULL -"
1148 " cannot check for new attentions!\n");
1150 u16 tmp_index = sb_attn->index;
1152 rc |= ecore_attn_update_idx(p_hwfn, sb_attn);
1153 DP_VERBOSE(p_hwfn->p_dev, ECORE_MSG_INTR,
1154 "Attention indices: 0x%08x --> 0x%08x\n",
1155 tmp_index, sb_attn->index);
1158 /* Check if we expect interrupts at this time. if not just ack them */
1159 if (!(rc & ECORE_SB_EVENT_MASK)) {
1160 ecore_sb_ack(sb_info, IGU_INT_ENABLE, 1);
1164 /* Check the validity of the DPC ptt. If not ack interrupts and fail */
1165 if (!p_hwfn->p_dpc_ptt) {
1166 DP_NOTICE(p_hwfn->p_dev, true, "Failed to allocate PTT\n");
1167 ecore_sb_ack(sb_info, IGU_INT_ENABLE, 1);
1171 if (rc & ECORE_SB_ATT_IDX)
1172 ecore_int_attentions(p_hwfn);
1174 if (rc & ECORE_SB_IDX) {
1177 /* Since we only looked at the SB index, it's possible more
1178 * than a single protocol-index on the SB incremented.
1179 * Iterate over all configured protocol indices and check
1180 * whether something happened for each.
1182 for (pi = 0; pi < arr_size; pi++) {
1183 pi_info = &p_hwfn->p_sp_sb->pi_info_arr[pi];
1184 if (pi_info->comp_cb != OSAL_NULL)
1185 pi_info->comp_cb(p_hwfn, pi_info->cookie);
1189 if (sb_attn && (rc & ECORE_SB_ATT_IDX)) {
1190 /* This should be done before the interrupts are enabled,
1191 * since otherwise a new attention will be generated.
1193 ecore_sb_ack_attn(p_hwfn, sb_info->igu_addr, sb_attn->index);
1196 ecore_sb_ack(sb_info, IGU_INT_ENABLE, 1);
1199 static void ecore_int_sb_attn_free(struct ecore_hwfn *p_hwfn)
1201 struct ecore_sb_attn_info *p_sb = p_hwfn->p_sb_attn;
1206 if (p_sb->sb_attn) {
1207 OSAL_DMA_FREE_COHERENT(p_hwfn->p_dev, p_sb->sb_attn,
1209 SB_ATTN_ALIGNED_SIZE(p_hwfn));
1211 OSAL_FREE(p_hwfn->p_dev, p_sb);
1214 static void ecore_int_sb_attn_setup(struct ecore_hwfn *p_hwfn,
1215 struct ecore_ptt *p_ptt)
1217 struct ecore_sb_attn_info *sb_info = p_hwfn->p_sb_attn;
1219 OSAL_MEMSET(sb_info->sb_attn, 0, sizeof(*sb_info->sb_attn));
1222 sb_info->known_attn = 0;
1224 /* Configure Attention Status Block in IGU */
1225 ecore_wr(p_hwfn, p_ptt, IGU_REG_ATTN_MSG_ADDR_L,
1226 DMA_LO(p_hwfn->p_sb_attn->sb_phys));
1227 ecore_wr(p_hwfn, p_ptt, IGU_REG_ATTN_MSG_ADDR_H,
1228 DMA_HI(p_hwfn->p_sb_attn->sb_phys));
1231 static void ecore_int_sb_attn_init(struct ecore_hwfn *p_hwfn,
1232 struct ecore_ptt *p_ptt,
1233 void *sb_virt_addr, dma_addr_t sb_phy_addr)
1235 struct ecore_sb_attn_info *sb_info = p_hwfn->p_sb_attn;
1238 sb_info->sb_attn = sb_virt_addr;
1239 sb_info->sb_phys = sb_phy_addr;
1241 /* Set the pointer to the AEU descriptors */
1242 sb_info->p_aeu_desc = aeu_descs;
1244 /* Calculate Parity Masks */
1245 OSAL_MEMSET(sb_info->parity_mask, 0, sizeof(u32) * NUM_ATTN_REGS);
1246 for (i = 0; i < NUM_ATTN_REGS; i++) {
1247 /* j is array index, k is bit index */
1248 for (j = 0, k = 0; k < 32; j++) {
1249 unsigned int flags = aeu_descs[i].bits[j].flags;
1251 if (flags & ATTENTION_PARITY)
1252 sb_info->parity_mask[i] |= 1 << k;
1254 k += ATTENTION_LENGTH(flags);
1256 DP_VERBOSE(p_hwfn, ECORE_MSG_INTR,
1257 "Attn Mask [Reg %d]: 0x%08x\n",
1258 i, sb_info->parity_mask[i]);
1261 /* Set the address of cleanup for the mcp attention */
1262 sb_info->mfw_attn_addr = (p_hwfn->rel_pf_id << 3) +
1263 MISC_REG_AEU_GENERAL_ATTN_0;
1265 ecore_int_sb_attn_setup(p_hwfn, p_ptt);
1268 static enum _ecore_status_t ecore_int_sb_attn_alloc(struct ecore_hwfn *p_hwfn,
1269 struct ecore_ptt *p_ptt)
1271 struct ecore_dev *p_dev = p_hwfn->p_dev;
1272 struct ecore_sb_attn_info *p_sb;
1273 dma_addr_t p_phys = 0;
1277 p_sb = OSAL_ALLOC(p_dev, GFP_KERNEL, sizeof(struct ecore_sb_attn_info));
1279 DP_NOTICE(p_dev, true,
1280 "Failed to allocate `struct ecore_sb_attn_info'");
1285 p_virt = OSAL_DMA_ALLOC_COHERENT(p_dev, &p_phys,
1286 SB_ATTN_ALIGNED_SIZE(p_hwfn));
1288 DP_NOTICE(p_dev, true,
1289 "Failed to allocate status block (attentions)");
1290 OSAL_FREE(p_dev, p_sb);
1294 /* Attention setup */
1295 p_hwfn->p_sb_attn = p_sb;
1296 ecore_int_sb_attn_init(p_hwfn, p_ptt, p_virt, p_phys);
1298 return ECORE_SUCCESS;
1301 /* coalescing timeout = timeset << (timer_res + 1) */
1302 #ifdef RTE_LIBRTE_QEDE_RX_COAL_US
1303 #define ECORE_CAU_DEF_RX_USECS RTE_LIBRTE_QEDE_RX_COAL_US
1305 #define ECORE_CAU_DEF_RX_USECS 24
1308 #ifdef RTE_LIBRTE_QEDE_TX_COAL_US
1309 #define ECORE_CAU_DEF_TX_USECS RTE_LIBRTE_QEDE_TX_COAL_US
1311 #define ECORE_CAU_DEF_TX_USECS 48
1314 void ecore_init_cau_sb_entry(struct ecore_hwfn *p_hwfn,
1315 struct cau_sb_entry *p_sb_entry,
1316 u8 pf_id, u16 vf_number, u8 vf_valid)
1318 struct ecore_dev *p_dev = p_hwfn->p_dev;
1321 OSAL_MEMSET(p_sb_entry, 0, sizeof(*p_sb_entry));
1323 SET_FIELD(p_sb_entry->params, CAU_SB_ENTRY_PF_NUMBER, pf_id);
1324 SET_FIELD(p_sb_entry->params, CAU_SB_ENTRY_VF_NUMBER, vf_number);
1325 SET_FIELD(p_sb_entry->params, CAU_SB_ENTRY_VF_VALID, vf_valid);
1326 SET_FIELD(p_sb_entry->params, CAU_SB_ENTRY_SB_TIMESET0, 0x7F);
1327 SET_FIELD(p_sb_entry->params, CAU_SB_ENTRY_SB_TIMESET1, 0x7F);
1329 /* setting the time resultion to a fixed value ( = 1) */
1330 SET_FIELD(p_sb_entry->params, CAU_SB_ENTRY_TIMER_RES0,
1331 ECORE_CAU_DEF_RX_TIMER_RES);
1332 SET_FIELD(p_sb_entry->params, CAU_SB_ENTRY_TIMER_RES1,
1333 ECORE_CAU_DEF_TX_TIMER_RES);
1335 cau_state = CAU_HC_DISABLE_STATE;
1337 if (p_dev->int_coalescing_mode == ECORE_COAL_MODE_ENABLE) {
1338 cau_state = CAU_HC_ENABLE_STATE;
1339 if (!p_dev->rx_coalesce_usecs) {
1340 p_dev->rx_coalesce_usecs = ECORE_CAU_DEF_RX_USECS;
1341 DP_INFO(p_dev, "Coalesce params rx-usecs=%u\n",
1342 p_dev->rx_coalesce_usecs);
1344 if (!p_dev->tx_coalesce_usecs) {
1345 p_dev->tx_coalesce_usecs = ECORE_CAU_DEF_TX_USECS;
1346 DP_INFO(p_dev, "Coalesce params tx-usecs=%u\n",
1347 p_dev->tx_coalesce_usecs);
1351 SET_FIELD(p_sb_entry->data, CAU_SB_ENTRY_STATE0, cau_state);
1352 SET_FIELD(p_sb_entry->data, CAU_SB_ENTRY_STATE1, cau_state);
1355 void ecore_int_cau_conf_sb(struct ecore_hwfn *p_hwfn,
1356 struct ecore_ptt *p_ptt,
1357 dma_addr_t sb_phys, u16 igu_sb_id,
1358 u16 vf_number, u8 vf_valid)
1360 struct cau_sb_entry sb_entry;
1362 ecore_init_cau_sb_entry(p_hwfn, &sb_entry, p_hwfn->rel_pf_id,
1363 vf_number, vf_valid);
1365 if (p_hwfn->hw_init_done) {
1366 /* Wide-bus, initialize via DMAE */
1367 u64 phys_addr = (u64)sb_phys;
1369 ecore_dmae_host2grc(p_hwfn, p_ptt,
1370 (u64)(osal_uintptr_t)&phys_addr,
1371 CAU_REG_SB_ADDR_MEMORY +
1372 igu_sb_id * sizeof(u64), 2, 0);
1373 ecore_dmae_host2grc(p_hwfn, p_ptt,
1374 (u64)(osal_uintptr_t)&sb_entry,
1375 CAU_REG_SB_VAR_MEMORY +
1376 igu_sb_id * sizeof(u64), 2, 0);
1378 /* Initialize Status Block Address */
1379 STORE_RT_REG_AGG(p_hwfn,
1380 CAU_REG_SB_ADDR_MEMORY_RT_OFFSET +
1381 igu_sb_id * 2, sb_phys);
1383 STORE_RT_REG_AGG(p_hwfn,
1384 CAU_REG_SB_VAR_MEMORY_RT_OFFSET +
1385 igu_sb_id * 2, sb_entry);
1388 /* Configure pi coalescing if set */
1389 if (p_hwfn->p_dev->int_coalescing_mode == ECORE_COAL_MODE_ENABLE) {
1390 u8 num_tc = 1; /* @@@TBD aelior ECORE_MULTI_COS */
1391 u8 timeset = p_hwfn->p_dev->rx_coalesce_usecs >>
1392 (ECORE_CAU_DEF_RX_TIMER_RES + 1);
1395 ecore_int_cau_conf_pi(p_hwfn, p_ptt, igu_sb_id, RX_PI,
1396 ECORE_COAL_RX_STATE_MACHINE, timeset);
1398 timeset = p_hwfn->p_dev->tx_coalesce_usecs >>
1399 (ECORE_CAU_DEF_TX_TIMER_RES + 1);
1401 for (i = 0; i < num_tc; i++) {
1402 ecore_int_cau_conf_pi(p_hwfn, p_ptt,
1403 igu_sb_id, TX_PI(i),
1404 ECORE_COAL_TX_STATE_MACHINE,
1410 void ecore_int_cau_conf_pi(struct ecore_hwfn *p_hwfn,
1411 struct ecore_ptt *p_ptt,
1412 u16 igu_sb_id, u32 pi_index,
1413 enum ecore_coalescing_fsm coalescing_fsm, u8 timeset)
1415 struct cau_pi_entry pi_entry;
1416 u32 sb_offset, pi_offset;
1418 if (IS_VF(p_hwfn->p_dev))
1419 return; /* @@@TBD MichalK- VF CAU... */
1421 sb_offset = igu_sb_id * PIS_PER_SB;
1422 OSAL_MEMSET(&pi_entry, 0, sizeof(struct cau_pi_entry));
1424 SET_FIELD(pi_entry.prod, CAU_PI_ENTRY_PI_TIMESET, timeset);
1425 if (coalescing_fsm == ECORE_COAL_RX_STATE_MACHINE)
1426 SET_FIELD(pi_entry.prod, CAU_PI_ENTRY_FSM_SEL, 0);
1428 SET_FIELD(pi_entry.prod, CAU_PI_ENTRY_FSM_SEL, 1);
1430 pi_offset = sb_offset + pi_index;
1431 if (p_hwfn->hw_init_done) {
1432 ecore_wr(p_hwfn, p_ptt,
1433 CAU_REG_PI_MEMORY + pi_offset * sizeof(u32),
1434 *((u32 *)&(pi_entry)));
1436 STORE_RT_REG(p_hwfn,
1437 CAU_REG_PI_MEMORY_RT_OFFSET + pi_offset,
1438 *((u32 *)&(pi_entry)));
1442 void ecore_int_sb_setup(struct ecore_hwfn *p_hwfn,
1443 struct ecore_ptt *p_ptt, struct ecore_sb_info *sb_info)
1445 /* zero status block and ack counter */
1446 sb_info->sb_ack = 0;
1447 OSAL_MEMSET(sb_info->sb_virt, 0, sizeof(*sb_info->sb_virt));
1449 if (IS_PF(p_hwfn->p_dev))
1450 ecore_int_cau_conf_sb(p_hwfn, p_ptt, sb_info->sb_phys,
1451 sb_info->igu_sb_id, 0, 0);
1455 * @brief ecore_get_igu_sb_id - given a sw sb_id return the
1463 static u16 ecore_get_igu_sb_id(struct ecore_hwfn *p_hwfn, u16 sb_id)
1467 /* Assuming continuous set of IGU SBs dedicated for given PF */
1468 if (sb_id == ECORE_SP_SB_ID)
1469 igu_sb_id = p_hwfn->hw_info.p_igu_info->igu_dsb_id;
1470 else if (IS_PF(p_hwfn->p_dev))
1471 igu_sb_id = sb_id + p_hwfn->hw_info.p_igu_info->igu_base_sb;
1473 igu_sb_id = ecore_vf_get_igu_sb_id(p_hwfn, sb_id);
1475 if (sb_id == ECORE_SP_SB_ID)
1476 DP_VERBOSE(p_hwfn, ECORE_MSG_INTR,
1477 "Slowpath SB index in IGU is 0x%04x\n", igu_sb_id);
1479 DP_VERBOSE(p_hwfn, ECORE_MSG_INTR,
1480 "SB [%04x] <--> IGU SB [%04x]\n", sb_id, igu_sb_id);
1485 enum _ecore_status_t ecore_int_sb_init(struct ecore_hwfn *p_hwfn,
1486 struct ecore_ptt *p_ptt,
1487 struct ecore_sb_info *sb_info,
1489 dma_addr_t sb_phy_addr, u16 sb_id)
1491 sb_info->sb_virt = sb_virt_addr;
1492 sb_info->sb_phys = sb_phy_addr;
1494 sb_info->igu_sb_id = ecore_get_igu_sb_id(p_hwfn, sb_id);
1496 if (sb_id != ECORE_SP_SB_ID) {
1497 p_hwfn->sbs_info[sb_id] = sb_info;
1500 #ifdef ECORE_CONFIG_DIRECT_HWFN
1501 sb_info->p_hwfn = p_hwfn;
1503 sb_info->p_dev = p_hwfn->p_dev;
1505 /* The igu address will hold the absolute address that needs to be
1506 * written to for a specific status block
1508 if (IS_PF(p_hwfn->p_dev)) {
1509 sb_info->igu_addr = (u8 OSAL_IOMEM *)p_hwfn->regview +
1510 GTT_BAR0_MAP_REG_IGU_CMD + (sb_info->igu_sb_id << 3);
1514 (u8 OSAL_IOMEM *)p_hwfn->regview +
1515 PXP_VF_BAR0_START_IGU +
1516 ((IGU_CMD_INT_ACK_BASE + sb_info->igu_sb_id) << 3);
1519 sb_info->flags |= ECORE_SB_INFO_INIT;
1521 ecore_int_sb_setup(p_hwfn, p_ptt, sb_info);
1523 return ECORE_SUCCESS;
1526 enum _ecore_status_t ecore_int_sb_release(struct ecore_hwfn *p_hwfn,
1527 struct ecore_sb_info *sb_info,
1530 if (sb_id == ECORE_SP_SB_ID) {
1531 DP_ERR(p_hwfn, "Do Not free sp sb using this function");
1535 /* zero status block and ack counter */
1536 sb_info->sb_ack = 0;
1537 OSAL_MEMSET(sb_info->sb_virt, 0, sizeof(*sb_info->sb_virt));
1539 if (p_hwfn->sbs_info[sb_id] != OSAL_NULL) {
1540 p_hwfn->sbs_info[sb_id] = OSAL_NULL;
1544 return ECORE_SUCCESS;
1547 static void ecore_int_sp_sb_free(struct ecore_hwfn *p_hwfn)
1549 struct ecore_sb_sp_info *p_sb = p_hwfn->p_sp_sb;
1554 if (p_sb->sb_info.sb_virt) {
1555 OSAL_DMA_FREE_COHERENT(p_hwfn->p_dev,
1556 p_sb->sb_info.sb_virt,
1557 p_sb->sb_info.sb_phys,
1558 SB_ALIGNED_SIZE(p_hwfn));
1561 OSAL_FREE(p_hwfn->p_dev, p_sb);
1564 static enum _ecore_status_t ecore_int_sp_sb_alloc(struct ecore_hwfn *p_hwfn,
1565 struct ecore_ptt *p_ptt)
1567 struct ecore_sb_sp_info *p_sb;
1568 dma_addr_t p_phys = 0;
1573 OSAL_ALLOC(p_hwfn->p_dev, GFP_KERNEL,
1574 sizeof(struct ecore_sb_sp_info));
1576 DP_NOTICE(p_hwfn, true,
1577 "Failed to allocate `struct ecore_sb_info'");
1582 p_virt = OSAL_DMA_ALLOC_COHERENT(p_hwfn->p_dev,
1583 &p_phys, SB_ALIGNED_SIZE(p_hwfn));
1585 DP_NOTICE(p_hwfn, true, "Failed to allocate status block");
1586 OSAL_FREE(p_hwfn->p_dev, p_sb);
1590 /* Status Block setup */
1591 p_hwfn->p_sp_sb = p_sb;
1592 ecore_int_sb_init(p_hwfn, p_ptt, &p_sb->sb_info,
1593 p_virt, p_phys, ECORE_SP_SB_ID);
1595 OSAL_MEMSET(p_sb->pi_info_arr, 0, sizeof(p_sb->pi_info_arr));
1597 return ECORE_SUCCESS;
1600 enum _ecore_status_t ecore_int_register_cb(struct ecore_hwfn *p_hwfn,
1601 ecore_int_comp_cb_t comp_cb,
1603 u8 *sb_idx, __le16 **p_fw_cons)
1605 struct ecore_sb_sp_info *p_sp_sb = p_hwfn->p_sp_sb;
1606 enum _ecore_status_t rc = ECORE_NOMEM;
1609 /* Look for a free index */
1610 for (pi = 0; pi < OSAL_ARRAY_SIZE(p_sp_sb->pi_info_arr); pi++) {
1611 if (p_sp_sb->pi_info_arr[pi].comp_cb != OSAL_NULL)
1614 p_sp_sb->pi_info_arr[pi].comp_cb = comp_cb;
1615 p_sp_sb->pi_info_arr[pi].cookie = cookie;
1617 *p_fw_cons = &p_sp_sb->sb_info.sb_virt->pi_array[pi];
1625 enum _ecore_status_t ecore_int_unregister_cb(struct ecore_hwfn *p_hwfn, u8 pi)
1627 struct ecore_sb_sp_info *p_sp_sb = p_hwfn->p_sp_sb;
1629 if (p_sp_sb->pi_info_arr[pi].comp_cb == OSAL_NULL)
1632 p_sp_sb->pi_info_arr[pi].comp_cb = OSAL_NULL;
1633 p_sp_sb->pi_info_arr[pi].cookie = OSAL_NULL;
1634 return ECORE_SUCCESS;
1637 u16 ecore_int_get_sp_sb_id(struct ecore_hwfn *p_hwfn)
1639 return p_hwfn->p_sp_sb->sb_info.igu_sb_id;
1642 void ecore_int_igu_enable_int(struct ecore_hwfn *p_hwfn,
1643 struct ecore_ptt *p_ptt,
1644 enum ecore_int_mode int_mode)
1646 u32 igu_pf_conf = IGU_PF_CONF_FUNC_EN;
1649 if (CHIP_REV_IS_FPGA(p_hwfn->p_dev))
1650 DP_INFO(p_hwfn, "FPGA - don't enable ATTN generation in IGU\n");
1653 igu_pf_conf |= IGU_PF_CONF_ATTN_BIT_EN;
1655 p_hwfn->p_dev->int_mode = int_mode;
1656 switch (p_hwfn->p_dev->int_mode) {
1657 case ECORE_INT_MODE_INTA:
1658 igu_pf_conf |= IGU_PF_CONF_INT_LINE_EN;
1659 igu_pf_conf |= IGU_PF_CONF_SINGLE_ISR_EN;
1662 case ECORE_INT_MODE_MSI:
1663 igu_pf_conf |= IGU_PF_CONF_MSI_MSIX_EN;
1664 igu_pf_conf |= IGU_PF_CONF_SINGLE_ISR_EN;
1667 case ECORE_INT_MODE_MSIX:
1668 igu_pf_conf |= IGU_PF_CONF_MSI_MSIX_EN;
1670 case ECORE_INT_MODE_POLL:
1674 ecore_wr(p_hwfn, p_ptt, IGU_REG_PF_CONFIGURATION, igu_pf_conf);
1677 static void ecore_int_igu_enable_attn(struct ecore_hwfn *p_hwfn,
1678 struct ecore_ptt *p_ptt)
1681 if (CHIP_REV_IS_FPGA(p_hwfn->p_dev)) {
1683 "FPGA - Don't enable Attentions in IGU and MISC\n");
1688 /* Configure AEU signal change to produce attentions */
1689 ecore_wr(p_hwfn, p_ptt, IGU_REG_ATTENTION_ENABLE, 0);
1690 ecore_wr(p_hwfn, p_ptt, IGU_REG_LEADING_EDGE_LATCH, 0xfff);
1691 ecore_wr(p_hwfn, p_ptt, IGU_REG_TRAILING_EDGE_LATCH, 0xfff);
1692 ecore_wr(p_hwfn, p_ptt, IGU_REG_ATTENTION_ENABLE, 0xfff);
1694 OSAL_MMIOWB(p_hwfn->p_dev);
1696 /* Unmask AEU signals toward IGU */
1697 ecore_wr(p_hwfn, p_ptt, MISC_REG_AEU_MASK_ATTN_IGU, 0xff);
1700 enum _ecore_status_t
1701 ecore_int_igu_enable(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
1702 enum ecore_int_mode int_mode)
1704 enum _ecore_status_t rc = ECORE_SUCCESS;
1707 /* @@@tmp - Mask General HW attentions 0-31, Enable 32-36 */
1708 tmp = ecore_rd(p_hwfn, p_ptt, MISC_REG_AEU_ENABLE4_IGU_OUT_0);
1710 ecore_wr(p_hwfn, p_ptt, MISC_REG_AEU_ENABLE3_IGU_OUT_0, 0);
1711 ecore_wr(p_hwfn, p_ptt, MISC_REG_AEU_ENABLE4_IGU_OUT_0, tmp);
1713 /* @@@tmp - Starting with MFW 8.2.1.0 we've started hitting AVS stop
1714 * attentions. Since we're waiting for BRCM answer regarding this
1715 * attention, in the meanwhile we simply mask it.
1717 tmp = ecore_rd(p_hwfn, p_ptt, MISC_REG_AEU_ENABLE4_IGU_OUT_0);
1719 ecore_wr(p_hwfn, p_ptt, MISC_REG_AEU_ENABLE4_IGU_OUT_0, tmp);
1721 ecore_int_igu_enable_attn(p_hwfn, p_ptt);
1723 if ((int_mode != ECORE_INT_MODE_INTA) || IS_LEAD_HWFN(p_hwfn)) {
1724 rc = OSAL_SLOWPATH_IRQ_REQ(p_hwfn);
1725 if (rc != ECORE_SUCCESS) {
1726 DP_NOTICE(p_hwfn, true,
1727 "Slowpath IRQ request failed\n");
1728 return ECORE_NORESOURCES;
1730 p_hwfn->b_int_requested = true;
1733 /* Enable interrupt Generation */
1734 ecore_int_igu_enable_int(p_hwfn, p_ptt, int_mode);
1736 p_hwfn->b_int_enabled = 1;
1741 void ecore_int_igu_disable_int(struct ecore_hwfn *p_hwfn,
1742 struct ecore_ptt *p_ptt)
1744 p_hwfn->b_int_enabled = 0;
1746 if (IS_VF(p_hwfn->p_dev))
1749 ecore_wr(p_hwfn, p_ptt, IGU_REG_PF_CONFIGURATION, 0);
1752 #define IGU_CLEANUP_SLEEP_LENGTH (1000)
1753 void ecore_int_igu_cleanup_sb(struct ecore_hwfn *p_hwfn,
1754 struct ecore_ptt *p_ptt,
1755 u32 sb_id, bool cleanup_set, u16 opaque_fid)
1757 u32 cmd_ctrl = 0, val = 0, sb_bit = 0, sb_bit_addr = 0, data = 0;
1758 u32 pxp_addr = IGU_CMD_INT_ACK_BASE + sb_id;
1759 u32 sleep_cnt = IGU_CLEANUP_SLEEP_LENGTH;
1760 u8 type = 0; /* FIXME MichalS type??? */
1762 OSAL_BUILD_BUG_ON((IGU_REG_CLEANUP_STATUS_4 -
1763 IGU_REG_CLEANUP_STATUS_0) != 0x200);
1765 /* USE Control Command Register to perform cleanup. There is an
1766 * option to do this using IGU bar, but then it can't be used for VFs.
1769 /* Set the data field */
1770 SET_FIELD(data, IGU_CLEANUP_CLEANUP_SET, cleanup_set ? 1 : 0);
1771 SET_FIELD(data, IGU_CLEANUP_CLEANUP_TYPE, type);
1772 SET_FIELD(data, IGU_CLEANUP_COMMAND_TYPE, IGU_COMMAND_TYPE_SET);
1774 /* Set the control register */
1775 SET_FIELD(cmd_ctrl, IGU_CTRL_REG_PXP_ADDR, pxp_addr);
1776 SET_FIELD(cmd_ctrl, IGU_CTRL_REG_FID, opaque_fid);
1777 SET_FIELD(cmd_ctrl, IGU_CTRL_REG_TYPE, IGU_CTRL_CMD_TYPE_WR);
1779 ecore_wr(p_hwfn, p_ptt, IGU_REG_COMMAND_REG_32LSB_DATA, data);
1781 OSAL_BARRIER(p_hwfn->p_dev);
1783 ecore_wr(p_hwfn, p_ptt, IGU_REG_COMMAND_REG_CTRL, cmd_ctrl);
1785 OSAL_MMIOWB(p_hwfn->p_dev);
1787 /* calculate where to read the status bit from */
1788 sb_bit = 1 << (sb_id % 32);
1789 sb_bit_addr = sb_id / 32 * sizeof(u32);
1791 sb_bit_addr += IGU_REG_CLEANUP_STATUS_0 + (0x80 * type);
1793 /* Now wait for the command to complete */
1794 while (--sleep_cnt) {
1795 val = ecore_rd(p_hwfn, p_ptt, sb_bit_addr);
1796 if ((val & sb_bit) == (cleanup_set ? sb_bit : 0))
1802 DP_NOTICE(p_hwfn, true,
1803 "Timeout waiting for clear status 0x%08x [for sb %d]\n",
1807 void ecore_int_igu_init_pure_rt_single(struct ecore_hwfn *p_hwfn,
1808 struct ecore_ptt *p_ptt,
1809 u32 sb_id, u16 opaque, bool b_set)
1815 ecore_int_igu_cleanup_sb(p_hwfn, p_ptt, sb_id, 1, opaque);
1818 ecore_int_igu_cleanup_sb(p_hwfn, p_ptt, sb_id, 0, opaque);
1820 /* Clear the CAU for the SB */
1821 for (pi = 0; pi < 12; pi++)
1822 ecore_wr(p_hwfn, p_ptt,
1823 CAU_REG_PI_MEMORY + (sb_id * 12 + pi) * 4, 0);
1826 void ecore_int_igu_init_pure_rt(struct ecore_hwfn *p_hwfn,
1827 struct ecore_ptt *p_ptt,
1828 bool b_set, bool b_slowpath)
1830 u32 igu_base_sb = p_hwfn->hw_info.p_igu_info->igu_base_sb;
1831 u32 igu_sb_cnt = p_hwfn->hw_info.p_igu_info->igu_sb_cnt;
1832 u32 sb_id = 0, val = 0;
1834 /* @@@TBD MichalK temporary... should be moved to init-tool... */
1835 val = ecore_rd(p_hwfn, p_ptt, IGU_REG_BLOCK_CONFIGURATION);
1836 val |= IGU_REG_BLOCK_CONFIGURATION_VF_CLEANUP_EN;
1837 val &= ~IGU_REG_BLOCK_CONFIGURATION_PXP_TPH_INTERFACE_EN;
1838 ecore_wr(p_hwfn, p_ptt, IGU_REG_BLOCK_CONFIGURATION, val);
1841 DP_VERBOSE(p_hwfn, ECORE_MSG_INTR,
1842 "IGU cleaning SBs [%d,...,%d]\n",
1843 igu_base_sb, igu_base_sb + igu_sb_cnt - 1);
1845 for (sb_id = igu_base_sb; sb_id < igu_base_sb + igu_sb_cnt; sb_id++)
1846 ecore_int_igu_init_pure_rt_single(p_hwfn, p_ptt, sb_id,
1847 p_hwfn->hw_info.opaque_fid,
1853 sb_id = p_hwfn->hw_info.p_igu_info->igu_dsb_id;
1854 DP_VERBOSE(p_hwfn, ECORE_MSG_INTR,
1855 "IGU cleaning slowpath SB [%d]\n", sb_id);
1856 ecore_int_igu_init_pure_rt_single(p_hwfn, p_ptt, sb_id,
1857 p_hwfn->hw_info.opaque_fid, b_set);
1860 static u32 ecore_int_igu_read_cam_block(struct ecore_hwfn *p_hwfn,
1861 struct ecore_ptt *p_ptt, u16 sb_id)
1863 u32 val = ecore_rd(p_hwfn, p_ptt,
1864 IGU_REG_MAPPING_MEMORY + sizeof(u32) * sb_id);
1865 struct ecore_igu_block *p_block;
1867 p_block = &p_hwfn->hw_info.p_igu_info->igu_map.igu_blocks[sb_id];
1869 /* stop scanning when hit first invalid PF entry */
1870 if (!GET_FIELD(val, IGU_MAPPING_LINE_VALID) &&
1871 GET_FIELD(val, IGU_MAPPING_LINE_PF_VALID))
1874 /* Fill the block information */
1875 p_block->status = ECORE_IGU_STATUS_VALID;
1876 p_block->function_id = GET_FIELD(val, IGU_MAPPING_LINE_FUNCTION_NUMBER);
1877 p_block->is_pf = GET_FIELD(val, IGU_MAPPING_LINE_PF_VALID);
1878 p_block->vector_number = GET_FIELD(val, IGU_MAPPING_LINE_VECTOR_NUMBER);
1880 DP_VERBOSE(p_hwfn, ECORE_MSG_INTR,
1881 "IGU_BLOCK: [SB 0x%04x, Value in CAM 0x%08x] func_id = %d"
1882 " is_pf = %d vector_num = 0x%x\n",
1883 sb_id, val, p_block->function_id, p_block->is_pf,
1884 p_block->vector_number);
1890 enum _ecore_status_t ecore_int_igu_read_cam(struct ecore_hwfn *p_hwfn,
1891 struct ecore_ptt *p_ptt)
1893 struct ecore_igu_info *p_igu_info;
1894 struct ecore_igu_block *p_block;
1895 u16 sb_id, last_iov_sb_id = 0;
1896 u32 min_vf, max_vf, val;
1897 u16 prev_sb_id = 0xFF;
1899 p_hwfn->hw_info.p_igu_info = OSAL_ALLOC(p_hwfn->p_dev,
1901 sizeof(*p_igu_info));
1902 if (!p_hwfn->hw_info.p_igu_info)
1905 OSAL_MEMSET(p_hwfn->hw_info.p_igu_info, 0, sizeof(*p_igu_info));
1907 p_igu_info = p_hwfn->hw_info.p_igu_info;
1909 /* Initialize base sb / sb cnt for PFs and VFs */
1910 p_igu_info->igu_base_sb = 0xffff;
1911 p_igu_info->igu_sb_cnt = 0;
1912 p_igu_info->igu_dsb_id = 0xffff;
1913 p_igu_info->igu_base_sb_iov = 0xffff;
1915 #ifdef CONFIG_ECORE_SRIOV
1916 min_vf = p_hwfn->hw_info.first_vf_in_pf;
1917 max_vf = p_hwfn->hw_info.first_vf_in_pf +
1918 p_hwfn->p_dev->sriov_info.total_vfs;
1924 for (sb_id = 0; sb_id < ECORE_MAPPING_MEMORY_SIZE(p_hwfn->p_dev);
1926 p_block = &p_igu_info->igu_map.igu_blocks[sb_id];
1927 val = ecore_int_igu_read_cam_block(p_hwfn, p_ptt, sb_id);
1928 if (!GET_FIELD(val, IGU_MAPPING_LINE_VALID) &&
1929 GET_FIELD(val, IGU_MAPPING_LINE_PF_VALID))
1932 if (p_block->is_pf) {
1933 if (p_block->function_id == p_hwfn->rel_pf_id) {
1934 p_block->status |= ECORE_IGU_STATUS_PF;
1936 if (p_block->vector_number == 0) {
1937 if (p_igu_info->igu_dsb_id == 0xffff)
1938 p_igu_info->igu_dsb_id = sb_id;
1940 if (p_igu_info->igu_base_sb == 0xffff) {
1941 p_igu_info->igu_base_sb = sb_id;
1942 } else if (prev_sb_id != sb_id - 1) {
1943 DP_NOTICE(p_hwfn->p_dev, false,
1951 /* we don't count the default */
1952 (p_igu_info->igu_sb_cnt)++;
1956 if ((p_block->function_id >= min_vf) &&
1957 (p_block->function_id < max_vf)) {
1958 /* Available for VFs of this PF */
1959 if (p_igu_info->igu_base_sb_iov == 0xffff) {
1960 p_igu_info->igu_base_sb_iov = sb_id;
1961 } else if (last_iov_sb_id != sb_id - 1) {
1963 DP_VERBOSE(p_hwfn->p_dev,
1965 "First uninited IGU"
1970 DP_NOTICE(p_hwfn->p_dev, false,
1981 p_block->status |= ECORE_IGU_STATUS_FREE;
1982 p_hwfn->hw_info.p_igu_info->free_blks++;
1983 last_iov_sb_id = sb_id;
1987 p_igu_info->igu_sb_cnt_iov = p_igu_info->free_blks;
1989 DP_VERBOSE(p_hwfn, ECORE_MSG_INTR,
1990 "IGU igu_base_sb=0x%x [IOV 0x%x] igu_sb_cnt=%d [IOV 0x%x] "
1991 "igu_dsb_id=0x%x\n",
1992 p_igu_info->igu_base_sb, p_igu_info->igu_base_sb_iov,
1993 p_igu_info->igu_sb_cnt, p_igu_info->igu_sb_cnt_iov,
1994 p_igu_info->igu_dsb_id);
1996 if (p_igu_info->igu_base_sb == 0xffff ||
1997 p_igu_info->igu_dsb_id == 0xffff || p_igu_info->igu_sb_cnt == 0) {
1998 DP_NOTICE(p_hwfn, true,
1999 "IGU CAM returned invalid values igu_base_sb=0x%x "
2000 "igu_sb_cnt=%d igu_dsb_id=0x%x\n",
2001 p_igu_info->igu_base_sb, p_igu_info->igu_sb_cnt,
2002 p_igu_info->igu_dsb_id);
2006 return ECORE_SUCCESS;
2010 * @brief Initialize igu runtime registers
2014 void ecore_int_igu_init_rt(struct ecore_hwfn *p_hwfn)
2016 u32 igu_pf_conf = IGU_PF_CONF_FUNC_EN;
2018 STORE_RT_REG(p_hwfn, IGU_REG_PF_CONFIGURATION_RT_OFFSET, igu_pf_conf);
2021 #define LSB_IGU_CMD_ADDR (IGU_REG_SISR_MDPC_WMASK_LSB_UPPER - \
2022 IGU_CMD_INT_ACK_BASE)
2023 #define MSB_IGU_CMD_ADDR (IGU_REG_SISR_MDPC_WMASK_MSB_UPPER - \
2024 IGU_CMD_INT_ACK_BASE)
2025 u64 ecore_int_igu_read_sisr_reg(struct ecore_hwfn *p_hwfn)
2027 u32 intr_status_hi = 0, intr_status_lo = 0;
2028 u64 intr_status = 0;
2030 intr_status_lo = REG_RD(p_hwfn,
2031 GTT_BAR0_MAP_REG_IGU_CMD +
2032 LSB_IGU_CMD_ADDR * 8);
2033 intr_status_hi = REG_RD(p_hwfn,
2034 GTT_BAR0_MAP_REG_IGU_CMD +
2035 MSB_IGU_CMD_ADDR * 8);
2036 intr_status = ((u64)intr_status_hi << 32) + (u64)intr_status_lo;
2041 static void ecore_int_sp_dpc_setup(struct ecore_hwfn *p_hwfn)
2043 OSAL_DPC_INIT(p_hwfn->sp_dpc, p_hwfn);
2044 p_hwfn->b_sp_dpc_enabled = true;
2047 static enum _ecore_status_t ecore_int_sp_dpc_alloc(struct ecore_hwfn *p_hwfn)
2049 p_hwfn->sp_dpc = OSAL_DPC_ALLOC(p_hwfn);
2050 if (!p_hwfn->sp_dpc)
2053 return ECORE_SUCCESS;
2056 static void ecore_int_sp_dpc_free(struct ecore_hwfn *p_hwfn)
2058 OSAL_FREE(p_hwfn->p_dev, p_hwfn->sp_dpc);
2061 enum _ecore_status_t ecore_int_alloc(struct ecore_hwfn *p_hwfn,
2062 struct ecore_ptt *p_ptt)
2064 enum _ecore_status_t rc = ECORE_SUCCESS;
2066 rc = ecore_int_sp_dpc_alloc(p_hwfn);
2067 if (rc != ECORE_SUCCESS) {
2068 DP_ERR(p_hwfn->p_dev, "Failed to allocate sp dpc mem\n");
2072 rc = ecore_int_sp_sb_alloc(p_hwfn, p_ptt);
2073 if (rc != ECORE_SUCCESS) {
2074 DP_ERR(p_hwfn->p_dev, "Failed to allocate sp sb mem\n");
2078 rc = ecore_int_sb_attn_alloc(p_hwfn, p_ptt);
2079 if (rc != ECORE_SUCCESS)
2080 DP_ERR(p_hwfn->p_dev, "Failed to allocate sb attn mem\n");
2085 void ecore_int_free(struct ecore_hwfn *p_hwfn)
2087 ecore_int_sp_sb_free(p_hwfn);
2088 ecore_int_sb_attn_free(p_hwfn);
2089 ecore_int_sp_dpc_free(p_hwfn);
2092 void ecore_int_setup(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt)
2094 if (!p_hwfn || !p_hwfn->p_sp_sb || !p_hwfn->p_sb_attn)
2097 ecore_int_sb_setup(p_hwfn, p_ptt, &p_hwfn->p_sp_sb->sb_info);
2098 ecore_int_sb_attn_setup(p_hwfn, p_ptt);
2099 ecore_int_sp_dpc_setup(p_hwfn);
2102 void ecore_int_get_num_sbs(struct ecore_hwfn *p_hwfn,
2103 struct ecore_sb_cnt_info *p_sb_cnt_info)
2105 struct ecore_igu_info *info = p_hwfn->hw_info.p_igu_info;
2107 if (!info || !p_sb_cnt_info)
2110 p_sb_cnt_info->sb_cnt = info->igu_sb_cnt;
2111 p_sb_cnt_info->sb_iov_cnt = info->igu_sb_cnt_iov;
2112 p_sb_cnt_info->sb_free_blk = info->free_blks;
2115 u16 ecore_int_queue_id_from_sb_id(struct ecore_hwfn *p_hwfn, u16 sb_id)
2117 struct ecore_igu_info *p_info = p_hwfn->hw_info.p_igu_info;
2119 /* Determine origin of SB id */
2120 if ((sb_id >= p_info->igu_base_sb) &&
2121 (sb_id < p_info->igu_base_sb + p_info->igu_sb_cnt)) {
2122 return sb_id - p_info->igu_base_sb;
2123 } else if ((sb_id >= p_info->igu_base_sb_iov) &&
2124 (sb_id < p_info->igu_base_sb_iov + p_info->igu_sb_cnt_iov)) {
2125 return sb_id - p_info->igu_base_sb_iov + p_info->igu_sb_cnt;
2128 DP_NOTICE(p_hwfn, true, "SB %d not in range for function\n",
2133 void ecore_int_disable_post_isr_release(struct ecore_dev *p_dev)
2137 for_each_hwfn(p_dev, i)
2138 p_dev->hwfns[i].b_int_requested = false;