Commit 1261fefa authored by Johannes Berg's avatar Johannes Berg

wifi: iwlwifi: refactor RX tracing

When there's not going to be any data in the data event, we
don't need to add it at all (unlike the TX version, it has
no data at all.)

Also combine the tracing into a separate inline so we only
call iwl_rx_trace_len() once, which also simplifies things,
and lets us have a single place to later add other checks.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarMiri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20231207044813.13325a4848d2.Ic9e7d794fc4aebfe5ac5136b539ee62789f210f3@changeidSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 637bbd5b
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved.
* Copyright(c) 2015 Intel Deutschland GmbH * Copyright(c) 2015 Intel Deutschland GmbH
* Copyright(c) 2018 - 2019 Intel Corporation * Copyright(c) 2018 - 2019, 2023 Intel Corporation
*****************************************************************************/ *****************************************************************************/
#if !defined(__IWLWIFI_DEVICE_TRACE_DATA) || defined(TRACE_HEADER_MULTI_READ) #if !defined(__IWLWIFI_DEVICE_TRACE_DATA) || defined(TRACE_HEADER_MULTI_READ)
...@@ -36,20 +36,17 @@ TRACE_EVENT(iwlwifi_dev_tx_tb, ...@@ -36,20 +36,17 @@ TRACE_EVENT(iwlwifi_dev_tx_tb,
TRACE_EVENT(iwlwifi_dev_rx_data, TRACE_EVENT(iwlwifi_dev_rx_data,
TP_PROTO(const struct device *dev, TP_PROTO(const struct device *dev,
const struct iwl_trans *trans, void *rxbuf, size_t len, size_t start),
void *rxbuf, size_t len), TP_ARGS(dev, rxbuf, len, start),
TP_ARGS(dev, trans, rxbuf, len),
TP_STRUCT__entry( TP_STRUCT__entry(
DEV_ENTRY DEV_ENTRY
__dynamic_array(u8, data, __dynamic_array(u8, data, len - start)
len - iwl_rx_trace_len(trans, rxbuf, len, NULL))
), ),
TP_fast_assign( TP_fast_assign(
size_t offs = iwl_rx_trace_len(trans, rxbuf, len, NULL);
DEV_ASSIGN; DEV_ASSIGN;
if (offs < len) if (start < len)
memcpy(__get_dynamic_array(data), memcpy(__get_dynamic_array(data),
((u8 *)rxbuf) + offs, len - offs); ((u8 *)rxbuf) + start, len - start);
), ),
TP_printk("[%s] RX frame data", __get_str(dev)) TP_printk("[%s] RX frame data", __get_str(dev))
); );
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved.
* Copyright(c) 2015 Intel Mobile Communications GmbH * Copyright(c) 2015 Intel Mobile Communications GmbH
* Copyright(c) 2016 - 2017 Intel Deutschland GmbH * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
* Copyright(c) 2018 Intel Corporation * Copyright(c) 2018, 2023 Intel Corporation
*****************************************************************************/ *****************************************************************************/
#if !defined(__IWLWIFI_DEVICE_TRACE_IWLWIFI) || defined(TRACE_HEADER_MULTI_READ) #if !defined(__IWLWIFI_DEVICE_TRACE_IWLWIFI) || defined(TRACE_HEADER_MULTI_READ)
...@@ -50,23 +50,20 @@ TRACE_EVENT(iwlwifi_dev_hcmd, ...@@ -50,23 +50,20 @@ TRACE_EVENT(iwlwifi_dev_hcmd,
); );
TRACE_EVENT(iwlwifi_dev_rx, TRACE_EVENT(iwlwifi_dev_rx,
TP_PROTO(const struct device *dev, const struct iwl_trans *trans, TP_PROTO(const struct device *dev,
struct iwl_rx_packet *pkt, size_t len), struct iwl_rx_packet *pkt, size_t len, size_t trace_len,
TP_ARGS(dev, trans, pkt, len), size_t hdr_offset),
TP_ARGS(dev, pkt, len, trace_len, hdr_offset),
TP_STRUCT__entry( TP_STRUCT__entry(
DEV_ENTRY DEV_ENTRY
__field(u16, cmd) __field(u16, cmd)
__field(u8, hdr_offset) __field(u8, hdr_offset)
__dynamic_array(u8, rxbuf, __dynamic_array(u8, rxbuf, trace_len)
iwl_rx_trace_len(trans, pkt, len, NULL))
), ),
TP_fast_assign( TP_fast_assign(
size_t hdr_offset = 0;
DEV_ASSIGN; DEV_ASSIGN;
__entry->cmd = WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd); __entry->cmd = WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd);
memcpy(__get_dynamic_array(rxbuf), pkt, memcpy(__get_dynamic_array(rxbuf), pkt, trace_len);
iwl_rx_trace_len(trans, pkt, len, &hdr_offset));
__entry->hdr_offset = hdr_offset; __entry->hdr_offset = hdr_offset;
), ),
TP_printk("[%s] RX cmd %#.2x", TP_printk("[%s] RX cmd %#.2x",
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/****************************************************************************** /******************************************************************************
* *
* Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved.
* Copyright (C) 2018 Intel Corporation * Copyright (C) 2018, 2023 Intel Corporation
*****************************************************************************/ *****************************************************************************/
#include <linux/module.h> #include <linux/module.h>
...@@ -20,4 +20,17 @@ ...@@ -20,4 +20,17 @@
EXPORT_TRACEPOINT_SYMBOL(iwlwifi_dev_ucode_event); EXPORT_TRACEPOINT_SYMBOL(iwlwifi_dev_ucode_event);
EXPORT_TRACEPOINT_SYMBOL(iwlwifi_dev_ucode_cont_event); EXPORT_TRACEPOINT_SYMBOL(iwlwifi_dev_ucode_cont_event);
EXPORT_TRACEPOINT_SYMBOL(iwlwifi_dev_ucode_wrap_event); EXPORT_TRACEPOINT_SYMBOL(iwlwifi_dev_ucode_wrap_event);
#endif #else
#include "iwl-devtrace.h"
#endif /* __CHECKER__ */
void __trace_iwlwifi_dev_rx(struct iwl_trans *trans, void *pkt, size_t len)
{
size_t hdr_offset = 0, trace_len;
trace_len = iwl_rx_trace_len(trans, pkt, len, &hdr_offset);
trace_iwlwifi_dev_rx(trans->dev, pkt, len, trace_len, hdr_offset);
if (trace_len < len)
trace_iwlwifi_dev_rx_data(trans->dev, pkt, len, trace_len);
}
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
*****************************************************************************/ *****************************************************************************/
#ifndef __IWLWIFI_DEVICE_TRACE #ifndef __IWLWIFI_DEVICE_TRACE
#define __IWLWIFI_DEVICE_TRACE
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/ieee80211.h> #include <linux/ieee80211.h>
#include <net/cfg80211.h> #include <net/cfg80211.h>
#include <net/mac80211.h> #include <net/mac80211.h>
#include "iwl-trans.h" #include "iwl-trans.h"
#if !defined(__IWLWIFI_DEVICE_TRACE)
static inline bool iwl_trace_data(struct sk_buff *skb) static inline bool iwl_trace_data(struct sk_buff *skb)
{ {
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
...@@ -70,9 +70,6 @@ static inline size_t iwl_rx_trace_len(const struct iwl_trans *trans, ...@@ -70,9 +70,6 @@ static inline size_t iwl_rx_trace_len(const struct iwl_trans *trans,
return sizeof(__le32) + sizeof(*cmd) + trans->rx_mpdu_cmd_hdr_size + return sizeof(__le32) + sizeof(*cmd) + trans->rx_mpdu_cmd_hdr_size +
ieee80211_hdrlen(hdr->frame_control); ieee80211_hdrlen(hdr->frame_control);
} }
#endif
#define __IWLWIFI_DEVICE_TRACE
#include <linux/tracepoint.h> #include <linux/tracepoint.h>
#include <linux/device.h> #include <linux/device.h>
...@@ -98,4 +95,20 @@ static inline void trace_ ## name(proto) {} ...@@ -98,4 +95,20 @@ static inline void trace_ ## name(proto) {}
#include "iwl-devtrace-data.h" #include "iwl-devtrace-data.h"
#include "iwl-devtrace-iwlwifi.h" #include "iwl-devtrace-iwlwifi.h"
#ifdef CONFIG_IWLWIFI_DEVICE_TRACING
DECLARE_TRACEPOINT(iwlwifi_dev_rx);
DECLARE_TRACEPOINT(iwlwifi_dev_rx_data);
#endif
void __trace_iwlwifi_dev_rx(struct iwl_trans *trans, void *pkt, size_t len);
static inline void maybe_trace_iwlwifi_dev_rx(struct iwl_trans *trans,
void *pkt, size_t len)
{
#ifdef CONFIG_IWLWIFI_DEVICE_TRACING
if (tracepoint_enabled(iwlwifi_dev_rx) ||
tracepoint_enabled(iwlwifi_dev_rx_data))
__trace_iwlwifi_dev_rx(trans, pkt, len);
#endif
}
#endif /* __IWLWIFI_DEVICE_TRACE */ #endif /* __IWLWIFI_DEVICE_TRACE */
...@@ -1351,8 +1351,7 @@ static void iwl_pcie_rx_handle_rb(struct iwl_trans *trans, ...@@ -1351,8 +1351,7 @@ static void iwl_pcie_rx_handle_rb(struct iwl_trans *trans,
if (len < sizeof(*pkt) || offset > max_len) if (len < sizeof(*pkt) || offset > max_len)
break; break;
trace_iwlwifi_dev_rx(trans->dev, trans, pkt, len); maybe_trace_iwlwifi_dev_rx(trans, pkt, len);
trace_iwlwifi_dev_rx_data(trans->dev, trans, pkt, len);
/* Reclaim a command buffer only if this packet is a response /* Reclaim a command buffer only if this packet is a response
* to a (driver-originated) command. * to a (driver-originated) command.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment