Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright (c) 2020 Marvell Semiconductor Inc.
3 : : * All rights reserved.
4 : : * www.marvell.com
5 : : */
6 : :
7 : : #include <assert.h>
8 : : #include <rte_common.h>
9 : : #include "base/bcm_osal.h"
10 : : #include "base/ecore.h"
11 : : #include "base/ecore_cxt.h"
12 : : #include "base/ecore_hsi_common.h"
13 : : #include "base/ecore_hw.h"
14 : : #include "base/ecore_mcp.h"
15 : : #include "base/reg_addr.h"
16 : : #include "qede_debug.h"
17 : :
18 : : /* Memory groups enum */
19 : : enum mem_groups {
20 : : MEM_GROUP_PXP_MEM,
21 : : MEM_GROUP_DMAE_MEM,
22 : : MEM_GROUP_CM_MEM,
23 : : MEM_GROUP_QM_MEM,
24 : : MEM_GROUP_DORQ_MEM,
25 : : MEM_GROUP_BRB_RAM,
26 : : MEM_GROUP_BRB_MEM,
27 : : MEM_GROUP_PRS_MEM,
28 : : MEM_GROUP_SDM_MEM,
29 : : MEM_GROUP_PBUF,
30 : : MEM_GROUP_IOR,
31 : : MEM_GROUP_RAM,
32 : : MEM_GROUP_BTB_RAM,
33 : : MEM_GROUP_RDIF_CTX,
34 : : MEM_GROUP_TDIF_CTX,
35 : : MEM_GROUP_CFC_MEM,
36 : : MEM_GROUP_CONN_CFC_MEM,
37 : : MEM_GROUP_CAU_PI,
38 : : MEM_GROUP_CAU_MEM,
39 : : MEM_GROUP_CAU_MEM_EXT,
40 : : MEM_GROUP_PXP_ILT,
41 : : MEM_GROUP_MULD_MEM,
42 : : MEM_GROUP_BTB_MEM,
43 : : MEM_GROUP_IGU_MEM,
44 : : MEM_GROUP_IGU_MSIX,
45 : : MEM_GROUP_CAU_SB,
46 : : MEM_GROUP_BMB_RAM,
47 : : MEM_GROUP_BMB_MEM,
48 : : MEM_GROUP_TM_MEM,
49 : : MEM_GROUP_TASK_CFC_MEM,
50 : : MEM_GROUPS_NUM
51 : : };
52 : :
53 : : /* Memory groups names */
54 : : static const char * const s_mem_group_names[] = {
55 : : "PXP_MEM",
56 : : "DMAE_MEM",
57 : : "CM_MEM",
58 : : "QM_MEM",
59 : : "DORQ_MEM",
60 : : "BRB_RAM",
61 : : "BRB_MEM",
62 : : "PRS_MEM",
63 : : "SDM_MEM",
64 : : "PBUF",
65 : : "IOR",
66 : : "RAM",
67 : : "BTB_RAM",
68 : : "RDIF_CTX",
69 : : "TDIF_CTX",
70 : : "CFC_MEM",
71 : : "CONN_CFC_MEM",
72 : : "CAU_PI",
73 : : "CAU_MEM",
74 : : "CAU_MEM_EXT",
75 : : "PXP_ILT",
76 : : "MULD_MEM",
77 : : "BTB_MEM",
78 : : "IGU_MEM",
79 : : "IGU_MSIX",
80 : : "CAU_SB",
81 : : "BMB_RAM",
82 : : "BMB_MEM",
83 : : "TM_MEM",
84 : : "TASK_CFC_MEM",
85 : : };
86 : : static_assert(RTE_DIM(s_mem_group_names) == MEM_GROUPS_NUM, "memory group string mismatch");
87 : :
88 : : /* Idle check conditions */
89 : :
90 : 0 : static u32 cond5(const u32 *r, const u32 *imm)
91 : : {
92 [ # # # # ]: 0 : return ((r[0] & imm[0]) != imm[1]) && ((r[1] & imm[2]) != imm[3]);
93 : : }
94 : :
95 : 0 : static u32 cond7(const u32 *r, const u32 *imm)
96 : : {
97 : 0 : return ((r[0] >> imm[0]) & imm[1]) != imm[2];
98 : : }
99 : :
100 : 0 : static u32 cond6(const u32 *r, const u32 *imm)
101 : : {
102 : 0 : return (r[0] & imm[0]) != imm[1];
103 : : }
104 : :
105 : 0 : static u32 cond9(const u32 *r, const u32 *imm)
106 : : {
107 : 0 : return ((r[0] & imm[0]) >> imm[1]) !=
108 : 0 : (((r[0] & imm[2]) >> imm[3]) | ((r[1] & imm[4]) << imm[5]));
109 : : }
110 : :
111 : 0 : static u32 cond10(const u32 *r, const u32 *imm)
112 : : {
113 : 0 : return ((r[0] & imm[0]) >> imm[1]) != (r[0] & imm[2]);
114 : : }
115 : :
116 : 0 : static u32 cond4(const u32 *r, const u32 *imm)
117 : : {
118 : 0 : return (r[0] & ~imm[0]) != imm[1];
119 : : }
120 : :
121 : 0 : static u32 cond0(const u32 *r, const u32 *imm)
122 : : {
123 : 0 : return (r[0] & ~r[1]) != imm[0];
124 : : }
125 : :
126 : 0 : static u32 cond1(const u32 *r, const u32 *imm)
127 : : {
128 : 0 : return r[0] != imm[0];
129 : : }
130 : :
131 : 0 : static u32 cond11(const u32 *r, const u32 *imm)
132 : : {
133 [ # # # # ]: 0 : return r[0] != r[1] && r[2] == imm[0];
134 : : }
135 : :
136 : 0 : static u32 cond12(const u32 *r, const u32 *imm)
137 : : {
138 [ # # # # ]: 0 : return r[0] != r[1] && r[2] > imm[0];
139 : : }
140 : :
141 : 0 : static u32 cond3(const u32 *r, const __rte_unused u32 *imm)
142 : : {
143 : 0 : return r[0] != r[1];
144 : : }
145 : :
146 : 0 : static u32 cond13(const u32 *r, const u32 *imm)
147 : : {
148 : 0 : return r[0] & imm[0];
149 : : }
150 : :
151 : 0 : static u32 cond8(const u32 *r, const u32 *imm)
152 : : {
153 : 0 : return r[0] < (r[1] - imm[0]);
154 : : }
155 : :
156 : 0 : static u32 cond2(const u32 *r, const u32 *imm)
157 : : {
158 : 0 : return r[0] > imm[0];
159 : : }
160 : :
161 : : /* Array of Idle Check conditions */
162 : : static u32(*cond_arr[]) (const u32 *r, const u32 *imm) = {
163 : : cond0,
164 : : cond1,
165 : : cond2,
166 : : cond3,
167 : : cond4,
168 : : cond5,
169 : : cond6,
170 : : cond7,
171 : : cond8,
172 : : cond9,
173 : : cond10,
174 : : cond11,
175 : : cond12,
176 : : cond13,
177 : : };
178 : :
179 : : #define NUM_PHYS_BLOCKS 84
180 : :
181 : : #define NUM_DBG_RESET_REGS 8
182 : :
183 : : /******************************* Data Types **********************************/
184 : :
185 : : enum hw_types {
186 : : HW_TYPE_ASIC,
187 : : PLATFORM_RESERVED,
188 : : PLATFORM_RESERVED2,
189 : : PLATFORM_RESERVED3,
190 : : PLATFORM_RESERVED4,
191 : : MAX_HW_TYPES
192 : : };
193 : :
194 : : /* CM context types */
195 : : enum cm_ctx_types {
196 : : CM_CTX_CONN_AG,
197 : : CM_CTX_CONN_ST,
198 : : CM_CTX_TASK_AG,
199 : : CM_CTX_TASK_ST,
200 : : NUM_CM_CTX_TYPES
201 : : };
202 : :
203 : : /* Debug bus frame modes */
204 : : enum dbg_bus_frame_modes {
205 : : DBG_BUS_FRAME_MODE_4ST = 0, /* 4 Storm dwords (no HW) */
206 : : DBG_BUS_FRAME_MODE_2ST_2HW = 1, /* 2 Storm dwords, 2 HW dwords */
207 : : DBG_BUS_FRAME_MODE_1ST_3HW = 2, /* 1 Storm dwords, 3 HW dwords */
208 : : DBG_BUS_FRAME_MODE_4HW = 3, /* 4 HW dwords (no Storms) */
209 : : DBG_BUS_FRAME_MODE_8HW = 4, /* 8 HW dwords (no Storms) */
210 : : DBG_BUS_NUM_FRAME_MODES
211 : : };
212 : :
213 : : /* Chip constant definitions */
214 : : struct chip_defs {
215 : : const char *name;
216 : : u32 num_ilt_pages;
217 : : };
218 : :
219 : : /* HW type constant definitions */
220 : : struct hw_type_defs {
221 : : const char *name;
222 : : u32 delay_factor;
223 : : u32 dmae_thresh;
224 : : u32 log_thresh;
225 : : };
226 : :
227 : : /* RBC reset definitions */
228 : : struct rbc_reset_defs {
229 : : u32 reset_reg_addr;
230 : : u32 reset_val[MAX_CHIP_IDS];
231 : : };
232 : :
233 : : /* Storm constant definitions.
234 : : * Addresses are in bytes, sizes are in quad-regs.
235 : : */
236 : : struct storm_defs {
237 : : char letter;
238 : : enum block_id sem_block_id;
239 : : enum dbg_bus_clients dbg_client_id[MAX_CHIP_IDS];
240 : : bool has_vfc;
241 : : u32 sem_fast_mem_addr;
242 : : u32 sem_frame_mode_addr;
243 : : u32 sem_slow_enable_addr;
244 : : u32 sem_slow_mode_addr;
245 : : u32 sem_slow_mode1_conf_addr;
246 : : u32 sem_sync_dbg_empty_addr;
247 : : u32 sem_gpre_vect_addr;
248 : : u32 cm_ctx_wr_addr;
249 : : u32 cm_ctx_rd_addr[NUM_CM_CTX_TYPES];
250 : : u32 cm_ctx_lid_sizes[MAX_CHIP_IDS][NUM_CM_CTX_TYPES];
251 : : };
252 : :
253 : : /* Debug Bus Constraint operation constant definitions */
254 : : struct dbg_bus_constraint_op_defs {
255 : : u8 hw_op_val;
256 : : bool is_cyclic;
257 : : };
258 : :
259 : : /* Storm Mode definitions */
260 : : struct storm_mode_defs {
261 : : const char *name;
262 : : bool is_fast_dbg;
263 : : u8 id_in_hw;
264 : : u32 src_disable_reg_addr;
265 : : u32 src_enable_val;
266 : : bool exists[MAX_CHIP_IDS];
267 : : };
268 : :
269 : : struct grc_param_defs {
270 : : u32 default_val[MAX_CHIP_IDS];
271 : : u32 min;
272 : : u32 max;
273 : : bool is_preset;
274 : : bool is_persistent;
275 : : u32 exclude_all_preset_val;
276 : : u32 crash_preset_val[MAX_CHIP_IDS];
277 : : };
278 : :
279 : : /* Address is in 128b units. Width is in bits. */
280 : : struct rss_mem_defs {
281 : : const char *mem_name;
282 : : const char *type_name;
283 : : u32 addr;
284 : : u32 entry_width;
285 : : u32 num_entries[MAX_CHIP_IDS];
286 : : };
287 : :
288 : : struct vfc_ram_defs {
289 : : const char *mem_name;
290 : : const char *type_name;
291 : : u32 base_row;
292 : : u32 num_rows;
293 : : };
294 : :
295 : : struct big_ram_defs {
296 : : const char *instance_name;
297 : : enum mem_groups mem_group_id;
298 : : enum mem_groups ram_mem_group_id;
299 : : enum dbg_grc_params grc_param;
300 : : u32 addr_reg_addr;
301 : : u32 data_reg_addr;
302 : : u32 is_256b_reg_addr;
303 : : u32 is_256b_bit_offset[MAX_CHIP_IDS];
304 : : u32 ram_size[MAX_CHIP_IDS]; /* In dwords */
305 : : };
306 : :
307 : : struct phy_defs {
308 : : const char *phy_name;
309 : :
310 : : /* PHY base GRC address */
311 : : u32 base_addr;
312 : :
313 : : /* Relative address of indirect TBUS address register (bits 0..7) */
314 : : u32 tbus_addr_lo_addr;
315 : :
316 : : /* Relative address of indirect TBUS address register (bits 8..10) */
317 : : u32 tbus_addr_hi_addr;
318 : :
319 : : /* Relative address of indirect TBUS data register (bits 0..7) */
320 : : u32 tbus_data_lo_addr;
321 : :
322 : : /* Relative address of indirect TBUS data register (bits 8..11) */
323 : : u32 tbus_data_hi_addr;
324 : : };
325 : :
326 : : /* Split type definitions */
327 : : struct split_type_defs {
328 : : const char *name;
329 : : };
330 : :
331 : : /******************************** Constants **********************************/
332 : :
333 : : #define BYTES_IN_DWORD sizeof(u32)
334 : : /* In the macros below, size and offset are specified in bits */
335 : : #define CEIL_DWORDS(size) DIV_ROUND_UP(size, 32)
336 : : #define FIELD_BIT_OFFSET(type, field) type ## _ ## field ## _ ## OFFSET
337 : : #define FIELD_BIT_SIZE(type, field) type ## _ ## field ## _ ## SIZE
338 : : #define FIELD_DWORD_OFFSET(type, field) \
339 : : (int)(FIELD_BIT_OFFSET(type, field) / 32)
340 : : #define FIELD_DWORD_SHIFT(type, field) (FIELD_BIT_OFFSET(type, field) % 32)
341 : : #define FIELD_BIT_MASK(type, field) \
342 : : (((1 << FIELD_BIT_SIZE(type, field)) - 1) << \
343 : : FIELD_DWORD_SHIFT(type, field))
344 : :
345 : : #define SET_VAR_FIELD(var, type, field, val) \
346 : : do { \
347 : : var[FIELD_DWORD_OFFSET(type, field)] &= \
348 : : (~FIELD_BIT_MASK(type, field)); \
349 : : var[FIELD_DWORD_OFFSET(type, field)] |= \
350 : : (val) << FIELD_DWORD_SHIFT(type, field); \
351 : : } while (0)
352 : :
353 : : #define ARR_REG_WR(dev, ptt, addr, arr, arr_size) \
354 : : do { \
355 : : for (i = 0; i < (arr_size); i++) \
356 : : ecore_wr(dev, ptt, addr, (arr)[i]); \
357 : : } while (0)
358 : :
359 : : #define DWORDS_TO_BYTES(dwords) ((dwords) * BYTES_IN_DWORD)
360 : : #define BYTES_TO_DWORDS(bytes) ((bytes) / BYTES_IN_DWORD)
361 : :
362 : : /* extra lines include a signature line + optional latency events line */
363 : : #define NUM_EXTRA_DBG_LINES(block) \
364 : : (GET_FIELD((block)->flags, DBG_BLOCK_CHIP_HAS_LATENCY_EVENTS) ? 2 : 1)
365 : : #define NUM_DBG_LINES(block) \
366 : : ((block)->num_of_dbg_bus_lines + NUM_EXTRA_DBG_LINES(block))
367 : :
368 : : #define USE_DMAE true
369 : : #define PROTECT_WIDE_BUS true
370 : :
371 : : #define RAM_LINES_TO_DWORDS(lines) ((lines) * 2)
372 : : #define RAM_LINES_TO_BYTES(lines) \
373 : : DWORDS_TO_BYTES(RAM_LINES_TO_DWORDS(lines))
374 : :
375 : : #define REG_DUMP_LEN_SHIFT 24
376 : : #define MEM_DUMP_ENTRY_SIZE_DWORDS \
377 : : BYTES_TO_DWORDS(sizeof(struct dbg_dump_mem))
378 : :
379 : : #define IDLE_CHK_RULE_SIZE_DWORDS \
380 : : BYTES_TO_DWORDS(sizeof(struct dbg_idle_chk_rule))
381 : :
382 : : #define IDLE_CHK_RESULT_HDR_DWORDS \
383 : : BYTES_TO_DWORDS(sizeof(struct dbg_idle_chk_result_hdr))
384 : :
385 : : #define IDLE_CHK_RESULT_REG_HDR_DWORDS \
386 : : BYTES_TO_DWORDS(sizeof(struct dbg_idle_chk_result_reg_hdr))
387 : :
388 : : #define PAGE_MEM_DESC_SIZE_DWORDS \
389 : : BYTES_TO_DWORDS(sizeof(struct phys_mem_desc))
390 : :
391 : : #define IDLE_CHK_MAX_ENTRIES_SIZE 32
392 : :
393 : : /* The sizes and offsets below are specified in bits */
394 : : #define VFC_CAM_CMD_STRUCT_SIZE 64
395 : : #define VFC_CAM_CMD_ROW_OFFSET 48
396 : : #define VFC_CAM_CMD_ROW_SIZE 9
397 : : #define VFC_CAM_ADDR_STRUCT_SIZE 16
398 : : #define VFC_CAM_ADDR_OP_OFFSET 0
399 : : #define VFC_CAM_ADDR_OP_SIZE 4
400 : : #define VFC_CAM_RESP_STRUCT_SIZE 256
401 : : #define VFC_RAM_ADDR_STRUCT_SIZE 16
402 : : #define VFC_RAM_ADDR_OP_OFFSET 0
403 : : #define VFC_RAM_ADDR_OP_SIZE 2
404 : : #define VFC_RAM_ADDR_ROW_OFFSET 2
405 : : #define VFC_RAM_ADDR_ROW_SIZE 10
406 : : #define VFC_RAM_RESP_STRUCT_SIZE 256
407 : :
408 : : #define VFC_CAM_CMD_DWORDS CEIL_DWORDS(VFC_CAM_CMD_STRUCT_SIZE)
409 : : #define VFC_CAM_ADDR_DWORDS CEIL_DWORDS(VFC_CAM_ADDR_STRUCT_SIZE)
410 : : #define VFC_CAM_RESP_DWORDS CEIL_DWORDS(VFC_CAM_RESP_STRUCT_SIZE)
411 : : #define VFC_RAM_CMD_DWORDS VFC_CAM_CMD_DWORDS
412 : : #define VFC_RAM_ADDR_DWORDS CEIL_DWORDS(VFC_RAM_ADDR_STRUCT_SIZE)
413 : : #define VFC_RAM_RESP_DWORDS CEIL_DWORDS(VFC_RAM_RESP_STRUCT_SIZE)
414 : :
415 : : #define NUM_VFC_RAM_TYPES 4
416 : :
417 : : #define VFC_CAM_NUM_ROWS 512
418 : :
419 : : #define VFC_OPCODE_CAM_RD 14
420 : : #define VFC_OPCODE_RAM_RD 0
421 : :
422 : : #define NUM_RSS_MEM_TYPES 5
423 : :
424 : : #define NUM_BIG_RAM_TYPES 3
425 : : #define BIG_RAM_NAME_LEN 3
426 : :
427 : : #define NUM_PHY_TBUS_ADDRESSES 2048
428 : : #define PHY_DUMP_SIZE_DWORDS (NUM_PHY_TBUS_ADDRESSES / 2)
429 : :
430 : : #define RESET_REG_UNRESET_OFFSET 4
431 : :
432 : : #define STALL_DELAY_MS 500
433 : :
434 : : #define STATIC_DEBUG_LINE_DWORDS 9
435 : :
436 : : #define NUM_COMMON_GLOBAL_PARAMS 11
437 : :
438 : : #define MAX_RECURSION_DEPTH 10
439 : :
440 : : #define FW_IMG_MAIN 1
441 : :
442 : : #define REG_FIFO_ELEMENT_DWORDS 2
443 : : #define REG_FIFO_DEPTH_ELEMENTS 32
444 : : #define REG_FIFO_DEPTH_DWORDS \
445 : : (REG_FIFO_ELEMENT_DWORDS * REG_FIFO_DEPTH_ELEMENTS)
446 : :
447 : : #define IGU_FIFO_ELEMENT_DWORDS 4
448 : : #define IGU_FIFO_DEPTH_ELEMENTS 64
449 : : #define IGU_FIFO_DEPTH_DWORDS \
450 : : (IGU_FIFO_ELEMENT_DWORDS * IGU_FIFO_DEPTH_ELEMENTS)
451 : :
452 : : #define PROTECTION_OVERRIDE_ELEMENT_DWORDS 2
453 : : #define PROTECTION_OVERRIDE_DEPTH_ELEMENTS 20
454 : : #define PROTECTION_OVERRIDE_DEPTH_DWORDS \
455 : : (PROTECTION_OVERRIDE_DEPTH_ELEMENTS * \
456 : : PROTECTION_OVERRIDE_ELEMENT_DWORDS)
457 : :
458 : : #define MCP_SPAD_TRACE_OFFSIZE_ADDR \
459 : : (MCP_REG_SCRATCH + \
460 : : offsetof(struct static_init, sections[SPAD_SECTION_TRACE]))
461 : :
462 : : #define MAX_SW_PLTAFORM_STR_SIZE 64
463 : :
464 : : #define EMPTY_FW_VERSION_STR "???_???_???_???"
465 : : #define EMPTY_FW_IMAGE_STR "???????????????"
466 : :
467 : : /***************************** Constant Arrays *******************************/
468 : :
469 : : /* Chip constant definitions array */
470 : : static struct chip_defs s_chip_defs[MAX_CHIP_IDS] = {
471 : : {"bb", PSWRQ2_REG_ILT_MEMORY_SIZE_BB / 2},
472 : : {"ah", PSWRQ2_REG_ILT_MEMORY_SIZE_K2 / 2}
473 : : };
474 : :
475 : : /* Storm constant definitions array */
476 : : static struct storm_defs s_storm_defs[] = {
477 : : /* Tstorm */
478 : : {'T', BLOCK_TSEM,
479 : : {DBG_BUS_CLIENT_RBCT, DBG_BUS_CLIENT_RBCT},
480 : : true,
481 : : TSEM_REG_FAST_MEMORY,
482 : : TSEM_REG_DBG_FRAME_MODE, TSEM_REG_SLOW_DBG_ACTIVE,
483 : : TSEM_REG_SLOW_DBG_MODE, TSEM_REG_DBG_MODE1_CFG,
484 : : TSEM_REG_SYNC_DBG_EMPTY, TSEM_REG_DBG_GPRE_VECT,
485 : : TCM_REG_CTX_RBC_ACCS,
486 : : {TCM_REG_AGG_CON_CTX, TCM_REG_SM_CON_CTX, TCM_REG_AGG_TASK_CTX,
487 : : TCM_REG_SM_TASK_CTX},
488 : : {{4, 16, 2, 4}, {4, 16, 2, 4} } /* {bb} {k2} */
489 : : },
490 : :
491 : : /* Mstorm */
492 : : {'M', BLOCK_MSEM,
493 : : {DBG_BUS_CLIENT_RBCT, DBG_BUS_CLIENT_RBCM},
494 : : false,
495 : : MSEM_REG_FAST_MEMORY,
496 : : MSEM_REG_DBG_FRAME_MODE,
497 : : MSEM_REG_SLOW_DBG_ACTIVE,
498 : : MSEM_REG_SLOW_DBG_MODE,
499 : : MSEM_REG_DBG_MODE1_CFG,
500 : : MSEM_REG_SYNC_DBG_EMPTY,
501 : : MSEM_REG_DBG_GPRE_VECT,
502 : : MCM_REG_CTX_RBC_ACCS,
503 : : {MCM_REG_AGG_CON_CTX, MCM_REG_SM_CON_CTX, MCM_REG_AGG_TASK_CTX,
504 : : MCM_REG_SM_TASK_CTX },
505 : : {{1, 10, 2, 7}, {1, 10, 2, 7} } /* {bb} {k2}*/
506 : : },
507 : :
508 : : /* Ustorm */
509 : : {'U', BLOCK_USEM,
510 : : {DBG_BUS_CLIENT_RBCU, DBG_BUS_CLIENT_RBCU},
511 : : false,
512 : : USEM_REG_FAST_MEMORY,
513 : : USEM_REG_DBG_FRAME_MODE,
514 : : USEM_REG_SLOW_DBG_ACTIVE,
515 : : USEM_REG_SLOW_DBG_MODE,
516 : : USEM_REG_DBG_MODE1_CFG,
517 : : USEM_REG_SYNC_DBG_EMPTY,
518 : : USEM_REG_DBG_GPRE_VECT,
519 : : UCM_REG_CTX_RBC_ACCS,
520 : : {UCM_REG_AGG_CON_CTX, UCM_REG_SM_CON_CTX, UCM_REG_AGG_TASK_CTX,
521 : : UCM_REG_SM_TASK_CTX},
522 : : {{2, 13, 3, 3}, {2, 13, 3, 3} } /* {bb} {k2} */
523 : : },
524 : :
525 : : /* Xstorm */
526 : : {'X', BLOCK_XSEM,
527 : : {DBG_BUS_CLIENT_RBCX, DBG_BUS_CLIENT_RBCX},
528 : : false,
529 : : XSEM_REG_FAST_MEMORY,
530 : : XSEM_REG_DBG_FRAME_MODE,
531 : : XSEM_REG_SLOW_DBG_ACTIVE,
532 : : XSEM_REG_SLOW_DBG_MODE,
533 : : XSEM_REG_DBG_MODE1_CFG,
534 : : XSEM_REG_SYNC_DBG_EMPTY,
535 : : XSEM_REG_DBG_GPRE_VECT,
536 : : XCM_REG_CTX_RBC_ACCS,
537 : : {XCM_REG_AGG_CON_CTX, XCM_REG_SM_CON_CTX, 0, 0},
538 : : {{9, 15, 0, 0}, {9, 15, 0, 0} } /* {bb} {k2} */
539 : : },
540 : :
541 : : /* Ystorm */
542 : : {'Y', BLOCK_YSEM,
543 : : {DBG_BUS_CLIENT_RBCX, DBG_BUS_CLIENT_RBCY},
544 : : false,
545 : : YSEM_REG_FAST_MEMORY,
546 : : YSEM_REG_DBG_FRAME_MODE,
547 : : YSEM_REG_SLOW_DBG_ACTIVE,
548 : : YSEM_REG_SLOW_DBG_MODE,
549 : : YSEM_REG_DBG_MODE1_CFG,
550 : : YSEM_REG_SYNC_DBG_EMPTY,
551 : : YSEM_REG_DBG_GPRE_VECT,
552 : : YCM_REG_CTX_RBC_ACCS,
553 : : {YCM_REG_AGG_CON_CTX, YCM_REG_SM_CON_CTX, YCM_REG_AGG_TASK_CTX,
554 : : YCM_REG_SM_TASK_CTX},
555 : : {{2, 3, 2, 12}, {2, 3, 2, 12} } /* {bb} {k2} */
556 : : },
557 : :
558 : : /* Pstorm */
559 : : {'P', BLOCK_PSEM,
560 : : {DBG_BUS_CLIENT_RBCS, DBG_BUS_CLIENT_RBCS},
561 : : true,
562 : : PSEM_REG_FAST_MEMORY,
563 : : PSEM_REG_DBG_FRAME_MODE,
564 : : PSEM_REG_SLOW_DBG_ACTIVE,
565 : : PSEM_REG_SLOW_DBG_MODE,
566 : : PSEM_REG_DBG_MODE1_CFG,
567 : : PSEM_REG_SYNC_DBG_EMPTY,
568 : : PSEM_REG_DBG_GPRE_VECT,
569 : : PCM_REG_CTX_RBC_ACCS,
570 : : {0, PCM_REG_SM_CON_CTX, 0, 0},
571 : : {{0, 10, 0, 0}, {0, 10, 0, 0} } /* {bb} {k2} */
572 : : },
573 : : };
574 : :
575 : : static struct hw_type_defs s_hw_type_defs[] = {
576 : : /* HW_TYPE_ASIC */
577 : : {"asic", 1, 256, 32768},
578 : : {"reserved", 0, 0, 0},
579 : : {"reserved2", 0, 0, 0},
580 : : {"reserved3", 0, 0, 0}
581 : : };
582 : :
583 : : static struct grc_param_defs s_grc_param_defs[] = {
584 : : /* DBG_GRC_PARAM_DUMP_TSTORM */
585 : : {{1, 1}, 0, 1, false, false, 1, {1, 1} },
586 : :
587 : : /* DBG_GRC_PARAM_DUMP_MSTORM */
588 : : {{1, 1}, 0, 1, false, false, 1, {1, 1} },
589 : :
590 : : /* DBG_GRC_PARAM_DUMP_USTORM */
591 : : {{1, 1}, 0, 1, false, false, 1, {1, 1} },
592 : :
593 : : /* DBG_GRC_PARAM_DUMP_XSTORM */
594 : : {{1, 1}, 0, 1, false, false, 1, {1, 1} },
595 : :
596 : : /* DBG_GRC_PARAM_DUMP_YSTORM */
597 : : {{1, 1}, 0, 1, false, false, 1, {1, 1} },
598 : :
599 : : /* DBG_GRC_PARAM_DUMP_PSTORM */
600 : : {{1, 1}, 0, 1, false, false, 1, {1, 1} },
601 : :
602 : : /* DBG_GRC_PARAM_DUMP_REGS */
603 : : {{1, 1}, 0, 1, false, false, 0, {1, 1} },
604 : :
605 : : /* DBG_GRC_PARAM_DUMP_RAM */
606 : : {{1, 1}, 0, 1, false, false, 0, {1, 1} },
607 : :
608 : : /* DBG_GRC_PARAM_DUMP_PBUF */
609 : : {{1, 1}, 0, 1, false, false, 0, {1, 1} },
610 : :
611 : : /* DBG_GRC_PARAM_DUMP_IOR */
612 : : {{0, 0}, 0, 1, false, false, 0, {1, 1} },
613 : :
614 : : /* DBG_GRC_PARAM_DUMP_VFC */
615 : : {{0, 0}, 0, 1, false, false, 0, {1, 1} },
616 : :
617 : : /* DBG_GRC_PARAM_DUMP_CM_CTX */
618 : : {{1, 1}, 0, 1, false, false, 0, {1, 1} },
619 : :
620 : : /* DBG_GRC_PARAM_DUMP_ILT */
621 : : {{1, 1}, 0, 1, false, false, 0, {1, 1} },
622 : :
623 : : /* DBG_GRC_PARAM_DUMP_RSS */
624 : : {{1, 1}, 0, 1, false, false, 0, {1, 1} },
625 : :
626 : : /* DBG_GRC_PARAM_DUMP_CAU */
627 : : {{1, 1}, 0, 1, false, false, 0, {1, 1} },
628 : :
629 : : /* DBG_GRC_PARAM_DUMP_QM */
630 : : {{1, 1}, 0, 1, false, false, 0, {1, 1} },
631 : :
632 : : /* DBG_GRC_PARAM_DUMP_MCP */
633 : : {{1, 1}, 0, 1, false, false, 0, {1, 1} },
634 : :
635 : : /* DBG_GRC_PARAM_DUMP_DORQ */
636 : : {{1, 1}, 0, 1, false, false, 0, {1, 1} },
637 : :
638 : : /* DBG_GRC_PARAM_DUMP_CFC */
639 : : {{1, 1}, 0, 1, false, false, 0, {1, 1} },
640 : :
641 : : /* DBG_GRC_PARAM_DUMP_IGU */
642 : : {{1, 1}, 0, 1, false, false, 0, {1, 1} },
643 : :
644 : : /* DBG_GRC_PARAM_DUMP_BRB */
645 : : {{0, 0}, 0, 1, false, false, 0, {1, 1} },
646 : :
647 : : /* DBG_GRC_PARAM_DUMP_BTB */
648 : : {{0, 0}, 0, 1, false, false, 0, {1, 1} },
649 : :
650 : : /* DBG_GRC_PARAM_DUMP_BMB */
651 : : {{0, 0}, 0, 1, false, false, 0, {0, 0} },
652 : :
653 : : /* DBG_GRC_PARAM_RESERVED1 */
654 : : {{0, 0}, 0, 1, false, false, 0, {0, 0} },
655 : :
656 : : /* DBG_GRC_PARAM_DUMP_MULD */
657 : : {{1, 1}, 0, 1, false, false, 0, {1, 1} },
658 : :
659 : : /* DBG_GRC_PARAM_DUMP_PRS */
660 : : {{1, 1}, 0, 1, false, false, 0, {1, 1} },
661 : :
662 : : /* DBG_GRC_PARAM_DUMP_DMAE */
663 : : {{1, 1}, 0, 1, false, false, 0, {1, 1} },
664 : :
665 : : /* DBG_GRC_PARAM_DUMP_TM */
666 : : {{1, 1}, 0, 1, false, false, 0, {1, 1} },
667 : :
668 : : /* DBG_GRC_PARAM_DUMP_SDM */
669 : : {{1, 1}, 0, 1, false, false, 0, {1, 1} },
670 : :
671 : : /* DBG_GRC_PARAM_DUMP_DIF */
672 : : {{1, 1}, 0, 1, false, false, 0, {1, 1} },
673 : :
674 : : /* DBG_GRC_PARAM_DUMP_STATIC */
675 : : {{1, 1}, 0, 1, false, false, 0, {1, 1} },
676 : :
677 : : /* DBG_GRC_PARAM_UNSTALL */
678 : : {{0, 0}, 0, 1, false, false, 0, {0, 0} },
679 : :
680 : : /* DBG_GRC_PARAM_RESERVED2 */
681 : : {{0, 0}, 0, 1, false, false, 0, {0, 0} },
682 : :
683 : : /* DBG_GRC_PARAM_MCP_TRACE_META_SIZE */
684 : : {{0, 0}, 1, 0xffffffff, false, true, 0, {0, 0} },
685 : :
686 : : /* DBG_GRC_PARAM_EXCLUDE_ALL */
687 : : {{0, 0}, 0, 1, true, false, 0, {0, 0} },
688 : :
689 : : /* DBG_GRC_PARAM_CRASH */
690 : : {{0, 0}, 0, 1, true, false, 0, {0, 0} },
691 : :
692 : : /* DBG_GRC_PARAM_PARITY_SAFE */
693 : : {{0, 0}, 0, 1, false, false, 0, {0, 0} },
694 : :
695 : : /* DBG_GRC_PARAM_DUMP_CM */
696 : : {{1, 1}, 0, 1, false, false, 0, {1, 1} },
697 : :
698 : : /* DBG_GRC_PARAM_DUMP_PHY */
699 : : {{0, 0}, 0, 1, false, false, 0, {0, 0} },
700 : :
701 : : /* DBG_GRC_PARAM_NO_MCP */
702 : : {{0, 0}, 0, 1, false, false, 0, {0, 0} },
703 : :
704 : : /* DBG_GRC_PARAM_NO_FW_VER */
705 : : {{0, 0}, 0, 1, false, false, 0, {0, 0} },
706 : :
707 : : /* DBG_GRC_PARAM_RESERVED3 */
708 : : {{0, 0}, 0, 1, false, false, 0, {0, 0} },
709 : :
710 : : /* DBG_GRC_PARAM_DUMP_MCP_HW_DUMP */
711 : : {{0, 1}, 0, 1, false, false, 0, {0, 1} },
712 : :
713 : : /* DBG_GRC_PARAM_DUMP_ILT_CDUC */
714 : : {{1, 1}, 0, 1, false, false, 0, {0, 0} },
715 : :
716 : : /* DBG_GRC_PARAM_DUMP_ILT_CDUT */
717 : : {{1, 1}, 0, 1, false, false, 0, {0, 0} },
718 : :
719 : : /* DBG_GRC_PARAM_DUMP_CAU_EXT */
720 : : {{0, 0}, 0, 1, false, false, 0, {1, 1} }
721 : : };
722 : :
723 : : static struct rss_mem_defs s_rss_mem_defs[] = {
724 : : {"rss_mem_cid", "rss_cid", 0, 32,
725 : : {256, 320} },
726 : :
727 : : {"rss_mem_key_msb", "rss_key", 1024, 256,
728 : : {128, 208} },
729 : :
730 : : {"rss_mem_key_lsb", "rss_key", 2048, 64,
731 : : {128, 208} },
732 : :
733 : : {"rss_mem_info", "rss_info", 3072, 16,
734 : : {128, 208} },
735 : :
736 : : {"rss_mem_ind", "rss_ind", 4096, 16,
737 : : {16384, 26624} }
738 : : };
739 : :
740 : : static struct vfc_ram_defs s_vfc_ram_defs[] = {
741 : : {"vfc_ram_tt1", "vfc_ram", 0, 512},
742 : : {"vfc_ram_mtt2", "vfc_ram", 512, 128},
743 : : {"vfc_ram_stt2", "vfc_ram", 640, 32},
744 : : {"vfc_ram_ro_vect", "vfc_ram", 672, 32}
745 : : };
746 : :
747 : : static struct big_ram_defs s_big_ram_defs[] = {
748 : : {"BRB", MEM_GROUP_BRB_MEM, MEM_GROUP_BRB_RAM, DBG_GRC_PARAM_DUMP_BRB,
749 : : BRB_REG_BIG_RAM_ADDRESS, BRB_REG_BIG_RAM_DATA,
750 : : MISC_REG_BLOCK_256B_EN, {0, 0},
751 : : {153600, 180224} },
752 : :
753 : : {"BTB", MEM_GROUP_BTB_MEM, MEM_GROUP_BTB_RAM, DBG_GRC_PARAM_DUMP_BTB,
754 : : BTB_REG_BIG_RAM_ADDRESS, BTB_REG_BIG_RAM_DATA,
755 : : MISC_REG_BLOCK_256B_EN, {0, 1},
756 : : {92160, 117760} },
757 : :
758 : : {"BMB", MEM_GROUP_BMB_MEM, MEM_GROUP_BMB_RAM, DBG_GRC_PARAM_DUMP_BMB,
759 : : BMB_REG_BIG_RAM_ADDRESS, BMB_REG_BIG_RAM_DATA,
760 : : MISCS_REG_BLOCK_256B_EN, {0, 0},
761 : : {36864, 36864} }
762 : : };
763 : :
764 : : static struct rbc_reset_defs s_rbc_reset_defs[] = {
765 : : {MISCS_REG_RESET_PL_HV,
766 : : {0x0, 0x400} },
767 : : {MISC_REG_RESET_PL_PDA_VMAIN_1,
768 : : {0x4404040, 0x4404040} },
769 : : {MISC_REG_RESET_PL_PDA_VMAIN_2,
770 : : {0x7, 0x7c00007} },
771 : : {MISC_REG_RESET_PL_PDA_VAUX,
772 : : {0x2, 0x2} },
773 : : };
774 : :
775 : : static struct phy_defs s_phy_defs[] = {
776 : : {"nw_phy", NWS_REG_NWS_CMU_K2,
777 : : PHY_NW_IP_REG_PHY0_TOP_TBUS_ADDR_7_0_K2,
778 : : PHY_NW_IP_REG_PHY0_TOP_TBUS_ADDR_15_8_K2,
779 : : PHY_NW_IP_REG_PHY0_TOP_TBUS_DATA_7_0_K2,
780 : : PHY_NW_IP_REG_PHY0_TOP_TBUS_DATA_11_8_K2},
781 : : {"sgmii_phy", MS_REG_MS_CMU_K2,
782 : : PHY_SGMII_IP_REG_AHB_CMU_CSR_0_X132_K2,
783 : : PHY_SGMII_IP_REG_AHB_CMU_CSR_0_X133_K2,
784 : : PHY_SGMII_IP_REG_AHB_CMU_CSR_0_X130_K2,
785 : : PHY_SGMII_IP_REG_AHB_CMU_CSR_0_X131_K2},
786 : : {"pcie_phy0", PHY_PCIE_REG_PHY0_K2,
787 : : PHY_PCIE_IP_REG_AHB_CMU_CSR_0_X132_K2,
788 : : PHY_PCIE_IP_REG_AHB_CMU_CSR_0_X133_K2,
789 : : PHY_PCIE_IP_REG_AHB_CMU_CSR_0_X130_K2,
790 : : PHY_PCIE_IP_REG_AHB_CMU_CSR_0_X131_K2},
791 : : {"pcie_phy1", PHY_PCIE_REG_PHY1_K2,
792 : : PHY_PCIE_IP_REG_AHB_CMU_CSR_0_X132_K2,
793 : : PHY_PCIE_IP_REG_AHB_CMU_CSR_0_X133_K2,
794 : : PHY_PCIE_IP_REG_AHB_CMU_CSR_0_X130_K2,
795 : : PHY_PCIE_IP_REG_AHB_CMU_CSR_0_X131_K2},
796 : : };
797 : :
798 : : static struct split_type_defs s_split_type_defs[] = {
799 : : /* SPLIT_TYPE_NONE */
800 : : {"eng"},
801 : :
802 : : /* SPLIT_TYPE_PORT */
803 : : {"port"},
804 : :
805 : : /* SPLIT_TYPE_PF */
806 : : {"pf"},
807 : :
808 : : /* SPLIT_TYPE_PORT_PF */
809 : : {"port"},
810 : :
811 : : /* SPLIT_TYPE_VF */
812 : : {"vf"}
813 : : };
814 : :
815 : : /**************************** Private Functions ******************************/
816 : :
817 : : /* Reads and returns a single dword from the specified unaligned buffer */
818 : : static u32 qed_read_unaligned_dword(u8 *buf)
819 : : {
820 : : u32 dword;
821 : :
822 : : memcpy((u8 *)&dword, buf, sizeof(dword));
823 : : return dword;
824 : : }
825 : :
826 : : /* Sets the value of the specified GRC param */
827 : : static void qed_grc_set_param(struct ecore_hwfn *p_hwfn,
828 : : enum dbg_grc_params grc_param, u32 val)
829 : : {
830 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
831 : :
832 : 0 : dev_data->grc.param_val[grc_param] = val;
833 : 0 : }
834 : :
835 : : /* Returns the value of the specified GRC param */
836 : : static u32 qed_grc_get_param(struct ecore_hwfn *p_hwfn,
837 : : enum dbg_grc_params grc_param)
838 : : {
839 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
840 : :
841 : 0 : return dev_data->grc.param_val[grc_param];
842 : : }
843 : :
844 : : /* Initializes the GRC parameters */
845 : : static void qed_dbg_grc_init_params(struct ecore_hwfn *p_hwfn)
846 : : {
847 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
848 : :
849 [ # # ]: 0 : if (!dev_data->grc.params_initialized) {
850 : 0 : qed_dbg_grc_set_params_default(p_hwfn);
851 : 0 : dev_data->grc.params_initialized = 1;
852 : : }
853 : : }
854 : :
855 : : /* Sets pointer and size for the specified binary buffer type */
856 : : static void qed_set_dbg_bin_buf(struct ecore_hwfn *p_hwfn,
857 : : enum bin_dbg_buffer_type buf_type,
858 : : const u32 *ptr, u32 size)
859 : : {
860 : : struct virt_mem_desc *buf = &p_hwfn->dbg_arrays[buf_type];
861 : :
862 : 0 : buf->ptr = (void *)(osal_uintptr_t)ptr;
863 : 0 : buf->size = size;
864 : : }
865 : :
866 : : /* Initializes debug data for the specified device */
867 : 0 : static enum dbg_status qed_dbg_dev_init(struct ecore_hwfn *p_hwfn)
868 : : {
869 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
870 : : u8 num_pfs = 0, max_pfs_per_port = 0;
871 : :
872 [ # # ]: 0 : if (dev_data->initialized)
873 : : return DBG_STATUS_OK;
874 : :
875 : : /* Set chip */
876 [ # # ]: 0 : if (ECORE_IS_K2(p_hwfn->p_dev)) {
877 : 0 : dev_data->chip_id = CHIP_K2;
878 : 0 : dev_data->mode_enable[MODE_K2] = 1;
879 : 0 : dev_data->num_vfs = MAX_NUM_VFS_K2;
880 : : num_pfs = MAX_NUM_PFS_K2;
881 : : max_pfs_per_port = MAX_NUM_PFS_K2 / 2;
882 [ # # # # : 0 : } else if (ECORE_IS_BB_B0(p_hwfn->p_dev)) {
# # # # ]
883 : 0 : dev_data->chip_id = CHIP_BB;
884 : 0 : dev_data->mode_enable[MODE_BB] = 1;
885 : 0 : dev_data->num_vfs = MAX_NUM_VFS_BB;
886 : : num_pfs = MAX_NUM_PFS_BB;
887 : 0 : max_pfs_per_port = MAX_NUM_PFS_BB;
888 : : } else {
889 : : return DBG_STATUS_UNKNOWN_CHIP;
890 : : }
891 : :
892 : : /* Set HW type */
893 : 0 : dev_data->hw_type = HW_TYPE_ASIC;
894 : 0 : dev_data->mode_enable[MODE_ASIC] = 1;
895 : :
896 : : /* Set port mode */
897 [ # # # # ]: 0 : switch (p_hwfn->p_dev->num_ports_in_engine) {
898 : 0 : case 1:
899 : 0 : dev_data->mode_enable[MODE_PORTS_PER_ENG_1] = 1;
900 : 0 : break;
901 : 0 : case 2:
902 : 0 : dev_data->mode_enable[MODE_PORTS_PER_ENG_2] = 1;
903 : 0 : break;
904 : 0 : case 4:
905 : 0 : dev_data->mode_enable[MODE_PORTS_PER_ENG_4] = 1;
906 : 0 : break;
907 : : }
908 : :
909 : : /* Set 100G mode */
910 [ # # ]: 0 : if (ECORE_IS_CMT(p_hwfn->p_dev))
911 : 0 : dev_data->mode_enable[MODE_100G] = 1;
912 : :
913 : : /* Set number of ports */
914 [ # # ]: 0 : if (dev_data->mode_enable[MODE_PORTS_PER_ENG_1] ||
915 [ # # ]: 0 : dev_data->mode_enable[MODE_100G])
916 : 0 : dev_data->num_ports = 1;
917 [ # # ]: 0 : else if (dev_data->mode_enable[MODE_PORTS_PER_ENG_2])
918 : 0 : dev_data->num_ports = 2;
919 [ # # ]: 0 : else if (dev_data->mode_enable[MODE_PORTS_PER_ENG_4])
920 : 0 : dev_data->num_ports = 4;
921 : :
922 : : /* Set number of PFs per port */
923 [ # # ]: 0 : dev_data->num_pfs_per_port = OSAL_MIN_T(u32,
924 : : num_pfs / dev_data->num_ports,
925 : : max_pfs_per_port);
926 : :
927 : : /* Initializes the GRC parameters */
928 : : qed_dbg_grc_init_params(p_hwfn);
929 : :
930 : 0 : dev_data->use_dmae = true;
931 : 0 : dev_data->initialized = 1;
932 : :
933 : 0 : return DBG_STATUS_OK;
934 : : }
935 : :
936 : : static const struct dbg_block *get_dbg_block(struct ecore_hwfn *p_hwfn,
937 : : enum block_id block_id)
938 : : {
939 : : const struct dbg_block *dbg_block;
940 : :
941 : 0 : dbg_block = p_hwfn->dbg_arrays[BIN_BUF_DBG_BLOCKS].ptr;
942 : 0 : return dbg_block + block_id;
943 : : }
944 : :
945 : : static const struct dbg_block_chip *qed_get_dbg_block_per_chip(struct ecore_hwfn
946 : : *p_hwfn,
947 : : enum block_id
948 : : block_id)
949 : : {
950 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
951 : :
952 : : return (const struct dbg_block_chip *)
953 : 0 : p_hwfn->dbg_arrays[BIN_BUF_DBG_BLOCKS_CHIP_DATA].ptr +
954 : 0 : block_id * MAX_CHIP_IDS + dev_data->chip_id;
955 : : }
956 : :
957 : : static const struct dbg_reset_reg *qed_get_dbg_reset_reg(struct ecore_hwfn
958 : : *p_hwfn,
959 : : u8 reset_reg_id)
960 : : {
961 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
962 : :
963 : : return (const struct dbg_reset_reg *)
964 : 0 : p_hwfn->dbg_arrays[BIN_BUF_DBG_RESET_REGS].ptr +
965 : 0 : reset_reg_id * MAX_CHIP_IDS + dev_data->chip_id;
966 : : }
967 : :
968 : : /* Reads the FW info structure for the specified Storm from the chip,
969 : : * and writes it to the specified fw_info pointer.
970 : : */
971 : 0 : static void qed_read_storm_fw_info(struct ecore_hwfn *p_hwfn,
972 : : struct ecore_ptt *p_ptt,
973 : : u8 storm_id, struct fw_info *fw_info)
974 : : {
975 : 0 : struct storm_defs *storm = &s_storm_defs[storm_id];
976 : : struct fw_info_location fw_info_location;
977 : : u32 addr, i, *dest;
978 : :
979 : : memset(&fw_info_location, 0, sizeof(fw_info_location));
980 : : memset(fw_info, 0, sizeof(*fw_info));
981 : :
982 : : /* Read first the address that points to fw_info location.
983 : : * The address is located in the last line of the Storm RAM.
984 : : */
985 : 0 : addr = storm->sem_fast_mem_addr + SEM_FAST_REG_INT_RAM +
986 : : DWORDS_TO_BYTES(SEM_FAST_REG_INT_RAM_SIZE) -
987 : : sizeof(fw_info_location);
988 : :
989 : : dest = (u32 *)&fw_info_location;
990 : :
991 [ # # ]: 0 : for (i = 0; i < BYTES_TO_DWORDS(sizeof(fw_info_location));
992 : 0 : i++, addr += BYTES_IN_DWORD)
993 : 0 : dest[i] = ecore_rd(p_hwfn, p_ptt, addr);
994 : :
995 : : /* Read FW version info from Storm RAM */
996 [ # # ]: 0 : if (fw_info_location.size > 0 && fw_info_location.size <=
997 : : sizeof(*fw_info)) {
998 : 0 : addr = fw_info_location.grc_addr;
999 : : dest = (u32 *)fw_info;
1000 [ # # ]: 0 : for (i = 0; i < BYTES_TO_DWORDS(fw_info_location.size);
1001 : 0 : i++, addr += BYTES_IN_DWORD)
1002 : 0 : dest[i] = ecore_rd(p_hwfn, p_ptt, addr);
1003 : : }
1004 : 0 : }
1005 : :
1006 : : /* Dumps the specified string to the specified buffer.
1007 : : * Returns the dumped size in bytes.
1008 : : */
1009 : 0 : static u32 qed_dump_str(char *dump_buf, bool dump, const char *str)
1010 : : {
1011 [ # # ]: 0 : if (dump)
1012 : : strcpy(dump_buf, str);
1013 : :
1014 : 0 : return (u32)strlen(str) + 1;
1015 : : }
1016 : :
1017 : : /* Dumps zeros to align the specified buffer to dwords.
1018 : : * Returns the dumped size in bytes.
1019 : : */
1020 : 0 : static u32 qed_dump_align(char *dump_buf, bool dump, u32 byte_offset)
1021 : : {
1022 : : u8 offset_in_dword, align_size;
1023 : :
1024 : 0 : offset_in_dword = (u8)(byte_offset & 0x3);
1025 [ # # ]: 0 : align_size = offset_in_dword ? BYTES_IN_DWORD - offset_in_dword : 0;
1026 : :
1027 [ # # ]: 0 : if (dump && align_size)
1028 : 0 : memset(dump_buf, 0, align_size);
1029 : :
1030 : 0 : return align_size;
1031 : : }
1032 : :
1033 : : /* Writes the specified string param to the specified buffer.
1034 : : * Returns the dumped size in dwords.
1035 : : */
1036 : 0 : static u32 qed_dump_str_param(u32 *dump_buf,
1037 : : bool dump,
1038 : : const char *param_name, const char *param_val)
1039 : : {
1040 : : char *char_buf = (char *)dump_buf;
1041 : : u32 offset = 0;
1042 : :
1043 : : /* Dump param name */
1044 : 0 : offset += qed_dump_str(char_buf + offset, dump, param_name);
1045 : :
1046 : : /* Indicate a string param value */
1047 [ # # ]: 0 : if (dump)
1048 : 0 : *(char_buf + offset) = 1;
1049 : 0 : offset++;
1050 : :
1051 : : /* Dump param value */
1052 : 0 : offset += qed_dump_str(char_buf + offset, dump, param_val);
1053 : :
1054 : : /* Align buffer to next dword */
1055 : 0 : offset += qed_dump_align(char_buf + offset, dump, offset);
1056 : :
1057 : 0 : return BYTES_TO_DWORDS(offset);
1058 : : }
1059 : :
1060 : : /* Writes the specified numeric param to the specified buffer.
1061 : : * Returns the dumped size in dwords.
1062 : : */
1063 : 0 : static u32 qed_dump_num_param(u32 *dump_buf,
1064 : : bool dump, const char *param_name, u32 param_val)
1065 : : {
1066 : : char *char_buf = (char *)dump_buf;
1067 : : u32 offset = 0;
1068 : :
1069 : : /* Dump param name */
1070 : 0 : offset += qed_dump_str(char_buf + offset, dump, param_name);
1071 : :
1072 : : /* Indicate a numeric param value */
1073 [ # # ]: 0 : if (dump)
1074 : 0 : *(char_buf + offset) = 0;
1075 : 0 : offset++;
1076 : :
1077 : : /* Align buffer to next dword */
1078 : 0 : offset += qed_dump_align(char_buf + offset, dump, offset);
1079 : :
1080 : : /* Dump param value (and change offset from bytes to dwords) */
1081 : 0 : offset = BYTES_TO_DWORDS(offset);
1082 [ # # ]: 0 : if (dump)
1083 : 0 : *(dump_buf + offset) = param_val;
1084 : 0 : offset++;
1085 : :
1086 : 0 : return offset;
1087 : : }
1088 : :
1089 : : /* Reads the FW version and writes it as a param to the specified buffer.
1090 : : * Returns the dumped size in dwords.
1091 : : */
1092 : 0 : static u32 qed_dump_fw_ver_param(struct ecore_hwfn *p_hwfn,
1093 : : struct ecore_ptt *p_ptt,
1094 : : u32 *dump_buf, bool dump)
1095 : : {
1096 : 0 : char fw_ver_str[16] = EMPTY_FW_VERSION_STR;
1097 : 0 : char fw_img_str[16] = EMPTY_FW_IMAGE_STR;
1098 : 0 : struct fw_info fw_info = { {0}, {0} };
1099 : : u32 offset = 0;
1100 : :
1101 [ # # # # ]: 0 : if (dump && !qed_grc_get_param(p_hwfn, DBG_GRC_PARAM_NO_FW_VER)) {
1102 : : /* Read FW info from chip */
1103 : 0 : qed_read_fw_info(p_hwfn, p_ptt, &fw_info);
1104 : :
1105 : : /* Create FW version/image strings */
1106 : 0 : if (snprintf(fw_ver_str, sizeof(fw_ver_str),
1107 : 0 : "%d_%d_%d_%d", fw_info.ver.num.major,
1108 : 0 : fw_info.ver.num.minor, fw_info.ver.num.rev,
1109 [ # # ]: 0 : fw_info.ver.num.eng) < 0)
1110 : 0 : DP_NOTICE(p_hwfn, false,
1111 : : "Unexpected debug error: invalid FW version string\n");
1112 [ # # ]: 0 : switch (fw_info.ver.image_id) {
1113 : : case FW_IMG_MAIN:
1114 : : strcpy(fw_img_str, "main");
1115 : : break;
1116 : : default:
1117 : : strcpy(fw_img_str, "unknown");
1118 : : break;
1119 : : }
1120 : : }
1121 : :
1122 : : /* Dump FW version, image and timestamp */
1123 : 0 : offset += qed_dump_str_param(dump_buf + offset,
1124 : : dump, "fw-version", fw_ver_str);
1125 : 0 : offset += qed_dump_str_param(dump_buf + offset,
1126 : : dump, "fw-image", fw_img_str);
1127 : 0 : offset += qed_dump_num_param(dump_buf + offset,
1128 : : dump,
1129 : : "fw-timestamp", fw_info.ver.timestamp);
1130 : :
1131 : 0 : return offset;
1132 : : }
1133 : :
1134 : : /* Reads the MFW version and writes it as a param to the specified buffer.
1135 : : * Returns the dumped size in dwords.
1136 : : */
1137 : 0 : static u32 qed_dump_mfw_ver_param(struct ecore_hwfn *p_hwfn,
1138 : : struct ecore_ptt *p_ptt,
1139 : : u32 *dump_buf, bool dump)
1140 : : {
1141 : 0 : char mfw_ver_str[16] = EMPTY_FW_VERSION_STR;
1142 : :
1143 [ # # # # ]: 0 : if (dump &&
1144 : : !qed_grc_get_param(p_hwfn, DBG_GRC_PARAM_NO_FW_VER)) {
1145 : : u32 global_section_offsize, global_section_addr, mfw_ver;
1146 : : u32 public_data_addr, global_section_offsize_addr;
1147 : :
1148 : : /* Find MCP public data GRC address. Needs to be ORed with
1149 : : * MCP_REG_SCRATCH due to a HW bug.
1150 : : */
1151 : 0 : public_data_addr = ecore_rd(p_hwfn,
1152 : : p_ptt,
1153 : : MISC_REG_SHARED_MEM_ADDR) |
1154 : : MCP_REG_SCRATCH;
1155 : :
1156 : : /* Find MCP public global section offset */
1157 : 0 : global_section_offsize_addr = public_data_addr +
1158 : : offsetof(struct mcp_public_data,
1159 : : sections) +
1160 : : sizeof(offsize_t) * PUBLIC_GLOBAL;
1161 : 0 : global_section_offsize = ecore_rd(p_hwfn, p_ptt,
1162 : : global_section_offsize_addr);
1163 : 0 : global_section_addr =
1164 : 0 : MCP_REG_SCRATCH +
1165 : 0 : (global_section_offsize & OFFSIZE_OFFSET_MASK) * 4;
1166 : :
1167 : : /* Read MFW version from MCP public global section */
1168 : 0 : mfw_ver = ecore_rd(p_hwfn, p_ptt,
1169 : : global_section_addr +
1170 : : offsetof(struct public_global, mfw_ver));
1171 : :
1172 : : /* Dump MFW version param */
1173 : 0 : if (snprintf(mfw_ver_str, sizeof(mfw_ver_str), "%d_%d_%d_%d",
1174 : 0 : (u8)(mfw_ver >> 24), (u8)(mfw_ver >> 16),
1175 [ # # ]: 0 : (u8)(mfw_ver >> 8), (u8)mfw_ver) < 0)
1176 : 0 : DP_NOTICE(p_hwfn, false,
1177 : : "Unexpected debug error: invalid MFW version string\n");
1178 : : }
1179 : :
1180 : 0 : return qed_dump_str_param(dump_buf, dump, "mfw-version", mfw_ver_str);
1181 : : }
1182 : :
1183 : : /* Reads the chip revision from the chip and writes it as a param to the
1184 : : * specified buffer. Returns the dumped size in dwords.
1185 : : */
1186 : 0 : static u32 qed_dump_chip_revision_param(struct ecore_hwfn *p_hwfn,
1187 : : struct ecore_ptt *p_ptt,
1188 : : u32 *dump_buf, bool dump)
1189 : : {
1190 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
1191 : 0 : char param_str[3] = "??";
1192 : :
1193 [ # # ]: 0 : if (dev_data->hw_type == HW_TYPE_ASIC) {
1194 : : u32 chip_rev, chip_metal;
1195 : :
1196 : 0 : chip_rev = ecore_rd(p_hwfn, p_ptt, MISCS_REG_CHIP_REV);
1197 : 0 : chip_metal = ecore_rd(p_hwfn, p_ptt, MISCS_REG_CHIP_METAL);
1198 : :
1199 : 0 : param_str[0] = 'a' + (u8)chip_rev;
1200 : 0 : param_str[1] = '0' + (u8)chip_metal;
1201 : : }
1202 : :
1203 : 0 : return qed_dump_str_param(dump_buf, dump, "chip-revision", param_str);
1204 : : }
1205 : :
1206 : : /* Writes a section header to the specified buffer.
1207 : : * Returns the dumped size in dwords.
1208 : : */
1209 : : static u32 qed_dump_section_hdr(u32 *dump_buf,
1210 : : bool dump, const char *name, u32 num_params)
1211 : : {
1212 : 0 : return qed_dump_num_param(dump_buf, dump, name, num_params);
1213 : : }
1214 : :
1215 : : /* Writes the common global params to the specified buffer.
1216 : : * Returns the dumped size in dwords.
1217 : : */
1218 : 0 : static u32 qed_dump_common_global_params(struct ecore_hwfn *p_hwfn,
1219 : : struct ecore_ptt *p_ptt,
1220 : : u32 *dump_buf,
1221 : : bool dump,
1222 : : u8 num_specific_global_params)
1223 : : {
1224 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
1225 : : char sw_platform_str[MAX_SW_PLTAFORM_STR_SIZE];
1226 : : u32 offset = 0;
1227 : : u8 num_params;
1228 : :
1229 : : /* Fill platform string */
1230 : 0 : ecore_set_platform_str(p_hwfn, sw_platform_str,
1231 : : MAX_SW_PLTAFORM_STR_SIZE);
1232 : :
1233 : : /* Dump global params section header */
1234 : 0 : num_params = NUM_COMMON_GLOBAL_PARAMS + num_specific_global_params +
1235 : 0 : (dev_data->chip_id == CHIP_BB ? 1 : 0);
1236 : 0 : offset += qed_dump_section_hdr(dump_buf + offset,
1237 : : dump, "global_params", num_params);
1238 : :
1239 : : /* Store params */
1240 : 0 : offset += qed_dump_fw_ver_param(p_hwfn, p_ptt, dump_buf + offset, dump);
1241 : 0 : offset += qed_dump_mfw_ver_param(p_hwfn,
1242 : 0 : p_ptt, dump_buf + offset, dump);
1243 : 0 : offset += qed_dump_chip_revision_param(p_hwfn,
1244 : 0 : p_ptt, dump_buf + offset, dump);
1245 : 0 : offset += qed_dump_num_param(dump_buf + offset,
1246 : : dump, "tools-version", TOOLS_VERSION);
1247 : 0 : offset += qed_dump_str_param(dump_buf + offset,
1248 : : dump,
1249 : : "chip",
1250 : 0 : s_chip_defs[dev_data->chip_id].name);
1251 : 0 : offset += qed_dump_str_param(dump_buf + offset,
1252 : : dump,
1253 : : "platform",
1254 : 0 : s_hw_type_defs[dev_data->hw_type].name);
1255 : 0 : offset += qed_dump_str_param(dump_buf + offset,
1256 : : dump, "sw-platform", sw_platform_str);
1257 : 0 : offset += qed_dump_num_param(dump_buf + offset,
1258 : 0 : dump, "pci-func", p_hwfn->abs_pf_id);
1259 : 0 : offset += qed_dump_num_param(dump_buf + offset,
1260 : 0 : dump, "epoch", OSAL_GET_EPOCH(p_hwfn));
1261 [ # # ]: 0 : if (dev_data->chip_id == CHIP_BB)
1262 : 0 : offset += qed_dump_num_param(dump_buf + offset,
1263 : : dump, "path",
1264 [ # # ]: 0 : ECORE_PATH_ID(p_hwfn));
1265 : :
1266 : 0 : return offset;
1267 : : }
1268 : :
1269 : : /* Writes the "last" section (including CRC) to the specified buffer at the
1270 : : * given offset. Returns the dumped size in dwords.
1271 : : */
1272 : 0 : static u32 qed_dump_last_section(u32 *dump_buf, u32 offset, bool dump)
1273 : : {
1274 : : u32 start_offset = offset;
1275 : :
1276 : : /* Dump CRC section header */
1277 : 0 : offset += qed_dump_section_hdr(dump_buf + offset, dump, "last", 0);
1278 : :
1279 : : /* Calculate CRC32 and add it to the dword after the "last" section */
1280 [ # # ]: 0 : if (dump)
1281 : 0 : *(dump_buf + offset) = ~OSAL_CRC32(0xffffffff,
1282 : : (u8 *)dump_buf,
1283 : : DWORDS_TO_BYTES(offset));
1284 : :
1285 : 0 : offset++;
1286 : :
1287 : 0 : return offset - start_offset;
1288 : : }
1289 : :
1290 : : /* Update blocks reset state */
1291 : 0 : static void qed_update_blocks_reset_state(struct ecore_hwfn *p_hwfn,
1292 : : struct ecore_ptt *p_ptt)
1293 : : {
1294 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
1295 : 0 : u32 reg_val[NUM_DBG_RESET_REGS] = { 0 };
1296 : : u8 rst_reg_id;
1297 : : u32 blk_id;
1298 : :
1299 : : /* Read reset registers */
1300 [ # # ]: 0 : for (rst_reg_id = 0; rst_reg_id < NUM_DBG_RESET_REGS; rst_reg_id++) {
1301 : : const struct dbg_reset_reg *rst_reg;
1302 : : bool rst_reg_removed;
1303 : : u32 rst_reg_addr;
1304 : :
1305 : 0 : rst_reg = qed_get_dbg_reset_reg(p_hwfn, rst_reg_id);
1306 : 0 : rst_reg_removed = GET_FIELD(rst_reg->data,
1307 : : DBG_RESET_REG_IS_REMOVED);
1308 : 0 : rst_reg_addr = DWORDS_TO_BYTES(GET_FIELD(rst_reg->data,
1309 : : DBG_RESET_REG_ADDR));
1310 : :
1311 [ # # ]: 0 : if (!rst_reg_removed)
1312 : 0 : reg_val[rst_reg_id] = ecore_rd(p_hwfn, p_ptt,
1313 : : rst_reg_addr);
1314 : : }
1315 : :
1316 : : /* Check if blocks are in reset */
1317 [ # # ]: 0 : for (blk_id = 0; blk_id < NUM_PHYS_BLOCKS; blk_id++) {
1318 : : const struct dbg_block_chip *blk;
1319 : : bool has_rst_reg;
1320 : : bool is_removed;
1321 : :
1322 : : blk = qed_get_dbg_block_per_chip(p_hwfn, (enum block_id)blk_id);
1323 : 0 : is_removed = GET_FIELD(blk->flags, DBG_BLOCK_CHIP_IS_REMOVED);
1324 : 0 : has_rst_reg = GET_FIELD(blk->flags,
1325 : : DBG_BLOCK_CHIP_HAS_RESET_REG);
1326 : :
1327 [ # # ]: 0 : if (!is_removed && has_rst_reg)
1328 : 0 : dev_data->block_in_reset[blk_id] =
1329 : 0 : !(reg_val[blk->reset_reg_id] &
1330 : 0 : OSAL_BIT(blk->reset_reg_bit_offset));
1331 : : }
1332 : 0 : }
1333 : :
1334 : : /* is_mode_match recursive function */
1335 : 0 : static bool qed_is_mode_match_rec(struct ecore_hwfn *p_hwfn,
1336 : : u16 *modes_buf_offset, u8 rec_depth)
1337 : : {
1338 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
1339 : : const u8 *dbg_array;
1340 : : bool arg1, arg2;
1341 : : u8 tree_val;
1342 : :
1343 [ # # ]: 0 : if (rec_depth > MAX_RECURSION_DEPTH) {
1344 : 0 : DP_NOTICE(p_hwfn, false,
1345 : : "Unexpected error: is_mode_match_rec exceeded the max recursion depth. This is probably due to a corrupt init/debug buffer.\n");
1346 : 0 : return false;
1347 : : }
1348 : :
1349 : : /* Get next element from modes tree buffer */
1350 : 0 : dbg_array = p_hwfn->dbg_arrays[BIN_BUF_DBG_MODE_TREE].ptr;
1351 : 0 : tree_val = dbg_array[(*modes_buf_offset)++];
1352 : :
1353 [ # # # ]: 0 : switch (tree_val) {
1354 : 0 : case INIT_MODE_OP_NOT:
1355 : 0 : return !qed_is_mode_match_rec(p_hwfn,
1356 : 0 : modes_buf_offset, rec_depth + 1);
1357 : 0 : case INIT_MODE_OP_OR:
1358 : : case INIT_MODE_OP_AND:
1359 : 0 : arg1 = qed_is_mode_match_rec(p_hwfn,
1360 : 0 : modes_buf_offset, rec_depth + 1);
1361 : 0 : arg2 = qed_is_mode_match_rec(p_hwfn,
1362 : : modes_buf_offset, rec_depth + 1);
1363 : : return (tree_val == INIT_MODE_OP_OR) ? (arg1 ||
1364 [ # # ]: 0 : arg2) : (arg1 && arg2);
1365 : 0 : default:
1366 : 0 : return dev_data->mode_enable[tree_val - MAX_INIT_MODE_OPS] > 0;
1367 : : }
1368 : : }
1369 : :
1370 : : /* Returns true if the mode (specified using modes_buf_offset) is enabled */
1371 : : static bool qed_is_mode_match(struct ecore_hwfn *p_hwfn, u16 *modes_buf_offset)
1372 : : {
1373 : 0 : return qed_is_mode_match_rec(p_hwfn, modes_buf_offset, 0);
1374 : : }
1375 : :
1376 : : /* Enable / disable the Debug block */
1377 : : static void qed_bus_enable_dbg_block(struct ecore_hwfn *p_hwfn,
1378 : : struct ecore_ptt *p_ptt, bool enable)
1379 : : {
1380 : 0 : ecore_wr(p_hwfn, p_ptt, DBG_REG_DBG_BLOCK_ON, enable ? 1 : 0);
1381 : 0 : }
1382 : :
1383 : : /* Resets the Debug block */
1384 : 0 : static void qed_bus_reset_dbg_block(struct ecore_hwfn *p_hwfn,
1385 : : struct ecore_ptt *p_ptt)
1386 : : {
1387 : : u32 reset_reg_addr, old_reset_reg_val, new_reset_reg_val;
1388 : : const struct dbg_reset_reg *reset_reg;
1389 : : const struct dbg_block_chip *block;
1390 : :
1391 : : block = qed_get_dbg_block_per_chip(p_hwfn, BLOCK_DBG);
1392 : 0 : reset_reg = qed_get_dbg_reset_reg(p_hwfn, block->reset_reg_id);
1393 : 0 : reset_reg_addr =
1394 : 0 : DWORDS_TO_BYTES(GET_FIELD(reset_reg->data, DBG_RESET_REG_ADDR));
1395 : :
1396 : 0 : old_reset_reg_val = ecore_rd(p_hwfn, p_ptt, reset_reg_addr);
1397 : 0 : new_reset_reg_val =
1398 : 0 : old_reset_reg_val & ~OSAL_BIT(block->reset_reg_bit_offset);
1399 : :
1400 : 0 : ecore_wr(p_hwfn, p_ptt, reset_reg_addr, new_reset_reg_val);
1401 : 0 : ecore_wr(p_hwfn, p_ptt, reset_reg_addr, old_reset_reg_val);
1402 : 0 : }
1403 : :
1404 : : /* Enable / disable Debug Bus clients according to the specified mask
1405 : : * (1 = enable, 0 = disable).
1406 : : */
1407 : : static void qed_bus_enable_clients(struct ecore_hwfn *p_hwfn,
1408 : : struct ecore_ptt *p_ptt, u32 client_mask)
1409 : : {
1410 : 0 : ecore_wr(p_hwfn, p_ptt, DBG_REG_CLIENT_ENABLE, client_mask);
1411 : 0 : }
1412 : :
1413 : 0 : static void qed_bus_config_dbg_line(struct ecore_hwfn *p_hwfn,
1414 : : struct ecore_ptt *p_ptt,
1415 : : enum block_id block_id,
1416 : : u8 line_id,
1417 : : u8 enable_mask,
1418 : : u8 right_shift,
1419 : : u8 force_valid_mask, u8 force_frame_mask)
1420 : : {
1421 : : const struct dbg_block_chip *block =
1422 : : qed_get_dbg_block_per_chip(p_hwfn, block_id);
1423 : :
1424 : 0 : ecore_wr(p_hwfn, p_ptt,
1425 : 0 : DWORDS_TO_BYTES(block->dbg_select_reg_addr),
1426 : : line_id);
1427 : 0 : ecore_wr(p_hwfn, p_ptt,
1428 : 0 : DWORDS_TO_BYTES(block->dbg_dword_enable_reg_addr),
1429 : : enable_mask);
1430 : 0 : ecore_wr(p_hwfn, p_ptt,
1431 : 0 : DWORDS_TO_BYTES(block->dbg_shift_reg_addr),
1432 : : right_shift);
1433 : 0 : ecore_wr(p_hwfn, p_ptt,
1434 : 0 : DWORDS_TO_BYTES(block->dbg_force_valid_reg_addr),
1435 : : force_valid_mask);
1436 : 0 : ecore_wr(p_hwfn, p_ptt,
1437 : 0 : DWORDS_TO_BYTES(block->dbg_force_frame_reg_addr),
1438 : : force_frame_mask);
1439 : 0 : }
1440 : :
1441 : : /* Disable debug bus in all blocks */
1442 : 0 : static void qed_bus_disable_blocks(struct ecore_hwfn *p_hwfn,
1443 : : struct ecore_ptt *p_ptt)
1444 : : {
1445 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
1446 : : u32 block_id;
1447 : :
1448 : : /* Disable all blocks */
1449 [ # # ]: 0 : for (block_id = 0; block_id < MAX_BLOCK_ID; block_id++) {
1450 : : const struct dbg_block_chip *block_per_chip =
1451 : : qed_get_dbg_block_per_chip(p_hwfn,
1452 : : (enum block_id)block_id);
1453 : :
1454 [ # # ]: 0 : if (GET_FIELD(block_per_chip->flags,
1455 : 0 : DBG_BLOCK_CHIP_IS_REMOVED) ||
1456 [ # # ]: 0 : dev_data->block_in_reset[block_id])
1457 : 0 : continue;
1458 : :
1459 : : /* Disable debug bus */
1460 [ # # ]: 0 : if (GET_FIELD(block_per_chip->flags,
1461 : : DBG_BLOCK_CHIP_HAS_DBG_BUS)) {
1462 : 0 : u32 dbg_en_addr =
1463 : : block_per_chip->dbg_dword_enable_reg_addr;
1464 : 0 : u16 modes_buf_offset =
1465 : 0 : GET_FIELD(block_per_chip->dbg_bus_mode.data,
1466 : : DBG_MODE_HDR_MODES_BUF_OFFSET);
1467 : : bool eval_mode =
1468 : : GET_FIELD(block_per_chip->dbg_bus_mode.data,
1469 : : DBG_MODE_HDR_EVAL_MODE) > 0;
1470 : :
1471 [ # # # # ]: 0 : if (!eval_mode ||
1472 : : qed_is_mode_match(p_hwfn, &modes_buf_offset))
1473 : 0 : ecore_wr(p_hwfn, p_ptt,
1474 : : DWORDS_TO_BYTES(dbg_en_addr),
1475 : : 0);
1476 : : }
1477 : : }
1478 : 0 : }
1479 : :
1480 : : /* Returns true if the specified entity (indicated by GRC param) should be
1481 : : * included in the dump, false otherwise.
1482 : : */
1483 : : static bool qed_grc_is_included(struct ecore_hwfn *p_hwfn,
1484 : : enum dbg_grc_params grc_param)
1485 : : {
1486 : 0 : return qed_grc_get_param(p_hwfn, grc_param) > 0;
1487 : : }
1488 : :
1489 : : /* Returns the storm_id that matches the specified Storm letter,
1490 : : * or MAX_DBG_STORMS if invalid storm letter.
1491 : : */
1492 : : static enum dbg_storms qed_get_id_from_letter(char storm_letter)
1493 : : {
1494 : : u8 storm_id;
1495 : :
1496 [ # # ]: 0 : for (storm_id = 0; storm_id < MAX_DBG_STORMS; storm_id++)
1497 [ # # ]: 0 : if (s_storm_defs[storm_id].letter == storm_letter)
1498 : 0 : return (enum dbg_storms)storm_id;
1499 : :
1500 : : return MAX_DBG_STORMS;
1501 : : }
1502 : :
1503 : : /* Returns true of the specified Storm should be included in the dump, false
1504 : : * otherwise.
1505 : : */
1506 : : static bool qed_grc_is_storm_included(struct ecore_hwfn *p_hwfn,
1507 : : enum dbg_storms storm)
1508 : : {
1509 : : return qed_grc_get_param(p_hwfn, (enum dbg_grc_params)storm) > 0;
1510 : : }
1511 : :
1512 : : /* Returns true if the specified memory should be included in the dump, false
1513 : : * otherwise.
1514 : : */
1515 : 0 : static bool qed_grc_is_mem_included(struct ecore_hwfn *p_hwfn,
1516 : : enum block_id block_id, u8 mem_group_id)
1517 : : {
1518 : : const struct dbg_block *block;
1519 : : u8 i;
1520 : :
1521 : : block = get_dbg_block(p_hwfn, block_id);
1522 : :
1523 : : /* If the block is associated with a Storm, check Storm match */
1524 [ # # ]: 0 : if (block->associated_storm_letter) {
1525 : : enum dbg_storms associated_storm_id =
1526 : 0 : qed_get_id_from_letter(block->associated_storm_letter);
1527 : :
1528 [ # # # # ]: 0 : if (associated_storm_id == MAX_DBG_STORMS ||
1529 : : !qed_grc_is_storm_included(p_hwfn, associated_storm_id))
1530 : : return false;
1531 : : }
1532 : :
1533 [ # # ]: 0 : for (i = 0; i < NUM_BIG_RAM_TYPES; i++) {
1534 : 0 : struct big_ram_defs *big_ram = &s_big_ram_defs[i];
1535 : :
1536 [ # # ]: 0 : if (mem_group_id == big_ram->mem_group_id ||
1537 [ # # ]: 0 : mem_group_id == big_ram->ram_mem_group_id)
1538 : 0 : return qed_grc_is_included(p_hwfn, big_ram->grc_param);
1539 : : }
1540 : :
1541 [ # # # # : 0 : switch (mem_group_id) {
# # # # #
# # # # #
# # # # ]
1542 : : case MEM_GROUP_PXP_ILT:
1543 : : case MEM_GROUP_PXP_MEM:
1544 : 0 : return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_PXP);
1545 : : case MEM_GROUP_RAM:
1546 : 0 : return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_RAM);
1547 : : case MEM_GROUP_PBUF:
1548 : 0 : return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_PBUF);
1549 : : case MEM_GROUP_CAU_MEM:
1550 : : case MEM_GROUP_CAU_SB:
1551 : : case MEM_GROUP_CAU_PI:
1552 : 0 : return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_CAU);
1553 : : case MEM_GROUP_CAU_MEM_EXT:
1554 : 0 : return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_CAU_EXT);
1555 : : case MEM_GROUP_QM_MEM:
1556 : 0 : return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_QM);
1557 : : case MEM_GROUP_CFC_MEM:
1558 : : case MEM_GROUP_CONN_CFC_MEM:
1559 : : case MEM_GROUP_TASK_CFC_MEM:
1560 [ # # # # ]: 0 : return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_CFC) ||
1561 : : qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_CM_CTX);
1562 : : case MEM_GROUP_DORQ_MEM:
1563 : 0 : return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_DORQ);
1564 : : case MEM_GROUP_IGU_MEM:
1565 : : case MEM_GROUP_IGU_MSIX:
1566 : 0 : return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_IGU);
1567 : : case MEM_GROUP_MULD_MEM:
1568 : 0 : return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_MULD);
1569 : : case MEM_GROUP_PRS_MEM:
1570 : 0 : return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_PRS);
1571 : : case MEM_GROUP_DMAE_MEM:
1572 : 0 : return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_DMAE);
1573 : : case MEM_GROUP_TM_MEM:
1574 : 0 : return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_TM);
1575 : : case MEM_GROUP_SDM_MEM:
1576 : 0 : return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_SDM);
1577 : : case MEM_GROUP_TDIF_CTX:
1578 : : case MEM_GROUP_RDIF_CTX:
1579 : 0 : return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_DIF);
1580 : : case MEM_GROUP_CM_MEM:
1581 : 0 : return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_CM);
1582 : : case MEM_GROUP_IOR:
1583 : 0 : return qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_IOR);
1584 : : default:
1585 : : return true;
1586 : : }
1587 : : }
1588 : :
1589 : : /* Stalls all Storms */
1590 : 0 : static void qed_grc_stall_storms(struct ecore_hwfn *p_hwfn,
1591 : : struct ecore_ptt *p_ptt, bool stall)
1592 : : {
1593 : : u32 reg_addr;
1594 : : u8 storm_id;
1595 : :
1596 [ # # ]: 0 : for (storm_id = 0; storm_id < MAX_DBG_STORMS; storm_id++) {
1597 [ # # ]: 0 : if (!qed_grc_is_storm_included(p_hwfn,
1598 : : (enum dbg_storms)storm_id))
1599 : 0 : continue;
1600 : :
1601 : 0 : reg_addr = s_storm_defs[storm_id].sem_fast_mem_addr +
1602 : : SEM_FAST_REG_STALL_0;
1603 : 0 : ecore_wr(p_hwfn, p_ptt, reg_addr, stall ? 1 : 0);
1604 : : }
1605 : :
1606 : 0 : OSAL_MSLEEP(STALL_DELAY_MS);
1607 : 0 : }
1608 : :
1609 : : /* Takes all blocks out of reset. If rbc_only is true, only RBC clients are
1610 : : * taken out of reset.
1611 : : */
1612 : 0 : static void qed_grc_unreset_blocks(struct ecore_hwfn *p_hwfn,
1613 : : struct ecore_ptt *p_ptt, bool rbc_only)
1614 : : {
1615 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
1616 : 0 : u8 chip_id = dev_data->chip_id;
1617 : : u32 i;
1618 : :
1619 : : /* Take RBCs out of reset */
1620 [ # # ]: 0 : for (i = 0; i < OSAL_ARRAY_SIZE(s_rbc_reset_defs); i++)
1621 [ # # ]: 0 : if (s_rbc_reset_defs[i].reset_val[dev_data->chip_id])
1622 : 0 : ecore_wr(p_hwfn,
1623 : : p_ptt,
1624 : 0 : s_rbc_reset_defs[i].reset_reg_addr +
1625 : : RESET_REG_UNRESET_OFFSET,
1626 : : s_rbc_reset_defs[i].reset_val[chip_id]);
1627 : :
1628 [ # # ]: 0 : if (!rbc_only) {
1629 : 0 : u32 reg_val[NUM_DBG_RESET_REGS] = { 0 };
1630 : : u8 reset_reg_id;
1631 : : u32 block_id;
1632 : :
1633 : : /* Fill reset regs values */
1634 [ # # ]: 0 : for (block_id = 0; block_id < NUM_PHYS_BLOCKS; block_id++) {
1635 : : bool is_removed, has_reset_reg, unreset_before_dump;
1636 : : const struct dbg_block_chip *block;
1637 : :
1638 : : block = qed_get_dbg_block_per_chip(p_hwfn,
1639 : : (enum block_id)
1640 : : block_id);
1641 : : is_removed =
1642 : 0 : GET_FIELD(block->flags, DBG_BLOCK_CHIP_IS_REMOVED);
1643 : 0 : has_reset_reg =
1644 : 0 : GET_FIELD(block->flags,
1645 : : DBG_BLOCK_CHIP_HAS_RESET_REG);
1646 : : unreset_before_dump =
1647 : 0 : GET_FIELD(block->flags,
1648 : : DBG_BLOCK_CHIP_UNRESET_BEFORE_DUMP);
1649 : :
1650 [ # # # # ]: 0 : if (!is_removed && has_reset_reg && unreset_before_dump)
1651 : 0 : reg_val[block->reset_reg_id] |=
1652 : 0 : OSAL_BIT(block->reset_reg_bit_offset);
1653 : : }
1654 : :
1655 : : /* Write reset registers */
1656 [ # # ]: 0 : for (reset_reg_id = 0; reset_reg_id < NUM_DBG_RESET_REGS;
1657 : 0 : reset_reg_id++) {
1658 : : const struct dbg_reset_reg *reset_reg;
1659 : : u32 reset_reg_addr;
1660 : :
1661 : 0 : reset_reg = qed_get_dbg_reset_reg(p_hwfn, reset_reg_id);
1662 : :
1663 [ # # ]: 0 : if (GET_FIELD
1664 : : (reset_reg->data, DBG_RESET_REG_IS_REMOVED))
1665 : 0 : continue;
1666 : :
1667 [ # # ]: 0 : if (reg_val[reset_reg_id]) {
1668 : 0 : reset_reg_addr =
1669 : : GET_FIELD(reset_reg->data,
1670 : : DBG_RESET_REG_ADDR);
1671 : 0 : ecore_wr(p_hwfn,
1672 : : p_ptt,
1673 : : DWORDS_TO_BYTES(reset_reg_addr) +
1674 : : RESET_REG_UNRESET_OFFSET,
1675 : : reg_val[reset_reg_id]);
1676 : : }
1677 : : }
1678 : : }
1679 : 0 : }
1680 : :
1681 : : /* Returns the attention block data of the specified block */
1682 : : static const struct dbg_attn_block_type_data *
1683 : : qed_get_block_attn_data(struct ecore_hwfn *p_hwfn,
1684 : : enum block_id block_id, enum dbg_attn_type attn_type)
1685 : : {
1686 : 0 : const struct dbg_attn_block *base_attn_block_arr =
1687 : : (const struct dbg_attn_block *)
1688 : : p_hwfn->dbg_arrays[BIN_BUF_DBG_ATTN_BLOCKS].ptr;
1689 : :
1690 : 0 : return &base_attn_block_arr[block_id].per_type_data[attn_type];
1691 : : }
1692 : :
1693 : : /* Returns the attention registers of the specified block */
1694 : : static const struct dbg_attn_reg *
1695 : : qed_get_block_attn_regs(struct ecore_hwfn *p_hwfn,
1696 : : enum block_id block_id, enum dbg_attn_type attn_type,
1697 : : u8 *num_attn_regs)
1698 : : {
1699 : : const struct dbg_attn_block_type_data *block_type_data =
1700 : : qed_get_block_attn_data(p_hwfn, block_id, attn_type);
1701 : :
1702 : 0 : *num_attn_regs = block_type_data->num_regs;
1703 : :
1704 : : return (const struct dbg_attn_reg *)
1705 : 0 : p_hwfn->dbg_arrays[BIN_BUF_DBG_ATTN_REGS].ptr +
1706 : 0 : block_type_data->regs_offset;
1707 : : }
1708 : :
1709 : : /* For each block, clear the status of all parities */
1710 : 0 : static void qed_grc_clear_all_prty(struct ecore_hwfn *p_hwfn,
1711 : : struct ecore_ptt *p_ptt)
1712 : : {
1713 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
1714 : : const struct dbg_attn_reg *attn_reg_arr;
1715 : : u8 reg_idx, num_attn_regs;
1716 : : u32 block_id;
1717 : :
1718 [ # # ]: 0 : for (block_id = 0; block_id < NUM_PHYS_BLOCKS; block_id++) {
1719 [ # # ]: 0 : if (dev_data->block_in_reset[block_id])
1720 : 0 : continue;
1721 : :
1722 : : attn_reg_arr = qed_get_block_attn_regs(p_hwfn,
1723 : : (enum block_id)block_id,
1724 : : ATTN_TYPE_PARITY,
1725 : : &num_attn_regs);
1726 : :
1727 [ # # ]: 0 : for (reg_idx = 0; reg_idx < num_attn_regs; reg_idx++) {
1728 : 0 : const struct dbg_attn_reg *reg_data =
1729 : 0 : &attn_reg_arr[reg_idx];
1730 : : u16 modes_buf_offset;
1731 : : bool eval_mode;
1732 : :
1733 : : /* Check mode */
1734 : 0 : eval_mode = GET_FIELD(reg_data->mode.data,
1735 : : DBG_MODE_HDR_EVAL_MODE) > 0;
1736 : 0 : modes_buf_offset =
1737 : : GET_FIELD(reg_data->mode.data,
1738 : : DBG_MODE_HDR_MODES_BUF_OFFSET);
1739 : :
1740 : : /* If Mode match: clear parity status */
1741 [ # # # # ]: 0 : if (!eval_mode ||
1742 : : qed_is_mode_match(p_hwfn, &modes_buf_offset))
1743 : 0 : ecore_rd(p_hwfn, p_ptt,
1744 : 0 : DWORDS_TO_BYTES(reg_data->sts_clr_address));
1745 : : }
1746 : : }
1747 : 0 : }
1748 : :
1749 : : /* Dumps GRC registers section header. Returns the dumped size in dwords.
1750 : : * the following parameters are dumped:
1751 : : * - count: no. of dumped entries
1752 : : * - split_type: split type
1753 : : * - split_id: split ID (dumped only if split_id != SPLIT_TYPE_NONE)
1754 : : * - reg_type_name: register type name (dumped only if reg_type_name != NULL)
1755 : : */
1756 : 0 : static u32 qed_grc_dump_regs_hdr(u32 *dump_buf,
1757 : : bool dump,
1758 : : u32 num_reg_entries,
1759 : : enum init_split_types split_type,
1760 : : u8 split_id, const char *reg_type_name)
1761 : : {
1762 : 0 : u8 num_params = 2 +
1763 [ # # ]: 0 : (split_type != SPLIT_TYPE_NONE ? 1 : 0) + (reg_type_name ? 1 : 0);
1764 : : u32 offset = 0;
1765 : :
1766 : 0 : offset += qed_dump_section_hdr(dump_buf + offset,
1767 : : dump, "grc_regs", num_params);
1768 : 0 : offset += qed_dump_num_param(dump_buf + offset,
1769 : : dump, "count", num_reg_entries);
1770 : 0 : offset += qed_dump_str_param(dump_buf + offset,
1771 : : dump, "split",
1772 : : s_split_type_defs[split_type].name);
1773 [ # # ]: 0 : if (split_type != SPLIT_TYPE_NONE)
1774 : 0 : offset += qed_dump_num_param(dump_buf + offset,
1775 : : dump, "id", split_id);
1776 [ # # ]: 0 : if (reg_type_name)
1777 : 0 : offset += qed_dump_str_param(dump_buf + offset,
1778 : : dump, "type", reg_type_name);
1779 : :
1780 : 0 : return offset;
1781 : : }
1782 : :
1783 : : /* Reads the specified registers into the specified buffer.
1784 : : * The addr and len arguments are specified in dwords.
1785 : : */
1786 : 0 : void qed_read_regs(struct ecore_hwfn *p_hwfn,
1787 : : struct ecore_ptt *p_ptt, u32 *buf, u32 addr, u32 len)
1788 : : {
1789 : : u32 i;
1790 : :
1791 [ # # ]: 0 : for (i = 0; i < len; i++)
1792 : 0 : buf[i] = ecore_rd(p_hwfn, p_ptt, DWORDS_TO_BYTES(addr + i));
1793 : 0 : }
1794 : :
1795 : : /* Dumps the GRC registers in the specified address range.
1796 : : * Returns the dumped size in dwords.
1797 : : * The addr and len arguments are specified in dwords.
1798 : : */
1799 : 0 : static u32 qed_grc_dump_addr_range(struct ecore_hwfn *p_hwfn,
1800 : : struct ecore_ptt *p_ptt,
1801 : : u32 *dump_buf,
1802 : : bool dump, u32 addr, u32 len, bool wide_bus,
1803 : : enum init_split_types split_type,
1804 : : u8 split_id)
1805 : : {
1806 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
1807 : : u8 port_id = 0, pf_id = 0;
1808 : : u16 vf_id = 0, fid = 0;
1809 : : bool read_using_dmae = false;
1810 : : u32 thresh;
1811 : :
1812 [ # # ]: 0 : if (!dump)
1813 : : return len;
1814 : :
1815 [ # # # # : 0 : switch (split_type) {
# ]
1816 : 0 : case SPLIT_TYPE_PORT:
1817 : : port_id = split_id;
1818 : 0 : break;
1819 : 0 : case SPLIT_TYPE_PF:
1820 : : pf_id = split_id;
1821 : 0 : break;
1822 : 0 : case SPLIT_TYPE_PORT_PF:
1823 : 0 : port_id = split_id / dev_data->num_pfs_per_port;
1824 : 0 : pf_id = port_id + dev_data->num_ports *
1825 : : (split_id % dev_data->num_pfs_per_port);
1826 : 0 : break;
1827 : 0 : case SPLIT_TYPE_VF:
1828 : 0 : vf_id = split_id;
1829 : 0 : break;
1830 : : default:
1831 : : break;
1832 : : }
1833 : :
1834 : : /* Try reading using DMAE */
1835 [ # # # # ]: 0 : if (dev_data->use_dmae && split_type != SPLIT_TYPE_VF &&
1836 [ # # # # ]: 0 : (len >= s_hw_type_defs[dev_data->hw_type].dmae_thresh ||
1837 : : (PROTECT_WIDE_BUS && wide_bus))) {
1838 : : struct dmae_params dmae_params;
1839 : :
1840 : : /* Set DMAE params */
1841 : : memset(&dmae_params, 0, sizeof(dmae_params));
1842 : 0 : SET_FIELD(dmae_params.flags, DMAE_PARAMS_COMPLETION_DST, 1);
1843 [ # # # # ]: 0 : switch (split_type) {
1844 : 0 : case SPLIT_TYPE_PORT:
1845 : 0 : SET_FIELD(dmae_params.flags, DMAE_PARAMS_PORT_VALID,
1846 : : 1);
1847 : 0 : dmae_params.port_id = port_id;
1848 : 0 : break;
1849 : 0 : case SPLIT_TYPE_PF:
1850 : 0 : SET_FIELD(dmae_params.flags,
1851 : : DMAE_PARAMS_SRC_PF_VALID, 1);
1852 : 0 : dmae_params.src_pf_id = pf_id;
1853 : 0 : break;
1854 : 0 : case SPLIT_TYPE_PORT_PF:
1855 : : SET_FIELD(dmae_params.flags, DMAE_PARAMS_PORT_VALID,
1856 : : 1);
1857 : 0 : SET_FIELD(dmae_params.flags,
1858 : : DMAE_PARAMS_SRC_PF_VALID, 1);
1859 : 0 : dmae_params.port_id = port_id;
1860 : 0 : dmae_params.src_pf_id = pf_id;
1861 : 0 : break;
1862 : : default:
1863 : : break;
1864 : : }
1865 : :
1866 : : /* Execute DMAE command */
1867 : 0 : read_using_dmae = !ecore_dmae_grc2host(p_hwfn,
1868 : : p_ptt,
1869 : : DWORDS_TO_BYTES(addr),
1870 : : (u64)(uintptr_t)(dump_buf),
1871 : : len, &dmae_params);
1872 [ # # ]: 0 : if (!read_using_dmae) {
1873 : 0 : dev_data->use_dmae = 0;
1874 [ # # ]: 0 : DP_VERBOSE(p_hwfn->p_dev,
1875 : : ECORE_MSG_DEBUG,
1876 : : "Failed reading from chip using DMAE, using GRC instead\n");
1877 : : }
1878 : : }
1879 : :
1880 [ # # ]: 0 : if (read_using_dmae)
1881 : 0 : goto print_log;
1882 : :
1883 : : /* If not read using DMAE, read using GRC */
1884 : :
1885 : : /* Set pretend */
1886 [ # # ]: 0 : if (split_type != dev_data->pretend.split_type ||
1887 [ # # ]: 0 : split_id != dev_data->pretend.split_id) {
1888 [ # # # # : 0 : switch (split_type) {
# ]
1889 : 0 : case SPLIT_TYPE_PORT:
1890 : 0 : ecore_port_pretend(p_hwfn, p_ptt, port_id);
1891 : 0 : break;
1892 : 0 : case SPLIT_TYPE_PF:
1893 : : fid = FIELD_VALUE(PXP_PRETEND_CONCRETE_FID_PFID,
1894 : : pf_id);
1895 : 0 : ecore_fid_pretend(p_hwfn, p_ptt, fid);
1896 : 0 : break;
1897 : 0 : case SPLIT_TYPE_PORT_PF:
1898 : : fid = FIELD_VALUE(PXP_PRETEND_CONCRETE_FID_PFID,
1899 : : pf_id);
1900 : 0 : ecore_port_fid_pretend(p_hwfn, p_ptt, port_id, fid);
1901 : 0 : break;
1902 : 0 : case SPLIT_TYPE_VF:
1903 : 0 : fid = FIELD_VALUE(PXP_PRETEND_CONCRETE_FID_VFVALID, 1)
1904 : 0 : | FIELD_VALUE(PXP_PRETEND_CONCRETE_FID_VFID,
1905 : : vf_id);
1906 : 0 : ecore_fid_pretend(p_hwfn, p_ptt, fid);
1907 : 0 : break;
1908 : : default:
1909 : : break;
1910 : : }
1911 : :
1912 : 0 : dev_data->pretend.split_type = (u8)split_type;
1913 : 0 : dev_data->pretend.split_id = split_id;
1914 : : }
1915 : :
1916 : : /* Read registers using GRC */
1917 : 0 : qed_read_regs(p_hwfn, p_ptt, dump_buf, addr, len);
1918 : :
1919 : 0 : print_log:
1920 : : /* Print log */
1921 : 0 : dev_data->num_regs_read += len;
1922 : 0 : thresh = s_hw_type_defs[dev_data->hw_type].log_thresh;
1923 : 0 : if ((dev_data->num_regs_read / thresh) >
1924 [ # # ]: 0 : ((dev_data->num_regs_read - len) / thresh))
1925 [ # # ]: 0 : DP_VERBOSE(p_hwfn->p_dev,
1926 : : ECORE_MSG_DEBUG,
1927 : : "Dumped %d registers...\n", dev_data->num_regs_read);
1928 : :
1929 : : return len;
1930 : : }
1931 : :
1932 : : /* Dumps GRC registers sequence header. Returns the dumped size in dwords.
1933 : : * The addr and len arguments are specified in dwords.
1934 : : */
1935 : : static u32 qed_grc_dump_reg_entry_hdr(u32 *dump_buf,
1936 : : bool dump, u32 addr, u32 len)
1937 : : {
1938 : 0 : if (dump)
1939 : 0 : *dump_buf = addr | (len << REG_DUMP_LEN_SHIFT);
1940 : :
1941 : : return 1;
1942 : : }
1943 : :
1944 : : /* Dumps GRC registers sequence. Returns the dumped size in dwords.
1945 : : * The addr and len arguments are specified in dwords.
1946 : : */
1947 : : static u32 qed_grc_dump_reg_entry(struct ecore_hwfn *p_hwfn,
1948 : : struct ecore_ptt *p_ptt,
1949 : : u32 *dump_buf,
1950 : : bool dump, u32 addr, u32 len, bool wide_bus,
1951 : : enum init_split_types split_type, u8 split_id)
1952 : : {
1953 : : u32 offset = 0;
1954 : :
1955 : : offset += qed_grc_dump_reg_entry_hdr(dump_buf, dump, addr, len);
1956 : 0 : offset += qed_grc_dump_addr_range(p_hwfn,
1957 : : p_ptt,
1958 : : dump_buf + offset,
1959 : : dump, addr, len, wide_bus,
1960 : : split_type, split_id);
1961 : :
1962 : : return offset;
1963 : : }
1964 : :
1965 : : /* Dumps GRC registers sequence with skip cycle.
1966 : : * Returns the dumped size in dwords.
1967 : : * - addr: start GRC address in dwords
1968 : : * - total_len: total no. of dwords to dump
1969 : : * - read_len: no. consecutive dwords to read
1970 : : * - skip_len: no. of dwords to skip (and fill with zeros)
1971 : : */
1972 [ # # ]: 0 : static u32 qed_grc_dump_reg_entry_skip(struct ecore_hwfn *p_hwfn,
1973 : : struct ecore_ptt *p_ptt,
1974 : : u32 *dump_buf,
1975 : : bool dump,
1976 : : u32 addr,
1977 : : u32 total_len,
1978 : : u32 read_len, u32 skip_len)
1979 : : {
1980 : : u32 offset = 0, reg_offset = 0;
1981 : :
1982 : : offset += qed_grc_dump_reg_entry_hdr(dump_buf, dump, addr, total_len);
1983 : :
1984 [ # # ]: 0 : if (!dump)
1985 : 0 : return offset + total_len;
1986 : :
1987 [ # # ]: 0 : while (reg_offset < total_len) {
1988 : 0 : u32 curr_len = OSAL_MIN_T(u32, read_len,
1989 : : total_len - reg_offset);
1990 : :
1991 : 0 : offset += qed_grc_dump_addr_range(p_hwfn,
1992 : : p_ptt,
1993 : 0 : dump_buf + offset,
1994 : : dump, addr, curr_len, false,
1995 : : SPLIT_TYPE_NONE, 0);
1996 : 0 : reg_offset += curr_len;
1997 : 0 : addr += curr_len;
1998 : :
1999 [ # # ]: 0 : if (reg_offset < total_len) {
2000 : 0 : curr_len = OSAL_MIN_T(u32, skip_len,
2001 : : total_len - skip_len);
2002 : 0 : memset(dump_buf + offset, 0, DWORDS_TO_BYTES(curr_len));
2003 : 0 : offset += curr_len;
2004 : 0 : reg_offset += curr_len;
2005 : 0 : addr += curr_len;
2006 : : }
2007 : : }
2008 : :
2009 : : return offset;
2010 : : }
2011 : :
2012 : : /* Dumps GRC registers entries. Returns the dumped size in dwords. */
2013 : 0 : static u32 qed_grc_dump_regs_entries(struct ecore_hwfn *p_hwfn,
2014 : : struct ecore_ptt *p_ptt,
2015 : : struct virt_mem_desc input_regs_arr,
2016 : : u32 *dump_buf,
2017 : : bool dump,
2018 : : enum init_split_types split_type,
2019 : : u8 split_id,
2020 : : bool block_enable[MAX_BLOCK_ID],
2021 : : u32 *num_dumped_reg_entries)
2022 : : {
2023 : : u32 i, offset = 0, input_offset = 0;
2024 : : bool mode_match = true;
2025 : :
2026 : 0 : *num_dumped_reg_entries = 0;
2027 : :
2028 [ # # ]: 0 : while (input_offset < BYTES_TO_DWORDS(input_regs_arr.size)) {
2029 : 0 : const struct dbg_dump_cond_hdr *cond_hdr =
2030 : : (const struct dbg_dump_cond_hdr *)
2031 : 0 : input_regs_arr.ptr + input_offset++;
2032 : : u16 modes_buf_offset;
2033 : : bool eval_mode;
2034 : :
2035 : : /* Check mode/block */
2036 : 0 : eval_mode = GET_FIELD(cond_hdr->mode.data,
2037 : : DBG_MODE_HDR_EVAL_MODE) > 0;
2038 [ # # ]: 0 : if (eval_mode) {
2039 : 0 : modes_buf_offset =
2040 : : GET_FIELD(cond_hdr->mode.data,
2041 : : DBG_MODE_HDR_MODES_BUF_OFFSET);
2042 : : mode_match = qed_is_mode_match(p_hwfn,
2043 : : &modes_buf_offset);
2044 : : }
2045 : :
2046 [ # # # # ]: 0 : if (!mode_match || !block_enable[cond_hdr->block_id]) {
2047 : 0 : input_offset += cond_hdr->data_size;
2048 : 0 : continue;
2049 : : }
2050 : :
2051 [ # # ]: 0 : for (i = 0; i < cond_hdr->data_size; i++, input_offset++) {
2052 : 0 : const struct dbg_dump_reg *reg =
2053 : : (const struct dbg_dump_reg *)
2054 : 0 : input_regs_arr.ptr + input_offset;
2055 : : u32 addr, len;
2056 : : bool wide_bus;
2057 : :
2058 : 0 : addr = GET_FIELD(reg->data, DBG_DUMP_REG_ADDRESS);
2059 : 0 : len = GET_FIELD(reg->data, DBG_DUMP_REG_LENGTH);
2060 : 0 : wide_bus = GET_FIELD(reg->data, DBG_DUMP_REG_WIDE_BUS);
2061 : 0 : offset += qed_grc_dump_reg_entry(p_hwfn,
2062 : : p_ptt,
2063 [ # # ]: 0 : dump_buf + offset,
2064 : : dump,
2065 : : addr,
2066 : : len,
2067 : : wide_bus,
2068 : : split_type, split_id);
2069 : 0 : (*num_dumped_reg_entries)++;
2070 : : }
2071 : : }
2072 : :
2073 : 0 : return offset;
2074 : : }
2075 : :
2076 : : /* Dumps GRC registers entries. Returns the dumped size in dwords. */
2077 : 0 : static u32 qed_grc_dump_split_data(struct ecore_hwfn *p_hwfn,
2078 : : struct ecore_ptt *p_ptt,
2079 : : struct virt_mem_desc input_regs_arr,
2080 : : u32 *dump_buf,
2081 : : bool dump,
2082 : : bool block_enable[MAX_BLOCK_ID],
2083 : : enum init_split_types split_type,
2084 : : u8 split_id, const char *reg_type_name)
2085 : : {
2086 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
2087 : : enum init_split_types hdr_split_type = split_type;
2088 : : u32 num_dumped_reg_entries, offset;
2089 : : u8 hdr_split_id = split_id;
2090 : :
2091 : : /* In PORT_PF split type, print a port split header */
2092 [ # # ]: 0 : if (split_type == SPLIT_TYPE_PORT_PF) {
2093 : : hdr_split_type = SPLIT_TYPE_PORT;
2094 : 0 : hdr_split_id = split_id / dev_data->num_pfs_per_port;
2095 : : }
2096 : :
2097 : : /* Calculate register dump header size (and skip it for now) */
2098 : 0 : offset = qed_grc_dump_regs_hdr(dump_buf,
2099 : : false,
2100 : : 0,
2101 : : hdr_split_type,
2102 : : hdr_split_id, reg_type_name);
2103 : :
2104 : : /* Dump registers */
2105 : 0 : offset += qed_grc_dump_regs_entries(p_hwfn,
2106 : : p_ptt,
2107 : : input_regs_arr,
2108 : 0 : dump_buf + offset,
2109 : : dump,
2110 : : split_type,
2111 : : split_id,
2112 : : block_enable,
2113 : : &num_dumped_reg_entries);
2114 : :
2115 : : /* Write register dump header */
2116 [ # # # # ]: 0 : if (dump && num_dumped_reg_entries > 0)
2117 : 0 : qed_grc_dump_regs_hdr(dump_buf,
2118 : : dump,
2119 : : num_dumped_reg_entries,
2120 : : hdr_split_type,
2121 : : hdr_split_id, reg_type_name);
2122 : :
2123 [ # # ]: 0 : return num_dumped_reg_entries > 0 ? offset : 0;
2124 : : }
2125 : :
2126 : : /* Dumps registers according to the input registers array. Returns the dumped
2127 : : * size in dwords.
2128 : : */
2129 : 0 : static u32 qed_grc_dump_registers(struct ecore_hwfn *p_hwfn,
2130 : : struct ecore_ptt *p_ptt,
2131 : : u32 *dump_buf,
2132 : : bool dump,
2133 : : bool block_enable[MAX_BLOCK_ID],
2134 : : const char *reg_type_name)
2135 : : {
2136 : : struct virt_mem_desc *dbg_buf =
2137 : : &p_hwfn->dbg_arrays[BIN_BUF_DBG_DUMP_REG];
2138 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
2139 : : u32 offset = 0, input_offset = 0;
2140 : :
2141 [ # # ]: 0 : while (input_offset < BYTES_TO_DWORDS(dbg_buf->size)) {
2142 : : const struct dbg_dump_split_hdr *split_hdr;
2143 : : struct virt_mem_desc curr_input_regs_arr;
2144 : : enum init_split_types split_type;
2145 : : u16 split_count = 0;
2146 : : u32 split_data_size;
2147 : : u8 split_id;
2148 : :
2149 : 0 : split_hdr =
2150 : : (const struct dbg_dump_split_hdr *)
2151 : 0 : dbg_buf->ptr + input_offset++;
2152 : 0 : split_type =
2153 : 0 : GET_FIELD(split_hdr->hdr,
2154 : : DBG_DUMP_SPLIT_HDR_SPLIT_TYPE_ID);
2155 : 0 : split_data_size = GET_FIELD(split_hdr->hdr,
2156 : : DBG_DUMP_SPLIT_HDR_DATA_SIZE);
2157 : 0 : curr_input_regs_arr.ptr =
2158 : 0 : (u32 *)p_hwfn->dbg_arrays[BIN_BUF_DBG_DUMP_REG].ptr +
2159 : : input_offset;
2160 : 0 : curr_input_regs_arr.size = DWORDS_TO_BYTES(split_data_size);
2161 : :
2162 [ # # # # : 0 : switch (split_type) {
# ]
2163 : : case SPLIT_TYPE_NONE:
2164 : : split_count = 1;
2165 : : break;
2166 : 0 : case SPLIT_TYPE_PORT:
2167 : 0 : split_count = dev_data->num_ports;
2168 : 0 : break;
2169 : 0 : case SPLIT_TYPE_PF:
2170 : : case SPLIT_TYPE_PORT_PF:
2171 : 0 : split_count = dev_data->num_ports *
2172 : 0 : dev_data->num_pfs_per_port;
2173 : 0 : break;
2174 : 0 : case SPLIT_TYPE_VF:
2175 : 0 : split_count = dev_data->num_vfs;
2176 : 0 : break;
2177 : 0 : default:
2178 : 0 : return 0;
2179 : : }
2180 : :
2181 [ # # ]: 0 : for (split_id = 0; split_id < split_count; split_id++)
2182 : 0 : offset += qed_grc_dump_split_data(p_hwfn, p_ptt,
2183 : : curr_input_regs_arr,
2184 : 0 : dump_buf + offset,
2185 : : dump, block_enable,
2186 : : split_type,
2187 : : split_id,
2188 : : reg_type_name);
2189 : :
2190 : 0 : input_offset += split_data_size;
2191 : : }
2192 : :
2193 : : /* Cancel pretends (pretend to original PF) */
2194 [ # # ]: 0 : if (dump) {
2195 : 0 : ecore_fid_pretend(p_hwfn, p_ptt,
2196 : 0 : FIELD_VALUE(PXP_PRETEND_CONCRETE_FID_PFID,
2197 : : p_hwfn->rel_pf_id));
2198 : 0 : dev_data->pretend.split_type = SPLIT_TYPE_NONE;
2199 : 0 : dev_data->pretend.split_id = 0;
2200 : : }
2201 : :
2202 : : return offset;
2203 : : }
2204 : :
2205 : : /* Dump reset registers. Returns the dumped size in dwords. */
2206 : 0 : static u32 qed_grc_dump_reset_regs(struct ecore_hwfn *p_hwfn,
2207 : : struct ecore_ptt *p_ptt,
2208 : : u32 *dump_buf, bool dump)
2209 : : {
2210 : : u32 offset = 0, num_regs = 0;
2211 : : u8 reset_reg_id;
2212 : :
2213 : : /* Calculate header size */
2214 : 0 : offset += qed_grc_dump_regs_hdr(dump_buf,
2215 : : false,
2216 : : 0, SPLIT_TYPE_NONE, 0, "RESET_REGS");
2217 : :
2218 : : /* Write reset registers */
2219 [ # # ]: 0 : for (reset_reg_id = 0; reset_reg_id < NUM_DBG_RESET_REGS;
2220 : 0 : reset_reg_id++) {
2221 : : const struct dbg_reset_reg *reset_reg;
2222 : : u32 reset_reg_addr;
2223 : :
2224 : 0 : reset_reg = qed_get_dbg_reset_reg(p_hwfn, reset_reg_id);
2225 : :
2226 [ # # ]: 0 : if (GET_FIELD(reset_reg->data, DBG_RESET_REG_IS_REMOVED))
2227 : 0 : continue;
2228 : :
2229 : 0 : reset_reg_addr = GET_FIELD(reset_reg->data, DBG_RESET_REG_ADDR);
2230 : 0 : offset += qed_grc_dump_reg_entry(p_hwfn,
2231 : : p_ptt,
2232 [ # # ]: 0 : dump_buf + offset,
2233 : : dump,
2234 : : reset_reg_addr,
2235 : : 1, false, SPLIT_TYPE_NONE, 0);
2236 : 0 : num_regs++;
2237 : : }
2238 : :
2239 : : /* Write header */
2240 [ # # ]: 0 : if (dump)
2241 : 0 : qed_grc_dump_regs_hdr(dump_buf,
2242 : : true, num_regs, SPLIT_TYPE_NONE,
2243 : : 0, "RESET_REGS");
2244 : :
2245 : 0 : return offset;
2246 : : }
2247 : :
2248 : : /* Dump registers that are modified during GRC Dump and therefore must be
2249 : : * dumped first. Returns the dumped size in dwords.
2250 : : */
2251 : 0 : static u32 qed_grc_dump_modified_regs(struct ecore_hwfn *p_hwfn,
2252 : : struct ecore_ptt *p_ptt,
2253 : : u32 *dump_buf, bool dump)
2254 : : {
2255 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
2256 : : u32 block_id, offset = 0, stall_regs_offset;
2257 : : const struct dbg_attn_reg *attn_reg_arr;
2258 : : u8 storm_id, reg_idx, num_attn_regs;
2259 : : u32 num_reg_entries = 0;
2260 : :
2261 : : /* Write empty header for attention registers */
2262 : 0 : offset += qed_grc_dump_regs_hdr(dump_buf,
2263 : : false,
2264 : : 0, SPLIT_TYPE_NONE, 0, "ATTN_REGS");
2265 : :
2266 : : /* Write parity registers */
2267 [ # # ]: 0 : for (block_id = 0; block_id < NUM_PHYS_BLOCKS; block_id++) {
2268 [ # # # # ]: 0 : if (dev_data->block_in_reset[block_id] && dump)
2269 : 0 : continue;
2270 : :
2271 : : attn_reg_arr = qed_get_block_attn_regs(p_hwfn,
2272 : : (enum block_id)block_id,
2273 : : ATTN_TYPE_PARITY,
2274 : : &num_attn_regs);
2275 : :
2276 [ # # ]: 0 : for (reg_idx = 0; reg_idx < num_attn_regs; reg_idx++) {
2277 : 0 : const struct dbg_attn_reg *reg_data =
2278 : 0 : &attn_reg_arr[reg_idx];
2279 : : u16 modes_buf_offset;
2280 : : bool eval_mode;
2281 : : u32 addr;
2282 : :
2283 : : /* Check mode */
2284 : 0 : eval_mode = GET_FIELD(reg_data->mode.data,
2285 : : DBG_MODE_HDR_EVAL_MODE) > 0;
2286 : 0 : modes_buf_offset =
2287 : : GET_FIELD(reg_data->mode.data,
2288 : : DBG_MODE_HDR_MODES_BUF_OFFSET);
2289 [ # # # # ]: 0 : if (eval_mode &&
2290 : : !qed_is_mode_match(p_hwfn, &modes_buf_offset))
2291 : 0 : continue;
2292 : :
2293 : : /* Mode match: read & dump registers */
2294 : 0 : addr = reg_data->mask_address;
2295 : 0 : offset += qed_grc_dump_reg_entry(p_hwfn,
2296 : : p_ptt,
2297 [ # # ]: 0 : dump_buf + offset,
2298 : : dump,
2299 : : addr,
2300 : : 1, false,
2301 : : SPLIT_TYPE_NONE, 0);
2302 : 0 : addr = GET_FIELD(reg_data->data,
2303 : : DBG_ATTN_REG_STS_ADDRESS);
2304 : 0 : offset += qed_grc_dump_reg_entry(p_hwfn,
2305 : : p_ptt,
2306 [ # # ]: 0 : dump_buf + offset,
2307 : : dump,
2308 : : addr,
2309 : : 1, false,
2310 : : SPLIT_TYPE_NONE, 0);
2311 : 0 : num_reg_entries += 2;
2312 : : }
2313 : : }
2314 : :
2315 : : /* Overwrite header for attention registers */
2316 [ # # ]: 0 : if (dump)
2317 : 0 : qed_grc_dump_regs_hdr(dump_buf,
2318 : : true,
2319 : : num_reg_entries,
2320 : : SPLIT_TYPE_NONE, 0, "ATTN_REGS");
2321 : :
2322 : : /* Write empty header for stall registers */
2323 : : stall_regs_offset = offset;
2324 : 0 : offset += qed_grc_dump_regs_hdr(dump_buf,
2325 : : false, 0, SPLIT_TYPE_NONE, 0, "REGS");
2326 : :
2327 : : /* Write Storm stall status registers */
2328 [ # # ]: 0 : for (storm_id = 0, num_reg_entries = 0; storm_id < MAX_DBG_STORMS;
2329 : 0 : storm_id++) {
2330 : 0 : struct storm_defs *storm = &s_storm_defs[storm_id];
2331 : : u32 addr;
2332 : :
2333 [ # # # # ]: 0 : if (dev_data->block_in_reset[storm->sem_block_id] && dump)
2334 : 0 : continue;
2335 : :
2336 : 0 : addr =
2337 : 0 : BYTES_TO_DWORDS(storm->sem_fast_mem_addr +
2338 : : SEM_FAST_REG_STALLED);
2339 : 0 : offset += qed_grc_dump_reg_entry(p_hwfn,
2340 : : p_ptt,
2341 [ # # ]: 0 : dump_buf + offset,
2342 : : dump,
2343 : : addr,
2344 : : 1,
2345 : : false, SPLIT_TYPE_NONE, 0);
2346 : 0 : num_reg_entries++;
2347 : : }
2348 : :
2349 : : /* Overwrite header for stall registers */
2350 [ # # ]: 0 : if (dump)
2351 : 0 : qed_grc_dump_regs_hdr(dump_buf + stall_regs_offset,
2352 : : true,
2353 : : num_reg_entries,
2354 : : SPLIT_TYPE_NONE, 0, "REGS");
2355 : :
2356 : 0 : return offset;
2357 : : }
2358 : :
2359 : : /* Dumps registers that can't be represented in the debug arrays */
2360 : 0 : static u32 qed_grc_dump_special_regs(struct ecore_hwfn *p_hwfn,
2361 : : struct ecore_ptt *p_ptt,
2362 : : u32 *dump_buf, bool dump)
2363 : : {
2364 : : u32 offset = 0, addr;
2365 : :
2366 : 0 : offset += qed_grc_dump_regs_hdr(dump_buf,
2367 : : dump, 2, SPLIT_TYPE_NONE, 0, "REGS");
2368 : :
2369 : : /* Dump R/TDIF_REG_DEBUG_ERROR_INFO_SIZE (every 8'th register should be
2370 : : * skipped).
2371 : : */
2372 : : addr = BYTES_TO_DWORDS(RDIF_REG_DEBUG_ERROR_INFO);
2373 : 0 : offset += qed_grc_dump_reg_entry_skip(p_hwfn,
2374 : : p_ptt,
2375 : 0 : dump_buf + offset,
2376 : : dump,
2377 : : addr,
2378 : : RDIF_REG_DEBUG_ERROR_INFO_SIZE,
2379 : : 7,
2380 : : 1);
2381 : : addr = BYTES_TO_DWORDS(TDIF_REG_DEBUG_ERROR_INFO);
2382 : 0 : offset +=
2383 : 0 : qed_grc_dump_reg_entry_skip(p_hwfn,
2384 : : p_ptt,
2385 : 0 : dump_buf + offset,
2386 : : dump,
2387 : : addr,
2388 : : TDIF_REG_DEBUG_ERROR_INFO_SIZE,
2389 : : 7,
2390 : : 1);
2391 : :
2392 : 0 : return offset;
2393 : : }
2394 : :
2395 : : /* Dumps a GRC memory header (section and params). Returns the dumped size in
2396 : : * dwords. The following parameters are dumped:
2397 : : * - name: dumped only if it's not NULL.
2398 : : * - addr: in dwords, dumped only if name is NULL.
2399 : : * - len: in dwords, always dumped.
2400 : : * - width: dumped if it's not zero.
2401 : : * - packed: dumped only if it's not false.
2402 : : * - mem_group: always dumped.
2403 : : * - is_storm: true only if the memory is related to a Storm.
2404 : : * - storm_letter: valid only if is_storm is true.
2405 : : *
2406 : : */
2407 : 0 : static u32 qed_grc_dump_mem_hdr(struct ecore_hwfn *p_hwfn,
2408 : : u32 *dump_buf,
2409 : : bool dump,
2410 : : const char *name,
2411 : : u32 addr,
2412 : : u32 len,
2413 : : u32 bit_width,
2414 : : bool packed,
2415 : : const char *mem_group, char storm_letter)
2416 : : {
2417 : : u8 num_params = 3;
2418 : : u32 offset = 0;
2419 : : char buf[64];
2420 : :
2421 [ # # ]: 0 : if (!len)
2422 : 0 : DP_NOTICE(p_hwfn, false,
2423 : : "Unexpected GRC Dump error: dumped memory size must be non-zero\n");
2424 : :
2425 [ # # ]: 0 : if (bit_width)
2426 : : num_params++;
2427 [ # # ]: 0 : if (packed)
2428 : 0 : num_params++;
2429 : :
2430 : : /* Dump section header */
2431 : 0 : offset += qed_dump_section_hdr(dump_buf + offset,
2432 : : dump, "grc_mem", num_params);
2433 : :
2434 [ # # ]: 0 : if (name) {
2435 : : /* Dump name */
2436 [ # # ]: 0 : if (storm_letter) {
2437 : : strcpy(buf, "?STORM_");
2438 : 0 : buf[0] = storm_letter;
2439 : 0 : strcpy(buf + strlen(buf), name);
2440 : : } else {
2441 : : strcpy(buf, name);
2442 : : }
2443 : :
2444 : 0 : offset += qed_dump_str_param(dump_buf + offset,
2445 : : dump, "name", buf);
2446 : : } else {
2447 : : /* Dump address */
2448 : 0 : u32 addr_in_bytes = DWORDS_TO_BYTES(addr);
2449 : :
2450 : 0 : offset += qed_dump_num_param(dump_buf + offset,
2451 : : dump, "addr", addr_in_bytes);
2452 : : }
2453 : :
2454 : : /* Dump len */
2455 : 0 : offset += qed_dump_num_param(dump_buf + offset, dump, "len", len);
2456 : :
2457 : : /* Dump bit width */
2458 [ # # ]: 0 : if (bit_width)
2459 : 0 : offset += qed_dump_num_param(dump_buf + offset,
2460 : : dump, "width", bit_width);
2461 : :
2462 : : /* Dump packed */
2463 [ # # ]: 0 : if (packed)
2464 : 0 : offset += qed_dump_num_param(dump_buf + offset,
2465 : : dump, "packed", 1);
2466 : :
2467 : : /* Dump reg type */
2468 [ # # ]: 0 : if (storm_letter) {
2469 : : strcpy(buf, "?STORM_");
2470 : 0 : buf[0] = storm_letter;
2471 : 0 : strcpy(buf + strlen(buf), mem_group);
2472 : : } else {
2473 : : strcpy(buf, mem_group);
2474 : : }
2475 : :
2476 : 0 : offset += qed_dump_str_param(dump_buf + offset, dump, "type", buf);
2477 : :
2478 : 0 : return offset;
2479 : : }
2480 : :
2481 : : /* Dumps a single GRC memory. If name is NULL, the memory is stored by address.
2482 : : * Returns the dumped size in dwords.
2483 : : * The addr and len arguments are specified in dwords.
2484 : : */
2485 : 0 : static u32 qed_grc_dump_mem(struct ecore_hwfn *p_hwfn,
2486 : : struct ecore_ptt *p_ptt,
2487 : : u32 *dump_buf,
2488 : : bool dump,
2489 : : const char *name,
2490 : : u32 addr,
2491 : : u32 len,
2492 : : bool wide_bus,
2493 : : u32 bit_width,
2494 : : bool packed,
2495 : : const char *mem_group, char storm_letter)
2496 : : {
2497 : : u32 offset = 0;
2498 : :
2499 : 0 : offset += qed_grc_dump_mem_hdr(p_hwfn,
2500 : : dump_buf + offset,
2501 : : dump,
2502 : : name,
2503 : : addr,
2504 : : len,
2505 : : bit_width,
2506 : : packed, mem_group, storm_letter);
2507 : 0 : offset += qed_grc_dump_addr_range(p_hwfn,
2508 : : p_ptt,
2509 : 0 : dump_buf + offset,
2510 : : dump, addr, len, wide_bus,
2511 : : SPLIT_TYPE_NONE, 0);
2512 : :
2513 : 0 : return offset;
2514 : : }
2515 : :
2516 : : /* Dumps GRC memories entries. Returns the dumped size in dwords. */
2517 : 0 : static u32 qed_grc_dump_mem_entries(struct ecore_hwfn *p_hwfn,
2518 : : struct ecore_ptt *p_ptt,
2519 : : struct virt_mem_desc input_mems_arr,
2520 : : u32 *dump_buf, bool dump)
2521 : : {
2522 : : u32 i, offset = 0, input_offset = 0;
2523 : : bool mode_match = true;
2524 : :
2525 [ # # ]: 0 : while (input_offset < BYTES_TO_DWORDS(input_mems_arr.size)) {
2526 : : const struct dbg_dump_cond_hdr *cond_hdr;
2527 : : u16 modes_buf_offset;
2528 : : u32 num_entries;
2529 : : bool eval_mode;
2530 : :
2531 : 0 : cond_hdr =
2532 : 0 : (const struct dbg_dump_cond_hdr *)input_mems_arr.ptr +
2533 : 0 : input_offset++;
2534 : 0 : num_entries = cond_hdr->data_size / MEM_DUMP_ENTRY_SIZE_DWORDS;
2535 : :
2536 : : /* Check required mode */
2537 : 0 : eval_mode = GET_FIELD(cond_hdr->mode.data,
2538 : : DBG_MODE_HDR_EVAL_MODE) > 0;
2539 [ # # ]: 0 : if (eval_mode) {
2540 : 0 : modes_buf_offset =
2541 : : GET_FIELD(cond_hdr->mode.data,
2542 : : DBG_MODE_HDR_MODES_BUF_OFFSET);
2543 : : mode_match = qed_is_mode_match(p_hwfn,
2544 : : &modes_buf_offset);
2545 : : }
2546 : :
2547 [ # # ]: 0 : if (!mode_match) {
2548 : 0 : input_offset += cond_hdr->data_size;
2549 : 0 : continue;
2550 : : }
2551 : :
2552 [ # # ]: 0 : for (i = 0; i < num_entries;
2553 : 0 : i++, input_offset += MEM_DUMP_ENTRY_SIZE_DWORDS) {
2554 : 0 : const struct dbg_dump_mem *mem =
2555 : : (const struct dbg_dump_mem *)((u32 *)
2556 : : input_mems_arr.ptr
2557 : 0 : + input_offset);
2558 : : const struct dbg_block *block;
2559 : : char storm_letter = 0;
2560 : : u32 mem_addr, mem_len;
2561 : : bool mem_wide_bus;
2562 : : u8 mem_group_id;
2563 : :
2564 : 0 : mem_group_id = GET_FIELD(mem->dword0,
2565 : : DBG_DUMP_MEM_MEM_GROUP_ID);
2566 [ # # ]: 0 : if (mem_group_id >= MEM_GROUPS_NUM) {
2567 : 0 : DP_NOTICE(p_hwfn, false, "Invalid mem_group_id\n");
2568 : 0 : return 0;
2569 : : }
2570 : :
2571 : 0 : if (!qed_grc_is_mem_included(p_hwfn,
2572 : : (enum block_id)
2573 [ # # ]: 0 : cond_hdr->block_id,
2574 : : mem_group_id))
2575 : 0 : continue;
2576 : :
2577 : 0 : mem_addr = GET_FIELD(mem->dword0, DBG_DUMP_MEM_ADDRESS);
2578 : 0 : mem_len = GET_FIELD(mem->dword1, DBG_DUMP_MEM_LENGTH);
2579 : 0 : mem_wide_bus = GET_FIELD(mem->dword1,
2580 : : DBG_DUMP_MEM_WIDE_BUS);
2581 : :
2582 : : block = get_dbg_block(p_hwfn,
2583 : : cond_hdr->block_id);
2584 : :
2585 : : /* If memory is associated with Storm,
2586 : : * update storm details
2587 : : */
2588 : 0 : if (block->associated_storm_letter)
2589 : : storm_letter = block->associated_storm_letter;
2590 : :
2591 : : /* Dump memory */
2592 : 0 : offset += qed_grc_dump_mem(p_hwfn,
2593 : : p_ptt,
2594 : 0 : dump_buf + offset,
2595 : : dump,
2596 : : NULL,
2597 : : mem_addr,
2598 : : mem_len,
2599 : : mem_wide_bus,
2600 : : 0,
2601 : : false,
2602 : 0 : s_mem_group_names[mem_group_id],
2603 : : storm_letter);
2604 : : }
2605 : : }
2606 : :
2607 : : return offset;
2608 : : }
2609 : :
2610 : : /* Dumps GRC memories according to the input array dump_mem.
2611 : : * Returns the dumped size in dwords.
2612 : : */
2613 : 0 : static u32 qed_grc_dump_memories(struct ecore_hwfn *p_hwfn,
2614 : : struct ecore_ptt *p_ptt,
2615 : : u32 *dump_buf, bool dump)
2616 : : {
2617 : : struct virt_mem_desc *dbg_buf =
2618 : : &p_hwfn->dbg_arrays[BIN_BUF_DBG_DUMP_MEM];
2619 : : u32 offset = 0, input_offset = 0;
2620 : :
2621 [ # # ]: 0 : while (input_offset < BYTES_TO_DWORDS(dbg_buf->size)) {
2622 : : const struct dbg_dump_split_hdr *split_hdr;
2623 : : struct virt_mem_desc curr_input_mems_arr;
2624 : : enum init_split_types split_type;
2625 : : u32 split_data_size;
2626 : :
2627 : 0 : split_hdr =
2628 : 0 : (const struct dbg_dump_split_hdr *)dbg_buf->ptr +
2629 : 0 : input_offset++;
2630 : 0 : split_type = GET_FIELD(split_hdr->hdr,
2631 : : DBG_DUMP_SPLIT_HDR_SPLIT_TYPE_ID);
2632 : 0 : split_data_size = GET_FIELD(split_hdr->hdr,
2633 : : DBG_DUMP_SPLIT_HDR_DATA_SIZE);
2634 : 0 : curr_input_mems_arr.ptr = (u32 *)dbg_buf->ptr + input_offset;
2635 : 0 : curr_input_mems_arr.size = DWORDS_TO_BYTES(split_data_size);
2636 : :
2637 [ # # ]: 0 : if (split_type == SPLIT_TYPE_NONE)
2638 : 0 : offset += qed_grc_dump_mem_entries(p_hwfn,
2639 : : p_ptt,
2640 : : curr_input_mems_arr,
2641 : 0 : dump_buf + offset,
2642 : : dump);
2643 : : else
2644 : 0 : DP_NOTICE(p_hwfn, false,
2645 : : "Dumping split memories is currently not supported\n");
2646 : :
2647 : 0 : input_offset += split_data_size;
2648 : : }
2649 : :
2650 : 0 : return offset;
2651 : : }
2652 : :
2653 : : /* Dumps GRC context data for the specified Storm.
2654 : : * Returns the dumped size in dwords.
2655 : : * The lid_size argument is specified in quad-regs.
2656 : : */
2657 : 0 : static u32 qed_grc_dump_ctx_data(struct ecore_hwfn *p_hwfn,
2658 : : struct ecore_ptt *p_ptt,
2659 : : u32 *dump_buf,
2660 : : bool dump,
2661 : : const char *name,
2662 : : u32 num_lids,
2663 : : enum cm_ctx_types ctx_type, u8 storm_id)
2664 : : {
2665 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
2666 : 0 : struct storm_defs *storm = &s_storm_defs[storm_id];
2667 : : u32 i, lid, lid_size, total_size;
2668 : : u32 rd_reg_addr, offset = 0;
2669 : :
2670 : : /* Convert quad-regs to dwords */
2671 : 0 : lid_size = storm->cm_ctx_lid_sizes[dev_data->chip_id][ctx_type] * 4;
2672 : :
2673 [ # # ]: 0 : if (!lid_size)
2674 : : return 0;
2675 : :
2676 : 0 : total_size = num_lids * lid_size;
2677 : :
2678 : 0 : offset += qed_grc_dump_mem_hdr(p_hwfn,
2679 : : dump_buf + offset,
2680 : : dump,
2681 : : name,
2682 : : 0,
2683 : : total_size,
2684 : : lid_size * 32,
2685 : 0 : false, name, storm->letter);
2686 : :
2687 [ # # ]: 0 : if (!dump)
2688 : 0 : return offset + total_size;
2689 : :
2690 : 0 : rd_reg_addr = BYTES_TO_DWORDS(storm->cm_ctx_rd_addr[ctx_type]);
2691 : :
2692 : : /* Dump context data */
2693 [ # # ]: 0 : for (lid = 0; lid < num_lids; lid++) {
2694 [ # # ]: 0 : for (i = 0; i < lid_size; i++) {
2695 : 0 : ecore_wr(p_hwfn,
2696 : 0 : p_ptt, storm->cm_ctx_wr_addr, (i << 9) | lid);
2697 : 0 : offset += qed_grc_dump_addr_range(p_hwfn,
2698 : : p_ptt,
2699 : 0 : dump_buf + offset,
2700 : : dump,
2701 : : rd_reg_addr,
2702 : : 1,
2703 : : false,
2704 : : SPLIT_TYPE_NONE, 0);
2705 : : }
2706 : : }
2707 : :
2708 : : return offset;
2709 : : }
2710 : :
2711 : : /* Dumps GRC contexts. Returns the dumped size in dwords. */
2712 : 0 : static u32 qed_grc_dump_ctx(struct ecore_hwfn *p_hwfn,
2713 : : struct ecore_ptt *p_ptt, u32 *dump_buf, bool dump)
2714 : : {
2715 : : u32 offset = 0;
2716 : : u8 storm_id;
2717 : :
2718 [ # # ]: 0 : for (storm_id = 0; storm_id < MAX_DBG_STORMS; storm_id++) {
2719 [ # # ]: 0 : if (!qed_grc_is_storm_included(p_hwfn,
2720 : : (enum dbg_storms)storm_id))
2721 : 0 : continue;
2722 : :
2723 : : /* Dump Conn AG context size */
2724 : 0 : offset += qed_grc_dump_ctx_data(p_hwfn,
2725 : : p_ptt,
2726 : 0 : dump_buf + offset,
2727 : : dump,
2728 : : "CONN_AG_CTX",
2729 : : NUM_OF_LCIDS,
2730 : : CM_CTX_CONN_AG, storm_id);
2731 : :
2732 : : /* Dump Conn ST context size */
2733 : 0 : offset += qed_grc_dump_ctx_data(p_hwfn,
2734 : : p_ptt,
2735 : 0 : dump_buf + offset,
2736 : : dump,
2737 : : "CONN_ST_CTX",
2738 : : NUM_OF_LCIDS,
2739 : : CM_CTX_CONN_ST, storm_id);
2740 : :
2741 : : /* Dump Task AG context size */
2742 : 0 : offset += qed_grc_dump_ctx_data(p_hwfn,
2743 : : p_ptt,
2744 : 0 : dump_buf + offset,
2745 : : dump,
2746 : : "TASK_AG_CTX",
2747 : : NUM_OF_LTIDS,
2748 : : CM_CTX_TASK_AG, storm_id);
2749 : :
2750 : : /* Dump Task ST context size */
2751 : 0 : offset += qed_grc_dump_ctx_data(p_hwfn,
2752 : : p_ptt,
2753 : 0 : dump_buf + offset,
2754 : : dump,
2755 : : "TASK_ST_CTX",
2756 : : NUM_OF_LTIDS,
2757 : : CM_CTX_TASK_ST, storm_id);
2758 : : }
2759 : :
2760 : 0 : return offset;
2761 : : }
2762 : :
2763 : : #define VFC_STATUS_RESP_READY_BIT 0
2764 : : #define VFC_STATUS_BUSY_BIT 1
2765 : : #define VFC_STATUS_SENDING_CMD_BIT 2
2766 : :
2767 : : #define VFC_POLLING_DELAY_MS 1
2768 : : #define VFC_POLLING_COUNT 20
2769 : :
2770 : : /* Reads data from VFC. Returns the number of dwords read (0 on error).
2771 : : * Sizes are specified in dwords.
2772 : : */
2773 : 0 : static u32 qed_grc_dump_read_from_vfc(struct ecore_hwfn *p_hwfn,
2774 : : struct ecore_ptt *p_ptt,
2775 : : struct storm_defs *storm,
2776 : : u32 *cmd_data,
2777 : : u32 cmd_size,
2778 : : u32 *addr_data,
2779 : : u32 addr_size,
2780 : : u32 resp_size, u32 *dump_buf)
2781 : : {
2782 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
2783 : : u32 vfc_status, polling_ms, polling_count = 0, i;
2784 : : u32 reg_addr, sem_base;
2785 : : bool is_ready = false;
2786 : :
2787 : 0 : sem_base = storm->sem_fast_mem_addr;
2788 : 0 : polling_ms = VFC_POLLING_DELAY_MS *
2789 : 0 : s_hw_type_defs[dev_data->hw_type].delay_factor;
2790 : :
2791 : : /* Write VFC command */
2792 [ # # ]: 0 : ARR_REG_WR(p_hwfn,
2793 : : p_ptt,
2794 : : sem_base + SEM_FAST_REG_VFC_DATA_WR,
2795 : : cmd_data, cmd_size);
2796 : :
2797 : : /* Write VFC address */
2798 [ # # ]: 0 : ARR_REG_WR(p_hwfn,
2799 : : p_ptt,
2800 : : sem_base + SEM_FAST_REG_VFC_ADDR,
2801 : : addr_data, addr_size);
2802 : :
2803 : : /* Read response */
2804 [ # # ]: 0 : for (i = 0; i < resp_size; i++) {
2805 : : /* Poll until ready */
2806 : : do {
2807 : 0 : reg_addr = sem_base + SEM_FAST_REG_VFC_STATUS;
2808 : 0 : qed_grc_dump_addr_range(p_hwfn,
2809 : : p_ptt,
2810 : : &vfc_status,
2811 : : true,
2812 : : BYTES_TO_DWORDS(reg_addr),
2813 : : 1,
2814 : : false, SPLIT_TYPE_NONE, 0);
2815 : 0 : is_ready = vfc_status &
2816 : : OSAL_BIT(VFC_STATUS_RESP_READY_BIT);
2817 : :
2818 [ # # ]: 0 : if (!is_ready) {
2819 [ # # ]: 0 : if (polling_count++ == VFC_POLLING_COUNT)
2820 : : return 0;
2821 : :
2822 : 0 : OSAL_MSLEEP(polling_ms);
2823 : : }
2824 [ # # ]: 0 : } while (!is_ready);
2825 : :
2826 : 0 : reg_addr = sem_base + SEM_FAST_REG_VFC_DATA_RD;
2827 : 0 : qed_grc_dump_addr_range(p_hwfn,
2828 : : p_ptt,
2829 : 0 : dump_buf + i,
2830 : : true,
2831 : : BYTES_TO_DWORDS(reg_addr),
2832 : : 1, false, SPLIT_TYPE_NONE, 0);
2833 : : }
2834 : :
2835 : : return resp_size;
2836 : : }
2837 : :
2838 : : /* Dump VFC CAM. Returns the dumped size in dwords. */
2839 : 0 : static u32 qed_grc_dump_vfc_cam(struct ecore_hwfn *p_hwfn,
2840 : : struct ecore_ptt *p_ptt,
2841 : : u32 *dump_buf, bool dump, u8 storm_id)
2842 : : {
2843 : : u32 total_size = VFC_CAM_NUM_ROWS * VFC_CAM_RESP_DWORDS;
2844 : 0 : struct storm_defs *storm = &s_storm_defs[storm_id];
2845 : : u32 cam_addr[VFC_CAM_ADDR_DWORDS] = { 0 };
2846 : 0 : u32 cam_cmd[VFC_CAM_CMD_DWORDS] = { 0 };
2847 : : u32 row, offset = 0;
2848 : :
2849 : 0 : offset += qed_grc_dump_mem_hdr(p_hwfn,
2850 : : dump_buf + offset,
2851 : : dump,
2852 : : "vfc_cam",
2853 : : 0,
2854 : : total_size,
2855 : : 256,
2856 : 0 : false, "vfc_cam", storm->letter);
2857 : :
2858 [ # # ]: 0 : if (!dump)
2859 : 0 : return offset + total_size;
2860 : :
2861 : : /* Prepare CAM address */
2862 : 0 : SET_VAR_FIELD(cam_addr, VFC_CAM_ADDR, OP, VFC_OPCODE_CAM_RD);
2863 : :
2864 : : /* Read VFC CAM data */
2865 [ # # ]: 0 : for (row = 0; row < VFC_CAM_NUM_ROWS; row++) {
2866 : 0 : SET_VAR_FIELD(cam_cmd, VFC_CAM_CMD, ROW, row);
2867 : 0 : offset += qed_grc_dump_read_from_vfc(p_hwfn,
2868 : : p_ptt,
2869 : : storm,
2870 : : cam_cmd,
2871 : : VFC_CAM_CMD_DWORDS,
2872 : : cam_addr,
2873 : : VFC_CAM_ADDR_DWORDS,
2874 : : VFC_CAM_RESP_DWORDS,
2875 : 0 : dump_buf + offset);
2876 : : }
2877 : :
2878 : : return offset;
2879 : : }
2880 : :
2881 : : /* Dump VFC RAM. Returns the dumped size in dwords. */
2882 : 0 : static u32 qed_grc_dump_vfc_ram(struct ecore_hwfn *p_hwfn,
2883 : : struct ecore_ptt *p_ptt,
2884 : : u32 *dump_buf,
2885 : : bool dump,
2886 : : u8 storm_id, struct vfc_ram_defs *ram_defs)
2887 : : {
2888 : 0 : u32 total_size = ram_defs->num_rows * VFC_RAM_RESP_DWORDS;
2889 : 0 : struct storm_defs *storm = &s_storm_defs[storm_id];
2890 : 0 : u32 ram_addr[VFC_RAM_ADDR_DWORDS] = { 0 };
2891 : 0 : u32 ram_cmd[VFC_RAM_CMD_DWORDS] = { 0 };
2892 : : u32 row, offset = 0;
2893 : :
2894 : 0 : offset += qed_grc_dump_mem_hdr(p_hwfn,
2895 : : dump_buf + offset,
2896 : : dump,
2897 : : ram_defs->mem_name,
2898 : : 0,
2899 : : total_size,
2900 : : 256,
2901 : : false,
2902 : : ram_defs->type_name,
2903 : 0 : storm->letter);
2904 : :
2905 [ # # ]: 0 : if (!dump)
2906 : 0 : return offset + total_size;
2907 : :
2908 : : /* Prepare RAM address */
2909 : : SET_VAR_FIELD(ram_addr, VFC_RAM_ADDR, OP, VFC_OPCODE_RAM_RD);
2910 : :
2911 : : /* Read VFC RAM data */
2912 : 0 : for (row = ram_defs->base_row;
2913 [ # # ]: 0 : row < ram_defs->base_row + ram_defs->num_rows; row++) {
2914 : 0 : SET_VAR_FIELD(ram_addr, VFC_RAM_ADDR, ROW, row);
2915 : 0 : offset += qed_grc_dump_read_from_vfc(p_hwfn,
2916 : : p_ptt,
2917 : : storm,
2918 : : ram_cmd,
2919 : : VFC_RAM_CMD_DWORDS,
2920 : : ram_addr,
2921 : : VFC_RAM_ADDR_DWORDS,
2922 : : VFC_RAM_RESP_DWORDS,
2923 : 0 : dump_buf + offset);
2924 : : }
2925 : :
2926 : : return offset;
2927 : : }
2928 : :
2929 : : /* Dumps GRC VFC data. Returns the dumped size in dwords. */
2930 : 0 : static u32 qed_grc_dump_vfc(struct ecore_hwfn *p_hwfn,
2931 : : struct ecore_ptt *p_ptt, u32 *dump_buf, bool dump)
2932 : : {
2933 : : u8 storm_id, i;
2934 : : u32 offset = 0;
2935 : :
2936 [ # # ]: 0 : for (storm_id = 0; storm_id < MAX_DBG_STORMS; storm_id++) {
2937 [ # # ]: 0 : if (!qed_grc_is_storm_included(p_hwfn,
2938 : 0 : (enum dbg_storms)storm_id) ||
2939 [ # # ]: 0 : !s_storm_defs[storm_id].has_vfc)
2940 : 0 : continue;
2941 : :
2942 : : /* Read CAM */
2943 : 0 : offset += qed_grc_dump_vfc_cam(p_hwfn,
2944 : : p_ptt,
2945 : 0 : dump_buf + offset,
2946 : : dump, storm_id);
2947 : :
2948 : : /* Read RAM */
2949 [ # # ]: 0 : for (i = 0; i < NUM_VFC_RAM_TYPES; i++)
2950 : 0 : offset += qed_grc_dump_vfc_ram(p_hwfn,
2951 : : p_ptt,
2952 : 0 : dump_buf + offset,
2953 : : dump,
2954 : : storm_id,
2955 : 0 : &s_vfc_ram_defs[i]);
2956 : : }
2957 : :
2958 : 0 : return offset;
2959 : : }
2960 : :
2961 : : /* Dumps GRC RSS data. Returns the dumped size in dwords. */
2962 : 0 : static u32 qed_grc_dump_rss(struct ecore_hwfn *p_hwfn,
2963 : : struct ecore_ptt *p_ptt, u32 *dump_buf, bool dump)
2964 : : {
2965 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
2966 : : u32 offset = 0;
2967 : : u8 rss_mem_id;
2968 : :
2969 [ # # ]: 0 : for (rss_mem_id = 0; rss_mem_id < NUM_RSS_MEM_TYPES; rss_mem_id++) {
2970 : : u32 rss_addr, num_entries, total_dwords;
2971 : : struct rss_mem_defs *rss_defs;
2972 : : u32 addr, num_dwords_to_read;
2973 : : bool packed;
2974 : :
2975 : 0 : rss_defs = &s_rss_mem_defs[rss_mem_id];
2976 : 0 : rss_addr = rss_defs->addr;
2977 : 0 : num_entries = rss_defs->num_entries[dev_data->chip_id];
2978 : 0 : total_dwords = (num_entries * rss_defs->entry_width) / 32;
2979 : 0 : packed = (rss_defs->entry_width == 16);
2980 : :
2981 : 0 : offset += qed_grc_dump_mem_hdr(p_hwfn,
2982 : 0 : dump_buf + offset,
2983 : : dump,
2984 : : rss_defs->mem_name,
2985 : : 0,
2986 : : total_dwords,
2987 : : rss_defs->entry_width,
2988 : : packed,
2989 : : rss_defs->type_name, 0);
2990 : :
2991 : : /* Dump RSS data */
2992 [ # # ]: 0 : if (!dump) {
2993 : 0 : offset += total_dwords;
2994 : 0 : continue;
2995 : : }
2996 : :
2997 : : addr = BYTES_TO_DWORDS(RSS_REG_RSS_RAM_DATA);
2998 [ # # ]: 0 : while (total_dwords) {
2999 : 0 : num_dwords_to_read = OSAL_MIN_T(u32,
3000 : : RSS_REG_RSS_RAM_DATA_SIZE,
3001 : : total_dwords);
3002 : 0 : ecore_wr(p_hwfn, p_ptt, RSS_REG_RSS_RAM_ADDR, rss_addr);
3003 : 0 : offset += qed_grc_dump_addr_range(p_hwfn,
3004 : : p_ptt,
3005 : 0 : dump_buf + offset,
3006 : : dump,
3007 : : addr,
3008 : : num_dwords_to_read,
3009 : : false,
3010 : : SPLIT_TYPE_NONE, 0);
3011 : 0 : total_dwords -= num_dwords_to_read;
3012 : 0 : rss_addr++;
3013 : : }
3014 : : }
3015 : :
3016 : 0 : return offset;
3017 : : }
3018 : :
3019 : : /* Dumps GRC Big RAM. Returns the dumped size in dwords. */
3020 : 0 : static u32 qed_grc_dump_big_ram(struct ecore_hwfn *p_hwfn,
3021 : : struct ecore_ptt *p_ptt,
3022 : : u32 *dump_buf, bool dump, u8 big_ram_id)
3023 : : {
3024 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
3025 : : u32 block_size, ram_size, offset = 0, reg_val, i;
3026 : 0 : char mem_name[12] = "???_BIG_RAM";
3027 : 0 : char type_name[8] = "???_RAM";
3028 : : struct big_ram_defs *big_ram;
3029 : :
3030 : 0 : big_ram = &s_big_ram_defs[big_ram_id];
3031 : 0 : ram_size = big_ram->ram_size[dev_data->chip_id];
3032 : :
3033 : 0 : reg_val = ecore_rd(p_hwfn, p_ptt, big_ram->is_256b_reg_addr);
3034 : : block_size = reg_val &
3035 : 0 : OSAL_BIT(big_ram->is_256b_bit_offset[dev_data->chip_id]) ?
3036 [ # # ]: 0 : 256 : 128;
3037 : :
3038 : 0 : strncpy(type_name, big_ram->instance_name, BIG_RAM_NAME_LEN);
3039 : : strncpy(mem_name, big_ram->instance_name, BIG_RAM_NAME_LEN);
3040 : :
3041 : : /* Dump memory header */
3042 : 0 : offset += qed_grc_dump_mem_hdr(p_hwfn,
3043 : : dump_buf + offset,
3044 : : dump,
3045 : : mem_name,
3046 : : 0,
3047 : : ram_size,
3048 : : block_size * 8,
3049 : : false, type_name, 0);
3050 : :
3051 : : /* Read and dump Big RAM data */
3052 [ # # ]: 0 : if (!dump)
3053 : 0 : return offset + ram_size;
3054 : :
3055 : : /* Dump Big RAM */
3056 [ # # ]: 0 : for (i = 0; i < DIV_ROUND_UP(ram_size, BRB_REG_BIG_RAM_DATA_SIZE);
3057 : 0 : i++) {
3058 : : u32 addr, len;
3059 : :
3060 : 0 : ecore_wr(p_hwfn, p_ptt, big_ram->addr_reg_addr, i);
3061 : 0 : addr = BYTES_TO_DWORDS(big_ram->data_reg_addr);
3062 : : len = BRB_REG_BIG_RAM_DATA_SIZE;
3063 : 0 : offset += qed_grc_dump_addr_range(p_hwfn,
3064 : : p_ptt,
3065 : 0 : dump_buf + offset,
3066 : : dump,
3067 : : addr,
3068 : : len,
3069 : : false, SPLIT_TYPE_NONE, 0);
3070 : : }
3071 : :
3072 : : return offset;
3073 : : }
3074 : :
3075 : : /* Dumps MCP scratchpad. Returns the dumped size in dwords. */
3076 : 0 : static u32 qed_grc_dump_mcp(struct ecore_hwfn *p_hwfn,
3077 : : struct ecore_ptt *p_ptt, u32 *dump_buf, bool dump)
3078 : : {
3079 : 0 : bool block_enable[MAX_BLOCK_ID] = { 0 };
3080 : : u32 offset = 0, addr;
3081 : : bool halted = false;
3082 : :
3083 : : /* Halt MCP */
3084 [ # # # # ]: 0 : if (dump && !qed_grc_get_param(p_hwfn, DBG_GRC_PARAM_NO_MCP)) {
3085 : 0 : halted = !ecore_mcp_halt(p_hwfn, p_ptt);
3086 [ # # ]: 0 : if (!halted)
3087 : 0 : DP_NOTICE(p_hwfn, false, "MCP halt failed!\n");
3088 : : }
3089 : :
3090 : : /* Dump MCP scratchpad */
3091 : 0 : offset += qed_grc_dump_mem(p_hwfn,
3092 : : p_ptt,
3093 : : dump_buf + offset,
3094 : : dump,
3095 : : NULL,
3096 : : BYTES_TO_DWORDS(MCP_REG_SCRATCH),
3097 : : MCP_REG_SCRATCH_SIZE,
3098 : : false, 0, false, "MCP", 0);
3099 : :
3100 : : /* Dump MCP cpu_reg_file */
3101 : 0 : offset += qed_grc_dump_mem(p_hwfn,
3102 : : p_ptt,
3103 : 0 : dump_buf + offset,
3104 : : dump,
3105 : : NULL,
3106 : : BYTES_TO_DWORDS(MCP_REG_CPU_REG_FILE),
3107 : : MCP_REG_CPU_REG_FILE_SIZE,
3108 : : false, 0, false, "MCP", 0);
3109 : :
3110 : : /* Dump MCP registers */
3111 : 0 : block_enable[BLOCK_MCP] = true;
3112 : 0 : offset += qed_grc_dump_registers(p_hwfn,
3113 : : p_ptt,
3114 : 0 : dump_buf + offset,
3115 : : dump, block_enable, "MCP");
3116 : :
3117 : : /* Dump required non-MCP registers */
3118 : 0 : offset += qed_grc_dump_regs_hdr(dump_buf + offset,
3119 : : dump, 1, SPLIT_TYPE_NONE, 0,
3120 : : "MCP");
3121 : : addr = BYTES_TO_DWORDS(MISC_REG_SHARED_MEM_ADDR);
3122 : 0 : offset += qed_grc_dump_reg_entry(p_hwfn,
3123 : : p_ptt,
3124 [ # # ]: 0 : dump_buf + offset,
3125 : : dump,
3126 : : addr,
3127 : : 1,
3128 : : false, SPLIT_TYPE_NONE, 0);
3129 : :
3130 : : /* Release MCP */
3131 [ # # # # ]: 0 : if (halted && ecore_mcp_resume(p_hwfn, p_ptt))
3132 : 0 : DP_NOTICE(p_hwfn, false, "Failed to resume MCP after halt!\n");
3133 : :
3134 : 0 : return offset;
3135 : : }
3136 : :
3137 : : /* Dumps the tbus indirect memory for all PHYs.
3138 : : * Returns the dumped size in dwords.
3139 : : */
3140 : 0 : static u32 qed_grc_dump_phy(struct ecore_hwfn *p_hwfn,
3141 : : struct ecore_ptt *p_ptt, u32 *dump_buf, bool dump)
3142 : : {
3143 : : u32 offset = 0, tbus_lo_offset, tbus_hi_offset;
3144 : : char mem_name[32];
3145 : : u8 phy_id;
3146 : :
3147 [ # # ]: 0 : for (phy_id = 0; phy_id < OSAL_ARRAY_SIZE(s_phy_defs); phy_id++) {
3148 : : u32 addr_lo_addr, addr_hi_addr, data_lo_addr, data_hi_addr;
3149 : : struct phy_defs *phy_defs;
3150 : : u8 *bytes_buf;
3151 : :
3152 : 0 : phy_defs = &s_phy_defs[phy_id];
3153 : 0 : addr_lo_addr = phy_defs->base_addr +
3154 : 0 : phy_defs->tbus_addr_lo_addr;
3155 : 0 : addr_hi_addr = phy_defs->base_addr +
3156 : 0 : phy_defs->tbus_addr_hi_addr;
3157 : 0 : data_lo_addr = phy_defs->base_addr +
3158 : 0 : phy_defs->tbus_data_lo_addr;
3159 : 0 : data_hi_addr = phy_defs->base_addr +
3160 : 0 : phy_defs->tbus_data_hi_addr;
3161 : :
3162 [ # # ]: 0 : if (snprintf(mem_name, sizeof(mem_name), "tbus_%s",
3163 : : phy_defs->phy_name) < 0)
3164 : 0 : DP_NOTICE(p_hwfn, false,
3165 : : "Unexpected debug error: invalid PHY memory name\n");
3166 : :
3167 : 0 : offset += qed_grc_dump_mem_hdr(p_hwfn,
3168 : 0 : dump_buf + offset,
3169 : : dump,
3170 : : mem_name,
3171 : : 0,
3172 : : PHY_DUMP_SIZE_DWORDS,
3173 : : 16, true, mem_name, 0);
3174 : :
3175 [ # # ]: 0 : if (!dump) {
3176 : 0 : offset += PHY_DUMP_SIZE_DWORDS;
3177 : 0 : continue;
3178 : : }
3179 : :
3180 : 0 : bytes_buf = (u8 *)(dump_buf + offset);
3181 : 0 : for (tbus_hi_offset = 0;
3182 [ # # ]: 0 : tbus_hi_offset < (NUM_PHY_TBUS_ADDRESSES >> 8);
3183 : 0 : tbus_hi_offset++) {
3184 : 0 : ecore_wr(p_hwfn, p_ptt, addr_hi_addr, tbus_hi_offset);
3185 [ # # ]: 0 : for (tbus_lo_offset = 0; tbus_lo_offset < 256;
3186 : 0 : tbus_lo_offset++) {
3187 : 0 : ecore_wr(p_hwfn,
3188 : : p_ptt, addr_lo_addr, tbus_lo_offset);
3189 : 0 : *(bytes_buf++) = (u8)ecore_rd(p_hwfn,
3190 : : p_ptt,
3191 : : data_lo_addr);
3192 : 0 : *(bytes_buf++) = (u8)ecore_rd(p_hwfn,
3193 : : p_ptt,
3194 : : data_hi_addr);
3195 : : }
3196 : : }
3197 : :
3198 : 0 : offset += PHY_DUMP_SIZE_DWORDS;
3199 : : }
3200 : :
3201 : 0 : return offset;
3202 : : }
3203 : :
3204 : : static enum dbg_status qed_find_nvram_image(struct ecore_hwfn *p_hwfn,
3205 : : struct ecore_ptt *p_ptt,
3206 : : u32 image_type,
3207 : : u32 *nvram_offset_bytes,
3208 : : u32 *nvram_size_bytes);
3209 : :
3210 : : static enum dbg_status qed_nvram_read(struct ecore_hwfn *p_hwfn,
3211 : : struct ecore_ptt *p_ptt,
3212 : : u32 nvram_offset_bytes,
3213 : : u32 nvram_size_bytes, u32 *ret_buf);
3214 : :
3215 : : /* Dumps the MCP HW dump from NVRAM. Returns the dumped size in dwords. */
3216 : 0 : static u32 qed_grc_dump_mcp_hw_dump(struct ecore_hwfn *p_hwfn,
3217 : : struct ecore_ptt *p_ptt,
3218 : : u32 *dump_buf, bool dump)
3219 : : {
3220 : 0 : u32 hw_dump_offset_bytes = 0, hw_dump_size_bytes = 0;
3221 : : u32 hw_dump_size_dwords = 0, offset = 0;
3222 : : enum dbg_status status;
3223 : :
3224 : : /* Read HW dump image from NVRAM */
3225 : 0 : status = qed_find_nvram_image(p_hwfn,
3226 : : p_ptt,
3227 : : NVM_TYPE_HW_DUMP_OUT,
3228 : : &hw_dump_offset_bytes,
3229 : : &hw_dump_size_bytes);
3230 [ # # ]: 0 : if (status != DBG_STATUS_OK)
3231 : : return 0;
3232 : :
3233 : 0 : hw_dump_size_dwords = BYTES_TO_DWORDS(hw_dump_size_bytes);
3234 : :
3235 : : /* Dump HW dump image section */
3236 : 0 : offset += qed_dump_section_hdr(dump_buf + offset,
3237 : : dump, "mcp_hw_dump", 1);
3238 : 0 : offset += qed_dump_num_param(dump_buf + offset,
3239 : : dump, "size", hw_dump_size_dwords);
3240 : :
3241 : : /* Read MCP HW dump image into dump buffer */
3242 [ # # ]: 0 : if (dump && hw_dump_size_dwords) {
3243 : 0 : status = qed_nvram_read(p_hwfn,
3244 : : p_ptt,
3245 : : hw_dump_offset_bytes,
3246 : 0 : hw_dump_size_bytes, dump_buf + offset);
3247 [ # # ]: 0 : if (status != DBG_STATUS_OK) {
3248 : 0 : DP_NOTICE(p_hwfn, false,
3249 : : "Failed to read MCP HW Dump image from NVRAM\n");
3250 : 0 : return 0;
3251 : : }
3252 : : }
3253 : 0 : offset += hw_dump_size_dwords;
3254 : :
3255 : 0 : return offset;
3256 : : }
3257 : :
3258 : : /* Dumps Static Debug data. Returns the dumped size in dwords. */
3259 : 0 : static u32 qed_grc_dump_static_debug(struct ecore_hwfn *p_hwfn,
3260 : : struct ecore_ptt *p_ptt,
3261 : : u32 *dump_buf, bool dump)
3262 : : {
3263 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
3264 : : u32 block_id, line_id, offset = 0, addr, len;
3265 : :
3266 : : /* Don't dump static debug if a debug bus recording is in progress */
3267 [ # # # # ]: 0 : if (dump && ecore_rd(p_hwfn, p_ptt, DBG_REG_DBG_BLOCK_ON))
3268 : : return 0;
3269 : :
3270 [ # # ]: 0 : if (dump) {
3271 : : /* Disable debug bus in all blocks */
3272 : 0 : qed_bus_disable_blocks(p_hwfn, p_ptt);
3273 : :
3274 : 0 : qed_bus_reset_dbg_block(p_hwfn, p_ptt);
3275 : 0 : ecore_wr(p_hwfn,
3276 : : p_ptt, DBG_REG_FRAMING_MODE, DBG_BUS_FRAME_MODE_8HW);
3277 : 0 : ecore_wr(p_hwfn,
3278 : : p_ptt, DBG_REG_DEBUG_TARGET, DBG_BUS_TARGET_ID_INT_BUF);
3279 : 0 : ecore_wr(p_hwfn, p_ptt, DBG_REG_FULL_MODE, 1);
3280 : : qed_bus_enable_dbg_block(p_hwfn, p_ptt, true);
3281 : : }
3282 : :
3283 : : /* Dump all static debug lines for each relevant block */
3284 [ # # ]: 0 : for (block_id = 0; block_id < MAX_BLOCK_ID; block_id++) {
3285 : : const struct dbg_block_chip *block_per_chip;
3286 : : const struct dbg_block *block;
3287 : : bool is_removed, has_dbg_bus;
3288 : : u16 modes_buf_offset;
3289 : : u32 block_dwords;
3290 : :
3291 : : block_per_chip =
3292 : : qed_get_dbg_block_per_chip(p_hwfn, (enum block_id)block_id);
3293 : 0 : is_removed = GET_FIELD(block_per_chip->flags,
3294 : : DBG_BLOCK_CHIP_IS_REMOVED);
3295 : 0 : has_dbg_bus = GET_FIELD(block_per_chip->flags,
3296 : : DBG_BLOCK_CHIP_HAS_DBG_BUS);
3297 : :
3298 : : /* read+clear for NWS parity is not working, skip NWS block */
3299 [ # # ]: 0 : if (block_id == BLOCK_NWS)
3300 : 0 : continue;
3301 : :
3302 [ # # ]: 0 : if (!is_removed && has_dbg_bus &&
3303 [ # # ]: 0 : GET_FIELD(block_per_chip->dbg_bus_mode.data,
3304 : : DBG_MODE_HDR_EVAL_MODE) > 0) {
3305 : 0 : modes_buf_offset =
3306 : : GET_FIELD(block_per_chip->dbg_bus_mode.data,
3307 : : DBG_MODE_HDR_MODES_BUF_OFFSET);
3308 [ # # ]: 0 : if (!qed_is_mode_match(p_hwfn, &modes_buf_offset))
3309 : : has_dbg_bus = false;
3310 : : }
3311 : :
3312 [ # # ]: 0 : if (is_removed || !has_dbg_bus)
3313 : 0 : continue;
3314 : :
3315 [ # # ]: 0 : block_dwords = NUM_DBG_LINES(block_per_chip) *
3316 : : STATIC_DEBUG_LINE_DWORDS;
3317 : :
3318 : : /* Dump static section params */
3319 : : block = get_dbg_block(p_hwfn, (enum block_id)block_id);
3320 : 0 : offset += qed_grc_dump_mem_hdr(p_hwfn,
3321 : 0 : dump_buf + offset,
3322 : : dump,
3323 : 0 : (const char *)block->name,
3324 : : 0,
3325 : : block_dwords,
3326 : : 32, false, "STATIC", 0);
3327 : :
3328 [ # # ]: 0 : if (!dump) {
3329 : 0 : offset += block_dwords;
3330 : 0 : continue;
3331 : : }
3332 : :
3333 : : /* If all lines are invalid - dump zeros */
3334 [ # # ]: 0 : if (dev_data->block_in_reset[block_id]) {
3335 : 0 : memset(dump_buf + offset, 0,
3336 : : DWORDS_TO_BYTES(block_dwords));
3337 : 0 : offset += block_dwords;
3338 : 0 : continue;
3339 : : }
3340 : :
3341 : : /* Enable block's client */
3342 : 0 : qed_bus_enable_clients(p_hwfn,
3343 : : p_ptt,
3344 : 0 : OSAL_BIT(block_per_chip->dbg_client_id));
3345 : :
3346 : : addr = BYTES_TO_DWORDS(DBG_REG_CALENDAR_OUT_DATA);
3347 : : len = STATIC_DEBUG_LINE_DWORDS;
3348 [ # # # # ]: 0 : for (line_id = 0; line_id < (u32)NUM_DBG_LINES(block_per_chip);
3349 : 0 : line_id++) {
3350 : : /* Configure debug line ID */
3351 : 0 : qed_bus_config_dbg_line(p_hwfn,
3352 : : p_ptt,
3353 : : (enum block_id)block_id,
3354 : : (u8)line_id, 0xf, 0, 0, 0);
3355 : :
3356 : : /* Read debug line info */
3357 : 0 : offset += qed_grc_dump_addr_range(p_hwfn,
3358 : : p_ptt,
3359 : 0 : dump_buf + offset,
3360 : : dump,
3361 : : addr,
3362 : : len,
3363 : : true, SPLIT_TYPE_NONE,
3364 : : 0);
3365 : : }
3366 : :
3367 : : /* Disable block's client and debug output */
3368 : : qed_bus_enable_clients(p_hwfn, p_ptt, 0);
3369 : 0 : qed_bus_config_dbg_line(p_hwfn, p_ptt,
3370 : : (enum block_id)block_id, 0, 0, 0, 0, 0);
3371 : : }
3372 : :
3373 [ # # ]: 0 : if (dump) {
3374 : : qed_bus_enable_dbg_block(p_hwfn, p_ptt, false);
3375 : : qed_bus_enable_clients(p_hwfn, p_ptt, 0);
3376 : : }
3377 : :
3378 : : return offset;
3379 : : }
3380 : :
3381 : : /* Performs GRC Dump to the specified buffer.
3382 : : * Returns the dumped size in dwords.
3383 : : */
3384 : 0 : static enum dbg_status qed_grc_dump(struct ecore_hwfn *p_hwfn,
3385 : : struct ecore_ptt *p_ptt,
3386 : : u32 *dump_buf,
3387 : : bool dump, u32 *num_dumped_dwords)
3388 : : {
3389 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
3390 : : u32 dwords_read, offset = 0;
3391 : : bool parities_masked = false;
3392 : : u8 i;
3393 : :
3394 : 0 : *num_dumped_dwords = 0;
3395 : 0 : dev_data->num_regs_read = 0;
3396 : :
3397 : : /* Update reset state */
3398 [ # # ]: 0 : if (dump)
3399 : 0 : qed_update_blocks_reset_state(p_hwfn, p_ptt);
3400 : :
3401 : : /* Dump global params */
3402 : 0 : offset += qed_dump_common_global_params(p_hwfn,
3403 : : p_ptt,
3404 : : dump_buf + offset, dump, 4);
3405 : 0 : offset += qed_dump_str_param(dump_buf + offset,
3406 : : dump, "dump-type", "grc-dump");
3407 : 0 : offset += qed_dump_num_param(dump_buf + offset,
3408 : : dump,
3409 : : "num-lcids",
3410 : : NUM_OF_LCIDS);
3411 : 0 : offset += qed_dump_num_param(dump_buf + offset,
3412 : : dump,
3413 : : "num-ltids",
3414 : : NUM_OF_LTIDS);
3415 : 0 : offset += qed_dump_num_param(dump_buf + offset,
3416 : 0 : dump, "num-ports", dev_data->num_ports);
3417 : :
3418 : : /* Dump reset registers (dumped before taking blocks out of reset ) */
3419 [ # # ]: 0 : if (qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_REGS))
3420 : 0 : offset += qed_grc_dump_reset_regs(p_hwfn,
3421 : : p_ptt,
3422 : 0 : dump_buf + offset, dump);
3423 : :
3424 : : /* Take all blocks out of reset (using reset registers) */
3425 [ # # ]: 0 : if (dump) {
3426 : 0 : qed_grc_unreset_blocks(p_hwfn, p_ptt, false);
3427 : 0 : qed_update_blocks_reset_state(p_hwfn, p_ptt);
3428 : : }
3429 : :
3430 : : /* Disable all parities using MFW command */
3431 [ # # # # ]: 0 : if (dump &&
3432 : : !qed_grc_get_param(p_hwfn, DBG_GRC_PARAM_NO_MCP)) {
3433 : 0 : parities_masked = !ecore_mcp_mask_parities(p_hwfn, p_ptt, 1);
3434 [ # # ]: 0 : if (!parities_masked) {
3435 : 0 : DP_NOTICE(p_hwfn, false,
3436 : : "Failed to mask parities using MFW\n");
3437 [ # # ]: 0 : if (qed_grc_get_param
3438 : : (p_hwfn, DBG_GRC_PARAM_PARITY_SAFE))
3439 : : return DBG_STATUS_MCP_COULD_NOT_MASK_PRTY;
3440 : : }
3441 : : }
3442 : :
3443 : : /* Dump modified registers (dumped before modifying them) */
3444 [ # # ]: 0 : if (qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_REGS))
3445 : 0 : offset += qed_grc_dump_modified_regs(p_hwfn,
3446 : : p_ptt,
3447 : 0 : dump_buf + offset, dump);
3448 : :
3449 : : /* Stall storms */
3450 [ # # # # ]: 0 : if (dump &&
3451 : : (qed_grc_is_included(p_hwfn,
3452 [ # # ]: 0 : DBG_GRC_PARAM_DUMP_IOR) ||
3453 : : qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_VFC)))
3454 : 0 : qed_grc_stall_storms(p_hwfn, p_ptt, true);
3455 : :
3456 : : /* Dump all regs */
3457 [ # # ]: 0 : if (qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_REGS)) {
3458 : : bool block_enable[MAX_BLOCK_ID];
3459 : :
3460 : : /* Dump all blocks except MCP */
3461 [ # # ]: 0 : for (i = 0; i < MAX_BLOCK_ID; i++)
3462 : 0 : block_enable[i] = true;
3463 : 0 : block_enable[BLOCK_MCP] = false;
3464 : 0 : offset += qed_grc_dump_registers(p_hwfn,
3465 : : p_ptt,
3466 : 0 : dump_buf +
3467 : : offset,
3468 : : dump,
3469 : : block_enable, NULL);
3470 : :
3471 : : /* Dump special registers */
3472 : 0 : offset += qed_grc_dump_special_regs(p_hwfn,
3473 : : p_ptt,
3474 : 0 : dump_buf + offset, dump);
3475 : : }
3476 : :
3477 : : /* Dump memories */
3478 : 0 : offset += qed_grc_dump_memories(p_hwfn, p_ptt, dump_buf + offset, dump);
3479 : :
3480 : : /* Dump MCP */
3481 [ # # ]: 0 : if (qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_MCP))
3482 : 0 : offset += qed_grc_dump_mcp(p_hwfn,
3483 : 0 : p_ptt, dump_buf + offset, dump);
3484 : :
3485 : : /* Dump context */
3486 [ # # ]: 0 : if (qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_CM_CTX))
3487 : 0 : offset += qed_grc_dump_ctx(p_hwfn,
3488 : 0 : p_ptt, dump_buf + offset, dump);
3489 : :
3490 : : /* Dump RSS memories */
3491 [ # # ]: 0 : if (qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_RSS))
3492 : 0 : offset += qed_grc_dump_rss(p_hwfn,
3493 : 0 : p_ptt, dump_buf + offset, dump);
3494 : :
3495 : : /* Dump Big RAM */
3496 [ # # ]: 0 : for (i = 0; i < NUM_BIG_RAM_TYPES; i++)
3497 [ # # ]: 0 : if (qed_grc_is_included(p_hwfn, s_big_ram_defs[i].grc_param))
3498 : 0 : offset += qed_grc_dump_big_ram(p_hwfn,
3499 : : p_ptt,
3500 : 0 : dump_buf + offset,
3501 : : dump, i);
3502 : :
3503 : : /* Dump VFC */
3504 [ # # ]: 0 : if (qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_VFC)) {
3505 : 0 : dwords_read = qed_grc_dump_vfc(p_hwfn,
3506 : 0 : p_ptt, dump_buf + offset, dump);
3507 : 0 : offset += dwords_read;
3508 [ # # ]: 0 : if (!dwords_read)
3509 : : return DBG_STATUS_VFC_READ_ERROR;
3510 : : }
3511 : :
3512 : : /* Dump PHY tbus */
3513 [ # # ]: 0 : if (qed_grc_is_included(p_hwfn,
3514 : : DBG_GRC_PARAM_DUMP_PHY) && dev_data->chip_id ==
3515 [ # # ]: 0 : CHIP_K2 && dev_data->hw_type == HW_TYPE_ASIC)
3516 : 0 : offset += qed_grc_dump_phy(p_hwfn,
3517 : 0 : p_ptt, dump_buf + offset, dump);
3518 : :
3519 : : /* Dump MCP HW Dump */
3520 [ # # # # ]: 0 : if (qed_grc_is_included(p_hwfn, DBG_GRC_PARAM_DUMP_MCP_HW_DUMP) &&
3521 : : !qed_grc_get_param(p_hwfn, DBG_GRC_PARAM_NO_MCP))
3522 : 0 : offset += qed_grc_dump_mcp_hw_dump(p_hwfn,
3523 : : p_ptt,
3524 : 0 : dump_buf + offset, dump);
3525 : :
3526 : : /* Dump static debug data (only if not during debug bus recording) */
3527 [ # # ]: 0 : if (qed_grc_is_included(p_hwfn,
3528 [ # # ]: 0 : DBG_GRC_PARAM_DUMP_STATIC) &&
3529 [ # # ]: 0 : (!dump || dev_data->bus.state == DBG_BUS_STATE_IDLE))
3530 : 0 : offset += qed_grc_dump_static_debug(p_hwfn,
3531 : : p_ptt,
3532 : 0 : dump_buf + offset, dump);
3533 : :
3534 : : /* Dump last section */
3535 : 0 : offset += qed_dump_last_section(dump_buf, offset, dump);
3536 : :
3537 [ # # ]: 0 : if (dump) {
3538 : : /* Unstall storms */
3539 [ # # ]: 0 : if (qed_grc_get_param(p_hwfn, DBG_GRC_PARAM_UNSTALL))
3540 : 0 : qed_grc_stall_storms(p_hwfn, p_ptt, false);
3541 : :
3542 : : /* Clear parity status */
3543 : 0 : qed_grc_clear_all_prty(p_hwfn, p_ptt);
3544 : :
3545 : : /* Enable all parities using MFW command */
3546 [ # # ]: 0 : if (parities_masked)
3547 : 0 : ecore_mcp_mask_parities(p_hwfn, p_ptt, 0);
3548 : : }
3549 : :
3550 : 0 : *num_dumped_dwords = offset;
3551 : :
3552 : 0 : return DBG_STATUS_OK;
3553 : : }
3554 : :
3555 : : /* Writes the specified failing Idle Check rule to the specified buffer.
3556 : : * Returns the dumped size in dwords.
3557 : : */
3558 : 0 : static u32 qed_idle_chk_dump_failure(struct ecore_hwfn *p_hwfn,
3559 : : struct ecore_ptt *p_ptt,
3560 : : u32 *
3561 : : dump_buf,
3562 : : bool dump,
3563 : : u16 rule_id,
3564 : : const struct dbg_idle_chk_rule *rule,
3565 : : u16 fail_entry_id, u32 *cond_reg_values)
3566 : : {
3567 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
3568 : : const struct dbg_idle_chk_cond_reg *cond_regs;
3569 : : const struct dbg_idle_chk_info_reg *info_regs;
3570 : : u32 i, next_reg_offset = 0, offset = 0;
3571 : : struct dbg_idle_chk_result_hdr *hdr;
3572 : : const union dbg_idle_chk_reg *regs;
3573 : : u8 reg_id;
3574 : :
3575 : : hdr = (struct dbg_idle_chk_result_hdr *)dump_buf;
3576 : 0 : regs = (const union dbg_idle_chk_reg *)
3577 : 0 : p_hwfn->dbg_arrays[BIN_BUF_DBG_IDLE_CHK_REGS].ptr +
3578 : 0 : rule->reg_offset;
3579 : 0 : cond_regs = ®s[0].cond_reg;
3580 : 0 : info_regs = ®s[rule->num_cond_regs].info_reg;
3581 : :
3582 : : /* Dump rule data */
3583 [ # # ]: 0 : if (dump) {
3584 : : memset(hdr, 0, sizeof(*hdr));
3585 : 0 : hdr->rule_id = rule_id;
3586 : 0 : hdr->mem_entry_id = fail_entry_id;
3587 : 0 : hdr->severity = rule->severity;
3588 : 0 : hdr->num_dumped_cond_regs = rule->num_cond_regs;
3589 : : }
3590 : :
3591 : : offset += IDLE_CHK_RESULT_HDR_DWORDS;
3592 : :
3593 : : /* Dump condition register values */
3594 [ # # ]: 0 : for (reg_id = 0; reg_id < rule->num_cond_regs; reg_id++) {
3595 : 0 : const struct dbg_idle_chk_cond_reg *reg = &cond_regs[reg_id];
3596 : : struct dbg_idle_chk_result_reg_hdr *reg_hdr;
3597 : :
3598 : 0 : reg_hdr =
3599 : 0 : (struct dbg_idle_chk_result_reg_hdr *)(dump_buf + offset);
3600 : :
3601 : : /* Write register header */
3602 [ # # ]: 0 : if (!dump) {
3603 : 0 : offset += IDLE_CHK_RESULT_REG_HDR_DWORDS +
3604 : 0 : reg->entry_size;
3605 : 0 : continue;
3606 : : }
3607 : :
3608 [ # # ]: 0 : offset += IDLE_CHK_RESULT_REG_HDR_DWORDS;
3609 : : memset(reg_hdr, 0, sizeof(*reg_hdr));
3610 : 0 : reg_hdr->start_entry = reg->start_entry;
3611 : 0 : reg_hdr->size = reg->entry_size;
3612 [ # # # # ]: 0 : SET_FIELD(reg_hdr->data,
3613 : : DBG_IDLE_CHK_RESULT_REG_HDR_IS_MEM,
3614 : : reg->num_entries > 1 || reg->start_entry > 0 ? 1 : 0);
3615 : 0 : SET_FIELD(reg_hdr->data,
3616 : : DBG_IDLE_CHK_RESULT_REG_HDR_REG_ID, reg_id);
3617 : :
3618 : : /* Write register values */
3619 [ # # ]: 0 : for (i = 0; i < reg_hdr->size; i++, next_reg_offset++, offset++)
3620 : 0 : dump_buf[offset] = cond_reg_values[next_reg_offset];
3621 : : }
3622 : :
3623 : : /* Dump info register values */
3624 [ # # ]: 0 : for (reg_id = 0; reg_id < rule->num_info_regs; reg_id++) {
3625 : 0 : const struct dbg_idle_chk_info_reg *reg = &info_regs[reg_id];
3626 : : u32 block_id;
3627 : :
3628 : : /* Check if register's block is in reset */
3629 [ # # ]: 0 : if (!dump) {
3630 : 0 : offset += IDLE_CHK_RESULT_REG_HDR_DWORDS + reg->size;
3631 : 0 : continue;
3632 : : }
3633 : :
3634 : 0 : block_id = GET_FIELD(reg->data, DBG_IDLE_CHK_INFO_REG_BLOCK_ID);
3635 [ # # ]: 0 : if (block_id >= MAX_BLOCK_ID) {
3636 : 0 : DP_NOTICE(p_hwfn, false, "Invalid block_id\n");
3637 : 0 : return 0;
3638 : : }
3639 : :
3640 [ # # ]: 0 : if (!dev_data->block_in_reset[block_id]) {
3641 : : struct dbg_idle_chk_result_reg_hdr *reg_hdr;
3642 : : bool wide_bus, eval_mode, mode_match = true;
3643 : : u16 modes_buf_offset;
3644 : : u32 addr;
3645 : :
3646 : 0 : reg_hdr = (struct dbg_idle_chk_result_reg_hdr *)
3647 : 0 : (dump_buf + offset);
3648 : :
3649 : : /* Check mode */
3650 : 0 : eval_mode = GET_FIELD(reg->mode.data,
3651 : : DBG_MODE_HDR_EVAL_MODE) > 0;
3652 [ # # ]: 0 : if (eval_mode) {
3653 : 0 : modes_buf_offset =
3654 : : GET_FIELD(reg->mode.data,
3655 : : DBG_MODE_HDR_MODES_BUF_OFFSET);
3656 : : mode_match =
3657 : : qed_is_mode_match(p_hwfn,
3658 : : &modes_buf_offset);
3659 : : }
3660 : :
3661 [ # # ]: 0 : if (!mode_match)
3662 : 0 : continue;
3663 : :
3664 : 0 : addr = GET_FIELD(reg->data,
3665 : : DBG_IDLE_CHK_INFO_REG_ADDRESS);
3666 : 0 : wide_bus = GET_FIELD(reg->data,
3667 : : DBG_IDLE_CHK_INFO_REG_WIDE_BUS);
3668 : :
3669 : : /* Write register header */
3670 : 0 : offset += IDLE_CHK_RESULT_REG_HDR_DWORDS;
3671 : 0 : hdr->num_dumped_info_regs++;
3672 : : memset(reg_hdr, 0, sizeof(*reg_hdr));
3673 : 0 : reg_hdr->size = reg->size;
3674 : 0 : SET_FIELD(reg_hdr->data,
3675 : : DBG_IDLE_CHK_RESULT_REG_HDR_REG_ID,
3676 : : rule->num_cond_regs + reg_id);
3677 : :
3678 : : /* Write register values */
3679 : 0 : offset += qed_grc_dump_addr_range(p_hwfn,
3680 : : p_ptt,
3681 : 0 : dump_buf + offset,
3682 : : dump,
3683 : : addr,
3684 : : reg->size, wide_bus,
3685 : : SPLIT_TYPE_NONE, 0);
3686 : : }
3687 : : }
3688 : :
3689 : : return offset;
3690 : : }
3691 : :
3692 : : /* Dumps idle check rule entries. Returns the dumped size in dwords. */
3693 : : static u32
3694 : 0 : qed_idle_chk_dump_rule_entries(struct ecore_hwfn *p_hwfn,
3695 : : struct ecore_ptt *p_ptt,
3696 : : u32 *dump_buf, bool dump,
3697 : : const struct dbg_idle_chk_rule *input_rules,
3698 : : u32 num_input_rules, u32 *num_failing_rules)
3699 : : {
3700 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
3701 : : u32 cond_reg_values[IDLE_CHK_MAX_ENTRIES_SIZE];
3702 : : u32 i, offset = 0;
3703 : : u16 entry_id;
3704 : : u8 reg_id;
3705 : :
3706 : 0 : *num_failing_rules = 0;
3707 : :
3708 [ # # ]: 0 : for (i = 0; i < num_input_rules; i++) {
3709 : : const struct dbg_idle_chk_cond_reg *cond_regs;
3710 : : const struct dbg_idle_chk_rule *rule;
3711 : : const union dbg_idle_chk_reg *regs;
3712 : : u16 num_reg_entries = 1;
3713 : : bool check_rule = true;
3714 : : const u32 *imm_values;
3715 : :
3716 : 0 : rule = &input_rules[i];
3717 : 0 : regs = (const union dbg_idle_chk_reg *)
3718 : 0 : p_hwfn->dbg_arrays[BIN_BUF_DBG_IDLE_CHK_REGS].ptr +
3719 : 0 : rule->reg_offset;
3720 : 0 : cond_regs = ®s[0].cond_reg;
3721 : 0 : imm_values =
3722 : 0 : (u32 *)p_hwfn->dbg_arrays[BIN_BUF_DBG_IDLE_CHK_IMMS].ptr +
3723 : 0 : rule->imm_offset;
3724 : :
3725 : : /* Check if all condition register blocks are out of reset, and
3726 : : * find maximal number of entries (all condition registers that
3727 : : * are memories must have the same size, which is > 1).
3728 : : */
3729 [ # # # # ]: 0 : for (reg_id = 0; reg_id < rule->num_cond_regs && check_rule;
3730 : 0 : reg_id++) {
3731 : 0 : u32 block_id =
3732 : 0 : GET_FIELD(cond_regs[reg_id].data,
3733 : : DBG_IDLE_CHK_COND_REG_BLOCK_ID);
3734 : :
3735 [ # # ]: 0 : if (block_id >= MAX_BLOCK_ID) {
3736 : 0 : DP_NOTICE(p_hwfn, false, "Invalid block_id\n");
3737 : 0 : return 0;
3738 : : }
3739 : :
3740 : 0 : check_rule = !dev_data->block_in_reset[block_id];
3741 : 0 : if (cond_regs[reg_id].num_entries > num_reg_entries)
3742 : : num_reg_entries = cond_regs[reg_id].num_entries;
3743 : : }
3744 : :
3745 [ # # ]: 0 : if (!check_rule && dump)
3746 : 0 : continue;
3747 : :
3748 [ # # ]: 0 : if (!dump) {
3749 : : u32 entry_dump_size =
3750 : 0 : qed_idle_chk_dump_failure(p_hwfn,
3751 : : p_ptt,
3752 : 0 : dump_buf + offset,
3753 : : false,
3754 : 0 : rule->rule_id,
3755 : : rule,
3756 : : 0,
3757 : : NULL);
3758 : :
3759 : 0 : offset += num_reg_entries * entry_dump_size;
3760 : 0 : (*num_failing_rules) += num_reg_entries;
3761 : 0 : continue;
3762 : : }
3763 : :
3764 : : /* Go over all register entries (number of entries is the same
3765 : : * for all condition registers).
3766 : : */
3767 [ # # ]: 0 : for (entry_id = 0; entry_id < num_reg_entries; entry_id++) {
3768 : : u32 next_reg_offset = 0;
3769 : :
3770 : : /* Read current entry of all condition registers */
3771 [ # # ]: 0 : for (reg_id = 0; reg_id < rule->num_cond_regs;
3772 : 0 : reg_id++) {
3773 : 0 : const struct dbg_idle_chk_cond_reg *reg =
3774 : 0 : &cond_regs[reg_id];
3775 : : u32 padded_entry_size, addr;
3776 : : bool wide_bus;
3777 : :
3778 : : /* Find GRC address (if it's a memory, the
3779 : : * address of the specific entry is calculated).
3780 : : */
3781 : 0 : addr = GET_FIELD(reg->data,
3782 : : DBG_IDLE_CHK_COND_REG_ADDRESS);
3783 : 0 : wide_bus =
3784 : 0 : GET_FIELD(reg->data,
3785 : : DBG_IDLE_CHK_COND_REG_WIDE_BUS);
3786 [ # # ]: 0 : if (reg->num_entries > 1 ||
3787 [ # # ]: 0 : reg->start_entry > 0) {
3788 : 0 : padded_entry_size =
3789 [ # # ]: 0 : reg->entry_size > 1 ?
3790 : 0 : OSAL_ROUNDUP_POW_OF_TWO(reg->entry_size) :
3791 : : 1;
3792 : 0 : addr += (reg->start_entry + entry_id) *
3793 : : padded_entry_size;
3794 : : }
3795 : :
3796 : : /* Read registers */
3797 [ # # ]: 0 : if (next_reg_offset + reg->entry_size >=
3798 : : IDLE_CHK_MAX_ENTRIES_SIZE) {
3799 : 0 : DP_NOTICE(p_hwfn, false,
3800 : : "idle check registers entry is too large\n");
3801 : 0 : return 0;
3802 : : }
3803 : :
3804 : 0 : next_reg_offset +=
3805 : 0 : qed_grc_dump_addr_range(p_hwfn, p_ptt,
3806 : 0 : cond_reg_values +
3807 : : next_reg_offset,
3808 : : dump, addr,
3809 : : reg->entry_size,
3810 : : wide_bus,
3811 : : SPLIT_TYPE_NONE, 0);
3812 : : }
3813 : :
3814 : : /* Call rule condition function.
3815 : : * If returns true, it's a failure.
3816 : : */
3817 [ # # ]: 0 : if ((*cond_arr[rule->cond_id]) (cond_reg_values,
3818 : : imm_values)) {
3819 : 0 : offset += qed_idle_chk_dump_failure(p_hwfn,
3820 : : p_ptt,
3821 : 0 : dump_buf + offset,
3822 : : dump,
3823 : 0 : rule->rule_id,
3824 : : rule,
3825 : : entry_id,
3826 : : cond_reg_values);
3827 : 0 : (*num_failing_rules)++;
3828 : : }
3829 : : }
3830 : : }
3831 : :
3832 : : return offset;
3833 : : }
3834 : :
3835 : : /* Performs Idle Check Dump to the specified buffer.
3836 : : * Returns the dumped size in dwords.
3837 : : */
3838 : 0 : static u32 qed_idle_chk_dump(struct ecore_hwfn *p_hwfn,
3839 : : struct ecore_ptt *p_ptt, u32 *dump_buf, bool dump)
3840 : : {
3841 : : struct virt_mem_desc *dbg_buf =
3842 : : &p_hwfn->dbg_arrays[BIN_BUF_DBG_IDLE_CHK_RULES];
3843 : : u32 num_failing_rules_offset, offset = 0,
3844 : : input_offset = 0, num_failing_rules = 0;
3845 : :
3846 : : /* Dump global params - 1 must match below amount of params */
3847 : 0 : offset += qed_dump_common_global_params(p_hwfn,
3848 : : p_ptt,
3849 : : dump_buf + offset, dump, 1);
3850 : 0 : offset += qed_dump_str_param(dump_buf + offset,
3851 : : dump, "dump-type", "idle-chk");
3852 : :
3853 : : /* Dump idle check section header with a single parameter */
3854 : 0 : offset += qed_dump_section_hdr(dump_buf + offset, dump, "idle_chk", 1);
3855 : : num_failing_rules_offset = offset;
3856 : 0 : offset += qed_dump_num_param(dump_buf + offset, dump, "num_rules", 0);
3857 : :
3858 [ # # ]: 0 : while (input_offset < BYTES_TO_DWORDS(dbg_buf->size)) {
3859 : 0 : const struct dbg_idle_chk_cond_hdr *cond_hdr =
3860 : 0 : (const struct dbg_idle_chk_cond_hdr *)dbg_buf->ptr +
3861 : 0 : input_offset++;
3862 : : bool eval_mode, mode_match = true;
3863 : : u32 curr_failing_rules;
3864 : : u16 modes_buf_offset;
3865 : :
3866 : : /* Check mode */
3867 : 0 : eval_mode = GET_FIELD(cond_hdr->mode.data,
3868 : : DBG_MODE_HDR_EVAL_MODE) > 0;
3869 [ # # ]: 0 : if (eval_mode) {
3870 : 0 : modes_buf_offset =
3871 : : GET_FIELD(cond_hdr->mode.data,
3872 : : DBG_MODE_HDR_MODES_BUF_OFFSET);
3873 : : mode_match = qed_is_mode_match(p_hwfn,
3874 : : &modes_buf_offset);
3875 : : }
3876 : :
3877 [ # # ]: 0 : if (mode_match) {
3878 : 0 : const struct dbg_idle_chk_rule *rule =
3879 : : (const struct dbg_idle_chk_rule *)((u32 *)
3880 : 0 : dbg_buf->ptr
3881 : 0 : + input_offset);
3882 : 0 : u32 num_input_rules =
3883 : 0 : cond_hdr->data_size / IDLE_CHK_RULE_SIZE_DWORDS;
3884 : 0 : offset +=
3885 : 0 : qed_idle_chk_dump_rule_entries(p_hwfn,
3886 : : p_ptt,
3887 : 0 : dump_buf +
3888 : : offset,
3889 : : dump,
3890 : : rule,
3891 : : num_input_rules,
3892 : : &curr_failing_rules);
3893 : 0 : num_failing_rules += curr_failing_rules;
3894 : : }
3895 : :
3896 : 0 : input_offset += cond_hdr->data_size;
3897 : : }
3898 : :
3899 : : /* Overwrite num_rules parameter */
3900 [ # # ]: 0 : if (dump)
3901 : 0 : qed_dump_num_param(dump_buf + num_failing_rules_offset,
3902 : : dump, "num_rules", num_failing_rules);
3903 : :
3904 : : /* Dump last section */
3905 : 0 : offset += qed_dump_last_section(dump_buf, offset, dump);
3906 : :
3907 : 0 : return offset;
3908 : : }
3909 : :
3910 : : /* Finds the meta data image in NVRAM */
3911 : 0 : static enum dbg_status qed_find_nvram_image(struct ecore_hwfn *p_hwfn,
3912 : : struct ecore_ptt *p_ptt,
3913 : : u32 image_type,
3914 : : u32 *nvram_offset_bytes,
3915 : : u32 *nvram_size_bytes)
3916 : : {
3917 : : u32 ret_mcp_resp, ret_mcp_param, ret_txn_size;
3918 : : struct mcp_file_att file_att;
3919 : : int nvm_result;
3920 : :
3921 : : /* Call NVRAM get file command */
3922 : 0 : nvm_result = ecore_mcp_nvm_rd_cmd(p_hwfn,
3923 : : p_ptt,
3924 : : DRV_MSG_CODE_NVM_GET_FILE_ATT,
3925 : : image_type,
3926 : : &ret_mcp_resp,
3927 : : &ret_mcp_param,
3928 : : &ret_txn_size, (u32 *)&file_att);
3929 : :
3930 : : /* Check response */
3931 [ # # ]: 0 : if (nvm_result ||
3932 [ # # ]: 0 : (ret_mcp_resp & FW_MSG_CODE_MASK) != FW_MSG_CODE_NVM_OK)
3933 : : return DBG_STATUS_NVRAM_GET_IMAGE_FAILED;
3934 : :
3935 : : /* Update return values */
3936 : 0 : *nvram_offset_bytes = file_att.nvm_start_addr;
3937 : 0 : *nvram_size_bytes = file_att.len;
3938 : :
3939 [ # # ]: 0 : DP_VERBOSE(p_hwfn->p_dev,
3940 : : ECORE_MSG_DEBUG,
3941 : : "find_nvram_image: found NVRAM image of type %d in NVRAM offset %d bytes with size %d bytes\n",
3942 : : image_type, *nvram_offset_bytes, *nvram_size_bytes);
3943 : :
3944 : : /* Check alignment */
3945 [ # # ]: 0 : if (*nvram_size_bytes & 0x3)
3946 : 0 : return DBG_STATUS_NON_ALIGNED_NVRAM_IMAGE;
3947 : :
3948 : : return DBG_STATUS_OK;
3949 : : }
3950 : :
3951 : : /* Reads data from NVRAM */
3952 : 0 : static enum dbg_status qed_nvram_read(struct ecore_hwfn *p_hwfn,
3953 : : struct ecore_ptt *p_ptt,
3954 : : u32 nvram_offset_bytes,
3955 : : u32 nvram_size_bytes, u32 *ret_buf)
3956 : : {
3957 : : u32 ret_mcp_resp, ret_mcp_param, ret_read_size, bytes_to_copy;
3958 : 0 : s32 bytes_left = nvram_size_bytes;
3959 : : u32 read_offset = 0, param = 0;
3960 : :
3961 : 0 : DP_NOTICE(p_hwfn->p_dev, false,
3962 : : "nvram_read: reading image of size %d bytes from NVRAM\n",
3963 : : nvram_size_bytes);
3964 : :
3965 : : do {
3966 : 0 : bytes_to_copy =
3967 : : (bytes_left >
3968 : 0 : MCP_DRV_NVM_BUF_LEN) ? MCP_DRV_NVM_BUF_LEN : bytes_left;
3969 : :
3970 : : /* Call NVRAM read command */
3971 : 0 : SET_MFW_FIELD(param,
3972 : : DRV_MB_PARAM_NVM_OFFSET,
3973 : : nvram_offset_bytes + read_offset);
3974 : 0 : SET_MFW_FIELD(param, DRV_MB_PARAM_NVM_LEN, bytes_to_copy);
3975 [ # # ]: 0 : if (ecore_mcp_nvm_rd_cmd(p_hwfn, p_ptt,
3976 : : DRV_MSG_CODE_NVM_READ_NVRAM, param,
3977 : : &ret_mcp_resp,
3978 : : &ret_mcp_param, &ret_read_size,
3979 : : (u32 *)((u8 *)ret_buf +
3980 : : read_offset))) {
3981 : 0 : DP_NOTICE(p_hwfn->p_dev, false, "rc = DBG_STATUS_NVRAM_READ_FAILED\n");
3982 : 0 : return DBG_STATUS_NVRAM_READ_FAILED;
3983 : : }
3984 : :
3985 : : /* Check response */
3986 [ # # ]: 0 : if ((ret_mcp_resp & FW_MSG_CODE_MASK) != FW_MSG_CODE_NVM_OK) {
3987 : 0 : DP_NOTICE(p_hwfn->p_dev, false, "rc = DBG_STATUS_NVRAM_READ_FAILED\n");
3988 : 0 : return DBG_STATUS_NVRAM_READ_FAILED;
3989 : : }
3990 : :
3991 : : /* Update read offset */
3992 : 0 : read_offset += ret_read_size;
3993 : 0 : bytes_left -= ret_read_size;
3994 [ # # ]: 0 : } while (bytes_left > 0);
3995 : :
3996 : : return DBG_STATUS_OK;
3997 : : }
3998 : :
3999 : : /* Get info on the MCP Trace data in the scratchpad:
4000 : : * - trace_data_grc_addr (OUT): trace data GRC address in bytes
4001 : : * - trace_data_size (OUT): trace data size in bytes (without the header)
4002 : : */
4003 : 0 : static enum dbg_status qed_mcp_trace_get_data_info(struct ecore_hwfn *p_hwfn,
4004 : : struct ecore_ptt *p_ptt,
4005 : : u32 *trace_data_grc_addr,
4006 : : u32 *trace_data_size)
4007 : : {
4008 : : u32 spad_trace_offsize, signature;
4009 : :
4010 : : /* Read trace section offsize structure from MCP scratchpad */
4011 : 0 : spad_trace_offsize = ecore_rd(p_hwfn, p_ptt,
4012 : : MCP_SPAD_TRACE_OFFSIZE_ADDR);
4013 : :
4014 : : /* Extract trace section address from offsize (in scratchpad) */
4015 : 0 : *trace_data_grc_addr =
4016 : 0 : MCP_REG_SCRATCH + SECTION_OFFSET(spad_trace_offsize);
4017 : :
4018 : : /* Read signature from MCP trace section */
4019 : 0 : signature = ecore_rd(p_hwfn, p_ptt,
4020 : : *trace_data_grc_addr +
4021 : : offsetof(struct mcp_trace, signature));
4022 : :
4023 [ # # ]: 0 : if (signature != MFW_TRACE_SIGNATURE)
4024 : : return DBG_STATUS_INVALID_TRACE_SIGNATURE;
4025 : :
4026 : : /* Read trace size from MCP trace section */
4027 : 0 : *trace_data_size = ecore_rd(p_hwfn,
4028 : : p_ptt,
4029 : 0 : *trace_data_grc_addr +
4030 : : offsetof(struct mcp_trace, size));
4031 : :
4032 : 0 : return DBG_STATUS_OK;
4033 : : }
4034 : :
4035 : : /* Reads MCP trace meta data image from NVRAM
4036 : : * - running_bundle_id (OUT): running bundle ID (invalid when loaded from file)
4037 : : * - trace_meta_offset (OUT): trace meta offset in NVRAM in bytes (invalid when
4038 : : * loaded from file).
4039 : : * - trace_meta_size (OUT): size in bytes of the trace meta data.
4040 : : */
4041 : 0 : static enum dbg_status qed_mcp_trace_get_meta_info(struct ecore_hwfn *p_hwfn,
4042 : : struct ecore_ptt *p_ptt,
4043 : : u32 trace_data_size_bytes,
4044 : : u32 *running_bundle_id,
4045 : : u32 *trace_meta_offset,
4046 : : u32 *trace_meta_size)
4047 : : {
4048 : : u32 spad_trace_offsize, nvram_image_type, running_mfw_addr;
4049 : :
4050 : : /* Read MCP trace section offsize structure from MCP scratchpad */
4051 : 0 : spad_trace_offsize = ecore_rd(p_hwfn, p_ptt,
4052 : : MCP_SPAD_TRACE_OFFSIZE_ADDR);
4053 : :
4054 : : /* Find running bundle ID */
4055 : 0 : running_mfw_addr =
4056 : 0 : MCP_REG_SCRATCH + SECTION_OFFSET(spad_trace_offsize) +
4057 : 0 : SECTION_SIZE(spad_trace_offsize) + trace_data_size_bytes;
4058 : 0 : *running_bundle_id = ecore_rd(p_hwfn, p_ptt, running_mfw_addr);
4059 [ # # ]: 0 : if (*running_bundle_id > 1)
4060 : : return DBG_STATUS_INVALID_NVRAM_BUNDLE;
4061 : :
4062 : : /* Find image in NVRAM */
4063 : : nvram_image_type =
4064 : : (*running_bundle_id ==
4065 [ # # ]: 0 : DIR_ID_1) ? NVM_TYPE_MFW_TRACE1 : NVM_TYPE_MFW_TRACE2;
4066 : 0 : return qed_find_nvram_image(p_hwfn,
4067 : : p_ptt,
4068 : : nvram_image_type,
4069 : : trace_meta_offset, trace_meta_size);
4070 : : }
4071 : :
4072 : : /* Reads the MCP Trace meta data from NVRAM into the specified buffer */
4073 : 0 : static enum dbg_status qed_mcp_trace_read_meta(struct ecore_hwfn *p_hwfn,
4074 : : struct ecore_ptt *p_ptt,
4075 : : u32 nvram_offset_in_bytes,
4076 : : u32 size_in_bytes, u32 *buf)
4077 : : {
4078 : : u8 modules_num, module_len, i, *byte_buf = (u8 *)buf;
4079 : : enum dbg_status status;
4080 : : u32 signature;
4081 : :
4082 : : /* Read meta data from NVRAM */
4083 : 0 : status = qed_nvram_read(p_hwfn,
4084 : : p_ptt,
4085 : : nvram_offset_in_bytes, size_in_bytes, buf);
4086 [ # # ]: 0 : if (status != DBG_STATUS_OK)
4087 : : return status;
4088 : :
4089 : : /* Extract and check first signature */
4090 : : signature = qed_read_unaligned_dword(byte_buf);
4091 : : byte_buf += sizeof(signature);
4092 [ # # ]: 0 : if (signature != NVM_MAGIC_VALUE)
4093 : : return DBG_STATUS_INVALID_TRACE_SIGNATURE;
4094 : :
4095 : : /* Extract number of modules */
4096 : 0 : modules_num = *(byte_buf++);
4097 : :
4098 : : /* Skip all modules */
4099 [ # # ]: 0 : for (i = 0; i < modules_num; i++) {
4100 : 0 : module_len = *(byte_buf++);
4101 : 0 : byte_buf += module_len;
4102 : : }
4103 : :
4104 : : /* Extract and check second signature */
4105 : : signature = qed_read_unaligned_dword(byte_buf);
4106 : : byte_buf += sizeof(signature);
4107 [ # # ]: 0 : if (signature != NVM_MAGIC_VALUE)
4108 : 0 : return DBG_STATUS_INVALID_TRACE_SIGNATURE;
4109 : :
4110 : : return DBG_STATUS_OK;
4111 : : }
4112 : :
4113 : : /* Dump MCP Trace */
4114 : 0 : static enum dbg_status qed_mcp_trace_dump(struct ecore_hwfn *p_hwfn,
4115 : : struct ecore_ptt *p_ptt,
4116 : : u32 *dump_buf,
4117 : : bool dump, u32 *num_dumped_dwords)
4118 : : {
4119 : : u32 trace_data_grc_addr, trace_data_size_bytes, trace_data_size_dwords;
4120 : : u32 trace_meta_size_dwords = 0, running_bundle_id, offset = 0;
4121 : 0 : u32 trace_meta_offset_bytes = 0, trace_meta_size_bytes = 0;
4122 : : enum dbg_status status;
4123 : : int halted = 0;
4124 : : bool use_mfw;
4125 : :
4126 : 0 : *num_dumped_dwords = 0;
4127 : :
4128 : 0 : use_mfw = !qed_grc_get_param(p_hwfn, DBG_GRC_PARAM_NO_MCP);
4129 : :
4130 : : /* Get trace data info */
4131 : 0 : status = qed_mcp_trace_get_data_info(p_hwfn,
4132 : : p_ptt,
4133 : : &trace_data_grc_addr,
4134 : : &trace_data_size_bytes);
4135 [ # # ]: 0 : if (status != DBG_STATUS_OK)
4136 : : return status;
4137 : :
4138 : : /* Dump global params */
4139 : 0 : offset += qed_dump_common_global_params(p_hwfn,
4140 : : p_ptt,
4141 : : dump_buf + offset, dump, 1);
4142 : 0 : offset += qed_dump_str_param(dump_buf + offset,
4143 : : dump, "dump-type", "mcp-trace");
4144 : :
4145 : : /* Halt MCP while reading from scratchpad so the read data will be
4146 : : * consistent. if halt fails, MCP trace is taken anyway, with a small
4147 : : * risk that it may be corrupt.
4148 : : */
4149 [ # # ]: 0 : if (dump && use_mfw) {
4150 : 0 : halted = !ecore_mcp_halt(p_hwfn, p_ptt);
4151 [ # # ]: 0 : if (!halted)
4152 : 0 : DP_NOTICE(p_hwfn, false, "MCP halt failed!\n");
4153 : : }
4154 : :
4155 : : /* Find trace data size */
4156 : 0 : trace_data_size_dwords =
4157 : 0 : DIV_ROUND_UP(trace_data_size_bytes + sizeof(struct mcp_trace),
4158 : : BYTES_IN_DWORD);
4159 : :
4160 : : /* Dump trace data section header and param */
4161 : 0 : offset += qed_dump_section_hdr(dump_buf + offset,
4162 : : dump, "mcp_trace_data", 1);
4163 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4164 : : dump, "size", trace_data_size_dwords);
4165 : :
4166 : : /* Read trace data from scratchpad into dump buffer */
4167 : 0 : offset += qed_grc_dump_addr_range(p_hwfn,
4168 : : p_ptt,
4169 : 0 : dump_buf + offset,
4170 : : dump,
4171 : : BYTES_TO_DWORDS(trace_data_grc_addr),
4172 : : trace_data_size_dwords, false,
4173 : : SPLIT_TYPE_NONE, 0);
4174 : :
4175 : : /* Resume MCP (only if halt succeeded) */
4176 [ # # # # ]: 0 : if (halted && ecore_mcp_resume(p_hwfn, p_ptt))
4177 : 0 : DP_NOTICE(p_hwfn, false, "Failed to resume MCP after halt!\n");
4178 : :
4179 : : /* Dump trace meta section header */
4180 : 0 : offset += qed_dump_section_hdr(dump_buf + offset,
4181 : : dump, "mcp_trace_meta", 1);
4182 : :
4183 : : /* If MCP Trace meta size parameter was set, use it.
4184 : : * Otherwise, read trace meta.
4185 : : * trace_meta_size_bytes is dword-aligned.
4186 : : */
4187 : 0 : trace_meta_size_bytes =
4188 : : qed_grc_get_param(p_hwfn, DBG_GRC_PARAM_MCP_TRACE_META_SIZE);
4189 [ # # # # ]: 0 : if ((!trace_meta_size_bytes || dump) && use_mfw)
4190 : 0 : status = qed_mcp_trace_get_meta_info(p_hwfn,
4191 : : p_ptt,
4192 : : trace_data_size_bytes,
4193 : : &running_bundle_id,
4194 : : &trace_meta_offset_bytes,
4195 : : &trace_meta_size_bytes);
4196 [ # # ]: 0 : if (status == DBG_STATUS_OK)
4197 : 0 : trace_meta_size_dwords = BYTES_TO_DWORDS(trace_meta_size_bytes);
4198 : :
4199 : : /* Dump trace meta size param */
4200 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4201 : : dump, "size", trace_meta_size_dwords);
4202 : :
4203 : : /* Read trace meta image into dump buffer */
4204 [ # # ]: 0 : if (dump && trace_meta_size_dwords)
4205 : 0 : status = qed_mcp_trace_read_meta(p_hwfn,
4206 : : p_ptt,
4207 : : trace_meta_offset_bytes,
4208 : : trace_meta_size_bytes,
4209 : 0 : dump_buf + offset);
4210 [ # # ]: 0 : if (status == DBG_STATUS_OK)
4211 : 0 : offset += trace_meta_size_dwords;
4212 : :
4213 : : /* Dump last section */
4214 : 0 : offset += qed_dump_last_section(dump_buf, offset, dump);
4215 : :
4216 : 0 : *num_dumped_dwords = offset;
4217 : :
4218 : : /* If no mcp access, indicate that the dump doesn't contain the meta
4219 : : * data from NVRAM.
4220 : : */
4221 [ # # ]: 0 : return use_mfw ? status : DBG_STATUS_NVRAM_GET_IMAGE_FAILED;
4222 : : }
4223 : :
4224 : : /* Dump GRC FIFO */
4225 : 0 : static enum dbg_status qed_reg_fifo_dump(struct ecore_hwfn *p_hwfn,
4226 : : struct ecore_ptt *p_ptt,
4227 : : u32 *dump_buf,
4228 : : bool dump, u32 *num_dumped_dwords)
4229 : : {
4230 : : u32 dwords_read, size_param_offset, offset = 0, addr, len;
4231 : : bool fifo_has_data;
4232 : :
4233 : 0 : *num_dumped_dwords = 0;
4234 : :
4235 : : /* Dump global params */
4236 : 0 : offset += qed_dump_common_global_params(p_hwfn,
4237 : : p_ptt,
4238 : : dump_buf + offset, dump, 1);
4239 : 0 : offset += qed_dump_str_param(dump_buf + offset,
4240 : : dump, "dump-type", "reg-fifo");
4241 : :
4242 : : /* Dump fifo data section header and param. The size param is 0 for
4243 : : * now, and is overwritten after reading the FIFO.
4244 : : */
4245 : 0 : offset += qed_dump_section_hdr(dump_buf + offset,
4246 : : dump, "reg_fifo_data", 1);
4247 : : size_param_offset = offset;
4248 : 0 : offset += qed_dump_num_param(dump_buf + offset, dump, "size", 0);
4249 : :
4250 [ # # ]: 0 : if (!dump) {
4251 : : /* FIFO max size is REG_FIFO_DEPTH_DWORDS. There is no way to
4252 : : * test how much data is available, except for reading it.
4253 : : */
4254 : 0 : offset += REG_FIFO_DEPTH_DWORDS;
4255 : 0 : goto out;
4256 : : }
4257 : :
4258 : 0 : fifo_has_data = ecore_rd(p_hwfn, p_ptt,
4259 : : GRC_REG_TRACE_FIFO_VALID_DATA) > 0;
4260 : :
4261 : : /* Pull available data from fifo. Use DMAE since this is widebus memory
4262 : : * and must be accessed atomically. Test for dwords_read not passing
4263 : : * buffer size since more entries could be added to the buffer as we are
4264 : : * emptying it.
4265 : : */
4266 : : addr = BYTES_TO_DWORDS(GRC_REG_TRACE_FIFO);
4267 : : len = REG_FIFO_ELEMENT_DWORDS;
4268 : 0 : for (dwords_read = 0;
4269 [ # # ]: 0 : fifo_has_data && dwords_read < REG_FIFO_DEPTH_DWORDS;
4270 : 0 : dwords_read += REG_FIFO_ELEMENT_DWORDS) {
4271 : 0 : offset += qed_grc_dump_addr_range(p_hwfn,
4272 : : p_ptt,
4273 : 0 : dump_buf + offset,
4274 : : true,
4275 : : addr,
4276 : : len,
4277 : : true, SPLIT_TYPE_NONE,
4278 : : 0);
4279 : 0 : fifo_has_data = ecore_rd(p_hwfn, p_ptt,
4280 : : GRC_REG_TRACE_FIFO_VALID_DATA) > 0;
4281 : : }
4282 : :
4283 : 0 : qed_dump_num_param(dump_buf + size_param_offset, dump, "size",
4284 : : dwords_read);
4285 : 0 : out:
4286 : : /* Dump last section */
4287 : 0 : offset += qed_dump_last_section(dump_buf, offset, dump);
4288 : :
4289 : 0 : *num_dumped_dwords = offset;
4290 : :
4291 : 0 : return DBG_STATUS_OK;
4292 : : }
4293 : :
4294 : : /* Dump IGU FIFO */
4295 : 0 : static enum dbg_status qed_igu_fifo_dump(struct ecore_hwfn *p_hwfn,
4296 : : struct ecore_ptt *p_ptt,
4297 : : u32 *dump_buf,
4298 : : bool dump, u32 *num_dumped_dwords)
4299 : : {
4300 : : u32 dwords_read, size_param_offset, offset = 0, addr, len;
4301 : : bool fifo_has_data;
4302 : :
4303 : 0 : *num_dumped_dwords = 0;
4304 : :
4305 : : /* Dump global params */
4306 : 0 : offset += qed_dump_common_global_params(p_hwfn,
4307 : : p_ptt,
4308 : : dump_buf + offset, dump, 1);
4309 : 0 : offset += qed_dump_str_param(dump_buf + offset,
4310 : : dump, "dump-type", "igu-fifo");
4311 : :
4312 : : /* Dump fifo data section header and param. The size param is 0 for
4313 : : * now, and is overwritten after reading the FIFO.
4314 : : */
4315 : 0 : offset += qed_dump_section_hdr(dump_buf + offset,
4316 : : dump, "igu_fifo_data", 1);
4317 : : size_param_offset = offset;
4318 : 0 : offset += qed_dump_num_param(dump_buf + offset, dump, "size", 0);
4319 : :
4320 [ # # ]: 0 : if (!dump) {
4321 : : /* FIFO max size is IGU_FIFO_DEPTH_DWORDS. There is no way to
4322 : : * test how much data is available, except for reading it.
4323 : : */
4324 : 0 : offset += IGU_FIFO_DEPTH_DWORDS;
4325 : 0 : goto out;
4326 : : }
4327 : :
4328 : 0 : fifo_has_data = ecore_rd(p_hwfn, p_ptt,
4329 : : IGU_REG_ERROR_HANDLING_DATA_VALID) > 0;
4330 : :
4331 : : /* Pull available data from fifo. Use DMAE since this is widebus memory
4332 : : * and must be accessed atomically. Test for dwords_read not passing
4333 : : * buffer size since more entries could be added to the buffer as we are
4334 : : * emptying it.
4335 : : */
4336 : : addr = BYTES_TO_DWORDS(IGU_REG_ERROR_HANDLING_MEMORY);
4337 : : len = IGU_FIFO_ELEMENT_DWORDS;
4338 : 0 : for (dwords_read = 0;
4339 [ # # ]: 0 : fifo_has_data && dwords_read < IGU_FIFO_DEPTH_DWORDS;
4340 : 0 : dwords_read += IGU_FIFO_ELEMENT_DWORDS) {
4341 : 0 : offset += qed_grc_dump_addr_range(p_hwfn,
4342 : : p_ptt,
4343 : 0 : dump_buf + offset,
4344 : : true,
4345 : : addr,
4346 : : len,
4347 : : true, SPLIT_TYPE_NONE,
4348 : : 0);
4349 : 0 : fifo_has_data = ecore_rd(p_hwfn, p_ptt,
4350 : : IGU_REG_ERROR_HANDLING_DATA_VALID) > 0;
4351 : : }
4352 : :
4353 : 0 : qed_dump_num_param(dump_buf + size_param_offset, dump, "size",
4354 : : dwords_read);
4355 : 0 : out:
4356 : : /* Dump last section */
4357 : 0 : offset += qed_dump_last_section(dump_buf, offset, dump);
4358 : :
4359 : 0 : *num_dumped_dwords = offset;
4360 : :
4361 : 0 : return DBG_STATUS_OK;
4362 : : }
4363 : :
4364 : : /* Protection Override dump */
4365 : 0 : static enum dbg_status qed_protection_override_dump(struct ecore_hwfn *p_hwfn,
4366 : : struct ecore_ptt *p_ptt,
4367 : : u32 *dump_buf,
4368 : : bool dump,
4369 : : u32 *num_dumped_dwords)
4370 : : {
4371 : : u32 size_param_offset, override_window_dwords, offset = 0, addr;
4372 : :
4373 : 0 : *num_dumped_dwords = 0;
4374 : :
4375 : : /* Dump global params */
4376 : 0 : offset += qed_dump_common_global_params(p_hwfn,
4377 : : p_ptt,
4378 : : dump_buf + offset, dump, 1);
4379 : 0 : offset += qed_dump_str_param(dump_buf + offset,
4380 : : dump, "dump-type", "protection-override");
4381 : :
4382 : : /* Dump data section header and param. The size param is 0 for now,
4383 : : * and is overwritten after reading the data.
4384 : : */
4385 : 0 : offset += qed_dump_section_hdr(dump_buf + offset,
4386 : : dump, "protection_override_data", 1);
4387 : : size_param_offset = offset;
4388 : 0 : offset += qed_dump_num_param(dump_buf + offset, dump, "size", 0);
4389 : :
4390 [ # # ]: 0 : if (!dump) {
4391 : 0 : offset += PROTECTION_OVERRIDE_DEPTH_DWORDS;
4392 : 0 : goto out;
4393 : : }
4394 : :
4395 : : /* Add override window info to buffer */
4396 : 0 : override_window_dwords =
4397 : 0 : ecore_rd(p_hwfn, p_ptt, GRC_REG_NUMBER_VALID_OVERRIDE_WINDOW) *
4398 : : PROTECTION_OVERRIDE_ELEMENT_DWORDS;
4399 [ # # ]: 0 : if (override_window_dwords) {
4400 : : addr = BYTES_TO_DWORDS(GRC_REG_PROTECTION_OVERRIDE_WINDOW);
4401 : 0 : offset += qed_grc_dump_addr_range(p_hwfn,
4402 : : p_ptt,
4403 : 0 : dump_buf + offset,
4404 : : true,
4405 : : addr,
4406 : : override_window_dwords,
4407 : : true, SPLIT_TYPE_NONE, 0);
4408 : 0 : qed_dump_num_param(dump_buf + size_param_offset, dump, "size",
4409 : : override_window_dwords);
4410 : : }
4411 : 0 : out:
4412 : : /* Dump last section */
4413 : 0 : offset += qed_dump_last_section(dump_buf, offset, dump);
4414 : :
4415 : 0 : *num_dumped_dwords = offset;
4416 : :
4417 : 0 : return DBG_STATUS_OK;
4418 : : }
4419 : :
4420 : : /* Performs FW Asserts Dump to the specified buffer.
4421 : : * Returns the dumped size in dwords.
4422 : : */
4423 : 0 : static u32 qed_fw_asserts_dump(struct ecore_hwfn *p_hwfn,
4424 : : struct ecore_ptt *p_ptt, u32 *dump_buf,
4425 : : bool dump)
4426 : : {
4427 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
4428 : : struct fw_asserts_ram_section *asserts;
4429 : 0 : char storm_letter_str[2] = "?";
4430 : : struct fw_info fw_info;
4431 : : u32 offset = 0;
4432 : : u8 storm_id;
4433 : :
4434 : : /* Dump global params */
4435 : 0 : offset += qed_dump_common_global_params(p_hwfn,
4436 : : p_ptt,
4437 : : dump_buf + offset, dump, 1);
4438 : 0 : offset += qed_dump_str_param(dump_buf + offset,
4439 : : dump, "dump-type", "fw-asserts");
4440 : :
4441 : : /* Find Storm dump size */
4442 [ # # ]: 0 : for (storm_id = 0; storm_id < MAX_DBG_STORMS; storm_id++) {
4443 : : u32 fw_asserts_section_addr, next_list_idx_addr, next_list_idx;
4444 : 0 : struct storm_defs *storm = &s_storm_defs[storm_id];
4445 : : u32 last_list_idx, addr;
4446 : :
4447 [ # # ]: 0 : if (dev_data->block_in_reset[storm->sem_block_id])
4448 : 0 : continue;
4449 : :
4450 : : /* Read FW info for the current Storm */
4451 : 0 : qed_read_storm_fw_info(p_hwfn, p_ptt, storm_id, &fw_info);
4452 : :
4453 : : asserts = &fw_info.fw_asserts_section;
4454 : :
4455 : : /* Dump FW Asserts section header and params */
4456 : 0 : storm_letter_str[0] = storm->letter;
4457 : 0 : offset += qed_dump_section_hdr(dump_buf + offset,
4458 : : dump, "fw_asserts", 2);
4459 : 0 : offset += qed_dump_str_param(dump_buf + offset,
4460 : : dump, "storm", storm_letter_str);
4461 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4462 : : dump,
4463 : : "size",
4464 : 0 : asserts->list_element_dword_size);
4465 : :
4466 : : /* Read and dump FW Asserts data */
4467 [ # # ]: 0 : if (!dump) {
4468 : 0 : offset += asserts->list_element_dword_size;
4469 : 0 : continue;
4470 : : }
4471 : :
4472 : 0 : fw_asserts_section_addr = storm->sem_fast_mem_addr +
4473 : 0 : SEM_FAST_REG_INT_RAM +
4474 : 0 : RAM_LINES_TO_BYTES(asserts->section_ram_line_offset);
4475 : 0 : next_list_idx_addr = fw_asserts_section_addr +
4476 : 0 : DWORDS_TO_BYTES(asserts->list_next_index_dword_offset);
4477 : 0 : next_list_idx = ecore_rd(p_hwfn, p_ptt, next_list_idx_addr);
4478 : : last_list_idx = (next_list_idx > 0 ?
4479 : : next_list_idx :
4480 [ # # ]: 0 : asserts->list_num_elements) - 1;
4481 : 0 : addr = BYTES_TO_DWORDS(fw_asserts_section_addr) +
4482 : 0 : asserts->list_dword_offset +
4483 : 0 : last_list_idx * asserts->list_element_dword_size;
4484 : 0 : offset +=
4485 : 0 : qed_grc_dump_addr_range(p_hwfn, p_ptt,
4486 : 0 : dump_buf + offset,
4487 : : dump, addr,
4488 : : asserts->list_element_dword_size,
4489 : : false, SPLIT_TYPE_NONE, 0);
4490 : : }
4491 : :
4492 : : /* Dump last section */
4493 : 0 : offset += qed_dump_last_section(dump_buf, offset, dump);
4494 : :
4495 : 0 : return offset;
4496 : : }
4497 : :
4498 : : /* Dumps the specified ILT pages to the specified buffer.
4499 : : * Returns the dumped size in dwords.
4500 : : */
4501 : 0 : static u32 qed_ilt_dump_pages_range(u32 *dump_buf,
4502 : : bool dump,
4503 : : u32 start_page_id,
4504 : : u32 num_pages,
4505 : : struct phys_mem_desc *ilt_pages,
4506 : : bool dump_page_ids)
4507 : : {
4508 : : u32 page_id, end_page_id, offset = 0;
4509 : :
4510 [ # # ]: 0 : if (num_pages == 0)
4511 : : return offset;
4512 : :
4513 : 0 : end_page_id = start_page_id + num_pages - 1;
4514 : :
4515 [ # # ]: 0 : for (page_id = start_page_id; page_id <= end_page_id; page_id++) {
4516 : 0 : struct phys_mem_desc *mem_desc = &ilt_pages[page_id];
4517 : :
4518 : : /**
4519 : : *
4520 : : * if (page_id >= ->p_cxt_mngr->ilt_shadow_size)
4521 : : * break;
4522 : : */
4523 : :
4524 [ # # ]: 0 : if (!ilt_pages[page_id].virt_addr)
4525 : 0 : continue;
4526 : :
4527 [ # # ]: 0 : if (dump_page_ids) {
4528 : : /* Copy page ID to dump buffer */
4529 [ # # ]: 0 : if (dump)
4530 : 0 : *(dump_buf + offset) = page_id;
4531 : 0 : offset++;
4532 : : } else {
4533 : : /* Copy page memory to dump buffer */
4534 [ # # ]: 0 : if (dump)
4535 : 0 : memcpy(dump_buf + offset,
4536 : 0 : mem_desc->virt_addr, mem_desc->size);
4537 : 0 : offset += BYTES_TO_DWORDS(mem_desc->size);
4538 : : }
4539 : : }
4540 : :
4541 : : return offset;
4542 : : }
4543 : :
4544 : : /* Dumps a section containing the dumped ILT pages.
4545 : : * Returns the dumped size in dwords.
4546 : : */
4547 : 0 : static u32 qed_ilt_dump_pages_section(struct ecore_hwfn *p_hwfn,
4548 : : u32 *dump_buf,
4549 : : bool dump,
4550 : : u32 valid_conn_pf_pages,
4551 : : u32 valid_conn_vf_pages,
4552 : : struct phys_mem_desc *ilt_pages,
4553 : : bool dump_page_ids)
4554 : : {
4555 : 0 : struct ecore_ilt_client_cfg *clients = p_hwfn->p_cxt_mngr->clients;
4556 : : u32 pf_start_line, start_page_id, offset = 0;
4557 : : u32 cdut_pf_init_pages, cdut_vf_init_pages;
4558 : : u32 cdut_pf_work_pages, cdut_vf_work_pages;
4559 : : u32 base_data_offset, size_param_offset;
4560 : : u32 cdut_pf_pages, cdut_vf_pages;
4561 : : const char *section_name;
4562 : : u8 i;
4563 : :
4564 [ # # ]: 0 : section_name = dump_page_ids ? "ilt_page_ids" : "ilt_page_mem";
4565 : 0 : cdut_pf_init_pages = ecore_get_cdut_num_pf_init_pages(p_hwfn);
4566 : 0 : cdut_vf_init_pages = ecore_get_cdut_num_vf_init_pages(p_hwfn);
4567 : 0 : cdut_pf_work_pages = ecore_get_cdut_num_pf_work_pages(p_hwfn);
4568 : 0 : cdut_vf_work_pages = ecore_get_cdut_num_vf_work_pages(p_hwfn);
4569 : 0 : cdut_pf_pages = cdut_pf_init_pages + cdut_pf_work_pages;
4570 : 0 : cdut_vf_pages = cdut_vf_init_pages + cdut_vf_work_pages;
4571 : 0 : pf_start_line = p_hwfn->p_cxt_mngr->pf_start_line;
4572 : :
4573 : : offset +=
4574 : 0 : qed_dump_section_hdr(dump_buf + offset, dump, section_name, 1);
4575 : :
4576 : : /* Dump size parameter (0 for now, overwritten with real size later) */
4577 : : size_param_offset = offset;
4578 : 0 : offset += qed_dump_num_param(dump_buf + offset, dump, "size", 0);
4579 : : base_data_offset = offset;
4580 : :
4581 : : /* CDUC pages are ordered as follows:
4582 : : * - PF pages - valid section (included in PF connection type mapping)
4583 : : * - PF pages - invalid section (not dumped)
4584 : : * - For each VF in the PF:
4585 : : * - VF pages - valid section (included in VF connection type mapping)
4586 : : * - VF pages - invalid section (not dumped)
4587 : : */
4588 [ # # ]: 0 : if (qed_grc_get_param(p_hwfn, DBG_GRC_PARAM_DUMP_ILT_CDUC)) {
4589 : : /* Dump connection PF pages */
4590 : 0 : start_page_id = clients[ILT_CLI_CDUC].first.val - pf_start_line;
4591 : 0 : offset += qed_ilt_dump_pages_range(dump_buf + offset,
4592 : : dump,
4593 : : start_page_id,
4594 : : valid_conn_pf_pages,
4595 : : ilt_pages, dump_page_ids);
4596 : :
4597 : : /* Dump connection VF pages */
4598 : 0 : start_page_id += clients[ILT_CLI_CDUC].pf_total_lines;
4599 [ # # ]: 0 : for (i = 0; i < p_hwfn->p_cxt_mngr->vf_count;
4600 : 0 : i++, start_page_id += clients[ILT_CLI_CDUC].vf_total_lines)
4601 : 0 : offset += qed_ilt_dump_pages_range(dump_buf + offset,
4602 : : dump,
4603 : : start_page_id,
4604 : : valid_conn_vf_pages,
4605 : : ilt_pages,
4606 : : dump_page_ids);
4607 : : }
4608 : :
4609 : : /* CDUT pages are ordered as follows:
4610 : : * - PF init pages (not dumped)
4611 : : * - PF work pages
4612 : : * - For each VF in the PF:
4613 : : * - VF init pages (not dumped)
4614 : : * - VF work pages
4615 : : */
4616 [ # # ]: 0 : if (qed_grc_get_param(p_hwfn, DBG_GRC_PARAM_DUMP_ILT_CDUT)) {
4617 : : /* Dump task PF pages */
4618 : 0 : start_page_id = clients[ILT_CLI_CDUT].first.val +
4619 : : cdut_pf_init_pages - pf_start_line;
4620 : 0 : offset += qed_ilt_dump_pages_range(dump_buf + offset,
4621 : : dump,
4622 : : start_page_id,
4623 : : cdut_pf_work_pages,
4624 : : ilt_pages, dump_page_ids);
4625 : :
4626 : : /* Dump task VF pages */
4627 : 0 : start_page_id = clients[ILT_CLI_CDUT].first.val +
4628 : 0 : cdut_pf_pages + cdut_vf_init_pages - pf_start_line;
4629 [ # # ]: 0 : for (i = 0; i < p_hwfn->p_cxt_mngr->vf_count;
4630 : 0 : i++, start_page_id += cdut_vf_pages)
4631 : 0 : offset += qed_ilt_dump_pages_range(dump_buf + offset,
4632 : : dump,
4633 : : start_page_id,
4634 : : cdut_vf_work_pages,
4635 : : ilt_pages,
4636 : : dump_page_ids);
4637 : : }
4638 : :
4639 : : /* Overwrite size param */
4640 [ # # ]: 0 : if (dump)
4641 : 0 : qed_dump_num_param(dump_buf + size_param_offset,
4642 : : dump, "size", offset - base_data_offset);
4643 : :
4644 : 0 : return offset;
4645 : : }
4646 : :
4647 : : /* Performs ILT Dump to the specified buffer.
4648 : : * Returns the dumped size in dwords.
4649 : : */
4650 : 0 : static u32 qed_ilt_dump(struct ecore_hwfn *p_hwfn,
4651 : : struct ecore_ptt *p_ptt, u32 *dump_buf, bool dump)
4652 : : {
4653 : 0 : struct ecore_ilt_client_cfg *clients = p_hwfn->p_cxt_mngr->clients;
4654 : : u32 valid_conn_vf_cids, valid_conn_vf_pages, offset = 0;
4655 : : u32 valid_conn_pf_cids, valid_conn_pf_pages, num_pages;
4656 : : u32 num_cids_per_page, conn_ctx_size;
4657 : : u32 cduc_page_size, cdut_page_size;
4658 : : struct phys_mem_desc *ilt_pages;
4659 : : u8 conn_type;
4660 : :
4661 : 0 : cduc_page_size = 1 <<
4662 : 0 : (clients[ILT_CLI_CDUC].p_size.val + PXP_ILT_PAGE_SIZE_NUM_BITS_MIN);
4663 : 0 : cdut_page_size = 1 <<
4664 : 0 : (clients[ILT_CLI_CDUT].p_size.val + PXP_ILT_PAGE_SIZE_NUM_BITS_MIN);
4665 : 0 : conn_ctx_size = p_hwfn->p_cxt_mngr->conn_ctx_size;
4666 : 0 : num_cids_per_page = (int)(cduc_page_size / conn_ctx_size);
4667 : 0 : ilt_pages = p_hwfn->p_cxt_mngr->ilt_shadow;
4668 : :
4669 : : /* Dump global params - 22 must match number of params below */
4670 : 0 : offset += qed_dump_common_global_params(p_hwfn, p_ptt,
4671 : : dump_buf + offset, dump, 22);
4672 : 0 : offset += qed_dump_str_param(dump_buf + offset,
4673 : : dump, "dump-type", "ilt-dump");
4674 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4675 : : dump,
4676 : : "cduc-page-size", cduc_page_size);
4677 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4678 : : dump,
4679 : : "cduc-first-page-id",
4680 : : clients[ILT_CLI_CDUC].first.val);
4681 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4682 : : dump,
4683 : : "cduc-last-page-id",
4684 : : clients[ILT_CLI_CDUC].last.val);
4685 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4686 : : dump,
4687 : : "cduc-num-pf-pages",
4688 : : clients
4689 : : [ILT_CLI_CDUC].pf_total_lines);
4690 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4691 : : dump,
4692 : : "cduc-num-vf-pages",
4693 : : clients
4694 : : [ILT_CLI_CDUC].vf_total_lines);
4695 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4696 : : dump,
4697 : : "max-conn-ctx-size",
4698 : : conn_ctx_size);
4699 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4700 : : dump,
4701 : : "cdut-page-size", cdut_page_size);
4702 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4703 : : dump,
4704 : : "cdut-first-page-id",
4705 : : clients[ILT_CLI_CDUT].first.val);
4706 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4707 : : dump,
4708 : : "cdut-last-page-id",
4709 : : clients[ILT_CLI_CDUT].last.val);
4710 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4711 : : dump,
4712 : : "cdut-num-pf-init-pages",
4713 : 0 : ecore_get_cdut_num_pf_init_pages(p_hwfn));
4714 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4715 : : dump,
4716 : : "cdut-num-vf-init-pages",
4717 : 0 : ecore_get_cdut_num_vf_init_pages(p_hwfn));
4718 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4719 : : dump,
4720 : : "cdut-num-pf-work-pages",
4721 : 0 : ecore_get_cdut_num_pf_work_pages(p_hwfn));
4722 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4723 : : dump,
4724 : : "cdut-num-vf-work-pages",
4725 : 0 : ecore_get_cdut_num_vf_work_pages(p_hwfn));
4726 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4727 : : dump,
4728 : : "max-task-ctx-size",
4729 : 0 : p_hwfn->p_cxt_mngr->task_ctx_size);
4730 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4731 : : dump,
4732 : : "task-type-id",
4733 : 0 : p_hwfn->p_cxt_mngr->task_type_id);
4734 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4735 : : dump,
4736 : : "first-vf-id-in-pf",
4737 : 0 : p_hwfn->p_cxt_mngr->first_vf_in_pf);
4738 : 0 : offset += /* 18 */ qed_dump_num_param(dump_buf + offset,
4739 : : dump,
4740 : : "num-vfs-in-pf",
4741 : 0 : p_hwfn->p_cxt_mngr->vf_count);
4742 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4743 : : dump,
4744 : : "ptr-size-bytes", sizeof(void *));
4745 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4746 : : dump,
4747 : : "pf-start-line",
4748 : 0 : p_hwfn->p_cxt_mngr->pf_start_line);
4749 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4750 : : dump,
4751 : : "page-mem-desc-size-dwords",
4752 : : PAGE_MEM_DESC_SIZE_DWORDS);
4753 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4754 : : dump,
4755 : : "ilt-shadow-size",
4756 : 0 : p_hwfn->p_cxt_mngr->ilt_shadow_size);
4757 : : /* Additional/Less parameters require matching of number in call to
4758 : : * dump_common_global_params()
4759 : : */
4760 : :
4761 : : /* Dump section containing number of PF CIDs per connection type */
4762 : 0 : offset += qed_dump_section_hdr(dump_buf + offset,
4763 : : dump, "num_pf_cids_per_conn_type", 1);
4764 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4765 : : dump, "size", NUM_OF_CONNECTION_TYPES);
4766 : 0 : for (conn_type = 0, valid_conn_pf_cids = 0;
4767 [ # # ]: 0 : conn_type < NUM_OF_CONNECTION_TYPES; conn_type++, offset++) {
4768 : 0 : u32 num_pf_cids =
4769 : 0 : p_hwfn->p_cxt_mngr->conn_cfg[conn_type].cid_count;
4770 : :
4771 [ # # ]: 0 : if (dump)
4772 : 0 : *(dump_buf + offset) = num_pf_cids;
4773 : 0 : valid_conn_pf_cids += num_pf_cids;
4774 : : }
4775 : :
4776 : : /* Dump section containing number of VF CIDs per connection type */
4777 : 0 : offset += qed_dump_section_hdr(dump_buf + offset,
4778 : : dump, "num_vf_cids_per_conn_type", 1);
4779 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4780 : : dump, "size", NUM_OF_CONNECTION_TYPES);
4781 : 0 : for (conn_type = 0, valid_conn_vf_cids = 0;
4782 [ # # ]: 0 : conn_type < NUM_OF_CONNECTION_TYPES; conn_type++, offset++) {
4783 : 0 : u32 num_vf_cids =
4784 : 0 : p_hwfn->p_cxt_mngr->conn_cfg[conn_type].cids_per_vf;
4785 : :
4786 [ # # ]: 0 : if (dump)
4787 : 0 : *(dump_buf + offset) = num_vf_cids;
4788 : 0 : valid_conn_vf_cids += num_vf_cids;
4789 : : }
4790 : :
4791 : : /* Dump section containing physical memory descs for each ILT page */
4792 : 0 : num_pages = p_hwfn->p_cxt_mngr->ilt_shadow_size;
4793 : 0 : offset += qed_dump_section_hdr(dump_buf + offset,
4794 : : dump, "ilt_page_desc", 1);
4795 : 0 : offset += qed_dump_num_param(dump_buf + offset,
4796 : : dump,
4797 : : "size",
4798 : : num_pages * PAGE_MEM_DESC_SIZE_DWORDS);
4799 : :
4800 : : /* Copy memory descriptors to dump buffer */
4801 [ # # ]: 0 : if (dump) {
4802 : : u32 page_id;
4803 : :
4804 [ # # ]: 0 : for (page_id = 0; page_id < num_pages;
4805 : 0 : page_id++, offset += PAGE_MEM_DESC_SIZE_DWORDS)
4806 : 0 : memcpy(dump_buf + offset,
4807 : 0 : &ilt_pages[page_id],
4808 : : DWORDS_TO_BYTES(PAGE_MEM_DESC_SIZE_DWORDS));
4809 : : } else {
4810 : 0 : offset += num_pages * PAGE_MEM_DESC_SIZE_DWORDS;
4811 : : }
4812 : :
4813 : 0 : valid_conn_pf_pages = DIV_ROUND_UP(valid_conn_pf_cids,
4814 : : num_cids_per_page);
4815 : 0 : valid_conn_vf_pages = DIV_ROUND_UP(valid_conn_vf_cids,
4816 : : num_cids_per_page);
4817 : :
4818 : : /* Dump ILT pages IDs */
4819 : 0 : offset += qed_ilt_dump_pages_section(p_hwfn,
4820 : 0 : dump_buf + offset,
4821 : : dump,
4822 : : valid_conn_pf_pages,
4823 : : valid_conn_vf_pages,
4824 : : ilt_pages, true);
4825 : :
4826 : : /* Dump ILT pages memory */
4827 : 0 : offset += qed_ilt_dump_pages_section(p_hwfn,
4828 : 0 : dump_buf + offset,
4829 : : dump,
4830 : : valid_conn_pf_pages,
4831 : : valid_conn_vf_pages,
4832 : : ilt_pages, false);
4833 : :
4834 : : /* Dump last section */
4835 : 0 : offset += qed_dump_last_section(dump_buf, offset, dump);
4836 : :
4837 : 0 : return offset;
4838 : : }
4839 : :
4840 : : /***************************** Public Functions *******************************/
4841 : :
4842 : 0 : enum dbg_status qed_dbg_set_bin_ptr(struct ecore_hwfn *p_hwfn,
4843 : : const u8 * const bin_ptr)
4844 : : {
4845 : : struct bin_buffer_hdr *buf_hdrs =
4846 : : (struct bin_buffer_hdr *)(osal_uintptr_t)bin_ptr;
4847 : : u8 buf_id;
4848 : :
4849 : : /* Convert binary data to debug arrays */
4850 [ # # ]: 0 : for (buf_id = 0; buf_id < MAX_BIN_DBG_BUFFER_TYPE; buf_id++)
4851 : 0 : qed_set_dbg_bin_buf(p_hwfn,
4852 : : buf_id,
4853 : : (const u32 *)(bin_ptr +
4854 : 0 : buf_hdrs[buf_id].offset),
4855 : 0 : buf_hdrs[buf_id].length);
4856 : :
4857 : 0 : return DBG_STATUS_OK;
4858 : : }
4859 : :
4860 : 0 : bool qed_read_fw_info(struct ecore_hwfn *p_hwfn,
4861 : : struct ecore_ptt *p_ptt, struct fw_info *fw_info)
4862 : : {
4863 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
4864 : : u8 storm_id;
4865 : :
4866 [ # # ]: 0 : for (storm_id = 0; storm_id < MAX_DBG_STORMS; storm_id++) {
4867 : 0 : struct storm_defs *storm = &s_storm_defs[storm_id];
4868 : :
4869 : : /* Skip Storm if it's in reset */
4870 [ # # ]: 0 : if (dev_data->block_in_reset[storm->sem_block_id])
4871 : : continue;
4872 : :
4873 : : /* Read FW info for the current Storm */
4874 : 0 : qed_read_storm_fw_info(p_hwfn, p_ptt, storm_id, fw_info);
4875 : :
4876 : 0 : return true;
4877 : : }
4878 : :
4879 : : return false;
4880 : : }
4881 : :
4882 : 0 : enum dbg_status qed_dbg_grc_config(struct ecore_hwfn *p_hwfn,
4883 : : enum dbg_grc_params grc_param, u32 val)
4884 : : {
4885 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
4886 : : enum dbg_status status;
4887 : : int i;
4888 : :
4889 [ # # ]: 0 : DP_VERBOSE(p_hwfn->p_dev,
4890 : : ECORE_MSG_DEBUG,
4891 : : "dbg_grc_config: paramId = %d, val = %d\n", grc_param, val);
4892 : :
4893 : 0 : status = qed_dbg_dev_init(p_hwfn);
4894 [ # # ]: 0 : if (status != DBG_STATUS_OK)
4895 : : return status;
4896 : :
4897 : : /* Initializes the GRC parameters (if not initialized). Needed in order
4898 : : * to set the default parameter values for the first time.
4899 : : */
4900 : : qed_dbg_grc_init_params(p_hwfn);
4901 : :
4902 [ # # ]: 0 : if (grc_param >= MAX_DBG_GRC_PARAMS)
4903 : : return DBG_STATUS_INVALID_ARGS;
4904 [ # # ]: 0 : if (val < s_grc_param_defs[grc_param].min ||
4905 [ # # ]: 0 : val > s_grc_param_defs[grc_param].max)
4906 : : return DBG_STATUS_INVALID_ARGS;
4907 : :
4908 [ # # ]: 0 : if (s_grc_param_defs[grc_param].is_preset) {
4909 : : /* Preset param */
4910 : :
4911 : : /* Disabling a preset is not allowed. Call
4912 : : * dbg_grc_set_params_default instead.
4913 : : */
4914 [ # # ]: 0 : if (!val)
4915 : : return DBG_STATUS_INVALID_ARGS;
4916 : :
4917 : : /* Update all params with the preset values */
4918 [ # # ]: 0 : for (i = 0; i < MAX_DBG_GRC_PARAMS; i++) {
4919 : : struct grc_param_defs *defs = &s_grc_param_defs[i];
4920 : : u32 preset_val;
4921 : : /* Skip persistent params */
4922 [ # # ]: 0 : if (defs->is_persistent)
4923 : 0 : continue;
4924 : :
4925 : : /* Find preset value */
4926 [ # # ]: 0 : if (grc_param == DBG_GRC_PARAM_EXCLUDE_ALL)
4927 : 0 : preset_val =
4928 : : defs->exclude_all_preset_val;
4929 [ # # ]: 0 : else if (grc_param == DBG_GRC_PARAM_CRASH)
4930 : 0 : preset_val =
4931 : 0 : defs->crash_preset_val[dev_data->chip_id];
4932 : : else
4933 : : return DBG_STATUS_INVALID_ARGS;
4934 : :
4935 : 0 : qed_grc_set_param(p_hwfn, i, preset_val);
4936 : : }
4937 : : } else {
4938 : : /* Regular param - set its value */
4939 : : qed_grc_set_param(p_hwfn, grc_param, val);
4940 : : }
4941 : :
4942 : : return DBG_STATUS_OK;
4943 : : }
4944 : :
4945 : : /* Assign default GRC param values */
4946 : 0 : void qed_dbg_grc_set_params_default(struct ecore_hwfn *p_hwfn)
4947 : : {
4948 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
4949 : : u32 i;
4950 : :
4951 [ # # ]: 0 : for (i = 0; i < MAX_DBG_GRC_PARAMS; i++)
4952 [ # # ]: 0 : if (!s_grc_param_defs[i].is_persistent)
4953 : 0 : dev_data->grc.param_val[i] =
4954 : 0 : s_grc_param_defs[i].default_val[dev_data->chip_id];
4955 : 0 : }
4956 : :
4957 : 0 : enum dbg_status qed_dbg_grc_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
4958 : : struct ecore_ptt *p_ptt,
4959 : : u32 *buf_size)
4960 : : {
4961 : 0 : enum dbg_status status = qed_dbg_dev_init(p_hwfn);
4962 : :
4963 : 0 : *buf_size = 0;
4964 : :
4965 [ # # ]: 0 : if (status != DBG_STATUS_OK)
4966 : : return status;
4967 : :
4968 [ # # ]: 0 : if (!p_hwfn->dbg_arrays[BIN_BUF_DBG_MODE_TREE].ptr ||
4969 [ # # ]: 0 : !p_hwfn->dbg_arrays[BIN_BUF_DBG_DUMP_REG].ptr ||
4970 [ # # ]: 0 : !p_hwfn->dbg_arrays[BIN_BUF_DBG_DUMP_MEM].ptr ||
4971 [ # # ]: 0 : !p_hwfn->dbg_arrays[BIN_BUF_DBG_ATTN_BLOCKS].ptr ||
4972 [ # # ]: 0 : !p_hwfn->dbg_arrays[BIN_BUF_DBG_ATTN_REGS].ptr)
4973 : : return DBG_STATUS_DBG_ARRAY_NOT_SET;
4974 : :
4975 : 0 : return qed_grc_dump(p_hwfn, p_ptt, NULL, false, buf_size);
4976 : : }
4977 : :
4978 : 0 : enum dbg_status qed_dbg_grc_dump(struct ecore_hwfn *p_hwfn,
4979 : : struct ecore_ptt *p_ptt,
4980 : : u32 *dump_buf,
4981 : : u32 buf_size_in_dwords,
4982 : : u32 *num_dumped_dwords)
4983 : : {
4984 : : u32 needed_buf_size_in_dwords;
4985 : : enum dbg_status status;
4986 : :
4987 : 0 : *num_dumped_dwords = 0;
4988 : :
4989 : 0 : status = qed_dbg_grc_get_dump_buf_size(p_hwfn,
4990 : : p_ptt,
4991 : : &needed_buf_size_in_dwords);
4992 [ # # ]: 0 : if (status != DBG_STATUS_OK)
4993 : : return status;
4994 : :
4995 [ # # ]: 0 : if (buf_size_in_dwords < needed_buf_size_in_dwords)
4996 : : return DBG_STATUS_DUMP_BUF_TOO_SMALL;
4997 : :
4998 : : /* GRC Dump */
4999 : 0 : status = qed_grc_dump(p_hwfn, p_ptt, dump_buf, true, num_dumped_dwords);
5000 : :
5001 : : /* Revert GRC params to their default */
5002 : 0 : qed_dbg_grc_set_params_default(p_hwfn);
5003 : :
5004 : 0 : return status;
5005 : : }
5006 : :
5007 : 0 : enum dbg_status qed_dbg_idle_chk_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
5008 : : struct ecore_ptt *p_ptt,
5009 : : u32 *buf_size)
5010 : : {
5011 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
5012 : : struct idle_chk_data *idle_chk = &dev_data->idle_chk;
5013 : : enum dbg_status status;
5014 : :
5015 : 0 : *buf_size = 0;
5016 : :
5017 : 0 : status = qed_dbg_dev_init(p_hwfn);
5018 [ # # ]: 0 : if (status != DBG_STATUS_OK)
5019 : : return status;
5020 : :
5021 [ # # ]: 0 : if (!p_hwfn->dbg_arrays[BIN_BUF_DBG_MODE_TREE].ptr ||
5022 [ # # ]: 0 : !p_hwfn->dbg_arrays[BIN_BUF_DBG_IDLE_CHK_REGS].ptr ||
5023 [ # # ]: 0 : !p_hwfn->dbg_arrays[BIN_BUF_DBG_IDLE_CHK_IMMS].ptr ||
5024 [ # # ]: 0 : !p_hwfn->dbg_arrays[BIN_BUF_DBG_IDLE_CHK_RULES].ptr)
5025 : : return DBG_STATUS_DBG_ARRAY_NOT_SET;
5026 : :
5027 [ # # ]: 0 : if (!idle_chk->buf_size_set) {
5028 : 0 : idle_chk->buf_size = qed_idle_chk_dump(p_hwfn,
5029 : : p_ptt, NULL, false);
5030 : 0 : idle_chk->buf_size_set = true;
5031 : : }
5032 : :
5033 : 0 : *buf_size = idle_chk->buf_size;
5034 : :
5035 : 0 : return DBG_STATUS_OK;
5036 : : }
5037 : :
5038 : 0 : enum dbg_status qed_dbg_idle_chk_dump(struct ecore_hwfn *p_hwfn,
5039 : : struct ecore_ptt *p_ptt,
5040 : : u32 *dump_buf,
5041 : : u32 buf_size_in_dwords,
5042 : : u32 *num_dumped_dwords)
5043 : : {
5044 : : u32 needed_buf_size_in_dwords;
5045 : : enum dbg_status status;
5046 : :
5047 : 0 : *num_dumped_dwords = 0;
5048 : :
5049 : 0 : status = qed_dbg_idle_chk_get_dump_buf_size(p_hwfn,
5050 : : p_ptt,
5051 : : &needed_buf_size_in_dwords);
5052 [ # # ]: 0 : if (status != DBG_STATUS_OK)
5053 : : return status;
5054 : :
5055 [ # # ]: 0 : if (buf_size_in_dwords < needed_buf_size_in_dwords)
5056 : : return DBG_STATUS_DUMP_BUF_TOO_SMALL;
5057 : :
5058 : : /* Update reset state */
5059 : 0 : qed_grc_unreset_blocks(p_hwfn, p_ptt, true);
5060 : 0 : qed_update_blocks_reset_state(p_hwfn, p_ptt);
5061 : :
5062 : : /* Idle Check Dump */
5063 : 0 : *num_dumped_dwords = qed_idle_chk_dump(p_hwfn, p_ptt, dump_buf, true);
5064 : :
5065 : : /* Revert GRC params to their default */
5066 : 0 : qed_dbg_grc_set_params_default(p_hwfn);
5067 : :
5068 : 0 : return DBG_STATUS_OK;
5069 : : }
5070 : :
5071 : 0 : enum dbg_status qed_dbg_mcp_trace_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
5072 : : struct ecore_ptt *p_ptt,
5073 : : u32 *buf_size)
5074 : : {
5075 : 0 : enum dbg_status status = qed_dbg_dev_init(p_hwfn);
5076 : :
5077 : 0 : *buf_size = 0;
5078 : :
5079 [ # # ]: 0 : if (status != DBG_STATUS_OK)
5080 : : return status;
5081 : :
5082 : 0 : return qed_mcp_trace_dump(p_hwfn, p_ptt, NULL, false, buf_size);
5083 : : }
5084 : :
5085 : 0 : enum dbg_status qed_dbg_mcp_trace_dump(struct ecore_hwfn *p_hwfn,
5086 : : struct ecore_ptt *p_ptt,
5087 : : u32 *dump_buf,
5088 : : u32 buf_size_in_dwords,
5089 : : u32 *num_dumped_dwords)
5090 : : {
5091 : : u32 needed_buf_size_in_dwords;
5092 : : enum dbg_status status;
5093 : :
5094 : : status =
5095 : 0 : qed_dbg_mcp_trace_get_dump_buf_size(p_hwfn,
5096 : : p_ptt,
5097 : : &needed_buf_size_in_dwords);
5098 [ # # ]: 0 : if (status != DBG_STATUS_OK && status !=
5099 : : DBG_STATUS_NVRAM_GET_IMAGE_FAILED)
5100 : : return status;
5101 [ # # ]: 0 : if (buf_size_in_dwords < needed_buf_size_in_dwords)
5102 : : return DBG_STATUS_DUMP_BUF_TOO_SMALL;
5103 : :
5104 : : /* Update reset state */
5105 : 0 : qed_update_blocks_reset_state(p_hwfn, p_ptt);
5106 : :
5107 : : /* Perform dump */
5108 : 0 : status = qed_mcp_trace_dump(p_hwfn,
5109 : : p_ptt, dump_buf, true, num_dumped_dwords);
5110 : :
5111 : : /* Revert GRC params to their default */
5112 : 0 : qed_dbg_grc_set_params_default(p_hwfn);
5113 : :
5114 : 0 : return status;
5115 : : }
5116 : :
5117 : 0 : enum dbg_status qed_dbg_reg_fifo_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
5118 : : struct ecore_ptt *p_ptt,
5119 : : u32 *buf_size)
5120 : : {
5121 : 0 : enum dbg_status status = qed_dbg_dev_init(p_hwfn);
5122 : :
5123 : 0 : *buf_size = 0;
5124 : :
5125 [ # # ]: 0 : if (status != DBG_STATUS_OK)
5126 : : return status;
5127 : :
5128 : 0 : return qed_reg_fifo_dump(p_hwfn, p_ptt, NULL, false, buf_size);
5129 : : }
5130 : :
5131 : 0 : enum dbg_status qed_dbg_reg_fifo_dump(struct ecore_hwfn *p_hwfn,
5132 : : struct ecore_ptt *p_ptt,
5133 : : u32 *dump_buf,
5134 : : u32 buf_size_in_dwords,
5135 : : u32 *num_dumped_dwords)
5136 : : {
5137 : : u32 needed_buf_size_in_dwords;
5138 : : enum dbg_status status;
5139 : :
5140 : 0 : *num_dumped_dwords = 0;
5141 : :
5142 : 0 : status = qed_dbg_reg_fifo_get_dump_buf_size(p_hwfn,
5143 : : p_ptt,
5144 : : &needed_buf_size_in_dwords);
5145 [ # # ]: 0 : if (status != DBG_STATUS_OK)
5146 : : return status;
5147 : :
5148 [ # # ]: 0 : if (buf_size_in_dwords < needed_buf_size_in_dwords)
5149 : : return DBG_STATUS_DUMP_BUF_TOO_SMALL;
5150 : :
5151 : : /* Update reset state */
5152 : 0 : qed_update_blocks_reset_state(p_hwfn, p_ptt);
5153 : :
5154 : 0 : status = qed_reg_fifo_dump(p_hwfn,
5155 : : p_ptt, dump_buf, true, num_dumped_dwords);
5156 : :
5157 : : /* Revert GRC params to their default */
5158 : 0 : qed_dbg_grc_set_params_default(p_hwfn);
5159 : :
5160 : 0 : return status;
5161 : : }
5162 : :
5163 : 0 : enum dbg_status qed_dbg_igu_fifo_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
5164 : : struct ecore_ptt *p_ptt,
5165 : : u32 *buf_size)
5166 : : {
5167 : 0 : enum dbg_status status = qed_dbg_dev_init(p_hwfn);
5168 : :
5169 : 0 : *buf_size = 0;
5170 : :
5171 [ # # ]: 0 : if (status != DBG_STATUS_OK)
5172 : : return status;
5173 : :
5174 : 0 : return qed_igu_fifo_dump(p_hwfn, p_ptt, NULL, false, buf_size);
5175 : : }
5176 : :
5177 : 0 : enum dbg_status qed_dbg_igu_fifo_dump(struct ecore_hwfn *p_hwfn,
5178 : : struct ecore_ptt *p_ptt,
5179 : : u32 *dump_buf,
5180 : : u32 buf_size_in_dwords,
5181 : : u32 *num_dumped_dwords)
5182 : : {
5183 : : u32 needed_buf_size_in_dwords;
5184 : : enum dbg_status status;
5185 : :
5186 : 0 : *num_dumped_dwords = 0;
5187 : :
5188 : 0 : status = qed_dbg_igu_fifo_get_dump_buf_size(p_hwfn,
5189 : : p_ptt,
5190 : : &needed_buf_size_in_dwords);
5191 [ # # ]: 0 : if (status != DBG_STATUS_OK)
5192 : : return status;
5193 : :
5194 [ # # ]: 0 : if (buf_size_in_dwords < needed_buf_size_in_dwords)
5195 : : return DBG_STATUS_DUMP_BUF_TOO_SMALL;
5196 : :
5197 : : /* Update reset state */
5198 : 0 : qed_update_blocks_reset_state(p_hwfn, p_ptt);
5199 : :
5200 : 0 : status = qed_igu_fifo_dump(p_hwfn,
5201 : : p_ptt, dump_buf, true, num_dumped_dwords);
5202 : : /* Revert GRC params to their default */
5203 : 0 : qed_dbg_grc_set_params_default(p_hwfn);
5204 : :
5205 : 0 : return status;
5206 : : }
5207 : :
5208 : : enum dbg_status
5209 : 0 : qed_dbg_protection_override_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
5210 : : struct ecore_ptt *p_ptt,
5211 : : u32 *buf_size)
5212 : : {
5213 : 0 : enum dbg_status status = qed_dbg_dev_init(p_hwfn);
5214 : :
5215 : 0 : *buf_size = 0;
5216 : :
5217 [ # # ]: 0 : if (status != DBG_STATUS_OK)
5218 : : return status;
5219 : :
5220 : 0 : return qed_protection_override_dump(p_hwfn,
5221 : : p_ptt, NULL, false, buf_size);
5222 : : }
5223 : :
5224 : 0 : enum dbg_status qed_dbg_protection_override_dump(struct ecore_hwfn *p_hwfn,
5225 : : struct ecore_ptt *p_ptt,
5226 : : u32 *dump_buf,
5227 : : u32 buf_size_in_dwords,
5228 : : u32 *num_dumped_dwords)
5229 : : {
5230 : : u32 needed_buf_size_in_dwords, *p_size = &needed_buf_size_in_dwords;
5231 : : enum dbg_status status;
5232 : :
5233 : 0 : *num_dumped_dwords = 0;
5234 : :
5235 : : status =
5236 : 0 : qed_dbg_protection_override_get_dump_buf_size(p_hwfn,
5237 : : p_ptt,
5238 : : p_size);
5239 [ # # ]: 0 : if (status != DBG_STATUS_OK)
5240 : : return status;
5241 : :
5242 [ # # ]: 0 : if (buf_size_in_dwords < needed_buf_size_in_dwords)
5243 : : return DBG_STATUS_DUMP_BUF_TOO_SMALL;
5244 : :
5245 : : /* Update reset state */
5246 : 0 : qed_update_blocks_reset_state(p_hwfn, p_ptt);
5247 : :
5248 : 0 : status = qed_protection_override_dump(p_hwfn,
5249 : : p_ptt,
5250 : : dump_buf,
5251 : : true, num_dumped_dwords);
5252 : :
5253 : : /* Revert GRC params to their default */
5254 : 0 : qed_dbg_grc_set_params_default(p_hwfn);
5255 : :
5256 : 0 : return status;
5257 : : }
5258 : :
5259 : 0 : enum dbg_status qed_dbg_fw_asserts_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
5260 : : struct ecore_ptt *p_ptt,
5261 : : u32 *buf_size)
5262 : : {
5263 : 0 : enum dbg_status status = qed_dbg_dev_init(p_hwfn);
5264 : :
5265 : 0 : *buf_size = 0;
5266 : :
5267 [ # # ]: 0 : if (status != DBG_STATUS_OK)
5268 : : return status;
5269 : :
5270 : : /* Update reset state */
5271 : 0 : qed_update_blocks_reset_state(p_hwfn, p_ptt);
5272 : :
5273 : 0 : *buf_size = qed_fw_asserts_dump(p_hwfn, p_ptt, NULL, false);
5274 : :
5275 : 0 : return DBG_STATUS_OK;
5276 : : }
5277 : :
5278 : 0 : enum dbg_status qed_dbg_fw_asserts_dump(struct ecore_hwfn *p_hwfn,
5279 : : struct ecore_ptt *p_ptt,
5280 : : u32 *dump_buf,
5281 : : u32 buf_size_in_dwords,
5282 : : u32 *num_dumped_dwords)
5283 : : {
5284 : : u32 needed_buf_size_in_dwords, *p_size = &needed_buf_size_in_dwords;
5285 : : enum dbg_status status;
5286 : :
5287 : 0 : *num_dumped_dwords = 0;
5288 : :
5289 : : status =
5290 : 0 : qed_dbg_fw_asserts_get_dump_buf_size(p_hwfn,
5291 : : p_ptt,
5292 : : p_size);
5293 [ # # ]: 0 : if (status != DBG_STATUS_OK)
5294 : : return status;
5295 : :
5296 [ # # ]: 0 : if (buf_size_in_dwords < needed_buf_size_in_dwords)
5297 : : return DBG_STATUS_DUMP_BUF_TOO_SMALL;
5298 : :
5299 : 0 : *num_dumped_dwords = qed_fw_asserts_dump(p_hwfn, p_ptt, dump_buf, true);
5300 : :
5301 : : /* Revert GRC params to their default */
5302 : 0 : qed_dbg_grc_set_params_default(p_hwfn);
5303 : :
5304 : 0 : return DBG_STATUS_OK;
5305 : : }
5306 : :
5307 : 0 : static enum dbg_status qed_dbg_ilt_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
5308 : : struct ecore_ptt *p_ptt,
5309 : : u32 *buf_size)
5310 : : {
5311 : 0 : enum dbg_status status = qed_dbg_dev_init(p_hwfn);
5312 : :
5313 : 0 : *buf_size = 0;
5314 : :
5315 [ # # ]: 0 : if (status != DBG_STATUS_OK)
5316 : : return status;
5317 : :
5318 : 0 : *buf_size = qed_ilt_dump(p_hwfn, p_ptt, NULL, false);
5319 : :
5320 : 0 : return DBG_STATUS_OK;
5321 : : }
5322 : :
5323 : 0 : static enum dbg_status qed_dbg_ilt_dump(struct ecore_hwfn *p_hwfn,
5324 : : struct ecore_ptt *p_ptt,
5325 : : u32 *dump_buf,
5326 : : u32 buf_size_in_dwords,
5327 : : u32 *num_dumped_dwords)
5328 : : {
5329 : : u32 needed_buf_size_in_dwords;
5330 : : enum dbg_status status;
5331 : :
5332 : 0 : *num_dumped_dwords = 0;
5333 : :
5334 : 0 : status = qed_dbg_ilt_get_dump_buf_size(p_hwfn,
5335 : : p_ptt,
5336 : : &needed_buf_size_in_dwords);
5337 [ # # ]: 0 : if (status != DBG_STATUS_OK)
5338 : : return status;
5339 : :
5340 [ # # ]: 0 : if (buf_size_in_dwords < needed_buf_size_in_dwords)
5341 : : return DBG_STATUS_DUMP_BUF_TOO_SMALL;
5342 : :
5343 : 0 : *num_dumped_dwords = qed_ilt_dump(p_hwfn, p_ptt, dump_buf, true);
5344 : :
5345 : : /* Revert GRC params to their default */
5346 : 0 : qed_dbg_grc_set_params_default(p_hwfn);
5347 : :
5348 : 0 : return DBG_STATUS_OK;
5349 : : }
5350 : :
5351 : 0 : enum dbg_status qed_dbg_read_attn(struct ecore_hwfn *p_hwfn,
5352 : : struct ecore_ptt *p_ptt,
5353 : : enum block_id block_id,
5354 : : enum dbg_attn_type attn_type,
5355 : : bool clear_status,
5356 : : struct dbg_attn_block_result *results)
5357 : : {
5358 : 0 : enum dbg_status status = qed_dbg_dev_init(p_hwfn);
5359 : : u8 reg_idx, num_attn_regs, num_result_regs = 0;
5360 : : const struct dbg_attn_reg *attn_reg_arr;
5361 : :
5362 [ # # ]: 0 : if (status != DBG_STATUS_OK)
5363 : : return status;
5364 : :
5365 [ # # ]: 0 : if (!p_hwfn->dbg_arrays[BIN_BUF_DBG_MODE_TREE].ptr ||
5366 [ # # ]: 0 : !p_hwfn->dbg_arrays[BIN_BUF_DBG_ATTN_BLOCKS].ptr ||
5367 [ # # ]: 0 : !p_hwfn->dbg_arrays[BIN_BUF_DBG_ATTN_REGS].ptr)
5368 : : return DBG_STATUS_DBG_ARRAY_NOT_SET;
5369 : :
5370 : : attn_reg_arr = qed_get_block_attn_regs(p_hwfn,
5371 : : block_id,
5372 : : attn_type, &num_attn_regs);
5373 : :
5374 [ # # ]: 0 : for (reg_idx = 0; reg_idx < num_attn_regs; reg_idx++) {
5375 : 0 : const struct dbg_attn_reg *reg_data = &attn_reg_arr[reg_idx];
5376 : : struct dbg_attn_reg_result *reg_result;
5377 : : u32 sts_addr, sts_val;
5378 : : u16 modes_buf_offset;
5379 : : bool eval_mode;
5380 : :
5381 : : /* Check mode */
5382 : 0 : eval_mode = GET_FIELD(reg_data->mode.data,
5383 : : DBG_MODE_HDR_EVAL_MODE) > 0;
5384 : 0 : modes_buf_offset = GET_FIELD(reg_data->mode.data,
5385 : : DBG_MODE_HDR_MODES_BUF_OFFSET);
5386 [ # # # # ]: 0 : if (eval_mode && !qed_is_mode_match(p_hwfn, &modes_buf_offset))
5387 : 0 : continue;
5388 : :
5389 : : /* Mode match - read attention status register */
5390 [ # # ]: 0 : sts_addr = DWORDS_TO_BYTES(clear_status ?
5391 : : reg_data->sts_clr_address :
5392 : : GET_FIELD(reg_data->data,
5393 : : DBG_ATTN_REG_STS_ADDRESS));
5394 : 0 : sts_val = ecore_rd(p_hwfn, p_ptt, sts_addr);
5395 [ # # ]: 0 : if (!sts_val)
5396 : 0 : continue;
5397 : :
5398 : : /* Non-zero attention status - add to results */
5399 : 0 : reg_result = &results->reg_results[num_result_regs];
5400 : 0 : SET_FIELD(reg_result->data,
5401 : : DBG_ATTN_REG_RESULT_STS_ADDRESS, sts_addr);
5402 : 0 : SET_FIELD(reg_result->data,
5403 : : DBG_ATTN_REG_RESULT_NUM_REG_ATTN,
5404 : : GET_FIELD(reg_data->data, DBG_ATTN_REG_NUM_REG_ATTN));
5405 : 0 : reg_result->block_attn_offset = reg_data->block_attn_offset;
5406 : 0 : reg_result->sts_val = sts_val;
5407 : 0 : reg_result->mask_val = ecore_rd(p_hwfn,
5408 : : p_ptt,
5409 : 0 : DWORDS_TO_BYTES
5410 : : (reg_data->mask_address));
5411 : 0 : num_result_regs++;
5412 : : }
5413 : :
5414 : 0 : results->block_id = (u8)block_id;
5415 : 0 : results->names_offset =
5416 : 0 : qed_get_block_attn_data(p_hwfn, block_id, attn_type)->names_offset;
5417 : 0 : SET_FIELD(results->data, DBG_ATTN_BLOCK_RESULT_ATTN_TYPE, attn_type);
5418 : 0 : SET_FIELD(results->data,
5419 : : DBG_ATTN_BLOCK_RESULT_NUM_REGS, num_result_regs);
5420 : :
5421 : 0 : return DBG_STATUS_OK;
5422 : : }
5423 : :
5424 : : /******************************* Data Types **********************************/
5425 : :
5426 : : /* REG fifo element */
5427 : : struct reg_fifo_element {
5428 : : u64 data;
5429 : : #define REG_FIFO_ELEMENT_ADDRESS_SHIFT 0
5430 : : #define REG_FIFO_ELEMENT_ADDRESS_MASK 0x7fffff
5431 : : #define REG_FIFO_ELEMENT_ACCESS_SHIFT 23
5432 : : #define REG_FIFO_ELEMENT_ACCESS_MASK 0x1
5433 : : #define REG_FIFO_ELEMENT_PF_SHIFT 24
5434 : : #define REG_FIFO_ELEMENT_PF_MASK 0xf
5435 : : #define REG_FIFO_ELEMENT_VF_SHIFT 28
5436 : : #define REG_FIFO_ELEMENT_VF_MASK 0xff
5437 : : #define REG_FIFO_ELEMENT_PORT_SHIFT 36
5438 : : #define REG_FIFO_ELEMENT_PORT_MASK 0x3
5439 : : #define REG_FIFO_ELEMENT_PRIVILEGE_SHIFT 38
5440 : : #define REG_FIFO_ELEMENT_PRIVILEGE_MASK 0x3
5441 : : #define REG_FIFO_ELEMENT_PROTECTION_SHIFT 40
5442 : : #define REG_FIFO_ELEMENT_PROTECTION_MASK 0x7
5443 : : #define REG_FIFO_ELEMENT_MASTER_SHIFT 43
5444 : : #define REG_FIFO_ELEMENT_MASTER_MASK 0xf
5445 : : #define REG_FIFO_ELEMENT_ERROR_SHIFT 47
5446 : : #define REG_FIFO_ELEMENT_ERROR_MASK 0x1f
5447 : : };
5448 : :
5449 : : /* REG fifo error element */
5450 : : struct reg_fifo_err {
5451 : : u32 err_code;
5452 : : const char *err_msg;
5453 : : };
5454 : :
5455 : : /* IGU fifo element */
5456 : : struct igu_fifo_element {
5457 : : u32 dword0;
5458 : : #define IGU_FIFO_ELEMENT_DWORD0_FID_SHIFT 0
5459 : : #define IGU_FIFO_ELEMENT_DWORD0_FID_MASK 0xff
5460 : : #define IGU_FIFO_ELEMENT_DWORD0_IS_PF_SHIFT 8
5461 : : #define IGU_FIFO_ELEMENT_DWORD0_IS_PF_MASK 0x1
5462 : : #define IGU_FIFO_ELEMENT_DWORD0_SOURCE_SHIFT 9
5463 : : #define IGU_FIFO_ELEMENT_DWORD0_SOURCE_MASK 0xf
5464 : : #define IGU_FIFO_ELEMENT_DWORD0_ERR_TYPE_SHIFT 13
5465 : : #define IGU_FIFO_ELEMENT_DWORD0_ERR_TYPE_MASK 0xf
5466 : : #define IGU_FIFO_ELEMENT_DWORD0_CMD_ADDR_SHIFT 17
5467 : : #define IGU_FIFO_ELEMENT_DWORD0_CMD_ADDR_MASK 0x7fff
5468 : : u32 dword1;
5469 : : u32 dword2;
5470 : : #define IGU_FIFO_ELEMENT_DWORD12_IS_WR_CMD_SHIFT 0
5471 : : #define IGU_FIFO_ELEMENT_DWORD12_IS_WR_CMD_MASK 0x1
5472 : : #define IGU_FIFO_ELEMENT_DWORD12_WR_DATA_SHIFT 1
5473 : : #define IGU_FIFO_ELEMENT_DWORD12_WR_DATA_MASK 0xffffffff
5474 : : u32 reserved;
5475 : : };
5476 : :
5477 : : struct igu_fifo_wr_data {
5478 : : u32 data;
5479 : : #define IGU_FIFO_WR_DATA_PROD_CONS_SHIFT 0
5480 : : #define IGU_FIFO_WR_DATA_PROD_CONS_MASK 0xffffff
5481 : : #define IGU_FIFO_WR_DATA_UPDATE_FLAG_SHIFT 24
5482 : : #define IGU_FIFO_WR_DATA_UPDATE_FLAG_MASK 0x1
5483 : : #define IGU_FIFO_WR_DATA_EN_DIS_INT_FOR_SB_SHIFT 25
5484 : : #define IGU_FIFO_WR_DATA_EN_DIS_INT_FOR_SB_MASK 0x3
5485 : : #define IGU_FIFO_WR_DATA_SEGMENT_SHIFT 27
5486 : : #define IGU_FIFO_WR_DATA_SEGMENT_MASK 0x1
5487 : : #define IGU_FIFO_WR_DATA_TIMER_MASK_SHIFT 28
5488 : : #define IGU_FIFO_WR_DATA_TIMER_MASK_MASK 0x1
5489 : : #define IGU_FIFO_WR_DATA_CMD_TYPE_SHIFT 31
5490 : : #define IGU_FIFO_WR_DATA_CMD_TYPE_MASK 0x1
5491 : : };
5492 : :
5493 : : struct igu_fifo_cleanup_wr_data {
5494 : : u32 data;
5495 : : #define IGU_FIFO_CLEANUP_WR_DATA_RESERVED_SHIFT 0
5496 : : #define IGU_FIFO_CLEANUP_WR_DATA_RESERVED_MASK 0x7ffffff
5497 : : #define IGU_FIFO_CLEANUP_WR_DATA_CLEANUP_VAL_SHIFT 27
5498 : : #define IGU_FIFO_CLEANUP_WR_DATA_CLEANUP_VAL_MASK 0x1
5499 : : #define IGU_FIFO_CLEANUP_WR_DATA_CLEANUP_TYPE_SHIFT 28
5500 : : #define IGU_FIFO_CLEANUP_WR_DATA_CLEANUP_TYPE_MASK 0x7
5501 : : #define IGU_FIFO_CLEANUP_WR_DATA_CMD_TYPE_SHIFT 31
5502 : : #define IGU_FIFO_CLEANUP_WR_DATA_CMD_TYPE_MASK 0x1
5503 : : };
5504 : :
5505 : : /* Protection override element */
5506 : : struct protection_override_element {
5507 : : u64 data;
5508 : : #define PROTECTION_OVERRIDE_ELEMENT_ADDRESS_SHIFT 0
5509 : : #define PROTECTION_OVERRIDE_ELEMENT_ADDRESS_MASK 0x7fffff
5510 : : #define PROTECTION_OVERRIDE_ELEMENT_WINDOW_SIZE_SHIFT 23
5511 : : #define PROTECTION_OVERRIDE_ELEMENT_WINDOW_SIZE_MASK 0xffffff
5512 : : #define PROTECTION_OVERRIDE_ELEMENT_READ_SHIFT 47
5513 : : #define PROTECTION_OVERRIDE_ELEMENT_READ_MASK 0x1
5514 : : #define PROTECTION_OVERRIDE_ELEMENT_WRITE_SHIFT 48
5515 : : #define PROTECTION_OVERRIDE_ELEMENT_WRITE_MASK 0x1
5516 : : #define PROTECTION_OVERRIDE_ELEMENT_READ_PROTECTION_SHIFT 49
5517 : : #define PROTECTION_OVERRIDE_ELEMENT_READ_PROTECTION_MASK 0x7
5518 : : #define PROTECTION_OVERRIDE_ELEMENT_WRITE_PROTECTION_SHIFT 52
5519 : : #define PROTECTION_OVERRIDE_ELEMENT_WRITE_PROTECTION_MASK 0x7
5520 : : };
5521 : :
5522 : : enum igu_fifo_sources {
5523 : : IGU_SRC_PXP0,
5524 : : IGU_SRC_PXP1,
5525 : : IGU_SRC_PXP2,
5526 : : IGU_SRC_PXP3,
5527 : : IGU_SRC_PXP4,
5528 : : IGU_SRC_PXP5,
5529 : : IGU_SRC_PXP6,
5530 : : IGU_SRC_PXP7,
5531 : : IGU_SRC_CAU,
5532 : : IGU_SRC_ATTN,
5533 : : IGU_SRC_GRC
5534 : : };
5535 : :
5536 : : enum igu_fifo_addr_types {
5537 : : IGU_ADDR_TYPE_MSIX_MEM,
5538 : : IGU_ADDR_TYPE_WRITE_PBA,
5539 : : IGU_ADDR_TYPE_WRITE_INT_ACK,
5540 : : IGU_ADDR_TYPE_WRITE_ATTN_BITS,
5541 : : IGU_ADDR_TYPE_READ_INT,
5542 : : IGU_ADDR_TYPE_WRITE_PROD_UPDATE,
5543 : : IGU_ADDR_TYPE_RESERVED
5544 : : };
5545 : :
5546 : : struct igu_fifo_addr_data {
5547 : : u16 start_addr;
5548 : : u16 end_addr;
5549 : : const char *desc;
5550 : : const char *vf_desc;
5551 : : enum igu_fifo_addr_types type;
5552 : : };
5553 : :
5554 : : /******************************** Constants **********************************/
5555 : :
5556 : : #define MAX_MSG_LEN 1024
5557 : :
5558 : : #define MCP_TRACE_MAX_MODULE_LEN 8
5559 : : #define MCP_TRACE_FORMAT_MAX_PARAMS 3
5560 : : #define MCP_TRACE_FORMAT_PARAM_WIDTH \
5561 : : (MCP_TRACE_FORMAT_P2_SIZE_OFFSET - MCP_TRACE_FORMAT_P1_SIZE_OFFSET)
5562 : :
5563 : : #define REG_FIFO_ELEMENT_ADDR_FACTOR 4
5564 : : #define REG_FIFO_ELEMENT_IS_PF_VF_VAL 127
5565 : :
5566 : : #define PROTECTION_OVERRIDE_ELEMENT_ADDR_FACTOR 4
5567 : :
5568 : : /***************************** Constant Arrays *******************************/
5569 : :
5570 : : /* Status string array */
5571 : : static const char * const s_status_str[] = {
5572 : : /* DBG_STATUS_OK */
5573 : : "Operation completed successfully",
5574 : :
5575 : : /* DBG_STATUS_APP_VERSION_NOT_SET */
5576 : : "Debug application version wasn't set",
5577 : :
5578 : : /* DBG_STATUS_UNSUPPORTED_APP_VERSION */
5579 : : "Unsupported debug application version",
5580 : :
5581 : : /* DBG_STATUS_DBG_BLOCK_NOT_RESET */
5582 : : "The debug block wasn't reset since the last recording",
5583 : :
5584 : : /* DBG_STATUS_INVALID_ARGS */
5585 : : "Invalid arguments",
5586 : :
5587 : : /* DBG_STATUS_OUTPUT_ALREADY_SET */
5588 : : "The debug output was already set",
5589 : :
5590 : : /* DBG_STATUS_INVALID_PCI_BUF_SIZE */
5591 : : "Invalid PCI buffer size",
5592 : :
5593 : : /* DBG_STATUS_PCI_BUF_ALLOC_FAILED */
5594 : : "PCI buffer allocation failed",
5595 : :
5596 : : /* DBG_STATUS_PCI_BUF_NOT_ALLOCATED */
5597 : : "A PCI buffer wasn't allocated",
5598 : :
5599 : : /* DBG_STATUS_INVALID_FILTER_TRIGGER_DWORDS */
5600 : : "The filter/trigger constraint dword offsets are not enabled for recording",
5601 : :
5602 : : /* DBG_STATUS_NO_MATCHING_FRAMING_MODE */
5603 : : "No matching frame mode",
5604 : :
5605 : : /* DBG_STATUS_VFC_READ_ERROR */
5606 : : "Error reading from VFC",
5607 : :
5608 : : /* DBG_STATUS_STORM_ALREADY_ENABLED */
5609 : : "The Storm was already enabled",
5610 : :
5611 : : /* DBG_STATUS_STORM_NOT_ENABLED */
5612 : : "The specified Storm wasn't enabled",
5613 : :
5614 : : /* DBG_STATUS_BLOCK_ALREADY_ENABLED */
5615 : : "The block was already enabled",
5616 : :
5617 : : /* DBG_STATUS_BLOCK_NOT_ENABLED */
5618 : : "The specified block wasn't enabled",
5619 : :
5620 : : /* DBG_STATUS_NO_INPUT_ENABLED */
5621 : : "No input was enabled for recording",
5622 : :
5623 : : /* DBG_STATUS_NO_FILTER_TRIGGER_256B */
5624 : : "Filters and triggers are not allowed in E4 256-bit mode",
5625 : :
5626 : : /* DBG_STATUS_FILTER_ALREADY_ENABLED */
5627 : : "The filter was already enabled",
5628 : :
5629 : : /* DBG_STATUS_TRIGGER_ALREADY_ENABLED */
5630 : : "The trigger was already enabled",
5631 : :
5632 : : /* DBG_STATUS_TRIGGER_NOT_ENABLED */
5633 : : "The trigger wasn't enabled",
5634 : :
5635 : : /* DBG_STATUS_CANT_ADD_CONSTRAINT */
5636 : : "A constraint can be added only after a filter was enabled or a trigger state was added",
5637 : :
5638 : : /* DBG_STATUS_TOO_MANY_TRIGGER_STATES */
5639 : : "Cannot add more than 3 trigger states",
5640 : :
5641 : : /* DBG_STATUS_TOO_MANY_CONSTRAINTS */
5642 : : "Cannot add more than 4 constraints per filter or trigger state",
5643 : :
5644 : : /* DBG_STATUS_RECORDING_NOT_STARTED */
5645 : : "The recording wasn't started",
5646 : :
5647 : : /* DBG_STATUS_DATA_DID_NOT_TRIGGER */
5648 : : "A trigger was configured, but it didn't trigger",
5649 : :
5650 : : /* DBG_STATUS_NO_DATA_RECORDED */
5651 : : "No data was recorded",
5652 : :
5653 : : /* DBG_STATUS_DUMP_BUF_TOO_SMALL */
5654 : : "Dump buffer is too small",
5655 : :
5656 : : /* DBG_STATUS_DUMP_NOT_CHUNK_ALIGNED */
5657 : : "Dumped data is not aligned to chunks",
5658 : :
5659 : : /* DBG_STATUS_UNKNOWN_CHIP */
5660 : : "Unknown chip",
5661 : :
5662 : : /* DBG_STATUS_VIRT_MEM_ALLOC_FAILED */
5663 : : "Failed allocating virtual memory",
5664 : :
5665 : : /* DBG_STATUS_BLOCK_IN_RESET */
5666 : : "The input block is in reset",
5667 : :
5668 : : /* DBG_STATUS_INVALID_TRACE_SIGNATURE */
5669 : : "Invalid MCP trace signature found in NVRAM",
5670 : :
5671 : : /* DBG_STATUS_INVALID_NVRAM_BUNDLE */
5672 : : "Invalid bundle ID found in NVRAM",
5673 : :
5674 : : /* DBG_STATUS_NVRAM_GET_IMAGE_FAILED */
5675 : : "Failed getting NVRAM image",
5676 : :
5677 : : /* DBG_STATUS_NON_ALIGNED_NVRAM_IMAGE */
5678 : : "NVRAM image is not dword-aligned",
5679 : :
5680 : : /* DBG_STATUS_NVRAM_READ_FAILED */
5681 : : "Failed reading from NVRAM",
5682 : :
5683 : : /* DBG_STATUS_IDLE_CHK_PARSE_FAILED */
5684 : : "Idle check parsing failed",
5685 : :
5686 : : /* DBG_STATUS_MCP_TRACE_BAD_DATA */
5687 : : "MCP Trace data is corrupt",
5688 : :
5689 : : /* DBG_STATUS_MCP_TRACE_NO_META */
5690 : : "Dump doesn't contain meta data - it must be provided in image file",
5691 : :
5692 : : /* DBG_STATUS_MCP_COULD_NOT_HALT */
5693 : : "Failed to halt MCP",
5694 : :
5695 : : /* DBG_STATUS_MCP_COULD_NOT_RESUME */
5696 : : "Failed to resume MCP after halt",
5697 : :
5698 : : /* DBG_STATUS_RESERVED0 */
5699 : : "",
5700 : :
5701 : : /* DBG_STATUS_SEMI_FIFO_NOT_EMPTY */
5702 : : "Failed to empty SEMI sync FIFO",
5703 : :
5704 : : /* DBG_STATUS_IGU_FIFO_BAD_DATA */
5705 : : "IGU FIFO data is corrupt",
5706 : :
5707 : : /* DBG_STATUS_MCP_COULD_NOT_MASK_PRTY */
5708 : : "MCP failed to mask parities",
5709 : :
5710 : : /* DBG_STATUS_FW_ASSERTS_PARSE_FAILED */
5711 : : "FW Asserts parsing failed",
5712 : :
5713 : : /* DBG_STATUS_REG_FIFO_BAD_DATA */
5714 : : "GRC FIFO data is corrupt",
5715 : :
5716 : : /* DBG_STATUS_PROTECTION_OVERRIDE_BAD_DATA */
5717 : : "Protection Override data is corrupt",
5718 : :
5719 : : /* DBG_STATUS_DBG_ARRAY_NOT_SET */
5720 : : "Debug arrays were not set (when using binary files, dbg_set_bin_ptr must be called)",
5721 : :
5722 : : /* DBG_STATUS_RESERVED1 */
5723 : : "",
5724 : :
5725 : : /* DBG_STATUS_NON_MATCHING_LINES */
5726 : : "Non-matching debug lines - in E4, all lines must be of the same type (either 128b or 256b)",
5727 : :
5728 : : /* DBG_STATUS_INSUFFICIENT_HW_IDS */
5729 : : "Insufficient HW IDs. Try to record less Storms/blocks",
5730 : :
5731 : : /* DBG_STATUS_DBG_BUS_IN_USE */
5732 : : "The debug bus is in use",
5733 : :
5734 : : /* DBG_STATUS_INVALID_STORM_DBG_MODE */
5735 : : "The storm debug mode is not supported in the current chip",
5736 : :
5737 : : /* DBG_STATUS_OTHER_ENGINE_BB_ONLY */
5738 : : "Other engine is supported only in BB",
5739 : :
5740 : : /* DBG_STATUS_FILTER_SINGLE_HW_ID */
5741 : : "The configured filter mode requires a single Storm/block input",
5742 : :
5743 : : /* DBG_STATUS_TRIGGER_SINGLE_HW_ID */
5744 : : "The configured filter mode requires that all the constraints of a single trigger state will be defined on a single Storm/block input",
5745 : :
5746 : : /* DBG_STATUS_MISSING_TRIGGER_STATE_STORM */
5747 : : "When triggering on Storm data, the Storm to trigger on must be specified"
5748 : : };
5749 : : static_assert(RTE_DIM(s_status_str) == MAX_DBG_STATUS, "status string table mismatch");
5750 : :
5751 : : /* Idle check severity names array */
5752 : : static const char * const s_idle_chk_severity_str[] = {
5753 : : "Error",
5754 : : "Error if no traffic",
5755 : : "Warning"
5756 : : };
5757 : :
5758 : : /* MCP Trace level names array */
5759 : : static const char * const s_mcp_trace_level_str[] = {
5760 : : "ERROR",
5761 : : "TRACE",
5762 : : "DEBUG"
5763 : : };
5764 : :
5765 : : /* Access type names array */
5766 : : static const char * const s_access_strs[] = {
5767 : : "read",
5768 : : "write"
5769 : : };
5770 : :
5771 : : /* Privilege type names array */
5772 : : static const char * const s_privilege_strs[] = {
5773 : : "VF",
5774 : : "PDA",
5775 : : "HV",
5776 : : "UA"
5777 : : };
5778 : :
5779 : : /* Protection type names array */
5780 : : static const char * const s_protection_strs[] = {
5781 : : "(default)",
5782 : : "(default)",
5783 : : "(default)",
5784 : : "(default)",
5785 : : "override VF",
5786 : : "override PDA",
5787 : : "override HV",
5788 : : "override UA"
5789 : : };
5790 : :
5791 : : /* Master type names array */
5792 : : static const char * const s_master_strs[] = {
5793 : : "???",
5794 : : "pxp",
5795 : : "mcp",
5796 : : "msdm",
5797 : : "psdm",
5798 : : "ysdm",
5799 : : "usdm",
5800 : : "tsdm",
5801 : : "xsdm",
5802 : : "dbu",
5803 : : "dmae",
5804 : : "jdap",
5805 : : "???",
5806 : : "???",
5807 : : "???",
5808 : : "???"
5809 : : };
5810 : :
5811 : : /* REG FIFO error messages array */
5812 : : static struct reg_fifo_err s_reg_fifo_errors[] = {
5813 : : {1, "grc timeout"},
5814 : : {2, "address doesn't belong to any block"},
5815 : : {4, "reserved address in block or write to read-only address"},
5816 : : {8, "privilege/protection mismatch"},
5817 : : {16, "path isolation error"},
5818 : : {17, "RSL error"}
5819 : : };
5820 : :
5821 : : /* IGU FIFO sources array */
5822 : : static const char * const s_igu_fifo_source_strs[] = {
5823 : : "TSTORM",
5824 : : "MSTORM",
5825 : : "USTORM",
5826 : : "XSTORM",
5827 : : "YSTORM",
5828 : : "PSTORM",
5829 : : "PCIE",
5830 : : "NIG_QM_PBF",
5831 : : "CAU",
5832 : : "ATTN",
5833 : : "GRC",
5834 : : };
5835 : :
5836 : : /* IGU FIFO error messages */
5837 : : static const char * const s_igu_fifo_error_strs[] = {
5838 : : "no error",
5839 : : "length error",
5840 : : "function disabled",
5841 : : "VF sent command to attention address",
5842 : : "host sent prod update command",
5843 : : "read of during interrupt register while in MIMD mode",
5844 : : "access to PXP BAR reserved address",
5845 : : "producer update command to attention index",
5846 : : "unknown error",
5847 : : "SB index not valid",
5848 : : "SB relative index and FID not found",
5849 : : "FID not match",
5850 : : "command with error flag asserted (PCI error or CAU discard)",
5851 : : "VF sent cleanup and RF cleanup is disabled",
5852 : : "cleanup command on type bigger than 4"
5853 : : };
5854 : :
5855 : : /* IGU FIFO address data */
5856 : : static const struct igu_fifo_addr_data s_igu_fifo_addr_data[] = {
5857 : : {0x0, 0x101, "MSI-X Memory", NULL,
5858 : : IGU_ADDR_TYPE_MSIX_MEM},
5859 : : {0x102, 0x1ff, "reserved", NULL,
5860 : : IGU_ADDR_TYPE_RESERVED},
5861 : : {0x200, 0x200, "Write PBA[0:63]", NULL,
5862 : : IGU_ADDR_TYPE_WRITE_PBA},
5863 : : {0x201, 0x201, "Write PBA[64:127]", "reserved",
5864 : : IGU_ADDR_TYPE_WRITE_PBA},
5865 : : {0x202, 0x202, "Write PBA[128]", "reserved",
5866 : : IGU_ADDR_TYPE_WRITE_PBA},
5867 : : {0x203, 0x3ff, "reserved", NULL,
5868 : : IGU_ADDR_TYPE_RESERVED},
5869 : : {0x400, 0x5ef, "Write interrupt acknowledgment", NULL,
5870 : : IGU_ADDR_TYPE_WRITE_INT_ACK},
5871 : : {0x5f0, 0x5f0, "Attention bits update", NULL,
5872 : : IGU_ADDR_TYPE_WRITE_ATTN_BITS},
5873 : : {0x5f1, 0x5f1, "Attention bits set", NULL,
5874 : : IGU_ADDR_TYPE_WRITE_ATTN_BITS},
5875 : : {0x5f2, 0x5f2, "Attention bits clear", NULL,
5876 : : IGU_ADDR_TYPE_WRITE_ATTN_BITS},
5877 : : {0x5f3, 0x5f3, "Read interrupt 0:63 with mask", NULL,
5878 : : IGU_ADDR_TYPE_READ_INT},
5879 : : {0x5f4, 0x5f4, "Read interrupt 0:31 with mask", NULL,
5880 : : IGU_ADDR_TYPE_READ_INT},
5881 : : {0x5f5, 0x5f5, "Read interrupt 32:63 with mask", NULL,
5882 : : IGU_ADDR_TYPE_READ_INT},
5883 : : {0x5f6, 0x5f6, "Read interrupt 0:63 without mask", NULL,
5884 : : IGU_ADDR_TYPE_READ_INT},
5885 : : {0x5f7, 0x5ff, "reserved", NULL,
5886 : : IGU_ADDR_TYPE_RESERVED},
5887 : : {0x600, 0x7ff, "Producer update", NULL,
5888 : : IGU_ADDR_TYPE_WRITE_PROD_UPDATE}
5889 : : };
5890 : :
5891 : : /******************************** Variables **********************************/
5892 : :
5893 : : /* Temporary buffer, used for print size calculations */
5894 : : static char s_temp_buf[MAX_MSG_LEN];
5895 : :
5896 : : /**************************** Private Functions ******************************/
5897 : :
5898 : : static u32 qed_cyclic_add(u32 a, u32 b, u32 size)
5899 : : {
5900 : 0 : return (a + b) % size;
5901 : : }
5902 : :
5903 : : static u32 qed_cyclic_sub(u32 a, u32 b, u32 size)
5904 : : {
5905 : 0 : return (size + a - b) % size;
5906 : : }
5907 : :
5908 : : /* Reads the specified number of bytes from the specified cyclic buffer (up to 4
5909 : : * bytes) and returns them as a dword value. the specified buffer offset is
5910 : : * updated.
5911 : : */
5912 : : static u32 qed_read_from_cyclic_buf(void *buf,
5913 : : u32 *offset,
5914 : : u32 buf_size, u8 num_bytes_to_read)
5915 : : {
5916 : : u8 i, *val_ptr, *bytes_buf = (u8 *)buf;
5917 : 0 : u32 val = 0;
5918 : :
5919 : : val_ptr = (u8 *)&val;
5920 : :
5921 : : /* Assume running on a LITTLE ENDIAN and the buffer is network order
5922 : : * (BIG ENDIAN), as high order bytes are placed in lower memory address.
5923 : : */
5924 [ # # # # ]: 0 : for (i = 0; i < num_bytes_to_read; i++) {
5925 : 0 : val_ptr[i] = bytes_buf[*offset];
5926 : : *offset = qed_cyclic_add(*offset, 1, buf_size);
5927 : : }
5928 : :
5929 : 0 : return val;
5930 : : }
5931 : :
5932 : : /* Reads and returns the next byte from the specified buffer.
5933 : : * The specified buffer offset is updated.
5934 : : */
5935 : : static u8 qed_read_byte_from_buf(void *buf, u32 *offset)
5936 : : {
5937 : 0 : return ((u8 *)buf)[(*offset)++];
5938 : : }
5939 : :
5940 : : /* Reads and returns the next dword from the specified buffer.
5941 : : * The specified buffer offset is updated.
5942 : : */
5943 : : static u32 qed_read_dword_from_buf(void *buf, u32 *offset)
5944 : : {
5945 : 0 : u32 dword_val = *(u32 *)&((u8 *)buf)[*offset];
5946 : :
5947 : 0 : *offset += 4;
5948 : :
5949 : : return dword_val;
5950 : : }
5951 : :
5952 : : /* Reads the next string from the specified buffer, and copies it to the
5953 : : * specified pointer. The specified buffer offset is updated.
5954 : : */
5955 : : static void qed_read_str_from_buf(void *buf, u32 *offset, u32 size, char *dest)
5956 : : {
5957 : 0 : const char *source_str = &((const char *)buf)[*offset];
5958 : :
5959 : 0 : OSAL_STRNCPY(dest, source_str, size);
5960 : 0 : dest[size - 1] = '\0';
5961 : 0 : *offset += size;
5962 : : }
5963 : :
5964 : : /* Returns a pointer to the specified offset (in bytes) of the specified buffer.
5965 : : * If the specified buffer in NULL, a temporary buffer pointer is returned.
5966 : : */
5967 : : static char *qed_get_buf_ptr(void *buf, u32 offset)
5968 : : {
5969 [ # # # # : 0 : return buf ? (char *)buf + offset : s_temp_buf;
# # # # #
# # # #
# ]
5970 : : }
5971 : :
5972 : : /* Reads a param from the specified buffer. Returns the number of dwords read.
5973 : : * If the returned str_param is NULL, the param is numeric and its value is
5974 : : * returned in num_param.
5975 : : * Otherwise, the param is a string and its pointer is returned in str_param.
5976 : : */
5977 : 0 : static u32 qed_read_param(u32 *dump_buf,
5978 : : const char **param_name,
5979 : : const char **param_str_val, u32 *param_num_val)
5980 : : {
5981 : : char *char_buf = (char *)dump_buf;
5982 : : size_t offset = 0;
5983 : :
5984 : : /* Extract param name */
5985 : 0 : *param_name = char_buf;
5986 : 0 : offset += strlen(*param_name) + 1;
5987 : :
5988 : : /* Check param type */
5989 [ # # ]: 0 : if (*(char_buf + offset++)) {
5990 : : /* String param */
5991 : 0 : *param_str_val = char_buf + offset;
5992 : 0 : *param_num_val = 0;
5993 : 0 : offset += strlen(*param_str_val) + 1;
5994 [ # # ]: 0 : if (offset & 0x3)
5995 : 0 : offset += (4 - (offset & 0x3));
5996 : : } else {
5997 : : /* Numeric param */
5998 : 0 : *param_str_val = NULL;
5999 [ # # ]: 0 : if (offset & 0x3)
6000 : 0 : offset += (4 - (offset & 0x3));
6001 : 0 : *param_num_val = *(u32 *)(char_buf + offset);
6002 : 0 : offset += 4;
6003 : : }
6004 : :
6005 : 0 : return (u32)offset / 4;
6006 : : }
6007 : :
6008 : : /* Reads a section header from the specified buffer.
6009 : : * Returns the number of dwords read.
6010 : : */
6011 : : static u32 qed_read_section_hdr(u32 *dump_buf,
6012 : : const char **section_name,
6013 : : u32 *num_section_params)
6014 : : {
6015 : : const char *param_str_val;
6016 : :
6017 : 0 : return qed_read_param(dump_buf,
6018 : : section_name, ¶m_str_val, num_section_params);
6019 : : }
6020 : :
6021 : : /* Reads section params from the specified buffer and prints them to the results
6022 : : * buffer. Returns the number of dwords read.
6023 : : */
6024 : 0 : static u32 qed_print_section_params(u32 *dump_buf,
6025 : : u32 num_section_params,
6026 : : char *results_buf, u32 *num_chars_printed)
6027 : : {
6028 : : u32 i, dump_offset = 0, results_offset = 0;
6029 : :
6030 [ # # ]: 0 : for (i = 0; i < num_section_params; i++) {
6031 : : const char *param_name, *param_str_val;
6032 : 0 : u32 param_num_val = 0;
6033 : :
6034 : 0 : dump_offset += qed_read_param(dump_buf + dump_offset,
6035 : : ¶m_name,
6036 : : ¶m_str_val, ¶m_num_val);
6037 : :
6038 [ # # ]: 0 : if (param_str_val) {
6039 : 0 : results_offset +=
6040 [ # # ]: 0 : sprintf(qed_get_buf_ptr(results_buf,
6041 : : results_offset),
6042 : : "%s: %s\n", param_name, param_str_val);
6043 [ # # ]: 0 : } else if (strcmp(param_name, "fw-timestamp")) {
6044 : 0 : results_offset +=
6045 [ # # ]: 0 : sprintf(qed_get_buf_ptr(results_buf,
6046 : : results_offset),
6047 : : "%s: %d\n", param_name, param_num_val);
6048 : : }
6049 : : }
6050 : :
6051 : 0 : results_offset += sprintf(qed_get_buf_ptr(results_buf, results_offset),
6052 : : "\n");
6053 : :
6054 : 0 : *num_chars_printed = results_offset;
6055 : :
6056 : 0 : return dump_offset;
6057 : : }
6058 : :
6059 : : /* Returns the block name that matches the specified block ID,
6060 : : * or NULL if not found.
6061 : : */
6062 : : static const char *qed_dbg_get_block_name(struct ecore_hwfn *p_hwfn,
6063 : : enum block_id block_id)
6064 : : {
6065 : 0 : const struct dbg_block_user *block =
6066 : : (const struct dbg_block_user *)
6067 : 0 : p_hwfn->dbg_arrays[BIN_BUF_DBG_BLOCKS_USER_DATA].ptr + block_id;
6068 : :
6069 : 0 : return (const char *)block->name;
6070 : : }
6071 : :
6072 : : static struct dbg_tools_user_data *qed_dbg_get_user_data(struct ecore_hwfn
6073 : : *p_hwfn)
6074 : : {
6075 : 0 : return (struct dbg_tools_user_data *)p_hwfn->dbg_user_info;
6076 : : }
6077 : :
6078 : : /* Parses the idle check rules and returns the number of characters printed.
6079 : : * In case of parsing error, returns 0.
6080 : : */
6081 : 0 : static u32 qed_parse_idle_chk_dump_rules(struct ecore_hwfn *p_hwfn,
6082 : : u32 *dump_buf,
6083 : : u32 *dump_buf_end,
6084 : : u32 num_rules,
6085 : : bool print_fw_idle_chk,
6086 : : char *results_buf,
6087 : : u32 *num_errors, u32 *num_warnings)
6088 : : {
6089 : : /* Offset in results_buf in bytes */
6090 : : u32 results_offset = 0;
6091 : :
6092 : : u32 rule_idx;
6093 : : u16 i, j;
6094 : :
6095 : 0 : *num_errors = 0;
6096 : 0 : *num_warnings = 0;
6097 : :
6098 : : /* Go over dumped results */
6099 [ # # ]: 0 : for (rule_idx = 0; rule_idx < num_rules && dump_buf < dump_buf_end;
6100 : 0 : rule_idx++) {
6101 : : const struct dbg_idle_chk_rule_parsing_data *rule_parsing_data;
6102 : : struct dbg_idle_chk_result_hdr *hdr;
6103 : : const char *parsing_str, *lsi_msg;
6104 : : u32 parsing_str_offset;
6105 : : bool has_fw_msg;
6106 : : u8 curr_reg_id;
6107 : :
6108 : : hdr = (struct dbg_idle_chk_result_hdr *)dump_buf;
6109 : 0 : rule_parsing_data =
6110 : : (const struct dbg_idle_chk_rule_parsing_data *)
6111 : 0 : p_hwfn->dbg_arrays[BIN_BUF_DBG_IDLE_CHK_PARSING_DATA].ptr +
6112 : 0 : hdr->rule_id;
6113 : 0 : parsing_str_offset =
6114 : 0 : GET_FIELD(rule_parsing_data->data,
6115 : : DBG_IDLE_CHK_RULE_PARSING_DATA_STR_OFFSET);
6116 : 0 : has_fw_msg =
6117 : 0 : GET_FIELD(rule_parsing_data->data,
6118 : : DBG_IDLE_CHK_RULE_PARSING_DATA_HAS_FW_MSG) > 0;
6119 : 0 : parsing_str = (const char *)
6120 : 0 : p_hwfn->dbg_arrays[BIN_BUF_DBG_PARSING_STRINGS].ptr +
6121 : : parsing_str_offset;
6122 : : lsi_msg = parsing_str;
6123 : : curr_reg_id = 0;
6124 : :
6125 [ # # ]: 0 : if (hdr->severity >= MAX_DBG_IDLE_CHK_SEVERITY_TYPES)
6126 : : return 0;
6127 : :
6128 : : /* Skip rule header */
6129 : 0 : dump_buf += BYTES_TO_DWORDS(sizeof(*hdr));
6130 : :
6131 : : /* Update errors/warnings count */
6132 [ # # ]: 0 : if (hdr->severity == IDLE_CHK_SEVERITY_ERROR ||
6133 : : hdr->severity == IDLE_CHK_SEVERITY_ERROR_NO_TRAFFIC)
6134 : 0 : (*num_errors)++;
6135 : : else
6136 : 0 : (*num_warnings)++;
6137 : :
6138 : : /* Print rule severity */
6139 : 0 : results_offset +=
6140 : 0 : sprintf(qed_get_buf_ptr(results_buf,
6141 : : results_offset), "%s: ",
6142 [ # # ]: 0 : s_idle_chk_severity_str[hdr->severity]);
6143 : :
6144 : : /* Print rule message */
6145 [ # # ]: 0 : if (has_fw_msg)
6146 : 0 : parsing_str += strlen(parsing_str) + 1;
6147 : 0 : results_offset +=
6148 : 0 : sprintf(qed_get_buf_ptr(results_buf,
6149 : : results_offset), "%s.",
6150 [ # # ]: 0 : has_fw_msg &&
6151 : : print_fw_idle_chk ? parsing_str : lsi_msg);
6152 [ # # ]: 0 : parsing_str += strlen(parsing_str) + 1;
6153 : :
6154 : : /* Print register values */
6155 : 0 : results_offset +=
6156 : 0 : sprintf(qed_get_buf_ptr(results_buf,
6157 : : results_offset), " Registers:");
6158 : 0 : for (i = 0;
6159 [ # # ]: 0 : i < hdr->num_dumped_cond_regs + hdr->num_dumped_info_regs;
6160 : 0 : i++) {
6161 : : struct dbg_idle_chk_result_reg_hdr *reg_hdr;
6162 : : bool is_mem;
6163 : : u8 reg_id;
6164 : :
6165 : : reg_hdr =
6166 : : (struct dbg_idle_chk_result_reg_hdr *)dump_buf;
6167 : 0 : is_mem = GET_FIELD(reg_hdr->data,
6168 : : DBG_IDLE_CHK_RESULT_REG_HDR_IS_MEM);
6169 : 0 : reg_id = GET_FIELD(reg_hdr->data,
6170 : : DBG_IDLE_CHK_RESULT_REG_HDR_REG_ID);
6171 : :
6172 : : /* Skip reg header */
6173 : 0 : dump_buf += BYTES_TO_DWORDS(sizeof(*reg_hdr));
6174 : :
6175 : : /* Skip register names until the required reg_id is
6176 : : * reached.
6177 : : */
6178 [ # # ]: 0 : while (reg_id > curr_reg_id) {
6179 : 0 : curr_reg_id++;
6180 : 0 : parsing_str += strlen(parsing_str) + 1;
6181 : : }
6182 : :
6183 : 0 : results_offset +=
6184 : 0 : sprintf(qed_get_buf_ptr(results_buf,
6185 : : results_offset), " %s",
6186 : : parsing_str);
6187 [ # # # # ]: 0 : if (i < hdr->num_dumped_cond_regs && is_mem)
6188 : 0 : results_offset +=
6189 : 0 : sprintf(qed_get_buf_ptr(results_buf,
6190 : : results_offset),
6191 : 0 : "[%d]", hdr->mem_entry_id +
6192 [ # # ]: 0 : reg_hdr->start_entry);
6193 : 0 : results_offset +=
6194 : 0 : sprintf(qed_get_buf_ptr(results_buf,
6195 : : results_offset), "=");
6196 [ # # ]: 0 : for (j = 0; j < reg_hdr->size; j++, dump_buf++) {
6197 : 0 : results_offset +=
6198 [ # # ]: 0 : sprintf(qed_get_buf_ptr(results_buf,
6199 : : results_offset),
6200 : : "0x%x", *dump_buf);
6201 [ # # ]: 0 : if (j < reg_hdr->size - 1)
6202 : 0 : results_offset +=
6203 : 0 : sprintf(qed_get_buf_ptr
6204 : : (results_buf,
6205 : : results_offset), ",");
6206 : : }
6207 : : }
6208 : :
6209 : 0 : results_offset +=
6210 : 0 : sprintf(qed_get_buf_ptr(results_buf, results_offset), "\n");
6211 : : }
6212 : :
6213 : : /* Check if end of dump buffer was exceeded */
6214 [ # # ]: 0 : if (dump_buf > dump_buf_end)
6215 : 0 : return 0;
6216 : :
6217 : : return results_offset;
6218 : : }
6219 : :
6220 : : /* Parses an idle check dump buffer.
6221 : : * If result_buf is not NULL, the idle check results are printed to it.
6222 : : * In any case, the required results buffer size is assigned to
6223 : : * parsed_results_bytes.
6224 : : * The parsing status is returned.
6225 : : */
6226 : 0 : static enum dbg_status qed_parse_idle_chk_dump(struct ecore_hwfn *p_hwfn,
6227 : : u32 *dump_buf,
6228 : : u32 num_dumped_dwords,
6229 : : char *results_buf,
6230 : : u32 *parsed_results_bytes,
6231 : : u32 *num_errors,
6232 : : u32 *num_warnings)
6233 : : {
6234 : : const char *section_name, *param_name, *param_str_val;
6235 : 0 : u32 *dump_buf_end = dump_buf + num_dumped_dwords;
6236 : 0 : u32 num_section_params = 0, num_rules;
6237 : :
6238 : : /* Offset in results_buf in bytes */
6239 : 0 : u32 results_offset = 0;
6240 : :
6241 : 0 : *parsed_results_bytes = 0;
6242 : 0 : *num_errors = 0;
6243 : 0 : *num_warnings = 0;
6244 : :
6245 [ # # ]: 0 : if (!p_hwfn->dbg_arrays[BIN_BUF_DBG_PARSING_STRINGS].ptr ||
6246 [ # # ]: 0 : !p_hwfn->dbg_arrays[BIN_BUF_DBG_IDLE_CHK_PARSING_DATA].ptr)
6247 : : return DBG_STATUS_DBG_ARRAY_NOT_SET;
6248 : :
6249 : : /* Read global_params section */
6250 : 0 : dump_buf += qed_read_section_hdr(dump_buf,
6251 : : §ion_name, &num_section_params);
6252 [ # # ]: 0 : if (strcmp(section_name, "global_params"))
6253 : : return DBG_STATUS_IDLE_CHK_PARSE_FAILED;
6254 : :
6255 : : /* Print global params */
6256 : 0 : dump_buf += qed_print_section_params(dump_buf,
6257 : : num_section_params,
6258 : : results_buf, &results_offset);
6259 : :
6260 : : /* Read idle_chk section */
6261 : 0 : dump_buf += qed_read_section_hdr(dump_buf,
6262 : : §ion_name, &num_section_params);
6263 [ # # # # ]: 0 : if (strcmp(section_name, "idle_chk") || num_section_params != 1)
6264 : : return DBG_STATUS_IDLE_CHK_PARSE_FAILED;
6265 : 0 : dump_buf += qed_read_param(dump_buf,
6266 : : ¶m_name, ¶m_str_val, &num_rules);
6267 [ # # ]: 0 : if (strcmp(param_name, "num_rules"))
6268 : : return DBG_STATUS_IDLE_CHK_PARSE_FAILED;
6269 : :
6270 [ # # ]: 0 : if (num_rules) {
6271 : : u32 rules_print_size;
6272 : :
6273 : : /* Print FW output */
6274 : 0 : results_offset +=
6275 [ # # ]: 0 : sprintf(qed_get_buf_ptr(results_buf,
6276 : : results_offset),
6277 : : "FW_IDLE_CHECK:\n");
6278 : : rules_print_size =
6279 [ # # ]: 0 : qed_parse_idle_chk_dump_rules(p_hwfn,
6280 : : dump_buf,
6281 : : dump_buf_end,
6282 : : num_rules,
6283 : : true,
6284 : : results_buf ?
6285 : 0 : results_buf +
6286 : : results_offset :
6287 : : NULL,
6288 : : num_errors,
6289 : : num_warnings);
6290 : 0 : results_offset += rules_print_size;
6291 [ # # ]: 0 : if (!rules_print_size)
6292 : : return DBG_STATUS_IDLE_CHK_PARSE_FAILED;
6293 : :
6294 : : /* Print LSI output */
6295 : 0 : results_offset +=
6296 : 0 : sprintf(qed_get_buf_ptr(results_buf,
6297 : : results_offset),
6298 : : "\nLSI_IDLE_CHECK:\n");
6299 : : rules_print_size =
6300 [ # # ]: 0 : qed_parse_idle_chk_dump_rules(p_hwfn,
6301 : : dump_buf,
6302 : : dump_buf_end,
6303 : : num_rules,
6304 : : false,
6305 : : results_buf ?
6306 : 0 : results_buf +
6307 : : results_offset :
6308 : : NULL,
6309 : : num_errors,
6310 : : num_warnings);
6311 : 0 : results_offset += rules_print_size;
6312 [ # # ]: 0 : if (!rules_print_size)
6313 : : return DBG_STATUS_IDLE_CHK_PARSE_FAILED;
6314 : : }
6315 : :
6316 : : /* Print errors/warnings count */
6317 [ # # ]: 0 : if (*num_errors)
6318 : 0 : results_offset +=
6319 [ # # ]: 0 : sprintf(qed_get_buf_ptr(results_buf,
6320 : : results_offset),
6321 : : "\nIdle Check failed!!! (with %d errors and %d warnings)\n",
6322 : : *num_errors, *num_warnings);
6323 [ # # ]: 0 : else if (*num_warnings)
6324 : 0 : results_offset +=
6325 [ # # ]: 0 : sprintf(qed_get_buf_ptr(results_buf,
6326 : : results_offset),
6327 : : "\nIdle Check completed successfully (with %d warnings)\n",
6328 : : *num_warnings);
6329 : : else
6330 : 0 : results_offset +=
6331 [ # # ]: 0 : sprintf(qed_get_buf_ptr(results_buf,
6332 : : results_offset),
6333 : : "\nIdle Check completed successfully\n");
6334 : :
6335 : : /* Add 1 for string NULL termination */
6336 : 0 : *parsed_results_bytes = results_offset + 1;
6337 : :
6338 : 0 : return DBG_STATUS_OK;
6339 : : }
6340 : :
6341 : : /* Allocates and fills MCP Trace meta data based on the specified meta data
6342 : : * dump buffer.
6343 : : * Returns debug status code.
6344 : : */
6345 : : static enum dbg_status
6346 : 0 : qed_mcp_trace_alloc_meta_data(struct ecore_hwfn *p_hwfn,
6347 : : const u32 *meta_buf)
6348 : : {
6349 : : struct dbg_tools_user_data *dev_user_data;
6350 : : u32 offset = 0, signature, i;
6351 : : struct mcp_trace_meta *meta;
6352 : : u8 *meta_buf_bytes = (u8 *)(osal_uintptr_t)meta_buf;
6353 : :
6354 : : dev_user_data = qed_dbg_get_user_data(p_hwfn);
6355 : 0 : meta = &dev_user_data->mcp_trace_meta;
6356 : :
6357 : : /* Free the previous meta before loading a new one. */
6358 [ # # ]: 0 : if (meta->is_allocated)
6359 : 0 : qed_mcp_trace_free_meta_data(p_hwfn);
6360 : :
6361 : : OSAL_MEMSET(meta, 0, sizeof(*meta));
6362 : :
6363 : : /* Read first signature */
6364 : : signature = qed_read_dword_from_buf(meta_buf_bytes, &offset);
6365 [ # # ]: 0 : if (signature != NVM_MAGIC_VALUE)
6366 : : return DBG_STATUS_INVALID_TRACE_SIGNATURE;
6367 : :
6368 : : /* Read no. of modules and allocate memory for their pointers */
6369 : 0 : meta->modules_num = qed_read_byte_from_buf(meta_buf_bytes, &offset);
6370 : 0 : meta->modules = (char **)OSAL_ZALLOC(p_hwfn->p_dev, GFP_KERNEL,
6371 : : meta->modules_num * sizeof(char *));
6372 [ # # ]: 0 : if (!meta->modules)
6373 : : return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
6374 : :
6375 : : /* Allocate and read all module strings */
6376 [ # # ]: 0 : for (i = 0; i < meta->modules_num; i++) {
6377 : : u8 module_len = qed_read_byte_from_buf(meta_buf_bytes, &offset);
6378 : :
6379 : 0 : *(meta->modules + i) = (char *)OSAL_ZALLOC(p_hwfn->p_dev,
6380 : : GFP_KERNEL,
6381 : : module_len);
6382 [ # # ]: 0 : if (!(*(meta->modules + i))) {
6383 : : /* Update number of modules to be released */
6384 [ # # ]: 0 : meta->modules_num = i ? i - 1 : 0;
6385 : 0 : return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
6386 : : }
6387 : :
6388 [ # # ]: 0 : qed_read_str_from_buf(meta_buf_bytes, &offset, module_len,
6389 : : *(meta->modules + i));
6390 [ # # ]: 0 : if (module_len > MCP_TRACE_MAX_MODULE_LEN)
6391 : 0 : (*(meta->modules + i))[MCP_TRACE_MAX_MODULE_LEN] = '\0';
6392 : : }
6393 : :
6394 : : /* Read second signature */
6395 : : signature = qed_read_dword_from_buf(meta_buf_bytes, &offset);
6396 [ # # ]: 0 : if (signature != NVM_MAGIC_VALUE)
6397 : : return DBG_STATUS_INVALID_TRACE_SIGNATURE;
6398 : :
6399 : : /* Read number of formats and allocate memory for all formats */
6400 : 0 : meta->formats_num = qed_read_dword_from_buf(meta_buf_bytes, &offset);
6401 : 0 : meta->formats =
6402 : 0 : (struct mcp_trace_format *)OSAL_ZALLOC(p_hwfn->p_dev,
6403 : : GFP_KERNEL,
6404 : : meta->formats_num *
6405 : : sizeof(struct mcp_trace_format));
6406 [ # # ]: 0 : if (!meta->formats)
6407 : : return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
6408 : :
6409 : : /* Allocate and read all strings */
6410 [ # # ]: 0 : for (i = 0; i < meta->formats_num; i++) {
6411 : 0 : struct mcp_trace_format *format_ptr = &meta->formats[i];
6412 : : u8 format_len;
6413 : :
6414 : 0 : format_ptr->data = qed_read_dword_from_buf(meta_buf_bytes,
6415 : : &offset);
6416 : 0 : format_len = GET_MFW_FIELD(format_ptr->data,
6417 : : MCP_TRACE_FORMAT_LEN);
6418 : 0 : format_ptr->format_str = (char *)OSAL_ZALLOC(p_hwfn->p_dev,
6419 : : GFP_KERNEL,
6420 : : format_len);
6421 [ # # ]: 0 : if (!format_ptr->format_str) {
6422 : : /* Update number of modules to be released */
6423 [ # # ]: 0 : meta->formats_num = i ? i - 1 : 0;
6424 : 0 : return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
6425 : : }
6426 : :
6427 : : qed_read_str_from_buf(meta_buf_bytes,
6428 : : &offset,
6429 : : format_len, format_ptr->format_str);
6430 : : }
6431 : :
6432 : 0 : meta->is_allocated = true;
6433 : 0 : return DBG_STATUS_OK;
6434 : : }
6435 : :
6436 : : /* Parses an MCP trace buffer. If result_buf is not NULL, the MCP Trace results
6437 : : * are printed to it. The parsing status is returned.
6438 : : * Arguments:
6439 : : * trace_buf - MCP trace cyclic buffer
6440 : : * trace_buf_size - MCP trace cyclic buffer size in bytes
6441 : : * data_offset - offset in bytes of the data to parse in the MCP trace cyclic
6442 : : * buffer.
6443 : : * data_size - size in bytes of data to parse.
6444 : : * parsed_buf - destination buffer for parsed data.
6445 : : * parsed_results_bytes - size of parsed data in bytes.
6446 : : */
6447 : 0 : static enum dbg_status qed_parse_mcp_trace_buf(struct ecore_hwfn *p_hwfn,
6448 : : u8 *trace_buf,
6449 : : u32 trace_buf_size,
6450 : : u32 data_offset,
6451 : : u32 data_size,
6452 : : char *parsed_buf,
6453 : : u32 *parsed_results_bytes)
6454 : : {
6455 : : struct dbg_tools_user_data *dev_user_data;
6456 : : struct mcp_trace_meta *meta;
6457 : : u32 param_mask, param_shift;
6458 : : enum dbg_status status;
6459 : :
6460 : : dev_user_data = qed_dbg_get_user_data(p_hwfn);
6461 : : meta = &dev_user_data->mcp_trace_meta;
6462 : 0 : *parsed_results_bytes = 0;
6463 : :
6464 [ # # ]: 0 : if (!meta->is_allocated)
6465 : : return DBG_STATUS_MCP_TRACE_BAD_DATA;
6466 : :
6467 : : status = DBG_STATUS_OK;
6468 : :
6469 [ # # ]: 0 : while (data_size) {
6470 : : struct mcp_trace_format *format_ptr;
6471 : : u8 format_level, format_module;
6472 : 0 : u32 params[3] = { 0, 0, 0 };
6473 : : u32 header, format_idx, i;
6474 : :
6475 [ # # ]: 0 : if (data_size < MFW_TRACE_ENTRY_SIZE)
6476 : 0 : return DBG_STATUS_MCP_TRACE_BAD_DATA;
6477 : :
6478 : : header = qed_read_from_cyclic_buf(trace_buf,
6479 : : &data_offset,
6480 : : trace_buf_size,
6481 : : MFW_TRACE_ENTRY_SIZE);
6482 : 0 : data_size -= MFW_TRACE_ENTRY_SIZE;
6483 : 0 : format_idx = header & MFW_TRACE_EVENTID_MASK;
6484 : :
6485 : : /* Skip message if its index doesn't exist in the meta data */
6486 [ # # ]: 0 : if (format_idx >= meta->formats_num) {
6487 : 0 : u8 format_size = (u8)GET_MFW_FIELD(header,
6488 : : MFW_TRACE_PRM_SIZE);
6489 : :
6490 [ # # ]: 0 : if (data_size < format_size)
6491 : : return DBG_STATUS_MCP_TRACE_BAD_DATA;
6492 : :
6493 : : data_offset = qed_cyclic_add(data_offset,
6494 : : format_size,
6495 : : trace_buf_size);
6496 : 0 : data_size -= format_size;
6497 : 0 : continue;
6498 : : }
6499 : :
6500 : 0 : format_ptr =
6501 : 0 : (struct mcp_trace_format *)&meta->formats[format_idx];
6502 : :
6503 : 0 : for (i = 0,
6504 : : param_mask = MCP_TRACE_FORMAT_P1_SIZE_MASK, param_shift =
6505 : : MCP_TRACE_FORMAT_P1_SIZE_OFFSET;
6506 [ # # ]: 0 : i < MCP_TRACE_FORMAT_MAX_PARAMS;
6507 : 0 : i++, param_mask <<= MCP_TRACE_FORMAT_PARAM_WIDTH,
6508 : 0 : param_shift += MCP_TRACE_FORMAT_PARAM_WIDTH) {
6509 : : /* Extract param size (0..3) */
6510 : 0 : u8 param_size = (u8)((format_ptr->data & param_mask) >>
6511 : : param_shift);
6512 : :
6513 : : /* If the param size is zero, there are no other
6514 : : * parameters.
6515 : : */
6516 [ # # ]: 0 : if (!param_size)
6517 : : break;
6518 : :
6519 : : /* Size is encoded using 2 bits, where 3 is used to
6520 : : * encode 4.
6521 : : */
6522 [ # # ]: 0 : if (param_size == 3)
6523 : : param_size = 4;
6524 : :
6525 [ # # ]: 0 : if (data_size < param_size)
6526 : : return DBG_STATUS_MCP_TRACE_BAD_DATA;
6527 : :
6528 : 0 : params[i] = qed_read_from_cyclic_buf(trace_buf,
6529 : : &data_offset,
6530 : : trace_buf_size,
6531 : : param_size);
6532 : 0 : data_size -= param_size;
6533 : : }
6534 : :
6535 : 0 : format_level = (u8)GET_MFW_FIELD(format_ptr->data,
6536 : : MCP_TRACE_FORMAT_LEVEL);
6537 : 0 : format_module = (u8)GET_MFW_FIELD(format_ptr->data,
6538 : : MCP_TRACE_FORMAT_MODULE);
6539 [ # # ]: 0 : if (format_level >= OSAL_ARRAY_SIZE(s_mcp_trace_level_str))
6540 : : return DBG_STATUS_MCP_TRACE_BAD_DATA;
6541 : :
6542 : : /* Print current message to results buffer */
6543 : 0 : *parsed_results_bytes +=
6544 [ # # ]: 0 : OSAL_SPRINTF(qed_get_buf_ptr(parsed_buf,
6545 : : *parsed_results_bytes),
6546 : : "%s %-8s: ",
6547 : : s_mcp_trace_level_str[format_level],
6548 : : meta->modules[format_module]);
6549 : 0 : *parsed_results_bytes +=
6550 : 0 : sprintf(qed_get_buf_ptr(parsed_buf, *parsed_results_bytes),
6551 [ # # ]: 0 : format_ptr->format_str,
6552 : : params[0], params[1], params[2]);
6553 : : }
6554 : :
6555 : : /* Add string NULL terminator */
6556 : 0 : (*parsed_results_bytes)++;
6557 : :
6558 : 0 : return status;
6559 : : }
6560 : :
6561 : : /* Parses an MCP Trace dump buffer.
6562 : : * If result_buf is not NULL, the MCP Trace results are printed to it.
6563 : : * In any case, the required results buffer size is assigned to
6564 : : * parsed_results_bytes.
6565 : : * The parsing status is returned.
6566 : : */
6567 : 0 : static enum dbg_status qed_parse_mcp_trace_dump(struct ecore_hwfn *p_hwfn,
6568 : : u32 *dump_buf,
6569 : : char *results_buf,
6570 : : u32 *parsed_results_bytes,
6571 : : bool free_meta_data)
6572 : : {
6573 : : const char *section_name, *param_name, *param_str_val;
6574 : : u32 data_size, trace_data_dwords, trace_meta_dwords;
6575 : : u32 offset, results_offset, results_buf_bytes;
6576 : : u32 param_num_val, num_section_params;
6577 : : struct mcp_trace *trace;
6578 : : enum dbg_status status;
6579 : : const u32 *meta_buf;
6580 : : u8 *trace_buf;
6581 : :
6582 : 0 : *parsed_results_bytes = 0;
6583 : :
6584 : : /* Read global_params section */
6585 : 0 : dump_buf += qed_read_section_hdr(dump_buf,
6586 : : §ion_name, &num_section_params);
6587 [ # # ]: 0 : if (strcmp(section_name, "global_params"))
6588 : : return DBG_STATUS_MCP_TRACE_BAD_DATA;
6589 : :
6590 : : /* Print global params */
6591 : 0 : dump_buf += qed_print_section_params(dump_buf,
6592 : : num_section_params,
6593 : : results_buf, &results_offset);
6594 : :
6595 : : /* Read trace_data section */
6596 : 0 : dump_buf += qed_read_section_hdr(dump_buf,
6597 : : §ion_name, &num_section_params);
6598 [ # # # # ]: 0 : if (strcmp(section_name, "mcp_trace_data") || num_section_params != 1)
6599 : : return DBG_STATUS_MCP_TRACE_BAD_DATA;
6600 : 0 : dump_buf += qed_read_param(dump_buf,
6601 : : ¶m_name, ¶m_str_val, ¶m_num_val);
6602 [ # # ]: 0 : if (strcmp(param_name, "size"))
6603 : : return DBG_STATUS_MCP_TRACE_BAD_DATA;
6604 : 0 : trace_data_dwords = param_num_val;
6605 : :
6606 : : /* Prepare trace info */
6607 : : trace = (struct mcp_trace *)dump_buf;
6608 [ # # # # ]: 0 : if (trace->signature != MFW_TRACE_SIGNATURE || !trace->size)
6609 : : return DBG_STATUS_MCP_TRACE_BAD_DATA;
6610 : :
6611 : 0 : trace_buf = (u8 *)dump_buf + sizeof(*trace);
6612 : 0 : offset = trace->trace_oldest;
6613 : 0 : data_size = qed_cyclic_sub(trace->trace_prod, offset, trace->size);
6614 : 0 : dump_buf += trace_data_dwords;
6615 : :
6616 : : /* Read meta_data section */
6617 : 0 : dump_buf += qed_read_section_hdr(dump_buf,
6618 : : §ion_name, &num_section_params);
6619 [ # # ]: 0 : if (strcmp(section_name, "mcp_trace_meta"))
6620 : : return DBG_STATUS_MCP_TRACE_BAD_DATA;
6621 : 0 : dump_buf += qed_read_param(dump_buf,
6622 : : ¶m_name, ¶m_str_val, ¶m_num_val);
6623 [ # # ]: 0 : if (strcmp(param_name, "size"))
6624 : : return DBG_STATUS_MCP_TRACE_BAD_DATA;
6625 : 0 : trace_meta_dwords = param_num_val;
6626 : :
6627 : : /* Choose meta data buffer */
6628 [ # # ]: 0 : if (!trace_meta_dwords) {
6629 : : /* Dump doesn't include meta data */
6630 : : struct dbg_tools_user_data *dev_user_data =
6631 : : qed_dbg_get_user_data(p_hwfn);
6632 : :
6633 [ # # ]: 0 : if (!dev_user_data->mcp_trace_user_meta_buf)
6634 : : return DBG_STATUS_MCP_TRACE_NO_META;
6635 : :
6636 : : meta_buf = dev_user_data->mcp_trace_user_meta_buf;
6637 : : } else {
6638 : : /* Dump includes meta data */
6639 : : meta_buf = dump_buf;
6640 : : }
6641 : :
6642 : : /* Allocate meta data memory */
6643 : 0 : status = qed_mcp_trace_alloc_meta_data(p_hwfn, meta_buf);
6644 [ # # ]: 0 : if (status != DBG_STATUS_OK)
6645 : : return status;
6646 : :
6647 [ # # ]: 0 : status = qed_parse_mcp_trace_buf(p_hwfn,
6648 : : trace_buf,
6649 : : trace->size,
6650 : : offset,
6651 : : data_size,
6652 : : results_buf ?
6653 : 0 : results_buf + results_offset :
6654 : : NULL,
6655 : : &results_buf_bytes);
6656 [ # # ]: 0 : if (status != DBG_STATUS_OK)
6657 : : return status;
6658 : :
6659 [ # # ]: 0 : if (free_meta_data)
6660 : 0 : qed_mcp_trace_free_meta_data(p_hwfn);
6661 : :
6662 : 0 : *parsed_results_bytes = results_offset + results_buf_bytes;
6663 : :
6664 : 0 : return DBG_STATUS_OK;
6665 : : }
6666 : :
6667 : : /* Parses a Reg FIFO dump buffer.
6668 : : * If result_buf is not NULL, the Reg FIFO results are printed to it.
6669 : : * In any case, the required results buffer size is assigned to
6670 : : * parsed_results_bytes.
6671 : : * The parsing status is returned.
6672 : : */
6673 : 0 : static enum dbg_status qed_parse_reg_fifo_dump(u32 *dump_buf,
6674 : : char *results_buf,
6675 : : u32 *parsed_results_bytes)
6676 : : {
6677 : : const char *section_name, *param_name, *param_str_val;
6678 : : u32 param_num_val, num_section_params, num_elements;
6679 : : struct reg_fifo_element *elements;
6680 : : u8 i, j, err_code, vf_val;
6681 : 0 : u32 results_offset = 0;
6682 : : char vf_str[4];
6683 : :
6684 : : /* Read global_params section */
6685 : 0 : dump_buf += qed_read_section_hdr(dump_buf,
6686 : : §ion_name, &num_section_params);
6687 [ # # ]: 0 : if (strcmp(section_name, "global_params"))
6688 : : return DBG_STATUS_REG_FIFO_BAD_DATA;
6689 : :
6690 : : /* Print global params */
6691 : 0 : dump_buf += qed_print_section_params(dump_buf,
6692 : : num_section_params,
6693 : : results_buf, &results_offset);
6694 : :
6695 : : /* Read reg_fifo_data section */
6696 : 0 : dump_buf += qed_read_section_hdr(dump_buf,
6697 : : §ion_name, &num_section_params);
6698 [ # # ]: 0 : if (strcmp(section_name, "reg_fifo_data"))
6699 : : return DBG_STATUS_REG_FIFO_BAD_DATA;
6700 : 0 : dump_buf += qed_read_param(dump_buf,
6701 : : ¶m_name, ¶m_str_val, ¶m_num_val);
6702 [ # # ]: 0 : if (strcmp(param_name, "size"))
6703 : : return DBG_STATUS_REG_FIFO_BAD_DATA;
6704 [ # # ]: 0 : if (param_num_val % REG_FIFO_ELEMENT_DWORDS)
6705 : : return DBG_STATUS_REG_FIFO_BAD_DATA;
6706 : 0 : num_elements = param_num_val / REG_FIFO_ELEMENT_DWORDS;
6707 : : elements = (struct reg_fifo_element *)dump_buf;
6708 : :
6709 : : /* Decode elements */
6710 [ # # ]: 0 : for (i = 0; i < num_elements; i++) {
6711 : : const char *err_msg = NULL;
6712 : :
6713 : : /* Discover if element belongs to a VF or a PF */
6714 : 0 : vf_val = GET_FIELD(elements[i].data, REG_FIFO_ELEMENT_VF);
6715 [ # # ]: 0 : if (vf_val == REG_FIFO_ELEMENT_IS_PF_VF_VAL)
6716 : : sprintf(vf_str, "%s", "N/A");
6717 : : else
6718 : 0 : sprintf(vf_str, "%d", vf_val);
6719 : :
6720 : : /* Find error message */
6721 : 0 : err_code = GET_FIELD(elements[i].data, REG_FIFO_ELEMENT_ERROR);
6722 [ # # ]: 0 : for (j = 0; j < OSAL_ARRAY_SIZE(s_reg_fifo_errors) && !err_msg;
6723 : 0 : j++)
6724 [ # # ]: 0 : if (err_code == s_reg_fifo_errors[j].err_code)
6725 : 0 : err_msg = s_reg_fifo_errors[j].err_msg;
6726 : :
6727 : : /* Add parsed element to parsed buffer */
6728 : 0 : results_offset +=
6729 [ # # ]: 0 : sprintf(qed_get_buf_ptr(results_buf,
6730 : : results_offset),
6731 : : "raw: 0x%016"PRIx64", address: 0x%07x, access: %-5s, pf: %2d, vf: %s, "
6732 : : "port: %d, privilege: %-3s, protection: %-12s, master: %-4s, error: %s\n",
6733 : : elements[i].data,
6734 : 0 : (u32)GET_FIELD(elements[i].data,
6735 : : REG_FIFO_ELEMENT_ADDRESS) *
6736 : : REG_FIFO_ELEMENT_ADDR_FACTOR,
6737 : 0 : s_access_strs[GET_FIELD(elements[i].data,
6738 : : REG_FIFO_ELEMENT_ACCESS)],
6739 : 0 : (u32)GET_FIELD(elements[i].data,
6740 : : REG_FIFO_ELEMENT_PF),
6741 : : vf_str,
6742 : 0 : (u32)GET_FIELD(elements[i].data,
6743 : : REG_FIFO_ELEMENT_PORT),
6744 : 0 : s_privilege_strs[GET_FIELD(elements[i].data,
6745 : : REG_FIFO_ELEMENT_PRIVILEGE)],
6746 : 0 : s_protection_strs[GET_FIELD(elements[i].data,
6747 : : REG_FIFO_ELEMENT_PROTECTION)],
6748 [ # # ]: 0 : s_master_strs[GET_FIELD(elements[i].data,
6749 : : REG_FIFO_ELEMENT_MASTER)],
6750 : : err_msg ? err_msg : "unknown error code");
6751 : : }
6752 : :
6753 [ # # ]: 0 : results_offset += sprintf(qed_get_buf_ptr(results_buf,
6754 : : results_offset),
6755 : : "fifo contained %d elements", num_elements);
6756 : :
6757 : : /* Add 1 for string NULL termination */
6758 : 0 : *parsed_results_bytes = results_offset + 1;
6759 : :
6760 : 0 : return DBG_STATUS_OK;
6761 : : }
6762 : :
6763 : 0 : static enum dbg_status qed_parse_igu_fifo_element(struct igu_fifo_element
6764 : : *element, char
6765 : : *results_buf,
6766 : : u32 *results_offset)
6767 : : {
6768 : : const struct igu_fifo_addr_data *found_addr = NULL;
6769 : : u8 source, err_type, i, is_cleanup;
6770 : : char parsed_addr_data[32];
6771 : : char parsed_wr_data[256];
6772 : : u32 wr_data, prod_cons;
6773 : : bool is_wr_cmd, is_pf;
6774 : : u16 cmd_addr;
6775 : : u64 dword12;
6776 : :
6777 : : /* Dword12 (dword index 1 and 2) contains bits 32..95 of the
6778 : : * FIFO element.
6779 : : */
6780 : 0 : dword12 = ((u64)element->dword2 << 32) | element->dword1;
6781 : 0 : is_wr_cmd = GET_FIELD(dword12, IGU_FIFO_ELEMENT_DWORD12_IS_WR_CMD);
6782 : 0 : is_pf = GET_FIELD(element->dword0, IGU_FIFO_ELEMENT_DWORD0_IS_PF);
6783 : 0 : cmd_addr = GET_FIELD(element->dword0, IGU_FIFO_ELEMENT_DWORD0_CMD_ADDR);
6784 : 0 : source = GET_FIELD(element->dword0, IGU_FIFO_ELEMENT_DWORD0_SOURCE);
6785 : 0 : err_type = GET_FIELD(element->dword0, IGU_FIFO_ELEMENT_DWORD0_ERR_TYPE);
6786 : :
6787 [ # # ]: 0 : if (source >= OSAL_ARRAY_SIZE(s_igu_fifo_source_strs))
6788 : : return DBG_STATUS_IGU_FIFO_BAD_DATA;
6789 [ # # ]: 0 : if (err_type >= OSAL_ARRAY_SIZE(s_igu_fifo_error_strs))
6790 : : return DBG_STATUS_IGU_FIFO_BAD_DATA;
6791 : :
6792 : : /* Find address data */
6793 [ # # ]: 0 : for (i = 0; i < OSAL_ARRAY_SIZE(s_igu_fifo_addr_data) && !found_addr;
6794 : 0 : i++) {
6795 : 0 : const struct igu_fifo_addr_data *curr_addr =
6796 : 0 : &s_igu_fifo_addr_data[i];
6797 : :
6798 [ # # ]: 0 : if (cmd_addr >= curr_addr->start_addr && cmd_addr <=
6799 [ # # ]: 0 : curr_addr->end_addr)
6800 : : found_addr = curr_addr;
6801 : : }
6802 : :
6803 [ # # ]: 0 : if (!found_addr)
6804 : : return DBG_STATUS_IGU_FIFO_BAD_DATA;
6805 : :
6806 : : /* Prepare parsed address data */
6807 [ # # # ]: 0 : switch (found_addr->type) {
6808 : 0 : case IGU_ADDR_TYPE_MSIX_MEM:
6809 : 0 : sprintf(parsed_addr_data, " vector_num = 0x%x", cmd_addr / 2);
6810 : : break;
6811 : 0 : case IGU_ADDR_TYPE_WRITE_INT_ACK:
6812 : : case IGU_ADDR_TYPE_WRITE_PROD_UPDATE:
6813 : 0 : sprintf(parsed_addr_data,
6814 : 0 : " SB = 0x%x", cmd_addr - found_addr->start_addr);
6815 : : break;
6816 : 0 : default:
6817 : 0 : parsed_addr_data[0] = '\0';
6818 : : }
6819 : :
6820 [ # # ]: 0 : if (!is_wr_cmd) {
6821 : 0 : parsed_wr_data[0] = '\0';
6822 : 0 : goto out;
6823 : : }
6824 : :
6825 : : /* Prepare parsed write data */
6826 : 0 : wr_data = GET_FIELD(dword12, IGU_FIFO_ELEMENT_DWORD12_WR_DATA);
6827 : 0 : prod_cons = GET_FIELD(wr_data, IGU_FIFO_WR_DATA_PROD_CONS);
6828 : 0 : is_cleanup = GET_FIELD(wr_data, IGU_FIFO_WR_DATA_CMD_TYPE);
6829 : :
6830 [ # # ]: 0 : if (source == IGU_SRC_ATTN) {
6831 : : sprintf(parsed_wr_data, "prod: 0x%x, ", prod_cons);
6832 : : } else {
6833 [ # # ]: 0 : if (is_cleanup) {
6834 : : u8 cleanup_val, cleanup_type;
6835 : :
6836 : 0 : cleanup_val =
6837 : 0 : GET_FIELD(wr_data,
6838 : : IGU_FIFO_CLEANUP_WR_DATA_CLEANUP_VAL);
6839 : 0 : cleanup_type =
6840 : 0 : GET_FIELD(wr_data,
6841 : : IGU_FIFO_CLEANUP_WR_DATA_CLEANUP_TYPE);
6842 : :
6843 [ # # ]: 0 : sprintf(parsed_wr_data,
6844 : : "cmd_type: cleanup, cleanup_val: %s, cleanup_type : %d, ",
6845 : : cleanup_val ? "set" : "clear",
6846 : : cleanup_type);
6847 : : } else {
6848 : : u8 update_flag, en_dis_int_for_sb, segment;
6849 : : u8 timer_mask;
6850 : :
6851 : 0 : update_flag = GET_FIELD(wr_data,
6852 : : IGU_FIFO_WR_DATA_UPDATE_FLAG);
6853 : 0 : en_dis_int_for_sb =
6854 : 0 : GET_FIELD(wr_data,
6855 : : IGU_FIFO_WR_DATA_EN_DIS_INT_FOR_SB);
6856 : 0 : segment = GET_FIELD(wr_data,
6857 : : IGU_FIFO_WR_DATA_SEGMENT);
6858 : 0 : timer_mask = GET_FIELD(wr_data,
6859 : : IGU_FIFO_WR_DATA_TIMER_MASK);
6860 : :
6861 [ # # # # : 0 : sprintf(parsed_wr_data,
# # ]
6862 : : "cmd_type: prod/cons update, prod/cons: 0x%x, update_flag: %s, en_dis_int_for_sb : %s, segment : %s, timer_mask = %d, ",
6863 : : prod_cons,
6864 : : update_flag ? "update" : "nop",
6865 : : en_dis_int_for_sb ?
6866 [ # # ]: 0 : (en_dis_int_for_sb == 1 ? "disable" : "nop") :
6867 : : "enable",
6868 : : segment ? "attn" : "regular",
6869 : : timer_mask);
6870 : : }
6871 : : }
6872 : 0 : out:
6873 : : /* Add parsed element to parsed buffer */
6874 [ # # # # ]: 0 : *results_offset += sprintf(qed_get_buf_ptr(results_buf,
6875 : : *results_offset),
6876 : : "raw: 0x%01x%08x%08x, %s: %d, source : %s, type : %s, cmd_addr : 0x%x(%s%s), %serror: %s\n",
6877 : : element->dword2, element->dword1,
6878 : : element->dword0,
6879 : : is_pf ? "pf" : "vf",
6880 : 0 : GET_FIELD(element->dword0,
6881 : : IGU_FIFO_ELEMENT_DWORD0_FID),
6882 [ # # ]: 0 : s_igu_fifo_source_strs[source],
6883 : : is_wr_cmd ? "wr" : "rd",
6884 : : cmd_addr,
6885 [ # # ]: 0 : (!is_pf && found_addr->vf_desc)
6886 : : ? found_addr->vf_desc
6887 : : : found_addr->desc,
6888 : : parsed_addr_data,
6889 : : parsed_wr_data,
6890 [ # # ]: 0 : s_igu_fifo_error_strs[err_type]);
6891 : :
6892 : 0 : return DBG_STATUS_OK;
6893 : : }
6894 : :
6895 : : /* Parses an IGU FIFO dump buffer.
6896 : : * If result_buf is not NULL, the IGU FIFO results are printed to it.
6897 : : * In any case, the required results buffer size is assigned to
6898 : : * parsed_results_bytes.
6899 : : * The parsing status is returned.
6900 : : */
6901 : 0 : static enum dbg_status qed_parse_igu_fifo_dump(u32 *dump_buf,
6902 : : char *results_buf,
6903 : : u32 *parsed_results_bytes)
6904 : : {
6905 : : const char *section_name, *param_name, *param_str_val;
6906 : : u32 param_num_val, num_section_params, num_elements;
6907 : : struct igu_fifo_element *elements;
6908 : : enum dbg_status status;
6909 : 0 : u32 results_offset = 0;
6910 : : u8 i;
6911 : :
6912 : : /* Read global_params section */
6913 : 0 : dump_buf += qed_read_section_hdr(dump_buf,
6914 : : §ion_name, &num_section_params);
6915 [ # # ]: 0 : if (strcmp(section_name, "global_params"))
6916 : : return DBG_STATUS_IGU_FIFO_BAD_DATA;
6917 : :
6918 : : /* Print global params */
6919 : 0 : dump_buf += qed_print_section_params(dump_buf,
6920 : : num_section_params,
6921 : : results_buf, &results_offset);
6922 : :
6923 : : /* Read igu_fifo_data section */
6924 : 0 : dump_buf += qed_read_section_hdr(dump_buf,
6925 : : §ion_name, &num_section_params);
6926 [ # # ]: 0 : if (strcmp(section_name, "igu_fifo_data"))
6927 : : return DBG_STATUS_IGU_FIFO_BAD_DATA;
6928 : 0 : dump_buf += qed_read_param(dump_buf,
6929 : : ¶m_name, ¶m_str_val, ¶m_num_val);
6930 [ # # ]: 0 : if (strcmp(param_name, "size"))
6931 : : return DBG_STATUS_IGU_FIFO_BAD_DATA;
6932 [ # # ]: 0 : if (param_num_val % IGU_FIFO_ELEMENT_DWORDS)
6933 : : return DBG_STATUS_IGU_FIFO_BAD_DATA;
6934 : 0 : num_elements = param_num_val / IGU_FIFO_ELEMENT_DWORDS;
6935 : : elements = (struct igu_fifo_element *)dump_buf;
6936 : :
6937 : : /* Decode elements */
6938 [ # # ]: 0 : for (i = 0; i < num_elements; i++) {
6939 : 0 : status = qed_parse_igu_fifo_element(&elements[i],
6940 : : results_buf,
6941 : : &results_offset);
6942 [ # # ]: 0 : if (status != DBG_STATUS_OK)
6943 : 0 : return status;
6944 : : }
6945 : :
6946 [ # # ]: 0 : results_offset += sprintf(qed_get_buf_ptr(results_buf,
6947 : : results_offset),
6948 : : "fifo contained %d elements", num_elements);
6949 : :
6950 : : /* Add 1 for string NULL termination */
6951 : 0 : *parsed_results_bytes = results_offset + 1;
6952 : :
6953 : 0 : return DBG_STATUS_OK;
6954 : : }
6955 : :
6956 : : static enum dbg_status
6957 : 0 : qed_parse_protection_override_dump(u32 *dump_buf,
6958 : : char *results_buf,
6959 : : u32 *parsed_results_bytes)
6960 : : {
6961 : : const char *section_name, *param_name, *param_str_val;
6962 : : u32 param_num_val, num_section_params, num_elements;
6963 : : struct protection_override_element *elements;
6964 : 0 : u32 results_offset = 0;
6965 : : u8 i;
6966 : :
6967 : : /* Read global_params section */
6968 : 0 : dump_buf += qed_read_section_hdr(dump_buf,
6969 : : §ion_name, &num_section_params);
6970 [ # # ]: 0 : if (strcmp(section_name, "global_params"))
6971 : : return DBG_STATUS_PROTECTION_OVERRIDE_BAD_DATA;
6972 : :
6973 : : /* Print global params */
6974 : 0 : dump_buf += qed_print_section_params(dump_buf,
6975 : : num_section_params,
6976 : : results_buf, &results_offset);
6977 : :
6978 : : /* Read protection_override_data section */
6979 : 0 : dump_buf += qed_read_section_hdr(dump_buf,
6980 : : §ion_name, &num_section_params);
6981 [ # # ]: 0 : if (strcmp(section_name, "protection_override_data"))
6982 : : return DBG_STATUS_PROTECTION_OVERRIDE_BAD_DATA;
6983 : 0 : dump_buf += qed_read_param(dump_buf,
6984 : : ¶m_name, ¶m_str_val, ¶m_num_val);
6985 [ # # ]: 0 : if (strcmp(param_name, "size"))
6986 : : return DBG_STATUS_PROTECTION_OVERRIDE_BAD_DATA;
6987 [ # # ]: 0 : if (param_num_val % PROTECTION_OVERRIDE_ELEMENT_DWORDS)
6988 : : return DBG_STATUS_PROTECTION_OVERRIDE_BAD_DATA;
6989 : 0 : num_elements = param_num_val / PROTECTION_OVERRIDE_ELEMENT_DWORDS;
6990 : : elements = (struct protection_override_element *)dump_buf;
6991 : :
6992 : : /* Decode elements */
6993 [ # # ]: 0 : for (i = 0; i < num_elements; i++) {
6994 : 0 : u32 address = GET_FIELD(elements[i].data,
6995 : : PROTECTION_OVERRIDE_ELEMENT_ADDRESS) *
6996 : : PROTECTION_OVERRIDE_ELEMENT_ADDR_FACTOR;
6997 : :
6998 : 0 : results_offset +=
6999 : 0 : sprintf(qed_get_buf_ptr(results_buf,
7000 : : results_offset),
7001 : : "window %2d, address: 0x%07x, size: %7d regs, read: %d, write: %d, read protection: %-12s, write protection: %-12s\n",
7002 : : i, address,
7003 : 0 : (u32)GET_FIELD(elements[i].data,
7004 : : PROTECTION_OVERRIDE_ELEMENT_WINDOW_SIZE),
7005 : 0 : (u32)GET_FIELD(elements[i].data,
7006 : : PROTECTION_OVERRIDE_ELEMENT_READ),
7007 : 0 : (u32)GET_FIELD(elements[i].data,
7008 : : PROTECTION_OVERRIDE_ELEMENT_WRITE),
7009 : 0 : s_protection_strs[GET_FIELD(elements[i].data,
7010 : : PROTECTION_OVERRIDE_ELEMENT_READ_PROTECTION)],
7011 [ # # ]: 0 : s_protection_strs[GET_FIELD(elements[i].data,
7012 : : PROTECTION_OVERRIDE_ELEMENT_WRITE_PROTECTION)]);
7013 : : }
7014 : :
7015 [ # # ]: 0 : results_offset += sprintf(qed_get_buf_ptr(results_buf,
7016 : : results_offset),
7017 : : "protection override contained %d elements",
7018 : : num_elements);
7019 : :
7020 : : /* Add 1 for string NULL termination */
7021 : 0 : *parsed_results_bytes = results_offset + 1;
7022 : :
7023 : 0 : return DBG_STATUS_OK;
7024 : : }
7025 : :
7026 : : /* Parses a FW Asserts dump buffer.
7027 : : * If result_buf is not NULL, the FW Asserts results are printed to it.
7028 : : * In any case, the required results buffer size is assigned to
7029 : : * parsed_results_bytes.
7030 : : * The parsing status is returned.
7031 : : */
7032 : 0 : static enum dbg_status qed_parse_fw_asserts_dump(u32 *dump_buf,
7033 : : char *results_buf,
7034 : : u32 *parsed_results_bytes)
7035 : : {
7036 : 0 : u32 num_section_params, param_num_val, i, results_offset = 0;
7037 : : const char *param_name, *param_str_val, *section_name;
7038 : : bool last_section_found = false;
7039 : :
7040 : 0 : *parsed_results_bytes = 0;
7041 : :
7042 : : /* Read global_params section */
7043 : 0 : dump_buf += qed_read_section_hdr(dump_buf,
7044 : : §ion_name, &num_section_params);
7045 [ # # ]: 0 : if (strcmp(section_name, "global_params"))
7046 : : return DBG_STATUS_FW_ASSERTS_PARSE_FAILED;
7047 : :
7048 : : /* Print global params */
7049 : 0 : dump_buf += qed_print_section_params(dump_buf,
7050 : : num_section_params,
7051 : : results_buf, &results_offset);
7052 : :
7053 [ # # ]: 0 : while (!last_section_found) {
7054 : 0 : dump_buf += qed_read_section_hdr(dump_buf,
7055 : : §ion_name,
7056 : : &num_section_params);
7057 [ # # ]: 0 : if (!strcmp(section_name, "fw_asserts")) {
7058 : : /* Extract params */
7059 : : const char *storm_letter = NULL;
7060 : : u32 storm_dump_size = 0;
7061 : :
7062 [ # # ]: 0 : for (i = 0; i < num_section_params; i++) {
7063 : 0 : dump_buf += qed_read_param(dump_buf,
7064 : : ¶m_name,
7065 : : ¶m_str_val,
7066 : : ¶m_num_val);
7067 [ # # ]: 0 : if (!strcmp(param_name, "storm"))
7068 : 0 : storm_letter = param_str_val;
7069 [ # # ]: 0 : else if (!strcmp(param_name, "size"))
7070 : 0 : storm_dump_size = param_num_val;
7071 : : else
7072 : : return
7073 : : DBG_STATUS_FW_ASSERTS_PARSE_FAILED;
7074 : : }
7075 : :
7076 [ # # ]: 0 : if (!storm_letter || !storm_dump_size)
7077 : : return DBG_STATUS_FW_ASSERTS_PARSE_FAILED;
7078 : :
7079 : : /* Print data */
7080 : 0 : results_offset +=
7081 [ # # ]: 0 : sprintf(qed_get_buf_ptr(results_buf,
7082 : : results_offset),
7083 : : "\n%sSTORM_ASSERT: size=%d\n",
7084 : : storm_letter, storm_dump_size);
7085 [ # # ]: 0 : for (i = 0; i < storm_dump_size; i++, dump_buf++)
7086 : 0 : results_offset +=
7087 [ # # ]: 0 : sprintf(qed_get_buf_ptr(results_buf,
7088 : : results_offset),
7089 : : "%08x\n", *dump_buf);
7090 [ # # ]: 0 : } else if (!strcmp(section_name, "last")) {
7091 : : last_section_found = true;
7092 : : } else {
7093 : : return DBG_STATUS_FW_ASSERTS_PARSE_FAILED;
7094 : : }
7095 : : }
7096 : :
7097 : : /* Add 1 for string NULL termination */
7098 : 0 : *parsed_results_bytes = results_offset + 1;
7099 : :
7100 : 0 : return DBG_STATUS_OK;
7101 : : }
7102 : :
7103 : : /***************************** Public Functions *******************************/
7104 : :
7105 : 0 : enum dbg_status qed_dbg_user_set_bin_ptr(struct ecore_hwfn *p_hwfn,
7106 : : const u8 * const bin_ptr)
7107 : : {
7108 : : struct bin_buffer_hdr *buf_hdrs =
7109 : : (struct bin_buffer_hdr *)(osal_uintptr_t)bin_ptr;
7110 : : u8 buf_id;
7111 : :
7112 : : /* Convert binary data to debug arrays */
7113 [ # # ]: 0 : for (buf_id = 0; buf_id < MAX_BIN_DBG_BUFFER_TYPE; buf_id++)
7114 : 0 : qed_set_dbg_bin_buf(p_hwfn,
7115 : : (enum bin_dbg_buffer_type)buf_id,
7116 : : (const u32 *)(bin_ptr +
7117 : 0 : buf_hdrs[buf_id].offset),
7118 : 0 : buf_hdrs[buf_id].length);
7119 : :
7120 : 0 : return DBG_STATUS_OK;
7121 : : }
7122 : :
7123 : 0 : enum dbg_status qed_dbg_alloc_user_data(__rte_unused struct ecore_hwfn *p_hwfn,
7124 : : void **user_data_ptr)
7125 : : {
7126 : 0 : *user_data_ptr = OSAL_ZALLOC(p_hwfn->p_dev, GFP_KERNEL,
7127 : : sizeof(struct dbg_tools_user_data));
7128 [ # # ]: 0 : if (!(*user_data_ptr))
7129 : 0 : return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
7130 : :
7131 : : return DBG_STATUS_OK;
7132 : : }
7133 : :
7134 : 0 : const char *qed_dbg_get_status_str(enum dbg_status status)
7135 : : {
7136 : : return (status <
7137 [ # # ]: 0 : MAX_DBG_STATUS) ? s_status_str[status] : "Invalid debug status";
7138 : : }
7139 : :
7140 : 0 : enum dbg_status qed_get_idle_chk_results_buf_size(struct ecore_hwfn *p_hwfn,
7141 : : u32 *dump_buf,
7142 : : u32 num_dumped_dwords,
7143 : : u32 *results_buf_size)
7144 : : {
7145 : : u32 num_errors, num_warnings;
7146 : :
7147 : 0 : return qed_parse_idle_chk_dump(p_hwfn,
7148 : : dump_buf,
7149 : : num_dumped_dwords,
7150 : : NULL,
7151 : : results_buf_size,
7152 : : &num_errors, &num_warnings);
7153 : : }
7154 : :
7155 : 0 : enum dbg_status qed_print_idle_chk_results(struct ecore_hwfn *p_hwfn,
7156 : : u32 *dump_buf,
7157 : : u32 num_dumped_dwords,
7158 : : char *results_buf,
7159 : : u32 *num_errors,
7160 : : u32 *num_warnings)
7161 : : {
7162 : : u32 parsed_buf_size;
7163 : :
7164 : 0 : return qed_parse_idle_chk_dump(p_hwfn,
7165 : : dump_buf,
7166 : : num_dumped_dwords,
7167 : : results_buf,
7168 : : &parsed_buf_size,
7169 : : num_errors, num_warnings);
7170 : : }
7171 : :
7172 : 0 : void qed_dbg_mcp_trace_set_meta_data(struct ecore_hwfn *p_hwfn,
7173 : : const u32 *meta_buf)
7174 : : {
7175 : : struct dbg_tools_user_data *dev_user_data =
7176 : : qed_dbg_get_user_data(p_hwfn);
7177 : :
7178 : 0 : dev_user_data->mcp_trace_user_meta_buf = meta_buf;
7179 : 0 : }
7180 : :
7181 : : enum dbg_status
7182 : 0 : qed_get_mcp_trace_results_buf_size(struct ecore_hwfn *p_hwfn,
7183 : : u32 *dump_buf,
7184 : : __rte_unused u32 num_dumped_dwords,
7185 : : u32 *results_buf_size)
7186 : : {
7187 : 0 : return qed_parse_mcp_trace_dump(p_hwfn,
7188 : : dump_buf, NULL, results_buf_size, true);
7189 : : }
7190 : :
7191 : 0 : enum dbg_status qed_print_mcp_trace_results(struct ecore_hwfn *p_hwfn,
7192 : : u32 *dump_buf,
7193 : : __rte_unused u32 num_dumped_dwords,
7194 : : char *results_buf)
7195 : : {
7196 : : u32 parsed_buf_size;
7197 : :
7198 : 0 : return qed_parse_mcp_trace_dump(p_hwfn,
7199 : : dump_buf,
7200 : : results_buf, &parsed_buf_size, true);
7201 : : }
7202 : :
7203 : 0 : enum dbg_status qed_print_mcp_trace_results_cont(struct ecore_hwfn *p_hwfn,
7204 : : u32 *dump_buf,
7205 : : char *results_buf)
7206 : : {
7207 : : u32 parsed_buf_size;
7208 : :
7209 : 0 : return qed_parse_mcp_trace_dump(p_hwfn, dump_buf, results_buf,
7210 : : &parsed_buf_size, false);
7211 : : }
7212 : :
7213 : 0 : enum dbg_status qed_print_mcp_trace_line(struct ecore_hwfn *p_hwfn,
7214 : : u8 *dump_buf,
7215 : : u32 num_dumped_bytes,
7216 : : char *results_buf)
7217 : : {
7218 : : u32 parsed_results_bytes;
7219 : :
7220 : 0 : return qed_parse_mcp_trace_buf(p_hwfn,
7221 : : dump_buf,
7222 : : num_dumped_bytes,
7223 : : 0,
7224 : : num_dumped_bytes,
7225 : : results_buf, &parsed_results_bytes);
7226 : : }
7227 : :
7228 : : /* Frees the specified MCP Trace meta data */
7229 : 0 : void qed_mcp_trace_free_meta_data(struct ecore_hwfn *p_hwfn)
7230 : : {
7231 : : struct dbg_tools_user_data *dev_user_data;
7232 : : struct mcp_trace_meta *meta;
7233 : : u32 i;
7234 : :
7235 : : dev_user_data = qed_dbg_get_user_data(p_hwfn);
7236 : : meta = &dev_user_data->mcp_trace_meta;
7237 [ # # ]: 0 : if (!meta->is_allocated)
7238 : : return;
7239 : :
7240 : : /* Release modules */
7241 [ # # ]: 0 : if (meta->modules) {
7242 [ # # ]: 0 : for (i = 0; i < meta->modules_num; i++)
7243 : 0 : OSAL_FREE(p_hwfn, meta->modules[i]);
7244 : 0 : OSAL_FREE(p_hwfn, meta->modules);
7245 : : }
7246 : :
7247 : : /* Release formats */
7248 [ # # ]: 0 : if (meta->formats) {
7249 [ # # ]: 0 : for (i = 0; i < meta->formats_num; i++)
7250 : 0 : OSAL_FREE(p_hwfn, meta->formats[i].format_str);
7251 : 0 : OSAL_FREE(p_hwfn, meta->formats);
7252 : : }
7253 : :
7254 : 0 : meta->is_allocated = false;
7255 : : }
7256 : :
7257 : : enum dbg_status
7258 : 0 : qed_get_reg_fifo_results_buf_size(__rte_unused struct ecore_hwfn *p_hwfn,
7259 : : u32 *dump_buf,
7260 : : __rte_unused u32 num_dumped_dwords,
7261 : : u32 *results_buf_size)
7262 : : {
7263 : 0 : return qed_parse_reg_fifo_dump(dump_buf, NULL, results_buf_size);
7264 : : }
7265 : :
7266 : : enum dbg_status
7267 : 0 : qed_print_reg_fifo_results(__rte_unused struct ecore_hwfn *p_hwfn,
7268 : : u32 *dump_buf,
7269 : : __rte_unused u32 num_dumped_dwords,
7270 : : char *results_buf)
7271 : : {
7272 : : u32 parsed_buf_size;
7273 : :
7274 : 0 : return qed_parse_reg_fifo_dump(dump_buf, results_buf, &parsed_buf_size);
7275 : : }
7276 : :
7277 : : enum dbg_status
7278 : 0 : qed_get_igu_fifo_results_buf_size(__rte_unused struct ecore_hwfn *p_hwfn,
7279 : : u32 *dump_buf,
7280 : : __rte_unused u32 num_dumped_dwords,
7281 : : u32 *results_buf_size)
7282 : : {
7283 : 0 : return qed_parse_igu_fifo_dump(dump_buf, NULL, results_buf_size);
7284 : : }
7285 : :
7286 : : enum dbg_status
7287 : 0 : qed_print_igu_fifo_results(__rte_unused struct ecore_hwfn *p_hwfn,
7288 : : u32 *dump_buf,
7289 : : __rte_unused u32 num_dumped_dwords,
7290 : : char *results_buf)
7291 : : {
7292 : : u32 parsed_buf_size;
7293 : :
7294 : 0 : return qed_parse_igu_fifo_dump(dump_buf, results_buf, &parsed_buf_size);
7295 : : }
7296 : :
7297 : : enum dbg_status
7298 : 0 : qed_get_protection_override_results_buf_size(__rte_unused
7299 : : struct ecore_hwfn *p_hwfn,
7300 : : u32 *dump_buf,
7301 : : __rte_unused u32 num_dumped_dwords,
7302 : : u32 *results_buf_size)
7303 : : {
7304 : 0 : return qed_parse_protection_override_dump(dump_buf,
7305 : : NULL, results_buf_size);
7306 : : }
7307 : :
7308 : : enum dbg_status
7309 : 0 : qed_print_protection_override_results(__rte_unused struct ecore_hwfn *p_hwfn,
7310 : : u32 *dump_buf,
7311 : : __rte_unused u32 num_dumped_dwords,
7312 : : char *results_buf)
7313 : : {
7314 : : u32 parsed_buf_size;
7315 : :
7316 : 0 : return qed_parse_protection_override_dump(dump_buf,
7317 : : results_buf,
7318 : : &parsed_buf_size);
7319 : : }
7320 : :
7321 : : enum dbg_status
7322 : 0 : qed_get_fw_asserts_results_buf_size(__rte_unused struct ecore_hwfn *p_hwfn,
7323 : : u32 *dump_buf,
7324 : : __rte_unused u32 num_dumped_dwords,
7325 : : u32 *results_buf_size)
7326 : : {
7327 : 0 : return qed_parse_fw_asserts_dump(dump_buf, NULL, results_buf_size);
7328 : : }
7329 : :
7330 : : enum dbg_status
7331 : 0 : qed_print_fw_asserts_results(__rte_unused struct ecore_hwfn *p_hwfn,
7332 : : u32 *dump_buf,
7333 : : __rte_unused u32 num_dumped_dwords,
7334 : : char *results_buf)
7335 : : {
7336 : : u32 parsed_buf_size;
7337 : :
7338 : 0 : return qed_parse_fw_asserts_dump(dump_buf,
7339 : : results_buf, &parsed_buf_size);
7340 : : }
7341 : :
7342 : 0 : enum dbg_status qed_dbg_parse_attn(struct ecore_hwfn *p_hwfn,
7343 : : struct dbg_attn_block_result *results)
7344 : : {
7345 : : const u32 *block_attn_name_offsets;
7346 : : const char *attn_name_base;
7347 : : const char *block_name;
7348 : : enum dbg_attn_type attn_type;
7349 : : u8 num_regs, i, j;
7350 : :
7351 : 0 : num_regs = GET_FIELD(results->data, DBG_ATTN_BLOCK_RESULT_NUM_REGS);
7352 : : attn_type = GET_FIELD(results->data, DBG_ATTN_BLOCK_RESULT_ATTN_TYPE);
7353 : 0 : block_name = qed_dbg_get_block_name(p_hwfn, results->block_id);
7354 [ # # ]: 0 : if (!block_name)
7355 : : return DBG_STATUS_INVALID_ARGS;
7356 : :
7357 [ # # ]: 0 : if (!p_hwfn->dbg_arrays[BIN_BUF_DBG_ATTN_INDEXES].ptr ||
7358 [ # # ]: 0 : !p_hwfn->dbg_arrays[BIN_BUF_DBG_ATTN_NAME_OFFSETS].ptr ||
7359 [ # # ]: 0 : !p_hwfn->dbg_arrays[BIN_BUF_DBG_PARSING_STRINGS].ptr)
7360 : : return DBG_STATUS_DBG_ARRAY_NOT_SET;
7361 : :
7362 : : block_attn_name_offsets =
7363 : : (u32 *)p_hwfn->dbg_arrays[BIN_BUF_DBG_ATTN_NAME_OFFSETS].ptr +
7364 : 0 : results->names_offset;
7365 : :
7366 : : attn_name_base = p_hwfn->dbg_arrays[BIN_BUF_DBG_PARSING_STRINGS].ptr;
7367 : :
7368 : : /* Go over registers with a non-zero attention status */
7369 [ # # ]: 0 : for (i = 0; i < num_regs; i++) {
7370 : : struct dbg_attn_bit_mapping *bit_mapping;
7371 : : struct dbg_attn_reg_result *reg_result;
7372 : : u8 num_reg_attn, bit_idx = 0;
7373 : :
7374 : 0 : reg_result = &results->reg_results[i];
7375 : 0 : num_reg_attn = GET_FIELD(reg_result->data,
7376 : : DBG_ATTN_REG_RESULT_NUM_REG_ATTN);
7377 : 0 : bit_mapping = (struct dbg_attn_bit_mapping *)
7378 : 0 : p_hwfn->dbg_arrays[BIN_BUF_DBG_ATTN_INDEXES].ptr +
7379 : 0 : reg_result->block_attn_offset;
7380 : :
7381 : : /* Go over attention status bits */
7382 [ # # ]: 0 : for (j = 0; j < num_reg_attn; j++, bit_idx++) {
7383 : 0 : u16 attn_idx_val = GET_FIELD(bit_mapping[j].data,
7384 : : DBG_ATTN_BIT_MAPPING_VAL);
7385 : : const char *attn_name, *attn_type_str, *masked_str;
7386 : : u32 attn_name_offset;
7387 : : u32 sts_addr;
7388 : :
7389 : : /* Check if bit mask should be advanced (due to unused
7390 : : * bits).
7391 : : */
7392 [ # # ]: 0 : if (GET_FIELD(bit_mapping[j].data,
7393 : : DBG_ATTN_BIT_MAPPING_IS_UNUSED_BIT_CNT)) {
7394 : 0 : bit_idx += (u8)attn_idx_val;
7395 : 0 : continue;
7396 : : }
7397 : :
7398 : : /* Check current bit index */
7399 [ # # ]: 0 : if (!(reg_result->sts_val & OSAL_BIT(bit_idx)))
7400 : 0 : continue;
7401 : :
7402 : : /* An attention bit with value=1 was found
7403 : : * Find attention name
7404 : : */
7405 : 0 : attn_name_offset =
7406 : 0 : block_attn_name_offsets[attn_idx_val];
7407 : 0 : attn_name = attn_name_base + attn_name_offset;
7408 : : attn_type_str =
7409 : : (attn_type ==
7410 [ # # ]: 0 : ATTN_TYPE_INTERRUPT ? "Interrupt" :
7411 : : "Parity");
7412 : 0 : masked_str = reg_result->mask_val & OSAL_BIT(bit_idx) ?
7413 [ # # ]: 0 : " [masked]" : "";
7414 : 0 : sts_addr = GET_FIELD(reg_result->data,
7415 : : DBG_ATTN_REG_RESULT_STS_ADDRESS);
7416 : 0 : DP_NOTICE(p_hwfn, false,
7417 : : "%s (%s) : %s [address 0x%08x, bit %d]%s\n",
7418 : : block_name, attn_type_str, attn_name,
7419 : : sts_addr * 4, bit_idx, masked_str);
7420 : : }
7421 : : }
7422 : :
7423 : : return DBG_STATUS_OK;
7424 : : }
7425 : :
7426 : : /* Wrapper for unifying the idle_chk and mcp_trace api */
7427 : : static enum dbg_status
7428 : 0 : qed_print_idle_chk_results_wrapper(struct ecore_hwfn *p_hwfn,
7429 : : u32 *dump_buf,
7430 : : u32 num_dumped_dwords,
7431 : : char *results_buf)
7432 : : {
7433 : : u32 num_errors, num_warnnings;
7434 : :
7435 : 0 : return qed_print_idle_chk_results(p_hwfn, dump_buf, num_dumped_dwords,
7436 : : results_buf, &num_errors,
7437 : : &num_warnnings);
7438 : : }
7439 : :
7440 : : /* Feature meta data lookup table */
7441 : : static struct {
7442 : : const char *name;
7443 : : enum dbg_status (*get_size)(struct ecore_hwfn *p_hwfn,
7444 : : struct ecore_ptt *p_ptt, u32 *size);
7445 : : enum dbg_status (*perform_dump)(struct ecore_hwfn *p_hwfn,
7446 : : struct ecore_ptt *p_ptt, u32 *dump_buf,
7447 : : u32 buf_size, u32 *dumped_dwords);
7448 : : enum dbg_status (*print_results)(struct ecore_hwfn *p_hwfn,
7449 : : u32 *dump_buf, u32 num_dumped_dwords,
7450 : : char *results_buf);
7451 : : enum dbg_status (*results_buf_size)(struct ecore_hwfn *p_hwfn,
7452 : : u32 *dump_buf,
7453 : : u32 num_dumped_dwords,
7454 : : u32 *results_buf_size);
7455 : : } qed_features_lookup[] = {
7456 : : {
7457 : : "grc", qed_dbg_grc_get_dump_buf_size,
7458 : : qed_dbg_grc_dump, NULL, NULL}, {
7459 : : "idle_chk",
7460 : : qed_dbg_idle_chk_get_dump_buf_size,
7461 : : qed_dbg_idle_chk_dump,
7462 : : qed_print_idle_chk_results_wrapper,
7463 : : qed_get_idle_chk_results_buf_size}, {
7464 : : "mcp_trace",
7465 : : qed_dbg_mcp_trace_get_dump_buf_size,
7466 : : qed_dbg_mcp_trace_dump, qed_print_mcp_trace_results,
7467 : : qed_get_mcp_trace_results_buf_size}, {
7468 : : "reg_fifo",
7469 : : qed_dbg_reg_fifo_get_dump_buf_size,
7470 : : qed_dbg_reg_fifo_dump, qed_print_reg_fifo_results,
7471 : : qed_get_reg_fifo_results_buf_size}, {
7472 : : "igu_fifo",
7473 : : qed_dbg_igu_fifo_get_dump_buf_size,
7474 : : qed_dbg_igu_fifo_dump, qed_print_igu_fifo_results,
7475 : : qed_get_igu_fifo_results_buf_size}, {
7476 : : "protection_override",
7477 : : qed_dbg_protection_override_get_dump_buf_size,
7478 : : qed_dbg_protection_override_dump,
7479 : : qed_print_protection_override_results,
7480 : : qed_get_protection_override_results_buf_size}, {
7481 : : "fw_asserts",
7482 : : qed_dbg_fw_asserts_get_dump_buf_size,
7483 : : qed_dbg_fw_asserts_dump,
7484 : : qed_print_fw_asserts_results,
7485 : : qed_get_fw_asserts_results_buf_size}, {
7486 : : "ilt",
7487 : : qed_dbg_ilt_get_dump_buf_size,
7488 : : qed_dbg_ilt_dump, NULL, NULL},};
7489 : :
7490 : : #define QED_RESULTS_BUF_MIN_SIZE 16
7491 : : /* Generic function for decoding debug feature info */
7492 : 0 : static enum dbg_status format_feature(struct ecore_hwfn *p_hwfn,
7493 : : enum ecore_dbg_features feature_idx)
7494 : : {
7495 : : struct ecore_dbg_feature *feature =
7496 : 0 : &p_hwfn->p_dev->dbg_params.features[feature_idx];
7497 : : u32 text_size_bytes, null_char_pos, i;
7498 : : enum dbg_status rc;
7499 : : char *text_buf;
7500 : :
7501 : : /* Check if feature supports formatting capability */
7502 [ # # ]: 0 : if (!qed_features_lookup[feature_idx].results_buf_size)
7503 : : return DBG_STATUS_OK;
7504 : :
7505 : : /* Obtain size of formatted output */
7506 : 0 : rc = qed_features_lookup[feature_idx].results_buf_size(p_hwfn,
7507 : 0 : (u32 *)feature->dump_buf,
7508 : : feature->dumped_dwords,
7509 : : &text_size_bytes);
7510 [ # # ]: 0 : if (rc != DBG_STATUS_OK)
7511 : : return rc;
7512 : :
7513 : : /* Make sure that the allocated size is a multiple of dword (4 bytes) */
7514 : 0 : null_char_pos = text_size_bytes - 1;
7515 : 0 : text_size_bytes = (text_size_bytes + 3) & ~0x3;
7516 : :
7517 [ # # ]: 0 : if (text_size_bytes < QED_RESULTS_BUF_MIN_SIZE) {
7518 : 0 : DP_NOTICE(p_hwfn->p_dev, false,
7519 : : "formatted size of feature was too small %d. Aborting\n",
7520 : : text_size_bytes);
7521 : 0 : return DBG_STATUS_INVALID_ARGS;
7522 : : }
7523 : :
7524 : : /* Allocate temp text buf */
7525 : 0 : text_buf = OSAL_VZALLOC(p_hwfn, text_size_bytes);
7526 [ # # ]: 0 : if (!text_buf) {
7527 : 0 : DP_NOTICE(p_hwfn->p_dev, false,
7528 : : "failed to allocate text buffer. Aborting\n");
7529 : 0 : return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
7530 : : }
7531 : :
7532 : : /* Decode feature opcodes to string on temp buf */
7533 : 0 : rc = qed_features_lookup[feature_idx].print_results(p_hwfn,
7534 : 0 : (u32 *)feature->dump_buf,
7535 : : feature->dumped_dwords,
7536 : : text_buf);
7537 [ # # ]: 0 : if (rc != DBG_STATUS_OK) {
7538 : 0 : OSAL_VFREE(p_hwfn, text_buf);
7539 : 0 : return rc;
7540 : : }
7541 : :
7542 : : /* Replace the original null character with a '\n' character.
7543 : : * The bytes that were added as a result of the dword alignment are also
7544 : : * padded with '\n' characters.
7545 : : */
7546 [ # # ]: 0 : for (i = null_char_pos; i < text_size_bytes; i++)
7547 : 0 : text_buf[i] = '\n';
7548 : :
7549 : :
7550 : : /* Free the old dump_buf and point the dump_buf to the newly allocated
7551 : : * and formatted text buffer.
7552 : : */
7553 : 0 : OSAL_VFREE(p_hwfn, feature->dump_buf);
7554 : 0 : feature->dump_buf = (u8 *)text_buf;
7555 : 0 : feature->buf_size = text_size_bytes;
7556 : 0 : feature->dumped_dwords = text_size_bytes / 4;
7557 : 0 : return rc;
7558 : : }
7559 : :
7560 : : #define MAX_DBG_FEATURE_SIZE_DWORDS 0x3FFFFFFF
7561 : :
7562 : : /* Generic function for performing the dump of a debug feature. */
7563 : 0 : static enum dbg_status qed_dbg_dump(struct ecore_hwfn *p_hwfn,
7564 : : struct ecore_ptt *p_ptt,
7565 : : enum ecore_dbg_features feature_idx)
7566 : : {
7567 : : struct ecore_dbg_feature *feature =
7568 : 0 : &p_hwfn->p_dev->dbg_params.features[feature_idx];
7569 : : u32 buf_size_dwords;
7570 : : enum dbg_status rc;
7571 : :
7572 : 0 : DP_NOTICE(p_hwfn->p_dev, false, "Collecting a debug feature [\"%s\"]\n",
7573 : : qed_features_lookup[feature_idx].name);
7574 : :
7575 : : /* Dump_buf was already allocated need to free (this can happen if dump
7576 : : * was called but file was never read).
7577 : : * We can't use the buffer as is since size may have changed.
7578 : : */
7579 [ # # ]: 0 : if (feature->dump_buf) {
7580 : 0 : OSAL_VFREE(p_hwfn, feature->dump_buf);
7581 : : feature->dump_buf = NULL;
7582 : : }
7583 : :
7584 : : /* Get buffer size from hsi, allocate accordingly, and perform the
7585 : : * dump.
7586 : : */
7587 : 0 : rc = qed_features_lookup[feature_idx].get_size(p_hwfn, p_ptt,
7588 : : &buf_size_dwords);
7589 [ # # ]: 0 : if (rc != DBG_STATUS_OK && rc != DBG_STATUS_NVRAM_GET_IMAGE_FAILED)
7590 : : return rc;
7591 : :
7592 [ # # ]: 0 : if (buf_size_dwords > MAX_DBG_FEATURE_SIZE_DWORDS) {
7593 : 0 : feature->buf_size = 0;
7594 : 0 : DP_NOTICE(p_hwfn->p_dev, false,
7595 : : "Debug feature [\"%s\"] size (0x%x dwords) exceeds maximum size (0x%x dwords)\n",
7596 : : qed_features_lookup[feature_idx].name,
7597 : : buf_size_dwords, MAX_DBG_FEATURE_SIZE_DWORDS);
7598 : :
7599 : 0 : return DBG_STATUS_OK;
7600 : : }
7601 : :
7602 : 0 : feature->buf_size = buf_size_dwords * sizeof(u32);
7603 : 0 : feature->dump_buf = OSAL_ZALLOC(p_hwfn, GFP_KERNEL, feature->buf_size);
7604 [ # # ]: 0 : if (!feature->dump_buf)
7605 : : return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
7606 : :
7607 : 0 : rc = qed_features_lookup[feature_idx].perform_dump(p_hwfn, p_ptt,
7608 : : (u32 *)feature->dump_buf,
7609 : 0 : feature->buf_size / sizeof(u32),
7610 : : &feature->dumped_dwords);
7611 : :
7612 : : /* If mcp is stuck we get DBG_STATUS_NVRAM_GET_IMAGE_FAILED error.
7613 : : * In this case the buffer holds valid binary data, but we won't able
7614 : : * to parse it (since parsing relies on data in NVRAM which is only
7615 : : * accessible when MFW is responsive). skip the formatting but return
7616 : : * success so that binary data is provided.
7617 : : */
7618 [ # # ]: 0 : if (rc == DBG_STATUS_NVRAM_GET_IMAGE_FAILED)
7619 : : return DBG_STATUS_OK;
7620 : :
7621 [ # # ]: 0 : if (rc != DBG_STATUS_OK)
7622 : : return rc;
7623 : :
7624 : : /* Format output */
7625 : 0 : rc = format_feature(p_hwfn, feature_idx);
7626 : 0 : return rc;
7627 : : }
7628 : :
7629 : 0 : int qed_dbg_grc(struct ecore_dev *edev, void *buffer, u32 *num_dumped_bytes)
7630 : : {
7631 : 0 : return qed_dbg_feature(edev, buffer, DBG_FEATURE_GRC, num_dumped_bytes);
7632 : : }
7633 : :
7634 : 0 : int qed_dbg_grc_size(struct ecore_dev *edev)
7635 : : {
7636 : 0 : return qed_dbg_feature_size(edev, DBG_FEATURE_GRC);
7637 : : }
7638 : :
7639 : : int
7640 : 0 : qed_dbg_idle_chk(struct ecore_dev *edev, void *buffer, u32 *num_dumped_bytes)
7641 : : {
7642 : 0 : return qed_dbg_feature(edev, buffer, DBG_FEATURE_IDLE_CHK,
7643 : : num_dumped_bytes);
7644 : : }
7645 : :
7646 : 0 : int qed_dbg_idle_chk_size(struct ecore_dev *edev)
7647 : : {
7648 : 0 : return qed_dbg_feature_size(edev, DBG_FEATURE_IDLE_CHK);
7649 : : }
7650 : :
7651 : : int
7652 : 0 : qed_dbg_reg_fifo(struct ecore_dev *edev, void *buffer, u32 *num_dumped_bytes)
7653 : : {
7654 : 0 : return qed_dbg_feature(edev, buffer, DBG_FEATURE_REG_FIFO,
7655 : : num_dumped_bytes);
7656 : : }
7657 : :
7658 : 0 : int qed_dbg_reg_fifo_size(struct ecore_dev *edev)
7659 : : {
7660 : 0 : return qed_dbg_feature_size(edev, DBG_FEATURE_REG_FIFO);
7661 : : }
7662 : :
7663 : : int
7664 : 0 : qed_dbg_igu_fifo(struct ecore_dev *edev, void *buffer, u32 *num_dumped_bytes)
7665 : : {
7666 : 0 : return qed_dbg_feature(edev, buffer, DBG_FEATURE_IGU_FIFO,
7667 : : num_dumped_bytes);
7668 : : }
7669 : :
7670 : 0 : int qed_dbg_igu_fifo_size(struct ecore_dev *edev)
7671 : : {
7672 : 0 : return qed_dbg_feature_size(edev, DBG_FEATURE_IGU_FIFO);
7673 : : }
7674 : :
7675 : : static int qed_dbg_nvm_image_length(struct ecore_hwfn *p_hwfn,
7676 : : enum ecore_nvm_images image_id, u32 *length)
7677 : : {
7678 : : struct ecore_nvm_image_att image_att;
7679 : : int rc;
7680 : :
7681 : : *length = 0;
7682 : 0 : rc = ecore_mcp_get_nvm_image_att(p_hwfn, image_id, &image_att);
7683 [ # # # # : 0 : if (rc)
# # # # ]
7684 : : return rc;
7685 : :
7686 : 0 : *length = image_att.length;
7687 : :
7688 : : return rc;
7689 : : }
7690 : :
7691 : 0 : int qed_dbg_protection_override(struct ecore_dev *edev, void *buffer,
7692 : : u32 *num_dumped_bytes)
7693 : : {
7694 : 0 : return qed_dbg_feature(edev, buffer, DBG_FEATURE_PROTECTION_OVERRIDE,
7695 : : num_dumped_bytes);
7696 : : }
7697 : :
7698 : 0 : int qed_dbg_protection_override_size(struct ecore_dev *edev)
7699 : : {
7700 : 0 : return qed_dbg_feature_size(edev, DBG_FEATURE_PROTECTION_OVERRIDE);
7701 : : }
7702 : :
7703 : 0 : int qed_dbg_fw_asserts(struct ecore_dev *edev, void *buffer,
7704 : : u32 *num_dumped_bytes)
7705 : : {
7706 : 0 : return qed_dbg_feature(edev, buffer, DBG_FEATURE_FW_ASSERTS,
7707 : : num_dumped_bytes);
7708 : : }
7709 : :
7710 : 0 : int qed_dbg_fw_asserts_size(struct ecore_dev *edev)
7711 : : {
7712 : 0 : return qed_dbg_feature_size(edev, DBG_FEATURE_FW_ASSERTS);
7713 : : }
7714 : :
7715 : 0 : int qed_dbg_ilt(struct ecore_dev *edev, void *buffer, u32 *num_dumped_bytes)
7716 : : {
7717 : 0 : return qed_dbg_feature(edev, buffer, DBG_FEATURE_ILT, num_dumped_bytes);
7718 : : }
7719 : :
7720 : 0 : int qed_dbg_ilt_size(struct ecore_dev *edev)
7721 : : {
7722 : 0 : return qed_dbg_feature_size(edev, DBG_FEATURE_ILT);
7723 : : }
7724 : :
7725 : 0 : int qed_dbg_mcp_trace(struct ecore_dev *edev, void *buffer,
7726 : : u32 *num_dumped_bytes)
7727 : : {
7728 : 0 : return qed_dbg_feature(edev, buffer, DBG_FEATURE_MCP_TRACE,
7729 : : num_dumped_bytes);
7730 : : }
7731 : :
7732 : 0 : int qed_dbg_mcp_trace_size(struct ecore_dev *edev)
7733 : : {
7734 : 0 : return qed_dbg_feature_size(edev, DBG_FEATURE_MCP_TRACE);
7735 : : }
7736 : :
7737 : : /* Defines the amount of bytes allocated for recording the length of debug
7738 : : * feature buffer.
7739 : : */
7740 : : #define REGDUMP_HEADER_SIZE sizeof(u32)
7741 : : #define REGDUMP_HEADER_SIZE_SHIFT 0
7742 : : #define REGDUMP_HEADER_SIZE_MASK 0xffffff
7743 : : #define REGDUMP_HEADER_FEATURE_SHIFT 24
7744 : : #define REGDUMP_HEADER_FEATURE_MASK 0x3f
7745 : : #define REGDUMP_HEADER_OMIT_ENGINE_SHIFT 30
7746 : : #define REGDUMP_HEADER_OMIT_ENGINE_MASK 0x1
7747 : : #define REGDUMP_HEADER_ENGINE_SHIFT 31
7748 : : #define REGDUMP_HEADER_ENGINE_MASK 0x1
7749 : : #define REGDUMP_MAX_SIZE 0x1000000
7750 : : #define ILT_DUMP_MAX_SIZE (1024 * 1024 * 15)
7751 : :
7752 : : enum debug_print_features {
7753 : : OLD_MODE = 0,
7754 : : IDLE_CHK = 1,
7755 : : GRC_DUMP = 2,
7756 : : MCP_TRACE = 3,
7757 : : REG_FIFO = 4,
7758 : : PROTECTION_OVERRIDE = 5,
7759 : : IGU_FIFO = 6,
7760 : : PHY = 7,
7761 : : FW_ASSERTS = 8,
7762 : : NVM_CFG1 = 9,
7763 : : DEFAULT_CFG = 10,
7764 : : NVM_META = 11,
7765 : : MDUMP = 12,
7766 : : ILT_DUMP = 13,
7767 : : };
7768 : :
7769 : 0 : static u32 qed_calc_regdump_header(struct ecore_dev *edev,
7770 : : enum debug_print_features feature,
7771 : : int engine, u32 feature_size, u8 omit_engine)
7772 : : {
7773 : : u32 res = 0;
7774 : :
7775 : 0 : SET_FIELD(res, REGDUMP_HEADER_SIZE, feature_size);
7776 [ # # ]: 0 : if (res != feature_size)
7777 : 0 : DP_NOTICE(edev, false,
7778 : : "Feature %d is too large (size 0x%x) and will corrupt the dump\n",
7779 : : feature, feature_size);
7780 : :
7781 : 0 : SET_FIELD(res, REGDUMP_HEADER_FEATURE, feature);
7782 : 0 : SET_FIELD(res, REGDUMP_HEADER_OMIT_ENGINE, omit_engine);
7783 : 0 : SET_FIELD(res, REGDUMP_HEADER_ENGINE, engine);
7784 : :
7785 : 0 : return res;
7786 : : }
7787 : :
7788 : 0 : int qed_dbg_all_data(struct ecore_dev *edev, void *buffer)
7789 : : {
7790 : : u8 cur_engine, omit_engine = 0, org_engine;
7791 : : struct ecore_hwfn *p_hwfn =
7792 : 0 : &edev->hwfns[edev->dbg_params.engine_for_debug];
7793 : : struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
7794 : : int grc_params[MAX_DBG_GRC_PARAMS], i;
7795 : : u32 offset = 0, feature_size;
7796 : : int rc;
7797 : :
7798 [ # # ]: 0 : for (i = 0; i < MAX_DBG_GRC_PARAMS; i++)
7799 : 0 : grc_params[i] = dev_data->grc.param_val[i];
7800 : :
7801 [ # # ]: 0 : if (!ECORE_IS_CMT(edev))
7802 : : omit_engine = 1;
7803 : :
7804 : 0 : OSAL_MUTEX_ACQUIRE(&edev->dbg_lock);
7805 : :
7806 : 0 : org_engine = qed_get_debug_engine(edev);
7807 [ # # ]: 0 : for (cur_engine = 0; cur_engine < edev->num_hwfns; cur_engine++) {
7808 : : /* Collect idle_chks and grcDump for each hw function */
7809 [ # # ]: 0 : DP_VERBOSE(edev, ECORE_MSG_DEBUG,
7810 : : "obtaining idle_chk and grcdump for current engine\n");
7811 : 0 : qed_set_debug_engine(edev, cur_engine);
7812 : :
7813 : : /* First idle_chk */
7814 : 0 : rc = qed_dbg_idle_chk(edev, (u8 *)buffer + offset +
7815 : : REGDUMP_HEADER_SIZE, &feature_size);
7816 [ # # ]: 0 : if (!rc) {
7817 : 0 : *(u32 *)((u8 *)buffer + offset) =
7818 : 0 : qed_calc_regdump_header(edev, IDLE_CHK, cur_engine,
7819 : : feature_size, omit_engine);
7820 : 0 : offset += (feature_size + REGDUMP_HEADER_SIZE);
7821 : : } else {
7822 : 0 : DP_ERR(edev, "qed_dbg_idle_chk failed. rc = %d\n", rc);
7823 : : }
7824 : :
7825 : : /* Second idle_chk */
7826 : 0 : rc = qed_dbg_idle_chk(edev, (u8 *)buffer + offset +
7827 : : REGDUMP_HEADER_SIZE, &feature_size);
7828 [ # # ]: 0 : if (!rc) {
7829 : 0 : *(u32 *)((u8 *)buffer + offset) =
7830 : 0 : qed_calc_regdump_header(edev, IDLE_CHK, cur_engine,
7831 : : feature_size, omit_engine);
7832 : 0 : offset += (feature_size + REGDUMP_HEADER_SIZE);
7833 : : } else {
7834 : 0 : DP_ERR(edev, "qed_dbg_idle_chk failed. rc = %d\n", rc);
7835 : : }
7836 : :
7837 : : /* reg_fifo dump */
7838 : 0 : rc = qed_dbg_reg_fifo(edev, (u8 *)buffer + offset +
7839 : : REGDUMP_HEADER_SIZE, &feature_size);
7840 [ # # ]: 0 : if (!rc) {
7841 : 0 : *(u32 *)((u8 *)buffer + offset) =
7842 : 0 : qed_calc_regdump_header(edev, REG_FIFO, cur_engine,
7843 : : feature_size, omit_engine);
7844 : 0 : offset += (feature_size + REGDUMP_HEADER_SIZE);
7845 : : } else {
7846 : 0 : DP_ERR(edev, "qed_dbg_reg_fifo failed. rc = %d\n", rc);
7847 : : }
7848 : :
7849 : : /* igu_fifo dump */
7850 : 0 : rc = qed_dbg_igu_fifo(edev, (u8 *)buffer + offset +
7851 : : REGDUMP_HEADER_SIZE, &feature_size);
7852 [ # # ]: 0 : if (!rc) {
7853 : 0 : *(u32 *)((u8 *)buffer + offset) =
7854 : 0 : qed_calc_regdump_header(edev, IGU_FIFO, cur_engine,
7855 : : feature_size, omit_engine);
7856 : 0 : offset += (feature_size + REGDUMP_HEADER_SIZE);
7857 : : } else {
7858 : 0 : DP_ERR(edev, "qed_dbg_igu_fifo failed. rc = %d", rc);
7859 : : }
7860 : :
7861 : : /* protection_override dump */
7862 : 0 : rc = qed_dbg_protection_override(edev, (u8 *)buffer + offset +
7863 : : REGDUMP_HEADER_SIZE,
7864 : : &feature_size);
7865 [ # # ]: 0 : if (!rc) {
7866 : 0 : *(u32 *)((u8 *)buffer + offset) =
7867 : 0 : qed_calc_regdump_header(edev, PROTECTION_OVERRIDE,
7868 : : cur_engine,
7869 : : feature_size, omit_engine);
7870 : 0 : offset += (feature_size + REGDUMP_HEADER_SIZE);
7871 : : } else {
7872 : 0 : DP_ERR(edev,
7873 : : "qed_dbg_protection_override failed. rc = %d\n",
7874 : : rc);
7875 : : }
7876 : :
7877 : : /* fw_asserts dump */
7878 : 0 : rc = qed_dbg_fw_asserts(edev, (u8 *)buffer + offset +
7879 : : REGDUMP_HEADER_SIZE, &feature_size);
7880 [ # # ]: 0 : if (!rc) {
7881 : 0 : *(u32 *)((u8 *)buffer + offset) =
7882 : 0 : qed_calc_regdump_header(edev, FW_ASSERTS,
7883 : : cur_engine, feature_size,
7884 : : omit_engine);
7885 : 0 : offset += (feature_size + REGDUMP_HEADER_SIZE);
7886 : : } else {
7887 : 0 : DP_ERR(edev, "qed_dbg_fw_asserts failed. rc = %d\n",
7888 : : rc);
7889 : : }
7890 : :
7891 : : /* GRC dump - must be last because when mcp stuck it will
7892 : : * clutter idle_chk, reg_fifo, ...
7893 : : */
7894 [ # # ]: 0 : for (i = 0; i < MAX_DBG_GRC_PARAMS; i++)
7895 : 0 : dev_data->grc.param_val[i] = grc_params[i];
7896 : :
7897 : 0 : rc = qed_dbg_grc(edev, (u8 *)buffer + offset +
7898 : : REGDUMP_HEADER_SIZE, &feature_size);
7899 [ # # ]: 0 : if (!rc) {
7900 : 0 : *(u32 *)((u8 *)buffer + offset) =
7901 : 0 : qed_calc_regdump_header(edev, GRC_DUMP,
7902 : : cur_engine,
7903 : : feature_size, omit_engine);
7904 : 0 : offset += (feature_size + REGDUMP_HEADER_SIZE);
7905 : : } else {
7906 : 0 : DP_ERR(edev, "qed_dbg_grc failed. rc = %d", rc);
7907 : : }
7908 : : }
7909 : :
7910 : 0 : qed_set_debug_engine(edev, org_engine);
7911 : :
7912 : : /* mcp_trace */
7913 : 0 : rc = qed_dbg_mcp_trace(edev, (u8 *)buffer + offset +
7914 : : REGDUMP_HEADER_SIZE, &feature_size);
7915 [ # # ]: 0 : if (!rc) {
7916 : 0 : *(u32 *)((u8 *)buffer + offset) =
7917 : 0 : qed_calc_regdump_header(edev, MCP_TRACE, cur_engine,
7918 : : feature_size, omit_engine);
7919 : : offset += (feature_size + REGDUMP_HEADER_SIZE);
7920 : : } else {
7921 : 0 : DP_ERR(edev, "qed_dbg_mcp_trace failed. rc = %d\n", rc);
7922 : : }
7923 : :
7924 : 0 : OSAL_MUTEX_RELEASE(&edev->dbg_lock);
7925 : :
7926 : 0 : return 0;
7927 : : }
7928 : :
7929 : 0 : int qed_dbg_all_data_size(struct ecore_dev *edev)
7930 : : {
7931 : 0 : struct ecore_hwfn *p_hwfn =
7932 : 0 : &edev->hwfns[edev->dbg_params.engine_for_debug];
7933 : : u32 regs_len = 0, image_len = 0, ilt_len = 0, total_ilt_len = 0;
7934 : : u8 cur_engine, org_engine;
7935 : :
7936 : 0 : edev->disable_ilt_dump = false;
7937 : 0 : org_engine = qed_get_debug_engine(edev);
7938 [ # # ]: 0 : for (cur_engine = 0; cur_engine < edev->num_hwfns; cur_engine++) {
7939 : : /* Engine specific */
7940 [ # # ]: 0 : DP_VERBOSE(edev, ECORE_MSG_DEBUG,
7941 : : "calculating idle_chk and grcdump register length for current engine\n");
7942 : 0 : qed_set_debug_engine(edev, cur_engine);
7943 : 0 : regs_len += REGDUMP_HEADER_SIZE + qed_dbg_idle_chk_size(edev) +
7944 : 0 : REGDUMP_HEADER_SIZE + qed_dbg_idle_chk_size(edev) +
7945 : 0 : REGDUMP_HEADER_SIZE + qed_dbg_grc_size(edev) +
7946 : 0 : REGDUMP_HEADER_SIZE + qed_dbg_reg_fifo_size(edev) +
7947 : 0 : REGDUMP_HEADER_SIZE + qed_dbg_igu_fifo_size(edev) +
7948 : 0 : REGDUMP_HEADER_SIZE +
7949 : 0 : qed_dbg_protection_override_size(edev) +
7950 : 0 : REGDUMP_HEADER_SIZE + qed_dbg_fw_asserts_size(edev);
7951 : :
7952 : 0 : ilt_len = REGDUMP_HEADER_SIZE + qed_dbg_ilt_size(edev);
7953 [ # # ]: 0 : if (ilt_len < ILT_DUMP_MAX_SIZE) {
7954 : 0 : total_ilt_len += ilt_len;
7955 : 0 : regs_len += ilt_len;
7956 : : }
7957 : : }
7958 : :
7959 : 0 : qed_set_debug_engine(edev, org_engine);
7960 : :
7961 : : /* Engine common */
7962 : 0 : regs_len += REGDUMP_HEADER_SIZE + qed_dbg_mcp_trace_size(edev);
7963 : : qed_dbg_nvm_image_length(p_hwfn, ECORE_NVM_IMAGE_NVM_CFG1, &image_len);
7964 [ # # ]: 0 : if (image_len)
7965 : 0 : regs_len += REGDUMP_HEADER_SIZE + image_len;
7966 : : qed_dbg_nvm_image_length(p_hwfn, ECORE_NVM_IMAGE_DEFAULT_CFG,
7967 : : &image_len);
7968 [ # # ]: 0 : if (image_len)
7969 : 0 : regs_len += REGDUMP_HEADER_SIZE + image_len;
7970 : : qed_dbg_nvm_image_length(p_hwfn, ECORE_NVM_IMAGE_NVM_META, &image_len);
7971 [ # # ]: 0 : if (image_len)
7972 : 0 : regs_len += REGDUMP_HEADER_SIZE + image_len;
7973 : : qed_dbg_nvm_image_length(p_hwfn, ECORE_NVM_IMAGE_MDUMP, &image_len);
7974 [ # # ]: 0 : if (image_len)
7975 : 0 : regs_len += REGDUMP_HEADER_SIZE + image_len;
7976 : :
7977 [ # # ]: 0 : if (regs_len > REGDUMP_MAX_SIZE) {
7978 [ # # ]: 0 : DP_VERBOSE(edev, ECORE_MSG_DEBUG,
7979 : : "Dump exceeds max size 0x%x, disable ILT dump\n",
7980 : : REGDUMP_MAX_SIZE);
7981 : 0 : edev->disable_ilt_dump = true;
7982 : 0 : regs_len -= total_ilt_len;
7983 : : }
7984 : :
7985 : 0 : return regs_len;
7986 : : }
7987 : :
7988 : 0 : int qed_dbg_feature(struct ecore_dev *edev, void *buffer,
7989 : : enum ecore_dbg_features feature, u32 *num_dumped_bytes)
7990 : : {
7991 : 0 : struct ecore_hwfn *p_hwfn =
7992 : 0 : &edev->hwfns[edev->dbg_params.engine_for_debug];
7993 : : struct ecore_dbg_feature *qed_feature =
7994 : : &edev->dbg_params.features[feature];
7995 : : enum dbg_status dbg_rc;
7996 : : struct ecore_ptt *p_ptt;
7997 : : int rc = 0;
7998 : :
7999 : : /* Acquire ptt */
8000 : 0 : p_ptt = ecore_ptt_acquire(p_hwfn);
8001 [ # # ]: 0 : if (!p_ptt)
8002 : : return -EINVAL;
8003 : :
8004 : : /* Get dump */
8005 : 0 : dbg_rc = qed_dbg_dump(p_hwfn, p_ptt, feature);
8006 [ # # ]: 0 : if (dbg_rc != DBG_STATUS_OK) {
8007 [ # # ]: 0 : DP_VERBOSE(edev, ECORE_MSG_DEBUG, "%s\n",
8008 : : qed_dbg_get_status_str(dbg_rc));
8009 : 0 : *num_dumped_bytes = 0;
8010 : : rc = -EINVAL;
8011 : 0 : goto out;
8012 : : }
8013 : :
8014 [ # # ]: 0 : DP_VERBOSE(edev, ECORE_MSG_DEBUG,
8015 : : "copying debug feature to external buffer\n");
8016 : 0 : memcpy(buffer, qed_feature->dump_buf, qed_feature->buf_size);
8017 : 0 : *num_dumped_bytes = edev->dbg_params.features[feature].dumped_dwords *
8018 : : 4;
8019 : :
8020 : 0 : out:
8021 : 0 : ecore_ptt_release(p_hwfn, p_ptt);
8022 : 0 : return rc;
8023 : : }
8024 : :
8025 : : int
8026 : 0 : qed_dbg_feature_size(struct ecore_dev *edev, enum ecore_dbg_features feature)
8027 : : {
8028 : 0 : struct ecore_hwfn *p_hwfn =
8029 : 0 : &edev->hwfns[edev->dbg_params.engine_for_debug];
8030 : : struct ecore_dbg_feature *qed_feature = &edev->dbg_features[feature];
8031 : 0 : struct ecore_ptt *p_ptt = ecore_ptt_acquire(p_hwfn);
8032 : : u32 buf_size_dwords;
8033 : : enum dbg_status rc;
8034 : :
8035 [ # # ]: 0 : if (!p_ptt)
8036 : : return -EINVAL;
8037 : :
8038 : 0 : rc = qed_features_lookup[feature].get_size(p_hwfn, p_ptt,
8039 : : &buf_size_dwords);
8040 [ # # ]: 0 : if (rc != DBG_STATUS_OK)
8041 : 0 : buf_size_dwords = 0;
8042 : :
8043 : : /* Feature will not be dumped if it exceeds maximum size */
8044 [ # # ]: 0 : if (buf_size_dwords > MAX_DBG_FEATURE_SIZE_DWORDS)
8045 : 0 : buf_size_dwords = 0;
8046 : :
8047 : 0 : ecore_ptt_release(p_hwfn, p_ptt);
8048 : 0 : qed_feature->buf_size = buf_size_dwords * sizeof(u32);
8049 : 0 : return qed_feature->buf_size;
8050 : : }
8051 : :
8052 : 0 : u8 qed_get_debug_engine(struct ecore_dev *edev)
8053 : : {
8054 : 0 : return edev->dbg_params.engine_for_debug;
8055 : : }
8056 : :
8057 : 0 : void qed_set_debug_engine(struct ecore_dev *edev, int engine_number)
8058 : : {
8059 [ # # ]: 0 : DP_VERBOSE(edev, ECORE_MSG_DEBUG, "set debug engine to %d\n",
8060 : : engine_number);
8061 : 0 : edev->dbg_params.engine_for_debug = engine_number;
8062 : 0 : }
8063 : :
8064 : 0 : void qed_dbg_pf_init(struct ecore_dev *edev)
8065 : : {
8066 : : const u8 *dbg_values = NULL;
8067 : : int i;
8068 : :
8069 : 0 : PMD_INIT_FUNC_TRACE(edev);
8070 : :
8071 : 0 : OSAL_MUTEX_INIT(&edev->dbg_lock);
8072 : :
8073 : : /* Debug values are after init values.
8074 : : * The offset is the first dword of the file.
8075 : : */
8076 : : /* TBD: change hardcoded value to offset from FW file */
8077 : 0 : dbg_values = (const u8 *)edev->firmware + 1337296;
8078 : :
8079 [ # # ]: 0 : for_each_hwfn(edev, i) {
8080 : 0 : qed_dbg_set_bin_ptr(&edev->hwfns[i], dbg_values);
8081 : 0 : qed_dbg_user_set_bin_ptr(&edev->hwfns[i], dbg_values);
8082 : : }
8083 : :
8084 : : /* Set the hwfn to be 0 as default */
8085 : 0 : edev->dbg_params.engine_for_debug = 0;
8086 : 0 : }
8087 : :
8088 : 0 : void qed_dbg_pf_exit(struct ecore_dev *edev)
8089 : : {
8090 : : struct ecore_dbg_feature *feature = NULL;
8091 : : enum ecore_dbg_features feature_idx;
8092 : :
8093 : 0 : PMD_INIT_FUNC_TRACE(edev);
8094 : :
8095 : : /* debug features' buffers may be allocated if debug feature was used
8096 : : * but dump wasn't called
8097 : : */
8098 [ # # ]: 0 : for (feature_idx = 0; feature_idx < DBG_FEATURE_NUM; feature_idx++) {
8099 : : feature = &edev->dbg_features[feature_idx];
8100 [ # # ]: 0 : if (feature->dump_buf) {
8101 : 0 : OSAL_VFREE(edev, feature->dump_buf);
8102 : : feature->dump_buf = NULL;
8103 : : }
8104 : : }
8105 : :
8106 : : OSAL_MUTEX_DEALLOC(&edev->dbg_lock);
8107 : 0 : }
|