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 #include "ice_eswitch_br.h" 25 26 /* ice_trace() macro enables shared code to refer to trace points 27 * like: 28 * 29 * trace_ice_example(args...) 30 * 31 * ... as: 32 * 33 * ice_trace(example, args...) 34 * 35 * ... to resolve to the PF version of the tracepoint without 36 * ifdefs, and to allow tracepoints to be disabled entirely at build 37 * time. 38 * 39 * Trace point should always be referred to in the driver via this 40 * macro. 41 * 42 * Similarly, ice_trace_enabled(trace_name) wraps references to 43 * trace_ice_<trace_name>_enabled() functions. 44 * @trace_name: name of tracepoint 45 */ 46 #define _ICE_TRACE_NAME(trace_name) (trace_##ice##_##trace_name) 47 #define ICE_TRACE_NAME(trace_name) _ICE_TRACE_NAME(trace_name) 48 49 #define ice_trace(trace_name, args...) ICE_TRACE_NAME(trace_name)(args) 50 51 #define ice_trace_enabled(trace_name) ICE_TRACE_NAME(trace_name##_enabled)() 52 53 /* This is for events common to PF. Corresponding versions will be named 54 * trace_ice_*. The ice_trace() macro above will select the right trace point 55 * name for the driver. 56 */ 57 58 /* Begin tracepoints */ 59 60 /* Global tracepoints */ 61 62 /* Events related to DIM, q_vectors and ring containers */ 63 DECLARE_EVENT_CLASS(ice_rx_dim_template, 64 TP_PROTO(struct ice_q_vector *q_vector, struct dim *dim), 65 TP_ARGS(q_vector, dim), 66 TP_STRUCT__entry(__field(u16, q_index) 67 __field(u8, state) 68 __field(u8, profile_ix) 69 __field(u8, tune_state) 70 __field(u8, steps_right) 71 __field(u8, steps_left) 72 __field(u8, tired) 73 __string(devname, q_vector->rx.rx_ring->netdev->name)), 74 75 TP_fast_assign(__entry->q_index = q_vector->rx.rx_ring->q_index; 76 __entry->state = dim->state; 77 __entry->profile_ix = dim->profile_ix; 78 __entry->tune_state = dim->tune_state; 79 __entry->steps_right = dim->steps_right; 80 __entry->steps_left = dim->steps_left; 81 __entry->tired = dim->tired; 82 __assign_str(devname);), 83 84 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", 85 __get_str(devname), 86 __entry->q_index, 87 __entry->state, 88 __entry->profile_ix, 89 __entry->tune_state, 90 __entry->steps_right, 91 __entry->steps_left, 92 __entry->tired) 93 ); 94 95 DEFINE_EVENT(ice_rx_dim_template, ice_rx_dim_work, 96 TP_PROTO(struct ice_q_vector *q_vector, struct dim *dim), 97 TP_ARGS(q_vector, dim) 98 ); 99 100 DECLARE_EVENT_CLASS(ice_tx_dim_template, 101 TP_PROTO(struct ice_q_vector *q_vector, struct dim *dim), 102 TP_ARGS(q_vector, dim), 103 TP_STRUCT__entry(__field(u16, q_index) 104 __field(u8, state) 105 __field(u8, profile_ix) 106 __field(u8, tune_state) 107 __field(u8, steps_right) 108 __field(u8, steps_left) 109 __field(u8, tired) 110 __string(devname, q_vector->tx.tx_ring->netdev->name)), 111 112 TP_fast_assign(__entry->q_index = q_vector->tx.tx_ring->q_index; 113 __entry->state = dim->state; 114 __entry->profile_ix = dim->profile_ix; 115 __entry->tune_state = dim->tune_state; 116 __entry->steps_right = dim->steps_right; 117 __entry->steps_left = dim->steps_left; 118 __entry->tired = dim->tired; 119 __assign_str(devname);), 120 121 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", 122 __get_str(devname), 123 __entry->q_index, 124 __entry->state, 125 __entry->profile_ix, 126 __entry->tune_state, 127 __entry->steps_right, 128 __entry->steps_left, 129 __entry->tired) 130 ); 131 132 DEFINE_EVENT(ice_tx_dim_template, ice_tx_dim_work, 133 TP_PROTO(struct ice_q_vector *q_vector, struct dim *dim), 134 TP_ARGS(q_vector, dim) 135 ); 136 137 /* Events related to a vsi & ring */ 138 DECLARE_EVENT_CLASS(ice_tx_template, 139 TP_PROTO(struct ice_tx_ring *ring, struct ice_tx_desc *desc, 140 struct ice_tx_buf *buf), 141 142 TP_ARGS(ring, desc, buf), 143 TP_STRUCT__entry(__field(void *, ring) 144 __field(void *, desc) 145 __field(void *, buf) 146 __string(devname, ring->netdev->name)), 147 148 TP_fast_assign(__entry->ring = ring; 149 __entry->desc = desc; 150 __entry->buf = buf; 151 __assign_str(devname);), 152 153 TP_printk("netdev: %s ring: %p desc: %p buf %p", __get_str(devname), 154 __entry->ring, __entry->desc, __entry->buf) 155 ); 156 157 #define DEFINE_TX_TEMPLATE_OP_EVENT(name) \ 158 DEFINE_EVENT(ice_tx_template, name, \ 159 TP_PROTO(struct ice_tx_ring *ring, \ 160 struct ice_tx_desc *desc, \ 161 struct ice_tx_buf *buf), \ 162 TP_ARGS(ring, desc, buf)) 163 164 DEFINE_TX_TEMPLATE_OP_EVENT(ice_clean_tx_irq); 165 DEFINE_TX_TEMPLATE_OP_EVENT(ice_clean_tx_irq_unmap); 166 DEFINE_TX_TEMPLATE_OP_EVENT(ice_clean_tx_irq_unmap_eop); 167 168 DECLARE_EVENT_CLASS(ice_rx_template, 169 TP_PROTO(struct ice_rx_ring *ring, union ice_32b_rx_flex_desc *desc), 170 171 TP_ARGS(ring, desc), 172 173 TP_STRUCT__entry(__field(void *, ring) 174 __field(void *, desc) 175 __string(devname, ring->netdev->name)), 176 177 TP_fast_assign(__entry->ring = ring; 178 __entry->desc = desc; 179 __assign_str(devname);), 180 181 TP_printk("netdev: %s ring: %p desc: %p", __get_str(devname), 182 __entry->ring, __entry->desc) 183 ); 184 DEFINE_EVENT(ice_rx_template, ice_clean_rx_irq, 185 TP_PROTO(struct ice_rx_ring *ring, union ice_32b_rx_flex_desc *desc), 186 TP_ARGS(ring, desc) 187 ); 188 189 DECLARE_EVENT_CLASS(ice_rx_indicate_template, 190 TP_PROTO(struct ice_rx_ring *ring, union ice_32b_rx_flex_desc *desc, 191 struct sk_buff *skb), 192 193 TP_ARGS(ring, desc, skb), 194 195 TP_STRUCT__entry(__field(void *, ring) 196 __field(void *, desc) 197 __field(void *, skb) 198 __string(devname, ring->netdev->name)), 199 200 TP_fast_assign(__entry->ring = ring; 201 __entry->desc = desc; 202 __entry->skb = skb; 203 __assign_str(devname);), 204 205 TP_printk("netdev: %s ring: %p desc: %p skb %p", __get_str(devname), 206 __entry->ring, __entry->desc, __entry->skb) 207 ); 208 209 DEFINE_EVENT(ice_rx_indicate_template, ice_clean_rx_irq_indicate, 210 TP_PROTO(struct ice_rx_ring *ring, union ice_32b_rx_flex_desc *desc, 211 struct sk_buff *skb), 212 TP_ARGS(ring, desc, skb) 213 ); 214 215 DECLARE_EVENT_CLASS(ice_xmit_template, 216 TP_PROTO(struct ice_tx_ring *ring, struct sk_buff *skb), 217 218 TP_ARGS(ring, skb), 219 220 TP_STRUCT__entry(__field(void *, ring) 221 __field(void *, skb) 222 __string(devname, ring->netdev->name)), 223 224 TP_fast_assign(__entry->ring = ring; 225 __entry->skb = skb; 226 __assign_str(devname);), 227 228 TP_printk("netdev: %s skb: %p ring: %p", __get_str(devname), 229 __entry->skb, __entry->ring) 230 ); 231 232 #define DEFINE_XMIT_TEMPLATE_OP_EVENT(name) \ 233 DEFINE_EVENT(ice_xmit_template, name, \ 234 TP_PROTO(struct ice_tx_ring *ring, struct sk_buff *skb), \ 235 TP_ARGS(ring, skb)) 236 237 DEFINE_XMIT_TEMPLATE_OP_EVENT(ice_xmit_frame_ring); 238 DEFINE_XMIT_TEMPLATE_OP_EVENT(ice_xmit_frame_ring_drop); 239 240 DECLARE_EVENT_CLASS(ice_tx_tstamp_template, 241 TP_PROTO(struct sk_buff *skb, int idx), 242 243 TP_ARGS(skb, idx), 244 245 TP_STRUCT__entry(__field(void *, skb) 246 __field(int, idx)), 247 248 TP_fast_assign(__entry->skb = skb; 249 __entry->idx = idx;), 250 251 TP_printk("skb %p idx %d", 252 __entry->skb, __entry->idx) 253 ); 254 #define DEFINE_TX_TSTAMP_OP_EVENT(name) \ 255 DEFINE_EVENT(ice_tx_tstamp_template, name, \ 256 TP_PROTO(struct sk_buff *skb, int idx), \ 257 TP_ARGS(skb, idx)) 258 259 DEFINE_TX_TSTAMP_OP_EVENT(ice_tx_tstamp_request); 260 DEFINE_TX_TSTAMP_OP_EVENT(ice_tx_tstamp_fw_req); 261 DEFINE_TX_TSTAMP_OP_EVENT(ice_tx_tstamp_fw_done); 262 DEFINE_TX_TSTAMP_OP_EVENT(ice_tx_tstamp_complete); 263 264 DECLARE_EVENT_CLASS(ice_esw_br_fdb_template, 265 TP_PROTO(struct ice_esw_br_fdb_entry *fdb), 266 TP_ARGS(fdb), 267 TP_STRUCT__entry(__array(char, dev_name, IFNAMSIZ) 268 __array(unsigned char, addr, ETH_ALEN) 269 __field(u16, vid) 270 __field(int, flags)), 271 TP_fast_assign(strscpy(__entry->dev_name, 272 netdev_name(fdb->dev), 273 IFNAMSIZ); 274 memcpy(__entry->addr, fdb->data.addr, ETH_ALEN); 275 __entry->vid = fdb->data.vid; 276 __entry->flags = fdb->flags;), 277 TP_printk("net_device=%s addr=%pM vid=%u flags=%x", 278 __entry->dev_name, 279 __entry->addr, 280 __entry->vid, 281 __entry->flags) 282 ); 283 284 DEFINE_EVENT(ice_esw_br_fdb_template, 285 ice_eswitch_br_fdb_entry_create, 286 TP_PROTO(struct ice_esw_br_fdb_entry *fdb), 287 TP_ARGS(fdb) 288 ); 289 290 DEFINE_EVENT(ice_esw_br_fdb_template, 291 ice_eswitch_br_fdb_entry_find_and_delete, 292 TP_PROTO(struct ice_esw_br_fdb_entry *fdb), 293 TP_ARGS(fdb) 294 ); 295 296 DECLARE_EVENT_CLASS(ice_esw_br_vlan_template, 297 TP_PROTO(struct ice_esw_br_vlan *vlan), 298 TP_ARGS(vlan), 299 TP_STRUCT__entry(__field(u16, vid) 300 __field(u16, flags)), 301 TP_fast_assign(__entry->vid = vlan->vid; 302 __entry->flags = vlan->flags;), 303 TP_printk("vid=%u flags=%x", 304 __entry->vid, 305 __entry->flags) 306 ); 307 308 DEFINE_EVENT(ice_esw_br_vlan_template, 309 ice_eswitch_br_vlan_create, 310 TP_PROTO(struct ice_esw_br_vlan *vlan), 311 TP_ARGS(vlan) 312 ); 313 314 DEFINE_EVENT(ice_esw_br_vlan_template, 315 ice_eswitch_br_vlan_cleanup, 316 TP_PROTO(struct ice_esw_br_vlan *vlan), 317 TP_ARGS(vlan) 318 ); 319 320 #define ICE_ESW_BR_PORT_NAME_L 16 321 322 DECLARE_EVENT_CLASS(ice_esw_br_port_template, 323 TP_PROTO(struct ice_esw_br_port *port), 324 TP_ARGS(port), 325 TP_STRUCT__entry(__field(u16, vport_num) 326 __array(char, port_type, ICE_ESW_BR_PORT_NAME_L)), 327 TP_fast_assign(__entry->vport_num = port->vsi_idx; 328 if (port->type == ICE_ESWITCH_BR_UPLINK_PORT) 329 strscpy(__entry->port_type, 330 "Uplink", 331 ICE_ESW_BR_PORT_NAME_L); 332 else 333 strscpy(__entry->port_type, 334 "VF Representor", 335 ICE_ESW_BR_PORT_NAME_L);), 336 TP_printk("vport_num=%u port type=%s", 337 __entry->vport_num, 338 __entry->port_type) 339 ); 340 341 DEFINE_EVENT(ice_esw_br_port_template, 342 ice_eswitch_br_port_link, 343 TP_PROTO(struct ice_esw_br_port *port), 344 TP_ARGS(port) 345 ); 346 347 DEFINE_EVENT(ice_esw_br_port_template, 348 ice_eswitch_br_port_unlink, 349 TP_PROTO(struct ice_esw_br_port *port), 350 TP_ARGS(port) 351 ); 352 353 DECLARE_EVENT_CLASS(ice_switch_stats_template, 354 TP_PROTO(struct ice_switch_info *sw_info), 355 TP_ARGS(sw_info), 356 TP_STRUCT__entry(__field(u16, rule_cnt) 357 __field(u8, recp_cnt)), 358 TP_fast_assign(__entry->rule_cnt = sw_info->rule_cnt; 359 __entry->recp_cnt = sw_info->recp_cnt;), 360 TP_printk("rules=%u recipes=%u", 361 __entry->rule_cnt, 362 __entry->recp_cnt) 363 ); 364 365 DEFINE_EVENT(ice_switch_stats_template, 366 ice_aq_sw_rules, 367 TP_PROTO(struct ice_switch_info *sw_info), 368 TP_ARGS(sw_info) 369 ); 370 371 /* End tracepoints */ 372 373 #endif /* _ICE_TRACE_H_ */ 374 /* This must be outside ifdef _ICE_TRACE_H */ 375 376 /* This trace include file is not located in the .../include/trace 377 * with the kernel tracepoint definitions, because we're a loadable 378 * module. 379 */ 380 #undef TRACE_INCLUDE_PATH 381 #define TRACE_INCLUDE_PATH . 382 #undef TRACE_INCLUDE_FILE 383 #define TRACE_INCLUDE_FILE ../../drivers/net/ethernet/intel/ice/ice_trace 384 #include <trace/define_trace.h> 385