linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jérôme Pouiller" <Jerome.Pouiller@silabs.com>
To: "devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Kalle Valo" <kvalo@codeaurora.org>,
	"David S . Miller" <davem@davemloft.net>,
	"Jérôme Pouiller" <Jerome.Pouiller@silabs.com>
Subject: [PATCH 46/65] staging: wfx: relocate "buffered" information to sta_priv
Date: Wed, 15 Jan 2020 12:13:10 +0000	[thread overview]
Message-ID: <20200115121041.10863-47-Jerome.Pouiller@silabs.com> (raw)
In-Reply-To: <20200115121041.10863-1-Jerome.Pouiller@silabs.com>

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

It simplify the code if field buffered is hosted in the struct sta_priv
instead of in the struct wfx_link_entry. More globally, struct
wfx_link_entry has no real reasons to exist and should be dropped soon.

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

diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c
index e669fc4485e6..9313c8f5d4d8 100644
--- a/drivers/staging/wfx/data_tx.c
+++ b/drivers/staging/wfx/data_tx.c
@@ -291,7 +291,6 @@ static int wfx_alloc_link_id(struct wfx_vif *wvif, const u8 *mac)
 
 		entry->status = WFX_LINK_RESERVE;
 		ether_addr_copy(entry->mac, mac);
-		memset(&entry->buffered, 0, WFX_MAX_TID);
 		wfx_tx_lock(wvif->wdev);
 
 		if (!schedule_work(&wvif->link_id_work))
