Skip to content

Commit bc10274

Browse files
besheltoanguy11
authored andcommitted
ice: Add MDD logging via devlink health
Add a devlink health reporter for MDD events. The 'dump' handler will return the information captured in each call to ice_handle_mdd_event(). A device reset (CORER/PFR) will put the reporter back in healthy state. Signed-off-by: Ben Shelton <benjamin.h.shelton@intel.com> Reviewed-by: Igor Bagnucki <igor.bagnucki@intel.com> Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com> Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel) Co-developed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 2a82874 commit bc10274

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed

drivers/net/ethernet/intel/ice/devlink/health.c

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,79 @@ static void ice_devlink_health_report(struct devlink_health_reporter *reporter,
2626
devlink_health_report(reporter, msg, priv_ctx);
2727
}
2828

29+
struct ice_mdd_event {
30+
enum ice_mdd_src src;
31+
u16 vf_num;
32+
u16 queue;
33+
u8 pf_num;
34+
u8 event;
35+
};
36+
37+
static const char *ice_mdd_src_to_str(enum ice_mdd_src src)
38+
{
39+
switch (src) {
40+
case ICE_MDD_SRC_TX_PQM:
41+
return "tx_pqm";
42+
case ICE_MDD_SRC_TX_TCLAN:
43+
return "tx_tclan";
44+
case ICE_MDD_SRC_TX_TDPU:
45+
return "tx_tdpu";
46+
case ICE_MDD_SRC_RX:
47+
return "rx";
48+
default:
49+
return "invalid";
50+
}
51+
}
52+
53+
static int
54+
ice_mdd_reporter_dump(struct devlink_health_reporter *reporter,
55+
struct devlink_fmsg *fmsg, void *priv_ctx,
56+
struct netlink_ext_ack *extack)
57+
{
58+
struct ice_mdd_event *mdd_event = priv_ctx;
59+
const char *src;
60+
61+
if (!mdd_event)
62+
return 0;
63+
64+
src = ice_mdd_src_to_str(mdd_event->src);
65+
66+
devlink_fmsg_obj_nest_start(fmsg);
67+
devlink_fmsg_put(fmsg, "src", src);
68+
ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, mdd_event, pf_num);
69+
ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, mdd_event, vf_num);
70+
ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, mdd_event, event);
71+
ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, mdd_event, queue);
72+
devlink_fmsg_obj_nest_end(fmsg);
73+
74+
return 0;
75+
}
76+
77+
/**
78+
* ice_report_mdd_event - Report an MDD event through devlink health
79+
* @pf: the PF device structure
80+
* @src: the HW block that was the source of this MDD event
81+
* @pf_num: the pf_num on which the MDD event occurred
82+
* @vf_num: the vf_num on which the MDD event occurred
83+
* @event: the event type of the MDD event
84+
* @queue: the queue on which the MDD event occurred
85+
*
86+
* Report an MDD event that has occurred on this PF.
87+
*/
88+
void ice_report_mdd_event(struct ice_pf *pf, enum ice_mdd_src src, u8 pf_num,
89+
u16 vf_num, u8 event, u16 queue)
90+
{
91+
struct ice_mdd_event ev = {
92+
.src = src,
93+
.pf_num = pf_num,
94+
.vf_num = vf_num,
95+
.event = event,
96+
.queue = queue,
97+
};
98+
99+
ice_devlink_health_report(pf->health_reporters.mdd, "MDD event", &ev);
100+
}
101+
29102
/**
30103
* ice_fmsg_put_ptr - put hex value of pointer into fmsg
31104
*
@@ -136,6 +209,7 @@ ice_init_devlink_rep(struct ice_pf *pf,
136209
.dump = ice_ ## _name ## _reporter_dump, \
137210
}
138211

212+
ICE_DEFINE_HEALTH_REPORTER_OPS(mdd);
139213
ICE_DEFINE_HEALTH_REPORTER_OPS(tx_hang);
140214

141215
/**
@@ -148,6 +222,7 @@ void ice_health_init(struct ice_pf *pf)
148222
{
149223
struct ice_health *reps = &pf->health_reporters;
150224

225+
reps->mdd = ice_init_devlink_rep(pf, &ice_mdd_reporter_ops);
151226
reps->tx_hang = ice_init_devlink_rep(pf, &ice_tx_hang_reporter_ops);
152227
}
153228

@@ -169,6 +244,7 @@ static void ice_deinit_devl_reporter(struct devlink_health_reporter *reporter)
169244
*/
170245
void ice_health_deinit(struct ice_pf *pf)
171246
{
247+
ice_deinit_devl_reporter(pf->health_reporters.mdd);
172248
ice_deinit_devl_reporter(pf->health_reporters.tx_hang);
173249
}
174250

