Skip to content

Commit 3c2179e

Browse files
Shruti Parabkuba-moo
authored andcommitted
bnxt_en: Add FW trace coredump segments to the coredump
The FW trace coredump segments are very similar to the context memory segments in the previous patch. The main difference is to call HWRM_DBG_LOG_BUFFER_FLUSH to flush the FW data to host memory and to include an additional record in the coredump that contains the head and tail information of the trace data. Reviewed-by: Hongguang Gao <[email protected]> Signed-off-by: Shruti Parab <[email protected]> Signed-off-by: Michael Chan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent bda2e63 commit 3c2179e

File tree

2 files changed

+90
-6
lines changed

2 files changed

+90
-6
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c

Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,40 @@ static const u16 bnxt_bstore_to_seg_id[] = {
2525
[BNXT_CTX_FTQM] = BNXT_CTX_MEM_SEG_FTQM,
2626
[BNXT_CTX_MRAV] = BNXT_CTX_MEM_SEG_MRAV,
2727
[BNXT_CTX_TIM] = BNXT_CTX_MEM_SEG_TIM,
28+
[BNXT_CTX_SRT] = BNXT_CTX_MEM_SEG_SRT,
29+
[BNXT_CTX_SRT2] = BNXT_CTX_MEM_SEG_SRT2,
30+
[BNXT_CTX_CRT] = BNXT_CTX_MEM_SEG_CRT,
31+
[BNXT_CTX_CRT2] = BNXT_CTX_MEM_SEG_CRT2,
32+
[BNXT_CTX_RIGP0] = BNXT_CTX_MEM_SEG_RIGP0,
33+
[BNXT_CTX_L2HWRM] = BNXT_CTX_MEM_SEG_L2HWRM,
34+
[BNXT_CTX_REHWRM] = BNXT_CTX_MEM_SEG_REHWRM,
35+
[BNXT_CTX_CA0] = BNXT_CTX_MEM_SEG_CA0,
36+
[BNXT_CTX_CA1] = BNXT_CTX_MEM_SEG_CA1,
37+
[BNXT_CTX_CA2] = BNXT_CTX_MEM_SEG_CA2,
38+
[BNXT_CTX_RIGP1] = BNXT_CTX_MEM_SEG_RIGP1,
2839
};
2940

