Skip to contentSkip to conversation

RNDIS Gadget Driver

ANNOUNCE Robert Schwebel 5 participants 20 messages Mar 25, 2004 – Mar 30, 2004 USB

lore
Share & tools
lore
#0 lore raw

David,

finally, here is our RNDIS USB Gadget Driver - see the attached patch against the gadget-2.4 BK tree as of now. It shouldn't be too difficult to port this to 2.6.

The patch adds support for Microsoft's RNDIS protocol to the standard g_ether driver. This makes it possible to connect a Linux USB gadget to any standard Windows machine and <*PALIM!*> there is a new USB network interface on the Windows side on which you can speak TCP/IP :-)

Unfortunately, although it works with the original Microsoft driver, you need an inf file on the windows side; you can download the template for that directly from M$.

Thanks to Auerswald GmbH for sponsoring this work!

Robert

Signature · 5 lines
 Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry
   Handelsregister:  Amtsgericht Hildesheim, HRA 2686
     Hornemannstraße 12,  31137 Hildesheim, Germany
    Phone: +49-5121-28619-0 |  Fax: +49-5121-28619-4
drivers/usb/gadget/config.c +4 -2
diff -urN gadget-2.4/drivers/usb/gadget/config.c linux-2.4.19-rmk7-pxa2-mtd20030728-ptx16pre/drivers/usb/gadget/config.c
@@ -22,6 +22,7 @@
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/string.h>
+#include <asm/byteorder.h>
 
 #include <linux/usb_ch9.h>
 
@@ -50,13 +51,14 @@
 	/* fill buffer from src[] until null descriptor ptr */
 	for (; 0 != *src; src++) {
 		unsigned		len = (*src)->bLength;
-
-		if (len > buflen);
+		
+		if (len > buflen)
 			return -EINVAL;
 		memcpy(dest, *src, len);
 		buflen -= len;
 		dest += len;
 	}
+
 	return dest - (u8 *)buf;
 }
 
drivers/usb/gadget/Config.in +1 -0
diff -urN gadget-2.4/drivers/usb/gadget/Config.in linux-2.4.19-rmk7-pxa2-mtd20030728-ptx16pre/drivers/usb/gadget/Config.in
@@ -68,6 +68,7 @@
 
   dep_tristate '  Gadget Zero (DEVELOPMENT)' CONFIG_USB_ZERO $CONFIG_USB_GADGET_CONTROLLER
   dep_tristate '  Ethernet Gadget (EXPERIMENTAL)' CONFIG_USB_ETH $CONFIG_USB_GADGET_CONTROLLER $CONFIG_NET
+  dep_tristate '  RNDIS support (EXPERIMENTAL)' CONFIG_USB_ETH_RNDIS $CONFIG_USB_ETH
   dep_tristate '  Gadget Filesystem API (EXPERIMENTAL)' CONFIG_USB_GADGETFS $CONFIG_USB_GADGET_CONTROLLER
   dep_tristate '  File-backed Storage Gadget (DEVELOPMENT)' CONFIG_USB_FILE_STORAGE $CONFIG_USB_GADGET_CONTROLLER
   dep_mbool '    File-backed Storage Gadget test mode' CONFIG_USB_FILE_STORAGE_TEST $CONFIG_USB_FILE_STORAGE
drivers/usb/gadget/epautoconf.c +1 -0
diff -urN gadget-2.4/drivers/usb/gadget/epautoconf.c linux-2.4.19-rmk7-pxa2-mtd20030728-ptx16pre/drivers/usb/gadget/epautoconf.c
@@ -27,6 +27,7 @@
 
 #include <linux/ctype.h>
 #include <linux/string.h>
+#include <asm/byteorder.h>
 
 #include <linux/usb_ch9.h>
 #include <linux/usb_gadget.h>
drivers/usb/gadget/ether.c +465 -27

731 lines not on this page · raw message

drivers/usb/gadget/Makefile +2 -1
diff -urN gadget-2.4/drivers/usb/gadget/Makefile linux-2.4.19-rmk7-pxa2-mtd20030728-ptx16pre/drivers/usb/gadget/Makefile
@@ -25,6 +25,7 @@
 
 g_ether-objs			:= ether.o usbstring.o config.o
 obj-$(CONFIG_USB_ETH)		+= g_ether.o
+obj-$(CONFIG_USB_ETH_RNDIS)	+= rndis.o
 
 gadgetfs-objs			:= inode.o usbstring.o
 obj-$(CONFIG_USB_GADGETFS)	+= gadgetfs.o
