wifi: mac80211_hwsim: move beacon transmission to a separate function
authorAloka Dixit <quic_alokad@quicinc.com>
Tue, 6 Dec 2022 00:50:38 +0000 (16:50 -0800)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 22 Mar 2023 12:55:03 +0000 (13:55 +0100)
Move the beacon transmission to a separate function to facilitate
addition of EMA beacon transmission.

Signed-off-by: Aloka Dixit <quic_alokad@quicinc.com>
Link: https://lore.kernel.org/r/20221206005040.3177-3-quic_alokad@quicinc.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/virtual/mac80211_hwsim.c

index f4bdc24..0b4f489 100644 (file)
@@ -2055,38 +2055,18 @@ static void mac80211_hwsim_tx_frame(struct ieee80211_hw *hw,
        dev_kfree_skb(skb);
 }
 
-static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac,
-                                    struct ieee80211_vif *vif)
+static void __mac80211_hwsim_beacon_tx(struct ieee80211_bss_conf *link_conf,
+                                      struct mac80211_hwsim_data *data,
+                                      struct ieee80211_hw *hw,
+                                      struct ieee80211_vif *vif,
+                                      struct sk_buff *skb)
 {
-       struct mac80211_hwsim_link_data *link_data = arg;
-       u32 link_id = link_data->link_id;
-       struct ieee80211_bss_conf *link_conf;
-       struct mac80211_hwsim_data *data =
-               container_of(link_data, struct mac80211_hwsim_data,
-                            link_data[link_id]);
-       struct ieee80211_hw *hw = data->hw;
        struct ieee80211_tx_info *info;
        struct ieee80211_rate *txrate;
        struct ieee80211_mgmt *mgmt;
-       struct sk_buff *skb;
        /* TODO: get MCS */
        int bitrate = 100;
 
-       hwsim_check_magic(vif);
-
-       link_conf = rcu_dereference(vif->link_conf[link_id]);
-       if (!link_conf)
-               return;
-
-       if (vif->type != NL80211_IFTYPE_AP &&
-           vif->type != NL80211_IFTYPE_MESH_POINT &&
-           vif->type != NL80211_IFTYPE_ADHOC &&
-           vif->type != NL80211_IFTYPE_OCB)
-               return;
-
-       skb = ieee80211_beacon_get(hw, vif, link_data->link_id);
-       if (skb == NULL)
-               return;
        info = IEEE80211_SKB_CB(skb);
        if (ieee80211_hw_check(hw, SUPPORTS_RC_TABLE))
                ieee80211_get_tx_rates(vif, NULL, skb,
@@ -2116,6 +2096,37 @@ static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac,
 
        mac80211_hwsim_tx_frame(hw, skb,
                        rcu_dereference(link_conf->chanctx_conf)->def.chan);
+}
+
+static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac,
+                                    struct ieee80211_vif *vif)
+{
+       struct mac80211_hwsim_link_data *link_data = arg;
+       u32 link_id = link_data->link_id;
+       struct ieee80211_bss_conf *link_conf;
+       struct mac80211_hwsim_data *data =
+               container_of(link_data, struct mac80211_hwsim_data,
+                            link_data[link_id]);
+       struct ieee80211_hw *hw = data->hw;
+       struct sk_buff *skb;
+
+       hwsim_check_magic(vif);
+
+       link_conf = rcu_dereference(vif->link_conf[link_id]);
+       if (!link_conf)
+               return;
+
+       if (vif->type != NL80211_IFTYPE_AP &&
+           vif->type != NL80211_IFTYPE_MESH_POINT &&
+           vif->type != NL80211_IFTYPE_ADHOC &&
+           vif->type != NL80211_IFTYPE_OCB)
+               return;
+
+       skb = ieee80211_beacon_get(hw, vif, link_id);
+       if (!skb)
+               return;
+
+       __mac80211_hwsim_beacon_tx(link_conf, data, hw, vif, skb);
 
        while ((skb = ieee80211_get_buffered_bc(hw, vif)) != NULL) {
                mac80211_hwsim_tx_frame(hw, skb,