Commit 427e21faee1877053828b115bbb336c289562ac5

Authored by stephen hemminger
Committed by David S. Miller
1 parent 750e06992d

acenic: use netdev_alloc_skb_ip_align

Take Eric's patch one step further.
Use netdev_skb_ip_align to do setup the receive skb.
Compile tested only.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 2 changed files with 27 additions and 24 deletions Side-by-side Diff

drivers/net/acenic.c
... ... @@ -1502,13 +1502,13 @@
1502 1502 * firmware to wipe the ring without re-initializing it.
1503 1503 */
1504 1504 if (!test_and_set_bit(0, &ap->std_refill_busy))
1505   - ace_load_std_rx_ring(ap, RX_RING_SIZE);
  1505 + ace_load_std_rx_ring(dev, RX_RING_SIZE);
1506 1506 else
1507 1507 printk(KERN_ERR "%s: Someone is busy refilling the RX ring\n",
1508 1508 ap->name);
1509 1509 if (ap->version >= 2) {
1510 1510 if (!test_and_set_bit(0, &ap->mini_refill_busy))
1511   - ace_load_mini_rx_ring(ap, RX_MINI_SIZE);
  1511 + ace_load_mini_rx_ring(dev, RX_MINI_SIZE);
1512 1512 else
1513 1513 printk(KERN_ERR "%s: Someone is busy refilling "
1514 1514 "the RX mini ring\n", ap->name);
1515 1515  
... ... @@ -1584,9 +1584,10 @@
1584 1584 }
1585 1585  
1586 1586  
1587   -static void ace_tasklet(unsigned long dev)
  1587 +static void ace_tasklet(unsigned long arg)
1588 1588 {
1589   - struct ace_private *ap = netdev_priv((struct net_device *)dev);
  1589 + struct net_device *dev = (struct net_device *) arg;
  1590 + struct ace_private *ap = netdev_priv(dev);
1590 1591 int cur_size;
1591 1592  
1592 1593 cur_size = atomic_read(&ap->cur_rx_bufs);
... ... @@ -1595,7 +1596,7 @@
1595 1596 #ifdef DEBUG
1596 1597 printk("refilling buffers (current %i)\n", cur_size);
1597 1598 #endif
1598   - ace_load_std_rx_ring(ap, RX_RING_SIZE - cur_size);
  1599 + ace_load_std_rx_ring(dev, RX_RING_SIZE - cur_size);
1599 1600 }
1600 1601  
1601 1602 if (ap->version >= 2) {
... ... @@ -1606,7 +1607,7 @@
1606 1607 printk("refilling mini buffers (current %i)\n",
1607 1608 cur_size);
1608 1609 #endif
1609   - ace_load_mini_rx_ring(ap, RX_MINI_SIZE - cur_size);
  1610 + ace_load_mini_rx_ring(dev, RX_MINI_SIZE - cur_size);
1610 1611 }
1611 1612 }
1612 1613  
... ... @@ -1616,7 +1617,7 @@
1616 1617 #ifdef DEBUG
1617 1618 printk("refilling jumbo buffers (current %i)\n", cur_size);
1618 1619 #endif
1619   - ace_load_jumbo_rx_ring(ap, RX_JUMBO_SIZE - cur_size);
  1620 + ace_load_jumbo_rx_ring(dev, RX_JUMBO_SIZE - cur_size);
1620 1621 }
1621 1622 ap->tasklet_pending = 0;
1622 1623 }
1623 1624  
... ... @@ -1642,8 +1643,9 @@
1642 1643 * done only before the device is enabled, thus no interrupts are
1643 1644 * generated and by the interrupt handler/tasklet handler.
1644 1645 */
1645   -static void ace_load_std_rx_ring(struct ace_private *ap, int nr_bufs)
  1646 +static void ace_load_std_rx_ring(struct net_device *dev, int nr_bufs)
