Skip to content

Commit 3089cf6

Browse files
jbrandebanguy11
authored andcommitted
ice: add tracepoints
This patch is modeled after one by Scott Peterson for i40e. Add tracepoints to the driver, via a new file ice_trace.h and some new trace calls added in interesting places in the driver. Add some tracing for DIMLIB to help debug interrupt moderation problems. Performance should not be affected, and this can be very useful for debugging and adding new trace events to paths in the future. Note eBPF programs can attach to these events, as well as perf can count them since we're attaching to the events subsystem in the kernel. Co-developed-by: Ben Shelton <[email protected]> Signed-off-by: Ben Shelton <[email protected]> Signed-off-by: Jesse Brandeburg <[email protected]> Tested-by: Tony Brelinski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 19938ba commit 3089cf6

File tree

3 files changed

+249
-0
lines changed

3 files changed

+249
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
#include "ice_dcb_lib.h"
1414
#include "ice_dcb_nl.h"
1515
#include "ice_devlink.h"
16+
/* Including ice_trace.h with CREATE_TRACE_POINTS defined will generate the
17+
* ice tracepoint functions. This must be done exactly once across the
18+
* ice driver.
19+
*/
20+
#define CREATE_TRACE_POINTS
21+
#include "ice_trace.h"
1622

1723
#define DRV_SUMMARY "Intel(R) Ethernet Connection E800 Series Linux Driver"
1824
static const char ice_driver_string[] = DRV_SUMMARY;
@@ -5477,6 +5483,7 @@ static void ice_tx_dim_work(struct work_struct *work)
54775483
itr = tx_profile[dim->profile_ix].itr;
54785484
intrl = tx_profile[dim->profile_ix].intrl;
54795485

5486+
ice_trace(tx_dim_work, q_vector, dim);
54805487
ice_write_itr(rc, itr);
54815488
ice_write_intrl(q_vector, intrl);
54825489

@@ -5501,6 +5508,7 @@ static void ice_rx_dim_work(struct work_struct *work)
55015508
itr = rx_profile[dim->profile_ix].itr;
55025509
intrl = rx_profile[dim->profile_ix].intrl;
55035510

