Linux Audio

Check our new training course

Loading...
v6.8
  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, 2023  Intel Corporation
 
 
 
 
 
  7 *****************************************************************************/
  8
  9#ifndef __IWLWIFI_DEVICE_TRACE
 10#define __IWLWIFI_DEVICE_TRACE
 11#include <linux/skbuff.h>
 12#include <linux/ieee80211.h>
 13#include <net/cfg80211.h>
 14#include <net/mac80211.h>
 15#include "iwl-trans.h"
 
 16static inline bool iwl_trace_data(struct sk_buff *skb)
 17{
 18	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
 19	struct ieee80211_hdr *hdr = (void *)skb->data;
 20	__le16 fc = hdr->frame_control;
 21	int offs = 24; /* start with normal header length */
 22
 23	if (!ieee80211_is_data(fc))
 24		return false;
 25
 26	/* If upper layers wanted TX status it's an important frame */
 27	if (info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS)
 28		return false;
 29
 30	/* Try to determine if the frame is EAPOL. This might have false
 31	 * positives (if there's no RFC 1042 header and we compare to some
 32	 * payload instead) but since we're only doing tracing that's not
 33	 * a problem.
 34	 */
 35
 36	if (ieee80211_has_a4(fc))
 37		offs += 6;
 38	if (ieee80211_is_data_qos(fc))
 39		offs += 2;
 40	/* don't account for crypto - these are unencrypted */
 41
 42	/* also account for the RFC 1042 header, of course */
 43	offs += 6;
 44
 45	return skb->len <= offs + 2 ||
 46		*(__be16 *)(skb->data + offs) != cpu_to_be16(ETH_P_PAE);
 47}
 48
 49static inline size_t iwl_rx_trace_len(const struct iwl_trans *trans,
 50				      void *rxbuf, size_t len,
 51				      size_t *out_hdr_offset)
 52{
 53	struct iwl_cmd_header *cmd = (void *)((u8 *)rxbuf + sizeof(__le32));
 54	struct ieee80211_hdr *hdr = NULL;
 55	size_t hdr_offset;
 56
 57	if (cmd->cmd != trans->rx_mpdu_cmd)
 58		return len;
 59
 60	hdr_offset = sizeof(struct iwl_cmd_header) +
 61		     trans->rx_mpdu_cmd_hdr_size;
 62
 63	if (out_hdr_offset)
 64		*out_hdr_offset = hdr_offset;
 65
 66	hdr = (void *)((u8 *)cmd + hdr_offset);
 67	if (!ieee80211_is_data(hdr->frame_control))
 68		return len;
 69	/* maybe try to identify EAPOL frames? */
 70	return sizeof(__le32) + sizeof(*cmd) + trans->rx_mpdu_cmd_hdr_size +
 71		ieee80211_hdrlen(hdr->frame_control);
 72}
 
 
 
 73
 74#include <linux/tracepoint.h>
 75#include <linux/device.h>
 76
 77
 78#if !defined(CONFIG_IWLWIFI_DEVICE_TRACING) || defined(__CHECKER__)
 79#undef TRACE_EVENT
 80#define TRACE_EVENT(name, proto, ...) \
 81static inline void trace_ ## name(proto) {}
 82#undef DECLARE_EVENT_CLASS
 83#define DECLARE_EVENT_CLASS(...)
 84#undef DEFINE_EVENT
 85#define DEFINE_EVENT(evt_class, name, proto, ...) \
 86static inline void trace_ ## name(proto) {}
 87#endif
 88
 89#define DEV_ENTRY	__string(dev, dev_name(dev))
 90#define DEV_ASSIGN	__assign_str(dev, dev_name(dev))
 91
 92#include "iwl-devtrace-io.h"
 93#include "iwl-devtrace-ucode.h"
 94#include "iwl-devtrace-msg.h"
 95#include "iwl-devtrace-data.h"
 96#include "iwl-devtrace-iwlwifi.h"
 97
 98#ifdef CONFIG_IWLWIFI_DEVICE_TRACING
 99DECLARE_TRACEPOINT(iwlwifi_dev_rx);
100DECLARE_TRACEPOINT(iwlwifi_dev_rx_data);
101#endif
102
103void __trace_iwlwifi_dev_rx(struct iwl_trans *trans, void *pkt, size_t len);
104
105static inline void maybe_trace_iwlwifi_dev_rx(struct iwl_trans *trans,
106					      void *pkt, size_t len)
107{
108#ifdef CONFIG_IWLWIFI_DEVICE_TRACING
109	if (tracepoint_enabled(iwlwifi_dev_rx) ||
110	    tracepoint_enabled(iwlwifi_dev_rx_data))
111		__trace_iwlwifi_dev_rx(trans, pkt, len);
112#endif
113}
114#endif /* __IWLWIFI_DEVICE_TRACE */
v5.9
  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 * Contact Information:
  9 *  Intel Linux Wireless <linuxwifi@intel.com>
 10 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
 11 *
 12 *****************************************************************************/
 13
 14#ifndef __IWLWIFI_DEVICE_TRACE
 
 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;
 23	__le16 fc = hdr->frame_control;
 24	int offs = 24; /* start with normal header length */
 25
 26	if (!ieee80211_is_data(fc))
 27		return false;
 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
 44	return skb->len <= offs + 2 ||
 45		*(__be16 *)(skb->data + offs) != cpu_to_be16(ETH_P_PAE);
 46}
 47
 48static inline size_t iwl_rx_trace_len(const struct iwl_trans *trans,
 49				      void *rxbuf, size_t len,
 50				      size_t *out_hdr_offset)
 51{
 52	struct iwl_cmd_header *cmd = (void *)((u8 *)rxbuf + sizeof(__le32));
 53	struct ieee80211_hdr *hdr = NULL;
 54	size_t hdr_offset;
 55
 56	if (cmd->cmd != trans->rx_mpdu_cmd)
 57		return len;
 58
 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);
 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
 74#define __IWLWIFI_DEVICE_TRACE
 75
 76#include <linux/tracepoint.h>
 77#include <linux/device.h>
 78
 79
 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) {}
 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) {}
 89#endif
 90
 91#define DEV_ENTRY	__string(dev, dev_name(dev))
 92#define DEV_ASSIGN	__assign_str(dev, dev_name(dev))
 93
 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"
 99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100#endif /* __IWLWIFI_DEVICE_TRACE */