Skip to contentSkip to conversation

wireless: add ieee80211_asmdu_to_8023s

RFC In review Zhu Yi 2 participants 12 messages Nov 26, 2009 – Nov 30, 2009

Subsystems (3)
lore
Share & tools
lore

Zhu Yi

author
#0 lore raw

RFC 1/2 wireless: add ieee80211_asmdu_to_8023s

Move the A-MSDU handling code from mac80211 to cfg80211 so that more drivers can use it. The new created function ieee80211_asmdu_to_8023s converts an A-MSDU frame to a list of 802.3 frames.

---
 include/net/cfg80211.h |   12 +++++
 net/mac80211/rx.c      |  107 ++++++++++-------------------------------------
 net/wireless/util.c    |  105 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 140 insertions(+), 84 deletions(-)
include/net/cfg80211.h +12 -0
index 0884b9a..ad31b55 100644
@@ -1593,6 +1593,18 @@ int ieee80211_data_from_8023(struct sk_buff *skb, u8 *addr,
 			     enum nl80211_iftype iftype, u8 *bssid, bool qos);
 
 /**
+ * ieee80211_asmdu_to_8023s - decode an IEEE 802.11n A-MSDU frame
+ *
+ * @skb: The input IEEE 802.11n A-MSDU frame.
+ * @list: The output list of 802.3 frames. It must be allocated and
+ *      initialized by by the caller.
+ * @addr: The device MAC address.
+ * @iftype: The device interface type.
+ */
+int ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list,
+                             u8 *addr, enum nl80211_iftype iftype);
+
+/**
  * cfg80211_classify8021d - determine the 802.1p/1d tag for a data frame
  * @skb: the data frame
  */
net/mac80211/rx.c +23 -84

131 lines not on this page · raw message

net/wireless/util.c +105 -0

111 lines not on this page · raw message

Signature · 1 line
1.6.0.4
author
#1 lore raw

RFC 2/2 iwmc3200wifi: rx aggregation support

When the device receives an A-MSDU frame (indicated by flag IWM_RX_TICKET_AMSDU_MSK), use ieee80211_amsdu_to_8023s to convert it to a list of 802.3 frames and handled them to upper layer.

---
 drivers/net/wireless/iwmc3200wifi/rx.c |   55 +++++++++++++++++++++++++++-----
 1 files changed, 47 insertions(+), 8 deletions(-)
drivers/net/wireless/iwmc3200wifi/rx.c +47 -8
index 72c27a3..99f4f8a 100644
@@ -1534,6 +1534,34 @@ static void classify8023(struct sk_buff *skb)
 	}
 }
 
+static int iwm_rx_process_amsdu(struct iwm_priv *iwm, struct sk_buff *skb)
+{
+	struct wireless_dev *wdev = iwm_to_wdev(iwm);
+	struct net_device *ndev = iwm_to_ndev(iwm);
+	struct sk_buff_head list;
+	struct sk_buff *frame;
+	int ret;
+
+	IWM_HEXDUMP(iwm, DBG, RX, "A-MSDU: ", skb->data, skb->len);
+
+	skb_queue_head_init(&list);
+	ret = ieee80211_amsdu_to_8023s(skb, &list, ndev->dev_addr,
+				       wdev->iftype);
+	if (ret) {
+		IWM_ERR(iwm, "decode A-MSDU frame failed\n");
+		return -EINVAL;
+	}
+
+	while ((frame = skb_dequeue(&list))) {
+		if (netif_rx_ni(frame) == NET_RX_DROP) {
+			IWM_ERR(iwm, "Packet dropped\n");
+			ndev->stats.rx_dropped++;
+		}
+	}
+
+	return 0;
+}
+
 static void iwm_rx_process_packet(struct iwm_priv *iwm,
 				  struct iwm_rx_packet *packet,
 				  struct iwm_rx_ticket_node *ticket_node)
