Skip to contentSkip to conversation

netxen: fix lro buffer allocation

PATCH Applied Dhananjay Phadke 3 participants 10 messages Sep 3, 2009 – Sep 4, 2009

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

PATCH 1/3 netxen: fix lro buffer allocation

From: Dhananjay Phadke <[email protected]>

Alloc 12k skbuffs so that firmware can aggregate more packets into one buffer. This doesn't raise memory consumption since 9k skbs use 16k slab cache anyway.

---
 drivers/net/netxen/netxen_nic.h      |    1 +
 drivers/net/netxen/netxen_nic_init.c |    8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/net/netxen/netxen_nic.h +1 -0
index 224a746..ede2fa7 100644
@@ -149,6 +149,7 @@
 #define NX_P2_RX_JUMBO_BUF_MAX_LEN     (NX_MAX_ETHERHDR + P2_MAX_MTU)
 #define NX_P3_RX_JUMBO_BUF_MAX_LEN     (NX_MAX_ETHERHDR + P3_MAX_MTU)
 #define NX_CT_DEFAULT_RX_BUF_LEN	2048
+#define NX_LRO_BUFFER_EXTRA		2048
 
 #define NX_RX_LRO_BUFFER_LENGTH		(8060)
 
drivers/net/netxen/netxen_nic_init.c +6 -2
index 8d4aa6f..04e36f2 100644
@@ -265,6 +265,10 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
 			else
 				rds_ring->dma_size =
 					NX_P2_RX_JUMBO_BUF_MAX_LEN;
+
+			if (adapter->capabilities & NX_CAP0_HW_LRO)
+				rds_ring->dma_size += NX_LRO_BUFFER_EXTRA;
+
 			rds_ring->skb_size =
 				rds_ring->dma_size + NET_IP_ALIGN;
 			break;
