Skip to content

Commit 8fa4219

Browse files
Edwin Peerkuba-moo
authored andcommitted
bnxt_en: add dynamic debug support for HWRM messages
Add logging of firmware messages. These can be useful for diagnosing issues in the field, but due to their verbosity are only appropriate at a debug message level. Signed-off-by: Edwin Peer <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 4ccdcc8 commit 8fa4219

File tree

2 files changed

+50
-21
lines changed

2 files changed

+50
-21
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,6 +2086,9 @@ static int bnxt_async_event_process(struct bnxt *bp,
20862086
u32 data1 = le32_to_cpu(cmpl->event_data1);
20872087
u32 data2 = le32_to_cpu(cmpl->event_data2);
20882088

2089+
netdev_dbg(bp->dev, "hwrm event 0x%x {0x%x, 0x%x}\n",
2090+
event_id, data1, data2);
2091+
20892092
/* TODO CHIMP_FW: Define event id's for link change, error etc */
20902093
switch (event_id) {
20912094
case ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE: {

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

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,32 @@ hwrm_update_token(struct bnxt *bp, u16 seq_id, enum bnxt_hwrm_wait_state state)
416416
netdev_err(bp->dev, "Invalid hwrm seq id %d\n", seq_id);
417417
}
418418

419+
static void hwrm_req_dbg(struct bnxt *bp, struct input *req)
420+
{
421+
u32 ring = le16_to_cpu(req->cmpl_ring);
422+
u32 type = le16_to_cpu(req->req_type);
423+
u32 tgt = le16_to_cpu(req->target_id);
424+
u32 seq = le16_to_cpu(req->seq_id);
425+
char opt[32] = "\n";
426+
427+
if (unlikely(ring != (u16)BNXT_HWRM_NO_CMPL_RING))
428+
snprintf(opt, 16, " ring %d\n", ring);
429+
430+
if (unlikely(tgt != BNXT_HWRM_TARGET))
431+
snprintf(opt + strlen(opt) - 1, 16, " tgt 0x%x\n", tgt);
432+
433+
netdev_dbg(bp->dev, "sent hwrm req_type 0x%x seq id 0x%x%s",
434+
type, seq, opt);
435+
}
436+
437+
#define hwrm_err(bp, ctx, fmt, ...) \
438+
do { \
439+
if ((ctx)->flags & BNXT_HWRM_CTX_SILENT) \
440+
netdev_dbg((bp)->dev, fmt, __VA_ARGS__); \
441+
else \
442+
netdev_err((bp)->dev, fmt, __VA_ARGS__); \
443+
} while (0)
444+
419445
static int __hwrm_send(struct bnxt *bp, struct bnxt_hwrm_ctx *ctx)
420446
{
421447
u32 doorbell_offset = BNXT_GRCPF_REG_CHIMP_COMM_TRIGGER;
@@ -436,8 +462,11 @@ static int __hwrm_send(struct bnxt *bp, struct bnxt_hwrm_ctx *ctx)
436462
memset(ctx->resp, 0, PAGE_SIZE);
437463

438464
req_type = le16_to_cpu(ctx->req->req_type);
439-
if (BNXT_NO_FW_ACCESS(bp) && req_type != HWRM_FUNC_RESET)
465+
if (BNXT_NO_FW_ACCESS(bp) && req_type != HWRM_FUNC_RESET) {
466+
netdev_dbg(bp->dev, "hwrm req_type 0x%x skipped, FW channel down\n",
467+
req_type);
440468
goto exit;
469+
}
441470

442471
if (msg_len > BNXT_HWRM_MAX_REQ_LEN &&
443472
msg_len > bp->hwrm_max_ext_req_len) {
@@ -490,6 +519,8 @@ static int __hwrm_send(struct bnxt *bp, struct bnxt_hwrm_ctx *ctx)
490519
/* Ring channel doorbell */
491520
writel(1, bp->bar0 + doorbell_offset);
492521

522+
hwrm_req_dbg(bp, ctx->req);
523+
493524
if (!pci_is_enabled(bp->pdev)) {
494525
rc = -ENODEV;
495526
goto exit;
@@ -531,9 +562,8 @@ static int __hwrm_send(struct bnxt *bp, struct bnxt_hwrm_ctx *ctx)
531562
}
532563

533564
if (READ_ONCE(token->state) != BNXT_HWRM_COMPLETE) {
534-
if (!(ctx->flags & BNXT_HWRM_CTX_SILENT))
535-
netdev_err(bp->dev, "Resp cmpl intr err msg: 0x%x\n",
536-
le16_to_cpu(ctx->req->req_type));
565+
hwrm_err(bp, ctx, "Resp cmpl intr err msg: 0x%x\n",
566+
req_type);
537567
goto exit;
538568
}
539569
len = le16_to_cpu(READ_ONCE(ctx->resp->resp_len));
@@ -565,7 +595,7 @@ static int __hwrm_send(struct bnxt *bp, struct bnxt_hwrm_ctx *ctx)
565595
if (resp_seq != seen_out_of_seq) {
566596
netdev_warn(bp->dev, "Discarding out of seq response: 0x%x for msg {0x%x 0x%x}\n",
567597
le16_to_cpu(resp_seq),
568-
le16_to_cpu(ctx->req->req_type),
598+
req_type,
569599
le16_to_cpu(ctx->req->seq_id));
570600
seen_out_of_seq = resp_seq;
571601
}
@@ -585,11 +615,9 @@ static int __hwrm_send(struct bnxt *bp, struct bnxt_hwrm_ctx *ctx)
585615

586616
if (i >= tmo_count) {
587617
timeout_abort:
588-
if (!(ctx->flags & BNXT_HWRM_CTX_SILENT))
589-
netdev_err(bp->dev, "Error (timeout: %u) msg {0x%x 0x%x} len:%d\n",
590-
hwrm_total_timeout(i),
591-
le16_to_cpu(ctx->req->req_type),
592-
le16_to_cpu(ctx->req->seq_id), len);
618+
hwrm_err(bp, ctx, "Error (timeout: %u) msg {0x%x 0x%x} len:%d\n",
619+
hwrm_total_timeout(i), req_type,
620+
le16_to_cpu(ctx->req->seq_id), len);
593621
goto exit;
594622
}
595623

@@ -604,12 +632,9 @@ static int __hwrm_send(struct bnxt *bp, struct bnxt_hwrm_ctx *ctx)
604632
}
605633

606634
if (j >= HWRM_VALID_BIT_DELAY_USEC) {
607-
if (!(ctx->flags & BNXT_HWRM_CTX_SILENT))
608-
netdev_err(bp->dev, "Error (timeout: %u) msg {0x%x 0x%x} len:%d v:%d\n",
609-
hwrm_total_timeout(i),
610-
le16_to_cpu(ctx->req->req_type),
611-
le16_to_cpu(ctx->req->seq_id), len,
612-
*valid);
635+
hwrm_err(bp, ctx, "Error (timeout: %u) msg {0x%x 0x%x} len:%d v:%d\n",
636+
hwrm_total_timeout(i), req_type,
637+
le16_to_cpu(ctx->req->seq_id), len, *valid);
613638
goto exit;
614639
}
615640
}
@@ -620,11 +645,12 @@ static int __hwrm_send(struct bnxt *bp, struct bnxt_hwrm_ctx *ctx)
620645
*/
621646
*valid = 0;
622647
rc = le16_to_cpu(ctx->resp->error_code);
623-
if (rc && !(ctx->flags & BNXT_HWRM_CTX_SILENT)) {
624-
netdev_err(bp->dev, "hwrm req_type 0x%x seq id 0x%x error 0x%x\n",
625-
le16_to_cpu(ctx->resp->req_type),
626-
le16_to_cpu(ctx->resp->seq_id), rc);
627-
}
648+
if (rc == HWRM_ERR_CODE_BUSY && !(ctx->flags & BNXT_HWRM_CTX_SILENT))
649+
netdev_warn(bp->dev, "FW returned busy, hwrm req_type 0x%x\n",
650+
req_type);
651+
else if (rc)
652+
hwrm_err(bp, ctx, "hwrm req_type 0x%x seq id 0x%x error 0x%x\n",
653+
req_type, token->seq_id, rc);
628654
rc = __hwrm_to_stderr(rc);
629655
exit:
630656
if (token)

0 commit comments

Comments
 (0)