Commit 38bd7e58 authored by Mordechay Goodstein's avatar Mordechay Goodstein Committed by Luca Coelho

iwlwifi: add 80211 hdr offset to trace data

Every rx mpdu cmd is built from cmd_hdr | 80211_hdr.  The problem is
that the size of cmd_hdr changes with API changes and we don't know
where the 80211_hdr starts.

By adding the size of cmd_hdr dynamically, we can ensure that we always
know how to parse mpdu frames, without dependending on the API changes.
Signed-off-by: default avatarMordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
parent b6fe2757
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,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 Intel Corporation
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as * under the terms of version 2 of the GNU General Public License as
...@@ -12,10 +13,6 @@ ...@@ -12,10 +13,6 @@
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* The full GNU General Public License is included in this distribution in the * The full GNU General Public License is included in this distribution in the
* file called LICENSE. * file called LICENSE.
* *
...@@ -76,12 +73,11 @@ TRACE_EVENT(iwlwifi_dev_rx_data, ...@@ -76,12 +73,11 @@ TRACE_EVENT(iwlwifi_dev_rx_data,
TP_ARGS(dev, trans, rxbuf, len), 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 - iwl_rx_trace_len(trans, rxbuf, len)) 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); size_t offs = iwl_rx_trace_len(trans, rxbuf, len, NULL);
DEV_ASSIGN; DEV_ASSIGN;
if (offs < len) if (offs < len)
memcpy(__get_dynamic_array(data), memcpy(__get_dynamic_array(data),
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,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
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as * under the terms of version 2 of the GNU General Public License as
...@@ -13,10 +14,6 @@ ...@@ -13,10 +14,6 @@
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* The full GNU General Public License is included in this distribution in the * The full GNU General Public License is included in this distribution in the
* file called LICENSE. * file called LICENSE.
* *
...@@ -75,13 +72,18 @@ TRACE_EVENT(iwlwifi_dev_rx, ...@@ -75,13 +72,18 @@ TRACE_EVENT(iwlwifi_dev_rx,
TP_STRUCT__entry( TP_STRUCT__entry(
DEV_ENTRY DEV_ENTRY
__field(u16, cmd) __field(u16, cmd)
__dynamic_array(u8, rxbuf, iwl_rx_trace_len(trans, pkt, len)) __field(u8, hdr_offset)
__dynamic_array(u8, rxbuf,
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,
iwl_rx_trace_len(trans, pkt, len)); iwl_rx_trace_len(trans, pkt, len, &hdr_offset));
__entry->hdr_offset = hdr_offset;
), ),
TP_printk("[%s] RX cmd %#.2x", TP_printk("[%s] RX cmd %#.2x",
__get_str(dev), __entry->cmd) __get_str(dev), __entry->cmd)
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* *
* Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved.
* Copyright(C) 2016 Intel Deutschland GmbH * Copyright(C) 2016 Intel Deutschland GmbH
* Copyright(c) 2018 Intel Corporation
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as * under the terms of version 2 of the GNU General Public License as
...@@ -12,10 +13,6 @@ ...@@ -12,10 +13,6 @@
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* The full GNU General Public License is included in this distribution in the * The full GNU General Public License is included in this distribution in the
* file called LICENSE. * file called LICENSE.
* *
...@@ -60,16 +57,23 @@ static inline bool iwl_trace_data(struct sk_buff *skb) ...@@ -60,16 +57,23 @@ static inline bool iwl_trace_data(struct sk_buff *skb)
} }
static inline size_t iwl_rx_trace_len(const struct iwl_trans *trans, static inline size_t iwl_rx_trace_len(const struct iwl_trans *trans,
void *rxbuf, size_t len) void *rxbuf, size_t len,
size_t *out_hdr_offset)
{ {
struct iwl_cmd_header *cmd = (void *)((u8 *)rxbuf + sizeof(__le32)); struct iwl_cmd_header *cmd = (void *)((u8 *)rxbuf + sizeof(__le32));
struct ieee80211_hdr *hdr; struct ieee80211_hdr *hdr = NULL;
size_t hdr_offset;
if (cmd->cmd != trans->rx_mpdu_cmd) if (cmd->cmd != trans->rx_mpdu_cmd)
return len; return len;
hdr = (void *)((u8 *)cmd + sizeof(struct iwl_cmd_header) + hdr_offset = sizeof(struct iwl_cmd_header) +
trans->rx_mpdu_cmd_hdr_size); trans->rx_mpdu_cmd_hdr_size;
if (out_hdr_offset)
*out_hdr_offset = hdr_offset;
hdr = (void *)((u8 *)cmd + hdr_offset);
if (!ieee80211_is_data(hdr->frame_control)) if (!ieee80211_is_data(hdr->frame_control))
return len; return len;
/* maybe try to identify EAPOL frames? */ /* maybe try to identify EAPOL frames? */
......
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