@@ -1548,25 +1576,36 @@ static void iwm_rx_process_packet(struct iwm_priv *iwm,
 	switch (le16_to_cpu(ticket_node->ticket->action)) {
 	case IWM_RX_TICKET_RELEASE:
 		IWM_DBG_RX(iwm, DBG, "RELEASE packet\n");
+
+		skb->dev = iwm_to_ndev(iwm);
+		skb->protocol = eth_type_trans(skb, ndev);
+		skb->ip_summed = CHECKSUM_NONE;
+		memset(skb->cb, 0, sizeof(skb->cb));
+
+		ndev->stats.rx_packets++;
+		ndev->stats.rx_bytes += skb->len;
+
 		classify8023(skb);
 		iwm_rx_adjust_packet(iwm, packet, ticket_node);
+
+		if (le16_to_cpu(ticket_node->ticket->flags) &
+		    IWM_RX_TICKET_AMSDU_MSK) {			
+			ret = iwm_rx_process_amsdu(iwm, skb);
+			if (ret < 0)
+				kfree_skb(packet->skb);
+			break;
+		}
+
 		ret = ieee80211_data_to_8023(skb, ndev->dev_addr, wdev->iftype);
 		if (ret < 0) {
 			IWM_DBG_RX(iwm, DBG, "Couldn't convert 802.11 header - "
 				   "%d\n", ret);
+			kfree_skb(packet->skb);
 			break;
 		}
 
 		IWM_HEXDUMP(iwm, DBG, RX, "802.3: ", skb->data, skb->len);
 
-		skb->dev = iwm_to_ndev(iwm);
-		skb->protocol = eth_type_trans(skb, ndev);
-		skb->ip_summed = CHECKSUM_NONE;
-		memset(skb->cb, 0, sizeof(skb->cb));
-
-		ndev->stats.rx_packets++;
-		ndev->stats.rx_bytes += skb->len;
-
 		if (netif_rx_ni(skb) == NET_RX_DROP) {
 			IWM_ERR(iwm, "Packet dropped\n");
 			ndev->stats.rx_dropped++;
Signature · 1 line
1.6.0.4
maintainer
#2 lore raw
In reply to Zhu Yi
Quoted 16 lines · Zhu Yi

Move the A-MSDU handling code from mac80211 to cfg80211 so that more drivers can use it. The new created function ieee80211_asmdu_to_8023s converts an A-MSDU frame to a list of 802.3 frames.

---
 include/net/cfg80211.h |   12 +++++
 net/mac80211/rx.c      |  107 ++++++++++-------------------------------------
 net/wireless/util.c    |  105 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 140 insertions(+), 84 deletions(-)
include/net/cfg80211.h +0 -0
index 0884b9a..ad31b55 100644

include/net/cfg80211.h int ieee80211_data_from_8023(struct sk_buff *skb, u8 *addr, · line 1596

Quoted 4 lines
include/net/cfg80211.h +1 -0
@@ -1593,6 +1593,18 @@ int ieee80211_data_from_8023(struct sk_buff *skb, u8 *addr,
 			     enum nl80211_iftype iftype, u8 *bssid, bool qos);
 
 /**
+ * ieee80211_asmdu_to_8023s - decode an IEEE 802.11n A-MSDU frame

^ typo

include/net/cfg80211.h int ieee80211_data_from_8023(struct sk_buff *skb, u8 *addr, · line 1598

Quoted 2 lines
include/net/cfg80211.h +2 -0
+	skb->dev = dev;
+	skb_queue_head_init(&frame_list);

^ use __ versions please, no need for locking since it's on stack

include/net/cfg80211.h int ieee80211_data_from_8023(struct sk_buff *skb, u8 *addr, · line 1600

Quoted 2 lines
include/net/cfg80211.h +2 -0
+	dev->stats.rx_packets++;
+	dev->stats.rx_bytes += skb->len;

Shouldn't rx_packets be per sub-frame?

include/net/cfg80211.h int ieee80211_data_from_8023(struct sk_buff *skb, u8 *addr, · line 1602

Quoted 2 lines
include/net/cfg80211.h +2 -0
+	while (!skb_queue_empty(&frame_list)) {
+		rx->skb = skb_dequeue(&frame_list);

__skb_dequeue

include/net/cfg80211.h int ieee80211_data_from_8023(struct sk_buff *skb, u8 *addr, · line 1604

Quoted 2 lines
include/net/cfg80211.h +2 -0
+/**
+ * ieee80211_asmdu_to_8023s - decode an IEEE 802.11n A-MSDU frame
                 ^ copy/paste :)

Why do you have the kernel-doc twice anyway?

include/net/cfg80211.h int ieee80211_data_from_8023(struct sk_buff *skb, u8 *addr, · line 1605

Quoted 1 line
include/net/cfg80211.h +1 -0
+		skb_queue_tail(list, frame);

__

include/net/cfg80211.h int ieee80211_data_from_8023(struct sk_buff *skb, u8 *addr, · line 1607

Quoted 2 lines
include/net/cfg80211.h +2 -0
+ purge:
+	skb_queue_purge(list);

__ (does that exist? guess it must?)

johannes

author
#3 lore raw
Quoted 4 lines · Johannes Berg

net/mac80211/rx.c ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) · line 1587

Quoted 2 lines
net/mac80211/rx.c +2 -0
+     skb->dev = dev;
+     skb_queue_head_init(&frame_list);

^ use __ versions please, no need for locking since it's on stack

You are right. Good catch!

Quoted 4 lines

net/mac80211/rx.c ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) · line 1595

Quoted 2 lines
net/mac80211/rx.c +2 -0
+     dev->stats.rx_packets++;
+     dev->stats.rx_bytes += skb->len;

Shouldn't rx_packets be per sub-frame?

Not very sure. Maybe it's one frame from the device's perspective? The original code does this so I didn't change the behavior. Should I?

Thanks,
-yi

maintainer
#4 lore raw
Quoted 7 lines · Zhu Yi
Quoted 4 lines

net/mac80211/rx.c ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) · line 1595

Quoted 2 lines
net/mac80211/rx.c +2 -0
+     dev->stats.rx_packets++;
+     dev->stats.rx_bytes += skb->len;

Shouldn't rx_packets be per sub-frame?

Not very sure. Maybe it's one frame from the device's perspective? The original code does this so I didn't change the behavior. Should I?

Ah, yes, I remember now -- had been wondering about this before. What does everybody else think?

johannes

maintainer
#5 lore raw
In reply to Zhu Yi
Quoted 6 lines · Zhu Yi
include/net/cfg80211.h +0 -0
@@ -1593,6 +1593,18 @@ int ieee80211_data_from_8023(struct sk_buff *skb, u8 *addr,
 			     enum nl80211_iftype iftype, u8 *bssid, bool qos);
 
 /**

include/net/cfg80211.h int ieee80211_data_from_8023(struct sk_buff *skb, u8 *addr, · line 1605

Quoted 10 lines
include/net/cfg80211.h +10 -0
+ * ieee80211_asmdu_to_8023s - decode an IEEE 802.11n A-MSDU frame
+ *
+ * @skb: The input IEEE 802.11n A-MSDU frame.
+ * @list: The output list of 802.3 frames. It must be allocated and
+ *      initialized by by the caller.
+ * @addr: The device MAC address.
+ * @iftype: The device interface type.
+ */
+int ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list,
+                             u8 *addr, enum nl80211_iftype iftype);

Oh one more thing, can you make addr const?

Also -- you lost the extra TX headroom which I think mac80211 as an AP requires since it could forward these frames? Or does that not happen? Not sure right now why that was there to start with.

johannes

author
#6 lore raw
Quoted 1 line · Johannes Berg

Oh one more thing, can you make addr const?

Sure.

Quoted 3 lines

Also -- you lost the extra TX headroom which I think mac80211 as an AP requires since it could forward these frames? Or does that not happen? Not sure right now why that was there to start with.

Yes, I'd like to hear more feedback on this. I think it's a trade off between performance optimization and clean interface. As we already use dev_alloc_skb to reserve 32 bytes headroom, it should be enough for most of the current drivers. While for those drivers really need a bigger extra headroom and support Rx aggregation, this probably means ieee80211_skb_resize. But the resize should always happen for every packet from the IP stack, right?

Thanks,
-yi

maintainer
#7 lore raw
Quoted 8 lines · Zhu Yi
Quoted 3 lines

Also -- you lost the extra TX headroom which I think mac80211 as an AP requires since it could forward these frames? Or does that not happen? Not sure right now why that was there to start with.

Yes, I'd like to hear more feedback on this. I think it's a trade off between performance optimization and clean interface. As we already use dev_alloc_skb to reserve 32 bytes headroom, it should be enough for most of the current drivers.

Is it? I don't think so. Many drivers go up beyond that as far as I know. Then some do different things like putting it in a different DMA block.

Quoted 4 lines

While for those drivers really need a bigger
extra headroom and support Rx aggregation, this probably means ieee80211_skb_resize. But the resize should always happen for every packet from the IP stack, right?

No, davem and I optimised that away a long time ago via using netdev->needed_headroom and netdev->needed_tailroom. It even works for bridges and their slave devices, iirc.

johannes

author
#8 lore raw
Quoted 4 lines · Johannes Berg

Is it? I don't think so. Many drivers go up beyond that as far as I know. Then some do different things like putting it in a different DMA block.

Quoted 8 lines
Quoted 4 lines

While for those drivers really need a bigger
extra headroom and support Rx aggregation, this probably means ieee80211_skb_resize. But the resize should always happen for every packet from the IP stack, right?

No, davem and I optimised that away a long time ago via using netdev->needed_headroom and netdev->needed_tailroom. It even works for bridges and their slave devices, iirc.

I missed this. Will check it. If so, I'll add another parameter to pass the extra hw tx headroom to ieee80211_asmdu_to_8023s.

Thanks,
-yi

maintainer
#9 lore raw
Quoted 10 lines · Zhu Yi
Quoted 9 lines · Johannes Berg

Is it? I don't think so. Many drivers go up beyond that as far as I know. Then some do different things like putting it in a different DMA block.

Quoted 4 lines

While for those drivers really need a bigger
extra headroom and support Rx aggregation, this probably means ieee80211_skb_resize. But the resize should always happen for every packet from the IP stack, right?

Quoted 6 lines
Quoted 3 lines

No, davem and I optimised that away a long time ago via using netdev->needed_headroom and netdev->needed_tailroom. It even works for bridges and their slave devices, iirc.

I missed this. Will check it. If so, I'll add another parameter to pass the extra hw tx headroom to ieee80211_asmdu_to_8023s.

The thing is that I'm not even sure if we can possibly forward a frame after this deaggregation. I'll poke at the code.

johannes

maintainer
#10 lore raw
Quoted 2 lines · Johannes Berg

The thing is that I'm not even sure if we can possibly forward a frame after this deaggregation. I'll poke at the code.

Ah, yes, it is possible -- the destination of the A-MSDU subframes might be associated to mac80211 acting as an AP. I was thinking multicast frames can't be encapsulated that way so it can't happen. So yes, adding a headroom parameter would be good I think.

johannes

author
#11 lore raw
In reply to Zhu Yi
Quoted 6 lines · Zhu Yi
Quoted 2 lines

No, davem and I optimised that away a long time ago via using netdev->needed_headroom and netdev->needed_tailroom. It even works

for bridges and their slave devices, iirc.

I missed this. Will check it. If so, I'll add another parameter to pass the extra hw tx headroom to ieee80211_asmdu_to_8023s.

Now I see your changes to LL_RESERVED_SPACE*(). Thanks!

-yi