All of lore.kernel.org
 help / color / mirror / Atom feed
From: greearb@candelatech.com
To: linux-wireless@vger.kernel.org
Cc: Ben Greear <greearb@candelatech.com>
Subject: [PATCH 04/11] mt76: mt7915: use nss for calculating rx-chains
Date: Thu, 18 Nov 2021 08:40:49 -0800	[thread overview]
Message-ID: <20211118164056.2965-4-greearb@candelatech.com> (raw)
In-Reply-To: <20211118164056.2965-1-greearb@candelatech.com>

From: Ben Greear <greearb@candelatech.com>

When group-5 is enabled, we can find the actuall NSS used.
In that case, update the rx chains info so that the upper
stack can give better idea of actual antenna usage.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
 .../net/wireless/mediatek/mt76/mt7915/mac.c   | 32 +++++++++++++------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
index a6bcc76dcb03..ddc85464b1e9 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
@@ -560,6 +560,7 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
 	/* RXD Group 3 - P-RXV */
 	if (rxd1 & MT_RXD1_NORMAL_GROUP_3) {
 		u32 v0, v1, v2;
+		u8 nss;
 
 		rxv = rxd; /* DW16 assuming group 1,2,3,4 */
 		rxd += 2;
@@ -577,21 +578,12 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
 		/* TODO:  When group-5 is enabled, use nss (and stbc) to
 		 * calculate chains properly for this particular skb.
 		 */
-		status->chains = mphy->antenna_mask;
 		status->chain_signal[0] = to_rssi(MT_PRXV_RCPI0, v1);
 		status->chain_signal[1] = to_rssi(MT_PRXV_RCPI1, v1);
 		status->chain_signal[2] = to_rssi(MT_PRXV_RCPI2, v1);
 		status->chain_signal[3] = to_rssi(MT_PRXV_RCPI3, v1);
-		status->signal = status->chain_signal[0];
 
-		for (i = 1; i < hweight8(mphy->antenna_mask); i++) {
-			if (!(status->chains & BIT(i)))
-				continue;
-
-			/* TODO:  Use db sum logic instead of max. */
-			status->signal = max(status->signal,
-					     status->chain_signal[i]);
-		}
+		nss = hweight8(mphy->antenna_mask);
 
 		/* RXD Group 5 - C-RXV.
 		 * Group 5 Not currently enabled for 7915 except in
@@ -604,6 +596,7 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
 			u8 gi = FIELD_GET(MT_CRXV_HT_SHORT_GI, v2);
 			bool cck = false;
 
+			nss = 1;
 			rxd += 18;
 			if ((u8 *)rxd - skb->data >= skb->len)
 				return -EINVAL;
@@ -623,6 +616,7 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
 				status->encoding = RX_ENC_HT;
 				if (i > 31)
 					return -EINVAL;
+				nss = i / 8 + 1;
 				break;
 			case MT_PHY_TYPE_VHT:
 				status->nss =
@@ -630,6 +624,7 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
 				status->encoding = RX_ENC_VHT;
 				if (i > 9)
 					return -EINVAL;
+				nss = status->nss;
 				break;
 			case MT_PHY_TYPE_HE_MU:
 				status->flag |= RX_FLAG_RADIOTAP_HE_MU;
@@ -639,6 +634,7 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
 			case MT_PHY_TYPE_HE_TB:
 				status->nss =
 					FIELD_GET(MT_PRXV_NSTS, v0) + 1;
+				nss = status->nss;
 				status->encoding = RX_ENC_HE;
 				status->flag |= RX_FLAG_RADIOTAP_HE;
 				i &= GENMASK(3, 0);
@@ -653,6 +649,11 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
 			}
 			status->rate_idx = i;
 
+			if (stbc) {
+				nss *= 2;
+				WARN_ON_ONCE(nss > 4);
+			}
+
 			switch (FIELD_GET(MT_CRXV_FRAME_MODE, v2)) {
 			case IEEE80211_STA_RX_BW_20:
 				break;
@@ -680,6 +681,17 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
 			if (mode < MT_PHY_TYPE_HE_SU && gi)
 				status->enc_flags |= RX_ENC_FLAG_SHORT_GI;
 		}
+
+		status->chains = 1;
+		status->signal = status->chain_signal[0];
+
+		for (i = 1; i < nss; i++) {
+			status->chains |= BIT(i);
+
+			/* TODO:  Use db sum logic instead of max. */
+			status->signal = max(status->signal,
+					     status->chain_signal[i]);
+		}
 	}
 
 	skb_pull(skb, (u8 *)rxd - skb->data + 2 * remove_pad);
-- 
2.20.1


  parent reply	other threads:[~2021-11-18 16:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-18 16:40 [PATCH 01/11] mt76: mt7915: add comments about rx descriptor parsing greearb
2021-11-18 16:40 ` [PATCH 02/11] mt76: mt7915: print out hw revision greearb
2021-11-18 16:59   ` Ryder Lee
2021-11-18 16:40 ` [PATCH 03/11] mt76: mt7915: support enabling rx group-5 status greearb
2022-01-04 10:39   ` Lorenzo Bianconi
2021-11-18 16:40 ` greearb [this message]
2021-12-03  9:16   ` [PATCH 04/11] mt76: mt7915: use nss for calculating rx-chains Felix Fietkau
2021-12-03 15:33     ` Ben Greear
2021-11-18 16:40 ` [PATCH 05/11] mt76: mt7915: ethtool group-5 rx stats information greearb
2022-01-04 10:58   ` Lorenzo Bianconi
2021-11-18 16:40 ` [PATCH 06/11] mt76: mt7915: ethtool counters for driver rx path greearb
2021-11-18 16:40 ` [PATCH 07/11] mt76: mt7915: fix rate rix and flags in txs path greearb
2022-01-04 11:15   ` Lorenzo Bianconi
2021-11-18 16:40 ` [PATCH 08/11] mt76: mt7915: add ethtool tx/rx pkts/bytes greearb
2021-11-18 16:40 ` [PATCH 09/11] mt76: mt7915: add rx-ppdu-size-out-of-range ethtool counter greearb
2021-11-18 16:40 ` [PATCH 10/11] mt76: mt7915: ethtool and mib rx stats greearb
2021-11-18 16:40 ` [PATCH 11/11] mt76: mt7915: poll mib counters every 200ms greearb
2021-11-18 17:01   ` Ryder Lee
2021-11-19 16:33 ` [PATCH 01/11] mt76: mt7915: add comments about rx descriptor parsing Lorenzo Bianconi
2021-11-19 16:41   ` Ben Greear

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=20211118164056.2965-4-greearb@candelatech.com \
    --to=greearb@candelatech.com \
    --cc=linux-wireless@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.