Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /******************************************************************************
0003  *
0004  * Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved.
0005  * Copyright(C) 2016        Intel Deutschland GmbH
0006  * Copyright(c) 2018        Intel Corporation
0007  *****************************************************************************/
0008 
0009 #ifndef __IWLWIFI_DEVICE_TRACE
0010 #include <linux/skbuff.h>
0011 #include <linux/ieee80211.h>
0012 #include <net/cfg80211.h>
0013 #include "iwl-trans.h"
0014 #if !defined(__IWLWIFI_DEVICE_TRACE)
0015 static inline bool iwl_trace_data(struct sk_buff *skb)
0016 {
0017     struct ieee80211_hdr *hdr = (void *)skb->data;
0018     __le16 fc = hdr->frame_control;
0019     int offs = 24; /* start with normal header length */
0020 
0021     if (!ieee80211_is_data(fc))
0022         return false;
0023 
0024     /* Try to determine if the frame is EAPOL. This might have false
0025      * positives (if there's no RFC 1042 header and we compare to some
0026      * payload instead) but since we're only doing tracing that's not
0027      * a problem.
0028      */
0029 
0030     if (ieee80211_has_a4(fc))
0031         offs += 6;
0032     if (ieee80211_is_data_qos(fc))
0033         offs += 2;
0034     /* don't account for crypto - these are unencrypted */
0035 
0036     /* also account for the RFC 1042 header, of course */
0037     offs += 6;
0038 
0039     return skb->len <= offs + 2 ||
0040         *(__be16 *)(skb->data + offs) != cpu_to_be16(ETH_P_PAE);
0041 }
0042 
0043 static inline size_t iwl_rx_trace_len(const struct iwl_trans *trans,
0044                       void *rxbuf, size_t len,
0045                       size_t *out_hdr_offset)
0046 {
0047     struct iwl_cmd_header *cmd = (void *)((u8 *)rxbuf + sizeof(__le32));
0048     struct ieee80211_hdr *hdr = NULL;
0049     size_t hdr_offset;
0050 
0051     if (cmd->cmd != trans->rx_mpdu_cmd)
0052         return len;
0053 
0054     hdr_offset = sizeof(struct iwl_cmd_header) +
0055              trans->rx_mpdu_cmd_hdr_size;
0056 
0057     if (out_hdr_offset)
0058         *out_hdr_offset = hdr_offset;
0059 
0060     hdr = (void *)((u8 *)cmd + hdr_offset);
0061     if (!ieee80211_is_data(hdr->frame_control))
0062         return len;
0063     /* maybe try to identify EAPOL frames? */
0064     return sizeof(__le32) + sizeof(*cmd) + trans->rx_mpdu_cmd_hdr_size +
0065         ieee80211_hdrlen(hdr->frame_control);
0066 }
0067 #endif
0068 
0069 #define __IWLWIFI_DEVICE_TRACE
0070 
0071 #include <linux/tracepoint.h>
0072 #include <linux/device.h>
0073 
0074 
0075 #if !defined(CONFIG_IWLWIFI_DEVICE_TRACING) || defined(__CHECKER__)
0076 #undef TRACE_EVENT
0077 #define TRACE_EVENT(name, proto, ...) \
0078 static inline void trace_ ## name(proto) {}
0079 #undef DECLARE_EVENT_CLASS
0080 #define DECLARE_EVENT_CLASS(...)
0081 #undef DEFINE_EVENT
0082 #define DEFINE_EVENT(evt_class, name, proto, ...) \
0083 static inline void trace_ ## name(proto) {}
0084 #endif
0085 
0086 #define DEV_ENTRY   __string(dev, dev_name(dev))
0087 #define DEV_ASSIGN  __assign_str(dev, dev_name(dev))
0088 
0089 #include "iwl-devtrace-io.h"
0090 #include "iwl-devtrace-ucode.h"
0091 #include "iwl-devtrace-msg.h"
0092 #include "iwl-devtrace-data.h"
0093 #include "iwl-devtrace-iwlwifi.h"
0094 
0095 #endif /* __IWLWIFI_DEVICE_TRACE */