Reinette Chatre | bb5d2db | 2010-01-15 13:42:59 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
Emmanuel Grumbach | 51368bf | 2013-12-30 13:15:54 +0200 | [diff] [blame] | 3 | * Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved. |
Mordechay Goodstein | 38bd7e5 | 2018-04-10 18:19:49 +0300 | [diff] [blame] | 4 | * Copyright(C) 2016 Intel Deutschland GmbH |
| 5 | * Copyright(c) 2018 Intel Corporation |
Reinette Chatre | bb5d2db | 2010-01-15 13:42:59 -0800 | [diff] [blame] | 6 | * |
| 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. |
| 10 | * |
| 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 |
| 14 | * more details. |
| 15 | * |
Reinette Chatre | bb5d2db | 2010-01-15 13:42:59 -0800 | [diff] [blame] | 16 | * The full GNU General Public License is included in this distribution in the |
| 17 | * file called LICENSE. |
| 18 | * |
| 19 | * Contact Information: |
Emmanuel Grumbach | cb2f827 | 2015-11-17 15:39:56 +0200 | [diff] [blame] | 20 | * Intel Linux Wireless <linuxwifi@intel.com> |
Reinette Chatre | bb5d2db | 2010-01-15 13:42:59 -0800 | [diff] [blame] | 21 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 22 | * |
| 23 | *****************************************************************************/ |
| 24 | |
Steven Rostedt (Red Hat) | c5ef935 | 2015-04-07 11:25:14 -0400 | [diff] [blame] | 25 | #ifndef __IWLWIFI_DEVICE_TRACE |
Johannes Berg | f042c2e | 2012-09-05 22:34:44 +0200 | [diff] [blame] | 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) |
| 32 | { |
| 33 | struct ieee80211_hdr *hdr = (void *)skb->data; |
Johannes Berg | 0c4cb73 | 2016-06-21 12:44:21 +0200 | [diff] [blame] | 34 | __le16 fc = hdr->frame_control; |
| 35 | int offs = 24; /* start with normal header length */ |
Johannes Berg | f042c2e | 2012-09-05 22:34:44 +0200 | [diff] [blame] | 36 | |
Johannes Berg | 0c4cb73 | 2016-06-21 12:44:21 +0200 | [diff] [blame] | 37 | if (!ieee80211_is_data(fc)) |
Johannes Berg | af61a16 | 2013-07-02 18:09:12 +0200 | [diff] [blame] | 38 | return false; |
Johannes Berg | 0c4cb73 | 2016-06-21 12:44:21 +0200 | [diff] [blame] | 39 | |
| 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 |
| 43 | * a problem. |
| 44 | */ |
| 45 | |
| 46 | if (ieee80211_has_a4(fc)) |
| 47 | offs += 6; |
| 48 | if (ieee80211_is_data_qos(fc)) |
| 49 | offs += 2; |
| 50 | /* don't account for crypto - these are unencrypted */ |
| 51 | |
| 52 | /* also account for the RFC 1042 header, of course */ |
| 53 | offs += 6; |
| 54 | |
Emmanuel Grumbach | 5462bcd | 2017-06-14 12:21:05 +0300 | [diff] [blame] | 55 | return skb->len <= offs + 2 || |
| 56 | *(__be16 *)(skb->data + offs) != cpu_to_be16(ETH_P_PAE); |
Johannes Berg | f042c2e | 2012-09-05 22:34:44 +0200 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | static inline size_t iwl_rx_trace_len(const struct iwl_trans *trans, |
Mordechay Goodstein | 38bd7e5 | 2018-04-10 18:19:49 +0300 | [diff] [blame] | 60 | void *rxbuf, size_t len, |
| 61 | size_t *out_hdr_offset) |
Johannes Berg | f042c2e | 2012-09-05 22:34:44 +0200 | [diff] [blame] | 62 | { |
| 63 | struct iwl_cmd_header *cmd = (void *)((u8 *)rxbuf + sizeof(__le32)); |
Mordechay Goodstein | 38bd7e5 | 2018-04-10 18:19:49 +0300 | [diff] [blame] | 64 | struct ieee80211_hdr *hdr = NULL; |
| 65 | size_t hdr_offset; |
Johannes Berg | f042c2e | 2012-09-05 22:34:44 +0200 | [diff] [blame] | 66 | |
| 67 | if (cmd->cmd != trans->rx_mpdu_cmd) |
| 68 | return len; |
| 69 | |
Mordechay Goodstein | 38bd7e5 | 2018-04-10 18:19:49 +0300 | [diff] [blame] | 70 | hdr_offset = sizeof(struct iwl_cmd_header) + |
| 71 | trans->rx_mpdu_cmd_hdr_size; |
| 72 | |
| 73 | if (out_hdr_offset) |
| 74 | *out_hdr_offset = hdr_offset; |
| 75 | |
| 76 | hdr = (void *)((u8 *)cmd + hdr_offset); |
Johannes Berg | f042c2e | 2012-09-05 22:34:44 +0200 | [diff] [blame] | 77 | if (!ieee80211_is_data(hdr->frame_control)) |
| 78 | return len; |
| 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); |
| 82 | } |
| 83 | #endif |
| 84 | |
Johannes Berg | be1a71a | 2009-10-02 13:44:02 -0700 | [diff] [blame] | 85 | #define __IWLWIFI_DEVICE_TRACE |
| 86 | |
| 87 | #include <linux/tracepoint.h> |
Johannes Berg | 1023fdc | 2012-05-15 12:16:34 +0200 | [diff] [blame] | 88 | #include <linux/device.h> |
Johannes Berg | 45eab7c | 2012-09-05 00:33:53 +0200 | [diff] [blame] | 89 | #include "iwl-trans.h" |
Johannes Berg | be1a71a | 2009-10-02 13:44:02 -0700 | [diff] [blame] | 90 | |
Emmanuel Grumbach | 83ed901 | 2011-08-25 23:11:14 -0700 | [diff] [blame] | 91 | |
Johannes Berg | be1a71a | 2009-10-02 13:44:02 -0700 | [diff] [blame] | 92 | #if !defined(CONFIG_IWLWIFI_DEVICE_TRACING) || defined(__CHECKER__) |
| 93 | #undef TRACE_EVENT |
| 94 | #define TRACE_EVENT(name, proto, ...) \ |
| 95 | static inline void trace_ ## name(proto) {} |
Johannes Berg | 2655e31 | 2012-01-31 21:08:37 -0800 | [diff] [blame] | 96 | #undef DECLARE_EVENT_CLASS |
| 97 | #define DECLARE_EVENT_CLASS(...) |
| 98 | #undef DEFINE_EVENT |
| 99 | #define DEFINE_EVENT(evt_class, name, proto, ...) \ |
| 100 | static inline void trace_ ## name(proto) {} |
Johannes Berg | be1a71a | 2009-10-02 13:44:02 -0700 | [diff] [blame] | 101 | #endif |
| 102 | |
Johannes Berg | 6c1011e | 2012-03-06 13:30:48 -0800 | [diff] [blame] | 103 | #define DEV_ENTRY __string(dev, dev_name(dev)) |
| 104 | #define DEV_ASSIGN __assign_str(dev, dev_name(dev)) |
Johannes Berg | be1a71a | 2009-10-02 13:44:02 -0700 | [diff] [blame] | 105 | |
Steven Rostedt (Red Hat) | c5ef935 | 2015-04-07 11:25:14 -0400 | [diff] [blame] | 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" |
Johannes Berg | be1a71a | 2009-10-02 13:44:02 -0700 | [diff] [blame] | 111 | |
Johannes Berg | be1a71a | 2009-10-02 13:44:02 -0700 | [diff] [blame] | 112 | #endif /* __IWLWIFI_DEVICE_TRACE */ |