Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[linux-2.6.git] / drivers / net / gianfar.c
index dfa55f9..d265c6e 100644 (file)
@@ -62,6 +62,9 @@
  *  The driver then cleans up the buffer.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define DEBUG
+
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/errno.h>
@@ -213,8 +216,7 @@ static int gfar_init_bds(struct net_device *ndev)
                        } else {
                                skb = gfar_new_skb(ndev);
                                if (!skb) {
-                                       pr_err("%s: Can't allocate RX buffers\n",
-                                                       ndev->name);
+                                       netdev_err(ndev, "Can't allocate RX buffers\n");
                                        goto err_rxalloc_fail;
                                }
                                rx_queue->rx_skbuff[j] = skb;
@@ -258,15 +260,14 @@ static int gfar_alloc_skb_resources(struct net_device *ndev)
                        sizeof(struct rxbd8) * priv->total_rx_ring_size,
                        &addr, GFP_KERNEL);
        if (!vaddr) {
-               if (netif_msg_ifup(priv))
-                       pr_err("%s: Could not allocate buffer descriptors!\n",
-                              ndev->name);
+               netif_err(priv, ifup, ndev,
+                         "Could not allocate buffer descriptors!\n");
                return -ENOMEM;
        }
 
        for (i = 0; i < priv->num_tx_queues; i++) {
                tx_queue = priv->tx_queue[i];
-               tx_queue->tx_bd_base = (struct txbd8 *) vaddr;
+               tx_queue->tx_bd_base = vaddr;
                tx_queue->tx_bd_dma_base = addr;
                tx_queue->dev = ndev;
                /* enet DMA only understands physical addresses */
@@ -277,7 +278,7 @@ static int gfar_alloc_skb_resources(struct net_device *ndev)
        /* Start the rx descriptor ring where the tx ring leaves off */
        for (i = 0; i < priv->num_rx_queues; i++) {
                rx_queue = priv->rx_queue[i];
-               rx_queue->rx_bd_base = (struct rxbd8 *) vaddr;
+               rx_queue->rx_bd_base = vaddr;
                rx_queue->rx_bd_dma_base = addr;
                rx_queue->dev = ndev;
                addr    += sizeof (struct rxbd8) * rx_queue->rx_ring_size;
@@ -290,9 +291,8 @@ static int gfar_alloc_skb_resources(struct net_device *ndev)
                tx_queue->tx_skbuff = kmalloc(sizeof(*tx_queue->tx_skbuff) *
                                  tx_queue->tx_ring_size, GFP_KERNEL);
                if (!tx_queue->tx_skbuff) {
-                       if (netif_msg_ifup(priv))
-                               pr_err("%s: Could not allocate tx_skbuff\n",
-                                               ndev->name);
+                       netif_err(priv, ifup, ndev,
+                                 "Could not allocate tx_skbuff\n");
                        goto cleanup;
                }
 
@@ -306,9 +306,8 @@ static int gfar_alloc_skb_resources(struct net_device *ndev)
                                  rx_queue->rx_ring_size, GFP_KERNEL);
 
                if (!rx_queue->rx_skbuff) {
-                       if (netif_msg_ifup(priv))
-                               pr_err("%s: Could not allocate rx_skbuff\n",
-                                      ndev->name);
+                       netif_err(priv, ifup, ndev,
+                                 "Could not allocate rx_skbuff\n");
                        goto cleanup;
                }
 
@@ -625,9 +624,9 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
        num_tx_qs = tx_queues ? *tx_queues : 1;
 
        if (num_tx_qs > MAX_TX_QS) {
-               printk(KERN_ERR "num_tx_qs(=%d) greater than MAX_TX_QS(=%d)\n",
-                               num_tx_qs, MAX_TX_QS);
-               printk(KERN_ERR "Cannot do alloc_etherdev, aborting\n");
+               pr_err("num_tx_qs(=%d) greater than MAX_TX_QS(=%d)\n",
+                      num_tx_qs, MAX_TX_QS);
+               pr_err("Cannot do alloc_etherdev, aborting\n");
                return -EINVAL;
        }
 
@@ -635,9 +634,9 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
        num_rx_qs = rx_queues ? *rx_queues : 1;
 
        if (num_rx_qs > MAX_RX_QS) {
-               printk(KERN_ERR "num_rx_qs(=%d) greater than MAX_RX_QS(=%d)\n",
-                               num_tx_qs, MAX_TX_QS);
-               printk(KERN_ERR "Cannot do alloc_etherdev, aborting\n");
+               pr_err("num_rx_qs(=%d) greater than MAX_RX_QS(=%d)\n",
+                      num_rx_qs, MAX_RX_QS);
+               pr_err("Cannot do alloc_etherdev, aborting\n");
                return -EINVAL;
        }
 
@@ -655,6 +654,11 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
        priv->num_rx_queues = num_rx_qs;
        priv->num_grps = 0x0;
 
+       /* Init Rx queue filer rule set linked list*/
+       INIT_LIST_HEAD(&priv->rx_list.list);
+       priv->rx_list.count = 0;
+       mutex_init(&priv->rx_queue_access);
+
        model = of_get_property(np, "model", NULL);
 
        for (i = 0; i < MAXGROUPS; i++)
@@ -1148,9 +1152,8 @@ static int gfar_probe(struct platform_device *ofdev)
                priv->rx_queue[i]->rxic = DEFAULT_RXIC;
        }
 
