scsi: Add support for LSI SAS1068 (mptsas) device
cover scsi: Add support for LSI SAS1068 (mptsas) device
Compared to previous submissions, more than one target on the same device works across all OSes. I tested Windows 2008, 2012 and 2012r2, as well as RHEL 4-5-6.
Note that for RHEL5 and RHEL6 you need to set up a WWN for the disks. RHEL4 and Windows do not care.
More info in patch commit logs.
Paolo
Paolo Bonzini (3):
scsi: push WWN fields up to SCSIDevice
scsi-generic: grab device and port SAS addresses from backend
scsi: Add support for LSI SAS1068 (mptsas) device
default-configs/pci.mak | 1 + hw/scsi/Makefile.objs | 1 + hw/scsi/mpi.h | 1153 ++++++++++++++++++++++++++++++++++++ hw/scsi/mptconfig.c | 903 +++++++++++++++++++++++++++++ hw/scsi/mptendian.c | 203 +++++++ hw/scsi/mptsas.c | 1443 ++++++++++++++++++++++++++++++++++++++++++++++ hw/scsi/mptsas.h | 100 ++++ hw/scsi/scsi-disk.c | 23 +- hw/scsi/scsi-generic.c | 92 +++ include/hw/pci/pci_ids.h | 1 + include/hw/scsi/scsi.h | 3 + trace-events | 22 + 12 files changed, 3933 insertions(+), 12 deletions(-) create mode 100644 hw/scsi/mpi.h create mode 100644 hw/scsi/mptconfig.c create mode 100644 hw/scsi/mptendian.c create mode 100644 hw/scsi/mptsas.c create mode 100644 hw/scsi/mptsas.h
Signature · 1 line
1.8.3.1
PATCH 1/3 scsi: push WWN fields up to SCSIDevice
SAS adapters need to access them in order to publish the SAS addresses of the end devices connected to them.
--- hw/scsi/scsi-disk.c | 22 ++++++++++------------ include/hw/scsi/scsi.h | 2 ++ 2 files changed, 12 insertions(+), 12 deletions(-)
hw/scsi/scsi-disk.c +10 -12
@@ -76,8 +76,6 @@ struct SCSIDiskStatebool media_changed;bool media_event;bool eject_request; -uint64_t wwn; -uint64_t port_wwn;uint16_t port_index;uint64_t max_unmap_size;uint64_t max_io_size;
@@ -632,21 +630,21 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf)memcpy (outbuf+buflen, str, id_len); buflen += id_len; -if (s->wwn) { +if (s->qdev.wwn) { outbuf[buflen++] =0x1 ;// Binary outbuf[buflen++] =0x3 ;// NAA outbuf[buflen++] =0 ;// reserved outbuf[buflen++] =8 ; -stq_be_p (&outbuf[buflen], s->wwn); +stq_be_p (&outbuf[buflen], s->qdev.wwn); buflen +=8 ; } -if (s->port_wwn) { +if (s->qdev.port_wwn) { outbuf[buflen++] =0x61 ;// SAS / Binary outbuf[buflen++] =0x93 ;// PIV / Target port / NAA outbuf[buflen++] =0 ;// reserved outbuf[buflen++] =8 ; -stq_be_p (&outbuf[buflen], s->port_wwn); +stq_be_p (&outbuf[buflen], s->qdev.port_wwn); buflen +=8 ; }
@@ -2667,8 +2665,8 @@ static Property scsi_hd_properties[] = { SCSI_DISK_F_REMOVABLE, false),DEFINE_PROP_BIT ("dpofua" , SCSIDiskState, features,SCSI_DISK_F_DPOFUA , false), -DEFINE_PROP_UINT64 ("wwn" , SCSIDiskState, wwn,0 ), -DEFINE_PROP_UINT64 ("port_wwn" , SCSIDiskState, port_wwn,0 ), +DEFINE_PROP_UINT64 ("wwn" , SCSIDiskState, qdev.wwn,0 ), +DEFINE_PROP_UINT64 ("port_wwn" , SCSIDiskState, qdev.port_wwn,0 ),DEFINE_PROP_UINT16 ("port_index" , SCSIDiskState, port_index,0 ),DEFINE_PROP_UINT64 ("max_unmap_size" , SCSIDiskState, max_unmap_size, DEFAULT_MAX_UNMAP_SIZE),
@@ -2717,8 +2715,8 @@ static const TypeInfo scsi_hd_info = {static Property scsi_cd_properties[] = {DEFINE_SCSI_DISK_PROPERTIES (), -DEFINE_PROP_UINT64 ("wwn" , SCSIDiskState, wwn,0 ), -DEFINE_PROP_UINT64 ("port_wwn" , SCSIDiskState, port_wwn,0 ), +DEFINE_PROP_UINT64 ("wwn" , SCSIDiskState, qdev.wwn,0 ), +DEFINE_PROP_UINT64 ("port_wwn" , SCSIDiskState, qdev.port_wwn,0 ),DEFINE_PROP_UINT16 ("port_index" , SCSIDiskState, port_index,0 ),DEFINE_PROP_UINT64 ("max_io_size" , SCSIDiskState, max_io_size,DEFAULT_MAX_IO_SIZE ),
@@ -2782,8 +2780,8 @@ static Property scsi_disk_properties[] = { SCSI_DISK_F_REMOVABLE, false),DEFINE_PROP_BIT ("dpofua" , SCSIDiskState, features,SCSI_DISK_F_DPOFUA , false), -DEFINE_PROP_UINT64 ("wwn" , SCSIDiskState, wwn,0 ), -DEFINE_PROP_UINT64 ("port_wwn" , SCSIDiskState, port_wwn,0 ), +DEFINE_PROP_UINT64 ("wwn" , SCSIDiskState, qdev.wwn,0 ), +DEFINE_PROP_UINT64 ("port_wwn" , SCSIDiskState, qdev.port_wwn,0 ),DEFINE_PROP_UINT16 ("port_index" , SCSIDiskState, port_index,0 ),DEFINE_PROP_UINT64 ("max_unmap_size" , SCSIDiskState, max_unmap_size, DEFAULT_MAX_UNMAP_SIZE),
include/hw/scsi/scsi.h +2 -0
@@ -108,6 +108,8 @@ struct SCSIDeviceint blocksize;int type;uint64_t max_lba; +uint64_t wwn; +uint64_t port_wwn; };extern const VMStateDescription vmstate_scsi_device;
Signature · 1 line
1.8.3.1
PATCH 2/3 scsi-generic: grab device and port SAS addresses from backend
In reply to Paolo BonziniThis lets a SAS adapter expose them through its own configuration mechanism.
--- hw/scsi/scsi-disk.c | 1 + hw/scsi/scsi-generic.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/hw/scsi/scsi.h | 1 + 3 files changed, 94 insertions(+)
hw/scsi/scsi-disk.c +1 -0
@@ -2572,6 +2572,7 @@ static void scsi_block_realize(SCSIDevice *dev, Error **errp) s->features |= (1 <<SCSI_DISK_F_NO_REMOVABLE_DEVOPS );scsi_realize (&s->qdev, errp); +scsi_generic_read_device_identification (&s->qdev); }static bool scsi_block_is_passthrough (SCSIDiskState *s,uint8_t *buf)
hw/scsi/scsi-generic.c +92 -0
104 lines not on this page · raw message
include/hw/scsi/scsi.h +1 -0
@@ -273,6 +273,7 @@ void scsi_device_purge_requests(SCSIDevice *sdev, SCSISense sense);void scsi_device_set_ua (SCSIDevice *sdev,SCSISense sense);void scsi_device_report_change (SCSIDevice *dev,SCSISense sense);void scsi_device_unit_attention_reported (SCSIDevice *dev); +void scsi_generic_read_device_identification (SCSIDevice *dev);int scsi_device_get_sense (SCSIDevice *dev,uint8_t *buf,int len,bool fixed);SCSIDevice *scsi_device_find (SCSIBus *bus,int channel,int target,int lun);
Signature · 1 line
2.5.0
Hi Paolo,
Seems patch 2/3 didn't arrive to the mailing list.
Regards,
Shmulik
Quoted 3 lines · Shmulik Ladkani
Hi Paolo,
Seems patch 2/3 didn't arrive to the mailing list.
Sent now, http://permalink.gmane.org/gmane.comp.emulators.qemu/390040
PATCH 1/1 scsi-generic: grab device and port SAS addresses from backend
In reply to Paolo BonziniThis lets a SAS adapter expose them through its own configuration mechanism.
--- hw/scsi/scsi-disk.c | 1 + hw/scsi/scsi-generic.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/hw/scsi/scsi.h | 1 + 3 files changed, 94 insertions(+)
hw/scsi/scsi-disk.c +1 -0
@@ -2572,6 +2572,7 @@ static void scsi_block_realize(SCSIDevice *dev, Error **errp) s->features |= (1 <<SCSI_DISK_F_NO_REMOVABLE_DEVOPS );scsi_realize (&s->qdev, errp); +scsi_generic_read_device_identification (&s->qdev); }static bool scsi_block_is_passthrough (SCSIDiskState *s,uint8_t *buf)
hw/scsi/scsi-generic.c +92 -0
104 lines not on this page · raw message
include/hw/scsi/scsi.h +1 -0
@@ -273,6 +273,7 @@ void scsi_device_purge_requests(SCSIDevice *sdev, SCSISense sense);void scsi_device_set_ua (SCSIDevice *sdev,SCSISense sense);void scsi_device_report_change (SCSIDevice *dev,SCSISense sense);void scsi_device_unit_attention_reported (SCSIDevice *dev); +void scsi_generic_read_device_identification (SCSIDevice *dev);int scsi_device_get_sense (SCSIDevice *dev,uint8_t *buf,int len,bool fixed);SCSIDevice *scsi_device_find (SCSIBus *bus,int channel,int target,int lun);
Signature · 1 line
2.5.0
PATCH 3/3 scsi: Add support for LSI SAS1068 (mptsas) device
In reply to Paolo BonziniThis adds the SAS1068 device, a SAS disk controller used in VMware that is oldish but widely supported and has decent performance. Unlike megasas, it presents itself as a SAS controller and not as a RAID controller. The device corresponds to the mptsas kernel driver in Linux.
A few small things in the device setup are based on Don Slutz's old patch, but the device emulation was written from scratch based on Don's SeaBIOS patch and on the FreeBSD and Linux drivers. It is 2400 lines shorter than Don's patch (and roughly the same size as MegaSAS---also because it doesn't support the similar SPI controller), implements SCSI task management functions (with asynchronous cancellation), supports big-endian hosts, has complete support for migration and follows the QEMU coding standards much more closely.
To write the driver, I first split Don's patch in two parts, with the configuration bits in one file and the rest in a separate file. I first left mptconfig.c in place and rewrote the rest, then deleted mptconfig.c as well. The configuration pages are still based mostly on VirtualBox's, though not exactly the same. However, the implementation is completely different. The contents of the pages themselves should not be copyrightable.
Message-Id: <[email protected]>
--- default-configs/pci.mak | 1 + hw/scsi/Makefile.objs | 1 + hw/scsi/mpi.h | 1153 ++++++++++++++++++++++++++++++++++++ hw/scsi/mptconfig.c | 903 +++++++++++++++++++++++++++++ hw/scsi/mptendian.c | 203 +++++++ hw/scsi/mptsas.c | 1443 ++++++++++++++++++++++++++++++++++++++++++++++ hw/scsi/mptsas.h | 100 ++++ include/hw/pci/pci_ids.h | 1 + trace-events | 22 + 9 files changed, 3827 insertions(+) create mode 100644 hw/scsi/mpi.h create mode 100644 hw/scsi/mptconfig.c create mode 100644 hw/scsi/mptendian.c create mode 100644 hw/scsi/mptsas.c create mode 100644 hw/scsi/mptsas.h
default-configs/pci.mak +1 -0
@@ -15,6 +15,7 @@ CONFIG_ES1370=y CONFIG_LSI_SCSI_PCI=y CONFIG_VMW_PVSCSI_SCSI_PCI=y CONFIG_MEGASAS_SCSI_PCI=y +CONFIG_MPTSAS_SCSI_PCI=y CONFIG_RTL8139_PCI=y CONFIG_E1000_PCI=y CONFIG_VMXNET3_PCI=y
hw/scsi/Makefile.objs +1 -0
@@ -1,6 +1,7 @@ common-obj-y += scsi-disk.o common-obj-y += scsi-generic.o scsi-bus.o common-obj-$(CONFIG_LSI_SCSI_PCI) += lsi53c895a.o +common-obj-$(CONFIG_MPTSAS_SCSI_PCI) += mptsas.o mptconfig.o mptendian.o common-obj-$(CONFIG_MEGASAS_SCSI_PCI) += megasas.o common-obj-$(CONFIG_VMW_PVSCSI_SCSI_PCI) += vmw_pvscsi.o common-obj-$(CONFIG_ESP) += esp.o
hw/scsi/mpi.h new file +1153 -0
1,153 lines not on this page · raw message
hw/scsi/mptconfig.c new file +903 -0
903 lines not on this page · raw message
hw/scsi/mptendian.c new file +203 -0
203 lines not on this page · raw message
hw/scsi/mptsas.c new file +1443 -0
727 lines not on this page · raw message
hw/scsi/mptsas.h new file +100 -0
100 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.8.3.1
Part of the diff is not shown here. View the raw message.