net: usb: r8152: Add in new Devices that are supported for Mac-Passthru
Subsystems (4)
PATCH v2 1/1 net: usb: r8152: Add in new Devices that are supported for Mac-Passthru
Lenovo Thunderbolt 4 Dock, and other Lenovo USB Docks are using the original Realtek USB ethernet Vendor and Product IDs
If the Network device is Realtek verify that it is on a Lenovo USB hub before enabling the passthru feature
This also adds in the device IDs for the Lenovo USB Dongle and one other USB-C dock
--- drivers/net/usb/r8152.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/net/usb/r8152.c +12 -0
@@ -771,6 +771,9 @@ enum rtl8152_flags { };#define DEVICE_ID_THINKPAD_THUNDERBOLT3_DOCK_GEN2 0x3082 +#define DEVICE_ID_THINKPAD_THUNDERBOLT4_DOCK_GEN1 0x8153 +#define DEVICE_ID_THINKPAD_USB_C_DOCK_GEN3 0x3062 +#define DEVICE_ID_THINKPAD_USB_C_DONGLE 0x720c#define DEVICE_ID_THINKPAD_USB_C_DOCK_GEN2 0xa387struct tally_counter {
@@ -9644,11 +9647,20 @@ static int rtl8152_probe(struct usb_interface *intf,if (le16_to_cpu (udev->descriptor.idVendor) ==VENDOR_ID_LENOVO ) {switch (le16_to_cpu (udev->descriptor.idProduct)) { +case DEVICE_ID_THINKPAD_USB_C_DOCK_GEN3 : +case DEVICE_ID_THINKPAD_USB_C_DONGLE :case DEVICE_ID_THINKPAD_THUNDERBOLT3_DOCK_GEN2 :case DEVICE_ID_THINKPAD_USB_C_DOCK_GEN2 : tp->lenovo_macpassthru =1 ; } } +else if ((le16_to_cpu (udev->descriptor.idVendor) ==VENDOR_ID_REALTEK ) && + (le16_to_cpu (udev->parent->descriptor.idVendor) ==VENDOR_ID_LENOVO )) { +switch (le16_to_cpu (udev->descriptor.idProduct)) { +case DEVICE_ID_THINKPAD_THUNDERBOLT4_DOCK_GEN1 : + tp->lenovo_macpassthru =1 ; + } + } if (le16_to_cpu(udev->descriptor.bcdDevice) == 0x3011 && udev->serial && (!strcmp(udev->serial, "000001000000") ||
Signature · 1 line
2.30.2
Quoted 18 lines · David Ober
Lenovo Thunderbolt 4 Dock, and other Lenovo USB Docks are using the original Realtek USB ethernet Vendor and Product IDs
If the Network device is Realtek verify that it is on a Lenovo USB hub before enabling the passthru featureThis also adds in the device IDs for the Lenovo USB Dongle and one other USB-C dock
Signed-off-by David Ober <[email protected]>--- drivers/net/usb/r8152.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/net/usb/r8152.c +0
-0
drivers/net/usb/r8152.c enum rtl8152_flags { · line 774
Quoted 4 lines
drivers/net/usb/r8152.c +1
-0@@ -771,6 +771,9 @@ enum rtl8152_flags { };#define DEVICE_ID_THINKPAD_THUNDERBOLT3_DOCK_GEN2 0x3082 +#define DEVICE_ID_THINKPAD_THUNDERBOLT4_DOCK_GEN1 0x8153
We used to have a macro named PRODUCT_ID_RTL8153 for this magic number, but it was removed in 2014:
commit 662412d14bfa6a672626e4470cab73b75c8b42f0
Author: hayeswang <[email protected]> Date: Thu Nov 6 12:47:40 2014 +0800
r8152: remove the definitions of the PID
The PIDs are only used in the id table, so the definitions are unnacessary. Remove them wouldn't have confusion.
drivers/net/usb/r8152.c +3 -7
@@ -461,11 +461,7 @@ enum rtl8152_flags {/* Define these values to match your device */ #define VENDOR_ID_REALTEK 0x0bda -#define PRODUCT_ID_RTL8152 0x8152 -#define PRODUCT_ID_RTL8153 0x8153 -#define VENDOR_ID_SAMSUNG 0x04e8 -#define PRODUCT_ID_SAMSUNG 0xa101#define MCU_TYPE_PLA 0x0100#define MCU_TYPE_USB 0x0000
@@ -3898,9 +3894,9 @@ static void rtl8152_disconnect(struct usb_interface *intf)/* table of devices that work with this driver */ static struct usb_device_id rtl8152_table[] = { - {USB_DEVICE (VENDOR_ID_REALTEK ,PRODUCT_ID_RTL8152 )}, - {USB_DEVICE (VENDOR_ID_REALTEK ,PRODUCT_ID_RTL8153 )}, - {USB_DEVICE (VENDOR_ID_SAMSUNG ,PRODUCT_ID_SAMSUNG )}, + {USB_DEVICE (VENDOR_ID_REALTEK ,0x8152 )}, + {USB_DEVICE (VENDOR_ID_REALTEK ,0x8153 )}, + {USB_DEVICE (VENDOR_ID_SAMSUNG ,0xa101 )}, {} };
Re-introducing it as DEVICE_ID_THINKPAD_THUNDERBOLT4_DOCK_GEN1 is confusing/obfuscating in several ways:
- the same value is now used two places in the driver, but only one of those places use the macro
- the name indicates that this is somehow unique to a specific Thinkpad product, which it obviously isn't. It's one of the most common device IDs for ethernet USB dongles at the moment, used by any number of vendors
- the attempt to treat these devices differently based on the parent vendor will cause confusion for anyone connecting any of these dongles to a Lenovo hub. This will match so much more than one specific dock product
I beleive I've said this before, but these policies would have been much better handled in userspace with the system mac address being a resource made available by some acpi driver. But whatever. I look forward to seeing the FCC unlock logic for Lenovo X55 modems added to the drivers/bus/mhi/host/pci_generic.c driver.
Bjørn
Hi Bjorn,
Quoted 4 lines
*From:* Bjørn Mork <[email protected]>
*Sent:* May 11, 2022 10:02
David Ober <[email protected]> writes:
<snip>
Quoted 4 lines
I beleive I've said this before, but these policies would have been much better handled in userspace with the system mac address being a resource made available by some acpi driver. But whatever.
We did look into this - but it got really messy quickly with moving between user and kernel space and assigning the MAC. We didn't spend ages on it but came to the conclusion it was far from easy.
I'm very happy to do a patch in thinkpad_acpi to expose the MAC to user space (via a sysfs node) and to use that to work towards a better solution, but think we'll need help for determining how that would work.
In the meantime we'd love the dock and the dongles to work for Lenovo customers. We have had a bunch of customer issues raised where they're using the system MAC (for either system ID, or in PXE server setups) where not having this feature work has been a pain. The feature is used.
I believe David is going to address your point about the IDs.
I'd like to continue with this approach until we have something better. Any suggestions who should I talk with for a longer term solution?
Quoted 4 lines
I look forward to
seeing the FCC unlock logic for Lenovo X55 modems added to thedrivers/bus/mhi/host/pci_generic.cdriver.
I'm afraid that cannot happen - and I don't really want to drag this thread sideways on that topic as it's completely not related. I'm very happy to have a separate conversation about it (either privately or publicly) if it will help. I will happily agree the FCC unlock sucks.
Mark