drivers/net/usb/catc.c
Source file repositories/reference/linux-study-clean/drivers/net/usb/catc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/usb/catc.c- Extension
.c- Size
- 24516 bytes
- Lines
- 1000
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/kernel.hlinux/string.hlinux/netdevice.hlinux/etherdevice.hlinux/skbuff.hlinux/spinlock.hlinux/ethtool.hlinux/crc32.hlinux/bitops.hlinux/gfp.hlinux/uaccess.hlinux/usb.h
Detected Declarations
struct catcstruct ctrl_queueenum catc_usb_epenum control_requestsenum register_offsetsenum eth_statsenum op_mode_bitsenum rx_filter_bitsenum led_valuesenum link_statusfunction catc_rx_donefunction catc_irq_donefunction catc_tx_runfunction catc_tx_donefunction catc_start_xmitfunction catc_tx_timeoutfunction catc_ctrl_msgfunction catc_ctrl_runfunction catc_ctrl_donefunction catc_ctrl_asyncfunction catc_stats_donefunction catc_stats_timerfunction catc_multicastfunction catc_set_multicast_listfunction netdev_for_each_mc_addrfunction catc_get_drvinfofunction catc_get_link_ksettingsfunction catc_openfunction catc_stopfunction catc_probefunction le16_to_cpufunction catc_disconnect
Annotated Snippet
static const struct net_device_ops catc_netdev_ops = {
.ndo_open = catc_open,
.ndo_stop = catc_stop,
.ndo_start_xmit = catc_start_xmit,
.ndo_tx_timeout = catc_tx_timeout,
.ndo_set_rx_mode = catc_set_multicast_list,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
};
/*
* USB probe, disconnect.
*/
static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id)
{
struct device *dev = &intf->dev;
struct usb_device *usbdev = interface_to_usbdev(intf);
struct net_device *netdev;
struct catc *catc;
u8 broadcast[ETH_ALEN];
u8 *macbuf;
int pktsz, ret = -ENOMEM;
static const u8 bulk_ep_addr[] = {
CATC_USB_EP_BULK | USB_DIR_OUT,
CATC_USB_EP_BULK | USB_DIR_IN,
0};
static const u8 int_ep_addr[] = {
CATC_USB_EP_INT_IN | USB_DIR_IN,
0};
macbuf = kmalloc(ETH_ALEN, GFP_KERNEL);
if (!macbuf)
goto error;
if (usb_set_interface(usbdev,
intf->altsetting->desc.bInterfaceNumber, 1)) {
dev_err(dev, "Can't set altsetting 1.\n");
ret = -EIO;
goto fail_mem;
}
/* Verify that all required endpoints are present */
if (!usb_check_bulk_endpoints(intf, bulk_ep_addr) ||
!usb_check_int_endpoints(intf, int_ep_addr)) {
dev_err(dev, "Missing or invalid endpoints\n");
ret = -ENODEV;
goto fail_mem;
}
netdev = alloc_etherdev(sizeof(struct catc));
if (!netdev)
goto fail_mem;
catc = netdev_priv(netdev);
netdev->netdev_ops = &catc_netdev_ops;
netdev->watchdog_timeo = TX_TIMEOUT;
netdev->ethtool_ops = &ops;
catc->usbdev = usbdev;
catc->netdev = netdev;
spin_lock_init(&catc->tx_lock);
spin_lock_init(&catc->ctrl_lock);
timer_setup(&catc->timer, catc_stats_timer, 0);
catc->ctrl_urb = usb_alloc_urb(0, GFP_KERNEL);
catc->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
catc->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
catc->irq_urb = usb_alloc_urb(0, GFP_KERNEL);
if ((!catc->ctrl_urb) || (!catc->tx_urb) ||
(!catc->rx_urb) || (!catc->irq_urb)) {
dev_err(&intf->dev, "No free urbs available.\n");
ret = -ENOMEM;
goto fail_free;
}
/* The F5U011 has the same vendor/product as the netmate but a device version of 0x130 */
if (le16_to_cpu(usbdev->descriptor.idVendor) == 0x0423 &&
le16_to_cpu(usbdev->descriptor.idProduct) == 0xa &&
le16_to_cpu(catc->usbdev->descriptor.bcdDevice) == 0x0130) {
dev_dbg(dev, "Testing for f5u011\n");
catc->is_f5u011 = 1;
atomic_set(&catc->recq_sz, 0);
pktsz = RX_PKT_SZ;
} else {
pktsz = RX_MAX_BURST * (PKT_SZ + 2);
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/string.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/skbuff.h`, `linux/spinlock.h`, `linux/ethtool.h`.
- Detected declarations: `struct catc`, `struct ctrl_queue`, `enum catc_usb_ep`, `enum control_requests`, `enum register_offsets`, `enum eth_stats`, `enum op_mode_bits`, `enum rx_filter_bits`, `enum led_values`, `enum link_status`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.