drivers/net/usb/cdc_ether.c
Source file repositories/reference/linux-study-clean/drivers/net/usb/cdc_ether.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/usb/cdc_ether.c- Extension
.c- Size
- 29427 bytes
- Lines
- 985
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/netdevice.hlinux/etherdevice.hlinux/ethtool.hlinux/workqueue.hlinux/mii.hlinux/usb.hlinux/usb/cdc.hlinux/usb/usbnet.h
Detected Declarations
function is_rndisfunction is_activesyncfunction is_wireless_rndisfunction is_novatel_rndisfunction usbnet_cdc_update_filterfunction usbnet_generic_cdc_bindfunction usbnet_ether_cdc_bindfunction usbnet_cdc_unbindfunction speed_changefunction usbnet_cdc_statusfunction usbnet_cdc_bindfunction usbnet_cdc_zte_bindfunction devicesfunction devicesexport usbnet_cdc_update_filterexport usbnet_generic_cdc_bindexport usbnet_ether_cdc_bindexport usbnet_cdc_unbindexport usbnet_cdc_statusexport usbnet_cdc_bindexport usbnet_cdc_zte_rx_fixup
Annotated Snippet
if (hep) {
buf = hep->extra;
len = hep->extralen;
}
if (len)
dev_dbg(&intf->dev,
"CDC descriptors on endpoint\n");
}
/* this assumes that if there's a non-RNDIS vendor variant
* of cdc-acm, it'll fail RNDIS requests cleanly.
*/
rndis = (is_rndis(&intf->cur_altsetting->desc) ||
is_activesync(&intf->cur_altsetting->desc) ||
is_wireless_rndis(&intf->cur_altsetting->desc) ||
is_novatel_rndis(&intf->cur_altsetting->desc));
memset(info, 0, sizeof(*info));
info->control = intf;
cdc_parse_cdc_header(&header, intf, buf, len);
info->u = header.usb_cdc_union_desc;
info->header = header.usb_cdc_header_desc;
info->ether = header.usb_cdc_ether_desc;
if (!info->u) {
if (rndis) {
goto skip;
} else {
/* in that case a quirk is mandatory */
dev_err(&dev->udev->dev, "No union descriptors\n");
goto bad_desc;
}
}
/* we need a master/control interface (what we're
* probed with) and a slave/data interface; union
* descriptors sort this all out.
*/
info->control = usb_ifnum_to_if(dev->udev, info->u->bMasterInterface0);
info->data = usb_ifnum_to_if(dev->udev, info->u->bSlaveInterface0);
if (!info->control || !info->data) {
dev_dbg(&intf->dev,
"master #%u/%p slave #%u/%p\n",
info->u->bMasterInterface0,
info->control,
info->u->bSlaveInterface0,
info->data);
/* fall back to hard-wiring for RNDIS */
if (rndis) {
android_rndis_quirk = true;
goto skip;
}
dev_err(&intf->dev, "bad CDC descriptors\n");
goto bad_desc;
}
if (info->control != intf) {
/* Ambit USB Cable Modem (and maybe others)
* interchanges master and slave interface.
*/
if (info->data == intf) {
info->data = info->control;
info->control = intf;
} else {
dev_err(&intf->dev, "bogus CDC Union\n");
goto bad_desc;
}
}
/* some devices merge these - skip class check */
if (info->control == info->data)
goto skip;
/* a data interface altsetting does the real i/o */
d = &info->data->cur_altsetting->desc;
if (d->bInterfaceClass != USB_CLASS_CDC_DATA) {
dev_err(&intf->dev, "slave class %u\n", d->bInterfaceClass);
goto bad_desc;
}
skip:
/* Communication class functions with bmCapabilities are not
* RNDIS. But some Wireless class RNDIS functions use
* bmCapabilities for their own purpose. The failsafe is
* therefore applied only to Communication class RNDIS
* functions. The rndis test is redundant, but a cheap
* optimization.
*/
if (rndis && is_rndis(&intf->cur_altsetting->desc) &&
header.usb_cdc_acm_descriptor &&
header.usb_cdc_acm_descriptor->bmCapabilities) {
dev_err(&intf->dev,
Annotation
- Immediate include surface: `linux/module.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/ethtool.h`, `linux/workqueue.h`, `linux/mii.h`, `linux/usb.h`, `linux/usb/cdc.h`.
- Detected declarations: `function is_rndis`, `function is_activesync`, `function is_wireless_rndis`, `function is_novatel_rndis`, `function usbnet_cdc_update_filter`, `function usbnet_generic_cdc_bind`, `function usbnet_ether_cdc_bind`, `function usbnet_cdc_unbind`, `function speed_change`, `function usbnet_cdc_status`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.