// SPDX-License-Identifier: GPL-2.0-or-later /* * Simple "CDC Subset" USB Networking Links * Copyright (C) 2000-2005 by David Brownell */ #include <linux/module.h> #include <linux/kmod.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/ethtool.h> #include <linux/workqueue.h> #include <linux/mii.h> #include <linux/usb.h> #include <linux/usb/usbnet.h> /* * This supports simple USB network links that don't require any special * framing or hardware control operations. The protocol used here is a * strict subset of CDC Ethernet, with three basic differences reflecting * the goal that almost any hardware should run it: * * - Minimal runtime control: one interface, no altsettings, and * no vendor or class specific control requests. If a device is * configured, it is allowed to exchange packets with the host. * Fancier models would mean not working on some hardware. * * - Minimal manufacturing control: no IEEE "Organizationally * Unique ID" required, or an EEPROMs to store one. Each host uses * one random "locally assigned" Ethernet address instead, which can * of course be overridden using standard tools like "ifconfig". * (With 2^46 such addresses, same-net collisions are quite rare.) * * - There is no additional framing data for USB. Packets are written * exactly as in CDC Ethernet, starting with an Ethernet header and * terminated by a short packet. However, the host will never send a * zero length packet; some systems can't handle those robustly. * * Anything that can transmit and receive USB bulk packets can implement * this protocol. That includes both smart peripherals and quite a lot * of "host-to-host" USB cables (which embed two devices back-to-back). * * Note that although Linux may use many of those host-to-host links * with this "cdc_subset" framing, that doesn't mean there may not be a * better approach. Handling the "other end unplugs/replugs" scenario * well tends to require chip-specific vendor requests. Also, Windows * peers at the other end of host-to-host cables may expect their own * framing to be used rather than this "cdc_subset" model. */ #if defined(CONFIG_USB_EPSON2888) || defined(CONFIG_USB_ARMLINUX) /* PDA style devices are always connected if present */ static int always_connected (struct usbnet *dev) { … } #endif #ifdef CONFIG_USB_ALI_M5632 #define HAVE_HARDWARE /*------------------------------------------------------------------------- * * ALi M5632 driver ... does high speed * * NOTE that the MS-Windows drivers for this chip use some funky and * (naturally) undocumented 7-byte prefix to each packet, so this is a * case where we don't currently interoperate. Also, once you unplug * one end of the cable, you need to replug the other end too ... since * chip docs are unavailable, there's no way to reset the relevant state * short of a power cycle. * *-------------------------------------------------------------------------*/ static void m5632_recover(struct usbnet *dev) { … } static const struct driver_info ali_m5632_info = …; #endif #ifdef CONFIG_USB_AN2720 #define HAVE_HARDWARE /*------------------------------------------------------------------------- * * AnchorChips 2720 driver ... http://www.cypress.com * * This doesn't seem to have a way to detect whether the peer is * connected, or need any reset handshaking. It's got pretty big * internal buffers (handles most of a frame's worth of data). * Chip data sheets don't describe any vendor control messages. * *-------------------------------------------------------------------------*/ static const struct driver_info an2720_info = …; #endif /* CONFIG_USB_AN2720 */ #ifdef CONFIG_USB_BELKIN #define HAVE_HARDWARE /*------------------------------------------------------------------------- * * Belkin F5U104 ... two NetChip 2280 devices + Atmel AVR microcontroller * * ... also two eTEK designs, including one sold as "Advance USBNET" * *-------------------------------------------------------------------------*/ static const struct driver_info belkin_info = …; #endif /* CONFIG_USB_BELKIN */ #ifdef CONFIG_USB_EPSON2888 #define HAVE_HARDWARE /*------------------------------------------------------------------------- * * EPSON USB clients * * This is the same idea as Linux PDAs (below) except the firmware in the * device might not be Tux-powered. Epson provides reference firmware that * implements this interface. Product developers can reuse or modify that * code, such as by using their own product and vendor codes. * * Support was from Juro Bystricky <[email protected]> * *-------------------------------------------------------------------------*/ static const struct driver_info epson2888_info = …; #endif /* CONFIG_USB_EPSON2888 */ /*------------------------------------------------------------------------- * * info from Jonathan McDowell <[email protected]> * *-------------------------------------------------------------------------*/ #ifdef CONFIG_USB_KC2190 #define HAVE_HARDWARE static const struct driver_info kc2190_info = …; #endif /* CONFIG_USB_KC2190 */ #ifdef CONFIG_USB_ARMLINUX #define HAVE_HARDWARE /*------------------------------------------------------------------------- * * Intel's SA-1100 chip integrates basic USB support, and is used * in PDAs like some iPaqs, the Yopy, some Zaurus models, and more. * When they run Linux, arch/arm/mach-sa1100/usb-eth.c may be used to * network using minimal USB framing data. * * This describes the driver currently in standard ARM Linux kernels. * The Zaurus uses a different driver (see later). * * PXA25x and PXA210 use XScale cores (ARM v5TE) with better USB support * and different USB endpoint numbering than the SA1100 devices. The * mach-pxa/usb-eth.c driver re-uses the device ids from mach-sa1100 * so we rely on the endpoint descriptors. * *-------------------------------------------------------------------------*/ static const struct driver_info linuxdev_info = …; static const struct driver_info yopy_info = …; static const struct driver_info blob_info = …; #endif /* CONFIG_USB_ARMLINUX */ /*-------------------------------------------------------------------------*/ #ifndef HAVE_HARDWARE #warning You need to configure some hardware for this driver #endif /* * chip vendor names won't normally be on the cables, and * may not be on the device. */ static const struct usb_device_id products [] = …; MODULE_DEVICE_TABLE(usb, products); /*-------------------------------------------------------------------------*/ static int dummy_prereset(struct usb_interface *intf) { … } static int dummy_postreset(struct usb_interface *intf) { … } static struct usb_driver cdc_subset_driver = …; module_usb_driver(…) …; MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …;