Hello, I have reworked this patch and tested on 6.4. It's now working properly. I was able to clean up and streamline some of the logic too. I have checked and it applies cleanly against -current as well.
This patch makes handling of E-Series or "new mode" Huawei devices a bit more generic, as well as adding support for the E8372 specifically. This code should work with other HiLink devices which require the new mode switching to enter cdce. It would be great if anyone with Huawei devices, especially ones which previously worked fine with OpenBSD 6.4, could test this patch. The patch should allow the device to register a cdce interface, rather than USB serial devices, allowing the device to be used at full capacity. Interestingly, I found that I had to modify the logic in cdce to return UMATCH_VENDOR_IFACESUBCLASS for the interface to be claimed as a cdce device, UMATCH_IFACECLASS_GENERIC or UMATCH_IFACECLASS did not work. I'm curious to understand the precedence of these return codes, but in the end I suppose if UMATCH_VENDOR_IFACESUBCLASS is the correct return then I am happy with that. Patch follows. Best, James Index: dev/usb/if_cdce.c =================================================================== RCS file: /cvs/src/sys/dev/usb/if_cdce.c,v retrieving revision 1.75 diff -u -p -u -r1.75 if_cdce.c --- dev/usb/if_cdce.c 2 Oct 2018 19:49:10 -0000 1.75 +++ dev/usb/if_cdce.c 28 Jan 2019 05:21:29 -0000 @@ -139,7 +139,7 @@ cdce_match(struct device *parent, void * (id->bInterfaceSubClass == UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL || id->bInterfaceSubClass == UISUBCLASS_MOBILE_DIRECT_LINE_MODEL)) - return (UMATCH_IFACECLASS_GENERIC); + return (UMATCH_VENDOR_IFACESUBCLASS); return (UMATCH_NONE); } Index: dev/usb/umsm.c =================================================================== RCS file: /cvs/src/sys/dev/usb/umsm.c,v retrieving revision 1.114 diff -u -p -u -r1.114 umsm.c --- dev/usb/umsm.c 15 Aug 2018 14:13:07 -0000 1.114 +++ dev/usb/umsm.c 28 Jan 2019 05:21:30 -0000 @@ -133,7 +133,7 @@ static const struct umsm_type umsm_devs[ {{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E182 }, DEV_UMASS5}, {{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E1820 }, DEV_UMASS5}, {{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E220 }, DEV_HUAWEI}, - {{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E303 }, DEV_UMASS5}, + {{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_ESERIES_INIT }, DEV_UMASS5}, {{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E353_INIT }, DEV_UMASS5}, {{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E510 }, DEV_HUAWEI}, {{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E618 }, DEV_HUAWEI}, @@ -150,6 +150,7 @@ static const struct umsm_type umsm_devs[ {{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E1750 }, DEV_UMASS5}, {{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E1752 }, 0}, {{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E3372 }, DEV_UMASS5}, + {{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E8372 }, DEV_UMASS5}, {{ USB_VENDOR_HYUNDAI, USB_PRODUCT_HYUNDAI_UM175 }, 0}, @@ -309,7 +310,16 @@ umsm_match(struct device *parent, void * * Some high-speed modems require special care. */ if (flag & DEV_HUAWEI) { - if (uaa->ifaceno != 2) + if (uaa->ifaceno != 2) + return UMATCH_VENDOR_IFACESUBCLASS; + else + return UMATCH_NONE; + } else if (flag & DEV_UMASS5) { + /* + * Interface 2 on these devices is an SD + * card slot typically, so let umsm grab it + */ + if (uaa->ifaceno == 2) return UMATCH_VENDOR_IFACESUBCLASS; else return UMATCH_NONE; @@ -374,6 +384,8 @@ umsm_attach(struct device *parent, struc printf("%s: truinstall mode. need to reattach\n", sc->sc_dev.dv_xname); } else if ((sc->sc_flag & DEV_UMASS) && uaa->ifaceno == 0) { + printf("%s: cdce/umsm will switch mode. need to reattach\n", + sc->sc_dev.dv_xname); umsm_umass_changemode(sc); } @@ -710,6 +722,10 @@ umsm_umass_changemode(struct umsm_softc cbw.bCBWFlags = CBWFLAGS_OUT; cbw.CBWCDB[0] = 0x11; cbw.CBWCDB[1] = 0x06; + cbw.CBWCDB[2] = 0x20; + cbw.CBWCDB[5] = 0x01; + cbw.CBWCDB[6] = 0x01; + cbw.CBWCDB[8] = 0x01; break; case DEV_UMASS6: /* ZTE */ USETDW(cbw.dCBWDataTransferLength, 0x20); Index: dev/usb/usbdevs =================================================================== RCS file: /cvs/src/sys/dev/usb/usbdevs,v retrieving revision 1.692 diff -u -p -u -r1.692 usbdevs --- dev/usb/usbdevs 22 Aug 2018 15:30:20 -0000 1.692 +++ dev/usb/usbdevs 28 Jan 2019 05:21:34 -0000 @@ -2218,6 +2218,7 @@ product HUAWEI E181 0x1414 HUAWEI Mobil product HUAWEI E1752 0x1417 HUAWEI Mobile Modem product HUAWEI E182 0x1429 HUAWEI Mobile Modem product HUAWEI E3372 0x1442 HUAWEI Mobile Modem +product HUAWEI E8372 0x14db HUAWEI Mobile Modem product HUAWEI E161 0x1446 HUAWEI Mobile Modem product HUAWEI K3765 0x1465 HUAWEI Mobile K3765 product HUAWEI K3772 0x14cf HUAWEI Mobile K3772 @@ -2231,7 +2232,7 @@ product HUAWEI K3772_INIT 0x1526 HUAWEI product HUAWEI MU609 0x1573 HUAWEI Mobile ME906 product HUAWEI E173S 0x1c05 HUAWEI Mobile E173s product HUAWEI E173S_INIT 0x1c0b HUAWEI Mobile E173s Initial -product HUAWEI E303 0x1f01 HUAWEI Mobile E303 +product HUAWEI ESERIES_INIT 0x1f01 HUAWEI Mobile ESeries Initial /* HUMAX products */ product HUMAX PVRSMART 0x138c PVR-SMART Index: dev/usb/usbdevs.h =================================================================== RCS file: /cvs/src/sys/dev/usb/usbdevs.h,v retrieving revision 1.704 diff -u -p -u -r1.704 usbdevs.h --- dev/usb/usbdevs.h 22 Aug 2018 15:31:05 -0000 1.704 +++ dev/usb/usbdevs.h 28 Jan 2019 05:21:40 -0000 @@ -2225,7 +2225,8 @@ #define USB_PRODUCT_HUAWEI_E1752 0x1417 /* HUAWEI Mobile Modem */ #define USB_PRODUCT_HUAWEI_E182 0x1429 /* HUAWEI Mobile Modem */ #define USB_PRODUCT_HUAWEI_E3372 0x1442 /* HUAWEI Mobile Modem */ -#define USB_PRODUCT_HUAWEI_E161 0x1446 /* HUAWEI Mobile Modem */ +#define USB_PRODUCT_HUAWEI_E161 0x1446 /* HUAWEI Mobile Modem */ +#define USB_PRODUCT_HUAWEI_E8372 0x14db /* HUAWEI Mobile Modem */ #define USB_PRODUCT_HUAWEI_K3765 0x1465 /* HUAWEI Mobile K3765 */ #define USB_PRODUCT_HUAWEI_K3772 0x14cf /* HUAWEI Mobile K3772 */ #define USB_PRODUCT_HUAWEI_E1820 0x14ac /* HUAWEI Mobile Modem */ @@ -2238,7 +2239,7 @@ #define USB_PRODUCT_HUAWEI_MU609 0x1573 /* HUAWEI Mobile ME906 */ #define USB_PRODUCT_HUAWEI_E173S 0x1c05 /* HUAWEI Mobile E173s */ #define USB_PRODUCT_HUAWEI_E173S_INIT 0x1c0b /* HUAWEI Mobile E173s Initial */ -#define USB_PRODUCT_HUAWEI_E303 0x1f01 /* HUAWEI Mobile E303 */ +#define USB_PRODUCT_HUAWEI_ESERIES_INIT 0x1f01 /* HUAWEI Mobile ESeries Generic Init */ /* HUMAX products */ #define USB_PRODUCT_HUMAX_PVRSMART 0x138c /* PVR-SMART */ Index: dev/usb/usbdevs_data.h =================================================================== RCS file: /cvs/src/sys/dev/usb/usbdevs_data.h,v retrieving revision 1.698 diff -u -p -u -r1.698 usbdevs_data.h --- dev/usb/usbdevs_data.h 22 Aug 2018 15:31:05 -0000 1.698 +++ dev/usb/usbdevs_data.h 28 Jan 2019 05:21:47 -0000 @@ -4698,6 +4698,10 @@ const struct usb_known_product usb_known "HUAWEI Mobile Modem", }, { + USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E8372, + "HUAWEI Mobile Modem", + }, + { USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_K3765, "HUAWEI Mobile K3765", }, @@ -4746,8 +4750,8 @@ const struct usb_known_product usb_known "HUAWEI Mobile E173s Initial", }, { - USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E303, - "HUAWEI Mobile E303", + USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_ESERIES_INIT, + "HUAWEI Mobile ESeries Generic Initial", }, { USB_VENDOR_HUMAX, USB_PRODUCT_HUMAX_PVRSMART, On Tue, Jan 22, 2019 at 07:11:53AM +1100, James Hebden wrote: > I've been doing some more testing on newer OpenBSD releases (namely 6.4) > and have picked up a couple of problems with this patch. There are a > couple of cleanups needed (a duplicated conditional in umsm.c for > example, and small formatting issues ) as a result of bringing this > patch forward, and I've got to work out why the reattach isn't happening > on OpenBSD 6.4+. > > If anyone has any feedback in the meantime, that would be very much > appreciated, but until then, I'll be working on diagnosing. > > Best, > James > > On Mon, Jan 21, 2019 at 05:04:02PM +1100, James Hebden wrote: > > Hello tech@, > > > > Given this is my first email to the list, and the first patch I have > > submitted to the OpenBSD project, I am very open to feedback on > > the attached patch and context provided! > > > > Below I have included a patch I have been working on to modify some of > > the logic when handling E-series Huawei USB mobile broadband dongles. > > > > These devices are able to operate in several modes, the most compatible > > and performant mode being as a USB networking device ('HiLink' mode), > > providing a NAT'ed connection to the mobile broadband service of the > > connected provider. > > > > Using this mode requires no additional software, other than a DHCP > > client in OpenBSD. Even that is optional, give you could statically > > configure the interface. > > > > This patch refactors lightly some of the logic around handling E-Series > > devices, and moves the original device definitions for the E303 to a > > generic 'E-Series' device definition, given all E-Series devices seem to > > share the parts of the intialisation and the USB product and vendor IDs > > which OpenBSD currently assigns to the E303 device. > > > > I have also added additional logic to identify the E8372, which is the > > device I am testing with, as additional logic is required to switch it > > into HiLink mode. This should work for other E-Series HiLink devices > > supporting the same mode. If anyone with one (or more!) of these > > devices (say, the E3372, which appears to be almost identical) > > could test this patch, it would be very much appreciated. > > > > I have tested this patch and it applies cleanly against -current, 6.4 > > and 6.3. I am currently using this on the 6.3 kernel as my > > home router, and so far it has proved reliable. > > > > Best Regards, > > James "ec0" Hebden > > > > Patch follows - > > <.. snip ..> > >
signature.asc
Description: PGP signature