diff options
Diffstat (limited to 'drivers/net/gianfar.c')
-rw-r--r-- | drivers/net/gianfar.c | 156 |
1 files changed, 70 insertions, 86 deletions
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index ff60b23a5b74..3321d714ca22 100644 --- a/drivers/net/gianfar.c +++ b/drivers/net/gianfar.c @@ -10,7 +10,7 @@ * Maintainer: Kumar Gala * Modifier: Sandeep Gopalpet <sandeep.kumar@freescale.com> * - * Copyright 2002-2009 Freescale Semiconductor, Inc. + * Copyright 2002-2009, 2011 Freescale Semiconductor, Inc. * Copyright 2007 MontaVista Software, Inc. * * This program is free software; you can redistribute it and/or modify it @@ -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; } @@ -476,9 +475,6 @@ static const struct net_device_ops gfar_netdev_ops = { #endif }; -unsigned int ftp_rqfpr[MAX_FILER_IDX + 1]; -unsigned int ftp_rqfcr[MAX_FILER_IDX + 1]; - void lock_rx_qs(struct gfar_private *priv) { int i = 0x0; @@ -628,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; } @@ -638,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; } @@ -658,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++) @@ -868,28 +869,28 @@ static u32 cluster_entry_per_class(struct gfar_private *priv, u32 rqfar, rqfar--; rqfcr = RQFCR_CLE | RQFCR_PID_MASK | RQFCR_CMP_EXACT; - ftp_rqfpr[rqfar] = rqfpr; - ftp_rqfcr[rqfar] = rqfcr; + priv->ftp_rqfpr[rqfar] = rqfpr; + priv->ftp_rqfcr[rqfar] = rqfcr; gfar_write_filer(priv, rqfar, rqfcr, rqfpr); rqfar--; rqfcr = RQFCR_CMP_NOMATCH; - ftp_rqfpr[rqfar] = rqfpr; - ftp_rqfcr[rqfar] = rqfcr; + priv->ftp_rqfpr[rqfar] = rqfpr; + priv->ftp_rqfcr[rqfar] = rqfcr; gfar_write_filer(priv, rqfar, rqfcr, rqfpr); rqfar--; rqfcr = RQFCR_CMP_EXACT | RQFCR_PID_PARSE | RQFCR_CLE | RQFCR_AND; rqfpr = class; - ftp_rqfcr[rqfar] = rqfcr; - ftp_rqfpr[rqfar] = rqfpr; + priv->ftp_rqfcr[rqfar] = rqfcr; + priv->ftp_rqfpr[rqfar] = rqfpr; gfar_write_filer(priv, rqfar, rqfcr, rqfpr); rqfar--; rqfcr = RQFCR_CMP_EXACT | RQFCR_PID_MASK | RQFCR_AND; rqfpr = class; - ftp_rqfcr[rqfar] = rqfcr; - ftp_rqfpr[rqfar] = rqfpr; + priv->ftp_rqfcr[rqfar] = rqfcr; + priv->ftp_rqfpr[rqfar] = rqfpr; gfar_write_filer(priv, rqfar, rqfcr, rqfpr); return rqfar; @@ -904,8 +905,8 @@ static void gfar_init_filer_table(struct gfar_private *priv) /* Default rule */ rqfcr = RQFCR_CMP_MATCH; - ftp_rqfcr[rqfar] = rqfcr; - ftp_rqfpr[rqfar] = rqfpr; + priv->ftp_rqfcr[rqfar] = rqfcr; + priv->ftp_rqfpr[rqfar] = rqfpr; gfar_write_filer(priv, rqfar, rqfcr, rqfpr); rqfar = cluster_entry_per_class(priv, rqfar, RQFPR_IPV6); @@ -921,8 +922,8 @@ static void gfar_init_filer_table(struct gfar_private *priv) /* Rest are masked rules */ rqfcr = RQFCR_CMP_NOMATCH; for (i = 0; i < rqfar; i++) { - ftp_rqfcr[i] = rqfcr; - ftp_rqfpr[i] = rqfpr; + priv->ftp_rqfcr[i] = rqfcr; + priv->ftp_rqfpr[i] = rqfpr; gfar_write_filer(priv, i, rqfcr, rqfpr); } } @@ -1151,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; @@ -1163,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; } @@ -1215,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; @@ -1858,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; } } @@ -2354,9 +2349,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; } @@ -2776,9 +2769,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++; } @@ -2981,10 +2972,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; } @@ -3189,8 +3179,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(®s->imask)); + netdev_dbg(dev, "error interrupt (ievent=0x%08x imask=0x%08x)\n", + events, gfar_read(®s->imask)); /* Update the error counters */ if (events & IEVENT_TXE) { @@ -3203,9 +3193,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++; @@ -3218,8 +3207,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++; @@ -3227,29 +3215,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(®s->rstat)); + netif_dbg(priv, rx_err, dev, "busy error (rstat: %x)\n", + gfar_read(®s->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; } |