NetBSD Problem Report #40049
From khorben@defora.org Thu Nov 27 18:04:49 2008
Return-Path: <khorben@defora.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by narn.NetBSD.org (Postfix) with ESMTP id 485A163B8BD
for <gnats-bugs@gnats.NetBSD.org>; Thu, 27 Nov 2008 18:04:49 +0000 (UTC)
Message-Id: <20081127170055.0ABA85470@syn.defora.rom>
Date: Thu, 27 Nov 2008 18:00:54 +0100 (CET)
From: Pierre Pronchery <ppronchery@bearstech.com>
Reply-To:
To: gnats-bugs@gnats.NetBSD.org
Subject: Openmoko Freerunner CDC Ethernet emulation does not work
X-Send-Pr-Version: 3.95
>Number: 40049
>Category: kern
>Synopsis: Support more USB CDC Ethernet devices (eg Openmoko Freerunner)
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: tron
>State: closed
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Thu Nov 27 18:05:00 +0000 2008
>Closed-Date: Sat Sep 05 12:58:23 +0000 2009
>Last-Modified: Sat Sep 05 12:58:23 +0000 2009
>Originator: Pierre Pronchery <ppronchery@bearstech.com>
>Release: NetBSD 5.0_BETA
>Organization:
Bearstech
>Environment:
System: NetBSD syn.defora.rom 5.0_BETA NetBSD 5.0_BETA (GENERIC) #11: Thu Nov 27 17:41:49 CET 2008 khorben@syn.defora.rom:/usr/obj/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
The Openmoko Freerunner is not successfully recognized as a CDC Ethernet device. FreeBSD has code for USB cable modems that makes this work (patch attached).
>How-To-Repeat:
Plug an Openmoko Freerunner into the USB port:
$ dmesg | grep cdce0
cdce0 at uhub0 port 2 configuration 1 interface 0
cdce0: Linux 2.6.24/s3c2410_udc RNDIS/Ethernet Gadget, rev 2.00/2.12, addr 2
cdce0: could not find data bulk in
And then the cdce0 interface does not exist.
>Fix:
With the following patch from FreeBSD:
$ ifconfig cdce0
cdce0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
address: 2a:27:01:00:00:00
inet 192.168.0.200 netmask 0xffffff00 broadcast 192.168.0.255
Index: sys/dev/usb/if_cdce.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/if_cdce.c,v
retrieving revision 1.18
diff -p -u -r1.18 if_cdce.c
--- sys/dev/usb/if_cdce.c 24 Sep 2008 07:19:18 -0000 1.18
+++ sys/dev/usb/if_cdce.c 27 Nov 2008 16:54:55 -0000
@@ -154,8 +154,9 @@ USB_ATTACH(cdce)
usb_interface_descriptor_t *id;
usb_endpoint_descriptor_t *ed;
const usb_cdc_union_descriptor_t *ud;
+ usb_config_descriptor_t *cd;
int data_ifcno;
- int i;
+ int i, j, numalts;
u_char eaddr[ETHER_ADDR_LEN];
const usb_cdc_ethernet_descriptor_t *ue;
char eaddr_str[USB_MAX_ENCODED_STRING_LEN];
@@ -202,29 +203,61 @@ USB_ATTACH(cdce)
USB_ATTACH_ERROR_RETURN;
}
- /* Find endpoints. */
+ /*
+ * <quote>
+ * The Data Class interface of a networking device shall have a minimum
+ * of two interface settings. The first setting (the default interface
+ * setting) includes no endpoints and therefore no networking traffic is
+ * exchanged whenever the default interface setting is selected. One or
+ * more additional interface settings are used for normal operation, and
+ * therefore each includes a pair of endpoints (one IN, and one OUT) to
+ * exchange network traffic. Select an alternate interface setting to
+ * initialize the network aspects of the device and to enable the
+ * exchange of network traffic.
+ * </quote>
+ *
+ * Some devices, most notably cable modems, include interface settings
+ * that have no IN or OUT endpoint, therefore loop through the list of all
+ * available interface settings looking for one with both IN and OUT
+ * endpoints.
+ */
id = usbd_get_interface_descriptor(sc->cdce_data_iface);
- sc->cdce_bulkin_no = sc->cdce_bulkout_no = -1;
- for (i = 0; i < id->bNumEndpoints; i++) {
- ed = usbd_interface2endpoint_descriptor(sc->cdce_data_iface, i);
- if (!ed) {
- aprint_error_dev(self,
- "could not read endpoint descriptor\n");
+ cd = usbd_get_config_descriptor(sc->cdce_udev);
+ numalts = usbd_get_no_alts(cd, id->bInterfaceNumber);
+
+ for (j = 0; j < numalts; j++) {
+ if (usbd_set_interface(sc->cdce_data_iface, j)) {
+ aprint_error_dev(sc->cdce_dev,
+ "setting alternate interface failed\n");
USB_ATTACH_ERROR_RETURN;
}
- if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
- UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
- sc->cdce_bulkin_no = ed->bEndpointAddress;
- } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&
- UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
- sc->cdce_bulkout_no = ed->bEndpointAddress;
- } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
- UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT) {
- /* XXX: CDC spec defines an interrupt pipe, but it is not
- * needed for simple host-to-host applications. */
- } else {
- aprint_error_dev(self, "unexpected endpoint\n");
+ /* Find endpoints. */
+ id = usbd_get_interface_descriptor(sc->cdce_data_iface);
+ sc->cdce_bulkin_no = sc->cdce_bulkout_no = -1;
+ for (i = 0; i < id->bNumEndpoints; i++) {
+ ed = usbd_interface2endpoint_descriptor(sc->cdce_data_iface, i);
+ if (!ed) {
+ aprint_error_dev(self,
+ "could not read endpoint descriptor\n");
+ USB_ATTACH_ERROR_RETURN;
+ }
+ if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
+ UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
+ sc->cdce_bulkin_no = ed->bEndpointAddress;
+ } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&
+ UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
+ sc->cdce_bulkout_no = ed->bEndpointAddress;
+ } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
+ UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT) {
+ /* XXX: CDC spec defines an interrupt pipe, but it is not
+ * needed for simple host-to-host applications. */
+ } else {
+ aprint_error_dev(self, "unexpected endpoint\n");
+ }
}
+ /* If we found something, try and use it... */
+ if ((sc->cdce_bulkin_no != -1) && (sc->cdce_bulkout_no != -1))
+ break;
}
if (sc->cdce_bulkin_no == -1) {
>Release-Note:
>Audit-Trail:
From: "John D. Baker" <jdbaker@mylinuxisp.com>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: Re: kern/40049
Date: Sat, 24 Jan 2009 20:07:54 -0600 (CST)
I've been successfully using this patch for a while. I've not
seen any problem. Could this be comitted?
I adapted it to v1.19 of the driver as found in -current and it works
fine there, too. Can this be committed upstream, too?
I also adapted it back to v1.12 of the driver as found in 4.0_STABLE.
As such, it solves the attachment problem. Attempting to communicate
through the cdce0 interface results in:
arpresolve: can't allocate llinfo on cdce0 for 192.168.0.202
which is similar to kern/36592 (and kern/37653).
If desired, I'll submit my adaptations of the patch.
Thanks.
--
John D. Baker, KN5UKS NetBSD Darwin/MacOS X
jdbaker[snail]mylinuxisp[flyspeck]com OpenBSD FreeBSD
BSD -- It just sits there and _works_!
GPG fingerprint: D703 4A7E 479F 63F8 D3F4 BD99 9572 8F23 E4AD 1645
From: Pierre Pronchery <khorben@defora.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: Re: kern/40049: Support more USB CDC Ethernet devices (eg Openmoko
Freerunner)
Date: Thu, 19 Feb 2009 15:56:46 +0100
I don't mean any pressure whatsoever, but I'd also like to see it
committed... A pull-up to NetBSD 5 before the release would be even
better :)
--
khorben
Responsible-Changed-From-To: kern-bug-people->tron
Responsible-Changed-By: tron@NetBSD.org
Responsible-Changed-When: Sun, 16 Aug 2009 13:39:23 +0000
Responsible-Changed-Why:
I'll try to handle this PR.
From: Matthias Scheler <tron@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/40049 CVS commit: src/sys/dev/usb
Date: Sun, 16 Aug 2009 14:18:49 +0000
Module Name: src
Committed By: tron
Date: Sun Aug 16 14:18:49 UTC 2009
Modified Files:
src/sys/dev/usb: if_cdce.c
Log Message:
Add support for the Openmoko Freerunner to cdce(4) ported from FreeBSD.
The patch was supplied by Pierre Pronchery in PR kern/40049.
To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/usb/if_cdce.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->pending-pullups
State-Changed-By: tron@NetBSD.org
State-Changed-When: Sun, 23 Aug 2009 10:27:18 +0000
State-Changed-Why:
Nobody complained about the change in NetBSD-current. It is time for
a pullup request.
From: Manuel Bouyer <bouyer@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/40049 CVS commit: [netbsd-5] src/sys/dev/usb
Date: Sat, 5 Sep 2009 12:52:40 +0000
Module Name: src
Committed By: bouyer
Date: Sat Sep 5 12:52:40 UTC 2009
Modified Files:
src/sys/dev/usb [netbsd-5]: if_cdce.c
Log Message:
Pull up following revision(s) (requested by tron in ticket #922):
sys/dev/usb/if_cdce.c: revision 1.22
Add support for the Openmoko Freerunner to cdce(4) ported from FreeBSD.
The patch was supplied by Pierre Pronchery in PR kern/40049.
To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.18.4.1 src/sys/dev/usb/if_cdce.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: pending-pullups->closed
State-Changed-By: tron@NetBSD.org
State-Changed-When: Sat, 05 Sep 2009 12:58:23 +0000
State-Changed-Why:
Your patch has been committed and pulled up. Thanks a lot for your
contribution.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.