-       /* enable filer if using multiple RX queues*/
-       if(priv->num_rx_queues > 1)
-               priv->rx_filer_enable = 1;
+       /* always enable rx filer*/
+       priv->rx_filer_enable = 1;
        /* Enable most messages by default */
        priv->msg_enable = (NETIF_MSG_IFUP << 1 ) - 1;
 
@@ -1160,8 +1163,7 @@ static int gfar_probe(struct platform_device *ofdev)
        err = register_netdev(dev);
 
        if (err) {
-               printk(KERN_ERR "%s: Cannot register net device, aborting.\n",
-                               dev->name);
+               pr_err("%s: Cannot register net device, aborting\n", dev->name);
                goto register_fail;
        }
 
@@ -1212,17 +1214,17 @@ static int gfar_probe(struct platform_device *ofdev)
        gfar_init_sysfs(dev);
 
        /* Print out the device info */
-       printk(KERN_INFO DEVICE_NAME "%pM\n", dev->name, dev->dev_addr);
+       netdev_info(dev, "mac: %pM\n", dev->dev_addr);
 
        /* Even more device info helps when determining which kernel */
        /* provided which set of benchmarks. */
-       printk(KERN_INFO "%s: Running with NAPI enabled\n", dev->name);
+       netdev_info(dev, "Running with NAPI enabled\n");
        for (i = 0; i < priv->num_rx_queues; i++)
-               printk(KERN_INFO "%s: RX BD ring size for Q[%d]: %d\n",
-                       dev->name, i, priv->rx_queue[i]->rx_ring_size);
+               netdev_info(dev, "RX BD ring size for Q[%d]: %d\n",
+                           i, priv->rx_queue[i]->rx_ring_size);
        for(i = 0; i < priv->num_tx_queues; i++)
-                printk(KERN_INFO "%s: TX BD ring size for Q[%d]: %d\n",
-                       dev->name, i, priv->tx_queue[i]->tx_ring_size);
+               netdev_info(dev, "TX BD ring size for Q[%d]: %d\n",
+                           i, priv->tx_queue[i]->tx_ring_size);
 
        return 0;
 
@@ -1855,34 +1857,30 @@ static int register_grp_irqs(struct gfar_priv_grp *grp)
                 * Transmit, and Receive */
                if ((err = request_irq(grp->interruptError, gfar_error, 0,
                                grp->int_name_er,grp)) < 0) {
-                       if (netif_msg_intr(priv))
-                               printk(KERN_ERR "%s: Can't get IRQ %d\n",
-                                       dev->name, grp->interruptError);
+                       netif_err(priv, intr, dev, "Can't get IRQ %d\n",
+                                 grp->interruptError);
 
                        goto err_irq_fail;
                }
 
                if ((err = request_irq(grp->interruptTransmit, gfar_transmit,
                                0, grp->int_name_tx, grp)) < 0) {
-                       if (netif_msg_intr(priv))
-                               printk(KERN_ERR "%s: Can't get IRQ %d\n",
-                                       dev->name, grp->interruptTransmit);
+                       netif_err(priv, intr, dev, "Can't get IRQ %d\n",
+                                 grp->interruptTransmit);
                        goto tx_irq_fail;
                }
 
                if ((err = request_irq(grp->interruptReceive, gfar_receive, 0,
                                grp->int_name_rx, grp)) < 0) {
-                       if (netif_msg_intr(priv))
-                               printk(KERN_ERR "%s: Can't get IRQ %d\n",
-                                       dev->name, grp->interruptReceive);
+                       netif_err(priv, intr, dev, "Can't get IRQ %d\n",
+                                 grp->interruptReceive);
                        goto rx_irq_fail;
                }
        } else {
                if ((err = request_irq(grp->interruptTransmit, gfar_interrupt, 0,
                                grp->int_name_tx, grp)) < 0) {
-                       if (netif_msg_intr(priv))
-                               printk(KERN_ERR "%s: Can't get IRQ %d\n",
-                                       dev->name, grp->interruptTransmit);
+                       netif_err(priv, intr, dev, "Can't get IRQ %d\n",
+                                 grp->interruptTransmit);
                        goto err_irq_fail;
                }
        }