@@ -1217,6 +1221,7 @@ netxen_process_rcv(struct netxen_adapter *adapter,
 	if (pkt_offset)
 		skb_pull(skb, pkt_offset);
 
+	skb->truesize = skb->len + sizeof(struct sk_buff);
 	skb->protocol = eth_type_trans(skb, netdev);
 
 	napi_gro_receive(&sds_ring->napi, skb);
@@ -1278,8 +1283,7 @@ netxen_process_lro(struct netxen_adapter *adapter,
 
 	skb_put(skb, lro_length + data_offset);
 
-	skb->truesize = (skb->len + sizeof(struct sk_buff) +
-			((unsigned long)skb->data - (unsigned long)skb->head));
+	skb->truesize = skb->len + sizeof(struct sk_buff) + skb_headroom(skb);
 
 	skb_pull(skb, l2_hdr_offset);
 	skb->protocol = eth_type_trans(skb, netdev);
Signature · 1 line
1.6.0.2
#1 lore raw

PATCH 2/3 netxen: remove duplicate napi_add

Remove duplicate calls to netxen_napi_add().

---
 drivers/net/netxen/netxen_nic_main.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
drivers/net/netxen/netxen_nic_main.c +0 -6
index f824a39..53d57dc 100644
@@ -1095,10 +1095,6 @@ netxen_setup_netdev(struct netxen_adapter *adapter,
 
 	netdev->irq = adapter->msix_entries[0].vector;
 
-	err = netxen_napi_add(adapter, netdev);
-	if (err)
-		return err;
-
 	init_timer(&adapter->watchdog_timer);
 	adapter->watchdog_timer.function = &netxen_watchdog;
 	adapter->watchdog_timer.data = (unsigned long)adapter;
@@ -2038,8 +2034,6 @@ netxen_remove_sysfs_entries(struct netxen_adapter *adapter)
 		device_remove_file(dev, &dev_attr_bridged_mode);
 }
 
-static void netxen_watchdog(unsigned long);
-
 #ifdef CONFIG_INET
 
 #define is_netxen_netdev(dev) (dev->netdev_ops == &netxen_netdev_ops)
Signature · 1 line
1.6.0.2
maintainer Applied
#2 lore raw

Re: [PATCH NEXT 2/3] netxen: remove duplicate napi_add

From: Dhananjay Phadke <[email protected]>
Date: Thu, 3 Sep 2009 16:10:54 -0700

Quoted 3 lines

Remove duplicate calls to netxen_napi_add().

Applied, but:

drivers/net/netxen/netxen_nic_main.c netxen_remove_sysfs_entries(struct netxen_adapter *adapter) · line 2039

Quoted 9 lines
drivers/net/netxen/netxen_nic_main.c +0 -2
@@ -2038,8 +2034,6 @@ netxen_remove_sysfs_entries(struct netxen_adapter *adapter)
 		device_remove_file(dev, &dev_attr_bridged_mode);
 }
 
-static void netxen_watchdog(unsigned long);
-
 #ifdef CONFIG_INET
 
 #define is_netxen_netdev(dev) (dev->netdev_ops == &netxen_netdev_ops)

Give me a friggin' break, really.

If you're going to slip unrelated cleanups like this into your patches, at least DOCUMENT them in the commit message.

#3 lore raw

PATCH 3/3 netxen: fix infinite loop on dma mapping failure

In reply to Dhananjay Phadke

Fix a perpetual while() loop in unwinding partial
mapped tx skb on dma mapping failure.

---
 drivers/net/netxen/netxen_nic_main.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/netxen/netxen_nic_main.c +2 -2
index 53d57dc..41b2967 100644
@@ -1577,8 +1577,8 @@ netxen_map_tx_skb(struct pci_dev *pdev,
 	return 0;
 
 unwind:
-	while (i > 0) {
-		nf = &pbuf->frag_array[i];
+	while (--i >= 0) {
+		nf = &pbuf->frag_array[i+1];
 		pci_unmap_page(pdev, nf->dma, nf->length, PCI_DMA_TODEVICE);
 	}
 
Signature · 1 line
1.6.0.2
maintainer Applied
#5 lore raw
In reply to Dhananjay Phadke

From: Dhananjay Phadke <[email protected]>
Date: Thu, 3 Sep 2009 16:10:53 -0700

Quoted 7 lines

From: Dhananjay Phadke <[email protected]>

Alloc 12k skbuffs so that firmware can aggregate more packets into one buffer. This doesn't raise memory consumption since 9k skbs use 16k slab cache anyway.

Applied. But allocating such huge linear buffers is asking for guarenteed trouble. Can't you split them up into page sized chunks with this chip?

#6 lore raw
Quoted 5 lines

Applied. But allocating such huge linear buffers is asking for guarenteed trouble. Can't you split them up into page sized chunks with this chip?

"chained" LRO is not enabled by firmware. Contiguous LRO requires fewer commands (internal) from firmware to DMA engines.

-Dhananjay

maintainer
#7 lore raw

From: Dhananjay Phadke <[email protected]>
Date: Thu, 3 Sep 2009 20:14:01 -0700

Quoted 8 lines
Quoted 5 lines

Applied. But allocating such huge linear buffers is asking for guarenteed trouble. Can't you split them up into page sized chunks with this chip?

"chained" LRO is not enabled by firmware. Contiguous LRO requires fewer commands (internal) from firmware to DMA engines.

But if the page allocator can't satisfy allocation requests it doesn't matter how many microseconds you're saving here.

I think you're priorities are backwards.

#8 lore raw
Quoted 4 lines

But if the page allocator can't satisfy allocation requests it doesn't matter how many microseconds you're saving here.

I think you're priorities are backwards.

Ok whatever. Whether I request 9k or 12k, page allocator is digging 16k chunks.

When there's enough memory, every cycle saved is important for firmware. I would love to enable fragmented rx, if it's not affecting throughput.

-Dhananjay

maintainer
#9 lore raw

From: Dhananjay Phadke <[email protected]>
Date: Thu, 3 Sep 2009 20:24:15 -0700

Quoted 11 lines
Quoted 4 lines

But if the page allocator can't satisfy allocation requests it doesn't matter how many microseconds you're saving here.

I think you're priorities are backwards.

Ok whatever. Whether I request 9k or 12k, page allocator is digging 16k chunks.

When there's enough memory, every cycle saved is important for firmware. I would love to enable fragmented rx, if it's not affecting throughput.

Ok.

Just FYI I won't be surprised if SLAB/SLUB/SLQB at some point handle this situation differently.