Skip to content

Commit 2a82874

Browse files
pkitszelanguy11
authored andcommitted
ice: add Tx hang devlink health reporter
Add Tx hang devlink health reporter, see struct ice_tx_hang_event to see what exactly is reported. For now dump descriptors with little metadata and skb diagnostic information. Reviewed-by: Igor Bagnucki <igor.bagnucki@intel.com> Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com> Co-developed-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com> Signed-off-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com> Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel) Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 2846fe5 commit 2a82874

File tree

5 files changed

+255
-5
lines changed

5 files changed

+255
-5
lines changed

drivers/net/ethernet/intel/ice/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ ice-y := ice_main.o \
3232
ice_parser_rt.o \
3333
ice_idc.o \
3434
devlink/devlink.o \
35+
devlink/health.o \
3536
devlink/port.o \
3637
ice_sf_eth.o \
3738
ice_sf_vsi_vlan_ops.o \
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/* Copyright (c) 2024, Intel Corporation. */
3+
4+
#include "health.h"
5+
#include "ice.h"
6+
7+
#define ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, obj, name) \
8+
devlink_fmsg_put(fmsg, #name, (obj)->name)
9+
10+
/**
11+
* ice_devlink_health_report - boilerplate to call given @reporter
12+
*
13+
* @reporter: devlink health reporter to call, do nothing on NULL
14+
* @msg: message to pass up, "event name" is fine
15+
* @priv_ctx: typically some event struct
16+
*/
17+
static void ice_devlink_health_report(struct devlink_health_reporter *reporter,
18+
const char *msg, void *priv_ctx)
19+
{
20+
if (!reporter)
21+
return;
22+
23+
/* We do not do auto recovering, so return value of the below function
24+
* will always be 0, thus we do ignore it.
25+
*/
26+
devlink_health_report(reporter, msg, priv_ctx);
27+
}
28+
29+
/**
30+
* ice_fmsg_put_ptr - put hex value of pointer into fmsg
31+
*
32+
* @fmsg: devlink fmsg under construction
33+
* @name: name to pass
34+
* @ptr: 64 bit value to print as hex and put into fmsg
35+
*/
36+
static void ice_fmsg_put_ptr(struct devlink_fmsg *fmsg, const char *name,
37+
void *ptr)
38+
{
39+
char buf[sizeof(ptr) * 3];
40+
41+
sprintf(buf, "%p", ptr);
42+
devlink_fmsg_put(fmsg, name, buf);
43+
}
44+
45+
struct ice_tx_hang_event {
46+
u32 head;
47+
u32 intr;
48+
u16 vsi_num;
49+
u16 queue;
50+
u16 next_to_clean;
51+
u16 next_to_use;
52+
struct ice_tx_ring *tx_ring;
53+
};
54+
55+
static int ice_tx_hang_reporter_dump(struct devlink_health_reporter *reporter,
56+
struct devlink_fmsg *fmsg, void *priv_ctx,
57+
struct netlink_ext_ack *extack)
58+
{
59+
struct ice_tx_hang_event *event = priv_ctx;
60+
struct sk_buff *skb;
61+
62+
if (!event)
63+
return 0;
64+
65+
skb = event->tx_ring->tx_buf->skb;
66+
devlink_fmsg_obj_nest_start(fmsg);
67+
ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, event, head);
68+
ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, event, intr);
69+
ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, event, vsi_num);
70+
ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, event, queue);
71+
ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, event, next_to_clean);
72+
ICE_DEVLINK_FMSG_PUT_FIELD(fmsg, event, next_to_use);
73+
devlink_fmsg_put(fmsg, "irq-mapping", event->tx_ring->q_vector->name);
74+
ice_fmsg_put_ptr(fmsg, "desc-ptr", event->tx_ring->desc);
75+
ice_fmsg_put_ptr(fmsg, "dma-ptr", (void *)(long)event->tx_ring->dma);
76+
ice_fmsg_put_ptr(fmsg, "skb-ptr", skb);
77+
devlink_fmsg_binary_pair_put(fmsg, "desc", event->tx_ring->desc,
78+
event->tx_ring->count * sizeof(struct ice_tx_desc));
79+
devlink_fmsg_dump_skb(fmsg, skb);
80+
devlink_fmsg_obj_nest_end(fmsg);
81+
82+
return 0;
83+
}
84+
85+
void ice_prep_tx_hang_report(struct ice_pf *pf, struct ice_tx_ring *tx_ring,
86+
u16 vsi_num, u32 head, u32 intr)
87+
{
88+
struct ice_health_tx_hang_buf *buf = &pf->health_reporters.tx_hang_buf;
89+
90+
buf->tx_ring = tx_ring;
91+
buf->vsi_num = vsi_num;
92+
buf->head = head;
93+
buf->intr = intr;
94+
}
95+
96+
void ice_report_tx_hang(struct ice_pf *pf)
97+
{
98+
struct ice_health_tx_hang_buf *buf = &pf->health_reporters.tx_hang_buf;
99+
struct ice_tx_ring *tx_ring = buf->tx_ring;
100+
101+
struct ice_tx_hang_event ev = {
102+
.head = buf->head,
103+
.intr = buf->intr,
104+
.vsi_num = buf->vsi_num,
105+
.queue = tx_ring->q_index,
106+
.next_to_clean = tx_ring->next_to_clean,
107+
.next_to_use = tx_ring->next_to_use,
108+
.tx_ring = tx_ring,
109+
};
110+
111+
ice_devlink_health_report(pf->health_reporters.tx_hang, "Tx hang", &ev);
112+
}
113+
114+
static struct devlink_health_reporter *
115+
ice_init_devlink_rep(struct ice_pf *pf,
116+
const struct devlink_health_reporter_ops *ops)
117+
{
118+
struct devlink *devlink = priv_to_devlink(pf);
119+
struct devlink_health_reporter *rep;
120+
const u64 graceful_period = 0;
121+
122+
rep = devl_health_reporter_create(devlink, ops, graceful_period, pf);
123+
if (IS_ERR(rep)) {
124+
struct device *dev = ice_pf_to_dev(pf);
125+
126+
dev_err(dev, "failed to create devlink %s health report er",
127+
ops->name);
128+
return NULL;
129+
}
130+
return rep;
131+
}
132+
133+
#define ICE_DEFINE_HEALTH_REPORTER_OPS(_name) \
134+
static const struct devlink_health_reporter_ops ice_ ## _name ## _reporter_ops = { \
135+
.name = #_name, \
136+
.dump = ice_ ## _name ## _reporter_dump, \
137+
}
138+
139+
ICE_DEFINE_HEALTH_REPORTER_OPS(tx_hang);
140+
141+
/**
142+
* ice_health_init - allocate and init all ice devlink health reporters and
143+
* accompanied data
144+
*
145+
* @pf: PF struct
146+
*/
147+
void ice_health_init(struct ice_pf *pf)
148+
{
149+
struct ice_health *reps = &pf->health_reporters;
150+
151+
reps->tx_hang = ice_init_devlink_rep(pf, &ice_tx_hang_reporter_ops);
152+
}
153+
154+
/**
155+
* ice_deinit_devl_reporter - destroy given devlink health reporter
156+
* @reporter: reporter to destroy
157+
*/
158+
static void ice_deinit_devl_reporter(struct devlink_health_reporter *reporter)
159+
{
160+
if (reporter)
161+
devl_health_reporter_destroy(reporter);
162+
}
163+
164+
/**
165+
* ice_health_deinit - deallocate all ice devlink health reporters and
166+
* accompanied data
167+
*
168+
* @pf: PF struct
169+
*/
170+
void ice_health_deinit(struct ice_pf *pf)
171+
{
172+
ice_deinit_devl_reporter(pf->health_reporters.tx_hang);
173+
}
174+
175+
static
176+
void ice_health_assign_healthy_state(struct devlink_health_reporter *reporter)
177+
{
178+
if (reporter)
179+
devlink_health_reporter_state_update(reporter,
180+
DEVLINK_HEALTH_REPORTER_STATE_HEALTHY);
181+
}
182+
183+
/**
184+
* ice_health_clear - clear devlink health issues after a reset
185+
* @pf: the PF device structure
186+
*
187+
* Mark the PF in healthy state again after a reset has completed.
188+
*/
189+
void ice_health_clear(struct ice_pf *pf)
190+
{
191+
ice_health_assign_healthy_state(pf->health_reporters.tx_hang);
192+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/* Copyright (c) 2024, Intel Corporation. */
3+
4+
#ifndef _HEALTH_H_
5+
#define _HEALTH_H_
6+
7+
#include <linux/types.h>
8+
9+
/**
10+
* DOC: health.h
11+
*
12+
* This header file stores everything that is needed for broadly understood
13+
* devlink health mechanism for ice driver.
14+
*/
15+
16+
struct ice_pf;
17+
struct ice_tx_ring;
18+
19+
/**
20+
* struct ice_health - stores ice devlink health reporters and accompanied data
21+
* @tx_hang: devlink health reporter for tx_hang event
22+
* @tx_hang_buf: pre-allocated place to put info for Tx hang reporter from
23+
* non-sleeping context
24+
* @tx_ring: ring that the hang occurred on
25+
* @head: descriptor head
26+
* @intr: interrupt register value
27+
* @vsi_num: VSI owning the queue that the hang occurred on
28+
*/
29+
struct ice_health {
30+
struct devlink_health_reporter *tx_hang;
31+
struct_group_tagged(ice_health_tx_hang_buf, tx_hang_buf,
32+
struct ice_tx_ring *tx_ring;
33+
u32 head;
34+
u32 intr;
35+
u16 vsi_num;
36+
);
37+
};
38+
39+
void ice_health_init(struct ice_pf *pf);
40+
void ice_health_deinit(struct ice_pf *pf);
41+
void ice_health_clear(struct ice_pf *pf);
42+
43+
void ice_prep_tx_hang_report(struct ice_pf *pf, struct ice_tx_ring *tx_ring,
44+
u16 vsi_num, u32 head, u32 intr);
45+
void ice_report_tx_hang(struct ice_pf *pf);
46+
47+
#endif /* _HEALTH_H_ */

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
#include "ice_irq.h"
7979
#include "ice_dpll.h"
8080
#include "ice_adapter.h"
81+
#include "devlink/health.h"
8182

8283
#define ICE_BAR0 0
8384
#define ICE_REQ_DESC_MULTIPLE 32
@@ -665,6 +666,7 @@ struct ice_pf {
665666
struct ice_agg_node vf_agg_node[ICE_MAX_VF_AGG_NODES];
666667
struct ice_dplls dplls;
667668
struct device *hwmon_dev;
669+
struct ice_health health_reporters;
668670

669671
u8 num_quanta_prof_used;
670672
};

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2364,9 +2364,11 @@ static void ice_service_task(struct work_struct *work)
23642364
struct ice_pf *pf = container_of(work, struct ice_pf, serv_task);
23652365
unsigned long start_time = jiffies;
23662366

2367-
/* subtasks */
2367+
if (pf->health_reporters.tx_hang_buf.tx_ring) {
2368+
ice_report_tx_hang(pf);
2369+
pf->health_reporters.tx_hang_buf.tx_ring = NULL;
2370+
}
23682371

2369-
/* process reset requests first */
23702372
ice_reset_subtask(pf);
23712373

23722374
/* bail if a reset/recovery cycle is pending or rebuild failed */
@@ -5087,6 +5089,7 @@ static int ice_init_devlink(struct ice_pf *pf)
50875089
return err;
50885090

50895091
ice_devlink_init_regions(pf);
5092+
ice_health_init(pf);
50905093
ice_devlink_register(pf);
50915094

50925095
return 0;
@@ -5095,6 +5098,7 @@ static int ice_init_devlink(struct ice_pf *pf)
50955098
static void ice_deinit_devlink(struct ice_pf *pf)
50965099
{
50975100
ice_devlink_unregister(pf);
5101+
ice_health_deinit(pf);
50985102
ice_devlink_destroy_regions(pf);
50995103
ice_devlink_unregister_params(pf);
51005104
}
@@ -7793,6 +7797,8 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)
77937797
/* if we get here, reset flow is successful */
77947798
clear_bit(ICE_RESET_FAILED, pf->state);
77957799

