1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2020 Marvell Semiconductor Inc.
7 #include <rte_common.h>
8 #include "base/bcm_osal.h"
9 #include "base/ecore.h"
10 #include "base/ecore_cxt.h"
11 #include "base/ecore_hsi_common.h"
12 #include "base/ecore_hw.h"
13 #include "base/ecore_mcp.h"
14 #include "base/reg_addr.h"
15 #include "qede_debug.h"
17 /* Memory groups enum */
35 MEM_GROUP_CONN_CFC_MEM,
38 MEM_GROUP_CAU_MEM_EXT,
48 MEM_GROUP_TASK_CFC_MEM,
52 /* Memory groups names */
53 static const char * const s_mem_group_names[] = {
86 /* Idle check conditions */
88 static u32 cond5(const u32 *r, const u32 *imm)
90 return ((r[0] & imm[0]) != imm[1]) && ((r[1] & imm[2]) != imm[3]);
93 static u32 cond7(const u32 *r, const u32 *imm)
95 return ((r[0] >> imm[0]) & imm[1]) != imm[2];
98 static u32 cond6(const u32 *r, const u32 *imm)
100 return (r[0] & imm[0]) != imm[1];
103 static u32 cond9(const u32 *r, const u32 *imm)
105 return ((r[0] & imm[0]) >> imm[1]) !=
106 (((r[0] & imm[2]) >> imm[3]) | ((r[1] & imm[4]) << imm[5]));
109 static u32 cond10(const u32 *r, const u32 *imm)
111 return ((r[0] & imm[0]) >> imm[1]) != (r[0] & imm[2]);
114 static u32 cond4(const u32 *r, const u32 *imm)
116 return (r[0] & ~imm[0]) != imm[1];
119 static u32 cond0(const u32 *r, const u32 *imm)
121 return (r[0] & ~r[1]) != imm[0];
124 static u32 cond1(const u32 *r, const u32 *imm)
126 return r[0] != imm[0];
129 static u32 cond11(const u32 *r, const u32 *imm)
131 return r[0] != r[1] && r[2] == imm[0];
134 static u32 cond12(const u32 *r, const u32 *imm)
136 return r[0] != r[1] && r[2] > imm[0];
139 static u32 cond3(const u32 *r, const __rte_unused u32 *imm)
144 static u32 cond13(const u32 *r, const u32 *imm)
146 return r[0] & imm[0];
149 static u32 cond8(const u32 *r, const u32 *imm)
151 return r[0] < (r[1] - imm[0]);
154 static u32 cond2(const u32 *r, const u32 *imm)
156 return r[0] > imm[0];
159 /* Array of Idle Check conditions */
160 static u32(*cond_arr[]) (const u32 *r, const u32 *imm) = {
177 #define NUM_PHYS_BLOCKS 84
179 #define NUM_DBG_RESET_REGS 8
181 /******************************* Data Types **********************************/
192 /* CM context types */
201 /* Debug bus frame modes */
202 enum dbg_bus_frame_modes {
203 DBG_BUS_FRAME_MODE_4ST = 0, /* 4 Storm dwords (no HW) */
204 DBG_BUS_FRAME_MODE_2ST_2HW = 1, /* 2 Storm dwords, 2 HW dwords */
205 DBG_BUS_FRAME_MODE_1ST_3HW = 2, /* 1 Storm dwords, 3 HW dwords */
206 DBG_BUS_FRAME_MODE_4HW = 3, /* 4 HW dwords (no Storms) */
207 DBG_BUS_FRAME_MODE_8HW = 4, /* 8 HW dwords (no Storms) */
208 DBG_BUS_NUM_FRAME_MODES
211 /* Chip constant definitions */
217 /* HW type constant definitions */
218 struct hw_type_defs {
225 /* RBC reset definitions */
226 struct rbc_reset_defs {
228 u32 reset_val[MAX_CHIP_IDS];
231 /* Storm constant definitions.
232 * Addresses are in bytes, sizes are in quad-regs.
236 enum block_id sem_block_id;
237 enum dbg_bus_clients dbg_client_id[MAX_CHIP_IDS];
239 u32 sem_fast_mem_addr;
240 u32 sem_frame_mode_addr;
241 u32 sem_slow_enable_addr;
242 u32 sem_slow_mode_addr;
243 u32 sem_slow_mode1_conf_addr;
244 u32 sem_sync_dbg_empty_addr;
245 u32 sem_gpre_vect_addr;
247 u32 cm_ctx_rd_addr[NUM_CM_CTX_TYPES];
248 u32 cm_ctx_lid_sizes[MAX_CHIP_IDS][NUM_CM_CTX_TYPES];
251 /* Debug Bus Constraint operation constant definitions */
252 struct dbg_bus_constraint_op_defs {
257 /* Storm Mode definitions */
258 struct storm_mode_defs {
262 u32 src_disable_reg_addr;
264 bool exists[MAX_CHIP_IDS];
267 struct grc_param_defs {
268 u32 default_val[MAX_CHIP_IDS];
273 u32 exclude_all_preset_val;
274 u32 crash_preset_val[MAX_CHIP_IDS];
277 /* Address is in 128b units. Width is in bits. */
278 struct rss_mem_defs {
279 const char *mem_name;
280 const char *type_name;
283 u32 num_entries[MAX_CHIP_IDS];
286 struct vfc_ram_defs {
287 const char *mem_name;
288 const char *type_name;
293 struct big_ram_defs {
294 const char *instance_name;
295 enum mem_groups mem_group_id;
296 enum mem_groups ram_mem_group_id;
297 enum dbg_grc_params grc_param;
300 u32 is_256b_reg_addr;
301 u32 is_256b_bit_offset[MAX_CHIP_IDS];
302 u32 ram_size[MAX_CHIP_IDS]; /* In dwords */
306 const char *phy_name;
308 /* PHY base GRC address */
311 /* Relative address of indirect TBUS address register (bits 0..7) */
312 u32 tbus_addr_lo_addr;
314 /* Relative address of indirect TBUS address register (bits 8..10) */
315 u32 tbus_addr_hi_addr;
317 /* Relative address of indirect TBUS data register (bits 0..7) */
318 u32 tbus_data_lo_addr;
320 /* Relative address of indirect TBUS data register (bits 8..11) */
321 u32 tbus_data_hi_addr;
324 /* Split type definitions */
325 struct split_type_defs {
329 /******************************** Constants **********************************/
331 #define BYTES_IN_DWORD sizeof(u32)
332 /* In the macros below, size and offset are specified in bits */
333 #define CEIL_DWORDS(size) DIV_ROUND_UP(size, 32)
334 #define FIELD_BIT_OFFSET(type, field) type ## _ ## field ## _ ## OFFSET
335 #define FIELD_BIT_SIZE(type, field) type ## _ ## field ## _ ## SIZE
336 #define FIELD_DWORD_OFFSET(type, field) \
337 (int)(FIELD_BIT_OFFSET(type, field) / 32)
338 #define FIELD_DWORD_SHIFT(type, field) (FIELD_BIT_OFFSET(type, field) % 32)
339 #define FIELD_BIT_MASK(type, field) \
340 (((1 << FIELD_BIT_SIZE(type, field)) - 1) << \
341 FIELD_DWORD_SHIFT(type, field))
343 #define SET_VAR_FIELD(var, type, field, val) \
345 var[FIELD_DWORD_OFFSET(type, field)] &= \
346 (~FIELD_BIT_MASK(type, field)); \
347 var[FIELD_DWORD_OFFSET(type, field)] |= \
348 (val) << FIELD_DWORD_SHIFT(type, field); \
351 #define ARR_REG_WR(dev, ptt, addr, arr, arr_size) \
353 for (i = 0; i < (arr_size); i++) \
354 ecore_wr(dev, ptt, addr, (arr)[i]); \
357 #define DWORDS_TO_BYTES(dwords) ((dwords) * BYTES_IN_DWORD)
358 #define BYTES_TO_DWORDS(bytes) ((bytes) / BYTES_IN_DWORD)
360 /* extra lines include a signature line + optional latency events line */
361 #define NUM_EXTRA_DBG_LINES(block) \
362 (GET_FIELD((block)->flags, DBG_BLOCK_CHIP_HAS_LATENCY_EVENTS) ? 2 : 1)
363 #define NUM_DBG_LINES(block) \
364 ((block)->num_of_dbg_bus_lines + NUM_EXTRA_DBG_LINES(block))
366 #define USE_DMAE true
367 #define PROTECT_WIDE_BUS true
369 #define RAM_LINES_TO_DWORDS(lines) ((lines) * 2)
370 #define RAM_LINES_TO_BYTES(lines) \
371 DWORDS_TO_BYTES(RAM_LINES_TO_DWORDS(lines))
373 #define REG_DUMP_LEN_SHIFT 24
374 #define MEM_DUMP_ENTRY_SIZE_DWORDS \
375 BYTES_TO_DWORDS(sizeof(struct dbg_dump_mem))
377 #define IDLE_CHK_RULE_SIZE_DWORDS \
378 BYTES_TO_DWORDS(sizeof(struct dbg_idle_chk_rule))
380 #define IDLE_CHK_RESULT_HDR_DWORDS \
381 BYTES_TO_DWORDS(sizeof(struct dbg_idle_chk_result_hdr))
383 #define IDLE_CHK_RESULT_REG_HDR_DWORDS \
384 BYTES_TO_DWORDS(sizeof(struct dbg_idle_chk_result_reg_hdr))
386 #define PAGE_MEM_DESC_SIZE_DWORDS \
387 BYTES_TO_DWORDS(sizeof(struct phys_mem_desc))
389 #define IDLE_CHK_MAX_ENTRIES_SIZE 32
391 /* The sizes and offsets below are specified in bits */
392 #define VFC_CAM_CMD_STRUCT_SIZE 64
393 #define VFC_CAM_CMD_ROW_OFFSET 48
394 #define VFC_CAM_CMD_ROW_SIZE 9
395 #define VFC_CAM_ADDR_STRUCT_SIZE 16
396 #define VFC_CAM_ADDR_OP_OFFSET 0
397 #define VFC_CAM_ADDR_OP_SIZE 4
398 #define VFC_CAM_RESP_STRUCT_SIZE 256
399 #define VFC_RAM_ADDR_STRUCT_SIZE 16
400 #define VFC_RAM_ADDR_OP_OFFSET 0
401 #define VFC_RAM_ADDR_OP_SIZE 2
402 #define VFC_RAM_ADDR_ROW_OFFSET 2
403 #define VFC_RAM_ADDR_ROW_SIZE 10
404 #define VFC_RAM_RESP_STRUCT_SIZE 256
406 #define VFC_CAM_CMD_DWORDS CEIL_DWORDS(VFC_CAM_CMD_STRUCT_SIZE)
407 #define VFC_CAM_ADDR_DWORDS CEIL_DWORDS(VFC_CAM_ADDR_STRUCT_SIZE)
408 #define VFC_CAM_RESP_DWORDS CEIL_DWORDS(VFC_CAM_RESP_STRUCT_SIZE)
409 #define VFC_RAM_CMD_DWORDS VFC_CAM_CMD_DWORDS
410 #define VFC_RAM_ADDR_DWORDS CEIL_DWORDS(VFC_RAM_ADDR_STRUCT_SIZE)
411 #define VFC_RAM_RESP_DWORDS CEIL_DWORDS(VFC_RAM_RESP_STRUCT_SIZE)
413 #define NUM_VFC_RAM_TYPES 4
415 #define VFC_CAM_NUM_ROWS 512
417 #define VFC_OPCODE_CAM_RD 14
418 #define VFC_OPCODE_RAM_RD 0
420 #define NUM_RSS_MEM_TYPES 5
422 #define NUM_BIG_RAM_TYPES 3
423 #define BIG_RAM_NAME_LEN 3
425 #define NUM_PHY_TBUS_ADDRESSES 2048
426 #define PHY_DUMP_SIZE_DWORDS (NUM_PHY_TBUS_ADDRESSES / 2)
428 #define RESET_REG_UNRESET_OFFSET 4
430 #define STALL_DELAY_MS 500
432 #define STATIC_DEBUG_LINE_DWORDS 9
434 #define NUM_COMMON_GLOBAL_PARAMS 11
436 #define MAX_RECURSION_DEPTH 10
438 #define FW_IMG_MAIN 1
440 #define REG_FIFO_ELEMENT_DWORDS 2
441 #define REG_FIFO_DEPTH_ELEMENTS 32
442 #define REG_FIFO_DEPTH_DWORDS \
443 (REG_FIFO_ELEMENT_DWORDS * REG_FIFO_DEPTH_ELEMENTS)
445 #define IGU_FIFO_ELEMENT_DWORDS 4
446 #define IGU_FIFO_DEPTH_ELEMENTS 64
447 #define IGU_FIFO_DEPTH_DWORDS \
448 (IGU_FIFO_ELEMENT_DWORDS * IGU_FIFO_DEPTH_ELEMENTS)
450 #define PROTECTION_OVERRIDE_ELEMENT_DWORDS 2
451 #define PROTECTION_OVERRIDE_DEPTH_ELEMENTS 20
452 #define PROTECTION_OVERRIDE_DEPTH_DWORDS \
453 (PROTECTION_OVERRIDE_DEPTH_ELEMENTS * \
454 PROTECTION_OVERRIDE_ELEMENT_DWORDS)
456 #define MCP_SPAD_TRACE_OFFSIZE_ADDR \
458 offsetof(struct static_init, sections[SPAD_SECTION_TRACE]))
460 #define MAX_SW_PLTAFORM_STR_SIZE 64
462 #define EMPTY_FW_VERSION_STR "???_???_???_???"
463 #define EMPTY_FW_IMAGE_STR "???????????????"
465 /***************************** Constant Arrays *******************************/
467 /* Chip constant definitions array */
468 static struct chip_defs s_chip_defs[MAX_CHIP_IDS] = {
469 {"bb", PSWRQ2_REG_ILT_MEMORY_SIZE_BB / 2},
470 {"ah", PSWRQ2_REG_ILT_MEMORY_SIZE_K2 / 2}
473 /* Storm constant definitions array */
474 static struct storm_defs s_storm_defs[] = {
477 {DBG_BUS_CLIENT_RBCT, DBG_BUS_CLIENT_RBCT},
479 TSEM_REG_FAST_MEMORY,
480 TSEM_REG_DBG_FRAME_MODE, TSEM_REG_SLOW_DBG_ACTIVE,
481 TSEM_REG_SLOW_DBG_MODE, TSEM_REG_DBG_MODE1_CFG,
482 TSEM_REG_SYNC_DBG_EMPTY, TSEM_REG_DBG_GPRE_VECT,
483 TCM_REG_CTX_RBC_ACCS,
484 {TCM_REG_AGG_CON_CTX, TCM_REG_SM_CON_CTX, TCM_REG_AGG_TASK_CTX,
485 TCM_REG_SM_TASK_CTX},
486 {{4, 16, 2, 4}, {4, 16, 2, 4} } /* {bb} {k2} */
491 {DBG_BUS_CLIENT_RBCT, DBG_BUS_CLIENT_RBCM},
493 MSEM_REG_FAST_MEMORY,
494 MSEM_REG_DBG_FRAME_MODE,
495 MSEM_REG_SLOW_DBG_ACTIVE,
496 MSEM_REG_SLOW_DBG_MODE,
497 MSEM_REG_DBG_MODE1_CFG,
498 MSEM_REG_SYNC_DBG_EMPTY,
499 MSEM_REG_DBG_GPRE_VECT,
500 MCM_REG_CTX_RBC_ACCS,
501 {MCM_REG_AGG_CON_CTX, MCM_REG_SM_CON_CTX, MCM_REG_AGG_TASK_CTX,
502 MCM_REG_SM_TASK_CTX },
503 {{1, 10, 2, 7}, {1, 10, 2, 7} } /* {bb} {k2}*/
508 {DBG_BUS_CLIENT_RBCU, DBG_BUS_CLIENT_RBCU},
510 USEM_REG_FAST_MEMORY,
511 USEM_REG_DBG_FRAME_MODE,
512 USEM_REG_SLOW_DBG_ACTIVE,
513 USEM_REG_SLOW_DBG_MODE,
514 USEM_REG_DBG_MODE1_CFG,
515 USEM_REG_SYNC_DBG_EMPTY,
516 USEM_REG_DBG_GPRE_VECT,
517 UCM_REG_CTX_RBC_ACCS,
518 {UCM_REG_AGG_CON_CTX, UCM_REG_SM_CON_CTX, UCM_REG_AGG_TASK_CTX,
519 UCM_REG_SM_TASK_CTX},
520 {{2, 13, 3, 3}, {2, 13, 3, 3} } /* {bb} {k2} */
525 {DBG_BUS_CLIENT_RBCX, DBG_BUS_CLIENT_RBCX},
527 XSEM_REG_FAST_MEMORY,
528 XSEM_REG_DBG_FRAME_MODE,
529 XSEM_REG_SLOW_DBG_ACTIVE,
530 XSEM_REG_SLOW_DBG_MODE,
531 XSEM_REG_DBG_MODE1_CFG,
532 XSEM_REG_SYNC_DBG_EMPTY,
533 XSEM_REG_DBG_GPRE_VECT,
534 XCM_REG_CTX_RBC_ACCS,
535 {XCM_REG_AGG_CON_CTX, XCM_REG_SM_CON_CTX, 0, 0},
536 {{9, 15, 0, 0}, {9, 15, 0, 0} } /* {bb} {k2} */
541 {DBG_BUS_CLIENT_RBCX, DBG_BUS_CLIENT_RBCY},
543 YSEM_REG_FAST_MEMORY,
544 YSEM_REG_DBG_FRAME_MODE,
545 YSEM_REG_SLOW_DBG_ACTIVE,
546 YSEM_REG_SLOW_DBG_MODE,
547 YSEM_REG_DBG_MODE1_CFG,
548 YSEM_REG_SYNC_DBG_EMPTY,
549 YSEM_REG_DBG_GPRE_VECT,
550 YCM_REG_CTX_RBC_ACCS,
551 {YCM_REG_AGG_CON_CTX, YCM_REG_SM_CON_CTX, YCM_REG_AGG_TASK_CTX,
552 YCM_REG_SM_TASK_CTX},
553 {{2, 3, 2, 12}, {2, 3, 2, 12} } /* {bb} {k2} */
558 {DBG_BUS_CLIENT_RBCS, DBG_BUS_CLIENT_RBCS},
560 PSEM_REG_FAST_MEMORY,
561 PSEM_REG_DBG_FRAME_MODE,
562 PSEM_REG_SLOW_DBG_ACTIVE,
563 PSEM_REG_SLOW_DBG_MODE,
564 PSEM_REG_DBG_MODE1_CFG,
565 PSEM_REG_SYNC_DBG_EMPTY,
566 PSEM_REG_DBG_GPRE_VECT,
567 PCM_REG_CTX_RBC_ACCS,
568 {0, PCM_REG_SM_CON_CTX, 0, 0},
569 {{0, 10, 0, 0}, {0, 10, 0, 0} } /* {bb} {k2} */
573 static struct hw_type_defs s_hw_type_defs[] = {
575 {"asic", 1, 256, 32768},
576 {"reserved", 0, 0, 0},
577 {"reserved2", 0, 0, 0},
578 {"reserved3", 0, 0, 0}
581 static struct grc_param_defs s_grc_param_defs[] = {
582 /* DBG_GRC_PARAM_DUMP_TSTORM */
583 {{1, 1}, 0, 1, false, false, 1, {1, 1} },
585 /* DBG_GRC_PARAM_DUMP_MSTORM */
586 {{1, 1}, 0, 1, false, false, 1, {1, 1} },
588 /* DBG_GRC_PARAM_DUMP_USTORM */
589 {{1, 1}, 0, 1, false, false, 1, {1, 1} },
591 /* DBG_GRC_PARAM_DUMP_XSTORM */
592 {{1, 1}, 0, 1, false, false, 1, {1, 1} },
594 /* DBG_GRC_PARAM_DUMP_YSTORM */
595 {{1, 1}, 0, 1, false, false, 1, {1, 1} },
597 /* DBG_GRC_PARAM_DUMP_PSTORM */
598 {{1, 1}, 0, 1, false, false, 1, {1, 1} },
600 /* DBG_GRC_PARAM_DUMP_REGS */
601 {{1, 1}, 0, 1, false, false, 0, {1, 1} },
603 /* DBG_GRC_PARAM_DUMP_RAM */
604 {{1, 1}, 0, 1, false, false, 0, {1, 1} },
606 /* DBG_GRC_PARAM_DUMP_PBUF */
607 {{1, 1}, 0, 1, false, false, 0, {1, 1} },
609 /* DBG_GRC_PARAM_DUMP_IOR */
610 {{0, 0}, 0, 1, false, false, 0, {1, 1} },
612 /* DBG_GRC_PARAM_DUMP_VFC */
613 {{0, 0}, 0, 1, false, false, 0, {1, 1} },
615 /* DBG_GRC_PARAM_DUMP_CM_CTX */
616 {{1, 1}, 0, 1, false, false, 0, {1, 1} },
618 /* DBG_GRC_PARAM_DUMP_ILT */
619 {{1, 1}, 0, 1, false, false, 0, {1, 1} },
621 /* DBG_GRC_PARAM_DUMP_RSS */
622 {{1, 1}, 0, 1, false, false, 0, {1, 1} },
624 /* DBG_GRC_PARAM_DUMP_CAU */
625 {{1, 1}, 0, 1, false, false, 0, {1, 1} },
627 /* DBG_GRC_PARAM_DUMP_QM */
628 {{1, 1}, 0, 1, false, false, 0, {1, 1} },
630 /* DBG_GRC_PARAM_DUMP_MCP */
631 {{1, 1}, 0, 1, false, false, 0, {1, 1} },
633 /* DBG_GRC_PARAM_DUMP_DORQ */
634 {{1, 1}, 0, 1, false, false, 0, {1, 1} },
636 /* DBG_GRC_PARAM_DUMP_CFC */
637 {{1, 1}, 0, 1, false, false, 0, {1, 1} },
639 /* DBG_GRC_PARAM_DUMP_IGU */
640 {{1, 1}, 0, 1, false, false, 0, {1, 1} },
642 /* DBG_GRC_PARAM_DUMP_BRB */
643 {{0, 0}, 0, 1, false, false, 0, {1, 1} },
645 /* DBG_GRC_PARAM_DUMP_BTB */
646 {{0, 0}, 0, 1, false, false, 0, {1, 1} },
648 /* DBG_GRC_PARAM_DUMP_BMB */
649 {{0, 0}, 0, 1, false, false, 0, {0, 0} },
651 /* DBG_GRC_PARAM_RESERVED1 */
652 {{0, 0}, 0, 1, false, false, 0, {0, 0} },
654 /* DBG_GRC_PARAM_DUMP_MULD */
655 {{1, 1}, 0, 1, false, false, 0, {1, 1} },
657 /* DBG_GRC_PARAM_DUMP_PRS */
658 {{1, 1}, 0, 1, false, false, 0, {1, 1} },
660 /* DBG_GRC_PARAM_DUMP_DMAE */
661 {{1, 1}, 0, 1, false, false, 0, {1, 1} },
663 /* DBG_GRC_PARAM_DUMP_TM */
664 {{1, 1}, 0, 1, false, false, 0, {1, 1} },
666 /* DBG_GRC_PARAM_DUMP_SDM */
667 {{1, 1}, 0, 1, false, false, 0, {1, 1} },
669 /* DBG_GRC_PARAM_DUMP_DIF */
670 {{1, 1}, 0, 1, false, false, 0, {1, 1} },
672 /* DBG_GRC_PARAM_DUMP_STATIC */
673 {{1, 1}, 0, 1, false, false, 0, {1, 1} },
675 /* DBG_GRC_PARAM_UNSTALL */
676 {{0, 0}, 0, 1, false, false, 0, {0, 0} },
678 /* DBG_GRC_PARAM_RESERVED2 */
679 {{0, 0}, 0, 1, false, false, 0, {0, 0} },
681 /* DBG_GRC_PARAM_MCP_TRACE_META_SIZE */
682 {{0, 0}, 1, 0xffffffff, false, true, 0, {0, 0} },
684 /* DBG_GRC_PARAM_EXCLUDE_ALL */
685 {{0, 0}, 0, 1, true, false, 0, {0, 0} },
687 /* DBG_GRC_PARAM_CRASH */
688 {{0, 0}, 0, 1, true, false, 0, {0, 0} },
690 /* DBG_GRC_PARAM_PARITY_SAFE */
691 {{0, 0}, 0, 1, false, false, 0, {0, 0} },
693 /* DBG_GRC_PARAM_DUMP_CM */
694 {{1, 1}, 0, 1, false, false, 0, {1, 1} },
696 /* DBG_GRC_PARAM_DUMP_PHY */
697 {{0, 0}, 0, 1, false, false, 0, {0, 0} },
699 /* DBG_GRC_PARAM_NO_MCP */
700 {{0, 0}, 0, 1, false, false, 0, {0, 0} },
702 /* DBG_GRC_PARAM_NO_FW_VER */
703 {{0, 0}, 0, 1, false, false, 0, {0, 0} },
705 /* DBG_GRC_PARAM_RESERVED3 */
706 {{0, 0}, 0, 1, false, false, 0, {0, 0} },
708 /* DBG_GRC_PARAM_DUMP_MCP_HW_DUMP */
709 {{0, 1}, 0, 1, false, false, 0, {0, 1} },
711 /* DBG_GRC_PARAM_DUMP_ILT_CDUC */
712 {{1, 1}, 0, 1, false, false, 0, {0, 0} },
714 /* DBG_GRC_PARAM_DUMP_ILT_CDUT */
715 {{1, 1}, 0, 1, false, false, 0, {0, 0} },
717 /* DBG_GRC_PARAM_DUMP_CAU_EXT */
718 {{0, 0}, 0, 1, false, false, 0, {1, 1} }
721 static struct rss_mem_defs s_rss_mem_defs[] = {
722 {"rss_mem_cid", "rss_cid", 0, 32,
725 {"rss_mem_key_msb", "rss_key", 1024, 256,
728 {"rss_mem_key_lsb", "rss_key", 2048, 64,
731 {"rss_mem_info", "rss_info", 3072, 16,
734 {"rss_mem_ind", "rss_ind", 4096, 16,
738 static struct vfc_ram_defs s_vfc_ram_defs[] = {
739 {"vfc_ram_tt1", "vfc_ram", 0, 512},
740 {"vfc_ram_mtt2", "vfc_ram", 512, 128},
741 {"vfc_ram_stt2", "vfc_ram", 640, 32},
742 {"vfc_ram_ro_vect", "vfc_ram", 672, 32}
745 static struct big_ram_defs s_big_ram_defs[] = {
746 {"BRB", MEM_GROUP_BRB_MEM, MEM_GROUP_BRB_RAM, DBG_GRC_PARAM_DUMP_BRB,
747 BRB_REG_BIG_RAM_ADDRESS, BRB_REG_BIG_RAM_DATA,
748 MISC_REG_BLOCK_256B_EN, {0, 0},
751 {"BTB", MEM_GROUP_BTB_MEM, MEM_GROUP_BTB_RAM, DBG_GRC_PARAM_DUMP_BTB,
752 BTB_REG_BIG_RAM_ADDRESS, BTB_REG_BIG_RAM_DATA,
753 MISC_REG_BLOCK_256B_EN, {0, 1},
756 {"BMB", MEM_GROUP_BMB_MEM, MEM_GROUP_BMB_RAM, DBG_GRC_PARAM_DUMP_BMB,
757 BMB_REG_BIG_RAM_ADDRESS, BMB_REG_BIG_RAM_DATA,
758 MISCS_REG_BLOCK_256B_EN, {0, 0},
762 static struct rbc_reset_defs s_rbc_reset_defs[] = {
763 {MISCS_REG_RESET_PL_HV,
765 {MISC_REG_RESET_PL_PDA_VMAIN_1,
766 {0x4404040, 0x4404040} },
767 {MISC_REG_RESET_PL_PDA_VMAIN_2,
769 {MISC_REG_RESET_PL_PDA_VAUX,
773 static struct phy_defs s_phy_defs[] = {
774 {"nw_phy", NWS_REG_NWS_CMU_K2,
775 PHY_NW_IP_REG_PHY0_TOP_TBUS_ADDR_7_0_K2,
776 PHY_NW_IP_REG_PHY0_TOP_TBUS_ADDR_15_8_K2,
777 PHY_NW_IP_REG_PHY0_TOP_TBUS_DATA_7_0_K2,
778 PHY_NW_IP_REG_PHY0_TOP_TBUS_DATA_11_8_K2},
779 {"sgmii_phy", MS_REG_MS_CMU_K2,
780 PHY_SGMII_IP_REG_AHB_CMU_CSR_0_X132_K2,
781 PHY_SGMII_IP_REG_AHB_CMU_CSR_0_X133_K2,
782 PHY_SGMII_IP_REG_AHB_CMU_CSR_0_X130_K2,
783 PHY_SGMII_IP_REG_AHB_CMU_CSR_0_X131_K2},
784 {"pcie_phy0", PHY_PCIE_REG_PHY0_K2,
785 PHY_PCIE_IP_REG_AHB_CMU_CSR_0_X132_K2,
786 PHY_PCIE_IP_REG_AHB_CMU_CSR_0_X133_K2,
787 PHY_PCIE_IP_REG_AHB_CMU_CSR_0_X130_K2,
788 PHY_PCIE_IP_REG_AHB_CMU_CSR_0_X131_K2},
789 {"pcie_phy1", PHY_PCIE_REG_PHY1_K2,
790 PHY_PCIE_IP_REG_AHB_CMU_CSR_0_X132_K2,
791 PHY_PCIE_IP_REG_AHB_CMU_CSR_0_X133_K2,
792 PHY_PCIE_IP_REG_AHB_CMU_CSR_0_X130_K2,
793 PHY_PCIE_IP_REG_AHB_CMU_CSR_0_X131_K2},
796 static struct split_type_defs s_split_type_defs[] = {
797 /* SPLIT_TYPE_NONE */
800 /* SPLIT_TYPE_PORT */
806 /* SPLIT_TYPE_PORT_PF */
813 /******************************** Variables *********************************/
816 * The version of the calling app
818 static u32 s_app_ver;
820 /**************************** Private Functions ******************************/
822 /* Reads and returns a single dword from the specified unaligned buffer */
823 static u32 qed_read_unaligned_dword(u8 *buf)
827 memcpy((u8 *)&dword, buf, sizeof(dword));
831 /* Sets the value of the specified GRC param */
832 static void qed_grc_set_param(struct ecore_hwfn *p_hwfn,
833 enum dbg_grc_params grc_param, u32 val)
835 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
837 dev_data->grc.param_val[grc_param] = val;
840 /* Returns the value of the specified GRC param */
841 static u32 qed_grc_get_param(struct ecore_hwfn *p_hwfn,
842 enum dbg_grc_params grc_param)
844 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
846 return dev_data->grc.param_val[grc_param];
849 /* Initializes the GRC parameters */
850 static void qed_dbg_grc_init_params(struct ecore_hwfn *p_hwfn)
852 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
854 if (!dev_data->grc.params_initialized) {
855 qed_dbg_grc_set_params_default(p_hwfn);
856 dev_data->grc.params_initialized = 1;
860 /* Sets pointer and size for the specified binary buffer type */
861 static void qed_set_dbg_bin_buf(struct ecore_hwfn *p_hwfn,
862 enum bin_dbg_buffer_type buf_type,
863 const u32 *ptr, u32 size)
865 struct virt_mem_desc *buf = &p_hwfn->dbg_arrays[buf_type];
867 buf->ptr = (void *)(osal_uintptr_t)ptr;
871 /* Initializes debug data for the specified device */
872 static enum dbg_status qed_dbg_dev_init(struct ecore_hwfn *p_hwfn)
874 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
875 u8 num_pfs = 0, max_pfs_per_port = 0;
877 if (dev_data->initialized)
878 return DBG_STATUS_OK;
881 if (ECORE_IS_K2(p_hwfn->p_dev)) {
882 dev_data->chip_id = CHIP_K2;
883 dev_data->mode_enable[MODE_K2] = 1;
884 dev_data->num_vfs = MAX_NUM_VFS_K2;
885 num_pfs = MAX_NUM_PFS_K2;
886 max_pfs_per_port = MAX_NUM_PFS_K2 / 2;
887 } else if (ECORE_IS_BB_B0(p_hwfn->p_dev)) {
888 dev_data->chip_id = CHIP_BB;
889 dev_data->mode_enable[MODE_BB] = 1;
890 dev_data->num_vfs = MAX_NUM_VFS_BB;
891 num_pfs = MAX_NUM_PFS_BB;
892 max_pfs_per_port = MAX_NUM_PFS_BB;
894 return DBG_STATUS_UNKNOWN_CHIP;
898 dev_data->hw_type = HW_TYPE_ASIC;
899 dev_data->mode_enable[MODE_ASIC] = 1;
902 switch (p_hwfn->p_dev->num_ports_in_engine) {
904 dev_data->mode_enable[MODE_PORTS_PER_ENG_1] = 1;
907 dev_data->mode_enable[MODE_PORTS_PER_ENG_2] = 1;
910 dev_data->mode_enable[MODE_PORTS_PER_ENG_4] = 1;
915 if (ECORE_IS_CMT(p_hwfn->p_dev))
916 dev_data->mode_enable[MODE_100G] = 1;
918 /* Set number of ports */
919 if (dev_data->mode_enable[MODE_PORTS_PER_ENG_1] ||
920 dev_data->mode_enable[MODE_100G])
921 dev_data->num_ports = 1;
922 else if (dev_data->mode_enable[MODE_PORTS_PER_ENG_2])
923 dev_data->num_ports = 2;
924 else if (dev_data->mode_enable[MODE_PORTS_PER_ENG_4])
925 dev_data->num_ports = 4;
927 /* Set number of PFs per port */
928 dev_data->num_pfs_per_port = OSAL_MIN_T(u32,
929 num_pfs / dev_data->num_ports,
932 /* Initializes the GRC parameters */
933 qed_dbg_grc_init_params(p_hwfn);
935 dev_data->use_dmae = true;
936 dev_data->initialized = 1;
938 return DBG_STATUS_OK;
941 static const struct dbg_block *get_dbg_block(struct ecore_hwfn *p_hwfn,
942 enum block_id block_id)
944 const struct dbg_block *dbg_block;
946 dbg_block = p_hwfn->dbg_arrays[BIN_BUF_DBG_BLOCKS].ptr;
947 return dbg_block + block_id;
950 static const struct dbg_block_chip *qed_get_dbg_block_per_chip(struct ecore_hwfn
955 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
957 return (const struct dbg_block_chip *)
958 p_hwfn->dbg_arrays[BIN_BUF_DBG_BLOCKS_CHIP_DATA].ptr +
959 block_id * MAX_CHIP_IDS + dev_data->chip_id;
962 static const struct dbg_reset_reg *qed_get_dbg_reset_reg(struct ecore_hwfn
966 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
968 return (const struct dbg_reset_reg *)
969 p_hwfn->dbg_arrays[BIN_BUF_DBG_RESET_REGS].ptr +
970 reset_reg_id * MAX_CHIP_IDS + dev_data->chip_id;
973 /* Reads the FW info structure for the specified Storm from the chip,
974 * and writes it to the specified fw_info pointer.
976 static void qed_read_storm_fw_info(struct ecore_hwfn *p_hwfn,
977 struct ecore_ptt *p_ptt,
978 u8 storm_id, struct fw_info *fw_info)
980 struct storm_defs *storm = &s_storm_defs[storm_id];
981 struct fw_info_location fw_info_location;
984 memset(&fw_info_location, 0, sizeof(fw_info_location));
985 memset(fw_info, 0, sizeof(*fw_info));
987 /* Read first the address that points to fw_info location.
988 * The address is located in the last line of the Storm RAM.
990 addr = storm->sem_fast_mem_addr + SEM_FAST_REG_INT_RAM +
991 DWORDS_TO_BYTES(SEM_FAST_REG_INT_RAM_SIZE) -
992 sizeof(fw_info_location);
994 dest = (u32 *)&fw_info_location;
996 for (i = 0; i < BYTES_TO_DWORDS(sizeof(fw_info_location));
997 i++, addr += BYTES_IN_DWORD)
998 dest[i] = ecore_rd(p_hwfn, p_ptt, addr);
1000 /* Read FW version info from Storm RAM */
1001 if (fw_info_location.size > 0 && fw_info_location.size <=
1003 addr = fw_info_location.grc_addr;
1004 dest = (u32 *)fw_info;
1005 for (i = 0; i < BYTES_TO_DWORDS(fw_info_location.size);
1006 i++, addr += BYTES_IN_DWORD)
1007 dest[i] = ecore_rd(p_hwfn, p_ptt, addr);
1011 /* Dumps the specified string to the specified buffer.
1012 * Returns the dumped size in bytes.
1014 static u32 qed_dump_str(char *dump_buf, bool dump, const char *str)
1017 strcpy(dump_buf, str);
1019 return (u32)strlen(str) + 1;
1022 /* Dumps zeros to align the specified buffer to dwords.
1023 * Returns the dumped size in bytes.
1025 static u32 qed_dump_align(char *dump_buf, bool dump, u32 byte_offset)
1027 u8 offset_in_dword, align_size;
1029 offset_in_dword = (u8)(byte_offset & 0x3);
1030 align_size = offset_in_dword ? BYTES_IN_DWORD - offset_in_dword : 0;
1032 if (dump && align_size)
1033 memset(dump_buf, 0, align_size);
1038 /* Writes the specified string param to the specified buffer.
1039 * Returns the dumped size in dwords.
1041 static u32 qed_dump_str_param(u32 *dump_buf,
1043 const char *param_name, const char *param_val)
1045 char *char_buf = (char *)dump_buf;
1048 /* Dump param name */
1049 offset += qed_dump_str(char_buf + offset, dump, param_name);
1051 /* Indicate a string param value */
1053 *(char_buf + offset) = 1;
1056 /* Dump param value */
1057 offset += qed_dump_str(char_buf + offset, dump, param_val);
1059 /* Align buffer to next dword */
1060 offset += qed_dump_align(char_buf + offset, dump, offset);
1062 return BYTES_TO_DWORDS(offset);
1065 /* Writes the specified numeric param to the specified buffer.
1066 * Returns the dumped size in dwords.
1068 static u32 qed_dump_num_param(u32 *dump_buf,
1069 bool dump, const char *param_name, u32 param_val)
1071 char *char_buf = (char *)dump_buf;
1074 /* Dump param name */
1075 offset += qed_dump_str(char_buf + offset, dump, param_name);
1077 /* Indicate a numeric param value */
1079 *(char_buf + offset) = 0;
1082 /* Align buffer to next dword */
1083 offset += qed_dump_align(char_buf + offset, dump, offset);
1085 /* Dump param value (and change offset from bytes to dwords) */
1086 offset = BYTES_TO_DWORDS(offset);
1088 *(dump_buf + offset) = param_val;
1094 /* Reads the FW version and writes it as a param to the specified buffer.
1095 * Returns the dumped size in dwords.
1097 static u32 qed_dump_fw_ver_param(struct ecore_hwfn *p_hwfn,
1098 struct ecore_ptt *p_ptt,
1099 u32 *dump_buf, bool dump)
1101 char fw_ver_str[16] = EMPTY_FW_VERSION_STR;
1102 char fw_img_str[16] = EMPTY_FW_IMAGE_STR;
1103 struct fw_info fw_info = { {0}, {0} };
1106 if (dump && !qed_grc_get_param(p_hwfn, DBG_GRC_PARAM_NO_FW_VER)) {
1107 /* Read FW info from chip */
1108 qed_read_fw_info(p_hwfn, p_ptt, &fw_info);
1110 /* Create FW version/image strings */
1111 if (snprintf(fw_ver_str, sizeof(fw_ver_str),
1112 "%d_%d_%d_%d", fw_info.ver.num.major,
1113 fw_info.ver.num.minor, fw_info.ver.num.rev,
1114 fw_info.ver.num.eng) < 0)
1115 DP_NOTICE(p_hwfn, false,
1116 "Unexpected debug error: invalid FW version string\n");
1117 switch (fw_info.ver.image_id) {
1119 strcpy(fw_img_str, "main");
1122 strcpy(fw_img_str, "unknown");
1127 /* Dump FW version, image and timestamp */
1128 offset += qed_dump_str_param(dump_buf + offset,
1129 dump, "fw-version", fw_ver_str);
1130 offset += qed_dump_str_param(dump_buf + offset,
1131 dump, "fw-image", fw_img_str);
1132 offset += qed_dump_num_param(dump_buf + offset,
1134 "fw-timestamp", fw_info.ver.timestamp);
1139 /* Reads the MFW version and writes it as a param to the specified buffer.
1140 * Returns the dumped size in dwords.
1142 static u32 qed_dump_mfw_ver_param(struct ecore_hwfn *p_hwfn,
1143 struct ecore_ptt *p_ptt,
1144 u32 *dump_buf, bool dump)
1146 char mfw_ver_str[16] = EMPTY_FW_VERSION_STR;
1149 !qed_grc_get_param(p_hwfn, DBG_GRC_PARAM_NO_FW_VER)) {
1150 u32 global_section_offsize, global_section_addr, mfw_ver;
1151 u32 public_data_addr, global_section_offsize_addr;
1153 /* Find MCP public data GRC address. Needs to be ORed with
1154 * MCP_REG_SCRATCH due to a HW bug.
1156 public_data_addr = ecore_rd(p_hwfn,
1158 MISC_REG_SHARED_MEM_ADDR) |
1161 /* Find MCP public global section offset */
1162 global_section_offsize_addr = public_data_addr +
1163 offsetof(struct mcp_public_data,
1165 sizeof(offsize_t) * PUBLIC_GLOBAL;
1166 global_section_offsize = ecore_rd(p_hwfn, p_ptt,
1167 global_section_offsize_addr);
1168 global_section_addr =
1170 (global_section_offsize & OFFSIZE_OFFSET_MASK) * 4;
1172 /* Read MFW version from MCP public global section */
1173 mfw_ver = ecore_rd(p_hwfn, p_ptt,
1174 global_section_addr +
1175 offsetof(struct public_global, mfw_ver));
1177 /* Dump MFW version param */
1178 if (snprintf(mfw_ver_str, sizeof(mfw_ver_str), "%d_%d_%d_%d",
1179 (u8)(mfw_ver >> 24), (u8)(mfw_ver >> 16),
1180 (u8)(mfw_ver >> 8), (u8)mfw_ver) < 0)
1181 DP_NOTICE(p_hwfn, false,
1182 "Unexpected debug error: invalid MFW version string\n");
1185 return qed_dump_str_param(dump_buf, dump, "mfw-version", mfw_ver_str);
1188 /* Reads the chip revision from the chip and writes it as a param to the
1189 * specified buffer. Returns the dumped size in dwords.
1191 static u32 qed_dump_chip_revision_param(struct ecore_hwfn *p_hwfn,
1192 struct ecore_ptt *p_ptt,
1193 u32 *dump_buf, bool dump)
1195 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
1196 char param_str[3] = "??";
1198 if (dev_data->hw_type == HW_TYPE_ASIC) {
1199 u32 chip_rev, chip_metal;
1201 chip_rev = ecore_rd(p_hwfn, p_ptt, MISCS_REG_CHIP_REV);
1202 chip_metal = ecore_rd(p_hwfn, p_ptt, MISCS_REG_CHIP_METAL);
1204 param_str[0] = 'a' + (u8)chip_rev;
1205 param_str[1] = '0' + (u8)chip_metal;
1208 return qed_dump_str_param(dump_buf, dump, "chip-revision", param_str);
1211 /* Writes a section header to the specified buffer.
1212 * Returns the dumped size in dwords.
1214 static u32 qed_dump_section_hdr(u32 *dump_buf,
1215 bool dump, const char *name, u32 num_params)
1217 return qed_dump_num_param(dump_buf, dump, name, num_params);
1220 /* Writes the common global params to the specified buffer.
1221 * Returns the dumped size in dwords.
1223 static u32 qed_dump_common_global_params(struct ecore_hwfn *p_hwfn,
1224 struct ecore_ptt *p_ptt,
1227 u8 num_specific_global_params)
1229 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
1230 char sw_platform_str[MAX_SW_PLTAFORM_STR_SIZE];
1234 /* Fill platform string */
1235 ecore_set_platform_str(p_hwfn, sw_platform_str,
1236 MAX_SW_PLTAFORM_STR_SIZE);
1238 /* Dump global params section header */
1239 num_params = NUM_COMMON_GLOBAL_PARAMS + num_specific_global_params +
1240 (dev_data->chip_id == CHIP_BB ? 1 : 0);
1241 offset += qed_dump_section_hdr(dump_buf + offset,
1242 dump, "global_params", num_params);
1245 offset += qed_dump_fw_ver_param(p_hwfn, p_ptt, dump_buf + offset, dump);
1246 offset += qed_dump_mfw_ver_param(p_hwfn,
1247 p_ptt, dump_buf + offset, dump);
1248 offset += qed_dump_chip_revision_param(p_hwfn,
1249 p_ptt, dump_buf + offset, dump);
1250 offset += qed_dump_num_param(dump_buf + offset,
1251 dump, "tools-version", TOOLS_VERSION);
1252 offset += qed_dump_str_param(dump_buf + offset,
1255 s_chip_defs[dev_data->chip_id].name);
1256 offset += qed_dump_str_param(dump_buf + offset,
1259 s_hw_type_defs[dev_data->hw_type].name);
1260 offset += qed_dump_str_param(dump_buf + offset,
1261 dump, "sw-platform", sw_platform_str);
1262 offset += qed_dump_num_param(dump_buf + offset,
1263 dump, "pci-func", p_hwfn->abs_pf_id);
1264 offset += qed_dump_num_param(dump_buf + offset,
1265 dump, "epoch", OSAL_GET_EPOCH(p_hwfn));
1266 if (dev_data->chip_id == CHIP_BB)
1267 offset += qed_dump_num_param(dump_buf + offset,
1269 ECORE_PATH_ID(p_hwfn));
1274 /* Writes the "last" section (including CRC) to the specified buffer at the
1275 * given offset. Returns the dumped size in dwords.
1277 static u32 qed_dump_last_section(u32 *dump_buf, u32 offset, bool dump)
1279 u32 start_offset = offset;
1281 /* Dump CRC section header */
1282 offset += qed_dump_section_hdr(dump_buf + offset, dump, "last", 0);
1284 /* Calculate CRC32 and add it to the dword after the "last" section */
1286 *(dump_buf + offset) = ~OSAL_CRC32(0xffffffff,
1288 DWORDS_TO_BYTES(offset));
1292 return offset - start_offset;
1295 /* Update blocks reset state */
1296 static void qed_update_blocks_reset_state(struct ecore_hwfn *p_hwfn,
1297 struct ecore_ptt *p_ptt)
1299 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
1300 u32 reg_val[NUM_DBG_RESET_REGS] = { 0 };
1304 /* Read reset registers */
1305 for (rst_reg_id = 0; rst_reg_id < NUM_DBG_RESET_REGS; rst_reg_id++) {
1306 const struct dbg_reset_reg *rst_reg;
1307 bool rst_reg_removed;
1310 rst_reg = qed_get_dbg_reset_reg(p_hwfn, rst_reg_id);
1311 rst_reg_removed = GET_FIELD(rst_reg->data,
1312 DBG_RESET_REG_IS_REMOVED);
1313 rst_reg_addr = DWORDS_TO_BYTES(GET_FIELD(rst_reg->data,
1314 DBG_RESET_REG_ADDR));
1316 if (!rst_reg_removed)
1317 reg_val[rst_reg_id] = ecore_rd(p_hwfn, p_ptt,
1321 /* Check if blocks are in reset */
1322 for (blk_id = 0; blk_id < NUM_PHYS_BLOCKS; blk_id++) {
1323 const struct dbg_block_chip *blk;
1327 blk = qed_get_dbg_block_per_chip(p_hwfn, (enum block_id)blk_id);
1328 is_removed = GET_FIELD(blk->flags, DBG_BLOCK_CHIP_IS_REMOVED);
1329 has_rst_reg = GET_FIELD(blk->flags,
1330 DBG_BLOCK_CHIP_HAS_RESET_REG);
1332 if (!is_removed && has_rst_reg)
1333 dev_data->block_in_reset[blk_id] =
1334 !(reg_val[blk->reset_reg_id] &
1335 OSAL_BIT(blk->reset_reg_bit_offset));
1339 /* is_mode_match recursive function */
1340 static bool qed_is_mode_match_rec(struct ecore_hwfn *p_hwfn,
1341 u16 *modes_buf_offset, u8 rec_depth)
1343 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
1344 const u8 *dbg_array;
1348 if (rec_depth > MAX_RECURSION_DEPTH) {
1349 DP_NOTICE(p_hwfn, false,
1350 "Unexpected error: is_mode_match_rec exceeded the max recursion depth. This is probably due to a corrupt init/debug buffer.\n");
1354 /* Get next element from modes tree buffer */
1355 dbg_array = p_hwfn->dbg_arrays[BIN_BUF_DBG_MODE_TREE].ptr;
1356 tree_val = dbg_array[(*modes_buf_offset)++];
1359 case INIT_MODE_OP_NOT:
1360 return !qed_is_mode_match_rec(p_hwfn,
1361 modes_buf_offset, rec_depth + 1);
1362 case INIT_MODE_OP_OR:
1363 case INIT_MODE_OP_AND:
1364 arg1 = qed_is_mode_match_rec(p_hwfn,
1365 modes_buf_offset, rec_depth + 1);
1366 arg2 = qed_is_mode_match_rec(p_hwfn,
1367 modes_buf_offset, rec_depth + 1);
1368 return (tree_val == INIT_MODE_OP_OR) ? (arg1 ||
1369 arg2) : (arg1 && arg2);
1371 return dev_data->mode_enable[tree_val - MAX_INIT_MODE_OPS] > 0;
1375 /* Returns true if the mode (specified using modes_buf_offset) is enabled */
1376 static bool qed_is_mode_match(struct ecore_hwfn *p_hwfn, u16 *modes_buf_offset)
1378 return qed_is_mode_match_rec(p_hwfn, modes_buf_offset, 0);
1381 /* Enable / disable the Debug block */
1382 static void qed_bus_enable_dbg_block(struct ecore_hwfn *p_hwfn,
1383 struct ecore_ptt *p_ptt, bool enable)
1385 ecore_wr(p_hwfn, p_ptt, DBG_REG_DBG_BLOCK_ON, enable ? 1 : 0);
1388 /* Resets the Debug block */
1389 static void qed_bus_reset_dbg_block(struct ecore_hwfn *p_hwfn,
1390 struct ecore_ptt *p_ptt)
1392 u32 reset_reg_addr, old_reset_reg_val, new_reset_reg_val;
1393 const struct dbg_reset_reg *reset_reg;
1394 const struct dbg_block_chip *block;
1396 block = qed_get_dbg_block_per_chip(p_hwfn, BLOCK_DBG);
1397 reset_reg = qed_get_dbg_reset_reg(p_hwfn, block->reset_reg_id);
1399 DWORDS_TO_BYTES(GET_FIELD(reset_reg->data, DBG_RESET_REG_ADDR));
1401 old_reset_reg_val = ecore_rd(p_hwfn, p_ptt, reset_reg_addr);
1403 old_reset_reg_val & ~OSAL_BIT(block->reset_reg_bit_offset);
1405 ecore_wr(p_hwfn, p_ptt, reset_reg_addr, new_reset_reg_val);
1406 ecore_wr(p_hwfn, p_ptt, reset_reg_addr, old_reset_reg_val);
1409 /* Enable / disable Debug Bus clients according to the specified mask
1410 * (1 = enable, 0 = disable).
1412 static void qed_bus_enable_clients(struct ecore_hwfn *p_hwfn,
1413 struct ecore_ptt *p_ptt, u32 client_mask)
1415 ecore_wr(p_hwfn, p_ptt, DBG_REG_CLIENT_ENABLE, client_mask);
1418 static void qed_bus_config_dbg_line(struct ecore_hwfn *p_hwfn,
1419 struct ecore_ptt *p_ptt,
1420 enum block_id block_id,
1424 u8 force_valid_mask, u8 force_frame_mask)
1426 const struct dbg_block_chip *block =
1427 qed_get_dbg_block_per_chip(p_hwfn, block_id);
1429 ecore_wr(p_hwfn, p_ptt,
1430 DWORDS_TO_BYTES(block->dbg_select_reg_addr),
1432 ecore_wr(p_hwfn, p_ptt,
1433 DWORDS_TO_BYTES(block->dbg_dword_enable_reg_addr),
1435 ecore_wr(p_hwfn, p_ptt,
1436 DWORDS_TO_BYTES(block->dbg_shift_reg_addr),
1438 ecore_wr(p_hwfn, p_ptt,
1439 DWORDS_TO_BYTES(block->dbg_force_valid_reg_addr),
1441 ecore_wr(p_hwfn, p_ptt,
1442 DWORDS_TO_BYTES(block->dbg_force_frame_reg_addr),
1446 /* Disable debug bus in all blocks */
1447 static void qed_bus_disable_blocks(struct ecore_hwfn *p_hwfn,
1448 struct ecore_ptt *p_ptt)
1450 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
1453 /* Disable all blocks */
1454 for (block_id = 0; block_id < MAX_BLOCK_ID; block_id++) {
1455 const struct dbg_block_chip *block_per_chip =
1456 qed_get_dbg_block_per_chip(p_hwfn,
1457 (enum block_id)block_id);
1459 if (GET_FIELD(block_per_chip->flags,
1460 DBG_BLOCK_CHIP_IS_REMOVED) ||
1461 dev_data->block_in_reset[block_id])
1464 /* Disable debug bus */
1465 if (GET_FIELD(block_per_chip->flags,
1466 DBG_BLOCK_CHIP_HAS_DBG_BUS)) {
1468 block_per_chip->dbg_dword_enable_reg_addr;
1469 u16 modes_buf_offset =
1470 GET_FIELD(block_per_chip->dbg_bus_mode.data,
1471 DBG_MODE_HDR_MODES_BUF_OFFSET);
1473 GET_FIELD(block_per_chip->dbg_bus_mode.data,
1474 DBG_MODE_HDR_EVAL_MODE) > 0;
1477 qed_is_mode_match(p_hwfn, &modes_buf_offset))
1478 ecore_wr(p_hwfn, p_ptt,
1479 DWORDS_TO_BYTES(dbg_en_addr),
1485 /* Returns true if the specified entity (indicated by GRC param) should be
1486 * included in the dump, false otherwise.
1488 static bool qed_grc_is_included(struct ecore_hwfn *p_hwfn,
1489 enum dbg_grc_params grc_param)
1491 return qed_grc_get_param(p_hwfn, grc_param) > 0;
1494 /* Returns the storm_id that matches the specified Storm letter,
1495 * or MAX_DBG_STORMS if invalid storm letter.
1497 static enum dbg_storms qed_get_id_from_letter(char storm_letter)
1501 for (storm_id = 0; storm_id < MAX_DBG_STORMS; storm_id++)
1502 if (s_storm_defs[storm_id].letter == storm_letter)
1503 return (enum dbg_storms)storm_id;
1505 return MAX_DBG_STORMS;
1508 /* Returns true of the specified Storm should be included in the dump, false
1511 static bool qed_grc_is_storm_included(struct ecore_hwfn *p_hwfn,
1512 enum dbg_storms storm)
1514 return qed_grc_get_param(p_hwfn, (enum dbg_grc_params)storm) > 0;
1517 /* Returns true if the specified memory should be included in the dump, false
1520 static bool qed_grc_is_mem_included(struct ecore_hwfn *p_hwfn,
1521 enum block_id block_id, u8 mem_group_id)
1523 const struct dbg_block *block;
1526 block = get_dbg_block(p_hwfn, block_id);
1528 /* If the block is associated with a Storm, check Storm match */
1529 if (block->associated_storm_letter) {
1530 enum dbg_storms associated_storm_id =
1531 qed_get_id_from_letter(block->associated_storm_letter);
1533 if (associated_storm_id == MAX_DBG_STORMS ||
1534 !qed_grc_is_storm_included(p_hwfn, associated_storm_id))
1538 for (i = 0; i < NUM_BIG_RAM_TYPES; i++) {
1539 struct big_ram_defs *big_ram = &s_big_ram_defs[i];
1541 if (mem_group_id == big_ram->mem_group_id ||
1542 mem_group_id == big_ram->ram_mem_group_id)
1543 return qed_grc_is_included(p_hwfn, big_ram->grc_param);
1546 switch (mem_group_id) {
1547 case MEM_GROUP_PXP_ILT:
1548 case MEM_GROUP_PXP_MEM:
1549 return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_PXP);
1551 return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_RAM);
1552 case MEM_GROUP_PBUF:
1553 return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_PBUF);
1554 case MEM_GROUP_CAU_MEM:
1555 case MEM_GROUP_CAU_SB:
1556 case MEM_GROUP_CAU_PI:
1557 return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_CAU);
1558 case MEM_GROUP_CAU_MEM_EXT:
1559 return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_CAU_EXT);
1560 case MEM_GROUP_QM_MEM:
1561 return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_QM);
1562 case MEM_GROUP_CFC_MEM:
1563 case MEM_GROUP_CONN_CFC_MEM:
1564 case MEM_GROUP_TASK_CFC_MEM:
1565 return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_CFC) ||
1566 qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_CM_CTX);
1567 case MEM_GROUP_DORQ_MEM:
1568 return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_DORQ);
1569 case MEM_GROUP_IGU_MEM:
1570 case MEM_GROUP_IGU_MSIX:
1571 return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_IGU);
1572 case MEM_GROUP_MULD_MEM:
1573 return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_MULD);
1574 case MEM_GROUP_PRS_MEM:
1575 return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_PRS);
1576 case MEM_GROUP_DMAE_MEM:
1577 return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_DMAE);
1578 case MEM_GROUP_TM_MEM:
1579 return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_TM);
1580 case MEM_GROUP_SDM_MEM:
1581 return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_SDM);
1582 case MEM_GROUP_TDIF_CTX:
1583 case MEM_GROUP_RDIF_CTX:
1584 return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_DIF);
1585 case MEM_GROUP_CM_MEM:
1586 return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_CM);
1588 return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_IOR);
1594 /* Stalls all Storms */
1595 static void qed_grc_stall_storms(struct ecore_hwfn *p_hwfn,
1596 struct ecore_ptt *p_ptt, bool stall)
1601 for (storm_id = 0; storm_id < MAX_DBG_STORMS; storm_id++) {
1602 if (!qed_grc_is_storm_included(p_hwfn,
1603 (enum dbg_storms)storm_id))
1606 reg_addr = s_storm_defs[storm_id].sem_fast_mem_addr +
1607 SEM_FAST_REG_STALL_0;
1608 ecore_wr(p_hwfn, p_ptt, reg_addr, stall ? 1 : 0);
1611 OSAL_MSLEEP(STALL_DELAY_MS);
1614 /* Takes all blocks out of reset. If rbc_only is true, only RBC clients are
1615 * taken out of reset.
1617 static void qed_grc_unreset_blocks(struct ecore_hwfn *p_hwfn,
1618 struct ecore_ptt *p_ptt, bool rbc_only)
1620 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
1621 u8 chip_id = dev_data->chip_id;
1624 /* Take RBCs out of reset */
1625 for (i = 0; i < OSAL_ARRAY_SIZE(s_rbc_reset_defs); i++)
1626 if (s_rbc_reset_defs[i].reset_val[dev_data->chip_id])
1629 s_rbc_reset_defs[i].reset_reg_addr +
1630 RESET_REG_UNRESET_OFFSET,
1631 s_rbc_reset_defs[i].reset_val[chip_id]);
1634 u32 reg_val[NUM_DBG_RESET_REGS] = { 0 };
1638 /* Fill reset regs values */
1639 for (block_id = 0; block_id < NUM_PHYS_BLOCKS; block_id++) {
1640 bool is_removed, has_reset_reg, unreset_before_dump;
1641 const struct dbg_block_chip *block;
1643 block = qed_get_dbg_block_per_chip(p_hwfn,
1647 GET_FIELD(block->flags, DBG_BLOCK_CHIP_IS_REMOVED);
1649 GET_FIELD(block->flags,
1650 DBG_BLOCK_CHIP_HAS_RESET_REG);
1651 unreset_before_dump =
1652 GET_FIELD(block->flags,
1653 DBG_BLOCK_CHIP_UNRESET_BEFORE_DUMP);
1655 if (!is_removed && has_reset_reg && unreset_before_dump)
1656 reg_val[block->reset_reg_id] |=
1657 OSAL_BIT(block->reset_reg_bit_offset);
1660 /* Write reset registers */
1661 for (reset_reg_id = 0; reset_reg_id < NUM_DBG_RESET_REGS;
1663 const struct dbg_reset_reg *reset_reg;
1666 reset_reg = qed_get_dbg_reset_reg(p_hwfn, reset_reg_id);
1669 (reset_reg->data, DBG_RESET_REG_IS_REMOVED))
1672 if (reg_val[reset_reg_id]) {
1674 GET_FIELD(reset_reg->data,
1675 DBG_RESET_REG_ADDR);
1678 DWORDS_TO_BYTES(reset_reg_addr) +
1679 RESET_REG_UNRESET_OFFSET,
1680 reg_val[reset_reg_id]);
1686 /* Returns the attention block data of the specified block */
1687 static const struct dbg_attn_block_type_data *
1688 qed_get_block_attn_data(struct ecore_hwfn *p_hwfn,
1689 enum block_id block_id, enum dbg_attn_type attn_type)
1691 const struct dbg_attn_block *base_attn_block_arr =
1692 (const struct dbg_attn_block *)
1693 p_hwfn->dbg_arrays[BIN_BUF_DBG_ATTN_BLOCKS].ptr;
1695 return &base_attn_block_arr[block_id].per_type_data[attn_type];
1698 /* Returns the attention registers of the specified block */
1699 static const struct dbg_attn_reg *
1700 qed_get_block_attn_regs(struct ecore_hwfn *p_hwfn,
1701 enum block_id block_id, enum dbg_attn_type attn_type,
1704 const struct dbg_attn_block_type_data *block_type_data =
1705 qed_get_block_attn_data(p_hwfn, block_id, attn_type);
1707 *num_attn_regs = block_type_data->num_regs;
1709 return (const struct dbg_attn_reg *)
1710 p_hwfn->dbg_arrays[BIN_BUF_DBG_ATTN_REGS].ptr +
1711 block_type_data->regs_offset;
1714 /* For each block, clear the status of all parities */
1715 static void qed_grc_clear_all_prty(struct ecore_hwfn *p_hwfn,
1716 struct ecore_ptt *p_ptt)
1718 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
1719 const struct dbg_attn_reg *attn_reg_arr;
1720 u8 reg_idx, num_attn_regs;
1723 for (block_id = 0; block_id < NUM_PHYS_BLOCKS; block_id++) {
1724 if (dev_data->block_in_reset[block_id])
1727 attn_reg_arr = qed_get_block_attn_regs(p_hwfn,
1728 (enum block_id)block_id,
1732 for (reg_idx = 0; reg_idx < num_attn_regs; reg_idx++) {
1733 const struct dbg_attn_reg *reg_data =
1734 &attn_reg_arr[reg_idx];
1735 u16 modes_buf_offset;
1739 eval_mode = GET_FIELD(reg_data->mode.data,
1740 DBG_MODE_HDR_EVAL_MODE) > 0;
1742 GET_FIELD(reg_data->mode.data,
1743 DBG_MODE_HDR_MODES_BUF_OFFSET);
1745 /* If Mode match: clear parity status */
1747 qed_is_mode_match(p_hwfn, &modes_buf_offset))
1748 ecore_rd(p_hwfn, p_ptt,
1749 DWORDS_TO_BYTES(reg_data->sts_clr_address));
1754 /* Dumps GRC registers section header. Returns the dumped size in dwords.
1755 * the following parameters are dumped:
1756 * - count: no. of dumped entries
1757 * - split_type: split type
1758 * - split_id: split ID (dumped only if split_id != SPLIT_TYPE_NONE)
1759 * - reg_type_name: register type name (dumped only if reg_type_name != NULL)
1761 static u32 qed_grc_dump_regs_hdr(u32 *dump_buf,
1763 u32 num_reg_entries,
1764 enum init_split_types split_type,
1765 u8 split_id, const char *reg_type_name)
1768 (split_type != SPLIT_TYPE_NONE ? 1 : 0) + (reg_type_name ? 1 : 0);
1771 offset += qed_dump_section_hdr(dump_buf + offset,
1772 dump, "grc_regs", num_params);
1773 offset += qed_dump_num_param(dump_buf + offset,
1774 dump, "count", num_reg_entries);
1775 offset += qed_dump_str_param(dump_buf + offset,
1777 s_split_type_defs[split_type].name);
1778 if (split_type != SPLIT_TYPE_NONE)
1779 offset += qed_dump_num_param(dump_buf + offset,
1780 dump, "id", split_id);
1782 offset += qed_dump_str_param(dump_buf + offset,
1783 dump, "type", reg_type_name);
1788 /* Reads the specified registers into the specified buffer.
1789 * The addr and len arguments are specified in dwords.
1791 void qed_read_regs(struct ecore_hwfn *p_hwfn,
1792 struct ecore_ptt *p_ptt, u32 *buf, u32 addr, u32 len)
1796 for (i = 0; i < len; i++)
1797 buf[i] = ecore_rd(p_hwfn, p_ptt, DWORDS_TO_BYTES(addr + i));
1800 /* Dumps the GRC registers in the specified address range.
1801 * Returns the dumped size in dwords.
1802 * The addr and len arguments are specified in dwords.
1804 static u32 qed_grc_dump_addr_range(struct ecore_hwfn *p_hwfn,
1805 struct ecore_ptt *p_ptt,
1807 bool dump, u32 addr, u32 len, bool wide_bus,
1808 enum init_split_types split_type,
1811 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
1812 u8 port_id = 0, pf_id = 0;
1813 u16 vf_id = 0, fid = 0;
1814 bool read_using_dmae = false;
1820 switch (split_type) {
1821 case SPLIT_TYPE_PORT:
1827 case SPLIT_TYPE_PORT_PF:
1828 port_id = split_id / dev_data->num_pfs_per_port;
1829 pf_id = port_id + dev_data->num_ports *
1830 (split_id % dev_data->num_pfs_per_port);
1839 /* Try reading using DMAE */
1840 if (dev_data->use_dmae && split_type != SPLIT_TYPE_VF &&
1841 (len >= s_hw_type_defs[dev_data->hw_type].dmae_thresh ||
1842 (PROTECT_WIDE_BUS && wide_bus))) {
1843 struct dmae_params dmae_params;
1845 /* Set DMAE params */
1846 memset(&dmae_params, 0, sizeof(dmae_params));
1847 SET_FIELD(dmae_params.flags, DMAE_PARAMS_COMPLETION_DST, 1);
1848 switch (split_type) {
1849 case SPLIT_TYPE_PORT:
1850 SET_FIELD(dmae_params.flags, DMAE_PARAMS_PORT_VALID,
1852 dmae_params.port_id = port_id;
1855 SET_FIELD(dmae_params.flags,
1856 DMAE_PARAMS_SRC_PF_VALID, 1);
1857 dmae_params.src_pf_id = pf_id;
1859 case SPLIT_TYPE_PORT_PF:
1860 SET_FIELD(dmae_params.flags, DMAE_PARAMS_PORT_VALID,
1862 SET_FIELD(dmae_params.flags,
1863 DMAE_PARAMS_SRC_PF_VALID, 1);
1864 dmae_params.port_id = port_id;
1865 dmae_params.src_pf_id = pf_id;
1871 /* Execute DMAE command */
1872 read_using_dmae = !ecore_dmae_grc2host(p_hwfn,
1874 DWORDS_TO_BYTES(addr),
1875 (u64)(uintptr_t)(dump_buf),
1877 if (!read_using_dmae) {
1878 dev_data->use_dmae = 0;
1879 DP_VERBOSE(p_hwfn->p_dev,
1881 "Failed reading from chip using DMAE, using GRC instead\n");
1885 if (read_using_dmae)
1888 /* If not read using DMAE, read using GRC */
1891 if (split_type != dev_data->pretend.split_type ||
1892 split_id != dev_data->pretend.split_id) {
1893 switch (split_type) {
1894 case SPLIT_TYPE_PORT:
1895 ecore_port_pretend(p_hwfn, p_ptt, port_id);
1898 fid = FIELD_VALUE(PXP_PRETEND_CONCRETE_FID_PFID,
1900 ecore_fid_pretend(p_hwfn, p_ptt, fid);
1902 case SPLIT_TYPE_PORT_PF:
1903 fid = FIELD_VALUE(PXP_PRETEND_CONCRETE_FID_PFID,
1905 ecore_port_fid_pretend(p_hwfn, p_ptt, port_id, fid);
1908 fid = FIELD_VALUE(PXP_PRETEND_CONCRETE_FID_VFVALID, 1)
1909 | FIELD_VALUE(PXP_PRETEND_CONCRETE_FID_VFID,
1911 ecore_fid_pretend(p_hwfn, p_ptt, fid);
1917 dev_data->pretend.split_type = (u8)split_type;
1918 dev_data->pretend.split_id = split_id;
1921 /* Read registers using GRC */
1922 qed_read_regs(p_hwfn, p_ptt, dump_buf, addr, len);
1926 dev_data->num_regs_read += len;
1927 thresh = s_hw_type_defs[dev_data->hw_type].log_thresh;
1928 if ((dev_data->num_regs_read / thresh) >
1929 ((dev_data->num_regs_read - len) / thresh))
1930 DP_VERBOSE(p_hwfn->p_dev,
1932 "Dumped %d registers...\n", dev_data->num_regs_read);
1937 /* Dumps GRC registers sequence header. Returns the dumped size in dwords.
1938 * The addr and len arguments are specified in dwords.
1940 static u32 qed_grc_dump_reg_entry_hdr(u32 *dump_buf,
1941 bool dump, u32 addr, u32 len)
1944 *dump_buf = addr | (len << REG_DUMP_LEN_SHIFT);
1949 /* Dumps GRC registers sequence. Returns the dumped size in dwords.
1950 * The addr and len arguments are specified in dwords.
1952 static u32 qed_grc_dump_reg_entry(struct ecore_hwfn *p_hwfn,
1953 struct ecore_ptt *p_ptt,
1955 bool dump, u32 addr, u32 len, bool wide_bus,
1956 enum init_split_types split_type, u8 split_id)
1960 offset += qed_grc_dump_reg_entry_hdr(dump_buf, dump, addr, len);
1961 offset += qed_grc_dump_addr_range(p_hwfn,
1964 dump, addr, len, wide_bus,
1965 split_type, split_id);
1970 /* Dumps GRC registers sequence with skip cycle.
1971 * Returns the dumped size in dwords.
1972 * - addr: start GRC address in dwords
1973 * - total_len: total no. of dwords to dump
1974 * - read_len: no. consecutive dwords to read
1975 * - skip_len: no. of dwords to skip (and fill with zeros)
1977 static u32 qed_grc_dump_reg_entry_skip(struct ecore_hwfn *p_hwfn,
1978 struct ecore_ptt *p_ptt,
1983 u32 read_len, u32 skip_len)
1985 u32 offset = 0, reg_offset = 0;
1987 offset += qed_grc_dump_reg_entry_hdr(dump_buf, dump, addr, total_len);
1990 return offset + total_len;
1992 while (reg_offset < total_len) {
1993 u32 curr_len = OSAL_MIN_T(u32, read_len,
1994 total_len - reg_offset);
1996 offset += qed_grc_dump_addr_range(p_hwfn,
1999 dump, addr, curr_len, false,
2000 SPLIT_TYPE_NONE, 0);
2001 reg_offset += curr_len;
2004 if (reg_offset < total_len) {
2005 curr_len = OSAL_MIN_T(u32, skip_len,
2006 total_len - skip_len);
2007 memset(dump_buf + offset, 0, DWORDS_TO_BYTES(curr_len));
2009 reg_offset += curr_len;
2017 /* Dumps GRC registers entries. Returns the dumped size in dwords. */
2018 static u32 qed_grc_dump_regs_entries(struct ecore_hwfn *p_hwfn,
2019 struct ecore_ptt *p_ptt,
2020 struct virt_mem_desc input_regs_arr,
2023 enum init_split_types split_type,
2025 bool block_enable[MAX_BLOCK_ID],
2026 u32 *num_dumped_reg_entries)
2028 u32 i, offset = 0, input_offset = 0;
2029 bool mode_match = true;
2031 *num_dumped_reg_entries = 0;
2033 while (input_offset < BYTES_TO_DWORDS(input_regs_arr.size)) {
2034 const struct dbg_dump_cond_hdr *cond_hdr =
2035 (const struct dbg_dump_cond_hdr *)
2036 input_regs_arr.ptr + input_offset++;
2037 u16 modes_buf_offset;
2040 /* Check mode/block */
2041 eval_mode = GET_FIELD(cond_hdr->mode.data,
2042 DBG_MODE_HDR_EVAL_MODE) > 0;
2045 GET_FIELD(cond_hdr->mode.data,
2046 DBG_MODE_HDR_MODES_BUF_OFFSET);
2047 mode_match = qed_is_mode_match(p_hwfn,
2051 if (!mode_match || !block_enable[cond_hdr->block_id]) {
2052 input_offset += cond_hdr->data_size;
2056 for (i = 0; i < cond_hdr->data_size; i++, input_offset++) {
2057 const struct dbg_dump_reg *reg =
2058 (const struct dbg_dump_reg *)
2059 input_regs_arr.ptr + input_offset;
2063 addr = GET_FIELD(reg->data, DBG_DUMP_REG_ADDRESS);
2064 len = GET_FIELD(reg->data, DBG_DUMP_REG_LENGTH);
2065 wide_bus = GET_FIELD(reg->data, DBG_DUMP_REG_WIDE_BUS);
2066 offset += qed_grc_dump_reg_entry(p_hwfn,
2073 split_type, split_id);
2074 (*num_dumped_reg_entries)++;
2081 /* Dumps GRC registers entries. Returns the dumped size in dwords. */
2082 static u32 qed_grc_dump_split_data(struct ecore_hwfn *p_hwfn,
2083 struct ecore_ptt *p_ptt,
2084 struct virt_mem_desc input_regs_arr,
2087 bool block_enable[MAX_BLOCK_ID],
2088 enum init_split_types split_type,
2089 u8 split_id, const char *reg_type_name)
2091 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
2092 enum init_split_types hdr_split_type = split_type;
2093 u32 num_dumped_reg_entries, offset;
2094 u8 hdr_split_id = split_id;
2096 /* In PORT_PF split type, print a port split header */
2097 if (split_type == SPLIT_TYPE_PORT_PF) {
2098 hdr_split_type = SPLIT_TYPE_PORT;
2099 hdr_split_id = split_id / dev_data->num_pfs_per_port;
2102 /* Calculate register dump header size (and skip it for now) */
2103 offset = qed_grc_dump_regs_hdr(dump_buf,
2107 hdr_split_id, reg_type_name);
2109 /* Dump registers */
2110 offset += qed_grc_dump_regs_entries(p_hwfn,
2118 &num_dumped_reg_entries);
2120 /* Write register dump header */
2121 if (dump && num_dumped_reg_entries > 0)
2122 qed_grc_dump_regs_hdr(dump_buf,
2124 num_dumped_reg_entries,
2126 hdr_split_id, reg_type_name);
2128 return num_dumped_reg_entries > 0 ? offset : 0;
2131 /* Dumps registers according to the input registers array. Returns the dumped
2134 static u32 qed_grc_dump_registers(struct ecore_hwfn *p_hwfn,
2135 struct ecore_ptt *p_ptt,
2138 bool block_enable[MAX_BLOCK_ID],
2139 const char *reg_type_name)
2141 struct virt_mem_desc *dbg_buf =
2142 &p_hwfn->dbg_arrays[BIN_BUF_DBG_DUMP_REG];
2143 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
2144 u32 offset = 0, input_offset = 0;
2146 while (input_offset < BYTES_TO_DWORDS(dbg_buf->size)) {
2147 const struct dbg_dump_split_hdr *split_hdr;
2148 struct virt_mem_desc curr_input_regs_arr;
2149 enum init_split_types split_type;
2150 u16 split_count = 0;
2151 u32 split_data_size;
2155 (const struct dbg_dump_split_hdr *)
2156 dbg_buf->ptr + input_offset++;
2158 GET_FIELD(split_hdr->hdr,
2159 DBG_DUMP_SPLIT_HDR_SPLIT_TYPE_ID);
2160 split_data_size = GET_FIELD(split_hdr->hdr,
2161 DBG_DUMP_SPLIT_HDR_DATA_SIZE);
2162 curr_input_regs_arr.ptr =
2163 (u32 *)p_hwfn->dbg_arrays[BIN_BUF_DBG_DUMP_REG].ptr +
2165 curr_input_regs_arr.size = DWORDS_TO_BYTES(split_data_size);
2167 switch (split_type) {
2168 case SPLIT_TYPE_NONE:
2171 case SPLIT_TYPE_PORT:
2172 split_count = dev_data->num_ports;
2175 case SPLIT_TYPE_PORT_PF:
2176 split_count = dev_data->num_ports *
2177 dev_data->num_pfs_per_port;
2180 split_count = dev_data->num_vfs;
2186 for (split_id = 0; split_id < split_count; split_id++)
2187 offset += qed_grc_dump_split_data(p_hwfn, p_ptt,
2188 curr_input_regs_arr,
2195 input_offset += split_data_size;
2198 /* Cancel pretends (pretend to original PF) */
2200 ecore_fid_pretend(p_hwfn, p_ptt,
2201 FIELD_VALUE(PXP_PRETEND_CONCRETE_FID_PFID,
2202 p_hwfn->rel_pf_id));
2203 dev_data->pretend.split_type = SPLIT_TYPE_NONE;
2204 dev_data->pretend.split_id = 0;
2210 /* Dump reset registers. Returns the dumped size in dwords. */
2211 static u32 qed_grc_dump_reset_regs(struct ecore_hwfn *p_hwfn,
2212 struct ecore_ptt *p_ptt,
2213 u32 *dump_buf, bool dump)
2215 u32 offset = 0, num_regs = 0;
2218 /* Calculate header size */
2219 offset += qed_grc_dump_regs_hdr(dump_buf,
2221 0, SPLIT_TYPE_NONE, 0, "RESET_REGS");
2223 /* Write reset registers */
2224 for (reset_reg_id = 0; reset_reg_id < NUM_DBG_RESET_REGS;
2226 const struct dbg_reset_reg *reset_reg;
2229 reset_reg = qed_get_dbg_reset_reg(p_hwfn, reset_reg_id);
2231 if (GET_FIELD(reset_reg->data, DBG_RESET_REG_IS_REMOVED))
2234 reset_reg_addr = GET_FIELD(reset_reg->data, DBG_RESET_REG_ADDR);
2235 offset += qed_grc_dump_reg_entry(p_hwfn,
2240 1, false, SPLIT_TYPE_NONE, 0);
2246 qed_grc_dump_regs_hdr(dump_buf,
2247 true, num_regs, SPLIT_TYPE_NONE,
2253 /* Dump registers that are modified during GRC Dump and therefore must be
2254 * dumped first. Returns the dumped size in dwords.
2256 static u32 qed_grc_dump_modified_regs(struct ecore_hwfn *p_hwfn,
2257 struct ecore_ptt *p_ptt,
2258 u32 *dump_buf, bool dump)
2260 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
2261 u32 block_id, offset = 0, stall_regs_offset;
2262 const struct dbg_attn_reg *attn_reg_arr;
2263 u8 storm_id, reg_idx, num_attn_regs;
2264 u32 num_reg_entries = 0;
2266 /* Write empty header for attention registers */
2267 offset += qed_grc_dump_regs_hdr(dump_buf,
2269 0, SPLIT_TYPE_NONE, 0, "ATTN_REGS");
2271 /* Write parity registers */
2272 for (block_id = 0; block_id < NUM_PHYS_BLOCKS; block_id++) {
2273 if (dev_data->block_in_reset[block_id] && dump)
2276 attn_reg_arr = qed_get_block_attn_regs(p_hwfn,
2277 (enum block_id)block_id,
2281 for (reg_idx = 0; reg_idx < num_attn_regs; reg_idx++) {
2282 const struct dbg_attn_reg *reg_data =
2283 &attn_reg_arr[reg_idx];
2284 u16 modes_buf_offset;
2289 eval_mode = GET_FIELD(reg_data->mode.data,
2290 DBG_MODE_HDR_EVAL_MODE) > 0;
2292 GET_FIELD(reg_data->mode.data,
2293 DBG_MODE_HDR_MODES_BUF_OFFSET);
2295 !qed_is_mode_match(p_hwfn, &modes_buf_offset))
2298 /* Mode match: read & dump registers */
2299 addr = reg_data->mask_address;
2300 offset += qed_grc_dump_reg_entry(p_hwfn,
2306 SPLIT_TYPE_NONE, 0);
2307 addr = GET_FIELD(reg_data->data,
2308 DBG_ATTN_REG_STS_ADDRESS);
2309 offset += qed_grc_dump_reg_entry(p_hwfn,
2315 SPLIT_TYPE_NONE, 0);
2316 num_reg_entries += 2;
2320 /* Overwrite header for attention registers */
2322 qed_grc_dump_regs_hdr(dump_buf,
2325 SPLIT_TYPE_NONE, 0, "ATTN_REGS");
2327 /* Write empty header for stall registers */
2328 stall_regs_offset = offset;
2329 offset += qed_grc_dump_regs_hdr(dump_buf,
2330 false, 0, SPLIT_TYPE_NONE, 0, "REGS");
2332 /* Write Storm stall status registers */
2333 for (storm_id = 0, num_reg_entries = 0; storm_id < MAX_DBG_STORMS;
2335 struct storm_defs *storm = &s_storm_defs[storm_id];
2338 if (dev_data->block_in_reset[storm->sem_block_id] && dump)
2342 BYTES_TO_DWORDS(storm->sem_fast_mem_addr +
2343 SEM_FAST_REG_STALLED);
2344 offset += qed_grc_dump_reg_entry(p_hwfn,
2350 false, SPLIT_TYPE_NONE, 0);
2354 /* Overwrite header for stall registers */
2356 qed_grc_dump_regs_hdr(dump_buf + stall_regs_offset,
2359 SPLIT_TYPE_NONE, 0, "REGS");
2364 /* Dumps registers that can't be represented in the debug arrays */
2365 static u32 qed_grc_dump_special_regs(struct ecore_hwfn *p_hwfn,
2366 struct ecore_ptt *p_ptt,
2367 u32 *dump_buf, bool dump)
2369 u32 offset = 0, addr;
2371 offset += qed_grc_dump_regs_hdr(dump_buf,
2372 dump, 2, SPLIT_TYPE_NONE, 0, "REGS");
2374 /* Dump R/TDIF_REG_DEBUG_ERROR_INFO_SIZE (every 8'th register should be
2377 addr = BYTES_TO_DWORDS(RDIF_REG_DEBUG_ERROR_INFO);
2378 offset += qed_grc_dump_reg_entry_skip(p_hwfn,
2383 RDIF_REG_DEBUG_ERROR_INFO_SIZE,
2386 addr = BYTES_TO_DWORDS(TDIF_REG_DEBUG_ERROR_INFO);
2388 qed_grc_dump_reg_entry_skip(p_hwfn,
2393 TDIF_REG_DEBUG_ERROR_INFO_SIZE,
2400 /* Dumps a GRC memory header (section and params). Returns the dumped size in
2401 * dwords. The following parameters are dumped:
2402 * - name: dumped only if it's not NULL.
2403 * - addr: in dwords, dumped only if name is NULL.
2404 * - len: in dwords, always dumped.
2405 * - width: dumped if it's not zero.
2406 * - packed: dumped only if it's not false.
2407 * - mem_group: always dumped.
2408 * - is_storm: true only if the memory is related to a Storm.
2409 * - storm_letter: valid only if is_storm is true.
2412 static u32 qed_grc_dump_mem_hdr(struct ecore_hwfn *p_hwfn,
2420 const char *mem_group, char storm_letter)
2427 DP_NOTICE(p_hwfn, false,
2428 "Unexpected GRC Dump error: dumped memory size must be non-zero\n");
2435 /* Dump section header */
2436 offset += qed_dump_section_hdr(dump_buf + offset,
2437 dump, "grc_mem", num_params);
2442 strcpy(buf, "?STORM_");
2443 buf[0] = storm_letter;
2444 strcpy(buf + strlen(buf), name);
2449 offset += qed_dump_str_param(dump_buf + offset,
2453 u32 addr_in_bytes = DWORDS_TO_BYTES(addr);
2455 offset += qed_dump_num_param(dump_buf + offset,
2456 dump, "addr", addr_in_bytes);
2460 offset += qed_dump_num_param(dump_buf + offset, dump, "len", len);
2462 /* Dump bit width */
2464 offset += qed_dump_num_param(dump_buf + offset,
2465 dump, "width", bit_width);
2469 offset += qed_dump_num_param(dump_buf + offset,
2474 strcpy(buf, "?STORM_");
2475 buf[0] = storm_letter;
2476 strcpy(buf + strlen(buf), mem_group);
2478 strcpy(buf, mem_group);
2481 offset += qed_dump_str_param(dump_buf + offset, dump, "type", buf);
2486 /* Dumps a single GRC memory. If name is NULL, the memory is stored by address.
2487 * Returns the dumped size in dwords.
2488 * The addr and len arguments are specified in dwords.
2490 static u32 qed_grc_dump_mem(struct ecore_hwfn *p_hwfn,
2491 struct ecore_ptt *p_ptt,
2500 const char *mem_group, char storm_letter)
2504 offset += qed_grc_dump_mem_hdr(p_hwfn,
2511 packed, mem_group, storm_letter);
2512 offset += qed_grc_dump_addr_range(p_hwfn,
2515 dump, addr, len, wide_bus,
2516 SPLIT_TYPE_NONE, 0);
2521 /* Dumps GRC memories entries. Returns the dumped size in dwords. */
2522 static u32 qed_grc_dump_mem_entries(struct ecore_hwfn *p_hwfn,
2523 struct ecore_ptt *p_ptt,
2524 struct virt_mem_desc input_mems_arr,
2525 u32 *dump_buf, bool dump)
2527 u32 i, offset = 0, input_offset = 0;
2528 bool mode_match = true;
2530 while (input_offset < BYTES_TO_DWORDS(input_mems_arr.size)) {
2531 const struct dbg_dump_cond_hdr *cond_hdr;
2532 u16 modes_buf_offset;
2537 (const struct dbg_dump_cond_hdr *)input_mems_arr.ptr +
2539 num_entries = cond_hdr->data_size / MEM_DUMP_ENTRY_SIZE_DWORDS;
2541 /* Check required mode */
2542 eval_mode = GET_FIELD(cond_hdr->mode.data,
2543 DBG_MODE_HDR_EVAL_MODE) > 0;
2546 GET_FIELD(cond_hdr->mode.data,
2547 DBG_MODE_HDR_MODES_BUF_OFFSET);
2548 mode_match = qed_is_mode_match(p_hwfn,
2553 input_offset += cond_hdr->data_size;
2557 for (i = 0; i < num_entries;
2558 i++, input_offset += MEM_DUMP_ENTRY_SIZE_DWORDS) {
2559 const struct dbg_dump_mem *mem =
2560 (const struct dbg_dump_mem *)((u32 *)
2563 const struct dbg_block *block;
2564 char storm_letter = 0;
2565 u32 mem_addr, mem_len;
2569 mem_group_id = GET_FIELD(mem->dword0,
2570 DBG_DUMP_MEM_MEM_GROUP_ID);
2571 if (mem_group_id >= MEM_GROUPS_NUM) {
2572 DP_NOTICE(p_hwfn, false, "Invalid mem_group_id\n");
2576 if (!qed_grc_is_mem_included(p_hwfn,
2582 mem_addr = GET_FIELD(mem->dword0, DBG_DUMP_MEM_ADDRESS);
2583 mem_len = GET_FIELD(mem->dword1, DBG_DUMP_MEM_LENGTH);
2584 mem_wide_bus = GET_FIELD(mem->dword1,
2585 DBG_DUMP_MEM_WIDE_BUS);
2587 block = get_dbg_block(p_hwfn,
2588 cond_hdr->block_id);
2590 /* If memory is associated with Storm,
2591 * update storm details
2593 if (block->associated_storm_letter)
2594 storm_letter = block->associated_storm_letter;
2597 offset += qed_grc_dump_mem(p_hwfn,
2607 s_mem_group_names[mem_group_id],
2615 /* Dumps GRC memories according to the input array dump_mem.
2616 * Returns the dumped size in dwords.
2618 static u32 qed_grc_dump_memories(struct ecore_hwfn *p_hwfn,
2619 struct ecore_ptt *p_ptt,
2620 u32 *dump_buf, bool dump)
2622 struct virt_mem_desc *dbg_buf =
2623 &p_hwfn->dbg_arrays[BIN_BUF_DBG_DUMP_MEM];
2624 u32 offset = 0, input_offset = 0;
2626 while (input_offset < BYTES_TO_DWORDS(dbg_buf->size)) {
2627 const struct dbg_dump_split_hdr *split_hdr;
2628 struct virt_mem_desc curr_input_mems_arr;
2629 enum init_split_types split_type;
2630 u32 split_data_size;
2633 (const struct dbg_dump_split_hdr *)dbg_buf->ptr +
2635 split_type = GET_FIELD(split_hdr->hdr,
2636 DBG_DUMP_SPLIT_HDR_SPLIT_TYPE_ID);
2637 split_data_size = GET_FIELD(split_hdr->hdr,
2638 DBG_DUMP_SPLIT_HDR_DATA_SIZE);
2639 curr_input_mems_arr.ptr = (u32 *)dbg_buf->ptr + input_offset;
2640 curr_input_mems_arr.size = DWORDS_TO_BYTES(split_data_size);
2642 if (split_type == SPLIT_TYPE_NONE)
2643 offset += qed_grc_dump_mem_entries(p_hwfn,
2645 curr_input_mems_arr,
2649 DP_NOTICE(p_hwfn, false,
2650 "Dumping split memories is currently not supported\n");
2652 input_offset += split_data_size;
2658 /* Dumps GRC context data for the specified Storm.
2659 * Returns the dumped size in dwords.
2660 * The lid_size argument is specified in quad-regs.
2662 static u32 qed_grc_dump_ctx_data(struct ecore_hwfn *p_hwfn,
2663 struct ecore_ptt *p_ptt,
2668 enum cm_ctx_types ctx_type, u8 storm_id)
2670 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
2671 struct storm_defs *storm = &s_storm_defs[storm_id];
2672 u32 i, lid, lid_size, total_size;
2673 u32 rd_reg_addr, offset = 0;
2675 /* Convert quad-regs to dwords */
2676 lid_size = storm->cm_ctx_lid_sizes[dev_data->chip_id][ctx_type] * 4;
2681 total_size = num_lids * lid_size;
2683 offset += qed_grc_dump_mem_hdr(p_hwfn,
2690 false, name, storm->letter);
2693 return offset + total_size;
2695 rd_reg_addr = BYTES_TO_DWORDS(storm->cm_ctx_rd_addr[ctx_type]);
2697 /* Dump context data */
2698 for (lid = 0; lid < num_lids; lid++) {
2699 for (i = 0; i < lid_size; i++) {
2701 p_ptt, storm->cm_ctx_wr_addr, (i << 9) | lid);
2702 offset += qed_grc_dump_addr_range(p_hwfn,
2709 SPLIT_TYPE_NONE, 0);
2716 /* Dumps GRC contexts. Returns the dumped size in dwords. */
2717 static u32 qed_grc_dump_ctx(struct ecore_hwfn *p_hwfn,
2718 struct ecore_ptt *p_ptt, u32 *dump_buf, bool dump)
2723 for (storm_id = 0; storm_id < MAX_DBG_STORMS; storm_id++) {
2724 if (!qed_grc_is_storm_included(p_hwfn,
2725 (enum dbg_storms)storm_id))
2728 /* Dump Conn AG context size */
2729 offset += qed_grc_dump_ctx_data(p_hwfn,
2735 CM_CTX_CONN_AG, storm_id);
2737 /* Dump Conn ST context size */
2738 offset += qed_grc_dump_ctx_data(p_hwfn,
2744 CM_CTX_CONN_ST, storm_id);
2746 /* Dump Task AG context size */
2747 offset += qed_grc_dump_ctx_data(p_hwfn,
2753 CM_CTX_TASK_AG, storm_id);
2755 /* Dump Task ST context size */
2756 offset += qed_grc_dump_ctx_data(p_hwfn,
2762 CM_CTX_TASK_ST, storm_id);
2768 #define VFC_STATUS_RESP_READY_BIT 0
2769 #define VFC_STATUS_BUSY_BIT 1
2770 #define VFC_STATUS_SENDING_CMD_BIT 2
2772 #define VFC_POLLING_DELAY_MS 1
2773 #define VFC_POLLING_COUNT 20
2775 /* Reads data from VFC. Returns the number of dwords read (0 on error).
2776 * Sizes are specified in dwords.
2778 static u32 qed_grc_dump_read_from_vfc(struct ecore_hwfn *p_hwfn,
2779 struct ecore_ptt *p_ptt,
2780 struct storm_defs *storm,
2785 u32 resp_size, u32 *dump_buf)
2787 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
2788 u32 vfc_status, polling_ms, polling_count = 0, i;
2789 u32 reg_addr, sem_base;
2790 bool is_ready = false;
2792 sem_base = storm->sem_fast_mem_addr;
2793 polling_ms = VFC_POLLING_DELAY_MS *
2794 s_hw_type_defs[dev_data->hw_type].delay_factor;
2796 /* Write VFC command */
2799 sem_base + SEM_FAST_REG_VFC_DATA_WR,
2800 cmd_data, cmd_size);
2802 /* Write VFC address */
2805 sem_base + SEM_FAST_REG_VFC_ADDR,
2806 addr_data, addr_size);
2809 for (i = 0; i < resp_size; i++) {
2810 /* Poll until ready */
2812 reg_addr = sem_base + SEM_FAST_REG_VFC_STATUS;
2813 qed_grc_dump_addr_range(p_hwfn,
2817 BYTES_TO_DWORDS(reg_addr),
2819 false, SPLIT_TYPE_NONE, 0);
2820 is_ready = vfc_status &
2821 OSAL_BIT(VFC_STATUS_RESP_READY_BIT);
2824 if (polling_count++ == VFC_POLLING_COUNT)
2827 OSAL_MSLEEP(polling_ms);
2829 } while (!is_ready);
2831 reg_addr = sem_base + SEM_FAST_REG_VFC_DATA_RD;
2832 qed_grc_dump_addr_range(p_hwfn,
2836 BYTES_TO_DWORDS(reg_addr),
2837 1, false, SPLIT_TYPE_NONE, 0);
2843 /* Dump VFC CAM. Returns the dumped size in dwords. */
2844 static u32 qed_grc_dump_vfc_cam(struct ecore_hwfn *p_hwfn,
2845 struct ecore_ptt *p_ptt,
2846 u32 *dump_buf, bool dump, u8 storm_id)
2848 u32 total_size = VFC_CAM_NUM_ROWS * VFC_CAM_RESP_DWORDS;
2849 struct storm_defs *storm = &s_storm_defs[storm_id];
2850 u32 cam_addr[VFC_CAM_ADDR_DWORDS] = { 0 };
2851 u32 cam_cmd[VFC_CAM_CMD_DWORDS] = { 0 };
2852 u32 row, offset = 0;
2854 offset += qed_grc_dump_mem_hdr(p_hwfn,
2861 false, "vfc_cam", storm->letter);
2864 return offset + total_size;
2866 /* Prepare CAM address */
2867 SET_VAR_FIELD(cam_addr, VFC_CAM_ADDR, OP, VFC_OPCODE_CAM_RD);
2869 /* Read VFC CAM data */
2870 for (row = 0; row < VFC_CAM_NUM_ROWS; row++) {
2871 SET_VAR_FIELD(cam_cmd, VFC_CAM_CMD, ROW, row);
2872 offset += qed_grc_dump_read_from_vfc(p_hwfn,
2878 VFC_CAM_ADDR_DWORDS,
2879 VFC_CAM_RESP_DWORDS,
2886 /* Dump VFC RAM. Returns the dumped size in dwords. */
2887 static u32 qed_grc_dump_vfc_ram(struct ecore_hwfn *p_hwfn,
2888 struct ecore_ptt *p_ptt,
2891 u8 storm_id, struct vfc_ram_defs *ram_defs)
2893 u32 total_size = ram_defs->num_rows * VFC_RAM_RESP_DWORDS;
2894 struct storm_defs *storm = &s_storm_defs[storm_id];
2895 u32 ram_addr[VFC_RAM_ADDR_DWORDS] = { 0 };
2896 u32 ram_cmd[VFC_RAM_CMD_DWORDS] = { 0 };
2897 u32 row, offset = 0;
2899 offset += qed_grc_dump_mem_hdr(p_hwfn,
2907 ram_defs->type_name,
2911 return offset + total_size;
2913 /* Prepare RAM address */
2914 SET_VAR_FIELD(ram_addr, VFC_RAM_ADDR, OP, VFC_OPCODE_RAM_RD);
2916 /* Read VFC RAM data */
2917 for (row = ram_defs->base_row;
2918 row < ram_defs->base_row + ram_defs->num_rows; row++) {
2919 SET_VAR_FIELD(ram_addr, VFC_RAM_ADDR, ROW, row);
2920 offset += qed_grc_dump_read_from_vfc(p_hwfn,
2926 VFC_RAM_ADDR_DWORDS,
2927 VFC_RAM_RESP_DWORDS,
2934 /* Dumps GRC VFC data. Returns the dumped size in dwords. */
2935 static u32 qed_grc_dump_vfc(struct ecore_hwfn *p_hwfn,
2936 struct ecore_ptt *p_ptt, u32 *dump_buf, bool dump)
2941 for (storm_id = 0; storm_id < MAX_DBG_STORMS; storm_id++) {
2942 if (!qed_grc_is_storm_included(p_hwfn,
2943 (enum dbg_storms)storm_id) ||
2944 !s_storm_defs[storm_id].has_vfc)
2948 offset += qed_grc_dump_vfc_cam(p_hwfn,
2954 for (i = 0; i < NUM_VFC_RAM_TYPES; i++)
2955 offset += qed_grc_dump_vfc_ram(p_hwfn,
2960 &s_vfc_ram_defs[i]);
2966 /* Dumps GRC RSS data. Returns the dumped size in dwords. */
2967 static u32 qed_grc_dump_rss(struct ecore_hwfn *p_hwfn,
2968 struct ecore_ptt *p_ptt, u32 *dump_buf, bool dump)
2970 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
2974 for (rss_mem_id = 0; rss_mem_id < NUM_RSS_MEM_TYPES; rss_mem_id++) {
2975 u32 rss_addr, num_entries, total_dwords;
2976 struct rss_mem_defs *rss_defs;
2977 u32 addr, num_dwords_to_read;
2980 rss_defs = &s_rss_mem_defs[rss_mem_id];
2981 rss_addr = rss_defs->addr;
2982 num_entries = rss_defs->num_entries[dev_data->chip_id];
2983 total_dwords = (num_entries * rss_defs->entry_width) / 32;
2984 packed = (rss_defs->entry_width == 16);
2986 offset += qed_grc_dump_mem_hdr(p_hwfn,
2992 rss_defs->entry_width,
2994 rss_defs->type_name, 0);
2998 offset += total_dwords;
3002 addr = BYTES_TO_DWORDS(RSS_REG_RSS_RAM_DATA);
3003 while (total_dwords) {
3004 num_dwords_to_read = OSAL_MIN_T(u32,
3005 RSS_REG_RSS_RAM_DATA_SIZE,
3007 ecore_wr(p_hwfn, p_ptt, RSS_REG_RSS_RAM_ADDR, rss_addr);
3008 offset += qed_grc_dump_addr_range(p_hwfn,
3015 SPLIT_TYPE_NONE, 0);
3016 total_dwords -= num_dwords_to_read;
3024 /* Dumps GRC Big RAM. Returns the dumped size in dwords. */
3025 static u32 qed_grc_dump_big_ram(struct ecore_hwfn *p_hwfn,
3026 struct ecore_ptt *p_ptt,
3027 u32 *dump_buf, bool dump, u8 big_ram_id)
3029 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
3030 u32 block_size, ram_size, offset = 0, reg_val, i;
3031 char mem_name[12] = "???_BIG_RAM";
3032 char type_name[8] = "???_RAM";
3033 struct big_ram_defs *big_ram;
3035 big_ram = &s_big_ram_defs[big_ram_id];
3036 ram_size = big_ram->ram_size[dev_data->chip_id];
3038 reg_val = ecore_rd(p_hwfn, p_ptt, big_ram->is_256b_reg_addr);
3039 block_size = reg_val &
3040 OSAL_BIT(big_ram->is_256b_bit_offset[dev_data->chip_id]) ?
3043 strncpy(type_name, big_ram->instance_name, BIG_RAM_NAME_LEN);
3044 strncpy(mem_name, big_ram->instance_name, BIG_RAM_NAME_LEN);
3046 /* Dump memory header */
3047 offset += qed_grc_dump_mem_hdr(p_hwfn,
3054 false, type_name, 0);
3056 /* Read and dump Big RAM data */
3058 return offset + ram_size;
3061 for (i = 0; i < DIV_ROUND_UP(ram_size, BRB_REG_BIG_RAM_DATA_SIZE);
3065 ecore_wr(p_hwfn, p_ptt, big_ram->addr_reg_addr, i);
3066 addr = BYTES_TO_DWORDS(big_ram->data_reg_addr);
3067 len = BRB_REG_BIG_RAM_DATA_SIZE;
3068 offset += qed_grc_dump_addr_range(p_hwfn,
3074 false, SPLIT_TYPE_NONE, 0);
3080 /* Dumps MCP scratchpad. Returns the dumped size in dwords. */
3081 static u32 qed_grc_dump_mcp(struct ecore_hwfn *p_hwfn,
3082 struct ecore_ptt *p_ptt, u32 *dump_buf, bool dump)
3084 bool block_enable[MAX_BLOCK_ID] = { 0 };
3085 u32 offset = 0, addr;
3086 bool halted = false;
3089 if (dump && !qed_grc_get_param(p_hwfn, DBG_GRC_PARAM_NO_MCP)) {
3090 halted = !ecore_mcp_halt(p_hwfn, p_ptt);
3092 DP_NOTICE(p_hwfn, false, "MCP halt failed!\n");
3095 /* Dump MCP scratchpad */
3096 offset += qed_grc_dump_mem(p_hwfn,
3101 BYTES_TO_DWORDS(MCP_REG_SCRATCH),
3102 MCP_REG_SCRATCH_SIZE,
3103 false, 0, false, "MCP", 0);
3105 /* Dump MCP cpu_reg_file */
3106 offset += qed_grc_dump_mem(p_hwfn,
3111 BYTES_TO_DWORDS(MCP_REG_CPU_REG_FILE),
3112 MCP_REG_CPU_REG_FILE_SIZE,
3113 false, 0, false, "MCP", 0);
3115 /* Dump MCP registers */
3116 block_enable[BLOCK_MCP] = true;
3117 offset += qed_grc_dump_registers(p_hwfn,
3120 dump, block_enable, "MCP");
3122 /* Dump required non-MCP registers */
3123 offset += qed_grc_dump_regs_hdr(dump_buf + offset,
3124 dump, 1, SPLIT_TYPE_NONE, 0,
3126 addr = BYTES_TO_DWORDS(MISC_REG_SHARED_MEM_ADDR);
3127 offset += qed_grc_dump_reg_entry(p_hwfn,
3133 false, SPLIT_TYPE_NONE, 0);
3136 if (halted && ecore_mcp_resume(p_hwfn, p_ptt))
3137 DP_NOTICE(p_hwfn, false, "Failed to resume MCP after halt!\n");
3142 /* Dumps the tbus indirect memory for all PHYs.
3143 * Returns the dumped size in dwords.
3145 static u32 qed_grc_dump_phy(struct ecore_hwfn *p_hwfn,
3146 struct ecore_ptt *p_ptt, u32 *dump_buf, bool dump)
3148 u32 offset = 0, tbus_lo_offset, tbus_hi_offset;
3152 for (phy_id = 0; phy_id < OSAL_ARRAY_SIZE(s_phy_defs); phy_id++) {
3153 u32 addr_lo_addr, addr_hi_addr, data_lo_addr, data_hi_addr;
3154 struct phy_defs *phy_defs;
3157 phy_defs = &s_phy_defs[phy_id];
3158 addr_lo_addr = phy_defs->base_addr +
3159 phy_defs->tbus_addr_lo_addr;
3160 addr_hi_addr = phy_defs->base_addr +
3161 phy_defs->tbus_addr_hi_addr;
3162 data_lo_addr = phy_defs->base_addr +
3163 phy_defs->tbus_data_lo_addr;
3164 data_hi_addr = phy_defs->base_addr +
3165 phy_defs->tbus_data_hi_addr;
3167 if (snprintf(mem_name, sizeof(mem_name), "tbus_%s",
3168 phy_defs->phy_name) < 0)
3169 DP_NOTICE(p_hwfn, false,
3170 "Unexpected debug error: invalid PHY memory name\n");
3172 offset += qed_grc_dump_mem_hdr(p_hwfn,
3177 PHY_DUMP_SIZE_DWORDS,
3178 16, true, mem_name, 0);
3181 offset += PHY_DUMP_SIZE_DWORDS;
3185 bytes_buf = (u8 *)(dump_buf + offset);
3186 for (tbus_hi_offset = 0;
3187 tbus_hi_offset < (NUM_PHY_TBUS_ADDRESSES >> 8);
3189 ecore_wr(p_hwfn, p_ptt, addr_hi_addr, tbus_hi_offset);
3190 for (tbus_lo_offset = 0; tbus_lo_offset < 256;
3193 p_ptt, addr_lo_addr, tbus_lo_offset);
3194 *(bytes_buf++) = (u8)ecore_rd(p_hwfn,
3197 *(bytes_buf++) = (u8)ecore_rd(p_hwfn,
3203 offset += PHY_DUMP_SIZE_DWORDS;
3209 static enum dbg_status qed_find_nvram_image(struct ecore_hwfn *p_hwfn,
3210 struct ecore_ptt *p_ptt,
3212 u32 *nvram_offset_bytes,
3213 u32 *nvram_size_bytes);
3215 static enum dbg_status qed_nvram_read(struct ecore_hwfn *p_hwfn,
3216 struct ecore_ptt *p_ptt,
3217 u32 nvram_offset_bytes,
3218 u32 nvram_size_bytes, u32 *ret_buf);
3220 /* Dumps the MCP HW dump from NVRAM. Returns the dumped size in dwords. */
3221 static u32 qed_grc_dump_mcp_hw_dump(struct ecore_hwfn *p_hwfn,
3222 struct ecore_ptt *p_ptt,
3223 u32 *dump_buf, bool dump)
3225 u32 hw_dump_offset_bytes = 0, hw_dump_size_bytes = 0;
3226 u32 hw_dump_size_dwords = 0, offset = 0;
3227 enum dbg_status status;
3229 /* Read HW dump image from NVRAM */
3230 status = qed_find_nvram_image(p_hwfn,
3232 NVM_TYPE_HW_DUMP_OUT,
3233 &hw_dump_offset_bytes,
3234 &hw_dump_size_bytes);
3235 if (status != DBG_STATUS_OK)
3238 hw_dump_size_dwords = BYTES_TO_DWORDS(hw_dump_size_bytes);
3240 /* Dump HW dump image section */
3241 offset += qed_dump_section_hdr(dump_buf + offset,
3242 dump, "mcp_hw_dump", 1);
3243 offset += qed_dump_num_param(dump_buf + offset,
3244 dump, "size", hw_dump_size_dwords);
3246 /* Read MCP HW dump image into dump buffer */
3247 if (dump && hw_dump_size_dwords) {
3248 status = qed_nvram_read(p_hwfn,
3250 hw_dump_offset_bytes,
3251 hw_dump_size_bytes, dump_buf + offset);
3252 if (status != DBG_STATUS_OK) {
3253 DP_NOTICE(p_hwfn, false,
3254 "Failed to read MCP HW Dump image from NVRAM\n");
3258 offset += hw_dump_size_dwords;
3263 /* Dumps Static Debug data. Returns the dumped size in dwords. */
3264 static u32 qed_grc_dump_static_debug(struct ecore_hwfn *p_hwfn,
3265 struct ecore_ptt *p_ptt,
3266 u32 *dump_buf, bool dump)
3268 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
3269 u32 block_id, line_id, offset = 0, addr, len;
3271 /* Don't dump static debug if a debug bus recording is in progress */
3272 if (dump && ecore_rd(p_hwfn, p_ptt, DBG_REG_DBG_BLOCK_ON))
3276 /* Disable debug bus in all blocks */
3277 qed_bus_disable_blocks(p_hwfn, p_ptt);
3279 qed_bus_reset_dbg_block(p_hwfn, p_ptt);
3281 p_ptt, DBG_REG_FRAMING_MODE, DBG_BUS_FRAME_MODE_8HW);
3283 p_ptt, DBG_REG_DEBUG_TARGET, DBG_BUS_TARGET_ID_INT_BUF);
3284 ecore_wr(p_hwfn, p_ptt, DBG_REG_FULL_MODE, 1);
3285 qed_bus_enable_dbg_block(p_hwfn, p_ptt, true);
3288 /* Dump all static debug lines for each relevant block */
3289 for (block_id = 0; block_id < MAX_BLOCK_ID; block_id++) {
3290 const struct dbg_block_chip *block_per_chip;
3291 const struct dbg_block *block;
3292 bool is_removed, has_dbg_bus;
3293 u16 modes_buf_offset;
3297 qed_get_dbg_block_per_chip(p_hwfn, (enum block_id)block_id);
3298 is_removed = GET_FIELD(block_per_chip->flags,
3299 DBG_BLOCK_CHIP_IS_REMOVED);
3300 has_dbg_bus = GET_FIELD(block_per_chip->flags,
3301 DBG_BLOCK_CHIP_HAS_DBG_BUS);
3303 /* read+clear for NWS parity is not working, skip NWS block */
3304 if (block_id == BLOCK_NWS)
3307 if (!is_removed && has_dbg_bus &&
3308 GET_FIELD(block_per_chip->dbg_bus_mode.data,
3309 DBG_MODE_HDR_EVAL_MODE) > 0) {
3311 GET_FIELD(block_per_chip->dbg_bus_mode.data,
3312 DBG_MODE_HDR_MODES_BUF_OFFSET);
3313 if (!qed_is_mode_match(p_hwfn, &modes_buf_offset))
3314 has_dbg_bus = false;
3317 if (is_removed || !has_dbg_bus)
3320 block_dwords = NUM_DBG_LINES(block_per_chip) *
3321 STATIC_DEBUG_LINE_DWORDS;
3323 /* Dump static section params */
3324 block = get_dbg_block(p_hwfn, (enum block_id)block_id);
3325 offset += qed_grc_dump_mem_hdr(p_hwfn,
3328 (const char *)block->name,
3331 32, false, "STATIC", 0);
3334 offset += block_dwords;
3338 /* If all lines are invalid - dump zeros */
3339 if (dev_data->block_in_reset[block_id]) {
3340 memset(dump_buf + offset, 0,
3341 DWORDS_TO_BYTES(block_dwords));
3342 offset += block_dwords;
3346 /* Enable block's client */
3347 qed_bus_enable_clients(p_hwfn,
3349 OSAL_BIT(block_per_chip->dbg_client_id));
3351 addr = BYTES_TO_DWORDS(DBG_REG_CALENDAR_OUT_DATA);
3352 len = STATIC_DEBUG_LINE_DWORDS;
3353 for (line_id = 0; line_id < (u32)NUM_DBG_LINES(block_per_chip);
3355 /* Configure debug line ID */
3356 qed_bus_config_dbg_line(p_hwfn,
3358 (enum block_id)block_id,
3359 (u8)line_id, 0xf, 0, 0, 0);
3361 /* Read debug line info */
3362 offset += qed_grc_dump_addr_range(p_hwfn,
3368 true, SPLIT_TYPE_NONE,
3372 /* Disable block's client and debug output */
3373 qed_bus_enable_clients(p_hwfn, p_ptt, 0);
3374 qed_bus_config_dbg_line(p_hwfn, p_ptt,
3375 (enum block_id)block_id, 0, 0, 0, 0, 0);
3379 qed_bus_enable_dbg_block(p_hwfn, p_ptt, false);
3380 qed_bus_enable_clients(p_hwfn, p_ptt, 0);
3386 /* Performs GRC Dump to the specified buffer.
3387 * Returns the dumped size in dwords.
3389 static enum dbg_status qed_grc_dump(struct ecore_hwfn *p_hwfn,
3390 struct ecore_ptt *p_ptt,
3392 bool dump, u32 *num_dumped_dwords)
3394 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
3395 u32 dwords_read, offset = 0;
3396 bool parities_masked = false;
3399 *num_dumped_dwords = 0;
3400 dev_data->num_regs_read = 0;
3402 /* Update reset state */
3404 qed_update_blocks_reset_state(p_hwfn, p_ptt);
3406 /* Dump global params */
3407 offset += qed_dump_common_global_params(p_hwfn,
3409 dump_buf + offset, dump, 4);
3410 offset += qed_dump_str_param(dump_buf + offset,
3411 dump, "dump-type", "grc-dump");
3412 offset += qed_dump_num_param(dump_buf + offset,
3416 offset += qed_dump_num_param(dump_buf + offset,
3420 offset += qed_dump_num_param(dump_buf + offset,
3421 dump, "num-ports", dev_data->num_ports);
3423 /* Dump reset registers (dumped before taking blocks out of reset ) */
3424 if (qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_REGS))
3425 offset += qed_grc_dump_reset_regs(p_hwfn,
3427 dump_buf + offset, dump);
3429 /* Take all blocks out of reset (using reset registers) */
3431 qed_grc_unreset_blocks(p_hwfn, p_ptt, false);
3432 qed_update_blocks_reset_state(p_hwfn, p_ptt);
3435 /* Disable all parities using MFW command */
3437 !qed_grc_get_param(p_hwfn, DBG_GRC_PARAM_NO_MCP)) {
3438 parities_masked = !ecore_mcp_mask_parities(p_hwfn, p_ptt, 1);
3439 if (!parities_masked) {
3440 DP_NOTICE(p_hwfn, false,
3441 "Failed to mask parities using MFW\n");
3442 if (qed_grc_get_param
3443 (p_hwfn, DBG_GRC_PARAM_PARITY_SAFE))
3444 return DBG_STATUS_MCP_COULD_NOT_MASK_PRTY;
3448 /* Dump modified registers (dumped before modifying them) */
3449 if (qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_REGS))
3450 offset += qed_grc_dump_modified_regs(p_hwfn,
3452 dump_buf + offset, dump);
3456 (qed_grc_is_included(p_hwfn,
3457 DBG_GRC_PARAM_DUMP_IOR) ||
3458 qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_VFC)))
3459 qed_grc_stall_storms(p_hwfn, p_ptt, true);
3462 if (qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_REGS)) {
3463 bool block_enable[MAX_BLOCK_ID];
3465 /* Dump all blocks except MCP */
3466 for (i = 0; i < MAX_BLOCK_ID; i++)
3467 block_enable[i] = true;
3468 block_enable[BLOCK_MCP] = false;
3469 offset += qed_grc_dump_registers(p_hwfn,
3474 block_enable, NULL);
3476 /* Dump special registers */
3477 offset += qed_grc_dump_special_regs(p_hwfn,
3479 dump_buf + offset, dump);
3483 offset += qed_grc_dump_memories(p_hwfn, p_ptt, dump_buf + offset, dump);
3486 if (qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_MCP))
3487 offset += qed_grc_dump_mcp(p_hwfn,
3488 p_ptt, dump_buf + offset, dump);
3491 if (qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_CM_CTX))
3492 offset += qed_grc_dump_ctx(p_hwfn,
3493 p_ptt, dump_buf + offset, dump);
3495 /* Dump RSS memories */
3496 if (qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_RSS))
3497 offset += qed_grc_dump_rss(p_hwfn,
3498 p_ptt, dump_buf + offset, dump);
3501 for (i = 0; i < NUM_BIG_RAM_TYPES; i++)
3502 if (qed_grc_is_included(p_hwfn, s_big_ram_defs[i].grc_param))
3503 offset += qed_grc_dump_big_ram(p_hwfn,
3509 if (qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_VFC)) {
3510 dwords_read = qed_grc_dump_vfc(p_hwfn,
3511 p_ptt, dump_buf + offset, dump);
3512 offset += dwords_read;
3514 return DBG_STATUS_VFC_READ_ERROR;
3518 if (qed_grc_is_included(p_hwfn,
3519 DBG_GRC_PARAM_DUMP_PHY) && dev_data->chip_id ==
3520 CHIP_K2 && dev_data->hw_type == HW_TYPE_ASIC)
3521 offset += qed_grc_dump_phy(p_hwfn,
3522 p_ptt, dump_buf + offset, dump);
3524 /* Dump MCP HW Dump */
3525 if (qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_MCP_HW_DUMP) &&
3526 !qed_grc_get_param(p_hwfn, DBG_GRC_PARAM_NO_MCP))
3527 offset += qed_grc_dump_mcp_hw_dump(p_hwfn,
3529 dump_buf + offset, dump);
3531 /* Dump static debug data (only if not during debug bus recording) */
3532 if (qed_grc_is_included(p_hwfn,
3533 DBG_GRC_PARAM_DUMP_STATIC) &&
3534 (!dump || dev_data->bus.state == DBG_BUS_STATE_IDLE))
3535 offset += qed_grc_dump_static_debug(p_hwfn,
3537 dump_buf + offset, dump);
3539 /* Dump last section */
3540 offset += qed_dump_last_section(dump_buf, offset, dump);
3543 /* Unstall storms */
3544 if (qed_grc_get_param(p_hwfn, DBG_GRC_PARAM_UNSTALL))
3545 qed_grc_stall_storms(p_hwfn, p_ptt, false);
3547 /* Clear parity status */
3548 qed_grc_clear_all_prty(p_hwfn, p_ptt);
3550 /* Enable all parities using MFW command */
3551 if (parities_masked)
3552 ecore_mcp_mask_parities(p_hwfn, p_ptt, 0);
3555 *num_dumped_dwords = offset;
3557 return DBG_STATUS_OK;
3560 /* Writes the specified failing Idle Check rule to the specified buffer.
3561 * Returns the dumped size in dwords.
3563 static u32 qed_idle_chk_dump_failure(struct ecore_hwfn *p_hwfn,
3564 struct ecore_ptt *p_ptt,
3569 const struct dbg_idle_chk_rule *rule,
3570 u16 fail_entry_id, u32 *cond_reg_values)
3572 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
3573 const struct dbg_idle_chk_cond_reg *cond_regs;
3574 const struct dbg_idle_chk_info_reg *info_regs;
3575 u32 i, next_reg_offset = 0, offset = 0;
3576 struct dbg_idle_chk_result_hdr *hdr;
3577 const union dbg_idle_chk_reg *regs;
3580 hdr = (struct dbg_idle_chk_result_hdr *)dump_buf;
3581 regs = (const union dbg_idle_chk_reg *)
3582 p_hwfn->dbg_arrays[BIN_BUF_DBG_IDLE_CHK_REGS].ptr +
3584 cond_regs = ®s[0].cond_reg;
3585 info_regs = ®s[rule->num_cond_regs].info_reg;
3587 /* Dump rule data */
3589 memset(hdr, 0, sizeof(*hdr));
3590 hdr->rule_id = rule_id;
3591 hdr->mem_entry_id = fail_entry_id;
3592 hdr->severity = rule->severity;
3593 hdr->num_dumped_cond_regs = rule->num_cond_regs;
3596 offset += IDLE_CHK_RESULT_HDR_DWORDS;
3598 /* Dump condition register values */
3599 for (reg_id = 0; reg_id < rule->num_cond_regs; reg_id++) {
3600 const struct dbg_idle_chk_cond_reg *reg = &cond_regs[reg_id];
3601 struct dbg_idle_chk_result_reg_hdr *reg_hdr;
3604 (struct dbg_idle_chk_result_reg_hdr *)(dump_buf + offset);
3606 /* Write register header */
3608 offset += IDLE_CHK_RESULT_REG_HDR_DWORDS +
3613 offset += IDLE_CHK_RESULT_REG_HDR_DWORDS;
3614 memset(reg_hdr, 0, sizeof(*reg_hdr));
3615 reg_hdr->start_entry = reg->start_entry;
3616 reg_hdr->size = reg->entry_size;
3617 SET_FIELD(reg_hdr->data,
3618 DBG_IDLE_CHK_RESULT_REG_HDR_IS_MEM,
3619 reg->num_entries > 1 || reg->start_entry > 0 ? 1 : 0);
3620 SET_FIELD(reg_hdr->data,
3621 DBG_IDLE_CHK_RESULT_REG_HDR_REG_ID, reg_id);
3623 /* Write register values */
3624 for (i = 0; i < reg_hdr->size; i++, next_reg_offset++, offset++)
3625 dump_buf[offset] = cond_reg_values[next_reg_offset];
3628 /* Dump info register values */
3629 for (reg_id = 0; reg_id < rule->num_info_regs; reg_id++) {
3630 const struct dbg_idle_chk_info_reg *reg = &info_regs[reg_id];
3633 /* Check if register's block is in reset */
3635 offset += IDLE_CHK_RESULT_REG_HDR_DWORDS + reg->size;
3639 block_id = GET_FIELD(reg->data, DBG_IDLE_CHK_INFO_REG_BLOCK_ID);
3640 if (block_id >= MAX_BLOCK_ID) {
3641 DP_NOTICE(p_hwfn, false, "Invalid block_id\n");
3645 if (!dev_data->block_in_reset[block_id]) {
3646 struct dbg_idle_chk_result_reg_hdr *reg_hdr;
3647 bool wide_bus, eval_mode, mode_match = true;
3648 u16 modes_buf_offset;
3651 reg_hdr = (struct dbg_idle_chk_result_reg_hdr *)
3652 (dump_buf + offset);
3655 eval_mode = GET_FIELD(reg->mode.data,
3656 DBG_MODE_HDR_EVAL_MODE) > 0;
3659 GET_FIELD(reg->mode.data,
3660 DBG_MODE_HDR_MODES_BUF_OFFSET);
3662 qed_is_mode_match(p_hwfn,
3669 addr = GET_FIELD(reg->data,
3670 DBG_IDLE_CHK_INFO_REG_ADDRESS);
3671 wide_bus = GET_FIELD(reg->data,
3672 DBG_IDLE_CHK_INFO_REG_WIDE_BUS);
3674 /* Write register header */
3675 offset += IDLE_CHK_RESULT_REG_HDR_DWORDS;
3676 hdr->num_dumped_info_regs++;
3677 memset(reg_hdr, 0, sizeof(*reg_hdr));
3678 reg_hdr->size = reg->size;
3679 SET_FIELD(reg_hdr->data,
3680 DBG_IDLE_CHK_RESULT_REG_HDR_REG_ID,
3681 rule->num_cond_regs + reg_id);
3683 /* Write register values */
3684 offset += qed_grc_dump_addr_range(p_hwfn,
3689 reg->size, wide_bus,
3690 SPLIT_TYPE_NONE, 0);
3697 /* Dumps idle check rule entries. Returns the dumped size in dwords. */
3699 qed_idle_chk_dump_rule_entries(struct ecore_hwfn *p_hwfn,
3700 struct ecore_ptt *p_ptt,
3701 u32 *dump_buf, bool dump,
3702 const struct dbg_idle_chk_rule *input_rules,
3703 u32 num_input_rules, u32 *num_failing_rules)
3705 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
3706 u32 cond_reg_values[IDLE_CHK_MAX_ENTRIES_SIZE];
3711 *num_failing_rules = 0;
3713 for (i = 0; i < num_input_rules; i++) {
3714 const struct dbg_idle_chk_cond_reg *cond_regs;
3715 const struct dbg_idle_chk_rule *rule;
3716 const union dbg_idle_chk_reg *regs;
3717 u16 num_reg_entries = 1;
3718 bool check_rule = true;
3719 const u32 *imm_values;
3721 rule = &input_rules[i];
3722 regs = (const union dbg_idle_chk_reg *)
3723 p_hwfn->dbg_arrays[BIN_BUF_DBG_IDLE_CHK_REGS].ptr +
3725 cond_regs = ®s[0].cond_reg;
3727 (u32 *)p_hwfn->dbg_arrays[BIN_BUF_DBG_IDLE_CHK_IMMS].ptr +
3730 /* Check if all condition register blocks are out of reset, and
3731 * find maximal number of entries (all condition registers that
3732 * are memories must have the same size, which is > 1).
3734 for (reg_id = 0; reg_id < rule->num_cond_regs && check_rule;
3737 GET_FIELD(cond_regs[reg_id].data,
3738 DBG_IDLE_CHK_COND_REG_BLOCK_ID);
3740 if (block_id >= MAX_BLOCK_ID) {
3741 DP_NOTICE(p_hwfn, false, "Invalid block_id\n");
3745 check_rule = !dev_data->block_in_reset[block_id];
3746 if (cond_regs[reg_id].num_entries > num_reg_entries)
3747 num_reg_entries = cond_regs[reg_id].num_entries;
3750 if (!check_rule && dump)
3754 u32 entry_dump_size =
3755 qed_idle_chk_dump_failure(p_hwfn,
3764 offset += num_reg_entries * entry_dump_size;
3765 (*num_failing_rules) += num_reg_entries;
3769 /* Go over all register entries (number of entries is the same
3770 * for all condition registers).
3772 for (entry_id = 0; entry_id < num_reg_entries; entry_id++) {
3773 u32 next_reg_offset = 0;
3775 /* Read current entry of all condition registers */
3776 for (reg_id = 0; reg_id < rule->num_cond_regs;
3778 const struct dbg_idle_chk_cond_reg *reg =
3780 u32 padded_entry_size, addr;
3783 /* Find GRC address (if it's a memory, the
3784 * address of the specific entry is calculated).
3786 addr = GET_FIELD(reg->data,
3787 DBG_IDLE_CHK_COND_REG_ADDRESS);
3789 GET_FIELD(reg->data,
3790 DBG_IDLE_CHK_COND_REG_WIDE_BUS);
3791 if (reg->num_entries > 1 ||
3792 reg->start_entry > 0) {
3794 reg->entry_size > 1 ?
3795 OSAL_ROUNDUP_POW_OF_TWO(reg->entry_size) :
3797 addr += (reg->start_entry + entry_id) *
3801 /* Read registers */
3802 if (next_reg_offset + reg->entry_size >=
3803 IDLE_CHK_MAX_ENTRIES_SIZE) {
3804 DP_NOTICE(p_hwfn, false,
3805 "idle check registers entry is too large\n");
3810 qed_grc_dump_addr_range(p_hwfn, p_ptt,
3816 SPLIT_TYPE_NONE, 0);
3819 /* Call rule condition function.
3820 * If returns true, it's a failure.
3822 if ((*cond_arr[rule->cond_id]) (cond_reg_values,
3824 offset += qed_idle_chk_dump_failure(p_hwfn,
3832 (*num_failing_rules)++;
3840 /* Performs Idle Check Dump to the specified buffer.
3841 * Returns the dumped size in dwords.
3843 static u32 qed_idle_chk_dump(struct ecore_hwfn *p_hwfn,
3844 struct ecore_ptt *p_ptt, u32 *dump_buf, bool dump)
3846 struct virt_mem_desc *dbg_buf =
3847 &p_hwfn->dbg_arrays[BIN_BUF_DBG_IDLE_CHK_RULES];
3848 u32 num_failing_rules_offset, offset = 0,
3849 input_offset = 0, num_failing_rules = 0;
3851 /* Dump global params - 1 must match below amount of params */
3852 offset += qed_dump_common_global_params(p_hwfn,
3854 dump_buf + offset, dump, 1);
3855 offset += qed_dump_str_param(dump_buf + offset,
3856 dump, "dump-type", "idle-chk");
3858 /* Dump idle check section header with a single parameter */
3859 offset += qed_dump_section_hdr(dump_buf + offset, dump, "idle_chk", 1);
3860 num_failing_rules_offset = offset;
3861 offset += qed_dump_num_param(dump_buf + offset, dump, "num_rules", 0);
3863 while (input_offset < BYTES_TO_DWORDS(dbg_buf->size)) {
3864 const struct dbg_idle_chk_cond_hdr *cond_hdr =
3865 (const struct dbg_idle_chk_cond_hdr *)dbg_buf->ptr +
3867 bool eval_mode, mode_match = true;
3868 u32 curr_failing_rules;
3869 u16 modes_buf_offset;
3872 eval_mode = GET_FIELD(cond_hdr->mode.data,
3873 DBG_MODE_HDR_EVAL_MODE) > 0;
3876 GET_FIELD(cond_hdr->mode.data,
3877 DBG_MODE_HDR_MODES_BUF_OFFSET);
3878 mode_match = qed_is_mode_match(p_hwfn,
3883 const struct dbg_idle_chk_rule *rule =
3884 (const struct dbg_idle_chk_rule *)((u32 *)
3887 u32 num_input_rules =
3888 cond_hdr->data_size / IDLE_CHK_RULE_SIZE_DWORDS;
3890 qed_idle_chk_dump_rule_entries(p_hwfn,
3897 &curr_failing_rules);
3898 num_failing_rules += curr_failing_rules;
3901 input_offset += cond_hdr->data_size;
3904 /* Overwrite num_rules parameter */
3906 qed_dump_num_param(dump_buf + num_failing_rules_offset,
3907 dump, "num_rules", num_failing_rules);
3909 /* Dump last section */
3910 offset += qed_dump_last_section(dump_buf, offset, dump);
3915 /* Finds the meta data image in NVRAM */
3916 static enum dbg_status qed_find_nvram_image(struct ecore_hwfn *p_hwfn,
3917 struct ecore_ptt *p_ptt,
3919 u32 *nvram_offset_bytes,
3920 u32 *nvram_size_bytes)
3922 u32 ret_mcp_resp, ret_mcp_param, ret_txn_size;
3923 struct mcp_file_att file_att;
3926 /* Call NVRAM get file command */
3927 nvm_result = ecore_mcp_nvm_rd_cmd(p_hwfn,
3929 DRV_MSG_CODE_NVM_GET_FILE_ATT,
3933 &ret_txn_size, (u32 *)&file_att);
3935 /* Check response */
3937 (ret_mcp_resp & FW_MSG_CODE_MASK) != FW_MSG_CODE_NVM_OK)
3938 return DBG_STATUS_NVRAM_GET_IMAGE_FAILED;
3940 /* Update return values */
3941 *nvram_offset_bytes = file_att.nvm_start_addr;
3942 *nvram_size_bytes = file_att.len;
3944 DP_VERBOSE(p_hwfn->p_dev,
3946 "find_nvram_image: found NVRAM image of type %d in NVRAM offset %d bytes with size %d bytes\n",
3947 image_type, *nvram_offset_bytes, *nvram_size_bytes);
3949 /* Check alignment */
3950 if (*nvram_size_bytes & 0x3)
3951 return DBG_STATUS_NON_ALIGNED_NVRAM_IMAGE;
3953 return DBG_STATUS_OK;
3956 /* Reads data from NVRAM */
3957 static enum dbg_status qed_nvram_read(struct ecore_hwfn *p_hwfn,
3958 struct ecore_ptt *p_ptt,
3959 u32 nvram_offset_bytes,
3960 u32 nvram_size_bytes, u32 *ret_buf)
3962 u32 ret_mcp_resp, ret_mcp_param, ret_read_size, bytes_to_copy;
3963 s32 bytes_left = nvram_size_bytes;
3964 u32 read_offset = 0, param = 0;
3966 DP_NOTICE(p_hwfn->p_dev, false,
3967 "nvram_read: reading image of size %d bytes from NVRAM\n",
3973 MCP_DRV_NVM_BUF_LEN) ? MCP_DRV_NVM_BUF_LEN : bytes_left;
3975 /* Call NVRAM read command */
3976 SET_MFW_FIELD(param,
3977 DRV_MB_PARAM_NVM_OFFSET,
3978 nvram_offset_bytes + read_offset);
3979 SET_MFW_FIELD(param, DRV_MB_PARAM_NVM_LEN, bytes_to_copy);
3980 if (ecore_mcp_nvm_rd_cmd(p_hwfn, p_ptt,
3981 DRV_MSG_CODE_NVM_READ_NVRAM, param,
3983 &ret_mcp_param, &ret_read_size,
3984 (u32 *)((u8 *)ret_buf +
3986 DP_NOTICE(p_hwfn->p_dev, false, "rc = DBG_STATUS_NVRAM_READ_FAILED\n");
3987 return DBG_STATUS_NVRAM_READ_FAILED;
3990 /* Check response */
3991 if ((ret_mcp_resp & FW_MSG_CODE_MASK) != FW_MSG_CODE_NVM_OK) {
3992 DP_NOTICE(p_hwfn->p_dev, false, "rc = DBG_STATUS_NVRAM_READ_FAILED\n");
3993 return DBG_STATUS_NVRAM_READ_FAILED;
3996 /* Update read offset */
3997 read_offset += ret_read_size;
3998 bytes_left -= ret_read_size;
3999 } while (bytes_left > 0);
4001 return DBG_STATUS_OK;
4004 /* Get info on the MCP Trace data in the scratchpad:
4005 * - trace_data_grc_addr (OUT): trace data GRC address in bytes
4006 * - trace_data_size (OUT): trace data size in bytes (without the header)
4008 static enum dbg_status qed_mcp_trace_get_data_info(struct ecore_hwfn *p_hwfn,
4009 struct ecore_ptt *p_ptt,
4010 u32 *trace_data_grc_addr,
4011 u32 *trace_data_size)
4013 u32 spad_trace_offsize, signature;
4015 /* Read trace section offsize structure from MCP scratchpad */
4016 spad_trace_offsize = ecore_rd(p_hwfn, p_ptt,
4017 MCP_SPAD_TRACE_OFFSIZE_ADDR);
4019 /* Extract trace section address from offsize (in scratchpad) */
4020 *trace_data_grc_addr =
4021 MCP_REG_SCRATCH + SECTION_OFFSET(spad_trace_offsize);
4023 /* Read signature from MCP trace section */
4024 signature = ecore_rd(p_hwfn, p_ptt,
4025 *trace_data_grc_addr +
4026 offsetof(struct mcp_trace, signature));
4028 if (signature != MFW_TRACE_SIGNATURE)
4029 return DBG_STATUS_INVALID_TRACE_SIGNATURE;
4031 /* Read trace size from MCP trace section */
4032 *trace_data_size = ecore_rd(p_hwfn,
4034 *trace_data_grc_addr +
4035 offsetof(struct mcp_trace, size));
4037 return DBG_STATUS_OK;
4040 /* Reads MCP trace meta data image from NVRAM
4041 * - running_bundle_id (OUT): running bundle ID (invalid when loaded from file)
4042 * - trace_meta_offset (OUT): trace meta offset in NVRAM in bytes (invalid when
4043 * loaded from file).
4044 * - trace_meta_size (OUT): size in bytes of the trace meta data.
4046 static enum dbg_status qed_mcp_trace_get_meta_info(struct ecore_hwfn *p_hwfn,
4047 struct ecore_ptt *p_ptt,
4048 u32 trace_data_size_bytes,
4049 u32 *running_bundle_id,
4050 u32 *trace_meta_offset,
4051 u32 *trace_meta_size)
4053 u32 spad_trace_offsize, nvram_image_type, running_mfw_addr;
4055 /* Read MCP trace section offsize structure from MCP scratchpad */
4056 spad_trace_offsize = ecore_rd(p_hwfn, p_ptt,
4057 MCP_SPAD_TRACE_OFFSIZE_ADDR);
4059 /* Find running bundle ID */
4061 MCP_REG_SCRATCH + SECTION_OFFSET(spad_trace_offsize) +
4062 SECTION_SIZE(spad_trace_offsize) + trace_data_size_bytes;
4063 *running_bundle_id = ecore_rd(p_hwfn, p_ptt, running_mfw_addr);
4064 if (*running_bundle_id > 1)
4065 return DBG_STATUS_INVALID_NVRAM_BUNDLE;
4067 /* Find image in NVRAM */
4069 (*running_bundle_id ==
4070 DIR_ID_1) ? NVM_TYPE_MFW_TRACE1 : NVM_TYPE_MFW_TRACE2;
4071 return qed_find_nvram_image(p_hwfn,
4074 trace_meta_offset, trace_meta_size);
4077 /* Reads the MCP Trace meta data from NVRAM into the specified buffer */
4078 static enum dbg_status qed_mcp_trace_read_meta(struct ecore_hwfn *p_hwfn,
4079 struct ecore_ptt *p_ptt,
4080 u32 nvram_offset_in_bytes,
4081 u32 size_in_bytes, u32 *buf)
4083 u8 modules_num, module_len, i, *byte_buf = (u8 *)buf;
4084 enum dbg_status status;
4087 /* Read meta data from NVRAM */
4088 status = qed_nvram_read(p_hwfn,
4090 nvram_offset_in_bytes, size_in_bytes, buf);
4091 if (status != DBG_STATUS_OK)
4094 /* Extract and check first signature */
4095 signature = qed_read_unaligned_dword(byte_buf);
4096 byte_buf += sizeof(signature);
4097 if (signature != NVM_MAGIC_VALUE)
4098 return DBG_STATUS_INVALID_TRACE_SIGNATURE;
4100 /* Extract number of modules */
4101 modules_num = *(byte_buf++);
4103 /* Skip all modules */
4104 for (i = 0; i < modules_num; i++) {
4105 module_len = *(byte_buf++);
4106 byte_buf += module_len;
4109 /* Extract and check second signature */
4110 signature = qed_read_unaligned_dword(byte_buf);
4111 byte_buf += sizeof(signature);
4112 if (signature != NVM_MAGIC_VALUE)
4113 return DBG_STATUS_INVALID_TRACE_SIGNATURE;
4115 return DBG_STATUS_OK;
4118 /* Dump MCP Trace */
4119 static enum dbg_status qed_mcp_trace_dump(struct ecore_hwfn *p_hwfn,
4120 struct ecore_ptt *p_ptt,
4122 bool dump, u32 *num_dumped_dwords)
4124 u32 trace_data_grc_addr, trace_data_size_bytes, trace_data_size_dwords;
4125 u32 trace_meta_size_dwords = 0, running_bundle_id, offset = 0;
4126 u32 trace_meta_offset_bytes = 0, trace_meta_size_bytes = 0;
4127 enum dbg_status status;
4131 *num_dumped_dwords = 0;
4133 use_mfw = !qed_grc_get_param(p_hwfn, DBG_GRC_PARAM_NO_MCP);
4135 /* Get trace data info */
4136 status = qed_mcp_trace_get_data_info(p_hwfn,
4138 &trace_data_grc_addr,
4139 &trace_data_size_bytes);
4140 if (status != DBG_STATUS_OK)
4143 /* Dump global params */
4144 offset += qed_dump_common_global_params(p_hwfn,
4146 dump_buf + offset, dump, 1);
4147 offset += qed_dump_str_param(dump_buf + offset,
4148 dump, "dump-type", "mcp-trace");
4150 /* Halt MCP while reading from scratchpad so the read data will be
4151 * consistent. if halt fails, MCP trace is taken anyway, with a small
4152 * risk that it may be corrupt.
4154 if (dump && use_mfw) {
4155 halted = !ecore_mcp_halt(p_hwfn, p_ptt);
4157 DP_NOTICE(p_hwfn, false, "MCP halt failed!\n");
4160 /* Find trace data size */
4161 trace_data_size_dwords =
4162 DIV_ROUND_UP(trace_data_size_bytes + sizeof(struct mcp_trace),
4165 /* Dump trace data section header and param */
4166 offset += qed_dump_section_hdr(dump_buf + offset,
4167 dump, "mcp_trace_data", 1);
4168 offset += qed_dump_num_param(dump_buf + offset,
4169 dump, "size", trace_data_size_dwords);
4171 /* Read trace data from scratchpad into dump buffer */
4172 offset += qed_grc_dump_addr_range(p_hwfn,
4176 BYTES_TO_DWORDS(trace_data_grc_addr),
4177 trace_data_size_dwords, false,
4178 SPLIT_TYPE_NONE, 0);
4180 /* Resume MCP (only if halt succeeded) */
4181 if (halted && ecore_mcp_resume(p_hwfn, p_ptt))
4182 DP_NOTICE(p_hwfn, false, "Failed to resume MCP after halt!\n");
4184 /* Dump trace meta section header */
4185 offset += qed_dump_section_hdr(dump_buf + offset,
4186 dump, "mcp_trace_meta", 1);
4188 /* If MCP Trace meta size parameter was set, use it.
4189 * Otherwise, read trace meta.
4190 * trace_meta_size_bytes is dword-aligned.
4192 trace_meta_size_bytes =
4193 qed_grc_get_param(p_hwfn, DBG_GRC_PARAM_MCP_TRACE_META_SIZE);
4194 if ((!trace_meta_size_bytes || dump) && use_mfw)
4195 status = qed_mcp_trace_get_meta_info(p_hwfn,
4197 trace_data_size_bytes,
4199 &trace_meta_offset_bytes,
4200 &trace_meta_size_bytes);
4201 if (status == DBG_STATUS_OK)
4202 trace_meta_size_dwords = BYTES_TO_DWORDS(trace_meta_size_bytes);
4204 /* Dump trace meta size param */
4205 offset += qed_dump_num_param(dump_buf + offset,
4206 dump, "size", trace_meta_size_dwords);
4208 /* Read trace meta image into dump buffer */
4209 if (dump && trace_meta_size_dwords)
4210 status = qed_mcp_trace_read_meta(p_hwfn,
4212 trace_meta_offset_bytes,
4213 trace_meta_size_bytes,
4215 if (status == DBG_STATUS_OK)
4216 offset += trace_meta_size_dwords;
4218 /* Dump last section */
4219 offset += qed_dump_last_section(dump_buf, offset, dump);
4221 *num_dumped_dwords = offset;
4223 /* If no mcp access, indicate that the dump doesn't contain the meta
4226 return use_mfw ? status : DBG_STATUS_NVRAM_GET_IMAGE_FAILED;
4230 static enum dbg_status qed_reg_fifo_dump(struct ecore_hwfn *p_hwfn,
4231 struct ecore_ptt *p_ptt,
4233 bool dump, u32 *num_dumped_dwords)
4235 u32 dwords_read, size_param_offset, offset = 0, addr, len;
4238 *num_dumped_dwords = 0;
4240 /* Dump global params */
4241 offset += qed_dump_common_global_params(p_hwfn,
4243 dump_buf + offset, dump, 1);
4244 offset += qed_dump_str_param(dump_buf + offset,
4245 dump, "dump-type", "reg-fifo");
4247 /* Dump fifo data section header and param. The size param is 0 for
4248 * now, and is overwritten after reading the FIFO.
4250 offset += qed_dump_section_hdr(dump_buf + offset,
4251 dump, "reg_fifo_data", 1);
4252 size_param_offset = offset;
4253 offset += qed_dump_num_param(dump_buf + offset, dump, "size", 0);
4256 /* FIFO max size is REG_FIFO_DEPTH_DWORDS. There is no way to
4257 * test how much data is available, except for reading it.
4259 offset += REG_FIFO_DEPTH_DWORDS;
4263 fifo_has_data = ecore_rd(p_hwfn, p_ptt,
4264 GRC_REG_TRACE_FIFO_VALID_DATA) > 0;
4266 /* Pull available data from fifo. Use DMAE since this is widebus memory
4267 * and must be accessed atomically. Test for dwords_read not passing
4268 * buffer size since more entries could be added to the buffer as we are
4271 addr = BYTES_TO_DWORDS(GRC_REG_TRACE_FIFO);
4272 len = REG_FIFO_ELEMENT_DWORDS;
4273 for (dwords_read = 0;
4274 fifo_has_data && dwords_read < REG_FIFO_DEPTH_DWORDS;
4275 dwords_read += REG_FIFO_ELEMENT_DWORDS) {
4276 offset += qed_grc_dump_addr_range(p_hwfn,
4282 true, SPLIT_TYPE_NONE,
4284 fifo_has_data = ecore_rd(p_hwfn, p_ptt,
4285 GRC_REG_TRACE_FIFO_VALID_DATA) > 0;
4288 qed_dump_num_param(dump_buf + size_param_offset, dump, "size",
4291 /* Dump last section */
4292 offset += qed_dump_last_section(dump_buf, offset, dump);
4294 *num_dumped_dwords = offset;
4296 return DBG_STATUS_OK;
4300 static enum dbg_status qed_igu_fifo_dump(struct ecore_hwfn *p_hwfn,
4301 struct ecore_ptt *p_ptt,
4303 bool dump, u32 *num_dumped_dwords)
4305 u32 dwords_read, size_param_offset, offset = 0, addr, len;
4308 *num_dumped_dwords = 0;
4310 /* Dump global params */
4311 offset += qed_dump_common_global_params(p_hwfn,
4313 dump_buf + offset, dump, 1);
4314 offset += qed_dump_str_param(dump_buf + offset,
4315 dump, "dump-type", "igu-fifo");
4317 /* Dump fifo data section header and param. The size param is 0 for
4318 * now, and is overwritten after reading the FIFO.
4320 offset += qed_dump_section_hdr(dump_buf + offset,
4321 dump, "igu_fifo_data", 1);
4322 size_param_offset = offset;
4323 offset += qed_dump_num_param(dump_buf + offset, dump, "size", 0);
4326 /* FIFO max size is IGU_FIFO_DEPTH_DWORDS. There is no way to
4327 * test how much data is available, except for reading it.
4329 offset += IGU_FIFO_DEPTH_DWORDS;
4333 fifo_has_data = ecore_rd(p_hwfn, p_ptt,
4334 IGU_REG_ERROR_HANDLING_DATA_VALID) > 0;
4336 /* Pull available data from fifo. Use DMAE since this is widebus memory
4337 * and must be accessed atomically. Test for dwords_read not passing
4338 * buffer size since more entries could be added to the buffer as we are
4341 addr = BYTES_TO_DWORDS(IGU_REG_ERROR_HANDLING_MEMORY);
4342 len = IGU_FIFO_ELEMENT_DWORDS;
4343 for (dwords_read = 0;
4344 fifo_has_data && dwords_read < IGU_FIFO_DEPTH_DWORDS;
4345 dwords_read += IGU_FIFO_ELEMENT_DWORDS) {
4346 offset += qed_grc_dump_addr_range(p_hwfn,
4352 true, SPLIT_TYPE_NONE,
4354 fifo_has_data = ecore_rd(p_hwfn, p_ptt,
4355 IGU_REG_ERROR_HANDLING_DATA_VALID) > 0;
4358 qed_dump_num_param(dump_buf + size_param_offset, dump, "size",
4361 /* Dump last section */
4362 offset += qed_dump_last_section(dump_buf, offset, dump);
4364 *num_dumped_dwords = offset;
4366 return DBG_STATUS_OK;
4369 /* Protection Override dump */
4370 static enum dbg_status qed_protection_override_dump(struct ecore_hwfn *p_hwfn,
4371 struct ecore_ptt *p_ptt,
4374 u32 *num_dumped_dwords)
4376 u32 size_param_offset, override_window_dwords, offset = 0, addr;
4378 *num_dumped_dwords = 0;
4380 /* Dump global params */
4381 offset += qed_dump_common_global_params(p_hwfn,
4383 dump_buf + offset, dump, 1);
4384 offset += qed_dump_str_param(dump_buf + offset,
4385 dump, "dump-type", "protection-override");
4387 /* Dump data section header and param. The size param is 0 for now,
4388 * and is overwritten after reading the data.
4390 offset += qed_dump_section_hdr(dump_buf + offset,
4391 dump, "protection_override_data", 1);
4392 size_param_offset = offset;
4393 offset += qed_dump_num_param(dump_buf + offset, dump, "size", 0);
4396 offset += PROTECTION_OVERRIDE_DEPTH_DWORDS;
4400 /* Add override window info to buffer */
4401 override_window_dwords =
4402 ecore_rd(p_hwfn, p_ptt, GRC_REG_NUMBER_VALID_OVERRIDE_WINDOW) *
4403 PROTECTION_OVERRIDE_ELEMENT_DWORDS;
4404 if (override_window_dwords) {
4405 addr = BYTES_TO_DWORDS(GRC_REG_PROTECTION_OVERRIDE_WINDOW);
4406 offset += qed_grc_dump_addr_range(p_hwfn,
4411 override_window_dwords,
4412 true, SPLIT_TYPE_NONE, 0);
4413 qed_dump_num_param(dump_buf + size_param_offset, dump, "size",
4414 override_window_dwords);
4417 /* Dump last section */
4418 offset += qed_dump_last_section(dump_buf, offset, dump);
4420 *num_dumped_dwords = offset;
4422 return DBG_STATUS_OK;
4425 /* Performs FW Asserts Dump to the specified buffer.
4426 * Returns the dumped size in dwords.
4428 static u32 qed_fw_asserts_dump(struct ecore_hwfn *p_hwfn,
4429 struct ecore_ptt *p_ptt, u32 *dump_buf,
4432 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
4433 struct fw_asserts_ram_section *asserts;
4434 char storm_letter_str[2] = "?";
4435 struct fw_info fw_info;
4439 /* Dump global params */
4440 offset += qed_dump_common_global_params(p_hwfn,
4442 dump_buf + offset, dump, 1);
4443 offset += qed_dump_str_param(dump_buf + offset,
4444 dump, "dump-type", "fw-asserts");
4446 /* Find Storm dump size */
4447 for (storm_id = 0; storm_id < MAX_DBG_STORMS; storm_id++) {
4448 u32 fw_asserts_section_addr, next_list_idx_addr, next_list_idx;
4449 struct storm_defs *storm = &s_storm_defs[storm_id];
4450 u32 last_list_idx, addr;
4452 if (dev_data->block_in_reset[storm->sem_block_id])
4455 /* Read FW info for the current Storm */
4456 qed_read_storm_fw_info(p_hwfn, p_ptt, storm_id, &fw_info);
4458 asserts = &fw_info.fw_asserts_section;
4460 /* Dump FW Asserts section header and params */
4461 storm_letter_str[0] = storm->letter;
4462 offset += qed_dump_section_hdr(dump_buf + offset,
4463 dump, "fw_asserts", 2);
4464 offset += qed_dump_str_param(dump_buf + offset,
4465 dump, "storm", storm_letter_str);
4466 offset += qed_dump_num_param(dump_buf + offset,
4469 asserts->list_element_dword_size);
4471 /* Read and dump FW Asserts data */
4473 offset += asserts->list_element_dword_size;
4477 fw_asserts_section_addr = storm->sem_fast_mem_addr +
4478 SEM_FAST_REG_INT_RAM +
4479 RAM_LINES_TO_BYTES(asserts->section_ram_line_offset);
4480 next_list_idx_addr = fw_asserts_section_addr +
4481 DWORDS_TO_BYTES(asserts->list_next_index_dword_offset);
4482 next_list_idx = ecore_rd(p_hwfn, p_ptt, next_list_idx_addr);
4483 last_list_idx = (next_list_idx > 0 ?
4485 asserts->list_num_elements) - 1;
4486 addr = BYTES_TO_DWORDS(fw_asserts_section_addr) +
4487 asserts->list_dword_offset +
4488 last_list_idx * asserts->list_element_dword_size;
4490 qed_grc_dump_addr_range(p_hwfn, p_ptt,
4493 asserts->list_element_dword_size,
4494 false, SPLIT_TYPE_NONE, 0);
4497 /* Dump last section */
4498 offset += qed_dump_last_section(dump_buf, offset, dump);
4503 /* Dumps the specified ILT pages to the specified buffer.
4504 * Returns the dumped size in dwords.
4506 static u32 qed_ilt_dump_pages_range(u32 *dump_buf,
4510 struct phys_mem_desc *ilt_pages,
4513 u32 page_id, end_page_id, offset = 0;
4518 end_page_id = start_page_id + num_pages - 1;
4520 for (page_id = start_page_id; page_id <= end_page_id; page_id++) {
4521 struct phys_mem_desc *mem_desc = &ilt_pages[page_id];
4525 * if (page_id >= ->p_cxt_mngr->ilt_shadow_size)
4529 if (!ilt_pages[page_id].virt_addr)
4532 if (dump_page_ids) {
4533 /* Copy page ID to dump buffer */
4535 *(dump_buf + offset) = page_id;
4538 /* Copy page memory to dump buffer */
4540 memcpy(dump_buf + offset,
4541 mem_desc->virt_addr, mem_desc->size);
4542 offset += BYTES_TO_DWORDS(mem_desc->size);
4549 /* Dumps a section containing the dumped ILT pages.
4550 * Returns the dumped size in dwords.
4552 static u32 qed_ilt_dump_pages_section(struct ecore_hwfn *p_hwfn,
4555 u32 valid_conn_pf_pages,
4556 u32 valid_conn_vf_pages,
4557 struct phys_mem_desc *ilt_pages,
4560 struct ecore_ilt_client_cfg *clients = p_hwfn->p_cxt_mngr->clients;
4561 u32 pf_start_line, start_page_id, offset = 0;
4562 u32 cdut_pf_init_pages, cdut_vf_init_pages;
4563 u32 cdut_pf_work_pages, cdut_vf_work_pages;
4564 u32 base_data_offset, size_param_offset;
4565 u32 cdut_pf_pages, cdut_vf_pages;
4566 const char *section_name;
4569 section_name = dump_page_ids ? "ilt_page_ids" : "ilt_page_mem";
4570 cdut_pf_init_pages = ecore_get_cdut_num_pf_init_pages(p_hwfn);
4571 cdut_vf_init_pages = ecore_get_cdut_num_vf_init_pages(p_hwfn);
4572 cdut_pf_work_pages = ecore_get_cdut_num_pf_work_pages(p_hwfn);
4573 cdut_vf_work_pages = ecore_get_cdut_num_vf_work_pages(p_hwfn);
4574 cdut_pf_pages = cdut_pf_init_pages + cdut_pf_work_pages;
4575 cdut_vf_pages = cdut_vf_init_pages + cdut_vf_work_pages;
4576 pf_start_line = p_hwfn->p_cxt_mngr->pf_start_line;
4579 qed_dump_section_hdr(dump_buf + offset, dump, section_name, 1);
4581 /* Dump size parameter (0 for now, overwritten with real size later) */
4582 size_param_offset = offset;
4583 offset += qed_dump_num_param(dump_buf + offset, dump, "size", 0);
4584 base_data_offset = offset;
4586 /* CDUC pages are ordered as follows:
4587 * - PF pages - valid section (included in PF connection type mapping)
4588 * - PF pages - invalid section (not dumped)
4589 * - For each VF in the PF:
4590 * - VF pages - valid section (included in VF connection type mapping)
4591 * - VF pages - invalid section (not dumped)
4593 if (qed_grc_get_param(p_hwfn, DBG_GRC_PARAM_DUMP_ILT_CDUC)) {
4594 /* Dump connection PF pages */
4595 start_page_id = clients[ILT_CLI_CDUC].first.val - pf_start_line;
4596 offset += qed_ilt_dump_pages_range(dump_buf + offset,
4599 valid_conn_pf_pages,
4600 ilt_pages, dump_page_ids);
4602 /* Dump connection VF pages */
4603 start_page_id += clients[ILT_CLI_CDUC].pf_total_lines;
4604 for (i = 0; i < p_hwfn->p_cxt_mngr->vf_count;
4605 i++, start_page_id += clients[ILT_CLI_CDUC].vf_total_lines)
4606 offset += qed_ilt_dump_pages_range(dump_buf + offset,
4609 valid_conn_vf_pages,
4614 /* CDUT pages are ordered as follows:
4615 * - PF init pages (not dumped)
4617 * - For each VF in the PF:
4618 * - VF init pages (not dumped)
4621 if (qed_grc_get_param(p_hwfn, DBG_GRC_PARAM_DUMP_ILT_CDUT)) {
4622 /* Dump task PF pages */
4623 start_page_id = clients[ILT_CLI_CDUT].first.val +
4624 cdut_pf_init_pages - pf_start_line;
4625 offset += qed_ilt_dump_pages_range(dump_buf + offset,
4629 ilt_pages, dump_page_ids);
4631 /* Dump task VF pages */
4632 start_page_id = clients[ILT_CLI_CDUT].first.val +
4633 cdut_pf_pages + cdut_vf_init_pages - pf_start_line;
4634 for (i = 0; i < p_hwfn->p_cxt_mngr->vf_count;
4635 i++, start_page_id += cdut_vf_pages)
4636 offset += qed_ilt_dump_pages_range(dump_buf + offset,
4644 /* Overwrite size param */
4646 qed_dump_num_param(dump_buf + size_param_offset,
4647 dump, "size", offset - base_data_offset);
4652 /* Performs ILT Dump to the specified buffer.
4653 * Returns the dumped size in dwords.
4655 static u32 qed_ilt_dump(struct ecore_hwfn *p_hwfn,
4656 struct ecore_ptt *p_ptt, u32 *dump_buf, bool dump)
4658 struct ecore_ilt_client_cfg *clients = p_hwfn->p_cxt_mngr->clients;
4659 u32 valid_conn_vf_cids, valid_conn_vf_pages, offset = 0;
4660 u32 valid_conn_pf_cids, valid_conn_pf_pages, num_pages;
4661 u32 num_cids_per_page, conn_ctx_size;
4662 u32 cduc_page_size, cdut_page_size;
4663 struct phys_mem_desc *ilt_pages;
4666 cduc_page_size = 1 <<
4667 (clients[ILT_CLI_CDUC].p_size.val + PXP_ILT_PAGE_SIZE_NUM_BITS_MIN);
4668 cdut_page_size = 1 <<
4669 (clients[ILT_CLI_CDUT].p_size.val + PXP_ILT_PAGE_SIZE_NUM_BITS_MIN);
4670 conn_ctx_size = p_hwfn->p_cxt_mngr->conn_ctx_size;
4671 num_cids_per_page = (int)(cduc_page_size / conn_ctx_size);
4672 ilt_pages = p_hwfn->p_cxt_mngr->ilt_shadow;
4674 /* Dump global params - 22 must match number of params below */
4675 offset += qed_dump_common_global_params(p_hwfn, p_ptt,
4676 dump_buf + offset, dump, 22);
4677 offset += qed_dump_str_param(dump_buf + offset,
4678 dump, "dump-type", "ilt-dump");
4679 offset += qed_dump_num_param(dump_buf + offset,
4681 "cduc-page-size", cduc_page_size);
4682 offset += qed_dump_num_param(dump_buf + offset,
4684 "cduc-first-page-id",
4685 clients[ILT_CLI_CDUC].first.val);
4686 offset += qed_dump_num_param(dump_buf + offset,
4688 "cduc-last-page-id",
4689 clients[ILT_CLI_CDUC].last.val);
4690 offset += qed_dump_num_param(dump_buf + offset,
4692 "cduc-num-pf-pages",
4694 [ILT_CLI_CDUC].pf_total_lines);
4695 offset += qed_dump_num_param(dump_buf + offset,
4697 "cduc-num-vf-pages",
4699 [ILT_CLI_CDUC].vf_total_lines);
4700 offset += qed_dump_num_param(dump_buf + offset,
4702 "max-conn-ctx-size",
4704 offset += qed_dump_num_param(dump_buf + offset,
4706 "cdut-page-size", cdut_page_size);
4707 offset += qed_dump_num_param(dump_buf + offset,
4709 "cdut-first-page-id",
4710 clients[ILT_CLI_CDUT].first.val);
4711 offset += qed_dump_num_param(dump_buf + offset,
4713 "cdut-last-page-id",
4714 clients[ILT_CLI_CDUT].last.val);
4715 offset += qed_dump_num_param(dump_buf + offset,
4717 "cdut-num-pf-init-pages",
4718 ecore_get_cdut_num_pf_init_pages(p_hwfn));
4719 offset += qed_dump_num_param(dump_buf + offset,
4721 "cdut-num-vf-init-pages",
4722 ecore_get_cdut_num_vf_init_pages(p_hwfn));
4723 offset += qed_dump_num_param(dump_buf + offset,
4725 "cdut-num-pf-work-pages",
4726 ecore_get_cdut_num_pf_work_pages(p_hwfn));
4727 offset += qed_dump_num_param(dump_buf + offset,
4729 "cdut-num-vf-work-pages",
4730 ecore_get_cdut_num_vf_work_pages(p_hwfn));
4731 offset += qed_dump_num_param(dump_buf + offset,
4733 "max-task-ctx-size",
4734 p_hwfn->p_cxt_mngr->task_ctx_size);
4735 offset += qed_dump_num_param(dump_buf + offset,
4738 p_hwfn->p_cxt_mngr->task_type_id);
4739 offset += qed_dump_num_param(dump_buf + offset,
4741 "first-vf-id-in-pf",
4742 p_hwfn->p_cxt_mngr->first_vf_in_pf);
4743 offset += /* 18 */ qed_dump_num_param(dump_buf + offset,
4746 p_hwfn->p_cxt_mngr->vf_count);
4747 offset += qed_dump_num_param(dump_buf + offset,
4749 "ptr-size-bytes", sizeof(void *));
4750 offset += qed_dump_num_param(dump_buf + offset,
4753 p_hwfn->p_cxt_mngr->pf_start_line);
4754 offset += qed_dump_num_param(dump_buf + offset,
4756 "page-mem-desc-size-dwords",
4757 PAGE_MEM_DESC_SIZE_DWORDS);
4758 offset += qed_dump_num_param(dump_buf + offset,
4761 p_hwfn->p_cxt_mngr->ilt_shadow_size);
4762 /* Additional/Less parameters require matching of number in call to
4763 * dump_common_global_params()
4766 /* Dump section containing number of PF CIDs per connection type */
4767 offset += qed_dump_section_hdr(dump_buf + offset,
4768 dump, "num_pf_cids_per_conn_type", 1);
4769 offset += qed_dump_num_param(dump_buf + offset,
4770 dump, "size", NUM_OF_CONNECTION_TYPES);
4771 for (conn_type = 0, valid_conn_pf_cids = 0;
4772 conn_type < NUM_OF_CONNECTION_TYPES; conn_type++, offset++) {
4774 p_hwfn->p_cxt_mngr->conn_cfg[conn_type].cid_count;
4777 *(dump_buf + offset) = num_pf_cids;
4778 valid_conn_pf_cids += num_pf_cids;
4781 /* Dump section containing number of VF CIDs per connection type */
4782 offset += qed_dump_section_hdr(dump_buf + offset,
4783 dump, "num_vf_cids_per_conn_type", 1);
4784 offset += qed_dump_num_param(dump_buf + offset,
4785 dump, "size", NUM_OF_CONNECTION_TYPES);
4786 for (conn_type = 0, valid_conn_vf_cids = 0;
4787 conn_type < NUM_OF_CONNECTION_TYPES; conn_type++, offset++) {
4789 p_hwfn->p_cxt_mngr->conn_cfg[conn_type].cids_per_vf;
4792 *(dump_buf + offset) = num_vf_cids;
4793 valid_conn_vf_cids += num_vf_cids;
4796 /* Dump section containing physical memory descs for each ILT page */
4797 num_pages = p_hwfn->p_cxt_mngr->ilt_shadow_size;
4798 offset += qed_dump_section_hdr(dump_buf + offset,
4799 dump, "ilt_page_desc", 1);
4800 offset += qed_dump_num_param(dump_buf + offset,
4803 num_pages * PAGE_MEM_DESC_SIZE_DWORDS);
4805 /* Copy memory descriptors to dump buffer */
4809 for (page_id = 0; page_id < num_pages;
4810 page_id++, offset += PAGE_MEM_DESC_SIZE_DWORDS)
4811 memcpy(dump_buf + offset,
4812 &ilt_pages[page_id],
4813 DWORDS_TO_BYTES(PAGE_MEM_DESC_SIZE_DWORDS));
4815 offset += num_pages * PAGE_MEM_DESC_SIZE_DWORDS;
4818 valid_conn_pf_pages = DIV_ROUND_UP(valid_conn_pf_cids,
4820 valid_conn_vf_pages = DIV_ROUND_UP(valid_conn_vf_cids,
4823 /* Dump ILT pages IDs */
4824 offset += qed_ilt_dump_pages_section(p_hwfn,
4827 valid_conn_pf_pages,
4828 valid_conn_vf_pages,
4831 /* Dump ILT pages memory */
4832 offset += qed_ilt_dump_pages_section(p_hwfn,
4835 valid_conn_pf_pages,
4836 valid_conn_vf_pages,
4839 /* Dump last section */
4840 offset += qed_dump_last_section(dump_buf, offset, dump);
4845 /***************************** Public Functions *******************************/
4847 enum dbg_status qed_dbg_set_bin_ptr(struct ecore_hwfn *p_hwfn,
4848 const u8 * const bin_ptr)
4850 struct bin_buffer_hdr *buf_hdrs =
4851 (struct bin_buffer_hdr *)(osal_uintptr_t)bin_ptr;
4854 /* Convert binary data to debug arrays */
4855 for (buf_id = 0; buf_id < MAX_BIN_DBG_BUFFER_TYPE; buf_id++)
4856 qed_set_dbg_bin_buf(p_hwfn,
4858 (const u32 *)(bin_ptr +
4859 buf_hdrs[buf_id].offset),
4860 buf_hdrs[buf_id].length);
4862 return DBG_STATUS_OK;
4865 enum dbg_status qed_dbg_set_app_ver(u32 ver)
4867 if (ver < TOOLS_VERSION)
4868 return DBG_STATUS_UNSUPPORTED_APP_VERSION;
4872 return DBG_STATUS_OK;
4875 bool qed_read_fw_info(struct ecore_hwfn *p_hwfn,
4876 struct ecore_ptt *p_ptt, struct fw_info *fw_info)
4878 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
4881 for (storm_id = 0; storm_id < MAX_DBG_STORMS; storm_id++) {
4882 struct storm_defs *storm = &s_storm_defs[storm_id];
4884 /* Skip Storm if it's in reset */
4885 if (dev_data->block_in_reset[storm->sem_block_id])
4888 /* Read FW info for the current Storm */
4889 qed_read_storm_fw_info(p_hwfn, p_ptt, storm_id, fw_info);
4897 enum dbg_status qed_dbg_grc_config(struct ecore_hwfn *p_hwfn,
4898 enum dbg_grc_params grc_param, u32 val)
4900 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
4901 enum dbg_status status;
4904 DP_VERBOSE(p_hwfn->p_dev,
4906 "dbg_grc_config: paramId = %d, val = %d\n", grc_param, val);
4908 status = qed_dbg_dev_init(p_hwfn);
4909 if (status != DBG_STATUS_OK)
4912 /* Initializes the GRC parameters (if not initialized). Needed in order
4913 * to set the default parameter values for the first time.
4915 qed_dbg_grc_init_params(p_hwfn);
4917 if (grc_param >= MAX_DBG_GRC_PARAMS)
4918 return DBG_STATUS_INVALID_ARGS;
4919 if (val < s_grc_param_defs[grc_param].min ||
4920 val > s_grc_param_defs[grc_param].max)
4921 return DBG_STATUS_INVALID_ARGS;
4923 if (s_grc_param_defs[grc_param].is_preset) {
4926 /* Disabling a preset is not allowed. Call
4927 * dbg_grc_set_params_default instead.
4930 return DBG_STATUS_INVALID_ARGS;
4932 /* Update all params with the preset values */
4933 for (i = 0; i < MAX_DBG_GRC_PARAMS; i++) {
4934 struct grc_param_defs *defs = &s_grc_param_defs[i];
4936 /* Skip persistent params */
4937 if (defs->is_persistent)
4940 /* Find preset value */
4941 if (grc_param == DBG_GRC_PARAM_EXCLUDE_ALL)
4943 defs->exclude_all_preset_val;
4944 else if (grc_param == DBG_GRC_PARAM_CRASH)
4946 defs->crash_preset_val[dev_data->chip_id];
4948 return DBG_STATUS_INVALID_ARGS;
4950 qed_grc_set_param(p_hwfn, i, preset_val);
4953 /* Regular param - set its value */
4954 qed_grc_set_param(p_hwfn, grc_param, val);
4957 return DBG_STATUS_OK;
4960 /* Assign default GRC param values */
4961 void qed_dbg_grc_set_params_default(struct ecore_hwfn *p_hwfn)
4963 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
4966 for (i = 0; i < MAX_DBG_GRC_PARAMS; i++)
4967 if (!s_grc_param_defs[i].is_persistent)
4968 dev_data->grc.param_val[i] =
4969 s_grc_param_defs[i].default_val[dev_data->chip_id];
4972 enum dbg_status qed_dbg_grc_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
4973 struct ecore_ptt *p_ptt,
4976 enum dbg_status status = qed_dbg_dev_init(p_hwfn);
4980 if (status != DBG_STATUS_OK)
4983 if (!p_hwfn->dbg_arrays[BIN_BUF_DBG_MODE_TREE].ptr ||
4984 !p_hwfn->dbg_arrays[BIN_BUF_DBG_DUMP_REG].ptr ||
4985 !p_hwfn->dbg_arrays[BIN_BUF_DBG_DUMP_MEM].ptr ||
4986 !p_hwfn->dbg_arrays[BIN_BUF_DBG_ATTN_BLOCKS].ptr ||
4987 !p_hwfn->dbg_arrays[BIN_BUF_DBG_ATTN_REGS].ptr)
4988 return DBG_STATUS_DBG_ARRAY_NOT_SET;
4990 return qed_grc_dump(p_hwfn, p_ptt, NULL, false, buf_size);
4993 enum dbg_status qed_dbg_grc_dump(struct ecore_hwfn *p_hwfn,
4994 struct ecore_ptt *p_ptt,
4996 u32 buf_size_in_dwords,
4997 u32 *num_dumped_dwords)
4999 u32 needed_buf_size_in_dwords;
5000 enum dbg_status status;
5002 *num_dumped_dwords = 0;
5004 status = qed_dbg_grc_get_dump_buf_size(p_hwfn,
5006 &needed_buf_size_in_dwords);
5007 if (status != DBG_STATUS_OK)
5010 if (buf_size_in_dwords < needed_buf_size_in_dwords)
5011 return DBG_STATUS_DUMP_BUF_TOO_SMALL;
5014 status = qed_grc_dump(p_hwfn, p_ptt, dump_buf, true, num_dumped_dwords);
5016 /* Revert GRC params to their default */
5017 qed_dbg_grc_set_params_default(p_hwfn);
5022 enum dbg_status qed_dbg_idle_chk_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
5023 struct ecore_ptt *p_ptt,
5026 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
5027 struct idle_chk_data *idle_chk = &dev_data->idle_chk;
5028 enum dbg_status status;
5032 status = qed_dbg_dev_init(p_hwfn);
5033 if (status != DBG_STATUS_OK)
5036 if (!p_hwfn->dbg_arrays[BIN_BUF_DBG_MODE_TREE].ptr ||
5037 !p_hwfn->dbg_arrays[BIN_BUF_DBG_IDLE_CHK_REGS].ptr ||
5038 !p_hwfn->dbg_arrays[BIN_BUF_DBG_IDLE_CHK_IMMS].ptr ||
5039 !p_hwfn->dbg_arrays[BIN_BUF_DBG_IDLE_CHK_RULES].ptr)
5040 return DBG_STATUS_DBG_ARRAY_NOT_SET;
5042 if (!idle_chk->buf_size_set) {
5043 idle_chk->buf_size = qed_idle_chk_dump(p_hwfn,
5044 p_ptt, NULL, false);
5045 idle_chk->buf_size_set = true;
5048 *buf_size = idle_chk->buf_size;
5050 return DBG_STATUS_OK;
5053 enum dbg_status qed_dbg_idle_chk_dump(struct ecore_hwfn *p_hwfn,
5054 struct ecore_ptt *p_ptt,
5056 u32 buf_size_in_dwords,
5057 u32 *num_dumped_dwords)
5059 u32 needed_buf_size_in_dwords;
5060 enum dbg_status status;
5062 *num_dumped_dwords = 0;
5064 status = qed_dbg_idle_chk_get_dump_buf_size(p_hwfn,
5066 &needed_buf_size_in_dwords);
5067 if (status != DBG_STATUS_OK)
5070 if (buf_size_in_dwords < needed_buf_size_in_dwords)
5071 return DBG_STATUS_DUMP_BUF_TOO_SMALL;
5073 /* Update reset state */
5074 qed_grc_unreset_blocks(p_hwfn, p_ptt, true);
5075 qed_update_blocks_reset_state(p_hwfn, p_ptt);
5077 /* Idle Check Dump */
5078 *num_dumped_dwords = qed_idle_chk_dump(p_hwfn, p_ptt, dump_buf, true);
5080 /* Revert GRC params to their default */
5081 qed_dbg_grc_set_params_default(p_hwfn);
5083 return DBG_STATUS_OK;
5086 enum dbg_status qed_dbg_mcp_trace_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
5087 struct ecore_ptt *p_ptt,
5090 enum dbg_status status = qed_dbg_dev_init(p_hwfn);
5094 if (status != DBG_STATUS_OK)
5097 return qed_mcp_trace_dump(p_hwfn, p_ptt, NULL, false, buf_size);
5100 enum dbg_status qed_dbg_mcp_trace_dump(struct ecore_hwfn *p_hwfn,
5101 struct ecore_ptt *p_ptt,
5103 u32 buf_size_in_dwords,
5104 u32 *num_dumped_dwords)
5106 u32 needed_buf_size_in_dwords;
5107 enum dbg_status status;
5110 qed_dbg_mcp_trace_get_dump_buf_size(p_hwfn,
5112 &needed_buf_size_in_dwords);
5113 if (status != DBG_STATUS_OK && status !=
5114 DBG_STATUS_NVRAM_GET_IMAGE_FAILED)
5116 if (buf_size_in_dwords < needed_buf_size_in_dwords)
5117 return DBG_STATUS_DUMP_BUF_TOO_SMALL;
5119 /* Update reset state */
5120 qed_update_blocks_reset_state(p_hwfn, p_ptt);
5123 status = qed_mcp_trace_dump(p_hwfn,
5124 p_ptt, dump_buf, true, num_dumped_dwords);
5126 /* Revert GRC params to their default */
5127 qed_dbg_grc_set_params_default(p_hwfn);
5132 enum dbg_status qed_dbg_reg_fifo_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
5133 struct ecore_ptt *p_ptt,
5136 enum dbg_status status = qed_dbg_dev_init(p_hwfn);
5140 if (status != DBG_STATUS_OK)
5143 return qed_reg_fifo_dump(p_hwfn, p_ptt, NULL, false, buf_size);
5146 enum dbg_status qed_dbg_reg_fifo_dump(struct ecore_hwfn *p_hwfn,
5147 struct ecore_ptt *p_ptt,
5149 u32 buf_size_in_dwords,
5150 u32 *num_dumped_dwords)
5152 u32 needed_buf_size_in_dwords;
5153 enum dbg_status status;
5155 *num_dumped_dwords = 0;
5157 status = qed_dbg_reg_fifo_get_dump_buf_size(p_hwfn,
5159 &needed_buf_size_in_dwords);
5160 if (status != DBG_STATUS_OK)
5163 if (buf_size_in_dwords < needed_buf_size_in_dwords)
5164 return DBG_STATUS_DUMP_BUF_TOO_SMALL;
5166 /* Update reset state */
5167 qed_update_blocks_reset_state(p_hwfn, p_ptt);
5169 status = qed_reg_fifo_dump(p_hwfn,
5170 p_ptt, dump_buf, true, num_dumped_dwords);
5172 /* Revert GRC params to their default */
5173 qed_dbg_grc_set_params_default(p_hwfn);
5178 enum dbg_status qed_dbg_igu_fifo_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
5179 struct ecore_ptt *p_ptt,
5182 enum dbg_status status = qed_dbg_dev_init(p_hwfn);
5186 if (status != DBG_STATUS_OK)
5189 return qed_igu_fifo_dump(p_hwfn, p_ptt, NULL, false, buf_size);
5192 enum dbg_status qed_dbg_igu_fifo_dump(struct ecore_hwfn *p_hwfn,
5193 struct ecore_ptt *p_ptt,
5195 u32 buf_size_in_dwords,
5196 u32 *num_dumped_dwords)
5198 u32 needed_buf_size_in_dwords;
5199 enum dbg_status status;
5201 *num_dumped_dwords = 0;
5203 status = qed_dbg_igu_fifo_get_dump_buf_size(p_hwfn,
5205 &needed_buf_size_in_dwords);
5206 if (status != DBG_STATUS_OK)
5209 if (buf_size_in_dwords < needed_buf_size_in_dwords)
5210 return DBG_STATUS_DUMP_BUF_TOO_SMALL;
5212 /* Update reset state */
5213 qed_update_blocks_reset_state(p_hwfn, p_ptt);
5215 status = qed_igu_fifo_dump(p_hwfn,
5216 p_ptt, dump_buf, true, num_dumped_dwords);
5217 /* Revert GRC params to their default */
5218 qed_dbg_grc_set_params_default(p_hwfn);
5224 qed_dbg_protection_override_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
5225 struct ecore_ptt *p_ptt,
5228 enum dbg_status status = qed_dbg_dev_init(p_hwfn);
5232 if (status != DBG_STATUS_OK)
5235 return qed_protection_override_dump(p_hwfn,
5236 p_ptt, NULL, false, buf_size);
5239 enum dbg_status qed_dbg_protection_override_dump(struct ecore_hwfn *p_hwfn,
5240 struct ecore_ptt *p_ptt,
5242 u32 buf_size_in_dwords,
5243 u32 *num_dumped_dwords)
5245 u32 needed_buf_size_in_dwords, *p_size = &needed_buf_size_in_dwords;
5246 enum dbg_status status;
5248 *num_dumped_dwords = 0;
5251 qed_dbg_protection_override_get_dump_buf_size(p_hwfn,
5254 if (status != DBG_STATUS_OK)
5257 if (buf_size_in_dwords < needed_buf_size_in_dwords)
5258 return DBG_STATUS_DUMP_BUF_TOO_SMALL;
5260 /* Update reset state */
5261 qed_update_blocks_reset_state(p_hwfn, p_ptt);
5263 status = qed_protection_override_dump(p_hwfn,
5266 true, num_dumped_dwords);
5268 /* Revert GRC params to their default */
5269 qed_dbg_grc_set_params_default(p_hwfn);
5274 enum dbg_status qed_dbg_fw_asserts_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
5275 struct ecore_ptt *p_ptt,
5278 enum dbg_status status = qed_dbg_dev_init(p_hwfn);
5282 if (status != DBG_STATUS_OK)
5285 /* Update reset state */
5286 qed_update_blocks_reset_state(p_hwfn, p_ptt);
5288 *buf_size = qed_fw_asserts_dump(p_hwfn, p_ptt, NULL, false);
5290 return DBG_STATUS_OK;
5293 enum dbg_status qed_dbg_fw_asserts_dump(struct ecore_hwfn *p_hwfn,
5294 struct ecore_ptt *p_ptt,
5296 u32 buf_size_in_dwords,
5297 u32 *num_dumped_dwords)
5299 u32 needed_buf_size_in_dwords, *p_size = &needed_buf_size_in_dwords;
5300 enum dbg_status status;
5302 *num_dumped_dwords = 0;
5305 qed_dbg_fw_asserts_get_dump_buf_size(p_hwfn,
5308 if (status != DBG_STATUS_OK)
5311 if (buf_size_in_dwords < needed_buf_size_in_dwords)
5312 return DBG_STATUS_DUMP_BUF_TOO_SMALL;
5314 *num_dumped_dwords = qed_fw_asserts_dump(p_hwfn, p_ptt, dump_buf, true);
5316 /* Revert GRC params to their default */
5317 qed_dbg_grc_set_params_default(p_hwfn);
5319 return DBG_STATUS_OK;
5322 static enum dbg_status qed_dbg_ilt_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
5323 struct ecore_ptt *p_ptt,
5326 enum dbg_status status = qed_dbg_dev_init(p_hwfn);
5330 if (status != DBG_STATUS_OK)
5333 *buf_size = qed_ilt_dump(p_hwfn, p_ptt, NULL, false);
5335 return DBG_STATUS_OK;
5338 static enum dbg_status qed_dbg_ilt_dump(struct ecore_hwfn *p_hwfn,
5339 struct ecore_ptt *p_ptt,
5341 u32 buf_size_in_dwords,
5342 u32 *num_dumped_dwords)
5344 u32 needed_buf_size_in_dwords;
5345 enum dbg_status status;
5347 *num_dumped_dwords = 0;
5349 status = qed_dbg_ilt_get_dump_buf_size(p_hwfn,
5351 &needed_buf_size_in_dwords);
5352 if (status != DBG_STATUS_OK)
5355 if (buf_size_in_dwords < needed_buf_size_in_dwords)
5356 return DBG_STATUS_DUMP_BUF_TOO_SMALL;
5358 *num_dumped_dwords = qed_ilt_dump(p_hwfn, p_ptt, dump_buf, true);
5360 /* Revert GRC params to their default */
5361 qed_dbg_grc_set_params_default(p_hwfn);
5363 return DBG_STATUS_OK;
5366 enum dbg_status qed_dbg_read_attn(struct ecore_hwfn *p_hwfn,
5367 struct ecore_ptt *p_ptt,
5368 enum block_id block_id,
5369 enum dbg_attn_type attn_type,
5371 struct dbg_attn_block_result *results)
5373 enum dbg_status status = qed_dbg_dev_init(p_hwfn);
5374 u8 reg_idx, num_attn_regs, num_result_regs = 0;
5375 const struct dbg_attn_reg *attn_reg_arr;
5377 if (status != DBG_STATUS_OK)
5380 if (!p_hwfn->dbg_arrays[BIN_BUF_DBG_MODE_TREE].ptr ||
5381 !p_hwfn->dbg_arrays[BIN_BUF_DBG_ATTN_BLOCKS].ptr ||
5382 !p_hwfn->dbg_arrays[BIN_BUF_DBG_ATTN_REGS].ptr)
5383 return DBG_STATUS_DBG_ARRAY_NOT_SET;
5385 attn_reg_arr = qed_get_block_attn_regs(p_hwfn,
5387 attn_type, &num_attn_regs);
5389 for (reg_idx = 0; reg_idx < num_attn_regs; reg_idx++) {
5390 const struct dbg_attn_reg *reg_data = &attn_reg_arr[reg_idx];
5391 struct dbg_attn_reg_result *reg_result;
5392 u32 sts_addr, sts_val;
5393 u16 modes_buf_offset;
5397 eval_mode = GET_FIELD(reg_data->mode.data,
5398 DBG_MODE_HDR_EVAL_MODE) > 0;
5399 modes_buf_offset = GET_FIELD(reg_data->mode.data,
5400 DBG_MODE_HDR_MODES_BUF_OFFSET);
5401 if (eval_mode && !qed_is_mode_match(p_hwfn, &modes_buf_offset))
5404 /* Mode match - read attention status register */
5405 sts_addr = DWORDS_TO_BYTES(clear_status ?
5406 reg_data->sts_clr_address :
5407 GET_FIELD(reg_data->data,
5408 DBG_ATTN_REG_STS_ADDRESS));
5409 sts_val = ecore_rd(p_hwfn, p_ptt, sts_addr);
5413 /* Non-zero attention status - add to results */
5414 reg_result = &results->reg_results[num_result_regs];
5415 SET_FIELD(reg_result->data,
5416 DBG_ATTN_REG_RESULT_STS_ADDRESS, sts_addr);
5417 SET_FIELD(reg_result->data,
5418 DBG_ATTN_REG_RESULT_NUM_REG_ATTN,
5419 GET_FIELD(reg_data->data, DBG_ATTN_REG_NUM_REG_ATTN));
5420 reg_result->block_attn_offset = reg_data->block_attn_offset;
5421 reg_result->sts_val = sts_val;
5422 reg_result->mask_val = ecore_rd(p_hwfn,
5425 (reg_data->mask_address));
5429 results->block_id = (u8)block_id;
5430 results->names_offset =
5431 qed_get_block_attn_data(p_hwfn, block_id, attn_type)->names_offset;
5432 SET_FIELD(results->data, DBG_ATTN_BLOCK_RESULT_ATTN_TYPE, attn_type);
5433 SET_FIELD(results->data,
5434 DBG_ATTN_BLOCK_RESULT_NUM_REGS, num_result_regs);
5436 return DBG_STATUS_OK;
5439 /******************************* Data Types **********************************/
5441 /* REG fifo element */
5442 struct reg_fifo_element {
5444 #define REG_FIFO_ELEMENT_ADDRESS_SHIFT 0
5445 #define REG_FIFO_ELEMENT_ADDRESS_MASK 0x7fffff
5446 #define REG_FIFO_ELEMENT_ACCESS_SHIFT 23
5447 #define REG_FIFO_ELEMENT_ACCESS_MASK 0x1
5448 #define REG_FIFO_ELEMENT_PF_SHIFT 24
5449 #define REG_FIFO_ELEMENT_PF_MASK 0xf
5450 #define REG_FIFO_ELEMENT_VF_SHIFT 28
5451 #define REG_FIFO_ELEMENT_VF_MASK 0xff
5452 #define REG_FIFO_ELEMENT_PORT_SHIFT 36
5453 #define REG_FIFO_ELEMENT_PORT_MASK 0x3
5454 #define REG_FIFO_ELEMENT_PRIVILEGE_SHIFT 38
5455 #define REG_FIFO_ELEMENT_PRIVILEGE_MASK 0x3
5456 #define REG_FIFO_ELEMENT_PROTECTION_SHIFT 40
5457 #define REG_FIFO_ELEMENT_PROTECTION_MASK 0x7
5458 #define REG_FIFO_ELEMENT_MASTER_SHIFT 43
5459 #define REG_FIFO_ELEMENT_MASTER_MASK 0xf
5460 #define REG_FIFO_ELEMENT_ERROR_SHIFT 47
5461 #define REG_FIFO_ELEMENT_ERROR_MASK 0x1f
5464 /* REG fifo error element */
5465 struct reg_fifo_err {
5467 const char *err_msg;
5470 /* IGU fifo element */
5471 struct igu_fifo_element {
5473 #define IGU_FIFO_ELEMENT_DWORD0_FID_SHIFT 0
5474 #define IGU_FIFO_ELEMENT_DWORD0_FID_MASK 0xff
5475 #define IGU_FIFO_ELEMENT_DWORD0_IS_PF_SHIFT 8
5476 #define IGU_FIFO_ELEMENT_DWORD0_IS_PF_MASK 0x1
5477 #define IGU_FIFO_ELEMENT_DWORD0_SOURCE_SHIFT 9
5478 #define IGU_FIFO_ELEMENT_DWORD0_SOURCE_MASK 0xf
5479 #define IGU_FIFO_ELEMENT_DWORD0_ERR_TYPE_SHIFT 13
5480 #define IGU_FIFO_ELEMENT_DWORD0_ERR_TYPE_MASK 0xf
5481 #define IGU_FIFO_ELEMENT_DWORD0_CMD_ADDR_SHIFT 17
5482 #define IGU_FIFO_ELEMENT_DWORD0_CMD_ADDR_MASK 0x7fff
5485 #define IGU_FIFO_ELEMENT_DWORD12_IS_WR_CMD_SHIFT 0
5486 #define IGU_FIFO_ELEMENT_DWORD12_IS_WR_CMD_MASK 0x1
5487 #define IGU_FIFO_ELEMENT_DWORD12_WR_DATA_SHIFT 1
5488 #define IGU_FIFO_ELEMENT_DWORD12_WR_DATA_MASK 0xffffffff
5492 struct igu_fifo_wr_data {
5494 #define IGU_FIFO_WR_DATA_PROD_CONS_SHIFT 0
5495 #define IGU_FIFO_WR_DATA_PROD_CONS_MASK 0xffffff
5496 #define IGU_FIFO_WR_DATA_UPDATE_FLAG_SHIFT 24
5497 #define IGU_FIFO_WR_DATA_UPDATE_FLAG_MASK 0x1
5498 #define IGU_FIFO_WR_DATA_EN_DIS_INT_FOR_SB_SHIFT 25
5499 #define IGU_FIFO_WR_DATA_EN_DIS_INT_FOR_SB_MASK 0x3
5500 #define IGU_FIFO_WR_DATA_SEGMENT_SHIFT 27
5501 #define IGU_FIFO_WR_DATA_SEGMENT_MASK 0x1
5502 #define IGU_FIFO_WR_DATA_TIMER_MASK_SHIFT 28
5503 #define IGU_FIFO_WR_DATA_TIMER_MASK_MASK 0x1
5504 #define IGU_FIFO_WR_DATA_CMD_TYPE_SHIFT 31
5505 #define IGU_FIFO_WR_DATA_CMD_TYPE_MASK 0x1
5508 struct igu_fifo_cleanup_wr_data {
5510 #define IGU_FIFO_CLEANUP_WR_DATA_RESERVED_SHIFT 0
5511 #define IGU_FIFO_CLEANUP_WR_DATA_RESERVED_MASK 0x7ffffff
5512 #define IGU_FIFO_CLEANUP_WR_DATA_CLEANUP_VAL_SHIFT 27
5513 #define IGU_FIFO_CLEANUP_WR_DATA_CLEANUP_VAL_MASK 0x1
5514 #define IGU_FIFO_CLEANUP_WR_DATA_CLEANUP_TYPE_SHIFT 28
5515 #define IGU_FIFO_CLEANUP_WR_DATA_CLEANUP_TYPE_MASK 0x7
5516 #define IGU_FIFO_CLEANUP_WR_DATA_CMD_TYPE_SHIFT 31
5517 #define IGU_FIFO_CLEANUP_WR_DATA_CMD_TYPE_MASK 0x1
5520 /* Protection override element */
5521 struct protection_override_element {
5523 #define PROTECTION_OVERRIDE_ELEMENT_ADDRESS_SHIFT 0
5524 #define PROTECTION_OVERRIDE_ELEMENT_ADDRESS_MASK 0x7fffff
5525 #define PROTECTION_OVERRIDE_ELEMENT_WINDOW_SIZE_SHIFT 23
5526 #define PROTECTION_OVERRIDE_ELEMENT_WINDOW_SIZE_MASK 0xffffff
5527 #define PROTECTION_OVERRIDE_ELEMENT_READ_SHIFT 47
5528 #define PROTECTION_OVERRIDE_ELEMENT_READ_MASK 0x1
5529 #define PROTECTION_OVERRIDE_ELEMENT_WRITE_SHIFT 48
5530 #define PROTECTION_OVERRIDE_ELEMENT_WRITE_MASK 0x1
5531 #define PROTECTION_OVERRIDE_ELEMENT_READ_PROTECTION_SHIFT 49
5532 #define PROTECTION_OVERRIDE_ELEMENT_READ_PROTECTION_MASK 0x7
5533 #define PROTECTION_OVERRIDE_ELEMENT_WRITE_PROTECTION_SHIFT 52
5534 #define PROTECTION_OVERRIDE_ELEMENT_WRITE_PROTECTION_MASK 0x7
5537 enum igu_fifo_sources {
5551 enum igu_fifo_addr_types {
5552 IGU_ADDR_TYPE_MSIX_MEM,
5553 IGU_ADDR_TYPE_WRITE_PBA,
5554 IGU_ADDR_TYPE_WRITE_INT_ACK,
5555 IGU_ADDR_TYPE_WRITE_ATTN_BITS,
5556 IGU_ADDR_TYPE_READ_INT,
5557 IGU_ADDR_TYPE_WRITE_PROD_UPDATE,
5558 IGU_ADDR_TYPE_RESERVED
5561 struct igu_fifo_addr_data {
5565 const char *vf_desc;
5566 enum igu_fifo_addr_types type;
5569 /******************************** Constants **********************************/
5571 #define MAX_MSG_LEN 1024
5573 #define MCP_TRACE_MAX_MODULE_LEN 8
5574 #define MCP_TRACE_FORMAT_MAX_PARAMS 3
5575 #define MCP_TRACE_FORMAT_PARAM_WIDTH \
5576 (MCP_TRACE_FORMAT_P2_SIZE_OFFSET - MCP_TRACE_FORMAT_P1_SIZE_OFFSET)
5578 #define REG_FIFO_ELEMENT_ADDR_FACTOR 4
5579 #define REG_FIFO_ELEMENT_IS_PF_VF_VAL 127
5581 #define PROTECTION_OVERRIDE_ELEMENT_ADDR_FACTOR 4
5583 /***************************** Constant Arrays *******************************/
5585 /* Status string array */
5586 static const char * const s_status_str[] = {
5588 "Operation completed successfully",
5590 /* DBG_STATUS_APP_VERSION_NOT_SET */
5591 "Debug application version wasn't set",
5593 /* DBG_STATUS_UNSUPPORTED_APP_VERSION */
5594 "Unsupported debug application version",
5596 /* DBG_STATUS_DBG_BLOCK_NOT_RESET */
5597 "The debug block wasn't reset since the last recording",
5599 /* DBG_STATUS_INVALID_ARGS */
5600 "Invalid arguments",
5602 /* DBG_STATUS_OUTPUT_ALREADY_SET */
5603 "The debug output was already set",
5605 /* DBG_STATUS_INVALID_PCI_BUF_SIZE */
5606 "Invalid PCI buffer size",
5608 /* DBG_STATUS_PCI_BUF_ALLOC_FAILED */
5609 "PCI buffer allocation failed",
5611 /* DBG_STATUS_PCI_BUF_NOT_ALLOCATED */
5612 "A PCI buffer wasn't allocated",
5614 /* DBG_STATUS_INVALID_FILTER_TRIGGER_DWORDS */
5615 "The filter/trigger constraint dword offsets are not enabled for recording",
5618 /* DBG_STATUS_VFC_READ_ERROR */
5619 "Error reading from VFC",
5621 /* DBG_STATUS_STORM_ALREADY_ENABLED */
5622 "The Storm was already enabled",
5624 /* DBG_STATUS_STORM_NOT_ENABLED */
5625 "The specified Storm wasn't enabled",
5627 /* DBG_STATUS_BLOCK_ALREADY_ENABLED */
5628 "The block was already enabled",
5630 /* DBG_STATUS_BLOCK_NOT_ENABLED */
5631 "The specified block wasn't enabled",
5633 /* DBG_STATUS_NO_INPUT_ENABLED */
5634 "No input was enabled for recording",
5636 /* DBG_STATUS_NO_FILTER_TRIGGER_256B */
5637 "Filters and triggers are not allowed in E4 256-bit mode",
5639 /* DBG_STATUS_FILTER_ALREADY_ENABLED */
5640 "The filter was already enabled",
5642 /* DBG_STATUS_TRIGGER_ALREADY_ENABLED */
5643 "The trigger was already enabled",
5645 /* DBG_STATUS_TRIGGER_NOT_ENABLED */
5646 "The trigger wasn't enabled",
5648 /* DBG_STATUS_CANT_ADD_CONSTRAINT */
5649 "A constraint can be added only after a filter was enabled or a trigger state was added",
5651 /* DBG_STATUS_TOO_MANY_TRIGGER_STATES */
5652 "Cannot add more than 3 trigger states",
5654 /* DBG_STATUS_TOO_MANY_CONSTRAINTS */
5655 "Cannot add more than 4 constraints per filter or trigger state",
5657 /* DBG_STATUS_RECORDING_NOT_STARTED */
5658 "The recording wasn't started",
5660 /* DBG_STATUS_DATA_DID_NOT_TRIGGER */
5661 "A trigger was configured, but it didn't trigger",
5663 /* DBG_STATUS_NO_DATA_RECORDED */
5664 "No data was recorded",
5666 /* DBG_STATUS_DUMP_BUF_TOO_SMALL */
5667 "Dump buffer is too small",
5669 /* DBG_STATUS_DUMP_NOT_CHUNK_ALIGNED */
5670 "Dumped data is not aligned to chunks",
5672 /* DBG_STATUS_UNKNOWN_CHIP */
5675 /* DBG_STATUS_VIRT_MEM_ALLOC_FAILED */
5676 "Failed allocating virtual memory",
5678 /* DBG_STATUS_BLOCK_IN_RESET */
5679 "The input block is in reset",
5681 /* DBG_STATUS_INVALID_TRACE_SIGNATURE */
5682 "Invalid MCP trace signature found in NVRAM",
5684 /* DBG_STATUS_INVALID_NVRAM_BUNDLE */
5685 "Invalid bundle ID found in NVRAM",
5687 /* DBG_STATUS_NVRAM_GET_IMAGE_FAILED */
5688 "Failed getting NVRAM image",
5690 /* DBG_STATUS_NON_ALIGNED_NVRAM_IMAGE */
5691 "NVRAM image is not dword-aligned",
5693 /* DBG_STATUS_NVRAM_READ_FAILED */
5694 "Failed reading from NVRAM",
5696 /* DBG_STATUS_IDLE_CHK_PARSE_FAILED */
5697 "Idle check parsing failed",
5699 /* DBG_STATUS_MCP_TRACE_BAD_DATA */
5700 "MCP Trace data is corrupt",
5702 /* DBG_STATUS_MCP_TRACE_NO_META */
5703 "Dump doesn't contain meta data - it must be provided in image file",
5705 /* DBG_STATUS_MCP_COULD_NOT_HALT */
5706 "Failed to halt MCP",
5708 /* DBG_STATUS_MCP_COULD_NOT_RESUME */
5709 "Failed to resume MCP after halt",
5711 /* DBG_STATUS_RESERVED0 */
5714 /* DBG_STATUS_SEMI_FIFO_NOT_EMPTY */
5715 "Failed to empty SEMI sync FIFO",
5717 /* DBG_STATUS_IGU_FIFO_BAD_DATA */
5718 "IGU FIFO data is corrupt",
5720 /* DBG_STATUS_MCP_COULD_NOT_MASK_PRTY */
5721 "MCP failed to mask parities",
5723 /* DBG_STATUS_FW_ASSERTS_PARSE_FAILED */
5724 "FW Asserts parsing failed",
5726 /* DBG_STATUS_REG_FIFO_BAD_DATA */
5727 "GRC FIFO data is corrupt",
5729 /* DBG_STATUS_PROTECTION_OVERRIDE_BAD_DATA */
5730 "Protection Override data is corrupt",
5732 /* DBG_STATUS_DBG_ARRAY_NOT_SET */
5733 "Debug arrays were not set (when using binary files, dbg_set_bin_ptr must be called)",
5735 /* DBG_STATUS_RESERVED1 */
5738 /* DBG_STATUS_NON_MATCHING_LINES */
5739 "Non-matching debug lines - in E4, all lines must be of the same type (either 128b or 256b)",
5741 /* DBG_STATUS_INSUFFICIENT_HW_IDS */
5742 "Insufficient HW IDs. Try to record less Storms/blocks",
5744 /* DBG_STATUS_DBG_BUS_IN_USE */
5745 "The debug bus is in use",
5747 /* DBG_STATUS_INVALID_STORM_DBG_MODE */
5748 "The storm debug mode is not supported in the current chip",
5750 /* DBG_STATUS_OTHER_ENGINE_BB_ONLY */
5751 "Other engine is supported only in BB",
5753 /* DBG_STATUS_FILTER_SINGLE_HW_ID */
5754 "The configured filter mode requires a single Storm/block input",
5756 /* DBG_STATUS_TRIGGER_SINGLE_HW_ID */
5757 "The configured filter mode requires that all the constraints of a single trigger state will be defined on a single Storm/block input",
5759 /* DBG_STATUS_MISSING_TRIGGER_STATE_STORM */
5760 "When triggering on Storm data, the Storm to trigger on must be specified"
5763 /* Idle check severity names array */
5764 static const char * const s_idle_chk_severity_str[] = {
5766 "Error if no traffic",
5770 /* MCP Trace level names array */
5771 static const char * const s_mcp_trace_level_str[] = {
5777 /* Access type names array */
5778 static const char * const s_access_strs[] = {
5783 /* Privilege type names array */
5784 static const char * const s_privilege_strs[] = {
5791 /* Protection type names array */
5792 static const char * const s_protection_strs[] = {
5803 /* Master type names array */
5804 static const char * const s_master_strs[] = {
5823 /* REG FIFO error messages array */
5824 static struct reg_fifo_err s_reg_fifo_errors[] = {
5826 {2, "address doesn't belong to any block"},
5827 {4, "reserved address in block or write to read-only address"},
5828 {8, "privilege/protection mismatch"},
5829 {16, "path isolation error"},
5833 /* IGU FIFO sources array */
5834 static const char * const s_igu_fifo_source_strs[] = {
5848 /* IGU FIFO error messages */
5849 static const char * const s_igu_fifo_error_strs[] = {
5852 "function disabled",
5853 "VF sent command to attention address",
5854 "host sent prod update command",
5855 "read of during interrupt register while in MIMD mode",
5856 "access to PXP BAR reserved address",
5857 "producer update command to attention index",
5859 "SB index not valid",
5860 "SB relative index and FID not found",
5862 "command with error flag asserted (PCI error or CAU discard)",
5863 "VF sent cleanup and RF cleanup is disabled",
5864 "cleanup command on type bigger than 4"
5867 /* IGU FIFO address data */
5868 static const struct igu_fifo_addr_data s_igu_fifo_addr_data[] = {
5869 {0x0, 0x101, "MSI-X Memory", NULL,
5870 IGU_ADDR_TYPE_MSIX_MEM},
5871 {0x102, 0x1ff, "reserved", NULL,
5872 IGU_ADDR_TYPE_RESERVED},
5873 {0x200, 0x200, "Write PBA[0:63]", NULL,
5874 IGU_ADDR_TYPE_WRITE_PBA},
5875 {0x201, 0x201, "Write PBA[64:127]", "reserved",
5876 IGU_ADDR_TYPE_WRITE_PBA},
5877 {0x202, 0x202, "Write PBA[128]", "reserved",
5878 IGU_ADDR_TYPE_WRITE_PBA},
5879 {0x203, 0x3ff, "reserved", NULL,
5880 IGU_ADDR_TYPE_RESERVED},
5881 {0x400, 0x5ef, "Write interrupt acknowledgment", NULL,
5882 IGU_ADDR_TYPE_WRITE_INT_ACK},
5883 {0x5f0, 0x5f0, "Attention bits update", NULL,
5884 IGU_ADDR_TYPE_WRITE_ATTN_BITS},
5885 {0x5f1, 0x5f1, "Attention bits set", NULL,
5886 IGU_ADDR_TYPE_WRITE_ATTN_BITS},
5887 {0x5f2, 0x5f2, "Attention bits clear", NULL,
5888 IGU_ADDR_TYPE_WRITE_ATTN_BITS},
5889 {0x5f3, 0x5f3, "Read interrupt 0:63 with mask", NULL,
5890 IGU_ADDR_TYPE_READ_INT},
5891 {0x5f4, 0x5f4, "Read interrupt 0:31 with mask", NULL,
5892 IGU_ADDR_TYPE_READ_INT},
5893 {0x5f5, 0x5f5, "Read interrupt 32:63 with mask", NULL,
5894 IGU_ADDR_TYPE_READ_INT},
5895 {0x5f6, 0x5f6, "Read interrupt 0:63 without mask", NULL,
5896 IGU_ADDR_TYPE_READ_INT},
5897 {0x5f7, 0x5ff, "reserved", NULL,
5898 IGU_ADDR_TYPE_RESERVED},
5899 {0x600, 0x7ff, "Producer update", NULL,
5900 IGU_ADDR_TYPE_WRITE_PROD_UPDATE}
5903 /******************************** Variables **********************************/
5905 /* Temporary buffer, used for print size calculations */
5906 static char s_temp_buf[MAX_MSG_LEN];
5908 /**************************** Private Functions ******************************/
5910 static u32 qed_cyclic_add(u32 a, u32 b, u32 size)
5912 return (a + b) % size;
5915 static u32 qed_cyclic_sub(u32 a, u32 b, u32 size)
5917 return (size + a - b) % size;
5920 /* Reads the specified number of bytes from the specified cyclic buffer (up to 4
5921 * bytes) and returns them as a dword value. the specified buffer offset is
5924 static u32 qed_read_from_cyclic_buf(void *buf,
5926 u32 buf_size, u8 num_bytes_to_read)
5928 u8 i, *val_ptr, *bytes_buf = (u8 *)buf;
5931 val_ptr = (u8 *)&val;
5933 /* Assume running on a LITTLE ENDIAN and the buffer is network order
5934 * (BIG ENDIAN), as high order bytes are placed in lower memory address.
5936 for (i = 0; i < num_bytes_to_read; i++) {
5937 val_ptr[i] = bytes_buf[*offset];
5938 *offset = qed_cyclic_add(*offset, 1, buf_size);
5944 /* Reads and returns the next byte from the specified buffer.
5945 * The specified buffer offset is updated.
5947 static u8 qed_read_byte_from_buf(void *buf, u32 *offset)
5949 return ((u8 *)buf)[(*offset)++];
5952 /* Reads and returns the next dword from the specified buffer.
5953 * The specified buffer offset is updated.
5955 static u32 qed_read_dword_from_buf(void *buf, u32 *offset)
5957 u32 dword_val = *(u32 *)&((u8 *)buf)[*offset];
5964 /* Reads the next string from the specified buffer, and copies it to the
5965 * specified pointer. The specified buffer offset is updated.
5967 static void qed_read_str_from_buf(void *buf, u32 *offset, u32 size, char *dest)
5969 const char *source_str = &((const char *)buf)[*offset];
5971 OSAL_STRNCPY(dest, source_str, size);
5972 dest[size - 1] = '\0';
5976 /* Returns a pointer to the specified offset (in bytes) of the specified buffer.
5977 * If the specified buffer in NULL, a temporary buffer pointer is returned.
5979 static char *qed_get_buf_ptr(void *buf, u32 offset)
5981 return buf ? (char *)buf + offset : s_temp_buf;
5984 /* Reads a param from the specified buffer. Returns the number of dwords read.
5985 * If the returned str_param is NULL, the param is numeric and its value is
5986 * returned in num_param.
5987 * Otherwise, the param is a string and its pointer is returned in str_param.
5989 static u32 qed_read_param(u32 *dump_buf,
5990 const char **param_name,
5991 const char **param_str_val, u32 *param_num_val)
5993 char *char_buf = (char *)dump_buf;
5996 /* Extract param name */
5997 *param_name = char_buf;
5998 offset += strlen(*param_name) + 1;
6000 /* Check param type */
6001 if (*(char_buf + offset++)) {
6003 *param_str_val = char_buf + offset;
6005 offset += strlen(*param_str_val) + 1;
6007 offset += (4 - (offset & 0x3));
6010 *param_str_val = NULL;
6012 offset += (4 - (offset & 0x3));
6013 *param_num_val = *(u32 *)(char_buf + offset);
6017 return (u32)offset / 4;
6020 /* Reads a section header from the specified buffer.
6021 * Returns the number of dwords read.
6023 static u32 qed_read_section_hdr(u32 *dump_buf,
6024 const char **section_name,
6025 u32 *num_section_params)
6027 const char *param_str_val;
6029 return qed_read_param(dump_buf,
6030 section_name, ¶m_str_val, num_section_params);
6033 /* Reads section params from the specified buffer and prints them to the results
6034 * buffer. Returns the number of dwords read.
6036 static u32 qed_print_section_params(u32 *dump_buf,
6037 u32 num_section_params,
6038 char *results_buf, u32 *num_chars_printed)
6040 u32 i, dump_offset = 0, results_offset = 0;
6042 for (i = 0; i < num_section_params; i++) {
6043 const char *param_name, *param_str_val;
6044 u32 param_num_val = 0;
6046 dump_offset += qed_read_param(dump_buf + dump_offset,
6048 ¶m_str_val, ¶m_num_val);
6050 if (param_str_val) {
6052 sprintf(qed_get_buf_ptr(results_buf,
6054 "%s: %s\n", param_name, param_str_val);
6055 } else if (strcmp(param_name, "fw-timestamp")) {
6057 sprintf(qed_get_buf_ptr(results_buf,
6059 "%s: %d\n", param_name, param_num_val);
6063 results_offset += sprintf(qed_get_buf_ptr(results_buf, results_offset),
6066 *num_chars_printed = results_offset;
6071 /* Returns the block name that matches the specified block ID,
6072 * or NULL if not found.
6074 static const char *qed_dbg_get_block_name(struct ecore_hwfn *p_hwfn,
6075 enum block_id block_id)
6077 const struct dbg_block_user *block =
6078 (const struct dbg_block_user *)
6079 p_hwfn->dbg_arrays[BIN_BUF_DBG_BLOCKS_USER_DATA].ptr + block_id;
6081 return (const char *)block->name;
6084 static struct dbg_tools_user_data *qed_dbg_get_user_data(struct ecore_hwfn
6087 return (struct dbg_tools_user_data *)p_hwfn->dbg_user_info;
6090 /* Parses the idle check rules and returns the number of characters printed.
6091 * In case of parsing error, returns 0.
6093 static u32 qed_parse_idle_chk_dump_rules(struct ecore_hwfn *p_hwfn,
6097 bool print_fw_idle_chk,
6099 u32 *num_errors, u32 *num_warnings)
6101 /* Offset in results_buf in bytes */
6102 u32 results_offset = 0;
6110 /* Go over dumped results */
6111 for (rule_idx = 0; rule_idx < num_rules && dump_buf < dump_buf_end;
6113 const struct dbg_idle_chk_rule_parsing_data *rule_parsing_data;
6114 struct dbg_idle_chk_result_hdr *hdr;
6115 const char *parsing_str, *lsi_msg;
6116 u32 parsing_str_offset;
6120 hdr = (struct dbg_idle_chk_result_hdr *)dump_buf;
6122 (const struct dbg_idle_chk_rule_parsing_data *)
6123 p_hwfn->dbg_arrays[BIN_BUF_DBG_IDLE_CHK_PARSING_DATA].ptr +
6125 parsing_str_offset =
6126 GET_FIELD(rule_parsing_data->data,
6127 DBG_IDLE_CHK_RULE_PARSING_DATA_STR_OFFSET);
6129 GET_FIELD(rule_parsing_data->data,
6130 DBG_IDLE_CHK_RULE_PARSING_DATA_HAS_FW_MSG) > 0;
6131 parsing_str = (const char *)
6132 p_hwfn->dbg_arrays[BIN_BUF_DBG_PARSING_STRINGS].ptr +
6134 lsi_msg = parsing_str;
6137 if (hdr->severity >= MAX_DBG_IDLE_CHK_SEVERITY_TYPES)
6140 /* Skip rule header */
6141 dump_buf += BYTES_TO_DWORDS(sizeof(*hdr));
6143 /* Update errors/warnings count */
6144 if (hdr->severity == IDLE_CHK_SEVERITY_ERROR ||
6145 hdr->severity == IDLE_CHK_SEVERITY_ERROR_NO_TRAFFIC)
6150 /* Print rule severity */
6152 sprintf(qed_get_buf_ptr(results_buf,
6153 results_offset), "%s: ",
6154 s_idle_chk_severity_str[hdr->severity]);
6156 /* Print rule message */
6158 parsing_str += strlen(parsing_str) + 1;
6160 sprintf(qed_get_buf_ptr(results_buf,
6161 results_offset), "%s.",
6163 print_fw_idle_chk ? parsing_str : lsi_msg);
6164 parsing_str += strlen(parsing_str) + 1;
6166 /* Print register values */
6168 sprintf(qed_get_buf_ptr(results_buf,
6169 results_offset), " Registers:");
6171 i < hdr->num_dumped_cond_regs + hdr->num_dumped_info_regs;
6173 struct dbg_idle_chk_result_reg_hdr *reg_hdr;
6178 (struct dbg_idle_chk_result_reg_hdr *)dump_buf;
6179 is_mem = GET_FIELD(reg_hdr->data,
6180 DBG_IDLE_CHK_RESULT_REG_HDR_IS_MEM);
6181 reg_id = GET_FIELD(reg_hdr->data,
6182 DBG_IDLE_CHK_RESULT_REG_HDR_REG_ID);
6184 /* Skip reg header */
6185 dump_buf += BYTES_TO_DWORDS(sizeof(*reg_hdr));
6187 /* Skip register names until the required reg_id is
6190 while (reg_id > curr_reg_id) {
6192 parsing_str += strlen(parsing_str) + 1;
6196 sprintf(qed_get_buf_ptr(results_buf,
6197 results_offset), " %s",
6199 if (i < hdr->num_dumped_cond_regs && is_mem)
6201 sprintf(qed_get_buf_ptr(results_buf,
6203 "[%d]", hdr->mem_entry_id +
6204 reg_hdr->start_entry);
6206 sprintf(qed_get_buf_ptr(results_buf,
6207 results_offset), "=");
6208 for (j = 0; j < reg_hdr->size; j++, dump_buf++) {
6210 sprintf(qed_get_buf_ptr(results_buf,
6213 if (j < reg_hdr->size - 1)
6215 sprintf(qed_get_buf_ptr
6217 results_offset), ",");
6222 sprintf(qed_get_buf_ptr(results_buf, results_offset), "\n");
6225 /* Check if end of dump buffer was exceeded */
6226 if (dump_buf > dump_buf_end)
6229 return results_offset;
6232 /* Parses an idle check dump buffer.
6233 * If result_buf is not NULL, the idle check results are printed to it.
6234 * In any case, the required results buffer size is assigned to
6235 * parsed_results_bytes.
6236 * The parsing status is returned.
6238 static enum dbg_status qed_parse_idle_chk_dump(struct ecore_hwfn *p_hwfn,
6240 u32 num_dumped_dwords,
6242 u32 *parsed_results_bytes,
6246 const char *section_name, *param_name, *param_str_val;
6247 u32 *dump_buf_end = dump_buf + num_dumped_dwords;
6248 u32 num_section_params = 0, num_rules;
6250 /* Offset in results_buf in bytes */
6251 u32 results_offset = 0;
6253 *parsed_results_bytes = 0;
6257 if (!p_hwfn->dbg_arrays[BIN_BUF_DBG_PARSING_STRINGS].ptr ||
6258 !p_hwfn->dbg_arrays[BIN_BUF_DBG_IDLE_CHK_PARSING_DATA].ptr)
6259 return DBG_STATUS_DBG_ARRAY_NOT_SET;
6261 /* Read global_params section */
6262 dump_buf += qed_read_section_hdr(dump_buf,
6263 §ion_name, &num_section_params);
6264 if (strcmp(section_name, "global_params"))
6265 return DBG_STATUS_IDLE_CHK_PARSE_FAILED;
6267 /* Print global params */
6268 dump_buf += qed_print_section_params(dump_buf,
6270 results_buf, &results_offset);
6272 /* Read idle_chk section */
6273 dump_buf += qed_read_section_hdr(dump_buf,
6274 §ion_name, &num_section_params);
6275 if (strcmp(section_name, "idle_chk") || num_section_params != 1)
6276 return DBG_STATUS_IDLE_CHK_PARSE_FAILED;
6277 dump_buf += qed_read_param(dump_buf,
6278 ¶m_name, ¶m_str_val, &num_rules);
6279 if (strcmp(param_name, "num_rules"))
6280 return DBG_STATUS_IDLE_CHK_PARSE_FAILED;
6283 u32 rules_print_size;
6285 /* Print FW output */
6287 sprintf(qed_get_buf_ptr(results_buf,
6289 "FW_IDLE_CHECK:\n");
6291 qed_parse_idle_chk_dump_rules(p_hwfn,
6302 results_offset += rules_print_size;
6303 if (!rules_print_size)
6304 return DBG_STATUS_IDLE_CHK_PARSE_FAILED;
6306 /* Print LSI output */
6308 sprintf(qed_get_buf_ptr(results_buf,
6310 "\nLSI_IDLE_CHECK:\n");
6312 qed_parse_idle_chk_dump_rules(p_hwfn,
6323 results_offset += rules_print_size;
6324 if (!rules_print_size)
6325 return DBG_STATUS_IDLE_CHK_PARSE_FAILED;
6328 /* Print errors/warnings count */
6331 sprintf(qed_get_buf_ptr(results_buf,
6333 "\nIdle Check failed!!! (with %d errors and %d warnings)\n",
6334 *num_errors, *num_warnings);
6335 else if (*num_warnings)
6337 sprintf(qed_get_buf_ptr(results_buf,
6339 "\nIdle Check completed successfully (with %d warnings)\n",
6343 sprintf(qed_get_buf_ptr(results_buf,
6345 "\nIdle Check completed successfully\n");
6347 /* Add 1 for string NULL termination */
6348 *parsed_results_bytes = results_offset + 1;
6350 return DBG_STATUS_OK;
6353 /* Allocates and fills MCP Trace meta data based on the specified meta data
6355 * Returns debug status code.
6357 static enum dbg_status
6358 qed_mcp_trace_alloc_meta_data(struct ecore_hwfn *p_hwfn,
6359 const u32 *meta_buf)
6361 struct dbg_tools_user_data *dev_user_data;
6362 u32 offset = 0, signature, i;
6363 struct mcp_trace_meta *meta;
6364 u8 *meta_buf_bytes = (u8 *)(osal_uintptr_t)meta_buf;
6366 dev_user_data = qed_dbg_get_user_data(p_hwfn);
6367 meta = &dev_user_data->mcp_trace_meta;
6369 /* Free the previous meta before loading a new one. */
6370 if (meta->is_allocated)
6371 qed_mcp_trace_free_meta_data(p_hwfn);
6373 OSAL_MEMSET(meta, 0, sizeof(*meta));
6375 /* Read first signature */
6376 signature = qed_read_dword_from_buf(meta_buf_bytes, &offset);
6377 if (signature != NVM_MAGIC_VALUE)
6378 return DBG_STATUS_INVALID_TRACE_SIGNATURE;
6380 /* Read no. of modules and allocate memory for their pointers */
6381 meta->modules_num = qed_read_byte_from_buf(meta_buf_bytes, &offset);
6382 meta->modules = (char **)OSAL_ZALLOC(p_hwfn->p_dev, GFP_KERNEL,
6383 meta->modules_num * sizeof(char *));
6385 return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
6387 /* Allocate and read all module strings */
6388 for (i = 0; i < meta->modules_num; i++) {
6389 u8 module_len = qed_read_byte_from_buf(meta_buf_bytes, &offset);
6391 *(meta->modules + i) = (char *)OSAL_ZALLOC(p_hwfn->p_dev,
6394 if (!(*(meta->modules + i))) {
6395 /* Update number of modules to be released */
6396 meta->modules_num = i ? i - 1 : 0;
6397 return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
6400 qed_read_str_from_buf(meta_buf_bytes, &offset, module_len,
6401 *(meta->modules + i));
6402 if (module_len > MCP_TRACE_MAX_MODULE_LEN)
6403 (*(meta->modules + i))[MCP_TRACE_MAX_MODULE_LEN] = '\0';
6406 /* Read second signature */
6407 signature = qed_read_dword_from_buf(meta_buf_bytes, &offset);
6408 if (signature != NVM_MAGIC_VALUE)
6409 return DBG_STATUS_INVALID_TRACE_SIGNATURE;
6411 /* Read number of formats and allocate memory for all formats */
6412 meta->formats_num = qed_read_dword_from_buf(meta_buf_bytes, &offset);
6414 (struct mcp_trace_format *)OSAL_ZALLOC(p_hwfn->p_dev,
6417 sizeof(struct mcp_trace_format));
6419 return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
6421 /* Allocate and read all strings */
6422 for (i = 0; i < meta->formats_num; i++) {
6423 struct mcp_trace_format *format_ptr = &meta->formats[i];
6426 format_ptr->data = qed_read_dword_from_buf(meta_buf_bytes,
6428 format_len = GET_MFW_FIELD(format_ptr->data,
6429 MCP_TRACE_FORMAT_LEN);
6430 format_ptr->format_str = (char *)OSAL_ZALLOC(p_hwfn->p_dev,
6433 if (!format_ptr->format_str) {
6434 /* Update number of modules to be released */
6435 meta->formats_num = i ? i - 1 : 0;
6436 return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
6439 qed_read_str_from_buf(meta_buf_bytes,
6441 format_len, format_ptr->format_str);
6444 meta->is_allocated = true;
6445 return DBG_STATUS_OK;
6448 /* Parses an MCP trace buffer. If result_buf is not NULL, the MCP Trace results
6449 * are printed to it. The parsing status is returned.
6451 * trace_buf - MCP trace cyclic buffer
6452 * trace_buf_size - MCP trace cyclic buffer size in bytes
6453 * data_offset - offset in bytes of the data to parse in the MCP trace cyclic
6455 * data_size - size in bytes of data to parse.
6456 * parsed_buf - destination buffer for parsed data.
6457 * parsed_results_bytes - size of parsed data in bytes.
6459 static enum dbg_status qed_parse_mcp_trace_buf(struct ecore_hwfn *p_hwfn,
6465 u32 *parsed_results_bytes)
6467 struct dbg_tools_user_data *dev_user_data;
6468 struct mcp_trace_meta *meta;
6469 u32 param_mask, param_shift;
6470 enum dbg_status status;
6472 dev_user_data = qed_dbg_get_user_data(p_hwfn);
6473 meta = &dev_user_data->mcp_trace_meta;
6474 *parsed_results_bytes = 0;
6476 if (!meta->is_allocated)
6477 return DBG_STATUS_MCP_TRACE_BAD_DATA;
6479 status = DBG_STATUS_OK;
6482 struct mcp_trace_format *format_ptr;
6483 u8 format_level, format_module;
6484 u32 params[3] = { 0, 0, 0 };
6485 u32 header, format_idx, i;
6487 if (data_size < MFW_TRACE_ENTRY_SIZE)
6488 return DBG_STATUS_MCP_TRACE_BAD_DATA;
6490 header = qed_read_from_cyclic_buf(trace_buf,
6493 MFW_TRACE_ENTRY_SIZE);
6494 data_size -= MFW_TRACE_ENTRY_SIZE;
6495 format_idx = header & MFW_TRACE_EVENTID_MASK;
6497 /* Skip message if its index doesn't exist in the meta data */
6498 if (format_idx >= meta->formats_num) {
6499 u8 format_size = (u8)GET_MFW_FIELD(header,
6500 MFW_TRACE_PRM_SIZE);
6502 if (data_size < format_size)
6503 return DBG_STATUS_MCP_TRACE_BAD_DATA;
6505 data_offset = qed_cyclic_add(data_offset,
6508 data_size -= format_size;
6513 (struct mcp_trace_format *)&meta->formats[format_idx];
6516 param_mask = MCP_TRACE_FORMAT_P1_SIZE_MASK, param_shift =
6517 MCP_TRACE_FORMAT_P1_SIZE_OFFSET;
6518 i < MCP_TRACE_FORMAT_MAX_PARAMS;
6519 i++, param_mask <<= MCP_TRACE_FORMAT_PARAM_WIDTH,
6520 param_shift += MCP_TRACE_FORMAT_PARAM_WIDTH) {
6521 /* Extract param size (0..3) */
6522 u8 param_size = (u8)((format_ptr->data & param_mask) >>
6525 /* If the param size is zero, there are no other
6531 /* Size is encoded using 2 bits, where 3 is used to
6534 if (param_size == 3)
6537 if (data_size < param_size)
6538 return DBG_STATUS_MCP_TRACE_BAD_DATA;
6540 params[i] = qed_read_from_cyclic_buf(trace_buf,
6544 data_size -= param_size;
6547 format_level = (u8)GET_MFW_FIELD(format_ptr->data,
6548 MCP_TRACE_FORMAT_LEVEL);
6549 format_module = (u8)GET_MFW_FIELD(format_ptr->data,
6550 MCP_TRACE_FORMAT_MODULE);
6551 if (format_level >= OSAL_ARRAY_SIZE(s_mcp_trace_level_str))
6552 return DBG_STATUS_MCP_TRACE_BAD_DATA;
6554 /* Print current message to results buffer */
6555 *parsed_results_bytes +=
6556 OSAL_SPRINTF(qed_get_buf_ptr(parsed_buf,
6557 *parsed_results_bytes),
6559 s_mcp_trace_level_str[format_level],
6560 meta->modules[format_module]);
6561 *parsed_results_bytes +=
6562 sprintf(qed_get_buf_ptr(parsed_buf, *parsed_results_bytes),
6563 format_ptr->format_str,
6564 params[0], params[1], params[2]);
6567 /* Add string NULL terminator */
6568 (*parsed_results_bytes)++;
6573 /* Parses an MCP Trace dump buffer.
6574 * If result_buf is not NULL, the MCP Trace results are printed to it.
6575 * In any case, the required results buffer size is assigned to
6576 * parsed_results_bytes.
6577 * The parsing status is returned.
6579 static enum dbg_status qed_parse_mcp_trace_dump(struct ecore_hwfn *p_hwfn,
6582 u32 *parsed_results_bytes,
6583 bool free_meta_data)
6585 const char *section_name, *param_name, *param_str_val;
6586 u32 data_size, trace_data_dwords, trace_meta_dwords;
6587 u32 offset, results_offset, results_buf_bytes;
6588 u32 param_num_val, num_section_params;
6589 struct mcp_trace *trace;
6590 enum dbg_status status;
6591 const u32 *meta_buf;
6594 *parsed_results_bytes = 0;
6596 /* Read global_params section */
6597 dump_buf += qed_read_section_hdr(dump_buf,
6598 §ion_name, &num_section_params);
6599 if (strcmp(section_name, "global_params"))
6600 return DBG_STATUS_MCP_TRACE_BAD_DATA;
6602 /* Print global params */
6603 dump_buf += qed_print_section_params(dump_buf,
6605 results_buf, &results_offset);
6607 /* Read trace_data section */
6608 dump_buf += qed_read_section_hdr(dump_buf,
6609 §ion_name, &num_section_params);
6610 if (strcmp(section_name, "mcp_trace_data") || num_section_params != 1)
6611 return DBG_STATUS_MCP_TRACE_BAD_DATA;
6612 dump_buf += qed_read_param(dump_buf,
6613 ¶m_name, ¶m_str_val, ¶m_num_val);
6614 if (strcmp(param_name, "size"))
6615 return DBG_STATUS_MCP_TRACE_BAD_DATA;
6616 trace_data_dwords = param_num_val;
6618 /* Prepare trace info */
6619 trace = (struct mcp_trace *)dump_buf;
6620 if (trace->signature != MFW_TRACE_SIGNATURE || !trace->size)
6621 return DBG_STATUS_MCP_TRACE_BAD_DATA;
6623 trace_buf = (u8 *)dump_buf + sizeof(*trace);
6624 offset = trace->trace_oldest;
6625 data_size = qed_cyclic_sub(trace->trace_prod, offset, trace->size);
6626 dump_buf += trace_data_dwords;
6628 /* Read meta_data section */
6629 dump_buf += qed_read_section_hdr(dump_buf,
6630 §ion_name, &num_section_params);
6631 if (strcmp(section_name, "mcp_trace_meta"))
6632 return DBG_STATUS_MCP_TRACE_BAD_DATA;
6633 dump_buf += qed_read_param(dump_buf,
6634 ¶m_name, ¶m_str_val, ¶m_num_val);
6635 if (strcmp(param_name, "size"))
6636 return DBG_STATUS_MCP_TRACE_BAD_DATA;
6637 trace_meta_dwords = param_num_val;
6639 /* Choose meta data buffer */
6640 if (!trace_meta_dwords) {
6641 /* Dump doesn't include meta data */
6642 struct dbg_tools_user_data *dev_user_data =
6643 qed_dbg_get_user_data(p_hwfn);
6645 if (!dev_user_data->mcp_trace_user_meta_buf)
6646 return DBG_STATUS_MCP_TRACE_NO_META;
6648 meta_buf = dev_user_data->mcp_trace_user_meta_buf;
6650 /* Dump includes meta data */
6651 meta_buf = dump_buf;
6654 /* Allocate meta data memory */
6655 status = qed_mcp_trace_alloc_meta_data(p_hwfn, meta_buf);
6656 if (status != DBG_STATUS_OK)
6659 status = qed_parse_mcp_trace_buf(p_hwfn,
6665 results_buf + results_offset :
6667 &results_buf_bytes);
6668 if (status != DBG_STATUS_OK)
6672 qed_mcp_trace_free_meta_data(p_hwfn);
6674 *parsed_results_bytes = results_offset + results_buf_bytes;
6676 return DBG_STATUS_OK;
6679 /* Parses a Reg FIFO dump buffer.
6680 * If result_buf is not NULL, the Reg FIFO results are printed to it.
6681 * In any case, the required results buffer size is assigned to
6682 * parsed_results_bytes.
6683 * The parsing status is returned.
6685 static enum dbg_status qed_parse_reg_fifo_dump(u32 *dump_buf,
6687 u32 *parsed_results_bytes)
6689 const char *section_name, *param_name, *param_str_val;
6690 u32 param_num_val, num_section_params, num_elements;
6691 struct reg_fifo_element *elements;
6692 u8 i, j, err_code, vf_val;
6693 u32 results_offset = 0;
6696 /* Read global_params section */
6697 dump_buf += qed_read_section_hdr(dump_buf,
6698 §ion_name, &num_section_params);
6699 if (strcmp(section_name, "global_params"))
6700 return DBG_STATUS_REG_FIFO_BAD_DATA;
6702 /* Print global params */
6703 dump_buf += qed_print_section_params(dump_buf,
6705 results_buf, &results_offset);
6707 /* Read reg_fifo_data section */
6708 dump_buf += qed_read_section_hdr(dump_buf,
6709 §ion_name, &num_section_params);
6710 if (strcmp(section_name, "reg_fifo_data"))
6711 return DBG_STATUS_REG_FIFO_BAD_DATA;
6712 dump_buf += qed_read_param(dump_buf,
6713 ¶m_name, ¶m_str_val, ¶m_num_val);
6714 if (strcmp(param_name, "size"))
6715 return DBG_STATUS_REG_FIFO_BAD_DATA;
6716 if (param_num_val % REG_FIFO_ELEMENT_DWORDS)
6717 return DBG_STATUS_REG_FIFO_BAD_DATA;
6718 num_elements = param_num_val / REG_FIFO_ELEMENT_DWORDS;
6719 elements = (struct reg_fifo_element *)dump_buf;
6721 /* Decode elements */
6722 for (i = 0; i < num_elements; i++) {
6723 const char *err_msg = NULL;
6725 /* Discover if element belongs to a VF or a PF */
6726 vf_val = GET_FIELD(elements[i].data, REG_FIFO_ELEMENT_VF);
6727 if (vf_val == REG_FIFO_ELEMENT_IS_PF_VF_VAL)
6728 sprintf(vf_str, "%s", "N/A");
6730 sprintf(vf_str, "%d", vf_val);
6732 /* Find error message */
6733 err_code = GET_FIELD(elements[i].data, REG_FIFO_ELEMENT_ERROR);
6734 for (j = 0; j < OSAL_ARRAY_SIZE(s_reg_fifo_errors) && !err_msg;
6736 if (err_code == s_reg_fifo_errors[j].err_code)
6737 err_msg = s_reg_fifo_errors[j].err_msg;
6739 /* Add parsed element to parsed buffer */
6741 sprintf(qed_get_buf_ptr(results_buf,
6743 "raw: 0x%016"PRIx64", address: 0x%07x, access: %-5s, pf: %2d, vf: %s, "
6744 "port: %d, privilege: %-3s, protection: %-12s, master: %-4s, error: %s\n",
6746 (u32)GET_FIELD(elements[i].data,
6747 REG_FIFO_ELEMENT_ADDRESS) *
6748 REG_FIFO_ELEMENT_ADDR_FACTOR,
6749 s_access_strs[GET_FIELD(elements[i].data,
6750 REG_FIFO_ELEMENT_ACCESS)],
6751 (u32)GET_FIELD(elements[i].data,
6752 REG_FIFO_ELEMENT_PF),
6754 (u32)GET_FIELD(elements[i].data,
6755 REG_FIFO_ELEMENT_PORT),
6756 s_privilege_strs[GET_FIELD(elements[i].data,
6757 REG_FIFO_ELEMENT_PRIVILEGE)],
6758 s_protection_strs[GET_FIELD(elements[i].data,
6759 REG_FIFO_ELEMENT_PROTECTION)],
6760 s_master_strs[GET_FIELD(elements[i].data,
6761 REG_FIFO_ELEMENT_MASTER)],
6762 err_msg ? err_msg : "unknown error code");
6765 results_offset += sprintf(qed_get_buf_ptr(results_buf,
6767 "fifo contained %d elements", num_elements);
6769 /* Add 1 for string NULL termination */
6770 *parsed_results_bytes = results_offset + 1;
6772 return DBG_STATUS_OK;
6775 static enum dbg_status qed_parse_igu_fifo_element(struct igu_fifo_element
6778 u32 *results_offset)
6780 const struct igu_fifo_addr_data *found_addr = NULL;
6781 u8 source, err_type, i, is_cleanup;
6782 char parsed_addr_data[32];
6783 char parsed_wr_data[256];
6784 u32 wr_data, prod_cons;
6785 bool is_wr_cmd, is_pf;
6789 /* Dword12 (dword index 1 and 2) contains bits 32..95 of the
6792 dword12 = ((u64)element->dword2 << 32) | element->dword1;
6793 is_wr_cmd = GET_FIELD(dword12, IGU_FIFO_ELEMENT_DWORD12_IS_WR_CMD);
6794 is_pf = GET_FIELD(element->dword0, IGU_FIFO_ELEMENT_DWORD0_IS_PF);
6795 cmd_addr = GET_FIELD(element->dword0, IGU_FIFO_ELEMENT_DWORD0_CMD_ADDR);
6796 source = GET_FIELD(element->dword0, IGU_FIFO_ELEMENT_DWORD0_SOURCE);
6797 err_type = GET_FIELD(element->dword0, IGU_FIFO_ELEMENT_DWORD0_ERR_TYPE);
6799 if (source >= OSAL_ARRAY_SIZE(s_igu_fifo_source_strs))
6800 return DBG_STATUS_IGU_FIFO_BAD_DATA;
6801 if (err_type >= OSAL_ARRAY_SIZE(s_igu_fifo_error_strs))
6802 return DBG_STATUS_IGU_FIFO_BAD_DATA;
6804 /* Find address data */
6805 for (i = 0; i < OSAL_ARRAY_SIZE(s_igu_fifo_addr_data) && !found_addr;
6807 const struct igu_fifo_addr_data *curr_addr =
6808 &s_igu_fifo_addr_data[i];
6810 if (cmd_addr >= curr_addr->start_addr && cmd_addr <=
6811 curr_addr->end_addr)
6812 found_addr = curr_addr;
6816 return DBG_STATUS_IGU_FIFO_BAD_DATA;
6818 /* Prepare parsed address data */
6819 switch (found_addr->type) {
6820 case IGU_ADDR_TYPE_MSIX_MEM:
6821 sprintf(parsed_addr_data, " vector_num = 0x%x", cmd_addr / 2);
6823 case IGU_ADDR_TYPE_WRITE_INT_ACK:
6824 case IGU_ADDR_TYPE_WRITE_PROD_UPDATE:
6825 sprintf(parsed_addr_data,
6826 " SB = 0x%x", cmd_addr - found_addr->start_addr);
6829 parsed_addr_data[0] = '\0';
6833 parsed_wr_data[0] = '\0';
6837 /* Prepare parsed write data */
6838 wr_data = GET_FIELD(dword12, IGU_FIFO_ELEMENT_DWORD12_WR_DATA);
6839 prod_cons = GET_FIELD(wr_data, IGU_FIFO_WR_DATA_PROD_CONS);
6840 is_cleanup = GET_FIELD(wr_data, IGU_FIFO_WR_DATA_CMD_TYPE);
6842 if (source == IGU_SRC_ATTN) {
6843 sprintf(parsed_wr_data, "prod: 0x%x, ", prod_cons);
6846 u8 cleanup_val, cleanup_type;
6850 IGU_FIFO_CLEANUP_WR_DATA_CLEANUP_VAL);
6853 IGU_FIFO_CLEANUP_WR_DATA_CLEANUP_TYPE);
6855 sprintf(parsed_wr_data,
6856 "cmd_type: cleanup, cleanup_val: %s, cleanup_type : %d, ",
6857 cleanup_val ? "set" : "clear",
6860 u8 update_flag, en_dis_int_for_sb, segment;
6863 update_flag = GET_FIELD(wr_data,
6864 IGU_FIFO_WR_DATA_UPDATE_FLAG);
6867 IGU_FIFO_WR_DATA_EN_DIS_INT_FOR_SB);
6868 segment = GET_FIELD(wr_data,
6869 IGU_FIFO_WR_DATA_SEGMENT);
6870 timer_mask = GET_FIELD(wr_data,
6871 IGU_FIFO_WR_DATA_TIMER_MASK);
6873 sprintf(parsed_wr_data,
6874 "cmd_type: prod/cons update, prod/cons: 0x%x, update_flag: %s, en_dis_int_for_sb : %s, segment : %s, timer_mask = %d, ",
6876 update_flag ? "update" : "nop",
6878 (en_dis_int_for_sb == 1 ? "disable" : "nop") :
6880 segment ? "attn" : "regular",
6885 /* Add parsed element to parsed buffer */
6886 *results_offset += sprintf(qed_get_buf_ptr(results_buf,
6888 "raw: 0x%01x%08x%08x, %s: %d, source : %s, type : %s, cmd_addr : 0x%x(%s%s), %serror: %s\n",
6889 element->dword2, element->dword1,
6891 is_pf ? "pf" : "vf",
6892 GET_FIELD(element->dword0,
6893 IGU_FIFO_ELEMENT_DWORD0_FID),
6894 s_igu_fifo_source_strs[source],
6895 is_wr_cmd ? "wr" : "rd",
6897 (!is_pf && found_addr->vf_desc)
6898 ? found_addr->vf_desc
6902 s_igu_fifo_error_strs[err_type]);
6904 return DBG_STATUS_OK;
6907 /* Parses an IGU FIFO dump buffer.
6908 * If result_buf is not NULL, the IGU FIFO results are printed to it.
6909 * In any case, the required results buffer size is assigned to
6910 * parsed_results_bytes.
6911 * The parsing status is returned.
6913 static enum dbg_status qed_parse_igu_fifo_dump(u32 *dump_buf,
6915 u32 *parsed_results_bytes)
6917 const char *section_name, *param_name, *param_str_val;
6918 u32 param_num_val, num_section_params, num_elements;
6919 struct igu_fifo_element *elements;
6920 enum dbg_status status;
6921 u32 results_offset = 0;
6924 /* Read global_params section */
6925 dump_buf += qed_read_section_hdr(dump_buf,
6926 §ion_name, &num_section_params);
6927 if (strcmp(section_name, "global_params"))
6928 return DBG_STATUS_IGU_FIFO_BAD_DATA;
6930 /* Print global params */
6931 dump_buf += qed_print_section_params(dump_buf,
6933 results_buf, &results_offset);
6935 /* Read igu_fifo_data section */
6936 dump_buf += qed_read_section_hdr(dump_buf,
6937 §ion_name, &num_section_params);
6938 if (strcmp(section_name, "igu_fifo_data"))
6939 return DBG_STATUS_IGU_FIFO_BAD_DATA;
6940 dump_buf += qed_read_param(dump_buf,
6941 ¶m_name, ¶m_str_val, ¶m_num_val);
6942 if (strcmp(param_name, "size"))
6943 return DBG_STATUS_IGU_FIFO_BAD_DATA;
6944 if (param_num_val % IGU_FIFO_ELEMENT_DWORDS)
6945 return DBG_STATUS_IGU_FIFO_BAD_DATA;
6946 num_elements = param_num_val / IGU_FIFO_ELEMENT_DWORDS;
6947 elements = (struct igu_fifo_element *)dump_buf;
6949 /* Decode elements */
6950 for (i = 0; i < num_elements; i++) {
6951 status = qed_parse_igu_fifo_element(&elements[i],
6954 if (status != DBG_STATUS_OK)
6958 results_offset += sprintf(qed_get_buf_ptr(results_buf,
6960 "fifo contained %d elements", num_elements);
6962 /* Add 1 for string NULL termination */
6963 *parsed_results_bytes = results_offset + 1;
6965 return DBG_STATUS_OK;
6968 static enum dbg_status
6969 qed_parse_protection_override_dump(u32 *dump_buf,
6971 u32 *parsed_results_bytes)
6973 const char *section_name, *param_name, *param_str_val;
6974 u32 param_num_val, num_section_params, num_elements;
6975 struct protection_override_element *elements;
6976 u32 results_offset = 0;
6979 /* Read global_params section */
6980 dump_buf += qed_read_section_hdr(dump_buf,
6981 §ion_name, &num_section_params);
6982 if (strcmp(section_name, "global_params"))
6983 return DBG_STATUS_PROTECTION_OVERRIDE_BAD_DATA;
6985 /* Print global params */
6986 dump_buf += qed_print_section_params(dump_buf,
6988 results_buf, &results_offset);
6990 /* Read protection_override_data section */
6991 dump_buf += qed_read_section_hdr(dump_buf,
6992 §ion_name, &num_section_params);
6993 if (strcmp(section_name, "protection_override_data"))
6994 return DBG_STATUS_PROTECTION_OVERRIDE_BAD_DATA;
6995 dump_buf += qed_read_param(dump_buf,
6996 ¶m_name, ¶m_str_val, ¶m_num_val);
6997 if (strcmp(param_name, "size"))
6998 return DBG_STATUS_PROTECTION_OVERRIDE_BAD_DATA;
6999 if (param_num_val % PROTECTION_OVERRIDE_ELEMENT_DWORDS)
7000 return DBG_STATUS_PROTECTION_OVERRIDE_BAD_DATA;
7001 num_elements = param_num_val / PROTECTION_OVERRIDE_ELEMENT_DWORDS;
7002 elements = (struct protection_override_element *)dump_buf;
7004 /* Decode elements */
7005 for (i = 0; i < num_elements; i++) {
7006 u32 address = GET_FIELD(elements[i].data,
7007 PROTECTION_OVERRIDE_ELEMENT_ADDRESS) *
7008 PROTECTION_OVERRIDE_ELEMENT_ADDR_FACTOR;
7011 sprintf(qed_get_buf_ptr(results_buf,
7013 "window %2d, address: 0x%07x, size: %7d regs, read: %d, write: %d, read protection: %-12s, write protection: %-12s\n",
7015 (u32)GET_FIELD(elements[i].data,
7016 PROTECTION_OVERRIDE_ELEMENT_WINDOW_SIZE),
7017 (u32)GET_FIELD(elements[i].data,
7018 PROTECTION_OVERRIDE_ELEMENT_READ),
7019 (u32)GET_FIELD(elements[i].data,
7020 PROTECTION_OVERRIDE_ELEMENT_WRITE),
7021 s_protection_strs[GET_FIELD(elements[i].data,
7022 PROTECTION_OVERRIDE_ELEMENT_READ_PROTECTION)],
7023 s_protection_strs[GET_FIELD(elements[i].data,
7024 PROTECTION_OVERRIDE_ELEMENT_WRITE_PROTECTION)]);
7027 results_offset += sprintf(qed_get_buf_ptr(results_buf,
7029 "protection override contained %d elements",
7032 /* Add 1 for string NULL termination */
7033 *parsed_results_bytes = results_offset + 1;
7035 return DBG_STATUS_OK;
7038 /* Parses a FW Asserts dump buffer.
7039 * If result_buf is not NULL, the FW Asserts results are printed to it.
7040 * In any case, the required results buffer size is assigned to
7041 * parsed_results_bytes.
7042 * The parsing status is returned.
7044 static enum dbg_status qed_parse_fw_asserts_dump(u32 *dump_buf,
7046 u32 *parsed_results_bytes)
7048 u32 num_section_params, param_num_val, i, results_offset = 0;
7049 const char *param_name, *param_str_val, *section_name;
7050 bool last_section_found = false;
7052 *parsed_results_bytes = 0;
7054 /* Read global_params section */
7055 dump_buf += qed_read_section_hdr(dump_buf,
7056 §ion_name, &num_section_params);
7057 if (strcmp(section_name, "global_params"))
7058 return DBG_STATUS_FW_ASSERTS_PARSE_FAILED;
7060 /* Print global params */
7061 dump_buf += qed_print_section_params(dump_buf,
7063 results_buf, &results_offset);
7065 while (!last_section_found) {
7066 dump_buf += qed_read_section_hdr(dump_buf,
7068 &num_section_params);
7069 if (!strcmp(section_name, "fw_asserts")) {
7070 /* Extract params */
7071 const char *storm_letter = NULL;
7072 u32 storm_dump_size = 0;
7074 for (i = 0; i < num_section_params; i++) {
7075 dump_buf += qed_read_param(dump_buf,
7079 if (!strcmp(param_name, "storm"))
7080 storm_letter = param_str_val;
7081 else if (!strcmp(param_name, "size"))
7082 storm_dump_size = param_num_val;
7085 DBG_STATUS_FW_ASSERTS_PARSE_FAILED;
7088 if (!storm_letter || !storm_dump_size)
7089 return DBG_STATUS_FW_ASSERTS_PARSE_FAILED;
7093 sprintf(qed_get_buf_ptr(results_buf,
7095 "\n%sSTORM_ASSERT: size=%d\n",
7096 storm_letter, storm_dump_size);
7097 for (i = 0; i < storm_dump_size; i++, dump_buf++)
7099 sprintf(qed_get_buf_ptr(results_buf,
7101 "%08x\n", *dump_buf);
7102 } else if (!strcmp(section_name, "last")) {
7103 last_section_found = true;
7105 return DBG_STATUS_FW_ASSERTS_PARSE_FAILED;
7109 /* Add 1 for string NULL termination */
7110 *parsed_results_bytes = results_offset + 1;
7112 return DBG_STATUS_OK;
7115 /***************************** Public Functions *******************************/
7117 enum dbg_status qed_dbg_user_set_bin_ptr(struct ecore_hwfn *p_hwfn,
7118 const u8 * const bin_ptr)
7120 struct bin_buffer_hdr *buf_hdrs =
7121 (struct bin_buffer_hdr *)(osal_uintptr_t)bin_ptr;
7124 /* Convert binary data to debug arrays */
7125 for (buf_id = 0; buf_id < MAX_BIN_DBG_BUFFER_TYPE; buf_id++)
7126 qed_set_dbg_bin_buf(p_hwfn,
7127 (enum bin_dbg_buffer_type)buf_id,
7128 (const u32 *)(bin_ptr +
7129 buf_hdrs[buf_id].offset),
7130 buf_hdrs[buf_id].length);
7132 return DBG_STATUS_OK;
7135 enum dbg_status qed_dbg_alloc_user_data(__rte_unused struct ecore_hwfn *p_hwfn,
7136 void **user_data_ptr)
7138 *user_data_ptr = OSAL_ZALLOC(p_hwfn->p_dev, GFP_KERNEL,
7139 sizeof(struct dbg_tools_user_data));
7140 if (!(*user_data_ptr))
7141 return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
7143 return DBG_STATUS_OK;
7146 const char *qed_dbg_get_status_str(enum dbg_status status)
7149 MAX_DBG_STATUS) ? s_status_str[status] : "Invalid debug status";
7152 enum dbg_status qed_get_idle_chk_results_buf_size(struct ecore_hwfn *p_hwfn,
7154 u32 num_dumped_dwords,
7155 u32 *results_buf_size)
7157 u32 num_errors, num_warnings;
7159 return qed_parse_idle_chk_dump(p_hwfn,
7164 &num_errors, &num_warnings);
7167 enum dbg_status qed_print_idle_chk_results(struct ecore_hwfn *p_hwfn,
7169 u32 num_dumped_dwords,
7174 u32 parsed_buf_size;
7176 return qed_parse_idle_chk_dump(p_hwfn,
7181 num_errors, num_warnings);
7184 void qed_dbg_mcp_trace_set_meta_data(struct ecore_hwfn *p_hwfn,
7185 const u32 *meta_buf)
7187 struct dbg_tools_user_data *dev_user_data =
7188 qed_dbg_get_user_data(p_hwfn);
7190 dev_user_data->mcp_trace_user_meta_buf = meta_buf;
7194 qed_get_mcp_trace_results_buf_size(struct ecore_hwfn *p_hwfn,
7196 __rte_unused u32 num_dumped_dwords,
7197 u32 *results_buf_size)
7199 return qed_parse_mcp_trace_dump(p_hwfn,
7200 dump_buf, NULL, results_buf_size, true);
7203 enum dbg_status qed_print_mcp_trace_results(struct ecore_hwfn *p_hwfn,
7205 __rte_unused u32 num_dumped_dwords,
7208 u32 parsed_buf_size;
7210 return qed_parse_mcp_trace_dump(p_hwfn,
7212 results_buf, &parsed_buf_size, true);
7215 enum dbg_status qed_print_mcp_trace_results_cont(struct ecore_hwfn *p_hwfn,
7219 u32 parsed_buf_size;
7221 return qed_parse_mcp_trace_dump(p_hwfn, dump_buf, results_buf,
7222 &parsed_buf_size, false);
7225 enum dbg_status qed_print_mcp_trace_line(struct ecore_hwfn *p_hwfn,
7227 u32 num_dumped_bytes,
7230 u32 parsed_results_bytes;
7232 return qed_parse_mcp_trace_buf(p_hwfn,
7237 results_buf, &parsed_results_bytes);
7240 /* Frees the specified MCP Trace meta data */
7241 void qed_mcp_trace_free_meta_data(struct ecore_hwfn *p_hwfn)
7243 struct dbg_tools_user_data *dev_user_data;
7244 struct mcp_trace_meta *meta;
7247 dev_user_data = qed_dbg_get_user_data(p_hwfn);
7248 meta = &dev_user_data->mcp_trace_meta;
7249 if (!meta->is_allocated)
7252 /* Release modules */
7253 if (meta->modules) {
7254 for (i = 0; i < meta->modules_num; i++)
7255 OSAL_FREE(p_hwfn, meta->modules[i]);
7256 OSAL_FREE(p_hwfn, meta->modules);
7259 /* Release formats */
7260 if (meta->formats) {
7261 for (i = 0; i < meta->formats_num; i++)
7262 OSAL_FREE(p_hwfn, meta->formats[i].format_str);
7263 OSAL_FREE(p_hwfn, meta->formats);
7266 meta->is_allocated = false;
7270 qed_get_reg_fifo_results_buf_size(__rte_unused struct ecore_hwfn *p_hwfn,
7272 __rte_unused u32 num_dumped_dwords,
7273 u32 *results_buf_size)
7275 return qed_parse_reg_fifo_dump(dump_buf, NULL, results_buf_size);
7279 qed_print_reg_fifo_results(__rte_unused struct ecore_hwfn *p_hwfn,
7281 __rte_unused u32 num_dumped_dwords,
7284 u32 parsed_buf_size;
7286 return qed_parse_reg_fifo_dump(dump_buf, results_buf, &parsed_buf_size);
7290 qed_get_igu_fifo_results_buf_size(__rte_unused struct ecore_hwfn *p_hwfn,
7292 __rte_unused u32 num_dumped_dwords,
7293 u32 *results_buf_size)
7295 return qed_parse_igu_fifo_dump(dump_buf, NULL, results_buf_size);
7299 qed_print_igu_fifo_results(__rte_unused struct ecore_hwfn *p_hwfn,
7301 __rte_unused u32 num_dumped_dwords,
7304 u32 parsed_buf_size;
7306 return qed_parse_igu_fifo_dump(dump_buf, results_buf, &parsed_buf_size);
7310 qed_get_protection_override_results_buf_size(__rte_unused
7311 struct ecore_hwfn *p_hwfn,
7313 __rte_unused u32 num_dumped_dwords,
7314 u32 *results_buf_size)
7316 return qed_parse_protection_override_dump(dump_buf,
7317 NULL, results_buf_size);
7321 qed_print_protection_override_results(__rte_unused struct ecore_hwfn *p_hwfn,
7323 __rte_unused u32 num_dumped_dwords,
7326 u32 parsed_buf_size;
7328 return qed_parse_protection_override_dump(dump_buf,
7334 qed_get_fw_asserts_results_buf_size(__rte_unused struct ecore_hwfn *p_hwfn,
7336 __rte_unused u32 num_dumped_dwords,
7337 u32 *results_buf_size)
7339 return qed_parse_fw_asserts_dump(dump_buf, NULL, results_buf_size);
7343 qed_print_fw_asserts_results(__rte_unused struct ecore_hwfn *p_hwfn,
7345 __rte_unused u32 num_dumped_dwords,
7348 u32 parsed_buf_size;
7350 return qed_parse_fw_asserts_dump(dump_buf,
7351 results_buf, &parsed_buf_size);
7354 enum dbg_status qed_dbg_parse_attn(struct ecore_hwfn *p_hwfn,
7355 struct dbg_attn_block_result *results)
7357 const u32 *block_attn_name_offsets;
7358 const char *attn_name_base;
7359 const char *block_name;
7360 enum dbg_attn_type attn_type;
7363 num_regs = GET_FIELD(results->data, DBG_ATTN_BLOCK_RESULT_NUM_REGS);
7364 attn_type = GET_FIELD(results->data, DBG_ATTN_BLOCK_RESULT_ATTN_TYPE);
7365 block_name = qed_dbg_get_block_name(p_hwfn, results->block_id);
7367 return DBG_STATUS_INVALID_ARGS;
7369 if (!p_hwfn->dbg_arrays[BIN_BUF_DBG_ATTN_INDEXES].ptr ||
7370 !p_hwfn->dbg_arrays[BIN_BUF_DBG_ATTN_NAME_OFFSETS].ptr ||
7371 !p_hwfn->dbg_arrays[BIN_BUF_DBG_PARSING_STRINGS].ptr)
7372 return DBG_STATUS_DBG_ARRAY_NOT_SET;
7374 block_attn_name_offsets =
7375 (u32 *)p_hwfn->dbg_arrays[BIN_BUF_DBG_ATTN_NAME_OFFSETS].ptr +
7376 results->names_offset;
7378 attn_name_base = p_hwfn->dbg_arrays[BIN_BUF_DBG_PARSING_STRINGS].ptr;
7380 /* Go over registers with a non-zero attention status */
7381 for (i = 0; i < num_regs; i++) {
7382 struct dbg_attn_bit_mapping *bit_mapping;
7383 struct dbg_attn_reg_result *reg_result;
7384 u8 num_reg_attn, bit_idx = 0;
7386 reg_result = &results->reg_results[i];
7387 num_reg_attn = GET_FIELD(reg_result->data,
7388 DBG_ATTN_REG_RESULT_NUM_REG_ATTN);
7389 bit_mapping = (struct dbg_attn_bit_mapping *)
7390 p_hwfn->dbg_arrays[BIN_BUF_DBG_ATTN_INDEXES].ptr +
7391 reg_result->block_attn_offset;
7393 /* Go over attention status bits */
7394 for (j = 0; j < num_reg_attn; j++, bit_idx++) {
7395 u16 attn_idx_val = GET_FIELD(bit_mapping[j].data,
7396 DBG_ATTN_BIT_MAPPING_VAL);
7397 const char *attn_name, *attn_type_str, *masked_str;
7398 u32 attn_name_offset;
7401 /* Check if bit mask should be advanced (due to unused
7404 if (GET_FIELD(bit_mapping[j].data,
7405 DBG_ATTN_BIT_MAPPING_IS_UNUSED_BIT_CNT)) {
7406 bit_idx += (u8)attn_idx_val;
7410 /* Check current bit index */
7411 if (!(reg_result->sts_val & OSAL_BIT(bit_idx)))
7414 /* An attention bit with value=1 was found
7415 * Find attention name
7418 block_attn_name_offsets[attn_idx_val];
7419 attn_name = attn_name_base + attn_name_offset;
7422 ATTN_TYPE_INTERRUPT ? "Interrupt" :
7424 masked_str = reg_result->mask_val & OSAL_BIT(bit_idx) ?
7426 sts_addr = GET_FIELD(reg_result->data,
7427 DBG_ATTN_REG_RESULT_STS_ADDRESS);
7428 DP_NOTICE(p_hwfn, false,
7429 "%s (%s) : %s [address 0x%08x, bit %d]%s\n",
7430 block_name, attn_type_str, attn_name,
7431 sts_addr * 4, bit_idx, masked_str);
7435 return DBG_STATUS_OK;
7438 /* Wrapper for unifying the idle_chk and mcp_trace api */
7439 static enum dbg_status
7440 qed_print_idle_chk_results_wrapper(struct ecore_hwfn *p_hwfn,
7442 u32 num_dumped_dwords,
7445 u32 num_errors, num_warnnings;
7447 return qed_print_idle_chk_results(p_hwfn, dump_buf, num_dumped_dwords,
7448 results_buf, &num_errors,
7452 /* Feature meta data lookup table */
7455 enum dbg_status (*get_size)(struct ecore_hwfn *p_hwfn,
7456 struct ecore_ptt *p_ptt, u32 *size);
7457 enum dbg_status (*perform_dump)(struct ecore_hwfn *p_hwfn,
7458 struct ecore_ptt *p_ptt, u32 *dump_buf,
7459 u32 buf_size, u32 *dumped_dwords);
7460 enum dbg_status (*print_results)(struct ecore_hwfn *p_hwfn,
7461 u32 *dump_buf, u32 num_dumped_dwords,
7463 enum dbg_status (*results_buf_size)(struct ecore_hwfn *p_hwfn,
7465 u32 num_dumped_dwords,
7466 u32 *results_buf_size);
7467 } qed_features_lookup[] = {
7469 "grc", qed_dbg_grc_get_dump_buf_size,
7470 qed_dbg_grc_dump, NULL, NULL}, {
7472 qed_dbg_idle_chk_get_dump_buf_size,
7473 qed_dbg_idle_chk_dump,
7474 qed_print_idle_chk_results_wrapper,
7475 qed_get_idle_chk_results_buf_size}, {
7477 qed_dbg_mcp_trace_get_dump_buf_size,
7478 qed_dbg_mcp_trace_dump, qed_print_mcp_trace_results,
7479 qed_get_mcp_trace_results_buf_size}, {
7481 qed_dbg_reg_fifo_get_dump_buf_size,
7482 qed_dbg_reg_fifo_dump, qed_print_reg_fifo_results,
7483 qed_get_reg_fifo_results_buf_size}, {
7485 qed_dbg_igu_fifo_get_dump_buf_size,
7486 qed_dbg_igu_fifo_dump, qed_print_igu_fifo_results,
7487 qed_get_igu_fifo_results_buf_size}, {
7488 "protection_override",
7489 qed_dbg_protection_override_get_dump_buf_size,
7490 qed_dbg_protection_override_dump,
7491 qed_print_protection_override_results,
7492 qed_get_protection_override_results_buf_size}, {
7494 qed_dbg_fw_asserts_get_dump_buf_size,
7495 qed_dbg_fw_asserts_dump,
7496 qed_print_fw_asserts_results,
7497 qed_get_fw_asserts_results_buf_size}, {
7499 qed_dbg_ilt_get_dump_buf_size,
7500 qed_dbg_ilt_dump, NULL, NULL},};
7502 #define QED_RESULTS_BUF_MIN_SIZE 16
7503 /* Generic function for decoding debug feature info */
7504 static enum dbg_status format_feature(struct ecore_hwfn *p_hwfn,
7505 enum ecore_dbg_features feature_idx)
7507 struct ecore_dbg_feature *feature =
7508 &p_hwfn->p_dev->dbg_params.features[feature_idx];
7509 u32 text_size_bytes, null_char_pos, i;
7513 /* Check if feature supports formatting capability */
7514 if (!qed_features_lookup[feature_idx].results_buf_size)
7515 return DBG_STATUS_OK;
7517 /* Obtain size of formatted output */
7518 rc = qed_features_lookup[feature_idx].results_buf_size(p_hwfn,
7519 (u32 *)feature->dump_buf,
7520 feature->dumped_dwords,
7522 if (rc != DBG_STATUS_OK)
7525 /* Make sure that the allocated size is a multiple of dword (4 bytes) */
7526 null_char_pos = text_size_bytes - 1;
7527 text_size_bytes = (text_size_bytes + 3) & ~0x3;
7529 if (text_size_bytes < QED_RESULTS_BUF_MIN_SIZE) {
7530 DP_NOTICE(p_hwfn->p_dev, false,
7531 "formatted size of feature was too small %d. Aborting\n",
7533 return DBG_STATUS_INVALID_ARGS;
7536 /* Allocate temp text buf */
7537 text_buf = OSAL_VZALLOC(p_hwfn, text_size_bytes);
7539 DP_NOTICE(p_hwfn->p_dev, false,
7540 "failed to allocate text buffer. Aborting\n");
7541 return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
7544 /* Decode feature opcodes to string on temp buf */
7545 rc = qed_features_lookup[feature_idx].print_results(p_hwfn,
7546 (u32 *)feature->dump_buf,
7547 feature->dumped_dwords,
7549 if (rc != DBG_STATUS_OK) {
7550 OSAL_VFREE(p_hwfn, text_buf);
7554 /* Replace the original null character with a '\n' character.
7555 * The bytes that were added as a result of the dword alignment are also
7556 * padded with '\n' characters.
7558 for (i = null_char_pos; i < text_size_bytes; i++)
7562 /* Free the old dump_buf and point the dump_buf to the newly allocated
7563 * and formatted text buffer.
7565 OSAL_VFREE(p_hwfn, feature->dump_buf);
7566 feature->dump_buf = (u8 *)text_buf;
7567 feature->buf_size = text_size_bytes;
7568 feature->dumped_dwords = text_size_bytes / 4;
7572 #define MAX_DBG_FEATURE_SIZE_DWORDS 0x3FFFFFFF
7574 /* Generic function for performing the dump of a debug feature. */
7575 static enum dbg_status qed_dbg_dump(struct ecore_hwfn *p_hwfn,
7576 struct ecore_ptt *p_ptt,
7577 enum ecore_dbg_features feature_idx)
7579 struct ecore_dbg_feature *feature =
7580 &p_hwfn->p_dev->dbg_params.features[feature_idx];
7581 u32 buf_size_dwords;
7584 DP_NOTICE(p_hwfn->p_dev, false, "Collecting a debug feature [\"%s\"]\n",
7585 qed_features_lookup[feature_idx].name);
7587 /* Dump_buf was already allocated need to free (this can happen if dump
7588 * was called but file was never read).
7589 * We can't use the buffer as is since size may have changed.
7591 if (feature->dump_buf) {
7592 OSAL_VFREE(p_hwfn, feature->dump_buf);
7593 feature->dump_buf = NULL;
7596 /* Get buffer size from hsi, allocate accordingly, and perform the
7599 rc = qed_features_lookup[feature_idx].get_size(p_hwfn, p_ptt,
7601 if (rc != DBG_STATUS_OK && rc != DBG_STATUS_NVRAM_GET_IMAGE_FAILED)
7604 if (buf_size_dwords > MAX_DBG_FEATURE_SIZE_DWORDS) {
7605 feature->buf_size = 0;
7606 DP_NOTICE(p_hwfn->p_dev, false,
7607 "Debug feature [\"%s\"] size (0x%x dwords) exceeds maximum size (0x%x dwords)\n",
7608 qed_features_lookup[feature_idx].name,
7609 buf_size_dwords, MAX_DBG_FEATURE_SIZE_DWORDS);
7611 return DBG_STATUS_OK;
7614 feature->buf_size = buf_size_dwords * sizeof(u32);
7615 feature->dump_buf = OSAL_ZALLOC(p_hwfn, GFP_KERNEL, feature->buf_size);
7616 if (!feature->dump_buf)
7617 return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
7619 rc = qed_features_lookup[feature_idx].perform_dump(p_hwfn, p_ptt,
7620 (u32 *)feature->dump_buf,
7621 feature->buf_size / sizeof(u32),
7622 &feature->dumped_dwords);
7624 /* If mcp is stuck we get DBG_STATUS_NVRAM_GET_IMAGE_FAILED error.
7625 * In this case the buffer holds valid binary data, but we won't able
7626 * to parse it (since parsing relies on data in NVRAM which is only
7627 * accessible when MFW is responsive). skip the formatting but return
7628 * success so that binary data is provided.
7630 if (rc == DBG_STATUS_NVRAM_GET_IMAGE_FAILED)
7631 return DBG_STATUS_OK;
7633 if (rc != DBG_STATUS_OK)
7637 rc = format_feature(p_hwfn, feature_idx);
7641 int qed_dbg_grc(struct ecore_dev *edev, void *buffer, u32 *num_dumped_bytes)
7643 return qed_dbg_feature(edev, buffer, DBG_FEATURE_GRC, num_dumped_bytes);
7646 int qed_dbg_grc_size(struct ecore_dev *edev)
7648 return qed_dbg_feature_size(edev, DBG_FEATURE_GRC);
7652 qed_dbg_idle_chk(struct ecore_dev *edev, void *buffer, u32 *num_dumped_bytes)
7654 return qed_dbg_feature(edev, buffer, DBG_FEATURE_IDLE_CHK,
7658 int qed_dbg_idle_chk_size(struct ecore_dev *edev)
7660 return qed_dbg_feature_size(edev, DBG_FEATURE_IDLE_CHK);
7664 qed_dbg_reg_fifo(struct ecore_dev *edev, void *buffer, u32 *num_dumped_bytes)
7666 return qed_dbg_feature(edev, buffer, DBG_FEATURE_REG_FIFO,
7670 int qed_dbg_reg_fifo_size(struct ecore_dev *edev)
7672 return qed_dbg_feature_size(edev, DBG_FEATURE_REG_FIFO);
7676 qed_dbg_igu_fifo(struct ecore_dev *edev, void *buffer, u32 *num_dumped_bytes)
7678 return qed_dbg_feature(edev, buffer, DBG_FEATURE_IGU_FIFO,
7682 int qed_dbg_igu_fifo_size(struct ecore_dev *edev)
7684 return qed_dbg_feature_size(edev, DBG_FEATURE_IGU_FIFO);
7687 static int qed_dbg_nvm_image_length(struct ecore_hwfn *p_hwfn,
7688 enum ecore_nvm_images image_id, u32 *length)
7690 struct ecore_nvm_image_att image_att;
7694 rc = ecore_mcp_get_nvm_image_att(p_hwfn, image_id, &image_att);
7698 *length = image_att.length;
7703 int qed_dbg_protection_override(struct ecore_dev *edev, void *buffer,
7704 u32 *num_dumped_bytes)
7706 return qed_dbg_feature(edev, buffer, DBG_FEATURE_PROTECTION_OVERRIDE,
7710 int qed_dbg_protection_override_size(struct ecore_dev *edev)
7712 return qed_dbg_feature_size(edev, DBG_FEATURE_PROTECTION_OVERRIDE);
7715 int qed_dbg_fw_asserts(struct ecore_dev *edev, void *buffer,
7716 u32 *num_dumped_bytes)
7718 return qed_dbg_feature(edev, buffer, DBG_FEATURE_FW_ASSERTS,
7722 int qed_dbg_fw_asserts_size(struct ecore_dev *edev)
7724 return qed_dbg_feature_size(edev, DBG_FEATURE_FW_ASSERTS);
7727 int qed_dbg_ilt(struct ecore_dev *edev, void *buffer, u32 *num_dumped_bytes)
7729 return qed_dbg_feature(edev, buffer, DBG_FEATURE_ILT, num_dumped_bytes);
7732 int qed_dbg_ilt_size(struct ecore_dev *edev)
7734 return qed_dbg_feature_size(edev, DBG_FEATURE_ILT);
7737 int qed_dbg_mcp_trace(struct ecore_dev *edev, void *buffer,
7738 u32 *num_dumped_bytes)
7740 return qed_dbg_feature(edev, buffer, DBG_FEATURE_MCP_TRACE,
7744 int qed_dbg_mcp_trace_size(struct ecore_dev *edev)
7746 return qed_dbg_feature_size(edev, DBG_FEATURE_MCP_TRACE);
7749 /* Defines the amount of bytes allocated for recording the length of debug
7752 #define REGDUMP_HEADER_SIZE sizeof(u32)
7753 #define REGDUMP_HEADER_SIZE_SHIFT 0
7754 #define REGDUMP_HEADER_SIZE_MASK 0xffffff
7755 #define REGDUMP_HEADER_FEATURE_SHIFT 24
7756 #define REGDUMP_HEADER_FEATURE_MASK 0x3f
7757 #define REGDUMP_HEADER_OMIT_ENGINE_SHIFT 30
7758 #define REGDUMP_HEADER_OMIT_ENGINE_MASK 0x1
7759 #define REGDUMP_HEADER_ENGINE_SHIFT 31
7760 #define REGDUMP_HEADER_ENGINE_MASK 0x1
7761 #define REGDUMP_MAX_SIZE 0x1000000
7762 #define ILT_DUMP_MAX_SIZE (1024 * 1024 * 15)
7764 enum debug_print_features {
7770 PROTECTION_OVERRIDE = 5,
7781 static u32 qed_calc_regdump_header(struct ecore_dev *edev,
7782 enum debug_print_features feature,
7783 int engine, u32 feature_size, u8 omit_engine)
7787 SET_FIELD(res, REGDUMP_HEADER_SIZE, feature_size);
7788 if (res != feature_size)
7789 DP_NOTICE(edev, false,
7790 "Feature %d is too large (size 0x%x) and will corrupt the dump\n",
7791 feature, feature_size);
7793 SET_FIELD(res, REGDUMP_HEADER_FEATURE, feature);
7794 SET_FIELD(res, REGDUMP_HEADER_OMIT_ENGINE, omit_engine);
7795 SET_FIELD(res, REGDUMP_HEADER_ENGINE, engine);
7800 int qed_dbg_all_data(struct ecore_dev *edev, void *buffer)
7802 u8 cur_engine, omit_engine = 0, org_engine;
7803 struct ecore_hwfn *p_hwfn =
7804 &edev->hwfns[edev->dbg_params.engine_for_debug];
7805 struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
7806 int grc_params[MAX_DBG_GRC_PARAMS], i;
7807 u32 offset = 0, feature_size;
7810 for (i = 0; i < MAX_DBG_GRC_PARAMS; i++)
7811 grc_params[i] = dev_data->grc.param_val[i];
7813 if (!ECORE_IS_CMT(edev))
7816 OSAL_MUTEX_ACQUIRE(&edev->dbg_lock);
7818 org_engine = qed_get_debug_engine(edev);
7819 for (cur_engine = 0; cur_engine < edev->num_hwfns; cur_engine++) {
7820 /* Collect idle_chks and grcDump for each hw function */
7821 DP_VERBOSE(edev, ECORE_MSG_DEBUG,
7822 "obtaining idle_chk and grcdump for current engine\n");
7823 qed_set_debug_engine(edev, cur_engine);
7825 /* First idle_chk */
7826 rc = qed_dbg_idle_chk(edev, (u8 *)buffer + offset +
7827 REGDUMP_HEADER_SIZE, &feature_size);
7829 *(u32 *)((u8 *)buffer + offset) =
7830 qed_calc_regdump_header(edev, IDLE_CHK, cur_engine,
7831 feature_size, omit_engine);
7832 offset += (feature_size + REGDUMP_HEADER_SIZE);
7834 DP_ERR(edev, "qed_dbg_idle_chk failed. rc = %d\n", rc);
7837 /* Second idle_chk */
7838 rc = qed_dbg_idle_chk(edev, (u8 *)buffer + offset +
7839 REGDUMP_HEADER_SIZE, &feature_size);
7841 *(u32 *)((u8 *)buffer + offset) =
7842 qed_calc_regdump_header(edev, IDLE_CHK, cur_engine,
7843 feature_size, omit_engine);
7844 offset += (feature_size + REGDUMP_HEADER_SIZE);
7846 DP_ERR(edev, "qed_dbg_idle_chk failed. rc = %d\n", rc);
7850 rc = qed_dbg_reg_fifo(edev, (u8 *)buffer + offset +
7851 REGDUMP_HEADER_SIZE, &feature_size);
7853 *(u32 *)((u8 *)buffer + offset) =
7854 qed_calc_regdump_header(edev, REG_FIFO, cur_engine,
7855 feature_size, omit_engine);
7856 offset += (feature_size + REGDUMP_HEADER_SIZE);
7858 DP_ERR(edev, "qed_dbg_reg_fifo failed. rc = %d\n", rc);
7862 rc = qed_dbg_igu_fifo(edev, (u8 *)buffer + offset +
7863 REGDUMP_HEADER_SIZE, &feature_size);
7865 *(u32 *)((u8 *)buffer + offset) =
7866 qed_calc_regdump_header(edev, IGU_FIFO, cur_engine,
7867 feature_size, omit_engine);
7868 offset += (feature_size + REGDUMP_HEADER_SIZE);
7870 DP_ERR(edev, "qed_dbg_igu_fifo failed. rc = %d", rc);
7873 /* protection_override dump */
7874 rc = qed_dbg_protection_override(edev, (u8 *)buffer + offset +
7875 REGDUMP_HEADER_SIZE,
7878 *(u32 *)((u8 *)buffer + offset) =
7879 qed_calc_regdump_header(edev, PROTECTION_OVERRIDE,
7881 feature_size, omit_engine);
7882 offset += (feature_size + REGDUMP_HEADER_SIZE);
7885 "qed_dbg_protection_override failed. rc = %d\n",
7889 /* fw_asserts dump */
7890 rc = qed_dbg_fw_asserts(edev, (u8 *)buffer + offset +
7891 REGDUMP_HEADER_SIZE, &feature_size);
7893 *(u32 *)((u8 *)buffer + offset) =
7894 qed_calc_regdump_header(edev, FW_ASSERTS,
7895 cur_engine, feature_size,
7897 offset += (feature_size + REGDUMP_HEADER_SIZE);
7899 DP_ERR(edev, "qed_dbg_fw_asserts failed. rc = %d\n",
7903 /* GRC dump - must be last because when mcp stuck it will
7904 * clutter idle_chk, reg_fifo, ...
7906 for (i = 0; i < MAX_DBG_GRC_PARAMS; i++)
7907 dev_data->grc.param_val[i] = grc_params[i];
7909 rc = qed_dbg_grc(edev, (u8 *)buffer + offset +
7910 REGDUMP_HEADER_SIZE, &feature_size);
7912 *(u32 *)((u8 *)buffer + offset) =
7913 qed_calc_regdump_header(edev, GRC_DUMP,
7915 feature_size, omit_engine);
7916 offset += (feature_size + REGDUMP_HEADER_SIZE);
7918 DP_ERR(edev, "qed_dbg_grc failed. rc = %d", rc);
7922 qed_set_debug_engine(edev, org_engine);
7925 rc = qed_dbg_mcp_trace(edev, (u8 *)buffer + offset +
7926 REGDUMP_HEADER_SIZE, &feature_size);
7928 *(u32 *)((u8 *)buffer + offset) =
7929 qed_calc_regdump_header(edev, MCP_TRACE, cur_engine,
7930 feature_size, omit_engine);
7931 offset += (feature_size + REGDUMP_HEADER_SIZE);
7933 DP_ERR(edev, "qed_dbg_mcp_trace failed. rc = %d\n", rc);
7936 OSAL_MUTEX_RELEASE(&edev->dbg_lock);
7941 int qed_dbg_all_data_size(struct ecore_dev *edev)
7943 struct ecore_hwfn *p_hwfn =
7944 &edev->hwfns[edev->dbg_params.engine_for_debug];
7945 u32 regs_len = 0, image_len = 0, ilt_len = 0, total_ilt_len = 0;
7946 u8 cur_engine, org_engine;
7948 edev->disable_ilt_dump = false;
7949 org_engine = qed_get_debug_engine(edev);
7950 for (cur_engine = 0; cur_engine < edev->num_hwfns; cur_engine++) {
7951 /* Engine specific */
7952 DP_VERBOSE(edev, ECORE_MSG_DEBUG,
7953 "calculating idle_chk and grcdump register length for current engine\n");
7954 qed_set_debug_engine(edev, cur_engine);
7955 regs_len += REGDUMP_HEADER_SIZE + qed_dbg_idle_chk_size(edev) +
7956 REGDUMP_HEADER_SIZE + qed_dbg_idle_chk_size(edev) +
7957 REGDUMP_HEADER_SIZE + qed_dbg_grc_size(edev) +
7958 REGDUMP_HEADER_SIZE + qed_dbg_reg_fifo_size(edev) +
7959 REGDUMP_HEADER_SIZE + qed_dbg_igu_fifo_size(edev) +
7960 REGDUMP_HEADER_SIZE +
7961 qed_dbg_protection_override_size(edev) +
7962 REGDUMP_HEADER_SIZE + qed_dbg_fw_asserts_size(edev);
7964 ilt_len = REGDUMP_HEADER_SIZE + qed_dbg_ilt_size(edev);
7965 if (ilt_len < ILT_DUMP_MAX_SIZE) {
7966 total_ilt_len += ilt_len;
7967 regs_len += ilt_len;
7971 qed_set_debug_engine(edev, org_engine);
7974 regs_len += REGDUMP_HEADER_SIZE + qed_dbg_mcp_trace_size(edev);
7975 qed_dbg_nvm_image_length(p_hwfn, ECORE_NVM_IMAGE_NVM_CFG1, &image_len);
7977 regs_len += REGDUMP_HEADER_SIZE + image_len;
7978 qed_dbg_nvm_image_length(p_hwfn, ECORE_NVM_IMAGE_DEFAULT_CFG,
7981 regs_len += REGDUMP_HEADER_SIZE + image_len;
7982 qed_dbg_nvm_image_length(p_hwfn, ECORE_NVM_IMAGE_NVM_META, &image_len);
7984 regs_len += REGDUMP_HEADER_SIZE + image_len;
7985 qed_dbg_nvm_image_length(p_hwfn, ECORE_NVM_IMAGE_MDUMP, &image_len);
7987 regs_len += REGDUMP_HEADER_SIZE + image_len;
7989 if (regs_len > REGDUMP_MAX_SIZE) {
7990 DP_VERBOSE(edev, ECORE_MSG_DEBUG,
7991 "Dump exceeds max size 0x%x, disable ILT dump\n",
7993 edev->disable_ilt_dump = true;
7994 regs_len -= total_ilt_len;
8000 int qed_dbg_feature(struct ecore_dev *edev, void *buffer,
8001 enum ecore_dbg_features feature, u32 *num_dumped_bytes)
8003 struct ecore_hwfn *p_hwfn =
8004 &edev->hwfns[edev->dbg_params.engine_for_debug];
8005 struct ecore_dbg_feature *qed_feature =
8006 &edev->dbg_params.features[feature];
8007 enum dbg_status dbg_rc;
8008 struct ecore_ptt *p_ptt;
8012 p_ptt = ecore_ptt_acquire(p_hwfn);
8017 dbg_rc = qed_dbg_dump(p_hwfn, p_ptt, feature);
8018 if (dbg_rc != DBG_STATUS_OK) {
8019 DP_VERBOSE(edev, ECORE_MSG_DEBUG, "%s\n",
8020 qed_dbg_get_status_str(dbg_rc));
8021 *num_dumped_bytes = 0;
8026 DP_VERBOSE(edev, ECORE_MSG_DEBUG,
8027 "copying debug feature to external buffer\n");
8028 memcpy(buffer, qed_feature->dump_buf, qed_feature->buf_size);
8029 *num_dumped_bytes = edev->dbg_params.features[feature].dumped_dwords *
8033 ecore_ptt_release(p_hwfn, p_ptt);
8038 qed_dbg_feature_size(struct ecore_dev *edev, enum ecore_dbg_features feature)
8040 struct ecore_hwfn *p_hwfn =
8041 &edev->hwfns[edev->dbg_params.engine_for_debug];
8042 struct ecore_dbg_feature *qed_feature = &edev->dbg_features[feature];
8043 struct ecore_ptt *p_ptt = ecore_ptt_acquire(p_hwfn);
8044 u32 buf_size_dwords;
8050 rc = qed_features_lookup[feature].get_size(p_hwfn, p_ptt,
8052 if (rc != DBG_STATUS_OK)
8053 buf_size_dwords = 0;
8055 /* Feature will not be dumped if it exceeds maximum size */
8056 if (buf_size_dwords > MAX_DBG_FEATURE_SIZE_DWORDS)
8057 buf_size_dwords = 0;
8059 ecore_ptt_release(p_hwfn, p_ptt);
8060 qed_feature->buf_size = buf_size_dwords * sizeof(u32);
8061 return qed_feature->buf_size;
8064 u8 qed_get_debug_engine(struct ecore_dev *edev)
8066 return edev->dbg_params.engine_for_debug;
8069 void qed_set_debug_engine(struct ecore_dev *edev, int engine_number)
8071 DP_VERBOSE(edev, ECORE_MSG_DEBUG, "set debug engine to %d\n",
8073 edev->dbg_params.engine_for_debug = engine_number;
8076 void qed_dbg_pf_init(struct ecore_dev *edev)
8078 const u8 *dbg_values = NULL;
8081 PMD_INIT_FUNC_TRACE(edev);
8083 OSAL_MUTEX_INIT(&edev->dbg_lock);
8085 /* Sync ver with debugbus qed code */
8086 qed_dbg_set_app_ver(TOOLS_VERSION);
8088 /* Debug values are after init values.
8089 * The offset is the first dword of the file.
8091 /* TBD: change hardcoded value to offset from FW file */
8092 dbg_values = (const u8 *)edev->firmware + 1337296;
8094 for_each_hwfn(edev, i) {
8095 qed_dbg_set_bin_ptr(&edev->hwfns[i], dbg_values);
8096 qed_dbg_user_set_bin_ptr(&edev->hwfns[i], dbg_values);
8099 /* Set the hwfn to be 0 as default */
8100 edev->dbg_params.engine_for_debug = 0;
8103 void qed_dbg_pf_exit(struct ecore_dev *edev)
8105 struct ecore_dbg_feature *feature = NULL;
8106 enum ecore_dbg_features feature_idx;
8108 PMD_INIT_FUNC_TRACE(edev);
8110 /* debug features' buffers may be allocated if debug feature was used
8111 * but dump wasn't called
8113 for (feature_idx = 0; feature_idx < DBG_FEATURE_NUM; feature_idx++) {
8114 feature = &edev->dbg_features[feature_idx];
8115 if (feature->dump_buf) {
8116 OSAL_VFREE(edev, feature->dump_buf);
8117 feature->dump_buf = NULL;
8121 OSAL_MUTEX_DEALLOC(&edev->dbg_lock);