diff mbox series

[2/3] wifi: mac80211: add link id argument for sta_flush() function

Message ID 20240125125855.827619-3-quic_adisi@quicinc.com (mailing list archive)
State Superseded
Delegated to: Johannes Berg
Headers show
Series wifi: cfg80211/mac80211: add support to flush stations based on link ID | expand

Commit Message

Aditya Kumar Singh Jan. 25, 2024, 12:58 p.m. UTC
Whenever sta_flush() function is invoked, all sta present in that interface
is flushed. However, there is a requirement in case of MLO that only flush
those sta who are using a given link id. This is not possible currently.

Hence add the support for the same.

Passing link id is done currently via cfg80211 op - del_station.
A subsequent patch would also use this during stopping AP.

Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
---
 net/mac80211/cfg.c      |  4 ++--
 net/mac80211/ibss.c     |  4 ++--
 net/mac80211/iface.c    |  2 +-
 net/mac80211/mesh.c     |  2 +-
 net/mac80211/mlme.c     |  2 +-
 net/mac80211/ocb.c      |  2 +-
 net/mac80211/sta_info.c | 20 +++++++++++++-------
 net/mac80211/sta_info.h | 14 +++++++++++---
 8 files changed, 32 insertions(+), 18 deletions(-)

Comments

Johannes Berg Jan. 26, 2024, 9:11 a.m. UTC | #1
On Thu, 2024-01-25 at 18:28 +0530, Aditya Kumar Singh wrote:
> Whenever sta_flush() function is invoked, all sta present in that interface

STAs

> is flushed. However, there is a requirement in case of MLO that only flush

are flushed; The sentence starting here could be reworded.

> those sta who are using a given link id.

who -> which/that? They're not people :)

>  This is not possible currently.

reorder the words a bit here?

> Hence add the support for the same.

I think (and hope :) ) you can improve the commit messages ... Maybe say
"Add support for this by implementing the new cfg80211 API ..."

> Passing link id is done currently via cfg80211 op - del_station.

The mechanics of this aren't really all _that_ interesting unless
they're really complicated - we can all read the code if we care about
that part.

johannes
Aditya Kumar Singh Jan. 27, 2024, 5:46 a.m. UTC | #2
On 1/26/24 14:41, Johannes Berg wrote:
> On Thu, 2024-01-25 at 18:28 +0530, Aditya Kumar Singh wrote:
>> Whenever sta_flush() function is invoked, all sta present in that interface
> 
> STAs
> 
>> is flushed. However, there is a requirement in case of MLO that only flush
> 
> are flushed; The sentence starting here could be reworded.
> 
>> those sta who are using a given link id.
> 
> who -> which/that? They're not people :)
> 
>>   This is not possible currently.
> 
> reorder the words a bit here?
> 
>> Hence add the support for the same.
> 
> I think (and hope :) ) you can improve the commit messages ... Maybe say
> "Add support for this by implementing the new cfg80211 API ..."
> 
>> Passing link id is done currently via cfg80211 op - del_station.
> 
> The mechanics of this aren't really all _that_ interesting unless
> they're really complicated - we can all read the code if we care about
> that part.
> 
> johannes

Sure got it. Thanks for all suggestion. Will address them in next version.
diff mbox series

Patch

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 489dd97f5172..26a8ea553401 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1618,7 +1618,7 @@  static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev,
 	link_conf->ema_ap = false;
 	link_conf->bssid_indicator = 0;
 
-	__sta_info_flush(sdata, true);
+	__sta_info_flush(sdata, true, -1);
 	ieee80211_free_keys(sdata, true);
 
 	link_conf->enable_beacon = false;
@@ -2093,7 +2093,7 @@  static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
 	if (params->mac)
 		return sta_info_destroy_addr_bss(sdata, params->mac);
 
-	sta_info_flush(sdata);
+	sta_info_flush(sdata, params->link_id);
 	return 0;
 }
 
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index 8f2b445a5ec3..e4c55760f90c 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -237,7 +237,7 @@  static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
 	drv_reset_tsf(local, sdata);
 
 	if (!ether_addr_equal(ifibss->bssid, bssid))
-		sta_info_flush(sdata);
+		sta_info_flush(sdata, -1);
 
 	/* if merging, indicate to driver that we leave the old IBSS */
 	if (sdata->vif.cfg.ibss_joined) {
@@ -682,7 +682,7 @@  static void ieee80211_ibss_disconnect(struct ieee80211_sub_if_data *sdata)
 
 	ifibss->state = IEEE80211_IBSS_MLME_SEARCH;
 
-	sta_info_flush(sdata);
+	sta_info_flush(sdata, -1);
 
 	spin_lock_bh(&ifibss->incomplete_lock);
 	while (!list_empty(&ifibss->incomplete_stations)) {
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index e4e7c0b38cb6..97728bb51f9b 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -511,7 +511,7 @@  static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do
 	 * would have removed them, but in other modes there shouldn't
 	 * be any stations.
 	 */
-	flushed = sta_info_flush(sdata);
+	flushed = sta_info_flush(sdata, -1);
 	WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_AP_VLAN && flushed > 0);
 
 	/* don't count this interface for allmulti while it is down */
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index fccbcde3359a..16b5af8ee859 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -1234,7 +1234,7 @@  void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata)
 	netif_carrier_off(sdata->dev);
 
 	/* flush STAs and mpaths on this iface */