41+
static int bnxt_dbg_hwrm_log_buffer_flush(struct bnxt *bp, u16 type, u32 flags,
42+
u32 *offset)
43+
{
44+
struct hwrm_dbg_log_buffer_flush_output *resp;
45+
struct hwrm_dbg_log_buffer_flush_input *req;
46+
int rc;
47+
48+
rc = hwrm_req_init(bp, req, HWRM_DBG_LOG_BUFFER_FLUSH);
49+
if (rc)
50+
return rc;
51+
52+
req->flags = cpu_to_le32(flags);
53+
req->type = cpu_to_le16(type);
54+
resp = hwrm_req_hold(bp, req);
55+
rc = hwrm_req_send(bp, req);
56+
if (!rc)
57+
*offset = le32_to_cpu(resp->current_buffer_offset);
58+
hwrm_req_drop(bp, req);
59+
return rc;
60+
}
61+
3062
static int bnxt_hwrm_dbg_dma_data(struct bnxt *bp, void *msg,
3163
struct bnxt_hwrm_dbg_dma_info *info)
3264
{
@@ -279,9 +311,29 @@ bnxt_fill_coredump_record(struct bnxt *bp, struct bnxt_coredump_record *record,
279311
record->ioctl_high_version = 0;
280312
}
281313

314+
static void bnxt_fill_drv_seg_record(struct bnxt *bp,
315+
struct bnxt_driver_segment_record *record,
316+
struct bnxt_ctx_mem_type *ctxm, u16 type)
317+
{
318+
struct bnxt_bs_trace_info *bs_trace = &bp->bs_trace[type];
319+
u32 offset = 0;
320+
int rc = 0;
321+
322+
rc = bnxt_dbg_hwrm_log_buffer_flush(bp, type, 0, &offset);
323+
if (rc)
324+
return;
325+
326+
bnxt_bs_trace_check_wrap(bs_trace, offset);
327+
record->max_entries = cpu_to_le32(ctxm->max_entries);
328+
record->entry_size = cpu_to_le32(ctxm->entry_size);
329+
record->offset = cpu_to_le32(bs_trace->last_offset);
330+
record->wrapped = bs_trace->wrapped;
331+
}
332+
282333
static u32 bnxt_get_ctx_coredump(struct bnxt *bp, void *buf, u32 offset,
283334
u32 *segs)
284335
{
336+
struct bnxt_driver_segment_record record = {};
285337
struct bnxt_coredump_segment_hdr seg_hdr;
286338
struct bnxt_ctx_mem_info *ctx = bp->ctx;
287339
u32 comp_id = BNXT_DRV_COMP_ID;
@@ -295,22 +347,33 @@ static u32 bnxt_get_ctx_coredump(struct bnxt *bp, void *buf, u32 offset,
295347

296348
if (buf)
297349
buf += offset;
298-
for (type = 0 ; type <= BNXT_CTX_TIM; type++) {
350+
for (type = 0 ; type <= BNXT_CTX_RIGP1; type++) {
299351
struct bnxt_ctx_mem_type *ctxm = &ctx->ctx_arr[type];
352+
bool trace = bnxt_bs_trace_avail(bp, type);
300353
u32 seg_id = bnxt_bstore_to_seg_id[type];
301-
size_t seg_len;
354+
size_t seg_len, extra_hlen = 0;
302355

303-
if (!ctxm->entry_size || !ctxm->pg_info || !seg_id)
356+
if (!ctxm->mem_valid || !seg_id)
304357
continue;
305358

359+
if (trace)
360+
extra_hlen = BNXT_SEG_RCD_LEN;
306361
if (buf)
307-
data = buf + BNXT_SEG_HDR_LEN;
308-
seg_len = bnxt_copy_ctx_mem(bp, ctxm, data, 0);
362+
data = buf + BNXT_SEG_HDR_LEN + extra_hlen;
363+
seg_len = bnxt_copy_ctx_mem(bp, ctxm, data, 0) + extra_hlen;
309364
if (buf) {
310365
bnxt_fill_coredump_seg_hdr(bp, &seg_hdr, NULL, seg_len,
311366
0, 0, 0, comp_id, seg_id);
312367
memcpy(buf, &seg_hdr, BNXT_SEG_HDR_LEN);
313-
buf += BNXT_SEG_HDR_LEN + seg_len;
368+
buf += BNXT_SEG_HDR_LEN;
369+
if (trace) {
370+
u16 trace_type = bnxt_bstore_to_trace[type];
371+
372+
bnxt_fill_drv_seg_record(bp, &record, ctxm,
373+
trace_type);
374+
memcpy(buf, &record, BNXT_SEG_RCD_LEN);
375+
}
376+
buf += seg_len;
314377
}
315378
len += BNXT_SEG_HDR_LEN + seg_len;
316379
*segs += 1;

drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ struct bnxt_coredump_record {
6868
__le16 rsvd3[313];
6969
};
7070

71+
struct bnxt_driver_segment_record {
72+
__le32 max_entries;
73+
__le32 entry_size;
74+
__le32 offset;
75+
__u8 wrapped:1;
76+
__u8 unused[3];
77+
};
78+
7179
#define BNXT_VER_GET_COMP_ID 2
7280
#define BNXT_DRV_COMP_ID 0xd
7381

@@ -83,12 +91,25 @@ struct bnxt_coredump_record {
8391
#define BNXT_CTX_MEM_SEG_MRAV (BNXT_CTX_MEM_SEG_ID_START + BNXT_CTX_MRAV)
8492
#define BNXT_CTX_MEM_SEG_TIM (BNXT_CTX_MEM_SEG_ID_START + BNXT_CTX_TIM)
8593

94+
#define BNXT_CTX_MEM_SEG_SRT 0x1
95+
#define BNXT_CTX_MEM_SEG_SRT2 0x2
96+
#define BNXT_CTX_MEM_SEG_CRT 0x3
97+
#define BNXT_CTX_MEM_SEG_CRT2 0x4
98+
#define BNXT_CTX_MEM_SEG_RIGP0 0x5
99+
#define BNXT_CTX_MEM_SEG_L2HWRM 0x6
100+
#define BNXT_CTX_MEM_SEG_REHWRM 0x7
101+
#define BNXT_CTX_MEM_SEG_CA0 0x8
102+
#define BNXT_CTX_MEM_SEG_CA1 0x9
103+
#define BNXT_CTX_MEM_SEG_CA2 0xa
104+
#define BNXT_CTX_MEM_SEG_RIGP1 0xb
105+
86106
#define BNXT_CRASH_DUMP_LEN (8 << 20)
87107

88108
#define COREDUMP_LIST_BUF_LEN 2048
89109
#define COREDUMP_RETRIEVE_BUF_LEN 4096
90110

91111
#define BNXT_SEG_HDR_LEN sizeof(struct bnxt_coredump_segment_hdr)
112+
#define BNXT_SEG_RCD_LEN sizeof(struct bnxt_driver_segment_record)
92113

93114
struct bnxt_coredump {
94115
void *data;

0 commit comments

Comments
 (0)