Skip to contentSkip to conversation

fix TX skb allocation flags and size

PATCH In review Michael Buesch 2 participants 3 messages Oct 13, 2005 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix TX skb allocation flags and size

ieee80211 subsystem:
* Use GFP mask on TX skb allocation.
* Allocate TX skb memory DMA mappable.
* Use the tx_headroom and reserve requested space.

net/ieee80211/ieee80211_tx.c 2005-10-13 22:56:43.000000000 +0200 renamed from net/ieee80211/ieee80211_tx.c.orig 2005-10-13 22:45:13.000000000 +0200 +6 -3
@@ -207,7 +207,7 @@ void ieee80211_txb_free(struct ieee80211
 }
 
 static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size,
-       gfp_t gfp_mask)
+       int headroom, gfp_t gfp_mask)
 {
  struct ieee80211_txb *txb;
  int i;
@@ -221,11 +221,13 @@ static struct ieee80211_txb *ieee80211_a
  txb->frag_size = txb_size;
 
 	for (i = 0; i < nr_frags; i++) {
-		txb->fragments[i] = dev_alloc_skb(txb_size);
+		txb->fragments[i] = __dev_alloc_skb(txb_size + headroom,
+						    gfp_mask | GFP_DMA);
 		if (unlikely(!txb->fragments[i])) {
 			i--;
    break;
   }
+  skb_reserve(txb->fragments[i], headroom);
  }
  if (unlikely(i != nr_frags)) {
   while (i >= 0)
@@ -350,7 +352,8 @@ int ieee80211_xmit(struct sk_buff *skb, 
  /* When we allocate the TXB we allocate enough space for the reserve
   * and full fragment bytes (bytes_per_frag doesn't include prefix,
   * postfix, header, FCS, etc.) */
- txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC);
+ txb = ieee80211_alloc_txb(nr_frags, frag_size,
+      ieee->tx_headroom, GFP_ATOMIC);
  if (unlikely(!txb)) {
   printk(KERN_WARNING "%s: Could not allocate TXB\n",
          ieee->dev->name);
Signature · 1 line
Greetings Michael.

ieee80211 subsystem:
* Use GFP mask on TX skb allocation.
* Allocate TX skb memory DMA mappable.
* Use the tx_headroom and reserve requested space.

net/ieee80211/ieee80211_tx.c renamed from net/ieee80211/ieee80211_tx.c.orig +6 -3
@@ -207,7 +207,7 @@ void ieee80211_txb_free(struct ieee80211
 }
 
 static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size,
-						 gfp_t gfp_mask)
+						 int headroom, gfp_t gfp_mask)
 {
 	struct ieee80211_txb *txb;
 	int i;
@@ -221,11 +221,13 @@ static struct ieee80211_txb *ieee80211_a
 	txb->frag_size = txb_size;
 
 	for (i = 0; i < nr_frags; i++) {
-		txb->fragments[i] = dev_alloc_skb(txb_size);
+		txb->fragments[i] = __dev_alloc_skb(txb_size + headroom,
+						    gfp_mask | GFP_DMA);
 		if (unlikely(!txb->fragments[i])) {
 			i--;
 			break;
 		}
+		skb_reserve(txb->fragments[i], headroom);
 	}
 	if (unlikely(i != nr_frags)) {
 		while (i >= 0)
@@ -350,7 +352,8 @@ int ieee80211_xmit(struct sk_buff *skb, 
 	/* When we allocate the TXB we allocate enough space for the reserve
 	 * and full fragment bytes (bytes_per_frag doesn't include prefix,
 	 * postfix, header, FCS, etc.) */
-	txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC);
+	txb = ieee80211_alloc_txb(nr_frags, frag_size,
+				  ieee->tx_headroom, GFP_ATOMIC);
 	if (unlikely(!txb)) {
 		printk(KERN_WARNING "%s: Could not allocate TXB\n",
 		       ieee->dev->name);
#1 lore raw

net/ieee80211/ieee80211_tx.c 2005-10-13 22:56:43.000000000 +0200 static struct ieee80211_txb *ieee80211_a · line 227

Quoted 9 lines · Michael Buesch
net/ieee80211/ieee80211_tx.c 2005-10-13 22:56:43.000000000 +0200 renamed from net/ieee80211/ieee80211_tx.c.orig 2005-10-13 22:45:13.000000000 +0200 +2 -1
@@ -221,11 +221,13 @@ static struct ieee80211_txb *ieee80211_a
  txb->frag_size = txb_size;
 
 	for (i = 0; i < nr_frags; i++) {
-		txb->fragments[i] = dev_alloc_skb(txb_size);
+		txb->fragments[i] = __dev_alloc_skb(txb_size + headroom,
+						    gfp_mask | GFP_DMA);
 		if (unlikely(!txb->fragments[i])) {
 			i--;

Very wrong. GFP_DMA means ISA DMA.

See pci_map_xxx() and other DMA API functions.

Jeff

#2 lore raw
Quoted 13 lines · you

Review static struct ieee80211_txb *ieee80211_a · line 227

Quoted 9 lines · Michael Buesch
(quoted diff) +2 -1
@@ -221,11 +221,13 @@ static struct ieee80211_txb *ieee80211_a
  txb->frag_size = txb_size;
 
  for (i = 0; i < nr_frags; i++) {
-  txb->fragments[i] = dev_alloc_skb(txb_size);
+  txb->fragments[i] = __dev_alloc_skb(txb_size + headroom,
+          gfp_mask | GFP_DMA);
   if (unlikely(!txb->fragments[i])) {
    i--;

Very wrong. GFP_DMA means ISA DMA.

Quoted 1 line

See pci_map_xxx() and other DMA API functions.

Ok, the size issue is still valid and the real reason for doing this patch. Please apply this:

ieee80211: Use tx_headroom

net/ieee80211/ieee80211_tx.c 2005-10-14 01:11:29.000000000 +0200 renamed from net/ieee80211/ieee80211_tx.c.orig 2005-10-13 22:45:13.000000000 +0200 +6 -3
@@ -207,7 +207,7 @@ void ieee80211_txb_free(struct ieee80211
 }
 
 static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size,
-       gfp_t gfp_mask)
+       int headroom, gfp_t gfp_mask)
 {
  struct ieee80211_txb *txb;
  int i;
@@ -221,11 +221,13 @@ static struct ieee80211_txb *ieee80211_a
  txb->frag_size = txb_size;
 
  for (i = 0; i < nr_frags; i++) {
-  txb->fragments[i] = dev_alloc_skb(txb_size);
+  txb->fragments[i] = __dev_alloc_skb(txb_size + headroom,
+          gfp_mask);
   if (unlikely(!txb->fragments[i])) {
    i--;
    break;
   }
+  skb_reserve(txb->fragments[i], headroom);
  }
  if (unlikely(i != nr_frags)) {
   while (i >= 0)
@@ -350,7 +352,8 @@ int ieee80211_xmit(struct sk_buff *skb, 
  /* When we allocate the TXB we allocate enough space for the reserve
   * and full fragment bytes (bytes_per_frag doesn't include prefix,
   * postfix, header, FCS, etc.) */
- txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC);
+ txb = ieee80211_alloc_txb(nr_frags, frag_size,
+      ieee->tx_headroom, GFP_ATOMIC);
  if (unlikely(!txb)) {
   printk(KERN_WARNING "%s: Could not allocate TXB\n",
          ieee->dev->name);
Signature · 1 line
Greetings Michael.

ieee80211: Use tx_headroom

net/ieee80211/ieee80211_tx.c renamed from net/ieee80211/ieee80211_tx.c.orig +6 -3
@@ -207,7 +207,7 @@ void ieee80211_txb_free(struct ieee80211
 }
 
 static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size,
-						 gfp_t gfp_mask)
+						 int headroom, gfp_t gfp_mask)
 {
 	struct ieee80211_txb *txb;
 	int i;
@@ -221,11 +221,13 @@ static struct ieee80211_txb *ieee80211_a
 	txb->frag_size = txb_size;
 
 	for (i = 0; i < nr_frags; i++) {
-		txb->fragments[i] = dev_alloc_skb(txb_size);
+		txb->fragments[i] = __dev_alloc_skb(txb_size + headroom,
+						    gfp_mask);
 		if (unlikely(!txb->fragments[i])) {
 			i--;
 			break;
 		}
+		skb_reserve(txb->fragments[i], headroom);
 	}
 	if (unlikely(i != nr_frags)) {
 		while (i >= 0)
@@ -350,7 +352,8 @@ int ieee80211_xmit(struct sk_buff *skb, 
 	/* When we allocate the TXB we allocate enough space for the reserve
 	 * and full fragment bytes (bytes_per_frag doesn't include prefix,
 	 * postfix, header, FCS, etc.) */
-	txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC);
+	txb = ieee80211_alloc_txb(nr_frags, frag_size,
+				  ieee->tx_headroom, GFP_ATOMIC);
 	if (unlikely(!txb)) {
 		printk(KERN_WARNING "%s: Could not allocate TXB\n",
 		       ieee->dev->name);