From 3eb415d1afd0ec22d2cba33877da036f83098105 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Mon, 4 Jul 2016 14:36:01 -0700 Subject: net: r6040: Utilize phy_print_status Instead of open coding our own version utilize the library provided function. Signed-off-by: Florian Fainelli Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c index 7a7a395..12fc7cd 100644 --- a/drivers/net/ethernet/rdc/r6040.c +++ b/drivers/net/ethernet/rdc/r6040.c @@ -1001,14 +1001,8 @@ static void r6040_adjust_link(struct net_device *dev) lp->old_duplex = phydev->duplex; } - if (status_changed) { - pr_info("%s: link %s", dev->name, phydev->link ? - "UP" : "DOWN"); - if (phydev->link) - pr_cont(" - %d/%s", phydev->speed, - DUPLEX_FULL == phydev->duplex ? "full" : "half"); - pr_cont("\n"); - } + if (status_changed) + phy_print_status(phydev); } static int r6040_mii_probe(struct net_device *dev) -- cgit v0.10.2 From 7def171ddc93c504bd91ccb56b802392770621c5 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Mon, 4 Jul 2016 14:36:02 -0700 Subject: net: r6040: Increase statistics upon transmit completion r6040_xmit() is increasing transmit statistics during transmission while this may still fail, do this in r6040_tx() where we complete transmitted buffers instead. Signed-off-by: Florian Fainelli Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c index 12fc7cd..75776ee 100644 --- a/drivers/net/ethernet/rdc/r6040.c +++ b/drivers/net/ethernet/rdc/r6040.c @@ -614,6 +614,11 @@ static void r6040_tx(struct net_device *dev) if (descptr->status & DSC_OWNER_MAC) break; /* Not complete */ skb_ptr = descptr->skb_ptr; + + /* Statistic Counter */ + dev->stats.tx_packets++; + dev->stats.tx_bytes += skb_ptr->len; + pci_unmap_single(priv->pdev, le32_to_cpu(descptr->buf), skb_ptr->len, PCI_DMA_TODEVICE); /* Free buffer */ @@ -821,9 +826,6 @@ static netdev_tx_t r6040_start_xmit(struct sk_buff *skb, return NETDEV_TX_BUSY; } - /* Statistic Counter */ - dev->stats.tx_packets++; - dev->stats.tx_bytes += skb->len; /* Set TX descriptor & Transmit it */ lp->tx_free_desc--; descptr = lp->tx_insert_ptr; -- cgit v0.10.2 From a546e557d9404834159b0599a4383ff4cd3321bf Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Mon, 4 Jul 2016 14:36:03 -0700 Subject: net: r6040: Utilize skb_put_padto() Pad the SKB to the minimum length of ETH_ZLEN by using skb_put_padto() and take this operation out of the critical section since there is no need to check any HW resources before doing that. Signed-off-by: Florian Fainelli Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c index 75776ee..46ed093 100644 --- a/drivers/net/ethernet/rdc/r6040.c +++ b/drivers/net/ethernet/rdc/r6040.c @@ -815,6 +815,9 @@ static netdev_tx_t r6040_start_xmit(struct sk_buff *skb, void __iomem *ioaddr = lp->base; unsigned long flags; + if (skb_put_padto(skb, ETH_ZLEN) < 0) + return NETDEV_TX_OK; + /* Critical Section */ spin_lock_irqsave(&lp->lock, flags); @@ -829,11 +832,7 @@ static netdev_tx_t r6040_start_xmit(struct sk_buff *skb, /* Set TX descriptor & Transmit it */ lp->tx_free_desc--; descptr = lp->tx_insert_ptr; - if (skb->len < ETH_ZLEN) - descptr->len = ETH_ZLEN; - else - descptr->len = skb->len; - + descptr->len = skb->len; descptr->skb_ptr = skb; descptr->buf = cpu_to_le32(pci_map_single(lp->pdev, skb->data, skb->len, PCI_DMA_TODEVICE)); -- cgit v0.10.2 From 58e6b056b0daa8f0287061cff2989e9d5e9a9b7c Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Mon, 4 Jul 2016 14:36:04 -0700 Subject: net: r6040: Reclaim transmitted buffers in NAPI Instead of taking one interrupt per packet transmitted, re-use the same NAPI context to free transmitted buffers. Since we are no longer in hard IRQ context replace dev_kfree_skb_irq() by dev_kfree_skb(). Signed-off-by: Florian Fainelli Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c index 46ed093..4bf78f1 100644 --- a/drivers/net/ethernet/rdc/r6040.c +++ b/drivers/net/ethernet/rdc/r6040.c @@ -622,7 +622,7 @@ static void r6040_tx(struct net_device *dev) pci_unmap_single(priv->pdev, le32_to_cpu(descptr->buf), skb_ptr->len, PCI_DMA_TODEVICE); /* Free buffer */ - dev_kfree_skb_irq(skb_ptr); + dev_kfree_skb(skb_ptr); descptr->skb_ptr = NULL; /* To next descriptor */ descptr = descptr->vndescp; @@ -643,12 +643,15 @@ static int r6040_poll(struct napi_struct *napi, int budget) void __iomem *ioaddr = priv->base; int work_done; + r6040_tx(dev); + work_done = r6040_rx(dev, budget); if (work_done < budget) { napi_complete(napi); - /* Enable RX interrupt */ - iowrite16(ioread16(ioaddr + MIER) | RX_INTS, ioaddr + MIER); + /* Enable RX/TX interrupt */ + iowrite16(ioread16(ioaddr + MIER) | RX_INTS | TX_INTS, + ioaddr + MIER); } return work_done; } @@ -675,7 +678,7 @@ static irqreturn_t r6040_interrupt(int irq, void *dev_id) } /* RX interrupt request */ - if (status & RX_INTS) { + if (status & (RX_INTS | TX_INTS)) { if (status & RX_NO_DESC) { /* RX descriptor unavailable */ dev->stats.rx_dropped++; @@ -686,15 +689,11 @@ static irqreturn_t r6040_interrupt(int irq, void *dev_id) if (likely(napi_schedule_prep(&lp->napi))) { /* Mask off RX interrupt */ - misr &= ~RX_INTS; + misr &= ~(RX_INTS | TX_INTS); __napi_schedule(&lp->napi); } } - /* TX interrupt request */ - if (status & TX_INTS) - r6040_tx(dev); - /* Restore RDC MAC interrupt */ iowrite16(misr, ioaddr + MIER); -- cgit v0.10.2 From 9507ffc2acf04c9b1aa02e346225d268c07d79f0 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Mon, 4 Jul 2016 14:36:05 -0700 Subject: net: r6040: Check for skb->xmit_more Kick the transmission only if this is the last SKB to transmit or the queue is not already stopped. Signed-off-by: Florian Fainelli Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c index 4bf78f1..96b2d63 100644 --- a/drivers/net/ethernet/rdc/r6040.c +++ b/drivers/net/ethernet/rdc/r6040.c @@ -840,7 +840,8 @@ static netdev_tx_t r6040_start_xmit(struct sk_buff *skb, skb_tx_timestamp(skb); /* Trigger the MAC to check the TX descriptor */ - iowrite16(TM2TX, ioaddr + MTPR); + if (!skb->xmit_more || netif_queue_stopped(dev)) + iowrite16(TM2TX, ioaddr + MTPR); lp->tx_insert_ptr = descptr->vndescp; /* If no tx resource, stop */ -- cgit v0.10.2 From ffb5bce0bfd7f196dcfb3263596202cef7b4b92c Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Mon, 4 Jul 2016 14:36:06 -0700 Subject: net: r6040: Utilize __napi_schedule_irqoff We are already in hard IRQ context, so we can use __napi_schedule_irqoff() to save a few operations. Signed-off-by: Florian Fainelli Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c index 96b2d63..13ff800 100644 --- a/drivers/net/ethernet/rdc/r6040.c +++ b/drivers/net/ethernet/rdc/r6040.c @@ -690,7 +690,7 @@ static irqreturn_t r6040_interrupt(int irq, void *dev_id) if (likely(napi_schedule_prep(&lp->napi))) { /* Mask off RX interrupt */ misr &= ~(RX_INTS | TX_INTS); - __napi_schedule(&lp->napi); + __napi_schedule_irqoff(&lp->napi); } } -- cgit v0.10.2 From 0305efff117ddc6671f5eaf4e4fefd7418116224 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Mon, 4 Jul 2016 14:36:07 -0700 Subject: net: r6040: Utilize napi_complete_done() We maintain how much work we did in NAPI context, so provide that with napi_complete_done(). Signed-off-by: Florian Fainelli Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c index 13ff800..c0256b8 100644 --- a/drivers/net/ethernet/rdc/r6040.c +++ b/drivers/net/ethernet/rdc/r6040.c @@ -648,7 +648,7 @@ static int r6040_poll(struct napi_struct *napi, int budget) work_done = r6040_rx(dev, budget); if (work_done < budget) { - napi_complete(napi); + napi_complete_done(napi, work_done); /* Enable RX/TX interrupt */ iowrite16(ioread16(ioaddr + MIER) | RX_INTS | TX_INTS, ioaddr + MIER); -- cgit v0.10.2 From 35566e9687af6cce72eee8466dd7173780fdd671 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Mon, 4 Jul 2016 14:36:08 -0700 Subject: net: r6040: Update my email Update my email address in the driver and MAINTAINERS file. Signed-off-by: Florian Fainelli Signed-off-by: David S. Miller diff --git a/MAINTAINERS b/MAINTAINERS index 67e4a65..6374be2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9559,7 +9559,7 @@ M: Florian Fainelli S: Maintained RDC R6040 FAST ETHERNET DRIVER -M: Florian Fainelli +M: Florian Fainelli L: netdev@vger.kernel.org S: Maintained F: drivers/net/ethernet/rdc/r6040.c diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c index c0256b8..c8985cf 100644 --- a/drivers/net/ethernet/rdc/r6040.c +++ b/drivers/net/ethernet/rdc/r6040.c @@ -4,7 +4,7 @@ * Copyright (C) 2004 Sten Wang * Copyright (C) 2007 * Daniel Gimpelevich - * Copyright (C) 2007-2012 Florian Fainelli + * Copyright (C) 2007-2012 Florian Fainelli * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -162,7 +162,7 @@ MODULE_AUTHOR("Sten Wang ," "Daniel Gimpelevich ," - "Florian Fainelli "); + "Florian Fainelli "); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("RDC R6040 NAPI PCI FastEthernet driver"); MODULE_VERSION(DRV_VERSION " " DRV_RELDATE); -- cgit v0.10.2 From 9da280413a2a7e03b38c880cf3e7e0c16dd7371b Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Mon, 4 Jul 2016 14:36:09 -0700 Subject: net: r6040: Bump version and date Bump version to 0.28 and date to 4th of July 2016. Signed-off-by: Florian Fainelli Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c index c8985cf..cb29ee2 100644 --- a/drivers/net/ethernet/rdc/r6040.c +++ b/drivers/net/ethernet/rdc/r6040.c @@ -48,8 +48,8 @@ #include #define DRV_NAME "r6040" -#define DRV_VERSION "0.28" -#define DRV_RELDATE "07Oct2011" +#define DRV_VERSION "0.29" +#define DRV_RELDATE "04Jul2016" /* Time in jiffies before concluding the transmitter is hung. */ #define TX_TIMEOUT (6000 * HZ / 1000) -- cgit v0.10.2