1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /****************************************************************************** 3 * 4 * Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved. 5 * Copyright(c) 2015 Intel Mobile Communications GmbH 6 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH 7 * Copyright(c) 2018, 2023 Intel Corporation 8 *****************************************************************************/ 9 10 #if !defined(__IWLWIFI_DEVICE_TRACE_IWLWIFI) || defined(TRACE_HEADER_MULTI_READ) 11 #define __IWLWIFI_DEVICE_TRACE_IWLWIFI 12 13 #include <linux/tracepoint.h> 14 15 #undef TRACE_SYSTEM 16 #define TRACE_SYSTEM iwlwifi 17 18 TRACE_EVENT(iwlwifi_dev_hcmd, 19 TP_PROTO(const struct device *dev, 20 struct iwl_host_cmd *cmd, u16 total_size, 21 struct iwl_cmd_header_wide *hdr), 22 TP_ARGS(dev, cmd, total_size, hdr), 23 TP_STRUCT__entry( 24 DEV_ENTRY 25 __dynamic_array(u8, hcmd, total_size) 26 __field(u32, flags) 27 ), 28 TP_fast_assign( 29 int i, offset = sizeof(struct iwl_cmd_header); 30 31 if (hdr->group_id) 32 offset = sizeof(struct iwl_cmd_header_wide); 33 34 DEV_ASSIGN; 35 __entry->flags = cmd->flags; 36 memcpy(__get_dynamic_array(hcmd), hdr, offset); 37 38 for (i = 0; i < IWL_MAX_CMD_TBS_PER_TFD; i++) { 39 if (!cmd->len[i]) 40 continue; 41 memcpy((u8 *)__get_dynamic_array(hcmd) + offset, 42 cmd->data[i], cmd->len[i]); 43 offset += cmd->len[i]; 44 } 45 ), 46 TP_printk("[%s] hcmd %#.2x.%#.2x (%ssync)", 47 __get_str(dev), ((u8 *)__get_dynamic_array(hcmd))[1], 48 ((u8 *)__get_dynamic_array(hcmd))[0], 49 __entry->flags & CMD_ASYNC ? "a" : "") 50 ); 51 52 TRACE_EVENT(iwlwifi_dev_rx, 53 TP_PROTO(const struct device *dev, 54 struct iwl_rx_packet *pkt, size_t len, size_t trace_len, 55 size_t hdr_offset), 56 TP_ARGS(dev, pkt, len, trace_len, hdr_offset), 57 TP_STRUCT__entry( 58 DEV_ENTRY 59 __field(u16, cmd) 60 __field(u8, hdr_offset) 61 __dynamic_array(u8, rxbuf, trace_len) 62 ), 63 TP_fast_assign( 64 DEV_ASSIGN; 65 __entry->cmd = WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd); 66 memcpy(__get_dynamic_array(rxbuf), pkt, trace_len); 67 __entry->hdr_offset = hdr_offset; 68 ), 69 TP_printk("[%s] RX cmd %#.2x", 70 __get_str(dev), __entry->cmd) 71 ); 72 73 TRACE_EVENT(iwlwifi_dev_tx, 74 TP_PROTO(const struct device *dev, struct sk_buff *skb, 75 void *tfd, size_t tfdlen, 76 void *buf0, size_t buf0_len, 77 int hdr_len), 78 TP_ARGS(dev, skb, tfd, tfdlen, buf0, buf0_len, hdr_len), 79 TP_STRUCT__entry( 80 DEV_ENTRY 81 __field(void *, skbaddr) 82 __field(size_t, framelen) 83 __dynamic_array(u8, tfd, tfdlen) 84 85 /* 86 * Do not insert between or below these items, 87 * we want to keep the frame together (except 88 * for the possible padding). 89 */ 90 __dynamic_array(u8, buf0, buf0_len) 91 __dynamic_array(u8, buf1, hdr_len > 0 && iwl_trace_data(skb) ? 92 0 : skb->len - hdr_len) 93 ), 94 TP_fast_assign( 95 DEV_ASSIGN; 96 __entry->skbaddr = skb; 97 __entry->framelen = buf0_len; 98 if (hdr_len > 0) 99 __entry->framelen += skb->len - hdr_len; 100 memcpy(__get_dynamic_array(tfd), tfd, tfdlen); 101 memcpy(__get_dynamic_array(buf0), buf0, buf0_len); 102 if (hdr_len > 0 && !iwl_trace_data(skb)) 103 skb_copy_bits(skb, hdr_len, 104 __get_dynamic_array(buf1), 105 skb->len - hdr_len); 106 ), 107 TP_printk("[%s] TX %.2x (%zu bytes) skbaddr=%p", 108 __get_str(dev), ((u8 *)__get_dynamic_array(buf0))[0], 109 __entry->framelen, __entry->skbaddr) 110 ); 111 112 TRACE_EVENT(iwlwifi_dev_ucode_event, 113 TP_PROTO(const struct device *dev, u32 time, u32 data, u32 ev), 114 TP_ARGS(dev, time, data, ev), 115 TP_STRUCT__entry( 116 DEV_ENTRY 117 118 __field(u32, time) 119 __field(u32, data) 120 __field(u32, ev) 121 ), 122 TP_fast_assign( 123 DEV_ASSIGN; 124 __entry->time = time; 125 __entry->data = data; 126 __entry->ev = ev; 127 ), 128 TP_printk("[%s] EVT_LOGT:%010u:0x%08x:%04u", 129 __get_str(dev), __entry->time, __entry->data, __entry->ev) 130 ); 131 #endif /* __IWLWIFI_DEVICE_TRACE_IWLWIFI */ 132 133 #undef TRACE_INCLUDE_PATH 134 #define TRACE_INCLUDE_PATH . 135 #undef TRACE_INCLUDE_FILE 136 #define TRACE_INCLUDE_FILE iwl-devtrace-iwlwifi 137 #include <trace/define_trace.h> 138