hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/net/usb/cdc_ether.c
....@@ -1,20 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * CDC Ethernet based networking peripherals
34 * Copyright (C) 2003-2005 by David Brownell
45 * Copyright (C) 2006 by Ole Andre Vadla Ravnas (ActiveSync)
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
186 */
197
208 // #define DEBUG // error path messages, extra info
....@@ -75,10 +63,8 @@
7563 0xa6, 0x07, 0xc0, 0xff, 0xcb, 0x7e, 0x39, 0x2a,
7664 };
7765
78
-static void usbnet_cdc_update_filter(struct usbnet *dev)
66
+void usbnet_cdc_update_filter(struct usbnet *dev)
7967 {
80
- struct cdc_state *info = (void *) &dev->data;
81
- struct usb_interface *intf = info->control;
8268 struct net_device *net = dev->net;
8369
8470 u16 cdc_filter = USB_CDC_PACKET_TYPE_DIRECTED
....@@ -98,12 +84,13 @@
9884 USB_CDC_SET_ETHERNET_PACKET_FILTER,
9985 USB_TYPE_CLASS | USB_RECIP_INTERFACE,
10086 cdc_filter,
101
- intf->cur_altsetting->desc.bInterfaceNumber,
87
+ dev->intf->cur_altsetting->desc.bInterfaceNumber,
10288 NULL,
10389 0,
10490 USB_CTRL_SET_TIMEOUT
10591 );
10692 }
93
+EXPORT_SYMBOL_GPL(usbnet_cdc_update_filter);
10794
10895 /* probes control interface, claims data interface, collects the bulk
10996 * endpoints, activates data interface (if needed), maybe sets MTU.
....@@ -179,10 +166,8 @@
179166 * probed with) and a slave/data interface; union
180167 * descriptors sort this all out.
181168 */
182
- info->control = usb_ifnum_to_if(dev->udev,
183
- info->u->bMasterInterface0);
184
- info->data = usb_ifnum_to_if(dev->udev,
185
- info->u->bSlaveInterface0);
169
+ info->control = usb_ifnum_to_if(dev->udev, info->u->bMasterInterface0);
170
+ info->data = usb_ifnum_to_if(dev->udev, info->u->bSlaveInterface0);
186171 if (!info->control || !info->data) {
187172 dev_dbg(&intf->dev,
188173 "master #%u/%p slave #%u/%p\n",
....@@ -216,8 +201,7 @@
216201 /* a data interface altsetting does the real i/o */
217202 d = &info->data->cur_altsetting->desc;
218203 if (d->bInterfaceClass != USB_CLASS_CDC_DATA) {
219
- dev_dbg(&intf->dev, "slave class %u\n",
220
- d->bInterfaceClass);
204
+ dev_dbg(&intf->dev, "slave class %u\n", d->bInterfaceClass);
221205 goto bad_desc;
222206 }
223207 skip:
....@@ -231,10 +215,10 @@
231215 if (rndis && is_rndis(&intf->cur_altsetting->desc) &&
232216 header.usb_cdc_acm_descriptor &&
233217 header.usb_cdc_acm_descriptor->bmCapabilities) {
234
- dev_dbg(&intf->dev,
235
- "ACM capabilities %02x, not really RNDIS?\n",
236
- header.usb_cdc_acm_descriptor->bmCapabilities);
237
- goto bad_desc;
218
+ dev_dbg(&intf->dev,
219
+ "ACM capabilities %02x, not really RNDIS?\n",
220
+ header.usb_cdc_acm_descriptor->bmCapabilities);
221
+ goto bad_desc;
238222 }
239223
240224 if (header.usb_cdc_ether_desc && info->ether->wMaxSegmentSize) {
....@@ -245,7 +229,7 @@
245229 }
246230
247231 if (header.usb_cdc_mdlm_desc &&
248
- memcmp(header.usb_cdc_mdlm_desc->bGUID, mbm_guid, 16)) {
232
+ memcmp(header.usb_cdc_mdlm_desc->bGUID, mbm_guid, 16)) {
249233 dev_dbg(&intf->dev, "GUID doesn't match\n");
250234 goto bad_desc;
251235 }
....@@ -309,7 +293,7 @@
309293 if (info->control->cur_altsetting->desc.bNumEndpoints == 1) {
310294 struct usb_endpoint_descriptor *desc;
311295
312
- dev->status = &info->control->cur_altsetting->endpoint [0];
296
+ dev->status = &info->control->cur_altsetting->endpoint[0];
313297 desc = &dev->status->desc;
314298 if (!usb_endpoint_is_int_in(desc) ||
315299 (le16_to_cpu(desc->wMaxPacketSize)
....@@ -554,16 +538,6 @@
554538 .manage_power = usbnet_manage_power,
555539 };
556540
557
-static const struct driver_info lte_info = {
558
- .description = "CDC Ethernet Device(lte)",
559
- .flags = FLAG_ETHER | FLAG_POINTTOPOINT | FLAG_LTE,
560
- .bind = usbnet_cdc_bind,
561
- .unbind = usbnet_cdc_unbind,
562
- .status = usbnet_cdc_status,
563
- .set_rx_mode = usbnet_cdc_update_filter,
564
- .manage_power = usbnet_manage_power,
565
-};
566
-
567541 /*-------------------------------------------------------------------------*/
568542
569543 #define HUAWEI_VENDOR_ID 0x12D1
....@@ -579,6 +553,8 @@
579553 #define MICROSOFT_VENDOR_ID 0x045e
580554 #define UBLOX_VENDOR_ID 0x1546
581555 #define TPLINK_VENDOR_ID 0x2357
556
+#define AQUANTIA_VENDOR_ID 0x2eca
557
+#define ASIX_VENDOR_ID 0x0b95
582558
583559 static const struct usb_device_id products[] = {
584560 /* BLACKLIST !!
....@@ -628,6 +604,13 @@
628604 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
629605 | USB_DEVICE_ID_MATCH_DEVICE,
630606 .idVendor = 0x04DD,
607
+ .idProduct = 0x8005, /* A-300 */
608
+ ZAURUS_FAKE_INTERFACE,
609
+ .driver_info = 0,
610
+}, {
611
+ .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
612
+ | USB_DEVICE_ID_MATCH_DEVICE,
613
+ .idVendor = 0x04DD,
631614 .idProduct = 0x8006, /* B-500/SL-5600 */
632615 ZAURUS_MASTER_INTERFACE,
633616 .driver_info = 0,
....@@ -635,9 +618,23 @@
635618 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
636619 | USB_DEVICE_ID_MATCH_DEVICE,
637620 .idVendor = 0x04DD,
621
+ .idProduct = 0x8006, /* B-500/SL-5600 */
622
+ ZAURUS_FAKE_INTERFACE,
623
+ .driver_info = 0,
624
+}, {
625
+ .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
626
+ | USB_DEVICE_ID_MATCH_DEVICE,
627
+ .idVendor = 0x04DD,
638628 .idProduct = 0x8007, /* C-700 */
639629 ZAURUS_MASTER_INTERFACE,
640630 .driver_info = 0,
631
+}, {
632
+ .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
633
+ | USB_DEVICE_ID_MATCH_DEVICE,
634
+ .idVendor = 0x04DD,
635
+ .idProduct = 0x8007, /* C-700 */
636
+ ZAURUS_FAKE_INTERFACE,
637
+ .driver_info = 0,
641638 }, {
642639 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
643640 | USB_DEVICE_ID_MATCH_DEVICE,
....@@ -787,6 +784,13 @@
787784 },
788785 #endif
789786
787
+/* Lenovo ThinkPad OneLink+ Dock (based on Realtek RTL8153) */
788
+{
789
+ USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x3054, USB_CLASS_COMM,
790
+ USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
791
+ .driver_info = 0,
792
+},
793
+
790794 /* ThinkPad USB-C Dock (based on Realtek RTL8153) */
791795 {
792796 USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x3062, USB_CLASS_COMM,
....@@ -797,6 +801,13 @@
797801 /* ThinkPad Thunderbolt 3 Dock (based on Realtek RTL8153) */
798802 {
799803 USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x3069, USB_CLASS_COMM,
804
+ USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
805
+ .driver_info = 0,
806
+},
807
+
808
+/* ThinkPad Thunderbolt 3 Dock Gen 2 (based on Realtek RTL8153) */
809
+{
810
+ USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x3082, USB_CLASS_COMM,
800811 USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
801812 .driver_info = 0,
802813 },
....@@ -868,6 +879,46 @@
868879 {
869880 USB_DEVICE_AND_INTERFACE_INFO(TPLINK_VENDOR_ID, 0x0601, USB_CLASS_COMM,
870881 USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
882
+ .driver_info = 0,
883
+},
884
+
885
+/* Aquantia AQtion USB to 5GbE Controller (based on AQC111U) */
886
+{
887
+ USB_DEVICE_AND_INTERFACE_INFO(AQUANTIA_VENDOR_ID, 0xc101,
888
+ USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET,
889
+ USB_CDC_PROTO_NONE),
890
+ .driver_info = 0,
891
+},
892
+
893
+/* ASIX USB 3.1 Gen1 to 5G Multi-Gigabit Ethernet Adapter(based on AQC111U) */
894
+{
895
+ USB_DEVICE_AND_INTERFACE_INFO(ASIX_VENDOR_ID, 0x2790, USB_CLASS_COMM,
896
+ USB_CDC_SUBCLASS_ETHERNET,
897
+ USB_CDC_PROTO_NONE),
898
+ .driver_info = 0,
899
+},
900
+
901
+/* ASIX USB 3.1 Gen1 to 2.5G Multi-Gigabit Ethernet Adapter(based on AQC112U) */
902
+{
903
+ USB_DEVICE_AND_INTERFACE_INFO(ASIX_VENDOR_ID, 0x2791, USB_CLASS_COMM,
904
+ USB_CDC_SUBCLASS_ETHERNET,
905
+ USB_CDC_PROTO_NONE),
906
+ .driver_info = 0,
907
+},
908
+
909
+/* USB-C 3.1 to 5GBASE-T Ethernet Adapter (based on AQC111U) */
910
+{
911
+ USB_DEVICE_AND_INTERFACE_INFO(0x20f4, 0xe05a, USB_CLASS_COMM,
912
+ USB_CDC_SUBCLASS_ETHERNET,
913
+ USB_CDC_PROTO_NONE),
914
+ .driver_info = 0,
915
+},
916
+
917
+/* QNAP QNA-UC5G1T USB to 5GbE Adapter (based on AQC111U) */
918
+{
919
+ USB_DEVICE_AND_INTERFACE_INFO(0x1c04, 0x0015, USB_CLASS_COMM,
920
+ USB_CDC_SUBCLASS_ETHERNET,
921
+ USB_CDC_PROTO_NONE),
871922 .driver_info = 0,
872923 },
873924
....@@ -957,12 +1008,6 @@
9571008 USB_CDC_SUBCLASS_ETHERNET,
9581009 USB_CDC_PROTO_NONE),
9591010 .driver_info = (unsigned long)&wwan_info,
960
-}, {
961
- /* RM310 modules*/
962
- USB_DEVICE_AND_INTERFACE_INFO(0x1286, 0x4E3C, USB_CLASS_COMM,
963
- USB_CDC_SUBCLASS_ETHERNET,
964
- USB_CDC_PROTO_NONE),
965
- .driver_info = (unsigned long)&lte_info,
9661011 }, {
9671012 USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET,
9681013 USB_CDC_PROTO_NONE),