VMWare PVSCSI paravirtual device implementation
v7 cover VMWare PVSCSI paravirtual device implementation
Below is the implementation of VMWare PVSCSI device
PVSCSI implementation is based on Paolo Bonzini code sumbitted some time ago but never applied.
See commit messages and file headers for details.
This patch contains changes made by Deep Debroy, see here:
http://lists.gnu.org/archive/html/qemu-devel/2012-07/msg03585.html
Cc: Deep Debroy <[email protected]>
Implementation supports of all the device features. Code was tested on different OSes:
Fedora 15
Ubuntu 10.4
Centos 6.2
Windows 2008R2
Windows 2008 64bit
Windows 2008 32bit
Windows 2003 64bit
Windows 2003 32bitChanges since V6:
1. Fixes as suggested by Paolo Bonzini
Changes since V5:
1. SCSI hotplug support added
2. Code rebase for mainline
Changes since V4:
Array access checks and minor beautification as suggested by Blue Swirl.
Changes since V3:
1. Utility function strpadcpy() and structure changes in SCSI devices removed from v4 since they are already applied to scsi-next from v3 by Paolo.
2. Logging ported to use tracepoints. All ifdef based custom macros for logging removed.
3. The vmware_utils.h is no longer present with necessary macros inlined.
4. pvscsi.h replaced by vmw_pvscsi.h from linux kernel with some minor modifications to build in qemu.
5. Various fixes and beautification as suggested by Blue Swirl.
Changes since V1:
Various fixes and beautification as suggested by Paolo Bonzini
Dmitry Fleytman (1):
VMWare PVSCSI paravirtual device implementation
default-configs/pci.mak | 1 + docs/specs/pvscsi-spec.txt | 92 ++++ hw/Makefile.objs | 1 + hw/pci/pci.h | 1 + hw/pvscsi.c | 1194 ++++++++++++++++++++++++++++++++++++++++++++ hw/vmw_pvscsi.h | 434 ++++++++++++++++ trace-events | 36 ++ 7 files changed, 1759 insertions(+) create mode 100644 docs/specs/pvscsi-spec.txt create mode 100644 hw/pvscsi.c create mode 100644 hw/vmw_pvscsi.h
Signature · 1 line
1.8.1.4
PATCH v7 1/1 VMWare PVSCSI paravirtual device implementation
--- default-configs/pci.mak | 1 + docs/specs/pvscsi-spec.txt | 92 ++++ hw/scsi/Makefile.objs | 1 + hw/scsi/pvscsi.c | 1210 ++++++++++++++++++++++++++++++++++++++++++++ hw/scsi/vmw_pvscsi.h | 434 ++++++++++++++++ include/hw/pci/pci.h | 1 + trace-events | 35 ++ 7 files changed, 1774 insertions(+) create mode 100644 docs/specs/pvscsi-spec.txt create mode 100644 hw/scsi/pvscsi.c create mode 100644 hw/scsi/vmw_pvscsi.h
default-configs/pci.mak +1 -0
@@ -10,6 +10,7 @@ CONFIG_EEPRO100_PCI=y CONFIG_PCNET_PCI=y CONFIG_PCNET_COMMON=y CONFIG_LSI_SCSI_PCI=y +CONFIG_PVSCSI_SCSI_PCI=y CONFIG_MEGASAS_SCSI_PCI=y CONFIG_RTL8139_PCI=y CONFIG_E1000_PCI=y
docs/specs/pvscsi-spec.txt new file +92 -0
92 lines not on this page · raw message
hw/scsi/Makefile.objs +1 -0
@@ -2,6 +2,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_MEGASAS_SCSI_PCI) += megasas.o +common-obj-$(CONFIG_PVSCSI_SCSI_PCI) += pvscsi.o common-obj-$(CONFIG_ESP) += esp.o common-obj-$(CONFIG_ESP_PCI) += esp-pci.o obj-$(CONFIG_PSERIES) += spapr_vscsi.o
hw/scsi/pvscsi.c new file +1210 -0
1,210 lines not on this page · raw message
hw/scsi/vmw_pvscsi.h new file +434 -0
434 lines not on this page · raw message
include/hw/pci/pci.h +1 -0
@@ -59,6 +59,7 @@#define PCI_DEVICE_ID_VMWARE_SVGA 0x0710#define PCI_DEVICE_ID_VMWARE_NET 0x0720#define PCI_DEVICE_ID_VMWARE_SCSI 0x0730 +#define PCI_DEVICE_ID_VMWARE_PVSCSI 0x07C0#define PCI_DEVICE_ID_VMWARE_IDE 0x1729#define PCI_DEVICE_ID_VMWARE_VMXNET3 0x07B0
trace-events +35 -0
@@ -766,6 +766,41 @@ pc87312_info_ide(uint32_t base) "base 0x%x" pc87312_info_parallel(uint32_t base, uint32_t irq) "base 0x%x, irq %u" pc87312_info_serial(int n, uint32_t base, uint32_t irq) "id=%d, base 0x%x, irq %u" +# hw/pvscsi.c +pvscsi_ring_init_data(uint32_t txr_len_log2, uint32_t rxr_len_log2) "TX/RX rings logarithms set to %d/%d" +pvscsi_ring_init_msg(uint32_t len_log2) "MSG ring logarithm set to %d" +pvscsi_ring_flush_cmp(uint64_t filled_cmp_ptr) "new production counter of completion ring is 0x%"PRIx64"" +pvscsi_ring_flush_msg(uint64_t filled_cmp_ptr) "new production counter of message ring is 0x%"PRIx64"" +pvscsi_update_irq_level(bool raise, uint64_t mask, uint64_t status) "interrupt level set to %d (MASK: 0x%"PRIx64", STATUS: 0x%"PRIx64")" +pvscsi_update_irq_msi(void) "sending MSI notification" +pvscsi_cmp_ring_put(unsigned long addr) "got completion descriptor 0x%lx" +pvscsi_msg_ring_put(unsigned long addr) "got message descriptor 0x%lx" +pvscsi_complete_request(uint64_t context, uint64_t len, uint8_t sense_key) "completion: ctx: 0x%"PRIx64", len: 0x%"PRIx64", sense key: %u" +pvscsi_get_sg_list(int nsg, size_t size) "get SG list: depth: %u, size: %lu" +pvscsi_get_next_sg_elem(uint32_t flags) "unknown flags in SG element (val: 0x%x)" +pvscsi_command_complete_not_found(uint32_t tag) "can't find request for tag 0x%x" +pvscsi_command_complete_data_run(void) "not all data required for command transferred" +pvscsi_command_complete_sense_len(int len) "sense information length is %d bytes" +pvscsi_convert_sglist(uint64_t context, unsigned long addr, uint32_t resid) "element: ctx: 0x%"PRIx64" addr: 0x%lx, len: %ul" +pvscsi_process_req_descr(uint8_t cmd, uint64_t ctx) "SCSI cmd 0x%x, ctx: 0x%"PRIx64"" +pvscsi_process_req_descr_unknown_device(void) "command directed to unknown device rejected" +pvscsi_process_req_descr_invalid_dir(void) "command with invalid transfer direction rejected" +pvscsi_process_io(unsigned long addr) "got descriptor 0x%lx" +pvscsi_on_cmd_noimpl(const char* cmd) "unimplemented command %s ignored" +pvscsi_on_cmd_reset_dev(uint32_t tgt, int lun, void* dev) "PVSCSI_CMD_RESET_DEVICE[target %u lun %d (dev 0x%p)]" +pvscsi_on_cmd_arrived(const char* cmd) "command %s arrived" +pvscsi_on_cmd_abort(uint64_t ctx, uint32_t tgt) "command PVSCSI_CMD_ABORT_CMD for ctx 0x%"PRIx64", target %u" +pvscsi_on_cmd_unknown(uint64_t cmd_id) "unknown command %"PRIx64"" +pvscsi_on_cmd_unknown_data(uint32_t data) "data for unknown command 0x:%x" +pvscsi_io_write(const char* cmd, uint64_t val) "%s write: %"PRIx64"" +pvscsi_io_write_unknown(unsigned long addr, unsigned sz, uint64_t val) "unknown write address: 0x%lx size: %u bytes value: 0x%"PRIx64"" +pvscsi_io_read(const char* cmd, uint64_t status) "%s read: 0x%"PRIx64"" +pvscsi_io_read_unknown(unsigned long addr, unsigned sz) "unknown read address: 0x%lx size: %u bytes" +pvscsi_init_msi_fail(int res) "failed to initialize MSI, error %d" +pvscsi_state(const char* state) "starting %s ..." +pvscsi_tx_rings_ppn(const char* label, uint64_t ppn) "%s page: %"PRIx64"" +pvscsi_tx_rings_num_pages(const char* label, uint32_t num) "Number of %s pages: %u" + # xen-all.c xen_ram_alloc(unsigned long ram_addr, unsigned long size) "requested: %#lx, size %#lx" xen_client_set_memory(uint64_t start_addr, unsigned long size, bool log_dirty) "%#"PRIx64" size %#lx, log_dirty %i"
Signature · 1 line
1.8.1.4
Il 19/04/2013 09:05, Dmitry Fleytman ha scritto:
hw/scsi/pvscsi.c line 545
Quoted 3 lines
hw/scsi/pvscsi.c new file +3
-0+if (pvscsi_req->dev->resetting) { + pvscsi_req->cmp.hostStatus =BTSTAT_BUSRESET ; + }
I'm changing this to
if (pvscsi_req->cmp.hostStatus == BTSTAT_SUCCESS) {
if (pvscsi_req->dev->resetting) {
pvscsi_req->cmp.hostStatus = BTSTAT_BUSRESET;
} else {
pvscsi_req->cmp.hostStatus = BTSTAT_ABORTQUEUE;
}
}Otherwise it's okay.
Thanks!
Paolo
Paolo, thanks for review.
Regarding the change - it's ok with me, but why do one needs this? I think we always set proper status before request cancellation.
May QEMU call cancel callback on its own?
Dmitry.
Quoted 21 lines · Paolo Bonzini
Il 19/04/2013 09:05, Dmitry Fleytman ha scritto:
hw/scsi/pvscsi.c line 545
Quoted 3 lines
hw/scsi/pvscsi.c new file +3
-0+if (pvscsi_req->dev->resetting) { + pvscsi_req->cmp.hostStatus =BTSTAT_BUSRESET ; + }I'm changing this to
if (pvscsi_req->cmp.hostStatus == BTSTAT_SUCCESS) { if (pvscsi_req->dev->resetting) { pvscsi_req->cmp.hostStatus = BTSTAT_BUSRESET; } else { pvscsi_req->cmp.hostStatus = BTSTAT_ABORTQUEUE; } }Otherwise it's okay.
Thanks!
Paolo
Il 19/04/2013 09:53, Dmitry Fleytman ha scritto:
Quoted 5 lines
Paolo, thanks for review.
Regarding the change - it's ok with me, but why do one needs this? I think we always set proper status before request cancellation. May QEMU call cancel callback on its own?
The cancel callback should not be run if the command is completed (what happens is that scsi_req_cancel will call _either_ the complete callback or the cancel callback). However, we had bugs in the past on this and I'm not sure all of them have been stomped.
The outer "if" statement is the equivalent of this in virtio-scsi.c
if (!req) {
return;
}
if (req->dev->resetting) {
...
}So it may even be better if I follow the scheme in virtio-scsi.c and do this:
if (r->completed) {
return;
} if (pvscsi_req->dev->resetting) {
pvscsi_req->cmp.hostStatus = BTSTAT_BUSRESET;
} else {
pvscsi_req->cmp.hostStatus = BTSTAT_ABORTQUEUE;
}pvscsi_complete_request(s, pvscsi_req);
Paolo
I see.
Thanks.
Quoted 39 lines · Paolo Bonzini
Il 19/04/2013 09:53, Dmitry Fleytman ha scritto:
Quoted 5 lines
Paolo, thanks for review.
Regarding the change - it's ok with me, but why do one needs this? I think we always set proper status before request cancellation. May QEMU call cancel callback on its own?
The cancel callback should not be run if the command is completed (what happens is that
scsi_req_cancelwill call _either_ the complete callback or the cancel callback). However, we had bugs in the past on this and I'm not sure all of them have been stomped.The outer "if" statement is the equivalent of this in
virtio-scsi.cif (!req) { return; } if (req->dev->resetting) { ... }So it may even be better if I follow the scheme in
virtio-scsi.cand do this:if (r->completed) { return; }if (pvscsi_req->dev->resetting) { pvscsi_req->cmp.hostStatus = BTSTAT_BUSRESET; } else { pvscsi_req->cmp.hostStatus = BTSTAT_ABORTQUEUE; }pvscsi_complete_request(s, pvscsi_req);Paolo