@@ -2365,9 +2363,7 @@ static int gfar_change_mtu(struct net_device *dev, int new_mtu)
                frame_size += VLAN_HLEN;
 
        if ((frame_size < 64) || (frame_size > JUMBO_FRAME_SIZE)) {
-               if (netif_msg_drv(priv))
-                       printk(KERN_ERR "%s: Invalid MTU setting\n",
-                                       dev->name);
+               netif_err(priv, drv, dev, "Invalid MTU setting\n");
                return -EINVAL;
        }
 
@@ -2787,9 +2783,7 @@ int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit)
                                gfar_process_frame(dev, skb, amount_pull);
 
                        } else {
-                               if (netif_msg_rx_err(priv))
-                                       printk(KERN_WARNING
-                                              "%s: Missing skb!\n", dev->name);
+                               netif_warn(priv, rx_err, dev, "Missing skb!\n");
                                rx_queue->stats.rx_dropped++;
                                priv->extra_stats.rx_skbmissing++;
                        }
@@ -2992,10 +2986,9 @@ static void adjust_link(struct net_device *dev)
                                        ecntrl &= ~(ECNTRL_R100);
                                break;
                        default:
-                               if (netif_msg_link(priv))
-                                       printk(KERN_WARNING
-                                               "%s: Ack!  Speed (%d) is not 10/100/1000!\n",
-                                               dev->name, phydev->speed);
+                               netif_warn(priv, link, dev,
+                                          "Ack!  Speed (%d) is not 10/100/1000!\n",
+                                          phydev->speed);
                                break;
                        }
 
@@ -3200,8 +3193,8 @@ static irqreturn_t gfar_error(int irq, void *grp_id)
 
        /* Hmm... */
        if (netif_msg_rx_err(priv) || netif_msg_tx_err(priv))
-               printk(KERN_DEBUG "%s: error interrupt (ievent=0x%08x imask=0x%08x)\n",
-                      dev->name, events, gfar_read(&regs->imask));
+               netdev_dbg(dev, "error interrupt (ievent=0x%08x imask=0x%08x)\n",
+                          events, gfar_read(&regs->imask));
 
        /* Update the error counters */
        if (events & IEVENT_TXE) {
@@ -3214,9 +3207,8 @@ static irqreturn_t gfar_error(int irq, void *grp_id)
                if (events & IEVENT_XFUN) {
                        unsigned long flags;
 
-                       if (netif_msg_tx_err(priv))
-                               printk(KERN_DEBUG "%s: TX FIFO underrun, "
-                                      "packet dropped.\n", dev->name);
+                       netif_dbg(priv, tx_err, dev,
+                                 "TX FIFO underrun, packet dropped\n");
                        dev->stats.tx_dropped++;
                        priv->extra_stats.tx_underrun++;
 
@@ -3229,8 +3221,7 @@ static irqreturn_t gfar_error(int irq, void *grp_id)
                        unlock_tx_qs(priv);
                        local_irq_restore(flags);
                }
-               if (netif_msg_tx_err(priv))
-                       printk(KERN_DEBUG "%s: Transmit Error\n", dev->name);
+               netif_dbg(priv, tx_err, dev, "Transmit Error\n");
        }
        if (events & IEVENT_BSY) {
                dev->stats.rx_errors++;
@@ -3238,29 +3229,25 @@ static irqreturn_t gfar_error(int irq, void *grp_id)
 
                gfar_receive(irq, grp_id);
 
-               if (netif_msg_rx_err(priv))
-                       printk(KERN_DEBUG "%s: busy error (rstat: %x)\n",
-                              dev->name, gfar_read(&regs->rstat));
+               netif_dbg(priv, rx_err, dev, "busy error (rstat: %x)\n",
+                         gfar_read(&regs->rstat));
        }
        if (events & IEVENT_BABR) {
                dev->stats.rx_errors++;
                priv->extra_stats.rx_babr++;
 
-               if (netif_msg_rx_err(priv))
-                       printk(KERN_DEBUG "%s: babbling RX error\n", dev->name);
+               netif_dbg(priv, rx_err, dev, "babbling RX error\n");
        }
        if (events & IEVENT_EBERR) {
                priv->extra_stats.eberr++;
-               if (netif_msg_rx_err(priv))
-                       printk(KERN_DEBUG "%s: bus error\n", dev->name);
+               netif_dbg(priv, rx_err, dev, "bus error\n");
        }
-       if ((events & IEVENT_RXC) && netif_msg_rx_status(priv))
-               printk(KERN_DEBUG "%s: control frame\n", dev->name);
+       if (events & IEVENT_RXC)
+               netif_dbg(priv, rx_status, dev, "control frame\n");
 
        if (events & IEVENT_BABT) {
                priv->extra_stats.tx_babt++;
-               if (netif_msg_tx_err(priv))
-                       printk(KERN_DEBUG "%s: babbling TX error\n", dev->name);
+               netif_dbg(priv, tx_err, dev, "babbling TX error\n");
        }
        return IRQ_HANDLED;
 }