git: 1997d3a4a9f2 - main - usb: add new scsi_huawei eject3 & eject4 driver support

From: Warner Losh <imp_at_FreeBSD.org>
Date: Sat, 04 Feb 2023 21:29:48 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=1997d3a4a9f20a846cf762306fd5193526a1d603

commit 1997d3a4a9f20a846cf762306fd5193526a1d603
Author:     Michael Paepcke <fbsd@paepcke.de>
AuthorDate: 2022-12-16 10:28:45 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-02-04 21:27:08 +0000

    usb: add new scsi_huawei eject3 & eject4 driver support
    
    Add initialization for new Huawei 4G E3372_NCM, E3372v153_NCM,
    E5573Cs322_NCM, E5573Cs322_ECM, and E5573Cs322_ACM.
    
    Remove now-obsolete Huawei 3G E3131 init sequence. These devices are
    obsolete, share IDs with new devices and the 3G networks are shutdown.
    These old devices work correctly via the 4G code while still allowing
    the shared IDs to work differently for the new devices.
    
    Reviewed by: imp
    Pull Request: https://github.com/freebsd/freebsd-src/pull/633
---
 sys/dev/usb/net/if_cdce.c |  2 ++
 sys/dev/usb/serial/u3g.c  | 24 ++++++++++++++++++++----
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/sys/dev/usb/net/if_cdce.c b/sys/dev/usb/net/if_cdce.c
index 551ba5d7fefa..50f909c630cd 100644
--- a/sys/dev/usb/net/if_cdce.c
+++ b/sys/dev/usb/net/if_cdce.c
@@ -265,6 +265,8 @@ static int  cdce_driver_loaded(struct module *, int, void *);
 
 static const STRUCT_USB_HOST_ID cdce_switch_devs[] = {
 	{USB_VPI(USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E3272_INIT, MSC_EJECT_HUAWEI2)},
+	{USB_VPI(USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E3372v153_INIT, MSC_EJECT_HUAWEI2)},
+	{USB_VPI(USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E3372_INIT, MSC_EJECT_HUAWEI3)},
 };
 
 static const STRUCT_USB_HOST_ID cdce_host_devs[] = {
diff --git a/sys/dev/usb/serial/u3g.c b/sys/dev/usb/serial/u3g.c
index 11e3b11ab65a..868ed9a86f9b 100644
--- a/sys/dev/usb/serial/u3g.c
+++ b/sys/dev/usb/serial/u3g.c
@@ -89,7 +89,9 @@ SYSCTL_INT(_hw_usb_u3g, OID_AUTO, debug, CTLFLAG_RWTUN,
 #define	U3GINIT_SAEL_M460	8	/* Requires vendor init */
 #define	U3GINIT_HUAWEISCSI	9	/* Requires Huawei SCSI init command */
 #define	U3GINIT_HUAWEISCSI2	10	/* Requires Huawei SCSI init command (2) */
-#define	U3GINIT_TCT		11	/* Requires TCT Mobile init command */
+#define	U3GINIT_HUAWEISCSI3	11	/* Requires Huawei SCSI init command (3) */
+#define	U3GINIT_HUAWEISCSI4	12	/* Requires Huawei SCSI init command (4) */
+#define	U3GINIT_TCT		13	/* Requires TCT Mobile init command */
 
 enum {
 	U3G_BULK_WR,
@@ -318,8 +320,6 @@ static const STRUCT_USB_HOST_ID u3g_devs[] = {
 	U3G_DEV(HUAWEI, E143F, U3GINIT_HUAWEI),
 	U3G_DEV(HUAWEI, E173, 0),
 	U3G_DEV(HUAWEI, E173_INIT, U3GINIT_HUAWEISCSI),
-	U3G_DEV(HUAWEI, E3131, 0),
-	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),
@@ -342,6 +342,12 @@ static const STRUCT_USB_HOST_ID u3g_devs[] = {
 	U3G_DEV(HUAWEI, ETS2055, U3GINIT_HUAWEI),
 	U3G_DEV(HUAWEI, E3272_INIT, U3GINIT_HUAWEISCSI2),
 	U3G_DEV(HUAWEI, E3272, 0),
+	U3G_DEV(HUAWEI, E3372_INIT, U3GINIT_HUAWEISCSI3),
+	U3G_DEV(HUAWEI, E3372v153_INIT, U3GINIT_HUAWEISCSI2),
+	U3G_DEV(HUAWEI, E3372v153_NCM, 0),
+	U3G_DEV(HUAWEI, E5573Cs322_NCM, 0),
+	U3G_DEV(HUAWEI, E5573Cs322_ECM, 0),
+	U3G_DEV(HUAWEI, E5573Cs322_ACM, 0),
 	U3G_DEV(KYOCERA2, CDMA_MSM_K, 0),
 	U3G_DEV(KYOCERA2, KPC680, 0),
 	U3G_DEV(LONGCHEER, WM66, U3GINIT_HUAWEI),
@@ -815,6 +821,10 @@ u3g_test_autoinst(void *arg, struct usb_device *udev,
 		method = U3GINIT_HUAWEISCSI;
 	else if (usb_test_quirk(uaa, UQ_MSC_EJECT_HUAWEISCSI2))
 		method = U3GINIT_HUAWEISCSI2;
+	else if (usb_test_quirk(uaa, UQ_MSC_EJECT_HUAWEISCSI3))
+		method = U3GINIT_HUAWEISCSI3;
+	else if (usb_test_quirk(uaa, UQ_MSC_EJECT_HUAWEISCSI4))
+		method = U3GINIT_HUAWEISCSI4;
 	else if (usb_test_quirk(uaa, UQ_MSC_EJECT_TCT))
 		method = U3GINIT_TCT;
 	else if (usbd_lookup_id_by_uaa(u3g_devs, sizeof(u3g_devs), uaa) == 0)
@@ -838,6 +848,12 @@ u3g_test_autoinst(void *arg, struct usb_device *udev,
 		case U3GINIT_HUAWEISCSI2:
 			error = usb_msc_eject(udev, 0, MSC_EJECT_HUAWEI2);
 			break;
+		case U3GINIT_HUAWEISCSI3:
+			error = usb_msc_eject(udev, 0, MSC_EJECT_HUAWEI3);
+			break;
+		case U3GINIT_HUAWEISCSI4:
+			error = usb_msc_eject(udev, 0, MSC_EJECT_HUAWEI4);
+			break;
 		case U3GINIT_SCSIEJECT:
 			error = usb_msc_eject(udev, 0, MSC_EJECT_STOPUNIT);
 			break;
@@ -888,7 +904,7 @@ u3g_driver_loaded(struct module *mod, int what, void *arg)
 	default:
 		return (EOPNOTSUPP);
 	}
- 	return (0);
+	return (0);
 }
 
 static int