1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /* Copyright (c) 2018-2019 Hisilicon Limited. */
4 /* This must be outside ifdef _HNS3_TRACE_H */
6 #define TRACE_SYSTEM hns3
8 #if !defined(_HNS3_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
11 #include <linux/tracepoint.h>
13 #define DESC_NR (sizeof(struct hns3_desc) / sizeof(u32))
15 DECLARE_EVENT_CLASS(hns3_skb_template
,
16 TP_PROTO(struct sk_buff
*skb
),
20 __field(unsigned int, headlen
)
21 __field(unsigned int, len
)
22 __field(__u8
, nr_frags
)
23 __field(__u8
, ip_summed
)
24 __field(unsigned int, hdr_len
)
25 __field(unsigned short, gso_size
)
26 __field(unsigned short, gso_segs
)
27 __field(unsigned int, gso_type
)
28 __field(bool, fraglist
)
29 __array(__u32
, size
, MAX_SKB_FRAGS
)
33 __entry
->headlen
= skb_headlen(skb
);
34 __entry
->len
= skb
->len
;
35 __entry
->nr_frags
= skb_shinfo(skb
)->nr_frags
;
36 __entry
->gso_size
= skb_shinfo(skb
)->gso_size
;
37 __entry
->gso_segs
= skb_shinfo(skb
)->gso_segs
;
38 __entry
->gso_type
= skb_shinfo(skb
)->gso_type
;
39 __entry
->hdr_len
= skb
->encapsulation
?
40 skb_inner_tcp_all_headers(skb
) : skb_tcp_all_headers(skb
);
41 __entry
->ip_summed
= skb
->ip_summed
;
42 __entry
->fraglist
= skb_has_frag_list(skb
);
43 hns3_shinfo_pack(skb_shinfo(skb
), __entry
->size
);
47 "len: %u, %u, %u, cs: %u, gso: %u, %u, %x, frag(%d %u): %s",
48 __entry
->headlen
, __entry
->len
, __entry
->hdr_len
,
49 __entry
->ip_summed
, __entry
->gso_size
, __entry
->gso_segs
,
50 __entry
->gso_type
, __entry
->fraglist
, __entry
->nr_frags
,
51 __print_array(__entry
->size
, MAX_SKB_FRAGS
, sizeof(__u32
))
55 DEFINE_EVENT(hns3_skb_template
, hns3_over_max_bd
,
56 TP_PROTO(struct sk_buff
*skb
),
59 DEFINE_EVENT(hns3_skb_template
, hns3_gro
,
60 TP_PROTO(struct sk_buff
*skb
),
63 DEFINE_EVENT(hns3_skb_template
, hns3_tso
,
64 TP_PROTO(struct sk_buff
*skb
),
67 TRACE_EVENT(hns3_tx_desc
,
68 TP_PROTO(struct hns3_enet_ring
*ring
, int cur_ntu
),
69 TP_ARGS(ring
, cur_ntu
),
75 __field(dma_addr_t
, desc_dma
)
76 __array(u32
, desc
, DESC_NR
)
77 __string(devname
, ring
->tqp
->handle
->kinfo
.netdev
->name
)
81 __entry
->index
= ring
->tqp
->tqp_index
;
82 __entry
->ntu
= ring
->next_to_use
;
83 __entry
->ntc
= ring
->next_to_clean
;
84 __entry
->desc_dma
= ring
->desc_dma_addr
,
85 memcpy(__entry
->desc
, &ring
->desc
[cur_ntu
],
86 sizeof(struct hns3_desc
));
87 __assign_str(devname
);
91 "%s-%d-%d/%d desc(%pad): %s",
92 __get_str(devname
), __entry
->index
, __entry
->ntu
,
93 __entry
->ntc
, &__entry
->desc_dma
,
94 __print_array(__entry
->desc
, DESC_NR
, sizeof(u32
))
98 TRACE_EVENT(hns3_rx_desc
,
99 TP_PROTO(struct hns3_enet_ring
*ring
),
106 __field(dma_addr_t
, desc_dma
)
107 __field(dma_addr_t
, buf_dma
)
108 __array(u32
, desc
, DESC_NR
)
109 __string(devname
, ring
->tqp
->handle
->kinfo
.netdev
->name
)
113 __entry
->index
= ring
->tqp
->tqp_index
;
114 __entry
->ntu
= ring
->next_to_use
;
115 __entry
->ntc
= ring
->next_to_clean
;
116 __entry
->desc_dma
= ring
->desc_dma_addr
;
117 __entry
->buf_dma
= ring
->desc_cb
[ring
->next_to_clean
].dma
;
118 memcpy(__entry
->desc
, &ring
->desc
[ring
->next_to_clean
],
119 sizeof(struct hns3_desc
));
120 __assign_str(devname
);
124 "%s-%d-%d/%d desc(%pad) buf(%pad): %s",
125 __get_str(devname
), __entry
->index
, __entry
->ntu
,
126 __entry
->ntc
, &__entry
->desc_dma
, &__entry
->buf_dma
,
127 __print_array(__entry
->desc
, DESC_NR
, sizeof(u32
))
131 #endif /* _HNS3_TRACE_H_ */
133 /* This must be outside ifdef _HNS3_TRACE_H */
134 #undef TRACE_INCLUDE_PATH
135 #define TRACE_INCLUDE_PATH .
136 #undef TRACE_INCLUDE_FILE
137 #define TRACE_INCLUDE_FILE hns3_trace
138 #include <trace/define_trace.h>