]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - drivers/net/starfire.c
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[mirror_ubuntu-zesty-kernel.git] / drivers / net / starfire.c
index 7b7b1717b0d161e86d03da072a339a88dfef1d41..1902f4fabde140018ed840bcb501cf6e3bb43ae9 100644 (file)
@@ -27,8 +27,8 @@
 */
 
 #define DRV_NAME       "starfire"
-#define DRV_VERSION    "2.0"
-#define DRV_RELDATE    "June 27, 2006"
+#define DRV_VERSION    "2.1"
+#define DRV_RELDATE    "July  6, 2008"
 
 #include <linux/module.h>
 #include <linux/kernel.h>
 #define VLAN_SUPPORT
 #endif
 
-#ifndef CONFIG_ADAPTEC_STARFIRE_NAPI
-#undef HAVE_NETDEV_POLL
-#endif
-
 /* The user-configurable values.
    These may be modified when a driver module is loaded.*/
 
@@ -177,44 +173,6 @@ static int full_duplex[MAX_UNITS] = {0, };
 #define skb_first_frag_len(skb)        skb_headlen(skb)
 #define skb_num_frags(skb) (skb_shinfo(skb)->nr_frags + 1)
 
-#ifdef HAVE_NETDEV_POLL
-#define init_poll(dev, np) \
-       netif_napi_add(dev, &np->napi, netdev_poll, max_interrupt_work)
-#define netdev_rx(dev, np, ioaddr) \
-do { \
-       u32 intr_enable; \
-       if (netif_rx_schedule_prep(dev, &np->napi)) { \
-               __netif_rx_schedule(dev, &np->napi); \
-               intr_enable = readl(ioaddr + IntrEnable); \
-               intr_enable &= ~(IntrRxDone | IntrRxEmpty); \
-               writel(intr_enable, ioaddr + IntrEnable); \
-               readl(ioaddr + IntrEnable); /* flush PCI posting buffers */ \
-       } else { \
-               /* Paranoia check */ \
-               intr_enable = readl(ioaddr + IntrEnable); \
-               if (intr_enable & (IntrRxDone | IntrRxEmpty)) { \
-                       printk(KERN_INFO "%s: interrupt while in polling mode!\n", dev->name); \
-                       intr_enable &= ~(IntrRxDone | IntrRxEmpty); \
-                       writel(intr_enable, ioaddr + IntrEnable); \
-               } \
-       } \
-} while (0)
-#define netdev_receive_skb(skb) netif_receive_skb(skb)
-#define vlan_netdev_receive_skb(skb, vlgrp, vlid) vlan_hwaccel_receive_skb(skb, vlgrp, vlid)
-static int     netdev_poll(struct napi_struct *napi, int budget);
-#else  /* not HAVE_NETDEV_POLL */
-#define init_poll(dev, np)
-#define netdev_receive_skb(skb) netif_rx(skb)
-#define vlan_netdev_receive_skb(skb, vlgrp, vlid) vlan_hwaccel_rx(skb, vlgrp, vlid)
-#define netdev_rx(dev, np, ioaddr) \
-do { \
-       int quota = np->dirty_rx + RX_RING_SIZE - np->cur_rx; \
-       __netdev_rx(dev, &quota);\
-} while (0)
-#endif /* not HAVE_NETDEV_POLL */
-/* end of compatibility code */
-
-
 /* These identify the driver base version and may not be removed. */
 static char version[] =
 KERN_INFO "starfire.c:v1.03 7/26/2000  Written by Donald Becker <becker@scyld.com>\n"
@@ -635,6 +593,7 @@ static int  start_tx(struct sk_buff *skb, struct net_device *dev);
 static irqreturn_t intr_handler(int irq, void *dev_instance);
 static void    netdev_error(struct net_device *dev, int intr_status);
 static int     __netdev_rx(struct net_device *dev, int *quota);
+static int     netdev_poll(struct napi_struct *napi, int budget);
 static void    refill_rx_ring(struct net_device *dev);
 static void    netdev_error(struct net_device *dev, int intr_status);
 static void    set_rx_mode(struct net_device *dev);
