1 /******************************************************************************
3 * Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved.
4 * Copyright(C) 2016 Intel Deutschland GmbH
5 * Copyright(c) 2018 Intel Corporation
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * The full GNU General Public License is included in this distribution in the
17 * file called LICENSE.
19 * Contact Information:
20 * Intel Linux Wireless <linuxwifi@intel.com>
21 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
23 *****************************************************************************/
25 #ifndef __IWLWIFI_DEVICE_TRACE
26 #include <linux/skbuff.h>
27 #include <linux/ieee80211.h>
28 #include <net/cfg80211.h>
29 #include "iwl-trans.h"
30 #if !defined(__IWLWIFI_DEVICE_TRACE)
31 static inline bool iwl_trace_data(struct sk_buff *skb)
33 struct ieee80211_hdr *hdr = (void *)skb->data;
34 __le16 fc = hdr->frame_control;
35 int offs = 24; /* start with normal header length */
37 if (!ieee80211_is_data(fc))
40 /* Try to determine if the frame is EAPOL. This might have false
41 * positives (if there's no RFC 1042 header and we compare to some
42 * payload instead) but since we're only doing tracing that's not
46 if (ieee80211_has_a4(fc))
48 if (ieee80211_is_data_qos(fc))
50 /* don't account for crypto - these are unencrypted */
52 /* also account for the RFC 1042 header, of course */
55 return skb->len <= offs + 2 ||
56 *(__be16 *)(skb->data + offs) != cpu_to_be16(ETH_P_PAE);
59 static inline size_t iwl_rx_trace_len(const struct iwl_trans *trans,
60 void *rxbuf, size_t len,
61 size_t *out_hdr_offset)
63 struct iwl_cmd_header *cmd = (void *)((u8 *)rxbuf + sizeof(__le32));
64 struct ieee80211_hdr *hdr = NULL;
67 if (cmd->cmd != trans->rx_mpdu_cmd)
70 hdr_offset = sizeof(struct iwl_cmd_header) +
71 trans->rx_mpdu_cmd_hdr_size;
74 *out_hdr_offset = hdr_offset;
76 hdr = (void *)((u8 *)cmd + hdr_offset);
77 if (!ieee80211_is_data(hdr->frame_control))
79 /* maybe try to identify EAPOL frames? */
80 return sizeof(__le32) + sizeof(*cmd) + trans->rx_mpdu_cmd_hdr_size +
81 ieee80211_hdrlen(hdr->frame_control);
85 #define __IWLWIFI_DEVICE_TRACE
87 #include <linux/tracepoint.h>
88 #include <linux/device.h>
89 #include "iwl-trans.h"
92 #if !defined(CONFIG_IWLWIFI_DEVICE_TRACING) || defined(__CHECKER__)
94 #define TRACE_EVENT(name, proto, ...) \
95 static inline void trace_ ## name(proto) {}
96 #undef DECLARE_EVENT_CLASS
97 #define DECLARE_EVENT_CLASS(...)
99 #define DEFINE_EVENT(evt_class, name, proto, ...) \
100 static inline void trace_ ## name(proto) {}
103 #define DEV_ENTRY __string(dev, dev_name(dev))
104 #define DEV_ASSIGN __assign_str(dev, dev_name(dev))
106 #include "iwl-devtrace-io.h"
107 #include "iwl-devtrace-ucode.h"
108 #include "iwl-devtrace-msg.h"
109 #include "iwl-devtrace-data.h"
110 #include "iwl-devtrace-iwlwifi.h"
112 #endif /* __IWLWIFI_DEVICE_TRACE */