linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/16] staging: wfx: rework the handling of the connection loss
@ 2020-04-20 16:02 Jerome Pouiller
  2020-04-20 16:02 ` [PATCH 01/16] staging: wfx: simplify the check if the the device is associated Jerome Pouiller
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: Jerome Pouiller @ 2020-04-20 16:02 UTC (permalink / raw)
  To: devel, linux-wireless
  Cc: netdev, linux-kernel, Greg Kroah-Hartman, Kalle Valo,
	David S . Miller, Jérôme Pouiller

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

Until now, the driver handled itself the connection loss. This series
allows to use ieee80211_beacon_loss() instead (patch 2/16). This change
allow a bunch of simplifications in many parts of the driver (most of
the patches 3 to 16). In particular it allows to drop the infamous enum
wfx_state (patch 15/16).

Jérôme Pouiller (16):
  staging: wfx: simplify the check if the the device is associated
  staging: wfx: use ieee80211_beacon_loss() provided by mac80211
  staging: wfx: drop useless attribute 'bss_params'
  staging: wfx: handle firmware events synchronously
  staging: wfx: also fix network parameters for IBSS networks
  staging: wfx: dual CTS is never necessary
  staging: wfx: field operational_rate_set is ignored by firmware
  staging: wfx: simplify hif_set_bss_params()
  staging: wfx: drop useless update of field basic_rate_set
  staging: wfx: introduce wfx_set_default_unicast_key()
  staging: wfx: keys are kept during whole firmware life
  staging: wfx: drop protection for asynchronous join during scan
  staging: wfx: drop useless checks in wfx_do_unjoin()
  staging: wfx: simplify wfx_remove_interface()
  staging: wfx: drop unused enum wfx_state
  staging: wfx: drop unused attribute 'join_complete_status'

 drivers/staging/wfx/data_tx.c     |   7 -
 drivers/staging/wfx/hif_api_mib.h |   6 -
 drivers/staging/wfx/hif_rx.c      |  39 +++--
 drivers/staging/wfx/hif_tx.c      |  12 +-
 drivers/staging/wfx/hif_tx.h      |   3 +-
 drivers/staging/wfx/hif_tx_mib.c  |  13 --
 drivers/staging/wfx/hif_tx_mib.h  |   1 -
 drivers/staging/wfx/key.c         |  68 +++-----
 drivers/staging/wfx/key.h         |   2 -
 drivers/staging/wfx/main.c        |   1 +
 drivers/staging/wfx/queue.c       |  44 ------
 drivers/staging/wfx/scan.c        |   3 -
 drivers/staging/wfx/sta.c         | 248 +++---------------------------
 drivers/staging/wfx/sta.h         |  17 +-
 drivers/staging/wfx/wfx.h         |  20 +--
 15 files changed, 77 insertions(+), 407 deletions(-)

-- 
2.26.1


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

* [PATCH 01/16] staging: wfx: simplify the check if the the device is associated
  2020-04-20 16:02 [PATCH 00/16] staging: wfx: rework the handling of the connection loss Jerome Pouiller
@ 2020-04-20 16:02 ` Jerome Pouiller
  2020-04-20 16:02 ` [PATCH 02/16] staging: wfx: use ieee80211_beacon_loss() provided by mac80211 Jerome Pouiller
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Jerome Pouiller @ 2020-04-20 16:02 UTC (permalink / raw)
  To: devel, linux-wireless
  Cc: netdev, linux-kernel, Greg Kroah-Hartman, Kalle Valo,
	David S . Miller, Jérôme Pouiller

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

Firmware dislikes the driver enables PS when it is not yet associated.
The current check for that condition is more complex than necessary.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/sta.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index c73dbb3a0de8..c0c3eb945967 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -263,7 +263,7 @@ static int wfx_update_pm(struct wfx_vif *wvif)
 	struct ieee80211_channel *chan0 = NULL, *chan1 = NULL;
 
 	WARN_ON(conf->dynamic_ps_timeout < 0);
-	if (wvif->state != WFX_STATE_STA || !wvif->bss_params.aid)
+	if (!wvif->vif->bss_conf.assoc)
 		return 0;
 	if (!ps)
 		ps_timeout = 0;
-- 
2.26.1


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

* [PATCH 02/16] staging: wfx: use ieee80211_beacon_loss() provided by mac80211
  2020-04-20 16:02 [PATCH 00/16] staging: wfx: rework the handling of the connection loss Jerome Pouiller
  2020-04-20 16:02 ` [PATCH 01/16] staging: wfx: simplify the check if the the device is associated Jerome Pouiller
@ 2020-04-20 16:02 ` Jerome Pouiller
  2020-04-20 16:02 ` [PATCH 03/16] staging: wfx: drop useless attribute 'bss_params' Jerome Pouiller
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Jerome Pouiller @ 2020-04-20 16:02 UTC (permalink / raw)
  To: devel, linux-wireless
  Cc: netdev, linux-kernel, Greg Kroah-Hartman, Kalle Valo,
	David S . Miller, Jérôme Pouiller

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

The firmware is able to filter beacons and send a notification if one or
multiple beacons are not received. Note that it send this notification
only once. Only if it receive beacons gain, it send a new notification.

Currently, the driver handle the connection loss itself (see
wfx_cqm_bssloss_sm()). It send null frames and watch the answers.

This patch fixes all this mess:
  - settle firmware to send a notification on the first beacon loss
  - call ieee80211_beacon_loss() and let mac80211 handle all the process
  - since we do have notification for each beacon loss, add a period
    task that call ieee80211_beacon_loss() until we receive "REGAIN"
    notification.

Thus, we can drop the ugly wfx_cqm_bssloss_sm() and
wfx_bss_params_work().

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/data_tx.c |   7 ---
 drivers/staging/wfx/queue.c   |  11 ----
 drivers/staging/wfx/sta.c     | 106 ++++++----------------------------
 drivers/staging/wfx/sta.h     |   1 -
 drivers/staging/wfx/wfx.h     |   7 +--
 5 files changed, 20 insertions(+), 112 deletions(-)

diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c
index c30e4f5b6e2d..9c1a91207dd8 100644
--- a/drivers/staging/wfx/data_tx.c
+++ b/drivers/staging/wfx/data_tx.c
@@ -547,9 +547,6 @@ void wfx_tx_confirm_cb(struct wfx_vif *wvif, const struct hif_cnf_tx *arg)
 	memset(tx_info->pad, 0, sizeof(tx_info->pad));
 
 	if (!arg->status) {
-		if (wvif->bss_loss_state &&
-		    arg->packet_id == wvif->bss_loss_confirm_id)
-			wfx_cqm_bssloss_sm(wvif, 0, 1, 0);
 		tx_info->status.tx_time =
 		arg->media_delay - arg->tx_queue_delay;
 		if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK)
@@ -563,10 +560,6 @@ void wfx_tx_confirm_cb(struct wfx_vif *wvif, const struct hif_cnf_tx *arg)
 			schedule_work(&wvif->update_tim_work);
 		}
 		tx_info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
-	} else {
-		if (wvif->bss_loss_state &&
-		    arg->packet_id == wvif->bss_loss_confirm_id)
-			wfx_cqm_bssloss_sm(wvif, 0, 0, 1);
 	}
 	wfx_skb_dtor(wvif->wdev, skb);
 }
diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c
index e6d7d0e45156..e9573e9d009f 100644
--- a/drivers/staging/wfx/queue.c
+++ b/drivers/staging/wfx/queue.c
@@ -266,17 +266,6 @@ static bool wfx_handle_tx_data(struct wfx_dev *wdev, struct sk_buff *skb)
 	if (!wvif)
 		return false;
 
-	// FIXME: mac80211 is smart enough to handle BSS loss. Driver should not
-	// try to do anything about that.
-	if (ieee80211_is_nullfunc(frame->frame_control)) {
-		mutex_lock(&wvif->bss_loss_lock);
-		if (wvif->bss_loss_state) {
-			wvif->bss_loss_confirm_id = req->packet_id;
-			req->queue_id.queue_id = HIF_QUEUE_ID_VOICE;
-		}
-		mutex_unlock(&wvif->bss_loss_lock);
-	}
-
 	// FIXME: identify the exact scenario matched by this condition. Does it
 	// happen yet?
 	if (ieee80211_has_protected(frame->frame_control) &&
diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index c0c3eb945967..ca84724e531c 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -59,60 +59,6 @@ static void wfx_free_event_queue(struct wfx_vif *wvif)
 	__wfx_free_event_queue(&list);
 }
 
