drivers/net/xen-netback/xenbus.c
Source file repositories/reference/linux-study-clean/drivers/net/xen-netback/xenbus.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/xen-netback/xenbus.c- Extension
.c- Size
- 29828 bytes
- Lines
- 1181
- 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.
- 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
common.hlinux/vmalloc.hlinux/rtnetlink.h
Detected Declarations
function xenvif_read_io_ringfunction xenvif_write_io_ringfunction xenvif_io_ring_openfunction xenvif_ctrl_showfunction xenvif_debugfs_addiffunction xenvif_debugfs_deliffunction netback_ueventfunction backend_create_xenviffunction backend_disconnectfunction backend_connectfunction backend_switch_statefunction set_backend_statefunction read_xenbus_frontend_xdpfunction frontend_changedfunction xen_net_read_ratefunction xen_net_read_macfunction xen_net_rate_changedfunction xen_register_credit_watchfunction xen_unregister_credit_watchfunction xen_mcast_ctrl_changedfunction xen_register_mcast_ctrl_watchfunction xen_unregister_mcast_ctrl_watchfunction xen_register_watchersfunction xen_unregister_watchersfunction unregister_hotplug_status_watchfunction hotplug_status_changedfunction connect_ctrl_ringfunction connectfunction connect_data_ringsfunction read_xenbus_vif_flagsfunction netback_removefunction netback_probefunction xenvif_xenbus_initfunction xenvif_xenbus_fini
Annotated Snippet
static const struct file_operations xenvif_dbg_io_ring_ops_fops = {
.owner = THIS_MODULE,
.open = xenvif_io_ring_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.write = xenvif_write_io_ring,
};
static int xenvif_ctrl_show(struct seq_file *m, void *v)
{
struct xenvif *vif = m->private;
xenvif_dump_hash_info(vif, m);
return 0;
}
DEFINE_SHOW_ATTRIBUTE(xenvif_ctrl);
static void xenvif_debugfs_addif(struct xenvif *vif)
{
int i;
vif->xenvif_dbg_root = debugfs_create_dir(vif->dev->name,
xen_netback_dbg_root);
for (i = 0; i < vif->num_queues; ++i) {
char filename[sizeof("io_ring_q") + 4];
snprintf(filename, sizeof(filename), "io_ring_q%d", i);
debugfs_create_file(filename, 0600, vif->xenvif_dbg_root,
&vif->queues[i],
&xenvif_dbg_io_ring_ops_fops);
}
if (vif->ctrl_irq)
debugfs_create_file("ctrl", 0400, vif->xenvif_dbg_root, vif,
&xenvif_ctrl_fops);
}
static void xenvif_debugfs_delif(struct xenvif *vif)
{
debugfs_remove_recursive(vif->xenvif_dbg_root);
vif->xenvif_dbg_root = NULL;
}
#endif /* CONFIG_DEBUG_FS */
/*
* Handle the creation of the hotplug script environment. We add the script
* and vif variables to the environment, for the benefit of the vif-* hotplug
* scripts.
*/
static int netback_uevent(const struct xenbus_device *xdev,
struct kobj_uevent_env *env)
{
struct backend_info *be = dev_get_drvdata(&xdev->dev);
if (!be)
return 0;
if (add_uevent_var(env, "script=%s", be->hotplug_script))
return -ENOMEM;
if (!be->vif)
return 0;
return add_uevent_var(env, "vif=%s", be->vif->dev->name);
}
static int backend_create_xenvif(struct backend_info *be)
{
int err;
long handle;
struct xenbus_device *dev = be->dev;
struct xenvif *vif;
if (be->vif != NULL)
return 0;
err = xenbus_scanf(XBT_NIL, dev->nodename, "handle", "%li", &handle);
if (err != 1) {
xenbus_dev_fatal(dev, err, "reading handle");
return (err < 0) ? err : -EINVAL;
}
vif = xenvif_alloc(&dev->dev, dev->otherend_id, handle);
if (IS_ERR(vif)) {
err = PTR_ERR(vif);
xenbus_dev_fatal(dev, err, "creating interface");
return err;
Annotation
- Immediate include surface: `common.h`, `linux/vmalloc.h`, `linux/rtnetlink.h`.
- Detected declarations: `function xenvif_read_io_ring`, `function xenvif_write_io_ring`, `function xenvif_io_ring_open`, `function xenvif_ctrl_show`, `function xenvif_debugfs_addif`, `function xenvif_debugfs_delif`, `function netback_uevent`, `function backend_create_xenvif`, `function backend_disconnect`, `function backend_connect`.
- 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.