From: Priyansha Tiwari Populate link_valid/link_id in mac80211_hwsim TX status so the transmitted link is reported to mac80211. Set the link information in both the direct TX status path and the wmediumd/netlink TX status path. Signed-off-by: Priyansha Tiwari --- .../wireless/virtual/mac80211_hwsim_main.c | 43 +++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/virtual/mac80211_hwsim_main.c b/drivers/net/wireless/virtual/mac80211_hwsim_main.c index dc9775cd9f54..4ad39cdfb7a7 100644 --- a/drivers/net/wireless/virtual/mac80211_hwsim_main.c +++ b/drivers/net/wireless/virtual/mac80211_hwsim_main.c @@ -2077,6 +2077,7 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw, bool ack, unicast_data; enum nl80211_chan_width confbw = NL80211_CHAN_WIDTH_20_NOHT; u32 _portid, i; + int tx_link_id = -1; if (WARN_ON(skb->len < 10)) { /* Should not happen; just a sanity check for addr1 use */ @@ -2134,6 +2135,9 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw, hdr, &link_sta); } + if (bss_conf) + tx_link_id = bss_conf->link_id; + if (unlikely(!bss_conf)) { /* if it's an MLO STA, it might have deactivated all * links temporarily - but we don't handle real PS in @@ -2245,6 +2249,12 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw, if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK) && ack) txi->flags |= IEEE80211_TX_STAT_ACK; + + if (tx_link_id >= 0) { + txi->status.link_valid = 1; + txi->status.link_id = tx_link_id; + } + ieee80211_tx_status_irqsafe(hw, skb); } @@ -6037,6 +6047,7 @@ static int mac80211_hwsim_new_radio(struct genl_info *info, wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST); wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_PUNCT); + wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_PROBE_AP); for (i = 0; i < ARRAY_SIZE(data->link_data); i++) { hrtimer_setup(&data->link_data[i].beacon_timer, mac80211_hwsim_beacon, @@ -6262,6 +6273,27 @@ static void hwsim_register_wmediumd(struct net *net, u32 portid) spin_unlock_bh(&hwsim_radio_lock); } +static int mac80211_hwsim_get_link_id(struct ieee80211_vif *vif, + struct ieee80211_hdr *hdr) +{ + int i; + + if (!vif || !ieee80211_vif_is_mld(vif)) + return -1; + + for (i = 0; i < IEEE80211_MLD_MAX_NUM_LINKS; i++) { + struct ieee80211_bss_conf *link_conf; + + link_conf = rcu_dereference(vif->link_conf[i]); + if (!link_conf) + continue; + if (ether_addr_equal(link_conf->addr, hdr->addr2)) + return i; + } + + return -1; +} + static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2, struct genl_info *info) { @@ -6342,13 +6374,18 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2, txi->status.ack_signal = nla_get_u32(info->attrs[HWSIM_ATTR_SIGNAL]); + hdr = (struct ieee80211_hdr *)skb->data; + i = mac80211_hwsim_get_link_id(txi->control.vif, hdr); + if (i >= 0) { + txi->status.link_valid = 1; + txi->status.link_id = i; + } + if (!(hwsim_flags & HWSIM_TX_CTL_NO_ACK) && (hwsim_flags & HWSIM_TX_STAT_ACK)) { - if (skb->len >= 16) { - hdr = (struct ieee80211_hdr *) skb->data; + if (skb->len >= 16) mac80211_hwsim_monitor_ack(data2->channel, hdr->addr2); - } txi->flags |= IEEE80211_TX_STAT_ACK; } -- 2.34.1