From: Bitterblue Smith <rtl8821cerfe2@gmail.com>
To: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Cc: Jes Sorensen <Jes.Sorensen@gmail.com>, Ping-Ke Shih <pkshih@realtek.com>
Subject: [PATCH] wifi: rtl8xxxu: Fix gen1 rate mask command
Date: Tue, 16 Apr 2024 00:10:11 +0300 [thread overview]
Message-ID: <3068a7f8-0178-4ea7-bd18-4e377db07e76@gmail.com> (raw)
The H2C (host to card) command which tells the firmware which TX rates
it can use is slightly wrong. Fix the order of the bytes.
Also put the macid in the command (relevant for AP mode).
This was tested with RTL8192CU. It also affects the RTL8723AU.
Cc: stable@vger.kernel.org
Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
---
.../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 10 +++++++---
.../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 18 +++++++++++-------
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
index fd92d23c43d9..ca44d82cb5aa 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
@@ -1430,10 +1430,14 @@ struct h2c_cmd {
u8 data;
} __packed joinbss;
struct {
+#define RAID_MASK GENMASK(31, 28)
+#define RATE_MASK_MASK GENMASK(27, 0)
+#define MACID_MASK GENMASK(4, 0)
+#define SHORT_GI_MASK BIT(5)
+
u8 cmd;
- __le16 mask_hi;
- u8 arg;
- __le16 mask_lo;
+ __le32 rate_mask_and_raid;
+ u8 macid_and_short_gi;
} __packed ramask;
struct {
u8 cmd;
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index fac7824ae727..acbafc25c6e0 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -4641,15 +4641,19 @@ void rtl8xxxu_update_rate_mask(struct rtl8xxxu_priv *priv,
memset(&h2c, 0, sizeof(struct h2c_cmd));
h2c.ramask.cmd = H2C_SET_RATE_MASK;
- h2c.ramask.mask_lo = cpu_to_le16(ramask & 0xffff);
- h2c.ramask.mask_hi = cpu_to_le16(ramask >> 16);
- h2c.ramask.arg = 0x80;
- if (sgi)
- h2c.ramask.arg |= 0x20;
+ le32p_replace_bits(&h2c.ramask.rate_mask_and_raid, rateid, RAID_MASK);
+ le32p_replace_bits(&h2c.ramask.rate_mask_and_raid, ramask, RATE_MASK_MASK);
+
+ u8p_replace_bits(&h2c.ramask.macid_and_short_gi, macid, MACID_MASK);
+ u8p_replace_bits(&h2c.ramask.macid_and_short_gi, sgi, SHORT_GI_MASK);
+ u8p_replace_bits(&h2c.ramask.macid_and_short_gi, 1, BIT(7));
+
+ dev_dbg(&priv->udev->dev,
+ "%s: rate mask %08x, rate id %02x, arg %02x, size %zi\n",
+ __func__, ramask, rateid, h2c.ramask.macid_and_short_gi,
+ sizeof(h2c.ramask));
- dev_dbg(&priv->udev->dev, "%s: rate mask %08x, arg %02x, size %zi\n",
- __func__, ramask, h2c.ramask.arg, sizeof(h2c.ramask));
rtl8xxxu_gen1_h2c_cmd(priv, &h2c, sizeof(h2c.ramask));
}
--
2.44.0
next reply other threads:[~2024-04-15 21:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-15 21:10 Bitterblue Smith [this message]
2024-04-16 4:01 ` [PATCH] wifi: rtl8xxxu: Fix gen1 rate mask command Ping-Ke Shih
2024-04-16 11:58 ` Bitterblue Smith
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=3068a7f8-0178-4ea7-bd18-4e377db07e76@gmail.com \
--to=rtl8821cerfe2@gmail.com \
--cc=Jes.Sorensen@gmail.com \
--cc=linux-wireless@vger.kernel.org \
--cc=pkshih@realtek.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