* [PATCH 00/13] Network driver changes for 2.6.26
@ 2008-04-16 23:37 Stephen Hemminger
2008-04-16 23:37 ` [PATCH 04/13] via-velocity: use netdev_alloc_skb Stephen Hemminger
` (12 more replies)
0 siblings, 13 replies; 22+ messages in thread
From: Stephen Hemminger @ 2008-04-16 23:37 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev
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.
--
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 04/13] via-velocity: use netdev_alloc_skb
2008-04-16 23:37 [PATCH 00/13] Network driver changes for 2.6.26 Stephen Hemminger
@ 2008-04-16 23:37 ` Stephen Hemminger
2008-04-16 23:37 ` [PATCH 05/13] via-velocity: use memmove Stephen Hemminger
` (11 subsequent siblings)
12 siblings, 0 replies; 22+ messages in thread
From: Stephen Hemminger @ 2008-04-16 23:37 UTC (permalink / raw)
To: Jeff Garzik, Francois Romieu; +Cc: netdev
[-- Attachment #1: via-velocity --]
[-- Type: text/plain, Size: 2016 bytes --]
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!
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/via-velocity.c 2008-04-02 10:55:31.000000000 -0700
+++ b/drivers/net/via-velocity.c 2008-04-16 16:20:44.000000000 -0700
@@ -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(struct
struct 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);
/*
--
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 05/13] via-velocity: use memmove
2008-04-16 23:37 [PATCH 00/13] Network driver changes for 2.6.26 Stephen Hemminger
2008-04-16 23:37 ` [PATCH 04/13] via-velocity: use netdev_alloc_skb Stephen Hemminger
@ 2008-04-16 23:37 ` Stephen Hemminger
2008-04-16 23:37 ` [PATCH 06/13] sis190: use netdev_alloc_skb Stephen Hemminger
` (10 subsequent siblings)
12 siblings, 0 replies; 22+ messages in thread
From: Stephen Hemminger @ 2008-04-16 23:37 UTC (permalink / raw)
To: Jeff Garzik, Francois Romieu; +Cc: netdev
[-- Attachment #1: via-velocity-memmove --]
[-- Type: text/plain, Size: 693 bytes --]
Use memmove to handle overlapping copy of data.
Compile tested only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/via-velocity.c 2008-04-16 16:21:25.000000000 -0700
+++ b/drivers/net/via-velocity.c 2008-04-16 16:24:48.000000000 -0700
@@ -1522,12 +1522,8 @@ static int velocity_rx_copy(struct sk_bu
static 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);
}
}
--
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 06/13] sis190: use netdev_alloc_skb
2008-04-16 23:37 [PATCH 00/13] Network driver changes for 2.6.26 Stephen Hemminger
2008-04-16 23:37 ` [PATCH 04/13] via-velocity: use netdev_alloc_skb Stephen Hemminger
2008-04-16 23:37 ` [PATCH 05/13] via-velocity: use memmove Stephen Hemminger
@ 2008-04-16 23:37 ` Stephen Hemminger
2008-04-17 1:04 ` Wang Chen
` (2 more replies)
2008-04-16 23:37 ` [PATCH 07/13] sb1250: " Stephen Hemminger
` (9 subsequent siblings)
12 siblings, 3 replies; 22+ messages in thread
From: Stephen Hemminger @ 2008-04-16 23:37 UTC (permalink / raw)
To: Jeff Garzik, Francois Romieu; +Cc: netdev
[-- Attachment #1: sis190 --]
[-- Type: text/plain, Size: 2728 bytes --]
Use netdev_alloc_skb. This sets skb->dev and allows arch specific
allocation.
Compile tested only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/sis190.c 2008-04-16 15:21:05.000000000 -0700
+++ b/drivers/net/sis190.c 2008-04-16 16:31:30.000000000 -0700
@@ -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 ne
le32_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;
--
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 07/13] sb1250: use netdev_alloc_skb
2008-04-16 23:37 [PATCH 00/13] Network driver changes for 2.6.26 Stephen Hemminger
` (2 preceding siblings ...)
2008-04-16 23:37 ` [PATCH 06/13] sis190: use netdev_alloc_skb Stephen Hemminger
@ 2008-04-16 23:37 ` Stephen Hemminger
2008-05-05 12:34 ` Maciej W. Rozycki
2008-04-16 23:37 ` [PATCH 08/13] ns8320: " Stephen Hemminger
` (8 subsequent siblings)
12 siblings, 1 reply; 22+ messages in thread
From: Stephen Hemminger @ 2008-04-16 23:37 UTC (permalink / raw)
To: Jeff Garzik, Maciej W. Rozycki; +Cc: netdev
[-- Attachment #1: sb1250 --]
[-- Type: text/plain, Size: 1723 bytes --]
Use 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
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/sb1250-mac.c 2008-04-02 10:55:30.000000000 -0700
+++ b/drivers/net/sb1250-mac.c 2008-04-16 16:32:06.000000000 -0700
@@ -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;
--
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 08/13] ns8320: use netdev_alloc_skb
2008-04-16 23:37 [PATCH 00/13] Network driver changes for 2.6.26 Stephen Hemminger
` (3 preceding siblings ...)
2008-04-16 23:37 ` [PATCH 07/13] sb1250: " Stephen Hemminger
@ 2008-04-16 23:37 ` Stephen Hemminger
2008-05-31 2:20 ` Jeff Garzik
2008-04-16 23:37 ` [PATCH 09/13] myri: " Stephen Hemminger
` (7 subsequent siblings)
12 siblings, 1 reply; 22+ messages in thread
From: Stephen Hemminger @ 2008-04-16 23:37 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev
[-- Attachment #1: ns83820 --]
[-- Type: text/plain, Size: 885 bytes --]
Use netdev_alloc_skb. This sets skb->dev and allows arch specific
allocation.
Compile tested only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/ns83820.c 2008-04-02 10:55:30.000000000 -0700
+++ b/drivers/net/ns83820.c 2008-04-16 16:34:50.000000000 -0700
@@ -585,16 +585,13 @@ static inline int rx_refill(struct net_d
for (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);
--
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 09/13] myri: use netdev_alloc_skb
2008-04-16 23:37 [PATCH 00/13] Network driver changes for 2.6.26 Stephen Hemminger
` (4 preceding siblings ...)
2008-04-16 23:37 ` [PATCH 08/13] ns8320: " Stephen Hemminger
@ 2008-04-16 23:37 ` Stephen Hemminger
2008-04-16 23:37 ` [PATCH 10/13] ixp2000: " Stephen Hemminger
` (6 subsequent siblings)
12 siblings, 0 replies; 22+ messages in thread
From: Stephen Hemminger @ 2008-04-16 23:37 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev
[-- Attachment #1: myri --]
[-- Type: text/plain, Size: 2787 bytes --]
Use netdev_alloc_skb. This sets skb->dev and allows arch specific
allocation.
Copmpile tested only
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/myri_sbus.c 2008-04-07 10:36:16.000000000 -0700
+++ b/drivers/net/myri_sbus.c 2008-04-07 12:44:15.000000000 -0700
@@ -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);
--- a/drivers/net/myri_sbus.h 2008-04-07 10:36:16.000000000 -0700
+++ b/drivers/net/myri_sbus.h 2008-04-07 12:43:47.000000000 -0700
@@ -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) */
--
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 10/13] ixp2000: use netdev_alloc_skb
2008-04-16 23:37 [PATCH 00/13] Network driver changes for 2.6.26 Stephen Hemminger
` (5 preceding siblings ...)
2008-04-16 23:37 ` [PATCH 09/13] myri: " Stephen Hemminger
@ 2008-04-16 23:37 ` Stephen Hemminger
2008-04-17 13:53 ` Lennert Buytenhek
2008-04-16 23:37 ` [PATCH 11/13] hamachi: " Stephen Hemminger
` (5 subsequent siblings)
12 siblings, 1 reply; 22+ messages in thread
From: Stephen Hemminger @ 2008-04-16 23:37 UTC (permalink / raw)
To: Jeff Garzik, Lennert Buytenhek; +Cc: netdev
[-- Attachment #1: ixp2000 --]
[-- Type: text/plain, Size: 824 bytes --]
Use netdev_alloc_skb. This sets skb->dev and allows arch specific
allocation.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/ixp2000/ixpdev.c 2008-04-07 10:36:16.000000000 -0700
+++ b/drivers/net/ixp2000/ixpdev.c 2008-04-07 12:43:41.000000000 -0700
@@ -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);
}
--
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 11/13] hamachi: use netdev_alloc_skb
2008-04-16 23:37 [PATCH 00/13] Network driver changes for 2.6.26 Stephen Hemminger
` (6 preceding siblings ...)
2008-04-16 23:37 ` [PATCH 10/13] ixp2000: " Stephen Hemminger
@ 2008-04-16 23:37 ` Stephen Hemminger
2008-04-16 23:37 ` [PATCH 12/13] dl2k: " Stephen Hemminger
` (4 subsequent siblings)
12 siblings, 0 replies; 22+ messages in thread
From: Stephen Hemminger @ 2008-04-16 23:37 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev
[-- Attachment #1: hamachi --]
[-- Type: text/plain, Size: 1587 bytes --]
Use netdev_alloc_skb. This sets skb->dev and allows arch specific
allocation.
Remove dead code and dead comments.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/hamachi.c 2008-04-07 08:48:24.000000000 -0700
+++ b/drivers/net/hamachi.c 2008-04-07 08:50:14.000000000 -0700
@@ -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
--
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 12/13] dl2k: use netdev_alloc_skb
2008-04-16 23:37 [PATCH 00/13] Network driver changes for 2.6.26 Stephen Hemminger
` (7 preceding siblings ...)
2008-04-16 23:37 ` [PATCH 11/13] hamachi: " Stephen Hemminger
@ 2008-04-16 23:37 ` Stephen Hemminger
2008-04-16 23:37 ` [PATCH 13/13] acenic: " Stephen Hemminger
` (3 subsequent siblings)
12 siblings, 0 replies; 22+ messages in thread
From: Stephen Hemminger @ 2008-04-16 23:37 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev
[-- Attachment #1: dl2k --]
[-- Type: text/plain, Size: 1752 bytes --]
Use netdev_alloc_skb. This sets skb->dev and allows arch specific
allocation.
Compile tested only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/dl2k.c 2008-04-07 10:36:16.000000000 -0700
+++ b/drivers/net/dl2k.c 2008-04-07 12:36:56.000000000 -0700
@@ -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
--
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 13/13] acenic: use netdev_alloc_skb
2008-04-16 23:37 [PATCH 00/13] Network driver changes for 2.6.26 Stephen Hemminger
` (8 preceding siblings ...)
2008-04-16 23:37 ` [PATCH 12/13] dl2k: " Stephen Hemminger
@ 2008-04-16 23:37 ` Stephen Hemminger
2008-05-31 2:21 ` Jeff Garzik
[not found] ` <20080416233757.090004281@vyatta.com>
` (2 subsequent siblings)
12 siblings, 1 reply; 22+ messages in thread
From: Stephen Hemminger @ 2008-04-16 23:37 UTC (permalink / raw)
To: Jeff Garzik, Jes Sorensen; +Cc: netdev, linux-acenic
[-- Attachment #1: acenic --]
[-- Type: text/plain, Size: 6190 bytes --]
Use netdev_alloc_skb. This sets skb->dev and allows arch specific
allocation.
Compile tested only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/acenic.c 2008-04-07 10:36:16.000000000 -0700
+++ b/drivers/net/acenic.c 2008-04-07 12:36:50.000000000 -0700
@@ -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 de
printk("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(struct
struct 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(struct
struct 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(struc
struct 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 irq
printk("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 irq
printk("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 *d
if (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 {
--- a/drivers/net/acenic.h 2008-04-07 10:36:16.000000000 -0700
+++ b/drivers/net/acenic.h 2008-04-07 12:36:50.000000000 -0700
@@ -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);
--
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 06/13] sis190: use netdev_alloc_skb
2008-04-16 23:37 ` [PATCH 06/13] sis190: use netdev_alloc_skb Stephen Hemminger
@ 2008-04-17 1:04 ` Wang Chen
2008-04-17 2:16 ` Wang Chen
2008-04-17 6:50 ` Francois Romieu
2 siblings, 0 replies; 22+ messages in thread
From: Wang Chen @ 2008-04-17 1:04 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Jeff Garzik, Francois Romieu, netdev
Stephen Hemminger said the following on 2008-4-17 7:37:
> Use netdev_alloc_skb. This sets skb->dev and allows arch specific
> allocation.
>
> Compile tested only.
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
>
> --- a/drivers/net/sis190.c 2008-04-16 15:21:05.000000000 -0700
> +++ b/drivers/net/sis190.c 2008-04-16 16:31:30.000000000 -0700
> @@ -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;
>
ret no longer be used.
> - 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;
ret no longer be used.
> 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 ne
> le32_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;
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 06/13] sis190: use netdev_alloc_skb
2008-04-16 23:37 ` [PATCH 06/13] sis190: use netdev_alloc_skb Stephen Hemminger
2008-04-17 1:04 ` Wang Chen
@ 2008-04-17 2:16 ` Wang Chen
2008-04-17 2:59 ` Stephen Hemminger
2008-04-17 6:50 ` Francois Romieu
2 siblings, 1 reply; 22+ messages in thread
From: Wang Chen @ 2008-04-17 2:16 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Jeff Garzik, Francois Romieu, netdev
Stephen Hemminger said the following on 2008-4-17 7:37:
> +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
> 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);
why?
[PATCH 02/13] atl1: use netdev_alloc_skb
using NET_IP_ALIGN, not 2.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 02/13] atl1: use netdev_alloc_skb
[not found] ` <20080416233757.090004281@vyatta.com>
@ 2008-04-17 2:33 ` Jay Cliburn
0 siblings, 0 replies; 22+ messages in thread
From: Jay Cliburn @ 2008-04-17 2:33 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Jeff Garzik, Chris Snook, netdev, atl1-devel
On Wed, 16 Apr 2008 16:37:29 -0700
Stephen Hemminger <shemminger@vyatta.com> wrote:
> Use netdev_alloc_skb for rx buffer allocation. This sets skb->dev
> and can be overriden for NUMA machines.
>
> Compile tested only!
Works fine.
Acked-by: Jay Cliburn <jacliburn@bellsouth.net>
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
>
> --- a/drivers/net/atlx/atl1.c 2008-04-16 14:42:38.000000000
> -0700 +++ b/drivers/net/atlx/atl1.c 2008-04-16
> 14:44:18.000000000 -0700 @@ -1742,7 +1742,8 @@ static u16
> atl1_alloc_rx_buffers(struct
> rfd_desc = ATL1_RFD_DESC(rfd_ring, rfd_next_to_use);
>
> - skb = dev_alloc_skb(adapter->rx_buffer_len +
> NET_IP_ALIGN);
> + skb = netdev_alloc_skb(adapter->netdev,
> + adapter->rx_buffer_len +
> NET_IP_ALIGN); if (unlikely(!skb)) {
> /* Better luck next round */
> adapter->net_stats.rx_dropped++;
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 06/13] sis190: use netdev_alloc_skb
2008-04-17 2:16 ` Wang Chen
@ 2008-04-17 2:59 ` Stephen Hemminger
0 siblings, 0 replies; 22+ messages in thread
From: Stephen Hemminger @ 2008-04-17 2:59 UTC (permalink / raw)
To: Wang Chen; +Cc: Stephen Hemminger, Jeff Garzik, Francois Romieu, netdev
On Thu, 17 Apr 2008 10:16:26 +0800
Wang Chen <wangchen@cn.fujitsu.com> wrote:
> Stephen Hemminger said the following on 2008-4-17 7:37:
> > +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
> why not : ret = 1
>
> > 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);
>
> why?
> [PATCH 02/13] atl1: use netdev_alloc_skb
> using NET_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.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 06/13] sis190: use netdev_alloc_skb
2008-04-16 23:37 ` [PATCH 06/13] sis190: use netdev_alloc_skb Stephen Hemminger
2008-04-17 1:04 ` Wang Chen
2008-04-17 2:16 ` Wang Chen
@ 2008-04-17 6:50 ` Francois Romieu
2 siblings, 0 replies; 22+ messages in thread
From: Francois Romieu @ 2008-04-17 6:50 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Jeff Garzik, netdev
Stephen Hemminger <shemminger@vyatta.com> :
> Use netdev_alloc_skb. This sets skb->dev and allows arch specific
> allocation.
>
> Compile tested only.
[...]
> -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.
>
> - 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;
> }
--
Ueimor
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 10/13] ixp2000: use netdev_alloc_skb
2008-04-16 23:37 ` [PATCH 10/13] ixp2000: " Stephen Hemminger
@ 2008-04-17 13:53 ` Lennert Buytenhek
0 siblings, 0 replies; 22+ messages in thread
From: Lennert Buytenhek @ 2008-04-17 13:53 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Jeff Garzik, netdev
On Wed, Apr 16, 2008 at 04:37:37PM -0700, Stephen Hemminger wrote:
> Use netdev_alloc_skb. This sets skb->dev and allows arch specific
> allocation.
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
No objections, I guess..
> --- a/drivers/net/ixp2000/ixpdev.c 2008-04-07 10:36:16.000000000 -0700
> +++ b/drivers/net/ixp2000/ixpdev.c 2008-04-07 12:43:41.000000000 -0700
> @@ -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);
> }
>
> --
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 07/13] sb1250: use netdev_alloc_skb
2008-04-16 23:37 ` [PATCH 07/13] sb1250: " Stephen Hemminger
@ 2008-05-05 12:34 ` Maciej W. Rozycki
0 siblings, 0 replies; 22+ messages in thread
From: Maciej W. Rozycki @ 2008-05-05 12:34 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Jeff Garzik, netdev
Use netdev_alloc_skb. This sets skb->dev and allows arch specific
allocation. Also simplify and cleanup the alignment code.
Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
On Wed, 16 Apr 2008, Stephen Hemminger wrote:
> Not tested, depends on non-x86 hardware
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
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
diff -up --recursive --new-file linux-mips-2.6.25-20080422.macro/drivers/net/sb1250-mac.c linux-mips-2.6.25-20080422/drivers/net/sb1250-mac.c
--- linux-mips-2.6.25-20080422.macro/drivers/net/sb1250-mac.c 2008-04-22 04:55:27.000000000 +0000
+++ linux-mips-2.6.25-20080422/drivers/net/sb1250-mac.c 2008-05-05 04:49:12.000000000 +0000
@@ -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.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 01/13] tg3: remove unneeded semicolons
[not found] ` <20080416233757.015978466@vyatta.com>
@ 2008-05-22 18:13 ` Jeff Garzik
0 siblings, 0 replies; 22+ messages in thread
From: Jeff Garzik @ 2008-05-22 18:13 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Michael Chan, netdev
Stephen Hemminger wrote:
> Remove extraneous semicolons after switch and conditional statements.
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
applied most of these (the ones that got acks and no negative feedback)
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 03/13] ts108: use netdev_alloc_skb
[not found] ` <20080416233757.166190217@vyatta.com>
@ 2008-05-31 2:20 ` Jeff Garzik
0 siblings, 0 replies; 22+ messages in thread
From: Jeff Garzik @ 2008-05-31 2:20 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Alex Bounine, Zang Roy-r61911, netdev
Stephen Hemminger wrote:
> Use netdev_alloc_skb for rx buffer allocation. This sets skb->dev
> and can be overriden for NUMA machines.
>
> This device is PowerPC only, so not tested or compiled.
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
applied
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 08/13] ns8320: use netdev_alloc_skb
2008-04-16 23:37 ` [PATCH 08/13] ns8320: " Stephen Hemminger
@ 2008-05-31 2:20 ` Jeff Garzik
0 siblings, 0 replies; 22+ messages in thread
From: Jeff Garzik @ 2008-05-31 2:20 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
Stephen Hemminger wrote:
> Use netdev_alloc_skb. This sets skb->dev and allows arch specific
> allocation.
>
> Compile tested only.
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
applied
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 13/13] acenic: use netdev_alloc_skb
2008-04-16 23:37 ` [PATCH 13/13] acenic: " Stephen Hemminger
@ 2008-05-31 2:21 ` Jeff Garzik
0 siblings, 0 replies; 22+ messages in thread
From: Jeff Garzik @ 2008-05-31 2:21 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Jes Sorensen, netdev, linux-acenic
Stephen Hemminger wrote:
> Use netdev_alloc_skb. This sets skb->dev and allows arch specific
> allocation.
>
> Compile tested only.
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
>
applied
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2008-05-31 2:21 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-16 23:37 [PATCH 00/13] Network driver changes for 2.6.26 Stephen Hemminger
2008-04-16 23:37 ` [PATCH 04/13] via-velocity: use netdev_alloc_skb Stephen Hemminger
2008-04-16 23:37 ` [PATCH 05/13] via-velocity: use memmove Stephen Hemminger
2008-04-16 23:37 ` [PATCH 06/13] sis190: use netdev_alloc_skb Stephen Hemminger
2008-04-17 1:04 ` Wang Chen
2008-04-17 2:16 ` Wang Chen
2008-04-17 2:59 ` Stephen Hemminger
2008-04-17 6:50 ` Francois Romieu
2008-04-16 23:37 ` [PATCH 07/13] sb1250: " Stephen Hemminger
2008-05-05 12:34 ` Maciej W. Rozycki
2008-04-16 23:37 ` [PATCH 08/13] ns8320: " Stephen Hemminger
2008-05-31 2:20 ` Jeff Garzik
2008-04-16 23:37 ` [PATCH 09/13] myri: " Stephen Hemminger
2008-04-16 23:37 ` [PATCH 10/13] ixp2000: " Stephen Hemminger
2008-04-17 13:53 ` Lennert Buytenhek
2008-04-16 23:37 ` [PATCH 11/13] hamachi: " Stephen Hemminger
2008-04-16 23:37 ` [PATCH 12/13] dl2k: " Stephen Hemminger
2008-04-16 23:37 ` [PATCH 13/13] acenic: " Stephen Hemminger
2008-05-31 2:21 ` Jeff Garzik
[not found] ` <20080416233757.090004281@vyatta.com>
2008-04-17 2:33 ` [PATCH 02/13] atl1: " Jay Cliburn
[not found] ` <20080416233757.015978466@vyatta.com>
2008-05-22 18:13 ` [PATCH 01/13] tg3: remove unneeded semicolons Jeff Garzik
[not found] ` <20080416233757.166190217@vyatta.com>
2008-05-31 2:20 ` [PATCH 03/13] ts108: use netdev_alloc_skb Jeff Garzik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).