@@ -694,7 +653,6 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
        void __iomem *base;
        int drv_flags, io_size;
        int boguscnt;
-       DECLARE_MAC_BUF(mac);
 
 /* when built into the kernel, we only print version if device is found */
 #ifndef MODULE
@@ -851,7 +809,7 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
        dev->hard_start_xmit = &start_tx;
        dev->tx_timeout = tx_timeout;
        dev->watchdog_timeo = TX_TIMEOUT;
-       init_poll(dev, np);
+       netif_napi_add(dev, &np->napi, netdev_poll, max_interrupt_work);
        dev->stop = &netdev_close;
        dev->get_stats = &get_stats;
        dev->set_multicast_list = &set_rx_mode;
@@ -864,9 +822,9 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
        if (register_netdev(dev))
                goto err_out_cleardev;
 
-       printk(KERN_INFO "%s: %s at %p, %s, IRQ %d.\n",
+       printk(KERN_INFO "%s: %s at %p, %pM, IRQ %d.\n",
               dev->name, netdrv_tbl[chip_idx].name, base,
-              print_mac(mac, dev->dev_addr), irq);
+              dev->dev_addr, irq);
 
        if (drv_flags & CanHaveMII) {
                int phy, phy_idx = 0;
@@ -1054,9 +1012,8 @@ static int netdev_open(struct net_device *dev)
 
        writel(np->intr_timer_ctrl, ioaddr + IntrTimerCtrl);
 
-#ifdef HAVE_NETDEV_POLL
        napi_enable(&np->napi);
-#endif
+
        netif_start_queue(dev);
 
        if (debug > 1)
@@ -1330,8 +1287,28 @@ static irqreturn_t intr_handler(int irq, void *dev_instance)
 
                handled = 1;
 
-               if (intr_status & (IntrRxDone | IntrRxEmpty))
-                       netdev_rx(dev, np, ioaddr);
+               if (intr_status & (IntrRxDone | IntrRxEmpty)) {
+                       u32 enable;
+
+                       if (likely(netif_rx_schedule_prep(&np->napi))) {
+                               __netif_rx_schedule(&np->napi);
+                               enable = readl(ioaddr + IntrEnable);
+                               enable &= ~(IntrRxDone | IntrRxEmpty);
+                               writel(enable, ioaddr + IntrEnable);
+                               /* flush PCI posting buffers */
+                               readl(ioaddr + IntrEnable);
+                       } else {
+                               /* Paranoia check */
+                               enable = readl(ioaddr + IntrEnable);
+                               if (enable & (IntrRxDone | IntrRxEmpty)) {
+                                       printk(KERN_INFO
+                                              "%s: interrupt while in poll!\n",
+                                              dev->name);
+                                       enable &= ~(IntrRxDone | IntrRxEmpty);
+                                       writel(enable, ioaddr + IntrEnable);
+                               }
+                       }
+               }
 
                /* Scavenge the skbuff list based on the Tx-done queue.
                   There are redundant checks here that may be cleaned up
@@ -1411,8 +1388,10 @@ static irqreturn_t intr_handler(int irq, void *dev_instance)
 }
 
 
-/* This routine is logically part of the interrupt/poll handler, but separated
-   for clarity, code sharing between NAPI/non-NAPI, and better register allocation. */
+/*
+ * This routine is logically part of the interrupt/poll handler, but separated
+ * for clarity and better register allocation.
+ */
 static int __netdev_rx(struct net_device *dev, int *quota)
 {
        struct netdev_private *np = netdev_priv(dev);
@@ -1472,12 +1451,8 @@ static int __netdev_rx(struct net_device *dev, int *quota)
 #ifndef final_version                  /* Remove after testing. */
                /* You will want this info for the initial debug. */
                if (debug > 5) {
-                       printk(KERN_DEBUG "  Rx data " MAC_FMT " " MAC_FMT
-                              " %2.2x%2.2x.\n",
-                              skb->data[0], skb->data[1], skb->data[2],
-                              skb->data[3], skb->data[4], skb->data[5],
-                              skb->data[6], skb->data[7], skb->data[8],
-                              skb->data[9], skb->data[10], skb->data[11],
+                       printk(KERN_DEBUG "  Rx data %pM %pM %2.2x%2.2x.\n",
+                              skb->data, skb->data + 6,
                               skb->data[12], skb->data[13]);
                }
 #endif
@@ -1507,14 +1482,20 @@ static int __netdev_rx(struct net_device *dev, int *quota)
                }
 #ifdef VLAN_SUPPORT
                if (np->vlgrp && le16_to_cpu(desc->status2) & 0x0200) {
-                       if (debug > 4)
-                               printk(KERN_DEBUG "  netdev_rx() vlanid = %d\n", le16_to_cpu(desc->vlanid));
-                       /* vlan_netdev_receive_skb() expects a packet with the VLAN tag stripped out */
-                       vlan_netdev_receive_skb(skb, np->vlgrp, le16_to_cpu(desc->vlanid) & VLAN_VID_MASK);
+                       u16 vlid = le16_to_cpu(desc->vlanid);
+
+                       if (debug > 4) {
+                               printk(KERN_DEBUG "  netdev_rx() vlanid = %d\n",
+                                      vlid);
+                       }
+                       /*
+                        * vlan_hwaccel_rx expects a packet with the VLAN tag
+                        * stripped out.
+                        */
+                       vlan_hwaccel_rx(skb, np->vlgrp, vlid);
                } else
 #endif /* VLAN_SUPPORT */
-                       netdev_receive_skb(skb);
-               dev->last_rx = jiffies;
+                       netif_receive_skb(skb);
                np->stats.rx_packets++;
 
        next_rx:
@@ -1522,6 +1503,11 @@ static int __netdev_rx(struct net_device *dev, int *quota)
                desc->status = 0;
                np->rx_done = (np->rx_done + 1) % DONE_Q_SIZE;
        }
+
+       if (*quota == 0) {      /* out of rx quota */
+               retcode = 1;
+               goto out;
+       }
        writew(np->rx_done, np->base + CompletionQConsumerIdx);
 
  out:
@@ -1532,8 +1518,6 @@ static int __netdev_rx(struct net_device *dev, int *quota)
        return retcode;
 }
 
