]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/skge.c
[EHEA]: Use LRO.
[linux-2.6-omap-h63xx.git] / drivers / net / skge.c
index d476a3cc2e94cf5f94df64940beb99ba5b2b2b51..0bf46ed4e684ce90ccbfa69f29d941971922a14b 100644 (file)
@@ -42,7 +42,7 @@
 #include "skge.h"
 
 #define DRV_NAME               "skge"
-#define DRV_VERSION            "1.10"
+#define DRV_VERSION            "1.11"
 #define PFX                    DRV_NAME " "
 
 #define DEFAULT_TX_RING_SIZE   128
@@ -135,10 +135,13 @@ static void skge_get_regs(struct net_device *dev, struct ethtool_regs *regs,
 /* Wake on Lan only supported on Yukon chips with rev 1 or above */
 static u32 wol_supported(const struct skge_hw *hw)
 {
-       if (hw->chip_id == CHIP_ID_YUKON && hw->chip_rev != 0)
-               return WAKE_MAGIC | WAKE_PHY;
-       else
+       if (hw->chip_id == CHIP_ID_GENESIS)
+               return 0;
+
+       if (hw->chip_id == CHIP_ID_YUKON && hw->chip_rev == 0)
                return 0;
+
+       return WAKE_MAGIC | WAKE_PHY;
 }
 
 static u32 pci_wake_enabled(struct pci_dev *dev)
@@ -818,7 +821,6 @@ static const struct ethtool_ops skge_ethtool_ops = {
        .phys_id        = skge_phys_id,
        .get_stats_count = skge_get_stats_count,
        .get_ethtool_stats = skge_get_ethtool_stats,
-       .get_perm_addr  = ethtool_op_get_perm_addr,
 };
 
 /*
@@ -2526,7 +2528,7 @@ static int skge_up(struct net_device *dev)
        skge_write32(hw, B0_IMSK, hw->intr_mask);
        spin_unlock_irq(&hw->hw_lock);
 
-       netif_poll_enable(dev);
+       napi_enable(&skge->napi);
        return 0;
 
  free_rx_ring:
@@ -2556,7 +2558,7 @@ static int skge_down(struct net_device *dev)
        if (hw->chip_id == CHIP_ID_GENESIS && hw->phy_type == SK_PHY_XMAC)
                del_timer_sync(&skge->link_timer);
 
-       netif_poll_disable(dev);
+       napi_disable(&skge->napi);
        netif_carrier_off(dev);
 
        spin_lock_irq(&hw->hw_lock);
@@ -2621,6 +2623,7 @@ static int skge_down(struct net_device *dev)
 
 static inline int skge_avail(const struct skge_ring *ring)
 {
+       smp_mb();
        return ((ring->to_clean > ring->to_use) ? 0 : ring->count)
                + (ring->to_clean - ring->to_use) - 1;
 }
@@ -2654,12 +2657,12 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
        td->dma_hi = map >> 32;
 
        if (skb->ip_summed == CHECKSUM_PARTIAL) {
-               int offset = skb->h.raw - skb->data;
+               const int offset = skb_transport_offset(skb);
 
                /* This seems backwards, but it is what the sk98lin
                 * does.  Looks like hardware is wrong?
                 */
-               if (skb->h.ipiph->protocol == IPPROTO_UDP
+               if (ipip_hdr(skb)->protocol == IPPROTO_UDP
                    && hw->chip_rev == 0 && hw->chip_id == CHIP_ID_YUKON)
                        control = BMU_TCP_CHECK;
                else
@@ -2709,6 +2712,8 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
                       dev->name, e - skge->tx_ring.start, skb->len);
 
        skge->tx_ring.to_use = e->next;
+       smp_wmb();
+
        if (skge_avail(&skge->tx_ring) <= TX_LOW_WATER) {
                pr_debug("%s: transmit queue full\n", dev->name);
                netif_stop_queue(dev);
@@ -2726,8 +2731,6 @@ static void skge_tx_free(struct skge_port *skge, struct skge_element *e,
 {
        struct pci_dev *pdev = skge->hw->pdev;
 
-       BUG_ON(!e->skb);
-
        /* skb header vs. fragment */
        if (control & BMU_STF)
                pci_unmap_single(pdev, pci_unmap_addr(e, mapaddr),
@@ -2745,7 +2748,6 @@ static void skge_tx_free(struct skge_port *skge, struct skge_element *e,
 
                dev_kfree_skb(e->skb);
        }
-       e->skb = NULL;
 }
 
 /* Free all buffers in transmit ring */
@@ -2950,7 +2952,7 @@ static struct sk_buff *skge_rx_get(struct net_device *dev,
                pci_dma_sync_single_for_cpu(skge->hw->pdev,
                                            pci_unmap_addr(e, mapaddr),
                                            len, PCI_DMA_FROMDEVICE);
-               memcpy(skb->data, e->skb->data, len);
+               skb_copy_from_linear_data(e->skb, skb->data, len);
                pci_dma_sync_single_for_device(skge->hw->pdev,
                                               pci_unmap_addr(e, mapaddr),
                                               len, PCI_DMA_FROMDEVICE);
@@ -3017,31 +3019,38 @@ static void skge_tx_done(struct net_device *dev)
 
        skge_write8(skge->hw, Q_ADDR(txqaddr[skge->port], Q_CSR), CSR_IRQ_CL_F);
 
-       netif_tx_lock(dev);
        for (e = ring->to_clean; e != ring->to_use; e = e->next) {
-               struct skge_tx_desc *td = e->desc;
+               u32 control = ((const struct skge_tx_desc *) e->desc)->control;
 
-               if (td->control & BMU_OWN)
+               if (control & BMU_OWN)
                        break;
 
-               skge_tx_free(skge, e, td->control);
+               skge_tx_free(skge, e, control);
        }
        skge->tx_ring.to_clean = e;
 
-       if (skge_avail(&skge->tx_ring) > TX_LOW_WATER)
-               netif_wake_queue(dev);
+       /* Can run lockless until we need to synchronize to restart queue. */
+       smp_mb();
 
-       netif_tx_unlock(dev);
+       if (unlikely(netif_queue_stopped(dev) &&
+                    skge_avail(&skge->tx_ring) > TX_LOW_WATER)) {
+               netif_tx_lock(dev);
+               if (unlikely(netif_queue_stopped(dev) &&
+                            skge_avail(&skge->tx_ring) > TX_LOW_WATER)) {
+                       netif_wake_queue(dev);
+
+               }
+               netif_tx_unlock(dev);
+       }
 }
 
-static int skge_poll(struct net_device *dev, int *budget)
+static int skge_poll(struct napi_struct *napi, int to_do)
 {
-       struct skge_port *skge = netdev_priv(dev);
+       struct skge_port *skge = container_of(napi, struct skge_port, napi);
+       struct net_device *dev = skge->netdev;
        struct skge_hw *hw = skge->hw;
        struct skge_ring *ring = &skge->rx_ring;
        struct skge_element *e;
-       unsigned long flags;
-       int to_do = min(dev->quota, *budget);
        int work_done = 0;
 
        skge_tx_done(dev);
@@ -3072,20 +3081,16 @@ static int skge_poll(struct net_device *dev, int *budget)
        wmb();
        skge_write8(hw, Q_ADDR(rxqaddr[skge->port], Q_CSR), CSR_START);
 
-       *budget -= work_done;
-       dev->quota -= work_done;
-
-       if (work_done >=  to_do)
-               return 1; /* not done */
-
-       spin_lock_irqsave(&hw->hw_lock, flags);
-       __netif_rx_complete(dev);
-       hw->intr_mask |= napimask[skge->port];
-       skge_write32(hw, B0_IMSK, hw->intr_mask);
-       skge_read32(hw, B0_IMSK);
-       spin_unlock_irqrestore(&hw->hw_lock, flags);
+       if (work_done < to_do) {
+               spin_lock_irq(&hw->hw_lock);
+               __netif_rx_complete(dev, napi);
+               hw->intr_mask |= napimask[skge->port];
+               skge_write32(hw, B0_IMSK, hw->intr_mask);
+               skge_read32(hw, B0_IMSK);
+               spin_unlock_irq(&hw->hw_lock);
+       }
 
-       return 0;
+       return work_done;
 }
 
 /* Parity errors seem to happen when Genesis is connected to a switch
@@ -3242,8 +3247,9 @@ static irqreturn_t skge_intr(int irq, void *dev_id)
        }
 
        if (status & (IS_XA1_F|IS_R1_F)) {
+               struct skge_port *skge = netdev_priv(hw->dev[0]);
                hw->intr_mask &= ~(IS_XA1_F|IS_R1_F);
-               netif_rx_schedule(hw->dev[0]);
+               netif_rx_schedule(hw->dev[0], &skge->napi);
        }
 
        if (status & IS_PA_TO_TX1)
@@ -3261,13 +3267,14 @@ static irqreturn_t skge_intr(int irq, void *dev_id)
                skge_mac_intr(hw, 0);
 
        if (hw->dev[1]) {
+               struct skge_port *skge = netdev_priv(hw->dev[1]);
+
                if (status & (IS_XA2_F|IS_R2_F)) {
                        hw->intr_mask &= ~(IS_XA2_F|IS_R2_F);
-                       netif_rx_schedule(hw->dev[1]);
+                       netif_rx_schedule(hw->dev[1], &skge->napi);
                }
 
                if (status & IS_PA_TO_RX2) {
-                       struct skge_port *skge = netdev_priv(hw->dev[1]);
                        ++skge->net_stats.rx_over_errors;
                        skge_write16(hw, B3_PA_CTRL, PA_CLR_TO_RX2);
                }
@@ -3559,8 +3566,6 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
        SET_ETHTOOL_OPS(dev, &skge_ethtool_ops);
        dev->tx_timeout = skge_tx_timeout;
        dev->watchdog_timeo = TX_WATCHDOG;
-       dev->poll = skge_poll;
-       dev->weight = NAPI_WEIGHT;
 #ifdef CONFIG_NET_POLL_CONTROLLER
        dev->poll_controller = skge_netpoll;
 #endif
@@ -3570,6 +3575,7 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
                dev->features |= NETIF_F_HIGHDMA;
 
        skge = netdev_priv(dev);
+       netif_napi_add(dev, &skge->napi, skge_poll, NAPI_WEIGHT);
        skge->netdev = dev;
        skge->hw = hw;
        skge->msg_enable = netif_msg_init(debug, default_msg);
@@ -3583,7 +3589,9 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
        skge->duplex = -1;
        skge->speed = -1;
        skge->advertising = skge_supported_modes(hw);
-       skge->wol = pci_wake_enabled(hw->pdev) ? wol_supported(hw) : 0;
+
+       if (pci_wake_enabled(hw->pdev))
+               skge->wol = wol_supported(hw) & WAKE_MAGIC;
 
        hw->dev[port] = dev;
 
@@ -3789,6 +3797,9 @@ static int skge_suspend(struct pci_dev *pdev, pm_message_t state)
        struct skge_hw *hw  = pci_get_drvdata(pdev);
        int i, err, wol = 0;
 
+       if (!hw)
+               return 0;
+
        err = pci_save_state(pdev);
        if (err)
                return err;
@@ -3817,6 +3828,9 @@ static int skge_resume(struct pci_dev *pdev)
        struct skge_hw *hw  = pci_get_drvdata(pdev);
        int i, err;
 
+       if (!hw)
+               return 0;
+
        err = pci_set_power_state(pdev, PCI_D0);
        if (err)
                goto out;
@@ -3855,6 +3869,9 @@ static void skge_shutdown(struct pci_dev *pdev)
        struct skge_hw *hw  = pci_get_drvdata(pdev);
        int i, wol = 0;
 
+       if (!hw)
+               return;
+
        for (i = 0; i < hw->ports; i++) {
                struct net_device *dev = hw->dev[i];
                struct skge_port *skge = netdev_priv(dev);