megasas: LSI MegaRAID SAS HBA emulation
PATCH 1/1 megasas: LSI MegaRAID SAS HBA emulation
This patch adds an emulation for the LSI MegaRAID SAS HBA. It is build on top of kraxel's scsi.v7 tree.
This is just a rough implementation, many of the more advanced topics (like Windows booting :-) are missing.
--
Makefile.hw +1 -1
@@ -33,7 +33,7 @@ obj-y += ne2000.o # SCSI layer obj-y += scsi-disk.o scsi-generic.o -obj-y += lsi53c895a.o +obj-y += lsi53c895a.o megasas.o obj-$(CONFIG_ESP) += esp.o obj-y += dma-helpers.o sysbus.o isa-bus.o
hw/megasas.c new file +1184 -0
1,184 lines not on this page · raw message
hw/pci_ids.h +2 -0
@@ -15,6 +15,7 @@#define PCI_CLASS_STORAGE_SCSI 0x0100#define PCI_CLASS_STORAGE_IDE 0x0101 +#define PCI_CLASS_STORAGE_RAID 0x0104#define PCI_CLASS_STORAGE_OTHER 0x0180#define PCI_CLASS_NETWORK_ETHERNET 0x0200
@@ -46,6 +47,7 @@#define PCI_VENDOR_ID_LSI_LOGIC 0x1000#define PCI_DEVICE_ID_LSI_53C895A 0x0012 +#define PCI_DEVICE_ID_LSI_SAS1078 0x0060#define PCI_VENDOR_ID_DEC 0x1011#define PCI_DEVICE_ID_DEC_21154 0x0026
Quoted 8 lines · Hannes Reinecke
This patch adds an emulation for the LSI MegaRAID SAS HBA. It is build on top of kraxel's scsi.v7 tree.
This is just a rough implementation, many of the more advanced topics (like Windows booting :-) are missing.
Signed-off-by Hannes Reinecke<[email protected]>
Added, will be in scsi.v8. Needs a patch after rebasing due to pci changes (attached fyi).
cheers,
Gerd
Quoted 1 line
From
ae3c2b55f84f9b12551369b21fd7b89d84ddfff6Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <[email protected]>
Date: Mon, 16 Nov 2009 23:12:53 +0100
Subject: [PATCH] megasas: adapt to pci changes.
--- hw/megasas.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
hw/megasas.c +6 -6
@@ -1034,7 +1034,7 @@ static void megasas_soft_reset(MPTState *s) }static void megasas_mmio_mapfunc (PCIDevice *pci_dev,int region_num, -uint32_t addr,uint32_t size,int type) +pcibus_t addr,pcibus_t size,int type) {MPTState *s =DO_UPCAST (MPTState, dev, pci_dev);
@@ -1043,7 +1043,7 @@ static void megasas_mmio_mapfunc(PCIDevice *pci_dev, int region_num, }static void megasas_io_mapfunc (PCIDevice *pci_dev,int region_num, -uint32_t addr,uint32_t size,int type) +pcibus_t addr,pcibus_t size,int type) {MPTState *s =DO_UPCAST (MPTState, dev, pci_dev);
@@ -1058,7 +1058,7 @@ static void megasas_io_mapfunc(PCIDevice *pci_dev, int region_num, }static void megasas_queue_mapfunc (PCIDevice *pci_dev,int region_num, -uint32_t addr,uint32_t size,int type) +pcibus_t addr,pcibus_t size,int type) {MPTState *s =DO_UPCAST (MPTState, dev, pci_dev);
@@ -1140,11 +1140,11 @@ static int megasas_scsi_init(PCIDevice *dev) s->queue_addr =cpu_register_io_memory (megasas_queue_readfn, megasas_queue_writefn, s);pci_register_bar ((struct PCIDevice *)s,0 ,0x40000 , -PCI_ADDRESS_SPACE_MEM , megasas_mmio_mapfunc); +PCI_BASE_ADDRESS_SPACE_MEMORY , megasas_mmio_mapfunc);pci_register_bar ((struct PCIDevice *)s,2 ,256 , -PCI_ADDRESS_SPACE_IO , megasas_io_mapfunc); +PCI_BASE_ADDRESS_SPACE_IO , megasas_io_mapfunc);pci_register_bar ((struct PCIDevice *)s,3 ,0x40000 , -PCI_ADDRESS_SPACE_MEM , megasas_queue_mapfunc); +PCI_BASE_ADDRESS_SPACE_MEMORY , megasas_queue_mapfunc); s->fw_sge =MEGASAS_MAX_SGE ; s->fw_cmds =MEGASAS_MAX_FRAMES ; s->fw_luns = (MEGASAS_MAX_LUNS > MAX_SCSI_DEVS) ?
Signature · 1 line
1.6.2.5
Quoted 5 lines · Gerd Hoffmann
Quoted 4 lines · Hannes Reinecke
This patch adds an emulation for the LSI MegaRAID SAS HBA. It is build on top of kraxel's scsi.v7 tree.
Quoted 8 lines
Quoted 4 lines
This is just a rough implementation, many of the more advanced topics (like Windows booting :-) are missing.
Signed-off-by Hannes Reinecke<[email protected]>Added, will be in scsi.v8. Needs a patch after rebasing due to pci changes (attached fyi).
Grand. Meanwhile I've dug up some more register definitions, so I'll doing some more updates to the driver.
Thanks for including it.
Meanwhile I've stumbled across another issue:
The megasas HBA insists on returning some data like inquiry or VPD pages during init/configuration.
I can't really use the normal command completion here, as eg on megasas configuration command requires me to issue several requests to the underlying device.
So what to do?
Easiest would it to have a non-completion interface, like req_buf() but without the callback bit. But really don't know if that's best.
We could also attach the inquiry data and vpd 0x83 as a property to the device; might be easier as we don't have to add another interface.
But the properties stuff is a bit beyond me currently.
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: Markus Rex, HRB 16746 (AG Nürnberg)
Quoted 2 lines · Hannes Reinecke
Grand. Meanwhile I've dug up some more register definitions, so I'll doing some more updates to the driver.
Feel free to send updates (both incremental and replacement are fine).
Quoted 7 lines
Meanwhile I've stumbled across another issue:
The megasas HBA insists on returning some data like inquiry or VPD pages during init/configuration.I can't really use the normal command completion here, as eg on megasas configuration command requires me to issue several requests to the underlying device.
Well, you can, but it probably isn't very convenient ...
Easy way out would be calling qemu_aio_wait(), when it returns you can be sure the request is finished (and the completion callback was called). You probably have to flag the request as being special somewhere in req->hba_private so your completion callback will not apply the usual processing.
Calling qemu_aio_wait() is only needed if there is actually something in flight asynchronously. req->status is initialized to -1 and set to a status code on completion, so you can use that to figure whenever the request is still being processed. All commands emulated by scsi-disk will complete instantly, i.e. the completion callback will be called before scsi_req_{buf,sgl} returns. Only with scsi-generic you'll find INQUIRY being processed really asynchronously.
cheers,
Gerd