Skip to content

Commit

Permalink
wifi: mac80211: remove DEAUTH_NEED_MGD_TX_PREP
Browse files Browse the repository at this point in the history
This flag is annoying because it puts a lot of logic into mac80211
that could just as well be in the driver (only iwlmvm uses it) and
the implementation is also broken for MLO.

Remove the flag in favour of calling drv_mgd_prepare_tx() without
any conditions even for the deauth-while-assoc case. The drivers
that implement it can take the appropriate actions, which for the
only user of DEAUTH_NEED_MGD_TX_PREP (iwlmvm) is a bit more tricky
than the implementation in mac80211 is anyway, and all others have
no need and can just exit if info->was_assoc is set.

Reviewed-by: Miriam Rachel Korenblit <[email protected]>
Link: https://patch.msgid.link/20240627132527.94924bcc9c9e.I328a219e45f2e2724cd52e75bb9feee3bf21a463@changeid
Signed-off-by: Johannes Berg <[email protected]>
  • Loading branch information
jmberg-intel committed Jun 28, 2024
1 parent 4314bb4 commit 8c62617
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 49 deletions.
12 changes: 6 additions & 6 deletions drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,6 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
if (!mvm->mld_api_is_used)
ieee80211_hw_set(hw, TIMING_BEACON_ONLY);

/* We should probably have this, but mac80211
* currently doesn't support it for MLO.
*/
if (!(hw->wiphy->flags & WIPHY_FLAG_SUPPORTS_MLO))
ieee80211_hw_set(hw, DEAUTH_NEED_MGD_TX_PREP);

/*
* On older devices, enabling TX A-MSDU occasionally leads to
* something getting messed up, the command read from the FIFO
Expand Down Expand Up @@ -2853,6 +2847,8 @@ static void iwl_mvm_bss_info_changed_station(struct iwl_mvm *mvm,

if (changes & BSS_CHANGED_ASSOC) {
if (vif->cfg.assoc) {
mvmvif->session_prot_connection_loss = false;

/* clear statistics to get clean beacon counter */
iwl_mvm_request_statistics(mvm, true);
for_each_mvm_vif_valid_link(mvmvif, i)
Expand Down Expand Up @@ -4268,8 +4264,12 @@ void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_prep_tx_info *info)
{
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);

if (info->was_assoc && !mvmvif->session_prot_connection_loss)
return;

