Loading...
1/******************************************************************************
2 *
3 * Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17 *
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
20 *
21 * Contact Information:
22 * Intel Linux Wireless <linuxwifi@intel.com>
23 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24 *
25 *****************************************************************************/
26
27#ifndef __IWLWIFI_DEVICE_TRACE
28#include <linux/skbuff.h>
29#include <linux/ieee80211.h>
30#include <net/cfg80211.h>
31#include "iwl-trans.h"
32#if !defined(__IWLWIFI_DEVICE_TRACE)
33static inline bool iwl_trace_data(struct sk_buff *skb)
34{
35 struct ieee80211_hdr *hdr = (void *)skb->data;
36 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
37
38 if (!ieee80211_is_data(hdr->frame_control))
39 return false;
40 return !(info->control.flags & IEEE80211_TX_CTRL_PORT_CTRL_PROTO);
41}
42
43static inline size_t iwl_rx_trace_len(const struct iwl_trans *trans,
44 void *rxbuf, size_t len)
45{
46 struct iwl_cmd_header *cmd = (void *)((u8 *)rxbuf + sizeof(__le32));
47 struct ieee80211_hdr *hdr;
48
49 if (cmd->cmd != trans->rx_mpdu_cmd)
50 return len;
51
52 hdr = (void *)((u8 *)cmd + sizeof(struct iwl_cmd_header) +
53 trans->rx_mpdu_cmd_hdr_size);
54 if (!ieee80211_is_data(hdr->frame_control))
55 return len;
56 /* maybe try to identify EAPOL frames? */
57 return sizeof(__le32) + sizeof(*cmd) + trans->rx_mpdu_cmd_hdr_size +
58 ieee80211_hdrlen(hdr->frame_control);
59}
60#endif
61
62#define __IWLWIFI_DEVICE_TRACE
63
64#include <linux/tracepoint.h>
65#include <linux/device.h>
66#include "iwl-trans.h"
67
68
69#if !defined(CONFIG_IWLWIFI_DEVICE_TRACING) || defined(__CHECKER__)
70#undef TRACE_EVENT
71#define TRACE_EVENT(name, proto, ...) \
72static inline void trace_ ## name(proto) {}
73#undef DECLARE_EVENT_CLASS
74#define DECLARE_EVENT_CLASS(...)
75#undef DEFINE_EVENT
76#define DEFINE_EVENT(evt_class, name, proto, ...) \
77static inline void trace_ ## name(proto) {}
78#endif
79
80#define DEV_ENTRY __string(dev, dev_name(dev))
81#define DEV_ASSIGN __assign_str(dev, dev_name(dev))
82
83#include "iwl-devtrace-io.h"
84#include "iwl-devtrace-ucode.h"
85#include "iwl-devtrace-msg.h"
86#include "iwl-devtrace-data.h"
87#include "iwl-devtrace-iwlwifi.h"
88
89#endif /* __IWLWIFI_DEVICE_TRACE */
1/* SPDX-License-Identifier: GPL-2.0-only */
2/******************************************************************************
3 *
4 * Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved.
5 * Copyright(C) 2016 Intel Deutschland GmbH
6 * Copyright(c) 2018 Intel Corporation
7 *****************************************************************************/
8
9#ifndef __IWLWIFI_DEVICE_TRACE
10#include <linux/skbuff.h>
11#include <linux/ieee80211.h>
12#include <net/cfg80211.h>
13#include "iwl-trans.h"
14#if !defined(__IWLWIFI_DEVICE_TRACE)
15static inline bool iwl_trace_data(struct sk_buff *skb)
16{
17 struct ieee80211_hdr *hdr = (void *)skb->data;
18 __le16 fc = hdr->frame_control;
19 int offs = 24; /* start with normal header length */
20
21 if (!ieee80211_is_data(fc))
22 return false;
23
24 /* Try to determine if the frame is EAPOL. This might have false
25 * positives (if there's no RFC 1042 header and we compare to some
26 * payload instead) but since we're only doing tracing that's not
27 * a problem.
28 */
29
30 if (ieee80211_has_a4(fc))
31 offs += 6;
32 if (ieee80211_is_data_qos(fc))
33 offs += 2;
34 /* don't account for crypto - these are unencrypted */
35
36 /* also account for the RFC 1042 header, of course */
37 offs += 6;
38
39 return skb->len <= offs + 2 ||
40 *(__be16 *)(skb->data + offs) != cpu_to_be16(ETH_P_PAE);
41}
42
43static inline size_t iwl_rx_trace_len(const struct iwl_trans *trans,
44 void *rxbuf, size_t len,
45 size_t *out_hdr_offset)
46{
47 struct iwl_cmd_header *cmd = (void *)((u8 *)rxbuf + sizeof(__le32));
48 struct ieee80211_hdr *hdr = NULL;
49 size_t hdr_offset;
50
51 if (cmd->cmd != trans->rx_mpdu_cmd)
52 return len;
53
54 hdr_offset = sizeof(struct iwl_cmd_header) +
55 trans->rx_mpdu_cmd_hdr_size;
56
57 if (out_hdr_offset)
58 *out_hdr_offset = hdr_offset;
59
60 hdr = (void *)((u8 *)cmd + hdr_offset);
61 if (!ieee80211_is_data(hdr->frame_control))
62 return len;
63 /* maybe try to identify EAPOL frames? */
64 return sizeof(__le32) + sizeof(*cmd) + trans->rx_mpdu_cmd_hdr_size +
65 ieee80211_hdrlen(hdr->frame_control);
66}
67#endif
68
69#define __IWLWIFI_DEVICE_TRACE
70
71#include <linux/tracepoint.h>
72#include <linux/device.h>
73
74
75#if !defined(CONFIG_IWLWIFI_DEVICE_TRACING) || defined(__CHECKER__)
76#undef TRACE_EVENT
77#define TRACE_EVENT(name, proto, ...) \
78static inline void trace_ ## name(proto) {}
79#undef DECLARE_EVENT_CLASS
80#define DECLARE_EVENT_CLASS(...)
81#undef DEFINE_EVENT
82#define DEFINE_EVENT(evt_class, name, proto, ...) \
83static inline void trace_ ## name(proto) {}
84#endif
85
86#define DEV_ENTRY __string(dev, dev_name(dev))
87#define DEV_ASSIGN __assign_str(dev, dev_name(dev))
88
89#include "iwl-devtrace-io.h"
90#include "iwl-devtrace-ucode.h"
91#include "iwl-devtrace-msg.h"
92#include "iwl-devtrace-data.h"
93#include "iwl-devtrace-iwlwifi.h"
94
95#endif /* __IWLWIFI_DEVICE_TRACE */