On Mon, May 21, 2018 at 08:47:29PM +0200, Karel Gardas wrote:
> 
> Hi,
> 
> I do have 2 USB ethernet adapters based on Realtek 8153:
> 
> TP-Link UE 300
> Lenovo Thinkpad USB 3.0 Gigabit Adapter
> 
> both adapters work well with 6.3-current on amd64 platform. If however I try 
> to use them on RPi3 with 6.3-current, both lead to system freeze. As I see it 
> now, there may be two possible ways to fix that:
> 
> 1) linux way: Linux consider Realtek 8153 non conformant to CDC Ethernet 
> specs. So it blacklists them from csc_ether driver and uses rtl815x driver 
> for them:
> https://github.com/torvalds/linux/blob/master/drivers/net/usb/cdc_ether.c. 
> I've verified that on Raspbian too.
> 
> 2) netbsd way: netbsd somehow manages to run both adapters on RPi3 fine using 
> cdce driver. I'm yet to analyze differences between OBSD's and NBSD's cdce 
> driver, but certainly NetBSD dwc2 USB driver looks more modern than this from 
> 6.3-current so my hypotesis is that more up to date dwc2 is responsible for 
> working cdce using both adapters on NetBSD.
> 
> I've somehow tested linux way on TP-Link adapter by using patch below and I 
> can verify that with that TP-Link runs fine on RPi3. I've also tested adding 
> vendor/product code for Thinkpad adapter into cdce driver, but the only 
> result was not OS freeze (so kind of progress), but
> 
> cdce0: usb error on tx: TIMEOUT
> cdce0: watchdog timeout
> 
> messages printed from time to time to the console and network not working.
> 
> Basically speaking linux way is 2 lines change to fix both adapters on RPi3. 
> NetBSD way is quite huge patch updating dwc2 USB driver + changes required by 
> OpenBSD on top of that. Before pursuing this path I'd like to ask if this 
> would be preferred way, or if the linux way is preferred in this case so I'd 
> just create a small patch for it.
> 
> Thanks,
> Karel
> 
> diff --git a/sys/dev/usb/if_cdce.c b/sys/dev/usb/if_cdce.c
> index c24f849c4fd..737e21ac8ba 100644
> --- a/sys/dev/usb/if_cdce.c
> +++ b/sys/dev/usb/if_cdce.c
> @@ -66,7 +66,7 @@
>  #include <dev/usb/usbcdc.h>
>  
>  #include <dev/usb/if_cdcereg.h>
> -
> +#define CDCE_DEBUG 1

I haven't tested the patch for this device, but this line may be a left-over
of debugging maybe.

