virtio: remove vdev->id

Now that vtpci_internal has been removed,
the vdev->id and g_ctrlr_counter are
obsolete and can be removed as well.

Change-Id: Ia1e83cdc81552173f4b57283f83c5791e2b90daa
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/388301
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Dariusz Stojaczyk 2017-11-20 23:15:35 +01:00 committed by Jim Harris
parent a87768a2ea
commit b948246133
3 changed files with 5 additions and 11 deletions

View File

@ -68,7 +68,6 @@
struct virtio_driver g_virtio_driver = {
.init_ctrlrs = TAILQ_HEAD_INITIALIZER(g_virtio_driver.init_ctrlrs),
.attached_ctrlrs = TAILQ_HEAD_INITIALIZER(g_virtio_driver.attached_ctrlrs),
.ctrlr_counter = 0,
};
/* Chain all the descriptors in the ring with an END */
@ -316,7 +315,6 @@ struct virtio_dev *
virtio_dev_construct(const struct virtio_dev_ops *ops, void *ctx)
{
struct virtio_dev *vdev;
unsigned vdev_num;
vdev = calloc(1, sizeof(*vdev));
if (vdev == NULL) {
@ -324,8 +322,6 @@ struct virtio_dev *
return NULL;
}
vdev_num = __sync_add_and_fetch(&g_virtio_driver.ctrlr_counter, 1);
vdev->id = vdev_num;
pthread_mutex_init(&vdev->mutex, NULL);
vdev->backend_ops = ops;
vdev->ctx = ctx;

View File

@ -72,9 +72,6 @@ struct virtio_dev {
/** Max number of queues the host supports. */
uint16_t max_queues;
/** Device index. */
uint32_t id;
/** Common device & guest features. */
uint64_t negotiated_features;
@ -189,9 +186,6 @@ struct virtio_req {
struct virtio_driver {
TAILQ_HEAD(, virtio_dev) init_ctrlrs;
TAILQ_HEAD(, virtio_dev) attached_ctrlrs;
/* Increment-only virtio_dev counter */
unsigned ctrlr_counter;
};
extern struct virtio_driver g_virtio_driver;

View File

@ -69,6 +69,8 @@ struct virtio_hw {
#define PCI_CAP_ID_VNDR 0x09
#define PCI_CAP_ID_MSIX 0x11
static int g_dev_counter = 0;
static inline int
check_vq_phys_addr_ok(struct virtqueue *vq)
{
@ -414,7 +416,9 @@ next:
static int
virtio_dev_pci_init(struct virtio_dev *vdev)
{
vdev->name = spdk_sprintf_alloc("VirtioScsi%"PRIu32, vdev->id);
int vdev_id = ++g_dev_counter;
vdev->name = spdk_sprintf_alloc("VirtioScsi%"PRIu32, vdev_id);
if (!vdev->name) {
return -1;
}