linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ryder Lee <ryder.lee@mediatek.com>
To: Felix Fietkau <nbd@nbd.name>,
	Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Cc: Shayne Chen <shayne.chen@mediatek.com>,
	YF Luo <yf.luo@mediatek.com>,
	Yiwei Chung <yiwei.chung@mediatek.com>,
	Chih-Min Chen <chih-min.chen@mediatek.com>,
	Evelyn Tsai <evelyn.tsai@mediatek.com>,
	Sean Wang <sean.wang@mediatek.com>,
	<linux-wireless@vger.kernel.org>,
	<linux-mediatek@lists.infradead.org>,
	Ryder Lee <ryder.lee@mediatek.com>
Subject: [PATCH 03/16] mt76: add Rx stats support for radiotap
Date: Fri, 10 Apr 2020 16:54:40 +0800	[thread overview]
Message-ID: <03f4b34864472f86aa5608fe08b4ca493e436140.1586507878.git.ryder.lee@mediatek.com> (raw)
In-Reply-To: <cover.1586507878.git.ryder.lee@mediatek.com>

HE deivces need to add Rx radiotap header.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
---
 drivers/net/wireless/mediatek/mt76/agg-rx.c   |  4 ++--
 drivers/net/wireless/mediatek/mt76/mac80211.c |  6 +++---
 drivers/net/wireless/mediatek/mt76/mt76.h     | 19 +++++++++++++++++++
 3 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/agg-rx.c b/drivers/net/wireless/mediatek/mt76/agg-rx.c
