wifi: iwlwifi: mvm: translate management frame address
authorShaul Triebitz <shaul.triebitz@intel.com>
Wed, 29 Mar 2023 07:05:19 +0000 (10:05 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 30 Mar 2023 10:08:39 +0000 (12:08 +0200)
For management frames sent by an AP interface, translate
the MLD addresses to LINK addresses (for an MLD AP).
AP (non-bufferable) management frames are sent via
the broadcast station so the translation cannot be
done by the firmware.

Signed-off-by: Shaul Triebitz <shaul.triebitz@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230329100039.3cb4292f51e8.Ia662c00ff271c70eda927c12ed49b045b1eb8489@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c

index 92567ab..4c8ab1d 100644 (file)
@@ -722,6 +722,9 @@ void iwl_mvm_mac_tx(struct ieee80211_hw *hw,
        struct ieee80211_hdr *hdr = (void *)skb->data;
        bool offchannel = IEEE80211_SKB_CB(skb)->flags &
                IEEE80211_TX_CTL_TX_OFFCHAN;
+       u32 link_id = u32_get_bits(info->control.flags,
+                                  IEEE80211_TX_CTRL_MLO_LINK);
+       struct ieee80211_sta *tmp_sta = sta;
 
        if (iwl_mvm_is_radio_killed(mvm)) {
                IWL_DEBUG_DROP(mvm, "Dropping - RF/CT KILL\n");
@@ -755,6 +758,25 @@ void iwl_mvm_mac_tx(struct ieee80211_hw *hw,
                }
        }
 
+       if (tmp_sta && !sta && link_id != IEEE80211_LINK_UNSPECIFIED &&
+           !ieee80211_is_probe_resp(hdr->frame_control)) {
+               /* translate MLD addresses to LINK addresses */
+               struct ieee80211_link_sta *link_sta =
+                       rcu_dereference(tmp_sta->link[link_id]);
+               struct ieee80211_bss_conf *link_conf =
+                       rcu_dereference(info->control.vif->link_conf[link_id]);
+               struct ieee80211_mgmt *mgmt;
+
+               if (WARN_ON(!link_sta || !link_conf))
+                       goto drop;
+
+               /* if sta is NULL, the frame is a management frame */
+               mgmt = (void *)hdr;
+               memcpy(mgmt->da, link_sta->addr, ETH_ALEN);
+               memcpy(mgmt->sa, link_conf->addr, ETH_ALEN);
+               memcpy(mgmt->bssid, link_conf->bssid, ETH_ALEN);
+       }
+
        iwl_mvm_tx_skb(mvm, skb, sta);
        return;
  drop: