Skip to content

Commit 27fed78

Browse files
caildavem330
authored andcommitted
qed: implement devlink dump
Gather and push out full device dump to devlink. Device dump is the same as with `ethtool -d`, but now its generated exactly at the moment bad thing happens. Signed-off-by: Igor Russkikh <irusskikh@marvell.com> Signed-off-by: Alexander Lobakin <alobakin@marvell.com> Signed-off-by: Michal Kalderon <michal.kalderon@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b228cb1 commit 27fed78

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

‎drivers/net/ethernet/qlogic/qed/qed_devlink.c‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <linux/kernel.h>
88
#include <linux/qed/qed_if.h>
9+
#include <linux/vmalloc.h>
910
#include "qed.h"
1011
#include "qed_devlink.h"
1112

@@ -32,6 +33,47 @@ int qed_report_fatal_error(struct devlink *devlink, enum qed_hw_err_type err_typ
3233
return 0;
3334
}
3435

36+
static int
37+
qed_fw_fatal_reporter_dump(struct devlink_health_reporter *reporter,
38+
struct devlink_fmsg *fmsg, void *priv_ctx,
39+
struct netlink_ext_ack *extack)
40+
{
41+
struct qed_devlink *qdl = devlink_health_reporter_priv(reporter);
42+
struct qed_fw_fatal_ctx *fw_fatal_ctx = priv_ctx;
43+
struct qed_dev *cdev = qdl->cdev;
44+
u32 dbg_data_buf_size;
45+
u8 *p_dbg_data_buf;
46+
int err;
47+
48+
/* Having context means that was a dump request after fatal,
49+
* so we enable extra debugging while gathering the dump,
50+
* just in case
51+
*/
52+
cdev->print_dbg_data = fw_fatal_ctx ? true : false;
53+
54+
dbg_data_buf_size = qed_dbg_all_data_size(cdev);
55+
p_dbg_data_buf = vzalloc(dbg_data_buf_size);
56+
if (!p_dbg_data_buf) {
57+
DP_NOTICE(cdev,
58+
"Failed to allocate memory for a debug data buffer\n");
59+
return -ENOMEM;
60+
}
61+
62+
err = qed_dbg_all_data(cdev, p_dbg_data_buf);
63+
if (err) {
64+
DP_NOTICE(cdev, "Failed to obtain debug data\n");
65+
vfree(p_dbg_data_buf);
66+
return err;
67+
}
68+
69+
err = devlink_fmsg_binary_pair_put(fmsg, "dump_data",
70+
p_dbg_data_buf, dbg_data_buf_size);
71+
72+
vfree(p_dbg_data_buf);
73+
74+
return err;
75+
}
76+
3577
static int
3678
qed_fw_fatal_reporter_recover(struct devlink_health_reporter *reporter,
3779
void *priv_ctx,
@@ -48,6 +90,7 @@ qed_fw_fatal_reporter_recover(struct devlink_health_reporter *reporter,
4890
static const struct devlink_health_reporter_ops qed_fw_fatal_reporter_ops = {
4991
.name = "fw_fatal",
5092
.recover = qed_fw_fatal_reporter_recover,
93+
.dump = qed_fw_fatal_reporter_dump,
5194
};
5295

5396
#define QED_REPORTER_FW_GRACEFUL_PERIOD 1200000

0 commit comments

Comments
 (0)