diff options
Diffstat (limited to 'drivers/net/usb')
| -rw-r--r-- | drivers/net/usb/Kconfig | 5 | ||||
| -rw-r--r-- | drivers/net/usb/asix_devices.c | 7 | ||||
| -rw-r--r-- | drivers/net/usb/ax88172a.c | 10 | ||||
| -rw-r--r-- | drivers/net/usb/ax88179_178a.c | 4 | ||||
| -rw-r--r-- | drivers/net/usb/catc.c | 59 | ||||
| -rw-r--r-- | drivers/net/usb/cdc-phonet.c | 12 | ||||
| -rw-r--r-- | drivers/net/usb/cdc_ether.c | 53 | ||||
| -rw-r--r-- | drivers/net/usb/cdc_ncm.c | 7 | ||||
| -rw-r--r-- | drivers/net/usb/ch9200.c | 9 | ||||
| -rw-r--r-- | drivers/net/usb/cx82310_eth.c | 7 | ||||
| -rw-r--r-- | drivers/net/usb/hso.c | 2 | ||||
| -rw-r--r-- | drivers/net/usb/kalmia.c | 2 | ||||
| -rw-r--r-- | drivers/net/usb/kaweth.c | 21 | ||||
| -rw-r--r-- | drivers/net/usb/lan78xx.c | 472 | ||||
| -rw-r--r-- | drivers/net/usb/lan78xx.h | 14 | ||||
| -rw-r--r-- | drivers/net/usb/pegasus.c | 32 | ||||
| -rw-r--r-- | drivers/net/usb/qmi_wwan.c | 16 | ||||
| -rw-r--r-- | drivers/net/usb/r8152.c | 184 | ||||
| -rw-r--r-- | drivers/net/usb/rndis_host.c | 2 | ||||
| -rw-r--r-- | drivers/net/usb/rtl8150.c | 37 | ||||
| -rw-r--r-- | drivers/net/usb/sierra_net.c | 124 | ||||
| -rw-r--r-- | drivers/net/usb/smsc75xx.c | 12 | ||||
| -rw-r--r-- | drivers/net/usb/smsc95xx.c | 12 | ||||
| -rw-r--r-- | drivers/net/usb/sr9700.c | 9 | ||||
| -rw-r--r-- | drivers/net/usb/usbnet.c | 23 |
25 files changed, 785 insertions, 350 deletions
diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig index cdde59089f72..3dd490f53e48 100644 --- a/drivers/net/usb/Kconfig +++ b/drivers/net/usb/Kconfig | |||
| @@ -114,6 +114,11 @@ config USB_LAN78XX | |||
| 114 | help | 114 | help |
| 115 | This option adds support for Microchip LAN78XX based USB 2 | 115 | This option adds support for Microchip LAN78XX based USB 2 |
| 116 | & USB 3 10/100/1000 Ethernet adapters. | 116 | & USB 3 10/100/1000 Ethernet adapters. |
| 117 | LAN7800 : USB 3 to 10/100/1000 Ethernet adapter | ||
| 118 | LAN7850 : USB 2 to 10/100/1000 Ethernet adapter | ||
| 119 | LAN7801 : USB 3 to 10/100/1000 Ethernet adapter (MAC only) | ||
| 120 | |||
| 121 | Proper PHY driver is required for LAN7801. | ||
| 117 | 122 | ||
| 118 | To compile this driver as a module, choose M here: the | 123 | To compile this driver as a module, choose M here: the |
| 119 | module will be called lan78xx. | 124 | module will be called lan78xx. |
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c index dc7b6392e75a..0dd510604118 100644 --- a/drivers/net/usb/asix_devices.c +++ b/drivers/net/usb/asix_devices.c | |||
| @@ -346,7 +346,7 @@ static int ax88772_reset(struct usbnet *dev) | |||
| 346 | if (ret < 0) | 346 | if (ret < 0) |
| 347 | goto out; | 347 | goto out; |
| 348 | 348 | ||
| 349 | asix_write_medium_mode(dev, AX88772_MEDIUM_DEFAULT, 0); | 349 | ret = asix_write_medium_mode(dev, AX88772_MEDIUM_DEFAULT, 0); |
| 350 | if (ret < 0) | 350 | if (ret < 0) |
| 351 | goto out; | 351 | goto out; |
| 352 | 352 | ||
| @@ -1026,9 +1026,6 @@ static int ax88178_change_mtu(struct net_device *net, int new_mtu) | |||
| 1026 | 1026 | ||
| 1027 | netdev_dbg(dev->net, "ax88178_change_mtu() new_mtu=%d\n", new_mtu); | 1027 | netdev_dbg(dev->net, "ax88178_change_mtu() new_mtu=%d\n", new_mtu); |
| 1028 | 1028 | ||
| 1029 | if (new_mtu <= 0 || ll_mtu > 16384) | ||
| 1030 | return -EINVAL; | ||
| 1031 | |||
| 1032 | if ((ll_mtu % dev->maxpacket) == 0) | 1029 | if ((ll_mtu % dev->maxpacket) == 0) |
| 1033 | return -EDOM; | 1030 | return -EDOM; |
| 1034 | 1031 | ||
| @@ -1081,6 +1078,7 @@ static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf) | |||
| 1081 | 1078 | ||
| 1082 | dev->net->netdev_ops = &ax88178_netdev_ops; | 1079 | dev->net->netdev_ops = &ax88178_netdev_ops; |
| 1083 | dev->net->ethtool_ops = &ax88178_ethtool_ops; | 1080 | dev->net->ethtool_ops = &ax88178_ethtool_ops; |
| 1081 | dev->net->max_mtu = 16384 - (dev->net->hard_header_len + 4); | ||
| 1084 | 1082 | ||
| 1085 | /* Blink LEDS so users know driver saw dongle */ | 1083 | /* Blink LEDS so users know driver saw dongle */ |
| 1086 | asix_sw_reset(dev, 0, 0); | 1084 | asix_sw_reset(dev, 0, 0); |
| @@ -1369,6 +1367,7 @@ static struct usb_driver asix_driver = { | |||
| 1369 | .probe = usbnet_probe, | 1367 | .probe = usbnet_probe, |
| 1370 | .suspend = asix_suspend, | 1368 | .suspend = asix_suspend, |
| 1371 | .resume = asix_resume, | 1369 | .resume = asix_resume, |
| 1370 | .reset_resume = asix_resume, | ||
| 1372 | .disconnect = usbnet_disconnect, | 1371 | .disconnect = usbnet_disconnect, |
| 1373 | .supports_autosuspend = 1, | 1372 | .supports_autosuspend = 1, |
| 1374 | .disable_hub_initiated_lpm = 1, | 1373 | .disable_hub_initiated_lpm = 1, |
diff --git a/drivers/net/usb/ax88172a.c b/drivers/net/usb/ax88172a.c index 49a3bc107d05..6308386b09df 100644 --- a/drivers/net/usb/ax88172a.c +++ b/drivers/net/usb/ax88172a.c | |||
| @@ -149,14 +149,6 @@ static const struct net_device_ops ax88172a_netdev_ops = { | |||
| 149 | .ndo_set_rx_mode = asix_set_multicast, | 149 | .ndo_set_rx_mode = asix_set_multicast, |
| 150 | }; | 150 | }; |
| 151 | 151 | ||
| 152 | static int ax88172a_nway_reset(struct net_device *net) | ||
| 153 | { | ||
| 154 | if (!net->phydev) | ||
| 155 | return -ENODEV; | ||
| 156 | |||
| 157 | return phy_start_aneg(net->phydev); | ||
| 158 | } | ||
| 159 | |||
| 160 | static const struct ethtool_ops ax88172a_ethtool_ops = { | 152 | static const struct ethtool_ops ax88172a_ethtool_ops = { |
| 161 | .get_drvinfo = asix_get_drvinfo, | 153 | .get_drvinfo = asix_get_drvinfo, |
| 162 | .get_link = usbnet_get_link, | 154 | .get_link = usbnet_get_link, |
| @@ -167,7 +159,7 @@ static const struct ethtool_ops ax88172a_ethtool_ops = { | |||
| 167 | .get_eeprom_len = asix_get_eeprom_len, | 159 | .get_eeprom_len = asix_get_eeprom_len, |
| 168 | .get_eeprom = asix_get_eeprom, | 160 | .get_eeprom = asix_get_eeprom, |
| 169 | .set_eeprom = asix_set_eeprom, | 161 | .set_eeprom = asix_set_eeprom, |
| 170 | .nway_reset = ax88172a_nway_reset, | 162 | .nway_reset = phy_ethtool_nway_reset, |
| 171 | .get_link_ksettings = phy_ethtool_get_link_ksettings, | 163 | .get_link_ksettings = phy_ethtool_get_link_ksettings, |
| 172 | .set_link_ksettings = phy_ethtool_set_link_ksettings, | 164 | .set_link_ksettings = phy_ethtool_set_link_ksettings, |
| 173 | }; | 165 | }; |
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c index 8a6675d92b98..a3a7db0702d8 100644 --- a/drivers/net/usb/ax88179_178a.c +++ b/drivers/net/usb/ax88179_178a.c | |||
| @@ -907,9 +907,6 @@ static int ax88179_change_mtu(struct net_device *net, int new_mtu) | |||
| 907 | struct usbnet *dev = netdev_priv(net); | 907 | struct usbnet *dev = netdev_priv(net); |
| 908 | u16 tmp16; | 908 | u16 tmp16; |
| 909 | 909 | ||
| 910 | if (new_mtu <= 0 || new_mtu > 4088) | ||
| 911 | return -EINVAL; | ||
| 912 | |||
| 913 | net->mtu = new_mtu; | 910 | net->mtu = new_mtu; |
| 914 | dev->hard_mtu = net->mtu + net->hard_header_len; | 911 | dev->hard_mtu = net->mtu + net->hard_header_len; |
| 915 | 912 | ||
| @@ -1266,6 +1263,7 @@ static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf) | |||
| 1266 | dev->net->netdev_ops = &ax88179_netdev_ops; | 1263 | dev->net->netdev_ops = &ax88179_netdev_ops; |
| 1267 | dev->net->ethtool_ops = &ax88179_ethtool_ops; | 1264 | dev->net->ethtool_ops = &ax88179_ethtool_ops; |
| 1268 | dev->net->needed_headroom = 8; | 1265 | dev->net->needed_headroom = 8; |
| 1266 | dev->net->max_mtu = 4088; | ||
| 1269 | 1267 | ||
| 1270 | /* Initialize MII structure */ | 1268 | /* Initialize MII structure */ |
| 1271 | dev->mii.dev = dev->net; | 1269 | dev->mii.dev = dev->net; |
diff --git a/drivers/net/usb/catc.c b/drivers/net/usb/catc.c index d9ca05d3ac8e..0acc9b640419 100644 --- a/drivers/net/usb/catc.c +++ b/drivers/net/usb/catc.c | |||
| @@ -42,7 +42,7 @@ | |||
| 42 | #include <linux/crc32.h> | 42 | #include <linux/crc32.h> |
| 43 | #include <linux/bitops.h> | 43 | #include <linux/bitops.h> |
| 44 | #include <linux/gfp.h> | 44 | #include <linux/gfp.h> |
| 45 | #include <asm/uaccess.h> | 45 | #include <linux/uaccess.h> |
| 46 | 46 | ||
| 47 | #undef DEBUG | 47 | #undef DEBUG |
| 48 | 48 | ||
| @@ -761,7 +761,6 @@ static const struct net_device_ops catc_netdev_ops = { | |||
| 761 | 761 | ||
| 762 | .ndo_tx_timeout = catc_tx_timeout, | 762 | .ndo_tx_timeout = catc_tx_timeout, |
| 763 | .ndo_set_rx_mode = catc_set_multicast_list, | 763 | .ndo_set_rx_mode = catc_set_multicast_list, |
| 764 | .ndo_change_mtu = eth_change_mtu, | ||
| 765 | .ndo_set_mac_address = eth_mac_addr, | 764 | .ndo_set_mac_address = eth_mac_addr, |
| 766 | .ndo_validate_addr = eth_validate_addr, | 765 | .ndo_validate_addr = eth_validate_addr, |
| 767 | }; | 766 | }; |
| @@ -777,7 +776,7 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
| 777 | struct net_device *netdev; | 776 | struct net_device *netdev; |
| 778 | struct catc *catc; | 777 | struct catc *catc; |
| 779 | u8 broadcast[ETH_ALEN]; | 778 | u8 broadcast[ETH_ALEN]; |
| 780 | int i, pktsz; | 779 | int pktsz, ret; |
| 781 | 780 | ||
| 782 | if (usb_set_interface(usbdev, | 781 | if (usb_set_interface(usbdev, |
| 783 | intf->altsetting->desc.bInterfaceNumber, 1)) { | 782 | intf->altsetting->desc.bInterfaceNumber, 1)) { |
| @@ -812,12 +811,8 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
| 812 | if ((!catc->ctrl_urb) || (!catc->tx_urb) || | 811 | if ((!catc->ctrl_urb) || (!catc->tx_urb) || |
| 813 | (!catc->rx_urb) || (!catc->irq_urb)) { | 812 | (!catc->rx_urb) || (!catc->irq_urb)) { |
| 814 | dev_err(&intf->dev, "No free urbs available.\n"); | 813 | dev_err(&intf->dev, "No free urbs available.\n"); |
| 815 | usb_free_urb(catc->ctrl_urb); | 814 | ret = -ENOMEM; |
| 816 | usb_free_urb(catc->tx_urb); | 815 | goto fail_free; |
| 817 | usb_free_urb(catc->rx_urb); | ||
| 818 | usb_free_urb(catc->irq_urb); | ||
| 819 | free_netdev(netdev); | ||
| 820 | return -ENOMEM; | ||
| 821 | } | 816 | } |
| 822 | 817 | ||
| 823 | /* The F5U011 has the same vendor/product as the netmate but a device version of 0x130 */ | 818 | /* The F5U011 has the same vendor/product as the netmate but a device version of 0x130 */ |
| @@ -845,15 +840,24 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
| 845 | catc->irq_buf, 2, catc_irq_done, catc, 1); | 840 | catc->irq_buf, 2, catc_irq_done, catc, 1); |
| 846 | 841 | ||
| 847 | if (!catc->is_f5u011) { | 842 | if (!catc->is_f5u011) { |
| 843 | u32 *buf; | ||
| 844 | int i; | ||
| 845 | |||
| 848 | dev_dbg(dev, "Checking memory size\n"); | 846 | dev_dbg(dev, "Checking memory size\n"); |
| 849 | 847 | ||
| 850 | i = 0x12345678; | 848 | buf = kmalloc(4, GFP_KERNEL); |
| 851 | catc_write_mem(catc, 0x7a80, &i, 4); | 849 | if (!buf) { |
| 852 | i = 0x87654321; | 850 | ret = -ENOMEM; |
| 853 | catc_write_mem(catc, 0xfa80, &i, 4); | 851 | goto fail_free; |
| 854 | catc_read_mem(catc, 0x7a80, &i, 4); | 852 | } |
| 853 | |||
| 854 | *buf = 0x12345678; | ||
| 855 | catc_write_mem(catc, 0x7a80, buf, 4); | ||
| 856 | *buf = 0x87654321; | ||
| 857 | catc_write_mem(catc, 0xfa80, buf, 4); | ||
| 858 | catc_read_mem(catc, 0x7a80, buf, 4); | ||
| 855 | 859 | ||
| 856 | switch (i) { | 860 | switch (*buf) { |
| 857 | case 0x12345678: | 861 | case 0x12345678: |
| 858 | catc_set_reg(catc, TxBufCount, 8); | 862 | catc_set_reg(catc, TxBufCount, 8); |
| 859 | catc_set_reg(catc, RxBufCount, 32); | 863 | catc_set_reg(catc, RxBufCount, 32); |
| @@ -868,6 +872,8 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
| 868 | dev_dbg(dev, "32k Memory\n"); | 872 | dev_dbg(dev, "32k Memory\n"); |
| 869 | break; | 873 | break; |
| 870 | } | 874 | } |
| 875 | |||
| 876 | kfree(buf); | ||
| 871 | 877 | ||
| 872 | dev_dbg(dev, "Getting MAC from SEEROM.\n"); | 878 | dev_dbg(dev, "Getting MAC from SEEROM.\n"); |
| 873 | 879 | ||
| @@ -914,16 +920,21 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
| 914 | usb_set_intfdata(intf, catc); | 920 | usb_set_intfdata(intf, catc); |
| 915 | 921 | ||
| 916 | SET_NETDEV_DEV(netdev, &intf->dev); | 922 | SET_NETDEV_DEV(netdev, &intf->dev); |
| 917 | if (register_netdev(netdev) != 0) { | 923 | ret = register_netdev(netdev); |
| 918 | usb_set_intfdata(intf, NULL); | 924 | if (ret) |
| 919 | usb_free_urb(catc->ctrl_urb); | 925 | goto fail_clear_intfdata; |
| 920 | usb_free_urb(catc->tx_urb); | 926 | |
| 921 | usb_free_urb(catc->rx_urb); | ||
| 922 | usb_free_urb(catc->irq_urb); | ||
| 923 | free_netdev(netdev); | ||
| 924 | return -EIO; | ||
| 925 | } | ||
| 926 | return 0; | 927 | return 0; |
| 928 | |||
| 929 | fail_clear_intfdata: | ||
| 930 | usb_set_intfdata(intf, NULL); | ||
| 931 | fail_free: | ||
| 932 | usb_free_urb(catc->ctrl_urb); | ||
| 933 | usb_free_urb(catc->tx_urb); | ||
| 934 | usb_free_urb(catc->rx_urb); | ||
| 935 | usb_free_urb(catc->irq_urb); | ||
| 936 | free_netdev(netdev); | ||
| 937 | return ret; | ||
| 927 | } | 938 | } |
| 928 | 939 | ||
| 929 | static void catc_disconnect(struct usb_interface *intf) | 940 | static void catc_disconnect(struct usb_interface *intf) |
diff --git a/drivers/net/usb/cdc-phonet.c b/drivers/net/usb/cdc-phonet.c index ff2270ead2e6..eb52de8205f0 100644 --- a/drivers/net/usb/cdc-phonet.c +++ b/drivers/net/usb/cdc-phonet.c | |||
| @@ -276,21 +276,11 @@ static int usbpn_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
| 276 | return -ENOIOCTLCMD; | 276 | return -ENOIOCTLCMD; |
| 277 | } | 277 | } |
| 278 | 278 | ||
| 279 | static int usbpn_set_mtu(struct net_device *dev, int new_mtu) | ||
| 280 | { | ||
| 281 | if ((new_mtu < PHONET_MIN_MTU) || (new_mtu > PHONET_MAX_MTU)) | ||
| 282 | return -EINVAL; | ||
| 283 | |||
| 284 | dev->mtu = new_mtu; | ||
| 285 | return 0; | ||
| 286 | } | ||
| 287 | |||
| 288 | static const struct net_device_ops usbpn_ops = { | 279 | static const struct net_device_ops usbpn_ops = { |
| 289 | .ndo_open = usbpn_open, | 280 | .ndo_open = usbpn_open, |
| 290 | .ndo_stop = usbpn_close, | 281 | .ndo_stop = usbpn_close, |
| 291 | .ndo_start_xmit = usbpn_xmit, | 282 | .ndo_start_xmit = usbpn_xmit, |
| 292 | .ndo_do_ioctl = usbpn_ioctl, | 283 | .ndo_do_ioctl = usbpn_ioctl, |
| 293 | .ndo_change_mtu = usbpn_set_mtu, | ||
| 294 | }; | 284 | }; |
| 295 | 285 | ||
| 296 | static void usbpn_setup(struct net_device *dev) | 286 | static void usbpn_setup(struct net_device *dev) |
| @@ -301,6 +291,8 @@ static void usbpn_setup(struct net_device *dev) | |||
| 301 | dev->type = ARPHRD_PHONET; | 291 | dev->type = ARPHRD_PHONET; |
| 302 | dev->flags = IFF_POINTOPOINT | IFF_NOARP; | 292 | dev->flags = IFF_POINTOPOINT | IFF_NOARP; |
| 303 | dev->mtu = PHONET_MAX_MTU; | 293 | dev->mtu = PHONET_MAX_MTU; |
| 294 | dev->min_mtu = PHONET_MIN_MTU; | ||
| 295 | dev->max_mtu = PHONET_MAX_MTU; | ||
| 304 | dev->hard_header_len = 1; | 296 | dev->hard_header_len = 1; |
| 305 | dev->dev_addr[0] = PN_MEDIA_USB; | 297 | dev->dev_addr[0] = PN_MEDIA_USB; |
| 306 | dev->addr_len = 1; | 298 | dev->addr_len = 1; |
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c index dd623f674487..f3ae88fdf332 100644 --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c | |||
| @@ -466,7 +466,7 @@ static int usbnet_cdc_zte_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | |||
| 466 | * connected. This causes the link state to be incorrect. Work around this by | 466 | * connected. This causes the link state to be incorrect. Work around this by |
| 467 | * always setting the state to off, then on. | 467 | * always setting the state to off, then on. |
| 468 | */ | 468 | */ |
| 469 | void usbnet_cdc_zte_status(struct usbnet *dev, struct urb *urb) | 469 | static void usbnet_cdc_zte_status(struct usbnet *dev, struct urb *urb) |
| 470 | { | 470 | { |
| 471 | struct usb_cdc_notification *event; | 471 | struct usb_cdc_notification *event; |
| 472 | 472 | ||
| @@ -531,6 +531,8 @@ static const struct driver_info wwan_info = { | |||
| 531 | #define SAMSUNG_VENDOR_ID 0x04e8 | 531 | #define SAMSUNG_VENDOR_ID 0x04e8 |
| 532 | #define LENOVO_VENDOR_ID 0x17ef | 532 | #define LENOVO_VENDOR_ID 0x17ef |
| 533 | #define NVIDIA_VENDOR_ID 0x0955 | 533 | #define NVIDIA_VENDOR_ID 0x0955 |
| 534 | #define HP_VENDOR_ID 0x03f0 | ||
| 535 | #define MICROSOFT_VENDOR_ID 0x045e | ||
| 534 | 536 | ||
| 535 | static const struct usb_device_id products[] = { | 537 | static const struct usb_device_id products[] = { |
| 536 | /* BLACKLIST !! | 538 | /* BLACKLIST !! |
| @@ -677,6 +679,13 @@ static const struct usb_device_id products[] = { | |||
| 677 | .driver_info = 0, | 679 | .driver_info = 0, |
| 678 | }, | 680 | }, |
| 679 | 681 | ||
| 682 | /* HP lt2523 (Novatel E371) - handled by qmi_wwan */ | ||
| 683 | { | ||
| 684 | USB_DEVICE_AND_INTERFACE_INFO(HP_VENDOR_ID, 0x421d, USB_CLASS_COMM, | ||
| 685 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), | ||
| 686 | .driver_info = 0, | ||
| 687 | }, | ||
| 688 | |||
| 680 | /* AnyDATA ADU960S - handled by qmi_wwan */ | 689 | /* AnyDATA ADU960S - handled by qmi_wwan */ |
| 681 | { | 690 | { |
| 682 | USB_DEVICE_AND_INTERFACE_INFO(0x16d5, 0x650a, USB_CLASS_COMM, | 691 | USB_DEVICE_AND_INTERFACE_INFO(0x16d5, 0x650a, USB_CLASS_COMM, |
| @@ -711,6 +720,20 @@ static const struct usb_device_id products[] = { | |||
| 711 | .driver_info = 0, | 720 | .driver_info = 0, |
| 712 | }, | 721 | }, |
| 713 | 722 | ||
| 723 | /* ThinkPad USB-C Dock (based on Realtek RTL8153) */ | ||
| 724 | { | ||
| 725 | USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x3062, USB_CLASS_COMM, | ||
| 726 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), | ||
| 727 | .driver_info = 0, | ||
| 728 | }, | ||
| 729 | |||
| 730 | /* ThinkPad Thunderbolt 3 Dock (based on Realtek RTL8153) */ | ||
| 731 | { | ||
| 732 | USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x3069, USB_CLASS_COMM, | ||
| 733 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), | ||
| 734 | .driver_info = 0, | ||
| 735 | }, | ||
| 736 | |||
| 714 | /* Lenovo Thinkpad USB 3.0 Ethernet Adapters (based on Realtek RTL8153) */ | 737 | /* Lenovo Thinkpad USB 3.0 Ethernet Adapters (based on Realtek RTL8153) */ |
| 715 | { | 738 | { |
| 716 | USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x7205, USB_CLASS_COMM, | 739 | USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x7205, USB_CLASS_COMM, |
| @@ -718,6 +741,20 @@ static const struct usb_device_id products[] = { | |||
| 718 | .driver_info = 0, | 741 | .driver_info = 0, |
| 719 | }, | 742 | }, |
| 720 | 743 | ||
| 744 | /* Lenovo USB C to Ethernet Adapter (based on Realtek RTL8153) */ | ||
| 745 | { | ||
| 746 | USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x720c, USB_CLASS_COMM, | ||
| 747 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), | ||
| 748 | .driver_info = 0, | ||
| 749 | }, | ||
| 750 | |||
| 751 | /* Lenovo USB-C Travel Hub (based on Realtek RTL8153) */ | ||
| 752 | { | ||
| 753 | USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x7214, USB_CLASS_COMM, | ||
| 754 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), | ||
| 755 | .driver_info = 0, | ||
| 756 | }, | ||
| 757 | |||
| 721 | /* NVIDIA Tegra USB 3.0 Ethernet Adapters (based on Realtek RTL8153) */ | 758 | /* NVIDIA Tegra USB 3.0 Ethernet Adapters (based on Realtek RTL8153) */ |
| 722 | { | 759 | { |
| 723 | USB_DEVICE_AND_INTERFACE_INFO(NVIDIA_VENDOR_ID, 0x09ff, USB_CLASS_COMM, | 760 | USB_DEVICE_AND_INTERFACE_INFO(NVIDIA_VENDOR_ID, 0x09ff, USB_CLASS_COMM, |
| @@ -725,6 +762,20 @@ static const struct usb_device_id products[] = { | |||
| 725 | .driver_info = 0, | 762 | .driver_info = 0, |
| 726 | }, | 763 | }, |
| 727 | 764 | ||
| 765 | /* Microsoft Surface 2 dock (based on Realtek RTL8152) */ | ||
| 766 | { | ||
| 767 | USB_DEVICE_AND_INTERFACE_INFO(MICROSOFT_VENDOR_ID, 0x07ab, USB_CLASS_COMM, | ||
| 768 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), | ||
| 769 | .driver_info = 0, | ||
| 770 | }, | ||
| 771 | |||
| 772 | /* Microsoft Surface 3 dock (based on Realtek RTL8153) */ | ||
| 773 | { | ||
| 774 | USB_DEVICE_AND_INTERFACE_INFO(MICROSOFT_VENDOR_ID, 0x07c6, USB_CLASS_COMM, | ||
| 775 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), | ||
| 776 | .driver_info = 0, | ||
| 777 | }, | ||
| 778 | |||
| 728 | /* WHITELIST!!! | 779 | /* WHITELIST!!! |
| 729 | * | 780 | * |
| 730 | * CDC Ether uses two interfaces, not necessarily consecutive. | 781 | * CDC Ether uses two interfaces, not necessarily consecutive. |
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index afbfc0f656f3..f317984f7536 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c | |||
| @@ -740,10 +740,6 @@ static void cdc_ncm_free(struct cdc_ncm_ctx *ctx) | |||
| 740 | int cdc_ncm_change_mtu(struct net_device *net, int new_mtu) | 740 | int cdc_ncm_change_mtu(struct net_device *net, int new_mtu) |
| 741 | { | 741 | { |
| 742 | struct usbnet *dev = netdev_priv(net); | 742 | struct usbnet *dev = netdev_priv(net); |
| 743 | int maxmtu = cdc_ncm_max_dgram_size(dev) - cdc_ncm_eth_hlen(dev); | ||
| 744 | |||
| 745 | if (new_mtu <= 0 || new_mtu > maxmtu) | ||
| 746 | return -EINVAL; | ||
| 747 | 743 | ||
| 748 | net->mtu = new_mtu; | 744 | net->mtu = new_mtu; |
| 749 | cdc_ncm_set_dgram_size(dev, new_mtu + cdc_ncm_eth_hlen(dev)); | 745 | cdc_ncm_set_dgram_size(dev, new_mtu + cdc_ncm_eth_hlen(dev)); |
| @@ -913,6 +909,7 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_ | |||
| 913 | 909 | ||
| 914 | /* must handle MTU changes */ | 910 | /* must handle MTU changes */ |
| 915 | dev->net->netdev_ops = &cdc_ncm_netdev_ops; | 911 | dev->net->netdev_ops = &cdc_ncm_netdev_ops; |
| 912 | dev->net->max_mtu = cdc_ncm_max_dgram_size(dev) - cdc_ncm_eth_hlen(dev); | ||
| 916 | 913 | ||
| 917 | return 0; | 914 | return 0; |
| 918 | 915 | ||
| @@ -1285,7 +1282,7 @@ static void cdc_ncm_tx_timeout_start(struct cdc_ncm_ctx *ctx) | |||
| 1285 | /* start timer, if not already started */ | 1282 | /* start timer, if not already started */ |
| 1286 | if (!(hrtimer_active(&ctx->tx_timer) || atomic_read(&ctx->stop))) | 1283 | if (!(hrtimer_active(&ctx->tx_timer) || atomic_read(&ctx->stop))) |
| 1287 | hrtimer_start(&ctx->tx_timer, | 1284 | hrtimer_start(&ctx->tx_timer, |
| 1288 | ktime_set(0, ctx->timer_interval), | 1285 | ctx->timer_interval, |
| 1289 | HRTIMER_MODE_REL); | 1286 | HRTIMER_MODE_REL); |
| 1290 | } | 1287 | } |
| 1291 | 1288 | ||
diff --git a/drivers/net/usb/ch9200.c b/drivers/net/usb/ch9200.c index 8a40202c0a17..c4f1c363e24b 100644 --- a/drivers/net/usb/ch9200.c +++ b/drivers/net/usb/ch9200.c | |||
| @@ -254,14 +254,9 @@ static struct sk_buff *ch9200_tx_fixup(struct usbnet *dev, struct sk_buff *skb, | |||
| 254 | tx_overhead = 0x40; | 254 | tx_overhead = 0x40; |
| 255 | 255 | ||
| 256 | len = skb->len; | 256 | len = skb->len; |
| 257 | if (skb_headroom(skb) < tx_overhead) { | 257 | if (skb_cow_head(skb, tx_overhead)) { |
| 258 | struct sk_buff *skb2; | ||
| 259 | |||
| 260 | skb2 = skb_copy_expand(skb, tx_overhead, 0, flags); | ||
| 261 | dev_kfree_skb_any(skb); | 258 | dev_kfree_skb_any(skb); |
| 262 | skb = skb2; | 259 | return NULL; |
| 263 | if (!skb) | ||
| 264 | return NULL; | ||
| 265 | } | 260 | } |
| 266 | 261 | ||
| 267 | __skb_push(skb, tx_overhead); | 262 | __skb_push(skb, tx_overhead); |
diff --git a/drivers/net/usb/cx82310_eth.c b/drivers/net/usb/cx82310_eth.c index e221bfcee76b..947bea81d924 100644 --- a/drivers/net/usb/cx82310_eth.c +++ b/drivers/net/usb/cx82310_eth.c | |||
| @@ -293,12 +293,9 @@ static struct sk_buff *cx82310_tx_fixup(struct usbnet *dev, struct sk_buff *skb, | |||
| 293 | { | 293 | { |
| 294 | int len = skb->len; | 294 | int len = skb->len; |
| 295 | 295 | ||
| 296 | if (skb_headroom(skb) < 2) { | 296 | if (skb_cow_head(skb, 2)) { |
| 297 | struct sk_buff *skb2 = skb_copy_expand(skb, 2, 0, flags); | ||
| 298 | dev_kfree_skb_any(skb); | 297 | dev_kfree_skb_any(skb); |
| 299 | skb = skb2; | 298 | return NULL; |
| 300 | if (!skb) | ||
| 301 | return NULL; | ||
| 302 | } | 299 | } |
| 303 | skb_push(skb, 2); | 300 | skb_push(skb, 2); |
| 304 | 301 | ||
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index e7b516342678..4f2e8141dbe2 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c | |||
| @@ -52,7 +52,7 @@ | |||
| 52 | 52 | ||
| 53 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 53 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 54 | 54 | ||
| 55 | #include <linux/sched.h> | 55 | #include <linux/sched/signal.h> |
| 56 | #include <linux/slab.h> | 56 | #include <linux/slab.h> |
| 57 | #include <linux/init.h> | 57 | #include <linux/init.h> |
| 58 | #include <linux/delay.h> | 58 | #include <linux/delay.h> |
diff --git a/drivers/net/usb/kalmia.c b/drivers/net/usb/kalmia.c index 3e37724d30ae..8aefb282c862 100644 --- a/drivers/net/usb/kalmia.c +++ b/drivers/net/usb/kalmia.c | |||
| @@ -343,7 +343,7 @@ static const struct driver_info kalmia_info = { | |||
| 343 | static const struct usb_device_id products[] = { | 343 | static const struct usb_device_id products[] = { |
| 344 | /* The unswitched USB ID, to get the module auto loaded: */ | 344 | /* The unswitched USB ID, to get the module auto loaded: */ |
| 345 | { USB_DEVICE(0x04e8, 0x689a) }, | 345 | { USB_DEVICE(0x04e8, 0x689a) }, |
| 346 | /* The stick swithed into modem (by e.g. usb_modeswitch): */ | 346 | /* The stick switched into modem (by e.g. usb_modeswitch): */ |
| 347 | { USB_DEVICE(0x04e8, 0x6889), | 347 | { USB_DEVICE(0x04e8, 0x6889), |
| 348 | .driver_info = (unsigned long) &kalmia_info, }, | 348 | .driver_info = (unsigned long) &kalmia_info, }, |
| 349 | { /* EMPTY == end of list */} }; | 349 | { /* EMPTY == end of list */} }; |
diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c index 66b34ddbe216..2a2c3edb6bad 100644 --- a/drivers/net/usb/kaweth.c +++ b/drivers/net/usb/kaweth.c | |||
| @@ -54,7 +54,7 @@ | |||
| 54 | #include <linux/dma-mapping.h> | 54 | #include <linux/dma-mapping.h> |
| 55 | #include <linux/wait.h> | 55 | #include <linux/wait.h> |
| 56 | #include <linux/firmware.h> | 56 | #include <linux/firmware.h> |
| 57 | #include <asm/uaccess.h> | 57 | #include <linux/uaccess.h> |
| 58 | #include <asm/byteorder.h> | 58 | #include <asm/byteorder.h> |
| 59 | 59 | ||
| 60 | #undef DEBUG | 60 | #undef DEBUG |
| @@ -803,18 +803,12 @@ static netdev_tx_t kaweth_start_xmit(struct sk_buff *skb, | |||
| 803 | } | 803 | } |
| 804 | 804 | ||
| 805 | /* We now decide whether we can put our special header into the sk_buff */ | 805 | /* We now decide whether we can put our special header into the sk_buff */ |
| 806 | if (skb_cloned(skb) || skb_headroom(skb) < 2) { | 806 | if (skb_cow_head(skb, 2)) { |
| 807 | /* no such luck - we make our own */ | 807 | kaweth->stats.tx_errors++; |
| 808 | struct sk_buff *copied_skb; | 808 | netif_start_queue(net); |
| 809 | copied_skb = skb_copy_expand(skb, 2, 0, GFP_ATOMIC); | 809 | spin_unlock_irq(&kaweth->device_lock); |
| 810 | dev_kfree_skb_irq(skb); | 810 | dev_kfree_skb_any(skb); |
| 811 | skb = copied_skb; | 811 | return NETDEV_TX_OK; |
| 812 | if (!copied_skb) { | ||
| 813 | kaweth->stats.tx_errors++; | ||
| 814 | netif_start_queue(net); | ||
| 815 | spin_unlock_irq(&kaweth->device_lock); | ||
| 816 | return NETDEV_TX_OK; | ||
| 817 | } | ||
| 818 | } | 812 | } |
| 819 | 813 | ||
| 820 | private_header = (__le16 *)__skb_push(skb, 2); | 814 | private_header = (__le16 *)__skb_push(skb, 2); |
| @@ -982,7 +976,6 @@ static const struct net_device_ops kaweth_netdev_ops = { | |||
| 982 | .ndo_tx_timeout = kaweth_tx_timeout, | 976 | .ndo_tx_timeout = kaweth_tx_timeout, |
| 983 | .ndo_set_rx_mode = kaweth_set_rx_mode, | 977 | .ndo_set_rx_mode = kaweth_set_rx_mode, |
| 984 | .ndo_get_stats = kaweth_netdev_stats, | 978 | .ndo_get_stats = kaweth_netdev_stats, |
| 985 | .ndo_change_mtu = eth_change_mtu, | ||
| 986 | .ndo_set_mac_address = eth_mac_addr, | 979 | .ndo_set_mac_address = eth_mac_addr, |
| 987 | .ndo_validate_addr = eth_validate_addr, | 980 | .ndo_validate_addr = eth_validate_addr, |
| 988 | }; | 981 | }; |
diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index f33460cec79f..636f48f19d1e 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c | |||
| @@ -30,13 +30,18 @@ | |||
| 30 | #include <linux/ipv6.h> | 30 | #include <linux/ipv6.h> |
| 31 | #include <linux/mdio.h> | 31 | #include <linux/mdio.h> |
| 32 | #include <net/ip6_checksum.h> | 32 | #include <net/ip6_checksum.h> |
| 33 | #include <linux/interrupt.h> | ||
| 34 | #include <linux/irqdomain.h> | ||
| 35 | #include <linux/irq.h> | ||
| 36 | #include <linux/irqchip/chained_irq.h> | ||
| 33 | #include <linux/microchipphy.h> | 37 | #include <linux/microchipphy.h> |
| 38 | #include <linux/phy.h> | ||
| 34 | #include "lan78xx.h" | 39 | #include "lan78xx.h" |
| 35 | 40 | ||
| 36 | #define DRIVER_AUTHOR "WOOJUNG HUH <woojung.huh@microchip.com>" | 41 | #define DRIVER_AUTHOR "WOOJUNG HUH <woojung.huh@microchip.com>" |
| 37 | #define DRIVER_DESC "LAN78XX USB 3.0 Gigabit Ethernet Devices" | 42 | #define DRIVER_DESC "LAN78XX USB 3.0 Gigabit Ethernet Devices" |
| 38 | #define DRIVER_NAME "lan78xx" | 43 | #define DRIVER_NAME "lan78xx" |
| 39 | #define DRIVER_VERSION "1.0.4" | 44 | #define DRIVER_VERSION "1.0.6" |
| 40 | 45 | ||
| 41 | #define TX_TIMEOUT_JIFFIES (5 * HZ) | 46 | #define TX_TIMEOUT_JIFFIES (5 * HZ) |
| 42 | #define THROTTLE_JIFFIES (HZ / 8) | 47 | #define THROTTLE_JIFFIES (HZ / 8) |
| @@ -63,6 +68,7 @@ | |||
| 63 | #define LAN78XX_USB_VENDOR_ID (0x0424) | 68 | #define LAN78XX_USB_VENDOR_ID (0x0424) |
| 64 | #define LAN7800_USB_PRODUCT_ID (0x7800) | 69 | #define LAN7800_USB_PRODUCT_ID (0x7800) |
| 65 | #define LAN7850_USB_PRODUCT_ID (0x7850) | 70 | #define LAN7850_USB_PRODUCT_ID (0x7850) |
| 71 | #define LAN7801_USB_PRODUCT_ID (0x7801) | ||
| 66 | #define LAN78XX_EEPROM_MAGIC (0x78A5) | 72 | #define LAN78XX_EEPROM_MAGIC (0x78A5) |
| 67 | #define LAN78XX_OTP_MAGIC (0x78F3) | 73 | #define LAN78XX_OTP_MAGIC (0x78F3) |
| 68 | 74 | ||
| @@ -89,6 +95,38 @@ | |||
| 89 | /* statistic update interval (mSec) */ | 95 | /* statistic update interval (mSec) */ |
| 90 | #define STAT_UPDATE_TIMER (1 * 1000) | 96 | #define STAT_UPDATE_TIMER (1 * 1000) |
| 91 | 97 | ||
| 98 | /* defines interrupts from interrupt EP */ | ||
| 99 | #define MAX_INT_EP (32) | ||
| 100 | #define INT_EP_INTEP (31) | ||
| 101 | #define INT_EP_OTP_WR_DONE (28) | ||
| 102 | #define INT_EP_EEE_TX_LPI_START (26) | ||
| 103 | #define INT_EP_EEE_TX_LPI_STOP (25) | ||
| 104 | #define INT_EP_EEE_RX_LPI (24) | ||
| 105 | #define INT_EP_MAC_RESET_TIMEOUT (23) | ||
| 106 | #define INT_EP_RDFO (22) | ||
| 107 | #define INT_EP_TXE (21) | ||
| 108 | #define INT_EP_USB_STATUS (20) | ||
| 109 | #define INT_EP_TX_DIS (19) | ||
| 110 | #define INT_EP_RX_DIS (18) | ||
| 111 | #define INT_EP_PHY (17) | ||
| 112 | #define INT_EP_DP (16) | ||
| 113 | #define INT_EP_MAC_ERR (15) | ||
| 114 | #define INT_EP_TDFU (14) | ||
| 115 | #define INT_EP_TDFO (13) | ||
| 116 | #define INT_EP_UTX (12) | ||
| 117 | #define INT_EP_GPIO_11 (11) | ||
| 118 | #define INT_EP_GPIO_10 (10) | ||
| 119 | #define INT_EP_GPIO_9 (9) | ||
| 120 | #define INT_EP_GPIO_8 (8) | ||
| 121 | #define INT_EP_GPIO_7 (7) | ||
| 122 | #define INT_EP_GPIO_6 (6) | ||
| 123 | #define INT_EP_GPIO_5 (5) | ||
| 124 | #define INT_EP_GPIO_4 (4) | ||
| 125 | #define INT_EP_GPIO_3 (3) | ||
| 126 | #define INT_EP_GPIO_2 (2) | ||
| 127 | #define INT_EP_GPIO_1 (1) | ||
| 128 | #define INT_EP_GPIO_0 (0) | ||
| 129 | |||
| 92 | static const char lan78xx_gstrings[][ETH_GSTRING_LEN] = { | 130 | static const char lan78xx_gstrings[][ETH_GSTRING_LEN] = { |
| 93 | "RX FCS Errors", | 131 | "RX FCS Errors", |
| 94 | "RX Alignment Errors", | 132 | "RX Alignment Errors", |
| @@ -296,6 +334,15 @@ struct statstage { | |||
| 296 | struct lan78xx_statstage64 curr_stat; | 334 | struct lan78xx_statstage64 curr_stat; |
| 297 | }; | 335 | }; |
| 298 | 336 | ||
| 337 | struct irq_domain_data { | ||
| 338 | struct irq_domain *irqdomain; | ||
| 339 | unsigned int phyirq; | ||
| 340 | struct irq_chip *irqchip; | ||
| 341 | irq_flow_handler_t irq_handler; | ||
| 342 | u32 irqenable; | ||
| 343 | struct mutex irq_lock; /* for irq bus access */ | ||
| 344 | }; | ||
| 345 | |||
| 299 | struct lan78xx_net { | 346 | struct lan78xx_net { |
| 300 | struct net_device *net; | 347 | struct net_device *net; |
| 301 | struct usb_device *udev; | 348 | struct usb_device *udev; |
| @@ -345,14 +392,21 @@ struct lan78xx_net { | |||
| 345 | u32 chipid; | 392 | u32 chipid; |
| 346 | u32 chiprev; | 393 | u32 chiprev; |
| 347 | struct mii_bus *mdiobus; | 394 | struct mii_bus *mdiobus; |
| 395 | phy_interface_t interface; | ||
| 348 | 396 | ||
| 349 | int fc_autoneg; | 397 | int fc_autoneg; |
| 350 | u8 fc_request_control; | 398 | u8 fc_request_control; |
| 351 | 399 | ||
| 352 | int delta; | 400 | int delta; |
| 353 | struct statstage stats; | 401 | struct statstage stats; |
| 402 | |||
| 403 | struct irq_domain_data domain_data; | ||
| 354 | }; | 404 | }; |
| 355 | 405 | ||
| 406 | /* define external phy id */ | ||
| 407 | #define PHY_LAN8835 (0x0007C130) | ||
| 408 | #define PHY_KSZ9031RNX (0x00221620) | ||
| 409 | |||
| 356 | /* use ethtool to change the level for any given device */ | 410 | /* use ethtool to change the level for any given device */ |
| 357 | static int msg_level = -1; | 411 | static int msg_level = -1; |
| 358 | module_param(msg_level, int, 0); | 412 | module_param(msg_level, int, 0); |
| @@ -1092,15 +1146,10 @@ static int lan78xx_update_flowcontrol(struct lan78xx_net *dev, u8 duplex, | |||
| 1092 | static int lan78xx_link_reset(struct lan78xx_net *dev) | 1146 | static int lan78xx_link_reset(struct lan78xx_net *dev) |
| 1093 | { | 1147 | { |
| 1094 | struct phy_device *phydev = dev->net->phydev; | 1148 | struct phy_device *phydev = dev->net->phydev; |
| 1095 | struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; | 1149 | struct ethtool_link_ksettings ecmd; |
| 1096 | int ladv, radv, ret; | 1150 | int ladv, radv, ret; |
| 1097 | u32 buf; | 1151 | u32 buf; |
| 1098 | 1152 | ||
| 1099 | /* clear PHY interrupt status */ | ||
| 1100 | ret = phy_read(phydev, LAN88XX_INT_STS); | ||
| 1101 | if (unlikely(ret < 0)) | ||
| 1102 | return -EIO; | ||
| 1103 | |||
| 1104 | /* clear LAN78xx interrupt status */ | 1153 | /* clear LAN78xx interrupt status */ |
| 1105 | ret = lan78xx_write_reg(dev, INT_STS, INT_STS_PHY_INT_); | 1154 | ret = lan78xx_write_reg(dev, INT_STS, INT_STS_PHY_INT_); |
| 1106 | if (unlikely(ret < 0)) | 1155 | if (unlikely(ret < 0)) |
| @@ -1120,18 +1169,14 @@ static int lan78xx_link_reset(struct lan78xx_net *dev) | |||
| 1120 | if (unlikely(ret < 0)) | 1169 | if (unlikely(ret < 0)) |
| 1121 | return -EIO; | 1170 | return -EIO; |
| 1122 | 1171 | ||
| 1123 | phy_mac_interrupt(phydev, 0); | ||
| 1124 | |||
| 1125 | del_timer(&dev->stat_monitor); | 1172 | del_timer(&dev->stat_monitor); |
| 1126 | } else if (phydev->link && !dev->link_on) { | 1173 | } else if (phydev->link && !dev->link_on) { |
| 1127 | dev->link_on = true; | 1174 | dev->link_on = true; |
| 1128 | 1175 | ||
| 1129 | phy_ethtool_gset(phydev, &ecmd); | 1176 | phy_ethtool_ksettings_get(phydev, &ecmd); |
| 1130 | |||
| 1131 | ret = phy_read(phydev, LAN88XX_INT_STS); | ||
| 1132 | 1177 | ||
| 1133 | if (dev->udev->speed == USB_SPEED_SUPER) { | 1178 | if (dev->udev->speed == USB_SPEED_SUPER) { |
| 1134 | if (ethtool_cmd_speed(&ecmd) == 1000) { | 1179 | if (ecmd.base.speed == 1000) { |
| 1135 | /* disable U2 */ | 1180 | /* disable U2 */ |
| 1136 | ret = lan78xx_read_reg(dev, USB_CFG1, &buf); | 1181 | ret = lan78xx_read_reg(dev, USB_CFG1, &buf); |
| 1137 | buf &= ~USB_CFG1_DEV_U2_INIT_EN_; | 1182 | buf &= ~USB_CFG1_DEV_U2_INIT_EN_; |
| @@ -1159,10 +1204,10 @@ static int lan78xx_link_reset(struct lan78xx_net *dev) | |||
| 1159 | 1204 | ||
| 1160 | netif_dbg(dev, link, dev->net, | 1205 | netif_dbg(dev, link, dev->net, |
| 1161 | "speed: %u duplex: %d anadv: 0x%04x anlpa: 0x%04x", | 1206 | "speed: %u duplex: %d anadv: 0x%04x anlpa: 0x%04x", |
| 1162 | ethtool_cmd_speed(&ecmd), ecmd.duplex, ladv, radv); | 1207 | ecmd.base.speed, ecmd.base.duplex, ladv, radv); |
| 1163 | 1208 | ||
| 1164 | ret = lan78xx_update_flowcontrol(dev, ecmd.duplex, ladv, radv); | 1209 | ret = lan78xx_update_flowcontrol(dev, ecmd.base.duplex, ladv, |
| 1165 | phy_mac_interrupt(phydev, 1); | 1210 | radv); |
| 1166 | 1211 | ||
| 1167 | if (!timer_pending(&dev->stat_monitor)) { | 1212 | if (!timer_pending(&dev->stat_monitor)) { |
| 1168 | dev->delta = 1; | 1213 | dev->delta = 1; |
| @@ -1201,7 +1246,10 @@ static void lan78xx_status(struct lan78xx_net *dev, struct urb *urb) | |||
| 1201 | 1246 | ||
| 1202 | if (intdata & INT_ENP_PHY_INT) { | 1247 | if (intdata & INT_ENP_PHY_INT) { |
| 1203 | netif_dbg(dev, link, dev->net, "PHY INTR: 0x%08x\n", intdata); | 1248 | netif_dbg(dev, link, dev->net, "PHY INTR: 0x%08x\n", intdata); |
| 1204 | lan78xx_defer_kevent(dev, EVENT_LINK_RESET); | 1249 | lan78xx_defer_kevent(dev, EVENT_LINK_RESET); |
| 1250 | |||
| 1251 | if (dev->domain_data.phyirq > 0) | ||
| 1252 | generic_handle_irq(dev->domain_data.phyirq); | ||
| 1205 | } else | 1253 | } else |
| 1206 | netdev_warn(dev->net, | 1254 | netdev_warn(dev->net, |
| 1207 | "unexpected interrupt: 0x%08x\n", intdata); | 1255 | "unexpected interrupt: 0x%08x\n", intdata); |
| @@ -1406,11 +1454,6 @@ static u32 lan78xx_get_link(struct net_device *net) | |||
| 1406 | return net->phydev->link; | 1454 | return net->phydev->link; |
| 1407 | } | 1455 | } |
| 1408 | 1456 | ||
| 1409 | static int lan78xx_nway_reset(struct net_device *net) | ||
| 1410 | { | ||
| 1411 | return phy_start_aneg(net->phydev); | ||
| 1412 | } | ||
| 1413 | |||
| 1414 | static void lan78xx_get_drvinfo(struct net_device *net, | 1457 | static void lan78xx_get_drvinfo(struct net_device *net, |
| 1415 | struct ethtool_drvinfo *info) | 1458 | struct ethtool_drvinfo *info) |
| 1416 | { | 1459 | { |
| @@ -1435,88 +1478,26 @@ static void lan78xx_set_msglevel(struct net_device *net, u32 level) | |||
| 1435 | dev->msg_enable = level; | 1478 | dev->msg_enable = level; |
| 1436 | } | 1479 | } |
| 1437 | 1480 | ||
| 1438 | static int lan78xx_get_mdix_status(struct net_device *net) | 1481 | static int lan78xx_get_link_ksettings(struct net_device *net, |
| 1439 | { | 1482 | struct ethtool_link_ksettings *cmd) |
| 1440 | struct phy_device *phydev = net->phydev; | ||
| 1441 | int buf; | ||
| 1442 | |||
| 1443 | phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS, LAN88XX_EXT_PAGE_SPACE_1); | ||
| 1444 | buf = phy_read(phydev, LAN88XX_EXT_MODE_CTRL); | ||
| 1445 | phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS, LAN88XX_EXT_PAGE_SPACE_0); | ||
| 1446 | |||
| 1447 | return buf; | ||
| 1448 | } | ||
| 1449 | |||
| 1450 | static void lan78xx_set_mdix_status(struct net_device *net, __u8 mdix_ctrl) | ||
| 1451 | { | ||
| 1452 | struct lan78xx_net *dev = netdev_priv(net); | ||
| 1453 | struct phy_device *phydev = net->phydev; | ||
| 1454 | int buf; | ||
| 1455 | |||
| 1456 | if (mdix_ctrl == ETH_TP_MDI) { | ||
| 1457 | phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS, | ||
| 1458 | LAN88XX_EXT_PAGE_SPACE_1); | ||
| 1459 | buf = phy_read(phydev, LAN88XX_EXT_MODE_CTRL); | ||
| 1460 | buf &= ~LAN88XX_EXT_MODE_CTRL_MDIX_MASK_; | ||
| 1461 | phy_write(phydev, LAN88XX_EXT_MODE_CTRL, | ||
| 1462 | buf | LAN88XX_EXT_MODE_CTRL_MDI_); | ||
| 1463 | phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS, | ||
| 1464 | LAN88XX_EXT_PAGE_SPACE_0); | ||
| 1465 | } else if (mdix_ctrl == ETH_TP_MDI_X) { | ||
| 1466 | phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS, | ||
| 1467 | LAN88XX_EXT_PAGE_SPACE_1); | ||
| 1468 | buf = phy_read(phydev, LAN88XX_EXT_MODE_CTRL); | ||
| 1469 | buf &= ~LAN88XX_EXT_MODE_CTRL_MDIX_MASK_; | ||
| 1470 | phy_write(phydev, LAN88XX_EXT_MODE_CTRL, | ||
| 1471 | buf | LAN88XX_EXT_MODE_CTRL_MDI_X_); | ||
| 1472 | phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS, | ||
| 1473 | LAN88XX_EXT_PAGE_SPACE_0); | ||
| 1474 | } else if (mdix_ctrl == ETH_TP_MDI_AUTO) { | ||
| 1475 | phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS, | ||
| 1476 | LAN88XX_EXT_PAGE_SPACE_1); | ||
| 1477 | buf = phy_read(phydev, LAN88XX_EXT_MODE_CTRL); | ||
| 1478 | buf &= ~LAN88XX_EXT_MODE_CTRL_MDIX_MASK_; | ||
| 1479 | phy_write(phydev, LAN88XX_EXT_MODE_CTRL, | ||
| 1480 | buf | LAN88XX_EXT_MODE_CTRL_AUTO_MDIX_); | ||
| 1481 | phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS, | ||
| 1482 | LAN88XX_EXT_PAGE_SPACE_0); | ||
| 1483 | } | ||
| 1484 | dev->mdix_ctrl = mdix_ctrl; | ||
| 1485 | } | ||
| 1486 | |||
| 1487 | static int lan78xx_get_settings(struct net_device *net, struct ethtool_cmd *cmd) | ||
| 1488 | { | 1483 | { |
| 1489 | struct lan78xx_net *dev = netdev_priv(net); | 1484 | struct lan78xx_net *dev = netdev_priv(net); |
| 1490 | struct phy_device *phydev = net->phydev; | 1485 | struct phy_device *phydev = net->phydev; |
| 1491 | int ret; | 1486 | int ret; |
| 1492 | int buf; | ||
| 1493 | 1487 | ||
| 1494 | ret = usb_autopm_get_interface(dev->intf); | 1488 | ret = usb_autopm_get_interface(dev->intf); |
| 1495 | if (ret < 0) | 1489 | if (ret < 0) |
| 1496 | return ret; | 1490 | return ret; |
| 1497 | 1491 | ||
| 1498 | ret = phy_ethtool_gset(phydev, cmd); | 1492 | ret = phy_ethtool_ksettings_get(phydev, cmd); |
| 1499 | |||
| 1500 | buf = lan78xx_get_mdix_status(net); | ||
| 1501 | |||
| 1502 | buf &= LAN88XX_EXT_MODE_CTRL_MDIX_MASK_; | ||
| 1503 | if (buf == LAN88XX_EXT_MODE_CTRL_AUTO_MDIX_) { | ||
| 1504 | cmd->eth_tp_mdix = ETH_TP_MDI_AUTO; | ||
| 1505 | cmd->eth_tp_mdix_ctrl = ETH_TP_MDI_AUTO; | ||
| 1506 | } else if (buf == LAN88XX_EXT_MODE_CTRL_MDI_) { | ||
| 1507 | cmd->eth_tp_mdix = ETH_TP_MDI; | ||
| 1508 | cmd->eth_tp_mdix_ctrl = ETH_TP_MDI; | ||
| 1509 | } else if (buf == LAN88XX_EXT_MODE_CTRL_MDI_X_) { | ||
| 1510 | cmd->eth_tp_mdix = ETH_TP_MDI_X; | ||
| 1511 | cmd->eth_tp_mdix_ctrl = ETH_TP_MDI_X; | ||
| 1512 | } | ||
| 1513 | 1493 | ||
| 1514 | usb_autopm_put_interface(dev->intf); | 1494 | usb_autopm_put_interface(dev->intf); |
| 1515 | 1495 | ||
| 1516 | return ret; | 1496 | return ret; |
| 1517 | } | 1497 | } |
| 1518 | 1498 | ||
| 1519 | static int lan78xx_set_settings(struct net_device *net, struct ethtool_cmd *cmd) | 1499 | static int lan78xx_set_link_ksettings(struct net_device *net, |
| 1500 | const struct ethtool_link_ksettings *cmd) | ||
| 1520 | { | 1501 | { |
| 1521 | struct lan78xx_net *dev = netdev_priv(net); | 1502 | struct lan78xx_net *dev = netdev_priv(net); |
| 1522 | struct phy_device *phydev = net->phydev; | 1503 | struct phy_device *phydev = net->phydev; |
| @@ -1527,14 +1508,10 @@ static int lan78xx_set_settings(struct net_device *net, struct ethtool_cmd *cmd) | |||
| 1527 | if (ret < 0) | 1508 | if (ret < 0) |
| 1528 | return ret; | 1509 | return ret; |
| 1529 | 1510 | ||
| 1530 | if (dev->mdix_ctrl != cmd->eth_tp_mdix_ctrl) { | ||
| 1531 | lan78xx_set_mdix_status(net, cmd->eth_tp_mdix_ctrl); | ||
| 1532 | } | ||
| 1533 | |||
| 1534 | /* change speed & duplex */ | 1511 | /* change speed & duplex */ |
| 1535 | ret = phy_ethtool_sset(phydev, cmd); | 1512 | ret = phy_ethtool_ksettings_set(phydev, cmd); |
| 1536 | 1513 | ||
| 1537 | if (!cmd->autoneg) { | 1514 | if (!cmd->base.autoneg) { |
| 1538 | /* force link down */ | 1515 | /* force link down */ |
| 1539 | temp = phy_read(phydev, MII_BMCR); | 1516 | temp = phy_read(phydev, MII_BMCR); |
| 1540 | phy_write(phydev, MII_BMCR, temp | BMCR_LOOPBACK); | 1517 | phy_write(phydev, MII_BMCR, temp | BMCR_LOOPBACK); |
| @@ -1552,9 +1529,9 @@ static void lan78xx_get_pause(struct net_device *net, | |||
| 1552 | { | 1529 | { |
| 1553 | struct lan78xx_net *dev = netdev_priv(net); | 1530 | struct lan78xx_net *dev = netdev_priv(net); |
| 1554 | struct phy_device *phydev = net->phydev; | 1531 | struct phy_device *phydev = net->phydev; |
| 1555 | struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; | 1532 | struct ethtool_link_ksettings ecmd; |
| 1556 | 1533 | ||
| 1557 | phy_ethtool_gset(phydev, &ecmd); | 1534 | phy_ethtool_ksettings_get(phydev, &ecmd); |
| 1558 | 1535 | ||
| 1559 | pause->autoneg = dev->fc_autoneg; | 1536 | pause->autoneg = dev->fc_autoneg; |
| 1560 | 1537 | ||
| @@ -1570,12 +1547,12 @@ static int lan78xx_set_pause(struct net_device *net, | |||
| 1570 | { | 1547 | { |
| 1571 | struct lan78xx_net *dev = netdev_priv(net); | 1548 | struct lan78xx_net *dev = netdev_priv(net); |
| 1572 | struct phy_device *phydev = net->phydev; | 1549 | struct phy_device *phydev = net->phydev; |
| 1573 | struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; | 1550 | struct ethtool_link_ksettings ecmd; |
| 1574 | int ret; | 1551 | int ret; |
| 1575 | 1552 | ||
| 1576 | phy_ethtool_gset(phydev, &ecmd); | 1553 | phy_ethtool_ksettings_get(phydev, &ecmd); |
| 1577 | 1554 | ||
| 1578 | if (pause->autoneg && !ecmd.autoneg) { | 1555 | if (pause->autoneg && !ecmd.base.autoneg) { |
| 1579 | ret = -EINVAL; | 1556 | ret = -EINVAL; |
| 1580 | goto exit; | 1557 | goto exit; |
| 1581 | } | 1558 | } |
| @@ -1587,13 +1564,21 @@ static int lan78xx_set_pause(struct net_device *net, | |||
| 1587 | if (pause->tx_pause) | 1564 | if (pause->tx_pause) |
| 1588 | dev->fc_request_control |= FLOW_CTRL_TX; | 1565 | dev->fc_request_control |= FLOW_CTRL_TX; |
| 1589 | 1566 | ||
| 1590 | if (ecmd.autoneg) { | 1567 | if (ecmd.base.autoneg) { |
| 1591 | u32 mii_adv; | 1568 | u32 mii_adv; |
| 1569 | u32 advertising; | ||
| 1570 | |||
| 1571 | ethtool_convert_link_mode_to_legacy_u32( | ||
| 1572 | &advertising, ecmd.link_modes.advertising); | ||
| 1592 | 1573 | ||
| 1593 | ecmd.advertising &= ~(ADVERTISED_Pause | ADVERTISED_Asym_Pause); | 1574 | advertising &= ~(ADVERTISED_Pause | ADVERTISED_Asym_Pause); |
| 1594 | mii_adv = (u32)mii_advertise_flowctrl(dev->fc_request_control); | 1575 | mii_adv = (u32)mii_advertise_flowctrl(dev->fc_request_control); |
| 1595 | ecmd.advertising |= mii_adv_to_ethtool_adv_t(mii_adv); | 1576 | advertising |= mii_adv_to_ethtool_adv_t(mii_adv); |
| 1596 | phy_ethtool_sset(phydev, &ecmd); | 1577 | |
| 1578 | ethtool_convert_legacy_u32_to_link_mode( | ||
| 1579 | ecmd.link_modes.advertising, advertising); | ||
| 1580 | |||
| 1581 | phy_ethtool_ksettings_set(phydev, &ecmd); | ||
| 1597 | } | 1582 | } |
| 1598 | 1583 | ||
| 1599 | dev->fc_autoneg = pause->autoneg; | 1584 | dev->fc_autoneg = pause->autoneg; |
| @@ -1605,12 +1590,10 @@ exit: | |||
| 1605 | 1590 | ||
| 1606 | static const struct ethtool_ops lan78xx_ethtool_ops = { | 1591 | static const struct ethtool_ops lan78xx_ethtool_ops = { |
| 1607 | .get_link = lan78xx_get_link, | 1592 | .get_link = lan78xx_get_link, |
| 1608 | .nway_reset = lan78xx_nway_reset, | 1593 | .nway_reset = phy_ethtool_nway_reset, |
| 1609 | .get_drvinfo = lan78xx_get_drvinfo, | 1594 | .get_drvinfo = lan78xx_get_drvinfo, |
| 1610 | .get_msglevel = lan78xx_get_msglevel, | 1595 | .get_msglevel = lan78xx_get_msglevel, |
| 1611 | .set_msglevel = lan78xx_set_msglevel, | 1596 | .set_msglevel = lan78xx_set_msglevel, |
| 1612 | .get_settings = lan78xx_get_settings, | ||
| 1613 | .set_settings = lan78xx_set_settings, | ||
| 1614 | .get_eeprom_len = lan78xx_ethtool_get_eeprom_len, | 1597 | .get_eeprom_len = lan78xx_ethtool_get_eeprom_len, |
| 1615 | .get_eeprom = lan78xx_ethtool_get_eeprom, | 1598 | .get_eeprom = lan78xx_ethtool_get_eeprom, |
| 1616 | .set_eeprom = lan78xx_ethtool_set_eeprom, | 1599 | .set_eeprom = lan78xx_ethtool_set_eeprom, |
| @@ -1623,6 +1606,8 @@ static const struct ethtool_ops lan78xx_ethtool_ops = { | |||
| 1623 | .set_eee = lan78xx_set_eee, | 1606 | .set_eee = lan78xx_set_eee, |
| 1624 | .get_pauseparam = lan78xx_get_pause, | 1607 | .get_pauseparam = lan78xx_get_pause, |
| 1625 | .set_pauseparam = lan78xx_set_pause, | 1608 | .set_pauseparam = lan78xx_set_pause, |
| 1609 | .get_link_ksettings = lan78xx_get_link_ksettings, | ||
| 1610 | .set_link_ksettings = lan78xx_set_link_ksettings, | ||
| 1626 | }; | 1611 | }; |
| 1627 | 1612 | ||
| 1628 | static int lan78xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) | 1613 | static int lan78xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) |
| @@ -1719,6 +1704,7 @@ static int lan78xx_mdiobus_read(struct mii_bus *bus, int phy_id, int idx) | |||
| 1719 | done: | 1704 | done: |
| 1720 | mutex_unlock(&dev->phy_mutex); | 1705 | mutex_unlock(&dev->phy_mutex); |
| 1721 | usb_autopm_put_interface(dev->intf); | 1706 | usb_autopm_put_interface(dev->intf); |
| 1707 | |||
| 1722 | return ret; | 1708 | return ret; |
| 1723 | } | 1709 | } |
| 1724 | 1710 | ||
| @@ -1781,6 +1767,10 @@ static int lan78xx_mdio_init(struct lan78xx_net *dev) | |||
| 1781 | /* set to internal PHY id */ | 1767 | /* set to internal PHY id */ |
| 1782 | dev->mdiobus->phy_mask = ~(1 << 1); | 1768 | dev->mdiobus->phy_mask = ~(1 << 1); |
| 1783 | break; | 1769 | break; |
| 1770 | case ID_REV_CHIP_ID_7801_: | ||
| 1771 | /* scan thru PHYAD[2..0] */ | ||
| 1772 | dev->mdiobus->phy_mask = ~(0xFF); | ||
| 1773 | break; | ||
| 1784 | } | 1774 | } |
| 1785 | 1775 | ||
| 1786 | ret = mdiobus_register(dev->mdiobus); | 1776 | ret = mdiobus_register(dev->mdiobus); |
| @@ -1834,6 +1824,168 @@ static void lan78xx_link_status_change(struct net_device *net) | |||
| 1834 | } | 1824 | } |
| 1835 | } | 1825 | } |
| 1836 | 1826 | ||
| 1827 | static int irq_map(struct irq_domain *d, unsigned int irq, | ||
| 1828 | irq_hw_number_t hwirq) | ||
| 1829 | { | ||
| 1830 | struct irq_domain_data *data = d->host_data; | ||
| 1831 | |||
| 1832 | irq_set_chip_data(irq, data); | ||
| 1833 | irq_set_chip_and_handler(irq, data->irqchip, data->irq_handler); | ||
| 1834 | irq_set_noprobe(irq); | ||
| 1835 | |||
| 1836 | return 0; | ||
| 1837 | } | ||
| 1838 | |||
| 1839 | static void irq_unmap(struct irq_domain *d, unsigned int irq) | ||
| 1840 | { | ||
| 1841 | irq_set_chip_and_handler(irq, NULL, NULL); | ||
| 1842 | irq_set_chip_data(irq, NULL); | ||
| 1843 | } | ||
| 1844 | |||
| 1845 | static const struct irq_domain_ops chip_domain_ops = { | ||
| 1846 | .map = irq_map, | ||
| 1847 | .unmap = irq_unmap, | ||
| 1848 | }; | ||
| 1849 | |||
| 1850 | static void lan78xx_irq_mask(struct irq_data *irqd) | ||
| 1851 | { | ||
| 1852 | struct irq_domain_data *data = irq_data_get_irq_chip_data(irqd); | ||
| 1853 | |||
| 1854 | data->irqenable &= ~BIT(irqd_to_hwirq(irqd)); | ||
| 1855 | } | ||
| 1856 | |||
| 1857 | static void lan78xx_irq_unmask(struct irq_data *irqd) | ||
| 1858 | { | ||
| 1859 | struct irq_domain_data *data = irq_data_get_irq_chip_data(irqd); | ||
| 1860 | |||
| 1861 | data->irqenable |= BIT(irqd_to_hwirq(irqd)); | ||
| 1862 | } | ||
| 1863 | |||
| 1864 | static void lan78xx_irq_bus_lock(struct irq_data *irqd) | ||
| 1865 | { | ||
| 1866 | struct irq_domain_data *data = irq_data_get_irq_chip_data(irqd); | ||
| 1867 | |||
| 1868 | mutex_lock(&data->irq_lock); | ||
| 1869 | } | ||
| 1870 | |||
| 1871 | static void lan78xx_irq_bus_sync_unlock(struct irq_data *irqd) | ||
| 1872 | { | ||
| 1873 | struct irq_domain_data *data = irq_data_get_irq_chip_data(irqd); | ||
| 1874 | struct lan78xx_net *dev = | ||
| 1875 | container_of(data, struct lan78xx_net, domain_data); | ||
| 1876 | u32 buf; | ||
| 1877 | int ret; | ||
| 1878 | |||
| 1879 | /* call register access here because irq_bus_lock & irq_bus_sync_unlock | ||
| 1880 | * are only two callbacks executed in non-atomic contex. | ||
| 1881 | */ | ||
| 1882 | ret = lan78xx_read_reg(dev, INT_EP_CTL, &buf); | ||
| 1883 | if (buf != data->irqenable) | ||
| 1884 | ret = lan78xx_write_reg(dev, INT_EP_CTL, data->irqenable); | ||
| 1885 | |||
| 1886 | mutex_unlock(&data->irq_lock); | ||
| 1887 | } | ||
| 1888 | |||
| 1889 | static struct irq_chip lan78xx_irqchip = { | ||
| 1890 | .name = "lan78xx-irqs", | ||
| 1891 | .irq_mask = lan78xx_irq_mask, | ||
| 1892 | .irq_unmask = lan78xx_irq_unmask, | ||
| 1893 | .irq_bus_lock = lan78xx_irq_bus_lock, | ||
| 1894 | .irq_bus_sync_unlock = lan78xx_irq_bus_sync_unlock, | ||
| 1895 | }; | ||
| 1896 | |||
| 1897 | static int lan78xx_setup_irq_domain(struct lan78xx_net *dev) | ||
| 1898 | { | ||
| 1899 | struct device_node *of_node; | ||
| 1900 | struct irq_domain *irqdomain; | ||
| 1901 | unsigned int irqmap = 0; | ||
| 1902 | u32 buf; | ||
| 1903 | int ret = 0; | ||
| 1904 | |||
| 1905 | of_node = dev->udev->dev.parent->of_node; | ||
| 1906 | |||
| 1907 | mutex_init(&dev->domain_data.irq_lock); | ||
| 1908 | |||
| 1909 | lan78xx_read_reg(dev, INT_EP_CTL, &buf); | ||
| 1910 | dev->domain_data.irqenable = buf; | ||
| 1911 | |||
| 1912 | dev->domain_data.irqchip = &lan78xx_irqchip; | ||
| 1913 | dev->domain_data.irq_handler = handle_simple_irq; | ||
| 1914 | |||
| 1915 | irqdomain = irq_domain_add_simple(of_node, MAX_INT_EP, 0, | ||
| 1916 | &chip_domain_ops, &dev->domain_data); | ||
| 1917 | if (irqdomain) { | ||
| 1918 | /* create mapping for PHY interrupt */ | ||
| 1919 | irqmap = irq_create_mapping(irqdomain, INT_EP_PHY); | ||
| 1920 | if (!irqmap) { | ||
| 1921 | irq_domain_remove(irqdomain); | ||
| 1922 | |||
| 1923 | irqdomain = NULL; | ||
| 1924 | ret = -EINVAL; | ||
| 1925 | } | ||
| 1926 | } else { | ||
| 1927 | ret = -EINVAL; | ||
| 1928 | } | ||
| 1929 | |||
| 1930 | dev->domain_data.irqdomain = irqdomain; | ||
| 1931 | dev->domain_data.phyirq = irqmap; | ||
| 1932 | |||
| 1933 | return ret; | ||
| 1934 | } | ||
| 1935 | |||
| 1936 | static void lan78xx_remove_irq_domain(struct lan78xx_net *dev) | ||
| 1937 | { | ||
| 1938 | if (dev->domain_data.phyirq > 0) { | ||
| 1939 | irq_dispose_mapping(dev->domain_data.phyirq); | ||
| 1940 | |||
| 1941 | if (dev->domain_data.irqdomain) | ||
| 1942 | irq_domain_remove(dev->domain_data.irqdomain); | ||
| 1943 | } | ||
| 1944 | dev->domain_data.phyirq = 0; | ||
| 1945 | dev->domain_data.irqdomain = NULL; | ||
| 1946 | } | ||
| 1947 | |||
| 1948 | static int lan8835_fixup(struct phy_device *phydev) | ||
| 1949 | { | ||
| 1950 | int buf; | ||
| 1951 | int ret; | ||
| 1952 | struct lan78xx_net *dev = netdev_priv(phydev->attached_dev); | ||
| 1953 | |||
| 1954 | /* LED2/PME_N/IRQ_N/RGMII_ID pin to IRQ_N mode */ | ||
| 1955 | buf = phy_read_mmd_indirect(phydev, 0x8010, 3); | ||
| 1956 | buf &= ~0x1800; | ||
| 1957 | buf |= 0x0800; | ||
| 1958 | phy_write_mmd_indirect(phydev, 0x8010, 3, buf); | ||
| 1959 | |||
| 1960 | /* RGMII MAC TXC Delay Enable */ | ||
| 1961 | ret = lan78xx_write_reg(dev, MAC_RGMII_ID, | ||
| 1962 | MAC_RGMII_ID_TXC_DELAY_EN_); | ||
| 1963 | |||
| 1964 | /* RGMII TX DLL Tune Adjust */ | ||
| 1965 | ret = lan78xx_write_reg(dev, RGMII_TX_BYP_DLL, 0x3D00); | ||
| 1966 | |||
| 1967 | dev->interface = PHY_INTERFACE_MODE_RGMII_TXID; | ||
| 1968 | |||
| 1969 | return 1; | ||
| 1970 | } | ||
| 1971 | |||
| 1972 | static int ksz9031rnx_fixup(struct phy_device *phydev) | ||
| 1973 | { | ||
| 1974 | struct lan78xx_net *dev = netdev_priv(phydev->attached_dev); | ||
| 1975 | |||
| 1976 | /* Micrel9301RNX PHY configuration */ | ||
| 1977 | /* RGMII Control Signal Pad Skew */ | ||
| 1978 | phy_write_mmd_indirect(phydev, 4, 2, 0x0077); | ||
| 1979 | /* RGMII RX Data Pad Skew */ | ||
| 1980 | phy_write_mmd_indirect(phydev, 5, 2, 0x7777); | ||
| 1981 | /* RGMII RX Clock Pad Skew */ | ||
| 1982 | phy_write_mmd_indirect(phydev, 8, 2, 0x1FF); | ||
| 1983 | |||
| 1984 | dev->interface = PHY_INTERFACE_MODE_RGMII_RXID; | ||
| 1985 | |||
| 1986 | return 1; | ||
| 1987 | } | ||
| 1988 | |||
| 1837 | static int lan78xx_phy_init(struct lan78xx_net *dev) | 1989 | static int lan78xx_phy_init(struct lan78xx_net *dev) |
| 1838 | { | 1990 | { |
| 1839 | int ret; | 1991 | int ret; |
| @@ -1846,28 +1998,61 @@ static int lan78xx_phy_init(struct lan78xx_net *dev) | |||
| 1846 | return -EIO; | 1998 | return -EIO; |
| 1847 | } | 1999 | } |
| 1848 | 2000 | ||
| 1849 | /* Enable PHY interrupts. | 2001 | if ((dev->chipid == ID_REV_CHIP_ID_7800_) || |
| 1850 | * We handle our own interrupt | 2002 | (dev->chipid == ID_REV_CHIP_ID_7850_)) { |
| 1851 | */ | 2003 | phydev->is_internal = true; |
| 1852 | ret = phy_read(phydev, LAN88XX_INT_STS); | 2004 | dev->interface = PHY_INTERFACE_MODE_GMII; |
| 1853 | ret = phy_write(phydev, LAN88XX_INT_MASK, | ||
| 1854 | LAN88XX_INT_MASK_MDINTPIN_EN_ | | ||
| 1855 | LAN88XX_INT_MASK_LINK_CHANGE_); | ||
| 1856 | 2005 | ||
| 1857 | phydev->irq = PHY_IGNORE_INTERRUPT; | 2006 | } else if (dev->chipid == ID_REV_CHIP_ID_7801_) { |
| 2007 | if (!phydev->drv) { | ||
| 2008 | netdev_err(dev->net, "no PHY driver found\n"); | ||
| 2009 | return -EIO; | ||
| 2010 | } | ||
| 2011 | |||
| 2012 | dev->interface = PHY_INTERFACE_MODE_RGMII; | ||
| 2013 | |||
| 2014 | /* external PHY fixup for KSZ9031RNX */ | ||
| 2015 | ret = phy_register_fixup_for_uid(PHY_KSZ9031RNX, 0xfffffff0, | ||
| 2016 | ksz9031rnx_fixup); | ||
| 2017 | if (ret < 0) { | ||
| 2018 | netdev_err(dev->net, "fail to register fixup\n"); | ||
| 2019 | return ret; | ||
| 2020 | } | ||
| 2021 | /* external PHY fixup for LAN8835 */ | ||
| 2022 | ret = phy_register_fixup_for_uid(PHY_LAN8835, 0xfffffff0, | ||
| 2023 | lan8835_fixup); | ||
| 2024 | if (ret < 0) { | ||
| 2025 | netdev_err(dev->net, "fail to register fixup\n"); | ||
| 2026 | return ret; | ||
| 2027 | } | ||
| 2028 | /* add more external PHY fixup here if needed */ | ||
| 2029 | |||
| 2030 | phydev->is_internal = false; | ||
| 2031 | } else { | ||
| 2032 | netdev_err(dev->net, "unknown ID found\n"); | ||
| 2033 | ret = -EIO; | ||
| 2034 | goto error; | ||
| 2035 | } | ||
| 2036 | |||
| 2037 | /* if phyirq is not set, use polling mode in phylib */ | ||
| 2038 | if (dev->domain_data.phyirq > 0) | ||
| 2039 | phydev->irq = dev->domain_data.phyirq; | ||
| 2040 | else | ||
| 2041 | phydev->irq = 0; | ||
| 2042 | netdev_dbg(dev->net, "phydev->irq = %d\n", phydev->irq); | ||
| 2043 | |||
| 2044 | /* set to AUTOMDIX */ | ||
| 2045 | phydev->mdix = ETH_TP_MDI_AUTO; | ||
| 1858 | 2046 | ||
| 1859 | ret = phy_connect_direct(dev->net, phydev, | 2047 | ret = phy_connect_direct(dev->net, phydev, |
| 1860 | lan78xx_link_status_change, | 2048 | lan78xx_link_status_change, |
| 1861 | PHY_INTERFACE_MODE_GMII); | 2049 | dev->interface); |
| 1862 | if (ret) { | 2050 | if (ret) { |
| 1863 | netdev_err(dev->net, "can't attach PHY to %s\n", | 2051 | netdev_err(dev->net, "can't attach PHY to %s\n", |
| 1864 | dev->mdiobus->id); | 2052 | dev->mdiobus->id); |
| 1865 | return -EIO; | 2053 | return -EIO; |
| 1866 | } | 2054 | } |
| 1867 | 2055 | ||
| 1868 | /* set to AUTOMDIX */ | ||
| 1869 | lan78xx_set_mdix_status(dev->net, ETH_TP_MDI_AUTO); | ||
| 1870 | |||
| 1871 | /* MAC doesn't support 1000T Half */ | 2056 | /* MAC doesn't support 1000T Half */ |
| 1872 | phydev->supported &= ~SUPPORTED_1000baseT_Half; | 2057 | phydev->supported &= ~SUPPORTED_1000baseT_Half; |
| 1873 | 2058 | ||
| @@ -1886,6 +2071,12 @@ static int lan78xx_phy_init(struct lan78xx_net *dev) | |||
| 1886 | netif_dbg(dev, ifup, dev->net, "phy initialised successfully"); | 2071 | netif_dbg(dev, ifup, dev->net, "phy initialised successfully"); |
| 1887 | 2072 | ||
| 1888 | return 0; | 2073 | return 0; |
| 2074 | |||
| 2075 | error: | ||
| 2076 | phy_unregister_fixup_for_uid(PHY_KSZ9031RNX, 0xfffffff0); | ||
| 2077 | phy_unregister_fixup_for_uid(PHY_LAN8835, 0xfffffff0); | ||
| 2078 | |||
| 2079 | return ret; | ||
| 1889 | } | 2080 | } |
| 1890 | 2081 | ||
| 1891 | static int lan78xx_set_rx_max_frame_length(struct lan78xx_net *dev, int size) | 2082 | static int lan78xx_set_rx_max_frame_length(struct lan78xx_net *dev, int size) |
| @@ -1970,11 +2161,6 @@ static int lan78xx_change_mtu(struct net_device *netdev, int new_mtu) | |||
| 1970 | int old_rx_urb_size = dev->rx_urb_size; | 2161 | int old_rx_urb_size = dev->rx_urb_size; |
| 1971 | int ret; | 2162 | int ret; |
| 1972 | 2163 | ||
| 1973 | if (new_mtu > MAX_SINGLE_PACKET_SIZE) | ||
| 1974 | return -EINVAL; | ||
| 1975 | |||
| 1976 | if (new_mtu <= 0) | ||
| 1977 | return -EINVAL; | ||
| 1978 | /* no second zero-length packet read wanted after mtu-sized packets */ | 2164 | /* no second zero-length packet read wanted after mtu-sized packets */ |
| 1979 | if ((ll_mtu % dev->maxpacket) == 0) | 2165 | if ((ll_mtu % dev->maxpacket) == 0) |
| 1980 | return -EDOM; | 2166 | return -EDOM; |
| @@ -2247,14 +2433,12 @@ static int lan78xx_reset(struct lan78xx_net *dev) | |||
| 2247 | } while ((buf & PMT_CTL_PHY_RST_) || !(buf & PMT_CTL_READY_)); | 2433 | } while ((buf & PMT_CTL_PHY_RST_) || !(buf & PMT_CTL_READY_)); |
| 2248 | 2434 | ||
| 2249 | ret = lan78xx_read_reg(dev, MAC_CR, &buf); | 2435 | ret = lan78xx_read_reg(dev, MAC_CR, &buf); |
| 2436 | /* LAN7801 only has RGMII mode */ | ||
| 2437 | if (dev->chipid == ID_REV_CHIP_ID_7801_) | ||
| 2438 | buf &= ~MAC_CR_GMII_EN_; | ||
| 2250 | buf |= MAC_CR_AUTO_DUPLEX_ | MAC_CR_AUTO_SPEED_; | 2439 | buf |= MAC_CR_AUTO_DUPLEX_ | MAC_CR_AUTO_SPEED_; |
| 2251 | ret = lan78xx_write_reg(dev, MAC_CR, buf); | 2440 | ret = lan78xx_write_reg(dev, MAC_CR, buf); |
| 2252 | 2441 | ||
| 2253 | /* enable PHY interrupts */ | ||
| 2254 | ret = lan78xx_read_reg(dev, INT_EP_CTL, &buf); | ||
| 2255 | buf |= INT_ENP_PHY_INT; | ||
| 2256 | ret = lan78xx_write_reg(dev, INT_EP_CTL, buf); | ||
| 2257 | |||
| 2258 | ret = lan78xx_read_reg(dev, MAC_TX, &buf); | 2442 | ret = lan78xx_read_reg(dev, MAC_TX, &buf); |
| 2259 | buf |= MAC_TX_TXEN_; | 2443 | buf |= MAC_TX_TXEN_; |
| 2260 | ret = lan78xx_write_reg(dev, MAC_TX, buf); | 2444 | ret = lan78xx_write_reg(dev, MAC_TX, buf); |
| @@ -2378,8 +2562,12 @@ static int lan78xx_stop(struct net_device *net) | |||
| 2378 | if (timer_pending(&dev->stat_monitor)) | 2562 | if (timer_pending(&dev->stat_monitor)) |
| 2379 | del_timer_sync(&dev->stat_monitor); | 2563 | del_timer_sync(&dev->stat_monitor); |
| 2380 | 2564 | ||
| 2565 | phy_unregister_fixup_for_uid(PHY_KSZ9031RNX, 0xfffffff0); | ||
| 2566 | phy_unregister_fixup_for_uid(PHY_LAN8835, 0xfffffff0); | ||
| 2567 | |||
| 2381 | phy_stop(net->phydev); | 2568 | phy_stop(net->phydev); |
| 2382 | phy_disconnect(net->phydev); | 2569 | phy_disconnect(net->phydev); |
| 2570 | |||
| 2383 | net->phydev = NULL; | 2571 | net->phydev = NULL; |
| 2384 | 2572 | ||
| 2385 | clear_bit(EVENT_DEV_OPEN, &dev->flags); | 2573 | clear_bit(EVENT_DEV_OPEN, &dev->flags); |
| @@ -2419,14 +2607,9 @@ static struct sk_buff *lan78xx_tx_prep(struct lan78xx_net *dev, | |||
| 2419 | { | 2607 | { |
| 2420 | u32 tx_cmd_a, tx_cmd_b; | 2608 | u32 tx_cmd_a, tx_cmd_b; |
| 2421 | 2609 | ||
| 2422 | if (skb_headroom(skb) < TX_OVERHEAD) { | 2610 | if (skb_cow_head(skb, TX_OVERHEAD)) { |
| 2423 | struct sk_buff *skb2; | ||
| 2424 | |||
| 2425 | skb2 = skb_copy_expand(skb, TX_OVERHEAD, 0, flags); | ||
| 2426 | dev_kfree_skb_any(skb); | 2611 | dev_kfree_skb_any(skb); |
| 2427 | skb = skb2; | 2612 | return NULL; |
| 2428 | if (!skb) | ||
| 2429 | return NULL; | ||
| 2430 | } | 2613 | } |
| 2431 | 2614 | ||
| 2432 | if (lan78xx_linearize(skb) < 0) | 2615 | if (lan78xx_linearize(skb) < 0) |
| @@ -2663,6 +2846,14 @@ static int lan78xx_bind(struct lan78xx_net *dev, struct usb_interface *intf) | |||
| 2663 | 2846 | ||
| 2664 | dev->net->hw_features = dev->net->features; | 2847 | dev->net->hw_features = dev->net->features; |
| 2665 | 2848 | ||
| 2849 | ret = lan78xx_setup_irq_domain(dev); | ||
| 2850 | if (ret < 0) { | ||
| 2851 | netdev_warn(dev->net, | ||
| 2852 | "lan78xx_setup_irq_domain() failed : %d", ret); | ||
| 2853 | kfree(pdata); | ||
| 2854 | return ret; | ||
| 2855 | } | ||
| 2856 | |||
| 2666 | /* Init all registers */ | 2857 | /* Init all registers */ |
| 2667 | ret = lan78xx_reset(dev); | 2858 | ret = lan78xx_reset(dev); |
| 2668 | 2859 | ||
| @@ -2679,6 +2870,8 @@ static void lan78xx_unbind(struct lan78xx_net *dev, struct usb_interface *intf) | |||
| 2679 | { | 2870 | { |
| 2680 | struct lan78xx_priv *pdata = (struct lan78xx_priv *)(dev->data[0]); | 2871 | struct lan78xx_priv *pdata = (struct lan78xx_priv *)(dev->data[0]); |
| 2681 | 2872 | ||
| 2873 | lan78xx_remove_irq_domain(dev); | ||
| 2874 | |||
| 2682 | lan78xx_remove_mdio(dev); | 2875 | lan78xx_remove_mdio(dev); |
| 2683 | 2876 | ||
| 2684 | if (pdata) { | 2877 | if (pdata) { |
| @@ -3378,6 +3571,9 @@ static int lan78xx_probe(struct usb_interface *intf, | |||
| 3378 | if (netdev->mtu > (dev->hard_mtu - netdev->hard_header_len)) | 3571 | if (netdev->mtu > (dev->hard_mtu - netdev->hard_header_len)) |
| 3379 | netdev->mtu = dev->hard_mtu - netdev->hard_header_len; | 3572 | netdev->mtu = dev->hard_mtu - netdev->hard_header_len; |
| 3380 | 3573 | ||
| 3574 | /* MTU range: 68 - 9000 */ | ||
| 3575 | netdev->max_mtu = MAX_SINGLE_PACKET_SIZE; | ||
| 3576 | |||
| 3381 | dev->ep_blkin = (intf->cur_altsetting)->endpoint + 0; | 3577 | dev->ep_blkin = (intf->cur_altsetting)->endpoint + 0; |
| 3382 | dev->ep_blkout = (intf->cur_altsetting)->endpoint + 1; | 3578 | dev->ep_blkout = (intf->cur_altsetting)->endpoint + 1; |
| 3383 | dev->ep_intr = (intf->cur_altsetting)->endpoint + 2; | 3579 | dev->ep_intr = (intf->cur_altsetting)->endpoint + 2; |
| @@ -3789,6 +3985,10 @@ static const struct usb_device_id products[] = { | |||
| 3789 | /* LAN7850 USB Gigabit Ethernet Device */ | 3985 | /* LAN7850 USB Gigabit Ethernet Device */ |
| 3790 | USB_DEVICE(LAN78XX_USB_VENDOR_ID, LAN7850_USB_PRODUCT_ID), | 3986 | USB_DEVICE(LAN78XX_USB_VENDOR_ID, LAN7850_USB_PRODUCT_ID), |
| 3791 | }, | 3987 | }, |
| 3988 | { | ||
| 3989 | /* LAN7801 USB Gigabit Ethernet Device */ | ||
| 3990 | USB_DEVICE(LAN78XX_USB_VENDOR_ID, LAN7801_USB_PRODUCT_ID), | ||
| 3991 | }, | ||
| 3792 | {}, | 3992 | {}, |
| 3793 | }; | 3993 | }; |
| 3794 | MODULE_DEVICE_TABLE(usb, products); | 3994 | MODULE_DEVICE_TABLE(usb, products); |
diff --git a/drivers/net/usb/lan78xx.h b/drivers/net/usb/lan78xx.h index 40927906109a..25aa54611774 100644 --- a/drivers/net/usb/lan78xx.h +++ b/drivers/net/usb/lan78xx.h | |||
| @@ -108,6 +108,7 @@ | |||
| 108 | #define ID_REV_CHIP_REV_MASK_ (0x0000FFFF) | 108 | #define ID_REV_CHIP_REV_MASK_ (0x0000FFFF) |
| 109 | #define ID_REV_CHIP_ID_7800_ (0x7800) | 109 | #define ID_REV_CHIP_ID_7800_ (0x7800) |
| 110 | #define ID_REV_CHIP_ID_7850_ (0x7850) | 110 | #define ID_REV_CHIP_ID_7850_ (0x7850) |
| 111 | #define ID_REV_CHIP_ID_7801_ (0x7801) | ||
| 111 | 112 | ||
| 112 | #define FPGA_REV (0x04) | 113 | #define FPGA_REV (0x04) |
| 113 | #define FPGA_REV_MINOR_MASK_ (0x0000FF00) | 114 | #define FPGA_REV_MINOR_MASK_ (0x0000FF00) |
| @@ -550,6 +551,7 @@ | |||
| 550 | #define LTM_INACTIVE1_TIMER10_ (0x0000FFFF) | 551 | #define LTM_INACTIVE1_TIMER10_ (0x0000FFFF) |
| 551 | 552 | ||
| 552 | #define MAC_CR (0x100) | 553 | #define MAC_CR (0x100) |
| 554 | #define MAC_CR_GMII_EN_ (0x00080000) | ||
| 553 | #define MAC_CR_EEE_TX_CLK_STOP_EN_ (0x00040000) | 555 | #define MAC_CR_EEE_TX_CLK_STOP_EN_ (0x00040000) |
| 554 | #define MAC_CR_EEE_EN_ (0x00020000) | 556 | #define MAC_CR_EEE_EN_ (0x00020000) |
| 555 | #define MAC_CR_EEE_TLAR_EN_ (0x00010000) | 557 | #define MAC_CR_EEE_TLAR_EN_ (0x00010000) |
| @@ -787,6 +789,18 @@ | |||
| 787 | #define PHY_DEV_ID_MODEL_MASK_ (0x0FC00000) | 789 | #define PHY_DEV_ID_MODEL_MASK_ (0x0FC00000) |
| 788 | #define PHY_DEV_ID_OUI_MASK_ (0x003FFFFF) | 790 | #define PHY_DEV_ID_OUI_MASK_ (0x003FFFFF) |
| 789 | 791 | ||
| 792 | #define RGMII_TX_BYP_DLL (0x708) | ||
| 793 | #define RGMII_TX_BYP_DLL_TX_TUNE_ADJ_MASK_ (0x000FC00) | ||
| 794 | #define RGMII_TX_BYP_DLL_TX_TUNE_SEL_MASK_ (0x00003F0) | ||
| 795 | #define RGMII_TX_BYP_DLL_TX_DLL_RESET_ (0x0000002) | ||
| 796 | #define RGMII_TX_BYP_DLL_TX_DLL_BYPASS_ (0x0000001) | ||
| 797 | |||
| 798 | #define RGMII_RX_BYP_DLL (0x70C) | ||
| 799 | #define RGMII_RX_BYP_DLL_RX_TUNE_ADJ_MASK_ (0x000FC00) | ||
| 800 | #define RGMII_RX_BYP_DLL_RX_TUNE_SEL_MASK_ (0x00003F0) | ||
| 801 | #define RGMII_RX_BYP_DLL_RX_DLL_RESET_ (0x0000002) | ||
| 802 | #define RGMII_RX_BYP_DLL_RX_DLL_BYPASS_ (0x0000001) | ||
| 803 | |||
| 790 | #define OTP_BASE_ADDR (0x00001000) | 804 | #define OTP_BASE_ADDR (0x00001000) |
| 791 | #define OTP_ADDR_RANGE_ (0x1FF) | 805 | #define OTP_ADDR_RANGE_ (0x1FF) |
| 792 | 806 | ||
diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c index 1434e5dd5f9c..36674484c6fb 100644 --- a/drivers/net/usb/pegasus.c +++ b/drivers/net/usb/pegasus.c | |||
| @@ -42,7 +42,7 @@ | |||
| 42 | #include <linux/usb.h> | 42 | #include <linux/usb.h> |
| 43 | #include <linux/module.h> | 43 | #include <linux/module.h> |
| 44 | #include <asm/byteorder.h> | 44 | #include <asm/byteorder.h> |
| 45 | #include <asm/uaccess.h> | 45 | #include <linux/uaccess.h> |
| 46 | #include "pegasus.h" | 46 | #include "pegasus.h" |
| 47 | 47 | ||
| 48 | /* | 48 | /* |
| @@ -126,40 +126,61 @@ static void async_ctrl_callback(struct urb *urb) | |||
| 126 | 126 | ||
| 127 | static int get_registers(pegasus_t *pegasus, __u16 indx, __u16 size, void *data) | 127 | static int get_registers(pegasus_t *pegasus, __u16 indx, __u16 size, void *data) |
| 128 | { | 128 | { |
| 129 | u8 *buf; | ||
| 129 | int ret; | 130 | int ret; |
| 130 | 131 | ||
| 132 | buf = kmalloc(size, GFP_NOIO); | ||
| 133 | if (!buf) | ||
| 134 | return -ENOMEM; | ||
| 135 | |||
| 131 | ret = usb_control_msg(pegasus->usb, usb_rcvctrlpipe(pegasus->usb, 0), | 136 | ret = usb_control_msg(pegasus->usb, usb_rcvctrlpipe(pegasus->usb, 0), |
| 132 | PEGASUS_REQ_GET_REGS, PEGASUS_REQT_READ, 0, | 137 | PEGASUS_REQ_GET_REGS, PEGASUS_REQT_READ, 0, |
| 133 | indx, data, size, 1000); | 138 | indx, buf, size, 1000); |
| 134 | if (ret < 0) | 139 | if (ret < 0) |
| 135 | netif_dbg(pegasus, drv, pegasus->net, | 140 | netif_dbg(pegasus, drv, pegasus->net, |
| 136 | "%s returned %d\n", __func__, ret); | 141 | "%s returned %d\n", __func__, ret); |
| 142 | else if (ret <= size) | ||
| 143 | memcpy(data, buf, ret); | ||
| 144 | kfree(buf); | ||
| 137 | return ret; | 145 | return ret; |
| 138 | } | 146 | } |
| 139 | 147 | ||
| 140 | static int set_registers(pegasus_t *pegasus, __u16 indx, __u16 size, void *data) | 148 | static int set_registers(pegasus_t *pegasus, __u16 indx, __u16 size, |
| 149 | const void *data) | ||
| 141 | { | 150 | { |
| 151 | u8 *buf; | ||
| 142 | int ret; | 152 | int ret; |
| 143 | 153 | ||
| 154 | buf = kmemdup(data, size, GFP_NOIO); | ||
| 155 | if (!buf) | ||
| 156 | return -ENOMEM; | ||
| 157 | |||
| 144 | ret = usb_control_msg(pegasus->usb, usb_sndctrlpipe(pegasus->usb, 0), | 158 | ret = usb_control_msg(pegasus->usb, usb_sndctrlpipe(pegasus->usb, 0), |
| 145 | PEGASUS_REQ_SET_REGS, PEGASUS_REQT_WRITE, 0, | 159 | PEGASUS_REQ_SET_REGS, PEGASUS_REQT_WRITE, 0, |
| 146 | indx, data, size, 100); | 160 | indx, buf, size, 100); |
| 147 | if (ret < 0) | 161 | if (ret < 0) |
| 148 | netif_dbg(pegasus, drv, pegasus->net, | 162 | netif_dbg(pegasus, drv, pegasus->net, |
| 149 | "%s returned %d\n", __func__, ret); | 163 | "%s returned %d\n", __func__, ret); |
| 164 | kfree(buf); | ||
| 150 | return ret; | 165 | return ret; |
| 151 | } | 166 | } |
| 152 | 167 | ||
| 153 | static int set_register(pegasus_t *pegasus, __u16 indx, __u8 data) | 168 | static int set_register(pegasus_t *pegasus, __u16 indx, __u8 data) |
| 154 | { | 169 | { |
| 170 | u8 *buf; | ||
| 155 | int ret; | 171 | int ret; |
| 156 | 172 | ||
| 173 | buf = kmemdup(&data, 1, GFP_NOIO); | ||
| 174 | if (!buf) | ||
| 175 | return -ENOMEM; | ||
| 176 | |||
| 157 | ret = usb_control_msg(pegasus->usb, usb_sndctrlpipe(pegasus->usb, 0), | 177 | ret = usb_control_msg(pegasus->usb, usb_sndctrlpipe(pegasus->usb, 0), |
| 158 | PEGASUS_REQ_SET_REG, PEGASUS_REQT_WRITE, data, | 178 | PEGASUS_REQ_SET_REG, PEGASUS_REQT_WRITE, data, |
| 159 | indx, &data, 1, 1000); | 179 | indx, buf, 1, 1000); |
| 160 | if (ret < 0) | 180 | if (ret < 0) |
| 161 | netif_dbg(pegasus, drv, pegasus->net, | 181 | netif_dbg(pegasus, drv, pegasus->net, |
| 162 | "%s returned %d\n", __func__, ret); | 182 | "%s returned %d\n", __func__, ret); |
| 183 | kfree(buf); | ||
| 163 | return ret; | 184 | return ret; |
| 164 | } | 185 | } |
| 165 | 186 | ||
| @@ -1273,7 +1294,6 @@ static const struct net_device_ops pegasus_netdev_ops = { | |||
| 1273 | .ndo_set_rx_mode = pegasus_set_multicast, | 1294 | .ndo_set_rx_mode = pegasus_set_multicast, |
| 1274 | .ndo_get_stats = pegasus_netdev_stats, | 1295 | .ndo_get_stats = pegasus_netdev_stats, |
| 1275 | .ndo_tx_timeout = pegasus_tx_timeout, | 1296 | .ndo_tx_timeout = pegasus_tx_timeout, |
| 1276 | .ndo_change_mtu = eth_change_mtu, | ||
| 1277 | .ndo_set_mac_address = eth_mac_addr, | 1297 | .ndo_set_mac_address = eth_mac_addr, |
| 1278 | .ndo_validate_addr = eth_validate_addr, | 1298 | .ndo_validate_addr = eth_validate_addr, |
| 1279 | }; | 1299 | }; |
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c index 6fe1cdb0174f..2474618404f5 100644 --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
| 14 | #include <linux/sched/signal.h> | ||
| 14 | #include <linux/netdevice.h> | 15 | #include <linux/netdevice.h> |
| 15 | #include <linux/ethtool.h> | 16 | #include <linux/ethtool.h> |
| 16 | #include <linux/etherdevice.h> | 17 | #include <linux/etherdevice.h> |
| @@ -579,6 +580,10 @@ static const struct usb_device_id products[] = { | |||
| 579 | USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 0x01, 0x69), | 580 | USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 0x01, 0x69), |
| 580 | .driver_info = (unsigned long)&qmi_wwan_info, | 581 | .driver_info = (unsigned long)&qmi_wwan_info, |
| 581 | }, | 582 | }, |
| 583 | { /* Motorola Mapphone devices with MDM6600 */ | ||
| 584 | USB_VENDOR_AND_INTERFACE_INFO(0x22b8, USB_CLASS_VENDOR_SPEC, 0xfb, 0xff), | ||
| 585 | .driver_info = (unsigned long)&qmi_wwan_info, | ||
| 586 | }, | ||
| 582 | 587 | ||
| 583 | /* 2. Combined interface devices matching on class+protocol */ | 588 | /* 2. Combined interface devices matching on class+protocol */ |
| 584 | { /* Huawei E367 and possibly others in "Windows mode" */ | 589 | { /* Huawei E367 and possibly others in "Windows mode" */ |
| @@ -654,6 +659,13 @@ static const struct usb_device_id products[] = { | |||
| 654 | USB_CDC_PROTO_NONE), | 659 | USB_CDC_PROTO_NONE), |
| 655 | .driver_info = (unsigned long)&qmi_wwan_info, | 660 | .driver_info = (unsigned long)&qmi_wwan_info, |
| 656 | }, | 661 | }, |
| 662 | { /* HP lt2523 (Novatel E371) */ | ||
| 663 | USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0x421d, | ||
| 664 | USB_CLASS_COMM, | ||
| 665 | USB_CDC_SUBCLASS_ETHERNET, | ||
| 666 | USB_CDC_PROTO_NONE), | ||
| 667 | .driver_info = (unsigned long)&qmi_wwan_info, | ||
| 668 | }, | ||
| 657 | { /* HP lt4112 LTE/HSPA+ Gobi 4G Module (Huawei me906e) */ | 669 | { /* HP lt4112 LTE/HSPA+ Gobi 4G Module (Huawei me906e) */ |
| 658 | USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0x581d, USB_CLASS_VENDOR_SPEC, 1, 7), | 670 | USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0x581d, USB_CLASS_VENDOR_SPEC, 1, 7), |
| 659 | .driver_info = (unsigned long)&qmi_wwan_info, | 671 | .driver_info = (unsigned long)&qmi_wwan_info, |
| @@ -896,7 +908,7 @@ static const struct usb_device_id products[] = { | |||
| 896 | {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */ | 908 | {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */ |
| 897 | {QMI_QUIRK_SET_DTR(0x1bc7, 0x1040, 2)}, /* Telit LE922A */ | 909 | {QMI_QUIRK_SET_DTR(0x1bc7, 0x1040, 2)}, /* Telit LE922A */ |
| 898 | {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */ | 910 | {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */ |
| 899 | {QMI_FIXED_INTF(0x1bc7, 0x1201, 2)}, /* Telit LE920 */ | 911 | {QMI_QUIRK_SET_DTR(0x1bc7, 0x1201, 2)}, /* Telit LE920, LE920A4 */ |
| 900 | {QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)}, /* XS Stick W100-2 from 4G Systems */ | 912 | {QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)}, /* XS Stick W100-2 from 4G Systems */ |
| 901 | {QMI_FIXED_INTF(0x0b3c, 0xc000, 4)}, /* Olivetti Olicard 100 */ | 913 | {QMI_FIXED_INTF(0x0b3c, 0xc000, 4)}, /* Olivetti Olicard 100 */ |
| 902 | {QMI_FIXED_INTF(0x0b3c, 0xc001, 4)}, /* Olivetti Olicard 120 */ | 914 | {QMI_FIXED_INTF(0x0b3c, 0xc001, 4)}, /* Olivetti Olicard 120 */ |
| @@ -917,6 +929,8 @@ static const struct usb_device_id products[] = { | |||
| 917 | {QMI_FIXED_INTF(0x413c, 0x81a9, 8)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */ | 929 | {QMI_FIXED_INTF(0x413c, 0x81a9, 8)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */ |
| 918 | {QMI_FIXED_INTF(0x413c, 0x81b1, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card */ | 930 | {QMI_FIXED_INTF(0x413c, 0x81b1, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card */ |
| 919 | {QMI_FIXED_INTF(0x413c, 0x81b3, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card (rev3) */ | 931 | {QMI_FIXED_INTF(0x413c, 0x81b3, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card (rev3) */ |
| 932 | {QMI_FIXED_INTF(0x413c, 0x81b6, 8)}, /* Dell Wireless 5811e */ | ||
| 933 | {QMI_FIXED_INTF(0x413c, 0x81b6, 10)}, /* Dell Wireless 5811e */ | ||
| 920 | {QMI_FIXED_INTF(0x03f0, 0x4e1d, 8)}, /* HP lt4111 LTE/EV-DO/HSPA+ Gobi 4G Module */ | 934 | {QMI_FIXED_INTF(0x03f0, 0x4e1d, 8)}, /* HP lt4111 LTE/EV-DO/HSPA+ Gobi 4G Module */ |
| 921 | {QMI_FIXED_INTF(0x22de, 0x9061, 3)}, /* WeTelecom WPD-600N */ | 935 | {QMI_FIXED_INTF(0x22de, 0x9061, 3)}, /* WeTelecom WPD-600N */ |
| 922 | {QMI_FIXED_INTF(0x1e0e, 0x9001, 5)}, /* SIMCom 7230E */ | 936 | {QMI_FIXED_INTF(0x1e0e, 0x9001, 5)}, /* SIMCom 7230E */ |
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index efb84f092492..07f788c49d57 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c | |||
| @@ -32,7 +32,7 @@ | |||
| 32 | #define NETNEXT_VERSION "08" | 32 | #define NETNEXT_VERSION "08" |
| 33 | 33 | ||
| 34 | /* Information for net */ | 34 | /* Information for net */ |
| 35 | #define NET_VERSION "6" | 35 | #define NET_VERSION "9" |
| 36 | 36 | ||
| 37 | #define DRIVER_VERSION "v1." NETNEXT_VERSION "." NET_VERSION | 37 | #define DRIVER_VERSION "v1." NETNEXT_VERSION "." NET_VERSION |
| 38 | #define DRIVER_AUTHOR "Realtek linux nic maintainers <nic_swsd@realtek.com>" | 38 | #define DRIVER_AUTHOR "Realtek linux nic maintainers <nic_swsd@realtek.com>" |
| @@ -501,6 +501,8 @@ enum rtl_register_content { | |||
| 501 | #define RTL8153_RMS RTL8153_MAX_PACKET | 501 | #define RTL8153_RMS RTL8153_MAX_PACKET |
| 502 | #define RTL8152_TX_TIMEOUT (5 * HZ) | 502 | #define RTL8152_TX_TIMEOUT (5 * HZ) |
| 503 | #define RTL8152_NAPI_WEIGHT 64 | 503 | #define RTL8152_NAPI_WEIGHT 64 |
| 504 | #define rx_reserved_size(x) ((x) + VLAN_ETH_HLEN + CRC_SIZE + \ | ||
| 505 | sizeof(struct rx_desc) + RX_ALIGN) | ||
| 504 | 506 | ||
| 505 | /* rtl8152 flags */ | 507 | /* rtl8152 flags */ |
| 506 | enum rtl8152_flags { | 508 | enum rtl8152_flags { |
| @@ -515,6 +517,7 @@ enum rtl8152_flags { | |||
| 515 | 517 | ||
| 516 | /* Define these values to match your device */ | 518 | /* Define these values to match your device */ |
| 517 | #define VENDOR_ID_REALTEK 0x0bda | 519 | #define VENDOR_ID_REALTEK 0x0bda |
| 520 | #define VENDOR_ID_MICROSOFT 0x045e | ||
| 518 | #define VENDOR_ID_SAMSUNG 0x04e8 | 521 | #define VENDOR_ID_SAMSUNG 0x04e8 |
| 519 | #define VENDOR_ID_LENOVO 0x17ef | 522 | #define VENDOR_ID_LENOVO 0x17ef |
| 520 | #define VENDOR_ID_NVIDIA 0x0955 | 523 | #define VENDOR_ID_NVIDIA 0x0955 |
| @@ -1292,6 +1295,7 @@ static void intr_callback(struct urb *urb) | |||
| 1292 | } | 1295 | } |
| 1293 | } else { | 1296 | } else { |
| 1294 | if (netif_carrier_ok(tp->netdev)) { | 1297 | if (netif_carrier_ok(tp->netdev)) { |
| 1298 | netif_stop_queue(tp->netdev); | ||
| 1295 | set_bit(RTL8152_LINK_CHG, &tp->flags); | 1299 | set_bit(RTL8152_LINK_CHG, &tp->flags); |
| 1296 | schedule_delayed_work(&tp->schedule, 0); | 1300 | schedule_delayed_work(&tp->schedule, 0); |
| 1297 | } | 1301 | } |
| @@ -1362,6 +1366,7 @@ static int alloc_all_mem(struct r8152 *tp) | |||
| 1362 | spin_lock_init(&tp->rx_lock); | 1366 | spin_lock_init(&tp->rx_lock); |
| 1363 | spin_lock_init(&tp->tx_lock); | 1367 | spin_lock_init(&tp->tx_lock); |
| 1364 | INIT_LIST_HEAD(&tp->tx_free); | 1368 | INIT_LIST_HEAD(&tp->tx_free); |
| 1369 | INIT_LIST_HEAD(&tp->rx_done); | ||
| 1365 | skb_queue_head_init(&tp->tx_queue); | 1370 | skb_queue_head_init(&tp->tx_queue); |
| 1366 | skb_queue_head_init(&tp->rx_queue); | 1371 | skb_queue_head_init(&tp->rx_queue); |
| 1367 | 1372 | ||
| @@ -1730,7 +1735,7 @@ static u8 r8152_rx_csum(struct r8152 *tp, struct rx_desc *rx_desc) | |||
| 1730 | u8 checksum = CHECKSUM_NONE; | 1735 | u8 checksum = CHECKSUM_NONE; |
| 1731 | u32 opts2, opts3; | 1736 | u32 opts2, opts3; |
| 1732 | 1737 | ||
| 1733 | if (tp->version == RTL_VER_01 || tp->version == RTL_VER_02) | 1738 | if (!(tp->netdev->features & NETIF_F_RXCSUM)) |
| 1734 | goto return_result; | 1739 | goto return_result; |
| 1735 | 1740 | ||
| 1736 | opts2 = le32_to_cpu(rx_desc->opts2); | 1741 | opts2 = le32_to_cpu(rx_desc->opts2); |
| @@ -1936,6 +1941,9 @@ static int r8152_poll(struct napi_struct *napi, int budget) | |||
| 1936 | napi_complete(napi); | 1941 | napi_complete(napi); |
| 1937 | if (!list_empty(&tp->rx_done)) | 1942 | if (!list_empty(&tp->rx_done)) |
| 1938 | napi_schedule(napi); | 1943 | napi_schedule(napi); |
| 1944 | else if (!skb_queue_empty(&tp->tx_queue) && | ||
| 1945 | !list_empty(&tp->tx_free)) | ||
| 1946 | napi_schedule(napi); | ||
| 1939 | } | 1947 | } |
| 1940 | 1948 | ||
| 1941 | return work_done; | 1949 | return work_done; |
| @@ -2249,8 +2257,7 @@ static void r8153_set_rx_early_timeout(struct r8152 *tp) | |||
| 2249 | 2257 | ||
| 2250 | static void r8153_set_rx_early_size(struct r8152 *tp) | 2258 | static void r8153_set_rx_early_size(struct r8152 *tp) |
| 2251 | { | 2259 | { |
| 2252 | u32 mtu = tp->netdev->mtu; | 2260 | u32 ocp_data = (agg_buf_sz - rx_reserved_size(tp->netdev->mtu)) / 4; |
| 2253 | u32 ocp_data = (agg_buf_sz - mtu - VLAN_ETH_HLEN - VLAN_HLEN) / 8; | ||
| 2254 | 2261 | ||
| 2255 | ocp_write_word(tp, MCU_TYPE_USB, USB_RX_EARLY_SIZE, ocp_data); | 2262 | ocp_write_word(tp, MCU_TYPE_USB, USB_RX_EARLY_SIZE, ocp_data); |
| 2256 | } | 2263 | } |
| @@ -2895,7 +2902,8 @@ static void r8153_first_init(struct r8152 *tp) | |||
| 2895 | 2902 | ||
| 2896 | rtl_rx_vlan_en(tp, tp->netdev->features & NETIF_F_HW_VLAN_CTAG_RX); | 2903 | rtl_rx_vlan_en(tp, tp->netdev->features & NETIF_F_HW_VLAN_CTAG_RX); |
| 2897 | 2904 | ||
| 2898 | ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, RTL8153_RMS); | 2905 | ocp_data = tp->netdev->mtu + VLAN_ETH_HLEN + CRC_SIZE; |
| 2906 | ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, ocp_data); | ||
| 2899 | ocp_write_byte(tp, MCU_TYPE_PLA, PLA_MTPS, MTPS_JUMBO); | 2907 | ocp_write_byte(tp, MCU_TYPE_PLA, PLA_MTPS, MTPS_JUMBO); |
| 2900 | 2908 | ||
| 2901 | ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_TCR0); | 2909 | ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_TCR0); |
| @@ -2947,7 +2955,8 @@ static void r8153_enter_oob(struct r8152 *tp) | |||
| 2947 | usleep_range(1000, 2000); | 2955 | usleep_range(1000, 2000); |
| 2948 | } | 2956 | } |
| 2949 | 2957 | ||
| 2950 | ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, RTL8153_RMS); | 2958 | ocp_data = tp->netdev->mtu + VLAN_ETH_HLEN + CRC_SIZE; |
| 2959 | ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, ocp_data); | ||
| 2951 | 2960 | ||
| 2952 | ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_TEREDO_CFG); | 2961 | ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_TEREDO_CFG); |
| 2953 | ocp_data &= ~TEREDO_WAKE_MASK; | 2962 | ocp_data &= ~TEREDO_WAKE_MASK; |
| @@ -3155,10 +3164,16 @@ static void set_carrier(struct r8152 *tp) | |||
| 3155 | if (!netif_carrier_ok(netdev)) { | 3164 | if (!netif_carrier_ok(netdev)) { |
| 3156 | tp->rtl_ops.enable(tp); | 3165 | tp->rtl_ops.enable(tp); |
| 3157 | set_bit(RTL8152_SET_RX_MODE, &tp->flags); | 3166 | set_bit(RTL8152_SET_RX_MODE, &tp->flags); |
| 3167 | netif_stop_queue(netdev); | ||
| 3158 | napi_disable(&tp->napi); | 3168 | napi_disable(&tp->napi); |
| 3159 | netif_carrier_on(netdev); | 3169 | netif_carrier_on(netdev); |
| 3160 | rtl_start_rx(tp); | 3170 | rtl_start_rx(tp); |
| 3161 | napi_enable(&tp->napi); | 3171 | napi_enable(&tp->napi); |
| 3172 | netif_wake_queue(netdev); | ||
| 3173 | netif_info(tp, link, netdev, "carrier on\n"); | ||
| 3174 | } else if (netif_queue_stopped(netdev) && | ||
| 3175 | skb_queue_len(&tp->tx_queue) < tp->tx_qlen) { | ||
| 3176 | netif_wake_queue(netdev); | ||
| 3162 | } | 3177 | } |
| 3163 | } else { | 3178 | } else { |
| 3164 | if (netif_carrier_ok(netdev)) { | 3179 | if (netif_carrier_ok(netdev)) { |
| @@ -3166,6 +3181,7 @@ static void set_carrier(struct r8152 *tp) | |||
| 3166 | napi_disable(&tp->napi); | 3181 | napi_disable(&tp->napi); |
| 3167 | tp->rtl_ops.disable(tp); | 3182 | tp->rtl_ops.disable(tp); |
| 3168 | napi_enable(&tp->napi); | 3183 | napi_enable(&tp->napi); |
| 3184 | netif_info(tp, link, netdev, "carrier off\n"); | ||
| 3169 | } | 3185 | } |
| 3170 | } | 3186 | } |
| 3171 | } | 3187 | } |
| @@ -3515,12 +3531,12 @@ static int rtl8152_pre_reset(struct usb_interface *intf) | |||
| 3515 | if (!netif_running(netdev)) | 3531 | if (!netif_running(netdev)) |
| 3516 | return 0; | 3532 | return 0; |
| 3517 | 3533 | ||
| 3534 | netif_stop_queue(netdev); | ||
| 3518 | napi_disable(&tp->napi); | 3535 | napi_disable(&tp->napi); |
| 3519 | clear_bit(WORK_ENABLE, &tp->flags); | 3536 | clear_bit(WORK_ENABLE, &tp->flags); |
| 3520 | usb_kill_urb(tp->intr_urb); | 3537 | usb_kill_urb(tp->intr_urb); |
| 3521 | cancel_delayed_work_sync(&tp->schedule); | 3538 | cancel_delayed_work_sync(&tp->schedule); |
| 3522 | if (netif_carrier_ok(netdev)) { | 3539 | if (netif_carrier_ok(netdev)) { |
| 3523 | netif_stop_queue(netdev); | ||
| 3524 | mutex_lock(&tp->control); | 3540 | mutex_lock(&tp->control); |
| 3525 | tp->rtl_ops.disable(tp); | 3541 | tp->rtl_ops.disable(tp); |
| 3526 | mutex_unlock(&tp->control); | 3542 | mutex_unlock(&tp->control); |
| @@ -3545,12 +3561,17 @@ static int rtl8152_post_reset(struct usb_interface *intf) | |||
| 3545 | if (netif_carrier_ok(netdev)) { | 3561 | if (netif_carrier_ok(netdev)) { |
| 3546 | mutex_lock(&tp->control); | 3562 | mutex_lock(&tp->control); |
| 3547 | tp->rtl_ops.enable(tp); | 3563 | tp->rtl_ops.enable(tp); |
| 3564 | rtl_start_rx(tp); | ||
| 3548 | rtl8152_set_rx_mode(netdev); | 3565 | rtl8152_set_rx_mode(netdev); |
| 3549 | mutex_unlock(&tp->control); | 3566 | mutex_unlock(&tp->control); |
| 3550 | netif_wake_queue(netdev); | ||
| 3551 | } | 3567 | } |
| 3552 | 3568 | ||
| 3553 | napi_enable(&tp->napi); | 3569 | napi_enable(&tp->napi); |
| 3570 | netif_wake_queue(netdev); | ||
| 3571 | usb_submit_urb(tp->intr_urb, GFP_KERNEL); | ||
| 3572 | |||
| 3573 | if (!list_empty(&tp->rx_done)) | ||
| 3574 | napi_schedule(&tp->napi); | ||
| 3554 | 3575 | ||
| 3555 | return 0; | 3576 | return 0; |
| 3556 | } | 3577 | } |
| @@ -3572,43 +3593,98 @@ static bool delay_autosuspend(struct r8152 *tp) | |||
| 3572 | */ | 3593 | */ |
| 3573 | if (!sw_linking && tp->rtl_ops.in_nway(tp)) | 3594 | if (!sw_linking && tp->rtl_ops.in_nway(tp)) |
| 3574 | return true; | 3595 | return true; |
| 3596 | else if (!skb_queue_empty(&tp->tx_queue)) | ||
| 3597 | return true; | ||
| 3575 | else | 3598 | else |
| 3576 | return false; | 3599 | return false; |
| 3577 | } | 3600 | } |
| 3578 | 3601 | ||
| 3579 | static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message) | 3602 | static int rtl8152_runtime_suspend(struct r8152 *tp) |
| 3580 | { | 3603 | { |
| 3581 | struct r8152 *tp = usb_get_intfdata(intf); | ||
| 3582 | struct net_device *netdev = tp->netdev; | 3604 | struct net_device *netdev = tp->netdev; |
| 3583 | int ret = 0; | 3605 | int ret = 0; |
| 3584 | 3606 | ||
| 3585 | mutex_lock(&tp->control); | 3607 | set_bit(SELECTIVE_SUSPEND, &tp->flags); |
| 3608 | smp_mb__after_atomic(); | ||
| 3609 | |||
| 3610 | if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) { | ||
| 3611 | u32 rcr = 0; | ||
| 3586 | 3612 | ||
| 3587 | if (PMSG_IS_AUTO(message)) { | 3613 | if (delay_autosuspend(tp)) { |
| 3588 | if (netif_running(netdev) && delay_autosuspend(tp)) { | 3614 | clear_bit(SELECTIVE_SUSPEND, &tp->flags); |
| 3615 | smp_mb__after_atomic(); | ||
| 3589 | ret = -EBUSY; | 3616 | ret = -EBUSY; |
| 3590 | goto out1; | 3617 | goto out1; |
| 3591 | } | 3618 | } |
| 3592 | 3619 | ||
| 3593 | set_bit(SELECTIVE_SUSPEND, &tp->flags); | 3620 | if (netif_carrier_ok(netdev)) { |
| 3594 | } else { | 3621 | u32 ocp_data; |
| 3595 | netif_device_detach(netdev); | 3622 | |
| 3623 | rcr = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); | ||
| 3624 | ocp_data = rcr & ~RCR_ACPT_ALL; | ||
| 3625 | ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); | ||
| 3626 | rxdy_gated_en(tp, true); | ||
| 3627 | ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, | ||
| 3628 | PLA_OOB_CTRL); | ||
| 3629 | if (!(ocp_data & RXFIFO_EMPTY)) { | ||
| 3630 | rxdy_gated_en(tp, false); | ||
| 3631 | ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, rcr); | ||
| 3632 | clear_bit(SELECTIVE_SUSPEND, &tp->flags); | ||
| 3633 | smp_mb__after_atomic(); | ||
| 3634 | ret = -EBUSY; | ||
| 3635 | goto out1; | ||
| 3636 | } | ||
| 3637 | } | ||
| 3638 | |||
| 3639 | clear_bit(WORK_ENABLE, &tp->flags); | ||
| 3640 | usb_kill_urb(tp->intr_urb); | ||
| 3641 | |||
| 3642 | tp->rtl_ops.autosuspend_en(tp, true); | ||
| 3643 | |||
| 3644 | if (netif_carrier_ok(netdev)) { | ||
| 3645 | napi_disable(&tp->napi); | ||
| 3646 | rtl_stop_rx(tp); | ||
| 3647 | rxdy_gated_en(tp, false); | ||
| 3648 | ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, rcr); | ||
| 3649 | napi_enable(&tp->napi); | ||
| 3650 | } | ||
| 3596 | } | 3651 | } |
| 3597 | 3652 | ||
| 3653 | out1: | ||
| 3654 | return ret; | ||
| 3655 | } | ||
| 3656 | |||
| 3657 | static int rtl8152_system_suspend(struct r8152 *tp) | ||
| 3658 | { | ||
| 3659 | struct net_device *netdev = tp->netdev; | ||
| 3660 | int ret = 0; | ||
| 3661 | |||
| 3662 | netif_device_detach(netdev); | ||
| 3663 | |||
| 3598 | if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) { | 3664 | if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) { |
| 3599 | clear_bit(WORK_ENABLE, &tp->flags); | 3665 | clear_bit(WORK_ENABLE, &tp->flags); |
| 3600 | usb_kill_urb(tp->intr_urb); | 3666 | usb_kill_urb(tp->intr_urb); |
| 3601 | napi_disable(&tp->napi); | 3667 | napi_disable(&tp->napi); |
| 3602 | if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) { | 3668 | cancel_delayed_work_sync(&tp->schedule); |
| 3603 | rtl_stop_rx(tp); | 3669 | tp->rtl_ops.down(tp); |
| 3604 | tp->rtl_ops.autosuspend_en(tp, true); | ||
| 3605 | } else { | ||
| 3606 | cancel_delayed_work_sync(&tp->schedule); | ||
| 3607 | tp->rtl_ops.down(tp); | ||
| 3608 | } | ||
| 3609 | napi_enable(&tp->napi); | 3670 | napi_enable(&tp->napi); |
| 3610 | } | 3671 | } |
| 3611 | out1: | 3672 | |
| 3673 | return ret; | ||
| 3674 | } | ||
| 3675 | |||
| 3676 | static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message) | ||
| 3677 | { | ||
| 3678 | struct r8152 *tp = usb_get_intfdata(intf); | ||
| 3679 | int ret; | ||
| 3680 | |||
| 3681 | mutex_lock(&tp->control); | ||
| 3682 | |||
| 3683 | if (PMSG_IS_AUTO(message)) | ||
| 3684 | ret = rtl8152_runtime_suspend(tp); | ||
| 3685 | else | ||
| 3686 | ret = rtl8152_system_suspend(tp); | ||
| 3687 | |||
| 3612 | mutex_unlock(&tp->control); | 3688 | mutex_unlock(&tp->control); |
| 3613 | 3689 | ||
| 3614 | return ret; | 3690 | return ret; |
| @@ -3629,12 +3705,25 @@ static int rtl8152_resume(struct usb_interface *intf) | |||
| 3629 | if (netif_running(tp->netdev) && tp->netdev->flags & IFF_UP) { | 3705 | if (netif_running(tp->netdev) && tp->netdev->flags & IFF_UP) { |
| 3630 | if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) { | 3706 | if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) { |
| 3631 | tp->rtl_ops.autosuspend_en(tp, false); | 3707 | tp->rtl_ops.autosuspend_en(tp, false); |
| 3632 | clear_bit(SELECTIVE_SUSPEND, &tp->flags); | ||
| 3633 | napi_disable(&tp->napi); | 3708 | napi_disable(&tp->napi); |
| 3634 | set_bit(WORK_ENABLE, &tp->flags); | 3709 | set_bit(WORK_ENABLE, &tp->flags); |
| 3635 | if (netif_carrier_ok(tp->netdev)) | 3710 | |
| 3636 | rtl_start_rx(tp); | 3711 | if (netif_carrier_ok(tp->netdev)) { |
| 3712 | if (rtl8152_get_speed(tp) & LINK_STATUS) { | ||
| 3713 | rtl_start_rx(tp); | ||
| 3714 | } else { | ||
| 3715 | netif_carrier_off(tp->netdev); | ||
| 3716 | tp->rtl_ops.disable(tp); | ||
| 3717 | netif_info(tp, link, tp->netdev, | ||
| 3718 | "linking down\n"); | ||
| 3719 | } | ||
| 3720 | } | ||
| 3721 | |||
| 3637 | napi_enable(&tp->napi); | 3722 | napi_enable(&tp->napi); |
| 3723 | clear_bit(SELECTIVE_SUSPEND, &tp->flags); | ||
| 3724 | smp_mb__after_atomic(); | ||
| 3725 | if (!list_empty(&tp->rx_done)) | ||
| 3726 | napi_schedule(&tp->napi); | ||
| 3638 | } else { | 3727 | } else { |
| 3639 | tp->rtl_ops.up(tp); | 3728 | tp->rtl_ops.up(tp); |
| 3640 | netif_carrier_off(tp->netdev); | 3729 | netif_carrier_off(tp->netdev); |
| @@ -4116,14 +4205,12 @@ static int rtl8152_change_mtu(struct net_device *dev, int new_mtu) | |||
| 4116 | switch (tp->version) { | 4205 | switch (tp->version) { |
| 4117 | case RTL_VER_01: | 4206 | case RTL_VER_01: |
| 4118 | case RTL_VER_02: | 4207 | case RTL_VER_02: |
| 4119 | return eth_change_mtu(dev, new_mtu); | 4208 | dev->mtu = new_mtu; |
| 4209 | return 0; | ||
| 4120 | default: | 4210 | default: |
| 4121 | break; | 4211 | break; |
| 4122 | } | 4212 | } |
| 4123 | 4213 | ||
| 4124 | if (new_mtu < 68 || new_mtu > RTL8153_MAX_MTU) | ||
| 4125 | return -EINVAL; | ||
| 4126 | |||
| 4127 | ret = usb_autopm_get_interface(tp->intf); | 4214 | ret = usb_autopm_get_interface(tp->intf); |
| 4128 | if (ret < 0) | 4215 | if (ret < 0) |
| 4129 | return ret; | 4216 | return ret; |
| @@ -4132,8 +4219,14 @@ static int rtl8152_change_mtu(struct net_device *dev, int new_mtu) | |||
| 4132 | 4219 | ||
| 4133 | dev->mtu = new_mtu; | 4220 | dev->mtu = new_mtu; |
| 4134 | 4221 | ||
| 4135 | if (netif_running(dev) && netif_carrier_ok(dev)) | 4222 | if (netif_running(dev)) { |
| 4136 | r8153_set_rx_early_size(tp); | 4223 | u32 rms = new_mtu + VLAN_ETH_HLEN + CRC_SIZE; |
| 4224 | |||
| 4225 | ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, rms); | ||
| 4226 | |||
| 4227 | if (netif_carrier_ok(dev)) | ||
| 4228 | r8153_set_rx_early_size(tp); | ||
| 4229 | } | ||
| 4137 | 4230 | ||
| 4138 | mutex_unlock(&tp->control); | 4231 | mutex_unlock(&tp->control); |
| 4139 | 4232 | ||
| @@ -4310,9 +4403,26 @@ static int rtl8152_probe(struct usb_interface *intf, | |||
| 4310 | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | | 4403 | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | |
| 4311 | NETIF_F_IPV6_CSUM | NETIF_F_TSO6; | 4404 | NETIF_F_IPV6_CSUM | NETIF_F_TSO6; |
| 4312 | 4405 | ||
| 4406 | if (tp->version == RTL_VER_01) { | ||
| 4407 | netdev->features &= ~NETIF_F_RXCSUM; | ||
| 4408 | netdev->hw_features &= ~NETIF_F_RXCSUM; | ||
| 4409 | } | ||
| 4410 | |||
| 4313 | netdev->ethtool_ops = &ops; | 4411 | netdev->ethtool_ops = &ops; |
| 4314 | netif_set_gso_max_size(netdev, RTL_LIMITED_TSO_SIZE); | 4412 | netif_set_gso_max_size(netdev, RTL_LIMITED_TSO_SIZE); |
| 4315 | 4413 | ||
| 4414 | /* MTU range: 68 - 1500 or 9194 */ | ||
| 4415 | netdev->min_mtu = ETH_MIN_MTU; | ||
| 4416 | switch (tp->version) { | ||
| 4417 | case RTL_VER_01: | ||
| 4418 | case RTL_VER_02: | ||
| 4419 | netdev->max_mtu = ETH_DATA_LEN; | ||
| 4420 | break; | ||
| 4421 | default: | ||
| 4422 | netdev->max_mtu = RTL8153_MAX_MTU; | ||
| 4423 | break; | ||
| 4424 | } | ||
| 4425 | |||
| 4316 | tp->mii.dev = netdev; | 4426 | tp->mii.dev = netdev; |
| 4317 | tp->mii.mdio_read = read_mii_word; | 4427 | tp->mii.mdio_read = read_mii_word; |
| 4318 | tp->mii.mdio_write = write_mii_word; | 4428 | tp->mii.mdio_write = write_mii_word; |
| @@ -4412,9 +4522,15 @@ static void rtl8152_disconnect(struct usb_interface *intf) | |||
| 4412 | static struct usb_device_id rtl8152_table[] = { | 4522 | static struct usb_device_id rtl8152_table[] = { |
| 4413 | {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8152)}, | 4523 | {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8152)}, |
| 4414 | {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8153)}, | 4524 | {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8153)}, |
| 4525 | {REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07ab)}, | ||
| 4526 | {REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07c6)}, | ||
| 4415 | {REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101)}, | 4527 | {REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101)}, |
| 4416 | {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7205)}, | ||
| 4417 | {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x304f)}, | 4528 | {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x304f)}, |
| 4529 | {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3062)}, | ||
| 4530 | {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3069)}, | ||
| 4531 | {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7205)}, | ||
| 4532 | {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x720c)}, | ||
| 4533 | {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7214)}, | ||
| 4418 | {REALTEK_USB_DEVICE(VENDOR_ID_NVIDIA, 0x09ff)}, | 4534 | {REALTEK_USB_DEVICE(VENDOR_ID_NVIDIA, 0x09ff)}, |
| 4419 | {} | 4535 | {} |
| 4420 | }; | 4536 | }; |
diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c index 4f4f71b2966b..c5b21138b7eb 100644 --- a/drivers/net/usb/rndis_host.c +++ b/drivers/net/usb/rndis_host.c | |||
| @@ -383,7 +383,7 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags) | |||
| 383 | 383 | ||
| 384 | /* REVISIT: peripheral "alignment" request is ignored ... */ | 384 | /* REVISIT: peripheral "alignment" request is ignored ... */ |
| 385 | dev_dbg(&intf->dev, | 385 | dev_dbg(&intf->dev, |
| 386 | "hard mtu %u (%u from dev), rx buflen %Zu, align %d\n", | 386 | "hard mtu %u (%u from dev), rx buflen %zu, align %d\n", |
| 387 | dev->hard_mtu, tmp, dev->rx_urb_size, | 387 | dev->hard_mtu, tmp, dev->rx_urb_size, |
| 388 | 1 << le32_to_cpu(u.init_c->packet_alignment)); | 388 | 1 << le32_to_cpu(u.init_c->packet_alignment)); |
| 389 | 389 | ||
diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c index 7c72bfac89d0..c81c79110cef 100644 --- a/drivers/net/usb/rtl8150.c +++ b/drivers/net/usb/rtl8150.c | |||
| @@ -14,7 +14,7 @@ | |||
| 14 | #include <linux/mii.h> | 14 | #include <linux/mii.h> |
| 15 | #include <linux/ethtool.h> | 15 | #include <linux/ethtool.h> |
| 16 | #include <linux/usb.h> | 16 | #include <linux/usb.h> |
| 17 | #include <asm/uaccess.h> | 17 | #include <linux/uaccess.h> |
| 18 | 18 | ||
| 19 | /* Version Information */ | 19 | /* Version Information */ |
| 20 | #define DRIVER_VERSION "v0.6.2 (2004/08/27)" | 20 | #define DRIVER_VERSION "v0.6.2 (2004/08/27)" |
| @@ -155,16 +155,36 @@ static const char driver_name [] = "rtl8150"; | |||
| 155 | */ | 155 | */ |
| 156 | static int get_registers(rtl8150_t * dev, u16 indx, u16 size, void *data) | 156 | static int get_registers(rtl8150_t * dev, u16 indx, u16 size, void *data) |
| 157 | { | 157 | { |
| 158 | return usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), | 158 | void *buf; |
| 159 | RTL8150_REQ_GET_REGS, RTL8150_REQT_READ, | 159 | int ret; |
| 160 | indx, 0, data, size, 500); | 160 | |
| 161 | buf = kmalloc(size, GFP_NOIO); | ||
| 162 | if (!buf) | ||
| 163 | return -ENOMEM; | ||
| 164 | |||
| 165 | ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), | ||
| 166 | RTL8150_REQ_GET_REGS, RTL8150_REQT_READ, | ||
| 167 | indx, 0, buf, size, 500); | ||
| 168 | if (ret > 0 && ret <= size) | ||
| 169 | memcpy(data, buf, ret); | ||
| 170 | kfree(buf); | ||
| 171 | return ret; | ||
| 161 | } | 172 | } |
| 162 | 173 | ||
| 163 | static int set_registers(rtl8150_t * dev, u16 indx, u16 size, void *data) | 174 | static int set_registers(rtl8150_t * dev, u16 indx, u16 size, const void *data) |
| 164 | { | 175 | { |
| 165 | return usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), | 176 | void *buf; |
| 166 | RTL8150_REQ_SET_REGS, RTL8150_REQT_WRITE, | 177 | int ret; |
| 167 | indx, 0, data, size, 500); | 178 | |
| 179 | buf = kmemdup(data, size, GFP_NOIO); | ||
| 180 | if (!buf) | ||
| 181 | return -ENOMEM; | ||
| 182 | |||
| 183 | ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), | ||
| 184 | RTL8150_REQ_SET_REGS, RTL8150_REQT_WRITE, | ||
| 185 | indx, 0, buf, size, 500); | ||
| 186 | kfree(buf); | ||
| 187 | return ret; | ||
| 168 | } | 188 | } |
| 169 | 189 | ||
| 170 | static void async_set_reg_cb(struct urb *urb) | 190 | static void async_set_reg_cb(struct urb *urb) |
| @@ -847,7 +867,6 @@ static const struct net_device_ops rtl8150_netdev_ops = { | |||
| 847 | .ndo_set_rx_mode = rtl8150_set_multicast, | 867 | .ndo_set_rx_mode = rtl8150_set_multicast, |
| 848 | .ndo_set_mac_address = rtl8150_set_mac_address, | 868 | .ndo_set_mac_address = rtl8150_set_mac_address, |
| 849 | 869 | ||
| 850 | .ndo_change_mtu = eth_change_mtu, | ||
| 851 | .ndo_validate_addr = eth_validate_addr, | 870 | .ndo_validate_addr = eth_validate_addr, |
| 852 | }; | 871 | }; |
| 853 | 872 | ||
diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c index a251588762ec..ac69f28d92d2 100644 --- a/drivers/net/usb/sierra_net.c +++ b/drivers/net/usb/sierra_net.c | |||
| @@ -73,8 +73,6 @@ static atomic_t iface_counter = ATOMIC_INIT(0); | |||
| 73 | /* Private data structure */ | 73 | /* Private data structure */ |
| 74 | struct sierra_net_data { | 74 | struct sierra_net_data { |
| 75 | 75 | ||
| 76 | u8 ethr_hdr_tmpl[ETH_HLEN]; /* ethernet header template for rx'd pkts */ | ||
| 77 | |||
| 78 | u16 link_up; /* air link up or down */ | 76 | u16 link_up; /* air link up or down */ |
| 79 | u8 tx_hdr_template[4]; /* part of HIP hdr for tx'd packets */ | 77 | u8 tx_hdr_template[4]; /* part of HIP hdr for tx'd packets */ |
| 80 | 78 | ||
| @@ -122,6 +120,7 @@ struct param { | |||
| 122 | 120 | ||
| 123 | /* LSI Protocol types */ | 121 | /* LSI Protocol types */ |
| 124 | #define SIERRA_NET_PROTOCOL_UMTS 0x01 | 122 | #define SIERRA_NET_PROTOCOL_UMTS 0x01 |
| 123 | #define SIERRA_NET_PROTOCOL_UMTS_DS 0x04 | ||
| 125 | /* LSI Coverage */ | 124 | /* LSI Coverage */ |
| 126 | #define SIERRA_NET_COVERAGE_NONE 0x00 | 125 | #define SIERRA_NET_COVERAGE_NONE 0x00 |
| 127 | #define SIERRA_NET_COVERAGE_NOPACKET 0x01 | 126 | #define SIERRA_NET_COVERAGE_NOPACKET 0x01 |
| @@ -129,7 +128,8 @@ struct param { | |||
| 129 | /* LSI Session */ | 128 | /* LSI Session */ |
| 130 | #define SIERRA_NET_SESSION_IDLE 0x00 | 129 | #define SIERRA_NET_SESSION_IDLE 0x00 |
| 131 | /* LSI Link types */ | 130 | /* LSI Link types */ |
| 132 | #define SIERRA_NET_AS_LINK_TYPE_IPv4 0x00 | 131 | #define SIERRA_NET_AS_LINK_TYPE_IPV4 0x00 |
| 132 | #define SIERRA_NET_AS_LINK_TYPE_IPV6 0x02 | ||
| 133 | 133 | ||
| 134 | struct lsi_umts { | 134 | struct lsi_umts { |
| 135 | u8 protocol; | 135 | u8 protocol; |
| @@ -137,9 +137,14 @@ struct lsi_umts { | |||
| 137 | __be16 length; | 137 | __be16 length; |
| 138 | /* eventually use a union for the rest - assume umts for now */ | 138 | /* eventually use a union for the rest - assume umts for now */ |
| 139 | u8 coverage; | 139 | u8 coverage; |
| 140 | u8 unused2[41]; | 140 | u8 network_len; /* network name len */ |
| 141 | u8 network[40]; /* network name (UCS2, bigendian) */ | ||
| 141 | u8 session_state; | 142 | u8 session_state; |
| 142 | u8 unused3[33]; | 143 | u8 unused3[33]; |
| 144 | } __packed; | ||
| 145 | |||
| 146 | struct lsi_umts_single { | ||
| 147 | struct lsi_umts lsi; | ||
| 143 | u8 link_type; | 148 | u8 link_type; |
| 144 | u8 pdp_addr_len; /* NW-supplied PDP address len */ | 149 | u8 pdp_addr_len; /* NW-supplied PDP address len */ |
| 145 | u8 pdp_addr[16]; /* NW-supplied PDP address (bigendian)) */ | 150 | u8 pdp_addr[16]; /* NW-supplied PDP address (bigendian)) */ |
| @@ -158,14 +163,34 @@ struct lsi_umts { | |||
| 158 | u8 reserved[8]; | 163 | u8 reserved[8]; |
| 159 | } __packed; | 164 | } __packed; |
| 160 | 165 | ||
| 166 | struct lsi_umts_dual { | ||
| 167 | struct lsi_umts lsi; | ||
| 168 | u8 pdp_addr4_len; /* NW-supplied PDP IPv4 address len */ | ||
| 169 | u8 pdp_addr4[4]; /* NW-supplied PDP IPv4 address (bigendian)) */ | ||
| 170 | u8 pdp_addr6_len; /* NW-supplied PDP IPv6 address len */ | ||
| 171 | u8 pdp_addr6[16]; /* NW-supplied PDP IPv6 address (bigendian)) */ | ||
| 172 | u8 unused4[23]; | ||
| 173 | u8 dns1_addr4_len; /* NW-supplied 1st DNS v4 address len (bigendian) */ | ||
| 174 | u8 dns1_addr4[4]; /* NW-supplied 1st DNS v4 address */ | ||
| 175 | u8 dns1_addr6_len; /* NW-supplied 1st DNS v6 address len */ | ||
| 176 | u8 dns1_addr6[16]; /* NW-supplied 1st DNS v6 address (bigendian)*/ | ||
| 177 | u8 dns2_addr4_len; /* NW-supplied 2nd DNS v4 address len (bigendian) */ | ||
| 178 | u8 dns2_addr4[4]; /* NW-supplied 2nd DNS v4 address */ | ||
| 179 | u8 dns2_addr6_len; /* NW-supplied 2nd DNS v6 address len */ | ||
| 180 | u8 dns2_addr6[16]; /* NW-supplied 2nd DNS v6 address (bigendian)*/ | ||
| 181 | u8 unused5[68]; | ||
| 182 | } __packed; | ||
| 183 | |||
| 161 | #define SIERRA_NET_LSI_COMMON_LEN 4 | 184 | #define SIERRA_NET_LSI_COMMON_LEN 4 |
| 162 | #define SIERRA_NET_LSI_UMTS_LEN (sizeof(struct lsi_umts)) | 185 | #define SIERRA_NET_LSI_UMTS_LEN (sizeof(struct lsi_umts_single)) |
| 163 | #define SIERRA_NET_LSI_UMTS_STATUS_LEN \ | 186 | #define SIERRA_NET_LSI_UMTS_STATUS_LEN \ |
| 164 | (SIERRA_NET_LSI_UMTS_LEN - SIERRA_NET_LSI_COMMON_LEN) | 187 | (SIERRA_NET_LSI_UMTS_LEN - SIERRA_NET_LSI_COMMON_LEN) |
| 188 | #define SIERRA_NET_LSI_UMTS_DS_LEN (sizeof(struct lsi_umts_dual)) | ||
| 189 | #define SIERRA_NET_LSI_UMTS_DS_STATUS_LEN \ | ||
| 190 | (SIERRA_NET_LSI_UMTS_DS_LEN - SIERRA_NET_LSI_COMMON_LEN) | ||
| 165 | 191 | ||
| 166 | /* Forward definitions */ | 192 | /* Forward definitions */ |
| 167 | static void sierra_sync_timer(unsigned long syncdata); | 193 | static void sierra_sync_timer(unsigned long syncdata); |
| 168 | static int sierra_net_change_mtu(struct net_device *net, int new_mtu); | ||
| 169 | 194 | ||
| 170 | /* Our own net device operations structure */ | 195 | /* Our own net device operations structure */ |
| 171 | static const struct net_device_ops sierra_net_device_ops = { | 196 | static const struct net_device_ops sierra_net_device_ops = { |
| @@ -173,7 +198,7 @@ static const struct net_device_ops sierra_net_device_ops = { | |||
| 173 | .ndo_stop = usbnet_stop, | 198 | .ndo_stop = usbnet_stop, |
| 174 | .ndo_start_xmit = usbnet_start_xmit, | 199 | .ndo_start_xmit = usbnet_start_xmit, |
| 175 | .ndo_tx_timeout = usbnet_tx_timeout, | 200 | .ndo_tx_timeout = usbnet_tx_timeout, |
| 176 | .ndo_change_mtu = sierra_net_change_mtu, | 201 | .ndo_change_mtu = usbnet_change_mtu, |
| 177 | .ndo_set_mac_address = eth_mac_addr, | 202 | .ndo_set_mac_address = eth_mac_addr, |
| 178 | .ndo_validate_addr = eth_validate_addr, | 203 | .ndo_validate_addr = eth_validate_addr, |
| 179 | }; | 204 | }; |
| @@ -191,10 +216,11 @@ static inline void sierra_net_set_private(struct usbnet *dev, | |||
| 191 | dev->data[0] = (unsigned long)priv; | 216 | dev->data[0] = (unsigned long)priv; |
| 192 | } | 217 | } |
| 193 | 218 | ||
| 194 | /* is packet IPv4 */ | 219 | /* is packet IPv4/IPv6 */ |
| 195 | static inline int is_ip(struct sk_buff *skb) | 220 | static inline int is_ip(struct sk_buff *skb) |
| 196 | { | 221 | { |
| 197 | return skb->protocol == cpu_to_be16(ETH_P_IP); | 222 | return skb->protocol == cpu_to_be16(ETH_P_IP) || |
| 223 | skb->protocol == cpu_to_be16(ETH_P_IPV6); | ||
| 198 | } | 224 | } |
| 199 | 225 | ||
| 200 | /* | 226 | /* |
| @@ -350,49 +376,54 @@ static inline int sierra_net_is_valid_addrlen(u8 len) | |||
| 350 | static int sierra_net_parse_lsi(struct usbnet *dev, char *data, int datalen) | 376 | static int sierra_net_parse_lsi(struct usbnet *dev, char *data, int datalen) |
| 351 | { | 377 | { |
| 352 | struct lsi_umts *lsi = (struct lsi_umts *)data; | 378 | struct lsi_umts *lsi = (struct lsi_umts *)data; |
| 379 | u32 expected_length; | ||
| 353 | 380 | ||
| 354 | if (datalen < sizeof(struct lsi_umts)) { | 381 | if (datalen < sizeof(struct lsi_umts_single)) { |
| 355 | netdev_err(dev->net, "%s: Data length %d, exp %Zu\n", | 382 | netdev_err(dev->net, "%s: Data length %d, exp >= %zu\n", |
| 356 | __func__, datalen, | 383 | __func__, datalen, sizeof(struct lsi_umts_single)); |
| 357 | sizeof(struct lsi_umts)); | ||
| 358 | return -1; | 384 | return -1; |
| 359 | } | 385 | } |
| 360 | 386 | ||
| 361 | if (lsi->length != cpu_to_be16(SIERRA_NET_LSI_UMTS_STATUS_LEN)) { | 387 | /* Validate the session state */ |
| 362 | netdev_err(dev->net, "%s: LSI_UMTS_STATUS_LEN %d, exp %u\n", | 388 | if (lsi->session_state == SIERRA_NET_SESSION_IDLE) { |
| 363 | __func__, be16_to_cpu(lsi->length), | 389 | netdev_err(dev->net, "Session idle, 0x%02x\n", |
| 364 | (u32)SIERRA_NET_LSI_UMTS_STATUS_LEN); | 390 | lsi->session_state); |
| 365 | return -1; | 391 | return 0; |
| 366 | } | 392 | } |
| 367 | 393 | ||
| 368 | /* Validate the protocol - only support UMTS for now */ | 394 | /* Validate the protocol - only support UMTS for now */ |
| 369 | if (lsi->protocol != SIERRA_NET_PROTOCOL_UMTS) { | 395 | if (lsi->protocol == SIERRA_NET_PROTOCOL_UMTS) { |
| 396 | struct lsi_umts_single *single = (struct lsi_umts_single *)lsi; | ||
| 397 | |||
| 398 | /* Validate the link type */ | ||
| 399 | if (single->link_type != SIERRA_NET_AS_LINK_TYPE_IPV4 && | ||
| 400 | single->link_type != SIERRA_NET_AS_LINK_TYPE_IPV6) { | ||
| 401 | netdev_err(dev->net, "Link type unsupported: 0x%02x\n", | ||
| 402 | single->link_type); | ||
| 403 | return -1; | ||
| 404 | } | ||
| 405 | expected_length = SIERRA_NET_LSI_UMTS_STATUS_LEN; | ||
| 406 | } else if (lsi->protocol == SIERRA_NET_PROTOCOL_UMTS_DS) { | ||
| 407 | expected_length = SIERRA_NET_LSI_UMTS_DS_STATUS_LEN; | ||
| 408 | } else { | ||
| 370 | netdev_err(dev->net, "Protocol unsupported, 0x%02x\n", | 409 | netdev_err(dev->net, "Protocol unsupported, 0x%02x\n", |
| 371 | lsi->protocol); | 410 | lsi->protocol); |
| 372 | return -1; | 411 | return -1; |
| 373 | } | 412 | } |
| 374 | 413 | ||
| 375 | /* Validate the link type */ | 414 | if (be16_to_cpu(lsi->length) != expected_length) { |
| 376 | if (lsi->link_type != SIERRA_NET_AS_LINK_TYPE_IPv4) { | 415 | netdev_err(dev->net, "%s: LSI_UMTS_STATUS_LEN %d, exp %u\n", |
| 377 | netdev_err(dev->net, "Link type unsupported: 0x%02x\n", | 416 | __func__, be16_to_cpu(lsi->length), expected_length); |
| 378 | lsi->link_type); | ||
| 379 | return -1; | 417 | return -1; |
| 380 | } | 418 | } |
| 381 | 419 | ||
| 382 | /* Validate the coverage */ | 420 | /* Validate the coverage */ |
| 383 | if (lsi->coverage == SIERRA_NET_COVERAGE_NONE | 421 | if (lsi->coverage == SIERRA_NET_COVERAGE_NONE || |
| 384 | || lsi->coverage == SIERRA_NET_COVERAGE_NOPACKET) { | 422 | lsi->coverage == SIERRA_NET_COVERAGE_NOPACKET) { |
| 385 | netdev_err(dev->net, "No coverage, 0x%02x\n", lsi->coverage); | 423 | netdev_err(dev->net, "No coverage, 0x%02x\n", lsi->coverage); |
| 386 | return 0; | 424 | return 0; |
| 387 | } | 425 | } |
| 388 | 426 | ||
| 389 | /* Validate the session state */ | ||
| 390 | if (lsi->session_state == SIERRA_NET_SESSION_IDLE) { | ||
| 391 | netdev_err(dev->net, "Session idle, 0x%02x\n", | ||
| 392 | lsi->session_state); | ||
| 393 | return 0; | ||
| 394 | } | ||
| 395 | |||
| 396 | /* Set link_sense true */ | 427 | /* Set link_sense true */ |
| 397 | return 1; | 428 | return 1; |
| 398 | } | 429 | } |
| @@ -622,15 +653,6 @@ static const struct ethtool_ops sierra_net_ethtool_ops = { | |||
| 622 | .nway_reset = usbnet_nway_reset, | 653 | .nway_reset = usbnet_nway_reset, |
| 623 | }; | 654 | }; |
| 624 | 655 | ||
| 625 | /* MTU can not be more than 1500 bytes, enforce it. */ | ||
| 626 | static int sierra_net_change_mtu(struct net_device *net, int new_mtu) | ||
| 627 | { | ||
| 628 | if (new_mtu > SIERRA_NET_MAX_SUPPORTED_MTU) | ||
| 629 | return -EINVAL; | ||
| 630 | |||
| 631 | return usbnet_change_mtu(net, new_mtu); | ||
| 632 | } | ||
| 633 | |||
| 634 | static int sierra_net_get_fw_attr(struct usbnet *dev, u16 *datap) | 656 | static int sierra_net_get_fw_attr(struct usbnet *dev, u16 *datap) |
| 635 | { | 657 | { |
| 636 | int result = 0; | 658 | int result = 0; |
| @@ -662,7 +684,6 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf) | |||
| 662 | u8 numendpoints; | 684 | u8 numendpoints; |
| 663 | u16 fwattr = 0; | 685 | u16 fwattr = 0; |
| 664 | int status; | 686 | int status; |
| 665 | struct ethhdr *eth; | ||
| 666 | struct sierra_net_data *priv; | 687 | struct sierra_net_data *priv; |
| 667 | static const u8 sync_tmplate[sizeof(priv->sync_msg)] = { | 688 | static const u8 sync_tmplate[sizeof(priv->sync_msg)] = { |
| 668 | 0x00, 0x00, SIERRA_NET_HIP_MSYNC_ID, 0x00}; | 689 | 0x00, 0x00, SIERRA_NET_HIP_MSYNC_ID, 0x00}; |
| @@ -700,11 +721,6 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf) | |||
| 700 | dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter); | 721 | dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter); |
| 701 | dev->net->dev_addr[ETH_ALEN-1] = ifacenum; | 722 | dev->net->dev_addr[ETH_ALEN-1] = ifacenum; |
| 702 | 723 | ||
| 703 | /* we will have to manufacture ethernet headers, prepare template */ | ||
| 704 | eth = (struct ethhdr *)priv->ethr_hdr_tmpl; | ||
| 705 | memcpy(ð->h_dest, dev->net->dev_addr, ETH_ALEN); | ||
| 706 | eth->h_proto = cpu_to_be16(ETH_P_IP); | ||
| 707 | |||
| 708 | /* prepare shutdown message template */ | 724 | /* prepare shutdown message template */ |
| 709 | memcpy(priv->shdwn_msg, shdwn_tmplate, sizeof(priv->shdwn_msg)); | 725 | memcpy(priv->shdwn_msg, shdwn_tmplate, sizeof(priv->shdwn_msg)); |
| 710 | /* set context index initially to 0 - prepares tx hdr template */ | 726 | /* set context index initially to 0 - prepares tx hdr template */ |
| @@ -720,6 +736,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf) | |||
| 720 | 736 | ||
| 721 | dev->net->hard_header_len += SIERRA_NET_HIP_EXT_HDR_LEN; | 737 | dev->net->hard_header_len += SIERRA_NET_HIP_EXT_HDR_LEN; |
| 722 | dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; | 738 | dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; |
| 739 | dev->net->max_mtu = SIERRA_NET_MAX_SUPPORTED_MTU; | ||
| 723 | 740 | ||
| 724 | /* Set up the netdev */ | 741 | /* Set up the netdev */ |
| 725 | dev->net->flags |= IFF_NOARP; | 742 | dev->net->flags |= IFF_NOARP; |
| @@ -833,9 +850,14 @@ static int sierra_net_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | |||
| 833 | 850 | ||
| 834 | skb_pull(skb, hh.hdrlen); | 851 | skb_pull(skb, hh.hdrlen); |
| 835 | 852 | ||
| 836 | /* We are going to accept this packet, prepare it */ | 853 | /* We are going to accept this packet, prepare it. |
| 837 | memcpy(skb->data, sierra_net_get_private(dev)->ethr_hdr_tmpl, | 854 | * In case protocol is IPv6, keep it, otherwise force IPv4. |
| 838 | ETH_HLEN); | 855 | */ |
| 856 | skb_reset_mac_header(skb); | ||
| 857 | if (eth_hdr(skb)->h_proto != cpu_to_be16(ETH_P_IPV6)) | ||
| 858 | eth_hdr(skb)->h_proto = cpu_to_be16(ETH_P_IP); | ||
| 859 | eth_zero_addr(eth_hdr(skb)->h_source); | ||
| 860 | memcpy(eth_hdr(skb)->h_dest, dev->net->dev_addr, ETH_ALEN); | ||
| 839 | 861 | ||
| 840 | /* Last packet in batch handled by usbnet */ | 862 | /* Last packet in batch handled by usbnet */ |
| 841 | if (hh.payload_len.word == skb->len) | 863 | if (hh.payload_len.word == skb->len) |
diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c index 9af9799935db..190de9a90f73 100644 --- a/drivers/net/usb/smsc75xx.c +++ b/drivers/net/usb/smsc75xx.c | |||
| @@ -925,9 +925,6 @@ static int smsc75xx_change_mtu(struct net_device *netdev, int new_mtu) | |||
| 925 | struct usbnet *dev = netdev_priv(netdev); | 925 | struct usbnet *dev = netdev_priv(netdev); |
| 926 | int ret; | 926 | int ret; |
| 927 | 927 | ||
| 928 | if (new_mtu > MAX_SINGLE_PACKET_SIZE) | ||
| 929 | return -EINVAL; | ||
| 930 | |||
| 931 | ret = smsc75xx_set_rx_max_frame_length(dev, new_mtu + ETH_HLEN); | 928 | ret = smsc75xx_set_rx_max_frame_length(dev, new_mtu + ETH_HLEN); |
| 932 | if (ret < 0) { | 929 | if (ret < 0) { |
| 933 | netdev_warn(dev->net, "Failed to set mac rx frame length\n"); | 930 | netdev_warn(dev->net, "Failed to set mac rx frame length\n"); |
| @@ -1448,6 +1445,7 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf) | |||
| 1448 | dev->net->flags |= IFF_MULTICAST; | 1445 | dev->net->flags |= IFF_MULTICAST; |
| 1449 | dev->net->hard_header_len += SMSC75XX_TX_OVERHEAD; | 1446 | dev->net->hard_header_len += SMSC75XX_TX_OVERHEAD; |
| 1450 | dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; | 1447 | dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; |
| 1448 | dev->net->max_mtu = MAX_SINGLE_PACKET_SIZE; | ||
| 1451 | return 0; | 1449 | return 0; |
| 1452 | } | 1450 | } |
| 1453 | 1451 | ||
| @@ -2205,13 +2203,9 @@ static struct sk_buff *smsc75xx_tx_fixup(struct usbnet *dev, | |||
| 2205 | { | 2203 | { |
| 2206 | u32 tx_cmd_a, tx_cmd_b; | 2204 | u32 tx_cmd_a, tx_cmd_b; |
| 2207 | 2205 | ||
| 2208 | if (skb_headroom(skb) < SMSC75XX_TX_OVERHEAD) { | 2206 | if (skb_cow_head(skb, SMSC75XX_TX_OVERHEAD)) { |
| 2209 | struct sk_buff *skb2 = | ||
| 2210 | skb_copy_expand(skb, SMSC75XX_TX_OVERHEAD, 0, flags); | ||
| 2211 | dev_kfree_skb_any(skb); | 2207 | dev_kfree_skb_any(skb); |
| 2212 | skb = skb2; | 2208 | return NULL; |
| 2213 | if (!skb) | ||
| 2214 | return NULL; | ||
| 2215 | } | 2209 | } |
| 2216 | 2210 | ||
| 2217 | tx_cmd_a = (u32)(skb->len & TX_CMD_A_LEN) | TX_CMD_A_FCS; | 2211 | tx_cmd_a = (u32)(skb->len & TX_CMD_A_LEN) | TX_CMD_A_FCS; |
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 831aa33d078a..5f19fb0f025d 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c | |||
| @@ -2001,13 +2001,13 @@ static struct sk_buff *smsc95xx_tx_fixup(struct usbnet *dev, | |||
| 2001 | /* We do not advertise SG, so skbs should be already linearized */ | 2001 | /* We do not advertise SG, so skbs should be already linearized */ |
| 2002 | BUG_ON(skb_shinfo(skb)->nr_frags); | 2002 | BUG_ON(skb_shinfo(skb)->nr_frags); |
| 2003 | 2003 | ||
| 2004 | if (skb_headroom(skb) < overhead) { | 2004 | /* Make writable and expand header space by overhead if required */ |
| 2005 | struct sk_buff *skb2 = skb_copy_expand(skb, | 2005 | if (skb_cow_head(skb, overhead)) { |
| 2006 | overhead, 0, flags); | 2006 | /* Must deallocate here as returning NULL to indicate error |
| 2007 | * means the skb won't be deallocated in the caller. | ||
| 2008 | */ | ||
| 2007 | dev_kfree_skb_any(skb); | 2009 | dev_kfree_skb_any(skb); |
| 2008 | skb = skb2; | 2010 | return NULL; |
| 2009 | if (!skb) | ||
| 2010 | return NULL; | ||
| 2011 | } | 2011 | } |
| 2012 | 2012 | ||
| 2013 | if (csum) { | 2013 | if (csum) { |
diff --git a/drivers/net/usb/sr9700.c b/drivers/net/usb/sr9700.c index 4a1e9c489f1f..aadfe1d1c37e 100644 --- a/drivers/net/usb/sr9700.c +++ b/drivers/net/usb/sr9700.c | |||
| @@ -456,14 +456,9 @@ static struct sk_buff *sr9700_tx_fixup(struct usbnet *dev, struct sk_buff *skb, | |||
| 456 | 456 | ||
| 457 | len = skb->len; | 457 | len = skb->len; |
| 458 | 458 | ||
| 459 | if (skb_headroom(skb) < SR_TX_OVERHEAD) { | 459 | if (skb_cow_head(skb, SR_TX_OVERHEAD)) { |
| 460 | struct sk_buff *skb2; | ||
| 461 | |||
| 462 | skb2 = skb_copy_expand(skb, SR_TX_OVERHEAD, 0, flags); | ||
| 463 | dev_kfree_skb_any(skb); | 460 | dev_kfree_skb_any(skb); |
| 464 | skb = skb2; | 461 | return NULL; |
| 465 | if (!skb) | ||
| 466 | return NULL; | ||
| 467 | } | 462 | } |
| 468 | 463 | ||
| 469 | __skb_push(skb, SR_TX_OVERHEAD); | 464 | __skb_push(skb, SR_TX_OVERHEAD); |
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index d5071e364d40..453244805c52 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c | |||
| @@ -384,8 +384,6 @@ int usbnet_change_mtu (struct net_device *net, int new_mtu) | |||
| 384 | int old_hard_mtu = dev->hard_mtu; | 384 | int old_hard_mtu = dev->hard_mtu; |
| 385 | int old_rx_urb_size = dev->rx_urb_size; | 385 | int old_rx_urb_size = dev->rx_urb_size; |
| 386 | 386 | ||
| 387 | if (new_mtu <= 0) | ||
| 388 | return -EINVAL; | ||
| 389 | // no second zero-length packet read wanted after mtu-sized packets | 387 | // no second zero-length packet read wanted after mtu-sized packets |
| 390 | if ((ll_mtu % dev->maxpacket) == 0) | 388 | if ((ll_mtu % dev->maxpacket) == 0) |
| 391 | return -EDOM; | 389 | return -EDOM; |
| @@ -1669,6 +1667,8 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) | |||
| 1669 | * bind() should set rx_urb_size in that case. | 1667 | * bind() should set rx_urb_size in that case. |
| 1670 | */ | 1668 | */ |
| 1671 | dev->hard_mtu = net->mtu + net->hard_header_len; | 1669 | dev->hard_mtu = net->mtu + net->hard_header_len; |
| 1670 | net->min_mtu = 0; | ||
| 1671 | net->max_mtu = ETH_MAX_MTU; | ||
| 1672 | 1672 | ||
| 1673 | net->netdev_ops = &usbnet_netdev_ops; | 1673 | net->netdev_ops = &usbnet_netdev_ops; |
| 1674 | net->watchdog_timeo = TX_TIMEOUT_JIFFIES; | 1674 | net->watchdog_timeo = TX_TIMEOUT_JIFFIES; |
| @@ -1929,7 +1929,7 @@ static int __usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype, | |||
| 1929 | " value=0x%04x index=0x%04x size=%d\n", | 1929 | " value=0x%04x index=0x%04x size=%d\n", |
| 1930 | cmd, reqtype, value, index, size); | 1930 | cmd, reqtype, value, index, size); |
| 1931 | 1931 | ||
| 1932 | if (data) { | 1932 | if (size) { |
| 1933 | buf = kmalloc(size, GFP_KERNEL); | 1933 | buf = kmalloc(size, GFP_KERNEL); |
| 1934 | if (!buf) | 1934 | if (!buf) |
| 1935 | goto out; | 1935 | goto out; |
| @@ -1938,8 +1938,13 @@ static int __usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype, | |||
| 1938 | err = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), | 1938 | err = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), |
| 1939 | cmd, reqtype, value, index, buf, size, | 1939 | cmd, reqtype, value, index, buf, size, |
| 1940 | USB_CTRL_GET_TIMEOUT); | 1940 | USB_CTRL_GET_TIMEOUT); |
| 1941 | if (err > 0 && err <= size) | 1941 | if (err > 0 && err <= size) { |
| 1942 | memcpy(data, buf, err); | 1942 | if (data) |
| 1943 | memcpy(data, buf, err); | ||
| 1944 | else | ||
| 1945 | netdev_dbg(dev->net, | ||
| 1946 | "Huh? Data requested but thrown away.\n"); | ||
| 1947 | } | ||
| 1943 | kfree(buf); | 1948 | kfree(buf); |
| 1944 | out: | 1949 | out: |
| 1945 | return err; | 1950 | return err; |
| @@ -1960,7 +1965,13 @@ static int __usbnet_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype, | |||
| 1960 | buf = kmemdup(data, size, GFP_KERNEL); | 1965 | buf = kmemdup(data, size, GFP_KERNEL); |
| 1961 | if (!buf) | 1966 | if (!buf) |
| 1962 | goto out; | 1967 | goto out; |
| 1963 | } | 1968 | } else { |
| 1969 | if (size) { | ||
| 1970 | WARN_ON_ONCE(1); | ||
| 1971 | err = -EINVAL; | ||
| 1972 | goto out; | ||
| 1973 | } | ||
| 1974 | } | ||
| 1964 | 1975 | ||
| 1965 | err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), | 1976 | err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), |
| 1966 | cmd, reqtype, value, index, buf, size, | 1977 | cmd, reqtype, value, index, buf, size, |
