linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: gregory.greenman@intel.com
To: kvalo@kernel.org, johannes@sipsolutions.net
Cc: linux-wireless@vger.kernel.org,
	Mordechay Goodstein <mordechay.goodstein@intel.com>,
	Gregory Greenman <gregory.greenman@intel.com>
Subject: [PATCH 08/12] wifi: iwlwifi: mvm: simplify by using SKB MAC header pointer
Date: Fri, 27 Jan 2023 00:28:17 +0200	[thread overview]
Message-ID: <20230127002430.3ec5493934a4.I1d41a2af28588b5899fcd2402f8c4bd8cc29a12e@changeid> (raw)
In-Reply-To: <20230126222821.305122-1-gregory.greenman@intel.com>

From: Mordechay Goodstein <mordechay.goodstein@intel.com>

Instead of calculating the offset to the 802.11 header based on radiotap
bits and length, shorten the code path by always setting the MAC header
in the skb and using skb_mac_header().

Signed-off-by: Mordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | 44 +++++++------------
 1 file changed, 16 insertions(+), 28 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
index 83e2be64b33f..4e7115ebede7 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
@@ -11,37 +11,11 @@
 #include "fw-api.h"
 #include "time-sync.h"
 
-static void *iwl_mvm_skb_get_hdr(struct sk_buff *skb)
-{
-	struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb);
-	u8 *data = skb->data;
-
-	/* Alignment concerns */
-	BUILD_BUG_ON(sizeof(struct ieee80211_radiotap_he) % 4);
-	BUILD_BUG_ON(sizeof(struct ieee80211_radiotap_he_mu) % 4);
-	BUILD_BUG_ON(sizeof(struct ieee80211_radiotap_lsig) % 4);
-	BUILD_BUG_ON(sizeof(struct ieee80211_vendor_radiotap) % 4);
-
-	if (rx_status->flag & RX_FLAG_RADIOTAP_HE)
-		data += sizeof(struct ieee80211_radiotap_he);
-	if (rx_status->flag & RX_FLAG_RADIOTAP_HE_MU)
-		data += sizeof(struct ieee80211_radiotap_he_mu);
-	if (rx_status->flag & RX_FLAG_RADIOTAP_LSIG)
-		data += sizeof(struct ieee80211_radiotap_lsig);
-	if (rx_status->flag & RX_FLAG_RADIOTAP_VENDOR_DATA) {
-		struct ieee80211_vendor_radiotap *radiotap = (void *)data;
-
-		data += sizeof(*radiotap) + radiotap->len + radiotap->pad;
-	}
-
-	return data;
-}
-
 static inline int iwl_mvm_check_pn(struct iwl_mvm *mvm, struct sk_buff *skb,
 				   int queue, struct ieee80211_sta *sta)
 {
 	struct iwl_mvm_sta *mvmsta;
-	struct ieee80211_hdr *hdr = iwl_mvm_skb_get_hdr(skb);
+	struct ieee80211_hdr *hdr = (void *)skb_mac_header(skb);
 	struct ieee80211_rx_status *stats = IEEE80211_SKB_RXCB(skb);
 	struct iwl_mvm_key_pn *ptk_pn;
 	int res;
@@ -180,6 +154,10 @@ static int iwl_mvm_create_skb(struct iwl_mvm *mvm, struct sk_buff *skb,
 	if (unlikely(headlen < hdrlen))
 		return -EINVAL;
 
+	/* Since data doesn't move data while putting data on skb and that is
+	 * the only way we use, data + len is the next place that hdr would be put
+	 */
+	skb_set_mac_header(skb, skb->len);
 	skb_put_data(skb, hdr, hdrlen);
 	skb_put_data(skb, (u8 *)hdr + hdrlen + pad_len, headlen - hdrlen);
 
@@ -937,7 +915,7 @@ static bool iwl_mvm_reorder(struct iwl_mvm *mvm,
 			    struct iwl_rx_mpdu_desc *desc)
 {
 	struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb);
-	struct ieee80211_hdr *hdr = iwl_mvm_skb_get_hdr(skb);
+	struct ieee80211_hdr *hdr = (void *)skb_mac_header(skb);
 	struct iwl_mvm_sta *mvm_sta;
 	struct iwl_mvm_baid_data *baid_data;
 	struct iwl_mvm_reorder_buffer *buffer;
@@ -2153,6 +2131,16 @@ void iwl_mvm_rx_monitor_no_data(struct iwl_mvm *mvm, struct napi_struct *napi,
 
 	iwl_mvm_rx_fill_status(mvm, skb, &phy_data, queue);
 
+	/* no more radio tap info should be put after this point.
+	 *
+	 * We mark it as mac header, for upper layers to know where
+	 * all radio tap header ends.
+	 *
+	 * Since data doesn't move data while putting data on skb and that is
+	 * the only way we use, data + len is the next place that hdr would be put
+	 */
+	skb_set_mac_header(skb, skb->len);
+
 	/*
 	 * Override the nss from the rx_vec since the rate_n_flags has
 	 * only 2 bits for the nss which gives a max of 4 ss but there
-- 
2.38.1


  parent reply	other threads:[~2023-01-26 22:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-26 22:28 [PATCH 00/12] iwlwifi: updates intended for v6.3 2023-01-27 gregory.greenman
2023-01-26 22:28 ` [PATCH 01/12] wifi: iwlwifi: mvm: report hardware timestamps in RX/TX status gregory.greenman
2023-01-26 22:28 ` [PATCH 02/12] wifi: iwlwifi: mention the response structure in the kerneldoc gregory.greenman
2023-01-26 22:28 ` [PATCH 03/12] wifi: iwlwifi: improve tag handling in iwl_request_firmware gregory.greenman
2023-01-26 22:28 ` [PATCH 04/12] wifi: iwlwifi: mvm: remove h from printk format specifier gregory.greenman
2023-01-26 22:28 ` [PATCH 05/12] wifi: iwlwifi: mvm: always send nullfunc frames on MGMT queue gregory.greenman
2023-01-26 22:28 ` [PATCH 06/12] wifi: iwlwifi: rx: add sniffer support for EHT mode gregory.greenman
2023-01-26 22:28 ` [PATCH 07/12] wifi: iwlwifi: mvm: add sniffer meta data APIs gregory.greenman
2023-01-26 22:28 ` gregory.greenman [this message]
2023-01-26 22:28 ` [PATCH 09/12] wifi: iwlwifi: mvm: Reset rate index if rate is wrong gregory.greenman
2023-01-26 22:28 ` [PATCH 10/12] wifi: iwlwifi: bump FW API to 74 for AX devices gregory.greenman
2023-01-26 22:28 ` [PATCH 11/12] wifi: iwlwifi: mvm: Support STEP equalizer settings from BIOS gregory.greenman
2023-01-26 22:28 ` [PATCH 12/12] wifi: iwlwifi: mei: fix compilation errors in rfkill() gregory.greenman
2023-01-29 16:47 ` [PATCH 00/12] iwlwifi: updates intended for v6.3 2023-01-27 Greenman, Gregory

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230127002430.3ec5493934a4.I1d41a2af28588b5899fcd2402f8c4bd8cc29a12e@changeid \
    --to=gregory.greenman@intel.com \
    --cc=johannes@sipsolutions.net \
    --cc=kvalo@kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=mordechay.goodstein@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).