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.

Dependency Surface

Detected Declarations

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

Implementation Notes