drivers/net/can/vcan.c
Source file repositories/reference/linux-study-clean/drivers/net/can/vcan.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/can/vcan.c- Extension
.c- Size
- 5975 bytes
- Lines
- 213
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/ethtool.hlinux/module.hlinux/init.hlinux/netdevice.hlinux/if_arp.hlinux/if_ether.hlinux/can.hlinux/can/can-ml.hlinux/can/dev.hlinux/can/skb.hlinux/slab.hnet/rtnetlink.h
Detected Declarations
function vcan_rxfunction vcan_txfunction vcan_set_cap_infofunction vcan_change_mtufunction vcan_setupfunction vcan_init_modulefunction vcan_cleanup_modulemodule init vcan_init_module
Annotated Snippet
static const struct net_device_ops vcan_netdev_ops = {
.ndo_start_xmit = vcan_tx,
.ndo_change_mtu = vcan_change_mtu,
};
static const struct ethtool_ops vcan_ethtool_ops = {
.get_ts_info = ethtool_op_get_ts_info,
};
static void vcan_setup(struct net_device *dev)
{
dev->type = ARPHRD_CAN;
dev->mtu = CANXL_MTU;
dev->hard_header_len = 0;
dev->addr_len = 0;
dev->tx_queue_len = 0;
dev->flags = IFF_NOARP;
can_set_ml_priv(dev, netdev_priv(dev));
vcan_set_cap_info(dev);
/* set flags according to driver capabilities */
if (echo)
dev->flags |= IFF_ECHO;
dev->netdev_ops = &vcan_netdev_ops;
dev->ethtool_ops = &vcan_ethtool_ops;
dev->needs_free_netdev = true;
}
static struct rtnl_link_ops vcan_link_ops __read_mostly = {
.kind = DRV_NAME,
.priv_size = sizeof(struct can_ml_priv),
.setup = vcan_setup,
};
static __init int vcan_init_module(void)
{
pr_info("Virtual CAN interface driver\n");
if (echo)
pr_info("enabled echo on driver level.\n");
return rtnl_link_register(&vcan_link_ops);
}
static __exit void vcan_cleanup_module(void)
{
rtnl_link_unregister(&vcan_link_ops);
}
module_init(vcan_init_module);
module_exit(vcan_cleanup_module);
Annotation
- Immediate include surface: `linux/ethtool.h`, `linux/module.h`, `linux/init.h`, `linux/netdevice.h`, `linux/if_arp.h`, `linux/if_ether.h`, `linux/can.h`, `linux/can/can-ml.h`.
- Detected declarations: `function vcan_rx`, `function vcan_tx`, `function vcan_set_cap_info`, `function vcan_change_mtu`, `function vcan_setup`, `function vcan_init_module`, `function vcan_cleanup_module`, `module init vcan_init_module`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern 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.