net/can/bcm.c
Source file repositories/reference/linux-study-clean/net/can/bcm.c
File Facts
- System
- Linux kernel
- Corpus path
net/can/bcm.c- Extension
.c- Size
- 46463 bytes
- Lines
- 1876
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/init.hlinux/interrupt.hlinux/hrtimer.hlinux/list.hlinux/proc_fs.hlinux/seq_file.hlinux/uio.hlinux/net.hlinux/netdevice.hlinux/socket.hlinux/if_arp.hlinux/skbuff.hlinux/can.hlinux/can/core.hlinux/can/skb.hlinux/can/bcm.hlinux/slab.hlinux/spinlock.hnet/can.hnet/sock.hnet/net_namespace.h
Detected Declarations
struct bcm_opstruct bcm_sockfunction canfunction bcm_timeval_to_ktimefunction bcm_is_invalid_tvfunction bcm_proc_showfunction list_for_each_entry_rcufunction list_for_each_entryfunction bcm_can_txfunction bcm_send_to_userfunction bcm_tx_set_expiryfunction bcm_tx_start_timerfunction bcm_tx_timeout_handlerfunction bcm_rx_changedfunction bcm_rx_update_and_sendfunction ktime_to_usfunction bcm_rx_cmp_to_indexfunction bcm_rx_starttimerfunction bcm_rx_timeout_handlerfunction bcm_rx_do_flushfunction bcm_rx_thr_flushfunction bcm_rx_thr_handlerfunction bcm_rx_handlerfunction list_for_each_entryfunction bcm_free_op_rcufunction bcm_remove_opfunction bcm_rx_unregfunction bcm_delete_rx_opfunction list_for_each_entry_safefunction bcm_delete_tx_opfunction list_for_each_entry_safefunction bcm_read_opfunction bcm_tx_setupfunction bcm_rx_setupfunction bcm_tx_sendfunction bcm_sendmsgfunction bcm_notifyfunction bcm_notifierfunction bcm_initfunction bcm_releasefunction list_for_each_entry_safefunction bcm_connectfunction bcm_recvmsgfunction bcm_sock_no_ioctlcmdfunction canbcm_pernet_initfunction canbcm_pernet_exitfunction bcm_module_initfunction bcm_module_exit
Annotated Snippet
static const struct proto_ops bcm_ops = {
.family = PF_CAN,
.release = bcm_release,
.bind = sock_no_bind,
.connect = bcm_connect,
.socketpair = sock_no_socketpair,
.accept = sock_no_accept,
.getname = sock_no_getname,
.poll = datagram_poll,
.ioctl = bcm_sock_no_ioctlcmd,
.gettstamp = sock_gettstamp,
.listen = sock_no_listen,
.shutdown = sock_no_shutdown,
.sendmsg = bcm_sendmsg,
.recvmsg = bcm_recvmsg,
.mmap = sock_no_mmap,
};
static struct proto bcm_proto __read_mostly = {
.name = "CAN_BCM",
.owner = THIS_MODULE,
.obj_size = sizeof(struct bcm_sock),
.init = bcm_init,
};
static const struct can_proto bcm_can_proto = {
.type = SOCK_DGRAM,
.protocol = CAN_BCM,
.ops = &bcm_ops,
.prot = &bcm_proto,
};
static int canbcm_pernet_init(struct net *net)
{
#if IS_ENABLED(CONFIG_PROC_FS)
/* create /proc/net/can-bcm directory */
net->can.bcmproc_dir = proc_net_mkdir(net, "can-bcm", net->proc_net);
#endif /* CONFIG_PROC_FS */
return 0;
}
static void canbcm_pernet_exit(struct net *net)
{
#if IS_ENABLED(CONFIG_PROC_FS)
/* remove /proc/net/can-bcm directory */
if (net->can.bcmproc_dir)
remove_proc_entry("can-bcm", net->proc_net);
#endif /* CONFIG_PROC_FS */
}
static struct pernet_operations canbcm_pernet_ops __read_mostly = {
.init = canbcm_pernet_init,
.exit = canbcm_pernet_exit,
};
static struct notifier_block canbcm_notifier = {
.notifier_call = bcm_notifier
};
static int __init bcm_module_init(void)
{
int err;
pr_info("can: broadcast manager protocol\n");
err = register_pernet_subsys(&canbcm_pernet_ops);
if (err)
return err;
err = register_netdevice_notifier(&canbcm_notifier);
if (err)
goto register_notifier_failed;
err = can_proto_register(&bcm_can_proto);
if (err < 0) {
printk(KERN_ERR "can: registration of bcm protocol failed\n");
goto register_proto_failed;
}
return 0;
register_proto_failed:
unregister_netdevice_notifier(&canbcm_notifier);
register_notifier_failed:
unregister_pernet_subsys(&canbcm_pernet_ops);
return err;
}
static void __exit bcm_module_exit(void)
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/interrupt.h`, `linux/hrtimer.h`, `linux/list.h`, `linux/proc_fs.h`, `linux/seq_file.h`, `linux/uio.h`.
- Detected declarations: `struct bcm_op`, `struct bcm_sock`, `function can`, `function bcm_timeval_to_ktime`, `function bcm_is_invalid_tv`, `function bcm_proc_show`, `function list_for_each_entry_rcu`, `function list_for_each_entry`, `function bcm_can_tx`, `function bcm_send_to_user`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.