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 /* Tx (egress) XSK fd */ 77 DEFINE_EVENT(dpaa2_eth_fd, dpaa2_tx_xsk_fd, 78 TP_PROTO(struct net_device *netdev, 79 const struct dpaa2_fd *fd), 80 81 TP_ARGS(netdev, fd) 82 ); 83 84 /* Rx fd */ 85 DEFINE_EVENT(dpaa2_eth_fd, dpaa2_rx_fd, 86 TP_PROTO(struct net_device *netdev, 87 const struct dpaa2_fd *fd), 88 89 TP_ARGS(netdev, fd) 90 ); 91 92 /* Rx XSK fd */ 93 DEFINE_EVENT(dpaa2_eth_fd, dpaa2_rx_xsk_fd, 94 TP_PROTO(struct net_device *netdev, 95 const struct dpaa2_fd *fd), 96 97 TP_ARGS(netdev, fd) 98 ); 99 100 /* Tx confirmation fd */ 101 DEFINE_EVENT(dpaa2_eth_fd, dpaa2_tx_conf_fd, 102 TP_PROTO(struct net_device *netdev, 103 const struct dpaa2_fd *fd), 104 105 TP_ARGS(netdev, fd) 106 ); 107 108 /* Log data about raw buffers. Useful for tracing DPBP content. */ 109 DECLARE_EVENT_CLASS(dpaa2_eth_buf, 110 /* Trace function prototype */ 111 TP_PROTO(struct net_device *netdev, 112 /* virtual address and size */ 113 void *vaddr, 114 size_t size, 115 /* dma map address and size */ 116 dma_addr_t dma_addr, 117 size_t map_size, 118 /* buffer pool id, if relevant */ 119 u16 bpid), 120 121 /* Repeat argument list here */ 122 TP_ARGS(netdev, vaddr, size, dma_addr, map_size, bpid), 123 124 /* A structure containing the relevant information we want 125 * to record. Declare name and type for each normal element, 126 * name, type and size for arrays. Use __string for variable 127 * length strings. 128 */ 129 TP_STRUCT__entry( 130 __field(void *, vaddr) 131 __field(size_t, size) 132 __field(dma_addr_t, dma_addr) 133 __field(size_t, map_size) 134 __field(u16, bpid) 135 __string(name, netdev->name) 136 ), 137 138 /* The function that assigns values to the above declared 139 * fields 140 */ 141 TP_fast_assign( 142 __entry->vaddr = vaddr; 143 __entry->size = size; 144 __entry->dma_addr = dma_addr; 145 __entry->map_size = map_size; 146 __entry->bpid = bpid; 147 __assign_str(name, netdev->name); 148 ), 149 150 /* This is what gets printed when the trace event is 151 * triggered. 152 */ 153 TP_printk(TR_BUF_FMT, 154 __get_str(name), 155 __entry->vaddr, 156 __entry->size, 157 &__entry->dma_addr, 158 __entry->map_size, 159 __entry->bpid) 160 ); 161 162 /* Main memory buff seeding */ 163 DEFINE_EVENT(dpaa2_eth_buf, dpaa2_eth_buf_seed, 164 TP_PROTO(struct net_device *netdev, 165 void *vaddr, 166 size_t size, 167 dma_addr_t dma_addr, 168 size_t map_size, 169 u16 bpid), 170 171 TP_ARGS(netdev, vaddr, size, dma_addr, map_size, bpid) 172 ); 173 174 /* UMEM buff seeding on AF_XDP fast path */ 175 DEFINE_EVENT(dpaa2_eth_buf, dpaa2_xsk_buf_seed, 176 TP_PROTO(struct net_device *netdev, 177 void *vaddr, 178 size_t size, 179 dma_addr_t dma_addr, 180 size_t map_size, 181 u16 bpid), 182 183 TP_ARGS(netdev, vaddr, size, dma_addr, map_size, bpid) 184 ); 185 186 /* If only one event of a certain type needs to be declared, use TRACE_EVENT(). 187 * The syntax is the same as for DECLARE_EVENT_CLASS(). 188 */ 189 190 #endif /* _DPAA2_ETH_TRACE_H */ 191 192 /* This must be outside ifdef _DPAA2_ETH_TRACE_H */ 193 #undef TRACE_INCLUDE_PATH 194 #define TRACE_INCLUDE_PATH . 195 #undef TRACE_INCLUDE_FILE 196 #define TRACE_INCLUDE_FILE dpaa2-eth-trace 197 #include <trace/define_trace.h> 198