@@ -434,6 +433,7 @@ static void wfx_tx_manage_pm(struct wfx_vif *wvif, struct ieee80211_hdr *hdr,
 			     struct ieee80211_sta *sta)
 {
 	u32 mask = ~BIT(tx_priv->raw_link_id);
+	struct wfx_sta_priv *sta_priv;
 
 	spin_lock_bh(&wvif->ps_state_lock);
 	if (ieee80211_is_auth(hdr->frame_control)) {
@@ -448,15 +448,17 @@ static void wfx_tx_manage_pm(struct wfx_vif *wvif, struct ieee80211_hdr *hdr,
 			schedule_work(&wvif->mcast_start_work);
 	}
 
-	if (tx_priv->raw_link_id) {
+	if (tx_priv->raw_link_id)
 		wvif->link_id_db[tx_priv->raw_link_id - 1].timestamp = jiffies;
-		if (tx_priv->tid < WFX_MAX_TID)
-			wvif->link_id_db[tx_priv->raw_link_id - 1].buffered[tx_priv->tid]++;
-	}
 	spin_unlock_bh(&wvif->ps_state_lock);
 
-	if (sta)
+	if (sta && tx_priv->tid < WFX_MAX_TID) {
+		sta_priv = (struct wfx_sta_priv *)&sta->drv_priv;
+		spin_lock_bh(&sta_priv->lock);
+		sta_priv->buffered[tx_priv->tid]++;
 		ieee80211_sta_set_buffered(sta, tx_priv->tid, true);
+		spin_unlock_bh(&sta_priv->lock);
+	}
 }
 
 static u8 wfx_tx_get_raw_link_id(struct wfx_vif *wvif,
@@ -789,31 +791,25 @@ void wfx_tx_confirm_cb(struct wfx_vif *wvif, const struct hif_cnf_tx *arg)
 	wfx_pending_remove(wvif->wdev, skb);
 }
 
-static void wfx_notify_buffered_tx(struct wfx_vif *wvif, struct sk_buff *skb,
-				   struct hif_req_tx *req)
+static void wfx_notify_buffered_tx(struct wfx_vif *wvif, struct sk_buff *skb)
 {
+	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
 	struct ieee80211_sta *sta;
-	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+	struct wfx_sta_priv *sta_priv;
 	int tid = wfx_tx_get_tid(hdr);
-	int raw_link_id = req->queue_id.peer_sta_id;
-	u8 *buffered;
 
-	if (raw_link_id && tid < WFX_MAX_TID) {
-		buffered = wvif->link_id_db[raw_link_id - 1].buffered;
-
-		spin_lock_bh(&wvif->ps_state_lock);
-		WARN(!buffered[tid], "inconsistent notification");
-		buffered[tid]--;
-		spin_unlock_bh(&wvif->ps_state_lock);
-
-		if (!buffered[tid]) {
-			rcu_read_lock();
-			sta = ieee80211_find_sta(wvif->vif, hdr->addr1);
-			if (sta)
-				ieee80211_sta_set_buffered(sta, tid, false);
-			rcu_read_unlock();
-		}
+	rcu_read_lock(); // protect sta
+	sta = ieee80211_find_sta(wvif->vif, hdr->addr1);
+	if (sta && tid < WFX_MAX_TID) {
+		sta_priv = (struct wfx_sta_priv *)&sta->drv_priv;
+		spin_lock_bh(&sta_priv->lock);
+		WARN(!sta_priv->buffered[tid], "inconsistent notification");
+		sta_priv->buffered[tid]--;
+		if (!sta_priv->buffered[tid])
+			ieee80211_sta_set_buffered(sta, tid, false);
+		spin_unlock_bh(&sta_priv->lock);
 	}
+	rcu_read_unlock();
 }
 
 void wfx_skb_dtor(struct wfx_dev *wdev, struct sk_buff *skb)
@@ -827,7 +823,7 @@ void wfx_skb_dtor(struct wfx_dev *wdev, struct sk_buff *skb)
 
 	WARN_ON(!wvif);
 	skb_pull(skb, offset);
-	wfx_notify_buffered_tx(wvif, skb, req);
+	wfx_notify_buffered_tx(wvif, skb);
 	wfx_tx_policy_put(wvif, req->tx_flags.retry_policy_index);
 	ieee80211_tx_status_irqsafe(wdev->hw, skb);
 }
diff --git a/drivers/staging/wfx/data_tx.h b/drivers/staging/wfx/data_tx.h
index 54738c2e3eac..d02a7b325b27 100644
--- a/drivers/staging/wfx/data_tx.h
+++ b/drivers/staging/wfx/data_tx.h
@@ -14,9 +14,6 @@
 #include "hif_api_cmd.h"
 #include "hif_api_mib.h"
 
-// FIXME: use IEEE80211_NUM_TIDS
-#define WFX_MAX_TID               8
-
 struct wfx_tx_priv;
 struct wfx_dev;
 struct wfx_vif;
@@ -33,7 +30,6 @@ struct wfx_link_entry {
 	enum wfx_link_status	status;
 	u8			mac[ETH_ALEN];
 	u8			old_mac[ETH_ALEN];
-	u8			buffered[WFX_MAX_TID];
 };
 
 struct tx_policy {
diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index 4a44d72f0db1..aebce96dcd4a 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -572,6 +572,7 @@ int wfx_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 	struct wfx_sta_priv *sta_priv = (struct wfx_sta_priv *) &sta->drv_priv;
 	struct wfx_link_entry *entry;
 
+	spin_lock_init(&sta_priv->lock);
 	if (wvif->vif->type != NL80211_IFTYPE_AP)
 		return 0;
 
diff --git a/drivers/staging/wfx/sta.h b/drivers/staging/wfx/sta.h
index e0b54332e98a..47d94d6b8590 100644
--- a/drivers/staging/wfx/sta.h
+++ b/drivers/staging/wfx/sta.h
@@ -12,6 +12,9 @@
 
 #include "hif_api_cmd.h"
 
+// FIXME: use IEEE80211_NUM_TIDS
+#define WFX_MAX_TID               8
+
 struct wfx_dev;
 struct wfx_vif;
 
@@ -37,6 +40,9 @@ struct wfx_grp_addr_table {
 struct wfx_sta_priv {
 	int link_id;
 	int vif_id;
+	u8 buffered[WFX_MAX_TID];
+	// Ensure atomicity of "buffered" and calls to ieee80211_sta_set_buffered()
+	spinlock_t lock;
 };
 
 // mac80211 interface
-- 
2.25.0


  parent reply	other threads:[~2020-01-15 12:15 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-15 12:12 [PATCH 00/65] Simplify and improve the wfx driver Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 01/65] staging: wfx: revert unexpected change in debugfs output Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 02/65] staging: wfx: make hif_scan() usage clearer Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 03/65] staging: wfx: add missing PROBE_RESP_OFFLOAD feature Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 04/65] staging: wfx: send rate policies one by one Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 05/65] staging: wfx: simplify hif_set_tx_rate_retry_policy() usage Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 06/65] staging: wfx: simplify hif_set_output_power() usage Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 07/65] staging: wfx: simplify hif_set_rcpi_rssi_threshold() usage Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 08/65] staging: wfx: simplify hif_set_arp_ipv4_filter() usage Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 09/65] staging: wfx: simplify hif_start() usage Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 10/65] staging: wfx: use specialized structs for HIF arguments Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 11/65] staging: wfx: retrieve ampdu_density from sta->ht_cap Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 12/65] staging: wfx: retrieve greenfield mode from sta->ht_cap and bss_conf Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 13/65] staging: wfx: drop struct wfx_ht_info Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 14/65] staging: wfx: drop wdev->output_power Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 15/65] staging: wfx: simplify wfx_config() Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 16/65] staging: wfx: rename wfx_upload_beacon() Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 17/65] staging: wfx: simplify wfx_upload_ap_templates() Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 18/65] staging: wfx: simplify wfx_update_beaconing() Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 19/65] staging: wfx: fix __wfx_flush() when drop == false Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 20/65] staging: wfx: simplify wfx_flush() Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 21/65] staging: wfx: simplify update of DTIM period Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 22/65] staging: wfx: drop wvif->dtim_period Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 23/65] staging: wfx: drop wvif->enable_beacon Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 24/65] staging: wfx: drop wvif->cqm_rssi_thold Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 25/65] staging: wfx: drop wvif->setbssparams_done Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 26/65] staging: wfx: drop wfx_set_cts_work() Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 27/65] staging: wfx: SSID should be provided to hif_start() even if hidden Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 28/65] staging: wfx: simplify hif_update_ie() Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 29/65] staging: wfx: simplify hif_join() Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 30/65] staging: wfx: simplify hif_set_association_mode() Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 31/65] staging: wfx: simplify hif_set_uc_mc_bc_condition() Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 32/65] staging: wfx: simplify hif_mib_uc_mc_bc_data_frame_condition Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 33/65] staging: wfx: simplify hif_mib_set_data_filtering Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 34/65] staging: wfx: simplify hif_set_data_filtering() Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 35/65] staging: wfx: simplify hif_set_mac_addr_condition() Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 36/65] staging: wfx: simplify hif_set_config_data_filter() Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 37/65] staging: wfx: simplify wfx_set_mcast_filter() Jérôme Pouiller
