diff mbox series

r8152: Add MAC passthrough support to new device

Message ID 20200114044127.20085-1-kai.heng.feng@canonical.com
State Changes Requested
Delegated to: David Miller
Headers show
Series r8152: Add MAC passthrough support to new device | expand

Commit Message

Kai-Heng Feng Jan. 14, 2020, 4:41 a.m. UTC
Device 0xa387 also supports MAC passthrough, therefore add it to the
whitelst.

BugLink: https://bugs.launchpad.net/bugs/1827961/comments/30
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/net/usb/r8152.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Prashant Malani Jan. 14, 2020, 7:51 a.m. UTC | #1
On Mon, Jan 13, 2020 at 8:41 PM Kai-Heng Feng
<kai.heng.feng@canonical.com> wrote:
>
> Device 0xa387 also supports MAC passthrough, therefore add it to the
> whitelst.
>
> BugLink: https://bugs.launchpad.net/bugs/1827961/comments/30
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> ---
>  drivers/net/usb/r8152.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
> index c5ebf35d2488..42dcf1442cc0 100644
> --- a/drivers/net/usb/r8152.c
> +++ b/drivers/net/usb/r8152.c
> @@ -6657,7 +6657,8 @@ static int rtl8152_probe(struct usb_interface *intf,
>         }
>
>         if (le16_to_cpu(udev->descriptor.idVendor) == VENDOR_ID_LENOVO &&
> -           le16_to_cpu(udev->descriptor.idProduct) == 0x3082)
> +           (le16_to_cpu(udev->descriptor.idProduct) == 0x3082 ||
> +            le16_to_cpu(udev->descriptor.idProduct) == 0xa387))
Perhaps we can try to use #define's for these vendor IDs (like
https://github.com/torvalds/linux/blob/master/drivers/net/usb/r8152.c#L680)
?

>                 set_bit(LENOVO_MACPASSTHRU, &tp->flags);
>
>         if (le16_to_cpu(udev->descriptor.bcdDevice) == 0x3011 && udev->serial &&
> --
> 2.17.1
>
Kai-Heng Feng Jan. 14, 2020, 8:03 a.m. UTC | #2
> On Jan 14, 2020, at 15:51, Prashant Malani <pmalani@chromium.org> wrote:
> 
> On Mon, Jan 13, 2020 at 8:41 PM Kai-Heng Feng
> <kai.heng.feng@canonical.com> wrote:
>> 
>> Device 0xa387 also supports MAC passthrough, therefore add it to the
>> whitelst.
>> 
>> BugLink: https://bugs.launchpad.net/bugs/1827961/comments/30
>> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
>> ---
>> drivers/net/usb/r8152.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>> 
>> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
>> index c5ebf35d2488..42dcf1442cc0 100644
>> --- a/drivers/net/usb/r8152.c
>> +++ b/drivers/net/usb/r8152.c
>> @@ -6657,7 +6657,8 @@ static int rtl8152_probe(struct usb_interface *intf,
>>        }
>> 
>>        if (le16_to_cpu(udev->descriptor.idVendor) == VENDOR_ID_LENOVO &&
>> -           le16_to_cpu(udev->descriptor.idProduct) == 0x3082)
>> +           (le16_to_cpu(udev->descriptor.idProduct) == 0x3082 ||
>> +            le16_to_cpu(udev->descriptor.idProduct) == 0xa387))
> Perhaps we can try to use #define's for these vendor IDs (like
> https://github.com/torvalds/linux/blob/master/drivers/net/usb/r8152.c#L680)
> ?

We can, but it'll bring some inconsistencies inside of rtl8152_table[], since we don't know idProduct for other devices.

Kai-Heng