5511+
ice_trace(rx_dim_work, q_vector, dim);
55045512
ice_write_itr(rc, itr);
55055513
ice_write_intrl(q_vector, intrl);
55065514

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/* Copyright (C) 2021 Intel Corporation. */
3+
4+
/* Modeled on trace-events-sample.h */
5+
6+
/* The trace subsystem name for ice will be "ice".
7+
*
8+
* This file is named ice_trace.h.
9+
*
10+
* Since this include file's name is different from the trace
11+
* subsystem name, we'll have to define TRACE_INCLUDE_FILE at the end
12+
* of this file.
13+
*/
14+
#undef TRACE_SYSTEM
15+
#define TRACE_SYSTEM ice
16+
17+
/* See trace-events-sample.h for a detailed description of why this
18+
* guard clause is different from most normal include files.
19+
*/
20+
#if !defined(_ICE_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
21+
#define _ICE_TRACE_H_
22+
23+
#include <linux/tracepoint.h>
24+
25+
/* ice_trace() macro enables shared code to refer to trace points
26+
* like:
27+
*
28+
* trace_ice_example(args...)
29+
*
30+
* ... as:
31+
*
32+
* ice_trace(example, args...)
33+
*
34+
* ... to resolve to the PF version of the tracepoint without
35+
* ifdefs, and to allow tracepoints to be disabled entirely at build
36+
* time.
37+
*
38+
* Trace point should always be referred to in the driver via this
39+
* macro.
40+
*
41+
* Similarly, ice_trace_enabled(trace_name) wraps references to
42+
* trace_ice_<trace_name>_enabled() functions.
43+
* @trace_name: name of tracepoint
44+
*/
45+
#define _ICE_TRACE_NAME(trace_name) (trace_##ice##_##trace_name)
46+
#define ICE_TRACE_NAME(trace_name) _ICE_TRACE_NAME(trace_name)
47+
48+
#define ice_trace(trace_name, args...) ICE_TRACE_NAME(trace_name)(args)
49+
50+
#define ice_trace_enabled(trace_name) ICE_TRACE_NAME(trace_name##_enabled)()
51+
52+
/* This is for events common to PF. Corresponding versions will be named
53+
* trace_ice_*. The ice_trace() macro above will select the right trace point
54+
* name for the driver.
55+
*/
56+
57+
/* Begin tracepoints */
58+
59+
/* Global tracepoints */
60+
61+
/* Events related to DIM, q_vectors and ring containers */
62+
DECLARE_EVENT_CLASS(ice_rx_dim_template,
63+
TP_PROTO(struct ice_q_vector *q_vector, struct dim *dim),
64+
TP_ARGS(q_vector, dim),
65+
TP_STRUCT__entry(__field(struct ice_q_vector *, q_vector)
66+
__field(struct dim *, dim)
67+
__string(devname, q_vector->rx.ring->netdev->name)),
68+
69+
TP_fast_assign(__entry->q_vector = q_vector;
70+
__entry->dim = dim;
71+
__assign_str(devname, q_vector->rx.ring->netdev->name);),
72+
73+
TP_printk("netdev: %s Rx-Q: %d dim-state: %d dim-profile: %d dim-tune: %d dim-st-right: %d dim-st-left: %d dim-tired: %d",
74+
__get_str(devname),
75+
__entry->q_vector->rx.ring->q_index,
76+
__entry->dim->state,
77+
__entry->dim->profile_ix,
78+
__entry->dim->tune_state,
79+
__entry->dim->steps_right,
80+
__entry->dim->steps_left,
81+
__entry->dim->tired)
82+
);
83+
84+
DEFINE_EVENT(ice_rx_dim_template, ice_rx_dim_work,
85+
TP_PROTO(struct ice_q_vector *q_vector, struct dim *dim),
86+
TP_ARGS(q_vector, dim)
87+
);
88+
89+
DECLARE_EVENT_CLASS(ice_tx_dim_template,
90+
TP_PROTO(struct ice_q_vector *q_vector, struct dim *dim),
91+
TP_ARGS(q_vector, dim),
92+
TP_STRUCT__entry(__field(struct ice_q_vector *, q_vector)
93+
__field(struct dim *, dim)
94+
__string(devname, q_vector->tx.ring->netdev->name)),
95+
96+
TP_fast_assign(__entry->q_vector = q_vector;
97+
__entry->dim = dim;
98+
__assign_str(devname, q_vector->tx.ring->netdev->name);),
99+
100+
TP_printk("netdev: %s Tx-Q: %d dim-state: %d dim-profile: %d dim-tune: %d dim-st-right: %d dim-st-left: %d dim-tired: %d",
101+
__get_str(devname),
102+
__entry->q_vector->tx.ring->q_index,
103+
__entry->dim->state,
104+
__entry->dim->profile_ix,
105+
__entry->dim->tune_state,
106+
__entry->dim->steps_right,
107+
__entry->dim->steps_left,
108+
__entry->dim->tired)
109+
);
110+
111+
DEFINE_EVENT(ice_tx_dim_template, ice_tx_dim_work,
112+
TP_PROTO(struct ice_q_vector *q_vector, struct dim *dim),
113+
TP_ARGS(q_vector, dim)
114+
);
115+
116+
/* Events related to a vsi & ring */
117+
DECLARE_EVENT_CLASS(ice_tx_template,
118+
TP_PROTO(struct ice_ring *ring, struct ice_tx_desc *desc,
119+
struct ice_tx_buf *buf),
120+
121+
TP_ARGS(ring, desc, buf),
122+
TP_STRUCT__entry(__field(void *, ring)
123+
__field(void *, desc)
124+
__field(void *, buf)
125+
__string(devname, ring->netdev->name)),
126+
127+
TP_fast_assign(__entry->ring = ring;
128+
__entry->desc = desc;
129+
__entry->buf = buf;
130+
__assign_str(devname, ring->netdev->name);),
131+
132+
TP_printk("netdev: %s ring: %pK desc: %pK buf %pK", __get_str(devname),
133+
__entry->ring, __entry->desc, __entry->buf)
134+
);
135+
136+
#define DEFINE_TX_TEMPLATE_OP_EVENT(name) \
137+
DEFINE_EVENT(ice_tx_template, name, \
138+
TP_PROTO(struct ice_ring *ring, \
139+
struct ice_tx_desc *desc, \
140+
struct ice_tx_buf *buf), \
141+
TP_ARGS(ring, desc, buf))
142+
143+
DEFINE_TX_TEMPLATE_OP_EVENT(ice_clean_tx_irq);
144+
DEFINE_TX_TEMPLATE_OP_EVENT(ice_clean_tx_irq_unmap);
145+
DEFINE_TX_TEMPLATE_OP_EVENT(ice_clean_tx_irq_unmap_eop);
146+
147+
DECLARE_EVENT_CLASS(ice_rx_template,
148+
TP_PROTO(struct ice_ring *ring, union ice_32b_rx_flex_desc *desc),
149+
150+
TP_ARGS(ring, desc),
151+
152+
TP_STRUCT__entry(__field(void *, ring)
153+
__field(void *, desc)
154+
__string(devname, ring->netdev->name)),
155+
156+
TP_fast_assign(__entry->ring = ring;
157+
__entry->desc = desc;
158+
__assign_str(devname, ring->netdev->name);),
159+
160+
TP_printk("netdev: %s ring: %pK desc: %pK", __get_str(devname),
161+
__entry->ring, __entry->desc)
162+
);
163+
DEFINE_EVENT(ice_rx_template, ice_clean_rx_irq,
164+
TP_PROTO(struct ice_ring *ring, union ice_32b_rx_flex_desc *desc),
165+
TP_ARGS(ring, desc)
166+
);
167+
168+
DECLARE_EVENT_CLASS(ice_rx_indicate_template,
169+
TP_PROTO(struct ice_ring *ring, union ice_32b_rx_flex_desc *desc,
170+
struct sk_buff *skb),
171+
172+
TP_ARGS(ring, desc, skb),
173+
174+
TP_STRUCT__entry(__field(void *, ring)
175+
__field(void *, desc)
176+
__field(void *, skb)
177+
__string(devname, ring->netdev->name)),
178+
179+
TP_fast_assign(__entry->ring = ring;
180+
__entry->desc = desc;
181+
__entry->skb = skb;
182+
__assign_str(devname, ring->netdev->name);),
183+
184+
TP_printk("netdev: %s ring: %pK desc: %pK skb %pK", __get_str(devname),
185+
__entry->ring, __entry->desc, __entry->skb)
186+
);
187+
188+
DEFINE_EVENT(ice_rx_indicate_template, ice_clean_rx_irq_indicate,
189+
TP_PROTO(struct ice_ring *ring, union ice_32b_rx_flex_desc *desc,
190+
struct sk_buff *skb),
191+
TP_ARGS(ring, desc, skb)
192+
);
193+
194+
DECLARE_EVENT_CLASS(ice_xmit_template,
195+
TP_PROTO(struct ice_ring *ring, struct sk_buff *skb),
196+
197+
TP_ARGS(ring, skb),
198+
199+
TP_STRUCT__entry(__field(void *, ring)
200+
__field(void *, skb)
201+
__string(devname, ring->netdev->name)),
202+
203+
TP_fast_assign(__entry->ring = ring;
204+
__entry->skb = skb;
205+
__assign_str(devname, ring->netdev->name);),
206+
207+
TP_printk("netdev: %s skb: %pK ring: %pK", __get_str(devname),
208+
__entry->skb, __entry->ring)
209+
);
210+
211+
#define DEFINE_XMIT_TEMPLATE_OP_EVENT(name) \
212+
DEFINE_EVENT(ice_xmit_template, name, \
213+
TP_PROTO(struct ice_ring *ring, struct sk_buff *skb), \
214+
TP_ARGS(ring, skb))
215+
216+
DEFINE_XMIT_TEMPLATE_OP_EVENT(ice_xmit_frame_ring);
217+
DEFINE_XMIT_TEMPLATE_OP_EVENT(ice_xmit_frame_ring_drop);
218+
219+
/* End tracepoints */
220+
221+
#endif /* _ICE_TRACE_H_ */
222+
/* This must be outside ifdef _ICE_TRACE_H */
223+
224+
/* This trace include file is not located in the .../include/trace
225+
* with the kernel tracepoint definitions, because we're a loadable
226+
* module.
227+
*/
228+
#undef TRACE_INCLUDE_PATH
229+
#define TRACE_INCLUDE_PATH .
230+
#undef TRACE_INCLUDE_FILE
231+
#define TRACE_INCLUDE_FILE ../../drivers/net/ethernet/intel/ice/ice_trace
232+
#include <trace/define_trace.h>

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "ice_txrx_lib.h"
1111
#include "ice_lib.h"
1212
#include "ice.h"
13+
#include "ice_trace.h"
1314
#include "ice_dcb_lib.h"
1415
#include "ice_xsk.h"
1516

