Skip to content

Commit bda2e63

Browse files
Michael Chankuba-moo
authored andcommitted
bnxt_en: Add a new ethtool -W dump flag
Add a new ethtool -W dump flag (2) to include driver coredump segments. This patch adds the host backing store context memory pages used by the chip and FW to store various states to the coredump. The pages for each context memory type is dumped into a separate coredump segment. Reviewed-by: Andy Gospodarek <[email protected]> Reviewed-by: Selvin Thyparampil Xavier <[email protected]> Reviewed-by: Shruti Parab <[email protected]> Reviewed-by: Kalesh AP <[email protected]> Reviewed-by: Saravanan Vajravel <[email protected]> Reviewed-by: Kashyap Desai <[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 a854a17 commit bda2e63

File tree

4 files changed

+90
-7
lines changed

4 files changed

+90
-7
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2662,6 +2662,7 @@ struct bnxt {
26622662
u16 dump_flag;
26632663
#define BNXT_DUMP_LIVE 0
26642664
#define BNXT_DUMP_CRASH 1
2665+
#define BNXT_DUMP_DRIVER 2
26652666

26662667
struct bpf_prog *xdp_prog;
26672668

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

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@
1515
#include "bnxt_hwrm.h"
1616
#include "bnxt_coredump.h"
1717

18+
static const u16 bnxt_bstore_to_seg_id[] = {
19+
[BNXT_CTX_QP] = BNXT_CTX_MEM_SEG_QP,
20+
[BNXT_CTX_SRQ] = BNXT_CTX_MEM_SEG_SRQ,
21+
[BNXT_CTX_CQ] = BNXT_CTX_MEM_SEG_CQ,
22+
[BNXT_CTX_VNIC] = BNXT_CTX_MEM_SEG_VNIC,
23+
[BNXT_CTX_STAT] = BNXT_CTX_MEM_SEG_STAT,
24+
[BNXT_CTX_STQM] = BNXT_CTX_MEM_SEG_STQM,
25+
[BNXT_CTX_FTQM] = BNXT_CTX_MEM_SEG_FTQM,
26+
[BNXT_CTX_MRAV] = BNXT_CTX_MEM_SEG_MRAV,
27+
[BNXT_CTX_TIM] = BNXT_CTX_MEM_SEG_TIM,
28+
};
29+
1830
static int bnxt_hwrm_dbg_dma_data(struct bnxt *bp, void *msg,
1931
struct bnxt_hwrm_dbg_dma_info *info)
2032
{
@@ -267,7 +279,47 @@ bnxt_fill_coredump_record(struct bnxt *bp, struct bnxt_coredump_record *record,
267279
record->ioctl_high_version = 0;
268280
}
269281

270-
static int __bnxt_get_coredump(struct bnxt *bp, void *buf, u32 *dump_len)
282+
static u32 bnxt_get_ctx_coredump(struct bnxt *bp, void *buf, u32 offset,
283+
u32 *segs)
284+
{
285+
struct bnxt_coredump_segment_hdr seg_hdr;
286+
struct bnxt_ctx_mem_info *ctx = bp->ctx;
287+
u32 comp_id = BNXT_DRV_COMP_ID;
288+
void *data = NULL;
289+
size_t len = 0;
290+
u16 type;
291+
292+
*segs = 0;
293+
if (!ctx)
294+
return 0;
295+
296+
if (buf)
297+
buf += offset;
298+
for (type = 0 ; type <= BNXT_CTX_TIM; type++) {
299+
struct bnxt_ctx_mem_type *ctxm = &ctx->ctx_arr[type];
300+
u32 seg_id = bnxt_bstore_to_seg_id[type];
301+
size_t seg_len;
302+
303+
if (!ctxm->entry_size || !ctxm->pg_info || !seg_id)
304+
continue;
305+
306+
if (buf)
307+
data = buf + BNXT_SEG_HDR_LEN;
308+
seg_len = bnxt_copy_ctx_mem(bp, ctxm, data, 0);
309+
if (buf) {
310+
bnxt_fill_coredump_seg_hdr(bp, &seg_hdr, NULL, seg_len,
311+
0, 0, 0, comp_id, seg_id);
312+
memcpy(buf, &seg_hdr, BNXT_SEG_HDR_LEN);
313+
buf += BNXT_SEG_HDR_LEN + seg_len;
314+
}
315+
len += BNXT_SEG_HDR_LEN + seg_len;
316+
*segs += 1;
317+
}
318+
return len;
319+
}
320+
321+
static int __bnxt_get_coredump(struct bnxt *bp, u16 dump_type, void *buf,
322+
u32 *dump_len)
271323
{
272324
u32 ver_get_resp_len = sizeof(struct hwrm_ver_get_output);
273325
u32 offset = 0, seg_hdr_len, seg_record_len, buf_len = 0;
@@ -298,6 +350,18 @@ static int __bnxt_get_coredump(struct bnxt *bp, void *buf, u32 *dump_len)
298350
offset += ver_get_resp_len;
299351
}
300352

353+
if (dump_type == BNXT_DUMP_DRIVER) {
354+
u32 drv_len, segs = 0;
355+
356+
drv_len = bnxt_get_ctx_coredump(bp, buf, offset, &segs);
357+
*dump_len += drv_len;
358+
offset += drv_len;
359+
if (buf)
360+
coredump.total_segs += segs;
361+
goto err;
362+
}
363+
364+
seg_record_len = sizeof(*seg_record);
301365
rc = bnxt_hwrm_dbg_coredump_list(bp, &coredump);
302366
if (rc) {
303367
netdev_err(bp->dev, "Failed to get coredump segment list\n");
@@ -442,7 +506,7 @@ int bnxt_get_coredump(struct bnxt *bp, u16 dump_type, void *buf, u32 *dump_len)
442506
else
443507
return -EOPNOTSUPP;
444508
} else {
445-
return __bnxt_get_coredump(bp, buf, dump_len);
509+
return __bnxt_get_coredump(bp, dump_type, buf, dump_len);
446510
}
447511
}
448512

@@ -512,9 +576,12 @@ u32 bnxt_get_coredump_length(struct bnxt *bp, u16 dump_type)
512576
return bp->fw_crash_len;
513577
}
514578

515-
if (bnxt_hwrm_get_dump_len(bp, dump_type, &len)) {
516-
if (dump_type != BNXT_DUMP_CRASH)
517-
__bnxt_get_coredump(bp, NULL, &len);
579+
if (dump_type != BNXT_DUMP_DRIVER) {
580+
if (!bnxt_hwrm_get_dump_len(bp, dump_type, &len))
581+
return len;
518582
}
583+
if (dump_type != BNXT_DUMP_CRASH)
584+
__bnxt_get_coredump(bp, dump_type, NULL, &len);
585+
519586
return len;
520587
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,27 @@ struct bnxt_coredump_record {
6969
};
7070

7171
#define BNXT_VER_GET_COMP_ID 2
72+
#define BNXT_DRV_COMP_ID 0xd
73+
74+
#define BNXT_CTX_MEM_SEG_ID_START 0x200
75+
76+
#define BNXT_CTX_MEM_SEG_QP (BNXT_CTX_MEM_SEG_ID_START + BNXT_CTX_QP)
77+
#define BNXT_CTX_MEM_SEG_SRQ (BNXT_CTX_MEM_SEG_ID_START + BNXT_CTX_SRQ)
78+
#define BNXT_CTX_MEM_SEG_CQ (BNXT_CTX_MEM_SEG_ID_START + BNXT_CTX_CQ)
79+
#define BNXT_CTX_MEM_SEG_VNIC (BNXT_CTX_MEM_SEG_ID_START + BNXT_CTX_VNIC)
80+
#define BNXT_CTX_MEM_SEG_STAT (BNXT_CTX_MEM_SEG_ID_START + BNXT_CTX_STAT)
81+
#define BNXT_CTX_MEM_SEG_STQM (BNXT_CTX_MEM_SEG_ID_START + BNXT_CTX_STQM)
82+
#define BNXT_CTX_MEM_SEG_FTQM (BNXT_CTX_MEM_SEG_ID_START + BNXT_CTX_FTQM)
83+
#define BNXT_CTX_MEM_SEG_MRAV (BNXT_CTX_MEM_SEG_ID_START + BNXT_CTX_MRAV)
84+
#define BNXT_CTX_MEM_SEG_TIM (BNXT_CTX_MEM_SEG_ID_START + BNXT_CTX_TIM)
7285

7386
#define BNXT_CRASH_DUMP_LEN (8 << 20)
7487

7588
#define COREDUMP_LIST_BUF_LEN 2048
7689
#define COREDUMP_RETRIEVE_BUF_LEN 4096
7790

91+
#define BNXT_SEG_HDR_LEN sizeof(struct bnxt_coredump_segment_hdr)
92+
7893
struct bnxt_coredump {
7994
void *data;
8095
int data_size;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4984,8 +4984,8 @@ static int bnxt_set_dump(struct net_device *dev, struct ethtool_dump *dump)
49844984
{
49854985
struct bnxt *bp = netdev_priv(dev);
49864986

4987-
if (dump->flag > BNXT_DUMP_CRASH) {
4988-
netdev_info(dev, "Supports only Live(0) and Crash(1) dumps.\n");
4987+
if (dump->flag > BNXT_DUMP_DRIVER) {
4988+
netdev_info(dev, "Supports only Live(0), Crash(1), Driver(2) dumps.\n");
49894989
return -EINVAL;
49904990
}
49914991

0 commit comments

Comments
 (0)