Skip to contentSkip to conversation

mac80211: Support receiving data frames on multiple vifs.

mac80211 [email protected] 2 participants 4 messages Sep 20, 2010 – Sep 21, 2010 mac80211

lore
Share & tools
lore
#0 lore raw

From: Ben Greear <[email protected]>

When using multiple STA interfaces on the same radio, some data packets need to be received on all interfaces (broadcast, for instance).

Remove special loop for data-only packets and just process all packets in the big loop that previously only handled non-data packets.

This needs review.

---
:100644 100644 c036815... 63baa04... M net/mac80211/rx.c

 net/mac80211/rx.c |  121 ++++++++++++++++++++++-------------------------------
 1 files changed, 50 insertions(+), 71 deletions(-)
net/mac80211/rx.c +50 -71
index c036815..63baa04 100644
@@ -2613,8 +2613,6 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
 	int prepares;
 	struct ieee80211_sub_if_data *prev = NULL;
 	struct sk_buff *skb_new;
-	struct sta_info *sta, *tmp;
-	bool found_sta = false;
 	int err = 0;
 
 	fc = ((struct ieee80211_hdr *)skb->data)->frame_control;
@@ -2643,87 +2641,68 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
 	ieee80211_parse_qos(&rx);
 	ieee80211_verify_alignment(&rx);
 
