Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
* [RFC 4/4] net: cdc_ncm: Add ACPI MAC address pass through functionality
@ 2019-08-20 22:23 Charles.Hyde
  2019-08-24 10:43 ` Bjørn Mork
  0 siblings, 1 reply; 3+ messages in thread
From: Charles.Hyde @ 2019-08-20 22:23 UTC (permalink / raw)
  To: linux-usb, linux-acpi; +Cc: gregkh, Mario.Limonciello, oliver, netdev, nic_swsd

This change adds support to cdc_ncm for ACPI MAC address pass through
functionality that also exists in the Realtek r8152 driver.  This is in
support of Dell's Universal Dock D6000, to give it the same feature
capability as is currently available in Windows and advertized on Dell's
product web site.

Signed-off-by: Charles Hyde <charles.hyde@dellteam.com>
Cc: Mario Limonciello <mario.limonciello@dell.com>
Cc: Oliver Neukum <oliver@neukum.org>
Cc: linux-usb@vger.kernel.org
---
 drivers/net/usb/cdc_ncm.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index f77c8672f972..1f046acca6fc 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -52,6 +52,7 @@
 #include <linux/usb/usbnet.h>
 #include <linux/usb/cdc.h>
 #include <linux/usb/cdc_ncm.h>
+#include <acpi/acpi_mac_passthru.h>
 
 #if IS_ENABLED(CONFIG_USB_NET_CDC_MBIM)
 static bool prefer_mbim = true;
@@ -930,11 +931,18 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
 	usb_set_intfdata(ctx->control, dev);
 
 	if (ctx->ether_desc) {
+		struct sockaddr sa;
+
 		temp = usbnet_get_ethernet_addr(dev, ctx->ether_desc->iMACAddress);
 		if (temp) {
 			dev_dbg(&intf->dev, "failed to get mac address\n");
 			goto error2;
 		}
+		if (get_acpi_mac_passthru(&intf->dev, &sa) == 0) {
+			memcpy(dev->net->dev_addr, sa.sa_data, ETH_ALEN);
+			if (usbnet_set_ethernet_addr(dev) < 0)
+				usbnet_get_ethernet_addr(dev, ctx->ether_desc->iMACAddress);
+		}
 		dev_info(&intf->dev, "MAC-Address: %pM\n", dev->net->dev_addr);
 	}
 
-- 
2.20.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC 4/4] net: cdc_ncm: Add ACPI MAC address pass through functionality
  2019-08-20 22:23 [RFC 4/4] net: cdc_ncm: Add ACPI MAC address pass through functionality Charles.Hyde
@ 2019-08-24 10:43 ` Bjørn Mork
  2019-08-24 13:26   ` Mario.Limonciello
  0 siblings, 1 reply; 3+ messages in thread
From: Bjørn Mork @ 2019-08-24 10:43 UTC (permalink / raw)
  To: Charles.Hyde
  Cc: linux-usb, linux-acpi, gregkh, Mario.Limonciello, oliver, netdev,
	nic_swsd

<Charles.Hyde@dellteam.com> writes:

> @@ -930,11 +931,18 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
>  	usb_set_intfdata(ctx->control, dev);
>  
>  	if (ctx->ether_desc) {
> +		struct sockaddr sa;
> +
>  		temp = usbnet_get_ethernet_addr(dev, ctx->ether_desc->iMACAddress);
>  		if (temp) {
>  			dev_dbg(&intf->dev, "failed to get mac address\n");
>  			goto error2;
>  		}
> +		if (get_acpi_mac_passthru(&intf->dev, &sa) == 0) {
> +			memcpy(dev->net->dev_addr, sa.sa_data, ETH_ALEN);
> +			if (usbnet_set_ethernet_addr(dev) < 0)
> +				usbnet_get_ethernet_addr(dev, ctx->ether_desc->iMACAddress);
> +		}
>  		dev_info(&intf->dev, "MAC-Address: %pM\n", dev->net->dev_addr);
>  	}

So you want to run a Dell specific ACPI method every time anyone plugs
some NCM class device into a host supporing ACPI?  That's going to annoy
the hell out of 99.9997% of the x86, ia64 and arm64 users of this
driver.

Call ACPI once when the driver loads, and only if running on an actual
Dell system where this method is supported.  There must be some ACPI
device ID you can match on to know if this method is supported or not?


Bjørn

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [RFC 4/4] net: cdc_ncm: Add ACPI MAC address pass through functionality
  2019-08-24 10:43 ` Bjørn Mork
@ 2019-08-24 13:26   ` Mario.Limonciello
  0 siblings, 0 replies; 3+ messages in thread
From: Mario.Limonciello @ 2019-08-24 13:26 UTC (permalink / raw)
  To: bjorn, Charles.Hyde
  Cc: linux-usb, linux-acpi, gregkh, oliver, netdev, nic_swsd

> -----Original Message-----
> From: Bjørn Mork <bjorn@mork.no>
> Sent: Saturday, August 24, 2019 5:44 AM
> To: Hyde, Charles - Dell Team
> Cc: linux-usb@vger.kernel.org; linux-acpi@vger.kernel.org;
> gregkh@linuxfoundation.org; Limonciello, Mario; oliver@neukum.org;
> netdev@vger.kernel.org; nic_swsd@realtek.com
> Subject: Re: [RFC 4/4] net: cdc_ncm: Add ACPI MAC address pass through
> functionality
> 
> 
> [EXTERNAL EMAIL]
> 
> <Charles.Hyde@dellteam.com> writes:
> 
> > @@ -930,11 +931,18 @@ int cdc_ncm_bind_common(struct usbnet *dev,
> struct usb_interface *intf, u8 data_
> >  	usb_set_intfdata(ctx->control, dev);
> >
> >  	if (ctx->ether_desc) {
> > +		struct sockaddr sa;
> > +
> >  		temp = usbnet_get_ethernet_addr(dev, ctx->ether_desc-
> >iMACAddress);
> >  		if (temp) {
> >  			dev_dbg(&intf->dev, "failed to get mac address\n");
> >  			goto error2;
> >  		}
> > +		if (get_acpi_mac_passthru(&intf->dev, &sa) == 0) {
> > +			memcpy(dev->net->dev_addr, sa.sa_data, ETH_ALEN);
> > +			if (usbnet_set_ethernet_addr(dev) < 0)
> > +				usbnet_get_ethernet_addr(dev, ctx-
> >ether_desc->iMACAddress);
> > +		}
> >  		dev_info(&intf->dev, "MAC-Address: %pM\n", dev->net-
> >dev_addr);
> >  	}
> 
> So you want to run a Dell specific ACPI method every time anyone plugs some
> NCM class device into a host supporing ACPI?  That's going to annoy the hell out
> of 99.9997% of the x86, ia64 and arm64 users of this driver.
> 
> Call ACPI once when the driver loads, and only if running on an actual Dell
> system where this method is supported.  There must be some ACPI device ID you
> can match on to know if this method is supported or not?
> 
> 
> Bjørn

I have to agree - this is missing an identifying factor of the D6000.  It shouldn't be
running on "just any" cdc_ncm device.

The code that is in get_acpi_mac_passthrough checks for a properly built ACPI method
though.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-20 22:23 [RFC 4/4] net: cdc_ncm: Add ACPI MAC address pass through functionality Charles.Hyde
2019-08-24 10:43 ` Bjørn Mork
2019-08-24 13:26   ` Mario.Limonciello

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org linux-usb@archiver.kernel.org
	public-inbox-index linux-usb


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/ public-inbox