xref: /openbmc/linux/drivers/net/fjes/fjes_trace.h (revision c4c3c32d)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  *  FUJITSU Extended Socket Network Device driver
4  *  Copyright (c) 2015-2016 FUJITSU LIMITED
5  */
6 
7 #if !defined(FJES_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
8 #define FJES_TRACE_H_
9 
10 #include <linux/types.h>
11 #include <linux/tracepoint.h>
12 
13 #undef TRACE_SYSTEM
14 #define TRACE_SYSTEM fjes
15 
16 /* tracepoints for fjes_hw.c */
17 
18 TRACE_EVENT(fjes_hw_issue_request_command,
19 	TP_PROTO(union REG_CR *cr, union REG_CS *cs, int timeout,
20 		 enum fjes_dev_command_response_e ret),
21 	TP_ARGS(cr, cs, timeout, ret),
22 	TP_STRUCT__entry(
23 		__field(u16, cr_req)
24 		__field(u8, cr_error)
25 		__field(u16, cr_err_info)
26 		__field(u8, cr_req_start)
27 		__field(u16, cs_req)
28 		__field(u8, cs_busy)
29 		__field(u8, cs_complete)
30 		__field(int, timeout)
31 		__field(int, ret)
32 	),
33 	TP_fast_assign(
34 		__entry->cr_req = cr->bits.req_code;
35 		__entry->cr_error = cr->bits.error;
36 		__entry->cr_err_info = cr->bits.err_info;
37 		__entry->cr_req_start = cr->bits.req_start;
38 		__entry->cs_req = cs->bits.req_code;
39 		__entry->cs_busy = cs->bits.busy;
40 		__entry->cs_complete = cs->bits.complete;
41 		__entry->timeout = timeout;
42 		__entry->ret = ret;
43 	),
44 	TP_printk("CR=[req=%04x, error=%u, err_info=%04x, req_start=%u], CS=[req=%04x, busy=%u, complete=%u], timeout=%d, ret=%d",
45 		  __entry->cr_req, __entry->cr_error, __entry->cr_err_info,
46 		  __entry->cr_req_start, __entry->cs_req, __entry->cs_busy,
47 		  __entry->cs_complete, __entry->timeout, __entry->ret)
48 );
49 
50 TRACE_EVENT(fjes_hw_request_info,
51 	TP_PROTO(struct fjes_hw *hw, union fjes_device_command_res *res_buf),
52 	TP_ARGS(hw, res_buf),
53 	TP_STRUCT__entry(
54 		__field(int, length)
55 		__field(int, code)
56 		__dynamic_array(u8, zone, hw->max_epid)
57 		__dynamic_array(u8, status, hw->max_epid)
58 	),
59 	TP_fast_assign(
60 		int x;
61 
62 		__entry->length = res_buf->info.length;
63 		__entry->code = res_buf->info.code;
64 		for (x = 0; x < hw->max_epid; x++) {
65 			*((u8 *)__get_dynamic_array(zone) + x) =
66 					res_buf->info.info[x].zone;
67 			*((u8 *)__get_dynamic_array(status) + x) =
68 					res_buf->info.info[x].es_status;
69 		}
70 	),
71 	TP_printk("res_buf=[length=%d, code=%d, es_zones=%s, es_status=%s]",
72 		  __entry->length, __entry->code,
73 		  __print_array(__get_dynamic_array(zone),
74 				__get_dynamic_array_len(zone) / sizeof(u8),
75 				sizeof(u8)),
76 		  __print_array(__get_dynamic_array(status),
77 				__get_dynamic_array_len(status) / sizeof(u8),
78 				sizeof(u8)))
79 );
80 
81 TRACE_EVENT(fjes_hw_request_info_err,
82 	TP_PROTO(char *err),
83 	TP_ARGS(err),
84 	TP_STRUCT__entry(
85 		__string(err, err)
86 	),
87 	TP_fast_assign(
88 		__assign_str(err, err);
89 	),
90 	TP_printk("%s", __get_str(err))
91 );
92 
93 TRACE_EVENT(fjes_hw_register_buff_addr_req,
94 	TP_PROTO(union fjes_device_command_req *req_buf,
95 		 struct ep_share_mem_info *buf_pair),
96 	TP_ARGS(req_buf, buf_pair),
97 	TP_STRUCT__entry(
98 		__field(int, length)
99 		__field(int, epid)
100 		__field(u64, tx)
101 		__field(size_t,	tx_size)
102 		__field(u64, rx)
103 		__field(size_t,	rx_size)
104 	),
105 	TP_fast_assign(
106 		void *tx, *rx;
107 
108 		tx = (void *)buf_pair->tx.buffer;
109 		rx = (void *)buf_pair->rx.buffer;
110 		__entry->length = req_buf->share_buffer.length;
111 		__entry->epid = req_buf->share_buffer.epid;
112 		__entry->tx_size = buf_pair->tx.size;
113 		__entry->rx_size = buf_pair->rx.size;
114 		__entry->tx = page_to_phys(vmalloc_to_page(tx)) +
115 				offset_in_page(tx);
116 		__entry->rx = page_to_phys(vmalloc_to_page(rx)) +
117 				offset_in_page(rx);
118 	),
119 	TP_printk("req_buf=[length=%d, epid=%d], TX=[phy=0x%016llx, size=%zu], RX=[phy=0x%016llx, size=%zu]",
120 		  __entry->length, __entry->epid, __entry->tx, __entry->tx_size,
121 		  __entry->rx, __entry->rx_size)
122 );
123 
124 TRACE_EVENT(fjes_hw_register_buff_addr,
125 	TP_PROTO(union fjes_device_command_res *res_buf, int timeout),
126 	TP_ARGS(res_buf, timeout),
127 	TP_STRUCT__entry(
128 		__field(int, length)
129 		__field(int, code)
130 		__field(int, timeout)
131 	),
132 	TP_fast_assign(
133 		__entry->length = res_buf->share_buffer.length;
134 		__entry->code = res_buf->share_buffer.code;
135 		__entry->timeout = timeout;
136 	),
137 	TP_printk("res_buf=[length=%d, code=%d], timeout=%d",
138 		  __entry->length, __entry->code, __entry->timeout)
139 );
140 
141 TRACE_EVENT(fjes_hw_register_buff_addr_err,
142 	TP_PROTO(char *err),
143 	TP_ARGS(err),
144 	TP_STRUCT__entry(
145 		__string(err, err)
146 	),
147 	TP_fast_assign(
148 		__assign_str(err, err);
149 	),
150 	TP_printk("%s", __get_str(err))
151 );
152 
153 TRACE_EVENT(fjes_hw_unregister_buff_addr_req,
154 	TP_PROTO(union fjes_device_command_req *req_buf),
155 	TP_ARGS(req_buf),
156 	TP_STRUCT__entry(
157 		__field(int, length)
158 		__field(int, epid)
159 	),
160 	TP_fast_assign(
161 		__entry->length = req_buf->unshare_buffer.length;
162 		__entry->epid = req_buf->unshare_buffer.epid;
163 	),
164 	TP_printk("req_buf=[length=%d, epid=%d]",
165 		  __entry->length, __entry->epid)
166 );
167 
168 TRACE_EVENT(fjes_hw_unregister_buff_addr,
169 	TP_PROTO(union fjes_device_command_res *res_buf, int timeout),
170 	TP_ARGS(res_buf, timeout),
171 	TP_STRUCT__entry(
172 		__field(int, length)
173 		__field(int, code)
174 		__field(int, timeout)
175 	),
176 	TP_fast_assign(
177 		__entry->length = res_buf->unshare_buffer.length;
178 		__entry->code = res_buf->unshare_buffer.code;
179 		__entry->timeout = timeout;
180 	),
181 	TP_printk("res_buf=[length=%d, code=%d], timeout=%d",
182 		  __entry->length, __entry->code, __entry->timeout)
183 );
184 
185 TRACE_EVENT(fjes_hw_unregister_buff_addr_err,
186 	TP_PROTO(char *err),
187 	TP_ARGS(err),
188 	TP_STRUCT__entry(
189 		__string(err, err)
190 	),
191 	TP_fast_assign(
192 		__assign_str(err, err);
193 	),
194 	TP_printk("%s", __get_str(err))
195 );
196 
197 TRACE_EVENT(fjes_hw_start_debug_req,
198 	TP_PROTO(union fjes_device_command_req *req_buf),
199 	TP_ARGS(req_buf),
200 	TP_STRUCT__entry(
201 		__field(int, length)
202 		__field(int, mode)
203 		__field(phys_addr_t, buffer)
204 	),
205 	TP_fast_assign(
206 		__entry->length = req_buf->start_trace.length;
207 		__entry->mode = req_buf->start_trace.mode;
208 		__entry->buffer = req_buf->start_trace.buffer[0];
209 	),
210 	TP_printk("req_buf=[length=%d, mode=%d, buffer=%pap]",
211 		  __entry->length, __entry->mode, &__entry->buffer)
212 );
213 
214 TRACE_EVENT(fjes_hw_start_debug,
215 	TP_PROTO(union fjes_device_command_res *res_buf),
216 	TP_ARGS(res_buf),
217 	TP_STRUCT__entry(
218 		__field(int, length)
219 		__field(int, code)
220 	),
221 	TP_fast_assign(
222 		__entry->length = res_buf->start_trace.length;
223 		__entry->code = res_buf->start_trace.code;
224 	),
225 	TP_printk("res_buf=[length=%d, code=%d]", __entry->length, __entry->code)
226 );
227 
228 TRACE_EVENT(fjes_hw_start_debug_err,
229 	TP_PROTO(char *err),
230 	TP_ARGS(err),
231 	TP_STRUCT__entry(
232 		 __string(err, err)
233 	),
234 	TP_fast_assign(
235 		__assign_str(err, err);
236 	),
237 	TP_printk("%s", __get_str(err))
238 );
239 
240 TRACE_EVENT(fjes_hw_stop_debug,
241 	TP_PROTO(union fjes_device_command_res *res_buf),
242 	TP_ARGS(res_buf),
243 	TP_STRUCT__entry(
244 		__field(int, length)
245 		__field(int, code)
246 	),
247 	TP_fast_assign(
248 		__entry->length = res_buf->stop_trace.length;
249 		__entry->code = res_buf->stop_trace.code;
250 	),
251 	TP_printk("res_buf=[length=%d, code=%d]", __entry->length, __entry->code)
252 );
253 
254 TRACE_EVENT(fjes_hw_stop_debug_err,
255 	TP_PROTO(char *err),
256 	TP_ARGS(err),
257 	TP_STRUCT__entry(
258 		 __string(err, err)
259 	),
260 	TP_fast_assign(
261 		__assign_str(err, err);
262 	),
263 	TP_printk("%s", __get_str(err))
264 );
265 
266 /* tracepoints for fjes_main.c */
267 
268 TRACE_EVENT(fjes_txrx_stop_req_irq_pre,
269 	TP_PROTO(struct fjes_hw *hw, int src_epid,
270 		 enum ep_partner_status status),
271 	TP_ARGS(hw, src_epid, status),
272 	TP_STRUCT__entry(
273 		__field(int, src_epid)
274 		__field(enum ep_partner_status, status)
275 		__field(u8, ep_status)
276 		__field(unsigned long, txrx_stop_req_bit)
277 		__field(u16, rx_status)
278 	),
279 	TP_fast_assign(
280 		__entry->src_epid = src_epid;
281 		__entry->status = status;
282 		__entry->ep_status = hw->hw_info.share->ep_status[src_epid];
283 		__entry->txrx_stop_req_bit = hw->txrx_stop_req_bit;
284 		__entry->rx_status =
285 			hw->ep_shm_info[src_epid].tx.info->v1i.rx_status;
286 	),
287 	TP_printk("epid=%d, partner_status=%d, ep_status=%x, txrx_stop_req_bit=%016lx, tx.rx_status=%08x",
288 		  __entry->src_epid, __entry->status, __entry->ep_status,
289 		  __entry->txrx_stop_req_bit, __entry->rx_status)
290 );
291 
292 TRACE_EVENT(fjes_txrx_stop_req_irq_post,
293 	TP_PROTO(struct fjes_hw *hw, int src_epid),
294 	TP_ARGS(hw, src_epid),
295 	TP_STRUCT__entry(
296 		__field(int, src_epid)
297 		__field(u8, ep_status)
298 		__field(unsigned long, txrx_stop_req_bit)
299 		__field(u16, rx_status)
300 	),
301 	TP_fast_assign(
302 		__entry->src_epid = src_epid;
303 		__entry->ep_status = hw->hw_info.share->ep_status[src_epid];
304 		__entry->txrx_stop_req_bit = hw->txrx_stop_req_bit;
305 		__entry->rx_status = hw->ep_shm_info[src_epid].tx.info->v1i.rx_status;
306 	),
307 	TP_printk("epid=%d, ep_status=%x, txrx_stop_req_bit=%016lx, tx.rx_status=%08x",
308 		  __entry->src_epid, __entry->ep_status,
309 		  __entry->txrx_stop_req_bit, __entry->rx_status)
310 );
311 
312 TRACE_EVENT(fjes_stop_req_irq_pre,
313 	TP_PROTO(struct fjes_hw *hw, int src_epid,
314 		 enum ep_partner_status status),
315 	TP_ARGS(hw, src_epid, status),
316 	TP_STRUCT__entry(
317 		__field(int, src_epid)
318 		__field(enum ep_partner_status, status)
319 		__field(u8, ep_status)
320 		__field(unsigned long, txrx_stop_req_bit)
321 		__field(u16, rx_status)
322 	),
323 	TP_fast_assign(
324 		__entry->src_epid = src_epid;
325 		__entry->status = status;
326 		__entry->ep_status = hw->hw_info.share->ep_status[src_epid];
327 		__entry->txrx_stop_req_bit = hw->txrx_stop_req_bit;
328 		__entry->rx_status =
329 			hw->ep_shm_info[src_epid].tx.info->v1i.rx_status;
330 	),
331 	TP_printk("epid=%d, partner_status=%d, ep_status=%x, txrx_stop_req_bit=%016lx, tx.rx_status=%08x",
332 		  __entry->src_epid, __entry->status, __entry->ep_status,
333 		  __entry->txrx_stop_req_bit, __entry->rx_status)
334 );
335 
336 TRACE_EVENT(fjes_stop_req_irq_post,
337 	TP_PROTO(struct fjes_hw *hw, int src_epid),
338 	TP_ARGS(hw, src_epid),
339 	TP_STRUCT__entry(
340 		__field(int, src_epid)
341 		__field(u8, ep_status)
342 		__field(unsigned long, txrx_stop_req_bit)
343 		__field(u16, rx_status)
344 	),
345 	TP_fast_assign(
346 		__entry->src_epid = src_epid;
347 		__entry->ep_status = hw->hw_info.share->ep_status[src_epid];
348 		__entry->txrx_stop_req_bit = hw->txrx_stop_req_bit;
349 		__entry->rx_status =
350 			hw->ep_shm_info[src_epid].tx.info->v1i.rx_status;
351 	),
352 	TP_printk("epid=%d, ep_status=%x, txrx_stop_req_bit=%016lx, tx.rx_status=%08x",
353 		  __entry->src_epid, __entry->ep_status,
354 		  __entry->txrx_stop_req_bit, __entry->rx_status)
355 );
356 
357 #endif /* FJES_TRACE_H_ */
358 
359 #undef TRACE_INCLUDE_PATH
360 #undef TRACE_INCLUDE_FILE
361 #define TRACE_INCLUDE_PATH ../../../drivers/net/fjes
362 #define TRACE_INCLUDE_FILE fjes_trace
363 
364 /* This part must be outside protection */
365 #include <trace/define_trace.h>
366