Skip to content

Commit c21c8e1

Browse files
Shruti Parabkuba-moo
authored andcommitted
bnxt_en: Report the ethtool coredump length after copying the coredump
ethtool first calls .get_dump_flags() to get the dump length. For coredump, the driver calls the FW to get the coredump length (L1). The min. of L1 and the user specified length is then passed to .get_dump_data() (L2) to get the coredump. The actual coredump length retrieved by the FW (L3) during .get_dump_data() may be smaller than L1. This length discrepancy will trigger a WARN_ON() in ethtool_get_dump_data(). ethtool has already vzalloc'ed a buffer with size L1. Just report the coredump length as L2 even though the actual coredump length L3 may be smaller. The extra zero padding does not matter. This will prevent the warning that may alarm the user. For correctness, only do the final length update if there is no error. Reviewed-by: Andy Gospodarek <[email protected]> Reviewed-by: Damodharam Ammepalli <[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 0fcad44 commit c21c8e1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,9 +496,16 @@ static int __bnxt_get_coredump(struct bnxt *bp, u16 dump_type, void *buf,
496496
start_utc, coredump.total_segs + 1,
497497
rc);
498498
kfree(coredump.data);
499-
*dump_len += sizeof(struct bnxt_coredump_record);
500-
if (rc == -ENOBUFS)
499+
if (!rc) {
500+
*dump_len += sizeof(struct bnxt_coredump_record);
501+
/* The actual coredump length can be smaller than the FW
502+
* reported length earlier. Use the ethtool provided length.
503+
*/
504+
if (buf_len)
505+
*dump_len = buf_len;
506+
} else if (rc == -ENOBUFS) {
501507
netdev_err(bp->dev, "Firmware returned large coredump buffer\n");
508+
}
502509
return rc;
503510
}
504511

0 commit comments

Comments
 (0)