During ST, a non-AP MLD moves through sub-states 4a, 4b, and 4c that impose different frame-filtering rules on the AP MLD. Add a new driver op that mac80211 calls on each sub-state transition. This lets drivers perform the necessary hardware queue and filtering adjustments at each phase of ST. Valid driver transitions: NONE -> PREPARED (ST preparation completed at the target AP MLD) NONE -> EXECUTING (ST execution in progress at the current AP MLD) EXECUTING -> DL_DRAIN (DL drain period started at the current AP MLD) Suggested-by: Rohan Dutta Signed-off-by: Pooventhiran G --- include/net/mac80211.h | 24 +++++++++++++++++ net/mac80211/cfg.c | 24 +++++++++++++++++ net/mac80211/driver-ops.c | 18 +++++++++++++ net/mac80211/driver-ops.h | 5 ++++ net/mac80211/sta_info.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++ net/mac80211/sta_info.h | 7 +++++ net/mac80211/trace.h | 28 ++++++++++++++++++++ 7 files changed, 173 insertions(+) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 5d9b11842420..63de0df466dd 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -4097,6 +4097,24 @@ struct ieee80211_prep_tx_info { int link_id; }; +/** + * enum ieee80211_sta_st_state - SMD Transition sub-state + * + * Tracks the 802.11bn SMD Transition sub-state (IEEE P802.11bn/D2.0, Aug 2026, + * subclause 11.3.1) for a specific (non-AP MLD, AP MLD) association. + * + * @IEEE80211_STA_ST_NONE: Plain State 4. No sub-state active. + * @IEEE80211_STA_ST_PREPARED: State 4a. STA prepared at the target AP MLD + * @IEEE80211_STA_ST_EXECUTING: State 4b. ST execution active at the current AP MLD + * @IEEE80211_STA_ST_DL_DRAIN: State 4c. DL draining period at the current AP MLD + */ +enum ieee80211_sta_st_state { + IEEE80211_STA_ST_NONE, + IEEE80211_STA_ST_PREPARED, + IEEE80211_STA_ST_EXECUTING, + IEEE80211_STA_ST_DL_DRAIN, +}; + /** * struct ieee80211_ops - callbacks from mac80211 to the driver * @@ -4779,6 +4797,8 @@ struct ieee80211_prep_tx_info { * @set_eml_op_mode: Configure eMLSR/eMLMR operation mode in the underlay * driver according to the parameter received in the EML Operating mode * notification frame. + * @sta_notify_st: Notifies low level driver about IEEE 802.11bn ST substate + * transition of a station. The callback can sleep. */ struct ieee80211_ops { void (*tx)(struct ieee80211_hw *hw, @@ -5192,6 +5212,10 @@ struct ieee80211_ops { struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct ieee80211_eml_params *eml_params); + void (*sta_notify_st)(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta, + enum ieee80211_sta_st_state state); }; /** diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index f05192a52fbb..0a4ba00c962e 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -2709,7 +2709,9 @@ static int sta_apply_st_state_flags(struct sta_info *sta, u32 st_state_mask = BIT(NL80211_STA_FLAG_ST_PREPARED) | BIT(NL80211_STA_FLAG_ST_EXECUTING) | BIT(NL80211_STA_FLAG_ST_DL_DRAIN); + enum ieee80211_sta_st_state new_ss; u32 st_flags; + int err; if (!(mask & st_state_mask)) return 0; @@ -2726,6 +2728,22 @@ static int sta_apply_st_state_flags(struct sta_info *sta, (st_executing || st_dl_drain)) return -EINVAL; + if (st_prepared) + new_ss = IEEE80211_STA_ST_PREPARED; + else if (st_executing) + new_ss = IEEE80211_STA_ST_EXECUTING; + else if (st_dl_drain) + new_ss = IEEE80211_STA_ST_DL_DRAIN; + else + new_ss = IEEE80211_STA_ST_NONE; + + if (new_ss == sta->st_state) + return 0; + + err = sta_info_move_st_state(sta, new_ss); + if (err) + return err; + if (st_prepared) { set_sta_flag(sta, WLAN_STA_ST_PREPARED); clear_sta_flag(sta, WLAN_STA_ST_EXECUTING); @@ -3034,6 +3052,12 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct wireless_dev *wdev, */ if (!err && sdata->vif.type == NL80211_IFTYPE_NAN_DATA) ieee80211_nan_update_ndi_carrier(sta->sdata); + + if (!err && sta->sta.smd_sta && + sta->st_state != IEEE80211_STA_ST_NONE) + drv_sta_notify_st(sta->local, sta->sdata, &sta->sta, + sta->st_state); + return err; } diff --git a/net/mac80211/driver-ops.c b/net/mac80211/driver-ops.c index 0e854b0974de..6ad3ecba4ea7 100644 --- a/net/mac80211/driver-ops.c +++ b/net/mac80211/driver-ops.c @@ -745,3 +745,21 @@ void drv_flush_sta(struct ieee80211_local *local, ieee80211_flush_queues(local, sdata, false); trace_drv_return_void(local); } + +void drv_sta_notify_st(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata, + struct ieee80211_sta *sta, + enum ieee80211_sta_st_state state) +{ + might_sleep(); + lockdep_assert_wiphy(local->hw.wiphy); + + sdata = get_bss_sdata(sdata); + if (!check_sdata_in_driver(sdata)) + return; + + trace_drv_sta_notify_st(local, sdata, sta, state); + if (local->ops->sta_notify_st) + local->ops->sta_notify_st(&local->hw, &sdata->vif, sta, state); + trace_drv_return_void(local); +} diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h index 0edaaab7ac52..8b35f3f89f78 100644 --- a/net/mac80211/driver-ops.h +++ b/net/mac80211/driver-ops.h @@ -1788,4 +1788,9 @@ drv_nan_peer_sched_changed(struct ieee80211_local *local, return ret; } +void drv_sta_notify_st(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata, + struct ieee80211_sta *sta, + enum ieee80211_sta_st_state state); + #endif /* __MAC80211_DRIVER_OPS */ diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index e2ff3a242bb3..e337cff214f5 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -730,6 +730,7 @@ __sta_info_alloc(struct ieee80211_sub_if_data *sdata, ieee80211_init_frag_cache(&sta->frags); sta->sta_state = IEEE80211_STA_NONE; + sta->st_state = IEEE80211_STA_ST_NONE; if (sdata->vif.type == NL80211_IFTYPE_MESH_POINT) sta->amsdu_mesh_control = -1; @@ -1640,6 +1641,14 @@ static int _sta_info_move_state(struct sta_info *sta, WARN_ONCE(err, "Driver is not allowed to fail if the sta_state is transitioning down the list: %d\n", err); + + /* revert ST sub-states if STA has transitioned down */ + if (sta->sta.smd_sta && + ((new_state == IEEE80211_STA_AUTH && + sta->sta_state == IEEE80211_STA_ASSOC) || + (new_state == IEEE80211_STA_ASSOC && + sta->sta_state == IEEE80211_STA_AUTHORIZED))) + sta_info_reset_st_state(sta); } sta->sta_state = new_state; @@ -4108,3 +4117,61 @@ bool ieee80211_link_sta_update_rc_bw(struct ieee80211_link_data *link, return true; } + +int sta_info_move_st_state(struct sta_info *sta, + enum ieee80211_sta_st_state new_ss) +{ + enum ieee80211_sta_st_state old_ss = sta->st_state; + struct ieee80211_local *local = sta->local; + + might_sleep(); + + if (old_ss == new_ss) + return 0; + + switch (new_ss) { + case IEEE80211_STA_ST_NONE: + if (old_ss != IEEE80211_STA_ST_PREPARED && + old_ss != IEEE80211_STA_ST_EXECUTING && + old_ss != IEEE80211_STA_ST_DL_DRAIN) + return -EINVAL; + break; + case IEEE80211_STA_ST_EXECUTING: + if (old_ss != IEEE80211_STA_ST_NONE) + return -EINVAL; + break; + case IEEE80211_STA_ST_DL_DRAIN: + if (old_ss != IEEE80211_STA_ST_EXECUTING) + return -EINVAL; + break; + case IEEE80211_STA_ST_PREPARED: + if (old_ss != IEEE80211_STA_ST_NONE) + return -EINVAL; + break; + default: + sdata_err(sta->sdata, "invalid st state %d", new_ss); + return -EINVAL; + } + + sta_dbg(sta->sdata, "moving STA %pM ST state %u -> %u\n", + sta->sta.addr, old_ss, new_ss); + + if (test_sta_flag(sta, WLAN_STA_INSERTED)) + drv_sta_notify_st(local, sta->sdata, &sta->sta, new_ss); + + sta->st_state = new_ss; + + return 0; +} + +void sta_info_reset_st_state(struct sta_info *sta) +{ + if (sta->st_state == IEEE80211_STA_ST_NONE) + return; + + clear_sta_flag(sta, WLAN_STA_ST_PREPARED); + clear_sta_flag(sta, WLAN_STA_ST_EXECUTING); + clear_sta_flag(sta, WLAN_STA_ST_DL_DRAIN); + + sta->st_state = IEEE80211_STA_ST_NONE; +} diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index da0babb15aaf..2c842fddf285 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -728,6 +728,7 @@ struct ieee80211_sta_removed_link_stats { * would be assigned to link[link_id] where link_id is the id assigned * by the AP. * @rem_link_stats: accumulated removed link stats + * @st_state: Sub-state for STAs in ST */ struct sta_info { /* General information, mostly static */ @@ -804,6 +805,8 @@ struct sta_info { struct link_sta_info __rcu *link[IEEE80211_MLD_MAX_NUM_LINKS]; struct ieee80211_sta_removed_link_stats rem_link_stats; + enum ieee80211_sta_st_state st_state; + /* keep last! */ struct ieee80211_sta sta; }; @@ -1200,4 +1203,8 @@ static inline u32 sta_stats_encode_rate(struct ieee80211_rx_status *s) return r; } +int sta_info_move_st_state(struct sta_info *sta, + enum ieee80211_sta_st_state new_ss); +void sta_info_reset_st_state(struct sta_info *sta); + #endif /* STA_INFO_H */ diff --git a/net/mac80211/trace.h b/net/mac80211/trace.h index f34d079f3d38..00464c6f3ae7 100644 --- a/net/mac80211/trace.h +++ b/net/mac80211/trace.h @@ -3426,6 +3426,34 @@ TRACE_EVENT(drv_nan_peer_sched_changed, ) ); +TRACE_EVENT(drv_sta_notify_st, + TP_PROTO(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata, + struct ieee80211_sta *sta, + enum ieee80211_sta_st_state state), + + TP_ARGS(local, sdata, sta, state), + + TP_STRUCT__entry( + LOCAL_ENTRY + VIF_ENTRY + STA_ENTRY + __field(u32, state) + ), + + TP_fast_assign( + LOCAL_ASSIGN; + VIF_ASSIGN; + STA_ASSIGN; + __entry->state = state; + ), + + TP_printk( + LOCAL_PR_FMT VIF_PR_FMT STA_PR_FMT " st_state: %d", + LOCAL_PR_ARG, VIF_PR_ARG, STA_PR_ARG, __entry->state + ) +); + #endif /* !__MAC80211_DRIVER_TRACE || TRACE_HEADER_MULTI_READ */ #undef TRACE_INCLUDE_PATH -- 2.34.1