@@ -188,5 +264,6 @@ void ice_health_assign_healthy_state(struct devlink_health_reporter *reporter)
188264
*/
189265
void ice_health_clear(struct ice_pf *pf)
190266
{
267+
ice_health_assign_healthy_state(pf->health_reporters.mdd);
191268
ice_health_assign_healthy_state(pf->health_reporters.tx_hang);
192269
}

drivers/net/ethernet/intel/ice/devlink/health.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,17 @@
1616
struct ice_pf;
1717
struct ice_tx_ring;
1818

19+
enum ice_mdd_src {
20+
ICE_MDD_SRC_TX_PQM,
21+
ICE_MDD_SRC_TX_TCLAN,
22+
ICE_MDD_SRC_TX_TDPU,
23+
ICE_MDD_SRC_RX,
24+
};
25+
1926
/**
2027
* struct ice_health - stores ice devlink health reporters and accompanied data
2128
* @tx_hang: devlink health reporter for tx_hang event
29+
* @mdd: devlink health reporter for MDD detection event
2230
* @tx_hang_buf: pre-allocated place to put info for Tx hang reporter from
2331
* non-sleeping context
2432
* @tx_ring: ring that the hang occurred on
@@ -27,6 +35,7 @@ struct ice_tx_ring;
2735
* @vsi_num: VSI owning the queue that the hang occurred on
2836
*/
2937
struct ice_health {
38+
struct devlink_health_reporter *mdd;
3039
struct devlink_health_reporter *tx_hang;
3140
struct_group_tagged(ice_health_tx_hang_buf, tx_hang_buf,
3241
struct ice_tx_ring *tx_ring;
@@ -42,6 +51,8 @@ void ice_health_clear(struct ice_pf *pf);
4251

4352
void ice_prep_tx_hang_report(struct ice_pf *pf, struct ice_tx_ring *tx_ring,
4453
u16 vsi_num, u32 head, u32 intr);
54+
void ice_report_mdd_event(struct ice_pf *pf, enum ice_mdd_src src, u8 pf_num,
55+
u16 vf_num, u8 event, u16 queue);
4556
void ice_report_tx_hang(struct ice_pf *pf);
4657

4758
#endif /* _HEALTH_H_ */

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,6 +1816,8 @@ static void ice_handle_mdd_event(struct ice_pf *pf)
18161816
if (netif_msg_tx_err(pf))
18171817
dev_info(dev, "Malicious Driver Detection event %d on TX queue %d PF# %d VF# %d\n",
18181818
event, queue, pf_num, vf_num);
1819+
ice_report_mdd_event(pf, ICE_MDD_SRC_TX_PQM, pf_num, vf_num,
1820+
event, queue);
18191821
wr32(hw, GL_MDET_TX_PQM, 0xffffffff);
18201822
}
18211823

@@ -1829,6 +1831,8 @@ static void ice_handle_mdd_event(struct ice_pf *pf)
18291831
if (netif_msg_tx_err(pf))
18301832
dev_info(dev, "Malicious Driver Detection event %d on TX queue %d PF# %d VF# %d\n",
18311833
event, queue, pf_num, vf_num);
1834+
ice_report_mdd_event(pf, ICE_MDD_SRC_TX_TCLAN, pf_num, vf_num,
1835+
event, queue);
18321836
wr32(hw, GL_MDET_TX_TCLAN_BY_MAC(hw), U32_MAX);
18331837
}
18341838

@@ -1842,6 +1846,8 @@ static void ice_handle_mdd_event(struct ice_pf *pf)
18421846
if (netif_msg_rx_err(pf))
18431847
dev_info(dev, "Malicious Driver Detection event %d on RX queue %d PF# %d VF# %d\n",
18441848
event, queue, pf_num, vf_num);
1849+
ice_report_mdd_event(pf, ICE_MDD_SRC_RX, pf_num, vf_num, event,
1850+
queue);
18451851
wr32(hw, GL_MDET_RX, 0xffffffff);
18461852
}
18471853

0 commit comments

Comments
 (0)