1 /* Copyright 2013-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	dpaa_eth
34 
35 #if !defined(_DPAA_ETH_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
36 #define _DPAA_ETH_TRACE_H
37 
38 #include <linux/skbuff.h>
39 #include <linux/netdevice.h>
40 #include "dpaa_eth.h"
41 #include <linux/tracepoint.h>
42 
43 #define fd_format_name(format)	{ qm_fd_##format, #format }
44 #define fd_format_list	\
45 	fd_format_name(contig),	\
46 	fd_format_name(sg)
47 
48 /* This is used to declare a class of events.
49  * individual events of this type will be defined below.
50  */
51 
52 /* Store details about a frame descriptor and the FQ on which it was
53  * transmitted/received.
54  */
55 DECLARE_EVENT_CLASS(dpaa_eth_fd,
56 	/* Trace function prototype */
57 	TP_PROTO(struct net_device *netdev,
58 		 struct qman_fq *fq,
59 		 const struct qm_fd *fd),
60 
61 	/* Repeat argument list here */
62 	TP_ARGS(netdev, fq, fd),
63 
64 	/* A structure containing the relevant information we want to record.
65 	 * Declare name and type for each normal element, name, type and size
66 	 * for arrays. Use __string for variable length strings.
67 	 */
68 	TP_STRUCT__entry(
69 		__field(u32,	fqid)
70 		__field(u64,	fd_addr)
71 		__field(u8,	fd_format)
72 		__field(u16,	fd_offset)
73 		__field(u32,	fd_length)
74 		__field(u32,	fd_status)
75 		__string(name,	netdev->name)
76 	),
77 
78 	/* The function that assigns values to the above declared fields */
79 	TP_fast_assign(
80 		__entry->fqid = fq->fqid;
81 		__entry->fd_addr = qm_fd_addr_get64(fd);
82 		__entry->fd_format = qm_fd_get_format(fd);
83 		__entry->fd_offset = qm_fd_get_offset(fd);
84 		__entry->fd_length = qm_fd_get_length(fd);
85 		__entry->fd_status = fd->status;
86 		__assign_str(name, netdev->name);
87 	),
88 
89 	/* This is what gets printed when the trace event is triggered */
90 	TP_printk("[%s] fqid=%d, fd: addr=0x%llx, format=%s, off=%u, len=%u, status=0x%08x",
91 		  __get_str(name), __entry->fqid, __entry->fd_addr,
92 		  __print_symbolic(__entry->fd_format, fd_format_list),
93 		  __entry->fd_offset, __entry->fd_length, __entry->fd_status)
94 );
95 
96 /* Now declare events of the above type. Format is:
97  * DEFINE_EVENT(class, name, proto, args), with proto and args same as for class
98  */
99 
100 /* Tx (egress) fd */
101 DEFINE_EVENT(dpaa_eth_fd, dpaa_tx_fd,
102 
103 	TP_PROTO(struct net_device *netdev,
104 		 struct qman_fq *fq,
105 		 const struct qm_fd *fd),
106 
107 	TP_ARGS(netdev, fq, fd)
108 );
109 
110 /* Rx fd */
111 DEFINE_EVENT(dpaa_eth_fd, dpaa_rx_fd,
112 
113 	TP_PROTO(struct net_device *netdev,
114 		 struct qman_fq *fq,
115 		 const struct qm_fd *fd),
116 
117 	TP_ARGS(netdev, fq, fd)
118 );
119 
120 /* Tx confirmation fd */
121 DEFINE_EVENT(dpaa_eth_fd, dpaa_tx_conf_fd,
122 
123 	TP_PROTO(struct net_device *netdev,
124 		 struct qman_fq *fq,
125 		 const struct qm_fd *fd),
126 
127 	TP_ARGS(netdev, fq, fd)
128 );
129 
130 /* If only one event of a certain type needs to be declared, use TRACE_EVENT().
131  * The syntax is the same as for DECLARE_EVENT_CLASS().
132  */
133 
134 #endif /* _DPAA_ETH_TRACE_H */
135 
136 /* This must be outside ifdef _DPAA_ETH_TRACE_H */
137 #undef TRACE_INCLUDE_PATH
138 #define TRACE_INCLUDE_PATH .
139 #undef TRACE_INCLUDE_FILE
140 #define TRACE_INCLUDE_FILE	dpaa_eth_trace
141 #include <trace/define_trace.h>
142