[Qemu-devel] status of pvscsi patches
Hi, I was wondering what would be the steps necessary to get the patches for vmware's pvscsi implementation submitted by Dmitry Fleytman on 18th March, 2012 applied to qemu? Here's a link to the intro to the patchset I am referring to: http://lists.gnu.org/archive/html/qemu-devel/2012-03/msg03438.html. I recently applied the patches to the qemu code base and tested with a linux guest (using a raw file-backed image) on both kvm and xen and it seems to be working well: lspci reported the pvscsi controller, the file-backed disk image attached to the controller was reported by fdisk and I could create partitions, mount a file system and perform IO on it. Thanks, Deep P.s. I just joined qemu-devel. So I do not have the original email thread for pvscsi in my inbox that I could directly respond to. Hence starting a new thread.
[Qemu-devel] [PATCH 0/4 V3] VMWare PVSCSI paravirtual device implementation
Below is a re-submission of VMWare PVSCSI device implementation patches (earlier submitted by Dmitry Fleytman) so that it gets applied to the qemu master. Details from Dmitry's earlier submission can be found at: http://lists.gnu.org/archive/html/qemu-devel/2012-03/msg03438.html New changes since V2: 1. Application of the earlier set of patches to the latest qemu master 2. Minor addition of a NULL parameter in the call to qemu_sglist_init Beyond prior testing, latest patch-set was tested with Ubuntu linux guests with vmw_pvscsi driver on kvm as well as xen. Deep Debroy (4): Utility function strpadcpy() added Vendor name and product name parameters for SCSI devices Options vendor_name and product_nameadded for SCSI disks. Header with various utility functions shared by VMWARE SCSI and network devices PVCSI paravirtualized device implementation cutils.c |7 + default-configs/pci.mak|1 + docs/specs/pvscsi-spec.txt | 92 hw/Makefile.objs |1 + hw/pci.h |1 + hw/pvscsi.c| 1260 hw/pvscsi.h| 442 hw/scsi-disk.c | 31 +- hw/vmware_utils.h | 126 + qemu-common.h |1 + 10 files changed, 1954 insertions(+), 8 deletions(-) create mode 100644 docs/specs/pvscsi-spec.txt create mode 100644 hw/pvscsi.c create mode 100644 hw/pvscsi.h create mode 100644 hw/vmware_utils.h -- 1.7.9.5
[Qemu-devel] [PATCH 1/4 V3] Utility function strpadcpy() added
Signed-off-by: Deep Debroy --- cutils.c |7 +++ qemu-common.h |1 + 2 files changed, 8 insertions(+) diff --git a/cutils.c b/cutils.c index af308cd..68a7d10 100644 --- a/cutils.c +++ b/cutils.c @@ -27,6 +27,13 @@ #include "qemu_socket.h" +void strpadcpy(char *buf, int buf_size, const char *str, char pad) +{ +int len = qemu_strnlen(str, buf_size); +memcpy(buf, str, len); +memset(buf + len, pad, buf_size - len); +} + void pstrcpy(char *buf, int buf_size, const char *str) { int c; diff --git a/qemu-common.h b/qemu-common.h index 9d9e603..1d8a514 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -137,6 +137,7 @@ int qemu_timedate_diff(struct tm *tm); /* cutils.c */ void pstrcpy(char *buf, int buf_size, const char *str); +void strpadcpy(char *buf, int buf_size, const char *str, char pad); char *pstrcat(char *buf, int buf_size, const char *s); int strstart(const char *str, const char *val, const char **ptr); int stristart(const char *str, const char *val, const char **ptr); -- 1.7.9.5
[Qemu-devel] [PATCH 2/4] Vendor name and product name parameters for SCSI devices
Options vendor_name and product_nameadded for SCSI disks. Signed-off-by: Deep Debroy --- hw/scsi-disk.c | 31 +++ 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index ae25194..a774c3c 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -70,6 +70,8 @@ struct SCSIDiskState QEMUBH *bh; char *version; char *serial; +char *vname; +char *pname; bool tray_open; bool tray_locked; }; @@ -660,12 +662,22 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf) outbuf[0] = s->qdev.type & 0x1f; outbuf[1] = (s->features & (1 << SCSI_DISK_F_REMOVABLE)) ? 0x80 : 0; -if (s->qdev.type == TYPE_ROM) { -memcpy(&outbuf[16], "QEMU CD-ROM ", 16); + +if (NULL != s->pname) { +strpadcpy((char *) &outbuf[16], 16, s->pname, ' '); +} else { +if (s->qdev.type == TYPE_ROM) { +memcpy(&outbuf[16], "QEMU CD-ROM ", 16); +} else { +memcpy(&outbuf[16], "QEMU HARDDISK ", 16); +} +} +if (NULL != s->vname) { +strpadcpy((char *) &outbuf[8], 8, s->vname, ' '); } else { -memcpy(&outbuf[16], "QEMU HARDDISK ", 16); +memcpy(&outbuf[8], "QEMU", 8); } -memcpy(&outbuf[8], "QEMU", 8); + memset(&outbuf[32], 0, 4); memcpy(&outbuf[32], s->version, MIN(4, strlen(s->version))); /* @@ -1914,10 +1926,13 @@ static SCSIRequest *scsi_block_new_request(SCSIDevice *d, uint32_t tag, } #endif -#define DEFINE_SCSI_DISK_PROPERTIES() \ -DEFINE_BLOCK_PROPERTIES(SCSIDiskState, qdev.conf), \ -DEFINE_PROP_STRING("ver", SCSIDiskState, version), \ -DEFINE_PROP_STRING("serial", SCSIDiskState, serial) +#define DEFINE_SCSI_DISK_PROPERTIES() \ +DEFINE_BLOCK_PROPERTIES(SCSIDiskState, qdev.conf),\ +DEFINE_PROP_STRING("ver", SCSIDiskState, version), \ +DEFINE_PROP_STRING("serial", SCSIDiskState, serial), \ +DEFINE_PROP_STRING("vendor_name", SCSIDiskState, vname), \ +DEFINE_PROP_STRING("product_name", SCSIDiskState, pname) + static Property scsi_hd_properties[] = { DEFINE_SCSI_DISK_PROPERTIES(), -- 1.7.9.5
[Qemu-devel] [PATCH 3/4 V3] Header with various utility functions shared
Signed-off-by: Deep Debroy --- hw/vmware_utils.h | 126 + 1 file changed, 126 insertions(+) create mode 100644 hw/vmware_utils.h diff --git a/hw/vmware_utils.h b/hw/vmware_utils.h new file mode 100644 index 000..73b039e --- /dev/null +++ b/hw/vmware_utils.h @@ -0,0 +1,126 @@ +/* + * QEMU VMWARE paravirtual devices - auxiliary code + * + * Copyright (c) 2012 Ravello Systems LTD (http://ravellosystems.com) + * + * Developed by Daynix Computing LTD (http://www.daynix.com) + * + * Authors: + * Dmitry Fleytman + * Yan Vugenfirer + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef VMWARE_UTILS_H +#define VMWARE_UTILS_H + +#ifndef DSHPRINTF +#define DSHPRINTF(fmt, ...) do {} while (0) +#endif + +/* Shared memory access functions with byte swap support */ +static inline void +vmw_shmem_read(target_phys_addr_t addr, void *buf, int len) +{ +DSHPRINTF("SHMEM r: %" PRIx64 ", len: %d to %p", addr, len, buf); +cpu_physical_memory_read(addr, buf, len); +} + +static inline void +vmw_shmem_write(target_phys_addr_t addr, void *buf, int len) +{ +DSHPRINTF("SHMEM w: %" PRIx64 ", len: %d to %p", addr, len, buf); +cpu_physical_memory_write(addr, buf, len); +} + +static inline void +vmw_shmem_rw(target_phys_addr_t addr, void *buf, int len, int is_write) +{ +DSHPRINTF("SHMEM r/w: %" PRIx64 ", len: %d (to %p), is write: %d", + addr, len, buf, is_write); + +cpu_physical_memory_rw(addr, buf, len, is_write); +} + +static inline void +vmw_shmem_set(target_phys_addr_t addr, uint8 val, int len) +{ +int i; +DSHPRINTF("SHMEM set: %" PRIx64 ", len: %d (value 0x%X)", addr, len, val); + +for (i = 0; i < len; i++) { +cpu_physical_memory_write(addr + i, &val, 1); +} +} + +static inline uint32_t +vmw_shmem_ld8(target_phys_addr_t addr) +{ +uint8_t res = ldub_phys(addr); +DSHPRINTF("SHMEM load8: %" PRIx64 " (value 0x%X)", addr, res); +return res; +} + +static inline void +vmw_shmem_st8(target_phys_addr_t addr, uint8_t value) +{ +DSHPRINTF("SHMEM store8: %" PRIx64 " (value 0x%X)", addr, value); +stb_phys(addr, value); +} + +static inline uint32_t +vmw_shmem_ld16(target_phys_addr_t addr) +{ +uint16_t res = lduw_le_phys(addr); +DSHPRINTF("SHMEM load16: %" PRIx64 " (value 0x%X)", addr, res); +return res; +} + +static inline void +vmw_shmem_st16(target_phys_addr_t addr, uint16_t value) +{ +DSHPRINTF("SHMEM store16: %" PRIx64 " (value 0x%X)", addr, value); +stw_le_phys(addr, value); +} + +static inline uint32_t +vmw_shmem_ld32(target_phys_addr_t addr) +{ +uint32_t res = ldl_le_phys(addr); +DSHPRINTF("SHMEM load32: %" PRIx64 " (value 0x%X)", addr, res); +return res; +} + +static inline void +vmw_shmem_st32(target_phys_addr_t addr, uint32_t value) +{ +DSHPRINTF("SHMEM store32: %" PRIx64 " (value 0x%X)", addr, value); +stl_le_phys(addr, value); +} + +static inline uint64_t +vmw_shmem_ld64(target_phys_addr_t addr) +{ +uint64_t res = ldq_le_phys(addr); +DSHPRINTF("SHMEM load64: %" PRIx64 " (value %" PRIx64 ")", addr, res); +return res; +} + +static inline void +vmw_shmem_st64(target_phys_addr_t addr, uint64_t value) +{ +DSHPRINTF("SHMEM store64: %" PRIx64 " (value %" PRIx64 ")", addr, value); +stq_le_phys(addr, value); +} + +/* MACROS for simplification of operations on array-style registers */ +#define IS_MULTIREG_ADDR(addr, base, cnt, regsize) \ +(((addr) >= (base)) && ((addr) < (base) + (cnt) * (regsize))) + +#define MULTIREG_IDX_BY_ADDR(addr, base, regsize) \ +(((addr) - (base)) / (regsize)) + +#endif -- 1.7.9.5
Re: [Qemu-devel] [PATCH 3/4 V3] Header with various utility functions shared
On Sun, Jul 8, 2012 at 11:57 PM, Paolo Bonzini wrote: > Il 07/07/2012 09:56, Blue Swirl ha scritto: >> These don't seem useful. I think DMA accessors should also be used. > > This is a paravirtualized device model, so I think no (like virtio). > > I agree that this patch can be dropped and the functions inlined > manually in pvscsi.c (patch 4). Sounds good. Will inline these into pvscsi.c and re-submit in the next version. > > Paolo >
Re: [Qemu-devel] [PATCH 2/6] usb: add usb attached scsi emulation
On Thu, Jul 12, 2012 at 6:08 AM, Gerd Hoffmann wrote: > $subject says all. First cut. > > It's a pure UAS (usb attached scsi) emulation, without BOT (bulk-only > transport) compatibility. If your guest can't handle it use usb-storage > instead. > > The emulation works like any other scsi hba emulation (eps, lsi, virtio, > megasas, ...). It provides just the HBA where you can attach scsi > devices as you like using '-device'. A single scsi target with up to > 256 luns is supported. > > For now only usb 2.0 transport is supported. This will change in the > future though as I plan to use this as playground when codeing up & > testing usb 3.0 transport and streams support in the qemu usb core and > the xhci emulation. > > No migration support yet. I'm planning to add usb 3.0 support first as > this probably requires saving additional state. > > Special thanks go to Paolo for bringing the qemu scsi emulation into > shape, so this can be added nicely without having to touch a single line > of scsi code. > > Signed-off-by: Gerd Hoffmann > --- > docs/usb-storage.txt | 38 +++ > hw/usb/Makefile.objs |1 + > hw/usb/dev-uas.c | 779 > ++ > trace-events | 14 + > 4 files changed, 832 insertions(+), 0 deletions(-) > create mode 100644 docs/usb-storage.txt > create mode 100644 hw/usb/dev-uas.c > > diff --git a/docs/usb-storage.txt b/docs/usb-storage.txt > new file mode 100644 > index 000..ff97559 > --- /dev/null > +++ b/docs/usb-storage.txt > @@ -0,0 +1,38 @@ > + > +qemu usb storage emulation > +-- > + > +Qemu has two emulations for usb storage devices. > + > +Number one emulates the classic bulk-only transport protocol which is > +used by 99% of the usb sticks on the marked today and is called > +"usb-storage". Usage (hooking up to xhci, other host controllers work > +too): > + > + qemu ${other_vm_args}\ > + -drive if=none,id=stick,file=/path/to/file.img \ > + -device nec-usb-xhci,id=xhci\ > + -device usb-storage,bus=xhci.0,drive=stick > + > + > +Number two is the newer usb attached scsi transport. This one doesn't > +automagically create a scsi disk, so you have to explicitly attach one > +manually. Multiple logical units are supported. Here is an example > +with tree logical units: > + > + qemu ${other_vm_args}\ > + -drive if=none,id=uas-disk1,file=/path/to/file1.img \ > + -drive if=none,id=uas-disk2,file=/path/to/file2.img \ > + -drive if=none,id=uas-cdrom,media=cdrom,file=/path/to/image.iso \ > + -device nec-usb-xhci,id=xhci\ > + -device usb-uas,id=uas,bus=xhci.0 \ > + -device scsi-hd,bus=uas.0,scsi-id=0,lun=0,drive=uas-disk1 \ > + -device scsi-hd,bus=uas.0,scsi-id=0,lun=1,drive=uas-disk2 \ > + -device scsi-cd,bus=uas.0,scsi-id=0,lun=5,drive=uas-cdrom > + > + > +enjoy, > + Gerd > + > +-- > +Gerd Hoffmann > diff --git a/hw/usb/Makefile.objs b/hw/usb/Makefile.objs > index 9c7ddf5..4225136 100644 > --- a/hw/usb/Makefile.objs > +++ b/hw/usb/Makefile.objs > @@ -11,3 +11,4 @@ common-obj-y += core.o bus.o desc.o dev-hub.o > common-obj-y += host-$(HOST_USB).o dev-bluetooth.o > common-obj-y += dev-hid.o dev-storage.o dev-wacom.o > common-obj-y += dev-serial.o dev-network.o dev-audio.o > +common-obj-y += dev-uas.o > diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c > new file mode 100644 > index 000..9b02ff4 > --- /dev/null > +++ b/hw/usb/dev-uas.c > @@ -0,0 +1,779 @@ > +/* > + * UAS (USB Attached SCSI) emulation > + * > + * Copyright Red Hat, Inc. 2012 > + * > + * Author: Gerd Hoffmann > + * > + * This work is licensed under the terms of the GNU GPL, version 2 or later. > + * See the COPYING file in the top-level directory. > + */ > + > +#include "qemu-common.h" > +#include "qemu-option.h" > +#include "qemu-config.h" > +#include "trace.h" > + > +#include "hw/usb.h" > +#include "hw/usb/desc.h" > +#include "hw/scsi.h" > +#include "hw/scsi-defs.h" > + > +/* - */ > + > +#define UAS_UI_COMMAND 0x01 > +#define UAS_UI_SENSE0x03 > +#define UAS_UI_RESPONSE 0x04 > +#define UAS_UI_TASK_MGMT0x05 > +#define UAS_UI_READ_READY 0x06 > +#define UAS_UI_WRITE_READY 0x07 > + > +#define UAS_RC_TMF_COMPLETE 0x00 > +#define UAS_RC_INVALID_INFO_UNIT0x02 > +#define UAS_RC_TMF_NOT_SUPPORTED0x04 > +#define UAS_RC_TMF_FAILED 0x05 > +#define UAS_RC_TMF_SUCCEEDED0x08 > +#define UAS_RC_INCORRECT_LUN0x09 > +#define UAS_RC_OVERLAPPED_TAG 0x0a > + > +#define UAS_TMF_ABORT_TASK 0x01 > +#define UAS_TMF_ABORT_TASK_SET 0x02 > +#define UAS_TMF_CLEAR_TASK_SET 0x04 > +#define
[Qemu-devel] [PATCH V4] VMWare PVSCSI paravirtual device implementation
Below is v4 of VMWare PVSCSI device implementation patches (earlier submitted by Dmitry Fleytman) so that it gets applied to the qemu master. Note that below patch is against scsi-next branch of git://github.com/bonzini/qemu.git. Details from Dmitry's earlier submission can be found at: http://lists.gnu.org/archive/html/qemu-devel/2012-03/msg03438.html Beyond prior testing, latest patch-set was tested with Ubuntu linux guests with vmw_pvscsi driver on kvm as well as xen. 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. Reported-by: Blue Swirl Signed-off-by: Deep Debroy --- default-configs/pci.mak|1 + docs/specs/pvscsi-spec.txt | 92 hw/Makefile.objs |1 + hw/pci.h |1 + hw/pvscsi.c| 1055 hw/vmw_pvscsi.h| 430 ++ trace-events | 33 ++ 7 files changed, 1613 insertions(+) create mode 100644 docs/specs/pvscsi-spec.txt create mode 100644 hw/pvscsi.c create mode 100644 hw/vmw_pvscsi.h diff --git a/default-configs/pci.mak b/default-configs/pci.mak index 9d3e1db..9fd4896 100644 --- a/default-configs/pci.mak +++ b/default-configs/pci.mak @@ -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_RTL8139_PCI=y CONFIG_E1000_PCI=y CONFIG_IDE_CORE=y diff --git a/docs/specs/pvscsi-spec.txt b/docs/specs/pvscsi-spec.txt new file mode 100644 index 000..b2c3a55 --- /dev/null +++ b/docs/specs/pvscsi-spec.txt @@ -0,0 +1,92 @@ +General Description +=== + +This document describes VMWare PVSCSI device interface specification. +Created by Dmitry Fleytman (dmi...@daynix.com), Daynix Computing LTD. +Based on source code of PVSCSI Linux driver from kernel 3.0.4 + +PVSCSI Device Interface Overview + + +The interface is based on memory area shared between hypervisor and VM. +Memory area is obtained by driver as device IO memory resource of +PVSCSI_MEM_SPACE_SIZE length. +The shared memory consists of registers area and rings area. +The registers area is used to raise hypervisor interrupts and issue device +commands. The rings area is used to transfer data descriptors and SCSI +commands from VM to hypervisor and to transfer messages produced by +hypervisor to VM. Data itself is transferred via virtual scatter-gather DMA. + +PVSCSI Device Registers +=== + +Registers area length is 1 page (PVSCSI_MEM_SPACE_COMMAND_NUM_PAGES). +Registers area structure is described by PVSCSIRegOffset enumeration. +There are registers to issue device command (with optional short data), +issue device interrupt, control interrupts masking. + +PVSCSI Device Rings +=== + +There are three rings in shared memory: + +1. Request ring (struct PVSCSIRingReqDesc *req_ring) +- ring for OS to device requests +2. Completion ring (struct PVSCSIRingCmpDesc *cmp_ring) +- ring for device request completions +3. Message ring (struct PVSCSIRingMsgDesc *msg_ring) +- ring for messages from device. + This ring is optional and may be not configured. +There is a control area (struct PVSCSIRingsState *rings_state) used to control +rings operation. + +PVSCSI Device to Host Interrupts + +There are following interrupt types supported by PVSCSI device: +1. Completion interrupts (completion ring notifications): +PVSCSI_INTR_CMPL_0 +PVSCSI_INTR_CMPL_1 +2. Message interrupts (message ring notifications): +PVSCSI_INTR_MSG_0 +PVSCSI_INTR_MSG_1 + +Interrupts are controlled via PVSCSI_REG_OFFSET_INTR_MASK register +Bit set means interrupt enabled, bit cleared - disabled + +Interrupt modes supported are legacy, MSI and MSI-X +In case of legacy interrupts register PVSCSI_REG_OFFSET_INTR_STATUS +used to verify interrupt arrival and to clear interrupt state +Interrupts are cleared by writing processed bits back +to interrupt status register. + +PVSCSI Device Operation Sequences += + +1. Startup sequence: +a. Issue PVSCSI_CMD_ADAPTER_RESET command; +aa. Windows driver reads interrupt status register here; +b. Issue PVSCSI_CMD_SETUP_MSG_RING command with no additional data, + check status and disable device messages if error returned; + (Omitted if device messages disabled by driver configuration) +c. Issue PVSCSI_CMD_SETUP_RINGS command, provide
[Qemu-devel] [PATCH V5] VMWare PVSCSI paravirtual device implementation
Below is V5 of VMWare PVSCSI device implementation patches (earlier submitted by Dmitry Fleytman) so that it gets applied to the qemu master. Note that below patch is against scsi-next branch of git://github.com/bonzini/qemu.git. Details from Dmitry's earlier submission can be found at: http://lists.gnu.org/archive/html/qemu-devel/2012-03/msg03438.html Beyond prior testing, latest patch-set was tested with Ubuntu linux guests with vmw_pvscsi driver on kvm as well as xen. Changes since V4: Array access checks and minor beautification as suggested by Blue Swirl. Reported-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. Reported-by: Blue Swirl Signed-off-by: Deep Debroy --- default-configs/pci.mak|1 + docs/specs/pvscsi-spec.txt | 92 hw/Makefile.objs |1 + hw/pci.h |1 + hw/pvscsi.c| 1056 hw/vmw_pvscsi.h| 430 ++ trace-events | 33 ++ 7 files changed, 1614 insertions(+) create mode 100644 docs/specs/pvscsi-spec.txt create mode 100644 hw/pvscsi.c create mode 100644 hw/vmw_pvscsi.h diff --git a/default-configs/pci.mak b/default-configs/pci.mak index 9d3e1db..9fd4896 100644 --- a/default-configs/pci.mak +++ b/default-configs/pci.mak @@ -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_RTL8139_PCI=y CONFIG_E1000_PCI=y CONFIG_IDE_CORE=y diff --git a/docs/specs/pvscsi-spec.txt b/docs/specs/pvscsi-spec.txt new file mode 100644 index 000..b2c3a55 --- /dev/null +++ b/docs/specs/pvscsi-spec.txt @@ -0,0 +1,92 @@ +General Description +=== + +This document describes VMWare PVSCSI device interface specification. +Created by Dmitry Fleytman (dmi...@daynix.com), Daynix Computing LTD. +Based on source code of PVSCSI Linux driver from kernel 3.0.4 + +PVSCSI Device Interface Overview + + +The interface is based on memory area shared between hypervisor and VM. +Memory area is obtained by driver as device IO memory resource of +PVSCSI_MEM_SPACE_SIZE length. +The shared memory consists of registers area and rings area. +The registers area is used to raise hypervisor interrupts and issue device +commands. The rings area is used to transfer data descriptors and SCSI +commands from VM to hypervisor and to transfer messages produced by +hypervisor to VM. Data itself is transferred via virtual scatter-gather DMA. + +PVSCSI Device Registers +=== + +Registers area length is 1 page (PVSCSI_MEM_SPACE_COMMAND_NUM_PAGES). +Registers area structure is described by PVSCSIRegOffset enumeration. +There are registers to issue device command (with optional short data), +issue device interrupt, control interrupts masking. + +PVSCSI Device Rings +=== + +There are three rings in shared memory: + +1. Request ring (struct PVSCSIRingReqDesc *req_ring) +- ring for OS to device requests +2. Completion ring (struct PVSCSIRingCmpDesc *cmp_ring) +- ring for device request completions +3. Message ring (struct PVSCSIRingMsgDesc *msg_ring) +- ring for messages from device. + This ring is optional and may be not configured. +There is a control area (struct PVSCSIRingsState *rings_state) used to control +rings operation. + +PVSCSI Device to Host Interrupts + +There are following interrupt types supported by PVSCSI device: +1. Completion interrupts (completion ring notifications): +PVSCSI_INTR_CMPL_0 +PVSCSI_INTR_CMPL_1 +2. Message interrupts (message ring notifications): +PVSCSI_INTR_MSG_0 +PVSCSI_INTR_MSG_1 + +Interrupts are controlled via PVSCSI_REG_OFFSET_INTR_MASK register +Bit set means interrupt enabled, bit cleared - disabled + +Interrupt modes supported are legacy, MSI and MSI-X +In case of legacy interrupts register PVSCSI_REG_OFFSET_INTR_STATUS +used to verify interrupt arrival and to clear interrupt state +Interrupts are cleared by writing processed bits back +to interrupt status register. + +PVSCSI Device Operation Sequences += + +1. Startup sequence: +a. Issue PVSCSI_CMD_ADAPTER_RESET command; +aa. Windows driver reads interrupt status register here; +b. Issue PVSCSI_CMD_SETUP_MSG_RING command with no additional data, + check status and disable device messages if error ret
[Qemu-devel] [PATCH V5] VMWare PVSCSI paravirtual device implementation
Below is V5 of VMWare PVSCSI device implementation patches (earlier submitted by Dmitry Fleytman) so that it gets applied to the qemu master. Note that below patch is against scsi-next branch of git://github.com/bonzini/qemu.git. Details from Dmitry's earlier submission can be found at: http://lists.gnu.org/archive/html/qemu-devel/2012-03/msg03438.html Beyond prior testing, latest patch-set was tested with Ubuntu linux guests with vmw_pvscsi driver on kvm as well as xen. Changes since V4: Array access checks and minor beautification as suggested by Blue Swirl. Reported-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. Reported-by: Blue Swirl Signed-off-by: Deep Debroy --- default-configs/pci.mak|1 + docs/specs/pvscsi-spec.txt | 92 hw/Makefile.objs |1 + hw/pci.h |1 + hw/pvscsi.c| 1056 hw/vmw_pvscsi.h| 430 ++ trace-events | 33 ++ 7 files changed, 1614 insertions(+) create mode 100644 docs/specs/pvscsi-spec.txt create mode 100644 hw/pvscsi.c create mode 100644 hw/vmw_pvscsi.h diff --git a/default-configs/pci.mak b/default-configs/pci.mak index 9d3e1db..9fd4896 100644 --- a/default-configs/pci.mak +++ b/default-configs/pci.mak @@ -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_RTL8139_PCI=y CONFIG_E1000_PCI=y CONFIG_IDE_CORE=y diff --git a/docs/specs/pvscsi-spec.txt b/docs/specs/pvscsi-spec.txt new file mode 100644 index 000..b2c3a55 --- /dev/null +++ b/docs/specs/pvscsi-spec.txt @@ -0,0 +1,92 @@ +General Description +=== + +This document describes VMWare PVSCSI device interface specification. +Created by Dmitry Fleytman (dmi...@daynix.com), Daynix Computing LTD. +Based on source code of PVSCSI Linux driver from kernel 3.0.4 + +PVSCSI Device Interface Overview + + +The interface is based on memory area shared between hypervisor and VM. +Memory area is obtained by driver as device IO memory resource of +PVSCSI_MEM_SPACE_SIZE length. +The shared memory consists of registers area and rings area. +The registers area is used to raise hypervisor interrupts and issue device +commands. The rings area is used to transfer data descriptors and SCSI +commands from VM to hypervisor and to transfer messages produced by +hypervisor to VM. Data itself is transferred via virtual scatter-gather DMA. + +PVSCSI Device Registers +=== + +Registers area length is 1 page (PVSCSI_MEM_SPACE_COMMAND_NUM_PAGES). +Registers area structure is described by PVSCSIRegOffset enumeration. +There are registers to issue device command (with optional short data), +issue device interrupt, control interrupts masking. + +PVSCSI Device Rings +=== + +There are three rings in shared memory: + +1. Request ring (struct PVSCSIRingReqDesc *req_ring) +- ring for OS to device requests +2. Completion ring (struct PVSCSIRingCmpDesc *cmp_ring) +- ring for device request completions +3. Message ring (struct PVSCSIRingMsgDesc *msg_ring) +- ring for messages from device. + This ring is optional and may be not configured. +There is a control area (struct PVSCSIRingsState *rings_state) used to control +rings operation. + +PVSCSI Device to Host Interrupts + +There are following interrupt types supported by PVSCSI device: +1. Completion interrupts (completion ring notifications): +PVSCSI_INTR_CMPL_0 +PVSCSI_INTR_CMPL_1 +2. Message interrupts (message ring notifications): +PVSCSI_INTR_MSG_0 +PVSCSI_INTR_MSG_1 + +Interrupts are controlled via PVSCSI_REG_OFFSET_INTR_MASK register +Bit set means interrupt enabled, bit cleared - disabled + +Interrupt modes supported are legacy, MSI and MSI-X +In case of legacy interrupts register PVSCSI_REG_OFFSET_INTR_STATUS +used to verify interrupt arrival and to clear interrupt state +Interrupts are cleared by writing processed bits back +to interrupt status register. + +PVSCSI Device Operation Sequences += + +1. Startup sequence: +a. Issue PVSCSI_CMD_ADAPTER_RESET command; +aa. Windows driver reads interrupt status register here; +b. Issue PVSCSI_CMD_SETUP_MSG_RING command with no additional data, + check status and disable device messages if error ret
[Qemu-devel] [PATCH V5] VMWare PVSCSI paravirtual device implementation
[Please ignore previous v5 submissions - I forgot to update the subject on the previous ones resulting them in getting threaded with v4] Below is v5 of VMWare PVSCSI device implementation patches (earlier submitted by Dmitry Fleytman) so that it gets applied to the qemu master. Note that below patch is against scsi-next branch of git://github.com/bonzini/qemu.git. Details from Dmitry's earlier submission can be found at: http://lists.gnu.org/archive/html/qemu-devel/2012-03/msg03438.html Beyond prior testing, latest patch-set was tested with Ubuntu linux guests with vmw_pvscsi driver on kvm as well as xen. Changes since V4: Array access checks and minor beautification as suggested by Blue Swirl. Reported-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. Reported-by: Blue Swirl Signed-off-by: Deep Debroy --- default-configs/pci.mak|1 + docs/specs/pvscsi-spec.txt | 92 hw/Makefile.objs |1 + hw/pci.h |1 + hw/pvscsi.c| 1056 hw/vmw_pvscsi.h| 430 ++ trace-events | 33 ++ 7 files changed, 1614 insertions(+) create mode 100644 docs/specs/pvscsi-spec.txt create mode 100644 hw/pvscsi.c create mode 100644 hw/vmw_pvscsi.h diff --git a/default-configs/pci.mak b/default-configs/pci.mak index 9d3e1db..9fd4896 100644 --- a/default-configs/pci.mak +++ b/default-configs/pci.mak @@ -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_RTL8139_PCI=y CONFIG_E1000_PCI=y CONFIG_IDE_CORE=y diff --git a/docs/specs/pvscsi-spec.txt b/docs/specs/pvscsi-spec.txt new file mode 100644 index 000..b2c3a55 --- /dev/null +++ b/docs/specs/pvscsi-spec.txt @@ -0,0 +1,92 @@ +General Description +=== + +This document describes VMWare PVSCSI device interface specification. +Created by Dmitry Fleytman (dmi...@daynix.com), Daynix Computing LTD. +Based on source code of PVSCSI Linux driver from kernel 3.0.4 + +PVSCSI Device Interface Overview + + +The interface is based on memory area shared between hypervisor and VM. +Memory area is obtained by driver as device IO memory resource of +PVSCSI_MEM_SPACE_SIZE length. +The shared memory consists of registers area and rings area. +The registers area is used to raise hypervisor interrupts and issue device +commands. The rings area is used to transfer data descriptors and SCSI +commands from VM to hypervisor and to transfer messages produced by +hypervisor to VM. Data itself is transferred via virtual scatter-gather DMA. + +PVSCSI Device Registers +=== + +Registers area length is 1 page (PVSCSI_MEM_SPACE_COMMAND_NUM_PAGES). +Registers area structure is described by PVSCSIRegOffset enumeration. +There are registers to issue device command (with optional short data), +issue device interrupt, control interrupts masking. + +PVSCSI Device Rings +=== + +There are three rings in shared memory: + +1. Request ring (struct PVSCSIRingReqDesc *req_ring) +- ring for OS to device requests +2. Completion ring (struct PVSCSIRingCmpDesc *cmp_ring) +- ring for device request completions +3. Message ring (struct PVSCSIRingMsgDesc *msg_ring) +- ring for messages from device. + This ring is optional and may be not configured. +There is a control area (struct PVSCSIRingsState *rings_state) used to control +rings operation. + +PVSCSI Device to Host Interrupts + +There are following interrupt types supported by PVSCSI device: +1. Completion interrupts (completion ring notifications): +PVSCSI_INTR_CMPL_0 +PVSCSI_INTR_CMPL_1 +2. Message interrupts (message ring notifications): +PVSCSI_INTR_MSG_0 +PVSCSI_INTR_MSG_1 + +Interrupts are controlled via PVSCSI_REG_OFFSET_INTR_MASK register +Bit set means interrupt enabled, bit cleared - disabled + +Interrupt modes supported are legacy, MSI and MSI-X +In case of legacy interrupts register PVSCSI_REG_OFFSET_INTR_STATUS +used to verify interrupt arrival and to clear interrupt state +Interrupts are cleared by writing processed bits back +to interrupt status register. + +PVSCSI Device Operation Sequences += + +1. Startup sequence: +a. Issue PVSCSI_CMD_ADAPTER_RESET command; +aa. Windows driver reads interrupt status register here; +b.