@@ -224,6 +225,7 @@ static bool ice_clean_tx_irq(struct ice_ring *tx_ring, int napi_budget)
224225

225226
smp_rmb(); /* prevent any other reads prior to eop_desc */
226227

228+
ice_trace(clean_tx_irq, tx_ring, tx_desc, tx_buf);
227229
/* if the descriptor isn't done, no work yet to do */
228230
if (!(eop_desc->cmd_type_offset_bsz &
229231
cpu_to_le64(ICE_TX_DESC_DTYPE_DESC_DONE)))
@@ -254,6 +256,7 @@ static bool ice_clean_tx_irq(struct ice_ring *tx_ring, int napi_budget)
254256

255257
/* unmap remaining buffers */
256258
while (tx_desc != eop_desc) {
259+
ice_trace(clean_tx_irq_unmap, tx_ring, tx_desc, tx_buf);
257260
tx_buf++;
258261
tx_desc++;
259262
i++;
@@ -272,6 +275,7 @@ static bool ice_clean_tx_irq(struct ice_ring *tx_ring, int napi_budget)
272275
dma_unmap_len_set(tx_buf, len, 0);
273276
}
274277
}
278+
ice_trace(clean_tx_irq_unmap_eop, tx_ring, tx_desc, tx_buf);
275279

