pci: Add SR-IOV convenience functions and macros
[safe/jmp/linux-2.6] / drivers / net / au1000_eth.c
index d58c105..9337d02 100644 (file)
@@ -34,6 +34,7 @@
  *
  *
  */
+#include <linux/capability.h>
 #include <linux/dma-mapping.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
@@ -721,7 +722,7 @@ static inline void update_rx_stats(struct net_device *dev, u32 status)
                ps->rx_errors++;
                if (status & RX_MISSED_FRAME)
                        ps->rx_missed_errors++;
-               if (status & (RX_OVERLEN | RX_OVERLEN | RX_LEN_ERROR))
+               if (status & (RX_OVERLEN | RX_RUNT | RX_LEN_ERROR))
                        ps->rx_length_errors++;
                if (status & RX_CRC_ERROR)
                        ps->rx_crc_errors++;
@@ -794,8 +795,6 @@ static int au1000_rx(struct net_device *dev)
                                        printk("rx len error\n");
                                if (status & RX_U_CNTRL_FRAME)
                                        printk("rx u control frame\n");
-                               if (status & RX_MISSED_FRAME)
-                                       printk("rx miss\n");
                        }
                }
                prxd->buff_stat = (u32)(pDB->dma_addr | RX_DMA_ENABLE);
@@ -882,7 +881,7 @@ static int au1000_open(struct net_device *dev)
        if (au1000_debug > 4)
                printk("%s: open: dev=%p\n", dev->name, dev);
 
-       if ((retval = request_irq(dev->irq, &au1000_interrupt, 0,
+       if ((retval = request_irq(dev->irq, au1000_interrupt, 0,
                                        dev->name, dev))) {
                printk(KERN_ERR "%s: unable to get IRQ %d\n",
                                dev->name, dev->irq);
@@ -937,7 +936,7 @@ static int au1000_close(struct net_device *dev)
 /*
  * Au1000 transmit routine.
  */
-static int au1000_tx(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t au1000_tx(struct sk_buff *skb, struct net_device *dev)
 {
        struct au1000_private *aup = netdev_priv(dev);
        struct net_device_stats *ps = &dev->stats;
@@ -957,7 +956,7 @@ static int au1000_tx(struct sk_buff *skb, struct net_device *dev)
                /* We've wrapped around and the transmitter is still busy */
                netif_stop_queue(dev);
                aup->tx_full = 1;
-               return 1;
+               return NETDEV_TX_BUSY;
        }
        else if (buff_stat & TX_T_DONE) {
                update_tx_stats(dev, ptxd->status);
@@ -988,7 +987,7 @@ static int au1000_tx(struct sk_buff *skb, struct net_device *dev)
        dev_kfree_skb(skb);
        aup->tx_head = (aup->tx_head + 1) & (NUM_TX_DMA - 1);
        dev->trans_start = jiffies;
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 /*
@@ -1014,7 +1013,7 @@ static void au1000_multicast_list(struct net_device *dev)
        if (dev->flags & IFF_PROMISC) {                 /* Set promiscuous. */
                aup->mac->control |= MAC_PROMISCUOUS;
        } else if ((dev->flags & IFF_ALLMULTI)  ||
-                          dev->mc_count > MULTICAST_FILTER_LIMIT) {
+                          netdev_mc_count(dev) > MULTICAST_FILTER_LIMIT) {
                aup->mac->control |= MAC_PASS_ALL_MULTI;
                aup->mac->control &= ~MAC_PROMISCUOUS;
                printk(KERN_INFO "%s: Pass all multicast\n", dev->name);
@@ -1024,7 +1023,7 @@ static void au1000_multicast_list(struct net_device *dev)
                u32 mc_filter[2];       /* Multicast hash filter */
 
                mc_filter[1] = mc_filter[0] = 0;
-               for (i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count;
+               for (i = 0, mclist = dev->mc_list; mclist && i < netdev_mc_count(dev);
                         i++, mclist = mclist->next) {
                        set_bit(ether_crc(ETH_ALEN, mclist->dmi_addr)>>26,
                                        (long *)mc_filter);
@@ -1089,7 +1088,14 @@ static struct net_device * au1000_probe(int port_num)
                return NULL;
        }
 
-       if ((err = register_netdev(dev)) != 0) {
+       dev->base_addr = base;
+       dev->irq = irq;
+       dev->netdev_ops = &au1000_netdev_ops;
+       SET_ETHTOOL_OPS(dev, &au1000_ethtool_ops);
+       dev->watchdog_timeo = ETH_TX_TIMEOUT;
+
+       err = register_netdev(dev);
+       if (err != 0) {
                printk(KERN_ERR "%s: Cannot register net device, error %d\n",
                                DRV_NAME, err);
                free_netdev(dev);
@@ -1157,6 +1163,9 @@ static struct net_device * au1000_probe(int port_num)
        aup->mii_bus->name = "au1000_eth_mii";
        snprintf(aup->mii_bus->id, MII_BUS_ID_SIZE, "%x", aup->mac_id);
        aup->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
+       if (aup->mii_bus->irq == NULL)
+               goto err_out;
+
        for(i = 0; i < PHY_MAX_ADDR; ++i)
                aup->mii_bus->irq[i] = PHY_POLL;
 
@@ -1207,12 +1216,6 @@ static struct net_device * au1000_probe(int port_num)
                aup->tx_db_inuse[i] = pDB;
        }
 
-       dev->base_addr = base;
-       dev->irq = irq;
-       dev->netdev_ops = &au1000_netdev_ops;
-       SET_ETHTOOL_OPS(dev, &au1000_ethtool_ops);
-       dev->watchdog_timeo = ETH_TX_TIMEOUT;
-
        /*
         * The boot code uses the ethernet controller, so reset it to start
         * fresh.  au1000_init() expects that the device is in reset state.