Network driver changes for 2.6.26
Subsystems (2)
cover Network driver changes for 2.6.26
Pile of random small changes mostly janitorial cleanups related to netdev_alloc_skb. Please don't just apply these without ack since in most cases they are compile tested only.
PATCH 4/13 via-velocity: use netdev_alloc_skb
Use netdev_alloc_skb for rx buffer allocation. This sets skb->dev and can be overriden for NUMA machines.
Change code to return new buffer rather than call by reference.
Compile tested only!
drivers/net/via-velocity.c +6 -13
@@ -1490,24 +1490,18 @@ static inline void velocity_rx_csum(stru* enough. This function returns a negative value if the received * packet is too big or if memory is exhausted. */ -static inline int velocity_rx_copy (struct sk_buff **rx_skb,int pkt_size, -struct velocity_info *vptr) +static int velocity_rx_copy (struct sk_buff **rx_skb,int pkt_size, +struct velocity_info *vptr) {int ret =-1 ; -if (pkt_size < rx_copybreak) {struct sk_buff *new_skb; - new_skb =dev_alloc_skb (pkt_size +2 ); + new_skb =netdev_alloc_skb (vptr->dev, pkt_size +2 );if (new_skb) { - new_skb->dev = vptr->dev; new_skb->ip_summed = rx_skb[0 ]->ip_summed; - -if (vptr->flags &VELOCITY_FLAGS_IP_ALIGN ) -skb_reserve (new_skb,2 ); - -skb_copy_from_linear_data (rx_skb[0 ], new_skb->data, - pkt_size); +skb_reserve (new_skb,2 ); +skb_copy_from_linear_data (*rx_skb, new_skb->data, pkt_size); *rx_skb = new_skb; ret =0 ; }
@@ -1619,7 +1613,7 @@ static int velocity_alloc_rx_buf(structstruct rx_desc *rd = &(vptr->rd_ring[idx]);struct velocity_rd_info *rd_info = &(vptr->rd_info[idx]); - rd_info->skb =dev_alloc_skb (vptr->rx_buf_sz +64 ); + rd_info->skb =netdev_alloc_skb (vptr->dev, vptr->rx_buf_sz +64 );if (rd_info->skb ==NULL )return -ENOMEM ;
@@ -1628,7 +1622,6 @@ static int velocity_alloc_rx_buf(struct* 64byte alignment. */ skb_reserve (rd_info->skb, (unsigned long ) rd_info->skb->data &63 ); - rd_info->skb->dev = vptr->dev; rd_info->skb_dma =pci_map_single (vptr->pdev, rd_info->skb->data, vptr->rx_buf_sz,PCI_DMA_FROMDEVICE );/*
PATCH 5/13 via-velocity: use memmove
In reply to Stephen HemmingerUse memmove to handle overlapping copy of data.
Compile tested only.
drivers/net/via-velocity.c +1 -5
@@ -1522,12 +1522,8 @@ static int velocity_rx_copy(struct sk_bustatic inline void velocity_iph_realign (struct velocity_info *vptr,struct sk_buff *skb,int pkt_size) { -/* FIXME - memmove ? */ if (vptr->flags &VELOCITY_FLAGS_IP_ALIGN ) { -int i; - -for (i = pkt_size; i >=0 ; i--) - *(skb->data + i +2 ) = *(skb->data + i); +memmove (skb->data +2 , skb->data, pkt_size);skb_reserve (skb,2 ); } }
PATCH 6/13 sis190: use netdev_alloc_skb
In reply to Stephen HemmingerUse netdev_alloc_skb. This sets skb->dev and allows arch specific allocation.
Compile tested only.
drivers/net/sis190.c +18 -18
@@ -480,30 +480,28 @@ static inline void sis190_make_unusable_ desc->status =0x0 ; } -static int sis190_alloc_rx_skb (struct pci_dev *pdev,struct sk_buff **sk_buff, -struct RxDesc *desc,u32 rx_buf_sz) +static struct sk_buff *sis190_alloc_rx_skb (struct pci_dev *pdev, +struct net_device *dev, +struct RxDesc *desc,u32 rx_buf_sz) {struct sk_buff *skb;dma_addr_t mapping;int ret =0 ; - skb =dev_alloc_skb (rx_buf_sz); + skb =netdev_alloc_skb (dev, rx_buf_sz);if (!skb) goto err_out; - *sk_buff = skb; - mapping =pci_map_single (pdev, skb->data, rx_buf_sz,PCI_DMA_FROMDEVICE );sis190_map_to_asic (desc, mapping, rx_buf_sz); -out: -return ret; +return skb; err_out: ret = -ENOMEM ;sis190_make_unusable_by_asic (desc); - goto out; +return NULL ; } static u32 sis190_rx_fill(struct sis190_private *tp, struct net_device *dev,
@@ -512,30 +510,32 @@ static u32 sis190_rx_fill(struct sis190_u32 cur;for (cur = start; cur < end; cur++) { -int ret, i = cur %NUM_RX_DESC ; +int i = cur %NUM_RX_DESC ;if (tp->Rx_skbuff[i])continue ; - ret =sis190_alloc_rx_skb (tp->pci_dev, tp->Rx_skbuff + i, - tp->RxDescRing + i, tp->rx_buf_sz); -if (ret <0 ) + tp->Rx_skbuff[i] =sis190_alloc_rx_skb (tp->pci_dev, dev, + tp->RxDescRing + i, + tp->rx_buf_sz); +if (!tp->Rx_skbuff[i])break ; }return cur - start; } -static inline int sis190_try_rx_copy (struct sk_buff **sk_buff,int pkt_size, -struct RxDesc *desc,int rx_buf_sz) +static int sis190_try_rx_copy (struct net_device *dev, +struct sk_buff **sk_buff,int pkt_size, +struct RxDesc *desc,int rx_buf_sz) { -int ret =-1 ; +int ret =01 ;if (pkt_size < rx_copybreak) {struct sk_buff *skb; - skb =dev_alloc_skb (pkt_size +NET_IP_ALIGN ); + skb =netdev_alloc_skb (dev, pkt_size +2 );if (skb) { -skb_reserve (skb,NET_IP_ALIGN ); +skb_reserve (skb,2 );skb_copy_to_linear_data (skb, sk_buff[0 ]->data, pkt_size); *sk_buff = skb;sis190_give_to_asic (desc, rx_buf_sz);
@@ -610,7 +610,7 @@ static int sis190_rx_interrupt(struct nele32_to_cpu (desc->addr), tp->rx_buf_sz, PCI_DMA_FROMDEVICE); -if (sis190_try_rx_copy (&skb, pkt_size, desc, +if (sis190_try_rx_copy (dev, &skb, pkt_size, desc, tp->rx_buf_sz)) { pci_action = pci_unmap_single; tp->Rx_skbuff[entry] =NULL ;
Re: [PATCH 06/13] sis190: use netdev_alloc_skb
Stephen Hemminger said the following on 2008-4-17 7:37:
Quoted 13 lines
Use
netdev_alloc_skb. This setsskb->devand allows arch specific allocation.Compile tested only.
Signed-off-by Stephen Hemminger <[email protected]>drivers/net/sis190.c +0
-0@@ -480,30 +480,28 @@ static inline void sis190_make_unusable_ desc->status =0x0 ; }
drivers/net/sis190.c static inline void sis190_make_unusable_ · line 490
Quoted 10 lines
drivers/net/sis190.c +3
-2-static int sis190_alloc_rx_skb (struct pci_dev *pdev,struct sk_buff **sk_buff, -struct RxDesc *desc,u32 rx_buf_sz) +static struct sk_buff *sis190_alloc_rx_skb (struct pci_dev *pdev, +struct net_device *dev, +struct RxDesc *desc,u32 rx_buf_sz) {struct sk_buff *skb;dma_addr_t mapping;int ret =0 ;
ret no longer be used.
Quoted 7 lines
drivers/net/sis190.c +1
-3- skb =dev_alloc_skb (rx_buf_sz); + skb =netdev_alloc_skb (dev, rx_buf_sz);if (!skb) goto err_out; - *sk_buff = skb; -
drivers/net/sis190.c static inline void sis190_make_unusable_ · line 502
Quoted 10 lines
drivers/net/sis190.c +1
-2mapping =pci_map_single (pdev, skb->data, rx_buf_sz,PCI_DMA_FROMDEVICE );sis190_map_to_asic (desc, mapping, rx_buf_sz); -out: -return ret; +return skb; err_out: ret = -ENOMEM ;
ret no longer be used.
Quoted 58 lines
drivers/net/sis190.c +13
-11sis190_make_unusable_by_asic (desc); - goto out; +return NULL ; } static u32 sis190_rx_fill(struct sis190_private *tp, struct net_device *dev,@@ -512,30 +510,32 @@ static u32 sis190_rx_fill(struct sis190_u32 cur;for (cur = start; cur < end; cur++) { -int ret, i = cur %NUM_RX_DESC ; +int i = cur %NUM_RX_DESC ;if (tp->Rx_skbuff[i])continue ; - ret =sis190_alloc_rx_skb (tp->pci_dev, tp->Rx_skbuff + i, - tp->RxDescRing + i, tp->rx_buf_sz); -if (ret <0 ) + tp->Rx_skbuff[i] =sis190_alloc_rx_skb (tp->pci_dev, dev, + tp->RxDescRing + i, + tp->rx_buf_sz); +if (!tp->Rx_skbuff[i])break ; }return cur - start; } -static inline int sis190_try_rx_copy (struct sk_buff **sk_buff,int pkt_size, -struct RxDesc *desc,int rx_buf_sz) +static int sis190_try_rx_copy (struct net_device *dev, +struct sk_buff **sk_buff,int pkt_size, +struct RxDesc *desc,int rx_buf_sz) { -int ret =-1 ; +int ret =01 ;if (pkt_size < rx_copybreak) {struct sk_buff *skb; - skb =dev_alloc_skb (pkt_size +NET_IP_ALIGN ); + skb =netdev_alloc_skb (dev, pkt_size +2 );if (skb) { -skb_reserve (skb,NET_IP_ALIGN ); +skb_reserve (skb,2 );skb_copy_to_linear_data (skb, sk_buff[0 ]->data, pkt_size); *sk_buff = skb;sis190_give_to_asic (desc, rx_buf_sz);@@ -610,7 +610,7 @@ static int sis190_rx_interrupt(struct nele32_to_cpu (desc->addr), tp->rx_buf_sz, PCI_DMA_FROMDEVICE); -if (sis190_try_rx_copy (&skb, pkt_size, desc, +if (sis190_try_rx_copy (dev, &skb, pkt_size, desc, tp->rx_buf_sz)) { pci_action = pci_unmap_single; tp->Rx_skbuff[entry] =NULL ;
Re: [PATCH 06/13] sis190: use netdev_alloc_skb
In reply to Stephen HemmingerStephen Hemminger said the following on 2008-4-17 7:37:
drivers/net/sis190.c static u32 sis190_rx_fill(struct sis190_ · line 531
Quoted 7 lines
drivers/net/sis190.c +4
-1+static int sis190_try_rx_copy (struct net_device *dev, +struct sk_buff **sk_buff,int pkt_size, +struct RxDesc *desc,int rx_buf_sz) { -int ret =-1 ; +int ret =01 ;
why not : ret = 1
drivers/net/sis190.c static u32 sis190_rx_fill(struct sis190_ · line 538
Quoted 8 lines
drivers/net/sis190.c +2
-2if (pkt_size < rx_copybreak) {struct sk_buff *skb; - skb =dev_alloc_skb (pkt_size +NET_IP_ALIGN ); + skb =netdev_alloc_skb (dev, pkt_size +2 );if (skb) { -skb_reserve (skb,NET_IP_ALIGN ); +skb_reserve (skb,2 );
why?
[PATCH 02/13] atl1: use netdev_alloc_skb
using NET_IP_ALIGN, not 2.
Re: [PATCH 06/13] sis190: use netdev_alloc_skb
Quoted 8 lines · On Thu, 17 Apr 2008 10:16:26 +0800 Wang Chen <[email protected]> wrote:
Stephen Hemminger said the following on 2008-4-17 7:37:
drivers/net/sis190.c static u32 sis190_rx_fill(struct sis190_ · line 531
Quoted 7 lines
drivers/net/sis190.c +4
-1+static int sis190_try_rx_copy (struct net_device *dev, +struct sk_buff **sk_buff,int pkt_size, +struct RxDesc *desc,int rx_buf_sz) { -int ret =-1 ; +int ret =01 ;
Sorry, that was a typo. meant to leave original -1
Quoted 5 lines
why not : ret = 1
Quoted 3 lines
drivers/net/sis190.c +0
-0if (pkt_size < rx_copybreak) {struct sk_buff *skb;
Quoted 9 lines
drivers/net/sis190.c static u32 sis190_rx_fill(struct sis190_ · line 538
Quoted 5 lines
drivers/net/sis190.c +2
-2- skb =dev_alloc_skb (pkt_size +NET_IP_ALIGN ); + skb =netdev_alloc_skb (dev, pkt_size +2 );if (skb) { -skb_reserve (skb,NET_IP_ALIGN ); +skb_reserve (skb,2 );why?
[PATCH 02/13] atl1: usenetdev_alloc_skb
usingNET_IP_ALIGN, not 2.
NET_IP_ALIGN is defined as 0 on some platforms where cost of unaligned DMA is greater than the cost of unaligned access. But in this case, the driver is copying into the buffer, so the cost of unaligned DMA is not involved so just align the data.
Re: [PATCH 06/13] sis190: use netdev_alloc_skb
In reply to Stephen HemmingerStephen Hemminger <[email protected]> :
Quoted 4 lines
Use
netdev_alloc_skb. This setsskb->devand allows arch specific allocation.Compile tested only.
[...]
drivers/net/sis190.c static inline void sis190_make_unusable_ · line 489
Quoted 9 lines
drivers/net/sis190.c +3
-2-static int sis190_alloc_rx_skb (struct pci_dev *pdev,struct sk_buff **sk_buff, -struct RxDesc *desc,u32 rx_buf_sz) +static struct sk_buff *sis190_alloc_rx_skb (struct pci_dev *pdev, +struct net_device *dev, +struct RxDesc *desc,u32 rx_buf_sz) {struct sk_buff *skb;dma_addr_t mapping;int ret =0 ;
'ret' is now an unused variable.
Quoted 22 lines
drivers/net/sis190.c +3
-6- skb =dev_alloc_skb (rx_buf_sz); + skb =netdev_alloc_skb (dev, rx_buf_sz);if (!skb) goto err_out; - *sk_buff = skb; - mapping =pci_map_single (pdev, skb->data, rx_buf_sz,PCI_DMA_FROMDEVICE );sis190_map_to_asic (desc, mapping, rx_buf_sz); -out: -return ret; +return skb; err_out: ret = -ENOMEM ;sis190_make_unusable_by_asic (desc); - goto out; +return NULL ; }
Signature · 1 line
Ueimor
PATCH 7/13 sb1250: use netdev_alloc_skb
In reply to Stephen HemmingerUse netdev_alloc_skb. This sets skb->dev and allows arch specific allocation. Also simplify and cleanup the alignment code.
Not tested, depends on non-x86 hardware
drivers/net/sb1250-mac.c +8 -11
@@ -179,7 +179,6 @@ enum sbmac_state {#define SBMAC_MAX_TXDESCR 256#define SBMAC_MAX_RXDESCR 256 -#define ETHER_ALIGN 2#define ETHER_ADDR_LEN 6#define ENET_PACKET_SIZE 1518/*#define ENET_PACKET_SIZE 9216 */
@@ -777,16 +776,13 @@ static void sbdma_channel_stop(struct sb d->sbdma_remptr =NULL ; } -static void sbdma_align_skb (struct sk_buff *skb,int power2,int offset) +static inline void sbdma_align_skb (struct sk_buff *skb, +unsigned power2,unsigned offset) { -unsigned long addr; -unsigned long newaddr; +unsigned long addr = skb->data; +unsigned long newaddr =PTR_ALIGN (addr, power2); - addr = (unsigned long ) skb->data; - - newaddr = (addr + power2 -1 ) & ~(power2 -1 ); - -skb_reserve (skb,newaddr-addr+offset); +skb_reserve (skb, newaddr - addr + offset); }
@@ -848,14 +844,15 @@ static int sbdma_add_rcvbuffer(struct sb*/ if (sb ==NULL ) { - sb_new =dev_alloc_skb (ENET_PACKET_SIZE +SMP_CACHE_BYTES *2 +ETHER_ALIGN ); + sb_new =netdev_alloc_skb (dev,ENET_PACKET_SIZE +SMP_CACHE_BYTES *2 + +NET_IP_ALIGN );if (sb_new ==NULL ) {pr_info ("%s: sk_buff allocation failed\n" , d->sbdma_eth->sbm_dev->name);return -ENOBUFS ; } -sbdma_align_skb (sb_new,SMP_CACHE_BYTES ,ETHER_ALIGN ); +sbdma_align_skb (sb_new,SMP_CACHE_BYTES ,NET_IP_ALIGN ); }else { sb_new = sb;
Re: [PATCH 07/13] sb1250: use netdev_alloc_skb
Use netdev_alloc_skb. This sets skb->dev and allows arch specific
allocation. Also simplify and cleanup the alignment code.
---
Quoted 3 lines · Stephen Hemminger
Not tested, depends on non-x86 hardware
Signed-off-by Stephen Hemminger <[email protected]>
Thanks for your work. Here is a version that not only builds, but also
boots to multi-user, NFS-rooted. Unfortunately this is about as much as I can test it now -- the platform is currently unstable because of some problem with code to support the CPU and the network interface is quite closely coupled to the former ;-) and cannot be tested separately.
Maciej
patch-mips-2.6.25-20080422-shemminger-sb1250-mac-align-1
drivers/net/sb1250-mac.c +31 -36
@@ -179,8 +179,7 @@ enum sbmac_state {#define SBMAC_MAX_TXDESCR 256#define SBMAC_MAX_RXDESCR 256 -#define ETHER_ALIGN 2 -#define ETHER_ADDR_LEN 6 +#define ETHER_ADDR_LEN 6#define ENET_PACKET_SIZE 1518/*#define ENET_PACKET_SIZE 9216 */
@@ -262,8 +261,6 @@ struct sbmac_softc {spinlock_t sbm_lock;/* spin lock */ int sbm_devflags;/* current device flags */ -int sbm_buffersize; -/* * Controller-specific things */
@@ -305,10 +302,11 @@ struct sbmac_softc {static void sbdma_initctx (struct sbmacdma *d,struct sbmac_softc *s,int chan,int txrx,int maxdescr);static void sbdma_channel_start (struct sbmacdma *d,int rxtx); -static int sbdma_add_rcvbuffer (struct sbmacdma *d,struct sk_buff *m); +static int sbdma_add_rcvbuffer (struct sbmac_softc *sc,struct sbmacdma *d, +struct sk_buff *m);static int sbdma_add_txbuffer (struct sbmacdma *d,struct sk_buff *m);static void sbdma_emptyring (struct sbmacdma *d); -static void sbdma_fillring (struct sbmacdma *d); +static void sbdma_fillring (struct sbmac_softc *sc,struct sbmacdma *d);static int sbdma_rx_process (struct sbmac_softc *sc,struct sbmacdma *d,int work_to_do,int poll); static void sbdma_tx_process(struct sbmac_softc *sc, struct sbmacdma *d,
@@ -777,16 +775,13 @@ static void sbdma_channel_stop(struct sb d->sbdma_remptr =NULL ; } -static void sbdma_align_skb (struct sk_buff *skb,int power2,int offset) +static inline void sbdma_align_skb (struct sk_buff *skb, +unsigned int power2,unsigned int offset) { -unsigned long addr; -unsigned long newaddr; - - addr = (unsigned long ) skb->data; - - newaddr = (addr + power2 -1 ) & ~(power2 -1 ); +unsigned char *addr = skb->data; +unsigned char *newaddr =PTR_ALIGN (addr, power2); -skb_reserve (skb,newaddr-addr+offset); +skb_reserve (skb, newaddr - addr + offset); }
@@ -797,7 +792,8 @@ static void sbdma_align_skb(struct sk_bu* this queues a buffer for inbound packets. * * Input parameters: -* d - DMA channel descriptor +* sc - softc structure +* d - DMA channel descriptor * sb - sk_buff to add, or NULL if we should allocate one * * Return value:
@@ -806,8 +802,10 @@ static void sbdma_align_skb(struct sk_bu********************************************************************* */ -static int sbdma_add_rcvbuffer (struct sbmacdma *d,struct sk_buff *sb) +static int sbdma_add_rcvbuffer (struct sbmac_softc *sc,struct sbmacdma *d, +struct sk_buff *sb) { +struct net_device *dev = sc->sbm_dev;struct sbdmadscr *dsc;struct sbdmadscr *nextdsc;struct sk_buff *sb_new =NULL ;
@@ -848,14 +846,16 @@ static int sbdma_add_rcvbuffer(struct sb*/ if (sb ==NULL ) { - sb_new =dev_alloc_skb (ENET_PACKET_SIZE +SMP_CACHE_BYTES *2 +ETHER_ALIGN ); + sb_new =netdev_alloc_skb (dev,ENET_PACKET_SIZE + +SMP_CACHE_BYTES *2 + +NET_IP_ALIGN );if (sb_new ==NULL ) {pr_info ("%s: sk_buff allocation failed\n" , d->sbdma_eth->sbm_dev->name);return -ENOBUFS ; } -sbdma_align_skb (sb_new,SMP_CACHE_BYTES ,ETHER_ALIGN ); +sbdma_align_skb (sb_new,SMP_CACHE_BYTES ,NET_IP_ALIGN ); }else { sb_new = sb;
@@ -874,10 +874,10 @@ static int sbdma_add_rcvbuffer(struct sb* Do not interrupt per DMA transfer. */ dsc->dscr_a =virt_to_phys (sb_new->data) | -V_DMA_DSCRA_A_SIZE (NUMCACHEBLKS (pktsize+ETHER_ALIGN )) |0 ; +V_DMA_DSCRA_A_SIZE (NUMCACHEBLKS (pktsize +NET_IP_ALIGN )) |0 ;#else dsc->dscr_a =virt_to_phys (sb_new->data) | -V_DMA_DSCRA_A_SIZE (NUMCACHEBLKS (pktsize+ETHER_ALIGN )) | +V_DMA_DSCRA_A_SIZE (NUMCACHEBLKS (pktsize +NET_IP_ALIGN )) |M_DMA_DSCRA_INTERRUPT ;#endif
@@ -1032,18 +1032,19 @@ static void sbdma_emptyring(struct sbmac* with sk_buffs * * Input parameters: -* d - DMA channel +* sc - softc structure +* d - DMA channel * * Return value: * nothing ********************************************************************* */ -static void sbdma_fillring (struct sbmacdma *d) +static void sbdma_fillring (struct sbmac_softc *sc,struct sbmacdma *d) {int idx; -for (idx =0 ; idx <SBMAC_MAX_RXDESCR -1 ; idx++) { -if (sbdma_add_rcvbuffer (d,NULL ) !=0 ) +for (idx =0 ; idx <SBMAC_MAX_RXDESCR -1 ; idx++) { +if (sbdma_add_rcvbuffer (sc, d,NULL ) !=0 )break ; } }
@@ -1159,10 +1160,11 @@ again:* packet and put it right back on the receive ring. */ -if (unlikely (sbdma_add_rcvbuffer (d,NULL ) == - -ENOBUFS )) { +if (unlikely (sbdma_add_rcvbuffer (sc, d,NULL ) == + -ENOBUFS )) { dev->stats.rx_dropped++; -sbdma_add_rcvbuffer (d,sb);/* re-add old buffer */ +/* Re-add old buffer */ +sbdma_add_rcvbuffer (sc, d, sb);/* No point in continuing at the moment */ printk (KERN_ERR "dropped packet (1)\n" ); d->sbdma_remptr =SBDMA_NEXTBUF (d,sbdma_remptr);
@@ -1212,7 +1214,7 @@ again:* put it back on the receive ring. */ dev->stats.rx_errors++; -sbdma_add_rcvbuffer (d,sb); +sbdma_add_rcvbuffer (sc, d, sb); }
@@ -1570,7 +1572,7 @@ static void sbmac_channel_start(struct s* Fill the receive ring */ -sbdma_fillring (&(s->sbm_rxdma)); +sbdma_fillring (s, &(s->sbm_rxdma));/* * Turn on the rest of the bits in the enable register
@@ -2312,13 +2314,6 @@ static int sbmac_init(struct platform_de dev->dev_addr[i] = eaddr[i]; } - -/* -* Init packet size -*/ - - sc->sbm_buffersize =ENET_PACKET_SIZE +SMP_CACHE_BYTES *2 +ETHER_ALIGN ; -/* * Initialize context (get pointers to registers and stuff), then * allocate the memory for the descriptor tables.
PATCH 8/13 ns8320: use netdev_alloc_skb
In reply to Stephen HemmingerUse netdev_alloc_skb. This sets skb->dev and allows arch specific allocation.
Compile tested only.
drivers/net/ns83820.c +3 -6
@@ -585,16 +585,13 @@ static inline int rx_refill(struct net_dfor (i=0 ; i<NR_RX_DESC ; i++) {struct sk_buff *skb;long res; +/* extra 16 bytes for alignment */ - skb =__dev_alloc_skb (REAL_RX_BUF_SIZE +16 , gfp); + skb =__netdev_alloc_skb (ndev,REAL_RX_BUF_SIZE +16 , gfp);if (unlikely (!skb))break ; - res = (long )skb->data &0xf ; - res =0x10 - res; - res &=0xf ; -skb_reserve (skb, res); - +skb_reserve (skb, skb->data -PTR_ALIGN (skb->data,16 ));if (gfp !=GFP_ATOMIC )spin_lock_irqsave (&dev->rx_info.lock, flags); res =ns83820_add_rx_skb (dev, skb);
Jeff Garzik
AppliedRe: [PATCH 08/13] ns8320: use netdev_alloc_skb
Quoted 6 lines · Stephen Hemminger
Use
netdev_alloc_skb. This setsskb->devand allows arch specific allocation.Compile tested only.
Signed-off-by Stephen Hemminger <[email protected]>
applied
PATCH 9/13 myri: use netdev_alloc_skb
In reply to Stephen HemmingerUse netdev_alloc_skb. This sets skb->dev and allows arch specific allocation.
Copmpile tested only
drivers/net/myri_sbus.c +18 -4
@@ -266,6 +266,22 @@ static void myri_clean_rings(struct myri } } + +/* We use this to acquire receive skb's that we can DMA directly into. */ +#define RX_SKB_PAD (addr) (PTR_ALIGN(addr, 64) - (unsigned long)(addr)) + +static struct sk_buff *myri_alloc_skb (struct net_device *dev, +unsigned int length,gfp_t gfp_flags) +{ +struct sk_buff *skb; + + skb =__netdev_alloc_skb (dev, length +64 , gfp_flags); +if (likely (skb)) { +skb_reserve (skb,RX_SKB_PAD (skb->data)); + } +return skb; +} +static void myri_init_rings (struct myri_eth *mp,int from_irq) {struct recvq __iomem *rq = mp->rq;
@@ -285,7 +301,6 @@ static void myri_init_rings(struct myri_if (!skb)continue ; mp->rx_skbs[i] = skb; - skb->dev = dev;skb_put (skb,RX_ALLOC_SIZE ); dma_addr =sbus_map_single (mp->myri_sdev, skb->data,RX_ALLOC_SIZE ,SBUS_DMA_FROMDEVICE );
@@ -469,7 +484,6 @@ static void myri_rx(struct myri_eth *mp,RX_ALLOC_SIZE , SBUS_DMA_FROMDEVICE); mp->rx_skbs[index] = new_skb; - new_skb->dev = dev;skb_put (new_skb,RX_ALLOC_SIZE ); dma_addr = sbus_map_single(mp->myri_sdev, new_skb->data,
@@ -485,7 +499,7 @@ static void myri_rx(struct myri_eth *mp,DRX (("trim(%d) " , len));skb_trim (skb, len); }else { -struct sk_buff *copy_skb =dev_alloc_skb (len); +struct sk_buff *copy_skb =netdev_alloc_skb (dev, len +2 );DRX (("SMALLBUFF " ));if (copy_skb ==NULL ) {
@@ -493,7 +507,7 @@ static void myri_rx(struct myri_eth *mp, goto drop_it; }/* DMA sync already done above. */ - copy_skb->dev = dev; +skb_reserve (copy_skb,2 );DRX (("resv_and_put " ));skb_put (copy_skb, len);skb_copy_from_linear_data (skb, copy_skb->data, len);
drivers/net/myri_sbus.h +0 -17
@@ -291,21 +291,4 @@ struct myri_eth { struct sbus_dev *myri_sdev; /* Our SBUS device struct. */ }; -/* We use this to acquire receive skb's that we can DMA directly into. */ -#define ALIGNED_RX_SKB_ADDR (addr) \ - ((((unsigned long)(addr) + (64 - 1)) & ~(64 - 1)) - (unsigned long)(addr)) -static inline struct sk_buff *myri_alloc_skb (unsigned int length,gfp_t gfp_flags) -{ -struct sk_buff *skb; - - skb =alloc_skb (length +64 , gfp_flags); -if (skb) { -int offset =ALIGNED_RX_SKB_ADDR (skb->data); - -if (offset) -skb_reserve (skb, offset); - } -return skb; -} -#endif /* !(_MYRI_SBUS_H) */
PATCH 10/13 ixp2000: use netdev_alloc_skb
In reply to Stephen HemmingerUse netdev_alloc_skb. This sets skb->dev and allows arch specific allocation.
drivers/net/ixp2000/ixpdev.c +2 -2
@@ -108,14 +108,14 @@ static int ixpdev_rx(struct net_device *if (unlikely (!netif_running (nds[desc->channel]))) goto err; - skb =dev_alloc_skb (desc->pkt_length +2 ); + skb =netdev_alloc_skb (dev, desc->pkt_length +2 );if (likely (skb !=NULL )) {skb_reserve (skb,2 );skb_copy_to_linear_data (skb, buf, desc->pkt_length);skb_put (skb, desc->pkt_length); skb->protocol =eth_type_trans (skb, nds[desc->channel]); - skb->dev->last_rx = jiffies; + dev->last_rx = jiffies;netif_receive_skb (skb); }
Re: [PATCH 10/13] ixp2000: use netdev_alloc_skb
Quoted 4 lines · Stephen Hemminger
Use
netdev_alloc_skb. This setsskb->devand allows arch specific allocation.Signed-off-by Stephen Hemminger <[email protected]>
No objections, I guess..
Quoted 21 lines
drivers/net/ixp2000/ixpdev.c +2
-2@@ -108,14 +108,14 @@ static int ixpdev_rx(struct net_device *if (unlikely (!netif_running (nds[desc->channel]))) goto err; - skb =dev_alloc_skb (desc->pkt_length +2 ); + skb =netdev_alloc_skb (dev, desc->pkt_length +2 );if (likely (skb !=NULL )) {skb_reserve (skb,2 );skb_copy_to_linear_data (skb, buf, desc->pkt_length);skb_put (skb, desc->pkt_length); skb->protocol =eth_type_trans (skb, nds[desc->channel]); - skb->dev->last_rx = jiffies; + dev->last_rx = jiffies;netif_receive_skb (skb); }Signature · 1 line
--
PATCH 11/13 hamachi: use netdev_alloc_skb
In reply to Stephen HemmingerUse netdev_alloc_skb. This sets skb->dev and allows arch specific allocation.
Remove dead code and dead comments.
drivers/net/hamachi.c +2 -10
@@ -1140,11 +1140,11 @@ static void hamachi_tx_timeout(struct ne }/* Fill in the Rx buffers. Handle allocation failure gracefully. */ for (i =0 ; i <RX_RING_SIZE ; i++) { -struct sk_buff *skb =dev_alloc_skb (hmp->rx_buf_sz); +struct sk_buff *skb =netdev_alloc_skb (dev, hmp->rx_buf_sz); hmp->rx_skbuff[i] = skb;if (skb ==NULL )break ; - skb->dev = dev;/* Mark as being used by this device. */ +skb_reserve (skb,2 );/* 16 byte align the IP header. */ hmp->rx_ring[i].addr =cpu_to_leXX (pci_map_single (hmp->pci_dev, skb->data, hmp->rx_buf_sz,PCI_DMA_FROMDEVICE ));
@@ -1178,14 +1178,6 @@ static void hamachi_init_ring(struct net hmp->cur_rx = hmp->cur_tx =0 ; hmp->dirty_rx = hmp->dirty_tx =0 ; -#if 0 -/* This is wrong. I'm not sure what the original plan was, but this -* is wrong. An MTU of 1 gets you a buffer of 1536, while an MTU -* of 1501 gets a buffer of 1533? -KDU -*/ - hmp->rx_buf_sz = (dev->mtu <=1500 ?PKT_BUF_SZ : dev->mtu +32 ); -#endif -/* My attempt at a reasonable correction */ /* +26 gets the maximum ethernet encapsulation, +7 & ~7 because the * card needs room to do 8 byte alignment, +2 so we can reserve * the first 2 bytes, and +16 gets room for the status word from the
PATCH 12/13 dl2k: use netdev_alloc_skb
In reply to Stephen HemmingerUse netdev_alloc_skb. This sets skb->dev and allows arch specific allocation.
Compile tested only.
drivers/net/dl2k.c +4 -4
@@ -499,7 +499,7 @@ rio_timer (unsigned long data) entry = np->old_rx %RX_RING_SIZE ;/* Dropped packets don't need to re-allocate */ if (np->rx_skbuff[entry] ==NULL ) { - skb =dev_alloc_skb (np->rx_buf_sz); + skb =netdev_alloc_skb (dev, np->rx_buf_sz);if (skb ==NULL ) { np->rx_ring[entry].fraginfo =0 ; printk (KERN_INFO
@@ -570,7 +570,7 @@ alloc_list (struct net_device *dev)/* Allocate the rx buffers */ for (i =0 ; i <RX_RING_SIZE ; i++) {/* Allocated fixed size of skbuff */ -struct sk_buff *skb =dev_alloc_skb (np->rx_buf_sz); +struct sk_buff *skb =netdev_alloc_skb (dev, np->rx_buf_sz); np->rx_skbuff[i] = skb;if (skb ==NULL ) { printk (KERN_ERR
@@ -867,7 +867,7 @@ receive_packet (struct net_device *dev) PCI_DMA_FROMDEVICE);skb_put (skb = np->rx_skbuff[entry], pkt_len); np->rx_skbuff[entry] =NULL ; - }else if ((skb =dev_alloc_skb (pkt_len +2 )) !=NULL ) { + }else if ((skb =netdev_alloc_skb (dev, pkt_len +2 ))) { pci_dma_sync_single_for_cpu(np->pdev, desc_to_dma(desc), np->rx_buf_sz,
@@ -904,7 +904,7 @@ receive_packet (struct net_device *dev)struct sk_buff *skb;/* Dropped packets don't need to re-allocate */ if (np->rx_skbuff[entry] ==NULL ) { - skb =dev_alloc_skb (np->rx_buf_sz); + skb =netdev_alloc_skb (dev, np->rx_buf_sz);if (skb ==NULL ) { np->rx_ring[entry].fraginfo =0 ; printk (KERN_INFO
PATCH 13/13 acenic: use netdev_alloc_skb
In reply to Stephen HemmingerUse netdev_alloc_skb. This sets skb->dev and allows arch specific allocation.
Compile tested only.
drivers/net/acenic.c +21 -17
@@ -1514,13 +1514,13 @@ static int __devinit ace_init(struct net* firmware to wipe the ring without re-initializing it. */ if (!test_and_set_bit (0 , &ap->std_refill_busy)) -ace_load_std_rx_ring (ap,RX_RING_SIZE ); +ace_load_std_rx_ring (dev,RX_RING_SIZE );else printk (KERN_ERR "%s: Someone is busy refilling the RX ring\n" , ap->name);if (ap->version >=2 ) {if (!test_and_set_bit (0 , &ap->mini_refill_busy)) -ace_load_mini_rx_ring (ap,RX_MINI_SIZE ); +ace_load_mini_rx_ring (dev,RX_MINI_SIZE );else printk (KERN_ERR "%s: Someone is busy refilling " "the RX mini ring\n" , ap->name);
@@ -1607,7 +1607,7 @@ static void ace_tasklet(unsigned long de#ifdef DEBUG printk ("refilling buffers (current %i)\n" , cur_size);#endif -ace_load_std_rx_ring (ap,RX_RING_SIZE - cur_size); +ace_load_std_rx_ring (dev,RX_RING_SIZE - cur_size); }if (ap->version >=2 ) {
@@ -1618,7 +1618,7 @@ static void ace_tasklet(unsigned long deprintk ("refilling mini buffers (current %i)\n" , cur_size);#endif -ace_load_mini_rx_ring (ap,RX_MINI_SIZE - cur_size); +ace_load_mini_rx_ring (dev,RX_MINI_SIZE - cur_size); } }
@@ -1628,7 +1628,7 @@ static void ace_tasklet(unsigned long de#ifdef DEBUG printk ("refilling jumbo buffers (current %i)\n" , cur_size);#endif -ace_load_jumbo_rx_ring (ap,RX_JUMBO_SIZE - cur_size); +ace_load_jumbo_rx_ring (dev,RX_JUMBO_SIZE - cur_size); } ap->tasklet_pending =0 ; }
@@ -1654,12 +1654,12 @@ static void ace_dump_trace(struct ace_pr* done only before the device is enabled, thus no interrupts are * generated and by the interrupt handler/tasklet handler. */ -static void ace_load_std_rx_ring (struct ace_private *ap,int nr_bufs) +static void ace_load_std_rx_ring (struct net_device *dev,int nr_bufs) { +struct ace_private *ap =netdev_priv (dev);struct ace_regs __iomem *regs = ap->regs;short i, idx; -prefetchw (&ap->cur_rx_bufs); idx = ap->rx_std_skbprd;
@@ -1669,7 +1669,7 @@ static void ace_load_std_rx_ring(structstruct rx_desc *rd;dma_addr_t mapping; - skb =alloc_skb (ACE_STD_BUFSIZE +NET_IP_ALIGN ,GFP_ATOMIC ); + skb =netdev_alloc_skb (dev,ACE_STD_BUFSIZE +NET_IP_ALIGN );if (!skb)break ;
@@ -1717,8 +1717,9 @@ static void ace_load_std_rx_ring(struct } -static void ace_load_mini_rx_ring (struct ace_private *ap,int nr_bufs) +static void ace_load_mini_rx_ring (struct net_device *dev,int nr_bufs) { +struct ace_private *ap =netdev_priv (dev);struct ace_regs __iomem *regs = ap->regs;short i, idx;
@@ -1730,7 +1731,7 @@ static void ace_load_mini_rx_ring(structstruct rx_desc *rd;dma_addr_t mapping; - skb =alloc_skb (ACE_MINI_BUFSIZE +NET_IP_ALIGN ,GFP_ATOMIC ); + skb =netdev_alloc_skb (dev,ACE_MINI_BUFSIZE +NET_IP_ALIGN );if (!skb)break ;
@@ -1774,8 +1775,9 @@ static void ace_load_mini_rx_ring(struct* Load the jumbo rx ring, this may happen at any time if the MTU * is changed to a value > 1500. */ -static void ace_load_jumbo_rx_ring (struct ace_private *ap,int nr_bufs) +static void ace_load_jumbo_rx_ring (struct net_device *dev,int nr_bufs) { +struct ace_private *ap =netdev_priv (dev);struct ace_regs __iomem *regs = ap->regs;short i, idx;
@@ -1786,7 +1788,7 @@ static void ace_load_jumbo_rx_ring(strucstruct rx_desc *rd;dma_addr_t mapping; - skb =alloc_skb (ACE_JUMBO_BUFSIZE +NET_IP_ALIGN ,GFP_ATOMIC ); + skb =netdev_alloc_skb (dev,ACE_JUMBO_BUFSIZE +NET_IP_ALIGN );if (!skb)break ;
@@ -2214,7 +2216,7 @@ static irqreturn_t ace_interrupt(int irq#ifdef DEBUG printk ("low on std buffers %i\n" , cur_size);#endif -ace_load_std_rx_ring (ap, +ace_load_std_rx_ring (dev,RX_RING_SIZE - cur_size); }else run_tasklet =1 ;
@@ -2230,7 +2232,8 @@ static irqreturn_t ace_interrupt(int irqprintk ("low on mini buffers %i\n" , cur_size);#endif -ace_load_mini_rx_ring (ap,RX_MINI_SIZE - cur_size); +ace_load_mini_rx_ring (dev, +RX_MINI_SIZE - cur_size); }else run_tasklet =1 ; }
@@ -2246,7 +2249,8 @@ static irqreturn_t ace_interrupt(int irqprintk ("low on jumbo buffers %i\n" , cur_size);#endif -ace_load_jumbo_rx_ring (ap,RX_JUMBO_SIZE - cur_size); +ace_load_jumbo_rx_ring (dev, +RX_JUMBO_SIZE - cur_size); }else run_tasklet =1 ; }
@@ -2303,7 +2307,7 @@ static int ace_open(struct net_device *dif (ap->jumbo && !test_and_set_bit (0 , &ap->jumbo_refill_busy)) -ace_load_jumbo_rx_ring (ap,RX_JUMBO_SIZE ); +ace_load_jumbo_rx_ring (dev,RX_JUMBO_SIZE );if (dev->flags &IFF_PROMISC ) { cmd.evt =C_SET_PROMISC_MODE ;
@@ -2621,7 +2625,7 @@ static int ace_change_mtu(struct net_dev "support\n", dev->name); ap->jumbo =1 ;if (!test_and_set_bit (0 , &ap->jumbo_refill_busy)) -ace_load_jumbo_rx_ring (ap,RX_JUMBO_SIZE ); +ace_load_jumbo_rx_ring (dev,RX_JUMBO_SIZE );ace_set_rxtx_parms (dev,1 ); } }else {
drivers/net/acenic.h +3 -3
@@ -766,9 +766,9 @@ static inline void ace_unmask_irq(struct* Prototypes */ static int ace_init (struct net_device *dev); -static void ace_load_std_rx_ring (struct ace_private *ap,int nr_bufs); -static void ace_load_mini_rx_ring (struct ace_private *ap,int nr_bufs); -static void ace_load_jumbo_rx_ring (struct ace_private *ap,int nr_bufs); +static void ace_load_std_rx_ring (struct net_device *dev,int nr_bufs); +static void ace_load_mini_rx_ring (struct net_device *dev,int nr_bufs); +static void ace_load_jumbo_rx_ring (struct net_device *dev,int nr_bufs);static irqreturn_t ace_interrupt (int irq,void *dev_id);static int ace_load_firmware (struct net_device *dev);static int ace_open (struct net_device *dev);
Jeff Garzik
AppliedRe: [PATCH 13/13] acenic: use netdev_alloc_skb
Quoted 7 lines · Stephen Hemminger
Use
netdev_alloc_skb. This setsskb->devand allows arch specific allocation.Compile tested only.
Signed-off-by Stephen Hemminger <[email protected]>
applied
A message that is not in the archive (sent off-list or not yet received): [email protected]
Jay Cliburn
Acked-byRe: [PATCH 02/13] atl1: use netdev_alloc_skb
Quoted 4 lines · On Wed, 16 Apr 2008 16:37:29 -0700 Stephen Hemminger <[email protected]>…
Use
netdev_alloc_skbfor rx buffer allocation. This setsskb->devand can be overriden for NUMA machines.Compile tested only!
Works fine.
Quoted 17 lines
Signed-off-by Stephen Hemminger <[email protected]>---
a/drivers/net/atlx/atl1.c2008-04-16 14:42:38.000000000
-0700 +++b/drivers/net/atlx/atl1.c2008-04-16
14:44:18.000000000 -0700 @@ -1742,7 +1742,8 @@ static u16 atl1_alloc_rx_buffers(struct(quoted diff) +0
-1rfd_desc = ATL1_RFD_DESC(rfd_ring, rfd_next_to_use); - skb = dev_alloc_skb(adapter->rx_buffer_len +
NET_IP_ALIGN);(quoted diff) +2
-0+ skb = netdev_alloc_skb(adapter->netdev, + adapter->rx_buffer_len +
NET_IP_ALIGN); if (unlikely(!skb)) {(quoted diff) +0
-0/* Better luck next round */ adapter->net_stats.rx_dropped++;
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 01/13] tg3: remove unneeded semicolons
Quoted 3 lines · Stephen Hemminger
Remove extraneous semicolons after switch and conditional statements.
Signed-off-by Stephen Hemminger <[email protected]>
applied most of these (the ones that got acks and no negative feedback)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Jeff Garzik
AppliedRe: [PATCH 03/13] ts108: use netdev_alloc_skb
Quoted 6 lines · Stephen Hemminger
Use
netdev_alloc_skbfor rx buffer allocation. This setsskb->devand can be overriden for NUMA machines.This device is PowerPC only, so not tested or compiled.
Signed-off-by Stephen Hemminger <[email protected]>
applied