2023-04-01 12:46:41

by Ping-Ke Shih

[permalink] [raw]
Subject: [PATCH 4/7] wifi: rtw88: disallow scan and PS during AP mode

From: Po-Hao Huang <[email protected]>

During concurrent operation, the VIF sharing same channel with AP mode
might scan. Reject those scan requests from driver when there's AP
currently operating. Also, disallow entering power saving mode.

Signed-off-by: Po-Hao Huang <[email protected]>
Signed-off-by: Ping-Ke Shih <[email protected]>
---
drivers/net/wireless/realtek/rtw88/mac80211.c | 16 ++++++++++++++++
drivers/net/wireless/realtek/rtw88/main.c | 2 +-
drivers/net/wireless/realtek/rtw88/main.h | 1 +
3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtw88/mac80211.c b/drivers/net/wireless/realtek/rtw88/mac80211.c
index 19c4d7c29759e..37a3146a2910c 100644
--- a/drivers/net/wireless/realtek/rtw88/mac80211.c
+++ b/drivers/net/wireless/realtek/rtw88/mac80211.c
@@ -449,12 +449,24 @@ static int rtw_ops_start_ap(struct ieee80211_hw *hw,
const struct rtw_chip_info *chip = rtwdev->chip;

mutex_lock(&rtwdev->mutex);
+ rtwdev->ap_active = true;
chip->ops->phy_calibration(rtwdev);
mutex_unlock(&rtwdev->mutex);

return 0;
}

+static void rtw_ops_stop_ap(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct ieee80211_bss_conf *link_conf)
+{
+ struct rtw_dev *rtwdev = hw->priv;
+
+ mutex_lock(&rtwdev->mutex);
+ rtwdev->ap_active = false;
+ mutex_unlock(&rtwdev->mutex);
+}
+
static int rtw_ops_conf_tx(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
unsigned int link_id, u16 ac,
@@ -853,6 +865,9 @@ static int rtw_ops_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
if (test_bit(RTW_FLAG_SCANNING, rtwdev->flags))
return -EBUSY;

+ if (rtwdev->ap_active)
+ return -EOPNOTSUPP;
+
mutex_lock(&rtwdev->mutex);
rtw_hw_scan_start(rtwdev, vif, req);
ret = rtw_hw_scan_offload(rtwdev, vif, true);
@@ -916,6 +931,7 @@ const struct ieee80211_ops rtw_ops = {
.configure_filter = rtw_ops_configure_filter,
.bss_info_changed = rtw_ops_bss_info_changed,
.start_ap = rtw_ops_start_ap,
+ .stop_ap = rtw_ops_stop_ap,
.conf_tx = rtw_ops_conf_tx,
.sta_add = rtw_ops_sta_add,
.sta_remove = rtw_ops_sta_remove,
diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
index ba05a5d68d05e..835abbdd87eff 100644
--- a/drivers/net/wireless/realtek/rtw88/main.c
+++ b/drivers/net/wireless/realtek/rtw88/main.c
@@ -256,7 +256,7 @@ static void rtw_watch_dog_work(struct work_struct *work)
* threshold.
*/
if (rtwdev->ps_enabled && data.rtwvif && !ps_active &&
- !rtwdev->beacon_loss)
+ !rtwdev->beacon_loss && !rtwdev->ap_active)
rtw_enter_lps(rtwdev, data.rtwvif->port);

rtwdev->watch_dog_cnt++;
diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h
index 532c56219a5f5..b04ed190ea5d4 100644
--- a/drivers/net/wireless/realtek/rtw88/main.h
+++ b/drivers/net/wireless/realtek/rtw88/main.h
@@ -2058,6 +2058,7 @@ struct rtw_dev {

bool need_rfk;
struct completion fw_scan_density;
+ bool ap_active;

/* hci related data, must be last */
u8 priv[] __aligned(sizeof(void *));
--
2.25.1


2023-04-12 12:44:40

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH 4/7] wifi: rtw88: disallow scan and PS during AP mode

Ping-Ke Shih <[email protected]> writes:

> From: Po-Hao Huang <[email protected]>
>
> During concurrent operation, the VIF sharing same channel with AP mode
> might scan. Reject those scan requests from driver when there's AP
> currently operating. Also, disallow entering power saving mode.
>
> Signed-off-by: Po-Hao Huang <[email protected]>
> Signed-off-by: Ping-Ke Shih <[email protected]>

How is a station interface useful if it cannot scan at all? IMHO quite
hard limitation.

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

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

2023-04-14 12:23:13

by Ping-Ke Shih

[permalink] [raw]
Subject: Re: [PATCH 4/7] wifi: rtw88: disallow scan and PS during AP mode

On Wed, 2023-04-12 at 15:39 +0300, Kalle Valo wrote:
>
> Ping-Ke Shih <[email protected]> writes:
>
> > From: Po-Hao Huang <[email protected]>
> >
> > During concurrent operation, the VIF sharing same channel with AP mode
> > might scan. Reject those scan requests from driver when there's AP
> > currently operating. Also, disallow entering power saving mode.
> >
> > Signed-off-by: Po-Hao Huang <[email protected]>
> > Signed-off-by: Ping-Ke Shih <[email protected]>
>
> How is a station interface useful if it cannot scan at all? IMHO quite
> hard limitation.
>

Due to hardware limitation, it can't host as AP mode and do scanning at
the same time, so we make this choice before. Now, we don't reject scan
requests, but AP's clients could get lost or disconnected. I think
that is a trade-off, so we leave this decision to user space.

I have sent v2 with this change.

Ping-Ke