mac80211: rtl8xxxu: sync with linux-next 20240229
[openwrt/staging/981213.git] / package / kernel / mac80211 / patches / rtl / 003-02-v6.9-wifi-rtl8xxxu-enable-channel-switch-support.patch
1 From ece90a8622320bf5a24d3326da1f8e109891573c Mon Sep 17 00:00:00 2001
2 From: Martin Kaistra <martin.kaistra@linutronix.de>
3 Date: Thu, 11 Jan 2024 17:36:28 +0100
4 Subject: [PATCH 2/2] wifi: rtl8xxxu: enable channel switch support
5
6 The CSA countdown in the beacon frames, which are sent out by firmware,
7 needs to get updated by the driver. To achieve this, convert
8 update_beacon_work to delayed_work and schedule it with the beacon
9 interval in case CSA is active and the countdown is not complete.
10
11 Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
12 Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
13 Signed-off-by: Kalle Valo <kvalo@kernel.org>
14 Link: https://msgid.link/20240111163628.320697-3-martin.kaistra@linutronix.de
15 ---
16 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 2 +-
17 .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 19 +++++++++++++++----
18 2 files changed, 16 insertions(+), 5 deletions(-)
19
20 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
21 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
22 @@ -1900,7 +1900,7 @@ struct rtl8xxxu_priv {
23 struct delayed_work ra_watchdog;
24 struct work_struct c2hcmd_work;
25 struct sk_buff_head c2hcmd_queue;
26 - struct work_struct update_beacon_work;
27 + struct delayed_work update_beacon_work;
28 struct rtl8xxxu_btcoex bt_coex;
29 struct rtl8xxxu_ra_report ra_report;
30 struct rtl8xxxu_cfo_tracking cfo_tracking;
31 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
32 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
33 @@ -4605,7 +4605,7 @@ static int rtl8xxxu_set_tim(struct ieee8
34 {
35 struct rtl8xxxu_priv *priv = hw->priv;
36
37 - schedule_work(&priv->update_beacon_work);
38 + schedule_delayed_work(&priv->update_beacon_work, 0);
39
40 return 0;
41 }
42 @@ -5107,7 +5107,7 @@ rtl8xxxu_bss_info_changed(struct ieee802
43 }
44
45 if (changed & BSS_CHANGED_BEACON)
46 - schedule_work(&priv->update_beacon_work);
47 + schedule_delayed_work(&priv->update_beacon_work, 0);
48
49 error:
50 return;
51 @@ -5726,7 +5726,7 @@ static void rtl8xxxu_send_beacon_frame(s
52 static void rtl8xxxu_update_beacon_work_callback(struct work_struct *work)
53 {
54 struct rtl8xxxu_priv *priv =
55 - container_of(work, struct rtl8xxxu_priv, update_beacon_work);
56 + container_of(work, struct rtl8xxxu_priv, update_beacon_work.work);
57 struct ieee80211_hw *hw = priv->hw;
58 struct ieee80211_vif *vif = priv->vifs[0];
59
60 @@ -5735,6 +5735,14 @@ static void rtl8xxxu_update_beacon_work_
61 return;
62 }
63
64 + if (vif->bss_conf.csa_active) {
65 + if (ieee80211_beacon_cntdwn_is_complete(vif)) {
66 + ieee80211_csa_finish(vif);
67 + return;
68 + }
69 + schedule_delayed_work(&priv->update_beacon_work,
70 + msecs_to_jiffies(vif->bss_conf.beacon_int));
71 + }
72 rtl8xxxu_send_beacon_frame(hw, vif);
73 }
74
75 @@ -7482,6 +7490,7 @@ static void rtl8xxxu_stop(struct ieee802
76
77 cancel_work_sync(&priv->c2hcmd_work);
78 cancel_delayed_work_sync(&priv->ra_watchdog);
79 + cancel_delayed_work_sync(&priv->update_beacon_work);
80
81 rtl8xxxu_free_rx_resources(priv);
82 rtl8xxxu_free_tx_resources(priv);
83 @@ -7763,7 +7772,7 @@ static int rtl8xxxu_probe(struct usb_int
84 spin_lock_init(&priv->rx_urb_lock);
85 INIT_WORK(&priv->rx_urb_wq, rtl8xxxu_rx_urb_work);
86 INIT_DELAYED_WORK(&priv->ra_watchdog, rtl8xxxu_watchdog_callback);
87 - INIT_WORK(&priv->update_beacon_work, rtl8xxxu_update_beacon_work_callback);
88 + INIT_DELAYED_WORK(&priv->update_beacon_work, rtl8xxxu_update_beacon_work_callback);
89 skb_queue_head_init(&priv->c2hcmd_queue);
90
91 usb_set_intfdata(interface, hw);
92 @@ -7824,6 +7833,8 @@ static int rtl8xxxu_probe(struct usb_int
93 hw->wiphy->interface_modes |= BIT(NL80211_IFTYPE_AP);
94 hw->queues = 4;
95
96 + hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
97 +
98 if (priv->fops->supports_concurrent) {
99 hw->wiphy->iface_combinations = rtl8xxxu_combinations;
100 hw->wiphy->n_iface_combinations = ARRAY_SIZE(rtl8xxxu_combinations);