From e376c668d480fc3e6a7e4bbebff04f7552ca6dfa Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Mon, 23 Mar 2015 07:02:16 +0100
Subject: [PATCH] WIP u4b urndis/umodem

---
 etc/devd/usb.conf           | 34 ++++++++++++++++++++++++++--------
 sys/bus/u4b/net/if_urndis.c | 20 +++-----------------
 sys/bus/u4b/serial/umodem.c | 20 +++++++-------------
 3 files changed, 36 insertions(+), 38 deletions(-)

diff --git a/etc/devd/usb.conf b/etc/devd/usb.conf
index 02c57ee..7765800 100644
--- a/etc/devd/usb.conf
+++ b/etc/devd/usb.conf
@@ -855,7 +855,7 @@ nomatch 32 {
 	match "bus" "uhub[0-9]+";
 	match "mode" "host";
 	match "vendor" "0x05c6";
-	match "product" "(0x1000|0x6000|0x6613)";
+	match "product" "(0x1000|0x6000|0x6500|0x6613|0x9000|0x9002|0x9204|0x9205)";
 	action "kldload -n u3g";
 };
 
@@ -2775,7 +2775,7 @@ nomatch 32 {
 	match "bus" "uhub[0-9]+";
 	match "mode" "host";
 	match "vendor" "0x19d2";
-	match "product" "(0x0001|0x0002|0x0003|0x0004|0x0005|0x0006|0x0007|0x0008|0x0009|0x000a|0x000b|0x000c|0x000d|0x000e|0x000f|0x0010|0x0011|0x0012|0x0013|0x0014|0x0015|0x0016|0x0017|0x0018|0x0019|0x0020|0x0021|0x0022|0x0023|0x0024|0x0025|0x0026|0x0027|0x0028|0x0029|0x0030|0x0031|0x0032|0x0033|0x0037|0x0039|0x0042|0x0043|0x0048|0x0049|0x0051|0x0052|0x0053|0x0054|0x0055|0x0057|0x0058|0x0059|0x0060|0x0061|0x0062|0x0063|0x0064|0x0066|0x0069|0x0070|0x0073|0x0076|0x0078|0x0082|0x0086|0x0117|0x2000|0x2002|0x2003|0xfff1|0xfff5|0xfffe)";
+	match "product" "(0x0001|0x0002|0x0003|0x0004|0x0005|0x0006|0x0007|0x0008|0x0009|0x000a|0x000b|0x000c|0x000d|0x000e|0x000f|0x0010|0x0011|0x0012|0x0013|0x0014|0x0015|0x0016|0x0017|0x0018|0x0019|0x0020|0x0021|0x0022|0x0023|0x0024|0x0025|0x0026|0x0027|0x0028|0x0029|0x0030|0x0031|0x0032|0x0033|0x0037|0x0039|0x0042|0x0043|0x0048|0x0049|0x0051|0x0052|0x0053|0x0054|0x0055|0x0057|0x0058|0x0059|0x0060|0x0061|0x0062|0x0063|0x0064|0x0066|0x0069|0x0070|0x0073|0x0076|0x0078|0x0082|0x0086|0x0117|0x1420|0x2000|0x2002|0x2003|0xffdd|0xffde|0xfff1|0xfff5|0xfffe)";
 	action "kldload -n u3g";
 };
 
@@ -2959,6 +2959,14 @@ nomatch 32 {
 	match "bus" "uhub[0-9]+";
 	match "mode" "host";
 	match "vendor" "0x2001";
+	match "product" "(0x7d02|0x7e12|0xa707|0xa805)";
+	action "kldload -n u3g";
+};
+
+nomatch 32 {
+	match "bus" "uhub[0-9]+";
+	match "mode" "host";
+	match "vendor" "0x2001";
 	match "product" "0xabc1";
 	action "kldload -n if_aue";
 };
