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