>  #ifdef CDCE_DEBUG
>  #define DPRINTFN(n, x)       do { if (cdcedebug > (n)) printf x; } while (0)
>  int cdcedebug = 0;
> @@ -103,6 +103,7 @@ const struct cdce_type cdce_devs[] = {
>      {{ USB_VENDOR_NETCHIP, USB_PRODUCT_NETCHIP_ETHERNETGADGET }, 0 },
>      {{ USB_VENDOR_COMPAQ, USB_PRODUCT_COMPAQ_IPAQLINUX }, 0 },
>      {{ USB_VENDOR_AMBIT, USB_PRODUCT_AMBIT_NTL_250 }, CDCE_SWAPUNION },
> +    {{ USB_VENDOR_LENOVO, USB_PRODUCT_LENOVO_THINKPAD_USB }, 0 }
>  };
>  #define cdce_lookup(v, p) \
>      ((const struct cdce_type *)usb_lookup(cdce_devs, v, p))
> diff --git a/sys/dev/usb/if_ure.c b/sys/dev/usb/if_ure.c
> index b6c6c99ef34..fa28d163859 100644
> --- a/sys/dev/usb/if_ure.c
> +++ b/sys/dev/usb/if_ure.c
> @@ -72,7 +72,8 @@ int uredebug = 0;
>  
>  const struct usb_devno ure_devs[] = {
>       { USB_VENDOR_REALTEK, USB_PRODUCT_REALTEK_RTL8152 },
> -     { USB_VENDOR_REALTEK, USB_PRODUCT_REALTEK_RTL8153 }
> +     { USB_VENDOR_REALTEK, USB_PRODUCT_REALTEK_RTL8153 },
> +     { USB_VENDOR_TPLINK, USB_PRODUCT_TPLINK_RTL8153 }
>  };
>  
>  int  ure_match(struct device *, void *, void *);
> diff --git a/sys/dev/usb/usbdevs b/sys/dev/usb/usbdevs
> index bc977839062..ae7bcce9ee6 100644
> --- a/sys/dev/usb/usbdevs
> +++ b/sys/dev/usb/usbdevs
> @@ -2510,6 +2510,7 @@ product LEADTEK 9531            0x2101  9531 GPS
>  /* Lenovo products */
>  product LENOVO AX88179               0x304b  AX88179
>  product LENOVO ETHERNET              0x7203  USB 2.0 Ethernet
> +product LENOVO THINKPAD_USB  0x7205  ThinkPad USB 3.0 Ethernet Adapter
>  
>  /* Lexar products */
>  product LEXAR JUMPSHOT               0x0001  jumpSHOT CompactFlash
> @@ -4260,6 +4261,7 @@ product TOSHIBA HSDPA           0x1302  HSDPA
>  product TPLINK RTL8192CU     0x0100  RTL8192CU
>  product TPLINK RTL8812AU     0x0101  RTL8812AU
>  product TPLINK RTL8188EUS    0x010C  RTL8188EUS
> +product TPLINK RTL8153               0x0601  RTL8153
>  
>  /* Trek Technology products */
>  product TREK THUMBDRIVE              0x1111  ThumbDrive
> diff --git a/sys/dev/usb/usbdevs.h b/sys/dev/usb/usbdevs.h
> index 7c47e33fc74..769ddfe3083 100644
> --- a/sys/dev/usb/usbdevs.h
> +++ b/sys/dev/usb/usbdevs.h
> @@ -1,4 +1,4 @@
> -/*   $OpenBSD: usbdevs.h,v 1.696 2018/04/11 04:18:18 bket Exp $      */
> +/*   $OpenBSD$       */
>  
>  /*
>   * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
> @@ -2517,6 +2517,7 @@
>  /* Lenovo products */
>  #define      USB_PRODUCT_LENOVO_AX88179      0x304b          /* AX88179 */
>  #define      USB_PRODUCT_LENOVO_ETHERNET     0x7203          /* USB 2.0 
> Ethernet */
> +#define      USB_PRODUCT_LENOVO_THINKPAD_USB 0x7205          /* ThinkPad USB 
> 3.0 Ethernet Adapter */
>  
>  /* Lexar products */
>  #define      USB_PRODUCT_LEXAR_JUMPSHOT      0x0001          /* jumpSHOT 
> CompactFlash */
> @@ -4267,6 +4268,7 @@
>  #define      USB_PRODUCT_TPLINK_RTL8192CU    0x0100          /* RTL8192CU */
>  #define      USB_PRODUCT_TPLINK_RTL8812AU    0x0101          /* RTL8812AU */
>  #define      USB_PRODUCT_TPLINK_RTL8188EUS   0x010C          /* RTL8188EUS */
> +#define      USB_PRODUCT_TPLINK_RTL8153      0x0601          /* RTL8153 */
>  
>  /* Trek Technology products */
>  #define      USB_PRODUCT_TREK_THUMBDRIVE     0x1111          /* ThumbDrive */
> diff --git a/sys/dev/usb/usbdevs_data.h b/sys/dev/usb/usbdevs_data.h
> index ea0bfdba35c..6d3409dcaaf 100644
> --- a/sys/dev/usb/usbdevs_data.h
> +++ b/sys/dev/usb/usbdevs_data.h
> @@ -1,4 +1,4 @@
> -/*   $OpenBSD: usbdevs_data.h,v 1.690 2018/04/11 04:18:18 bket Exp $ */
> +/*   $OpenBSD$       */
>  
>  /*
>   * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
> @@ -5517,6 +5517,10 @@ const struct usb_known_product usb_known_products[] = {
>           USB_VENDOR_LENOVO, USB_PRODUCT_LENOVO_ETHERNET,
>           "USB 2.0 Ethernet",
>       },
> +     {
> +         USB_VENDOR_LENOVO, USB_PRODUCT_LENOVO_THINKPAD_USB,
> +         "ThinkPad USB 3.0 Ethernet Adapter",
> +     },
>       {
>           USB_VENDOR_LEXAR, USB_PRODUCT_LEXAR_JUMPSHOT,
>           "jumpSHOT CompactFlash",
> @@ -10913,6 +10917,10 @@ const struct usb_known_product usb_known_products[] 
> = {
>           USB_VENDOR_TPLINK, USB_PRODUCT_TPLINK_RTL8188EUS,
>           "RTL8188EUS",
>       },
> +     {
> +         USB_VENDOR_TPLINK, USB_PRODUCT_TPLINK_RTL8153,
> +         "RTL8153",
> +     },
>       {
>           USB_VENDOR_TREK, USB_PRODUCT_TREK_THUMBDRIVE,
>           "ThumbDrive",
> 
> 
> 
> 

-- 
Kind regards,
Hiltjo

Reply via email to