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