diff mbox series

[14/19] staging: wfx: fix PS parameters when multiple vif are in use

Message ID 20200515083325.378539-15-Jerome.Pouiller@silabs.com
State New
Headers show
Series staging: wfx: various fixes | expand

Commit Message

Jérôme Pouiller May 15, 2020, 8:33 a.m. UTC
From: Jérôme Pouiller <jerome.pouiller@silabs.com>

When multiple vif are in use (= one access point and one station), and
when the channels are different, it is necessary to enable power save on
station.

The firmware check that steps are done in the correct order:
  - AP can't start if PS is not enable on the station
  - PS can't set on the station before the association has finished
    (= before the call set_bss_params)

Obviously, in add, when one of the interface disappears, it is necessary to
restore the power save status.

wfx_update_pm() is able to set the correct PS configuration. But it has
to be called at the right time:
   1. before hif_start(), but after the channel configuration is known
   2. after hif_set_bss_params()
   3. after hif_reset()

Therefore, the call to wfx_update_pm() from wfx_add_interface() is too
early to address 1.

The call after hif_set_bss_params() already exists.

For the symmetry, the call from wfx_remove_interface() (that handle 3.)
is also relocated.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/sta.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index 6e9f38d051ab..0cb7315bb050 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -347,15 +347,20 @@  static void wfx_set_mfp(struct wfx_vif *wvif,
 
 void wfx_reset(struct wfx_vif *wvif)
 {
-	wfx_tx_lock_flush(wvif->wdev);
+	struct wfx_dev *wdev = wvif->wdev;
+
+	wfx_tx_lock_flush(wdev);
 	hif_reset(wvif, false);
 	wfx_tx_policy_init(wvif);
-	if (wvif_count(wvif->wdev) <= 1)
+	if (wvif_count(wdev) <= 1)
 		hif_set_block_ack_policy(wvif, 0xFF, 0xFF);
-	wfx_tx_unlock(wvif->wdev);
+	wfx_tx_unlock(wdev);
 	wvif->join_in_progress = false;
 	wvif->bss_not_support_ps_poll = false;
 	cancel_delayed_work_sync(&wvif->beacon_loss_work);
+	wvif =  NULL;
+	while ((wvif = wvif_iterate(wdev, wvif)) != NULL)
+		wfx_update_pm(wvif);
 }
 
 static void wfx_do_join(struct wfx_vif *wvif)
@@ -471,7 +476,12 @@  static int wfx_upload_ap_templates(struct wfx_vif *wvif)
 int wfx_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 {
 	struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
+	struct wfx_dev *wdev = wvif->wdev;
 
+	wvif =  NULL;
+	while ((wvif = wvif_iterate(wdev, wvif)) != NULL)
+		wfx_update_pm(wvif);
+	wvif = (struct wfx_vif *)vif->drv_priv;
 	wfx_upload_ap_templates(wvif);
 	hif_start(wvif, &vif->bss_conf, wvif->channel);
 	return 0;
@@ -786,8 +796,6 @@  int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 			hif_set_block_ack_policy(wvif, 0xFF, 0xFF);
 		else
 			hif_set_block_ack_policy(wvif, 0x00, 0x00);
-		// Combo force powersave mode. We can re-enable it now
-		ret = wfx_update_pm(wvif);
 	}
 	return ret;
 }
@@ -818,8 +826,6 @@  void wfx_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 			hif_set_block_ack_policy(wvif, 0xFF, 0xFF);
 		else
 			hif_set_block_ack_policy(wvif, 0x00, 0x00);
-		// Combo force powersave mode. We can re-enable it now
-		wfx_update_pm(wvif);
 	}
 }