FreeBSD xen subsystem code
xenbusb_back.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/sbuf.h>
#include <sys/sysctl.h>
#include <sys/syslog.h>
#include <sys/systm.h>
#include <sys/sx.h>
#include <sys/taskqueue.h>
#include <machine/stdarg.h>
#include <xen/xen-os.h>
#include <xen/gnttab.h>
#include <xen/xenbus/xenbusvar.h>
#include <xen/xenbus/xenbusb.h>
Include dependency graph for xenbusb_back.c:

Go to the source code of this file.

Functions

 __FBSDID ("$FreeBSD$")
 
static int xenbusb_back_probe (device_t dev)
 Probe for the existence of the XenBus back bus. More...
 
static int xenbusb_back_attach (device_t dev)
 Attach the XenBus back bus. More...
 
static int xenbusb_back_enumerate_type (device_t dev, const char *type)
 Enumerate all devices of the given type on this bus. More...
 
static int xenbusb_back_get_otherend_node (device_t dev, struct xenbus_device_ivars *ivars)
 Determine and store the XenStore path for the other end of a split device whose local end is represented by ivars. More...
 
static void xenbusb_back_otherend_changed (device_t bus, device_t child, enum xenbus_state peer_state)
 Backend XenBus method implementing responses to peer state changes. More...
 
static void xenbusb_back_localend_changed (device_t bus, device_t child, const char *path)
 Backend XenBus method implementing responses to local XenStore changes. More...
 
 DEFINE_CLASS_0 (xenbusb_back, xenbusb_back_driver, xenbusb_back_methods, sizeof(struct xenbusb_softc))
 
 DRIVER_MODULE (xenbusb_back, xenstore, xenbusb_back_driver, xenbusb_back_devclass, 0, 0)
 

Variables

static device_method_t xenbusb_back_methods []
 
devclass_t xenbusb_back_devclass
 

Detailed Description

XenBus management of the NewBus bus containing the backend instances of Xen split devices.

Definition in file xenbusb_back.c.

Function Documentation

◆ xenbusb_back_attach()

static int xenbusb_back_attach ( device_t  dev)
static

Attach the XenBus back bus.

Parameters
devNewBus device_t for this XenBus back bus instance.
Returns
On success, 0. Otherwise an errno value indicating the type of failure.

Definition at line 86 of file xenbusb_back.c.

References xenbusb_softc::xbs_flags, xenbusb_softc::xbs_lock, and xenbusb_attach().

Here is the call graph for this function:

◆ xenbusb_back_enumerate_type()

static int xenbusb_back_enumerate_type ( device_t  dev,
const char *  type 
)
static

Enumerate all devices of the given type on this bus.

Parameters
devNewBus device_t for this XenBus backend bus instance.
typeString indicating the device sub-tree (e.g. "vfb", "vif") to enumerate.
Returns
On success, 0. Otherwise an errno value indicating the type of failure.

Devices that are found are entered into the NewBus hierarchy via xenbusb_add_device(). xenbusb_add_device() ignores duplicate detects and ignores duplicate devices, so it can be called unconditionally for any device found in the XenStore.

The backend XenStore hierarchy has the following format:

backend/<device type>/<frontend vm id>/<device id>

Definition at line 132 of file xenbusb_back.c.

References xenbusb_softc::xbs_node, and xenbusb_add_device().

Here is the call graph for this function:

◆ xenbusb_back_get_otherend_node()

static int xenbusb_back_get_otherend_node ( device_t  dev,
struct xenbus_device_ivars ivars 
)
static

Determine and store the XenStore path for the other end of a split device whose local end is represented by ivars.

Parameters
devNewBus device_t for this XenBus backend bus instance.
ivarsInstance variables from the XenBus child device for which to perform this function.
Returns
On success, 0. Otherwise an errno value indicating the type of failure.

If successful, the xd_otherend_path field of the child's instance variables will be updated.

Definition at line 193 of file xenbusb_back.c.

References xenbus_device_ivars::xd_node, xenbus_device_ivars::xd_otherend_id, xenbus_device_ivars::xd_otherend_path, and xenbus_device_ivars::xd_otherend_path_len.

◆ xenbusb_back_localend_changed()

static void xenbusb_back_localend_changed ( device_t  bus,
device_t  child,
const char *  path 
)
static

Backend XenBus method implementing responses to local XenStore changes.

