lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 5 Nov 2019 08:55:49 +0000
From:   Hayes Wang <hayeswang@...ltek.com>
To:     Kai-Heng Feng <kai.heng.feng@...onical.com>,
        "davem@...emloft.net" <davem@...emloft.net>,
        "oliver@...kum.org" <oliver@...kum.org>
CC:     "linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v2] r8152: Add macpassthru support for ThinkPad Thunderbolt 3 Dock Gen 2

Kai-Heng Feng [mailto:kai.heng.feng@...onical.com]
> Sent: Tuesday, November 05, 2019 4:15 PM
> To: davem@...emloft.net; oliver@...kum.org
[...]
> +	if (test_bit(LENOVO_MACPASSTHRU, &tp->flags)) {
> +		bypass_test = true;
> +		mac_obj_name = "\\MACA";
> +		mac_obj_type = ACPI_TYPE_STRING;
> +		mac_strlen = 0x16;
>  	} else {
> -		/* test for RTL8153-BND and RTL8153-BD */
> -		ocp_data = ocp_read_byte(tp, MCU_TYPE_USB, USB_MISC_1);
> -		if ((ocp_data & BND_MASK) == 0 && (ocp_data & BD_MASK) == 0) {
> -			netif_dbg(tp, probe, tp->netdev,
> -				  "Invalid variant for MAC pass through\n");
> -			return -ENODEV;
> +		bypass_test = false;
> +		mac_obj_name = "\\_SB.AMAC";
> +		mac_obj_type = ACPI_TYPE_BUFFER;
> +		mac_strlen = 0x17;
> +	}
> +
> +	if (!bypass_test) {

Maybe you could combine this with the "else" above.
Then, the variable "bypass_test" could be removed.
And the declaration of "ocp_data" could be moved after the "else".

> +		/* test for -AD variant of RTL8153 */
> +		ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_MISC_0);
> +		if ((ocp_data & AD_MASK) == 0x1000) {
> +			/* test for MAC address pass-through bit */
> +			ocp_data = ocp_read_byte(tp, MCU_TYPE_USB, EFUSE);
> +			if ((ocp_data & PASS_THRU_MASK) != 1) {
> +				netif_dbg(tp, probe, tp->netdev,
> +						"No efuse for RTL8153-AD MAC pass
> through\n");
> +				return -ENODEV;
> +			}
> +		} else {
> +			/* test for RTL8153-BND and RTL8153-BD */
> +			ocp_data = ocp_read_byte(tp, MCU_TYPE_USB, USB_MISC_1);
> +			if ((ocp_data & BND_MASK) == 0 && (ocp_data & BD_MASK)
> == 0) {
> +				netif_dbg(tp, probe, tp->netdev,
> +						"Invalid variant for MAC pass through\n");
> +				return -ENODEV;
> +			}
>  		}
>  	}
> 
>  	/* returns _AUXMAC_#AABBCCDDEEFF# */
> -	status = acpi_evaluate_object(NULL, "\\_SB.AMAC", NULL, &buffer);
> +	status = acpi_evaluate_object(NULL, mac_obj_name, NULL, &buffer);
>  	obj = (union acpi_object *)buffer.pointer;
>  	if (!ACPI_SUCCESS(status))
>  		return -ENODEV;
> -	if (obj->type != ACPI_TYPE_BUFFER || obj->string.length != 0x17) {
> +	if (obj->type != mac_obj_type || obj->string.length != mac_strlen) {
>  		netif_warn(tp, probe, tp->netdev,
>  			   "Invalid buffer for pass-thru MAC addr: (%d, %d)\n",
>  			   obj->type, obj->string.length);
>  		goto amacout;
>  	}
> +
>  	if (strncmp(obj->string.pointer, "_AUXMAC_#", 9) != 0 ||
>  	    strncmp(obj->string.pointer + 0x15, "#", 1) != 0) {
>  		netif_warn(tp, probe, tp->netdev,
> @@ -6629,6 +6649,10 @@ static int rtl8152_probe(struct usb_interface *intf,
>  		netdev->hw_features &= ~NETIF_F_RXCSUM;
>  	}
> 
> +	if (le16_to_cpu(udev->descriptor.idVendor) == VENDOR_ID_LENOVO &&
> +	    le16_to_cpu(udev->descriptor.idProduct) == 0x3082)
> +		set_bit(LENOVO_MACPASSTHRU, &tp->flags);
> +
>  	if (le16_to_cpu(udev->descriptor.bcdDevice) == 0x3011 && udev->serial
> &&
>  	    (!strcmp(udev->serial, "000001000000") ||
>  	     !strcmp(udev->serial, "000002000000"))) {
> @@ -6755,6 +6779,7 @@ static const struct usb_device_id rtl8152_table[] = {
>  	{REALTEK_USB_DEVICE(VENDOR_ID_LENOVO,  0x304f)},
>  	{REALTEK_USB_DEVICE(VENDOR_ID_LENOVO,  0x3062)},
>  	{REALTEK_USB_DEVICE(VENDOR_ID_LENOVO,  0x3069)},
> +	{REALTEK_USB_DEVICE(VENDOR_ID_LENOVO,  0x3082)},
>  	{REALTEK_USB_DEVICE(VENDOR_ID_LENOVO,  0x7205)},
>  	{REALTEK_USB_DEVICE(VENDOR_ID_LENOVO,  0x720c)},
>  	{REALTEK_USB_DEVICE(VENDOR_ID_LENOVO,  0x7214)},
> --
> 2.17.1


Best Regards,
Hayes


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