1646 1647 {
  1648 + struct ace_private *ap = netdev_priv(dev);
1647 1649 struct ace_regs __iomem *regs = ap->regs;
1648 1650 short i, idx;
1649 1651  
1650 1652  
... ... @@ -1657,11 +1659,10 @@
1657 1659 struct rx_desc *rd;
1658 1660 dma_addr_t mapping;
1659 1661  
1660   - skb = dev_alloc_skb(ACE_STD_BUFSIZE + NET_IP_ALIGN);
  1662 + skb = netdev_alloc_skb_ip_align(dev, ACE_STD_BUFSIZE);
1661 1663 if (!skb)
1662 1664 break;
1663 1665  
1664   - skb_reserve(skb, NET_IP_ALIGN);
1665 1666 mapping = pci_map_page(ap->pdev, virt_to_page(skb->data),
1666 1667 offset_in_page(skb->data),
1667 1668 ACE_STD_BUFSIZE,
1668 1669  
... ... @@ -1705,8 +1706,9 @@
1705 1706 }
1706 1707  
1707 1708  
1708   -static void ace_load_mini_rx_ring(struct ace_private *ap, int nr_bufs)
  1709 +static void ace_load_mini_rx_ring(struct net_device *dev, int nr_bufs)
1709 1710 {
  1711 + struct ace_private *ap = netdev_priv(dev);
1710 1712 struct ace_regs __iomem *regs = ap->regs;
1711 1713 short i, idx;
1712 1714  
1713 1715  
... ... @@ -1718,11 +1720,10 @@
1718 1720 struct rx_desc *rd;
1719 1721 dma_addr_t mapping;
1720 1722  
1721   - skb = dev_alloc_skb(ACE_MINI_BUFSIZE + NET_IP_ALIGN);
  1723 + skb = netdev_alloc_skb_ip_align(dev, ACE_MINI_BUFSIZE);
1722 1724 if (!skb)
1723 1725 break;
1724 1726  
1725   - skb_reserve(skb, NET_IP_ALIGN);
1726 1727 mapping = pci_map_page(ap->pdev, virt_to_page(skb->data),
1727 1728 offset_in_page(skb->data),
1728 1729 ACE_MINI_BUFSIZE,
1729 1730  
... ... @@ -1762,8 +1763,9 @@
1762 1763 * Load the jumbo rx ring, this may happen at any time if the MTU
1763 1764 * is changed to a value > 1500.
1764 1765 */
1765   -static void ace_load_jumbo_rx_ring(struct ace_private *ap, int nr_bufs)
  1766 +static void ace_load_jumbo_rx_ring(struct net_device *dev, int nr_bufs)
1766 1767 {
  1768 + struct ace_private *ap = netdev_priv(dev);
1767 1769 struct ace_regs __iomem *regs = ap->regs;
1768 1770 short i, idx;
1769 1771  
1770 1772  
... ... @@ -1774,11 +1776,10 @@
1774 1776 struct rx_desc *rd;
1775 1777 dma_addr_t mapping;
1776 1778  
1777   - skb = dev_alloc_skb(ACE_JUMBO_BUFSIZE + NET_IP_ALIGN);
  1779 + skb = netdev_alloc_skb_ip_align(dev, ACE_JUMBO_BUFSIZE);
1778 1780 if (!skb)
1779 1781 break;
1780 1782  
1781   - skb_reserve(skb, NET_IP_ALIGN);
1782 1783 mapping = pci_map_page(ap->pdev, virt_to_page(skb->data),
1783 1784 offset_in_page(skb->data),
1784 1785 ACE_JUMBO_BUFSIZE,
... ... @@ -2196,7 +2197,7 @@
2196 2197 #ifdef DEBUG
2197 2198 printk("low on std buffers %i\n", cur_size);
2198 2199 #endif
2199   - ace_load_std_rx_ring(ap,
  2200 + ace_load_std_rx_ring(dev,
2200 2201 RX_RING_SIZE - cur_size);
2201 2202 } else
2202 2203 run_tasklet = 1;
... ... @@ -2212,7 +2213,8 @@
2212 2213 printk("low on mini buffers %i\n",
2213 2214 cur_size);
2214 2215 #endif
2215   - ace_load_mini_rx_ring(ap, RX_MINI_SIZE - cur_size);
  2216 + ace_load_mini_rx_ring(dev,
  2217 + RX_MINI_SIZE - cur_size);
2216 2218 } else
2217 2219 run_tasklet = 1;
2218 2220 }
... ... @@ -2228,7 +2230,8 @@
2228 2230 printk("low on jumbo buffers %i\n",
2229 2231 cur_size);
2230 2232 #endif
2231   - ace_load_jumbo_rx_ring(ap, RX_JUMBO_SIZE - cur_size);
  2233 + ace_load_jumbo_rx_ring(dev,
  2234 + RX_JUMBO_SIZE - cur_size);
2232 2235 } else
2233 2236 run_tasklet = 1;
2234 2237 }
... ... @@ -2267,7 +2270,7 @@
2267 2270  
2268 2271 if (ap->jumbo &&
2269 2272 !test_and_set_bit(0, &ap->jumbo_refill_busy))
2270   - ace_load_jumbo_rx_ring(ap, RX_JUMBO_SIZE);
  2273 + ace_load_jumbo_rx_ring(dev, RX_JUMBO_SIZE);
2271 2274  
2272 2275 if (dev->flags & IFF_PROMISC) {
2273 2276 cmd.evt = C_SET_PROMISC_MODE;
... ... @@ -2575,7 +2578,7 @@
2575 2578 "support\n", dev->name);
2576 2579 ap->jumbo = 1;
2577 2580 if (!test_and_set_bit(0, &ap->jumbo_refill_busy))
2578   - ace_load_jumbo_rx_ring(ap, RX_JUMBO_SIZE);
  2581 + ace_load_jumbo_rx_ring(dev, RX_JUMBO_SIZE);
2579 2582 ace_set_rxtx_parms(dev, 1);
2580 2583 }
2581 2584 } else {
drivers/net/acenic.h
... ... @@ -766,9 +766,9 @@
766 766 * Prototypes
767 767 */
768 768 static int ace_init(struct net_device *dev);
769   -static void ace_load_std_rx_ring(struct ace_private *ap, int nr_bufs);
770   -static void ace_load_mini_rx_ring(struct ace_private *ap, int nr_bufs);
771   -static void ace_load_jumbo_rx_ring(struct ace_private *ap, int nr_bufs);
  769 +static void ace_load_std_rx_ring(struct net_device *dev, int nr_bufs);
  770 +static void ace_load_mini_rx_ring(struct net_device *dev, int nr_bufs);
  771 +static void ace_load_jumbo_rx_ring(struct net_device *dev, int nr_bufs);
772 772 static irqreturn_t ace_interrupt(int irq, void *dev_id);
773 773 static int ace_load_firmware(struct net_device *dev);
774 774 static int ace_open(struct net_device *dev);