> 
>>                set_bit(LENOVO_MACPASSTHRU, &tp->flags);
>> 
>>        if (le16_to_cpu(udev->descriptor.bcdDevice) == 0x3011 && udev->serial &&
>> --
>> 2.17.1
>>
Oliver Neukum Jan. 14, 2020, 8:23 a.m. UTC | #3
Am Dienstag, den 14.01.2020, 12:41 +0800 schrieb Kai-Heng Feng:
> Device 0xa387 also supports MAC passthrough, therefore add it to the
> whitelst.

Hi,

this list is getting longer and longer. Isn't there a way to do
this generically? ACPI?

	Regards
		Oliver
Kai-Heng Feng Jan. 14, 2020, 9:22 a.m. UTC | #4
> On Jan 14, 2020, at 16:23, Oliver Neukum <oneukum@suse.com> wrote:
> 
> Am Dienstag, den 14.01.2020, 12:41 +0800 schrieb Kai-Heng Feng:
>> Device 0xa387 also supports MAC passthrough, therefore add it to the
>> whitelst.
> 
> Hi,
> 
> this list is getting longer and longer. Isn't there a way to do
> this generically? ACPI?

ACPI only provides the MAC address, to write the MAC to r8152 it still requires hardware support.
So we need to use whitelist here, not all r8152 support this feature.

Kai-Heng

> 
> 	Regards
> 		Oliver
>
Limonciello, Mario Jan. 14, 2020, 8:33 p.m. UTC | #5
> -----Original Message-----
> From: Kai-Heng Feng <kai.heng.feng@canonical.com>
> Sent: Monday, January 13, 2020 10:41 PM
> To: davem@davemloft.net; hayeswang@realtek.com
> Cc: Kai-Heng Feng; Jakub Kicinski; Prashant Malani; Grant Grundler; Limonciello,
> Mario; Chen7, David; open list:USB NETWORKING DRIVERS; open list:NETWORKING
> DRIVERS; open list
> Subject: [PATCH] r8152: Add MAC passthrough support to new device
> 
> 
> [EXTERNAL EMAIL]
> 
> Device 0xa387 also supports MAC passthrough, therefore add it to the
> whitelst.

Have you confirmed whether this product ID is unique to the products that
support this feature or if it's also re-used in other products?

For Dell's devices there are very specific tests that make sure that this
feature only applies on the products it is supposed to and nothing else
(For example RTL8153-AD checks variant as well as effuse value)
(Example two: RTL8153-BND is a Dell only part).

> 
> BugLink: https://bugs.launchpad.net/bugs/1827961/comments/30
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> ---
>  drivers/net/usb/r8152.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
> index c5ebf35d2488..42dcf1442cc0 100644
> --- a/drivers/net/usb/r8152.c
> +++ b/drivers/net/usb/r8152.c
> @@ -6657,7 +6657,8 @@ static int rtl8152_probe(struct usb_interface *intf,
>  	}
> 
>  	if (le16_to_cpu(udev->descriptor.idVendor) == VENDOR_ID_LENOVO &&
> -	    le16_to_cpu(udev->descriptor.idProduct) == 0x3082)
> +	    (le16_to_cpu(udev->descriptor.idProduct) == 0x3082 ||
> +	     le16_to_cpu(udev->descriptor.idProduct) == 0xa387))
>  		set_bit(LENOVO_MACPASSTHRU, &tp->flags);
> 
>  	if (le16_to_cpu(udev->descriptor.bcdDevice) == 0x3011 && udev->serial
> &&
> --
> 2.17.1
Hayes Wang Jan. 15, 2020, 6:19 a.m. UTC | #6
Kai-Heng Feng [mailto:kai.heng.feng@canonical.com]
> Sent: Tuesday, January 14, 2020 12:41 PM
[...]
>  	if (le16_to_cpu(udev->descriptor.idVendor) == VENDOR_ID_LENOVO &&
> -	    le16_to_cpu(udev->descriptor.idProduct) == 0x3082)
> +	    (le16_to_cpu(udev->descriptor.idProduct) == 0x3082 ||
> +	     le16_to_cpu(udev->descriptor.idProduct) == 0xa387))

How about using
switch (le16_to_cpu(udev->descriptor.idProduct)) {
...
}

