usb: gadget: f_rndis: fix usb_interface_descriptor for rndis
Subsystems (6)
PATCH 1/1 usb: gadget: f_rndis: fix usb_interface_descriptor for rndis
use the values for RNDIS over Ethernet as defined in
http://www.usb.org/developers/defined_class
(search for RDNIS):
- baseclass: 0xef (miscellaneous)
- subclass: 0x04
- protocol: 0x01
with this setings the file in Documentation/usb/linux.inf is obsolete.
---
Tested with the "USB Compliance test suite which runs Windows", see:
http://www.usb.org/developers/tools/usb20_tools/#usb20cv
drivers/net/usb/cdc_ether.c | 6 +++--- drivers/usb/core/generic.c | 6 +++--- drivers/usb/gadget/function/f_rndis.c | 6 +++--- include/uapi/linux/usb/cdc.h | 3 +++ 4 files changed, 12 insertions(+), 9 deletions(-)
drivers/net/usb/cdc_ether.c +3 -3
@@ -35,9 +35,9 @@static int is_rndis (struct usb_interface_descriptor *desc) { -return (desc->bInterfaceClass ==USB_CLASS_COMM && - desc->bInterfaceSubClass ==2 && - desc->bInterfaceProtocol ==0xff ); +return (desc->bInterfaceClass ==USB_CLASS_MISC && + desc->bInterfaceSubClass ==USB_CDC_SUBCLASS_RNDIS && + desc->bInterfaceProtocol ==USB_CDC_RNDIS_PROTO_ETH ); }static int is_activesync (struct usb_interface_descriptor *desc)
drivers/usb/core/generic.c +3 -3
@@ -28,9 +28,9 @@ static inline const char *plural(int n)static int is_rndis (struct usb_interface_descriptor *desc) { -return desc->bInterfaceClass ==USB_CLASS_COMM - && desc->bInterfaceSubClass ==2 - && desc->bInterfaceProtocol ==0xff ; +return desc->bInterfaceClass ==USB_CLASS_MISC + && desc->bInterfaceSubClass ==USB_CDC_SUBCLASS_RNDIS + && desc->bInterfaceProtocol ==USB_CDC_RNDIS_PROTO_ETH ; }static int is_activesync (struct usb_interface_descriptor *desc)
drivers/usb/gadget/function/f_rndis.c +3 -3
@@ -117,9 +117,9 @@ static struct usb_interface_descriptor rndis_control_intf = {/* .bInterfaceNumber = DYNAMIC */ /* status endpoint is optional; this could be patched later */ .bNumEndpoints = 1, - .bInterfaceClass = USB_CLASS_COMM, - .bInterfaceSubClass = USB_CDC_SUBCLASS_ACM, - .bInterfaceProtocol = USB_CDC_ACM_PROTO_VENDOR, + .bInterfaceClass = USB_CLASS_MISC, + .bInterfaceSubClass = USB_CDC_SUBCLASS_RNDIS, + .bInterfaceProtocol = USB_CDC_RNDIS_PROTO_ETH,/* .iInterface = DYNAMIC */ };
include/uapi/linux/usb/cdc.h +3 -0
@@ -12,6 +12,7 @@#include <linux/types.h> #define USB_CDC_SUBCLASS_ACM 0x02 +#define USB_CDC_SUBCLASS_RNDIS 0x04#define USB_CDC_SUBCLASS_ETHERNET 0x06#define USB_CDC_SUBCLASS_WHCM 0x08#define USB_CDC_SUBCLASS_DMM 0x09
@@ -31,6 +32,8 @@#define USB_CDC_ACM_PROTO_AT_CDMA 6#define USB_CDC_ACM_PROTO_VENDOR 0xff +#define USB_CDC_RNDIS_PROTO_ETH 1 +#define USB_CDC_PROTO_EEM 7#define USB_CDC_NCM_PROTO_NTB 1
Signature · 1 line
1.8.3.1
Quoted 42 lines · Heiko Schocher
use the values for RNDIS over Ethernet as defined in
http://www.usb.org/developers/defined_class
(search for RDNIS):- baseclass:
0xef(miscellaneous)
- subclass:0x04
- protocol:0x01with this setings the file in
Documentation/usb/linux.infis obsolete.Signed-off-by Heiko Schocher <[email protected]>---
Cc Felipe Balbi <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Oliver Neukum <[email protected]>Cc Andrzej Pietrasiewicz <[email protected]>Cc Michal Nazarewicz <[email protected]>Cc Kyungmin Park <[email protected]>Cc Dan Carpenter <[email protected]>Cc Macpaul Lin <[email protected]>Tested with the "USB Compliance test suite which runs Windows", see:
http://www.usb.org/developers/tools/usb20_tools/#usb20cvdrivers/net/usb/cdc_ether.c | 6 +++--- drivers/usb/core/generic.c | 6 +++--- drivers/usb/gadget/function/f_rndis.c | 6 +++--- include/uapi/linux/usb/cdc.h | 3 +++ 4 files changed, 12 insertions(+), 9 deletions(-)drivers/net/usb/cdc_ether.c +0
-0
drivers/net/usb/cdc_ether.c line 41
Quoted 10 lines
drivers/net/usb/cdc_ether.c +3
-3@@ -35,9 +35,9 @@static int is_rndis (struct usb_interface_descriptor *desc) { -return (desc->bInterfaceClass ==USB_CLASS_COMM && - desc->bInterfaceSubClass ==2 && - desc->bInterfaceProtocol ==0xff ); +return (desc->bInterfaceClass ==USB_CLASS_MISC && + desc->bInterfaceSubClass ==USB_CDC_SUBCLASS_RNDIS && + desc->bInterfaceProtocol ==USB_CDC_RNDIS_PROTO_ETH ); }
Does that mean that new kernels will stop working with old RNDIs gadgets because they stop recognising them as RNDIS? I feel like this function should accept both, i.e.:
return (desc->bInterfaceClass == USB_CLASS_COMM && desc->bInterfaceSubClass == 2 && desc->bInterfaceProtocol == 0xff) || (desc->bInterfaceClass == USB_CLASS_MISC && desc->bInterfaceSubClass == USB_CDC_SUBCLASS_RNDIS && desc->bInterfaceProtocol == USB_CDC_RNDIS_PROTO_ETH);
Quoted 7 lines
drivers/net/usb/cdc_ether.c +0
-0static int is_activesync (struct usb_interface_descriptor *desc)drivers/usb/core/generic.c +0
-0
drivers/usb/core/generic.c static inline const char *plural(int n) · line 34
Quoted 10 lines
drivers/usb/core/generic.c +3
-3@@ -28,9 +28,9 @@ static inline const char *plural(int n)static int is_rndis (struct usb_interface_descriptor *desc) { -return desc->bInterfaceClass ==USB_CLASS_COMM - && desc->bInterfaceSubClass ==2 - && desc->bInterfaceProtocol ==0xff ; +return desc->bInterfaceClass ==USB_CLASS_MISC + && desc->bInterfaceSubClass ==USB_CDC_SUBCLASS_RNDIS + && desc->bInterfaceProtocol ==USB_CDC_RNDIS_PROTO_ETH ; }
Ditto.
Quoted 40 lines
drivers/usb/core/generic.c +0
-0static int is_activesync (struct usb_interface_descriptor *desc)drivers/usb/gadget/function/f_rndis.c +3
-3@@ -117,9 +117,9 @@ static struct usb_interface_descriptor rndis_control_intf = {/* .bInterfaceNumber = DYNAMIC */ /* status endpoint is optional; this could be patched later */ .bNumEndpoints = 1, - .bInterfaceClass = USB_CLASS_COMM, - .bInterfaceSubClass = USB_CDC_SUBCLASS_ACM, - .bInterfaceProtocol = USB_CDC_ACM_PROTO_VENDOR, + .bInterfaceClass = USB_CLASS_MISC, + .bInterfaceSubClass = USB_CDC_SUBCLASS_RNDIS, + .bInterfaceProtocol = USB_CDC_RNDIS_PROTO_ETH,/* .iInterface = DYNAMIC */ };include/uapi/linux/usb/cdc.h +3
-0@@ -12,6 +12,7 @@#include <linux/types.h> #define USB_CDC_SUBCLASS_ACM 0x02 +#define USB_CDC_SUBCLASS_RNDIS 0x04#define USB_CDC_SUBCLASS_ETHERNET 0x06#define USB_CDC_SUBCLASS_WHCM 0x08#define USB_CDC_SUBCLASS_DMM 0x09@@ -31,6 +32,8 @@#define USB_CDC_ACM_PROTO_AT_CDMA 6#define USB_CDC_ACM_PROTO_VENDOR 0xff +#define USB_CDC_RNDIS_PROTO_ETH 1 +#define USB_CDC_PROTO_EEM 7#define USB_CDC_NCM_PROTO_NTB 1
Signature · 4 lines
Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał “mina86” Nazarewicz (o o) ooo +--<[email protected]>--<xmpp:[email protected]>--ooO--(_)--Ooo--
Quoted 8 lines · Heiko Schocher
use the values for RNDIS over Ethernet as defined in
http://www.usb.org/developers/defined_class
(search for RDNIS):- baseclass:
0xef(miscellaneous)
- subclass:0x04
- protocol:0x01
That is usb class, it is not the same thing as communication device class.
include/uapi/linux/usb/cdc.h line 15
Quoted 7 lines
include/uapi/linux/usb/cdc.h +1
-0@@ -12,6 +12,7 @@#include <linux/types.h> #define USB_CDC_SUBCLASS_ACM 0x02 +#define USB_CDC_SUBCLASS_RNDIS 0x04
No, no, no.
There is no CDC_SUBCLASS_RNDIS and you can not define one over an already used cdc subclass number, 0x04 is Multi-Channel Control Model
Hello Michal,
Am 24.09.2014 11:38, schrieb Michal Nazarewicz:
Quoted 44 lines · Heiko Schocher
Quoted 43 lines
use the values for RNDIS over Ethernet as defined in
http://www.usb.org/developers/defined_class
(search for RDNIS):- baseclass:
0xef(miscellaneous)
- subclass:0x04
- protocol:0x01with this setings the file in
Documentation/usb/linux.infis obsolete.Signed-off-by Heiko Schocher<[email protected]>---
Cc Felipe Balbi<[email protected]>Cc Greg Kroah-Hartman<[email protected]>Cc Oliver Neukum<[email protected]>Cc Andrzej Pietrasiewicz<[email protected]>Cc Michal Nazarewicz<[email protected]>Cc Kyungmin Park<[email protected]>Cc Dan Carpenter<[email protected]>Cc Macpaul Lin<[email protected]>Tested with the "USB Compliance test suite which runs Windows", see:
http://www.usb.org/developers/tools/usb20_tools/#usb20cvdrivers/net/usb/cdc_ether.c | 6 +++--- drivers/usb/core/generic.c | 6 +++--- drivers/usb/gadget/function/f_rndis.c | 6 +++--- include/uapi/linux/usb/cdc.h | 3 +++ 4 files changed, 12 insertions(+), 9 deletions(-)drivers/net/usb/cdc_ether.c +0
-0@@ -35,9 +35,9 @@
Quoted 13 lines
drivers/net/usb/cdc_ether.c line 41
Quoted 9 lines
drivers/net/usb/cdc_ether.c +3
-3static int is_rndis (struct usb_interface_descriptor *desc) { -return (desc->bInterfaceClass ==USB_CLASS_COMM && - desc->bInterfaceSubClass ==2 && - desc->bInterfaceProtocol ==0xff ); +return (desc->bInterfaceClass ==USB_CLASS_MISC && + desc->bInterfaceSubClass ==USB_CDC_SUBCLASS_RNDIS && + desc->bInterfaceProtocol ==USB_CDC_RNDIS_PROTO_ETH ); }Does that mean that new kernels will stop working with old RNDIs gadgets because they stop recognising them as RNDIS? I feel like this function should accept both, i.e.:
Hmm.. I am not a usb guru ... but I think, yes, you are right. I add this to a v2 (if this patch has a chance to go in mainline).
Thanks!
bye,
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Hello Lars,
Am 24.09.2014 14:25, schrieb Lars Melin:
Quoted 10 lines · Heiko Schocher
Quoted 8 lines
use the values for RNDIS over Ethernet as defined in
http://www.usb.org/developers/defined_class
(search for RDNIS):- baseclass:
0xef(miscellaneous)
- subclass:0x04
- protocol:0x01That is usb class, it is not the same thing as communication device class.
Quoted 8 lines
include/uapi/linux/usb/cdc.h line 14
Quoted 6 lines
include/uapi/linux/usb/cdc.h +1
-0@@ -12,6 +12,7 @@#include <linux/types.h> #define USB_CDC_SUBCLASS_ACM 0x02 +#define USB_CDC_SUBCLASS_RNDIS 0x04No, no, no.
There is noCDC_SUBCLASS_RNDISand you can not define one over an already used cdc subclass number,0x04is Multi-Channel Control Model
Ah, ok, so I have to define this values in a new header file, as there is no current file for the USB_CLASS_MISC defines? Or is there a proper place for them?
BTW: where do I find the "cdc subclass number, 0x04 is Multi-Channel Control Model" define?
bye,
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Quoted 26 lines · Heiko Schocher
Hello Lars,
Am 24.09.2014 14:25, schrieb Lars Melin:
Quoted 10 lines · Heiko Schocher
Quoted 8 lines
use the values for RNDIS over Ethernet as defined in
http://www.usb.org/developers/defined_class
(search for RDNIS):- baseclass:
0xef(miscellaneous)
- subclass:0x04
- protocol:0x01That is usb class, it is not the same thing as communication device class.
Quoted 8 lines
include/uapi/linux/usb/cdc.h line 14
Quoted 6 lines
include/uapi/linux/usb/cdc.h +1
-0@@ -12,6 +12,7 @@#include <linux/types.h> #define USB_CDC_SUBCLASS_ACM 0x02 +#define USB_CDC_SUBCLASS_RNDIS 0x04No, no, no.
There is noCDC_SUBCLASS_RNDISand you can not define one over an already used cdc subclass number,0x04is Multi-Channel Control ModelAh, ok, so I have to define this values in a new header file, as there is no current file for the
USB_CLASS_MISCdefines? Or is there a proper place for them?
Quoted 5 lines
BTW: where do I find the "cdc subclass number,
0x04is Multi-Channel Control Model" define?bye,
Heiko
You can still find the original specification usbcdc11.pdf on the net if you google for it, it has been pulled from usb.org where you could download it until a few years ago. It is old but covers a lot of what you need to know.
Linux has afaik only the cdc.h definition file, everything else is coded by class/subclass in respectively drivers when needed.
02/02/ff or e0/01/03 are the most common interface attribute for rndis, both of them together with a data interface with attributes 0a/00/00.
Please check the whitelisting in drivers/net/usb/rndis_host.c and also blacklistings in other net drivers under the same path, it should give you an idea how to bind an interface to a specific driver by interface attributes and/or usb vid:pid. You should be able to do the same for your particular device.
Hello Lars,
sorry for my late answer ...
Am 24.09.2014 16:22, schrieb Lars Melin:
Quoted 27 lines · Heiko Schocher
Quoted 26 lines
Hello Lars,
Am 24.09.2014 14:25, schrieb Lars Melin:
Quoted 10 lines · Heiko Schocher
Quoted 8 lines
use the values for RNDIS over Ethernet as defined in
http://www.usb.org/developers/defined_class
(search for RDNIS):- baseclass:
0xef(miscellaneous)
- subclass:0x04
- protocol:0x01That is usb class, it is not the same thing as communication device class.
Quoted 8 lines
include/uapi/linux/usb/cdc.h line 14
Quoted 6 lines
include/uapi/linux/usb/cdc.h +1
-0@@ -12,6 +12,7 @@#include <linux/types.h> #define USB_CDC_SUBCLASS_ACM 0x02 +#define USB_CDC_SUBCLASS_RNDIS 0x04No, no, no.
There is noCDC_SUBCLASS_RNDISand you can not define one over an already used cdc subclass number,0x04is Multi-Channel Control ModelAh, ok, so I have to define this values in a new header file, as there is no current file for the
USB_CLASS_MISCdefines? Or is there a proper place for them?
Quoted 8 lines
Quoted 5 lines
BTW: where do I find the "cdc subclass number,
0x04is Multi-Channel Control Model" define?bye,
HeikoYou can still find the original specification usbcdc11.pdf on the net if you google for it, it has been pulled from usb.org where you could download it until a few years ago. It is old but covers a lot of what you need to know.
Hmm.. maybe I am to dummy for finding this docment...
http://www.usb.org/results?q=usbcdc11.pdf&submit=Search
does not find this document ... could you send me a direct link?
I found with the above search:
http://www.usb.org/developers/defined_class
and this site, exactly describes the values for RNDIS over ethernet, as my patch changes [1]
Quoted 1 line
Linux has afaik only the
cdc.hdefinition file, everything else is coded by class/subclass in respectively drivers when needed.
why not in header files? I thought, magical values are not welcome in source code ...
As for the is_rndis() function case, this function is defined in 2 places:
- drivers/net/usb/cdc_ether.c
- drivers/usb/core/generic.c
Has this a special reason? This seems suboptimal to me ...
Quoted 1 line
02/02/ff or e0/01/03 are the most common interface attribute for rndis, both of them together with a data interface with attributes 0a/00/00.
I must admit, I am not a USB nor a RNDIS expert ...
Quoted 2 lines
Please check the whitelisting in
drivers/net/usb/rndis_host.cand also blacklistings in other net drivers under the same path, it should give you an idea how to bind an interface to a specific driver by interface attributes and/or usb vid:pid. You should be able to do the same for your particular device.
Hmm.. I did not understand you here ... so, one step back:
I got from a customer this patch (in a similiar version) and he did tests with [3] and saw, that a board which runs linux, is seen in [3] with the values [2] ... so he changed the values in drivers/usb/gadget/function/f_rndis.c to the values [1], which are documented in [4] and with them the test [3] is happy ... and the file "Documentation/usb/linux.inf" is not longer needed on the windows pc!
So he (and at the end I too) thought, that this is the proper way to make [3] happy ... (maybe [3] is incorrect ? )
Is current ML code correct? And if yes, why?
If the values [2] in current ML linux are correct, could you say me, where they are documented?
(and sorry for my stupid questions ...)
Thanks!
bye,
Heiko
[1] values which my patch sets for RNDIS over ethernet
- baseclass: 0xef (miscellaneous)
- subclass: 0x04
- protocol: 0x01
[2] currently used values for RNDIS over ethernet
- baseclass: 0x02 (USB_CLASS_COMM)
- subclass: 0x02
- protocol: 0xff
[3] "USB Compliance test suite which runs Windows", see:
http://www.usb.org/developers/tools/usb20_tools/#usb20cv
[4] http://www.usb.org/developers/defined_class
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Quoted 43 lines · Heiko Schocher
Hello Lars,
sorry for my late answer ...
Am 24.09.2014 16:22, schrieb Lars Melin:
Quoted 27 lines · Heiko Schocher
Quoted 26 lines
Hello Lars,
Am 24.09.2014 14:25, schrieb Lars Melin:
Quoted 10 lines · Heiko Schocher
Quoted 8 lines
use the values for RNDIS over Ethernet as defined in
http://www.usb.org/developers/defined_class
(search for RDNIS):- baseclass:
0xef(miscellaneous)
- subclass:0x04
- protocol:0x01That is usb class, it is not the same thing as communication device class.
Quoted 8 lines
include/uapi/linux/usb/cdc.h line 14
Quoted 6 lines
include/uapi/linux/usb/cdc.h +1
-0@@ -12,6 +12,7 @@#include <linux/types.h> #define USB_CDC_SUBCLASS_ACM 0x02 +#define USB_CDC_SUBCLASS_RNDIS 0x04No, no, no.
There is noCDC_SUBCLASS_RNDISand you can not define one over an already used cdc subclass number,0x04is Multi-Channel Control ModelAh, ok, so I have to define this values in a new header file, as there is no current file for the
USB_CLASS_MISCdefines? Or is there a proper place for them?Quoted 8 lines
Quoted 5 lines
BTW: where do I find the "cdc subclass number,
0x04is Multi-Channel Control Model" define?bye,
HeikoYou can still find the original specification usbcdc11.pdf on the net if you google for it, it has been pulled from usb.org where you could download it until a few years ago. It is old but covers a lot of what you need to know.
Hmm.. maybe I am to dummy for finding this docment...
Quoted 7 lines
http://www.usb.org/results?q=usbcdc11.pdf&submit=Search
does not find this document ... could you send me a direct link?
I found with the above search:
I don't know if it is a good idea to provide a link here to a document which usb.org has made unavailable, I told you to google for the file name , not to search for it on usb.org
Quoted 8 lines
and this site, exactly describes the values for RNDIS over ethernet, as my patch changes [1]
Quoted 1 line
Linux has afaik only the
cdc.hdefinition file, everything else is coded by class/subclass in respectively drivers when needed.why not in header files? I thought, magical values are not welcome in source code ...
I was wrong, usb class definitions are included in ../include/uapi/linux/usb/ch9.h
Quoted 7 lines
As for the
is_rndis()function case, this function is defined in 2 places:-
drivers/net/usb/cdc_ether.c
-drivers/usb/core/generic.cHas this a special reason? This seems suboptimal to me ...
Yes it has, but the core driver is not an interface driver so it is not of relevance in this case. cdc_ether handles interfaces of device connected to the usb bus, not interfaces of gadget devices created by linux.
Quoted 9 lines
I got from a customer this patch (in a similiar version) and he did tests with [3] and saw, that a board which runs linux, is seen in [3] with the values [2] ... so he changed the values in
drivers/usb/gadget/function/f_rndis.cto the values [1], which are documented in [4] and with them the test [3] is happy ... and the file "Documentation/usb/linux.inf" is not longer needed on the windows pc!
The patch from your customer removed the most common rndis interface attributes and substituted them with one of many other interface attributes which Microsoft uses, this is not the right way of doing it. Why did he patch ../core/generic.c and ../net/usb/cdc_ether.c if he wants to change the interface attributes of g_rndis?
Lars