linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stanislaw Gruszka <sgruszka@redhat.com>
To: linux-wireless@vger.kernel.org
Cc: Helmut Schaa <helmut.schaa@googlemail.com>, Felix Fietkau <nbd@nbd.name>
Subject: [PATCH 08/10] rt2800: status based rate flags for nomatch case
Date: Tue, 14 Feb 2017 13:46:06 +0100	[thread overview]
Message-ID: <1487076368-7020-9-git-send-email-sgruszka@redhat.com> (raw)
In-Reply-To: <1487076368-7020-1-git-send-email-sgruszka@redhat.com>

We use skb_desc->tx_rate_flags from entry as rate[].flags even if
skb does not match status. Patch corrects flags and also fixes
mcs for legacy rates.

rt2800_rate_from_status() is based on Felix's mt76
mt76x2_mac_process_tx_rate() function.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
 drivers/net/wireless/ralink/rt2x00/rt2800.h    |  2 ++
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 35 +++++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800.h b/drivers/net/wireless/ralink/rt2x00/rt2800.h
index 0e7051d..480b086 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h
@@ -1760,6 +1760,8 @@
 #define TX_STA_FIFO_WCID		FIELD32(0x0000ff00)
 #define TX_STA_FIFO_SUCCESS_RATE	FIELD32(0xffff0000)
 #define TX_STA_FIFO_MCS			FIELD32(0x007f0000)
+#define TX_STA_FIFO_BW			FIELD32(0x00800000)
+#define TX_STA_FIFO_SGI			FIELD32(0x01000000)
 #define TX_STA_FIFO_PHYMODE		FIELD32(0xc0000000)
 
 /*
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index 8a76b27..b806ff1 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -852,6 +852,39 @@ void rt2800_process_rxwi(struct queue_entry *entry,
 }
 EXPORT_SYMBOL_GPL(rt2800_process_rxwi);
 
+static void rt2800_rate_from_status(struct skb_frame_desc *skbdesc,
+				    u32 status, enum nl80211_band band)
+{
+	u8 flags = 0;
+	u8 idx = rt2x00_get_field32(status, TX_STA_FIFO_MCS);
+
+	switch (rt2x00_get_field32(status, TX_STA_FIFO_PHYMODE)) {
+	case RATE_MODE_HT_GREENFIELD:
+		flags |= IEEE80211_TX_RC_GREEN_FIELD;
+		/* fall through */
+	case RATE_MODE_HT_MIX:
+		flags |= IEEE80211_TX_RC_MCS;
+		break;
+	case RATE_MODE_OFDM:
+		if (band == NL80211_BAND_2GHZ)
+			idx += 4;
+		break;
+	case RATE_MODE_CCK:
+		if (idx >= 8)
+			idx -= 8;
+		break;
+	}
+
+	if (rt2x00_get_field32(status, TX_STA_FIFO_BW))
+		flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
+
+	if (rt2x00_get_field32(status, TX_STA_FIFO_SGI))
+		flags |= IEEE80211_TX_RC_SHORT_GI;
+
+	skbdesc->tx_rate_idx = idx;
+	skbdesc->tx_rate_flags = flags;
+}
+
 void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi,
 			 bool match)
 {
@@ -898,7 +931,7 @@ void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi,
 	 * and provide retry count.
 	 */
 	if (unlikely((aggr == 1 && ampdu == 0 && real_mcs != mcs)) || !match) {
-		skbdesc->tx_rate_idx = real_mcs;
+		rt2800_rate_from_status(skbdesc, status, rt2x00dev->curr_band);
 		mcs = real_mcs;
 	}
 
-- 
1.8.3.1

  parent reply	other threads:[~2017-02-14 12:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-14 12:45 [PATCH 00/10] rt2x00 patches 14.02.2017 Stanislaw Gruszka
2017-02-14 12:45 ` [PATCH 01/10] rt2x00: rt2800lib: move rt2800_drv_data declaration into rt2800lib.h Stanislaw Gruszka
2017-02-14 12:46 ` [PATCH 02/10] rt2800: identify station based on status WCID Stanislaw Gruszka
2017-02-14 13:10   ` Felix Fietkau
2017-02-14 13:32     ` Stanislaw Gruszka
2017-02-14 13:46       ` Felix Fietkau
2017-02-14 12:46 ` [PATCH 03/10] rt2x00: separte filling tx status from rt2x00lib_txdone Stanislaw Gruszka
2017-02-14 12:46 ` [PATCH 04/10] rt2x00: separte clearing entry " Stanislaw Gruszka
2017-02-14 12:46 ` [PATCH 05/10] rt2x00: add txdone nomatch function Stanislaw Gruszka
2017-02-14 12:46 ` [PATCH 06/10] rt2x00: fixup fill_tx_status for nomatch case Stanislaw Gruszka
2017-02-14 13:51   ` Felix Fietkau
2017-02-14 16:32   ` Kalle Valo
2017-02-14 12:46 ` [PATCH 07/10] rt2x00: use txdone_nomatch on rt2800usb Stanislaw Gruszka
2017-02-14 12:46 ` Stanislaw Gruszka [this message]
2017-02-14 12:46 ` [PATCH 09/10] rt2800: use TXOP_BACKOFF for probe frames Stanislaw Gruszka
2017-02-14 12:46 ` [PATCH 10/10] rt2x00: fix rt2x00debug_dump_frame comment Stanislaw Gruszka

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=1487076368-7020-9-git-send-email-sgruszka@redhat.com \
    --to=sgruszka@redhat.com \
    --cc=helmut.schaa@googlemail.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=nbd@nbd.name \
    /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).