Skip to content

Commit e993af2

Browse files
Miriam-Racheljmberg-intel
authored andcommitted
wifi: mac80211: add a driver callback to check active_links
During ieee80211_set_active_links() we do (among the others): 1. Call drv_change_vif_links() with both old_active and new_active 2. Unassign the chanctx for the removed link(s) (if any) 3. Assign chanctx to the added link(s) (if any) 4. Call drv_change_vif_links() with the new_active links bitmap The problem here is that during step #1 the driver doesn't know whether we will activate multiple links simultaneously or are just doing a link switch, so it can't check there if multiple links are supported/enabled. (Some of the drivers might enable/disable this option dynamically) And during step #3, in which the driver already knows that, returning an error code (for example when multiple links are not supported or disabled), will cause a warning, and we will still complete the transition to the new_active links. (It is hard to undo things in that stage, since we released channels etc.) Therefore add a driver callback to check if the desired new_active links will be supported by the driver or not. This callback will be called in the beginning of ieee80211_set_active_links() so we won't do anything before we are sure it is supported. Signed-off-by: Miri Korenblit <[email protected]> Reviewed-by: Gregory Greenman <[email protected]> Reviewed-by: Johannes Berg <[email protected]> Link: https://msgid.link/20231220133549.64c4d70b33b8.I79708619be76b8ecd4ef3975205b8f903e24a2cd@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent b1a23f8 commit e993af2

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

include/net/mac80211.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4272,6 +4272,8 @@ struct ieee80211_prep_tx_info {
42724272
* disable background CAC/radar detection.
42734273
* @net_fill_forward_path: Called from .ndo_fill_forward_path in order to
42744274
* resolve a path for hardware flow offloading
4275+
* @can_activate_links: Checks if a specific active_links bitmap is
4276+
* supported by the driver.
42754277
* @change_vif_links: Change the valid links on an interface, note that while
42764278
* removing the old link information is still valid (link_conf pointer),
42774279
* but may immediately disappear after the function returns. The old or
@@ -4652,6 +4654,9 @@ struct ieee80211_ops {
46524654
struct ieee80211_sta *sta,
46534655
struct net_device_path_ctx *ctx,
46544656
struct net_device_path *path);
4657+
bool (*can_activate_links)(struct ieee80211_hw *hw,
4658+
struct ieee80211_vif *vif,
4659+
u16 active_links);
46554660
int (*change_vif_links)(struct ieee80211_hw *hw,
46564661
struct ieee80211_vif *vif,
46574662
u16 old_links, u16 new_links,

net/mac80211/driver-ops.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,6 +1666,26 @@ static inline int drv_net_setup_tc(struct ieee80211_local *local,
16661666
return ret;
16671667
}
16681668

1669+
static inline bool drv_can_activate_links(struct ieee80211_local *local,
1670+
struct ieee80211_sub_if_data *sdata,
1671+
u16 active_links)
1672+
{
1673+
bool ret = true;
1674+
1675+
lockdep_assert_wiphy(local->hw.wiphy);
1676+
1677+
if (!check_sdata_in_driver(sdata))
1678+
return false;
1679+
1680+
trace_drv_can_activate_links(local, sdata, active_links);
1681+
if (local->ops->can_activate_links)
1682+
ret = local->ops->can_activate_links(&local->hw, &sdata->vif,
1683+
active_links);
1684+
trace_drv_return_bool(local, ret);
1685+
1686+
return ret;
1687+
}
1688+
16691689
int drv_change_vif_links(struct ieee80211_local *local,
16701690
struct ieee80211_sub_if_data *sdata,
16711691
u16 old_links, u16 new_links,

net/mac80211/link.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,9 @@ int ieee80211_set_active_links(struct ieee80211_vif *vif, u16 active_links)
444444

445445
lockdep_assert_wiphy(local->hw.wiphy);
446446

447+
if (!drv_can_activate_links(local, sdata, active_links))
448+
return -EINVAL;
449+
447450
old_active = sdata->vif.active_links;
448451
if (old_active & active_links) {
449452
/*

net/mac80211/trace.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2512,6 +2512,31 @@ TRACE_EVENT(drv_net_setup_tc,
25122512
)
25132513
);
25142514

2515+
TRACE_EVENT(drv_can_activate_links,
2516+
TP_PROTO(struct ieee80211_local *local,
2517+
struct ieee80211_sub_if_data *sdata,
2518+
u16 active_links),
2519+
2520+
TP_ARGS(local, sdata, active_links),
2521+
2522+
TP_STRUCT__entry(
2523+
LOCAL_ENTRY
2524+
VIF_ENTRY
2525+
__field(u16, active_links)
2526+
),
2527+
2528+
TP_fast_assign(
2529+
LOCAL_ASSIGN;
2530+
VIF_ASSIGN;
2531+
__entry->active_links = active_links;
2532+
),
2533+
2534+
TP_printk(
2535+
LOCAL_PR_FMT VIF_PR_FMT " requested active_links:0x%04x\n",
2536+
LOCAL_PR_ARG, VIF_PR_ARG, __entry->active_links
2537+
)
2538+
);
2539+
25152540
TRACE_EVENT(drv_change_vif_links,
25162541
TP_PROTO(struct ieee80211_local *local,
25172542
struct ieee80211_sub_if_data *sdata,

0 commit comments

Comments
 (0)