diff mbox

net:usb:cdc_ncm: fix that tag Huawei devices as wwan

Message ID CA+55aFz3S3nR_aDMMS1vcayyEqJCBL5tgoYAfDE2WGyM3Vcrww@mail.gmail.com
State RFC, archived
Delegated to: David Miller
Headers show

Commit Message

Linus Torvalds June 14, 2015, 11:51 p.m. UTC
Hmm. Oliver is marked as the maintainer of the USB CDC code, but
others have touched it more recently. So I'm just wildly adding people
to the cc to comment on this patch and maybe apply it.
Oliver/David/Ben/Bjørn?

                Linus


---------- Forwarded message ----------
From: xiaomao <xiaomao0213@hotmail.com>
Date: Sun, Jun 14, 2015 at 1:18 PM
Subject: [PATCH] net:usb:cdc_ncm: fix that tag Huawei devices as wwan


Form: Qianni Mamaqianni@huawei.com

Huawei devices is the gereric CDC_NCM devices, but not is WWAN
devices. In the patch, we deleted the code about tagging Huawei
devices as WWAN.
---

Signed-off-by:Qianni Mamaqianni@huawei.com

Comments

Bjørn Mork June 15, 2015, 8:58 a.m. UTC | #1
Linus Torvalds <torvalds@linux-foundation.org> writes:

> Hmm. Oliver is marked as the maintainer of the USB CDC code, but
> others have touched it more recently. So I'm just wildly adding people
> to the cc to comment on this patch and maybe apply it.
> Oliver/David/Ben/Bjørn?

Adding Aleksander and Dan, too.  The 'wwanX' vs 'usbX' distinction is a
hint for userspace and nothing more. We try our best to make this hint
as precise as possible, but there has never been any guarantee that it
is 100% correct.  So userspace will have to deal with hints being wrong.
This has been discussed before:
http://lists.freedesktop.org/archives/modemmanager-devel/2014-April/001068.html

What makes the Huawei NCM devices special is that the same ID is reused
for both types of devices, making it impossible to achieve perfect
hinting by adding exceptions to the generic rule.  We can choose between
wrong towards 'wwanX' or wrong towards 'usbX'.  But the hint WILL be
wrong in some cases no matter what we do.

The 12d1:1506 device ID is a perfect example.  Here's a report of a
Huawei E5776 which should be used as a plain 'usbX' NCM device:
http://lists.freedesktop.org/archives/modemmanager-devel/2014-April/001040.html
And here's a report of a Huawei E3276 which needs wwan management and
therefore should be hinted as a 'wwanX' NCM device:
http://www.dd-wrt.com/phpBB2/viewtopic.php?p=764920

So which of the two wrongs should we choose?

Huawei wanting this changed is a strong argument for the 'usbX'
direction, of course.  But this will be a user visible change which is
likely to break currently working devices until userspace adapts.  And
that will normally trump almost any other argument.  I don't think we
can change this now.  I sincerely apologise about having added the
generic rule in the first place, but I don't see how I can go back and
change that.

I believe we have to follow the path of least surprise: Keeping what we
have.

But we should definitely work with userspace to ensure that a wrongly
flagged 'wwanX' device is usable without any wwan management.
Preferably without the user really noticing anything different (except
possibly the device name).



Bjørn

