e1000e: stop unnecessary polling when using msi-x
[safe/jmp/linux-2.6] / drivers / net / via-velocity.c
index 58e25d0..b02f7ad 100644 (file)
@@ -377,7 +377,7 @@ static void velocity_print_info(struct velocity_info *vptr);
 static int velocity_open(struct net_device *dev);
 static int velocity_change_mtu(struct net_device *dev, int mtu);
 static int velocity_xmit(struct sk_buff *skb, struct net_device *dev);
-static int velocity_intr(int irq, void *dev_instance);
+static irqreturn_t velocity_intr(int irq, void *dev_instance);
 static void velocity_set_multi(struct net_device *dev);
 static struct net_device_stats *velocity_get_stats(struct net_device *dev);
 static int velocity_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
@@ -855,6 +855,7 @@ static const struct net_device_ops velocity_netdev_ops = {
        .ndo_start_xmit         = velocity_xmit,
        .ndo_get_stats          = velocity_get_stats,
        .ndo_validate_addr      = eth_validate_addr,
+       .ndo_set_mac_address    = eth_mac_addr,
        .ndo_set_multicast_list = velocity_set_multi,
        .ndo_change_mtu         = velocity_change_mtu,
        .ndo_do_ioctl           = velocity_ioctl,
@@ -988,8 +989,10 @@ static int __devinit velocity_found1(struct pci_dev *pdev, const struct pci_devi
        if (ret < 0)
                goto err_iounmap;
 
-       if (velocity_get_link(dev))
+       if (!velocity_get_link(dev)) {
                netif_carrier_off(dev);
+               vptr->mii_status |= VELOCITY_LINK_FAIL;
+       }
 
        velocity_print_info(vptr);
        pci_set_drvdata(pdev, dev);
@@ -1301,7 +1304,7 @@ static void velocity_free_rd_ring(struct velocity_info *vptr)
 static int velocity_init_td_ring(struct velocity_info *vptr)
 {
        dma_addr_t curr;
-       unsigned int j;
+       int j;
 
        /* Init the TD ring entries */
        for (j = 0; j < vptr->tx.numq; j++) {
@@ -1384,7 +1387,7 @@ static void velocity_free_td_ring(struct velocity_info *vptr)
 
 static int velocity_rx_srv(struct velocity_info *vptr, int status)
 {
-       struct net_device_stats *stats = &vptr->stats;
+       struct net_device_stats *stats = &vptr->dev->stats;
        int rd_curr = vptr->rx.curr;
        int works = 0;
 
@@ -1518,7 +1521,7 @@ static inline void velocity_iph_realign(struct velocity_info *vptr,
 static int velocity_receive_frame(struct velocity_info *vptr, int idx)
 {
        void (*pci_action)(struct pci_dev *, dma_addr_t, size_t, int);
-       struct net_device_stats *stats = &vptr->stats;
+       struct net_device_stats *stats = &vptr->dev->stats;
        struct velocity_rd_info *rd_info = &(vptr->rx.info[idx]);
        struct rx_desc *rd = &(vptr->rx.ring[idx]);
        int pkt_len = le16_to_cpu(rd->rdesc0.len) & 0x3fff;
@@ -1531,7 +1534,7 @@ static int velocity_receive_frame(struct velocity_info *vptr, int idx)
        }
 
        if (rd->rdesc0.RSR & RSR_MAR)
-               vptr->stats.multicast++;
+               stats->multicast++;
 
        skb = rd_info->skb;
 
@@ -1633,7 +1636,7 @@ static int velocity_tx_srv(struct velocity_info *vptr, u32 status)
        int idx;
        int works = 0;
        struct velocity_td_info *tdinfo;
-       struct net_device_stats *stats = &vptr->stats;
+       struct net_device_stats *stats = &vptr->dev->stats;
 
        for (qnum = 0; qnum < vptr->tx.numq; qnum++) {
                for (idx = vptr->tx.tail[qnum]; vptr->tx.used[qnum] > 0;
@@ -1837,17 +1840,19 @@ static void velocity_free_tx_buf(struct velocity_info *vptr, struct velocity_td_
 {
        struct sk_buff *skb = tdinfo->skb;
        int i;
+       int pktlen;
 
        /*
         *      Don't unmap the pre-allocated tx_bufs
         */
        if (tdinfo->skb_dma) {
 
+               pktlen = (skb->len > ETH_ZLEN ? : ETH_ZLEN);
                for (i = 0; i < tdinfo->nskb_dma; i++) {
 #ifdef VELOCITY_ZERO_COPY_SUPPORT
                        pci_unmap_single(vptr->pdev, tdinfo->skb_dma[i], le16_to_cpu(td->tdesc1.len), PCI_DMA_TODEVICE);
 #else
-                       pci_unmap_single(vptr->pdev, tdinfo->skb_dma[i], skb->len, PCI_DMA_TODEVICE);
+                       pci_unmap_single(vptr->pdev, tdinfo->skb_dma[i], pktlen, PCI_DMA_TODEVICE);
 #endif
                        tdinfo->skb_dma[i] = 0;
                }
@@ -2079,17 +2084,14 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)
        struct tx_desc *td_ptr;
        struct velocity_td_info *tdinfo;
        unsigned long flags;
-       int pktlen = skb->len;
+       int pktlen;
        __le16 len;
        int index;
 
 
-
-       if (skb->len < ETH_ZLEN) {
-               if (skb_padto(skb, ETH_ZLEN))
-                       goto out;
-               pktlen = ETH_ZLEN;
-       }
+       if (skb_padto(skb, ETH_ZLEN))
+               goto out;
+       pktlen = max_t(unsigned int, skb->len, ETH_ZLEN);
 
        len = cpu_to_le16(pktlen);
 
@@ -2215,7 +2217,7 @@ out:
  *     efficiently as possible.
  */
 
-static int velocity_intr(int irq, void *dev_instance)
+static irqreturn_t velocity_intr(int irq, void *dev_instance)
 {
        struct net_device *dev = dev_instance;
        struct velocity_info *vptr = netdev_priv(dev);
@@ -2324,22 +2326,22 @@ static struct net_device_stats *velocity_get_stats(struct net_device *dev)
 
        /* If the hardware is down, don't touch MII */
        if(!netif_running(dev))
-               return &vptr->stats;
+               return &dev->stats;
 
        spin_lock_irq(&vptr->lock);
        velocity_update_hw_mibs(vptr);
        spin_unlock_irq(&vptr->lock);
 
-       vptr->stats.rx_packets = vptr->mib_counter[HW_MIB_ifRxAllPkts];
-       vptr->stats.rx_errors = vptr->mib_counter[HW_MIB_ifRxErrorPkts];
-       vptr->stats.rx_length_errors = vptr->mib_counter[HW_MIB_ifInRangeLengthErrors];
+       dev->stats.rx_packets = vptr->mib_counter[HW_MIB_ifRxAllPkts];
+       dev->stats.rx_errors = vptr->mib_counter[HW_MIB_ifRxErrorPkts];
+       dev->stats.rx_length_errors = vptr->mib_counter[HW_MIB_ifInRangeLengthErrors];
 
 //  unsigned long   rx_dropped;     /* no space in linux buffers    */
-       vptr->stats.collisions = vptr->mib_counter[HW_MIB_ifTxEtherCollisions];
+       dev->stats.collisions = vptr->mib_counter[HW_MIB_ifTxEtherCollisions];
        /* detailed rx_errors: */
 //  unsigned long   rx_length_errors;
 //  unsigned long   rx_over_errors;     /* receiver ring buff overflow  */
-       vptr->stats.rx_crc_errors = vptr->mib_counter[HW_MIB_ifRxPktCRCE];
+       dev->stats.rx_crc_errors = vptr->mib_counter[HW_MIB_ifRxPktCRCE];
 //  unsigned long   rx_frame_errors;    /* recv'd frame alignment error */
 //  unsigned long   rx_fifo_errors;     /* recv'r fifo overrun      */
 //  unsigned long   rx_missed_errors;   /* receiver missed packet   */
@@ -2347,7 +2349,7 @@ static struct net_device_stats *velocity_get_stats(struct net_device *dev)
        /* detailed tx_errors */
 //  unsigned long   tx_fifo_errors;
 
-       return &vptr->stats;
+       return &dev->stats;
 }