-	if (ieee80211_is_data(fc)) {
-		for_each_sta_info(local, hdr->addr2, sta, tmp) {
-			rx.sta = sta;
-			found_sta = true;
-			rx.sdata = sta->sdata;
-
-			rx.flags |= IEEE80211_RX_RA_MATCH;
-			prepares = prepare_for_handlers(rx.sdata, &rx, hdr);
-			if (prepares) {
-				if (status->flag & RX_FLAG_MMIC_ERROR) {
-					if (rx.flags & IEEE80211_RX_RA_MATCH)
-						ieee80211_rx_michael_mic_report(hdr, &rx);
-				} else
-					prev = rx.sdata;
-			}
-		}
-	}
-	if (!found_sta) {
-		list_for_each_entry_rcu(sdata, &local->interfaces, list) {
-			if (!ieee80211_sdata_running(sdata))
-				continue;
-
-			if (sdata->vif.type == NL80211_IFTYPE_MONITOR ||
-			    sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
-				continue;
+	list_for_each_entry_rcu(sdata, &local->interfaces, list) {
+		if (!ieee80211_sdata_running(sdata))
+			continue;
 
-			/*
-			 * frame is destined for this interface, but if it's
-			 * not also for the previous one we handle that after
-			 * the loop to avoid copying the SKB once too much
-			 */
+		if (sdata->vif.type == NL80211_IFTYPE_MONITOR ||
+		    sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
+			continue;
 
-			if (!prev) {
-				prev = sdata;
-				continue;
-			}
+		/*
+		 * frame is destined for this interface, but if it's
+		 * not also for the previous one we handle that after
+		 * the loop to avoid copying the SKB once too much
+		 */
 
-			rx.sta = sta_info_get_bss(prev, hdr->addr2);
+		if (!prev) {
+			prev = sdata;
+			continue;
+		}
 
-			rx.flags |= IEEE80211_RX_RA_MATCH;
-			prepares = prepare_for_handlers(prev, &rx, hdr);
+		rx.sta = sta_info_get_bss(prev, hdr->addr2);
+		rx.sdata = prev;
+		rx.flags |= IEEE80211_RX_RA_MATCH;
+		prepares = prepare_for_handlers(prev, &rx, hdr);
 
-			if (!prepares)
-				goto next;
+		if (!prepares)
+			goto next;
 
-			if (status->flag & RX_FLAG_MMIC_ERROR) {
-				rx.sdata = prev;
-				if (rx.flags & IEEE80211_RX_RA_MATCH)
-					ieee80211_rx_michael_mic_report(hdr,
-									&rx);
-				goto next;
-			}
+		if (status->flag & RX_FLAG_MMIC_ERROR) {
+			rx.sdata = prev;
+			if (rx.flags & IEEE80211_RX_RA_MATCH)
+				ieee80211_rx_michael_mic_report(hdr, &rx);
+			goto next;
+		}
 
-			/*
-			 * frame was destined for the previous interface
-			 * so invoke RX handlers for it
-			 */
+		/*
+		 * frame was destined for the previous interface
+		 * so invoke RX handlers for it
+		 */
 
-			skb_new = skb_copy(skb, GFP_ATOMIC);
-			if (!skb_new) {
-				if (net_ratelimit())
-					wiphy_debug(local->hw.wiphy,
-						    "failed to copy multicast frame for %s\n",
-						    prev->name);
-				goto next;
-			}
-			ieee80211_invoke_rx_handlers(prev, &rx, skb_new);
-next:
-			prev = sdata;
+		skb_new = skb_copy(skb, GFP_ATOMIC);
+		if (!skb_new) {
+			if (net_ratelimit())
+				wiphy_debug(local->hw.wiphy,
+					    "failed to copy multicast frame for %s\n",
+					    prev->name);
+			goto next;
 		}
+		ieee80211_invoke_rx_handlers(prev, &rx, skb_new);
+next:
+		prev = sdata;
+	} /* for all interfaces */
 
-		if (prev) {
-			rx.sta = sta_info_get_bss(prev, hdr->addr2);
-
-			rx.flags |= IEEE80211_RX_RA_MATCH;
-			prepares = prepare_for_handlers(prev, &rx, hdr);
+	if (prev) {
+		rx.sta = sta_info_get_bss(prev, hdr->addr2);
+		rx.sdata = prev;
+		rx.flags |= IEEE80211_RX_RA_MATCH;
+		prepares = prepare_for_handlers(prev, &rx, hdr);
 
-			if (!prepares)
-				prev = NULL;
-		}
+		if (!prepares)
+			prev = NULL;
 	}
+
 	if (prev)
 		ieee80211_invoke_rx_handlers(prev, &rx, skb);
 	else
Signature · 1 line
1.7.2.2
maintainer
#1 lore raw
Quoted 9 lines · On Mon, 2010-09-20 at 10:52 -0700, [email protected] wrote:

From: Ben Greear <[email protected]>

When using multiple STA interfaces on the same radio, some data packets need to be received on all interfaces (broadcast, for instance).

Remove special loop for data-only packets and just process all packets in the big loop that previously only handled non-data packets.

I'd prefer keeping different for_each_*, but maybe we can make the loops just call a common function, say with &prev pointer or something? The station loop will typically be iterating over fewer things here.

johannes

author
#2 lore raw
Quoted 7 lines · Johannes Berg
Quoted 6 lines · On Mon, 2010-09-20 at 10:52 -0700, [email protected] wrote:

From: Ben Greear<[email protected]>

When using multiple STA interfaces on the same radio, some data packets need to be received on all interfaces (broadcast, for instance).

Quoted 7 lines
Quoted 3 lines

Remove special loop for data-only packets and just process all packets in the big loop that previously only handled non-data packets.

I'd prefer keeping different for_each_*, but maybe we can make the loops just call a common function, say with&prev pointer or something? The station loop will typically be iterating over fewer things here.

While attempting this, I see something strange. It appears that for the last interface (in the non-data loop), the
if (status->flag & RX_FLAG_MMIC_ERROR)
logic will not be run?

Is that on purpose?

Thanks,
Ben

Quoted 2 lines

johannes

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com
maintainer
#3 lore raw
Quoted 16 lines · Ben Greear
Quoted 7 lines · Johannes Berg
Quoted 6 lines · On Mon, 2010-09-20 at 10:52 -0700, [email protected] wrote:

From: Ben Greear<[email protected]>

When using multiple STA interfaces on the same radio, some data packets need to be received on all interfaces (broadcast, for instance).

Quoted 7 lines
Quoted 3 lines

Remove special loop for data-only packets and just process all packets in the big loop that previously only handled non-data packets.

I'd prefer keeping different for_each_*, but maybe we can make the loops just call a common function, say with&prev pointer or something? The station loop will typically be iterating over fewer things here.

Quoted 6 lines

While attempting this, I see something strange. It appears that for the last interface (in the non-data loop), the
if (status->flag & RX_FLAG_MMIC_ERROR)
logic will not be run?

Is that on purpose?

No, certainly not.

johannes