wifi: cfg80211/mac80211: extend link support for stop iface handler
cover wifi: cfg80211/mac80211: extend link support for stop iface handler
Currently whenever stop iface is called, the complete iface is getting stopped. However, there could be a need for AP/P2P_GO type, where one would like to stop a link alone instead of the whole interface.
Hence, extend stop iface infra to handle the event on the passed link id and stop that link alone instead of the whole iface. This would be useful during cases such as failed to finalize CSA. In that case, a link alone could be stopped instead of stopping the whole interface.
---
Aditya Kumar Singh (2):
wifi: cfg80211: extend link support for stop iface handler
wifi: mac80211: Update csa_finalize to use link_id
drivers/net/wireless/microchip/wilc1000/cfg80211.c | 2 +- include/net/cfg80211.h | 6 +++++- net/mac80211/cfg.c | 8 +++++++- net/mac80211/chan.c | 2 +- net/mac80211/iface.c | 5 +++-- net/wireless/core.c | 22 ++++++++++++++++------ net/wireless/core.h | 3 ++- net/wireless/reg.c | 2 +- net/wireless/sysfs.c | 2 +- net/wireless/trace.h | 11 +++++++---- net/wireless/util.c | 3 ++- 11 files changed, 46 insertions(+), 20 deletions(-)
---
base-commit: ee6960bdbb74499516261b84eadb19acc01cb361
change-id: 20250908-stop_iface-split-be69429a0718
PATCH 1/2 wifi: cfg80211: extend link support for stop iface handler
From: Aditya Kumar Singh <[email protected]>
Currently whenever stop iface is called, the complete iface is getting stopped. However, there could be a need for AP/P2P_GO type, where one would like to stop a link alone instead of the whole interface.
Hence, extend stop iface infra to handle the event on the passed link id and stop that link alone instead of the whole iface.
--- drivers/net/wireless/microchip/wilc1000/cfg80211.c | 2 +- include/net/cfg80211.h | 6 +++++- net/mac80211/cfg.c | 2 +- net/mac80211/chan.c | 2 +- net/mac80211/iface.c | 5 +++-- net/wireless/core.c | 22 ++++++++++++++++------ net/wireless/core.h | 3 ++- net/wireless/reg.c | 2 +- net/wireless/sysfs.c | 2 +- net/wireless/trace.h | 11 +++++++---- net/wireless/util.c | 3 ++- 11 files changed, 40 insertions(+), 20 deletions(-)
drivers/net/wireless/microchip/wilc1000/cfg80211.c +1 -1
@@ -1606,7 +1606,7 @@ static int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) wdev->iftype == NL80211_IFTYPE_P2P_GO)wilc_wfi_deinit_mon_interface (wl, true); vif =netdev_priv (wdev->netdev); -cfg80211_stop_iface (wiphy, wdev,GFP_KERNEL ); +cfg80211_stop_iface (wiphy, wdev,-1 ,GFP_KERNEL );cfg80211_unregister_netdevice (vif->ndev); vif->monitor_flag =0 ;
include/net/cfg80211.h +5 -1
@@ -9559,15 +9559,19 @@ int cfg80211_get_radio_idx_by_chan(struct wiphy *wiphy,* * @wiphy: the wiphy * @wdev: wireless device +* @link_id: valid link ID in case of MLO AP/P2P_GO Operation or else -1 * @gfp: context flags * * Trigger interface to be stopped as if AP was stopped, IBSS/mesh left, STA * disconnected. +* In case of AP/P2P_GO types, if link_id is passed, it would only stop that +* link on the iface alone. If need to stop the whole iface, -1 should be +* passed. * * Note: This doesn't need any locks and is asynchronous. */ void cfg80211_stop_iface (struct wiphy *wiphy,struct wireless_dev *wdev, -gfp_t gfp); +int link_id,gfp_t gfp);/** * cfg80211_shutdown_all_interfaces - shut down all interfaces for a wiphy
net/mac80211/cfg.c +1 -1
@@ -4036,7 +4036,7 @@ static void ieee80211_csa_finalize(struct ieee80211_link_data *link_data)sdata_info (sdata,"failed to finalize CSA on link %d, disconnecting\n" , link_data->link_id);cfg80211_stop_iface (sdata->local->hw.wiphy, &sdata->wdev, -GFP_KERNEL ); +-1 ,GFP_KERNEL ); } }
net/mac80211/chan.c +1 -1
@@ -1820,7 +1820,7 @@ static int ieee80211_vif_use_reserved_switch(struct ieee80211_local *local)ieee80211_link_unreserve_chanctx (link);cfg80211_stop_iface (local->hw.wiphy, &link->sdata->wdev, -GFP_KERNEL ); +-1 ,GFP_KERNEL ); } } }
net/mac80211/iface.c +3 -2
@@ -778,13 +778,14 @@ void ieee80211_stop_mbssid(struct ieee80211_sub_if_data *sdata)* removal can be supported. */ cfg80211_stop_iface (link_sdata->wdev.wiphy, &link_sdata->wdev, -GFP_KERNEL ); +-1 ,GFP_KERNEL ); }/* If we are not tx sdata, remove links of tx sdata and proceed */ if (sdata != tx_sdata &&ieee80211_sdata_running (tx_sdata))cfg80211_stop_iface (tx_sdata->wdev.wiphy, - &tx_sdata->wdev,GFP_KERNEL ); + &tx_sdata->wdev,-1 , +GFP_KERNEL ); } }
net/wireless/core.c +16 -6
@@ -344,7 +344,7 @@ void cfg80211_destroy_ifaces(struct cfg80211_registered_device *rdev)guard (wiphy)(&rdev->wiphy); -cfg80211_leave (rdev, wdev); +cfg80211_leave (rdev, wdev,-1 );cfg80211_remove_virtual_intf (rdev, wdev); } }
@@ -1347,7 +1347,7 @@ void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev, }void cfg80211_leave (struct cfg80211_registered_device *rdev, -struct wireless_dev *wdev) +struct wireless_dev *wdev,int link_id) {struct net_device *dev = wdev->netdev;struct cfg80211_sched_scan_request *pos, *tmp;
@@ -1384,7 +1384,7 @@ void cfg80211_leave(struct cfg80211_registered_device *rdev,break ;case NL80211_IFTYPE_AP :case NL80211_IFTYPE_P2P_GO : -cfg80211_stop_ap (rdev, dev,-1 , true); +cfg80211_stop_ap (rdev, dev, link_id, true);break ;case NL80211_IFTYPE_OCB :cfg80211_leave_ocb (rdev, dev);
@@ -1406,13 +1406,16 @@ void cfg80211_leave(struct cfg80211_registered_device *rdev, }void cfg80211_stop_iface (struct wiphy *wiphy,struct wireless_dev *wdev, -gfp_t gfp) +int link_id,gfp_t gfp) {struct cfg80211_registered_device *rdev =wiphy_to_rdev (wiphy);struct cfg80211_event *ev;unsigned long flags; -trace_cfg80211_stop_iface (wiphy, wdev); +trace_cfg80211_stop_iface (wiphy, wdev, link_id); + +if (WARN_ON_ONCE (link_id >=IEEE80211_MLD_MAX_NUM_LINKS )) +return ; ev =kzalloc (sizeof (*ev), gfp);if (!ev)
@@ -1420,6 +1423,13 @@ void cfg80211_stop_iface(struct wiphy *wiphy, struct wireless_dev *wdev, ev->type =EVENT_STOPPED ; +/* link_id is expected only for AP/P2P_GO type currently */ +if (WARN_ON_ONCE ((wdev->iftype !=NL80211_IFTYPE_AP && + wdev->iftype !=NL80211_IFTYPE_P2P_GO ) && link_id >=0 )) + link_id =-1 ; + + ev->link_id = link_id; +spin_lock_irqsave (&wdev->event_lock, flags);list_add_tail (&ev->list, &wdev->event_list);spin_unlock_irqrestore (&wdev->event_lock, flags);
@@ -1564,7 +1574,7 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,break ;case NETDEV_GOING_DOWN : scoped_guard(wiphy, &rdev->wiphy) { -cfg80211_leave (rdev, wdev); +cfg80211_leave (rdev, wdev,-1 );cfg80211_remove_links (wdev); }/* since we just did cfg80211_leave() nothing to do there */
net/wireless/core.h +2 -1
@@ -288,6 +288,7 @@ struct cfg80211_event {const u8 *td_bitmap;u8 td_bitmap_len; } pa; +int link_id; }; };
@@ -536,7 +537,7 @@ void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev, enum nl80211_iftype iftype, int num);void cfg80211_leave (struct cfg80211_registered_device *rdev, -struct wireless_dev *wdev); +struct wireless_dev *wdev,int link_id);void cfg80211_stop_p2p_device (struct cfg80211_registered_device *rdev,struct wireless_dev *wdev);
net/wireless/reg.c +1 -1
@@ -2472,7 +2472,7 @@ static void reg_leave_invalid_chans(struct wiphy *wiphy)list_for_each_entry (wdev, &rdev->wiphy.wdev_list, list)if (!reg_wdev_chan_valid (wiphy, wdev)) -cfg80211_leave (rdev, wdev); +cfg80211_leave (rdev, wdev,-1 ); }static void reg_check_chans_work (struct work_struct *work)
net/wireless/sysfs.c +1 -1
@@ -88,7 +88,7 @@ static void cfg80211_leave_all(struct cfg80211_registered_device *rdev)struct wireless_dev *wdev;list_for_each_entry (wdev, &rdev->wiphy.wdev_list, list) -cfg80211_leave (rdev, wdev); +cfg80211_leave (rdev, wdev,-1 ); }static int wiphy_suspend (struct device *dev)
net/wireless/trace.h +7 -4
@@ -3951,18 +3951,21 @@ TRACE_EVENT(cfg80211_ft_event, );TRACE_EVENT (cfg80211_stop_iface, - TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev), -TP_ARGS (wiphy, wdev), + TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev, + int link_id), +TP_ARGS (wiphy, wdev, link_id),TP_STRUCT__entry ( WIPHY_ENTRY WDEV_ENTRY +__field (int, link_id) ),TP_fast_assign ( WIPHY_ASSIGN; WDEV_ASSIGN; + __entry->link_id = link_id; ), -TP_printk (WIPHY_PR_FMT ", " WDEV_PR_FMT , -WIPHY_PR_ARG ,WDEV_PR_ARG ) +TP_printk (WIPHY_PR_FMT ", " WDEV_PR_FMT ", link_id: %d" , +WIPHY_PR_ARG ,WDEV_PR_ARG , __entry->link_id) ); TRACE_EVENT(cfg80211_pmsr_report,
net/wireless/util.c +2 -1
@@ -1171,7 +1171,8 @@ void cfg80211_process_wdev_events(struct wireless_dev *wdev) ev->ij.channel);break ;case EVENT_STOPPED : -cfg80211_leave (wiphy_to_rdev (wdev->wiphy), wdev); +cfg80211_leave (wiphy_to_rdev (wdev->wiphy), wdev, + ev->link_id);break ;case EVENT_PORT_AUTHORIZED : __cfg80211_port_authorized(wdev, ev->pa.peer_addr,
Signature · 1 line
2.34.1
Johannes Berg
maintainerRe: [PATCH wireless-next 1/2] wifi: cfg80211: extend link support for stop iface handler
Quoted 10 lines · Manish Dharanenthiran
+++
b/include/net/cfg80211.hinclude/net/cfg80211.h +1
-0@@ -9559,15 +9559,19 @@ int cfg80211_get_radio_idx_by_chan(struct wiphy *wiphy,* * @wiphy: the wiphy * @wdev: wireless device +* @link_id: valid link ID in case of MLO AP/P2P_GO Operation or else -1 * @gfp: context flags * * Trigger interface to be stopped as if AP was stopped, IBSS/mesh left, STA
include/net/cfg80211.h int cfg80211_get_radio_idx_by_chan(struct wiphy *wiphy, · line 9574
Quoted 10 lines
include/net/cfg80211.h +4
-1* disconnected. +* In case of AP/P2P_GO types, if link_id is passed, it would only stop that +* link on the iface alone. If need to stop the whole iface, -1 should be +* passed. * * Note: This doesn't need any locks and is asynchronous. */ void cfg80211_stop_iface (struct wiphy *wiphy,struct wireless_dev *wdev, -gfp_t gfp); +int link_id,gfp_t gfp);
I think the naming (and touching all drivers) here is awful. Much better would be to make a new cfg80211_stop_link() or so, pass -1 there to mean the whole interface, and have cfg80211_stop_iface() be an inline that always passes -1? In one fell swoop you get better naming and not touching all drivers.
johannes
Re: [PATCH wireless-next 1/2] wifi: cfg80211: extend link support for stop iface handler
Quoted 28 lines · Johannes Berg
Quoted 10 lines · Manish Dharanenthiran
+++
b/include/net/cfg80211.hinclude/net/cfg80211.h +1
-0@@ -9559,15 +9559,19 @@ int cfg80211_get_radio_idx_by_chan(struct wiphy *wiphy,* * @wiphy: the wiphy * @wdev: wireless device +* @link_id: valid link ID in case of MLO AP/P2P_GO Operation or else -1 * @gfp: context flags * * Trigger interface to be stopped as if AP was stopped, IBSS/mesh left, STA include/net/cfg80211.h int cfg80211_get_radio_idx_by_chan(struct wiphy *wiphy, · line 9574
Quoted 10 lines
include/net/cfg80211.h +4
-1* disconnected. +* In case of AP/P2P_GO types, if link_id is passed, it would only stop that +* link on the iface alone. If need to stop the whole iface, -1 should be +* passed. * * Note: This doesn't need any locks and is asynchronous. */ void cfg80211_stop_iface (struct wiphy *wiphy,struct wireless_dev *wdev, -gfp_t gfp); +int link_id,gfp_t gfp);I think the naming (and touching all drivers) here is awful. Much better would be to make a new
cfg80211_stop_link()or so, pass -1 there to mean the whole interface, and havecfg80211_stop_iface()be an inline that always passes -1? In one fell swoop you get better naming and not touching all drivers.
Quoted 1 line
johannes
Sure Johannes, will introduce a new API as mentioned and re-spin a new version.
Regards
Manish Dharanenthiran
PATCH 2/2 wifi: mac80211: Update csa_finalize to use link_id
In reply to Manish DharanenthiranFrom: Aditya Kumar Singh <[email protected]>
With stop_iface infra to handle the event on the passed link_id, for AP/P2P_GO interface types, there may be cases where finalizing the CSA fails. In those cases, a link alone can be stopped instead of stopping the whole interface.
Add changes to send link_id if its AP/P2P_GO type and -1, otherwise.
--- net/mac80211/cfg.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
net/mac80211/cfg.c +7 -1
@@ -4031,12 +4031,18 @@ static int __ieee80211_csa_finalize(struct ieee80211_link_data *link_data)static void ieee80211_csa_finalize (struct ieee80211_link_data *link_data) {struct ieee80211_sub_if_data *sdata = link_data->sdata; +u8 link_id =-1 ;if (__ieee80211_csa_finalize (link_data)) {sdata_info (sdata,"failed to finalize CSA on link %d, disconnecting\n" , link_data->link_id); +/* link_id is expected only for AP/P2P_GO type currently */ +if (sdata->vif.type ==NL80211_IFTYPE_AP || + sdata->vif.type ==NL80211_IFTYPE_P2P_GO ) + link_id = link_data->link_id; +cfg80211_stop_iface (sdata->local->hw.wiphy, &sdata->wdev, --1 ,GFP_KERNEL ); + link_id,GFP_KERNEL ); } }
Signature · 1 line
2.34.1