Deleted Added
full compact
xenbusb.h (214077) xenbusb.h (222975)
1/*-
2 * Core definitions and data structures shareable across OS platforms.
3 *
4 * Copyright (c) 2010 Spectra Logic Corporation
5 * Copyright (C) 2008 Doug Rabson
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 16 unchanged lines hidden (view full) ---

25 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGES.
32 *
1/*-
2 * Core definitions and data structures shareable across OS platforms.
3 *
4 * Copyright (c) 2010 Spectra Logic Corporation
5 * Copyright (C) 2008 Doug Rabson
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 16 unchanged lines hidden (view full) ---

25 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGES.
32 *
33 * $FreeBSD: head/sys/xen/xenbus/xenbusb.h 214077 2010-10-19 20:53:30Z gibbs $
33 * $FreeBSD: head/sys/xen/xenbus/xenbusb.h 222975 2011-06-11 04:59:01Z gibbs $
34 */
35#ifndef _XEN_XENBUS_XENBUSB_H
36#define _XEN_XENBUS_XENBUSB_H
37
38/**
39 * \file xenbusb.h
40 *
41 * Datastructures and function declarations for use in implementing
42 * bus attachements (e.g. frontend and backend device busses) for XenBus.
43 */
34 */
35#ifndef _XEN_XENBUS_XENBUSB_H
36#define _XEN_XENBUS_XENBUSB_H
37
38/**
39 * \file xenbusb.h
40 *
41 * Datastructures and function declarations for use in implementing
42 * bus attachements (e.g. frontend and backend device busses) for XenBus.
43 */
44#include "xenbusb_if.h"
45
46/**
47 * Enumeration of state flag values for the xbs_flags field of
48 * the xenbusb_softc structure.
49 */
50typedef enum {
51 /** */
52 XBS_ATTACH_CH_ACTIVE = 0x01
53} xenbusb_softc_flag;
54
55/**
56 * \brief Container for all state needed to manage a Xenbus Bus
57 * attachment.
58 */
59struct xenbusb_softc {
60 /**
61 * XenStore watch used to monitor the subtree of the
62 * XenStore where devices for this bus attachment arrive
63 * and depart.
44
45/**
46 * Enumeration of state flag values for the xbs_flags field of
47 * the xenbusb_softc structure.
48 */
49typedef enum {
50 /** */
51 XBS_ATTACH_CH_ACTIVE = 0x01
52} xenbusb_softc_flag;
53
54/**
55 * \brief Container for all state needed to manage a Xenbus Bus
56 * attachment.
57 */
58struct xenbusb_softc {
59 /**
60 * XenStore watch used to monitor the subtree of the
61 * XenStore where devices for this bus attachment arrive
62 * and depart.
64 *
65 * \note This field must be the first in the softc structure
66 * so that a simple cast can be used to retrieve the
67 * softc from within a XenStore watch event callback.
68 */
69 struct xs_watch xbs_device_watch;
70
71 /** Mutex used to protect fields of the xenbusb_softc. */
72 struct mtx xbs_lock;
73
74 /** State flags. */
75 xenbusb_softc_flag xbs_flags;

--- 48 unchanged lines hidden (view full) ---

124} xenbus_dev_flag;
125
126/** Instance variables for devices on a XenBus bus. */
127struct xenbus_device_ivars {
128 /**
129 * XenStore watch used to monitor the subtree of the
130 * XenStore where information about the otherend of
131 * the split Xen device this device instance represents.
63 */
64 struct xs_watch xbs_device_watch;
65
66 /** Mutex used to protect fields of the xenbusb_softc. */
67 struct mtx xbs_lock;
68
69 /** State flags. */
70 xenbusb_softc_flag xbs_flags;

--- 48 unchanged lines hidden (view full) ---

119} xenbus_dev_flag;
120
121/** Instance variables for devices on a XenBus bus. */
122struct xenbus_device_ivars {
123 /**
124 * XenStore watch used to monitor the subtree of the
125 * XenStore where information about the otherend of
126 * the split Xen device this device instance represents.
132 *
133 * \note This field must be the first in the instance
134 * variable structure so that a simple cast can be
135 * used to retrieve ivar data from within a XenStore
136 * watch event callback.
137 */
138 struct xs_watch xd_otherend_watch;
139
127 */
128 struct xs_watch xd_otherend_watch;
129
130 /**
131 * XenStore watch used to monitor the XenStore sub-tree
132 * associated with this device. This watch will fire
133 * for modifications that we make from our domain as
134 * well as for those made by the control domain.
135 */
136 struct xs_watch xd_local_watch;
137
140 /** Sleepable lock used to protect instance data. */
141 struct sx xd_lock;
142
143 /** State flags. */
144 xenbus_dev_flag xd_flags;
145
146 /** The NewBus device_t for this XenBus device instance. */
147 device_t xd_dev;
148
149 /**
150 * The VM relative path to the XenStore subtree representing
151 * this VMs half of this device.
152 */
153 char *xd_node;
154
138 /** Sleepable lock used to protect instance data. */
139 struct sx xd_lock;
140
141 /** State flags. */
142 xenbus_dev_flag xd_flags;
143
144 /** The NewBus device_t for this XenBus device instance. */
145 device_t xd_dev;
146
147 /**
148 * The VM relative path to the XenStore subtree representing
149 * this VMs half of this device.
150 */
151 char *xd_node;
152
153 /** The length of xd_node. */
154 int xd_node_len;
155
155 /** XenBus device type ("vbd", "vif", etc.). */
156 char *xd_type;
157
158 /**
159 * Cached version of <xd_node>/state node in the XenStore.
160 */
161 enum xenbus_state xd_state;
162
163 /** The VM identifier of the other end of this split device. */
164 int xd_otherend_id;
165
166 /**
167 * The path to the subtree of the XenStore where information
168 * about the otherend of this split device instance.
169 */
170 char *xd_otherend_path;
156 /** XenBus device type ("vbd", "vif", etc.). */
157 char *xd_type;
158
159 /**
160 * Cached version of <xd_node>/state node in the XenStore.
161 */
162 enum xenbus_state xd_state;
163
164 /** The VM identifier of the other end of this split device. */
165 int xd_otherend_id;
166
167 /**
168 * The path to the subtree of the XenStore where information
169 * about the otherend of this split device instance.
170 */
171 char *xd_otherend_path;
172
173 /** The length of xd_otherend_path. */
174 int xd_otherend_path_len;
171};
172
173/**
174 * \brief Identify instances of this device type in the system.
175 *
176 * \param driver The driver performing this identify action.
177 * \param parent The NewBus parent device for any devices this method adds.
178 */

--- 63 unchanged lines hidden (view full) ---

242 *
243 * \return On success, 0. Otherwise an errno value indicating the
244 * type of failure.
245 */
246int xenbusb_write_ivar(device_t dev, device_t child, int index,
247 uintptr_t value);
248
249/**
175};
176
177/**
178 * \brief Identify instances of this device type in the system.
179 *
180 * \param driver The driver performing this identify action.
181 * \param parent The NewBus parent device for any devices this method adds.
182 */

--- 63 unchanged lines hidden (view full) ---

246 *
247 * \return On success, 0. Otherwise an errno value indicating the
248 * type of failure.
249 */
250int xenbusb_write_ivar(device_t dev, device_t child, int index,
251 uintptr_t value);
252
253/**
254 * \brief Common XenBus method implementing responses to peer state changes.
255 *
256 * \param bus The XenBus bus parent of child.
257 * \param child The XenBus child whose peer stat has changed.
258 * \param state The current state of the peer.
259 */
260void xenbusb_otherend_changed(device_t bus, device_t child,
261 enum xenbus_state state);
262
263/**
264 * \brief Common XenBus method implementing responses to local XenStore changes.
265 *
266 * \param bus The XenBus bus parent of child.
267 * \param child The XenBus child whose peer stat has changed.
268 * \param path The tree relative sub-path to the modified node. The empty
269 * string indicates the root of the tree was destroyed.
270 */
271void xenbusb_localend_changed(device_t bus, device_t child, const char *path);
272
273/**
250 * \brief Attempt to add a XenBus device instance to this XenBus bus.
251 *
252 * \param dev The NewBus device representing this XenBus bus.
253 * \param type The device type being added (e.g. "vbd", "vif").
254 * \param id The device ID for this device.
255 *
256 * \return On success, 0. Otherwise an errno value indicating the
257 * type of failure. Failure indicates that either the

--- 6 unchanged lines hidden (view full) ---

264 * processing is not performed by this routine, but must be scheduled
265 * via the xbs_probe_children task. This separation of responsibilities
266 * is required to avoid hanging up the XenStore event delivery thread
267 * with our probe/attach work in the event a device is added via
268 * a callback from the XenStore.
269 */
270int xenbusb_add_device(device_t dev, const char *type, const char *id);
271
274 * \brief Attempt to add a XenBus device instance to this XenBus bus.
275 *
276 * \param dev The NewBus device representing this XenBus bus.
277 * \param type The device type being added (e.g. "vbd", "vif").
278 * \param id The device ID for this device.
279 *
280 * \return On success, 0. Otherwise an errno value indicating the
281 * type of failure. Failure indicates that either the

--- 6 unchanged lines hidden (view full) ---

288 * processing is not performed by this routine, but must be scheduled
289 * via the xbs_probe_children task. This separation of responsibilities
290 * is required to avoid hanging up the XenStore event delivery thread
291 * with our probe/attach work in the event a device is added via
292 * a callback from the XenStore.
293 */
294int xenbusb_add_device(device_t dev, const char *type, const char *id);
295
296#include "xenbusb_if.h"
297
272#endif /* _XEN_XENBUS_XENBUSB_H */
298#endif /* _XEN_XENBUS_XENBUSB_H */