189e0f4d2SKip Macy /* 289e0f4d2SKip Macy * 39999d2cbSKip Macy * XenBSD block device driver 49999d2cbSKip Macy * 59999d2cbSKip Macy * Copyright (c) 2009 Frank Suchomel, Citrix 69999d2cbSKip Macy * Copyright (c) 2009 Doug F. Rabson, Citrix 79999d2cbSKip Macy * Copyright (c) 2005 Kip Macy 89999d2cbSKip Macy * Copyright (c) 2003-2004, Keir Fraser & Steve Hand 99999d2cbSKip Macy * Modifications by Mark A. Williamson are (c) Intel Research Cambridge 109999d2cbSKip Macy * 119999d2cbSKip Macy * 129999d2cbSKip Macy * Permission is hereby granted, free of charge, to any person obtaining a copy 139999d2cbSKip Macy * of this software and associated documentation files (the "Software"), to 149999d2cbSKip Macy * deal in the Software without restriction, including without limitation the 159999d2cbSKip Macy * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 169999d2cbSKip Macy * sell copies of the Software, and to permit persons to whom the Software is 179999d2cbSKip Macy * furnished to do so, subject to the following conditions: 189999d2cbSKip Macy * 199999d2cbSKip Macy * The above copyright notice and this permission notice shall be included in 209999d2cbSKip Macy * all copies or substantial portions of the Software. 2189e0f4d2SKip Macy * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 2289e0f4d2SKip Macy * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 2389e0f4d2SKip Macy * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 2489e0f4d2SKip Macy * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 2589e0f4d2SKip Macy * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 2689e0f4d2SKip Macy * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 2789e0f4d2SKip Macy * IN THE SOFTWARE. 2889e0f4d2SKip Macy * 2989e0f4d2SKip Macy * $FreeBSD$ 3089e0f4d2SKip Macy */ 3189e0f4d2SKip Macy 3289e0f4d2SKip Macy 3389e0f4d2SKip Macy #ifndef __XEN_DRIVERS_BLOCK_H__ 3489e0f4d2SKip Macy #define __XEN_DRIVERS_BLOCK_H__ 3589e0f4d2SKip Macy #include <xen/interface/io/blkif.h> 3689e0f4d2SKip Macy 3789e0f4d2SKip Macy struct xlbd_type_info 3889e0f4d2SKip Macy { 3989e0f4d2SKip Macy int partn_shift; 4089e0f4d2SKip Macy int disks_per_major; 4189e0f4d2SKip Macy char *devname; 4289e0f4d2SKip Macy char *diskname; 4389e0f4d2SKip Macy }; 4489e0f4d2SKip Macy 4589e0f4d2SKip Macy struct xlbd_major_info 4689e0f4d2SKip Macy { 4789e0f4d2SKip Macy int major; 4889e0f4d2SKip Macy int index; 4989e0f4d2SKip Macy int usage; 5089e0f4d2SKip Macy struct xlbd_type_info *type; 5189e0f4d2SKip Macy }; 5289e0f4d2SKip Macy 5389e0f4d2SKip Macy struct blk_shadow { 5489e0f4d2SKip Macy blkif_request_t req; 5589e0f4d2SKip Macy unsigned long request; 5689e0f4d2SKip Macy unsigned long frame[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 5789e0f4d2SKip Macy }; 5889e0f4d2SKip Macy 5989e0f4d2SKip Macy #define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE) 6089e0f4d2SKip Macy 6189e0f4d2SKip Macy 6289e0f4d2SKip Macy struct xb_softc { 6389e0f4d2SKip Macy device_t xb_dev; 6489e0f4d2SKip Macy struct disk *xb_disk; /* disk params */ 6589e0f4d2SKip Macy struct bio_queue_head xb_bioq; /* sort queue */ 6689e0f4d2SKip Macy int xb_unit; 6789e0f4d2SKip Macy int xb_flags; 6889e0f4d2SKip Macy struct blkfront_info *xb_info; 6989e0f4d2SKip Macy LIST_ENTRY(xb_softc) entry; 7089e0f4d2SKip Macy #define XB_OPEN (1<<0) /* drive is open (can't shut down) */ 7189e0f4d2SKip Macy }; 7289e0f4d2SKip Macy 7389e0f4d2SKip Macy 7489e0f4d2SKip Macy /* 7589e0f4d2SKip Macy * We have one of these per vbd, whether ide, scsi or 'other'. They 7689e0f4d2SKip Macy * hang in private_data off the gendisk structure. We may end up 7789e0f4d2SKip Macy * putting all kinds of interesting stuff here :-) 7889e0f4d2SKip Macy */ 7989e0f4d2SKip Macy struct blkfront_info 8089e0f4d2SKip Macy { 8123dc5621SKip Macy device_t xbdev; 8289e0f4d2SKip Macy dev_t dev; 8389e0f4d2SKip Macy struct gendisk *gd; 8489e0f4d2SKip Macy int vdevice; 8589e0f4d2SKip Macy blkif_vdev_t handle; 8689e0f4d2SKip Macy int connected; 8789e0f4d2SKip Macy int ring_ref; 8889e0f4d2SKip Macy blkif_front_ring_t ring; 8989e0f4d2SKip Macy unsigned int irq; 9089e0f4d2SKip Macy struct xlbd_major_info *mi; 9189e0f4d2SKip Macy #if 0 9289e0f4d2SKip Macy request_queue_t *rq; 9389e0f4d2SKip Macy struct work_struct work; 9489e0f4d2SKip Macy #endif 9589e0f4d2SKip Macy struct gnttab_free_callback callback; 9689e0f4d2SKip Macy struct blk_shadow shadow[BLK_RING_SIZE]; 9789e0f4d2SKip Macy unsigned long shadow_free; 9889e0f4d2SKip Macy struct xb_softc *sc; 9989e0f4d2SKip Macy int feature_barrier; 10089e0f4d2SKip Macy int is_ready; 10189e0f4d2SKip Macy /** 10289e0f4d2SKip Macy * The number of people holding this device open. We won't allow a 10389e0f4d2SKip Macy * hot-unplug unless this is 0. 10489e0f4d2SKip Macy */ 10589e0f4d2SKip Macy int users; 10689e0f4d2SKip Macy }; 10789e0f4d2SKip Macy /* Note that xlvbd_add doesn't call add_disk for you: you're expected 10889e0f4d2SKip Macy to call add_disk on info->gd once the disk is properly connected 10989e0f4d2SKip Macy up. */ 11023dc5621SKip Macy int xlvbd_add(device_t, blkif_sector_t capacity, int device, 11189e0f4d2SKip Macy uint16_t vdisk_info, uint16_t sector_size, struct blkfront_info *info); 11289e0f4d2SKip Macy void xlvbd_del(struct blkfront_info *info); 11389e0f4d2SKip Macy 11489e0f4d2SKip Macy #endif /* __XEN_DRIVERS_BLOCK_H__ */ 11589e0f4d2SKip Macy 116