Initial OLPC target
[openwrt.git] / target / linux / ar7 / files / drivers / net / cpmac.c
index b0ba670..2c8d529 100644 (file)
@@ -460,30 +460,23 @@ static int cpmac_start_xmit(struct sk_buff *skb, struct net_device *dev)
        struct cpmac_desc *desc;
        struct cpmac_priv *priv = netdev_priv(dev);
 
-       if (unlikely(skb_padto(skb, ETH_ZLEN))) {
-               if (netif_msg_tx_err(priv) && net_ratelimit())
-                       printk(KERN_WARNING
-                              "%s: tx: padding failed, dropping\n", dev->name);
-               spin_lock(&priv->lock);
-               dev->stats.tx_dropped++;
-               spin_unlock(&priv->lock);
-               return -ENOMEM;
-       }
+       if (unlikely(skb_padto(skb, ETH_ZLEN)))
+               return NETDEV_TX_OK;
 
        len = max(skb->len, ETH_ZLEN);
        queue = skb->queue_mapping;
+#ifdef CONFIG_NETDEVICES_MULTIQUEUE
        netif_stop_subqueue(dev, queue);
+#else
+       netif_stop_queue(dev);
+#endif
 
        desc = &priv->desc_ring[queue];
        if (unlikely(desc->dataflags & CPMAC_OWN)) {
                if (netif_msg_tx_err(priv) && net_ratelimit())
-                       printk(KERN_WARNING "%s: tx dma ring full, dropping\n",
+                       printk(KERN_WARNING "%s: tx dma ring full\n",
                               dev->name);
-               spin_lock(&priv->lock);
-               dev->stats.tx_dropped++;
-               spin_unlock(&priv->lock);
-               dev_kfree_skb_any(skb);
-               return -ENOMEM;
+               return NETDEV_TX_BUSY;
        }
 
        spin_lock(&priv->lock);
@@ -505,7 +498,7 @@ static int cpmac_start_xmit(struct sk_buff *skb, struct net_device *dev)
                cpmac_dump_skb(dev, skb);
        cpmac_write(priv->regs, CPMAC_TX_PTR(queue), (u32)desc->mapping);
 
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 static void cpmac_end_xmit(struct net_device *dev, int queue)
@@ -529,14 +522,24 @@ static void cpmac_end_xmit(struct net_device *dev, int queue)
 
                dev_kfree_skb_irq(desc->skb);
                desc->skb = NULL;
+#ifdef CONFIG_NETDEVICES_MULTIQUEUE
                if (netif_subqueue_stopped(dev, queue))
                        netif_wake_subqueue(dev, queue);
+#else
+               if (netif_queue_stopped(dev))
+                       netif_wake_queue(dev);
+#endif
        } else {
                if (netif_msg_tx_err(priv) && net_ratelimit())
                        printk(KERN_WARNING
                               "%s: end_xmit: spurious interrupt\n", dev->name);
+#ifdef CONFIG_NETDEVICES_MULTIQUEUE
                if (netif_subqueue_stopped(dev, queue))
                        netif_wake_subqueue(dev, queue);
+#else
+               if (netif_queue_stopped(dev))
+                       netif_wake_queue(dev);
+#endif
        }
 }
 
@@ -632,12 +635,14 @@ static void cpmac_clear_tx(struct net_device *dev)
        int i;
        if (unlikely(!priv->desc_ring))
                return;
-       for (i = 0; i < CPMAC_QUEUES; i++)
+       for (i = 0; i < CPMAC_QUEUES; i++) {
+               priv->desc_ring[i].dataflags = 0;
                if (priv->desc_ring[i].skb) {
                        dev_kfree_skb_any(priv->desc_ring[i].skb);
                        if (netif_subqueue_stopped(dev, i))
                            netif_wake_subqueue(dev, i);
                }
+       }
 }
 
 static void cpmac_hw_error(struct work_struct *work)
@@ -710,12 +715,20 @@ static void cpmac_tx_timeout(struct net_device *dev)
         * FIXME: waking up random queue is not the best thing to
         * do... on the other hand why we got here at all?
         */
+#ifdef CONFIG_NETDEVICES_MULTIQUEUE
        for (i = 0; i < CPMAC_QUEUES; i++)
                if (priv->desc_ring[i].skb) {
+                       priv->desc_ring[i].dataflags = 0;
                        dev_kfree_skb_any(priv->desc_ring[i].skb);
                        netif_wake_subqueue(dev, i);
                        break;
                }
+#else
+       priv->desc_ring[0].dataflags = 0;
+       if (priv->desc_ring[0].skb)
+               dev_kfree_skb_any(priv->desc_ring[0].skb);
+       netif_wake_queue(dev);
+#endif
 }
 
 static int cpmac_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
@@ -774,7 +787,7 @@ static int cpmac_set_ringparam(struct net_device *dev, struct ethtool_ringparam*
 {
        struct cpmac_priv *priv = netdev_priv(dev);
 
-       if (dev->flags && IFF_UP)
+       if (netif_running(dev))
                return -EBUSY;
        priv->ring_size = ring->rx_pending;
        return 0;
This page took 0.031582 seconds and 4 git commands to generate.