1 /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
2 /* Copyright 2014-2015 Freescale Semiconductor Inc.
3  */
4 
5 #undef TRACE_SYSTEM
6 #define TRACE_SYSTEM	dpaa2_eth
7 
8 #if !defined(_DPAA2_ETH_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
9 #define _DPAA2_ETH_TRACE_H
10 
11 #include <linux/skbuff.h>
12 #include <linux/netdevice.h>
13 #include <linux/tracepoint.h>
14 
15 #define TR_FMT "[%s] fd: addr=0x%llx, len=%u, off=%u"
16 /* trace_printk format for raw buffer event class */
17 #define TR_BUF_FMT "[%s] vaddr=%p size=%zu dma_addr=%pad map_size=%zu bpid=%d"
18 
19 /* This is used to declare a class of events.
20  * individual events of this type will be defined below.
21  */
22 
23 /* Store details about a frame descriptor */
24 DECLARE_EVENT_CLASS(dpaa2_eth_fd,
25 		    /* Trace function prototype */
26 		    TP_PROTO(struct net_device *netdev,
27 			     const struct dpaa2_fd *fd),
28 
29 		    /* Repeat argument list here */
30 		    TP_ARGS(netdev, fd),
31 
32 		    /* A structure containing the relevant information we want
33 		     * to record. Declare name and type for each normal element,
34 		     * name, type and size for arrays. Use __string for variable
35 		     * length strings.
36 		     */
37 		    TP_STRUCT__entry(
38 				     __field(u64, fd_addr)
39 				     __field(u32, fd_len)
40 				     __field(u16, fd_offset)
41 				     __string(name, netdev->name)
42 		    ),
43 
44 		    /* The function that assigns values to the above declared
45 		     * fields
46 		     */
47 		    TP_fast_assign(
48 				   __entry->fd_addr = dpaa2_fd_get_addr(fd);
49 				   __entry->fd_len = dpaa2_fd_get_len(fd);
50 				   __entry->fd_offset = dpaa2_fd_get_offset(fd);
51 				   __assign_str(name, netdev->name);
52 		    ),
53 
54 		    /* This is what gets printed when the trace event is
55 		     * triggered.
56 		     */
57 		    TP_printk(TR_FMT,
58 			      __get_str(name),
59 			      __entry->fd_addr,
60 			      __entry->fd_len,
61 			      __entry->fd_offset)
62 );
63 
64 /* Now declare events of the above type. Format is:
65  * DEFINE_EVENT(class, name, proto, args), with proto and args same as for class
66  */
67 
68 /* Tx (egress) fd */
69 DEFINE_EVENT(dpaa2_eth_fd, dpaa2_tx_fd,
70 	     TP_PROTO(struct net_device *netdev,
71 		      const struct dpaa2_fd *fd),
72 
73 	     TP_ARGS(netdev, fd)
74 );
75 
76 /* Rx fd */
77 DEFINE_EVENT(dpaa2_eth_fd, dpaa2_rx_fd,
78 	     TP_PROTO(struct net_device *netdev,
79 		      const struct dpaa2_fd *fd),
80 
81 	     TP_ARGS(netdev, fd)
82 );
83 
84 /* Tx confirmation fd */
85 DEFINE_EVENT(dpaa2_eth_fd, dpaa2_tx_conf_fd,
86 	     TP_PROTO(struct net_device *netdev,
87 		      const struct dpaa2_fd *fd),
88 
89 	     TP_ARGS(netdev, fd)
90 );
91 
92 /* Log data about raw buffers. Useful for tracing DPBP content. */
93 TRACE_EVENT(dpaa2_eth_buf_seed,
94 	    /* Trace function prototype */
95 	    TP_PROTO(struct net_device *netdev,
96 		     /* virtual address and size */
97 		     void *vaddr,
98 		     size_t size,
99 		     /* dma map address and size */
100 		     dma_addr_t dma_addr,
101 		     size_t map_size,
102 		     /* buffer pool id, if relevant */
103 		     u16 bpid),
104 
105 	    /* Repeat argument list here */
106 	    TP_ARGS(netdev, vaddr, size, dma_addr, map_size, bpid),
107 
108 	    /* A structure containing the relevant information we want
109 	     * to record. Declare name and type for each normal element,
110 	     * name, type and size for arrays. Use __string for variable
111 	     * length strings.
112 	     */
113 	    TP_STRUCT__entry(
114 			     __field(void *, vaddr)
115 			     __field(size_t, size)
116 			     __field(dma_addr_t, dma_addr)
117 			     __field(size_t, map_size)
118 			     __field(u16, bpid)
119 			     __string(name, netdev->name)
120 	    ),
121 
122 	    /* The function that assigns values to the above declared
123 	     * fields
124 	     */
125 	    TP_fast_assign(
126 			   __entry->vaddr = vaddr;
127 			   __entry->size = size;
128 			   __entry->dma_addr = dma_addr;
129 			   __entry->map_size = map_size;
130 			   __entry->bpid = bpid;
131 			   __assign_str(name, netdev->name);
132 	    ),
133 
134 	    /* This is what gets printed when the trace event is
135 	     * triggered.
136 	     */
137 	    TP_printk(TR_BUF_FMT,
138 		      __get_str(name),
139 		      __entry->vaddr,
140 		      __entry->size,
141 		      &__entry->dma_addr,
142 		      __entry->map_size,
143 		      __entry->bpid)
144 );
145 
146 /* If only one event of a certain type needs to be declared, use TRACE_EVENT().
147  * The syntax is the same as for DECLARE_EVENT_CLASS().
148  */
149 
150 #endif /* _DPAA2_ETH_TRACE_H */
151 
152 /* This must be outside ifdef _DPAA2_ETH_TRACE_H */
153 #undef TRACE_INCLUDE_PATH
154 #define TRACE_INCLUDE_PATH .
155 #undef TRACE_INCLUDE_FILE
156 #define TRACE_INCLUDE_FILE	dpaa2-eth-trace
157 #include <trace/define_trace.h>
158