> ---------- Forwarded message ----------
> From: xiaomao <xiaomao0213@hotmail.com>
> Date: Sun, Jun 14, 2015 at 1:18 PM
> Subject: [PATCH] net:usb:cdc_ncm: fix that tag Huawei devices as wwan
>
>
> Form: Qianni Mamaqianni@huawei.com
>
> Huawei devices is the gereric CDC_NCM devices, but not is WWAN
> devices. In the patch, we deleted the code about tagging Huawei
> devices as WWAN.
> ---
>
> Signed-off-by:Qianni Mamaqianni@huawei.com
>
> --- linux-3.19/drivers/net/usb/cdc_ncm.c.orig	2015-06-15 01:29:52.354238079 +0800
> +++ linux-3.19/drivers/net/usb/cdc_ncm.c	2015-06-15 01:31:04.074236246 +0800
> @@ -1573,12 +1573,12 @@ static const struct usb_device_id cdc_de
>  	},
>  
>  	/* tag Huawei devices as wwan */
> -	{ USB_VENDOR_AND_INTERFACE_INFO(0x12d1,
> +	/*{ USB_VENDOR_AND_INTERFACE_INFO(0x12d1,
>  					USB_CLASS_COMM,
>  					USB_CDC_SUBCLASS_NCM,
>  					USB_CDC_PROTO_NONE),
>  	  .driver_info = (unsigned long)&wwan_info,
> -	},
> +	},*/
>  
>  	/* Infineon(now Intel) HSPA Modem platform */
>  	{ USB_DEVICE_AND_INTERFACE_INFO(0x1519, 0x0443,
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Oliver Neukum June 15, 2015, 9:08 a.m. UTC | #2
On Sun, 2015-06-14 at 13:51 -1000, Linus Torvalds wrote:
> Hmm. Oliver is marked as the maintainer of the USB CDC code, but

I do CDC ACM, CDC WDM and CDC Ether, but not CDC NCM (it is a
very different beast)

> others have touched it more recently. So I'm just wildly adding people
> to the cc to comment on this patch and maybe apply it.
> Oliver/David/Ben/Bjørn?

That said this patch looks very broad. There are devices this fits
which are legitimately WWAN. I would ask Huawei to come up
with a solution of finer granularity.

	HTH
		Oliver



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marcel Holtmann June 15, 2015, 10:22 a.m. UTC | #3
Hi Bjorn,

>> Hmm. Oliver is marked as the maintainer of the USB CDC code, but
>> others have touched it more recently. So I'm just wildly adding people
>> to the cc to comment on this patch and maybe apply it.
>> Oliver/David/Ben/Bjørn?
> 
> Adding Aleksander and Dan, too.  The 'wwanX' vs 'usbX' distinction is a
> hint for userspace and nothing more. We try our best to make this hint
> as precise as possible, but there has never been any guarantee that it
> is 100% correct.  So userspace will have to deal with hints being wrong.
> This has been discussed before:
> http://lists.freedesktop.org/archives/modemmanager-devel/2014-April/001068.html
> 
> What makes the Huawei NCM devices special is that the same ID is reused
> for both types of devices, making it impossible to achieve perfect
> hinting by adding exceptions to the generic rule.  We can choose between
> wrong towards 'wwanX' or wrong towards 'usbX'.  But the hint WILL be
> wrong in some cases no matter what we do.
> 
> The 12d1:1506 device ID is a perfect example.  Here's a report of a
> Huawei E5776 which should be used as a plain 'usbX' NCM device:
> http://lists.freedesktop.org/archives/modemmanager-devel/2014-April/001040.html
> And here's a report of a Huawei E3276 which needs wwan management and
> therefore should be hinted as a 'wwanX' NCM device:
> http://www.dd-wrt.com/phpBB2/viewtopic.php?p=764920
> 
> So which of the two wrongs should we choose?
> 
> Huawei wanting this changed is a strong argument for the 'usbX'
> direction, of course.  But this will be a user visible change which is
> likely to break currently working devices until userspace adapts.  And
> that will normally trump almost any other argument.  I don't think we
> can change this now.  I sincerely apologise about having added the
> generic rule in the first place, but I don't see how I can go back and
> change that.
> 
> I believe we have to follow the path of least surprise: Keeping what we
> have.
> 
> But we should definitely work with userspace to ensure that a wrongly
> flagged 'wwanX' device is usable without any wwan management.
> Preferably without the user really noticing anything different (except
> possibly the device name).

we introduced DEVTYPE in uevent a long time ago. That is what userspace should be using and not second guessing on interface names.

Why is userspace trying to hack around the kernel anyway. This never really goes well unless the kernel exposes clear information to identify devices. If there are some weird devices, then work this out in the kernel and have DEVTYPE identity them correctly.

Regards

Marcel

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bjørn Mork June 15, 2015, 11:09 a.m. UTC | #4
Marcel Holtmann <marcel@holtmann.org> writes:

> we introduced DEVTYPE in uevent a long time ago. That is what
> userspace should be using and not second guessing on interface names.

Yes, sorry for confusing this by mentioning the device name.  This is
really about DEVTYPE.

usbnet minidrivers use FLAG_WWAN to set both the 'wwanX' device name and
DEVTYPE=wwan. The question here is whether or not to set that flag for
Huawei NCM devices.  We can discuss that in the DEVTYPE context if you
prefer.

> Why is userspace trying to hack around the kernel anyway.

Because you can never expect DEVTYPE to be 100% correct. There isn't a
one-to-one relationship between USB classes and DEVTYPE. So we use a
default DEVTYPE and exception lists in class drivers like cdc_ether and
cdc_ncm.  These exception lists will always be incomplete, like any such
whitelist/blacklist.

I believe we have discussed this before, and my opinion on DEVTYPE is
still that it is a best effort thing which we would have been better off
without.  But it's too late to do anything about that.  Userspace has to
deal with it.  The kernel provides a hint.  The hint cannot be trusted.

> This never
> really goes well unless the kernel exposes clear information to
> identify devices. If there are some weird devices, then work this out
> in the kernel and have DEVTYPE identity them correctly.

How?  These devices share device IDs. We do not touch their management
interfaces from the kernel.  We depend on being able to classify device
types based on USB descriptors. How can we identify which device is wwan
and which is not if the descriptors are identical down to the device ID?

It is tempting to say that Huawei knows best for their own devices, if
you all find the change acceptable.  I most certainly don't know better
than they do. I would have loved to travel back in time and never submit
that patch...


Bjørn
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marcel Holtmann June 15, 2015, 11:25 a.m. UTC | #5
Hi Bjorn,

>> we introduced DEVTYPE in uevent a long time ago. That is what
>> userspace should be using and not second guessing on interface names.
> 
> Yes, sorry for confusing this by mentioning the device name.  This is
> really about DEVTYPE.
> 
> usbnet minidrivers use FLAG_WWAN to set both the 'wwanX' device name and
> DEVTYPE=wwan. The question here is whether or not to set that flag for
> Huawei NCM devices.  We can discuss that in the DEVTYPE context if you
> prefer.
> 
>> Why is userspace trying to hack around the kernel anyway.
> 
> Because you can never expect DEVTYPE to be 100% correct. There isn't a
> one-to-one relationship between USB classes and DEVTYPE. So we use a
> default DEVTYPE and exception lists in class drivers like cdc_ether and
> cdc_ncm.  These exception lists will always be incomplete, like any such
> whitelist/blacklist.
> 
> I believe we have discussed this before, and my opinion on DEVTYPE is
> still that it is a best effort thing which we would have been better off
> without.  But it's too late to do anything about that.  Userspace has to
> deal with it.  The kernel provides a hint.  The hint cannot be trusted.

if this is a 2G/3G/LTE or whatever card providing broadband networking then this is DEVTYPE=wwan. It makes no difference if this is NCM or not. It is important to know what this network interface connects to.

>> This never
>> really goes well unless the kernel exposes clear information to
>> identify devices. If there are some weird devices, then work this out
>> in the kernel and have DEVTYPE identity them correctly.
> 
> How?  These devices share device IDs. We do not touch their management
> interfaces from the kernel.  We depend on being able to classify device
> types based on USB descriptors. How can we identify which device is wwan
> and which is not if the descriptors are identical down to the device ID?

What is Huawei building besides broadband cards? Are they in the business of WiFi or Ethernet now?

> It is tempting to say that Huawei knows best for their own devices, if
> you all find the change acceptable.  I most certainly don't know better
> than they do. I would have loved to travel back in time and never submit
> that patch...

I mean if this is about distinguishing their phones from their data cards, then surely the other USB descriptors are different so that the driver can quirk this correctly.

Regards

Marcel

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bjørn Mork June 26, 2015, 9:20 a.m. UTC | #6
"Chenqi (jakio)" <cqi.chen@huawei.com> writes:

> Hi, All,
>
> I'm from Huawei Technologies Co., Ltd, working in mobile broadband
> devices department.
>
> Huawei's broadband card don't support wwan in linux OS, there are
> several historical reasons:
>
> 1.  Huawei produced dozens of broadband card types in past years, and
> our customers/users integrate our products in many different OS
> versions, We need give customer/user a continuous method to let them
> use convenience.
>
> 2.  Wwan connection need application support, while we didn't test
> them for compatibility.
>
> Meanwhile, we have provided serial port to let other existing
> applications dial-up the connection
>
> I understand that you guys have some confusion why the Huawei
> broadband cards support wwan in windows OS but not in linux OS with
> the same device ID.  Since wwan standard is used firstly in windows
> OS, when we pronounced to support this feature, wwan is not enabled in
> linux.  So we keep the card's behavior in linux same as before.

The Linux kernel/drivers/userspace always will attempt to use hardware
in the same way Windows use it, or at least as close as we are able to
get.  The reason is simple: A billion (or whatever) Windows users is the
best test lab you can get.

You may not agree with this strategy, but as a hardware vendor you have
to expect it to happen.  The community will continue to develop support
based on that assumption, even if you try to accommodate Linux by adding
addiotional "Linux specific" features or modes.

> This wwan patch has great influence on our broadband cards, we have
> tested many our broadband cards with this kernel version, and this
> compatible issue is common.  So please approve our modification for
> this problem.

If noone else has any comments or objections here, then I am certainly
not going to object to the proposed patch.

Please go ahead and submit the patch formally.  I am going to keep my
big mouth shut :)

> I think the root cause of this issue is this kernel version trait the
> NCM as wwan devtype, maybe we can add a flag in usb descriptor in
> future to indicate whether the device support wwan or not, then Huawei
> can support wwan feature later for the newest product without
> introducing compatible issues.
>
> BTW: if we want to join the usb-ethernet kernel evolution in linux,
> which forum or organization should we join in?  We can participate in
> it to avoid similar problems.

USB networking drivers are discussed, along with other network drivers,
on the netdev@vger.kernel.org mailing list.  Preferable with a copy to
the linux-usb@vger.kernel.org mailing list for USB expert review.

But as you point out above:  wwan connections need application support.
Userspace projects like ModemManager, oFono, libmbim, libqmi, umbim,
uqmi and probably more, each have their own development forums/mailing
lists.  This is where the most important part of the wwan developemt
takes place.

Huawei have already made important contributions to the development of
both Linux wwan drivers and userspace applications.  I am sure all those
projects will appreciate any further help Huawei are able to offer.

Thanks a lot for your detailed introduction and explanation.


Bjørn
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chenqi (jakio) July 1, 2015, 12:49 a.m. UTC | #7
Hi,bjorn,

Thanks for your kindly reply and providing so much info about linux wwan components!

We'll make a deep research on linux wwan architecture, maybe we can support it in the newly developing products.
About what you saying about "submit the patch formally", what steps should I do? Is there any documents about it?


Best Regards!
Jakio.chen




华为技术有限公司 Huawei Technologies Co., Ltd.

Phone: 18909297056
Email: cqi.chen@huawei.com
地址:西安市锦业一路软件大厦G座 邮编:710000


-----邮件原件-----
发件人: Bjørn Mork [mailto:bjorn@mork.no] 
发送时间: 2015年6月26日 17:21
收件人: Chenqi (jakio)
抄送: torvalds@linux-foundation.org; aleksander@aleksander.es; dcbw@redhat.com; oliver@neukum.org; ben.hutchings@codethink.co.uk; linux-usb@vger.kernel.org; netdev@vger.kernel.org; marcel@holtmann.org; xiaomao0213@hotmail.com; Zhangyuhan
主题: Re: about [PATCH] net:usb:cdc_ncm: fix that tag Huawei devices as wwan

"Chenqi (jakio)" <cqi.chen@huawei.com> writes:

> Hi, All,

>

> I'm from Huawei Technologies Co., Ltd, working in mobile broadband 

> devices department.

>

> Huawei's broadband card don't support wwan in linux OS, there are 

> several historical reasons:

>

> 1.  Huawei produced dozens of broadband card types in past years, and 

> our customers/users integrate our products in many different OS 

> versions, We need give customer/user a continuous method to let them 

> use convenience.

>

> 2.  Wwan connection need application support, while we didn't test 

> them for compatibility.

>

> Meanwhile, we have provided serial port to let other existing 

> applications dial-up the connection

>

> I understand that you guys have some confusion why the Huawei 

> broadband cards support wwan in windows OS but not in linux OS with 

> the same device ID.  Since wwan standard is used firstly in windows 

> OS, when we pronounced to support this feature, wwan is not enabled in 

> linux.  So we keep the card's behavior in linux same as before.


The Linux kernel/drivers/userspace always will attempt to use hardware in the same way Windows use it, or at least as close as we are able to get.  The reason is simple: A billion (or whatever) Windows users is the best test lab you can get.

You may not agree with this strategy, but as a hardware vendor you have to expect it to happen.  The community will continue to develop support based on that assumption, even if you try to accommodate Linux by adding addiotional "Linux specific" features or modes.

> This wwan patch has great influence on our broadband cards, we have 

> tested many our broadband cards with this kernel version, and this 

> compatible issue is common.  So please approve our modification for 

> this problem.


If noone else has any comments or objections here, then I am certainly not going to object to the proposed patch.

Please go ahead and submit the patch formally.  I am going to keep my big mouth shut :)

> I think the root cause of this issue is this kernel version trait the 

> NCM as wwan devtype, maybe we can add a flag in usb descriptor in 

> future to indicate whether the device support wwan or not, then Huawei 

> can support wwan feature later for the newest product without 

> introducing compatible issues.

>

> BTW: if we want to join the usb-ethernet kernel evolution in linux, 

> which forum or organization should we join in?  We can participate in 

> it to avoid similar problems.


USB networking drivers are discussed, along with other network drivers, on the netdev@vger.kernel.org mailing list.  Preferable with a copy to the linux-usb@vger.kernel.org mailing list for USB expert review.

But as you point out above:  wwan connections need application support.
Userspace projects like ModemManager, oFono, libmbim, libqmi, umbim, uqmi and probably more, each have their own development forums/mailing lists.  This is where the most important part of the wwan developemt takes place.

Huawei have already made important contributions to the development of both Linux wwan drivers and userspace applications.  I am sure all those projects will appreciate any further help Huawei are able to offer.

Thanks a lot for your detailed introduction and explanation.


Bjørn
gregkh@linuxfoundation.org July 1, 2015, 1:04 a.m. UTC | #8
On Wed, Jul 01, 2015 at 12:49:01AM +0000, Chenqi (jakio) wrote:
> Hi,bjorn,
> 
> Thanks for your kindly reply and providing so much info about linux wwan components!
> 
> We'll make a deep research on linux wwan architecture, maybe we can support it in the newly developing products.
> About what you saying about "submit the patch formally", what steps should I do? Is there any documents about it?

The kernel source file, Documentation/SubmittingPatches describes the
steps and details everything you need to know about how to properly
submit a kernel patch.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

--- linux-3.19/drivers/net/usb/cdc_ncm.c.orig	2015-06-15 01:29:52.354238079 +0800
+++ linux-3.19/drivers/net/usb/cdc_ncm.c	2015-06-15 01:31:04.074236246 +0800
@@ -1573,12 +1573,12 @@  static const struct usb_device_id cdc_de
 	},
 
 	/* tag Huawei devices as wwan */
-	{ USB_VENDOR_AND_INTERFACE_INFO(0x12d1,
+	/*{ USB_VENDOR_AND_INTERFACE_INFO(0x12d1,
 					USB_CLASS_COMM,
 					USB_CDC_SUBCLASS_NCM,
 					USB_CDC_PROTO_NONE),
 	  .driver_info = (unsigned long)&wwan_info,
-	},
+	},*/
 
 	/* Infineon(now Intel) HSPA Modem platform */
 	{ USB_DEVICE_AND_INTERFACE_INFO(0x1519, 0x0443,