@@ -3312,6 +3320,16 @@ nomatch 32 {
 nomatch 32 {
 	match "bus" "uhub[0-9]+";
 	match "mode" "host";
+	match "vendor" "0x0830";
+	match "intclass" "0x02";
+	match "intsubclass" "0x02";
+	match "intprotocol" "0xff";
+	action "kldload -n if_urndis";
+};
+
+nomatch 32 {
+	match "bus" "uhub[0-9]+";
+	match "mode" "host";
 	match "vendor" "0x12d1";
 	match "intclass" "0x02";
 	match "intsubclass" "0x02";
@@ -3321,20 +3339,20 @@ nomatch 32 {
 
 nomatch 32 {
 	match "bus" "uhub[0-9]+";
-	match "mode" "host";
+	match "mode" "(host|device)";
 	match "intclass" "0x02";
 	match "intsubclass" "0x02";
-	match "intprotocol" "0x01";
+	match "intprotocol" "0x00";
 	action "kldload -n umodem";
 };
 
 nomatch 32 {
 	match "bus" "uhub[0-9]+";
-	match "mode" "host";
+	match "mode" "(host|device)";
 	match "intclass" "0x02";
 	match "intsubclass" "0x02";
-	match "intprotocol" "0xff";
-	action "kldload -n if_urndis";
+	match "intprotocol" "0x01";
+	action "kldload -n umodem";
 };
 
 nomatch 32 {
@@ -3447,5 +3465,5 @@ nomatch 32 {
 	action "kldload -n umass";
 };
 
-# 1643 USB entries processed
+# 1656 USB entries processed
 
diff --git a/sys/bus/u4b/net/if_urndis.c b/sys/bus/u4b/net/if_urndis.c
index 74ff239..8131711 100644
--- a/sys/bus/u4b/net/if_urndis.c
+++ b/sys/bus/u4b/net/if_urndis.c
@@ -169,35 +169,21 @@ static const struct usb_ether_methods urndis_ue_methods = {
 static const STRUCT_USB_HOST_ID urndis_host_devs[] = {
 	/* Generic RNDIS class match */
 	{USB_IFACE_CLASS(UICLASS_WIRELESS), USB_IFACE_SUBCLASS(UISUBCLASS_RF),
-	USB_IFACE_PROTOCOL(UIPROTO_RNDIS)},
+		USB_IFACE_PROTOCOL(UIPROTO_RNDIS)},
 	{USB_IFACE_CLASS(UICLASS_IAD), USB_IFACE_SUBCLASS(UISUBCLASS_SYNC),
-	USB_IFACE_PROTOCOL(UIPROTO_ACTIVESYNC)},
+		USB_IFACE_PROTOCOL(UIPROTO_ACTIVESYNC)},
 	/* HP-WebOS */
 	{USB_VENDOR(USB_VENDOR_PALM), USB_IFACE_CLASS(UICLASS_CDC),
 		USB_IFACE_SUBCLASS(UISUBCLASS_ABSTRACT_CONTROL_MODEL),
 		USB_IFACE_PROTOCOL(0xff)},
 };
 
-static const STRUCT_USB_HOST_ID urndis_non_huawei_host_devs[] = {
-	{USB_IFACE_CLASS(UICLASS_CDC),
-	USB_IFACE_SUBCLASS(UISUBCLASS_ABSTRACT_CONTROL_MODEL),
-	USB_IFACE_PROTOCOL(0xff)},
-};
-
 static int
 urndis_probe(device_t dev)
 {
-	int res;
 	struct usb_attach_arg *uaa = device_get_ivars(dev);
 
-	res = usbd_lookup_id_by_uaa(urndis_host_devs,
-	    sizeof(urndis_host_devs), uaa);
-	if (res == 0)
-		return(0);
-	if (uaa->info.idVendor == USB_VENDOR_HUAWEI)
-		return(ENXIO);
-	return (usbd_lookup_id_by_uaa(urndis_non_huawei_host_devs,
-		sizeof(urndis_non_huawei_host_devs), uaa));
+	return (usbd_lookup_id_by_uaa(urndis_host_devs, sizeof(urndis_host_devs), uaa));
 }
 
 static void
diff --git a/sys/bus/u4b/serial/umodem.c b/sys/bus/u4b/serial/umodem.c
index 4192a66..56b24a0 100644
--- a/sys/bus/u4b/serial/umodem.c
+++ b/sys/bus/u4b/serial/umodem.c
@@ -124,9 +124,14 @@ static const STRUCT_USB_DUAL_ID umodem_dual_devs[] = {
 	{USB_IFACE_CLASS(UICLASS_CDC),
 		USB_IFACE_SUBCLASS(UISUBCLASS_ABSTRACT_CONTROL_MODEL),
 		USB_IFACE_PROTOCOL(UIPROTO_CDC_AT)},
+	{USB_IFACE_CLASS(UICLASS_CDC),
+		USB_IFACE_SUBCLASS(UISUBCLASS_ABSTRACT_CONTROL_MODEL),
+		USB_IFACE_PROTOCOL(UIPROTO_CDC_NONE)},
+};
+
+static const STRUCT_USB_HOST_ID umodem_host_devs[] = {
 	/* Huawei Modem class match */
-	{USB_VENDOR(USB_VENDOR_HUAWEI),
-		USB_IFACE_CLASS(UICLASS_CDC),
+	{USB_VENDOR(USB_VENDOR_HUAWEI),USB_IFACE_CLASS(UICLASS_CDC),
 		USB_IFACE_SUBCLASS(UISUBCLASS_ABSTRACT_CONTROL_MODEL),
 		USB_IFACE_PROTOCOL(0xFF)},
 	/* Kyocera AH-K3001V */
@@ -135,17 +140,6 @@ static const STRUCT_USB_DUAL_ID umodem_dual_devs[] = {
 	{USB_VPI(USB_VENDOR_CURITEL, USB_PRODUCT_CURITEL_PC5740, 1)},
 };
 
-static const STRUCT_USB_HOST_ID umodem_host_devs[] = {
-        /* Huawei Modem class match */
-        {USB_VENDOR(USB_VENDOR_HUAWEI),USB_IFACE_CLASS(UICLASS_CDC),
-                USB_IFACE_SUBCLASS(UISUBCLASS_ABSTRACT_CONTROL_MODEL),
-                USB_IFACE_PROTOCOL(0xFF)},
-        /* Kyocera AH-K3001V */
-        {USB_VPI(USB_VENDOR_KYOCERA, USB_PRODUCT_KYOCERA_AHK3001V, 1)},
-        {USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC5720, 1)},
-        {USB_VPI(USB_VENDOR_CURITEL, USB_PRODUCT_CURITEL_PC5740, 1)},
-};
-
 /*
  * As speeds for umodem deivces increase, these numbers will need to
  * be increased. They should be good for G3 speeds and below.
-- 
2.3.1

