FreeBSD kernel /amd64 XEN device code
|
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <sys/bio.h>
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/module.h>
#include <sys/sysctl.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <machine/resource.h>
#include <machine/vmparam.h>
#include <xen/xen-os.h>
#include <xen/hypervisor.h>
#include <xen/xen_intr.h>
#include <xen/gnttab.h>
#include <contrib/xen/grant_table.h>
#include <contrib/xen/io/protocols.h>
#include <xen/xenbus/xenbusvar.h>
#include <machine/_inttypes.h>
#include <geom/geom_disk.h>
#include <dev/xen/blkfront/block.h>
#include "xenbus_if.h"
Go to the source code of this file.
Macros | |
#define | DPRINTK(fmt, args...) |
#define | XBD_SECTOR_SHFT 9 |
Functions | |
__FBSDID ("$FreeBSD$") | |
static void | xbd_closing (device_t) |
static void | xbd_startio (struct xbd_softc *sc) |
static | MALLOC_DEFINE (M_XENBLOCKFRONT, "xbd", "Xen Block Front driver data") |
SYSCTL_NODE (_hw, OID_AUTO, xbd, CTLFLAG_RD|CTLFLAG_MPSAFE, 0, "xbd driver parameters") | |
SYSCTL_INT (_hw_xbd, OID_AUTO, xbd_enable_indirect, CTLFLAG_RDTUN, &xbd_enable_indirect, 0, "Enable xbd indirect segments") | |
static void | xbd_freeze (struct xbd_softc *sc, xbd_flag_t xbd_flag) |
static void | xbd_thaw (struct xbd_softc *sc, xbd_flag_t xbd_flag) |
static void | xbd_cm_freeze (struct xbd_softc *sc, struct xbd_command *cm, xbdc_flag_t cm_flag) |
static void | xbd_cm_thaw (struct xbd_softc *sc, struct xbd_command *cm) |
static void | xbd_flush_requests (struct xbd_softc *sc) |
static void | xbd_free_command (struct xbd_command *cm) |
static void | xbd_mksegarray (bus_dma_segment_t *segs, int nsegs, grant_ref_t *gref_head, int otherend_id, int readonly, grant_ref_t *sg_ref, struct blkif_request_segment *sg) |
static void | xbd_queue_cb (void *arg, bus_dma_segment_t *segs, int nsegs, int error) |
static int | xbd_queue_request (struct xbd_softc *sc, struct xbd_command *cm) |
static void | xbd_restart_queue_callback (void *arg) |
static struct xbd_command * | xbd_bio_command (struct xbd_softc *sc) |
static void | xbd_bio_complete (struct xbd_softc *sc, struct xbd_command *cm) |
static void | xbd_int (void *xsc) |
static void | xbd_quiesce (struct xbd_softc *sc) |
static void | xbd_dump_complete (struct xbd_command *cm) |
static int | xbd_dump (void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t length) |
static int | xbd_open (struct disk *dp) |
static int | xbd_close (struct disk *dp) |
static int | xbd_ioctl (struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) |
static void | xbd_strategy (struct bio *bp) |
static int | xbd_alloc_ring (struct xbd_softc *sc) |
static void | xbd_free_ring (struct xbd_softc *sc) |
static int | xbd_feature_string (struct xbd_softc *sc, char *features, size_t len) |
static int | xbd_sysctl_features (SYSCTL_HANDLER_ARGS) |
static void | xbd_setup_sysctl (struct xbd_softc *xbd) |
static void | xbd_vdevice_to_unit (uint32_t vdevice, int *unit, const char **name) |
int | xbd_instance_create (struct xbd_softc *sc, blkif_sector_t sectors, int vdevice, uint16_t vdisk_info, unsigned long sector_size, unsigned long phys_sector_size) |
static void | xbd_free (struct xbd_softc *sc) |
static void | xbd_initialize (struct xbd_softc *sc) |
static void | xbd_connect (struct xbd_softc *sc) |
static int | xbd_probe (device_t dev) |
static int | xbd_attach (device_t dev) |
static int | xbd_detach (device_t dev) |
static int | xbd_suspend (device_t dev) |
static int | xbd_resume (device_t dev) |
static void | xbd_backend_changed (device_t dev, XenbusState backend_state) |
DRIVER_MODULE (xbd, xenbusb_front, xbd_driver, xbd_devclass, 0, 0) | |
Variables | |
static int | xbd_enable_indirect = 1 |
static device_method_t | xbd_methods [] |
static driver_t | xbd_driver |
devclass_t | xbd_devclass |
#define DPRINTK | ( | fmt, | |
args... | |||
) |
Definition at line 76 of file blkfront.c.
#define XBD_SECTOR_SHFT 9 |
Definition at line 79 of file blkfront.c.
__FBSDID | ( | "$FreeBSD$" | ) |
DRIVER_MODULE | ( | xbd | , |
xenbusb_front | , | ||
xbd_driver | , | ||
xbd_devclass | , | ||
0 | , | ||
0 | |||
) |
|
static |
SYSCTL_INT | ( | _hw_xbd | , |
OID_AUTO | , | ||
xbd_enable_indirect | , | ||
CTLFLAG_RDTUN | , | ||
& | xbd_enable_indirect, | ||
0 | , | ||
"Enable xbd indirect segments" | |||
) |
SYSCTL_NODE | ( | _hw | , |
OID_AUTO | , | ||
xbd | , | ||
CTLFLAG_RD| | CTLFLAG_MPSAFE, | ||
0 | , | ||
"xbd driver parameters" | |||
) |
|
static |
Definition at line 750 of file blkfront.c.
References xbd_softc::xbd_dev, xbd_int(), xbd_softc::xbd_ring, xbd_softc::xbd_ring_pages, xbd_softc::xbd_ring_ref, xbd_softc::xen_intr_handle, and xs_printf().
Referenced by xbd_initialize().
|
static |
Definition at line 1485 of file blkfront.c.
References xbd_softc::xbd_dev, xbd_initqs(), xbd_softc::xbd_io_lock, XBD_MAX_RING_PAGES, xbd_softc::xbd_ring_ref, xbd_setup_sysctl(), xbd_softc::xbd_state, XBD_STATE_DISCONNECTED, xbd_softc::xbd_vdevice, xbd_vdevice_to_unit(), and xs_scanf().
|
static |
Callback received when the backend's state changes.
Definition at line 1591 of file blkfront.c.
References DPRINTK, xbd_closing(), xbd_connect(), xbd_softc::xbd_disk, xbd_initialize(), and xbd_softc::xbd_users.
|
static |
Definition at line 335 of file blkfront.c.
References xbd_command::cm_bp, xbd_command::cm_flags, xbd_command::cm_gref_head, xbd_command::cm_operation, xbd_command::cm_sector_number, gnttab_alloc_grant_references(), gnttab_request_free_callback(), xbd_softc::xbd_callback, xbd_dequeue_bio(), xbd_dequeue_cm(), xbd_enqueue_cm(), xbd_softc::xbd_flags, xbd_freeze(), xbd_softc::xbd_max_request_segments, XBD_Q_BUSY, XBD_Q_FREE, XBD_Q_READY, xbd_queue_length(), xbd_requeue_bio(), xbd_requeue_cm(), xbd_restart_queue_callback(), xbd_softc::xbd_state, XBD_STATE_CONNECTED, XBDCF_Q_FREEZE, XBDF_BARRIER, XBDF_CM_SHORTAGE, XBDF_FLUSH, XBDF_GNT_SHORTAGE, and XBDF_WAIT_IDLE.
Referenced by xbd_startio().
|
static |
Definition at line 460 of file blkfront.c.
References xbd_command::cm_bp, xbd_command::cm_status, and xbd_free_command().
Referenced by xbd_int().
|
static |
Definition at line 687 of file blkfront.c.
References xbd_closing(), xbd_softc::xbd_dev, xbd_softc::xbd_flags, and xbd_softc::xbd_users.
Referenced by xbd_instance_create().
|
static |
Handle the change of state of the backend to Closing. We must delete our device-layer structures now, to ensure that writes are flushed through to the backend. Once this is done, we can switch to Closed in acknowledgement.
Definition at line 1418 of file blkfront.c.
References DPRINTK, and xbd_softc::xbd_disk.
Referenced by xbd_backend_changed(), and xbd_close().
|
static |
Definition at line 116 of file blkfront.c.
References xbd_command::cm_flags, xbd_freeze(), XBDCF_FROZEN, and XBDF_NONE.
Referenced by xbd_queue_request(), and xbd_startio().
|
static |
Definition at line 126 of file blkfront.c.
References xbd_command::cm_flags, xbd_thaw(), XBDCF_FROZEN, and XBDF_NONE.
Referenced by xbd_int().
|
static |
Definition at line 1221 of file blkfront.c.
References xbd_command::cm_flags, xbd_command::cm_id, xbd_command::cm_indirectionpages, xbd_command::cm_indirectionrefs, xbd_command::cm_map, xbd_command::cm_sc, xbd_command::cm_sg_refs, DPRINTK, gnttab_grant_foreign_access(), xbd_softc::xbd_dev, xbd_softc::xbd_disk, xbd_enable_indirect, xbd_softc::xbd_flags, xbd_free_command(), XBD_INDIRECT_SEGS_TO_PAGES, xbd_instance_create(), xbd_softc::xbd_io_dmat, xbd_softc::xbd_io_lock, XBD_MAX_INDIRECT_SEGMENTS, xbd_softc::xbd_max_request_indirectpages, xbd_softc::xbd_max_request_segments, xbd_softc::xbd_max_request_size, xbd_softc::xbd_max_requests, XBD_SEGS_TO_SIZE, xbd_softc::xbd_shadow, XBD_SIZE_TO_SEGS, xbd_startio(), xbd_softc::xbd_state, XBD_STATE_CONNECTED, XBD_STATE_SUSPENDED, xbd_softc::xbd_vdevice, XBDCF_INITIALIZER, XBDF_BARRIER, XBDF_FLUSH, XBDF_READY, and xs_gather().
Referenced by xbd_backend_changed().
|
static |
Definition at line 1529 of file blkfront.c.
References DPRINTK, xbd_free(), and xbd_softc::xbd_io_lock.
|
static |
Definition at line 596 of file blkfront.c.
References xbd_command::cm_complete, xbd_command::cm_data, xbd_command::cm_datalen, xbd_command::cm_gref_head, xbd_command::cm_operation, xbd_command::cm_sector_number, xbd_command::cm_status, gnttab_alloc_grant_references(), xbd_dequeue_cm(), xbd_softc::xbd_dev, xbd_dump_complete(), xbd_enqueue_cm(), xbd_free_command(), xbd_softc::xbd_io_lock, xbd_softc::xbd_max_request_segments, xbd_softc::xbd_max_request_size, XBD_Q_COMPLETE, XBD_Q_FREE, XBD_Q_READY, xbd_quiesce(), and xbd_startio().
Referenced by xbd_instance_create().
|
static |
Definition at line 589 of file blkfront.c.
References xbd_enqueue_cm(), and XBD_Q_COMPLETE.
Referenced by xbd_dump().
|
static |
Definition at line 837 of file blkfront.c.
References xbd_softc::xbd_flags, XBDF_BARRIER, XBDF_DISCARD, XBDF_FLUSH, and XBDF_PERSISTENT.
Referenced by xbd_instance_create(), and xbd_sysctl_features().
|
inlinestatic |
Definition at line 136 of file blkfront.c.
References notify(), xbd_softc::xbd_ring, and xbd_softc::xen_intr_handle.
Referenced by xbd_queue_cb(), and xbd_startio().
|
static |
Definition at line 1047 of file blkfront.c.
References xbd_command::cm_indirectionpages, xbd_command::cm_indirectionrefs, xbd_command::cm_map, xbd_command::cm_sg_refs, gnttab_end_foreign_access_references(), xbd_free_ring(), xbd_initq_cm(), xbd_softc::xbd_io_dmat, xbd_softc::xbd_io_lock, xbd_softc::xbd_max_request_indirectpages, xbd_softc::xbd_max_requests, XBD_Q_COMPLETE, XBD_Q_FREE, XBD_Q_READY, xbd_softc::xbd_shadow, xbd_softc::xbd_state, XBD_STATE_DISCONNECTED, and xbd_softc::xen_intr_handle.
Referenced by xbd_detach(), and xbd_resume().
|
static |
Definition at line 147 of file blkfront.c.
References xbd_command::cm_bp, xbd_command::cm_complete, xbd_command::cm_flags, xbd_command::cm_sc, xbd_enqueue_cm(), XBD_Q_FREE, XBD_Q_NONE, xbd_thaw(), XBDCF_INITIALIZER, XBDCF_Q_MASK, and XBDF_CM_SHORTAGE.
Referenced by xbd_bio_complete(), xbd_connect(), xbd_dump(), xbd_int(), and xbd_queue_cb().
|
static |
Definition at line 818 of file blkfront.c.
References gnttab_end_foreign_access_ref(), xbd_softc::xbd_ring, xbd_softc::xbd_ring_pages, and xbd_softc::xbd_ring_ref.
Referenced by xbd_free().
|
static |
Definition at line 92 of file blkfront.c.
References xbd_softc::xbd_flags, xbd_softc::xbd_qfrozen_cnt, and XBDF_NONE.
Referenced by xbd_bio_command(), and xbd_cm_freeze().
|
static |
Definition at line 1096 of file blkfront.c.
References xbd_alloc_ring(), xbd_softc::xbd_dev, XBD_MAX_REQUESTS, xbd_softc::xbd_max_requests, XBD_MAX_RING_PAGES, xbd_softc::xbd_ring_pages, xbd_softc::xen_intr_handle, xs_printf(), and xs_scanf().
Referenced by xbd_backend_changed(), and xbd_resume().
int xbd_instance_create | ( | struct xbd_softc * | sc, |
blkif_sector_t | sectors, | ||
int | vdevice, | ||
uint16_t | vdisk_info, | ||
unsigned long | sector_size, | ||
unsigned long | phys_sector_size | ||
) |
Definition at line 1000 of file blkfront.c.
References xbd_close(), xbd_softc::xbd_dev, xbd_softc::xbd_disk, xbd_dump(), xbd_feature_string(), xbd_softc::xbd_flags, xbd_ioctl(), xbd_softc::xbd_max_request_size, xbd_open(), xbd_strategy(), xbd_softc::xbd_unit, xbd_vdevice_to_unit(), XBDF_BARRIER, and XBDF_FLUSH.
Referenced by xbd_connect().
|
static |
Definition at line 482 of file blkfront.c.
References xbd_command::cm_bp, xbd_command::cm_complete, xbd_command::cm_map, xbd_command::cm_nseg, xbd_command::cm_operation, xbd_command::cm_sg_refs, xbd_command::cm_status, gnttab_end_foreign_access_references(), xbd_bio_complete(), xbd_softc::xbd_cm_q, xbd_cm_thaw(), xbd_free_command(), xbd_softc::xbd_io_dmat, xbd_softc::xbd_io_lock, XBD_Q_BUSY, xbd_queue_length(), xbd_remove_cm(), xbd_softc::xbd_ring, xbd_softc::xbd_shadow, xbd_startio(), xbd_softc::xbd_state, XBD_STATE_DISCONNECTED, XBD_STATE_SUSPENDED, xbd_thaw(), and XBDF_WAIT_IDLE.
Referenced by xbd_alloc_ring(), and xbd_quiesce().
|
static |
Definition at line 708 of file blkfront.c.
Referenced by xbd_instance_create().
|
static |
Definition at line 162 of file blkfront.c.
References gnttab_claim_grant_reference(), gnttab_grant_foreign_access_ref(), and XBD_SECTOR_SHFT.
Referenced by xbd_queue_cb().
|
static |
Definition at line 672 of file blkfront.c.
References xbd_softc::xbd_flags, xbd_softc::xbd_users, and XBDF_OPEN.
Referenced by xbd_instance_create().
|
static |
Definition at line 1436 of file blkfront.c.
References xs_read().
|
static |
Definition at line 212 of file blkfront.c.
References xbd_command::cm_bp, xbd_command::cm_flags, xbd_command::cm_gref_head, xbd_command::cm_id, xbd_command::cm_indirectionpages, xbd_command::cm_indirectionrefs, xbd_command::cm_map, xbd_command::cm_nseg, xbd_command::cm_operation, xbd_command::cm_sc, xbd_command::cm_sector_number, xbd_command::cm_sg_refs, gnttab_free_grant_references(), xbd_softc::xbd_dev, xbd_softc::xbd_disk, xbd_enqueue_cm(), xbd_flush_requests(), xbd_free_command(), xbd_softc::xbd_io_dmat, xbd_softc::xbd_max_request_indirectpages, xbd_mksegarray(), XBD_Q_BUSY, xbd_softc::xbd_ring, and XBDCF_ASYNC_MAPPING.
Referenced by xbd_queue_request().
|
static |
Definition at line 296 of file blkfront.c.
References xbd_command::cm_bp, xbd_command::cm_data, xbd_command::cm_datalen, xbd_command::cm_map, xbd_cm_freeze(), xbd_softc::xbd_io_dmat, xbd_queue_cb(), and XBDCF_ASYNC_MAPPING.
Referenced by xbd_startio().
|
static |
Quiesce the disk writes for a dump file before allowing the next buffer.
Definition at line 566 of file blkfront.c.
References xbd_int(), XBD_Q_BUSY, xbd_queue_length(), and xbd_softc::xbd_ring.
Referenced by xbd_dump().
|
static |
Definition at line 321 of file blkfront.c.
References xbd_softc::xbd_io_lock, xbd_startio(), xbd_thaw(), and XBDF_GNT_SHORTAGE.
Referenced by xbd_bio_command().
|
static |
Definition at line 1571 of file blkfront.c.
References DPRINTK, xbd_free(), xbd_initialize(), xbd_softc::xbd_state, XBD_STATE_CONNECTED, and xen_suspend_cancelled.
|
static |
Definition at line 894 of file blkfront.c.
References xbd_softc::xbd_dev, xbd_softc::xbd_max_request_segments, xbd_softc::xbd_max_request_size, xbd_softc::xbd_max_requests, xbd_softc::xbd_ring_pages, and xbd_sysctl_features().
Referenced by xbd_attach().
|
static |
Definition at line 418 of file blkfront.c.
References xbd_command::cm_flags, xbd_bio_command(), xbd_cm_freeze(), xbd_dequeue_cm(), xbd_flush_requests(), xbd_softc::xbd_io_lock, XBD_Q_READY, xbd_softc::xbd_qfrozen_cnt, xbd_queue_request(), xbd_softc::xbd_ring, xbd_softc::xbd_state, XBD_STATE_CONNECTED, and XBDCF_Q_FREEZE.
Referenced by xbd_connect(), xbd_dump(), xbd_int(), xbd_restart_queue_callback(), and xbd_strategy().
|
static |
Definition at line 723 of file blkfront.c.
References xbd_enqueue_bio(), xbd_softc::xbd_io_lock, and xbd_startio().
Referenced by xbd_instance_create().
|
static |
Definition at line 1542 of file blkfront.c.
References xbd_softc::xbd_cm_q, xbd_softc::xbd_io_lock, XBD_Q_BUSY, xbd_queue_length(), xbd_softc::xbd_state, and XBD_STATE_SUSPENDED.
|
static |
Definition at line 876 of file blkfront.c.
References xbd_feature_string().
Referenced by xbd_setup_sysctl().
|
static |
Definition at line 102 of file blkfront.c.
References xbd_softc::xbd_flags, xbd_softc::xbd_qfrozen_cnt, and XBDF_NONE.
Referenced by xbd_cm_thaw(), xbd_free_command(), xbd_int(), and xbd_restart_queue_callback().
|
static |
Definition at line 937 of file blkfront.c.
Referenced by xbd_attach(), and xbd_instance_create().
devclass_t xbd_devclass |
Definition at line 1649 of file blkfront.c.
|
static |
Definition at line 1644 of file blkfront.c.
|
static |
Definition at line 84 of file blkfront.c.
Referenced by xbd_connect().
|
static |
Definition at line 1629 of file blkfront.c.