276280
/* move us one more past the eop_desc for start of next pkt */
277281
tx_buf++;
@@ -1102,6 +1106,7 @@ int ice_clean_rx_irq(struct ice_ring *rx_ring, int budget)
11021106
*/
11031107
dma_rmb();
11041108

1109+
ice_trace(clean_rx_irq, rx_ring, rx_desc);
11051110
if (rx_desc->wb.rxdid == FDIR_DESC_RXDID || !rx_ring->netdev) {
11061111
struct ice_vsi *ctrl_vsi = rx_ring->vsi;
11071112

@@ -1207,6 +1212,7 @@ int ice_clean_rx_irq(struct ice_ring *rx_ring, int budget)
12071212

12081213
ice_process_skb_fields(rx_ring, rx_desc, skb, rx_ptype);
12091214

1215+
ice_trace(clean_rx_irq_indicate, rx_ring, rx_desc, skb);
12101216
/* send completed skb up the stack */
12111217
ice_receive_skb(rx_ring, skb, vlan_tag);
12121218
skb = NULL;
@@ -2188,6 +2194,8 @@ ice_xmit_frame_ring(struct sk_buff *skb, struct ice_ring *tx_ring)
21882194
unsigned int count;
21892195
int tso, csum;
21902196

2197+
ice_trace(xmit_frame_ring, tx_ring, skb);
2198+
21912199
count = ice_xmit_desc_count(skb);
21922200
if (ice_chk_linearize(skb, count)) {
21932201
if (__skb_linearize(skb))
@@ -2262,6 +2270,7 @@ ice_xmit_frame_ring(struct sk_buff *skb, struct ice_ring *tx_ring)
22622270
return NETDEV_TX_OK;
22632271

22642272
out_drop:
2273+
ice_trace(xmit_frame_ring_drop, tx_ring, skb);
22652274
dev_kfree_skb_any(skb);
22662275
return NETDEV_TX_OK;
22672276
}

0 commit comments

Comments
 (0)