linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f
@ 2023-04-19 10:01 Martin Kaistra
  2023-04-19 10:01 ` [PATCH v2 01/18] wifi: rtl8xxxu: Add start_ap() callback Martin Kaistra
                   ` (18 more replies)
  0 siblings, 19 replies; 36+ messages in thread
From: Martin Kaistra @ 2023-04-19 10:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: Jes Sorensen, Kalle Valo, Ping-Ke Shih, Bitterblue Smith,
	Sebastian Andrzej Siewior

This series intends to bring AP mode support to the rtl8xxxu driver,
more specifically for the 8188f, because this is the HW I have.
The work is based on the vendor driver as I do not have access to
datasheets.

Also while doing some measurements with iperf3 to compare with the
vendor driver, I saw, that TCP traffic from AP to STA is slower than in
the vendor driver. For UDP it looks fine. I hope I can get some help to
fix this.

* vendor driver:

  without 802.11n:
    UDP (AP -> STA): 27 Mbits/sec
    UDP (STA -> AP): 33 Mbits/sec
    TCP (AP -> STA): 24 Mbits/sec
    TCP (STA -> AP): 26 Mbits/sec

  with 802.11n:
    UDP (AP -> STA): 51 Mbits/sec
    UDP (STA -> AP): 35 Mbits/sec
    TCP (AP -> STA): 40 Mbits/sec
    TCP (STA -> AP): 36 Mbits/sec

* rtl8xxxu:

  without 802.11n:
    UDP (AP -> STA): 25 Mbits/sec
    UDP (STA -> AP): 31 Mbits/sec
    TCP (AP -> STA):  3 Mbits/sec !
    TCP (STA -> AP): 25 Mbits/sec

  with 802.11n:
    UDP (AP -> STA): 41 Mbits/sec
    UDP (STA -> AP): 36 Mbits/sec
    TCP (AP -> STA):  3 Mbits/sec !
    TCP (STA -> AP): 32 Mbits/sec

Thanks,
  Martin

v2 changelog:
- dropped RFC prefix
- rebase patches to newest wireless-next
- add some R-bs
- new patch: "Add parameter force to rtl8xxxu_refresh_rate_mask"
- new patch: "Remove usage of ieee80211_get_tx_rate()"
- new patch: "Remove usage of tx_info->control.rates[0].flags"
- new patch: "Set maximum number of supported stations"
- add macro for broadcast/multicast frames macid
- add more explanation about beacon queue in commit message of patch 2
- add macros for bit definitions for beacon functions
- implement enable_beacon = false case
- fix beacon valid loop so that error condition is actually reached
- add more explanation about setting mac address register in add_interface
  in commit message of patch 6
- rename role macros for connect report h2c
- use bitmap for assigning macids
- add helper function for looking up assigned macids
- move patch 7 so we can use rtl8xxxu_get_macid helper
- add sta_remove callback
- do things in sta_add only in AP mode
- use IEEE80211_TX_CTL_ASSIGN_SEQ flag to determine when to use HW sequence
  numbers
- add priv->vif null pointer check in configure_filter, rework setting
  BSSID_BEACON/BSSID_MATCH in RCR

v1: https://lore.kernel.org/linux-wireless/20230322171905.492855-1-martin.kaistra@linutronix.de/