2020-01-15 12:12 ` [PATCH 38/65] staging: wfx: simplify wfx_update_filtering() Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 39/65] staging: wfx: simplify wfx_scan_complete() Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 40/65] staging: wfx: update power-save per interface Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 41/65] staging: wfx: with multiple vifs, force PS only if channels differs Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 42/65] staging: wfx: do not update uapsd if not necessary Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 43/65] staging: wfx: fix case where RTS threshold is 0 Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 44/65] staging: wfx: fix possible overflow on jiffies comparaison Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 45/65] staging: wfx: remove handling of "early_data" Jérôme Pouiller
2020-01-15 12:13 ` Jérôme Pouiller [this message]
2020-01-15 12:13 ` [PATCH 47/65] staging: wfx: fix bss_loss Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 48/65] staging: wfx: fix RCU usage Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 49/65] staging: wfx: simplify wfx_set_tim_impl() Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 50/65] staging: wfx: simplify the link-id allocation Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 51/65] staging: wfx: check that no tx is pending before release sta Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 52/65] staging: wfx: replace wfx_tx_get_tid() with ieee80211_get_tid() Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 53/65] staging: wfx: pspoll_mask make no sense Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 54/65] staging: wfx: sta and dtim Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 55/65] staging: wfx: firmware never return PS status for stations Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 56/65] staging: wfx: simplify wfx_suspend_resume_mc() Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 57/65] staging: wfx: simplify handling of IEEE80211_TX_CTL_SEND_AFTER_DTIM Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 58/65] staging: wfx: simplify wfx_ps_notify_sta() Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 59/65] staging: wfx: ensure that packet_id is unique Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 60/65] staging: wfx: remove unused do_probe Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 61/65] staging: wfx: remove check for interface state Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 62/65] staging: wfx: simplify hif_handle_tx_data() Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 63/65] staging: wfx: simplify wfx_tx_queue_get_num_queued() Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 64/65] staging: wfx: simplify hif_multi_tx_confirm() Jérôme Pouiller
2020-01-15 12:13 ` [PATCH 65/65] staging: wfx: update TODO Jérôme Pouiller
2020-01-15 13:40 ` [PATCH 00/65] Simplify and improve the wfx driver Greg Kroah-Hartman
2020-01-15 13:50   ` Jérôme Pouiller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200115121041.10863-47-Jerome.Pouiller@silabs.com \
    --to=jerome.pouiller@silabs.com \
    --cc=davem@davemloft.net \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).