-void wfx_cqm_bssloss_sm(struct wfx_vif *wvif, int init, int good, int bad)
-{
-	int tx = 0;
-
-	mutex_lock(&wvif->bss_loss_lock);
-	cancel_work_sync(&wvif->bss_params_work);
-
-	if (init) {
-		schedule_delayed_work(&wvif->bss_loss_work, HZ);
-		wvif->bss_loss_state = 0;
-
-		if (!atomic_read(&wvif->wdev->tx_lock))
-			tx = 1;
-	} else if (good) {
-		cancel_delayed_work_sync(&wvif->bss_loss_work);
-		wvif->bss_loss_state = 0;
-		schedule_work(&wvif->bss_params_work);
-	} else if (bad) {
-		/* FIXME Should we just keep going until we time out? */
-		if (wvif->bss_loss_state < 3)
-			tx = 1;
-	} else {
-		cancel_delayed_work_sync(&wvif->bss_loss_work);
-		wvif->bss_loss_state = 0;
-	}
-
-	/* Spit out a NULL packet to our AP if necessary */
-	// FIXME: call ieee80211_beacon_loss/ieee80211_connection_loss instead
-	if (tx) {
-		struct sk_buff *skb;
-		struct ieee80211_hdr *hdr;
-		struct ieee80211_tx_control control = { };
-
-		wvif->bss_loss_state++;
-
-		skb = ieee80211_nullfunc_get(wvif->wdev->hw, wvif->vif, false);
-		if (!skb)
-			goto end;
-		hdr = (struct ieee80211_hdr *)skb->data;
-		memset(IEEE80211_SKB_CB(skb), 0,
-		       sizeof(*IEEE80211_SKB_CB(skb)));
-		IEEE80211_SKB_CB(skb)->control.vif = wvif->vif;
-		IEEE80211_SKB_CB(skb)->driver_rates[0].idx = 0;
-		IEEE80211_SKB_CB(skb)->driver_rates[0].count = 1;
-		IEEE80211_SKB_CB(skb)->driver_rates[1].idx = -1;
-		rcu_read_lock(); // protect control.sta
-		control.sta = ieee80211_find_sta(wvif->vif, hdr->addr1);
-		wfx_tx(wvif->wdev->hw, &control, skb);
-		rcu_read_unlock();
-	}
-end:
-	mutex_unlock(&wvif->bss_loss_lock);
-}
-
 static void wfx_filter_beacon(struct wfx_vif *wvif, bool filter_beacon)
 {
 	const struct hif_ie_table_entry filter_ies[] = {
@@ -339,6 +285,17 @@ static void wfx_event_report_rssi(struct wfx_vif *wvif, u8 raw_rcpi_rssi)
 	ieee80211_cqm_rssi_notify(wvif->vif, cqm_evt, rcpi_rssi, GFP_KERNEL);
 }
 
+static void wfx_beacon_loss_work(struct work_struct *work)
+{
+	struct wfx_vif *wvif = container_of(to_delayed_work(work),
+					    struct wfx_vif, beacon_loss_work);
+	struct ieee80211_bss_conf *bss_conf = &wvif->vif->bss_conf;
+
+	ieee80211_beacon_loss(wvif->vif);
+	schedule_delayed_work(to_delayed_work(work),
+			      msecs_to_jiffies(bss_conf->beacon_int));
+}
+
 static void wfx_event_handler_work(struct work_struct *work)
 {
 	struct wfx_vif *wvif =
@@ -354,12 +311,10 @@ static void wfx_event_handler_work(struct work_struct *work)
 	list_for_each_entry(event, &list, link) {
 		switch (event->evt.event_id) {
 		case HIF_EVENT_IND_BSSLOST:
-			mutex_lock(&wvif->scan_lock);
-			wfx_cqm_bssloss_sm(wvif, 1, 0, 0);
-			mutex_unlock(&wvif->scan_lock);
+			schedule_delayed_work(&wvif->beacon_loss_work, 0);
 			break;
 		case HIF_EVENT_IND_BSSREGAINED:
-			wfx_cqm_bssloss_sm(wvif, 0, 0, 0);
+			cancel_delayed_work(&wvif->beacon_loss_work);
 			break;
 		case HIF_EVENT_IND_RCPI_RSSI:
 			wfx_event_report_rssi(wvif,
@@ -379,26 +334,6 @@ static void wfx_event_handler_work(struct work_struct *work)
 	__wfx_free_event_queue(&list);
 }
 
-static void wfx_bss_loss_work(struct work_struct *work)
-{
-	struct wfx_vif *wvif = container_of(work, struct wfx_vif,
-					    bss_loss_work.work);
-
-	ieee80211_connection_loss(wvif->vif);
-}
-
-static void wfx_bss_params_work(struct work_struct *work)
-{
-	struct wfx_vif *wvif = container_of(work, struct wfx_vif,
-					    bss_params_work);
-
-	mutex_lock(&wvif->wdev->conf_mutex);
-	wvif->bss_params.bss_flags.lost_count_only = 1;
-	hif_set_bss_params(wvif, &wvif->bss_params);
-	wvif->bss_params.bss_flags.lost_count_only = 0;
-	mutex_unlock(&wvif->wdev->conf_mutex);
-}
-
 // Call it with wdev->conf_mutex locked
 static void wfx_do_unjoin(struct wfx_vif *wvif)
 {
@@ -418,10 +353,10 @@ static void wfx_do_unjoin(struct wfx_vif *wvif)
 		hif_set_block_ack_policy(wvif, 0xFF, 0xFF);
 	wfx_free_event_queue(wvif);
 	cancel_work_sync(&wvif->event_handler_work);
-	wfx_cqm_bssloss_sm(wvif, 0, 0, 0);
 
 	memset(&wvif->bss_params, 0, sizeof(wvif->bss_params));
 	wfx_tx_unlock(wvif->wdev);
+	cancel_delayed_work_sync(&wvif->beacon_loss_work);
 }
 
 static void wfx_set_mfp(struct wfx_vif *wvif,
@@ -615,9 +550,9 @@ static void wfx_join_finalize(struct wfx_vif *wvif,
 	else
 		hif_dual_cts_protection(wvif, false);
 
-	wfx_cqm_bssloss_sm(wvif, 0, 0, 0);
-
-	wvif->bss_params.beacon_lost_count = 20;
+	// beacon_loss_count is defined to 7 in net/mac80211/mlme.c. Let's use
+	// the same value.
+	wvif->bss_params.beacon_lost_count = 7;
 	wvif->bss_params.aid = info->aid;
 
 	hif_set_association_mode(wvif, info);
@@ -904,12 +839,10 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 
 	wvif->link_id_map = 1; // link-id 0 is reserved for multicast
 	INIT_WORK(&wvif->update_tim_work, wfx_update_tim_work);
+	INIT_DELAYED_WORK(&wvif->beacon_loss_work, wfx_beacon_loss_work);
 
 	memset(&wvif->bss_params, 0, sizeof(wvif->bss_params));
 
-	mutex_init(&wvif->bss_loss_lock);
-	INIT_DELAYED_WORK(&wvif->bss_loss_work, wfx_bss_loss_work);
-
 	wvif->wep_default_key_id = -1;
 	INIT_WORK(&wvif->wep_key_work, wfx_wep_key_work);
 
@@ -919,7 +852,6 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 
 	init_completion(&wvif->set_pm_mode_complete);
 	complete(&wvif->set_pm_mode_complete);
-	INIT_WORK(&wvif->bss_params_work, wfx_bss_params_work);
 	INIT_WORK(&wvif->tx_policy_upload_work, wfx_tx_policy_upload_work);
 
 	mutex_init(&wvif->scan_lock);
@@ -974,8 +906,8 @@ void wfx_remove_interface(struct ieee80211_hw *hw,
 	/* FIXME: In add to reset MAC address, try to reset interface */
 	hif_set_macaddr(wvif, NULL);
 
-	wfx_cqm_bssloss_sm(wvif, 0, 0, 0);
 	wfx_free_event_queue(wvif);
+	cancel_delayed_work_sync(&wvif->beacon_loss_work);
 
 	wdev->vif[wvif->id] = NULL;
 	wvif->vif = NULL;
diff --git a/drivers/staging/wfx/sta.h b/drivers/staging/wfx/sta.h
index 31097057563a..6d7734c65902 100644
--- a/drivers/staging/wfx/sta.h
+++ b/drivers/staging/wfx/sta.h
@@ -81,7 +81,6 @@ void wfx_unassign_vif_chanctx(struct ieee80211_hw *hw,
 void wfx_suspend_resume_mc(struct wfx_vif *wvif, enum sta_notify_cmd cmd);
 
 // Other Helpers
-void wfx_cqm_bssloss_sm(struct wfx_vif *wvif, int init, int good, int bad);
 u32 wfx_rate_mask_to_hw(struct wfx_dev *wdev, u32 rates);
 
 #endif /* WFX_STA_H */
diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h
index b5d2d0f07740..2747c7cdf4d1 100644
--- a/drivers/staging/wfx/wfx.h
+++ b/drivers/staging/wfx/wfx.h
@@ -69,14 +69,10 @@ struct wfx_vif {
 	int			id;
 	enum wfx_state		state;
 
-	int			bss_loss_state;
-	u32			bss_loss_confirm_id;
-	struct mutex		bss_loss_lock;
-	struct delayed_work	bss_loss_work;
-
 	u32			link_id_map;
 
 	bool			after_dtim_tx_allowed;
+	struct delayed_work	beacon_loss_work;
 
 	s8			wep_default_key_id;
 	struct sk_buff		*wep_pending_skb;
@@ -92,7 +88,6 @@ struct wfx_vif {
 
 	unsigned long		uapsd_mask;
 	struct hif_req_set_bss_params bss_params;
-	struct work_struct	bss_params_work;
 
 	int			join_complete_status;
 
-- 
2.26.1


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

* [PATCH 03/16] staging: wfx: drop useless attribute 'bss_params'
  2020-04-20 16:02 [PATCH 00/16] staging: wfx: rework the handling of the connection loss Jerome Pouiller
  2020-04-20 16:02 ` [PATCH 01/16] staging: wfx: simplify the check if the the device is associated Jerome Pouiller
  2020-04-20 16:02 ` [PATCH 02/16] staging: wfx: use ieee80211_beacon_loss() provided by mac80211 Jerome Pouiller
@ 2020-04-20 16:02 ` Jerome Pouiller
  2020-04-20 16:02 ` [PATCH 04/16] staging: wfx: handle firmware events synchronously Jerome Pouiller
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Jerome Pouiller @ 2020-04-20 16:02 UTC (permalink / raw)
  To: devel, linux-wireless
  Cc: netdev, linux-kernel, Greg Kroah-Hartman, Kalle Valo,
	David S . Miller, Jérôme Pouiller

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

Since wfx_bss_params_work() does not exist anymore, there is no more
reason to keep a copy of bss_params in struct wfx_dev. A local instance
in wfx_join_finalize() is sufficient.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/sta.c | 14 ++++++--------
 drivers/staging/wfx/wfx.h |  1 -
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index ca84724e531c..2253ec2bdbf3 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -354,7 +354,6 @@ static void wfx_do_unjoin(struct wfx_vif *wvif)
 	wfx_free_event_queue(wvif);
 	cancel_work_sync(&wvif->event_handler_work);
 
-	memset(&wvif->bss_params, 0, sizeof(wvif->bss_params));
 	wfx_tx_unlock(wvif->wdev);
 	cancel_delayed_work_sync(&wvif->beacon_loss_work);
 }
@@ -534,15 +533,16 @@ static void wfx_join_finalize(struct wfx_vif *wvif,
 			      struct ieee80211_bss_conf *info)
 {
 	struct ieee80211_sta *sta = NULL;
+	struct hif_req_set_bss_params bss_params = { };
 
 	rcu_read_lock(); // protect sta
 	if (info->bssid && !info->ibss_joined)
 		sta = ieee80211_find_sta(wvif->vif, info->bssid);
 	if (sta)
-		wvif->bss_params.operational_rate_set =
+		bss_params.operational_rate_set =
 			wfx_rate_mask_to_hw(wvif->wdev, sta->supp_rates[wvif->channel->band]);
 	else
-		wvif->bss_params.operational_rate_set = -1;
+		bss_params.operational_rate_set = -1;
 	rcu_read_unlock();
 	if (sta &&
 	    info->ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT)
@@ -552,15 +552,15 @@ static void wfx_join_finalize(struct wfx_vif *wvif,
 
 	// beacon_loss_count is defined to 7 in net/mac80211/mlme.c. Let's use
 	// the same value.
-	wvif->bss_params.beacon_lost_count = 7;
-	wvif->bss_params.aid = info->aid;
+	bss_params.beacon_lost_count = 7;
+	bss_params.aid = info->aid;
 
 	hif_set_association_mode(wvif, info);
 
 	if (!info->ibss_joined) {
 		wvif->state = WFX_STATE_STA;
 		hif_keep_alive_period(wvif, 0);
-		hif_set_bss_params(wvif, &wvif->bss_params);
+		hif_set_bss_params(wvif, &bss_params);
 		hif_set_beacon_wakeup_period(wvif, 1, 1);
 		wfx_update_pm(wvif);
 	}
@@ -841,8 +841,6 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 	INIT_WORK(&wvif->update_tim_work, wfx_update_tim_work);
 	INIT_DELAYED_WORK(&wvif->beacon_loss_work, wfx_beacon_loss_work);
 
-	memset(&wvif->bss_params, 0, sizeof(wvif->bss_params));
-
 	wvif->wep_default_key_id = -1;
 	INIT_WORK(&wvif->wep_key_work, wfx_wep_key_work);
 
diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h
index 2747c7cdf4d1..5484e7c64c3c 100644
--- a/drivers/staging/wfx/wfx.h
+++ b/drivers/staging/wfx/wfx.h
@@ -87,7 +87,6 @@ struct wfx_vif {
 	u8			filter_mcast_addr[8][ETH_ALEN];
 
 	unsigned long		uapsd_mask;
-	struct hif_req_set_bss_params bss_params;
 
 	int			join_complete_status;
 
-- 
2.26.1


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

* [PATCH 04/16] staging: wfx: handle firmware events synchronously
  2020-04-20 16:02 [PATCH 00/16] staging: wfx: rework the handling of the connection loss Jerome Pouiller
                   ` (2 preceding siblings ...)
  2020-04-20 16:02 ` [PATCH 03/16] staging: wfx: drop useless attribute 'bss_params' Jerome Pouiller
@ 2020-04-20 16:02 ` Jerome Pouiller
  2020-04-20 16:03 ` [PATCH 05/16] staging: wfx: also fix network parameters for IBSS networks Jerome Pouiller
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Jerome Pouiller @ 2020-04-20 16:02 UTC (permalink / raw)
  To: devel, linux-wireless
  Cc: netdev, linux-kernel, Greg Kroah-Hartman, Kalle Valo,
	David S . Miller, Jérôme Pouiller

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

Currently, events from firmware are handled in a work queue with a
complex event queue mechanism. It is probably overkill since there is
only two events to handle: bss_loss and CQM events. Handling these
events synchronously is sufficient.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/hif_rx.c | 39 +++++++++++---------
 drivers/staging/wfx/sta.c    | 70 +-----------------------------------
 drivers/staging/wfx/sta.h    |  6 +---
 drivers/staging/wfx/wfx.h    |  4 ---
 4 files changed, 24 insertions(+), 95 deletions(-)

diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c
index 33c22c5d629d..b8d570256498 100644
--- a/drivers/staging/wfx/hif_rx.c
+++ b/drivers/staging/wfx/hif_rx.c
@@ -158,26 +158,31 @@ static int hif_event_indication(struct wfx_dev *wdev,
 {
 	struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface);
 	const struct hif_ind_event *body = buf;
-	struct wfx_hif_event *event;
-	int first;
 
-	WARN_ON(!wvif);
-	if (!wvif)
+	if (!wvif) {
+		dev_warn(wdev->dev, "received event for non-existent vif\n");
 		return 0;
+	}
 
-	event = kzalloc(sizeof(*event), GFP_KERNEL);
-	if (!event)
-		return -ENOMEM;
-
-	memcpy(&event->evt, body, sizeof(struct hif_ind_event));
-	spin_lock(&wvif->event_queue_lock);
-	first = list_empty(&wvif->event_queue);
-	list_add_tail(&event->link, &wvif->event_queue);
-	spin_unlock(&wvif->event_queue_lock);
-
-	if (first)
-		schedule_work(&wvif->event_handler_work);
-
+	switch (body->event_id) {
+	case HIF_EVENT_IND_RCPI_RSSI:
+		wfx_event_report_rssi(wvif, body->event_data.rcpi_rssi);
+		break;
+	case HIF_EVENT_IND_BSSLOST:
+		schedule_delayed_work(&wvif->beacon_loss_work, 0);
+		break;
+	case HIF_EVENT_IND_BSSREGAINED:
+		cancel_delayed_work(&wvif->beacon_loss_work);
+		dev_dbg(wdev->dev, "ignore BSSREGAINED indication\n");
+		break;
+	case HIF_EVENT_IND_PS_MODE_ERROR:
+		dev_warn(wdev->dev, "error while processing power save request\n");
+		break;
+	default:
+		dev_warn(wdev->dev, "unhandled event indication: %.2x\n",
+			 body->event_id);
+		break;
+	}
 	return 0;
 }
 
diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index 2253ec2bdbf3..a0c841658a0b 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -38,27 +38,6 @@ u32 wfx_rate_mask_to_hw(struct wfx_dev *wdev, u32 rates)
 	return ret;
 }
 
-static void __wfx_free_event_queue(struct list_head *list)
-{
-	struct wfx_hif_event *event, *tmp;
-
-	list_for_each_entry_safe(event, tmp, list, link) {
-		list_del(&event->link);
-		kfree(event);
-	}
-}
-
-static void wfx_free_event_queue(struct wfx_vif *wvif)
-{
-	LIST_HEAD(list);
-
-	spin_lock(&wvif->event_queue_lock);
-	list_splice_init(&wvif->event_queue, &list);
-	spin_unlock(&wvif->event_queue_lock);
-
-	__wfx_free_event_queue(&list);
-}
-
 static void wfx_filter_beacon(struct wfx_vif *wvif, bool filter_beacon)
 {
 	const struct hif_ie_table_entry filter_ies[] = {
@@ -269,7 +248,7 @@ int wfx_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
 
 /* WSM callbacks */
 
-static void wfx_event_report_rssi(struct wfx_vif *wvif, u8 raw_rcpi_rssi)
+void wfx_event_report_rssi(struct wfx_vif *wvif, u8 raw_rcpi_rssi)
 {
 	/* RSSI: signed Q8.0, RCPI: unsigned Q7.1
 	 * RSSI = RCPI / 2 - 110
@@ -296,44 +275,6 @@ static void wfx_beacon_loss_work(struct work_struct *work)
 			      msecs_to_jiffies(bss_conf->beacon_int));
 }
 
-static void wfx_event_handler_work(struct work_struct *work)
-{
-	struct wfx_vif *wvif =
-		container_of(work, struct wfx_vif, event_handler_work);
-	struct wfx_hif_event *event;
-
-	LIST_HEAD(list);
-
-	spin_lock(&wvif->event_queue_lock);
-	list_splice_init(&wvif->event_queue, &list);
-	spin_unlock(&wvif->event_queue_lock);
-
-	list_for_each_entry(event, &list, link) {
-		switch (event->evt.event_id) {
-		case HIF_EVENT_IND_BSSLOST:
-			schedule_delayed_work(&wvif->beacon_loss_work, 0);
-			break;
-		case HIF_EVENT_IND_BSSREGAINED:
-			cancel_delayed_work(&wvif->beacon_loss_work);
-			break;
-		case HIF_EVENT_IND_RCPI_RSSI:
-			wfx_event_report_rssi(wvif,
-					      event->evt.event_data.rcpi_rssi);
-			break;
-		case HIF_EVENT_IND_PS_MODE_ERROR:
-			dev_warn(wvif->wdev->dev,
-				 "error while processing power save request\n");
-			break;
-		default:
-			dev_warn(wvif->wdev->dev,
-				 "unhandled event indication: %.2x\n",
-				 event->evt.event_id);
-			break;
-		}
-	}
-	__wfx_free_event_queue(&list);
-}
-
 // Call it with wdev->conf_mutex locked
 static void wfx_do_unjoin(struct wfx_vif *wvif)
 {
@@ -351,9 +292,6 @@ static void wfx_do_unjoin(struct wfx_vif *wvif)
 	wfx_tx_policy_init(wvif);
 	if (wvif_count(wvif->wdev) <= 1)
 		hif_set_block_ack_policy(wvif, 0xFF, 0xFF);
-	wfx_free_event_queue(wvif);
-	cancel_work_sync(&wvif->event_handler_work);
-
 	wfx_tx_unlock(wvif->wdev);
 	cancel_delayed_work_sync(&wvif->beacon_loss_work);
 }
@@ -844,10 +782,6 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 	wvif->wep_default_key_id = -1;
 	INIT_WORK(&wvif->wep_key_work, wfx_wep_key_work);
 
-	spin_lock_init(&wvif->event_queue_lock);
-	INIT_LIST_HEAD(&wvif->event_queue);
-	INIT_WORK(&wvif->event_handler_work, wfx_event_handler_work);
-
 	init_completion(&wvif->set_pm_mode_complete);
 	complete(&wvif->set_pm_mode_complete);
 	INIT_WORK(&wvif->tx_policy_upload_work, wfx_tx_policy_upload_work);
@@ -904,9 +838,7 @@ void wfx_remove_interface(struct ieee80211_hw *hw,
 	/* FIXME: In add to reset MAC address, try to reset interface */
 	hif_set_macaddr(wvif, NULL);
 
-	wfx_free_event_queue(wvif);
 	cancel_delayed_work_sync(&wvif->beacon_loss_work);
-
 	wdev->vif[wvif->id] = NULL;
 	wvif->vif = NULL;
 
diff --git a/drivers/staging/wfx/sta.h b/drivers/staging/wfx/sta.h
index 6d7734c65902..767b794fa398 100644
--- a/drivers/staging/wfx/sta.h
+++ b/drivers/staging/wfx/sta.h
@@ -23,11 +23,6 @@ enum wfx_state {
 	WFX_STATE_AP,
 };
 
-struct wfx_hif_event {
-	struct list_head link;
-	struct hif_ind_event evt;
-};
-
 struct wfx_sta_priv {
 	int link_id;
 	int vif_id;
@@ -79,6 +74,7 @@ void wfx_unassign_vif_chanctx(struct ieee80211_hw *hw,
 
 // WSM Callbacks
 void wfx_suspend_resume_mc(struct wfx_vif *wvif, enum sta_notify_cmd cmd);
+void wfx_event_report_rssi(struct wfx_vif *wvif, u8 raw_rcpi_rssi);
 
 // Other Helpers
 u32 wfx_rate_mask_to_hw(struct wfx_dev *wdev, u32 rates);
diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h
index 5484e7c64c3c..913b80d024a3 100644
--- a/drivers/staging/wfx/wfx.h
+++ b/drivers/staging/wfx/wfx.h
@@ -98,10 +98,6 @@ struct wfx_vif {
 	struct ieee80211_scan_request *scan_req;
 
 	struct completion	set_pm_mode_complete;
-
-	struct list_head	event_queue;
-	spinlock_t		event_queue_lock;
-	struct work_struct	event_handler_work;
 };
 
 static inline struct wfx_vif *wdev_to_wvif(struct wfx_dev *wdev, int vif_id)
-- 
2.26.1


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

* [PATCH 05/16] staging: wfx: also fix network parameters for IBSS networks
  2020-04-20 16:02 [PATCH 00/16] staging: wfx: rework the handling of the connection loss Jerome Pouiller
                   ` (3 preceding siblings ...)
  2020-04-20 16:02 ` [PATCH 04/16] staging: wfx: handle firmware events synchronously Jerome Pouiller
@ 2020-04-20 16:03 ` Jerome Pouiller
  2020-04-20 16:03 ` [PATCH 06/16] staging: wfx: dual CTS is never necessary Jerome Pouiller
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Jerome Pouiller @ 2020-04-20 16:03 UTC (permalink / raw)
  To: devel, linux-wireless
  Cc: netdev, linux-kernel, Greg Kroah-Hartman, Kalle Valo,
	David S . Miller, Jérôme Pouiller

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

Current code skip some configuration during joining an IBSS network.
Indeed, it seems that this configuration is not used in IBSS. However,
it would be harmless to set them. In add, we would prefer to keep
association processes for ad-hoc and managed networks the closest as
possible. It also ensures the values of internal parameters of the
firmware.

Therefore, apply them unconditionally.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/sta.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index a0c841658a0b..a0c7737903b9 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -494,14 +494,13 @@ static void wfx_join_finalize(struct wfx_vif *wvif,
 	bss_params.aid = info->aid;
 
 	hif_set_association_mode(wvif, info);
+	hif_keep_alive_period(wvif, 0);
+	hif_set_bss_params(wvif, &bss_params);
+	hif_set_beacon_wakeup_period(wvif, 1, 1);
+	wfx_update_pm(wvif);
 
-	if (!info->ibss_joined) {
+	if (!info->ibss_joined)
 		wvif->state = WFX_STATE_STA;
-		hif_keep_alive_period(wvif, 0);
-		hif_set_bss_params(wvif, &bss_params);
-		hif_set_beacon_wakeup_period(wvif, 1, 1);
-		wfx_update_pm(wvif);
-	}
 }
 
 int wfx_join_ibss(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
-- 
2.26.1


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

* [PATCH 06/16] staging: wfx: dual CTS is never necessary
  2020-04-20 16:02 [PATCH 00/16] staging: wfx: rework the handling of the connection loss Jerome Pouiller
                   ` (4 preceding siblings ...)
  2020-04-20 16:03 ` [PATCH 05/16] staging: wfx: also fix network parameters for IBSS networks Jerome Pouiller
@ 2020-04-20 16:03 ` Jerome Pouiller
  2020-04-20 16:03 ` [PATCH 07/16] staging: wfx: field operational_rate_set is ignored by firmware Jerome Pouiller
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Jerome Pouiller @ 2020-04-20 16:03 UTC (permalink / raw)
  To: devel, linux-wireless
  Cc: netdev, linux-kernel, Greg Kroah-Hartman, Kalle Valo,
	David S . Miller, Jérôme Pouiller

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

Dual CTS is only necessary when sending/receiving STBC data. However,
the chip does not support STBC, so it is never necessary to enable
double CTS.

We can simplify the code.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/hif_api_mib.h |  6 ------
 drivers/staging/wfx/hif_tx_mib.c  | 10 ----------
 drivers/staging/wfx/hif_tx_mib.h  |  1 -
 drivers/staging/wfx/sta.c         |  6 ------
 4 files changed, 23 deletions(-)

diff --git a/drivers/staging/wfx/hif_api_mib.h b/drivers/staging/wfx/hif_api_mib.h
index 9f30cf503ad5..6f1434795fa8 100644
--- a/drivers/staging/wfx/hif_api_mib.h
+++ b/drivers/staging/wfx/hif_api_mib.h
@@ -379,12 +379,6 @@ struct hif_mib_protected_mgmt_policy {
 	u8     reserved2[3];
 } __packed;
 
-struct hif_mib_set_ht_protection {
-	u8     dual_cts_prot:1;
-	u8     reserved1:7;
-	u8     reserved2[3];
-} __packed;
-
 struct hif_mib_keep_alive_period {
 	__le16 keep_alive_period;
 	u8     reserved[2];
diff --git a/drivers/staging/wfx/hif_tx_mib.c b/drivers/staging/wfx/hif_tx_mib.c
index 1d26d740bd0b..f04116ecb373 100644
--- a/drivers/staging/wfx/hif_tx_mib.c
+++ b/drivers/staging/wfx/hif_tx_mib.c
@@ -365,16 +365,6 @@ int hif_slot_time(struct wfx_vif *wvif, int val)
 			     &arg, sizeof(arg));
 }
 
-int hif_dual_cts_protection(struct wfx_vif *wvif, bool enable)
-{
-	struct hif_mib_set_ht_protection arg = {
-		.dual_cts_prot = enable,
-	};
-
-	return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_SET_HT_PROTECTION,
-			     &arg, sizeof(arg));
-}
-
 int hif_wep_default_key_id(struct wfx_vif *wvif, int val)
 {
 	struct hif_mib_wep_default_key_id arg = {
diff --git a/drivers/staging/wfx/hif_tx_mib.h b/drivers/staging/wfx/hif_tx_mib.h
index 0f8b3bd9f14e..bb7c104a03d8 100644
--- a/drivers/staging/wfx/hif_tx_mib.h
+++ b/drivers/staging/wfx/hif_tx_mib.h
@@ -52,7 +52,6 @@ int hif_use_multi_tx_conf(struct wfx_dev *wdev, bool enable);
 int hif_set_uapsd_info(struct wfx_vif *wvif, unsigned long val);
 int hif_erp_use_protection(struct wfx_vif *wvif, bool enable);
 int hif_slot_time(struct wfx_vif *wvif, int val);
-int hif_dual_cts_protection(struct wfx_vif *wvif, bool enable);
 int hif_wep_default_key_id(struct wfx_vif *wvif, int val);
 int hif_rts_threshold(struct wfx_vif *wvif, int val);
 
diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index a0c7737903b9..2a9c7f28d934 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -482,12 +482,6 @@ static void wfx_join_finalize(struct wfx_vif *wvif,
 	else
 		bss_params.operational_rate_set = -1;
 	rcu_read_unlock();
-	if (sta &&
-	    info->ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT)
-		hif_dual_cts_protection(wvif, true);
-	else
-		hif_dual_cts_protection(wvif, false);
-
 	// beacon_loss_count is defined to 7 in net/mac80211/mlme.c. Let's use
 	// the same value.
 	bss_params.beacon_lost_count = 7;
-- 
2.26.1


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

* [PATCH 07/16] staging: wfx: field operational_rate_set is ignored by firmware
  2020-04-20 16:02 [PATCH 00/16] staging: wfx: rework the handling of the connection loss Jerome Pouiller
                   ` (5 preceding siblings ...)
  2020-04-20 16:03 ` [PATCH 06/16] staging: wfx: dual CTS is never necessary Jerome Pouiller
@ 2020-04-20 16:03 ` Jerome Pouiller
  2020-04-20 16:03 ` [PATCH 08/16] staging: wfx: simplify hif_set_bss_params() Jerome Pouiller
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Jerome Pouiller @ 2020-04-20 16:03 UTC (permalink / raw)
  To: devel, linux-wireless
  Cc: netdev, linux-kernel, Greg Kroah-Hartman, Kalle Valo,
	David S . Miller, Jérôme Pouiller

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

The field bss_params.operational_rate_set is ignore by the firmware. It
is not necessary to send it. This change greatly simplify
wfx_join_finalize(). It is no more necessary to get sta and it allow to
save a RCU.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/sta.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index 2a9c7f28d934..6cdb40a05991 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -470,22 +470,12 @@ void wfx_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 static void wfx_join_finalize(struct wfx_vif *wvif,
 			      struct ieee80211_bss_conf *info)
 {
-	struct ieee80211_sta *sta = NULL;
-	struct hif_req_set_bss_params bss_params = { };
-
-	rcu_read_lock(); // protect sta
-	if (info->bssid && !info->ibss_joined)
-		sta = ieee80211_find_sta(wvif->vif, info->bssid);
-	if (sta)
-		bss_params.operational_rate_set =
-			wfx_rate_mask_to_hw(wvif->wdev, sta->supp_rates[wvif->channel->band]);
-	else
-		bss_params.operational_rate_set = -1;
-	rcu_read_unlock();
-	// beacon_loss_count is defined to 7 in net/mac80211/mlme.c. Let's use
-	// the same value.
-	bss_params.beacon_lost_count = 7;
-	bss_params.aid = info->aid;
+	struct hif_req_set_bss_params bss_params = {
+		// beacon_loss_count is defined to 7 in net/mac80211/mlme.c.
+		// Let's use the same value.
+		.beacon_lost_count = 7,
+		.aid = info->aid,
+	};
 
 	hif_set_association_mode(wvif, info);
 	hif_keep_alive_period(wvif, 0);
-- 
2.26.1


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

* [PATCH 08/16] staging: wfx: simplify hif_set_bss_params()
  2020-04-20 16:02 [PATCH 00/16] staging: wfx: rework the handling of the connection loss Jerome Pouiller
                   ` (6 preceding siblings ...)
  2020-04-20 16:03 ` [PATCH 07/16] staging: wfx: field operational_rate_set is ignored by firmware Jerome Pouiller
@ 2020-04-20 16:03 ` Jerome Pouiller
  2020-04-20 16:03 ` [PATCH 09/16] staging: wfx: drop useless update of field basic_rate_set Jerome Pouiller
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Jerome Pouiller @ 2020-04-20 16:03 UTC (permalink / raw)
  To: devel, linux-wireless
  Cc: netdev, linux-kernel, Greg Kroah-Hartman, Kalle Valo,
	David S . Miller, Jérôme Pouiller

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

The structure hif_req_set_bss_params come from hardware API. It is not
intended to be manipulated in upper layers of the driver.

In add, current code for hif_req_set_bss_params() is too dumb. It should
pack data with hardware representation instead of leaving all work to
the caller.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/hif_tx.c | 12 +++++-------
 drivers/staging/wfx/hif_tx.h |  3 +--
 drivers/staging/wfx/sta.c    | 11 +++--------
 3 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/wfx/hif_tx.c b/drivers/staging/wfx/hif_tx.c
index f49ab67e1a6d..17721cf9e2a3 100644
--- a/drivers/staging/wfx/hif_tx.c
+++ b/drivers/staging/wfx/hif_tx.c
@@ -321,17 +321,15 @@ int hif_join(struct wfx_vif *wvif, const struct ieee80211_bss_conf *conf,
 	return ret;
 }
 
-int hif_set_bss_params(struct wfx_vif *wvif,
-		       const struct hif_req_set_bss_params *arg)
+int hif_set_bss_params(struct wfx_vif *wvif, int aid, int beacon_lost_count)
 {
 	int ret;
 	struct hif_msg *hif;
-	struct hif_req_set_bss_params *body = wfx_alloc_hif(sizeof(*body),
-							    &hif);
+	struct hif_req_set_bss_params *body =
+		wfx_alloc_hif(sizeof(*body), &hif);
 
-	memcpy(body, arg, sizeof(*body));
-	cpu_to_le16s(&body->aid);
-	cpu_to_le32s(&body->operational_rate_set);
+	body->aid = cpu_to_le16(aid);
+	body->beacon_lost_count = beacon_lost_count;
 	wfx_fill_header(hif, wvif->id, HIF_REQ_ID_SET_BSS_PARAMS,
 			sizeof(*body));
 	ret = wfx_cmd_send(wvif->wdev, hif, NULL, 0, false);
diff --git a/drivers/staging/wfx/hif_tx.h b/drivers/staging/wfx/hif_tx.h
index f8520a14c14c..038ea54e2574 100644
--- a/drivers/staging/wfx/hif_tx.h
+++ b/drivers/staging/wfx/hif_tx.h
@@ -48,8 +48,7 @@ int hif_stop_scan(struct wfx_vif *wvif);
 int hif_join(struct wfx_vif *wvif, const struct ieee80211_bss_conf *conf,
 	     struct ieee80211_channel *channel, const u8 *ssid, int ssidlen);
 int hif_set_pm(struct wfx_vif *wvif, bool ps, int dynamic_ps_timeout);
-int hif_set_bss_params(struct wfx_vif *wvif,
-		       const struct hif_req_set_bss_params *arg);
+int hif_set_bss_params(struct wfx_vif *wvif, int aid, int beacon_lost_count);
 int hif_add_key(struct wfx_dev *wdev, const struct hif_req_add_key *arg);
 int hif_remove_key(struct wfx_dev *wdev, int idx);
 int hif_set_edca_queue_params(struct wfx_vif *wvif, u16 queue,
diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index 6cdb40a05991..1cc437f0bc81 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -470,16 +470,11 @@ void wfx_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 static void wfx_join_finalize(struct wfx_vif *wvif,
 			      struct ieee80211_bss_conf *info)
 {
-	struct hif_req_set_bss_params bss_params = {
-		// beacon_loss_count is defined to 7 in net/mac80211/mlme.c.
-		// Let's use the same value.
-		.beacon_lost_count = 7,
-		.aid = info->aid,
-	};
-
 	hif_set_association_mode(wvif, info);
 	hif_keep_alive_period(wvif, 0);
-	hif_set_bss_params(wvif, &bss_params);
+	// beacon_loss_count is defined to 7 in net/mac80211/mlme.c. Let's use
+	// the same value.
+	hif_set_bss_params(wvif, info->aid, 7);
 	hif_set_beacon_wakeup_period(wvif, 1, 1);
 	wfx_update_pm(wvif);
 
-- 
2.26.1


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

* [PATCH 09/16] staging: wfx: drop useless update of field basic_rate_set
  2020-04-20 16:02 [PATCH 00/16] staging: wfx: rework the handling of the connection loss Jerome Pouiller
                   ` (7 preceding siblings ...)
  2020-04-20 16:03 ` [PATCH 08/16] staging: wfx: simplify hif_set_bss_params() Jerome Pouiller
@ 2020-04-20 16:03 ` Jerome Pouiller
  2020-04-20 16:03 ` [PATCH 10/16] staging: wfx: introduce wfx_set_default_unicast_key() Jerome Pouiller
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Jerome Pouiller @ 2020-04-20 16:03 UTC (permalink / raw)
  To: devel, linux-wireless
  Cc: netdev, linux-kernel, Greg Kroah-Hartman, Kalle Valo,
	David S . Miller, Jérôme Pouiller

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

Basic Rates are already set by hif_join(). hif_join() is also able to
manage possible changes after association.

Firmware also allows to change the Basic Rates with
hif_set_association_mode() but it does not bring anything in our case.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/hif_tx_mib.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/wfx/hif_tx_mib.c b/drivers/staging/wfx/hif_tx_mib.c
index f04116ecb373..16f4908055af 100644
--- a/drivers/staging/wfx/hif_tx_mib.c
+++ b/drivers/staging/wfx/hif_tx_mib.c
@@ -190,15 +190,12 @@ int hif_set_block_ack_policy(struct wfx_vif *wvif,
 int hif_set_association_mode(struct wfx_vif *wvif,
 			     struct ieee80211_bss_conf *info)
 {
-	int basic_rates = wfx_rate_mask_to_hw(wvif->wdev, info->basic_rates);
 	struct ieee80211_sta *sta = NULL;
 	struct hif_mib_set_association_mode val = {
 		.preambtype_use = 1,
 		.mode = 1,
-		.rateset = 1,
 		.spacing = 1,
 		.short_preamble = info->use_short_preamble,
-		.basic_rate_set = cpu_to_le32(basic_rates)
 	};
 
 	rcu_read_lock(); // protect sta
-- 
2.26.1


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

* [PATCH 10/16] staging: wfx: introduce wfx_set_default_unicast_key()
  2020-04-20 16:02 [PATCH 00/16] staging: wfx: rework the handling of the connection loss Jerome Pouiller
                   ` (8 preceding siblings ...)
  2020-04-20 16:03 ` [PATCH 09/16] staging: wfx: drop useless update of field basic_rate_set Jerome Pouiller
@ 2020-04-20 16:03 ` Jerome Pouiller
  2020-04-20 16:03 ` [PATCH 11/16] staging: wfx: keys are kept during whole firmware life Jerome Pouiller
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Jerome Pouiller @ 2020-04-20 16:03 UTC (permalink / raw)
  To: devel, linux-wireless
  Cc: netdev, linux-kernel, Greg Kroah-Hartman, Kalle Valo,
	David S . Miller, Jérôme Pouiller

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

Currently code handle WEP keys manually. It is far easier to use
the set_default_unicast_key() callback provided by mac80211.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/key.c   | 10 ----------
 drivers/staging/wfx/key.h   |  1 -
 drivers/staging/wfx/main.c  |  1 +
 drivers/staging/wfx/queue.c | 33 ---------------------------------
 drivers/staging/wfx/sta.c   | 18 ++++++++----------
 drivers/staging/wfx/sta.h   |  2 ++
 drivers/staging/wfx/wfx.h   |  4 ----
 7 files changed, 11 insertions(+), 58 deletions(-)

diff --git a/drivers/staging/wfx/key.c b/drivers/staging/wfx/key.c
index 7b79b6175372..e3853cbf431c 100644
--- a/drivers/staging/wfx/key.c
+++ b/drivers/staging/wfx/key.c
@@ -257,13 +257,3 @@ int wfx_upload_keys(struct wfx_vif *wvif)
 	return 0;
 }
 
-void wfx_wep_key_work(struct work_struct *work)
-{
-	struct wfx_vif *wvif = container_of(work, struct wfx_vif, wep_key_work);
-
-	wfx_tx_flush(wvif->wdev);
-	hif_wep_default_key_id(wvif, wvif->wep_default_key_id);
-	wfx_pending_requeue(wvif->wdev, wvif->wep_pending_skb);
-	wvif->wep_pending_skb = NULL;
-	wfx_tx_unlock(wvif->wdev);
-}
diff --git a/drivers/staging/wfx/key.h b/drivers/staging/wfx/key.h
index 9436ccdf4d3b..2c334f9fb2a8 100644
--- a/drivers/staging/wfx/key.h
+++ b/drivers/staging/wfx/key.h
@@ -17,6 +17,5 @@ int wfx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 		struct ieee80211_vif *vif, struct ieee80211_sta *sta,
 		struct ieee80211_key_conf *key);
 int wfx_upload_keys(struct wfx_vif *wvif);
-void wfx_wep_key_work(struct work_struct *work);
 
 #endif /* WFX_STA_H */
diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c
index 8a2c96dacd63..cc7f924f3106 100644
--- a/drivers/staging/wfx/main.c
+++ b/drivers/staging/wfx/main.c
@@ -145,6 +145,7 @@ static const struct ieee80211_ops wfx_ops = {
 	.set_tim		= wfx_set_tim,
 	.set_key		= wfx_set_key,
 	.set_rts_threshold	= wfx_set_rts_threshold,
+	.set_default_unicast_key = wfx_set_default_unicast_key,
 	.bss_info_changed	= wfx_bss_info_changed,
 	.prepare_multicast	= wfx_prepare_multicast,
 	.configure_filter	= wfx_configure_filter,
diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c
index e9573e9d009f..2f6f9faf15be 100644
--- a/drivers/staging/wfx/queue.c
+++ b/drivers/staging/wfx/queue.c
@@ -254,36 +254,6 @@ bool wfx_tx_queues_has_cab(struct wfx_vif *wvif)
 	return false;
 }
 
-static bool wfx_handle_tx_data(struct wfx_dev *wdev, struct sk_buff *skb)
-{
-	struct hif_req_tx *req = wfx_skb_txreq(skb);
-	struct ieee80211_key_conf *hw_key = wfx_skb_tx_priv(skb)->hw_key;
-	struct ieee80211_hdr *frame =
-		(struct ieee80211_hdr *)(req->frame + req->data_flags.fc_offset);
-	struct wfx_vif *wvif =
-		wdev_to_wvif(wdev, ((struct hif_msg *)skb->data)->interface);
-
-	if (!wvif)
-		return false;
-
-	// FIXME: identify the exact scenario matched by this condition. Does it
-	// happen yet?
-	if (ieee80211_has_protected(frame->frame_control) &&
-	    hw_key && hw_key->keyidx != wvif->wep_default_key_id &&
-	    (hw_key->cipher == WLAN_CIPHER_SUITE_WEP40 ||
-	     hw_key->cipher == WLAN_CIPHER_SUITE_WEP104)) {
-		wfx_tx_lock(wdev);
-		WARN_ON(wvif->wep_pending_skb);
-		wvif->wep_default_key_id = hw_key->keyidx;
-		wvif->wep_pending_skb = skb;
-		if (!schedule_work(&wvif->wep_key_work))
-			wfx_tx_unlock(wdev);
-		return true;
-	} else {
-		return false;
-	}
-}
-
 static struct sk_buff *wfx_tx_queues_get_skb(struct wfx_dev *wdev)
 {
 	struct wfx_queue *sorted_queues[IEEE80211_NUM_ACS];
@@ -348,9 +318,6 @@ struct hif_msg *wfx_tx_queues_get(struct wfx_dev *wdev)
 			return NULL;
 		skb_queue_tail(&wdev->tx_pending, skb);
 		wake_up(&wdev->tx_dequeue);
-		// FIXME: is it useful?
-		if (wfx_handle_tx_data(wdev, skb))
-			continue;
 		tx_priv = wfx_skb_tx_priv(skb);
 		tx_priv->xmit_timestamp = ktime_get();
 		return (struct hif_msg *)skb->data;
diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index 1cc437f0bc81..876952f39fc9 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -275,6 +275,14 @@ static void wfx_beacon_loss_work(struct work_struct *work)
 			      msecs_to_jiffies(bss_conf->beacon_int));
 }
 
+void wfx_set_default_unicast_key(struct ieee80211_hw *hw,
+				 struct ieee80211_vif *vif, int idx)
+{
+	struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
+
+	hif_wep_default_key_id(wvif, idx);
+}
+
 // Call it with wdev->conf_mutex locked
 static void wfx_do_unjoin(struct wfx_vif *wvif)
 {
@@ -560,13 +568,6 @@ void wfx_bss_info_changed(struct ieee80211_hw *hw,
 		wfx_filter_beacon(wvif, true);
 	}
 
-	/* assoc/disassoc, or maybe AID changed */
-	if (changed & BSS_CHANGED_ASSOC) {
-		wfx_tx_lock_flush(wdev);
-		wvif->wep_default_key_id = -1;
-		wfx_tx_unlock(wdev);
-	}
-
 	if (changed & BSS_CHANGED_ASSOC) {
 		if (info->assoc || info->ibss_joined)
 			wfx_join_finalize(wvif, info);
@@ -757,9 +758,6 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 	INIT_WORK(&wvif->update_tim_work, wfx_update_tim_work);
 	INIT_DELAYED_WORK(&wvif->beacon_loss_work, wfx_beacon_loss_work);
 
-	wvif->wep_default_key_id = -1;
-	INIT_WORK(&wvif->wep_key_work, wfx_wep_key_work);
-
 	init_completion(&wvif->set_pm_mode_complete);
 	complete(&wvif->set_pm_mode_complete);
 	INIT_WORK(&wvif->tx_policy_upload_work, wfx_tx_policy_upload_work);
diff --git a/drivers/staging/wfx/sta.h b/drivers/staging/wfx/sta.h
index 767b794fa398..fe728e642cfc 100644
--- a/drivers/staging/wfx/sta.h
+++ b/drivers/staging/wfx/sta.h
@@ -36,6 +36,8 @@ int wfx_start(struct ieee80211_hw *hw);
 void wfx_stop(struct ieee80211_hw *hw);
 int wfx_config(struct ieee80211_hw *hw, u32 changed);
 int wfx_set_rts_threshold(struct ieee80211_hw *hw, u32 value);
+void wfx_set_default_unicast_key(struct ieee80211_hw *hw,
+				 struct ieee80211_vif *vif, int idx);
 u64 wfx_prepare_multicast(struct ieee80211_hw *hw,
 			  struct netdev_hw_addr_list *mc_list);
 void wfx_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags,
diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h
index 913b80d024a3..0fa88de64907 100644
--- a/drivers/staging/wfx/wfx.h
+++ b/drivers/staging/wfx/wfx.h
@@ -74,10 +74,6 @@ struct wfx_vif {
 	bool			after_dtim_tx_allowed;
 	struct delayed_work	beacon_loss_work;
 
-	s8			wep_default_key_id;
-	struct sk_buff		*wep_pending_skb;
-	struct work_struct	wep_key_work;
-
 	struct tx_policy_cache	tx_policy_cache;
 	struct work_struct	tx_policy_upload_work;
 
-- 
2.26.1


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

* [PATCH 11/16] staging: wfx: keys are kept during whole firmware life
  2020-04-20 16:02 [PATCH 00/16] staging: wfx: rework the handling of the connection loss Jerome Pouiller
                   ` (9 preceding siblings ...)
  2020-04-20 16:03 ` [PATCH 10/16] staging: wfx: introduce wfx_set_default_unicast_key() Jerome Pouiller
@ 2020-04-20 16:03 ` Jerome Pouiller
  2020-04-20 16:03 ` [PATCH 12/16] staging: wfx: drop protection for asynchronous join during scan Jerome Pouiller
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Jerome Pouiller @ 2020-04-20 16:03 UTC (permalink / raw)
  To: devel, linux-wireless
  Cc: netdev, linux-kernel, Greg Kroah-Hartman, Kalle Valo,
	David S . Miller, Jérôme Pouiller

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

Keys sent to the firmware are never reset. So, it is not necessary to
re-upload them after hif_reset(). Thus, it is no more necessary to keep
a copy of the keys in struct wfx_dev.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/key.c | 58 ++++++++++++++-------------------------
 drivers/staging/wfx/key.h |  1 -
 drivers/staging/wfx/sta.c |  4 ---
 drivers/staging/wfx/wfx.h |  1 -
 4 files changed, 20 insertions(+), 44 deletions(-)

diff --git a/drivers/staging/wfx/key.c b/drivers/staging/wfx/key.c
index e3853cbf431c..ceb57cbdfefd 100644
--- a/drivers/staging/wfx/key.c
+++ b/drivers/staging/wfx/key.c
@@ -21,14 +21,12 @@ static int wfx_alloc_key(struct wfx_dev *wdev)
 		return -1;
 
 	wdev->key_map |= BIT(idx);
-	wdev->keys[idx].entry_index = idx;
 	return idx;
 }
 
 static void wfx_free_key(struct wfx_dev *wdev, int idx)
 {
 	WARN(!(wdev->key_map & BIT(idx)), "inconsistent key allocation");
-	memset(&wdev->keys[idx], 0, sizeof(wdev->keys[idx]));
 	wdev->key_map &= ~BIT(idx);
 }
 
@@ -160,7 +158,7 @@ static int wfx_add_key(struct wfx_vif *wvif, struct ieee80211_sta *sta,
 		       struct ieee80211_key_conf *key)
 {
 	int ret;
-	struct hif_req_add_key *k;
+	struct hif_req_add_key k = { };
 	struct ieee80211_key_seq seq;
 	struct wfx_dev *wdev = wvif->wdev;
 	int idx = wfx_alloc_key(wvif->wdev);
@@ -170,44 +168,44 @@ static int wfx_add_key(struct wfx_vif *wvif, struct ieee80211_sta *sta,
 	ieee80211_get_key_rx_seq(key, 0, &seq);
 	if (idx < 0)
 		return -EINVAL;
-	k = &wdev->keys[idx];
-	k->int_id = wvif->id;
+	k.int_id = wvif->id;
+	k.entry_index = idx;
 	if (key->cipher == WLAN_CIPHER_SUITE_WEP40 ||
 	    key->cipher ==  WLAN_CIPHER_SUITE_WEP104) {
 		if (pairwise)
-			k->type = fill_wep_pair(&k->key.wep_pairwise_key, key,
-						sta->addr);
+			k.type = fill_wep_pair(&k.key.wep_pairwise_key, key,
+					       sta->addr);
 		else
-			k->type = fill_wep_group(&k->key.wep_group_key, key);
+			k.type = fill_wep_group(&k.key.wep_group_key, key);
 	} else if (key->cipher == WLAN_CIPHER_SUITE_TKIP) {
 		if (pairwise)
-			k->type = fill_tkip_pair(&k->key.tkip_pairwise_key, key,
-						 sta->addr);
+			k.type = fill_tkip_pair(&k.key.tkip_pairwise_key, key,
+						sta->addr);
 		else
-			k->type = fill_tkip_group(&k->key.tkip_group_key, key,
-						  &seq, wvif->vif->type);
+			k.type = fill_tkip_group(&k.key.tkip_group_key, key,
+						 &seq, wvif->vif->type);
 	} else if (key->cipher == WLAN_CIPHER_SUITE_CCMP) {
 		if (pairwise)
-			k->type = fill_ccmp_pair(&k->key.aes_pairwise_key, key,
-						 sta->addr);
+			k.type = fill_ccmp_pair(&k.key.aes_pairwise_key, key,
+						sta->addr);
 		else
-			k->type = fill_ccmp_group(&k->key.aes_group_key, key,
-						  &seq);
+			k.type = fill_ccmp_group(&k.key.aes_group_key, key,
+						 &seq);
 	} else if (key->cipher ==  WLAN_CIPHER_SUITE_SMS4) {
 		if (pairwise)
-			k->type = fill_sms4_pair(&k->key.wapi_pairwise_key, key,
-						 sta->addr);
+			k.type = fill_sms4_pair(&k.key.wapi_pairwise_key, key,
+						sta->addr);
 		else
-			k->type = fill_sms4_group(&k->key.wapi_group_key, key);
+			k.type = fill_sms4_group(&k.key.wapi_group_key, key);
 	} else if (key->cipher ==  WLAN_CIPHER_SUITE_AES_CMAC) {
-		k->type = fill_aes_cmac_group(&k->key.igtk_group_key, key,
-					      &seq);
+		k.type = fill_aes_cmac_group(&k.key.igtk_group_key, key,
+					     &seq);
 	} else {
 		dev_warn(wdev->dev, "unsupported key type %d\n", key->cipher);
 		wfx_free_key(wdev, idx);
 		return -EOPNOTSUPP;
 	}
-	ret = hif_add_key(wdev, k);
+	ret = hif_add_key(wdev, &k);
 	if (ret) {
 		wfx_free_key(wdev, idx);
 		return -EOPNOTSUPP;
@@ -241,19 +239,3 @@ int wfx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 	return ret;
 }
 
-int wfx_upload_keys(struct wfx_vif *wvif)
-{
-	int i;
-	struct hif_req_add_key *key;
-	struct wfx_dev *wdev = wvif->wdev;
-
-	for (i = 0; i < ARRAY_SIZE(wdev->keys); i++) {
-		if (wdev->key_map & BIT(i)) {
-			key = &wdev->keys[i];
-			if (key->int_id == wvif->id)
-				hif_add_key(wdev, key);
-		}
-	}
-	return 0;
-}
-
diff --git a/drivers/staging/wfx/key.h b/drivers/staging/wfx/key.h
index 2c334f9fb2a8..ff31fc9c565a 100644
--- a/drivers/staging/wfx/key.h
+++ b/drivers/staging/wfx/key.h
@@ -16,6 +16,5 @@ struct wfx_vif;
 int wfx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 		struct ieee80211_vif *vif, struct ieee80211_sta *sta,
 		struct ieee80211_key_conf *key);
-int wfx_upload_keys(struct wfx_vif *wvif);
 
 #endif /* WFX_STA_H */
diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index 876952f39fc9..56cb6fff4a06 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -378,9 +378,6 @@ static void wfx_do_join(struct wfx_vif *wvif)
 		else
 			wvif->state = WFX_STATE_PRE_STA;
 
-		/* Upload keys */
-		wfx_upload_keys(wvif);
-
 		/* Due to beacon filtering it is possible that the
 		 * AP's beacon is not known for the mac80211 stack.
 		 * Disable filtering temporary to make sure the stack
@@ -457,7 +454,6 @@ int wfx_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 {
 	struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
 
-	wfx_upload_keys(wvif);
 	wvif->state = WFX_STATE_AP;
 	wfx_upload_ap_templates(wvif);
 	hif_start(wvif, &vif->bss_conf, wvif->channel);
diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h
index 0fa88de64907..354a62394db0 100644
--- a/drivers/staging/wfx/wfx.h
+++ b/drivers/staging/wfx/wfx.h
@@ -56,7 +56,6 @@ struct wfx_dev {
 
 	atomic_t		packet_id;
 	u32			key_map;
-	struct hif_req_add_key	keys[MAX_KEY_ENTRIES];
 
 	struct hif_rx_stats	rx_stats;
 	struct mutex		rx_stats_lock;
-- 
2.26.1


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

* [PATCH 12/16] staging: wfx: drop protection for asynchronous join during scan
  2020-04-20 16:02 [PATCH 00/16] staging: wfx: rework the handling of the connection loss Jerome Pouiller
                   ` (10 preceding siblings ...)
  2020-04-20 16:03 ` [PATCH 11/16] staging: wfx: keys are kept during whole firmware life Jerome Pouiller
@ 2020-04-20 16:03 ` Jerome Pouiller
  2020-04-20 16:03 ` [PATCH 13/16] staging: wfx: drop useless checks in wfx_do_unjoin() Jerome Pouiller
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Jerome Pouiller @ 2020-04-20 16:03 UTC (permalink / raw)
  To: devel, linux-wireless
  Cc: netdev, linux-kernel, Greg Kroah-Hartman, Kalle Valo,
	David S . Miller, Jérôme Pouiller

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

In former code (before the inclusion of the driver in mainline kernel),
hif_join() could run asynchronously. When a join request was in
progress, it was forbidden to launch hif_scan().

Now, hif_join() is always run synchronously. There is no more reasons to
keep a protection against this case.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/scan.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/wfx/scan.c b/drivers/staging/wfx/scan.c
index 276fdacd7143..76761e4960dd 100644
--- a/drivers/staging/wfx/scan.c
+++ b/drivers/staging/wfx/scan.c
@@ -110,9 +110,6 @@ int wfx_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 	if (vif->type == NL80211_IFTYPE_AP)
 		return -EOPNOTSUPP;
 
-	if (wvif->state == WFX_STATE_PRE_STA)
-		return -EBUSY;
-
 	wvif->scan_req = hw_req;
 	schedule_work(&wvif->scan_work);
 	return 0;
-- 
2.26.1


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

* [PATCH 13/16] staging: wfx: drop useless checks in wfx_do_unjoin()
  2020-04-20 16:02 [PATCH 00/16] staging: wfx: rework the handling of the connection loss Jerome Pouiller
                   ` (11 preceding siblings ...)
  2020-04-20 16:03 ` [PATCH 12/16] staging: wfx: drop protection for asynchronous join during scan Jerome Pouiller
@ 2020-04-20 16:03 ` Jerome Pouiller
  2020-04-20 16:03 ` [PATCH 14/16] staging: wfx: simplify wfx_remove_interface() Jerome Pouiller
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Jerome Pouiller @ 2020-04-20 16:03 UTC (permalink / raw)
  To: devel, linux-wireless
  Cc: netdev, linux-kernel, Greg Kroah-Hartman, Kalle Valo,
	David S . Miller, Jérôme Pouiller

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

The callers of wfx_do_unjoin() already take care of vif state.
Therefore, it is not necessary to take care of the status of the
interface.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/sta.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index 56cb6fff4a06..bc891b6e4392 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -286,12 +286,6 @@ void wfx_set_default_unicast_key(struct ieee80211_hw *hw,
 // Call it with wdev->conf_mutex locked
 static void wfx_do_unjoin(struct wfx_vif *wvif)
 {
-	if (!wvif->state)
-		return;
-
-	if (wvif->state == WFX_STATE_AP)
-		return;
-
 	wvif->state = WFX_STATE_PASSIVE;
 
 	/* Unjoin is a reset. */
-- 
2.26.1


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

* [PATCH 14/16] staging: wfx: simplify wfx_remove_interface()
  2020-04-20 16:02 [PATCH 00/16] staging: wfx: rework the handling of the connection loss Jerome Pouiller
                   ` (12 preceding siblings ...)
  2020-04-20 16:03 ` [PATCH 13/16] staging: wfx: drop useless checks in wfx_do_unjoin() Jerome Pouiller
@ 2020-04-20 16:03 ` Jerome Pouiller
  2020-04-20 16:03 ` [PATCH 15/16] staging: wfx: drop unused enum wfx_state Jerome Pouiller
  2020-04-20 16:03 ` [PATCH 16/16] staging: wfx: drop unused attribute 'join_complete_status' Jerome Pouiller
  15 siblings, 0 replies; 17+ messages in thread
From: Jerome Pouiller @ 2020-04-20 16:03 UTC (permalink / raw)
  To: devel, linux-wireless
  Cc: netdev, linux-kernel, Greg Kroah-Hartman, Kalle Valo,
	David S . Miller, Jérôme Pouiller

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

In wfx_remove_interface(), the current code differentiate AP and Station
cases. However, it is not necessary. In all cases, the only important
thing is the call to hif_reset(). We can use the same code to support
all cases.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/sta.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index bc891b6e4392..1732f3d0a1e5 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -785,24 +785,11 @@ void wfx_remove_interface(struct ieee80211_hw *hw,
 
 	mutex_lock(&wdev->conf_mutex);
 	WARN(wvif->link_id_map != 1, "corrupted state");
-	switch (wvif->state) {
-	case WFX_STATE_PRE_STA:
-	case WFX_STATE_STA:
-	case WFX_STATE_IBSS:
-		wfx_do_unjoin(wvif);
-		break;
-	case WFX_STATE_AP:
-		/* reset.link_id = 0; */
-		hif_reset(wvif, false);
-		break;
-	default:
-		break;
-	}
 
+	hif_reset(wvif, false);
 	wvif->state = WFX_STATE_PASSIVE;
-
-	/* FIXME: In add to reset MAC address, try to reset interface */
 	hif_set_macaddr(wvif, NULL);
+	wfx_tx_policy_init(wvif);
 
 	cancel_delayed_work_sync(&wvif->beacon_loss_work);
 	wdev->vif[wvif->id] = NULL;
-- 
2.26.1


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

* [PATCH 15/16] staging: wfx: drop unused enum wfx_state
  2020-04-20 16:02 [PATCH 00/16] staging: wfx: rework the handling of the connection loss Jerome Pouiller
                   ` (13 preceding siblings ...)
  2020-04-20 16:03 ` [PATCH 14/16] staging: wfx: simplify wfx_remove_interface() Jerome Pouiller
@ 2020-04-20 16:03 ` Jerome Pouiller
  2020-04-20 16:03 ` [PATCH 16/16] staging: wfx: drop unused attribute 'join_complete_status' Jerome Pouiller
  15 siblings, 0 replies; 17+ messages in thread
From: Jerome Pouiller @ 2020-04-20 16:03 UTC (permalink / raw)
  To: devel, linux-wireless
  Cc: netdev, linux-kernel, Greg Kroah-Hartman, Kalle Valo,
	David S . Miller, Jérôme Pouiller

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

In former code, the field wvif->state was more or less redundant with
vif->type. With the lasts change it has become unused. It is now time to
drop it.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/sta.c | 13 -------------
 drivers/staging/wfx/sta.h |  8 --------
 drivers/staging/wfx/wfx.h |  1 -
 3 files changed, 22 deletions(-)

diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index 1732f3d0a1e5..1e43e3b65953 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -286,8 +286,6 @@ void wfx_set_default_unicast_key(struct ieee80211_hw *hw,
 // Call it with wdev->conf_mutex locked
 static void wfx_do_unjoin(struct wfx_vif *wvif)
 {
-	wvif->state = WFX_STATE_PASSIVE;
-
 	/* Unjoin is a reset. */
 	wfx_tx_lock_flush(wvif->wdev);
 	hif_reset(wvif, false);
@@ -367,11 +365,6 @@ static void wfx_do_join(struct wfx_vif *wvif)
 		wfx_do_unjoin(wvif);
 	} else {
 		wvif->join_complete_status = 0;
-		if (wvif->vif->type == NL80211_IFTYPE_ADHOC)
-			wvif->state = WFX_STATE_IBSS;
-		else
-			wvif->state = WFX_STATE_PRE_STA;
-
 		/* Due to beacon filtering it is possible that the
 		 * AP's beacon is not known for the mac80211 stack.
 		 * Disable filtering temporary to make sure the stack
@@ -448,7 +441,6 @@ int wfx_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 {
 	struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
 
-	wvif->state = WFX_STATE_AP;
 	wfx_upload_ap_templates(wvif);
 	hif_start(wvif, &vif->bss_conf, wvif->channel);
 	return 0;
@@ -462,7 +454,6 @@ void wfx_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 	wfx_tx_policy_init(wvif);
 	if (wvif_count(wvif->wdev) <= 1)
 		hif_set_block_ack_policy(wvif, 0xFF, 0xFF);
-	wvif->state = WFX_STATE_PASSIVE;
 }
 
 static void wfx_join_finalize(struct wfx_vif *wvif,
@@ -475,9 +466,6 @@ static void wfx_join_finalize(struct wfx_vif *wvif,
 	hif_set_bss_params(wvif, info->aid, 7);
 	hif_set_beacon_wakeup_period(wvif, 1, 1);
 	wfx_update_pm(wvif);
-
-	if (!info->ibss_joined)
-		wvif->state = WFX_STATE_STA;
 }
 
 int wfx_join_ibss(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
@@ -787,7 +775,6 @@ void wfx_remove_interface(struct ieee80211_hw *hw,
 	WARN(wvif->link_id_map != 1, "corrupted state");
 
 	hif_reset(wvif, false);
-	wvif->state = WFX_STATE_PASSIVE;
 	hif_set_macaddr(wvif, NULL);
 	wfx_tx_policy_init(wvif);
 
diff --git a/drivers/staging/wfx/sta.h b/drivers/staging/wfx/sta.h
index fe728e642cfc..e814fe743b7d 100644
--- a/drivers/staging/wfx/sta.h
+++ b/drivers/staging/wfx/sta.h
@@ -15,14 +15,6 @@
 struct wfx_dev;
 struct wfx_vif;
 
-enum wfx_state {
-	WFX_STATE_PASSIVE = 0,
-	WFX_STATE_PRE_STA,
-	WFX_STATE_STA,
-	WFX_STATE_IBSS,
-	WFX_STATE_AP,
-};
-
 struct wfx_sta_priv {
 	int link_id;
 	int vif_id;
diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h
index 354a62394db0..8d29bf77cfed 100644
--- a/drivers/staging/wfx/wfx.h
+++ b/drivers/staging/wfx/wfx.h
@@ -66,7 +66,6 @@ struct wfx_vif {
 	struct ieee80211_vif	*vif;
 	struct ieee80211_channel *channel;
 	int			id;
-	enum wfx_state		state;
 
 	u32			link_id_map;
 
-- 
2.26.1


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

* [PATCH 16/16] staging: wfx: drop unused attribute 'join_complete_status'
  2020-04-20 16:02 [PATCH 00/16] staging: wfx: rework the handling of the connection loss Jerome Pouiller
                   ` (14 preceding siblings ...)
  2020-04-20 16:03 ` [PATCH 15/16] staging: wfx: drop unused enum wfx_state Jerome Pouiller
@ 2020-04-20 16:03 ` Jerome Pouiller
  15 siblings, 0 replies; 17+ messages in thread
From: Jerome Pouiller @ 2020-04-20 16:03 UTC (permalink / raw)
  To: devel, linux-wireless
  Cc: netdev, linux-kernel, Greg Kroah-Hartman, Kalle Valo,
	David S . Miller, Jérôme Pouiller

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

The field join_complete_status is never read. Drop it.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/sta.c | 2 --
 drivers/staging/wfx/wfx.h | 2 --
 2 files changed, 4 deletions(-)

diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index 1e43e3b65953..5d5c8951f50b 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -361,10 +361,8 @@ static void wfx_do_join(struct wfx_vif *wvif)
 	ret = hif_join(wvif, conf, wvif->channel, ssid, ssidlen);
 	if (ret) {
 		ieee80211_connection_loss(wvif->vif);
-		wvif->join_complete_status = -1;
 		wfx_do_unjoin(wvif);
 	} else {
-		wvif->join_complete_status = 0;
 		/* Due to beacon filtering it is possible that the
 		 * AP's beacon is not known for the mac80211 stack.
 		 * Disable filtering temporary to make sure the stack
diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h
index 8d29bf77cfed..706e95cd1092 100644
--- a/drivers/staging/wfx/wfx.h
+++ b/drivers/staging/wfx/wfx.h
@@ -82,8 +82,6 @@ struct wfx_vif {
 
 	unsigned long		uapsd_mask;
 
-	int			join_complete_status;
-
 	/* avoid some operations in parallel with scan */
 	struct mutex		scan_lock;
 	struct work_struct	scan_work;
-- 
2.26.1


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

end of thread, other threads:[~2020-04-20 16:05 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-20 16:02 [PATCH 00/16] staging: wfx: rework the handling of the connection loss Jerome Pouiller
2020-04-20 16:02 ` [PATCH 01/16] staging: wfx: simplify the check if the the device is associated Jerome Pouiller
2020-04-20 16:02 ` [PATCH 02/16] staging: wfx: use ieee80211_beacon_loss() provided by mac80211 Jerome Pouiller
2020-04-20 16:02 ` [PATCH 03/16] staging: wfx: drop useless attribute 'bss_params' Jerome Pouiller
2020-04-20 16:02 ` [PATCH 04/16] staging: wfx: handle firmware events synchronously Jerome Pouiller
2020-04-20 16:03 ` [PATCH 05/16] staging: wfx: also fix network parameters for IBSS networks Jerome Pouiller
2020-04-20 16:03 ` [PATCH 06/16] staging: wfx: dual CTS is never necessary Jerome Pouiller
2020-04-20 16:03 ` [PATCH 07/16] staging: wfx: field operational_rate_set is ignored by firmware Jerome Pouiller
2020-04-20 16:03 ` [PATCH 08/16] staging: wfx: simplify hif_set_bss_params() Jerome Pouiller
2020-04-20 16:03 ` [PATCH 09/16] staging: wfx: drop useless update of field basic_rate_set Jerome Pouiller
2020-04-20 16:03 ` [PATCH 10/16] staging: wfx: introduce wfx_set_default_unicast_key() Jerome Pouiller
2020-04-20 16:03 ` [PATCH 11/16] staging: wfx: keys are kept during whole firmware life Jerome Pouiller
2020-04-20 16:03 ` [PATCH 12/16] staging: wfx: drop protection for asynchronous join during scan Jerome Pouiller
2020-04-20 16:03 ` [PATCH 13/16] staging: wfx: drop useless checks in wfx_do_unjoin() Jerome Pouiller
2020-04-20 16:03 ` [PATCH 14/16] staging: wfx: simplify wfx_remove_interface() Jerome Pouiller
2020-04-20 16:03 ` [PATCH 15/16] staging: wfx: drop unused enum wfx_state Jerome Pouiller
2020-04-20 16:03 ` [PATCH 16/16] staging: wfx: drop unused attribute 'join_complete_status' Jerome Pouiller

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