blob: f5c1127253cb13fcccde047ba2d210b9f41fb556 [file] [log] [blame]
Reinette Chatrebb5d2db2010-01-15 13:42:59 -08001/******************************************************************************
2 *
Emmanuel Grumbach51368bf2013-12-30 13:15:54 +02003 * Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved.
Johannes Berg0c4cb732016-06-21 12:44:21 +02004 * Copyright(C) 2016 Intel Deutschland GmbH
Reinette Chatrebb5d2db2010-01-15 13:42:59 -08005 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of version 2 of the GNU General Public License as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 *
19 * The full GNU General Public License is included in this distribution in the
20 * file called LICENSE.
21 *
22 * Contact Information:
Emmanuel Grumbachcb2f8272015-11-17 15:39:56 +020023 * Intel Linux Wireless <linuxwifi@intel.com>
Reinette Chatrebb5d2db2010-01-15 13:42:59 -080024 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 *
26 *****************************************************************************/
27
Steven Rostedt (Red Hat)c5ef9352015-04-07 11:25:14 -040028#ifndef __IWLWIFI_DEVICE_TRACE
Johannes Bergf042c2e2012-09-05 22:34:44 +020029#include <linux/skbuff.h>
30#include <linux/ieee80211.h>
31#include <net/cfg80211.h>
32#include "iwl-trans.h"
33#if !defined(__IWLWIFI_DEVICE_TRACE)
34static inline bool iwl_trace_data(struct sk_buff *skb)
35{
36 struct ieee80211_hdr *hdr = (void *)skb->data;
Johannes Berg0c4cb732016-06-21 12:44:21 +020037 __le16 fc = hdr->frame_control;
38 int offs = 24; /* start with normal header length */
Johannes Bergf042c2e2012-09-05 22:34:44 +020039
Johannes Berg0c4cb732016-06-21 12:44:21 +020040 if (!ieee80211_is_data(fc))
Johannes Bergaf61a162013-07-02 18:09:12 +020041 return false;
Johannes Berg0c4cb732016-06-21 12:44:21 +020042
43 /* Try to determine if the frame is EAPOL. This might have false
44 * positives (if there's no RFC 1042 header and we compare to some
45 * payload instead) but since we're only doing tracing that's not
46 * a problem.
47 */
48
49 if (ieee80211_has_a4(fc))
50 offs += 6;
51 if (ieee80211_is_data_qos(fc))
52 offs += 2;
53 /* don't account for crypto - these are unencrypted */
54
55 /* also account for the RFC 1042 header, of course */
56 offs += 6;
57
Emmanuel Grumbach5462bcd2017-06-14 12:21:05 +030058 return skb->len <= offs + 2 ||
59 *(__be16 *)(skb->data + offs) != cpu_to_be16(ETH_P_PAE);
Johannes Bergf042c2e2012-09-05 22:34:44 +020060}
61
62static inline size_t iwl_rx_trace_len(const struct iwl_trans *trans,
63 void *rxbuf, size_t len)
64{
65 struct iwl_cmd_header *cmd = (void *)((u8 *)rxbuf + sizeof(__le32));
66 struct ieee80211_hdr *hdr;
67
68 if (cmd->cmd != trans->rx_mpdu_cmd)
69 return len;
70
71 hdr = (void *)((u8 *)cmd + sizeof(struct iwl_cmd_header) +
72 trans->rx_mpdu_cmd_hdr_size);
73 if (!ieee80211_is_data(hdr->frame_control))
74 return len;
75 /* maybe try to identify EAPOL frames? */
76 return sizeof(__le32) + sizeof(*cmd) + trans->rx_mpdu_cmd_hdr_size +
77 ieee80211_hdrlen(hdr->frame_control);
78}
79#endif
80
Johannes Bergbe1a71a2009-10-02 13:44:02 -070081#define __IWLWIFI_DEVICE_TRACE
82
83#include <linux/tracepoint.h>
Johannes Berg1023fdc2012-05-15 12:16:34 +020084#include <linux/device.h>
Johannes Berg45eab7c2012-09-05 00:33:53 +020085#include "iwl-trans.h"
Johannes Bergbe1a71a2009-10-02 13:44:02 -070086
Emmanuel Grumbach83ed9012011-08-25 23:11:14 -070087
Johannes Bergbe1a71a2009-10-02 13:44:02 -070088#if !defined(CONFIG_IWLWIFI_DEVICE_TRACING) || defined(__CHECKER__)
89#undef TRACE_EVENT
90#define TRACE_EVENT(name, proto, ...) \
91static inline void trace_ ## name(proto) {}
Johannes Berg2655e312012-01-31 21:08:37 -080092#undef DECLARE_EVENT_CLASS
93#define DECLARE_EVENT_CLASS(...)
94#undef DEFINE_EVENT
95#define DEFINE_EVENT(evt_class, name, proto, ...) \
96static inline void trace_ ## name(proto) {}
Johannes Bergbe1a71a2009-10-02 13:44:02 -070097#endif
98
Johannes Berg6c1011e2012-03-06 13:30:48 -080099#define DEV_ENTRY __string(dev, dev_name(dev))
100#define DEV_ASSIGN __assign_str(dev, dev_name(dev))
Johannes Bergbe1a71a2009-10-02 13:44:02 -0700101
Steven Rostedt (Red Hat)c5ef9352015-04-07 11:25:14 -0400102#include "iwl-devtrace-io.h"
103#include "iwl-devtrace-ucode.h"
104#include "iwl-devtrace-msg.h"
105#include "iwl-devtrace-data.h"
106#include "iwl-devtrace-iwlwifi.h"
Johannes Bergbe1a71a2009-10-02 13:44:02 -0700107
Johannes Bergbe1a71a2009-10-02 13:44:02 -0700108#endif /* __IWLWIFI_DEVICE_TRACE */