-	sta_info_flush(sdata);
+	sta_info_flush(sdata, -1);
 	ieee80211_free_keys(sdata, true);
 	mesh_path_flush_by_iface(sdata);
 
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 073105deb424..b3f2de3b1669 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -2991,7 +2991,7 @@  static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
 	sdata->vif.cfg.ssid_len = 0;
 
 	/* remove AP and TDLS peers */
-	sta_info_flush(sdata);
+	sta_info_flush(sdata, -1);
 
 	/* finally reset all BSS / config parameters */
 	if (!ieee80211_vif_is_mld(&sdata->vif))
diff --git a/net/mac80211/ocb.c b/net/mac80211/ocb.c
index 449af4e1cca4..7d06166f63bb 100644
--- a/net/mac80211/ocb.c
+++ b/net/mac80211/ocb.c
@@ -207,7 +207,7 @@  int ieee80211_ocb_leave(struct ieee80211_sub_if_data *sdata)
 	lockdep_assert_wiphy(sdata->local->hw.wiphy);
 
 	ifocb->joined = false;
-	sta_info_flush(sdata);
+	sta_info_flush(sdata, -1);
 
 	spin_lock_bh(&ifocb->incomplete_lock);
 	while (!list_empty(&ifocb->incomplete_stations)) {
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index bf1adcd96b41..6c9aa8db3c62 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -1561,7 +1561,8 @@  void sta_info_stop(struct ieee80211_local *local)
 }
 
 
-int __sta_info_flush(struct ieee80211_sub_if_data *sdata, bool vlans)
+int __sta_info_flush(struct ieee80211_sub_if_data *sdata, bool vlans,
+		     int link_id)
 {
 	struct ieee80211_local *local = sdata->local;
 	struct sta_info *sta, *tmp;
@@ -1575,12 +1576,17 @@  int __sta_info_flush(struct ieee80211_sub_if_data *sdata, bool vlans)
 	WARN_ON(vlans && !sdata->bss);
 
 	list_for_each_entry_safe(sta, tmp, &local->sta_list, list) {
-		if (sdata == sta->sdata ||
-		    (vlans && sdata->bss == sta->sdata->bss)) {
-			if (!WARN_ON(__sta_info_destroy_part1(sta)))
-				list_add(&sta->free_list, &free_list);
-			ret++;
-		}
+		if (sdata != sta->sdata &&
+		    (!vlans || sdata->bss != sta->sdata->bss))
+			continue;
+
+		if (link_id >= 0 && !(sta->sta.valid_links & BIT(link_id)))
+			continue;
+
+		if (!WARN_ON(__sta_info_destroy_part1(sta)))
+			list_add(&sta->free_list, &free_list);
+
+		ret++;
 	}
 
 	if (!list_empty(&free_list)) {
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index 5ef1554f991f..f03731a5bbee 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -886,8 +886,12 @@  void sta_info_stop(struct ieee80211_local *local);
  *
  * @sdata: sdata to remove all stations from
  * @vlans: if the given interface is an AP interface, also flush VLANs
+ * @link_id: if given (>=0), all those STA entries using @link_id only
+ *	     will be removed. If -1 is passed, all STA entries will be
+ *	     removed.
  */
-int __sta_info_flush(struct ieee80211_sub_if_data *sdata, bool vlans);
+int __sta_info_flush(struct ieee80211_sub_if_data *sdata, bool vlans,
+		     int link_id);
 
 /**
  * sta_info_flush - flush matching STA entries from the STA table
@@ -895,10 +899,14 @@  int __sta_info_flush(struct ieee80211_sub_if_data *sdata, bool vlans);
  * Returns the number of removed STA entries.
  *
  * @sdata: sdata to remove all stations from
+ * @link_id: if given (>=0), all those STA entries using @link_id only
+ *	     will be removed. If -1 is passed, all STA entries will be
+ *	     removed.
  */
-static inline int sta_info_flush(struct ieee80211_sub_if_data *sdata)
+static inline int sta_info_flush(struct ieee80211_sub_if_data *sdata,
+				 int link_id)
 {
-	return __sta_info_flush(sdata, false);
+	return __sta_info_flush(sdata, false, link_id);
 }
 
 void sta_set_rate_info_tx(struct sta_info *sta,