Skip to contentSkip to conversation

wifi: mac80211: determine missing link_id in ieee80211_rx_for_interface() based on frequency

PATCH New Michael-CY Lee 1 participant 1 message Jul 21, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 wifi: mac80211: determine missing link_id in ieee80211_rx_for_interface() based on frequency

For broadcast frames, every interface might have to process it and therefore the link_id cannot be determined in the driver.

In mac80211, when the frame is about to be forwarded to each interface, we can use the member "freq" in struct ieee80211_rx_status to determine the "link_id" for each interface.

---
v2:
- use frequency instead of band

---
 net/mac80211/rx.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
net/mac80211/rx.c +22 -1
index b414c9e6e61b..2ac8ccb838ff 100644
@@ -5106,8 +5106,29 @@ static bool ieee80211_rx_for_interface(struct ieee80211_rx_data *rx,
 		struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
 
 		sta = sta_info_get_bss(rx->sdata, hdr->addr2);
-		if (status->link_valid)
+		if (status->link_valid) {
 			link_id = status->link_id;
+		} else if (ieee80211_vif_is_mld(&rx->sdata->vif) &&
+			   status->freq) {
+			struct ieee80211_link_data *link;
+			struct ieee80211_chanctx_conf *conf;
+			int i;
+
+			for_each_valid_link(&rx->sdata->wdev, i) {
+				link = rcu_dereference(rx->sdata->link[i]);
+				if (!link || !link->conf)
+					continue;
+
+				conf = rcu_dereference(link->conf->chanctx_conf);
+				if (!conf || !conf->def.chan)
+					continue;
+
+				if (status->freq == conf->def.chan->center_freq) {
+					link_id = i;
+					break;
+				}
+			}
+		}
 	}
 
 	if (!ieee80211_rx_data_set_sta(rx, sta, link_id))
Signature · 1 line
2.25.1