Message ID | 20130320113024.00377b99@nehalam.linuxnetplumber.net |
---|---|
State | Changes Requested, archived |
Delegated to: | David Miller |
Headers | show |
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. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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); -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
--- 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;
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> -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html