Martin Kaistra (18):
  wifi: rtl8xxxu: Add start_ap() callback
  wifi: rtl8xxxu: Select correct queue for beacon frames
  wifi: rtl8xxxu: Add beacon functions
  wifi: rtl8xxxu: Add set_tim() callback
  wifi: rtl8xxxu: Allow setting rts threshold to -1
  wifi: rtl8xxxu: Allow creating interface in AP mode
  wifi: rtl8xxxu: Actually use macid in rtl8xxxu_gen2_report_connect
  wifi: rtl8xxxu: Add parameter role to report_connect
  wifi: rtl8xxxu: Add parameter force to rtl8xxxu_refresh_rate_mask
  wifi: rtl8xxxu: Add sta_add() and sta_remove() callbacks
  wifi: rtl8xxxu: Put the macid in txdesc
  wifi: rtl8xxxu: Add parameter macid to update_rate_mask
  wifi: rtl8xxxu: Enable hw seq for mgmt/non-QoS data frames
  wifi: rtl8xxxu: Clean up filter configuration
  wifi: rtl8xxxu: Remove usage of ieee80211_get_tx_rate()
  wifi: rtl8xxxu: Remove usage of tx_info->control.rates[0].flags
  wifi: rtl8xxxu: Declare AP mode support for 8188f
  wifi: rtl8xxxu: Set maximum number of supported stations

 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h  |  39 +-
 .../realtek/rtl8xxxu/rtl8xxxu_8188e.c         |   3 +-
 .../realtek/rtl8xxxu/rtl8xxxu_8188f.c         |   2 +
 .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 346 ++++++++++++++----
 .../wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h |   5 +
 5 files changed, 311 insertions(+), 84 deletions(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH v2 01/18] wifi: rtl8xxxu: Add start_ap() callback
  2023-04-19 10:01 [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Martin Kaistra
@ 2023-04-19 10:01 ` Martin Kaistra
  2023-04-19 10:01 ` [PATCH v2 02/18] wifi: rtl8xxxu: Select correct queue for beacon frames Martin Kaistra
                   ` (17 subsequent siblings)
  18 siblings, 0 replies; 36+ messages in thread
From: Martin Kaistra @ 2023-04-19 10:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: Jes Sorensen, Kalle Valo, Ping-Ke Shih, Bitterblue Smith,
	Sebastian Andrzej Siewior

This gets called at the start of AP mode operation. Set bssid, beacon
interval and send a connect report to the HW.

Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h  |  1 +
 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 15 +++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
index 82a0290ccb299..cb8c019b63372 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
@@ -1727,6 +1727,7 @@ struct rtl8xxxu_cfo_tracking {
 };
 
 #define RTL8XXXU_HW_LED_CONTROL	2
+#define RTL8XXXU_BC_MC_MACID	0
 
 struct rtl8xxxu_priv {
 	struct ieee80211_hw *hw;
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 6106b47d0c37f..b2be89c35d914 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -4889,6 +4889,20 @@ rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 	return;
 }
 
+static int rtl8xxxu_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+			     struct ieee80211_bss_conf *link_conf)
+{
+	struct rtl8xxxu_priv *priv = hw->priv;
+	struct device *dev = &priv->udev->dev;
+
+	dev_dbg(dev, "Start AP mode\n");
+	rtl8xxxu_set_bssid(priv, vif->bss_conf.bssid);
+	rtl8xxxu_write16(priv, REG_BCN_INTERVAL, vif->bss_conf.beacon_int);
+	priv->fops->report_connect(priv, RTL8XXXU_BC_MC_MACID, true);
+
+	return 0;
+}
+
 static u32 rtl8xxxu_80211_to_rtl_queue(u32 queue)
 {
 	u32 rtlqueue;
@@ -7016,6 +7030,7 @@ static const struct ieee80211_ops rtl8xxxu_ops = {
 	.config = rtl8xxxu_config,
 	.conf_tx = rtl8xxxu_conf_tx,
 	.bss_info_changed = rtl8xxxu_bss_info_changed,
+	.start_ap = rtl8xxxu_start_ap,
 	.configure_filter = rtl8xxxu_configure_filter,
 	.set_rts_threshold = rtl8xxxu_set_rts_threshold,
 	.start = rtl8xxxu_start,
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 02/18] wifi: rtl8xxxu: Select correct queue for beacon frames
  2023-04-19 10:01 [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Martin Kaistra
  2023-04-19 10:01 ` [PATCH v2 01/18] wifi: rtl8xxxu: Add start_ap() callback Martin Kaistra
@ 2023-04-19 10:01 ` Martin Kaistra
  2023-04-19 10:01 ` [PATCH v2 03/18] wifi: rtl8xxxu: Add beacon functions Martin Kaistra
                   ` (16 subsequent siblings)
  18 siblings, 0 replies; 36+ messages in thread
From: Martin Kaistra @ 2023-04-19 10:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: Jes Sorensen, Kalle Valo, Ping-Ke Shih, Bitterblue Smith,
	Sebastian Andrzej Siewior

Use the special beacon queue for beacon frames instead of the management
frame queue. They will be put in a special area called reserved page and
send out periodically when in AP mode.

Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index b2be89c35d914..2c2513cee3a63 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -4931,7 +4931,9 @@ static u32 rtl8xxxu_queue_select(struct ieee80211_hdr *hdr, struct sk_buff *skb)
 {
 	u32 queue;
 
-	if (ieee80211_is_mgmt(hdr->frame_control))
+	if (unlikely(ieee80211_is_beacon(hdr->frame_control)))
+		queue = TXDESC_QUEUE_BEACON;
+	else if (ieee80211_is_mgmt(hdr->frame_control))
 		queue = TXDESC_QUEUE_MGNT;
 	else
 		queue = rtl8xxxu_80211_to_rtl_queue(skb_get_queue_mapping(skb));
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 03/18] wifi: rtl8xxxu: Add beacon functions
  2023-04-19 10:01 [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Martin Kaistra
  2023-04-19 10:01 ` [PATCH v2 01/18] wifi: rtl8xxxu: Add start_ap() callback Martin Kaistra
  2023-04-19 10:01 ` [PATCH v2 02/18] wifi: rtl8xxxu: Select correct queue for beacon frames Martin Kaistra
@ 2023-04-19 10:01 ` Martin Kaistra
  2023-04-24  2:29   ` Ping-Ke Shih
  2023-04-19 10:01 ` [PATCH v2 04/18] wifi: rtl8xxxu: Add set_tim() callback Martin Kaistra
                   ` (15 subsequent siblings)
  18 siblings, 1 reply; 36+ messages in thread
From: Martin Kaistra @ 2023-04-19 10:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: Jes Sorensen, Kalle Valo, Ping-Ke Shih, Bitterblue Smith,
	Sebastian Andrzej Siewior

Add a workqueue to update the beacon contents asynchronously and
implement downloading the beacon to the HW and starting beacon tx like
the vendor driver.

Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
---
 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h  |  3 +
 .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 84 +++++++++++++++++++
 .../wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h |  3 +
 3 files changed, 90 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
index cb8c019b63372..93f744cd8d6d8 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
@@ -1745,6 +1745,8 @@ struct rtl8xxxu_priv {
 	bool shutdown;
 	struct work_struct rx_urb_wq;
 
+	bool beacon_enabled;
+
 	u8 mac_addr[ETH_ALEN];
 	char chip_name[8];
 	char chip_vendor[8];
@@ -1851,6 +1853,7 @@ struct rtl8xxxu_priv {
 	struct delayed_work ra_watchdog;
 	struct work_struct c2hcmd_work;
 	struct sk_buff_head c2hcmd_queue;
+	struct work_struct update_beacon_work;
 	struct rtl8xxxu_btcoex bt_coex;
 	struct rtl8xxxu_ra_report ra_report;
 	struct rtl8xxxu_cfo_tracking cfo_tracking;
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 2c2513cee3a63..960e3efcb0ee2 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -1104,6 +1104,24 @@ static void rtl8xxxu_stop_tx_beacon(struct rtl8xxxu_priv *priv)
 	val8 = rtl8xxxu_read8(priv, REG_TBTT_PROHIBIT + 2);
 	val8 &= ~BIT(0);
 	rtl8xxxu_write8(priv, REG_TBTT_PROHIBIT + 2, val8);
+
+	priv->beacon_enabled = false;
+}
+
+static void rtl8xxxu_start_tx_beacon(struct rtl8xxxu_priv *priv)
+{
+	u8 val8;
+
+	val8 = rtl8xxxu_read8(priv, REG_FWHW_TXQ_CTRL + 2);
+	val8 |= EN_BCNQ_DL >> 16;
+	rtl8xxxu_write8(priv, REG_FWHW_TXQ_CTRL + 2, val8);
+
+	rtl8xxxu_write8(priv, REG_TBTT_PROHIBIT + 1, 0x80);
+	val8 = rtl8xxxu_read8(priv, REG_TBTT_PROHIBIT + 2);
+	val8 &= 0xF0;
+	rtl8xxxu_write8(priv, REG_TBTT_PROHIBIT + 2, val8);
+
+	priv->beacon_enabled = true;
 }
 
 
@@ -4885,6 +4903,22 @@ rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 		dev_dbg(dev, "Changed BASIC_RATES!\n");
 		rtl8xxxu_set_basic_rates(priv, bss_conf->basic_rates);
 	}
+
+	if (changed & BSS_CHANGED_BEACON ||
+	    (changed & BSS_CHANGED_BEACON_ENABLED &&
+	     bss_conf->enable_beacon)) {
+		if (!priv->beacon_enabled) {
+			dev_dbg(dev, "BSS_CHANGED_BEACON_ENABLED\n");
+			rtl8xxxu_start_tx_beacon(priv);
+		}
+		schedule_work(&priv->update_beacon_work);
+	}
+
+	if (changed & BSS_CHANGED_BEACON_ENABLED && !bss_conf->enable_beacon) {
+		if (priv->beacon_enabled)
+			rtl8xxxu_stop_tx_beacon(priv);
+	}
+
 error:
 	return;
 }
@@ -5466,6 +5500,55 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw,
 	dev_kfree_skb(skb);
 }
 
+static void rtl8xxxu_send_beacon_frame(struct ieee80211_hw *hw,
+				       struct ieee80211_vif *vif)
+{
+	struct rtl8xxxu_priv *priv = hw->priv;
+	struct sk_buff *skb = ieee80211_beacon_get(hw, vif, 0);
+	struct device *dev = &priv->udev->dev;
+	int retry;
+	u8 val8;
+
+	/* BCN_VALID, write 1 to clear, cleared by SW */
+	val8 = rtl8xxxu_read8(priv, REG_TDECTRL + 2);
+	val8 |= BIT_BCN_VALID >> 16;
+	rtl8xxxu_write8(priv, REG_TDECTRL + 2, val8);
+
+	/* SW_BCN_SEL - Port0 */
+	val8 = rtl8xxxu_read8(priv, REG_DWBCN1_CTRL_8723B + 2);
+	val8 &= ~(BIT_SW_BCN_SEL >> 16);
+	rtl8xxxu_write8(priv, REG_DWBCN1_CTRL_8723B + 2, val8);
+
+	if (skb)
+		rtl8xxxu_tx(hw, NULL, skb);
+
+	retry = 100;
+	do {
+		val8 = rtl8xxxu_read8(priv, REG_TDECTRL + 2);
+		if (val8 & (BIT_BCN_VALID >> 16))
+			break;
+		usleep_range(10, 20);
+	} while (--retry);
+
+	if (!retry)
+		dev_err(dev, "%s: Failed to read beacon valid bit\n", __func__);
+}
+
+static void rtl8xxxu_update_beacon_work_callback(struct work_struct *work)
+{
+	struct rtl8xxxu_priv *priv =
+		container_of(work, struct rtl8xxxu_priv, update_beacon_work);
+	struct ieee80211_hw *hw = priv->hw;
+	struct ieee80211_vif *vif = priv->vif;
+
+	if (!vif) {
+		WARN_ONCE(true, "no vif to update beacon\n");
+		return;
+	}
+
+	rtl8xxxu_send_beacon_frame(hw, vif);
+}
+
 void rtl8723au_rx_parse_phystats(struct rtl8xxxu_priv *priv,
 				 struct ieee80211_rx_status *rx_status,
 				 struct rtl8723au_phy_stats *phy_stats,
@@ -7234,6 +7317,7 @@ static int rtl8xxxu_probe(struct usb_interface *interface,
 	spin_lock_init(&priv->rx_urb_lock);
 	INIT_WORK(&priv->rx_urb_wq, rtl8xxxu_rx_urb_work);
 	INIT_DELAYED_WORK(&priv->ra_watchdog, rtl8xxxu_watchdog_callback);
+	INIT_WORK(&priv->update_beacon_work, rtl8xxxu_update_beacon_work_callback);
 	skb_queue_head_init(&priv->c2hcmd_queue);
 
 	usb_set_intfdata(interface, hw);
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
index 4dffbab494c3b..ad285e4ac0ec4 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
@@ -456,6 +456,7 @@
 
 #define REG_FIFOPAGE			0x0204
 #define REG_TDECTRL			0x0208
+#define  BIT_BCN_VALID			BIT(16)
 
 #define REG_DWBCN0_CTRL_8188F		REG_TDECTRL
 
@@ -470,6 +471,7 @@
 #define  AUTO_LLT_INIT_LLT		BIT(16)
 
 #define REG_DWBCN1_CTRL_8723B		0x0228
+#define  BIT_SW_BCN_SEL			BIT(20)
 
 /* 0x0280 ~ 0x02FF	RXDMA Configuration */
 #define REG_RXDMA_AGG_PG_TH		0x0280	/* 0-7 : USB DMA size bits
@@ -516,6 +518,7 @@
 #define REG_FWHW_TXQ_CTRL		0x0420
 #define  FWHW_TXQ_CTRL_AMPDU_RETRY	BIT(7)
 #define  FWHW_TXQ_CTRL_XMIT_MGMT_ACK	BIT(12)
+#define  EN_BCNQ_DL			BIT(22)
 
 #define REG_HWSEQ_CTRL			0x0423
 #define REG_TXPKTBUF_BCNQ_BDNY		0x0424
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 04/18] wifi: rtl8xxxu: Add set_tim() callback
  2023-04-19 10:01 [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Martin Kaistra
                   ` (2 preceding siblings ...)
  2023-04-19 10:01 ` [PATCH v2 03/18] wifi: rtl8xxxu: Add beacon functions Martin Kaistra
@ 2023-04-19 10:01 ` Martin Kaistra
  2023-04-19 10:01 ` [PATCH v2 05/18] wifi: rtl8xxxu: Allow setting rts threshold to -1 Martin Kaistra
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 36+ messages in thread
From: Martin Kaistra @ 2023-04-19 10:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: Jes Sorensen, Kalle Valo, Ping-Ke Shih, Bitterblue Smith,
	Sebastian Andrzej Siewior

Update beacon content if TIM bitmap maintained by mac80211 is changed.

Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 960e3efcb0ee2..6a354165224a8 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -4428,6 +4428,16 @@ int rtl8xxxu_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant)
 	return 0;
 }
 
+static int rtl8xxxu_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
+			    bool set)
+{
+	struct rtl8xxxu_priv *priv = hw->priv;
+
+	schedule_work(&priv->update_beacon_work);
+
+	return 0;
+}
+
 static void rtl8xxxu_sw_scan_start(struct ieee80211_hw *hw,
 				   struct ieee80211_vif *vif, const u8 *mac)
 {
@@ -7126,6 +7136,7 @@ static const struct ieee80211_ops rtl8xxxu_ops = {
 	.ampdu_action = rtl8xxxu_ampdu_action,
 	.sta_statistics = rtl8xxxu_sta_statistics,
 	.get_antenna = rtl8xxxu_get_antenna,
+	.set_tim = rtl8xxxu_set_tim,
 };
 
 static int rtl8xxxu_parse_usb(struct rtl8xxxu_priv *priv,
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 05/18] wifi: rtl8xxxu: Allow setting rts threshold to -1
  2023-04-19 10:01 [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Martin Kaistra
                   ` (3 preceding siblings ...)
  2023-04-19 10:01 ` [PATCH v2 04/18] wifi: rtl8xxxu: Add set_tim() callback Martin Kaistra
@ 2023-04-19 10:01 ` Martin Kaistra
  2023-04-19 10:01 ` [PATCH v2 06/18] wifi: rtl8xxxu: Allow creating interface in AP mode Martin Kaistra
                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 36+ messages in thread
From: Martin Kaistra @ 2023-04-19 10:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: Jes Sorensen, Kalle Valo, Ping-Ke Shih, Bitterblue Smith,
	Sebastian Andrzej Siewior

The default setting in hostapd.conf for rts threshold is -1, which means
disabled. Allow to set it.

Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 6a354165224a8..60b50a57da284 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -6585,7 +6585,7 @@ static void rtl8xxxu_configure_filter(struct ieee80211_hw *hw,
 
 static int rtl8xxxu_set_rts_threshold(struct ieee80211_hw *hw, u32 rts)
 {
-	if (rts > 2347)
+	if (rts > 2347 && rts != (u32)-1)
 		return -EINVAL;
 
 	return 0;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 06/18] wifi: rtl8xxxu: Allow creating interface in AP mode
  2023-04-19 10:01 [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Martin Kaistra
                   ` (4 preceding siblings ...)
  2023-04-19 10:01 ` [PATCH v2 05/18] wifi: rtl8xxxu: Allow setting rts threshold to -1 Martin Kaistra
@ 2023-04-19 10:01 ` Martin Kaistra
  2023-04-24  2:32   ` Ping-Ke Shih
  2023-04-19 10:01 ` [PATCH v2 07/18] wifi: rtl8xxxu: Actually use macid in rtl8xxxu_gen2_report_connect Martin Kaistra
                   ` (12 subsequent siblings)
  18 siblings, 1 reply; 36+ messages in thread
From: Martin Kaistra @ 2023-04-19 10:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: Jes Sorensen, Kalle Valo, Ping-Ke Shih, Bitterblue Smith,
	Sebastian Andrzej Siewior

Use the sequence from the vendor driver for setting up the beacon
related registers.
Also set the MAC address register here, in case the MAC address for the
new interface should be different from what was set in
rtl8xxxu_init_device(). This happens for example with the hostapd config
option "bssid".

Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
---
 .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 31 ++++++++++++++++---
 .../wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h |  2 ++
 2 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 60b50a57da284..de44e79dd186a 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -6401,18 +6401,39 @@ static int rtl8xxxu_add_interface(struct ieee80211_hw *hw,
 	int ret;
 	u8 val8;
 
+	if (!priv->vif)
+		priv->vif = vif;
+	else
+		return -EOPNOTSUPP;
+
 	switch (vif->type) {
 	case NL80211_IFTYPE_STATION:
-		if (!priv->vif)
-			priv->vif = vif;
-		else
-			return -EOPNOTSUPP;
 		rtl8xxxu_stop_tx_beacon(priv);
 
 		val8 = rtl8xxxu_read8(priv, REG_BEACON_CTRL);
 		val8 |= BEACON_ATIM | BEACON_FUNCTION_ENABLE |
 			BEACON_DISABLE_TSF_UPDATE;
 		rtl8xxxu_write8(priv, REG_BEACON_CTRL, val8);
+		ret = 0;
+		break;
+	case NL80211_IFTYPE_AP:
+		rtl8xxxu_write8(priv, REG_BEACON_CTRL,
+				BEACON_DISABLE_TSF_UPDATE | BEACON_CTRL_MBSSID);
+		rtl8xxxu_write8(priv, REG_ATIMWND, 0x0c); /* 12ms */
+		rtl8xxxu_write16(priv, REG_TSFTR_SYN_OFFSET, 0x7fff); /* ~32ms */
+		rtl8xxxu_write8(priv, REG_DUAL_TSF_RST, DUAL_TSF_RESET_TSF0);
+
+		/* enable BCN0 function */
+		rtl8xxxu_write8(priv, REG_BEACON_CTRL,
+				BEACON_DISABLE_TSF_UPDATE |
+				BEACON_FUNCTION_ENABLE | BEACON_CTRL_MBSSID |
+				BEACON_CTRL_TX_BEACON_RPT);
+
+		/* select BCN on port 0 */
+		val8 = rtl8xxxu_read8(priv, REG_CCK_CHECK);
+		val8 &= ~BIT_BCN_PORT_SEL;
+		rtl8xxxu_write8(priv, REG_CCK_CHECK, val8);
+
 		ret = 0;
 		break;
 	default:
@@ -6420,6 +6441,8 @@ static int rtl8xxxu_add_interface(struct ieee80211_hw *hw,
 	}
 
 	rtl8xxxu_set_linktype(priv, vif->type);
+	ether_addr_copy(priv->mac_addr, vif->addr);
+	rtl8xxxu_set_mac(priv);
 
 	return ret;
 }
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
index ad285e4ac0ec4..8571d5129f327 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
@@ -575,6 +575,8 @@
 #define REG_ARFR1			0x0448
 #define REG_ARFR2			0x044c
 #define REG_ARFR3			0x0450
+#define REG_CCK_CHECK			0x0454
+#define BIT_BCN_PORT_SEL		BIT(5)
 #define REG_AMPDU_MAX_TIME_8723B	0x0456
 #define REG_AGGLEN_LMT			0x0458
 #define REG_AMPDU_MIN_SPACE		0x045c
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 07/18] wifi: rtl8xxxu: Actually use macid in rtl8xxxu_gen2_report_connect
  2023-04-19 10:01 [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Martin Kaistra
                   ` (5 preceding siblings ...)
  2023-04-19 10:01 ` [PATCH v2 06/18] wifi: rtl8xxxu: Allow creating interface in AP mode Martin Kaistra
@ 2023-04-19 10:01 ` Martin Kaistra
  2023-04-19 10:01 ` [PATCH v2 08/18] wifi: rtl8xxxu: Add parameter role to report_connect Martin Kaistra
                   ` (11 subsequent siblings)
  18 siblings, 0 replies; 36+ messages in thread
From: Martin Kaistra @ 2023-04-19 10:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: Jes Sorensen, Kalle Valo, Ping-Ke Shih, Bitterblue Smith,
	Sebastian Andrzej Siewior

The report_connect function has had a macid parameter from the
beginning, but it has not been used, because in STA mode, the value was
always zero.
As it can now have different values in AP mode, actually wire it up to
the H2C command.

Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index de44e79dd186a..ede9f7e1c446c 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -4544,6 +4544,8 @@ void rtl8xxxu_gen2_report_connect(struct rtl8xxxu_priv *priv,
 	else
 		h2c.media_status_rpt.parm &= ~BIT(0);
 
+	h2c.media_status_rpt.macid = macid;
+
 	rtl8xxxu_gen2_h2c_cmd(priv, &h2c, sizeof(h2c.media_status_rpt));
 }
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 08/18] wifi: rtl8xxxu: Add parameter role to report_connect
  2023-04-19 10:01 [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Martin Kaistra
                   ` (6 preceding siblings ...)
  2023-04-19 10:01 ` [PATCH v2 07/18] wifi: rtl8xxxu: Actually use macid in rtl8xxxu_gen2_report_connect Martin Kaistra
@ 2023-04-19 10:01 ` Martin Kaistra
  2023-04-24  2:40   ` Ping-Ke Shih
  2023-04-19 10:01 ` [PATCH v2 09/18] wifi: rtl8xxxu: Add parameter force to rtl8xxxu_refresh_rate_mask Martin Kaistra
                   ` (10 subsequent siblings)
  18 siblings, 1 reply; 36+ messages in thread
From: Martin Kaistra @ 2023-04-19 10:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: Jes Sorensen, Kalle Valo, Ping-Ke Shih, Bitterblue Smith,
	Sebastian Andrzej Siewior

This allows to tell the HW if a connection is made to a STA or an AP.
Add the implementation for the gen2 version.

Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h      |  9 ++++++---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 11 ++++++-----
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
index 93f744cd8d6d8..93091068b3fd2 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
@@ -1280,6 +1280,9 @@ struct rtl8xxxu_rfregs {
 #define  H2C_JOIN_BSS_DISCONNECT	0
 #define  H2C_JOIN_BSS_CONNECT		1
 
+#define H2C_MACID_ROLE_STA		1
+#define H2C_MACID_ROLE_AP		2
+
 /*
  * H2C (firmware) commands differ between the older generation chips
  * 8188[cr]u, 819[12]cu, and 8723au, and the more recent chips 8723bu,
@@ -1908,7 +1911,7 @@ struct rtl8xxxu_fileops {
 	void (*update_rate_mask) (struct rtl8xxxu_priv *priv,
 				  u32 ramask, u8 rateid, int sgi, int txbw_40mhz);
 	void (*report_connect) (struct rtl8xxxu_priv *priv,
-				u8 macid, bool connect);
+				u8 macid, u8 role, bool connect);
 	void (*report_rssi) (struct rtl8xxxu_priv *priv, u8 macid, u8 rssi);
 	void (*fill_txdesc) (struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
 			     struct ieee80211_tx_info *tx_info,
@@ -2017,9 +2020,9 @@ void rtl8xxxu_update_rate_mask(struct rtl8xxxu_priv *priv,
 void rtl8xxxu_gen2_update_rate_mask(struct rtl8xxxu_priv *priv,
 				    u32 ramask, u8 rateid, int sgi, int txbw_40mhz);
 void rtl8xxxu_gen1_report_connect(struct rtl8xxxu_priv *priv,
-				  u8 macid, bool connect);
+				  u8 macid, u8 role, bool connect);
 void rtl8xxxu_gen2_report_connect(struct rtl8xxxu_priv *priv,
-				  u8 macid, bool connect);
+				  u8 macid, u8 role, bool connect);
 void rtl8xxxu_gen1_report_rssi(struct rtl8xxxu_priv *priv, u8 macid, u8 rssi);
 void rtl8xxxu_gen2_report_rssi(struct rtl8xxxu_priv *priv, u8 macid, u8 rssi);
 void rtl8xxxu_gen1_init_aggregation(struct rtl8xxxu_priv *priv);
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index ede9f7e1c446c..75b8b6d07ea67 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -4511,7 +4511,7 @@ void rtl8xxxu_gen2_update_rate_mask(struct rtl8xxxu_priv *priv,
 }
 
 void rtl8xxxu_gen1_report_connect(struct rtl8xxxu_priv *priv,
-				  u8 macid, bool connect)
+				  u8 macid, u8 role, bool connect)
 {
 	struct h2c_cmd h2c;
 
@@ -4528,7 +4528,7 @@ void rtl8xxxu_gen1_report_connect(struct rtl8xxxu_priv *priv,
 }
 
 void rtl8xxxu_gen2_report_connect(struct rtl8xxxu_priv *priv,
-				  u8 macid, bool connect)
+				  u8 macid, u8 role, bool connect)
 {
 	/*
 	 * The firmware turns on the rate control when it knows it's
@@ -4544,6 +4544,7 @@ void rtl8xxxu_gen2_report_connect(struct rtl8xxxu_priv *priv,
 	else
 		h2c.media_status_rpt.parm &= ~BIT(0);
 
+	h2c.media_status_rpt.parm |= ((role << 4) & 0xf0);
 	h2c.media_status_rpt.macid = macid;
 
 	rtl8xxxu_gen2_h2c_cmd(priv, &h2c, sizeof(h2c.media_status_rpt));
@@ -4872,13 +4873,13 @@ rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 			rtl8xxxu_write16(priv, REG_BCN_PSR_RPT,
 					 0xc000 | vif->cfg.aid);
 
-			priv->fops->report_connect(priv, 0, true);
+			priv->fops->report_connect(priv, 0, H2C_MACID_ROLE_AP, true);
 		} else {
 			val8 = rtl8xxxu_read8(priv, REG_BEACON_CTRL);
 			val8 |= BEACON_DISABLE_TSF_UPDATE;
 			rtl8xxxu_write8(priv, REG_BEACON_CTRL, val8);
 
-			priv->fops->report_connect(priv, 0, false);
+			priv->fops->report_connect(priv, 0, H2C_MACID_ROLE_AP, false);
 		}
 	}
 
@@ -4944,7 +4945,7 @@ static int rtl8xxxu_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 	dev_dbg(dev, "Start AP mode\n");
 	rtl8xxxu_set_bssid(priv, vif->bss_conf.bssid);
 	rtl8xxxu_write16(priv, REG_BCN_INTERVAL, vif->bss_conf.beacon_int);
-	priv->fops->report_connect(priv, RTL8XXXU_BC_MC_MACID, true);
+	priv->fops->report_connect(priv, RTL8XXXU_BC_MC_MACID, 0, true);
 
 	return 0;
 }
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 09/18] wifi: rtl8xxxu: Add parameter force to rtl8xxxu_refresh_rate_mask
  2023-04-19 10:01 [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Martin Kaistra
                   ` (7 preceding siblings ...)
  2023-04-19 10:01 ` [PATCH v2 08/18] wifi: rtl8xxxu: Add parameter role to report_connect Martin Kaistra
@ 2023-04-19 10:01 ` Martin Kaistra
  2023-04-24  2:42   ` Ping-Ke Shih
  2023-04-19 10:01 ` [PATCH v2 10/18] wifi: rtl8xxxu: Add sta_add() and sta_remove() callbacks Martin Kaistra
                   ` (9 subsequent siblings)
  18 siblings, 1 reply; 36+ messages in thread
From: Martin Kaistra @ 2023-04-19 10:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: Jes Sorensen, Kalle Valo, Ping-Ke Shih, Bitterblue Smith,
	Sebastian Andrzej Siewior

In AP mode, when multiple STAs connect to us, we need to set an initial
rate mask for each of them. This initialisation should happen regardless
of the rssi_level saved in the priv struct.

Add a parameter called force to rtl8xxxu_refresh_rate_mask() which will
be used for this initialisation.

Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 75b8b6d07ea67..19e115d10493a 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -6760,7 +6760,8 @@ static u8 rtl8xxxu_signal_to_snr(int signal)
 }
 
 static void rtl8xxxu_refresh_rate_mask(struct rtl8xxxu_priv *priv,
-				       int signal, struct ieee80211_sta *sta)
+				       int signal, struct ieee80211_sta *sta,
+				       bool force)
 {
 	struct ieee80211_hw *hw = priv->hw;
 	u16 wireless_mode;
@@ -6794,7 +6795,7 @@ static void rtl8xxxu_refresh_rate_mask(struct rtl8xxxu_priv *priv,
 	else
 		rssi_level = RTL8XXXU_RATR_STA_LOW;
 
-	if (rssi_level != priv->rssi_level) {
+	if (rssi_level != priv->rssi_level || force) {
 		int sgi = 0;
 		u32 rate_bitmap = 0;
 
@@ -7010,7 +7011,7 @@ static void rtl8xxxu_watchdog_callback(struct work_struct *work)
 		if (priv->fops->set_crystal_cap)
 			rtl8xxxu_track_cfo(priv);
 
-		rtl8xxxu_refresh_rate_mask(priv, signal, sta);
+		rtl8xxxu_refresh_rate_mask(priv, signal, sta, false);
 	}
 
 out:
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 10/18] wifi: rtl8xxxu: Add sta_add() and sta_remove() callbacks
  2023-04-19 10:01 [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Martin Kaistra
                   ` (8 preceding siblings ...)
  2023-04-19 10:01 ` [PATCH v2 09/18] wifi: rtl8xxxu: Add parameter force to rtl8xxxu_refresh_rate_mask Martin Kaistra
@ 2023-04-19 10:01 ` Martin Kaistra
  2023-04-24  2:46   ` Ping-Ke Shih
  2023-04-19 10:01 ` [PATCH v2 11/18] wifi: rtl8xxxu: Put the macid in txdesc Martin Kaistra
                   ` (8 subsequent siblings)
  18 siblings, 1 reply; 36+ messages in thread
From: Martin Kaistra @ 2023-04-19 10:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: Jes Sorensen, Kalle Valo, Ping-Ke Shih, Bitterblue Smith,
	Sebastian Andrzej Siewior

In AP mode, sta_add() gets called when a new STA gets associated to
us. Call rtl8xxxu_refresh_rate_mask() to set a rate mask for the newly
connected STA (referenced by the macid) and then send a media connnect
report. Ignore the call to sta_add() in station mode.

Reserve one macid for broadcast/multicast packets in init.

Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
---
 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h  |  9 ++++
 .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 52 +++++++++++++++++++
 2 files changed, 61 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
index 93091068b3fd2..fb8ba97566c23 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
@@ -1730,6 +1730,7 @@ struct rtl8xxxu_cfo_tracking {
 };
 
 #define RTL8XXXU_HW_LED_CONTROL	2
+#define RTL8XXXU_MAX_MAC_ID_NUM	128
 #define RTL8XXXU_BC_MC_MACID	0
 
 struct rtl8xxxu_priv {
@@ -1865,6 +1866,14 @@ struct rtl8xxxu_priv {
 	bool led_registered;
 	char led_name[32];
 	struct led_classdev led_cdev;
+	DECLARE_BITMAP(mac_id_map, RTL8XXXU_MAX_MAC_ID_NUM);
+};
+
+struct rtl8xxxu_sta_info {
+	struct ieee80211_sta *sta;
+	struct ieee80211_vif *vif;
+
+	u8 macid;
 };
 
 struct rtl8xxxu_rx_urb {
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 19e115d10493a..d0c7d3a191f1a 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -3902,6 +3902,22 @@ void rtl8xxxu_init_burst(struct rtl8xxxu_priv *priv)
 	rtl8xxxu_write8(priv, REG_RSV_CTRL, val8);
 }
 
+static u8 rtl8xxxu_acquire_macid(struct rtl8xxxu_priv *priv)
+{
+	u8 macid;
+
+	macid = find_first_zero_bit(priv->mac_id_map, RTL8XXXU_MAX_MAC_ID_NUM);
+	if (macid < RTL8XXXU_MAX_MAC_ID_NUM)
+		set_bit(macid, priv->mac_id_map);
+
+	return macid;
+}
+
+static void rtl8xxxu_release_macid(struct rtl8xxxu_priv *priv, u8 macid)
+{
+	clear_bit(macid, priv->mac_id_map);
+}
+
 static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
 {
 	struct rtl8xxxu_priv *priv = hw->priv;
@@ -4371,6 +4387,8 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
 	if (priv->rtl_chip == RTL8188E)
 		rtl8188e_ra_info_init_all(&priv->ra_info);
 
+	set_bit(RTL8XXXU_BC_MC_MACID, priv->mac_id_map);
+
 exit:
 	return ret;
 }
@@ -7144,6 +7162,38 @@ static void rtl8xxxu_stop(struct ieee80211_hw *hw)
 	rtl8xxxu_free_tx_resources(priv);
 }
 
+static int rtl8xxxu_sta_add(struct ieee80211_hw *hw,
+			    struct ieee80211_vif *vif,
+			    struct ieee80211_sta *sta)
+{
+	struct rtl8xxxu_sta_info *sta_info = (struct rtl8xxxu_sta_info *)sta->drv_priv;
+	struct rtl8xxxu_priv *priv = hw->priv;
+
+	if (vif->type == NL80211_IFTYPE_AP) {
+		sta_info->macid = rtl8xxxu_acquire_macid(priv);
+		if (sta_info->macid >= RTL8XXXU_MAX_MAC_ID_NUM)
+			return -ENOSPC;
+
+		rtl8xxxu_refresh_rate_mask(priv, 0, sta, true);
+		priv->fops->report_connect(priv, sta_info->macid, H2C_MACID_ROLE_STA, true);
+	}
+
+	return 0;
+}
+
+static int rtl8xxxu_sta_remove(struct ieee80211_hw *hw,
+			       struct ieee80211_vif *vif,
+			       struct ieee80211_sta *sta)
+{
+	struct rtl8xxxu_sta_info *sta_info = (struct rtl8xxxu_sta_info *)sta->drv_priv;
+	struct rtl8xxxu_priv *priv = hw->priv;
+
+	if (vif->type == NL80211_IFTYPE_AP)
+		rtl8xxxu_release_macid(priv, sta_info->macid);
+
+	return 0;
+}
+
 static const struct ieee80211_ops rtl8xxxu_ops = {
 	.tx = rtl8xxxu_tx,
 	.wake_tx_queue = ieee80211_handle_wake_tx_queue,
@@ -7164,6 +7214,8 @@ static const struct ieee80211_ops rtl8xxxu_ops = {
 	.sta_statistics = rtl8xxxu_sta_statistics,
 	.get_antenna = rtl8xxxu_get_antenna,
 	.set_tim = rtl8xxxu_set_tim,
+	.sta_add = rtl8xxxu_sta_add,
+	.sta_remove = rtl8xxxu_sta_remove,
 };
 
 static int rtl8xxxu_parse_usb(struct rtl8xxxu_priv *priv,
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 11/18] wifi: rtl8xxxu: Put the macid in txdesc
  2023-04-19 10:01 [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Martin Kaistra
                   ` (9 preceding siblings ...)
  2023-04-19 10:01 ` [PATCH v2 10/18] wifi: rtl8xxxu: Add sta_add() and sta_remove() callbacks Martin Kaistra
@ 2023-04-19 10:01 ` Martin Kaistra
  2023-04-24  3:00   ` Ping-Ke Shih
  2023-04-19 10:01 ` [PATCH v2 12/18] wifi: rtl8xxxu: Add parameter macid to update_rate_mask Martin Kaistra
                   ` (7 subsequent siblings)
  18 siblings, 1 reply; 36+ messages in thread
From: Martin Kaistra @ 2023-04-19 10:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: Jes Sorensen, Kalle Valo, Ping-Ke Shih, Bitterblue Smith,
	Sebastian Andrzej Siewior

Add a parameter macid to fill_txdesc(), implement setting it for the
gen2 version.
This is used to tell the HW who the recipient of the packet is, so that
the appropriate data rate can be selected.

Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
---
 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h  |  8 +++---
 .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 28 +++++++++++++++----
 2 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
index fb8ba97566c23..88ce369d33808 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
@@ -1926,7 +1926,7 @@ struct rtl8xxxu_fileops {
 			     struct ieee80211_tx_info *tx_info,
 			     struct rtl8xxxu_txdesc32 *tx_desc, bool sgi,
 			     bool short_preamble, bool ampdu_enable,
-			     u32 rts_rate);
+			     u32 rts_rate, u8 macid);
 	void (*set_crystal_cap) (struct rtl8xxxu_priv *priv, u8 crystal_cap);
 	s8 (*cck_rssi) (struct rtl8xxxu_priv *priv, struct rtl8723au_phy_stats *phy_stats);
 	int (*led_classdev_brightness_set) (struct led_classdev *led_cdev,
@@ -2060,17 +2060,17 @@ void rtl8xxxu_fill_txdesc_v1(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
 			     struct ieee80211_tx_info *tx_info,
 			     struct rtl8xxxu_txdesc32 *tx_desc, bool sgi,
 			     bool short_preamble, bool ampdu_enable,
-			     u32 rts_rate);
+			     u32 rts_rate, u8 macid);
 void rtl8xxxu_fill_txdesc_v2(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
 			     struct ieee80211_tx_info *tx_info,
 			     struct rtl8xxxu_txdesc32 *tx_desc32, bool sgi,
 			     bool short_preamble, bool ampdu_enable,
-			     u32 rts_rate);
+			     u32 rts_rate, u8 macid);
 void rtl8xxxu_fill_txdesc_v3(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
 			     struct ieee80211_tx_info *tx_info,
 			     struct rtl8xxxu_txdesc32 *tx_desc32, bool sgi,
 			     bool short_preamble, bool ampdu_enable,
-			     u32 rts_rate);
+			     u32 rts_rate, u8 macid);
 void rtl8723bu_set_ps_tdma(struct rtl8xxxu_priv *priv,
 			   u8 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5);
 void rtl8723bu_phy_init_antenna_selection(struct rtl8xxxu_priv *priv);
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index d0c7d3a191f1a..4a41e1e3cdeaa 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -3918,6 +3918,18 @@ static void rtl8xxxu_release_macid(struct rtl8xxxu_priv *priv, u8 macid)
 	clear_bit(macid, priv->mac_id_map);
 }
 
+static inline u8 rtl8xxxu_get_macid(struct rtl8xxxu_priv *priv,
+				    struct ieee80211_sta *sta)
+{
+	struct rtl8xxxu_sta_info *sta_info;
+
+	if (!priv->vif || priv->vif->type == NL80211_IFTYPE_STATION || !sta)
+		return 0;
+
+	sta_info = (struct rtl8xxxu_sta_info *)sta->drv_priv;
+	return sta_info->macid;
+}
+
 static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
 {
 	struct rtl8xxxu_priv *priv = hw->priv;
@@ -5161,7 +5173,8 @@ void
 rtl8xxxu_fill_txdesc_v1(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
 			struct ieee80211_tx_info *tx_info,
 			struct rtl8xxxu_txdesc32 *tx_desc, bool sgi,
-			bool short_preamble, bool ampdu_enable, u32 rts_rate)
+			bool short_preamble, bool ampdu_enable, u32 rts_rate,
+			u8 macid)
 {
 	struct ieee80211_rate *tx_rate = ieee80211_get_tx_rate(hw, tx_info);
 	struct rtl8xxxu_priv *priv = hw->priv;
@@ -5233,7 +5246,8 @@ void
 rtl8xxxu_fill_txdesc_v2(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
 			struct ieee80211_tx_info *tx_info,
 			struct rtl8xxxu_txdesc32 *tx_desc32, bool sgi,
-			bool short_preamble, bool ampdu_enable, u32 rts_rate)
+			bool short_preamble, bool ampdu_enable, u32 rts_rate,
+			u8 macid)
 {
 	struct ieee80211_rate *tx_rate = ieee80211_get_tx_rate(hw, tx_info);
 	struct rtl8xxxu_priv *priv = hw->priv;
@@ -5257,6 +5271,8 @@ rtl8xxxu_fill_txdesc_v2(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
 		dev_info(dev, "%s: TX rate: %d, pkt size %u\n",
 			 __func__, rate, le16_to_cpu(tx_desc40->pkt_size));
 
+	tx_desc40->txdw1 |= cpu_to_le32(macid << TXDESC40_MACID_SHIFT);
+
 	seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));
 
 	tx_desc40->txdw4 = cpu_to_le32(rate);
@@ -5308,7 +5324,8 @@ void
 rtl8xxxu_fill_txdesc_v3(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
 			struct ieee80211_tx_info *tx_info,
 			struct rtl8xxxu_txdesc32 *tx_desc, bool sgi,
-			bool short_preamble, bool ampdu_enable, u32 rts_rate)
+			bool short_preamble, bool ampdu_enable, u32 rts_rate,
+			u8 macid)
 {
 	struct ieee80211_rate *tx_rate = ieee80211_get_tx_rate(hw, tx_info);
 	struct rtl8xxxu_priv *priv = hw->priv;
@@ -5407,6 +5424,7 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw,
 	u16 pktlen = skb->len;
 	u16 rate_flag = tx_info->control.rates[0].flags;
 	int tx_desc_size = priv->fops->tx_desc_size;
+	u8 macid;
 	int ret;
 	bool ampdu_enable, sgi = false, short_preamble = false;
 
@@ -5506,9 +5524,9 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw,
 	else
 		rts_rate = 0;
 
-
+	macid = rtl8xxxu_get_macid(priv, sta);
 	priv->fops->fill_txdesc(hw, hdr, tx_info, tx_desc, sgi, short_preamble,
-				ampdu_enable, rts_rate);
+				ampdu_enable, rts_rate, macid);
 
 	rtl8xxxu_calc_tx_desc_csum(tx_desc);
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 12/18] wifi: rtl8xxxu: Add parameter macid to update_rate_mask
  2023-04-19 10:01 [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Martin Kaistra
                   ` (10 preceding siblings ...)
  2023-04-19 10:01 ` [PATCH v2 11/18] wifi: rtl8xxxu: Put the macid in txdesc Martin Kaistra
@ 2023-04-19 10:01 ` Martin Kaistra
  2023-04-24  3:01   ` Ping-Ke Shih
  2023-04-19 10:01 ` [PATCH v2 13/18] wifi: rtl8xxxu: Enable hw seq for mgmt/non-QoS data frames Martin Kaistra
                   ` (6 subsequent siblings)
  18 siblings, 1 reply; 36+ messages in thread
From: Martin Kaistra @ 2023-04-19 10:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: Jes Sorensen, Kalle Valo, Ping-Ke Shih, Bitterblue Smith,
	Sebastian Andrzej Siewior

The HW maintains a rate_mask for each connection, referenced by the
macid. Add a parameter to update_rate_mask and add the macid to the
h2c call in the gen2 implementation.

Also extend refresh_rate_mask to get the macid from sta_info.

Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h    |  7 ++++---
 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c  |  3 ++-
 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c   | 13 +++++++++----
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
index 88ce369d33808..0610ab57f132d 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
@@ -1918,7 +1918,8 @@ struct rtl8xxxu_fileops {
 	void (*set_tx_power) (struct rtl8xxxu_priv *priv, int channel,
 			      bool ht40);
 	void (*update_rate_mask) (struct rtl8xxxu_priv *priv,
-				  u32 ramask, u8 rateid, int sgi, int txbw_40mhz);
+				  u32 ramask, u8 rateid, int sgi, int txbw_40mhz,
+				  u8 macid);
 	void (*report_connect) (struct rtl8xxxu_priv *priv,
 				u8 macid, u8 role, bool connect);
 	void (*report_rssi) (struct rtl8xxxu_priv *priv, u8 macid, u8 rssi);
@@ -2025,9 +2026,9 @@ void rtl8xxxu_gen2_config_channel(struct ieee80211_hw *hw);
 void rtl8xxxu_gen1_usb_quirks(struct rtl8xxxu_priv *priv);
 void rtl8xxxu_gen2_usb_quirks(struct rtl8xxxu_priv *priv);
 void rtl8xxxu_update_rate_mask(struct rtl8xxxu_priv *priv,
-			       u32 ramask, u8 rateid, int sgi, int txbw_40mhz);
+			       u32 ramask, u8 rateid, int sgi, int txbw_40mhz, u8 macid);
 void rtl8xxxu_gen2_update_rate_mask(struct rtl8xxxu_priv *priv,
-				    u32 ramask, u8 rateid, int sgi, int txbw_40mhz);
+				    u32 ramask, u8 rateid, int sgi, int txbw_40mhz, u8 macid);
 void rtl8xxxu_gen1_report_connect(struct rtl8xxxu_priv *priv,
 				  u8 macid, u8 role, bool connect);
 void rtl8xxxu_gen2_report_connect(struct rtl8xxxu_priv *priv,
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c
index af8436070ba77..3751fac3037dd 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c
@@ -1798,7 +1798,8 @@ static void rtl8188e_arfb_refresh(struct rtl8xxxu_ra_info *ra)
 
 static void
 rtl8188e_update_rate_mask(struct rtl8xxxu_priv *priv,
-			  u32 ramask, u8 rateid, int sgi, int txbw_40mhz)
+			  u32 ramask, u8 rateid, int sgi, int txbw_40mhz,
+			  u8 macid)
 {
 	struct rtl8xxxu_ra_info *ra = &priv->ra_info;
 
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 4a41e1e3cdeaa..2e02812a4a85a 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -4491,7 +4491,8 @@ static void rtl8xxxu_sw_scan_complete(struct ieee80211_hw *hw,
 }
 
 void rtl8xxxu_update_rate_mask(struct rtl8xxxu_priv *priv,
-			       u32 ramask, u8 rateid, int sgi, int txbw_40mhz)
+			       u32 ramask, u8 rateid, int sgi, int txbw_40mhz,
+			       u8 macid)
 {
 	struct h2c_cmd h2c;
 
@@ -4511,7 +4512,8 @@ void rtl8xxxu_update_rate_mask(struct rtl8xxxu_priv *priv,
 }
 
 void rtl8xxxu_gen2_update_rate_mask(struct rtl8xxxu_priv *priv,
-				    u32 ramask, u8 rateid, int sgi, int txbw_40mhz)
+				    u32 ramask, u8 rateid, int sgi, int txbw_40mhz,
+				    u8 macid)
 {
 	struct h2c_cmd h2c;
 	u8 bw;
@@ -4528,6 +4530,7 @@ void rtl8xxxu_gen2_update_rate_mask(struct rtl8xxxu_priv *priv,
 	h2c.b_macid_cfg.ramask1 = (ramask >> 8) & 0xff;
 	h2c.b_macid_cfg.ramask2 = (ramask >> 16) & 0xff;
 	h2c.b_macid_cfg.ramask3 = (ramask >> 24) & 0xff;
+	h2c.b_macid_cfg.macid = macid;
 
 	h2c.b_macid_cfg.data1 = rateid;
 	if (sgi)
@@ -4893,7 +4896,8 @@ rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 			priv->vif = vif;
 			priv->rssi_level = RTL8XXXU_RATR_STA_INIT;
 
-			priv->fops->update_rate_mask(priv, ramask, 0, sgi, bw == RATE_INFO_BW_40);
+			priv->fops->update_rate_mask(priv, ramask, 0, sgi,
+						     bw == RATE_INFO_BW_40, 0);
 
 			rtl8xxxu_write8(priv, REG_BCN_MAX_ERR, 0xff);
 
@@ -6805,6 +6809,7 @@ static void rtl8xxxu_refresh_rate_mask(struct rtl8xxxu_priv *priv,
 	u8 txbw_40mhz;
 	u8 snr, snr_thresh_high, snr_thresh_low;
 	u8 go_up_gap = 5;
+	u8 macid = rtl8xxxu_get_macid(priv, sta);
 
 	rssi_level = priv->rssi_level;
 	snr = rtl8xxxu_signal_to_snr(signal);
@@ -6924,7 +6929,7 @@ static void rtl8xxxu_refresh_rate_mask(struct rtl8xxxu_priv *priv,
 		}
 
 		priv->rssi_level = rssi_level;
-		priv->fops->update_rate_mask(priv, rate_bitmap, ratr_idx, sgi, txbw_40mhz);
+		priv->fops->update_rate_mask(priv, rate_bitmap, ratr_idx, sgi, txbw_40mhz, macid);
 	}
 }
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 13/18] wifi: rtl8xxxu: Enable hw seq for mgmt/non-QoS data frames
  2023-04-19 10:01 [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Martin Kaistra
                   ` (11 preceding siblings ...)
  2023-04-19 10:01 ` [PATCH v2 12/18] wifi: rtl8xxxu: Add parameter macid to update_rate_mask Martin Kaistra
@ 2023-04-19 10:01 ` Martin Kaistra
  2023-04-24  3:04   ` Ping-Ke Shih
  2023-04-19 10:01 ` [PATCH v2 14/18] wifi: rtl8xxxu: Clean up filter configuration Martin Kaistra
                   ` (5 subsequent siblings)
  18 siblings, 1 reply; 36+ messages in thread
From: Martin Kaistra @ 2023-04-19 10:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: Jes Sorensen, Kalle Valo, Ping-Ke Shih, Bitterblue Smith,
	Sebastian Andrzej Siewior

Beacon frames are generated by the HW and therefore contain a HW
generated seq number. Enable HW sequence number for other frames to
match that.
mac80211 will tell us via IEEE80211_TX_CTL_ASSIGN_SEQ when that is
necessary.

Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 2e02812a4a85a..cff465c7cda30 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -5300,6 +5300,9 @@ rtl8xxxu_fill_txdesc_v2(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
 		tx_desc40->txdw4 |= cpu_to_le32(TXDESC40_RETRY_LIMIT_ENABLE);
 	}
 
+	if (tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ)
+		tx_desc40->txdw8 |= cpu_to_le32(TXDESC40_HW_SEQ_ENABLE);
+
 	if (short_preamble)
 		tx_desc40->txdw5 |= cpu_to_le32(TXDESC40_SHORT_PREAMBLE);
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 14/18] wifi: rtl8xxxu: Clean up filter configuration
  2023-04-19 10:01 [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Martin Kaistra
                   ` (12 preceding siblings ...)
  2023-04-19 10:01 ` [PATCH v2 13/18] wifi: rtl8xxxu: Enable hw seq for mgmt/non-QoS data frames Martin Kaistra
@ 2023-04-19 10:01 ` Martin Kaistra
  2023-04-24  3:05   ` Ping-Ke Shih
  2023-04-19 10:01 ` [PATCH v2 15/18] wifi: rtl8xxxu: Remove usage of ieee80211_get_tx_rate() Martin Kaistra
                   ` (4 subsequent siblings)
  18 siblings, 1 reply; 36+ messages in thread
From: Martin Kaistra @ 2023-04-19 10:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: Jes Sorensen, Kalle Valo, Ping-Ke Shih, Bitterblue Smith,
	Sebastian Andrzej Siewior

When RCR_CHECK_BSSID_MATCH is set in AP mode, we don't receive any data
frames. Rearrange RCR bits to filter flags to match other realtek drivers
and remove RCR_CHECK_BSSID_MATCH in AP mode.

Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
---
 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c  | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index cff465c7cda30..f5b6ff3351e5a 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -6619,22 +6619,22 @@ static void rtl8xxxu_configure_filter(struct ieee80211_hw *hw,
 	 */
 
 	if (*total_flags & FIF_BCN_PRBRESP_PROMISC)
-		rcr &= ~RCR_CHECK_BSSID_BEACON;
+		rcr &= ~(RCR_CHECK_BSSID_BEACON | RCR_CHECK_BSSID_MATCH);
 	else
-		rcr |= RCR_CHECK_BSSID_BEACON;
+		rcr |= RCR_CHECK_BSSID_BEACON | RCR_CHECK_BSSID_MATCH;
+
+	if (priv->vif && priv->vif->type == NL80211_IFTYPE_AP)
+		rcr &= ~RCR_CHECK_BSSID_MATCH;
 
 	if (*total_flags & FIF_CONTROL)
 		rcr |= RCR_ACCEPT_CTRL_FRAME;
 	else
 		rcr &= ~RCR_ACCEPT_CTRL_FRAME;
 
-	if (*total_flags & FIF_OTHER_BSS) {
+	if (*total_flags & FIF_OTHER_BSS)
 		rcr |= RCR_ACCEPT_AP;
-		rcr &= ~RCR_CHECK_BSSID_MATCH;
-	} else {
+	else
 		rcr &= ~RCR_ACCEPT_AP;
-		rcr |= RCR_CHECK_BSSID_MATCH;
-	}
 
 	if (*total_flags & FIF_PSPOLL)
 		rcr |= RCR_ACCEPT_PM;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 15/18] wifi: rtl8xxxu: Remove usage of ieee80211_get_tx_rate()
  2023-04-19 10:01 [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Martin Kaistra
                   ` (13 preceding siblings ...)
  2023-04-19 10:01 ` [PATCH v2 14/18] wifi: rtl8xxxu: Clean up filter configuration Martin Kaistra
@ 2023-04-19 10:01 ` Martin Kaistra
  2023-04-24  3:07   ` Ping-Ke Shih
  2023-04-19 10:01 ` [PATCH v2 16/18] wifi: rtl8xxxu: Remove usage of tx_info->control.rates[0].flags Martin Kaistra
                   ` (3 subsequent siblings)
  18 siblings, 1 reply; 36+ messages in thread
From: Martin Kaistra @ 2023-04-19 10:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: Jes Sorensen, Kalle Valo, Ping-Ke Shih, Bitterblue Smith,
	Sebastian Andrzej Siewior

As this driver uses HAS_RATE_CONTROL, tx_rates will not be provided by
mac80211.

For some frames c->control.rates[0].idx is negative, which means
ieee80211_get_tx_rate() will print a warning and return NULL.

Only management frames have USE_DRIVER_RATE set, so for all others the
rate info of txdesc is ignored anyway.

Remove call to ieee80211_get_tx_rate() and send management frames with
1M (rate info = 0).

Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
---
 .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 27 +++----------------
 1 file changed, 3 insertions(+), 24 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index f5b6ff3351e5a..b60f90ea5187b 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -5180,21 +5180,14 @@ rtl8xxxu_fill_txdesc_v1(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
 			bool short_preamble, bool ampdu_enable, u32 rts_rate,
 			u8 macid)
 {
-	struct ieee80211_rate *tx_rate = ieee80211_get_tx_rate(hw, tx_info);
 	struct rtl8xxxu_priv *priv = hw->priv;
 	struct device *dev = &priv->udev->dev;
 	u8 *qc = ieee80211_get_qos_ctl(hdr);
 	u8 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
-	u32 rate;
+	u32 rate = 0;
 	u16 rate_flags = tx_info->control.rates[0].flags;
 	u16 seq_number;
 
-	if (rate_flags & IEEE80211_TX_RC_MCS &&
-	    !ieee80211_is_mgmt(hdr->frame_control))
-		rate = tx_info->control.rates[0].idx + DESC_RATE_MCS0;
-	else
-		rate = tx_rate->hw_value;
-
 	if (rtl8xxxu_debug & RTL8XXXU_DEBUG_TX)
 		dev_info(dev, "%s: TX rate: %d, pkt size %u\n",
 			 __func__, rate, le16_to_cpu(tx_desc->pkt_size));
@@ -5253,24 +5246,17 @@ rtl8xxxu_fill_txdesc_v2(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
 			bool short_preamble, bool ampdu_enable, u32 rts_rate,
 			u8 macid)
 {
-	struct ieee80211_rate *tx_rate = ieee80211_get_tx_rate(hw, tx_info);
 	struct rtl8xxxu_priv *priv = hw->priv;
 	struct device *dev = &priv->udev->dev;
 	struct rtl8xxxu_txdesc40 *tx_desc40;
 	u8 *qc = ieee80211_get_qos_ctl(hdr);
 	u8 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
-	u32 rate;
+	u32 rate = 0;
 	u16 rate_flags = tx_info->control.rates[0].flags;
 	u16 seq_number;
 
 	tx_desc40 = (struct rtl8xxxu_txdesc40 *)tx_desc32;
 
-	if (rate_flags & IEEE80211_TX_RC_MCS &&
-	    !ieee80211_is_mgmt(hdr->frame_control))
-		rate = tx_info->control.rates[0].idx + DESC_RATE_MCS0;
-	else
-		rate = tx_rate->hw_value;
-
 	if (rtl8xxxu_debug & RTL8XXXU_DEBUG_TX)
 		dev_info(dev, "%s: TX rate: %d, pkt size %u\n",
 			 __func__, rate, le16_to_cpu(tx_desc40->pkt_size));
@@ -5334,22 +5320,15 @@ rtl8xxxu_fill_txdesc_v3(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
 			bool short_preamble, bool ampdu_enable, u32 rts_rate,
 			u8 macid)
 {
-	struct ieee80211_rate *tx_rate = ieee80211_get_tx_rate(hw, tx_info);
 	struct rtl8xxxu_priv *priv = hw->priv;
 	struct device *dev = &priv->udev->dev;
 	struct rtl8xxxu_ra_info *ra = &priv->ra_info;
 	u8 *qc = ieee80211_get_qos_ctl(hdr);
 	u8 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
-	u32 rate;
+	u32 rate = 0;
 	u16 rate_flags = tx_info->control.rates[0].flags;
 	u16 seq_number;
 
-	if (rate_flags & IEEE80211_TX_RC_MCS &&
-	    !ieee80211_is_mgmt(hdr->frame_control))
-		rate = tx_info->control.rates[0].idx + DESC_RATE_MCS0;
-	else
-		rate = tx_rate->hw_value;
-
 	seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));
 
 	if (ieee80211_is_data(hdr->frame_control)) {
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 16/18] wifi: rtl8xxxu: Remove usage of tx_info->control.rates[0].flags
  2023-04-19 10:01 [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Martin Kaistra
                   ` (14 preceding siblings ...)
  2023-04-19 10:01 ` [PATCH v2 15/18] wifi: rtl8xxxu: Remove usage of ieee80211_get_tx_rate() Martin Kaistra
@ 2023-04-19 10:01 ` Martin Kaistra
  2023-04-24  3:10   ` Ping-Ke Shih
  2023-04-19 10:01 ` [PATCH v2 17/18] wifi: rtl8xxxu: Declare AP mode support for 8188f Martin Kaistra
                   ` (2 subsequent siblings)
  18 siblings, 1 reply; 36+ messages in thread
From: Martin Kaistra @ 2023-04-19 10:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: Jes Sorensen, Kalle Valo, Ping-Ke Shih, Bitterblue Smith,
	Sebastian Andrzej Siewior

As this driver uses HAS_RATE_CONTROL, rate_flags will not be provided by
mac80211.

Stop using tx_info->control.rates[0].flags and ieee80211_get_rts_cts_rate()
and use rts_threshold and bss_conf.use_cts_prot instead to determine
when to use RTS and CTS.

Send RTS with 24M rate like the vendor drivers. Also set this RTS rate
for ampdu_enable = true, because we also enable RTS for these frames.

Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
---
 .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 40 +++++++++----------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index b60f90ea5187b..7ff6f4e6a0ff5 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -5185,7 +5185,6 @@ rtl8xxxu_fill_txdesc_v1(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
 	u8 *qc = ieee80211_get_qos_ctl(hdr);
 	u8 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
 	u32 rate = 0;
-	u16 rate_flags = tx_info->control.rates[0].flags;
 	u16 seq_number;
 
 	if (rtl8xxxu_debug & RTL8XXXU_DEBUG_TX)
@@ -5226,10 +5225,10 @@ rtl8xxxu_fill_txdesc_v1(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
 	 * rts_rate is zero if RTS/CTS or CTS to SELF are not enabled
 	 */
 	tx_desc->txdw4 |= cpu_to_le32(rts_rate << TXDESC32_RTS_RATE_SHIFT);
-	if (ampdu_enable || (rate_flags & IEEE80211_TX_RC_USE_RTS_CTS)) {
+	if (ampdu_enable || tx_info->control.use_rts) {
 		tx_desc->txdw4 |= cpu_to_le32(TXDESC32_RTS_CTS_ENABLE);
 		tx_desc->txdw4 |= cpu_to_le32(TXDESC32_HW_RTS_ENABLE);
-	} else if (rate_flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
+	} else if (tx_info->control.use_cts_prot) {
 		tx_desc->txdw4 |= cpu_to_le32(TXDESC32_CTS_SELF_ENABLE);
 		tx_desc->txdw4 |= cpu_to_le32(TXDESC32_HW_RTS_ENABLE);
 	}
@@ -5252,7 +5251,6 @@ rtl8xxxu_fill_txdesc_v2(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
 	u8 *qc = ieee80211_get_qos_ctl(hdr);
 	u8 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
 	u32 rate = 0;
-	u16 rate_flags = tx_info->control.rates[0].flags;
 	u16 seq_number;
 
 	tx_desc40 = (struct rtl8xxxu_txdesc40 *)tx_desc32;
@@ -5293,13 +5291,14 @@ rtl8xxxu_fill_txdesc_v2(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
 		tx_desc40->txdw5 |= cpu_to_le32(TXDESC40_SHORT_PREAMBLE);
 
 	tx_desc40->txdw4 |= cpu_to_le32(rts_rate << TXDESC40_RTS_RATE_SHIFT);
+
 	/*
 	 * rts_rate is zero if RTS/CTS or CTS to SELF are not enabled
 	 */
-	if (ampdu_enable || (rate_flags & IEEE80211_TX_RC_USE_RTS_CTS)) {
+	if (ampdu_enable || tx_info->control.use_rts) {
 		tx_desc40->txdw3 |= cpu_to_le32(TXDESC40_RTS_CTS_ENABLE);
 		tx_desc40->txdw3 |= cpu_to_le32(TXDESC40_HW_RTS_ENABLE);
-	} else if (rate_flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
+	} else if (tx_info->control.use_cts_prot) {
 		/*
 		 * For some reason the vendor driver doesn't set
 		 * TXDESC40_HW_RTS_ENABLE for CTS to SELF
@@ -5326,7 +5325,6 @@ rtl8xxxu_fill_txdesc_v3(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
 	u8 *qc = ieee80211_get_qos_ctl(hdr);
 	u8 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
 	u32 rate = 0;
-	u16 rate_flags = tx_info->control.rates[0].flags;
 	u16 seq_number;
 
 	seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));
@@ -5381,10 +5379,10 @@ rtl8xxxu_fill_txdesc_v3(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
 	 * rts_rate is zero if RTS/CTS or CTS to SELF are not enabled
 	 */
 	tx_desc->txdw4 |= cpu_to_le32(rts_rate << TXDESC32_RTS_RATE_SHIFT);
-	if (ampdu_enable || (rate_flags & IEEE80211_TX_RC_USE_RTS_CTS)) {
+	if (ampdu_enable || tx_info->control.use_rts) {
 		tx_desc->txdw4 |= cpu_to_le32(TXDESC32_RTS_CTS_ENABLE);
 		tx_desc->txdw4 |= cpu_to_le32(TXDESC32_HW_RTS_ENABLE);
-	} else if (rate_flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
+	} else if (tx_info->control.use_cts_prot) {
 		tx_desc->txdw4 |= cpu_to_le32(TXDESC32_CTS_SELF_ENABLE);
 		tx_desc->txdw4 |= cpu_to_le32(TXDESC32_HW_RTS_ENABLE);
 	}
@@ -5408,7 +5406,6 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw,
 	struct device *dev = &priv->udev->dev;
 	u32 queue, rts_rate;
 	u16 pktlen = skb->len;
-	u16 rate_flag = tx_info->control.rates[0].flags;
 	int tx_desc_size = priv->fops->tx_desc_size;
 	u8 macid;
 	int ret;
@@ -5493,20 +5490,23 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw,
 		}
 	}
 
-	if (rate_flag & IEEE80211_TX_RC_SHORT_GI ||
-	    (ieee80211_is_data_qos(hdr->frame_control) &&
-	     sta && sta->deflink.ht_cap.cap &
-	     (IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_SGI_20)))
+	if (ieee80211_is_data_qos(hdr->frame_control) &&
+	    sta && sta->deflink.ht_cap.cap &
+	    (IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_SGI_20))
 		sgi = true;
 
-	if (rate_flag & IEEE80211_TX_RC_USE_SHORT_PREAMBLE ||
-	    (sta && vif && vif->bss_conf.use_short_preamble))
+	if (sta && vif && vif->bss_conf.use_short_preamble)
 		short_preamble = true;
 
-	if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS)
-		rts_rate = ieee80211_get_rts_cts_rate(hw, tx_info)->hw_value;
-	else if (rate_flag & IEEE80211_TX_RC_USE_CTS_PROTECT)
-		rts_rate = ieee80211_get_rts_cts_rate(hw, tx_info)->hw_value;
+	if (skb->len > hw->wiphy->rts_threshold)
+		tx_info->control.use_rts = true;
+
+	if (sta && vif && vif->bss_conf.use_cts_prot)
+		tx_info->control.use_cts_prot = true;
+
+	if (ampdu_enable || tx_info->control.use_rts ||
+	    tx_info->control.use_cts_prot)
+		rts_rate = DESC_RATE_24M;
 	else
 		rts_rate = 0;
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 17/18] wifi: rtl8xxxu: Declare AP mode support for 8188f
  2023-04-19 10:01 [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Martin Kaistra
                   ` (15 preceding siblings ...)
  2023-04-19 10:01 ` [PATCH v2 16/18] wifi: rtl8xxxu: Remove usage of tx_info->control.rates[0].flags Martin Kaistra
@ 2023-04-19 10:01 ` Martin Kaistra
  2023-04-19 10:01 ` [PATCH v2 18/18] wifi: rtl8xxxu: Set maximum number of supported stations Martin Kaistra
  2023-04-19 20:35 ` [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Bitterblue Smith
  18 siblings, 0 replies; 36+ messages in thread
From: Martin Kaistra @ 2023-04-19 10:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: Jes Sorensen, Kalle Valo, Ping-Ke Shih, Bitterblue Smith,
	Sebastian Andrzej Siewior

Everything is in place now for AP mode, we can tell the system that we
support it. Put the feature behind a flag in priv->fops, because it is
not (yet) implemented for all chips.

Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h       | 1 +
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c | 1 +
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c  | 2 ++
 3 files changed, 4 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
index 0610ab57f132d..64e823f216967 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
@@ -1945,6 +1945,7 @@ struct rtl8xxxu_fileops {
 	u8 init_reg_hmtfr:1;
 	u8 ampdu_max_time;
 	u8 ustime_tsf_edca;
+	u8 supports_ap:1;
 	u32 adda_1t_init;
 	u32 adda_1t_path_on;
 	u32 adda_2t_path_on_a;
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
index dfb250adb1689..7dc2fd8aa5317 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
@@ -1751,6 +1751,7 @@ struct rtl8xxxu_fileops rtl8188fu_fops = {
 	.init_reg_hmtfr = 1,
 	.ampdu_max_time = 0x70,
 	.ustime_tsf_edca = 0x28,
+	.supports_ap = 1,
 	.adda_1t_init = 0x03c00014,
 	.adda_1t_path_on = 0x03c00014,
 	.trxff_boundary = 0x3f7f,
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 7ff6f4e6a0ff5..bf471c3f98b86 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -7465,6 +7465,8 @@ static int rtl8xxxu_probe(struct usb_interface *interface,
 	hw->wiphy->max_scan_ssids = 1;
 	hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN;
 	hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
+	if (priv->fops->supports_ap)
+		hw->wiphy->interface_modes |= BIT(NL80211_IFTYPE_AP);
 	hw->queues = 4;
 
 	sband = &rtl8xxxu_supported_band;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 18/18] wifi: rtl8xxxu: Set maximum number of supported stations
  2023-04-19 10:01 [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Martin Kaistra
                   ` (16 preceding siblings ...)
  2023-04-19 10:01 ` [PATCH v2 17/18] wifi: rtl8xxxu: Declare AP mode support for 8188f Martin Kaistra
@ 2023-04-19 10:01 ` Martin Kaistra
  2023-04-24  3:12   ` Ping-Ke Shih
  2023-04-24 20:16   ` Bitterblue Smith
  2023-04-19 20:35 ` [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Bitterblue Smith
  18 siblings, 2 replies; 36+ messages in thread
From: Martin Kaistra @ 2023-04-19 10:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: Jes Sorensen, Kalle Valo, Ping-Ke Shih, Bitterblue Smith,
	Sebastian Andrzej Siewior

Set maximum number of associated stations supported in AP mode. For
8188f, the maximum number of supported macids is 16, reserve one for
broadcast/multicast frames.

Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h       | 1 +
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c | 1 +
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c  | 2 ++
 3 files changed, 4 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
index 64e823f216967..e996168d0bfd1 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
@@ -1946,6 +1946,7 @@ struct rtl8xxxu_fileops {
 	u8 ampdu_max_time;
 	u8 ustime_tsf_edca;
 	u8 supports_ap:1;
+	u16 max_sta_num;
 	u32 adda_1t_init;
 	u32 adda_1t_path_on;
 	u32 adda_2t_path_on_a;
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
index 7dc2fd8aa5317..085721c734ae2 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
@@ -1752,6 +1752,7 @@ struct rtl8xxxu_fileops rtl8188fu_fops = {
 	.ampdu_max_time = 0x70,
 	.ustime_tsf_edca = 0x28,
 	.supports_ap = 1,
+	.max_sta_num = 16,
 	.adda_1t_init = 0x03c00014,
 	.adda_1t_path_on = 0x03c00014,
 	.trxff_boundary = 0x3f7f,
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index bf471c3f98b86..6d0c775244274 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -7464,6 +7464,8 @@ static int rtl8xxxu_probe(struct usb_interface *interface,
 
 	hw->wiphy->max_scan_ssids = 1;
 	hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN;
+	if (priv->fops->max_sta_num)
+		hw->wiphy->max_ap_assoc_sta = priv->fops->max_sta_num - 1;
 	hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
 	if (priv->fops->supports_ap)
 		hw->wiphy->interface_modes |= BIT(NL80211_IFTYPE_AP);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f
  2023-04-19 10:01 [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Martin Kaistra
                   ` (17 preceding siblings ...)
  2023-04-19 10:01 ` [PATCH v2 18/18] wifi: rtl8xxxu: Set maximum number of supported stations Martin Kaistra
@ 2023-04-19 20:35 ` Bitterblue Smith
  2023-04-20  7:44   ` Martin Kaistra
  18 siblings, 1 reply; 36+ messages in thread
From: Bitterblue Smith @ 2023-04-19 20:35 UTC (permalink / raw)
  To: Martin Kaistra, linux-wireless
  Cc: Jes Sorensen, Kalle Valo, Ping-Ke Shih, Sebastian Andrzej Siewior

On 19/04/2023 13:01, Martin Kaistra wrote:
> This series intends to bring AP mode support to the rtl8xxxu driver,
> more specifically for the 8188f, because this is the HW I have.
> The work is based on the vendor driver as I do not have access to
> datasheets.
> 
> Also while doing some measurements with iperf3 to compare with the
> vendor driver, I saw, that TCP traffic from AP to STA is slower than in
> the vendor driver. For UDP it looks fine. I hope I can get some help to
> fix this.
> 
> * vendor driver:
> 
>   without 802.11n:
>     UDP (AP -> STA): 27 Mbits/sec
>     UDP (STA -> AP): 33 Mbits/sec
>     TCP (AP -> STA): 24 Mbits/sec
>     TCP (STA -> AP): 26 Mbits/sec
> 
>   with 802.11n:
>     UDP (AP -> STA): 51 Mbits/sec
>     UDP (STA -> AP): 35 Mbits/sec
>     TCP (AP -> STA): 40 Mbits/sec
>     TCP (STA -> AP): 36 Mbits/sec
> 
> * rtl8xxxu:
> 
>   without 802.11n:
>     UDP (AP -> STA): 25 Mbits/sec
>     UDP (STA -> AP): 31 Mbits/sec
>     TCP (AP -> STA):  3 Mbits/sec !
>     TCP (STA -> AP): 25 Mbits/sec
> 
>   with 802.11n:
>     UDP (AP -> STA): 41 Mbits/sec
>     UDP (STA -> AP): 36 Mbits/sec
>     TCP (AP -> STA):  3 Mbits/sec !
>     TCP (STA -> AP): 32 Mbits/sec
> 
> Thanks,
>   Martin
> 
> v2 changelog:
> - dropped RFC prefix
> - rebase patches to newest wireless-next
> - add some R-bs
> - new patch: "Add parameter force to rtl8xxxu_refresh_rate_mask"
> - new patch: "Remove usage of ieee80211_get_tx_rate()"
> - new patch: "Remove usage of tx_info->control.rates[0].flags"
> - new patch: "Set maximum number of supported stations"
> - add macro for broadcast/multicast frames macid
> - add more explanation about beacon queue in commit message of patch 2
> - add macros for bit definitions for beacon functions
> - implement enable_beacon = false case
> - fix beacon valid loop so that error condition is actually reached
> - add more explanation about setting mac address register in add_interface
>   in commit message of patch 6
> - rename role macros for connect report h2c
> - use bitmap for assigning macids
> - add helper function for looking up assigned macids
> - move patch 7 so we can use rtl8xxxu_get_macid helper
> - add sta_remove callback
> - do things in sta_add only in AP mode
> - use IEEE80211_TX_CTL_ASSIGN_SEQ flag to determine when to use HW sequence
>   numbers
> - add priv->vif null pointer check in configure_filter, rework setting
>   BSSID_BEACON/BSSID_MATCH in RCR
> 
> v1: https://lore.kernel.org/linux-wireless/20230322171905.492855-1-martin.kaistra@linutronix.de/
> 

The system didn't freeze with v2!

Also the download speed I got on the phone at speedtest.net
was around 35 megabits/second, which is normal. Did you test
v2 with iperf3?

I saw a few of these in the journal:

usb 1-2: rtl8xxxu_send_beacon_frame: Failed to read beacon valid bit

I'm not sure what caused that.

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f
  2023-04-19 20:35 ` [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Bitterblue Smith
@ 2023-04-20  7:44   ` Martin Kaistra
  0 siblings, 0 replies; 36+ messages in thread
From: Martin Kaistra @ 2023-04-20  7:44 UTC (permalink / raw)
  To: Bitterblue Smith, linux-wireless
  Cc: Jes Sorensen, Kalle Valo, Ping-Ke Shih, Sebastian Andrzej Siewior

Am 19.04.23 um 22:35 schrieb Bitterblue Smith:
> On 19/04/2023 13:01, Martin Kaistra wrote:
>> This series intends to bring AP mode support to the rtl8xxxu driver,
>> more specifically for the 8188f, because this is the HW I have.
>> The work is based on the vendor driver as I do not have access to
>> datasheets.
>>
>> Also while doing some measurements with iperf3 to compare with the
>> vendor driver, I saw, that TCP traffic from AP to STA is slower than in
>> the vendor driver. For UDP it looks fine. I hope I can get some help to
>> fix this.
>>
>> * vendor driver:
>>
>>    without 802.11n:
>>      UDP (AP -> STA): 27 Mbits/sec
>>      UDP (STA -> AP): 33 Mbits/sec
>>      TCP (AP -> STA): 24 Mbits/sec
>>      TCP (STA -> AP): 26 Mbits/sec
>>
>>    with 802.11n:
>>      UDP (AP -> STA): 51 Mbits/sec
>>      UDP (STA -> AP): 35 Mbits/sec
>>      TCP (AP -> STA): 40 Mbits/sec
>>      TCP (STA -> AP): 36 Mbits/sec
>>
>> * rtl8xxxu:
>>
>>    without 802.11n:
>>      UDP (AP -> STA): 25 Mbits/sec
>>      UDP (STA -> AP): 31 Mbits/sec
>>      TCP (AP -> STA):  3 Mbits/sec !
>>      TCP (STA -> AP): 25 Mbits/sec
>>
>>    with 802.11n:
>>      UDP (AP -> STA): 41 Mbits/sec
>>      UDP (STA -> AP): 36 Mbits/sec
>>      TCP (AP -> STA):  3 Mbits/sec !
>>      TCP (STA -> AP): 32 Mbits/sec
>>
>> Thanks,
>>    Martin
>>
>> v2 changelog:
>> - dropped RFC prefix
>> - rebase patches to newest wireless-next
>> - add some R-bs
>> - new patch: "Add parameter force to rtl8xxxu_refresh_rate_mask"
>> - new patch: "Remove usage of ieee80211_get_tx_rate()"
>> - new patch: "Remove usage of tx_info->control.rates[0].flags"
>> - new patch: "Set maximum number of supported stations"
>> - add macro for broadcast/multicast frames macid
>> - add more explanation about beacon queue in commit message of patch 2
>> - add macros for bit definitions for beacon functions
>> - implement enable_beacon = false case
>> - fix beacon valid loop so that error condition is actually reached
>> - add more explanation about setting mac address register in add_interface
>>    in commit message of patch 6
>> - rename role macros for connect report h2c
>> - use bitmap for assigning macids
>> - add helper function for looking up assigned macids
>> - move patch 7 so we can use rtl8xxxu_get_macid helper
>> - add sta_remove callback
>> - do things in sta_add only in AP mode
>> - use IEEE80211_TX_CTL_ASSIGN_SEQ flag to determine when to use HW sequence
>>    numbers
>> - add priv->vif null pointer check in configure_filter, rework setting
>>    BSSID_BEACON/BSSID_MATCH in RCR
>>
>> v1: https://lore.kernel.org/linux-wireless/20230322171905.492855-1-martin.kaistra@linutronix.de/
>>
> 
> The system didn't freeze with v2!
> 
> Also the download speed I got on the phone at speedtest.net
> was around 35 megabits/second, which is normal. Did you test
> v2 with iperf3?

Yes, I can still see a difference between rtl8xxxu and the vendor driver for TCP:


vendor driver (8188fu):

» iperf3 -B 192.168.0.11 -c 192.168.0.35
Connecting to host 192.168.0.35, port 5201
[  5] local 192.168.0.11 port 52125 connected to 192.168.0.35 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  5.01 MBytes  42.0 Mbits/sec    0    174 KBytes
[  5]   1.00-2.00   sec  5.78 MBytes  48.5 Mbits/sec    0    185 KBytes
[  5]   2.00-3.00   sec  5.53 MBytes  46.4 Mbits/sec    0    197 KBytes
[  5]   3.00-4.00   sec  5.65 MBytes  47.4 Mbits/sec    0    208 KBytes
[  5]   4.00-5.00   sec  6.09 MBytes  51.1 Mbits/sec    0    219 KBytes
[  5]   5.00-6.00   sec  5.53 MBytes  46.4 Mbits/sec    0    219 KBytes
[  5]   6.00-7.00   sec  5.84 MBytes  49.0 Mbits/sec    0    219 KBytes
[  5]   7.00-8.00   sec  5.72 MBytes  48.0 Mbits/sec    0    291 KBytes
[  5]   8.00-9.00   sec  6.15 MBytes  51.6 Mbits/sec    0    291 KBytes
[  5]   9.00-10.00  sec  5.59 MBytes  46.9 Mbits/sec    0    291 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  56.9 MBytes  47.7 Mbits/sec    0             sender
[  5]   0.00-10.06  sec  55.6 MBytes  46.3 Mbits/sec                  receiver

iperf Done.

» iperf3 -u -B 192.168.0.11 -c 192.168.0.35 --bitrate 60M
Connecting to host 192.168.0.35, port 5201
[  5] local 192.168.0.11 port 38501 connected to 192.168.0.35 port 5201
[ ID] Interval           Transfer     Bitrate         Total Datagrams
[  5]   0.00-1.00   sec  6.05 MBytes  50.7 Mbits/sec  4380
[  5]   1.00-2.00   sec  6.09 MBytes  51.0 Mbits/sec  4407
[  5]   2.00-3.00   sec  6.09 MBytes  51.1 Mbits/sec  4407
[  5]   3.00-4.00   sec  5.94 MBytes  49.8 Mbits/sec  4303
[  5]   4.00-5.00   sec  5.96 MBytes  50.0 Mbits/sec  4316
[  5]   5.00-6.00   sec  6.23 MBytes  52.3 Mbits/sec  4511
[  5]   6.00-7.00   sec  6.25 MBytes  52.4 Mbits/sec  4524
[  5]   7.00-8.00   sec  5.87 MBytes  49.2 Mbits/sec  4251
[  5]   8.00-9.00   sec  6.12 MBytes  51.4 Mbits/sec  4433
[  5]   9.00-10.00  sec  6.25 MBytes  52.4 Mbits/sec  4524
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Jitter    Lost/Total Datagrams
[  5]   0.00-10.00  sec  60.8 MBytes  51.0 Mbits/sec  0.000 ms  0/44056 (0%)  sender
[  5]   0.00-10.07  sec  60.8 MBytes  50.7 Mbits/sec  0.345 ms  0/44052 (0%)  receiver

iperf Done.


rtl8xxxu:

» iperf3 -B 192.168.0.11 -c 192.168.0.35
Connecting to host 192.168.0.35, port 5201
[  5] local 192.168.0.11 port 35887 connected to 192.168.0.35 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  1.77 MBytes  14.8 Mbits/sec    2   1.41 KBytes
[  5]   1.00-2.00   sec   509 KBytes  4.17 Mbits/sec    0    242 KBytes
[  5]   2.00-3.00   sec  0.00 Bytes  0.00 bits/sec    0    242 KBytes
[  5]   3.00-4.00   sec   509 KBytes  4.17 Mbits/sec    1    246 KBytes
[  5]   4.00-5.00   sec  0.00 Bytes  0.00 bits/sec    0    246 KBytes
[  5]   5.00-6.00   sec  0.00 Bytes  0.00 bits/sec    0    246 KBytes
[  5]   6.00-7.00   sec  0.00 Bytes  0.00 bits/sec    0    246 KBytes
[  5]   7.00-8.00   sec  0.00 Bytes  0.00 bits/sec    0    246 KBytes
[  5]   8.00-9.00   sec  0.00 Bytes  0.00 bits/sec    0    246 KBytes
[  5]   9.00-10.00  sec   509 KBytes  4.17 Mbits/sec    0    246 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  3.26 MBytes  2.73 Mbits/sec    3             sender
[  5]   0.00-10.04  sec  1.98 MBytes  1.65 Mbits/sec                  receiver

iperf Done.

» iperf3 -u -B 192.168.0.11 -c 192.168.0.35 --bitrate 60M
Connecting to host 192.168.0.35, port 5201
[  5] local 192.168.0.11 port 39467 connected to 192.168.0.35 port 5201
[ ID] Interval           Transfer     Bitrate         Total Datagrams
[  5]   0.00-1.00   sec  5.77 MBytes  48.4 Mbits/sec  4178
[  5]   1.00-2.00   sec  5.62 MBytes  47.1 Mbits/sec  4067
[  5]   2.00-3.00   sec  5.51 MBytes  46.2 Mbits/sec  3991
[  5]   3.00-4.00   sec  5.38 MBytes  45.1 Mbits/sec  3895
[  5]   4.00-5.00   sec  5.51 MBytes  46.2 Mbits/sec  3990
[  5]   5.00-6.00   sec  5.51 MBytes  46.2 Mbits/sec  3990
[  5]   6.00-7.00   sec  5.67 MBytes  47.6 Mbits/sec  4108
[  5]   7.00-8.00   sec  5.68 MBytes  47.6 Mbits/sec  4112
[  5]   8.00-9.00   sec  5.63 MBytes  47.3 Mbits/sec  4080
[  5]   9.00-10.00  sec  5.61 MBytes  47.1 Mbits/sec  4064
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Jitter    Lost/Total Datagrams
[  5]   0.00-10.00  sec  55.9 MBytes  46.9 Mbits/sec  0.000 ms  0/40475 (0%)  sender
[  5]   0.00-11.94  sec  55.9 MBytes  39.3 Mbits/sec  0.493 ms  0/40466 (0%)  receiver

iperf Done.


> 
> I saw a few of these in the journal:
> 
> usb 1-2: rtl8xxxu_send_beacon_frame: Failed to read beacon valid bit
> 
> I'm not sure what caused that.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* RE: [PATCH v2 03/18] wifi: rtl8xxxu: Add beacon functions
  2023-04-19 10:01 ` [PATCH v2 03/18] wifi: rtl8xxxu: Add beacon functions Martin Kaistra
@ 2023-04-24  2:29   ` Ping-Ke Shih
  2023-04-24  9:17     ` Martin Kaistra
  0 siblings, 1 reply; 36+ messages in thread
From: Ping-Ke Shih @ 2023-04-24  2:29 UTC (permalink / raw)
  To: Martin Kaistra, linux-wireless@vger.kernel.org
  Cc: Jes Sorensen, Kalle Valo, Bitterblue Smith,
	Sebastian Andrzej Siewior



> -----Original Message-----
> From: Martin Kaistra <martin.kaistra@linutronix.de>
> Sent: Wednesday, April 19, 2023 6:02 PM
> To: linux-wireless@vger.kernel.org
> Cc: Jes Sorensen <Jes.Sorensen@gmail.com>; Kalle Valo <kvalo@kernel.org>; Ping-Ke Shih
> <pkshih@realtek.com>; Bitterblue Smith <rtl8821cerfe2@gmail.com>; Sebastian Andrzej Siewior
> <bigeasy@linutronix.de>
> Subject: [PATCH v2 03/18] wifi: rtl8xxxu: Add beacon functions
> 
> Add a workqueue to update the beacon contents asynchronously and
> implement downloading the beacon to the HW and starting beacon tx like
> the vendor driver.
> 
> Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>

[...]

> @@ -4885,6 +4903,22 @@ rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
>                 dev_dbg(dev, "Changed BASIC_RATES!\n");
>                 rtl8xxxu_set_basic_rates(priv, bss_conf->basic_rates);
>         }
> +
> +       if (changed & BSS_CHANGED_BEACON ||
> +           (changed & BSS_CHANGED_BEACON_ENABLED &&
> +            bss_conf->enable_beacon)) {
> +               if (!priv->beacon_enabled) {

Is it possible to rely on bss_conf->enable_beacon only? Then, we don't need
priv->beacon_enabled. Like

if (changed & BSS_CHANGED_BEACON_ENABLED && bss_conf->enable_beacon)
      rtl8xxxu_start_tx_beacon(priv);

if (changed & BSS_CHANGED_BEACON)
      schedule_work(&priv->update_beacon_work);

if (changed & BSS_CHANGED_BEACON_ENABLED && !bss_conf->enable_beacon)
      rtl8xxxu_stop_tx_beacon(priv);

> +                       dev_dbg(dev, "BSS_CHANGED_BEACON_ENABLED\n");
> +                       rtl8xxxu_start_tx_beacon(priv);
> +               }
> +               schedule_work(&priv->update_beacon_work);
> +       }
> +
> +       if (changed & BSS_CHANGED_BEACON_ENABLED && !bss_conf->enable_beacon) {
> +               if (priv->beacon_enabled)
> +                       rtl8xxxu_stop_tx_beacon(priv);
> +       }
> +
>  error:
>         return;
>  }

[...]


^ permalink raw reply	[flat|nested] 36+ messages in thread

* RE: [PATCH v2 06/18] wifi: rtl8xxxu: Allow creating interface in AP mode
  2023-04-19 10:01 ` [PATCH v2 06/18] wifi: rtl8xxxu: Allow creating interface in AP mode Martin Kaistra
@ 2023-04-24  2:32   ` Ping-Ke Shih
  0 siblings, 0 replies; 36+ messages in thread
From: Ping-Ke Shih @ 2023-04-24  2:32 UTC (permalink / raw)
  To: Martin Kaistra, linux-wireless@vger.kernel.org
  Cc: Jes Sorensen, Kalle Valo, Bitterblue Smith,
	Sebastian Andrzej Siewior



> -----Original Message-----
> From: Martin Kaistra <martin.kaistra@linutronix.de>
> Sent: Wednesday, April 19, 2023 6:02 PM
> To: linux-wireless@vger.kernel.org
> Cc: Jes Sorensen <Jes.Sorensen@gmail.com>; Kalle Valo <kvalo@kernel.org>; Ping-Ke Shih
> <pkshih@realtek.com>; Bitterblue Smith <rtl8821cerfe2@gmail.com>; Sebastian Andrzej Siewior
> <bigeasy@linutronix.de>
> Subject: [PATCH v2 06/18] wifi: rtl8xxxu: Allow creating interface in AP mode
> 
> Use the sequence from the vendor driver for setting up the beacon
> related registers.
> Also set the MAC address register here, in case the MAC address for the
> new interface should be different from what was set in
> rtl8xxxu_init_device(). This happens for example with the hostapd config
> option "bssid".
> 
> Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>

Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>

[...]


^ permalink raw reply	[flat|nested] 36+ messages in thread

* RE: [PATCH v2 08/18] wifi: rtl8xxxu: Add parameter role to report_connect
  2023-04-19 10:01 ` [PATCH v2 08/18] wifi: rtl8xxxu: Add parameter role to report_connect Martin Kaistra
@ 2023-04-24  2:40   ` Ping-Ke Shih
  0 siblings, 0 replies; 36+ messages in thread
From: Ping-Ke Shih @ 2023-04-24  2:40 UTC (permalink / raw)
  To: Martin Kaistra, linux-wireless@vger.kernel.org
  Cc: Jes Sorensen, Kalle Valo, Bitterblue Smith,
	Sebastian Andrzej Siewior



> -----Original Message-----
> From: Martin Kaistra <martin.kaistra@linutronix.de>
> Sent: Wednesday, April 19, 2023 6:02 PM
> To: linux-wireless@vger.kernel.org
> Cc: Jes Sorensen <Jes.Sorensen@gmail.com>; Kalle Valo <kvalo@kernel.org>; Ping-Ke Shih
> <pkshih@realtek.com>; Bitterblue Smith <rtl8821cerfe2@gmail.com>; Sebastian Andrzej Siewior
> <bigeasy@linutronix.de>
> Subject: [PATCH v2 08/18] wifi: rtl8xxxu: Add parameter role to report_connect
> 
> This allows to tell the HW if a connection is made to a STA or an AP.
> Add the implementation for the gen2 version.
> 
> Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>

Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>

[...]


^ permalink raw reply	[flat|nested] 36+ messages in thread

* RE: [PATCH v2 09/18] wifi: rtl8xxxu: Add parameter force to rtl8xxxu_refresh_rate_mask
  2023-04-19 10:01 ` [PATCH v2 09/18] wifi: rtl8xxxu: Add parameter force to rtl8xxxu_refresh_rate_mask Martin Kaistra
@ 2023-04-24  2:42   ` Ping-Ke Shih
  0 siblings, 0 replies; 36+ messages in thread
From: Ping-Ke Shih @ 2023-04-24  2:42 UTC (permalink / raw)
  To: Martin Kaistra, linux-wireless@vger.kernel.org
  Cc: Jes Sorensen, Kalle Valo, Bitterblue Smith,
	Sebastian Andrzej Siewior



> -----Original Message-----
> From: Martin Kaistra <martin.kaistra@linutronix.de>
> Sent: Wednesday, April 19, 2023 6:02 PM
> To: linux-wireless@vger.kernel.org
> Cc: Jes Sorensen <Jes.Sorensen@gmail.com>; Kalle Valo <kvalo@kernel.org>; Ping-Ke Shih
> <pkshih@realtek.com>; Bitterblue Smith <rtl8821cerfe2@gmail.com>; Sebastian Andrzej Siewior
> <bigeasy@linutronix.de>
> Subject: [PATCH v2 09/18] wifi: rtl8xxxu: Add parameter force to rtl8xxxu_refresh_rate_mask
> 
> In AP mode, when multiple STAs connect to us, we need to set an initial
> rate mask for each of them. This initialisation should happen regardless
> of the rssi_level saved in the priv struct.
> 
> Add a parameter called force to rtl8xxxu_refresh_rate_mask() which will
> be used for this initialisation.
> 
> Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>

Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>

[...]


^ permalink raw reply	[flat|nested] 36+ messages in thread

* RE: [PATCH v2 10/18] wifi: rtl8xxxu: Add sta_add() and sta_remove() callbacks
  2023-04-19 10:01 ` [PATCH v2 10/18] wifi: rtl8xxxu: Add sta_add() and sta_remove() callbacks Martin Kaistra
@ 2023-04-24  2:46   ` Ping-Ke Shih
  0 siblings, 0 replies; 36+ messages in thread
From: Ping-Ke Shih @ 2023-04-24  2:46 UTC (permalink / raw)
  To: Martin Kaistra, linux-wireless@vger.kernel.org
  Cc: Jes Sorensen, Kalle Valo, Bitterblue Smith,
	Sebastian Andrzej Siewior



> -----Original Message-----
> From: Martin Kaistra <martin.kaistra@linutronix.de>
> Sent: Wednesday, April 19, 2023 6:02 PM
> To: linux-wireless@vger.kernel.org
> Cc: Jes Sorensen <Jes.Sorensen@gmail.com>; Kalle Valo <kvalo@kernel.org>; Ping-Ke Shih
> <pkshih@realtek.com>; Bitterblue Smith <rtl8821cerfe2@gmail.com>; Sebastian Andrzej Siewior
> <bigeasy@linutronix.de>
> Subject: [PATCH v2 10/18] wifi: rtl8xxxu: Add sta_add() and sta_remove() callbacks
> 
> In AP mode, sta_add() gets called when a new STA gets associated to
> us. Call rtl8xxxu_refresh_rate_mask() to set a rate mask for the newly
> connected STA (referenced by the macid) and then send a media connnect
> report. Ignore the call to sta_add() in station mode.
> 
> Reserve one macid for broadcast/multicast packets in init.
> 
> Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>

Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>

[...]


^ permalink raw reply	[flat|nested] 36+ messages in thread

* RE: [PATCH v2 11/18] wifi: rtl8xxxu: Put the macid in txdesc
  2023-04-19 10:01 ` [PATCH v2 11/18] wifi: rtl8xxxu: Put the macid in txdesc Martin Kaistra
@ 2023-04-24  3:00   ` Ping-Ke Shih
  0 siblings, 0 replies; 36+ messages in thread
From: Ping-Ke Shih @ 2023-04-24  3:00 UTC (permalink / raw)
  To: Martin Kaistra, linux-wireless@vger.kernel.org
  Cc: Jes Sorensen, Kalle Valo, Bitterblue Smith,
	Sebastian Andrzej Siewior



> -----Original Message-----
> From: Martin Kaistra <martin.kaistra@linutronix.de>
> Sent: Wednesday, April 19, 2023 6:02 PM
> To: linux-wireless@vger.kernel.org
> Cc: Jes Sorensen <Jes.Sorensen@gmail.com>; Kalle Valo <kvalo@kernel.org>; Ping-Ke Shih
> <pkshih@realtek.com>; Bitterblue Smith <rtl8821cerfe2@gmail.com>; Sebastian Andrzej Siewior
> <bigeasy@linutronix.de>
> Subject: [PATCH v2 11/18] wifi: rtl8xxxu: Put the macid in txdesc
> 
> Add a parameter macid to fill_txdesc(), implement setting it for the
> gen2 version.
> This is used to tell the HW who the recipient of the packet is, so that
> the appropriate data rate can be selected.
> 
> Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>

Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>

[...]


^ permalink raw reply	[flat|nested] 36+ messages in thread

* RE: [PATCH v2 12/18] wifi: rtl8xxxu: Add parameter macid to update_rate_mask
  2023-04-19 10:01 ` [PATCH v2 12/18] wifi: rtl8xxxu: Add parameter macid to update_rate_mask Martin Kaistra
@ 2023-04-24  3:01   ` Ping-Ke Shih
  0 siblings, 0 replies; 36+ messages in thread
From: Ping-Ke Shih @ 2023-04-24  3:01 UTC (permalink / raw)
  To: Martin Kaistra, linux-wireless@vger.kernel.org
  Cc: Jes Sorensen, Kalle Valo, Bitterblue Smith,
	Sebastian Andrzej Siewior



> -----Original Message-----
> From: Martin Kaistra <martin.kaistra@linutronix.de>
> Sent: Wednesday, April 19, 2023 6:02 PM
> To: linux-wireless@vger.kernel.org
> Cc: Jes Sorensen <Jes.Sorensen@gmail.com>; Kalle Valo <kvalo@kernel.org>; Ping-Ke Shih
> <pkshih@realtek.com>; Bitterblue Smith <rtl8821cerfe2@gmail.com>; Sebastian Andrzej Siewior
> <bigeasy@linutronix.de>
> Subject: [PATCH v2 12/18] wifi: rtl8xxxu: Add parameter macid to update_rate_mask
> 
> The HW maintains a rate_mask for each connection, referenced by the
> macid. Add a parameter to update_rate_mask and add the macid to the
> h2c call in the gen2 implementation.
> 
> Also extend refresh_rate_mask to get the macid from sta_info.
> 
> Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>

Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>

[...]


^ permalink raw reply	[flat|nested] 36+ messages in thread

* RE: [PATCH v2 13/18] wifi: rtl8xxxu: Enable hw seq for mgmt/non-QoS data frames
  2023-04-19 10:01 ` [PATCH v2 13/18] wifi: rtl8xxxu: Enable hw seq for mgmt/non-QoS data frames Martin Kaistra
@ 2023-04-24  3:04   ` Ping-Ke Shih
  0 siblings, 0 replies; 36+ messages in thread
From: Ping-Ke Shih @ 2023-04-24  3:04 UTC (permalink / raw)
  To: Martin Kaistra, linux-wireless@vger.kernel.org
  Cc: Jes Sorensen, Kalle Valo, Bitterblue Smith,
	Sebastian Andrzej Siewior



> -----Original Message-----
> From: Martin Kaistra <martin.kaistra@linutronix.de>
> Sent: Wednesday, April 19, 2023 6:02 PM
> To: linux-wireless@vger.kernel.org
> Cc: Jes Sorensen <Jes.Sorensen@gmail.com>; Kalle Valo <kvalo@kernel.org>; Ping-Ke Shih
> <pkshih@realtek.com>; Bitterblue Smith <rtl8821cerfe2@gmail.com>; Sebastian Andrzej Siewior
> <bigeasy@linutronix.de>
> Subject: [PATCH v2 13/18] wifi: rtl8xxxu: Enable hw seq for mgmt/non-QoS data frames
> 
> Beacon frames are generated by the HW and therefore contain a HW
> generated seq number. Enable HW sequence number for other frames to
> match that.
> mac80211 will tell us via IEEE80211_TX_CTL_ASSIGN_SEQ when that is
> necessary.
> 
> Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>

Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>

[...]


^ permalink raw reply	[flat|nested] 36+ messages in thread

* RE: [PATCH v2 14/18] wifi: rtl8xxxu: Clean up filter configuration
  2023-04-19 10:01 ` [PATCH v2 14/18] wifi: rtl8xxxu: Clean up filter configuration Martin Kaistra
@ 2023-04-24  3:05   ` Ping-Ke Shih
  0 siblings, 0 replies; 36+ messages in thread
From: Ping-Ke Shih @ 2023-04-24  3:05 UTC (permalink / raw)
  To: Martin Kaistra, linux-wireless@vger.kernel.org
  Cc: Jes Sorensen, Kalle Valo, Bitterblue Smith,
	Sebastian Andrzej Siewior



> -----Original Message-----
> From: Martin Kaistra <martin.kaistra@linutronix.de>
> Sent: Wednesday, April 19, 2023 6:02 PM
> To: linux-wireless@vger.kernel.org
> Cc: Jes Sorensen <Jes.Sorensen@gmail.com>; Kalle Valo <kvalo@kernel.org>; Ping-Ke Shih
> <pkshih@realtek.com>; Bitterblue Smith <rtl8821cerfe2@gmail.com>; Sebastian Andrzej Siewior
> <bigeasy@linutronix.de>
> Subject: [PATCH v2 14/18] wifi: rtl8xxxu: Clean up filter configuration
> 
> When RCR_CHECK_BSSID_MATCH is set in AP mode, we don't receive any data
> frames. Rearrange RCR bits to filter flags to match other realtek drivers
> and remove RCR_CHECK_BSSID_MATCH in AP mode.
> 
> Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>

Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>

[...]


^ permalink raw reply	[flat|nested] 36+ messages in thread

* RE: [PATCH v2 15/18] wifi: rtl8xxxu: Remove usage of ieee80211_get_tx_rate()
  2023-04-19 10:01 ` [PATCH v2 15/18] wifi: rtl8xxxu: Remove usage of ieee80211_get_tx_rate() Martin Kaistra
@ 2023-04-24  3:07   ` Ping-Ke Shih
  0 siblings, 0 replies; 36+ messages in thread
From: Ping-Ke Shih @ 2023-04-24  3:07 UTC (permalink / raw)
  To: Martin Kaistra, linux-wireless@vger.kernel.org
  Cc: Jes Sorensen, Kalle Valo, Bitterblue Smith,
	Sebastian Andrzej Siewior



> -----Original Message-----
> From: Martin Kaistra <martin.kaistra@linutronix.de>
> Sent: Wednesday, April 19, 2023 6:02 PM
> To: linux-wireless@vger.kernel.org
> Cc: Jes Sorensen <Jes.Sorensen@gmail.com>; Kalle Valo <kvalo@kernel.org>; Ping-Ke Shih
> <pkshih@realtek.com>; Bitterblue Smith <rtl8821cerfe2@gmail.com>; Sebastian Andrzej Siewior
> <bigeasy@linutronix.de>
> Subject: [PATCH v2 15/18] wifi: rtl8xxxu: Remove usage of ieee80211_get_tx_rate()
> 
> As this driver uses HAS_RATE_CONTROL, tx_rates will not be provided by
> mac80211.
> 
> For some frames c->control.rates[0].idx is negative, which means
> ieee80211_get_tx_rate() will print a warning and return NULL.
> 
> Only management frames have USE_DRIVER_RATE set, so for all others the
> rate info of txdesc is ignored anyway.
> 
> Remove call to ieee80211_get_tx_rate() and send management frames with
> 1M (rate info = 0).
> 
> Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>

Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>

[...]


^ permalink raw reply	[flat|nested] 36+ messages in thread

* RE: [PATCH v2 16/18] wifi: rtl8xxxu: Remove usage of tx_info->control.rates[0].flags
  2023-04-19 10:01 ` [PATCH v2 16/18] wifi: rtl8xxxu: Remove usage of tx_info->control.rates[0].flags Martin Kaistra
@ 2023-04-24  3:10   ` Ping-Ke Shih
  0 siblings, 0 replies; 36+ messages in thread
From: Ping-Ke Shih @ 2023-04-24  3:10 UTC (permalink / raw)
  To: Martin Kaistra, linux-wireless@vger.kernel.org
  Cc: Jes Sorensen, Kalle Valo, Bitterblue Smith,
	Sebastian Andrzej Siewior



> -----Original Message-----
> From: Martin Kaistra <martin.kaistra@linutronix.de>
> Sent: Wednesday, April 19, 2023 6:02 PM
> To: linux-wireless@vger.kernel.org
> Cc: Jes Sorensen <Jes.Sorensen@gmail.com>; Kalle Valo <kvalo@kernel.org>; Ping-Ke Shih
> <pkshih@realtek.com>; Bitterblue Smith <rtl8821cerfe2@gmail.com>; Sebastian Andrzej Siewior
> <bigeasy@linutronix.de>
> Subject: [PATCH v2 16/18] wifi: rtl8xxxu: Remove usage of tx_info->control.rates[0].flags
> 
> As this driver uses HAS_RATE_CONTROL, rate_flags will not be provided by
> mac80211.
> 
> Stop using tx_info->control.rates[0].flags and ieee80211_get_rts_cts_rate()
> and use rts_threshold and bss_conf.use_cts_prot instead to determine
> when to use RTS and CTS.
> 
> Send RTS with 24M rate like the vendor drivers. Also set this RTS rate
> for ampdu_enable = true, because we also enable RTS for these frames.
> 
> Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>

Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>

[...]


^ permalink raw reply	[flat|nested] 36+ messages in thread

* RE: [PATCH v2 18/18] wifi: rtl8xxxu: Set maximum number of supported stations
  2023-04-19 10:01 ` [PATCH v2 18/18] wifi: rtl8xxxu: Set maximum number of supported stations Martin Kaistra
@ 2023-04-24  3:12   ` Ping-Ke Shih
  2023-04-24 20:16   ` Bitterblue Smith
  1 sibling, 0 replies; 36+ messages in thread
From: Ping-Ke Shih @ 2023-04-24  3:12 UTC (permalink / raw)
  To: Martin Kaistra, linux-wireless@vger.kernel.org
  Cc: Jes Sorensen, Kalle Valo, Bitterblue Smith,
	Sebastian Andrzej Siewior



> -----Original Message-----
> From: Martin Kaistra <martin.kaistra@linutronix.de>
> Sent: Wednesday, April 19, 2023 6:02 PM
> To: linux-wireless@vger.kernel.org
> Cc: Jes Sorensen <Jes.Sorensen@gmail.com>; Kalle Valo <kvalo@kernel.org>; Ping-Ke Shih
> <pkshih@realtek.com>; Bitterblue Smith <rtl8821cerfe2@gmail.com>; Sebastian Andrzej Siewior
> <bigeasy@linutronix.de>
> Subject: [PATCH v2 18/18] wifi: rtl8xxxu: Set maximum number of supported stations
> 
> Set maximum number of associated stations supported in AP mode. For
> 8188f, the maximum number of supported macids is 16, reserve one for
> broadcast/multicast frames.
> 
> Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>

Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v2 03/18] wifi: rtl8xxxu: Add beacon functions
  2023-04-24  2:29   ` Ping-Ke Shih
@ 2023-04-24  9:17     ` Martin Kaistra
  0 siblings, 0 replies; 36+ messages in thread
From: Martin Kaistra @ 2023-04-24  9:17 UTC (permalink / raw)
  To: Ping-Ke Shih, linux-wireless@vger.kernel.org
  Cc: Jes Sorensen, Kalle Valo, Bitterblue Smith,
	Sebastian Andrzej Siewior

Am 24.04.23 um 04:29 schrieb Ping-Ke Shih:
> 
> 
>> -----Original Message-----
>> From: Martin Kaistra <martin.kaistra@linutronix.de>
>> Sent: Wednesday, April 19, 2023 6:02 PM
>> To: linux-wireless@vger.kernel.org
>> Cc: Jes Sorensen <Jes.Sorensen@gmail.com>; Kalle Valo <kvalo@kernel.org>; Ping-Ke Shih
>> <pkshih@realtek.com>; Bitterblue Smith <rtl8821cerfe2@gmail.com>; Sebastian Andrzej Siewior
>> <bigeasy@linutronix.de>
>> Subject: [PATCH v2 03/18] wifi: rtl8xxxu: Add beacon functions
>>
>> Add a workqueue to update the beacon contents asynchronously and
>> implement downloading the beacon to the HW and starting beacon tx like
>> the vendor driver.
>>
>> Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
> 
> [...]
> 
>> @@ -4885,6 +4903,22 @@ rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
>>                  dev_dbg(dev, "Changed BASIC_RATES!\n");
>>                  rtl8xxxu_set_basic_rates(priv, bss_conf->basic_rates);
>>          }
>> +
>> +       if (changed & BSS_CHANGED_BEACON ||
>> +           (changed & BSS_CHANGED_BEACON_ENABLED &&
>> +            bss_conf->enable_beacon)) {
>> +               if (!priv->beacon_enabled) {
> 
> Is it possible to rely on bss_conf->enable_beacon only? Then, we don't need
> priv->beacon_enabled. Like
> 
> if (changed & BSS_CHANGED_BEACON_ENABLED && bss_conf->enable_beacon)
>        rtl8xxxu_start_tx_beacon(priv);
> 
> if (changed & BSS_CHANGED_BEACON)
>        schedule_work(&priv->update_beacon_work);
> 
> if (changed & BSS_CHANGED_BEACON_ENABLED && !bss_conf->enable_beacon)
>        rtl8xxxu_stop_tx_beacon(priv);

Looking at the the mac80211 code which calls ops->bss_info_changed(), this seems 
fine to me. I will implement your suggestion and do some testing.

> 
>> +                       dev_dbg(dev, "BSS_CHANGED_BEACON_ENABLED\n");
>> +                       rtl8xxxu_start_tx_beacon(priv);
>> +               }
>> +               schedule_work(&priv->update_beacon_work);
>> +       }
>> +
>> +       if (changed & BSS_CHANGED_BEACON_ENABLED && !bss_conf->enable_beacon) {
>> +               if (priv->beacon_enabled)
>> +                       rtl8xxxu_stop_tx_beacon(priv);
>> +       }
>> +
>>   error:
>>          return;
>>   }
> 
> [...]
> 

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v2 18/18] wifi: rtl8xxxu: Set maximum number of supported stations
  2023-04-19 10:01 ` [PATCH v2 18/18] wifi: rtl8xxxu: Set maximum number of supported stations Martin Kaistra
  2023-04-24  3:12   ` Ping-Ke Shih
@ 2023-04-24 20:16   ` Bitterblue Smith
  2023-04-25  5:53     ` Kalle Valo
  1 sibling, 1 reply; 36+ messages in thread
From: Bitterblue Smith @ 2023-04-24 20:16 UTC (permalink / raw)
  To: Martin Kaistra, linux-wireless
  Cc: Jes Sorensen, Kalle Valo, Ping-Ke Shih, Sebastian Andrzej Siewior

On 19/04/2023 13:01, Martin Kaistra wrote:
> Set maximum number of associated stations supported in AP mode. For
> 8188f, the maximum number of supported macids is 16, reserve one for
> broadcast/multicast frames.
> 
> Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
> ---
>  drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h       | 1 +
>  drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c | 1 +
>  drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c  | 2 ++
>  3 files changed, 4 insertions(+)
> 
> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
> index 64e823f216967..e996168d0bfd1 100644
> --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
> +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
> @@ -1946,6 +1946,7 @@ struct rtl8xxxu_fileops {
>  	u8 ampdu_max_time;
>  	u8 ustime_tsf_edca;
>  	u8 supports_ap:1;
> +	u16 max_sta_num;
>  	u32 adda_1t_init;
>  	u32 adda_1t_path_on;
>  	u32 adda_2t_path_on_a;
> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
> index 7dc2fd8aa5317..085721c734ae2 100644
> --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
> +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
> @@ -1752,6 +1752,7 @@ struct rtl8xxxu_fileops rtl8188fu_fops = {
>  	.ampdu_max_time = 0x70,
>  	.ustime_tsf_edca = 0x28,
>  	.supports_ap = 1,
> +	.max_sta_num = 16,
>  	.adda_1t_init = 0x03c00014,
>  	.adda_1t_path_on = 0x03c00014,
>  	.trxff_boundary = 0x3f7f,
> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> index bf471c3f98b86..6d0c775244274 100644
> --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> @@ -7464,6 +7464,8 @@ static int rtl8xxxu_probe(struct usb_interface *interface,
>  
>  	hw->wiphy->max_scan_ssids = 1;
>  	hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN;
> +	if (priv->fops->max_sta_num)
> +		hw->wiphy->max_ap_assoc_sta = priv->fops->max_sta_num - 1;

The way you use it, "max_macid_num" would be a more accurate name.

>  	hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
>  	if (priv->fops->supports_ap)
>  		hw->wiphy->interface_modes |= BIT(NL80211_IFTYPE_AP);


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v2 18/18] wifi: rtl8xxxu: Set maximum number of supported stations
  2023-04-24 20:16   ` Bitterblue Smith
@ 2023-04-25  5:53     ` Kalle Valo
  0 siblings, 0 replies; 36+ messages in thread
From: Kalle Valo @ 2023-04-25  5:53 UTC (permalink / raw)
  To: Bitterblue Smith
  Cc: Martin Kaistra, linux-wireless, Jes Sorensen, Ping-Ke Shih,
	Sebastian Andrzej Siewior

Bitterblue Smith <rtl8821cerfe2@gmail.com> writes:

>> --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
>> +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
>> @@ -7464,6 +7464,8 @@ static int rtl8xxxu_probe(struct usb_interface *interface,
>>  
>>  	hw->wiphy->max_scan_ssids = 1;
>>  	hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN;
>> +	if (priv->fops->max_sta_num)
>> +		hw->wiphy->max_ap_assoc_sta = priv->fops->max_sta_num - 1;
>
> The way you use it, "max_macid_num" would be a more accurate name.

Indeed. I was first wondering why subtract max_sta_num, at least for me
max_macid_num makes more sense.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2023-04-25  5:53 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-19 10:01 [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Martin Kaistra
2023-04-19 10:01 ` [PATCH v2 01/18] wifi: rtl8xxxu: Add start_ap() callback Martin Kaistra
2023-04-19 10:01 ` [PATCH v2 02/18] wifi: rtl8xxxu: Select correct queue for beacon frames Martin Kaistra
2023-04-19 10:01 ` [PATCH v2 03/18] wifi: rtl8xxxu: Add beacon functions Martin Kaistra
2023-04-24  2:29   ` Ping-Ke Shih
2023-04-24  9:17     ` Martin Kaistra
2023-04-19 10:01 ` [PATCH v2 04/18] wifi: rtl8xxxu: Add set_tim() callback Martin Kaistra
2023-04-19 10:01 ` [PATCH v2 05/18] wifi: rtl8xxxu: Allow setting rts threshold to -1 Martin Kaistra
2023-04-19 10:01 ` [PATCH v2 06/18] wifi: rtl8xxxu: Allow creating interface in AP mode Martin Kaistra
2023-04-24  2:32   ` Ping-Ke Shih
2023-04-19 10:01 ` [PATCH v2 07/18] wifi: rtl8xxxu: Actually use macid in rtl8xxxu_gen2_report_connect Martin Kaistra
2023-04-19 10:01 ` [PATCH v2 08/18] wifi: rtl8xxxu: Add parameter role to report_connect Martin Kaistra
2023-04-24  2:40   ` Ping-Ke Shih
2023-04-19 10:01 ` [PATCH v2 09/18] wifi: rtl8xxxu: Add parameter force to rtl8xxxu_refresh_rate_mask Martin Kaistra
2023-04-24  2:42   ` Ping-Ke Shih
2023-04-19 10:01 ` [PATCH v2 10/18] wifi: rtl8xxxu: Add sta_add() and sta_remove() callbacks Martin Kaistra
2023-04-24  2:46   ` Ping-Ke Shih
2023-04-19 10:01 ` [PATCH v2 11/18] wifi: rtl8xxxu: Put the macid in txdesc Martin Kaistra
2023-04-24  3:00   ` Ping-Ke Shih
2023-04-19 10:01 ` [PATCH v2 12/18] wifi: rtl8xxxu: Add parameter macid to update_rate_mask Martin Kaistra
2023-04-24  3:01   ` Ping-Ke Shih
2023-04-19 10:01 ` [PATCH v2 13/18] wifi: rtl8xxxu: Enable hw seq for mgmt/non-QoS data frames Martin Kaistra
2023-04-24  3:04   ` Ping-Ke Shih
2023-04-19 10:01 ` [PATCH v2 14/18] wifi: rtl8xxxu: Clean up filter configuration Martin Kaistra
2023-04-24  3:05   ` Ping-Ke Shih
2023-04-19 10:01 ` [PATCH v2 15/18] wifi: rtl8xxxu: Remove usage of ieee80211_get_tx_rate() Martin Kaistra
2023-04-24  3:07   ` Ping-Ke Shih
2023-04-19 10:01 ` [PATCH v2 16/18] wifi: rtl8xxxu: Remove usage of tx_info->control.rates[0].flags Martin Kaistra
2023-04-24  3:10   ` Ping-Ke Shih
2023-04-19 10:01 ` [PATCH v2 17/18] wifi: rtl8xxxu: Declare AP mode support for 8188f Martin Kaistra
2023-04-19 10:01 ` [PATCH v2 18/18] wifi: rtl8xxxu: Set maximum number of supported stations Martin Kaistra
2023-04-24  3:12   ` Ping-Ke Shih
2023-04-24 20:16   ` Bitterblue Smith
2023-04-25  5:53     ` Kalle Valo
2023-04-19 20:35 ` [PATCH v2 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Bitterblue Smith
2023-04-20  7:44   ` Martin Kaistra

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).