scsi-bsg: Add initial support for BSG based SCSIDeviceInfo
PATCH 5/5 scsi-bsg: Add initial support for BSG based SCSIDeviceInfo
From: Nicholas Bellinger <[email protected]>
This patch adds initial support for using the Linux BSG interface with write/read vectored AIO as a QEMU backstore (SCSIDeviceInfo) with hw/scsi-bus.c compatible HBA emulation.
So far it has been tested with x86_64 host and guest using hw/megasas.c and TCM_Loop LLD Port LUNs. Because this patch uses struct iovec for struct sg_io_v4->d[out,in]_xferp payloads, which currently requires a patch to linux/block/bsg.c:bsg_map_hdr() in order to setup the
user -> kernel iovecs. This patch can be found in lio-core-2.6.git here:
commit fec4e8457c744de50e1ead69a36d5c4ee089d1ac
Author: Nicholas Bellinger <[email protected]> Date: Sun Jun 13 23:13:20 2010 -0700
[BSG]: Add support for struct sg_io_v4->d[out,in]_iovec_count
This also will only currently work with paired user/kernel (eg: 64bit user / 64bit kernel) because of different pointer sizes in struct iovec->iov_base.
There are also two FIXMEs in hw/scsi-bsg.c:bsg_generic_initfn() related to extraction of SCSI LUN and device type values using BSG and required by QEMU-KVM.
--- Makefile.objs | 2 +- hw/scsi-bsg.c | 720 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 721 insertions(+), 1 deletions(-) create mode 100644 hw/scsi-bsg.c
Makefile.objs +1 -1
@@ -79,7 +79,7 @@ common-obj-$(CONFIG_DS1338) += ds1338.o common-obj-y += i2c.o smbus.o smbus_eeprom.o common-obj-y += eeprom93xx.o common-obj-y += scsi-disk.o cdrom.o -common-obj-y += scsi-generic.o scsi-bus.o +common-obj-y += scsi-generic.o scsi-bsg.o scsi-bus.o common-obj-y += usb.o usb-hub.o usb-$(HOST_USB).o usb-hid.o usb-msd.o usb-wacom.o common-obj-y += usb-serial.o usb-net.o usb-bus.o common-obj-$(CONFIG_SSI) += ssi.o
hw/scsi-bsg.c new file +720 -0
720 lines not on this page · raw message
Signature · 1 line
1.5.6.5
Quoted 14 lines · Nicholas A. Bellinger
From: Nicholas Bellinger<[email protected]>
This patch adds initial support for using the Linux BSG interface with write/read vectored AIO as a QEMU backstore (SCSIDeviceInfo) with
hw/scsi-bus.ccompatible HBA emulation.So far it has been tested with
x86_64host and guest usinghw/megasas.candTCM_LoopLLD Port LUNs. Because this patch uses struct iovec for struct sg_io_v4->d[out,in]_xferp payloads, which currently requires a patch to linux/block/bsg.c:bsg_map_hdr() in order to setup the
user -> kernel iovecs. This patch can be found in lio-core-2.6.git here:commit
fec4e8457c744de50e1ead69a36d5c4ee089d1acAuthor: Nicholas Bellinger<[email protected]> Date: Sun Jun 13 23:13:20 2010 -0700
Quoted 7 lines
[BSG]: Add support for struct sg_io_v4->d[out,in]_iovec_countThis also will only currently work with paired user/kernel (eg: 64bit user / 64bit kernel) because of different pointer sizes in struct
iovec->iov_base.There are also two FIXMEs in hw/scsi-bsg.c:bsg_generic_initfn() related to extraction of SCSI LUN and device type values using BSG and required by QEMU-KVM.
Any reason why this should be a different driver than scsi-generic, i.e. why the scsi-generic should not switch automatically between SG and BSG depending on the kind of device being opened?
In fact, there is no reason why scsi-generic should use bounce buffers rather than sg_iovec_t, so that most of the differences between scsi-generic and scsi-bsg would go away.
Paolo
Quoted 23 lines · Paolo Bonzini
Quoted 14 lines · Nicholas A. Bellinger
From: Nicholas Bellinger<[email protected]>
This patch adds initial support for using the Linux BSG interface with write/read vectored AIO as a QEMU backstore (SCSIDeviceInfo) with
hw/scsi-bus.ccompatible HBA emulation.So far it has been tested with
x86_64host and guest usinghw/megasas.candTCM_LoopLLD Port LUNs. Because this patch uses struct iovec for struct sg_io_v4->d[out,in]_xferp payloads, which currently requires a patch to linux/block/bsg.c:bsg_map_hdr() in order to setup the
user -> kernel iovecs. This patch can be found in lio-core-2.6.git here:commit
fec4e8457c744de50e1ead69a36d5c4ee089d1acAuthor: Nicholas Bellinger<[email protected]> Date: Sun Jun 13 23:13:20 2010 -0700Quoted 7 lines
[BSG]: Add support for struct sg_io_v4->d[out,in]_iovec_countThis also will only currently work with paired user/kernel (eg: 64bit user / 64bit kernel) because of different pointer sizes in struct
iovec->iov_base.There are also two FIXMEs in hw/scsi-bsg.c:bsg_generic_initfn() related to extraction of SCSI LUN and device type values using BSG and required by QEMU-KVM.
Quoted 8 lines
Any reason why this should be a different driver than scsi-generic, i.e. why the scsi-generic should not switch automatically between SG and BSG depending on the kind of device being opened?
In fact, there is no reason why scsi-generic should use bounce buffers rather than
sg_iovec_t, so that most of the differences between scsi-generic and scsi-bsg would go away.
Originally I split these up into a seperate scsi-bsg.c file because:
*) BSG uses aio_submit_len() and polling reads for interaction with the BSG ioctl.
*) BSG uses a different struct API (struct sg_io_v4) for user <-> kernel communication.
Between hw/scsi-generic.c with Hannes's and Co's recent cleanups scsi-generic.c and scsi-bsg.c are more similar than they used to be in v0.12.5 w/ v1 of Gerd's SCSI SGL passthrough, but I really don't have a strong perference here.
Thanks!
--nab