Parameters
busThe XenBus bus parent of child.
childThe XenBus child whose peer stat has changed. \param_path The tree relative sub-path to the modified node. The empty string indicates the root of the tree was destroyed.

Definition at line 254 of file xenbusb_back.c.

References xenbus_dev_is_online(), and xenbusb_localend_changed().

Here is the call graph for this function:

◆ xenbusb_back_otherend_changed()

static void xenbusb_back_otherend_changed ( device_t  bus,
device_t  child,
enum xenbus_state  peer_state 
)
static

Backend XenBus method implementing responses to peer state changes.

Parameters
busThe XenBus bus parent of child.
childThe XenBus child whose peer stat has changed.
stateThe current state of the peer.

Definition at line 224 of file xenbusb_back.c.

References xenbus_dev_is_online(), and xenbusb_otherend_changed().

Here is the call graph for this function:

◆ xenbusb_back_probe()

static int xenbusb_back_probe ( device_t  dev)
static

Probe for the existence of the XenBus back bus.

Parameters
devNewBus device_t for this XenBus back bus instance.
Returns
Always returns 0 indicating success.

Definition at line 70 of file xenbusb_back.c.

Variable Documentation

◆ xenbusb_back_devclass

devclass_t xenbusb_back_devclass

Definition at line 315 of file xenbusb_back.c.

◆ xenbusb_back_methods

device_method_t xenbusb_back_methods[]
static
Initial value:
= {
DEVMETHOD(device_identify, xenbusb_identify),
DEVMETHOD(device_probe, xenbusb_back_probe),
DEVMETHOD(device_attach, xenbusb_back_attach),
DEVMETHOD(device_detach, bus_generic_detach),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD(device_suspend, bus_generic_suspend),
DEVMETHOD(device_resume, xenbusb_resume),
DEVMETHOD(bus_print_child, xenbusb_print_child),
DEVMETHOD(bus_read_ivar, xenbusb_read_ivar),
DEVMETHOD(bus_write_ivar, xenbusb_write_ivar),
DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
DEVMETHOD(xenbusb_enumerate_type, xenbusb_back_enumerate_type),
DEVMETHOD(xenbusb_get_otherend_node, xenbusb_back_get_otherend_node),
{ 0, 0 }
}
int xenbusb_read_ivar(device_t dev, device_t child, int index, uintptr_t *result)
Common XenBus child instance variable read access method.
Definition: xenbusb.c:870
int xenbusb_print_child(device_t dev, device_t child)
Pretty-prints information about a child of a XenBus bus.
Definition: xenbusb.c:857
void xenbusb_localend_changed(device_t bus, device_t child, const char *path)
Common XenBus method implementing responses to local XenStore changes.
Definition: xenbusb.c:976
void xenbusb_identify(driver_t *driver __unused, device_t parent)
Identify instances of this device type in the system.
Definition: xenbusb.c:627
void xenbusb_otherend_changed(device_t bus, device_t child, enum xenbus_state state)
Common XenBus method implementing responses to peer state changes.
Definition: xenbusb.c:970
int xenbusb_resume(device_t dev)
Perform common XenBus bus resume handling.
Definition: xenbusb.c:791
int xenbusb_write_ivar(device_t dev, device_t child, int index, uintptr_t value)
Common XenBus child instance variable write access method.
Definition: xenbusb.c:900
static int xenbusb_back_get_otherend_node(device_t dev, struct xenbus_device_ivars *ivars)
Determine and store the XenStore path for the other end of a split device whose local end is represen...
Definition: xenbusb_back.c:193
static int xenbusb_back_attach(device_t dev)
Attach the XenBus back bus.
Definition: xenbusb_back.c:86
static int xenbusb_back_enumerate_type(device_t dev, const char *type)
Enumerate all devices of the given type on this bus.
Definition: xenbusb_back.c:132
static void xenbusb_back_localend_changed(device_t bus, device_t child, const char *path)
Backend XenBus method implementing responses to local XenStore changes.
Definition: xenbusb_back.c:254
static int xenbusb_back_probe(device_t dev)
Probe for the existence of the XenBus back bus.
Definition: xenbusb_back.c:70
static void xenbusb_back_otherend_changed(device_t bus, device_t child, enum xenbus_state peer_state)
Backend XenBus method implementing responses to peer state changes.
Definition: xenbusb_back.c:224

Definition at line 286 of file xenbusb_back.c.