wifi: mac80211: update beacon counters per link basis
authorAditya Kumar Singh <quic_adisi@quicinc.com>
Tue, 30 Jan 2024 14:09:15 +0000 (19:39 +0530)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 8 Feb 2024 14:00:45 +0000 (15:00 +0100)
Currently, function to update beacon counter uses deflink to fetch
the beacon and then update the counter. However, with MLO, there is
a need to update the counter for the beacon in a particular link.

Add support to use link_id in order to fetch the beacon from a particular
link data during beacon update counter.

Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
Link: https://msgid.link/20240130140918.1172387-3-quic_adisi@quicinc.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/ath/ath10k/mac.c
drivers/net/wireless/ath/ath11k/mac.c
drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
include/net/mac80211.h
net/mac80211/tx.c

index fc503db2fd8ed3fda007a6118dc1828a2986cd86..b802204061044616d99c44f41b6418e824afe22b 100644 (file)
@@ -2035,7 +2035,7 @@ static void ath10k_mac_vif_ap_csa_count_down(struct ath10k_vif *arvif)
                return;
 
        if (!ieee80211_beacon_cntdwn_is_complete(vif)) {
-               ieee80211_beacon_update_cntdwn(vif);
+               ieee80211_beacon_update_cntdwn(vif, 0);
 
                ret = ath10k_mac_setup_bcn_tmpl(arvif);
                if (ret)
index bbf4d1f4d310c1f9b1a1355faeb6274499ca031c..f7cab50bdfd12b3cfc0b7ea915d47b0e5ffa65b4 100644 (file)
@@ -1586,7 +1586,7 @@ void ath11k_mac_bcn_tx_event(struct ath11k_vif *arvif)
        arvif->bcca_zero_sent = false;
 
        if (vif->bss_conf.color_change_active)
-               ieee80211_beacon_update_cntdwn(vif);
+               ieee80211_beacon_update_cntdwn(vif, 0);
        ath11k_mac_setup_bcn_tmpl(arvif);
 }
 
index 61269c7b1934f95a389a54a1a43ae6412301782d..3dea06b28472f4db0d88781a43ccc31098a01c4c 100644 (file)
@@ -1467,7 +1467,7 @@ static void iwl_mvm_csa_count_down(struct iwl_mvm *mvm,
        mvmvif->csa_countdown = true;
 
        if (!ieee80211_beacon_cntdwn_is_complete(csa_vif)) {
-               int c = ieee80211_beacon_update_cntdwn(csa_vif);
+               int c = ieee80211_beacon_update_cntdwn(csa_vif, 0);
 
                iwl_mvm_mac_ctxt_beacon_changed(mvm, csa_vif,
                                                &csa_vif->bss_conf);
index 54aa4a06c878dc796b5541a15c0322f21b63e0fb..8acee7ce3aa9cb2f151e2da444e66c0070d8591d 100644 (file)
@@ -5526,6 +5526,7 @@ static inline struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
 /**
  * ieee80211_beacon_update_cntdwn - request mac80211 to decrement the beacon countdown
  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
+ * @link_id: valid link_id during MLO or 0 for non-MLO
  *
  * The beacon counter should be updated after each beacon transmission.
  * This function is called implicitly when
@@ -5535,7 +5536,8 @@ static inline struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
  *
  * Return: new countdown value
  */
-u8 ieee80211_beacon_update_cntdwn(struct ieee80211_vif *vif);
+u8 ieee80211_beacon_update_cntdwn(struct ieee80211_vif *vif,
+                                 unsigned int link_id);
 
 /**
  * ieee80211_beacon_set_cntdwn - request mac80211 to set beacon countdown
index 098b32947c2b1a187f3d6204353c17776ad8edbf..876de3ba98ba40cf1eed1523ac63ef3c8092c70c 100644 (file)
@@ -5027,16 +5027,24 @@ static u8 __ieee80211_beacon_update_cntdwn(struct beacon_data *beacon)
        return beacon->cntdwn_current_counter;
 }
 
-u8 ieee80211_beacon_update_cntdwn(struct ieee80211_vif *vif)
+u8 ieee80211_beacon_update_cntdwn(struct ieee80211_vif *vif, unsigned int link_id)
 {
        struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
+       struct ieee80211_link_data *link;
        struct beacon_data *beacon = NULL;
        u8 count = 0;
 
+       if (WARN_ON(link_id >= IEEE80211_MLD_MAX_NUM_LINKS))
+               return 0;
+
        rcu_read_lock();
 
+       link = rcu_dereference(sdata->link[link_id]);
+       if (!link)
+               goto unlock;
+
        if (sdata->vif.type == NL80211_IFTYPE_AP)
-               beacon = rcu_dereference(sdata->deflink.u.ap.beacon);
+               beacon = rcu_dereference(link->u.ap.beacon);
        else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
                beacon = rcu_dereference(sdata->u.ibss.presp);
        else if (ieee80211_vif_is_mesh(&sdata->vif))
@@ -5277,7 +5285,7 @@ ieee80211_beacon_get_ap(struct ieee80211_hw *hw,
 
        if (beacon->cntdwn_counter_offsets[0]) {
                if (!is_template)
-                       ieee80211_beacon_update_cntdwn(vif);
+                       ieee80211_beacon_update_cntdwn(vif, link->link_id);
 
                ieee80211_set_beacon_cntdwn(sdata, beacon, link);
        }