guard(mvm)(mvm);
iwl_mvm_protect_assoc(mvm, vif, info->duration, info->link_id);
}
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,8 @@ static void iwl_mvm_mld_vif_cfg_changed_station(struct iwl_mvm *mvm,

if (changes & BSS_CHANGED_ASSOC) {
if (vif->cfg.assoc) {
mvmvif->session_prot_connection_loss = false;

/* clear statistics to get clean beacon counter */
iwl_mvm_request_statistics(mvm, true);
iwl_mvm_sf_update(mvm, vif, false);
Expand Down
4 changes: 4 additions & 0 deletions drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,9 @@ struct iwl_mvm_esr_exit {
* @unblock_esr_tpt_wk: work for unblocking EMLSR when tpt is high enough.
* @roc_activity: currently running ROC activity for this vif (or
* ROC_NUM_ACTIVITIES if no activity is running).
* @session_prot_connection_loss: the connection was lost due to session
* protection ending without receiving a beacon, so we need to now
* protect the deauth separately
*/
struct iwl_mvm_vif {
struct iwl_mvm *mvm;
Expand All @@ -463,6 +466,7 @@ struct iwl_mvm_vif {
bool pm_enabled;
bool monitor_active;
bool esr_active;
bool session_prot_connection_loss;

u8 low_latency: 6;
u8 low_latency_actual: 1;
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/wireless/intel/iwlwifi/mvm/time-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ static bool iwl_mvm_te_check_disconnect(struct iwl_mvm *mvm,
iwl_dbg_tlv_time_point(&mvm->fwrt,
IWL_FW_INI_TIME_POINT_ASSOC_FAILED,
NULL);

mvmvif->session_prot_connection_loss = true;
}

iwl_mvm_connection_loss(mvm, vif, errmsg);
Expand Down
22 changes: 6 additions & 16 deletions include/net/mac80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -2767,14 +2767,6 @@ struct ieee80211_txq {
* @IEEE80211_HW_SUPPORTS_TDLS_BUFFER_STA: Hardware supports buffer STA on
* TDLS links.
*
* @IEEE80211_HW_DEAUTH_NEED_MGD_TX_PREP: The driver requires the
* mgd_prepare_tx() callback to be called before transmission of a
* deauthentication frame in case the association was completed but no
* beacon was heard. This is required in multi-channel scenarios, where the
* virtual interface might not be given air time for the transmission of
* the frame, as it is not synced with the AP/P2P GO yet, and thus the
* deauthentication frame might not be transmitted.
*
* @IEEE80211_HW_DOESNT_SUPPORT_QOS_NDP: The driver (or firmware) doesn't
* support QoS NDP for AP probing - that's most likely a driver bug.
*
Expand Down Expand Up @@ -2874,7 +2866,6 @@ enum ieee80211_hw_flags {
IEEE80211_HW_REPORTS_LOW_ACK,
IEEE80211_HW_SUPPORTS_TX_FRAG,
IEEE80211_HW_SUPPORTS_TDLS_BUFFER_STA,
IEEE80211_HW_DEAUTH_NEED_MGD_TX_PREP,
IEEE80211_HW_DOESNT_SUPPORT_QOS_NDP,
IEEE80211_HW_BUFF_MMPDU_TXQ,
IEEE80211_HW_SUPPORTS_VHT_EXT_NSS_BW,
Expand Down Expand Up @@ -3787,13 +3778,15 @@ enum ieee80211_reconfig_type {
* @success: whether the frame exchange was successful, only
* used with the mgd_complete_tx() method, and then only
* valid for auth and (re)assoc.
* @was_assoc: set if this call is due to deauth/disassoc
* while just having been associated
* @link_id: the link id on which the frame will be TX'ed.
* Only used with the mgd_prepare_tx() method.
*/
struct ieee80211_prep_tx_info {
u16 duration;
u16 subtype;
u8 success:1;
u8 success:1, was_assoc:1;
int link_id;
};

Expand Down Expand Up @@ -4242,12 +4235,9 @@ struct ieee80211_prep_tx_info {
* yet it need not necessarily be given airtime, in particular since any
* transmission to a P2P GO needs to be synchronized against the GO's
* powersave state. mac80211 will call this function before transmitting a
* management frame prior to having successfully associated to allow the
* driver to give it channel time for the transmission, to get a response
* and to be able to synchronize with the GO.
* For drivers that set %IEEE80211_HW_DEAUTH_NEED_MGD_TX_PREP, mac80211
* would also call this function before transmitting a deauthentication
* frame in case that no beacon was heard from the AP/P2P GO.
* management frame prior to transmitting that frame to allow the driver
* to give it channel time for the transmission, to get a response and be
* able to synchronize with the GO.
* The callback will be called before each transmission and upon return
* mac80211 will transmit the frame right away.
* Additional information is passed in the &struct ieee80211_prep_tx_info
Expand Down
1 change: 0 additions & 1 deletion net/mac80211/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,6 @@ static const char *hw_flag_names[] = {
FLAG(REPORTS_LOW_ACK),
FLAG(SUPPORTS_TX_FRAG),
FLAG(SUPPORTS_TDLS_BUFFER_STA),
FLAG(DEAUTH_NEED_MGD_TX_PREP),
FLAG(DOESNT_SUPPORT_QOS_NDP),
FLAG(BUFF_MMPDU_TXQ),
FLAG(SUPPORTS_VHT_EXT_NSS_BW),
Expand Down
3 changes: 0 additions & 3 deletions net/mac80211/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1161,9 +1161,6 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)

if (WARN_ON(!ieee80211_hw_check(hw, AP_LINK_PS)))
return -EINVAL;

if (WARN_ON(ieee80211_hw_check(hw, DEAUTH_NEED_MGD_TX_PREP)))
return -EINVAL;
}

#ifdef CONFIG_PM
Expand Down
26 changes: 3 additions & 23 deletions net/mac80211/mlme.c
Original file line number Diff line number Diff line change
Expand Up @@ -3521,6 +3521,8 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
u64 changed = 0;
struct ieee80211_prep_tx_info info = {
.subtype = stype,
.was_assoc = true,
.link_id = ffs(sdata->vif.active_links) - 1,
};

lockdep_assert_wiphy(local->hw.wiphy);
Expand Down Expand Up @@ -3569,29 +3571,7 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,

/* deauthenticate/disassociate now */
if (tx || frame_buf) {
/*
* In multi channel scenarios guarantee that the virtual
* interface is granted immediate airtime to transmit the
* deauthentication frame by calling mgd_prepare_tx, if the
* driver requested so.
*/
if (ieee80211_hw_check(&local->hw, DEAUTH_NEED_MGD_TX_PREP)) {
for (link_id = 0; link_id < ARRAY_SIZE(sdata->link);
link_id++) {
struct ieee80211_link_data *link;

link = sdata_dereference(sdata->link[link_id],
sdata);
if (!link)
continue;
if (link->u.mgd.have_beacon)
break;
}
if (link_id == IEEE80211_MLD_MAX_NUM_LINKS) {
info.link_id = ffs(sdata->vif.active_links) - 1;
drv_mgd_prepare_tx(sdata->local, sdata, &info);
}
}
drv_mgd_prepare_tx(sdata->local, sdata, &info);

ieee80211_send_deauth_disassoc(sdata, sdata->vif.cfg.ap_addr,
sdata->vif.cfg.ap_addr, stype,
Expand Down

0 comments on commit 8c62617

Please sign in to comment.