1214077Sgibbs#- 2214077Sgibbs# Copyright (c) 2010 Spectra Logic Corporation 3214077Sgibbs# All rights reserved. 4214077Sgibbs# 5214077Sgibbs# Redistribution and use in source and binary forms, with or without 6214077Sgibbs# modification, are permitted provided that the following conditions 7214077Sgibbs# are met: 8214077Sgibbs# 1. Redistributions of source code must retain the above copyright 9214077Sgibbs# notice, this list of conditions, and the following disclaimer, 10214077Sgibbs# without modification. 11214077Sgibbs# 2. Redistributions in binary form must reproduce at minimum a disclaimer 12214077Sgibbs# substantially similar to the "NO WARRANTY" disclaimer below 13214077Sgibbs# ("Disclaimer") and any redistribution must be conditioned upon 14214077Sgibbs# including a substantially similar Disclaimer requirement for further 15214077Sgibbs# binary redistribution. 16214077Sgibbs# 17214077Sgibbs# NO WARRANTY 18214077Sgibbs# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19214077Sgibbs# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20214077Sgibbs# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 21214077Sgibbs# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22214077Sgibbs# HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23214077Sgibbs# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24214077Sgibbs# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25214077Sgibbs# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26214077Sgibbs# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 27214077Sgibbs# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28214077Sgibbs# POSSIBILITY OF SUCH DAMAGES. 29214077Sgibbs# 30214077Sgibbs# $FreeBSD: releng/11.0/sys/xen/xenbus/xenbusb_if.m 222975 2011-06-11 04:59:01Z gibbs $ 31214077Sgibbs# 32214077Sgibbs 33214077Sgibbs#include <sys/bus.h> 34222975Sgibbs#include <sys/lock.h> 35222975Sgibbs#include <sys/sx.h> 36222975Sgibbs#include <sys/taskqueue.h> 37214077Sgibbs 38222975Sgibbs#include <xen/xenstore/xenstorevar.h> 39222975Sgibbs#include <xen/xenbus/xenbusb.h> 40214077Sgibbs 41214077SgibbsINTERFACE xenbusb; 42214077Sgibbs 43214077Sgibbs/** 44214077Sgibbs * \brief Enumerate all devices of the given type on this bus. 45214077Sgibbs * 46214077Sgibbs * \param _dev NewBus device_t for this XenBus (front/back) bus instance. 47214077Sgibbs * \param _type String indicating the device sub-tree (e.g. "vfb", "vif") 48214077Sgibbs * to enumerate. 49214077Sgibbs * 50214077Sgibbs * \return On success, 0. Otherwise an errno value indicating the 51214077Sgibbs * type of failure. 52214077Sgibbs * 53214077Sgibbs * Devices that are found should be entered into the NewBus hierarchy via 54214077Sgibbs * xenbusb_add_device(). xenbusb_add_device() ignores duplicate detects 55214077Sgibbs * and ignores duplicate devices, so it can be called unconditionally 56214077Sgibbs * for any device found in the XenStore. 57214077Sgibbs */ 58214077SgibbsMETHOD int enumerate_type { 59214077Sgibbs device_t _dev; 60214077Sgibbs const char *_type; 61214077Sgibbs}; 62214077Sgibbs 63214077Sgibbs/** 64214077Sgibbs * \brief Determine and store the XenStore path for the other end of 65214077Sgibbs * a split device whose local end is represented by ivars. 66214077Sgibbs * 67214077Sgibbs * If successful, the xd_otherend_path field of the child's instance 68214077Sgibbs * variables must be updated. 69214077Sgibbs * 70214077Sgibbs * \param _dev NewBus device_t for this XenBus (front/back) bus instance. 71214077Sgibbs * \param _ivars Instance variables from the XenBus child device for 72214077Sgibbs * which to perform this function. 73214077Sgibbs * 74214077Sgibbs * \return On success, 0. Otherwise an errno value indicating the 75214077Sgibbs * type of failure. 76214077Sgibbs */ 77214077SgibbsMETHOD int get_otherend_node { 78214077Sgibbs device_t _dev; 79214077Sgibbs struct xenbus_device_ivars *_ivars; 80214077Sgibbs} 81222975Sgibbs 82222975Sgibbs/** 83222975Sgibbs * \brief Handle a XenStore change detected in the peer tree of a child 84222975Sgibbs * device of the bus. 85222975Sgibbs * 86222975Sgibbs * \param _bus NewBus device_t for this XenBus (front/back) bus instance. 87222975Sgibbs * \param _child NewBus device_t for the child device whose peer XenStore 88222975Sgibbs * tree has changed. 89222975Sgibbs * \param _state The current state of the peer. 90222975Sgibbs */ 91222975SgibbsMETHOD void otherend_changed { 92222975Sgibbs device_t _bus; 93222975Sgibbs device_t _child; 94222975Sgibbs enum xenbus_state _state; 95222975Sgibbs} DEFAULT xenbusb_otherend_changed; 96222975Sgibbs 97222975Sgibbs/** 98222975Sgibbs * \brief Handle a XenStore change detected in the local tree of a child 99222975Sgibbs * device of the bus. 100222975Sgibbs * 101222975Sgibbs * \param _bus NewBus device_t for this XenBus (front/back) bus instance. 102222975Sgibbs * \param _child NewBus device_t for the child device whose peer XenStore 103222975Sgibbs * tree has changed. 104222975Sgibbs * \param _path The tree relative sub-path to the modified node. The empty 105222975Sgibbs * string indicates the root of the tree was destroyed. 106222975Sgibbs */ 107222975SgibbsMETHOD void localend_changed { 108222975Sgibbs device_t _bus; 109222975Sgibbs device_t _child; 110222975Sgibbs const char * _path; 111222975Sgibbs} DEFAULT xenbusb_localend_changed; 112