Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
efe3e6b
Documentation
LICENSES
arch
block
certs
crypto
drivers
accessibility
acpi
amba
android
ata
atm
auxdisplay
base
bcma
block
bluetooth
bus
cdrom
char
clk
clocksource
comedi
connector
counter
cpufreq
cpuidle
crypto
cxl
dax
dca
devfreq
dio
dma-buf
dma
edac
eisa
extcon
firewire
firmware
fpga
fsi
gnss
gpio
gpu
greybus
hid
hsi
hte
hv
hwmon
hwspinlock
hwtracing
i2c
i3c
idle
iio
infiniband
input
interconnect
iommu
ipack
irqchip
isdn
leds
macintosh
mailbox
mcb
md
media
memory
memstick
message
mfd
misc
mmc
most
mtd
mux
net
appletalk
arcnet
bonding
caif
can
dsa
ethernet
fddi
fjes
hamradio
hippi
hyperv
ieee802154
ipa
ipvlan
mctp
mdio
netdevsim
pcs
phy
plip
ppp
slip
team
usb
Kconfig
Makefile
aqc111.c
aqc111.h
asix.h
asix_common.c
asix_devices.c
ax88172a.c
ax88179_178a.c
catc.c
cdc-phonet.c
cdc_eem.c
cdc_ether.c
cdc_mbim.c
cdc_ncm.c
cdc_subset.c
ch9200.c
cx82310_eth.c
dm9601.c
gl620a.c
hso.c
huawei_cdc_ncm.c
int51x1.c
ipheth.c
kalmia.c
kaweth.c
lan78xx.c
lan78xx.h
lg-vl600.c
mcs7830.c
net1080.c
pegasus.c
pegasus.h
plusb.c
qmi_wwan.c
r8152.c
r8153_ecm.c
rndis_host.c
rtl8150.c
sierra_net.c
smsc75xx.c
smsc75xx.h
smsc95xx.c
smsc95xx.h
sr9700.c
sr9700.h
sr9800.c
sr9800.h
usbnet.c
zaurus.c
vmxnet3
vxlan
wan
wireguard
wireless
wwan
xen-netback
Kconfig
LICENSE.SRC
Makefile
Space.c
amt.c
bareudp.c
dummy.c
eql.c
geneve.c
gtp.c
ifb.c
loopback.c
macsec.c
macvlan.c
macvtap.c
mdio.c
mhi_net.c
mii.c
net_failover.c
netconsole.c
nlmon.c
ntb_netdev.c
rionet.c
sb1000.c
sungem_phy.c
tap.c
thunderbolt.c
tun.c
veth.c
virtio_net.c
vrf.c
vsockmon.c
xen-netfront.c
nfc
ntb
nubus
nvdimm
nvme
nvmem
of
opp
parisc
parport
pci
pcmcia
peci
perf
phy
pinctrl
platform
pnp
power
powercap
pps
ps3
ptp
pwm
rapidio
ras
regulator
remoteproc
reset
rpmsg
rtc
s390
sbus
scsi
sh
siox
slimbus
soc
soundwire
spi
spmi
ssb
staging
target
tc
tee
thermal
thunderbolt
tty
ufs
uio
usb
vdpa
vfio
vhost
video
virt
virtio
vlynq
vme
w1
watchdog
xen
zorro
Kconfig
Makefile
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
tools
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
drivers
/
net
/
usb
/
cdc_subset.c
Blame
Blame
Latest commit
Xie Shaowen
and
Jakub Kicinski
net: usb: delete extra space and tab in blank line
Jul 29, 2022
efe3e6b
·
Jul 29, 2022
History
History
357 lines (303 loc) · 10.6 KB
Breadcrumbs
linux
/
drivers
/
net
/
usb
/
cdc_subset.c
Top
File metadata and controls
Code
Blame
357 lines (303 loc) · 10.6 KB
Raw
// 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) { return 0; } #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) { struct usb_device *udev = dev->udev; struct usb_interface *intf = dev->intf; int r; r = usb_lock_device_for_reset(udev, intf); if (r < 0) return; usb_reset_device(udev); usb_unlock_device(udev); } static const struct driver_info ali_m5632_info = { .description = "ALi M5632", .flags = FLAG_POINTTOPOINT, .recover = m5632_recover, }; #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 = { .description = "AnchorChips/Cypress 2720", .flags = FLAG_POINTTOPOINT, // no reset available! // no check_connect available! .in = 2, .out = 2, // direction distinguishes these }; #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 = { .description = "Belkin, eTEK, or compatible", .flags = FLAG_POINTTOPOINT, }; #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 <bystricky.juro@erd.epson.com> * *-------------------------------------------------------------------------*/ static const struct driver_info epson2888_info = { .description = "Epson USB Device", .check_connect = always_connected, .flags = FLAG_POINTTOPOINT, .in = 4, .out = 3, }; #endif /* CONFIG_USB_EPSON2888 */ /*------------------------------------------------------------------------- * * info from Jonathan McDowell <noodles@earth.li> * *-------------------------------------------------------------------------*/ #ifdef CONFIG_USB_KC2190 #define HAVE_HARDWARE static const struct driver_info kc2190_info = { .description = "KC Technology KC-190", .flags = FLAG_POINTTOPOINT, }; #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 = { .description = "Linux Device", .check_connect = always_connected, .flags = FLAG_POINTTOPOINT, }; static const struct driver_info yopy_info = { .description = "Yopy", .check_connect = always_connected, .flags = FLAG_POINTTOPOINT, }; static const struct driver_info blob_info = { .description = "Boot Loader OBject", .check_connect = always_connected, .flags = FLAG_POINTTOPOINT, }; #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 [] = { #ifdef CONFIG_USB_ALI_M5632 { USB_DEVICE (0x0402, 0x5632), // ALi defaults .driver_info = (unsigned long) &ali_m5632_info, }, { USB_DEVICE (0x182d,0x207c), // SiteCom CN-124 .driver_info = (unsigned long) &ali_m5632_info, }, #endif #ifdef CONFIG_USB_AN2720 { USB_DEVICE (0x0547, 0x2720), // AnchorChips defaults .driver_info = (unsigned long) &an2720_info, }, { USB_DEVICE (0x0547, 0x2727), // Xircom PGUNET .driver_info = (unsigned long) &an2720_info, }, #endif #ifdef CONFIG_USB_BELKIN { USB_DEVICE (0x050d, 0x0004), // Belkin .driver_info = (unsigned long) &belkin_info, }, { USB_DEVICE (0x056c, 0x8100), // eTEK .driver_info = (unsigned long) &belkin_info, }, { USB_DEVICE (0x0525, 0x9901), // Advance USBNET (eTEK) .driver_info = (unsigned long) &belkin_info, }, #endif #ifdef CONFIG_USB_EPSON2888 { USB_DEVICE (0x0525, 0x2888), // EPSON USB client .driver_info = (unsigned long) &epson2888_info, }, #endif #ifdef CONFIG_USB_KC2190 { USB_DEVICE (0x050f, 0x0190), // KC-190 .driver_info = (unsigned long) &kc2190_info, }, #endif #ifdef CONFIG_USB_ARMLINUX /* * SA-1100 using standard ARM Linux kernels, or compatible. * Often used when talking to Linux PDAs (iPaq, Yopy, etc). * The sa-1100 "usb-eth" driver handles the basic framing. * * PXA25x or PXA210 ... these use a "usb-eth" driver much like * the sa1100 one, but hardware uses different endpoint numbers. * * Or the Linux "Ethernet" gadget on hardware that can't talk * CDC Ethernet (e.g., no altsettings), in either of two modes: * - acting just like the old "usb-eth" firmware, though * the implementation is different * - supporting RNDIS as the first/default configuration for * MS-Windows interop; Linux needs to use the other config */ { // 1183 = 0x049F, both used as hex values? // Compaq "Itsy" vendor/product id USB_DEVICE (0x049F, 0x505A), // usb-eth, or compatible .driver_info = (unsigned long) &linuxdev_info, }, { USB_DEVICE (0x0E7E, 0x1001), // G.Mate "Yopy" .driver_info = (unsigned long) &yopy_info, }, { USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader .driver_info = (unsigned long) &blob_info, }, { USB_DEVICE (0x1286, 0x8001), // "blob" bootloader .driver_info = (unsigned long) &blob_info, }, { // Linux Ethernet/RNDIS gadget, mostly on PXA, second config // e.g. Gumstix, current OpenZaurus, ... or anything else // that just enables this gadget option. USB_DEVICE (0x0525, 0xa4a2), .driver_info = (unsigned long) &linuxdev_info, }, #endif { }, // END }; MODULE_DEVICE_TABLE(usb, products); /*-------------------------------------------------------------------------*/ static int dummy_prereset(struct usb_interface *intf) { return 0; } static int dummy_postreset(struct usb_interface *intf) { return 0; } static struct usb_driver cdc_subset_driver = { .name = "cdc_subset", .probe = usbnet_probe, .suspend = usbnet_suspend, .resume = usbnet_resume, .pre_reset = dummy_prereset, .post_reset = dummy_postreset, .disconnect = usbnet_disconnect, .id_table = products, .disable_hub_initiated_lpm = 1, }; module_usb_driver(cdc_subset_driver); MODULE_AUTHOR("David Brownell"); MODULE_DESCRIPTION("Simple 'CDC Subset' USB networking links"); MODULE_LICENSE("GPL");
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
You can’t perform that action at this time.