megasas: LSI Megaraid SAS emulation
PATCH v7 1/1 megasas: LSI Megaraid SAS emulation
This patch adds an emulation for the LSI Megaraid SAS 8708EM2 HBA. It is based off the 'block' tree from Kevin Wolf, as he pulled in the preliminary patches.
I've tested it to work with Linux, Windows Vista, and Windows7.
Changes since v6:
- Preliminary patches pushed to Kevins block tree
- Implement 64bit contexts, required for Windows7
- Use iovecs for DCMD processing
- Add MSI-X support
Latest Linux driver now happily uses MSI-X.
- Static iovec allocation
We have a fixed upper number of iovecs, so we can save us the allocation. Suggested by Alex Graf.
- Update MFI header
Latest Linux driver has some more definitions, add them
- Fixup AEN handling
- Update tracing details
- Remove sdev pointer from megasas_cmd_t
Changes since v5:
- megasas: Use tracing infrastructure instead of DPRINTF
- megasas: Use new PCI infrastructure
- megasas: Check for iovec mapping failure cpu_map_physical_memory() might fail, so we need to check for it when mapping iovecs.
- megasas: Trace scsi buffer overflow
The transfer length as specified in the SCSI command might disagree with the length of the iovec. We should be tracing these issues.
- megasas: Reset frames after init firmware
When receiving an INIT FIRMWARE command we need reset all frames, otherwise some frames might point to invalid memory.
Chances since v4:
- megasas: checkpatch.pl fixes and update to work with the changed interface in scsi_req_new(). Also included the suggested fixes from Alex.
--- Makefile.objs | 1 + default-configs/pci.mak | 1 + hw/megasas.c | 2183 +++++++++++++++++++++++++++++++++++++++++++++++ hw/mfi.h | 1281 +++++++++++++++++++++++++++ hw/pci_ids.h | 3 +- trace-events | 71 ++ 6 files changed, 3539 insertions(+), 1 deletions(-) create mode 100644 hw/megasas.c create mode 100644 hw/mfi.h
Makefile.objs +1 -0
@@ -258,6 +258,7 @@ hw-obj-$(CONFIG_AHCI) += ide/ich.o # SCSI layer hw-obj-$(CONFIG_LSI_SCSI_PCI) += lsi53c895a.o +hw-obj-$(CONFIG_MEGASAS_SCSI_PCI) += megasas.o hw-obj-$(CONFIG_ESP) += esp.o hw-obj-y += dma-helpers.o sysbus.o isa-bus.o
default-configs/pci.mak +1 -0
@@ -9,6 +9,7 @@ CONFIG_EEPRO100_PCI=y CONFIG_PCNET_PCI=y CONFIG_PCNET_COMMON=y CONFIG_LSI_SCSI_PCI=y +CONFIG_MEGASAS_SCSI_PCI=y CONFIG_RTL8139_PCI=y CONFIG_E1000_PCI=y CONFIG_IDE_CORE=y
hw/megasas.c new file +2183 -0
2,183 lines not on this page · raw message
hw/mfi.h new file +1281 -0
803 lines not on this page · raw message
trace-events +71 -0
71 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.3.4
Part of the diff is not shown here. View the raw message.
I've mentioned this a few times before, but just to make sure it's not lost:
This is a really bad idea for adding to qemu. It's not a controller that actually speaks a plain SCSI protocol to disks, but a RAID controller, that has it's own command set for data plan operation, and minimal support for a few SCSI CDBs around it. I also supports passthrough channels for CDROMs and other periphals, but using those with disks is not recommended by LSI, thus explicitly disabled in most drivers and most certainly not tested. So it fits the qemu model, especially if using scsi-generic undeneath pretty badly and I don't think it helps us in practice.
Quoted 11 lines · Christoph Hellwig
I've mentioned this a few times before, but just to make sure it's not lost:
This is a really bad idea for adding to qemu. It's not a controller that actually speaks a plain SCSI protocol to disks, but a RAID controller, that has it's own command set for data plan operation, and minimal support for a few SCSI CDBs around it. I also supports passthrough channels for CDROMs and other periphals, but using those with disks is not recommended by LSI, thus explicitly disabled in most drivers and most certainly not tested. So it fits the qemu model, especially if using scsi-generic undeneath pretty badly and I don't think it helps us in practice.
I don't understand where your reluctance comes from. Conceptually, it's basically the same as having a virtio-blk driver also exporting a scsi interface, which is the perfect case wrt performance.
So worst case what do we get? Worst case we get a working block adapter that can handle disk I/O pretty straight forward and is comparable to AHCI. Best case, we can also use SGIO on top of it. Either way, we get something that's a lot faster than the current LSI parallel SCSI adapter and also calls itself "SCSI", thus has drivers for a good bunch of OSs.
I don't see how anything would go against this adapter - we really have nothing to lose. If you want to sit down and write an emulation layer for an even better (recent) SCSI HBA, please, go ahead and do so. This one is the best SCSI adapter we'd have in Qemu at the time of its commit though and can at least help us straighten out our internal APIs.
Alex
Quoted 12 lines · Christoph Hellwig
I've mentioned this a few times before, but just to make sure it's not lost:
This is a really bad idea for adding to qemu. It's not a controller that actually speaks a plain SCSI protocol to disks, but a RAID controller, that has it's own command set for data plan operation, and minimal support for a few SCSI CDBs around it. I also supports passthrough channels for CDROMs and other periphals, but using those with disks is not recommended by LSI, thus explicitly disabled in most drivers and most certainly not tested. So it fits the qemu model, especially if using scsi-generic undeneath pretty badly and I don't think it helps us in practice.
Hmm. This driver emulates an existing piece of hardware.
If the OS driver has shortcomings, okay, so be it.
But are there any rules which devices might be emulated and which shouldn't?
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
Quoted 4 lines · Hannes Reinecke
This patch adds an emulation for the LSI Megaraid SAS 8708EM2 HBA. It is based off the 'block' tree from Kevin Wolf, as he pulled in the preliminary patches.
I've tested it to work with Linux, Windows Vista, and Windows7.
Why hasn't this patch already been commited?
(for me looking at mailing list archive it looks like for "academic" reasons. I think we should have a more pragmatic approach a mark it e.g. as linux kernel as experimental that more users can test it).
Ciao,
Gerhard
Am 08.01.2012 22:56, schrieb Gerhard Wiesinger:
Quoted 7 lines · Hannes Reinecke
Quoted 4 lines
This patch adds an emulation for the LSI Megaraid SAS 8708EM2 HBA. It is based off the 'block' tree from Kevin Wolf, as he pulled in the preliminary patches.
I've tested it to work with Linux, Windows Vista, and Windows7.Why hasn't this patch already been commited?
It needs to be rebased, and there have been more urgent priorities. It's definitely not forgotten at SUSE.
http://lists.gnu.org/archive/html/qemu-devel/2011-11/msg00403.html
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg