Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Jan 2018 12:59:14 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r328162 - in head/sys/dev/usb: net serial
Message-ID:  <201801191259.w0JCxEfa096220@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Fri Jan 19 12:59:14 2018
New Revision: 328162
URL: https://svnweb.freebsd.org/changeset/base/328162

Log:
  Improve support for USB based 3G/4G/5G dongles from Huawei.
  
  PR:		192345
  Sponsored by:	Mellanox Technologies

Modified:
  head/sys/dev/usb/net/if_cdce.c
  head/sys/dev/usb/serial/u3g.c
  head/sys/dev/usb/serial/umodem.c

Modified: head/sys/dev/usb/net/if_cdce.c
==============================================================================
--- head/sys/dev/usb/net/if_cdce.c	Fri Jan 19 12:50:03 2018	(r328161)
+++ head/sys/dev/usb/net/if_cdce.c	Fri Jan 19 12:59:14 2018	(r328162)
@@ -286,6 +286,9 @@ static const STRUCT_USB_HOST_ID cdce_host_devs[] = {
 	{USB_VENDOR(USB_VENDOR_HUAWEI), USB_IFACE_CLASS(UICLASS_VENDOR),
 		USB_IFACE_SUBCLASS(0x02), USB_IFACE_PROTOCOL(0x76),
 		USB_DRIVER_INFO(0)},
+	{USB_VENDOR(USB_VENDOR_HUAWEI), USB_IFACE_CLASS(UICLASS_VENDOR),
+		USB_IFACE_SUBCLASS(0x03), USB_IFACE_PROTOCOL(0x16),
+		USB_DRIVER_INFO(0)},
 };
 
 static const STRUCT_USB_DUAL_ID cdce_dual_devs[] = {

Modified: head/sys/dev/usb/serial/u3g.c
==============================================================================
--- head/sys/dev/usb/serial/u3g.c	Fri Jan 19 12:50:03 2018	(r328161)
+++ head/sys/dev/usb/serial/u3g.c	Fri Jan 19 12:59:14 2018	(r328162)
@@ -308,7 +308,7 @@ static const STRUCT_USB_HOST_ID u3g_devs[] = {
 	U3G_DEV(HUAWEI, E173, 0),
 	U3G_DEV(HUAWEI, E173_INIT, U3GINIT_HUAWEISCSI),
 	U3G_DEV(HUAWEI, E3131, 0),
-	U3G_DEV(HUAWEI, E3131_INIT, U3GINIT_HUAWEISCSI),
+	U3G_DEV(HUAWEI, E3131_INIT, U3GINIT_HUAWEISCSI2),
 	U3G_DEV(HUAWEI, E180V, U3GINIT_HUAWEI),
 	U3G_DEV(HUAWEI, E220, U3GINIT_HUAWEI),
 	U3G_DEV(HUAWEI, E220BIS, U3GINIT_HUAWEI),
@@ -329,6 +329,8 @@ static const STRUCT_USB_HOST_ID u3g_devs[] = {
 	U3G_DEV(HUAWEI, K4505, U3GINIT_HUAWEI),
 	U3G_DEV(HUAWEI, K4505_INIT, U3GINIT_HUAWEISCSI),
 	U3G_DEV(HUAWEI, ETS2055, U3GINIT_HUAWEI),
+	U3G_DEV(HUAWEI, E3272_INIT, U3GINIT_HUAWEISCSI2),
+	U3G_DEV(HUAWEI, E3272, 0),
 	U3G_DEV(KYOCERA2, CDMA_MSM_K, 0),
 	U3G_DEV(KYOCERA2, KPC680, 0),
 	U3G_DEV(LONGCHEER, WM66, U3GINIT_HUAWEI),
@@ -631,6 +633,45 @@ u3g_huawei_init(struct usb_device *udev)
 	return (0);
 }
 
+static int
+u3g_huawei_is_cdce(uint16_t idVendor, uint8_t bInterfaceSubClass,
+    uint8_t bInterfaceProtocol)
+{
+	/*
+	 * This function returns non-zero if the interface being
+	 * probed is of type CDC ethernet, which the U3G driver should
+	 * not attach to. See sys/dev/usb/net/if_cdce.c for matching
+	 * entries.
+	 */
+	if (idVendor != USB_VENDOR_HUAWEI)
+		goto done;
+
+	switch (bInterfaceSubClass) {
+	case 0x02:
+		switch (bInterfaceProtocol) {
+		case 0x16:
+		case 0x46:
+		case 0x76:
+			return (1);
+		default:
+			break;
+		}
+		break;
+	case 0x03:
+		switch (bInterfaceProtocol) {
+		case 0x16:
+			return (1);
+		default:
+			break;
+		}
+		break;
+	default:
+		break;
+	}
+done:
+	return (0);
+}
+
 static void
 u3g_sael_m460_init(struct usb_device *udev)
 {
@@ -844,6 +885,10 @@ u3g_probe(device_t self)
 	if (uaa->info.bInterfaceClass != UICLASS_VENDOR) {
 		return (ENXIO);
 	}
+	if (u3g_huawei_is_cdce(uaa->info.idVendor, uaa->info.bInterfaceSubClass,
+	    uaa->info.bInterfaceProtocol)) {
+		return (ENXIO);
+	}
 	return (usbd_lookup_id_by_uaa(u3g_devs, sizeof(u3g_devs), uaa));
 }
 
@@ -886,6 +931,9 @@ u3g_attach(device_t dev)
 			break;
 		id = usbd_get_interface_descriptor(iface);
 		if (id == NULL || id->bInterfaceClass != UICLASS_VENDOR)
+			continue;
+		if (u3g_huawei_is_cdce(uaa->info.idVendor,
+		    id->bInterfaceSubClass, id->bInterfaceProtocol))
 			continue;
 		usbd_set_parent_iface(uaa->device, i, uaa->info.bIfaceIndex);
 		iface_valid |= (1<<i);

Modified: head/sys/dev/usb/serial/umodem.c
==============================================================================
--- head/sys/dev/usb/serial/umodem.c	Fri Jan 19 12:50:03 2018	(r328161)
+++ head/sys/dev/usb/serial/umodem.c	Fri Jan 19 12:59:14 2018	(r328162)
@@ -131,6 +131,18 @@ static const STRUCT_USB_DUAL_ID umodem_dual_devs[] = {
 
 static const STRUCT_USB_HOST_ID umodem_host_devs[] = {
 	/* Huawei Modem class match */
+	{USB_VENDOR(USB_VENDOR_HUAWEI), USB_IFACE_CLASS(UICLASS_VENDOR),
+		USB_IFACE_SUBCLASS(0x02), USB_IFACE_PROTOCOL(0x01)},
+	{USB_VENDOR(USB_VENDOR_HUAWEI), USB_IFACE_CLASS(UICLASS_VENDOR),
+		USB_IFACE_SUBCLASS(0x02), USB_IFACE_PROTOCOL(0x02)},
+	{USB_VENDOR(USB_VENDOR_HUAWEI), USB_IFACE_CLASS(UICLASS_VENDOR),
+		USB_IFACE_SUBCLASS(0x02), USB_IFACE_PROTOCOL(0x10)},
+	{USB_VENDOR(USB_VENDOR_HUAWEI), USB_IFACE_CLASS(UICLASS_VENDOR),
+		USB_IFACE_SUBCLASS(0x02), USB_IFACE_PROTOCOL(0x12)},
+	{USB_VENDOR(USB_VENDOR_HUAWEI), USB_IFACE_CLASS(UICLASS_VENDOR),
+		USB_IFACE_SUBCLASS(0x02), USB_IFACE_PROTOCOL(0x61)},
+	{USB_VENDOR(USB_VENDOR_HUAWEI), USB_IFACE_CLASS(UICLASS_VENDOR),
+		USB_IFACE_SUBCLASS(0x02), USB_IFACE_PROTOCOL(0x62)},
 	{USB_VENDOR(USB_VENDOR_HUAWEI),USB_IFACE_CLASS(UICLASS_CDC),
 		USB_IFACE_SUBCLASS(UISUBCLASS_ABSTRACT_CONTROL_MODEL),
 		USB_IFACE_PROTOCOL(0xFF)},



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201801191259.w0JCxEfa096220>