@@ -35,7 +36,7 @@
 g_serial-objs			:= gserial.o usbstring.o
 obj-$(CONFIG_USB_G_SERIAL)	+= g_serial.o
 
-export-objs :=			$(controller-y) $(controller-m)
+export-objs :=			$(controller-y) $(controller-m) rndis.o
 
 include $(TOPDIR)/Rules.make
 
drivers/usb/gadget/ndis.h +187 -0

187 lines not on this page · raw message

drivers/usb/gadget/pxa2xx_udc.c +22 -17
diff -urN gadget-2.4/drivers/usb/gadget/pxa2xx_udc.c linux-2.4.19-rmk7-pxa2-mtd20030728-ptx16pre/drivers/usb/gadget/pxa2xx_udc.c
@@ -23,8 +23,10 @@
  *
  */
 
+#if 0
 #define	DEBUG	1
-// #define	VERBOSE	DBG_VERBOSE
+#define	VERBOSE	DBG_VERBOSE
+#endif
 
 #include <linux/config.h>
 #include <linux/module.h>
@@ -1728,6 +1730,7 @@
 			switch (u.r.bRequest) {
 			/* hardware restricts gadget drivers here! */
 			case USB_REQ_SET_CONFIGURATION:
+				printk ("USB_REQ_SET_CONFIGURATION\n");
 				if (u.r.bRequestType == USB_RECIP_DEVICE) {
 					/* reflect hardware's automagic
 					 * up to the gadget driver.
@@ -2099,7 +2102,8 @@
 	},
 
 	/* control endpoint */
-	.ep[0] = {
+	.ep = {
+	  [0] = {
 		.ep = {
 			.name		= ep0name,
 			.ops		= &pxa2xx_ep_ops,
@@ -2111,7 +2115,7 @@
 	},
 
 	/* first group of endpoints */
-	.ep[1] = {
+	  [1] = {
 		.ep = {
 			.name		= "ep1in-bulk",
 			.ops		= &pxa2xx_ep_ops,
@@ -2125,7 +2129,7 @@
 		.reg_uddr	= &UDDR1,
 		drcmr (25)
 	},
-	.ep[2] = {
+	  [2] = {
 		.ep = {
 			.name		= "ep2out-bulk",
 			.ops		= &pxa2xx_ep_ops,
@@ -2141,7 +2145,7 @@
 		drcmr (26)
 	},
 #ifndef CONFIG_USB_PXA2XX_SMALL
-	.ep[3] = {
+	  [3] = {
 		.ep = {
 			.name		= "ep3in-iso",
 			.ops		= &pxa2xx_ep_ops,
@@ -2155,7 +2159,7 @@
 		.reg_uddr	= &UDDR3,
 		drcmr (27)
 	},
-	.ep[4] = {
+	  [4] = {
 		.ep = {
 			.name		= "ep4out-iso",
 			.ops		= &pxa2xx_ep_ops,
@@ -2170,7 +2174,7 @@
 		.reg_uddr	= &UDDR4,
 		drcmr (28)
 	},
-	.ep[5] = {
+	  [5] = {
 		.ep = {
 			.name		= "ep5in-int",
 			.ops		= &pxa2xx_ep_ops,
@@ -2185,7 +2189,7 @@
 	},
 
 	/* second group of endpoints */
-	.ep[6] = {
+	  [6] = {
 		.ep = {
 			.name		= "ep6in-bulk",
 			.ops		= &pxa2xx_ep_ops,
@@ -2199,7 +2203,7 @@
 		.reg_uddr	= &UDDR6,
 		drcmr (30)
 	},
-	.ep[7] = {
+	  [7] = {
 		.ep = {
 			.name		= "ep7out-bulk",
 			.ops		= &pxa2xx_ep_ops,
@@ -2214,7 +2218,7 @@
 		.reg_uddr	= &UDDR7,
 		drcmr (31)
 	},
-	.ep[8] = {
+	  [8] = {
 		.ep = {
 			.name		= "ep8in-iso",
 			.ops		= &pxa2xx_ep_ops,
@@ -2228,7 +2232,7 @@
 		.reg_uddr	= &UDDR8,
 		drcmr (32)
 	},
-	.ep[9] = {
+	  [9] = {
 		.ep = {
 			.name		= "ep9out-iso",
 			.ops		= &pxa2xx_ep_ops,
@@ -2243,7 +2247,7 @@
 		.reg_uddr	= &UDDR9,
 		drcmr (33)
 	},
-	.ep[10] = {
+	  [10] = {
 		.ep = {
 			.name		= "ep10in-int",
 			.ops		= &pxa2xx_ep_ops,
@@ -2258,7 +2262,7 @@
 	},
 
 	/* third group of endpoints */
-	.ep[11] = {
+	  [11] = {
 		.ep = {
 			.name		= "ep11in-bulk",
 			.ops		= &pxa2xx_ep_ops,
@@ -2272,7 +2276,7 @@
 		.reg_uddr	= &UDDR11,
 		drcmr (35)
 	},
-	.ep[12] = {
+	  [12] = {
 		.ep = {
 			.name		= "ep12out-bulk",
 			.ops		= &pxa2xx_ep_ops,
@@ -2287,7 +2291,7 @@
 		.reg_uddr	= &UDDR12,
 		drcmr (36)
 	},
-	.ep[13] = {
+	  [13] = {
 		.ep = {
 			.name		= "ep13in-iso",
 			.ops		= &pxa2xx_ep_ops,
@@ -2301,7 +2305,7 @@
 		.reg_uddr	= &UDDR13,
 		drcmr (37)
 	},
-	.ep[14] = {
+	  [14] = {
 		.ep = {
 			.name		= "ep14out-iso",
 			.ops		= &pxa2xx_ep_ops,
@@ -2316,7 +2320,7 @@
 		.reg_uddr	= &UDDR14,
 		drcmr (38)
 	},
-	.ep[15] = {
+	  [15] = {
 		.ep = {
 			.name		= "ep15in-int",
 			.ops		= &pxa2xx_ep_ops,
@@ -2330,6 +2334,7 @@
 		.reg_uddr	= &UDDR15,
 	},
 #endif /* !CONFIG_USB_PXA2XX_SMALL */
+	}
 };
 
 #define CP15R0_VENDOR_MASK	0xffffe000
drivers/usb/gadget/pxa2xx_udc.h +19 -2
diff -urN gadget-2.4/drivers/usb/gadget/pxa2xx_udc.h linux-2.4.19-rmk7-pxa2-mtd20030728-ptx16pre/drivers/usb/gadget/pxa2xx_udc.h
@@ -297,7 +297,15 @@
 #ifdef CONFIG_ARCH_INNOKOM
 	if (machine_is_innokom()) {
 		GPSR(GPIO_INNOKOM_USB_ONOFF) = GPIO_bit(GPIO_INNOKOM_USB_ONOFF);
-		printk("RS: disappear\n");
+		printk("innokom: disappear\n");
+		udelay(5);
+		return;
+	}
+#endif
+#ifdef CONFIG_ARCH_CSB226
+	if (machine_is_csb226()) {
+		GPCR0 |= 0x00000080;
+		printk("csb226: disappear\n");
 		udelay(5);
 		return;
 	}
@@ -349,7 +357,16 @@
 #ifdef CONFIG_ARCH_INNOKOM
 	if (machine_is_innokom()) {
 		GPCR(GPIO_INNOKOM_USB_ONOFF) = GPIO_bit(GPIO_INNOKOM_USB_ONOFF);
-		printk("RS: appear\n");
+		printk("innokom: appear\n");
+		udelay(5);
+		return;
+	}
+#endif
+#ifdef CONFIG_ARCH_CSB226
+	if (machine_is_csb226()) {
+		GPDR0 |= 0x00000080;
+		GPSR0 |= 0x00000080;
+		printk("csb226: appear\n");
 		udelay(5);
 		return;
 	}
drivers/usb/gadget/rndis.c +1412 -0

1,412 lines not on this page · raw message

drivers/usb/gadget/rndis.h +314 -0

314 lines not on this page · raw message

drivers/usb/gadget/usbstring.c +1 -0
diff -urN gadget-2.4/drivers/usb/gadget/usbstring.c linux-2.4.19-rmk7-pxa2-mtd20030728-ptx16pre/drivers/usb/gadget/usbstring.c
@@ -12,6 +12,7 @@
 #include <linux/list.h>
 #include <linux/string.h>
 #include <linux/init.h>
+#include <asm/byteorder.h>
 
 #include <linux/usb_ch9.h>
 #include <linux/usb_gadget.h>
#1 lore raw
Quoted 5 lines · Robert Schwebel

David,

finally, here is our RNDIS USB Gadget Driver - see the attached patch against the gadget-2.4 BK tree as of now. It shouldn't be too difficult to port this to 2.6.

Yowsza! I've been looking forward to this ... :)

I'll look it over and see how the 2.6 merge goes, and probably run some revisions by you. The autoconfiguration updates will make this more complicated, since g_ether is starting to support a more dynamic configuration model; the HH.org crew need that, so PDA Linux distros don't need to hard-wire as much knowledge about hardware targets into their kernels.

Quoted 4 lines

The patch adds support for Microsoft's RNDIS protocol to the standard g_ether driver. This makes it possible to connect a Linux USB gadget to any standard Windows machine and <*PALIM!*> there is a new USB network interface on the Windows side on which you can speak TCP/IP :-)

Which is exactly what a lot of Linux solution providers need to see; I'm sure this will get a lot of use. Applause!

(Although I personally would prefer that Microsoft adopt vendor-neutral protocols, instead of pushing the rest of the industry to adopt things that are MSFT-biased ... for some reason, they haven't listened to almost anyone on such topics. Oh well. ;)

Quoted 5 lines

Unfortunately, although it works with the original Microsoft driver, you need an inf file on the windows side; you can download the template for that directly from M$.

Thanks to Auerswald GmbH for sponsoring this work!

I'll add them to the official "thank you" list on the
http://www.linux-usb.org/gadget webpage.

- Dave

Quoted 3 lines

Robert

#2 lore raw
Quoted 4 lines · David Brownell

(Although I personally would prefer that Microsoft adopt vendor-neutral protocols, instead of pushing the rest of the industry to adopt things that are MSFT-biased ... for some reason, they haven't listened to almost anyone on such topics. Oh well. ;)

Out of interest -- have they (or has anyone else) invented a 'file system' USB device yet? For exporting some file systems, pretending to be a block device really isn't very useful.

Signature · 1 line
dwmw2
#3 lore raw
Quoted 4 lines · David Woodhouse

Out of interest -- have they (or has anyone else) invented a 'file system' USB device yet? For exporting some file systems, pretending to be a block device really isn't very useful.

There's a file system protocol used by many digital still cameras, which isn't actually camera-specific. Not MSFT-specific either.

Originally called "Picture Transfer Protocol" (PTP) it's actually more of a remote hierarchical filesystem protocol ... with an event channel (handy for "new picture" or "inserted new flash memory") and some built-in search capabilities ("what JPGs do you have"). The strangest capability was a file type tag, which isn't actually that bizarre.

As with RNDIS, and USB Mass Storage, I understand that support for PTP is part of MS-Windows since about Win2K. So a PTP gadget driver would probably be a useful contribution to Linux.

- Dave

#4 lore raw
Quoted 10 lines · David Brownell

There's a file system protocol used by many digital still cameras, which isn't actually camera-specific. Not MSFT-specific either.

Originally called "Picture Transfer Protocol" (PTP) it's actually more of a remote hierarchical filesystem protocol ... with an event channel (handy for "new picture" or "inserted new flash memory") and some built-in search capabilities ("what JPGs do you have"). The strangest capability was a file type tag, which isn't actually that bizarre.

Quoted 3 lines

As with RNDIS, and USB Mass Storage, I understand that support for PTP is part of MS-Windows since about Win2K. So a PTP gadget driver would probably be a useful contribution to Linux.

A host driver "USB PTP Storage" would be really nice too. First as a generic camera interface, second to access a gadget with the PTP interface.

(Please embarrass me by saying there already is one, I'll be so happy I won't care :-) ).

I have a PTP camera and would certainly be happy to test such a driver. Time to write it is a different matter.

Don Reid

#5 lore raw
Quoted 10 lines
Quoted 3 lines

There's a file system protocol used by many digital still cameras, which isn't actually camera-specific. Not MSFT-specific either.
...

A host driver "USB PTP Storage" would be really nice too. First as a generic camera interface, second to access a gadget with the PTP interface.

(Please embarrass me by saying there already is one, I'll be so happy I won't care :-) ).

There isn't one. There are two. No need to be embarrassed ... ;)

They're both user-mode drivers. "gPhoto2", and "jPhoto". The author of jPhoto (moi) hasn't had time to update that code in ages.

- Dave

#6 lore raw
Quoted 8 lines · David Brownell
Quoted 8 lines
Quoted 3 lines

There's a file system protocol used by many digital still cameras, which isn't actually camera-specific. Not MSFT-specific either.
...

A host driver "USB PTP Storage" would be really nice too. First as a generic camera interface, second to access a gadget with the PTP interface.

Quoted 8 lines
Quoted 2 lines

(Please embarrass me by saying there already is one, I'll be so happy I won't care :-) ).

There isn't one. There are two. No need to be embarrassed ... ;)

They're both user-mode drivers. "gPhoto2", and "jPhoto". The author of jPhoto (moi) hasn't had time to update that code in ages.

These are applications, not file system interfaces like USB Mass Storage. I want to mount the camera or gadget file system and access it from any program, not run a separate app to fetch files like Mass Stor. mounts a memory device.

Why create a dedicated app like a camera interface instead of using your favorite image browser on some files?

Signature · 1 line
Don Reid
#7 lore raw
Quoted 7 lines · don

These are applications, not file system interfaces like USB Mass Storage. I want to mount the camera or gadget file system and access it from any program, not run a separate app to fetch files like Mass Stor. mounts a memory device.

Why create a dedicated app like a camera interface instead of using your favorite image browser on some files?

Bear in mind also that the reason I asked is because I want to export _real_ file systems this way, so you can plug your iPAQ in and access its file system without having to do it over NFS.

Signature · 1 line
dwmw2
#8 lore raw
In reply to don
Quoted 11 lines · don
Quoted 9 lines
Quoted 3 lines

A host driver "USB PTP Storage" would be really nice too. First as a generic camera interface, second to access a gadget with the PTP interface.

There isn't one. There are two. No need to be embarrassed ... ;)

They're both user-mode drivers. "gPhoto2", and "jPhoto". The author of jPhoto (moi) hasn't had time to update that code in ages.

Quoted 4 lines

These are applications, not file system interfaces like USB Mass Storage. I want to mount the camera or gadget file system and access it from any program, not run a separate app to fetch files like Mass Stor. mounts a memory device.

As Andrew Zabolotny commented, NFS _does_ work today from those devices. Except that it doesn't work to MS-Windows hosts, unless they've been taught other parts of the protocol stack.

Presumably Samba over RNDIS would work from Windows, but that would need extra work from many Linux hosts. Tradeoffs...

Quoted 2 lines

Why create a dedicated app like a camera interface instead of using your favorite image browser on some files?

Well, PTP should take less memory inside the device/gadget than a network stack, though it'd be less flexible. And there's also something to be said for less code in the kernel, and a simpler device setup model ... especially for the kinds of products that'd be considering something like PTP.

But I think the basic answer to your question is probably just that nobody's yet written, or at least submitted, PTP client or server kernel code for Linux.

- Dave

#9 lore raw
In reply to Robert Schwebel
Quoted 3 lines · Robert Schwebel

Unfortunately, although it works with the original Microsoft driver, you need an inf file on the windows side; you can download the template for that directly from M$.

I don't understand this comment, it would probably be very wise to add something to Documentation/ about this.

drivers/usb/gadget/ether.c line 449

Quoted 2 lines
drivers/usb/gadget/ether.c +1 -1
-	.bDeviceClass =		DEV_CONFIG_CLASS,
+	.bDeviceClass =		0x02,

Is this wise?

Thanks for this work, looks cool!

Signature · 2 lines
http://www.PowerDNS.com      Open source, database driven DNS Software 
http://lartc.org           Linux Advanced Routing & Traffic Control HOWTO
#10 lore raw
Quoted 6 lines · bert hubert
Quoted 3 lines

Unfortunately, although it works with the original Microsoft driver, you need an inf file on the windows side; you can download the template for that directly from M$.

I don't understand this comment, it would probably be very wise to add something to Documentation/ about this.

You need such an .inf file on the windows side; M$ has a template where you simply need to insert your vendor/device ID and other stuff. I'm not sure about the license for these files, so I don't know if it is allowed to distribute them.

Quoted 4 lines

drivers/usb/gadget/ether.c line 449

Quoted 2 lines
drivers/usb/gadget/ether.c +1 -1
-	.bDeviceClass =		DEV_CONFIG_CLASS,
+	.bDeviceClass =		0x02,

Is this wise?

Until now DEV_CONFIG_CLASS was 0xFF, which results in Windows getting hickup. If you directly set this to 0x02 (Network Device) Win is happy. Might be a good idea anyway.

Robert

Signature · 5 lines
 Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry
   Handelsregister:  Amtsgericht Hildesheim, HRA 2686
     Hornemannstraße 12,  31137 Hildesheim, Germany
    Phone: +49-5121-28619-0 |  Fax: +49-5121-28619-4
#11 lore raw
Quoted 4 lines · Robert Schwebel

You need such an .inf file on the windows side; M$ has a template where you simply need to insert your vendor/device ID and other stuff. I'm not sure about the license for these files, so I don't know if it is allowed to distribute them.

And that .inf describes 'Linux'? No matter what the license is, you can link to it and instruct people on how to change it. You could even show pieces of the .inf with the linux data filled in ('fair use').

I ask about this because I know that to get adequate testing coverage, experimenting with this code should be as easy as possible. Something like 'visit this URL and paste in the following: (...) and now do such and such in windows and you should be set'.

I'll happily write this for you if you provide the pointers.

Good luck!

Signature · 2 lines
http://www.PowerDNS.com      Open source, database driven DNS Software 
http://lartc.org           Linux Advanced Routing & Traffic Control HOWTO
#12 lore raw
In reply to Robert Schwebel
Quoted 10 lines · Robert Schwebel
Quoted 4 lines · bert hubert

drivers/usb/gadget/ether.c line 449

Quoted 2 lines
drivers/usb/gadget/ether.c +1 -1
-	.bDeviceClass =		DEV_CONFIG_CLASS,
+	.bDeviceClass =		0x02,

Is this wise?

Until now DEV_CONFIG_CLASS was 0xFF, which results in Windows getting hickup. If you directly set this to 0x02 (Network Device) Win is happy.

Actually I suspect setting it to USB_CLASS_COMM would be preferred, in RNDIS-specific config descriptors....

- Dave

#13 lore raw
Quoted 11 lines · David Brownell
Quoted 8 lines
Quoted 4 lines

drivers/usb/gadget/ether.c line 449

Quoted 2 lines
drivers/usb/gadget/ether.c +1 -1
-	.bDeviceClass =		DEV_CONFIG_CLASS,
+	.bDeviceClass =		0x02,

Is this wise?

Until now DEV_CONFIG_CLASS was 0xFF, which results in Windows getting hickup. If you directly set this to 0x02 (Network Device) Win is happy.

Actually I suspect setting it to USB_CLASS_COMM would be preferred, in RNDIS-specific config descriptors....

We have tried that, Windows does not like it. The only constellation where it worked was setting the device descriptor's bConfigClass=0x02.

RNDIS is a sensitive beast. Do one bit different results in that uggly "Error 10" message on the Windows side. We saw it when we started with the driver, we saw it when the driver was half way finished and we will see it again if somebody tweaks the driver without exactly knowing what the guys at Microsoft smoked when they designed that protocol :-)

Robert

Signature · 5 lines
 Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry
   Handelsregister:  Amtsgericht Hildesheim, HRA 2686
     Hornemannstraße 12,  31137 Hildesheim, Germany
    Phone: +49-5121-28619-0 |  Fax: +49-5121-28619-4
#14 lore raw
Quoted 8 lines · Robert Schwebel
Quoted 6 lines · David Brownell
Quoted 6 lines
Quoted 4 lines

drivers/usb/gadget/ether.c line 449

Quoted 2 lines
drivers/usb/gadget/ether.c +1 -1
-	.bDeviceClass =		DEV_CONFIG_CLASS,
+	.bDeviceClass =		0x02,

Is this wise?

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

Until now DEV_CONFIG_CLASS was 0xFF, which results in Windows getting hickup. If you directly set this to 0x02 (Network Device) Win is happy.

Actually I suspect setting it to USB_CLASS_COMM would be preferred, in RNDIS-specific config descriptors....

(since: #define USB_CLASS_COMM 2)

Quoted 2 lines

We have tried that, Windows does not like it. The only constellation where it worked was setting the device descriptor's bConfigClass=0x02.

Sorry, I meant "device" descriptors. Yes, I noticed their "spec" had strange things to say. Is there some reason you're not including the CDC header and union descriptors? That spec does talk about those, and the erratum I found also talks about better CDC ACM conformance.

Quoted 5 lines

RNDIS is a sensitive beast. Do one bit different results in that uggly "Error 10" message on the Windows side. We saw it when we started with the driver, we saw it when the driver was half way finished and we will see it again if somebody tweaks the driver without exactly knowing what the guys at Microsoft smoked when they designed that protocol :-)

I thought it was "just say no to vendor-neutral protocols" crack ... although that close to BC they would have much better options! ;)

The purist in me is annoyed that rather than just defining a purely vendor-specific protocol, they re-used bits and pieces of the USB-IF CDC-ACM spec. It's not like they needed _any_ of it. (Unless maybe subtle sabotoge of CDC was a goal?)

Different topic: I noticed that on PXA you were using "ep5-int". That's documented as always using DATA0 -- data toggle not working. Was that making any trouble for you? I've never actually tried using those endpoints, because of that functional limitation.

Also it looks like you've only tested this on PXA hardware. Most of the patch is the (R)NDIS support code, which is easy to merge, but the "g_ether" updates will take longer.

- Dave

Quoted 1 line

Robert

#15 lore raw
Quoted 7 lines · David Brownell
Quoted 2 lines

We have tried that, Windows does not like it. The only constellation where it worked was setting the device descriptor's bConfigClass=0x02.

Sorry, I meant "device" descriptors. Yes, I noticed their "spec" had strange things to say. Is there some reason you're not including the CDC header and union descriptors? That spec does talk about those, and the erratum I found also talks about better CDC ACM conformance.

USB_CLASS_COM is surely ok. The descriptors may be a relict from the time where the CDC equivalents where not in the driver...

The problem is that, as it is now, it works. The whole RNDIS stuff is extremely time intensive to debug: when you have one odd value in some place, Windows just says "Error 10" and you have to guess what you did wrong. No further information available. So the best way to be successful may be to check it in as it is, maybe add some FIXMEs, and let the masses test the code. Then cleanup the remaining issues step by step and wait until nobody crys any more :-)

Quoted 4 lines

Different topic: I noticed that on PXA you were using "ep5-int". That's documented as always using DATA0 -- data toggle not working. Was that making any trouble for you? I've never actually tried using those endpoints, because of that functional limitation.

Well, there is no other interrupt endpoint on the PXA, and it somehow works :-)

Quoted 1 line

Also it looks like you've only tested this on PXA hardware.

It was hard enough :-)

Quoted 2 lines

Most of the patch is the (R)NDIS support code, which is easy to merge, but the "g_ether" updates will take longer.

Ok. We have tried to make the design as minimal-invasive as possible...

Robert

Signature · 5 lines
 Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry
   Handelsregister:  Amtsgericht Hildesheim, HRA 2686
     Hornemannstraße 12,  31137 Hildesheim, Germany
    Phone: +49-5121-28619-0 |  Fax: +49-5121-28619-4
#16 lore raw
Quoted 9 lines · Robert Schwebel

...

The problem is that, as it is now, it works. The whole RNDIS stuff is extremely time intensive to debug: when you have one odd value in some place, Windows just says "Error 10" and you have to guess what you did wrong. No further information available. So the best way to be successful may be to check it in as it is, maybe add some FIXMEs, and let the masses test the code. Then cleanup the remaining issues step by step and wait until nobody crys any more :-)

Well, what I merge is necessarily going to work on more hardware than just PXA ... it'll work over net2280 (at high speed), goku, and surely other hardware. In most cases that'll just require sanity testing. Maybe I can get Julian to test on SH3, and it sounds like Andrew is getting close on the MediaQ.

Once I can see it work, then it'll be ready for that more widespread testing. (Do penguins actually cry?)

Quoted 8 lines
Quoted 4 lines

Different topic: I noticed that on PXA you were using "ep5-int". That's documented as always using DATA0 -- data toggle not working. Was that making any trouble for you? I've never actually tried using those endpoints, because of that functional limitation.

Well, there is no other interrupt endpoint on the PXA, and it somehow works :-)

It's not as if the protocol actually _needs_ an interrupt endpoint, though the MSFT spec says it does. It's actually simpler for the host to poll for completion on the control endpoint; none of the requests should take very long to finish anyway. An RNDIS host might not even notice those "toggle broken" issues.

Did you have any evidence that the MSFT host was actually using
that interrupt endpoint? Like CATC snooping showing it never
tried to collect responses until the interrupt packet arrived?

Also, which versions of MS-Windows did you test against? Some of the MSFT docs suggest version-specific protocol quirks. That's where I expect most of the end-user problem reports to appear! Which is why I'd like to have all the documented protocol quirks (including the other CDC descriptors) resolved before this starts to get really broad testing.

- Dave

#17 lore raw
Quoted 5 lines · David Brownell

Well, what I merge is necessarily going to work on more hardware than just PXA ... it'll work over net2280 (at high speed), goku, and surely other hardware. In most cases that'll just require sanity testing. Maybe I can get Julian to test on SH3, and it sounds like Andrew is getting close on the MediaQ.

A broader variety of controllers would indeed be helpful. When you have the stuff integrated the way you think it's right, just tell me and I'll test if it still works on our testbed.

Quoted 2 lines

Once I can see it work, then it'll be ready for that more widespread testing. (Do penguins actually cry?)

Only if they have to read Microsoft specifications :-)

Quoted 5 lines

It's not as if the protocol actually _needs_ an interrupt endpoint, though the MSFT spec says it does. It's actually simpler for the host to poll for completion on the control endpoint; none of the requests should take very long to finish anyway. An RNDIS host might not even notice those "toggle broken" issues.

You probably underestimate the mental sensibility of Windows machines. We have seen cases where the Windows host just floods you with interrupts when it is not happy with things like these...

Quoted 3 lines

Did you have any evidence that the MSFT host was actually using that interrupt endpoint? Like CATC snooping showing it never tried to collect responses until the interrupt packet arrived?

We have seen the packets with the protocol analyzer. I think we agree that using an interrupt endpoint just to announce that the gadget has a message for the host available, but that's how M$ designed it...

Quoted 2 lines

Also, which versions of MS-Windows did you test against? Some of the MSFT docs suggest version-specific protocol quirks.

Win 98, XP, 2000. Auerswald currently tests all available other variants, and the tests they invented are _really_ crazy ;)

Robert

Signature · 5 lines
 Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry
   Handelsregister:  Amtsgericht Hildesheim, HRA 2686
     Hornemannstraße 12,  31137 Hildesheim, Germany
    Phone: +49-5121-28619-0 |  Fax: +49-5121-28619-4
#18 lore raw
Quoted 3 lines · Robert Schwebel

A broader variety of controllers would indeed be helpful. When you have the stuff integrated the way you think it's right, just tell me and I'll test if it still works on our testbed.

OK, that'll work fine. Probably next week sometime.

Quoted 10 lines
Quoted 5 lines

It's not as if the protocol actually _needs_ an interrupt endpoint, though the MSFT spec says it does. It's actually simpler for the host to poll for completion on the control endpoint; none of the requests should take very long to finish anyway. An RNDIS host might not even notice those "toggle broken" issues.

You probably underestimate the mental sensibility of Windows machines. We have seen cases where the Windows host just floods you with interrupts when it is not happy with things like these...

Any system where BSOD is anything other than a screensaver is lacking many kinds of sensibility ... :)

That question was mostly for curiousity. The issue with interrupt endpoints and data toggle is trivially resolved by using ep6in-bulk instead of ep5in-int. Which is what the autoconfig version will likely end up doing, since default quality-of-service model for interrupt endpoints includes having working data toggle. PXA is wierd in that way, but it's got endpoints to burn.

Quoted 8 lines
Quoted 3 lines

Did you have any evidence that the MSFT host was actually using that interrupt endpoint? Like CATC snooping showing it never tried to collect responses until the interrupt packet arrived?

We have seen the packets with the protocol analyzer. I think we agree that using an interrupt endpoint just to announce that the gadget has a message for the host available, but that's how M$ designed it...

Sure it gets sent, but does it get used? If it does, does the data toggle matter, or is MSFT by default ignoring the toggle (and hence letting that needless data stream be undetectably corrupted)?

Quoted 6 lines
Quoted 2 lines

Also, which versions of MS-Windows did you test against? Some of the MSFT docs suggest version-specific protocol quirks.

Win 98, XP, 2000. Auerswald currently tests all available other variants, and the tests they invented are _really_ crazy ;)

OK, so good basic coverage. Modulo bugs introduced by various service packs or national releases ... ;)

- Dave

#19 lore raw
In reply to Robert Schwebel
Quoted 5 lines · Robert Schwebel
Quoted 2 lines

Most of the patch is the (R)NDIS support code, which is easy to merge, but the "g_ether" updates will take longer.

Ok. We have tried to make the design as minimal-invasive as possible...

And that pretty much worked ... I've sent Greg a 2.6 version, tested with net2280 and goku_udc, so I hope that'll appear in some "-mm" patch soonish (and then presumably in 2.6.6-early).

It does need testing on PXA though.

- Dave