-
-#ifdef HAVE_NETDEV_POLL
 static int netdev_poll(struct napi_struct *napi, int budget)
 {
        struct netdev_private *np = container_of(napi, struct netdev_private, napi);
@@ -1551,7 +1535,7 @@ static int netdev_poll(struct napi_struct *napi, int budget)
                intr_status = readl(ioaddr + IntrStatus);
        } while (intr_status & (IntrRxDone | IntrRxEmpty));
 
-       netif_rx_complete(dev, napi);
+       netif_rx_complete(napi);
        intr_status = readl(ioaddr + IntrEnable);
        intr_status |= IntrRxDone | IntrRxEmpty;
        writel(intr_status, ioaddr + IntrEnable);
@@ -1564,8 +1548,6 @@ static int netdev_poll(struct napi_struct *napi, int budget)
        /* Restart Rx engine if stopped. */
        return budget - quota;
 }
-#endif /* HAVE_NETDEV_POLL */
-
 
 static void refill_rx_ring(struct net_device *dev)
 {
@@ -1906,9 +1888,8 @@ static int netdev_close(struct net_device *dev)
        int i;
 
        netif_stop_queue(dev);
-#ifdef HAVE_NETDEV_POLL
+
        napi_disable(&np->napi);
-#endif
 
        if (debug > 1) {
                printk(KERN_DEBUG "%s: Shutting down ethercard, Intr status %#8.8x.\n",
@@ -2044,11 +2025,8 @@ static int __init starfire_init (void)
 /* when a module, this is printed whether or not devices are found in probe */
 #ifdef MODULE
        printk(version);
-#ifdef HAVE_NETDEV_POLL
+
        printk(KERN_INFO DRV_NAME ": polling (NAPI) enabled\n");
-#else
-       printk(KERN_INFO DRV_NAME ": polling (NAPI) disabled\n");
-#endif
 #endif
 
        /* we can do this test only at run-time... sigh */