GNU Linux-libre 4.14.266-gnu1
[releases.git] / drivers / staging / fsl-dpaa2 / ethernet / dpaa2-eth-trace.h
1 /* Copyright 2014-2015 Freescale Semiconductor Inc.
2  *
3  * Redistribution and use in source and binary forms, with or without
4  * modification, are permitted provided that the following conditions are met:
5  *     * Redistributions of source code must retain the above copyright
6  *       notice, this list of conditions and the following disclaimer.
7  *     * Redistributions in binary form must reproduce the above copyright
8  *       notice, this list of conditions and the following disclaimer in the
9  *       documentation and/or other materials provided with the distribution.
10  *     * Neither the name of Freescale Semiconductor nor the
11  *       names of its contributors may be used to endorse or promote products
12  *       derived from this software without specific prior written permission.
13  *
14  *
15  * ALTERNATIVELY, this software may be distributed under the terms of the
16  * GNU General Public License ("GPL") as published by the Free Software
17  * Foundation, either version 2 of that License or (at your option) any
18  * later version.
19  *
20  * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
21  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23  * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
24  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31
32 #undef TRACE_SYSTEM
33 #define TRACE_SYSTEM    dpaa2_eth
34
35 #if !defined(_DPAA2_ETH_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
36 #define _DPAA2_ETH_TRACE_H
37
38 #include <linux/skbuff.h>
39 #include <linux/netdevice.h>
40 #include "dpaa2-eth.h"
41 #include <linux/tracepoint.h>
42
43 #define TR_FMT "[%s] fd: addr=0x%llx, len=%u, off=%u"
44 /* trace_printk format for raw buffer event class */
45 #define TR_BUF_FMT "[%s] vaddr=%p size=%zu dma_addr=%pad map_size=%zu bpid=%d"
46
47 /* This is used to declare a class of events.
48  * individual events of this type will be defined below.
49  */
50
51 /* Store details about a frame descriptor */
52 DECLARE_EVENT_CLASS(dpaa2_eth_fd,
53                     /* Trace function prototype */
54                     TP_PROTO(struct net_device *netdev,
55                              const struct dpaa2_fd *fd),
56
57                     /* Repeat argument list here */
58                     TP_ARGS(netdev, fd),
59
60                     /* A structure containing the relevant information we want
61                      * to record. Declare name and type for each normal element,
62                      * name, type and size for arrays. Use __string for variable
63                      * length strings.
64                      */
65                     TP_STRUCT__entry(
66                                      __field(u64, fd_addr)
67                                      __field(u32, fd_len)
68                                      __field(u16, fd_offset)
69                                      __string(name, netdev->name)
70                     ),
71
72                     /* The function that assigns values to the above declared
73                      * fields
74                      */
75                     TP_fast_assign(
76                                    __entry->fd_addr = dpaa2_fd_get_addr(fd);
77                                    __entry->fd_len = dpaa2_fd_get_len(fd);
78                                    __entry->fd_offset = dpaa2_fd_get_offset(fd);
79                                    __assign_str(name, netdev->name);
80                     ),
81
82                     /* This is what gets printed when the trace event is
83                      * triggered.
84                      */
85                     TP_printk(TR_FMT,
86                               __get_str(name),
87                               __entry->fd_addr,
88                               __entry->fd_len,
89                               __entry->fd_offset)
90 );
91
92 /* Now declare events of the above type. Format is:
93  * DEFINE_EVENT(class, name, proto, args), with proto and args same as for class
94  */
95
96 /* Tx (egress) fd */
97 DEFINE_EVENT(dpaa2_eth_fd, dpaa2_tx_fd,
98              TP_PROTO(struct net_device *netdev,
99                       const struct dpaa2_fd *fd),
100
101              TP_ARGS(netdev, fd)
102 );
103
104 /* Rx fd */
105 DEFINE_EVENT(dpaa2_eth_fd, dpaa2_rx_fd,
106              TP_PROTO(struct net_device *netdev,
107                       const struct dpaa2_fd *fd),
108
109              TP_ARGS(netdev, fd)
110 );
111
112 /* Tx confirmation fd */
113 DEFINE_EVENT(dpaa2_eth_fd, dpaa2_tx_conf_fd,
114              TP_PROTO(struct net_device *netdev,
115                       const struct dpaa2_fd *fd),
116
117              TP_ARGS(netdev, fd)
118 );
119
120 /* Log data about raw buffers. Useful for tracing DPBP content. */
121 TRACE_EVENT(dpaa2_eth_buf_seed,
122             /* Trace function prototype */
123             TP_PROTO(struct net_device *netdev,
124                      /* virtual address and size */
125                      void *vaddr,
126                      size_t size,
127                      /* dma map address and size */
128                      dma_addr_t dma_addr,
129                      size_t map_size,
130                      /* buffer pool id, if relevant */
131                      u16 bpid),
132
133             /* Repeat argument list here */
134             TP_ARGS(netdev, vaddr, size, dma_addr, map_size, bpid),
135
136             /* A structure containing the relevant information we want
137              * to record. Declare name and type for each normal element,
138              * name, type and size for arrays. Use __string for variable
139              * length strings.
140              */
141             TP_STRUCT__entry(
142                              __field(void *, vaddr)
143                              __field(size_t, size)
144                              __field(dma_addr_t, dma_addr)
145                              __field(size_t, map_size)
146                              __field(u16, bpid)
147                              __string(name, netdev->name)
148             ),
149
150             /* The function that assigns values to the above declared
151              * fields
152              */
153             TP_fast_assign(
154                            __entry->vaddr = vaddr;
155                            __entry->size = size;
156                            __entry->dma_addr = dma_addr;
157                            __entry->map_size = map_size;
158                            __entry->bpid = bpid;
159                            __assign_str(name, netdev->name);
160             ),
161
162             /* This is what gets printed when the trace event is
163              * triggered.
164              */
165             TP_printk(TR_BUF_FMT,
166                       __get_str(name),
167                       __entry->vaddr,
168                       __entry->size,
169                       &__entry->dma_addr,
170                       __entry->map_size,
171                       __entry->bpid)
172 );
173
174 /* If only one event of a certain type needs to be declared, use TRACE_EVENT().
175  * The syntax is the same as for DECLARE_EVENT_CLASS().
176  */
177
178 #endif /* _DPAA2_ETH_TRACE_H */
179
180 /* This must be outside ifdef _DPAA2_ETH_TRACE_H */
181 #undef TRACE_INCLUDE_PATH
182 #define TRACE_INCLUDE_PATH .
183 #undef TRACE_INCLUDE_FILE
184 #define TRACE_INCLUDE_FILE      dpaa2-eth-trace
185 #include <trace/define_trace.h>