From: "Georg Müller" <georgmueller@gmx.net>
To: mehmet.fide@gmail.com, Jes.Sorensen@gmail.com
Cc: rtl8821cerfe2@gmail.com, pkshih@realtek.com, hi@shreyan.sh,
mehmet.fide@screeningeagle.com, linux-wireless@vger.kernel.org,
linux-kernel@vger.kernel.org,
"Georg Müller" <georgmueller@gmx.net>
Subject: [RFC PATCH v4 2/5] wifi: rtl8xxxu: handle rate control per mac_id for 8188e
Date: Thu, 26 Nov 2026 11:57:39 +0100 [thread overview]
Message-ID: <20261126105742.1086282-3-georgmueller@gmx.net> (raw)
In-Reply-To: <20261126054350.2893087-1-mehmet.fide@gmail.com>
Convert member ra_info to an array with one entry per mac id. This
allows having different rate control settings per connected station
in AP mode.
The max_macid_num is conservative. The old driver used 32 [1], some
other sources said 64 [2]. I have not enough adapters to test any of the
higher values. Given the usage of this chipset in nano dongles, I think
the 16 might be high enough.
[1] https://github.com/lwfinger/rtl8188eu/blob/f5d1c8df2e2d8b217ea0113bf2cf3e37df8cb716/include/sta_info.h#L28
[2] https://lore.kernel.org/linux-wireless/27e83382-4c84-1841-c428-d1e5143ea20c@gmail.com/
Signed-off-by: Georg Müller <georgmueller@gmx.net>
---
drivers/net/wireless/realtek/rtl8xxxu/8188e.c | 18 ++++++++++--------
drivers/net/wireless/realtek/rtl8xxxu/core.c | 19 ++++++++++++++++---
.../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 3 ++-
3 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/8188e.c b/drivers/net/wireless/realtek/rtl8xxxu/8188e.c
index d6f50e72d2ce..3c887322f76b 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/8188e.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/8188e.c
@@ -1468,9 +1468,8 @@ static void rtl8188e_reset_ra_counter(struct rtl8xxxu_ra_info *ra)
ra->nsc_down = (n_threshold_high[rate_id] + n_threshold_low[rate_id]) >> 1;
}
-static void rtl8188e_rate_decision(struct rtl8xxxu_ra_info *ra)
+static void rtl8188e_rate_decision(struct rtl8xxxu_priv *priv, struct rtl8xxxu_ra_info *ra)
{
- struct rtl8xxxu_priv *priv = container_of(ra, struct rtl8xxxu_priv, ra_info);
const u8 *retry_penalty_idx_0;
const u8 *retry_penalty_idx_1;
const u8 *retry_penalty_up_idx;
@@ -1669,7 +1668,7 @@ void rtl8188e_handle_ra_tx_report2(struct rtl8xxxu_priv *priv, struct sk_buff *s
u32 *_rx_desc = (u32 *)(skb->data - sizeof(struct rtl8xxxu_rxdesc16));
struct rtl8xxxu_rxdesc16 *rx_desc = (struct rtl8xxxu_rxdesc16 *)_rx_desc;
struct device *dev = &priv->udev->dev;
- struct rtl8xxxu_ra_info *ra = &priv->ra_info;
+ struct rtl8xxxu_ra_info *ra;
u32 tx_rpt_len = rx_desc->pktlen & 0x3ff;
u32 items = tx_rpt_len / TX_RPT2_ITEM_SIZE;
u64 macid_valid = ((u64)_rx_desc[5] << 32) | _rx_desc[4];
@@ -1680,14 +1679,17 @@ void rtl8188e_handle_ra_tx_report2(struct rtl8xxxu_priv *priv, struct sk_buff *s
dev_dbg(dev, "%s: len: %d items: %d\n", __func__, tx_rpt_len, items);
- /* We only use macid 0, so only the first item is relevant.
- * AP mode will use more of them if it's ever implemented.
+ /* In station mode we only use macid 0, so only the first item
+ * is relevant. In AP mode every station has its own macid.
*/
if (!priv->vifs[0] || priv->vifs[0]->type == NL80211_IFTYPE_STATION)
items = 1;
+ else
+ items = min_t(u32, items, RTL8188E_MAX_MAC_ID_NUM);
for (macid = 0; macid < items; macid++) {
valid = false;
+ ra = &priv->ra_info[macid];
if (macid < 64)
valid = macid_valid & BIT(macid);
@@ -1704,7 +1706,7 @@ void rtl8188e_handle_ra_tx_report2(struct rtl8xxxu_priv *priv, struct sk_buff *s
if (ra->total > 0) {
if (ra->ra_stage < 5)
- rtl8188e_rate_decision(ra);
+ rtl8188e_rate_decision(priv, ra);
else if (ra->ra_stage == 5)
rtl8188e_power_training_try_state(ra);
else /* ra->ra_stage == 6 */
@@ -1781,7 +1783,7 @@ rtl8188e_update_rate_mask(struct rtl8xxxu_priv *priv,
u32 ramask, u8 rateid, int sgi, int txbw_40mhz,
u8 macid)
{
- struct rtl8xxxu_ra_info *ra = &priv->ra_info;
+ struct rtl8xxxu_ra_info *ra = &priv->ra_info[macid];
ra->rate_id = rateid;
ra->rate_mask = ramask;
@@ -1792,7 +1794,7 @@ rtl8188e_update_rate_mask(struct rtl8xxxu_priv *priv,
static void rtl8188e_ra_set_rssi(struct rtl8xxxu_priv *priv, u8 macid, u8 rssi)
{
- priv->ra_info.rssi_sta_ra = rssi;
+ priv->ra_info[macid].rssi_sta_ra = rssi;
}
void rtl8188e_ra_info_init_all(struct rtl8xxxu_ra_info *ra)
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/core.c b/drivers/net/wireless/realtek/rtl8xxxu/core.c
index 3d0c22db30a8..e3266ed9c302 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/core.c
@@ -3963,6 +3963,7 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
struct device *dev = &priv->udev->dev;
struct rtl8xxxu_fileops *fops = priv->fops;
bool macpower;
+ u16 mac_id;
int ret;
u8 val8;
u16 val16;
@@ -4443,8 +4444,10 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
priv->cfo_tracking.crystal_cap = priv->default_crystal_cap;
}
- if (priv->rtl_chip == RTL8188E)
- rtl8188e_ra_info_init_all(&priv->ra_info);
+ if (priv->rtl_chip == RTL8188E) {
+ for (mac_id = 0; mac_id < RTL8188E_MAX_MAC_ID_NUM; mac_id++)
+ rtl8188e_ra_info_init_all(&priv->ra_info[mac_id]);
+ }
set_bit(RTL8XXXU_BC_MC_MACID, priv->mac_id_map);
set_bit(RTL8XXXU_BC_MC_MACID1, priv->mac_id_map);
@@ -5385,7 +5388,7 @@ rtl8xxxu_fill_txdesc_v3(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
{
struct rtl8xxxu_priv *priv = hw->priv;
struct device *dev = &priv->udev->dev;
- struct rtl8xxxu_ra_info *ra = &priv->ra_info;
+ struct rtl8xxxu_ra_info *ra = &priv->ra_info[macid];
u8 *qc = ieee80211_get_qos_ctl(hdr);
u8 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
u32 rate = 0;
@@ -7892,6 +7895,16 @@ static int rtl8xxxu_probe(struct usb_interface *interface,
goto err_set_intfdata;
}
+ if (priv->rtl_chip == RTL8188E) {
+ priv->ra_info = devm_kcalloc(&interface->dev,
+ RTL8188E_MAX_MAC_ID_NUM,
+ sizeof(*priv->ra_info), GFP_KERNEL);
+ if (!priv->ra_info) {
+ ret = -ENOMEM;
+ goto err_set_intfdata;
+ }
+ }
+
ret = rtl8xxxu_init_device(hw);
if (ret)
goto err_set_intfdata;
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
index debaaad217e0..6d3b65ee9cc5 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
@@ -76,6 +76,7 @@
#define RTL_FW_PAGE_SIZE 4096
#define RTL8XXXU_FIRMWARE_POLL_MAX 1000
+#define RTL8188E_MAX_MAC_ID_NUM 16
#define RTL8723A_CHANNEL_GROUPS 3
#define RTL8723A_MAX_RF_PATHS 2
#define RTL8723B_CHANNEL_GROUPS 6
@@ -1921,7 +1922,7 @@ struct rtl8xxxu_priv {
struct rtl8xxxu_btcoex bt_coex;
struct rtl8xxxu_ra_report ra_report;
struct rtl8xxxu_cfo_tracking cfo_tracking;
- struct rtl8xxxu_ra_info ra_info; /* 8188e specific */
+ struct rtl8xxxu_ra_info *ra_info; /* 8188e specific */
u8 dynamic_tx_rpt_timing_counter; /* 8188e specific */
bool led_registered;
--
2.56.1
next prev parent reply other threads:[~2026-11-26 10:58 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-13 13:53 [RFC PATCH v3 0/4] wifi: rtl8xxxu: implement AP mode for 8188EU Georg Müller
2026-03-13 13:53 ` [RFC PATCH v3 1/4] wifi: rtl8xxxu: move dynamic_tx_rpt_timing_counter from ra_info to priv Georg Müller
2026-03-16 6:17 ` Ping-Ke Shih
2026-03-16 9:30 ` Georg Müller
2026-03-17 2:52 ` Ping-Ke Shih
2026-03-13 13:53 ` [RFC PATCH v3 2/4] wifi: rtl8xxxu: handle rate control for 8188e a per mac_id Georg Müller
2026-03-16 6:35 ` Ping-Ke Shih
2026-03-16 9:41 ` Georg Müller
2026-03-13 13:53 ` [RFC PATCH v3 3/4] wifi: rtl8xxxu: update max report mac id on station add / remove for 8188e chips Georg Müller
2026-03-16 7:07 ` Ping-Ke Shih
2026-03-13 13:53 ` [RFC PATCH v3 4/4] wifi: rtl8xxxu: Enable AP mode for RTL8188EU Georg Müller
2026-03-13 23:14 ` [RFC PATCH v3 0/4] wifi: rtl8xxxu: implement AP mode for 8188EU Bitterblue Smith
2026-03-27 13:58 ` Georg Müller
2026-11-25 16:06 ` Mehmet Fide
2026-11-25 20:37 ` Bitterblue Smith
2026-11-26 1:09 ` Georg Müller
2026-11-26 5:43 ` Mehmet Fide
2026-11-26 10:57 ` [RFC PATCH v4 0/5] " Georg Müller
2026-11-26 10:57 ` [RFC PATCH v4 1/5] wifi: rtl8xxxu: move dynamic_tx_rpt_timing_counter from ra_info to priv Georg Müller
2026-11-26 10:57 ` Georg Müller [this message]
2026-11-26 10:57 ` [RFC PATCH v4 3/5] wifi: rtl8xxxu: update max report mac id on station add / remove for 8188e chips Georg Müller
2026-11-26 10:57 ` [RFC PATCH v4 4/5] wifi: rtl8xxxu: Enable AP mode for RTL8188EU Georg Müller
2026-11-26 10:57 ` [RFC PATCH v4 5/5] wifi: rtl8xxxu: set macid in TX descriptor for 8188e Georg Müller
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=20261126105742.1086282-3-georgmueller@gmx.net \
--to=georgmueller@gmx.net \
--cc=Jes.Sorensen@gmail.com \
--cc=hi@shreyan.sh \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=mehmet.fide@gmail.com \
--cc=mehmet.fide@screeningeagle.com \
--cc=pkshih@realtek.com \
--cc=rtl8821cerfe2@gmail.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