1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #if !defined(_NETVSC_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
4 #define _NETVSC_TRACE_H
5 
6 #include <linux/tracepoint.h>
7 
8 #undef TRACE_SYSTEM
9 #define TRACE_SYSTEM netvsc
10 #define TRACE_INCLUDE_FILE netvsc_trace
11 
12 TRACE_DEFINE_ENUM(RNDIS_MSG_PACKET);
13 TRACE_DEFINE_ENUM(RNDIS_MSG_INDICATE);
14 TRACE_DEFINE_ENUM(RNDIS_MSG_INIT);
15 TRACE_DEFINE_ENUM(RNDIS_MSG_INIT_C);
16 TRACE_DEFINE_ENUM(RNDIS_MSG_HALT);
17 TRACE_DEFINE_ENUM(RNDIS_MSG_QUERY);
18 TRACE_DEFINE_ENUM(RNDIS_MSG_QUERY_C);
19 TRACE_DEFINE_ENUM(RNDIS_MSG_SET);
20 TRACE_DEFINE_ENUM(RNDIS_MSG_SET_C);
21 TRACE_DEFINE_ENUM(RNDIS_MSG_RESET);
22 TRACE_DEFINE_ENUM(RNDIS_MSG_RESET_C);
23 TRACE_DEFINE_ENUM(RNDIS_MSG_KEEPALIVE);
24 TRACE_DEFINE_ENUM(RNDIS_MSG_KEEPALIVE_C);
25 
26 #define show_rndis_type(type)					\
27 	__print_symbolic(type,					\
28 		 { RNDIS_MSG_PACKET,	  "PACKET" },		\
29 		 { RNDIS_MSG_INDICATE,	  "INDICATE", },	\
30 		 { RNDIS_MSG_INIT,	  "INIT", },		\
31 		 { RNDIS_MSG_INIT_C,	  "INIT_C", },		\
32 		 { RNDIS_MSG_HALT,	  "HALT", },		\
33 		 { RNDIS_MSG_QUERY,	  "QUERY", },		\
34 		 { RNDIS_MSG_QUERY_C,	  "QUERY_C", },		\
35 		 { RNDIS_MSG_SET,	  "SET", },		\
36 		 { RNDIS_MSG_SET_C,	  "SET_C", },		\
37 		 { RNDIS_MSG_RESET,	  "RESET", },		\
38 		 { RNDIS_MSG_RESET_C,	  "RESET_C", },		\
39 		 { RNDIS_MSG_KEEPALIVE,	  "KEEPALIVE", },	\
40 		 { RNDIS_MSG_KEEPALIVE_C, "KEEPALIVE_C", })
41 
42 DECLARE_EVENT_CLASS(rndis_msg_class,
43        TP_PROTO(const struct net_device *ndev, u16 q,
44 		const struct rndis_message *msg),
45        TP_ARGS(ndev, q, msg),
46        TP_STRUCT__entry(
47 	       __string( name, ndev->name  )
48 	       __field(	 u16,  queue	   )
49 	       __field(	 u32,  req_id	   )
50 	       __field(	 u32,  msg_type	   )
51 	       __field(	 u32,  msg_len	   )
52        ),
53        TP_fast_assign(
54 	       __assign_str(name, ndev->name);
55 	       __entry->queue	 = q;
56 	       __entry->req_id	 = msg->msg.init_req.req_id;
57 	       __entry->msg_type = msg->ndis_msg_type;
58 	       __entry->msg_len	 = msg->msg_len;
59        ),
60        TP_printk("dev=%s q=%u req=%#x type=%s msg_len=%u",
61 		 __get_str(name), __entry->queue, __entry->req_id,
62 		 show_rndis_type(__entry->msg_type), __entry->msg_len)
63 );
64 
65 DEFINE_EVENT(rndis_msg_class, rndis_send,
66        TP_PROTO(const struct net_device *ndev, u16 q,
67 		const struct rndis_message *msg),
68        TP_ARGS(ndev, q, msg)
69 );
70 
71 DEFINE_EVENT(rndis_msg_class, rndis_recv,
72        TP_PROTO(const struct net_device *ndev, u16 q,
73 		const struct rndis_message *msg),
74        TP_ARGS(ndev, q, msg)
75 );
76 
77 TRACE_DEFINE_ENUM(NVSP_MSG_TYPE_INIT);
78 TRACE_DEFINE_ENUM(NVSP_MSG_TYPE_INIT_COMPLETE);
79 TRACE_DEFINE_ENUM(NVSP_MSG1_TYPE_SEND_NDIS_VER);
80 TRACE_DEFINE_ENUM(NVSP_MSG1_TYPE_SEND_RECV_BUF);
81 TRACE_DEFINE_ENUM(NVSP_MSG1_TYPE_SEND_RECV_BUF_COMPLETE);
82 TRACE_DEFINE_ENUM(NVSP_MSG1_TYPE_REVOKE_RECV_BUF);
83 TRACE_DEFINE_ENUM(NVSP_MSG1_TYPE_SEND_SEND_BUF);
84 TRACE_DEFINE_ENUM(NVSP_MSG1_TYPE_SEND_SEND_BUF_COMPLETE);
85 TRACE_DEFINE_ENUM(NVSP_MSG1_TYPE_REVOKE_SEND_BUF);
86 TRACE_DEFINE_ENUM(NVSP_MSG1_TYPE_SEND_RNDIS_PKT);
87 TRACE_DEFINE_ENUM(NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE);
88 TRACE_DEFINE_ENUM(NVSP_MSG2_TYPE_SEND_NDIS_CONFIG);
89 
90 TRACE_DEFINE_ENUM(NVSP_MSG4_TYPE_SEND_VF_ASSOCIATION);
91 TRACE_DEFINE_ENUM(NVSP_MSG4_TYPE_SWITCH_DATA_PATH);
92 
93 TRACE_DEFINE_ENUM(NVSP_MSG5_TYPE_SUBCHANNEL);
94 TRACE_DEFINE_ENUM(NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE);
95 
96 #define show_nvsp_type(type)								\
97 	__print_symbolic(type,								\
98 		  { NVSP_MSG_TYPE_INIT,			   "INIT" },			\
99 		  { NVSP_MSG_TYPE_INIT_COMPLETE,	   "INIT_COMPLETE" },		\
100 		  { NVSP_MSG1_TYPE_SEND_NDIS_VER,	   "SEND_NDIS_VER" },		\
101 		  { NVSP_MSG1_TYPE_SEND_RECV_BUF,	   "SEND_RECV_BUF" },		\
102 		  { NVSP_MSG1_TYPE_SEND_RECV_BUF_COMPLETE, "SEND_RECV_BUF_COMPLETE" },	\
103 		  { NVSP_MSG1_TYPE_REVOKE_RECV_BUF,	   "REVOKE_RECV_BUF" },		\
104 		  { NVSP_MSG1_TYPE_SEND_SEND_BUF,	   "SEND_SEND_BUF" },		\
105 		  { NVSP_MSG1_TYPE_SEND_SEND_BUF_COMPLETE, "SEND_SEND_BUF_COMPLETE" },	\
106 		  { NVSP_MSG1_TYPE_REVOKE_SEND_BUF,	   "REVOKE_SEND_BUF" },		\
107 		  { NVSP_MSG1_TYPE_SEND_RNDIS_PKT,	   "SEND_RNDIS_PKT" },		\
108 		  { NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE, "SEND_RNDIS_PKT_COMPLETE" },\
109 		  { NVSP_MSG2_TYPE_SEND_NDIS_CONFIG,	   "SEND_NDIS_CONFIG" },	\
110 		  { NVSP_MSG4_TYPE_SEND_VF_ASSOCIATION,	   "SEND_VF_ASSOCIATION" },	\
111 		  { NVSP_MSG4_TYPE_SWITCH_DATA_PATH,	   "SWITCH_DATA_PATH" },	\
112 		  { NVSP_MSG5_TYPE_SUBCHANNEL,		    "SUBCHANNEL" },		\
113 		  { NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE,  "SEND_INDIRECTION_TABLE" })
114 
115 TRACE_EVENT(nvsp_send,
116 	TP_PROTO(const struct net_device *ndev,
117 		 const struct nvsp_message *msg),
118 	TP_ARGS(ndev, msg),
119 	TP_STRUCT__entry(
120 		__string( name,	ndev->name  )
121 		__field(  u32,	msg_type    )
122 	),
123 	TP_fast_assign(
124 		__assign_str(name, ndev->name);
125 		__entry->msg_type = msg->hdr.msg_type;
126 	),
127 	TP_printk("dev=%s type=%s",
128 		  __get_str(name),
129 		  show_nvsp_type(__entry->msg_type))
130 );
131 
132 TRACE_EVENT(nvsp_send_pkt,
133 	TP_PROTO(const struct net_device *ndev,
134 		 const struct vmbus_channel *chan,
135 		 const struct nvsp_1_message_send_rndis_packet *rpkt),
136 	TP_ARGS(ndev, chan, rpkt),
137 	TP_STRUCT__entry(
138 		__string( name,	ndev->name    )
139 		__field(  u16,	qid	      )
140 		__field(  u32,	channel_type  )
141 		__field(  u32,	section_index )
142 		__field(  u32,	section_size  )
143 	),
144 	TP_fast_assign(
145 		__assign_str(name, ndev->name);
146 		__entry->qid = chan->offermsg.offer.sub_channel_index;
147 		__entry->channel_type = rpkt->channel_type;
148 		__entry->section_index = rpkt->send_buf_section_index;
149 		__entry->section_size = rpkt->send_buf_section_size;
150 	),
151 	TP_printk("dev=%s qid=%u type=%s section=%u size=%d",
152 		  __get_str(name), __entry->qid,
153 		  __entry->channel_type ? "CONTROL" : "DATA",
154 		  __entry->section_index, __entry->section_size)
155 );
156 
157 TRACE_EVENT(nvsp_recv,
158 	TP_PROTO(const struct net_device *ndev,
159 		 const struct vmbus_channel *chan,
160 		 const struct nvsp_message *msg),
161 	TP_ARGS(ndev, chan, msg),
162 	TP_STRUCT__entry(
163 		__string( name,	ndev->name  )
164 		__field(  u16,	qid	    )
165 		__field(  u32,	msg_type    )
166 	),
167 	TP_fast_assign(
168 		__assign_str(name, ndev->name);
169 		__entry->qid = chan->offermsg.offer.sub_channel_index;
170 		__entry->msg_type = msg->hdr.msg_type;
171 	),
172 	TP_printk("dev=%s qid=%u type=%s",
173 		  __get_str(name), __entry->qid,
174 		  show_nvsp_type(__entry->msg_type))
175 );
176 
177 #endif /* _NETVSC_TRACE_H */
178 
179 /* This part must be outside protection */
180 #undef TRACE_INCLUDE_PATH
181 #define TRACE_INCLUDE_PATH ../../drivers/net/hyperv
182 #include <trace/define_trace.h>
183