* [PATCH] chelsio: add headroom in RX path
@ 2013-03-20 16:33 Eric Dumazet
2013-03-20 17:29 ` David Miller
2013-03-20 18:30 ` [PATCH] chelsio: use netdev_alloc_skb Stephen Hemminger
0 siblings, 2 replies; 7+ messages in thread
From: Eric Dumazet @ 2013-03-20 16:33 UTC (permalink / raw)
To: David Miller; +Cc: netdev
From: Eric Dumazet <edumazet@google.com>
Drivers should reserve some headroom in skb used in receive path,
to avoid future head reallocation.
One possible way to do that is to use dev_alloc_skb() instead
of alloc_skb(), so that NET_SKB_PAD bytes are reserved.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
drivers/net/ethernet/chelsio/cxgb/sge.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/chelsio/cxgb/sge.c b/drivers/net/ethernet/chelsio/cxgb/sge.c
index 4829769..89bef50 100644
--- a/drivers/net/ethernet/chelsio/cxgb/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb/sge.c
@@ -835,7 +835,7 @@ static void refill_free_list(struct sge *sge, struct freelQ *q)
struct sk_buff *skb;
dma_addr_t mapping;
- skb = alloc_skb(q->rx_buffer_size, GFP_ATOMIC);
+ skb = dev_alloc_skb(q->rx_buffer_size);
if (!skb)
break;
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] chelsio: add headroom in RX path
2013-03-20 16:33 [PATCH] chelsio: add headroom in RX path Eric Dumazet
@ 2013-03-20 17:29 ` David Miller
2013-03-20 18:30 ` [PATCH] chelsio: use netdev_alloc_skb Stephen Hemminger
1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2013-03-20 17:29 UTC (permalink / raw)
To: eric.dumazet; +Cc: netdev
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 20 Mar 2013 09:33:19 -0700
> From: Eric Dumazet <edumazet@google.com>
>
> Drivers should reserve some headroom in skb used in receive path,
> to avoid future head reallocation.
>
> One possible way to do that is to use dev_alloc_skb() instead
> of alloc_skb(), so that NET_SKB_PAD bytes are reserved.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Applied, thanks Eric.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] chelsio: use netdev_alloc_skb
2013-03-20 16:33 [PATCH] chelsio: add headroom in RX path Eric Dumazet
2013-03-20 17:29 ` David Miller
@ 2013-03-20 18:30 ` Stephen Hemminger
2013-03-20 18:42 ` Eric Dumazet
2013-03-20 18:44 ` [PATCH] chelsio: use netdev_alloc_skb Eric Dumazet
1 sibling, 2 replies; 7+ messages in thread
From: Stephen Hemminger @ 2013-03-20 18:30 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David Miller, netdev
This extends on Eric's patch. It uses netdev_alloc_skb which fixes a couple of
other issues.
* driver was never setting skb->dev on the received buffer
* copybreak allocation wasn't padding buffer
* copybreak assumed that ip alignment padding was always 2 (it is platform dependent)
Compile tested only, don't have this hardware.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
--- a/drivers/net/ethernet/chelsio/cxgb/sge.c 2013-03-20 11:13:47.950986878 -0700
+++ b/drivers/net/ethernet/chelsio/cxgb/sge.c 2013-03-20 11:24:26.942722757 -0700
@@ -835,7 +835,7 @@ static void refill_free_list(struct sge
struct sk_buff *skb;
dma_addr_t mapping;
- skb = dev_alloc_skb(q->rx_buffer_size);
+ skb = netdev_alloc_skb(sge->netdev, q->rx_buffer_size);
if (!skb)
break;
@@ -1039,18 +1039,18 @@ MODULE_PARM_DESC(copybreak, "Receive cop
* threshold and the packet is too big to copy, or (b) the packet should
* be copied but there is no memory for the copy.
*/
-static inline struct sk_buff *get_packet(struct pci_dev *pdev,
+static inline struct sk_buff *get_packet(struct net_device *netdev,
+ struct pci_dev *pdev,
struct freelQ *fl, unsigned int len)
{
struct sk_buff *skb;
const struct freelQ_ce *ce = &fl->centries[fl->cidx];
if (len < copybreak) {
- skb = alloc_skb(len + 2, GFP_ATOMIC);
+ skb = netdev_alloc_skb_ip_align(netdev, len + 2);
if (!skb)
goto use_orig_buf;
- skb_reserve(skb, 2); /* align IP header */
skb_put(skb, len);
pci_dma_sync_single_for_cpu(pdev,
dma_unmap_addr(ce, dma_addr),
@@ -1360,7 +1360,7 @@ static void sge_rx(struct sge *sge, stru
struct sge_port_stats *st;
struct net_device *dev;
- skb = get_packet(adapter->pdev, fl, len - sge->rx_pkt_pad);
+ skb = get_packet(sge->netdev, adapter->pdev, fl, len - sge->rx_pkt_pad);
if (unlikely(!skb)) {
sge->stats.rx_drops++;
return;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] chelsio: use netdev_alloc_skb
2013-03-20 18:30 ` [PATCH] chelsio: use netdev_alloc_skb Stephen Hemminger
@ 2013-03-20 18:42 ` Eric Dumazet
2013-03-20 19:02 ` [PATCH v2] chelsio: use netdev_alloc_skb_ip_align Stephen Hemminger
2013-03-20 18:44 ` [PATCH] chelsio: use netdev_alloc_skb Eric Dumazet
1 sibling, 1 reply; 7+ messages in thread
From: Eric Dumazet @ 2013-03-20 18:42 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev
On Wed, 2013-03-20 at 11:30 -0700, Stephen Hemminger wrote:
> This extends on Eric's patch. It uses netdev_alloc_skb which fixes a couple of
> other issues.
> * driver was never setting skb->dev on the received buffer
> * copybreak allocation wasn't padding buffer
> * copybreak assumed that ip alignment padding was always 2 (it is platform dependent)
>
> Compile tested only, don't have this hardware.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
>
>
> --- a/drivers/net/ethernet/chelsio/cxgb/sge.c 2013-03-20 11:13:47.950986878 -0700
> +++ b/drivers/net/ethernet/chelsio/cxgb/sge.c 2013-03-20 11:24:26.942722757 -0700
> @@ -835,7 +835,7 @@ static void refill_free_list(struct sge
> struct sk_buff *skb;
> dma_addr_t mapping;
>
> - skb = dev_alloc_skb(q->rx_buffer_size);
> + skb = netdev_alloc_skb(sge->netdev, q->rx_buffer_size);
> if (!skb)
> break;
Well, this (skb->dev = dev) is done in eth_type_trans()
Many drivers use dev_alloc_skb(), I am not sure we really want to change
them.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] chelsio: use netdev_alloc_skb
2013-03-20 18:30 ` [PATCH] chelsio: use netdev_alloc_skb Stephen Hemminger
2013-03-20 18:42 ` Eric Dumazet
@ 2013-03-20 18:44 ` Eric Dumazet
1 sibling, 0 replies; 7+ messages in thread
From: Eric Dumazet @ 2013-03-20 18:44 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev
On Wed, 2013-03-20 at 11:30 -0700, Stephen Hemminger wrote:
> - skb = alloc_skb(len + 2, GFP_ATOMIC);
> + skb = netdev_alloc_skb_ip_align(netdev, len + 2);
> if (!skb)
> goto use_orig_buf;
>
If you use the helper, no need for 'len + 2' but :
netdev_alloc_skb_ip_align(netdev, len);
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] chelsio: use netdev_alloc_skb_ip_align
2013-03-20 18:42 ` Eric Dumazet
@ 2013-03-20 19:02 ` Stephen Hemminger
2013-03-20 19:25 ` David Miller
0 siblings, 1 reply; 7+ messages in thread
From: Stephen Hemminger @ 2013-03-20 19:02 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David Miller, netdev
Use netdev_alloc_sk_ip_align in the case where packet is copied.
This handles case where NET_IP_ALIGN == 0 as well as adding required header
padding.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
--- a/drivers/net/ethernet/chelsio/cxgb/sge.c 2013-03-20 11:13:47.950986878 -0700
+++ b/drivers/net/ethernet/chelsio/cxgb/sge.c 2013-03-20 12:00:01.551115729 -0700
@@ -1046,11 +1046,10 @@ static inline struct sk_buff *get_packet
const struct freelQ_ce *ce = &fl->centries[fl->cidx];
if (len < copybreak) {
- skb = alloc_skb(len + 2, GFP_ATOMIC);
+ skb = netdev_alloc_skb_ip_align(NULL, len);
if (!skb)
goto use_orig_buf;
- skb_reserve(skb, 2); /* align IP header */
skb_put(skb, len);
pci_dma_sync_single_for_cpu(pdev,
dma_unmap_addr(ce, dma_addr),
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] chelsio: use netdev_alloc_skb_ip_align
2013-03-20 19:02 ` [PATCH v2] chelsio: use netdev_alloc_skb_ip_align Stephen Hemminger
@ 2013-03-20 19:25 ` David Miller
0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2013-03-20 19:25 UTC (permalink / raw)
To: stephen; +Cc: eric.dumazet, netdev
From: Stephen Hemminger <stephen@networkplumber.org>
Date: Wed, 20 Mar 2013 12:02:41 -0700
> Use netdev_alloc_sk_ip_align in the case where packet is copied.
> This handles case where NET_IP_ALIGN == 0 as well as adding required header
> padding.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Applied, thanks Stephen.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-03-20 19:25 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-20 16:33 [PATCH] chelsio: add headroom in RX path Eric Dumazet
2013-03-20 17:29 ` David Miller
2013-03-20 18:30 ` [PATCH] chelsio: use netdev_alloc_skb Stephen Hemminger
2013-03-20 18:42 ` Eric Dumazet
2013-03-20 19:02 ` [PATCH v2] chelsio: use netdev_alloc_skb_ip_align Stephen Hemminger
2013-03-20 19:25 ` David Miller
2013-03-20 18:44 ` [PATCH] chelsio: use netdev_alloc_skb Eric Dumazet
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.