index acdbe6f8248d..df25c00d9e06 100644
--- a/drivers/net/wireless/mediatek/mt76/agg-rx.c
+++ b/drivers/net/wireless/mediatek/mt76/agg-rx.c
@@ -119,7 +119,7 @@ static void
 mt76_rx_aggr_check_ctl(struct sk_buff *skb, struct sk_buff_head *frames)
 {
 	struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
-	struct ieee80211_bar *bar = (struct ieee80211_bar *)skb->data;
+	struct ieee80211_bar *bar = mt76_skb_get_hdr(skb);
 	struct mt76_wcid *wcid = status->wcid;
 	struct mt76_rx_tid *tid;
 	u16 seqno;
@@ -147,7 +147,7 @@ mt76_rx_aggr_check_ctl(struct sk_buff *skb, struct sk_buff_head *frames)
 void mt76_rx_aggr_reorder(struct sk_buff *skb, struct sk_buff_head *frames)
 {
 	struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
-	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+	struct ieee80211_hdr *hdr = mt76_skb_get_hdr(skb);
 	struct mt76_wcid *wcid = status->wcid;
 	struct ieee80211_sta *sta;
 	struct mt76_rx_tid *tid;
diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
index 5e795e849990..b76dee2c9632 100644
--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
+++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
@@ -727,7 +727,7 @@ mt76_check_ccmp_pn(struct sk_buff *skb)
 		 * Validate the first fragment both here and in mac80211
 		 * All further fragments will be validated by mac80211 only.
 		 */
-		hdr = (struct ieee80211_hdr *)skb->data;
+		hdr = mt76_skb_get_hdr(skb);
 		if (ieee80211_is_frag(hdr) &&
 		    !ieee80211_is_first_frag(hdr->frame_control))
 			return 0;
@@ -800,7 +800,7 @@ mt76_airtime_flush_ampdu(struct mt76_dev *dev)
 static void
 mt76_airtime_check(struct mt76_dev *dev, struct sk_buff *skb)
 {
-	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+	struct ieee80211_hdr *hdr = mt76_skb_get_hdr(skb);
 	struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
 	struct mt76_wcid *wcid = status->wcid;
 
@@ -837,7 +837,7 @@ static void
 mt76_check_sta(struct mt76_dev *dev, struct sk_buff *skb)
 {
 	struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
-	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+	struct ieee80211_hdr *hdr = mt76_skb_get_hdr(skb);
 	struct ieee80211_sta *sta;
 	struct ieee80211_hw *hw;
 	struct mt76_wcid *wcid = status->wcid;
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index 4f99804ff902..8d27af61b62e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -742,6 +742,25 @@ static inline struct mt76_tx_cb *mt76_tx_skb_cb(struct sk_buff *skb)
 	return ((void *)IEEE80211_SKB_CB(skb)->status.status_driver_data);
 }
 
+static inline void *mt76_skb_get_hdr(struct sk_buff *skb)
+{
+	struct mt76_rx_status mstat;
+	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);
+
+	mstat = *((struct mt76_rx_status *)skb->cb);
+
+	if (mstat.flag & RX_FLAG_RADIOTAP_HE)
+		data += sizeof(struct ieee80211_radiotap_he);
+	if (mstat.flag & RX_FLAG_RADIOTAP_HE_MU)
+		data += sizeof(struct ieee80211_radiotap_he_mu);
+
+	return data;
+}
+
 static inline void mt76_insert_hdr_pad(struct sk_buff *skb)
 {
 	int len = ieee80211_get_hdrlen_from_skb(skb);
-- 
2.18.0

  parent reply	other threads:[~2020-04-10  8:55 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-10  8:54 [PATCH 00/16] Add MediaTek IEEE 802.11ax devices - MT7915E Ryder Lee
2020-04-10  8:54 ` [PATCH 01/16] mt76: avoid rx reorder buffer overflow Ryder Lee
2020-04-10  8:54 ` [PATCH 02/16] mt76: add support for HE RX rate reporting Ryder Lee
2020-04-10  8:54 ` Ryder Lee [this message]
2020-04-10  8:54 ` [PATCH 04/16] mt76: adjust wcid size to support new 802.11ax generation Ryder Lee
2020-04-10  8:54 ` [PATCH 05/16] mt76: add HE phy modes and hardware queue Ryder Lee
2020-04-10  8:54 ` [PATCH 06/16] mt76: add mac80211 driver for MT7915 PCIe-based chipsets Ryder Lee
2020-04-14  6:37   ` Kalle Valo
2020-04-14  9:05     ` Ryder Lee
2020-04-10  8:54 ` [PATCH 07/16] mt76: mt7915: implement HE per-rate tx power support Ryder Lee
2020-04-10  8:54 ` [PATCH 08/16] mt76: mt7915: add offloading Tx AMSDU support Ryder Lee
2020-04-14  6:44   ` Kalle Valo
2020-04-14  9:59     ` Ryder Lee
2020-04-14 10:05       ` Kalle Valo
2020-04-10  8:54 ` [PATCH 09/16] mt76: mt7915: register HE capabilities for each interface Ryder Lee
2020-04-10  8:54 ` [PATCH 10/16] mt76: mt7915: add HE bss_conf support for interfaces Ryder Lee
2020-04-10  8:54 ` [PATCH 11/16] mt76: mt7915: add HE capabilities support for peers Ryder Lee
2020-04-10  8:54 ` [PATCH 12/16] mt76: mt7915: add Rx radiotap header support Ryder Lee
2020-04-10  8:54 ` [PATCH 13/16] mt76: mt7915: add .sta_add_debugfs support Ryder Lee
2020-04-10  8:54 ` [PATCH 14/16] mt76: mt7915: add .sta_statistics support Ryder Lee
2020-04-10  8:54 ` [PATCH 15/16] mt76: mt7915: set peer Tx fixed rate through debugfs Ryder Lee
2020-04-10  8:54 ` [PATCH 16/16] mt76: mt7915: enable firmware module debug support Ryder Lee

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=03f4b34864472f86aa5608fe08b4ca493e436140.1586507878.git.ryder.lee@mediatek.com \
    --to=ryder.lee@mediatek.com \
    --cc=chih-min.chen@mediatek.com \
    --cc=evelyn.tsai@mediatek.com \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=nbd@nbd.name \
    --cc=sean.wang@mediatek.com \
    --cc=shayne.chen@mediatek.com \
    --cc=yf.luo@mediatek.com \
    --cc=yiwei.chung@mediatek.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).