aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-05-09 03:39:13 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-05-09 03:39:13 -0400
commit10ee08292028d3d22d201a34ba7d24a085818cb3 (patch)
treecf3bff48a7eab154574355f00a4b4f27dc85ff11 /drivers/net/usb
parent7da4b8b7378790dd1e4af1bb7522863127fa1438 (diff)
parent44549e8f5eea4e0a41b487b63e616cb089922b99 (diff)
Merge 4.6-rc7 into tty-next
We want the pty fixes in here as well so that patches can build on it. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/net/usb')
-rw-r--r--drivers/net/usb/lan78xx.c44
-rw-r--r--drivers/net/usb/pegasus.c10
-rw-r--r--drivers/net/usb/smsc75xx.c12
-rw-r--r--drivers/net/usb/smsc95xx.c12
4 files changed, 65 insertions, 13 deletions
diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index f20890ee03f3..f64778ad9753 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -269,6 +269,7 @@ struct skb_data { /* skb->cb is one of these */
269 struct lan78xx_net *dev; 269 struct lan78xx_net *dev;
270 enum skb_state state; 270 enum skb_state state;
271 size_t length; 271 size_t length;
272 int num_of_packet;
272}; 273};
273 274
274struct usb_context { 275struct usb_context {
@@ -1803,7 +1804,34 @@ static void lan78xx_remove_mdio(struct lan78xx_net *dev)
1803 1804
1804static void lan78xx_link_status_change(struct net_device *net) 1805static void lan78xx_link_status_change(struct net_device *net)
1805{ 1806{
1806 /* nothing to do */ 1807 struct phy_device *phydev = net->phydev;
1808 int ret, temp;
1809
1810 /* At forced 100 F/H mode, chip may fail to set mode correctly
1811 * when cable is switched between long(~50+m) and short one.
1812 * As workaround, set to 10 before setting to 100
1813 * at forced 100 F/H mode.
1814 */
1815 if (!phydev->autoneg && (phydev->speed == 100)) {
1816 /* disable phy interrupt */
1817 temp = phy_read(phydev, LAN88XX_INT_MASK);
1818 temp &= ~LAN88XX_INT_MASK_MDINTPIN_EN_;
1819 ret = phy_write(phydev, LAN88XX_INT_MASK, temp);
1820
1821 temp = phy_read(phydev, MII_BMCR);
1822 temp &= ~(BMCR_SPEED100 | BMCR_SPEED1000);
1823 phy_write(phydev, MII_BMCR, temp); /* set to 10 first */
1824 temp |= BMCR_SPEED100;
1825 phy_write(phydev, MII_BMCR, temp); /* set to 100 later */
1826
1827 /* clear pending interrupt generated while workaround */
1828 temp = phy_read(phydev, LAN88XX_INT_STS);
1829
1830 /* enable phy interrupt back */
1831 temp = phy_read(phydev, LAN88XX_INT_MASK);
1832 temp |= LAN88XX_INT_MASK_MDINTPIN_EN_;
1833 ret = phy_write(phydev, LAN88XX_INT_MASK, temp);
1834 }
1807} 1835}
1808 1836
1809static int lan78xx_phy_init(struct lan78xx_net *dev) 1837static int lan78xx_phy_init(struct lan78xx_net *dev)
@@ -2464,7 +2492,7 @@ static void tx_complete(struct urb *urb)
2464 struct lan78xx_net *dev = entry->dev; 2492 struct lan78xx_net *dev = entry->dev;
2465 2493
2466 if (urb->status == 0) { 2494 if (urb->status == 0) {
2467 dev->net->stats.tx_packets++; 2495 dev->net->stats.tx_packets += entry->num_of_packet;
2468 dev->net->stats.tx_bytes += entry->length; 2496 dev->net->stats.tx_bytes += entry->length;
2469 } else { 2497 } else {
2470 dev->net->stats.tx_errors++; 2498 dev->net->stats.tx_errors++;
@@ -2681,10 +2709,11 @@ void lan78xx_skb_return(struct lan78xx_net *dev, struct sk_buff *skb)
2681 return; 2709 return;
2682 } 2710 }
2683 2711
2684 skb->protocol = eth_type_trans(skb, dev->net);
2685 dev->net->stats.rx_packets++; 2712 dev->net->stats.rx_packets++;
2686 dev->net->stats.rx_bytes += skb->len; 2713 dev->net->stats.rx_bytes += skb->len;
2687 2714
2715 skb->protocol = eth_type_trans(skb, dev->net);
2716
2688 netif_dbg(dev, rx_status, dev->net, "< rx, len %zu, type 0x%x\n", 2717 netif_dbg(dev, rx_status, dev->net, "< rx, len %zu, type 0x%x\n",
2689 skb->len + sizeof(struct ethhdr), skb->protocol); 2718 skb->len + sizeof(struct ethhdr), skb->protocol);
2690 memset(skb->cb, 0, sizeof(struct skb_data)); 2719 memset(skb->cb, 0, sizeof(struct skb_data));
@@ -2934,13 +2963,16 @@ static void lan78xx_tx_bh(struct lan78xx_net *dev)
2934 2963
2935 skb_totallen = 0; 2964 skb_totallen = 0;
2936 pkt_cnt = 0; 2965 pkt_cnt = 0;
2966 count = 0;
2967 length = 0;
2937 for (skb = tqp->next; pkt_cnt < tqp->qlen; skb = skb->next) { 2968 for (skb = tqp->next; pkt_cnt < tqp->qlen; skb = skb->next) {
2938 if (skb_is_gso(skb)) { 2969 if (skb_is_gso(skb)) {
2939 if (pkt_cnt) { 2970 if (pkt_cnt) {
2940 /* handle previous packets first */ 2971 /* handle previous packets first */
2941 break; 2972 break;
2942 } 2973 }
2943 length = skb->len; 2974 count = 1;
2975 length = skb->len - TX_OVERHEAD;
2944 skb2 = skb_dequeue(tqp); 2976 skb2 = skb_dequeue(tqp);
2945 goto gso_skb; 2977 goto gso_skb;
2946 } 2978 }
@@ -2961,14 +2993,13 @@ static void lan78xx_tx_bh(struct lan78xx_net *dev)
2961 for (count = pos = 0; count < pkt_cnt; count++) { 2993 for (count = pos = 0; count < pkt_cnt; count++) {
2962 skb2 = skb_dequeue(tqp); 2994 skb2 = skb_dequeue(tqp);
2963 if (skb2) { 2995 if (skb2) {
2996 length += (skb2->len - TX_OVERHEAD);
2964 memcpy(skb->data + pos, skb2->data, skb2->len); 2997 memcpy(skb->data + pos, skb2->data, skb2->len);
2965 pos += roundup(skb2->len, sizeof(u32)); 2998 pos += roundup(skb2->len, sizeof(u32));
2966 dev_kfree_skb(skb2); 2999 dev_kfree_skb(skb2);
2967 } 3000 }
2968 } 3001 }
2969 3002
2970 length = skb_totallen;
2971
2972gso_skb: 3003gso_skb:
2973 urb = usb_alloc_urb(0, GFP_ATOMIC); 3004 urb = usb_alloc_urb(0, GFP_ATOMIC);
2974 if (!urb) { 3005 if (!urb) {
@@ -2980,6 +3011,7 @@ gso_skb:
2980 entry->urb = urb; 3011 entry->urb = urb;
2981 entry->dev = dev; 3012 entry->dev = dev;
2982 entry->length = length; 3013 entry->length = length;
3014 entry->num_of_packet = count;
2983 3015
2984 spin_lock_irqsave(&dev->txq.lock, flags); 3016 spin_lock_irqsave(&dev->txq.lock, flags);
2985 ret = usb_autopm_get_interface_async(dev->intf); 3017 ret = usb_autopm_get_interface_async(dev->intf);
diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c
index f84080215915..82129eef7774 100644
--- a/drivers/net/usb/pegasus.c
+++ b/drivers/net/usb/pegasus.c
@@ -411,7 +411,7 @@ static int enable_net_traffic(struct net_device *dev, struct usb_device *usb)
411 int ret; 411 int ret;
412 412
413 read_mii_word(pegasus, pegasus->phy, MII_LPA, &linkpart); 413 read_mii_word(pegasus, pegasus->phy, MII_LPA, &linkpart);
414 data[0] = 0xc9; 414 data[0] = 0xc8; /* TX & RX enable, append status, no CRC */
415 data[1] = 0; 415 data[1] = 0;
416 if (linkpart & (ADVERTISE_100FULL | ADVERTISE_10FULL)) 416 if (linkpart & (ADVERTISE_100FULL | ADVERTISE_10FULL))
417 data[1] |= 0x20; /* set full duplex */ 417 data[1] |= 0x20; /* set full duplex */
@@ -497,7 +497,7 @@ static void read_bulk_callback(struct urb *urb)
497 pkt_len = buf[count - 3] << 8; 497 pkt_len = buf[count - 3] << 8;
498 pkt_len += buf[count - 4]; 498 pkt_len += buf[count - 4];
499 pkt_len &= 0xfff; 499 pkt_len &= 0xfff;
500 pkt_len -= 8; 500 pkt_len -= 4;
501 } 501 }
502 502
503 /* 503 /*
@@ -528,7 +528,7 @@ static void read_bulk_callback(struct urb *urb)
528goon: 528goon:
529 usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb, 529 usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb,
530 usb_rcvbulkpipe(pegasus->usb, 1), 530 usb_rcvbulkpipe(pegasus->usb, 1),
531 pegasus->rx_skb->data, PEGASUS_MTU + 8, 531 pegasus->rx_skb->data, PEGASUS_MTU,
532 read_bulk_callback, pegasus); 532 read_bulk_callback, pegasus);
533 rx_status = usb_submit_urb(pegasus->rx_urb, GFP_ATOMIC); 533 rx_status = usb_submit_urb(pegasus->rx_urb, GFP_ATOMIC);
534 if (rx_status == -ENODEV) 534 if (rx_status == -ENODEV)
@@ -569,7 +569,7 @@ static void rx_fixup(unsigned long data)
569 } 569 }
570 usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb, 570 usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb,
571 usb_rcvbulkpipe(pegasus->usb, 1), 571 usb_rcvbulkpipe(pegasus->usb, 1),
572 pegasus->rx_skb->data, PEGASUS_MTU + 8, 572 pegasus->rx_skb->data, PEGASUS_MTU,
573 read_bulk_callback, pegasus); 573 read_bulk_callback, pegasus);
574try_again: 574try_again:
575 status = usb_submit_urb(pegasus->rx_urb, GFP_ATOMIC); 575 status = usb_submit_urb(pegasus->rx_urb, GFP_ATOMIC);
@@ -823,7 +823,7 @@ static int pegasus_open(struct net_device *net)
823 823
824 usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb, 824 usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb,
825 usb_rcvbulkpipe(pegasus->usb, 1), 825 usb_rcvbulkpipe(pegasus->usb, 1),
826 pegasus->rx_skb->data, PEGASUS_MTU + 8, 826 pegasus->rx_skb->data, PEGASUS_MTU,
827 read_bulk_callback, pegasus); 827 read_bulk_callback, pegasus);
828 if ((res = usb_submit_urb(pegasus->rx_urb, GFP_KERNEL))) { 828 if ((res = usb_submit_urb(pegasus->rx_urb, GFP_KERNEL))) {
829 if (res == -ENODEV) 829 if (res == -ENODEV)
diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index 30033dbe6662..c369db99c005 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -29,6 +29,7 @@
29#include <linux/crc32.h> 29#include <linux/crc32.h>
30#include <linux/usb/usbnet.h> 30#include <linux/usb/usbnet.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/of_net.h>
32#include "smsc75xx.h" 33#include "smsc75xx.h"
33 34
34#define SMSC_CHIPNAME "smsc75xx" 35#define SMSC_CHIPNAME "smsc75xx"
@@ -761,6 +762,15 @@ static int smsc75xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
761 762
762static void smsc75xx_init_mac_address(struct usbnet *dev) 763static void smsc75xx_init_mac_address(struct usbnet *dev)
763{ 764{
765 const u8 *mac_addr;
766
767 /* maybe the boot loader passed the MAC address in devicetree */
768 mac_addr = of_get_mac_address(dev->udev->dev.of_node);
769 if (mac_addr) {
770 memcpy(dev->net->dev_addr, mac_addr, ETH_ALEN);
771 return;
772 }
773
764 /* try reading mac address from EEPROM */ 774 /* try reading mac address from EEPROM */
765 if (smsc75xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN, 775 if (smsc75xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN,
766 dev->net->dev_addr) == 0) { 776 dev->net->dev_addr) == 0) {
@@ -772,7 +782,7 @@ static void smsc75xx_init_mac_address(struct usbnet *dev)
772 } 782 }
773 } 783 }
774 784
775 /* no eeprom, or eeprom values are invalid. generate random MAC */ 785 /* no useful static MAC address found. generate a random one */
776 eth_hw_addr_random(dev->net); 786 eth_hw_addr_random(dev->net);
777 netif_dbg(dev, ifup, dev->net, "MAC address set to eth_random_addr\n"); 787 netif_dbg(dev, ifup, dev->net, "MAC address set to eth_random_addr\n");
778} 788}
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 66b3ab9f614e..2edc2bc6d1b9 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -29,6 +29,7 @@
29#include <linux/crc32.h> 29#include <linux/crc32.h>
30#include <linux/usb/usbnet.h> 30#include <linux/usb/usbnet.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/of_net.h>
32#include "smsc95xx.h" 33#include "smsc95xx.h"
33 34
34#define SMSC_CHIPNAME "smsc95xx" 35#define SMSC_CHIPNAME "smsc95xx"
@@ -765,6 +766,15 @@ static int smsc95xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
765 766
766static void smsc95xx_init_mac_address(struct usbnet *dev) 767static void smsc95xx_init_mac_address(struct usbnet *dev)
767{ 768{
769 const u8 *mac_addr;
770
771 /* maybe the boot loader passed the MAC address in devicetree */
772 mac_addr = of_get_mac_address(dev->udev->dev.of_node);
773 if (mac_addr) {
774 memcpy(dev->net->dev_addr, mac_addr, ETH_ALEN);
775 return;
776 }
777
768 /* try reading mac address from EEPROM */ 778 /* try reading mac address from EEPROM */
769 if (smsc95xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN, 779 if (smsc95xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN,
770 dev->net->dev_addr) == 0) { 780 dev->net->dev_addr) == 0) {
@@ -775,7 +785,7 @@ static void smsc95xx_init_mac_address(struct usbnet *dev)
775 } 785 }
776 } 786 }
777 787
778 /* no eeprom, or eeprom values are invalid. generate random MAC */ 788 /* no useful static MAC address found. generate a random one */
779 eth_hw_addr_random(dev->net); 789 eth_hw_addr_random(dev->net);
780 netif_dbg(dev, ifup, dev->net, "MAC address set to eth_random_addr\n"); 790 netif_dbg(dev, ifup, dev->net, "MAC address set to eth_random_addr\n");
781} 791}