iwl-trans: move dev_cmd_offs, page_offs to a common trans header
[linux-block.git] / drivers / net / wireless / intel / iwlwifi / iwl-devtrace.h
CommitLineData
4273a380 1/* SPDX-License-Identifier: GPL-2.0-only */
bb5d2db5
RC
2/******************************************************************************
3 *
51368bf7 4 * Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved.
38bd7e58
MG
5 * Copyright(C) 2016 Intel Deutschland GmbH
6 * Copyright(c) 2018 Intel Corporation
bb5d2db5 7 *
bb5d2db5 8 * Contact Information:
cb2f8277 9 * Intel Linux Wireless <linuxwifi@intel.com>
bb5d2db5
RC
10 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
11 *
12 *****************************************************************************/
13
c5ef935d 14#ifndef __IWLWIFI_DEVICE_TRACE
f042c2eb
JB
15#include <linux/skbuff.h>
16#include <linux/ieee80211.h>
17#include <net/cfg80211.h>
18#include "iwl-trans.h"
19#if !defined(__IWLWIFI_DEVICE_TRACE)
20static inline bool iwl_trace_data(struct sk_buff *skb)
21{
22 struct ieee80211_hdr *hdr = (void *)skb->data;
0c4cb731
JB
23 __le16 fc = hdr->frame_control;
24 int offs = 24; /* start with normal header length */
f042c2eb 25
0c4cb731 26 if (!ieee80211_is_data(fc))
af61a165 27 return false;
0c4cb731
JB
28
29 /* Try to determine if the frame is EAPOL. This might have false
30 * positives (if there's no RFC 1042 header and we compare to some
31 * payload instead) but since we're only doing tracing that's not
32 * a problem.
33 */
34
35 if (ieee80211_has_a4(fc))
36 offs += 6;
37 if (ieee80211_is_data_qos(fc))
38 offs += 2;
39 /* don't account for crypto - these are unencrypted */
40
41 /* also account for the RFC 1042 header, of course */
42 offs += 6;
43
5462bcd8
EG
44 return skb->len <= offs + 2 ||
45 *(__be16 *)(skb->data + offs) != cpu_to_be16(ETH_P_PAE);
f042c2eb
JB
46}
47
48static inline size_t iwl_rx_trace_len(const struct iwl_trans *trans,
38bd7e58
MG
49 void *rxbuf, size_t len,
50 size_t *out_hdr_offset)
f042c2eb
JB
51{
52 struct iwl_cmd_header *cmd = (void *)((u8 *)rxbuf + sizeof(__le32));
38bd7e58
MG
53 struct ieee80211_hdr *hdr = NULL;
54 size_t hdr_offset;
f042c2eb
JB
55
56 if (cmd->cmd != trans->rx_mpdu_cmd)
57 return len;
58
38bd7e58
MG
59 hdr_offset = sizeof(struct iwl_cmd_header) +
60 trans->rx_mpdu_cmd_hdr_size;
61
62 if (out_hdr_offset)
63 *out_hdr_offset = hdr_offset;
64
65 hdr = (void *)((u8 *)cmd + hdr_offset);
f042c2eb
JB
66 if (!ieee80211_is_data(hdr->frame_control))
67 return len;
68 /* maybe try to identify EAPOL frames? */
69 return sizeof(__le32) + sizeof(*cmd) + trans->rx_mpdu_cmd_hdr_size +
70 ieee80211_hdrlen(hdr->frame_control);
71}
72#endif
73
be1a71a1
JB
74#define __IWLWIFI_DEVICE_TRACE
75
76#include <linux/tracepoint.h>
1023fdc4 77#include <linux/device.h>
be1a71a1 78
83ed9015 79
be1a71a1
JB
80#if !defined(CONFIG_IWLWIFI_DEVICE_TRACING) || defined(__CHECKER__)
81#undef TRACE_EVENT
82#define TRACE_EVENT(name, proto, ...) \
83static inline void trace_ ## name(proto) {}
2655e314
JB
84#undef DECLARE_EVENT_CLASS
85#define DECLARE_EVENT_CLASS(...)
86#undef DEFINE_EVENT
87#define DEFINE_EVENT(evt_class, name, proto, ...) \
88static inline void trace_ ## name(proto) {}
be1a71a1
JB
89#endif
90
6c1011e1
JB
91#define DEV_ENTRY __string(dev, dev_name(dev))
92#define DEV_ASSIGN __assign_str(dev, dev_name(dev))
be1a71a1 93
c5ef935d
SRRH
94#include "iwl-devtrace-io.h"
95#include "iwl-devtrace-ucode.h"
96#include "iwl-devtrace-msg.h"
97#include "iwl-devtrace-data.h"
98#include "iwl-devtrace-iwlwifi.h"
be1a71a1 99
be1a71a1 100#endif /* __IWLWIFI_DEVICE_TRACE */