>  		set_bit(LENOVO_MACPASSTHRU, &tp->flags);
> 
>  	if (le16_to_cpu(udev->descriptor.bcdDevice) == 0x3011 && udev->serial
> &&
> --
> 2.17.1


Best Regards,
Hayes
Kai-Heng Feng Jan. 15, 2020, 6:40 a.m. UTC | #7
> On Jan 15, 2020, at 4:33 AM, Mario.Limonciello@dell.com wrote:
> 
> 
> 
>> -----Original Message-----
>> From: Kai-Heng Feng <kai.heng.feng@canonical.com>
>> Sent: Monday, January 13, 2020 10:41 PM
>> To: davem@davemloft.net; hayeswang@realtek.com
>> Cc: Kai-Heng Feng; Jakub Kicinski; Prashant Malani; Grant Grundler; Limonciello,
>> Mario; Chen7, David; open list:USB NETWORKING DRIVERS; open list:NETWORKING
>> DRIVERS; open list
>> Subject: [PATCH] r8152: Add MAC passthrough support to new device
>> 
>> 
>> [EXTERNAL EMAIL]
>> 
>> Device 0xa387 also supports MAC passthrough, therefore add it to the
>> whitelst.
> 
> Have you confirmed whether this product ID is unique to the products that
> support this feature or if it's also re-used in other products?

This is unique for Lenovo product.

> 
> For Dell's devices there are very specific tests that make sure that this
> feature only applies on the products it is supposed to and nothing else
> (For example RTL8153-AD checks variant as well as effuse value)
> (Example two: RTL8153-BND is a Dell only part).

Hayes, do you know how macpassthru on Lenovo dock works?

Kai-Heng

> 
>> 
>> BugLink: https://bugs.launchpad.net/bugs/1827961/comments/30
>> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
>> ---
>> drivers/net/usb/r8152.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>> 
>> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
>> index c5ebf35d2488..42dcf1442cc0 100644
>> --- a/drivers/net/usb/r8152.c
>> +++ b/drivers/net/usb/r8152.c
>> @@ -6657,7 +6657,8 @@ static int rtl8152_probe(struct usb_interface *intf,
>> 	}
>> 
>> 	if (le16_to_cpu(udev->descriptor.idVendor) == VENDOR_ID_LENOVO &&
>> -	    le16_to_cpu(udev->descriptor.idProduct) == 0x3082)
>> +	    (le16_to_cpu(udev->descriptor.idProduct) == 0x3082 ||
>> +	     le16_to_cpu(udev->descriptor.idProduct) == 0xa387))
>> 		set_bit(LENOVO_MACPASSTHRU, &tp->flags);
>> 
>> 	if (le16_to_cpu(udev->descriptor.bcdDevice) == 0x3011 && udev->serial
>> &&
>> --
>> 2.17.1
>
Hayes Wang Jan. 15, 2020, 7:04 a.m. UTC | #8
Kai Heng Feng [mailto:kai.heng.feng@canonical.com]
> Sent: Wednesday, January 15, 2020 2:40 PM
[...]
> >> Device 0xa387 also supports MAC passthrough, therefore add it to the
> >> whitelst.
> >
> > Have you confirmed whether this product ID is unique to the products that
> > support this feature or if it's also re-used in other products?
> 
> This is unique for Lenovo product.
> 
> >
> > For Dell's devices there are very specific tests that make sure that this
> > feature only applies on the products it is supposed to and nothing else
> > (For example RTL8153-AD checks variant as well as effuse value)
> > (Example two: RTL8153-BND is a Dell only part).
> 
> Hayes, do you know how macpassthru on Lenovo dock works?

I don't sure about it.

The Dell's devices use the VID/PID of Realtek, so they have another way
to check which devices support macpassthru.

The Lenovo use their VID/PID, so I guess they only check VID/PID.

Best Regards,
Hayes
diff mbox series

Patch

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index c5ebf35d2488..42dcf1442cc0 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -6657,7 +6657,8 @@  static int rtl8152_probe(struct usb_interface *intf,
 	}
 
 	if (le16_to_cpu(udev->descriptor.idVendor) == VENDOR_ID_LENOVO &&
-	    le16_to_cpu(udev->descriptor.idProduct) == 0x3082)
+	    (le16_to_cpu(udev->descriptor.idProduct) == 0x3082 ||
+	     le16_to_cpu(udev->descriptor.idProduct) == 0xa387))
 		set_bit(LENOVO_MACPASSTHRU, &tp->flags);
 
 	if (le16_to_cpu(udev->descriptor.bcdDevice) == 0x3011 && udev->serial &&