Skip to content

Megasas HBA emulation and SCSI update

Hannes Reinecke qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest16 patches 33 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/16Allow zero alloc_hint in qemu_sglist_init()dma-helpers.c+4 -12 replies
2/16scsi: Increase the number of possible devicesblockdev.h hw/scsi-bus.c hw/scsi.h+4 -31 reply
3/16scsi: Return SAM status codeshw/scsi-defs.h hw/scsi-generic.c+16 -141 reply
4/16scsi: INQUIRY VPD fixeshw/scsi-disk.c+14 -41 reply
5/16scsi: Move sense handling into the driverhw/scsi-bus.c hw/scsi-disk.c hw/scsi.h+25 -261 reply
6/16scsi-disk: Remove duplicate cdb parsinghw/scsi-disk.c+21 -531 reply
7/16scsi: Update sense code handlinghw/scsi-bus.c hw/scsi-disk.c hw/scsi-generic.c +1 more+239 -761 reply
8/16lsi53c895a: Rename 'sense' to 'status'hw/lsi53c895a.c+9 -90 replies
9/16scsi-disk: Allocate iovec dynamicallyhw/scsi-disk.c+70 -425 replies
10/16scsi: Use 'SCSIRequest' directlyhw/esp.c hw/lsi53c895a.c hw/scsi-bus.c +4 more+135 -2344 replies
11/16scsi-disk: add data direction checkinghw/scsi-disk.c+7 -62 replies
12/16scsi-generic: use plain ioctlhw/scsi-generic.c+7 -146 replies
13/16Remove 'bus' argument from SCSI command completion callbackshw/esp.c hw/lsi53c895a.c hw/scsi-bus.c +4 more+15 -201 reply
14/16scsi: Implement 'get_sense' callbackhw/scsi-disk.c hw/scsi-generic.c hw/scsi.h+27 -00 replies
15/16scsi: Implement get_req_iov callbackhw/scsi-disk.c hw/scsi-generic.c hw/scsi.h+57 -141 reply
16/16megasas: LSI Megaraid SAS emulationMakefile.objs hw/megasas.c hw/mfi.h +2 more+3027 -16 replies

Reviews trailers per patch

1 of 16 patches has a Reviewed-by or Acked-by.

PatchChristoph Hellwig
1/16
2/16
3/16
4/16
5/16
6/16R-b
7/16
8/16
9/16
10/16
11/16
12/16
13/16
14/16
15/16
16/16

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [Qemu-devel] [PATCH 00/16] Megasas HBA emulation and SCSI update

Due to popular demand here is now the LSI Megaraid HBA emulation. And an update to the SCSI stack to bring it more in line with modern standards.

For the SCSI update there are three key points:
- Improved sense code handling: the SCSI standard specifies several sense codes to be returned on common errors; we should be following that.
- Reworked SCSI layer: Instead of indirectly addressing a SCSI request by an abstract 'tag' we're now using the request directly, thus saving us a lookup on every invocation.
- Add iovec passing: I've added an interface to pass an iovec to a SCSI request, so that we don't need to use bounce buffers for data transfer. The old interface is left in place.

And, of course, the megasas driver itself.

A quick 'dd' comparison against virtio on a tmpfs backed sparse file shows:

# dd if=/dev/sdb of=/dev/null bs=16M count=1000 iflag=direct
1000+0 records in
1000+0 records out
16777216000 bytes (17 GB) copied, 9.40123 s, 1.8 GB/s
# dd if=/dev/vda of=/dev/null bs=16M count=1000 iflag=direct
1000+0 records in
1000+0 records out
16777216000 bytes (17 GB) copied, 7.44681 s, 2.3 GB/s

So we're having about 80% virtio speed.
Unoptimized :-)

And the patches in detail:

Hannes Reinecke (16):
Allow zero alloc_hint in qemu_sglist_init()
scsi: Increase the number of possible devices
scsi: Return SAM status codes
scsi: INQUIRY VPD fixes
scsi: Move sense handling into the driver
scsi-disk: Remove duplicate cdb parsing
scsi: Update sense code handling
lsi53c895a: Rename 'sense' to 'status'
scsi-disk: Allocate iovec dynamically
scsi: Use 'SCSIRequest' directly
scsi-disk: add data direction checking
scsi-generic: use plain ioctl
Remove 'bus' argument from SCSI command completion callbacks
scsi: Implement 'get_sense' callback
scsi: Implement get_req_iov callback
megasas: LSI Megaraid SAS emulation

 Makefile.objs     |    2 +-
 blockdev.h        |    2 +-
 dma-helpers.c     |    5 +-
 hw/esp.c          |   23 +-
 hw/lsi53c895a.c   |   46 +-
 hw/megasas.c      | 1826 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/mfi.h          | 1197 +++++++++++++++++++++++++++++++++++
 hw/pci_ids.h      |    2 +
 hw/scsi-bus.c     |  120 +++-
 hw/scsi-defs.h    |   20 +-
 hw/scsi-disk.c    |  456 +++++++-------
 hw/scsi-generic.c |  249 ++++----
 hw/scsi.h         |   64 ++-
 hw/usb-msd.c      |   26 +-
 14 files changed, 3599 insertions(+), 439 deletions(-)
 create mode 100644 hw/megasas.c
 create mode 100644 hw/mfi.h