2011-02-11 11:40:59 +03:00
|
|
|
/*
|
|
|
|
* Virtio SCSI HBA
|
|
|
|
*
|
|
|
|
* Copyright IBM, Corp. 2010
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2. See
|
|
|
|
* the COPYING file in the top-level directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _QEMU_VIRTIO_SCSI_H
|
|
|
|
#define _QEMU_VIRTIO_SCSI_H
|
|
|
|
|
2013-02-04 18:40:22 +04:00
|
|
|
#include "hw/virtio.h"
|
|
|
|
#include "hw/pci/pci.h"
|
2013-03-18 20:37:18 +04:00
|
|
|
#include "hw/scsi.h"
|
2011-02-11 11:40:59 +03:00
|
|
|
|
2013-03-21 18:15:14 +04:00
|
|
|
#define TYPE_VIRTIO_SCSI "virtio-scsi"
|
|
|
|
#define VIRTIO_SCSI(obj) \
|
|
|
|
OBJECT_CHECK(VirtIOSCSI, (obj), TYPE_VIRTIO_SCSI)
|
|
|
|
|
|
|
|
|
2011-02-11 11:40:59 +03:00
|
|
|
/* The ID for virtio_scsi */
|
|
|
|
#define VIRTIO_ID_SCSI 8
|
|
|
|
|
2012-08-20 17:23:28 +04:00
|
|
|
/* Feature Bits */
|
|
|
|
#define VIRTIO_SCSI_F_INOUT 0
|
|
|
|
#define VIRTIO_SCSI_F_HOTPLUG 1
|
|
|
|
#define VIRTIO_SCSI_F_CHANGE 2
|
|
|
|
|
2011-02-11 11:40:59 +03:00
|
|
|
struct VirtIOSCSIConf {
|
|
|
|
uint32_t num_queues;
|
|
|
|
uint32_t max_sectors;
|
|
|
|
uint32_t cmd_per_lun;
|
|
|
|
};
|
|
|
|
|
2013-03-18 20:37:18 +04:00
|
|
|
typedef struct VirtIOSCSI {
|
2013-03-21 18:15:18 +04:00
|
|
|
VirtIODevice parent_obj;
|
2013-03-21 18:15:11 +04:00
|
|
|
VirtIOSCSIConf conf;
|
2013-03-18 20:37:18 +04:00
|
|
|
|
|
|
|
SCSIBus bus;
|
|
|
|
uint32_t sense_size;
|
|
|
|
uint32_t cdb_size;
|
|
|
|
int resetting;
|
|
|
|
bool events_dropped;
|
|
|
|
VirtQueue *ctrl_vq;
|
|
|
|
VirtQueue *event_vq;
|
2013-03-21 18:15:12 +04:00
|
|
|
VirtQueue **cmd_vqs;
|
2013-03-18 20:37:18 +04:00
|
|
|
} VirtIOSCSI;
|
|
|
|
|
2013-03-21 18:15:13 +04:00
|
|
|
#define DEFINE_VIRTIO_SCSI_PROPERTIES(_state, _conf_field) \
|
|
|
|
DEFINE_PROP_UINT32("num_queues", _state, _conf_field.num_queues, 1), \
|
|
|
|
DEFINE_PROP_UINT32("max_sectors", _state, _conf_field.max_sectors, 0xFFFF),\
|
|
|
|
DEFINE_PROP_UINT32("cmd_per_lun", _state, _conf_field.cmd_per_lun, 128)
|
|
|
|
|
|
|
|
#define DEFINE_VIRTIO_SCSI_FEATURES(_state, _feature_field) \
|
|
|
|
DEFINE_VIRTIO_COMMON_FEATURES(_state, _feature_field), \
|
|
|
|
DEFINE_PROP_BIT("hotplug", _state, _feature_field, VIRTIO_SCSI_F_HOTPLUG, \
|
|
|
|
true), \
|
|
|
|
DEFINE_PROP_BIT("param_change", _state, _feature_field, \
|
|
|
|
VIRTIO_SCSI_F_CHANGE, true)
|
2011-02-11 11:40:59 +03:00
|
|
|
|
|
|
|
#endif /* _QEMU_VIRTIO_SCSI_H */
|