7800+
ice_health_clear(pf);
7801+
77967802
ice_plug_aux_dev(pf);
77977803
if (ice_is_feature_supported(pf, ICE_F_SRIOV_LAG))
77987804
ice_lag_rebuild(pf);
@@ -8283,16 +8289,18 @@ void ice_tx_timeout(struct net_device *netdev, unsigned int txqueue)
82838289

82848290
if (tx_ring) {
82858291
struct ice_hw *hw = &pf->hw;
8286-
u32 head, val = 0;
8292+
u32 head, intr = 0;
82878293

82888294
head = FIELD_GET(QTX_COMM_HEAD_HEAD_M,
82898295
rd32(hw, QTX_COMM_HEAD(vsi->txq_map[txqueue])));
82908296
/* Read interrupt register */
8291-
val = rd32(hw, GLINT_DYN_CTL(tx_ring->q_vector->reg_idx));
8297+
intr = rd32(hw, GLINT_DYN_CTL(tx_ring->q_vector->reg_idx));
82928298

82938299
netdev_info(netdev, "tx_timeout: VSI_num: %d, Q %u, NTC: 0x%x, HW_HEAD: 0x%x, NTU: 0x%x, INT: 0x%x\n",
82948300
vsi->vsi_num, txqueue, tx_ring->next_to_clean,
8295-
head, tx_ring->next_to_use, val);
8301+
head, tx_ring->next_to_use, intr);
8302+
8303+
ice_prep_tx_hang_report(pf, tx_ring, vsi->vsi_num, head, intr);
82968304
}
82978305

82988306
pf->tx_timeout_last_recovery = jiffies;

0 commit comments

Comments
 (0)