rte_virtio: remove vtpci_internal
Now that legacy PCI support has been dropped, we can safely assume there's only one backend type per device. So the vtpci_internal - containing process-local data - can be removed. Change-Id: I15d87a280b74318c7a44ee60ce3408756d1f5a69 Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/385423 Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
79f99ccce0
commit
a8c375ad77
@ -287,11 +287,8 @@ virtio_dev_init(struct virtio_dev *dev, uint64_t req_features)
|
||||
void
|
||||
virtio_dev_free(struct virtio_dev *dev)
|
||||
{
|
||||
uint32_t vdev_id = dev->id;
|
||||
|
||||
virtio_free_queues(dev);
|
||||
vtpci_ops(dev)->free_vdev(dev);
|
||||
vtpci_deinit(vdev_id);
|
||||
pthread_mutex_destroy(&dev->mutex);
|
||||
free(dev);
|
||||
}
|
||||
|
@ -98,6 +98,9 @@ struct virtio_dev {
|
||||
/** Mutex for asynchronous virtqueue-changing operations. */
|
||||
pthread_mutex_t mutex;
|
||||
|
||||
/** Backend-specific callbacks. */
|
||||
const struct virtio_pci_ops *backend_ops;
|
||||
|
||||
/** Context for the backend ops */
|
||||
void *ctx;
|
||||
|
||||
|
@ -43,6 +43,7 @@
|
||||
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,
|
||||
};
|
||||
|
||||
/*
|
||||
@ -519,27 +520,17 @@ struct virtio_dev *
|
||||
struct virtio_dev *vdev;
|
||||
unsigned vdev_num;
|
||||
|
||||
for (vdev_num = 0; vdev_num < VIRTIO_MAX_DEVICES; vdev_num++) {
|
||||
if (g_virtio_driver.internal[vdev_num].vtpci_ops == NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (vdev_num == VIRTIO_MAX_DEVICES) {
|
||||
SPDK_ERRLOG("Max vhost device limit reached (%u).\n", VIRTIO_MAX_DEVICES);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
vdev = calloc(1, sizeof(*vdev));
|
||||
if (vdev == NULL) {
|
||||
SPDK_ERRLOG("virtio device calloc failed\n");
|
||||
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;
|
||||
g_virtio_driver.internal[vdev_num].vtpci_ops = ops;
|
||||
|
||||
return vdev;
|
||||
}
|
||||
@ -558,13 +549,7 @@ vtpci_enumerate_pci(void)
|
||||
const struct virtio_pci_ops *
|
||||
vtpci_ops(struct virtio_dev *dev)
|
||||
{
|
||||
return g_virtio_driver.internal[dev->id].vtpci_ops;
|
||||
}
|
||||
|
||||
void
|
||||
vtpci_deinit(uint32_t id)
|
||||
{
|
||||
g_virtio_driver.internal[id].vtpci_ops = NULL;
|
||||
return dev->backend_ops;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -45,8 +45,6 @@
|
||||
|
||||
struct virtqueue;
|
||||
|
||||
#define VIRTIO_MAX_DEVICES 128
|
||||
|
||||
/* Extra status define for readability */
|
||||
#define VIRTIO_CONFIG_S_RESET 0
|
||||
|
||||
@ -104,19 +102,12 @@ struct virtio_hw {
|
||||
struct virtio_scsi_config *dev_cfg;
|
||||
};
|
||||
|
||||
/*
|
||||
* While virtio_hw is stored in shared memory, this structure stores
|
||||
* some infos that may vary in the multiple process model locally.
|
||||
* For example, the vtpci_ops pointer.
|
||||
*/
|
||||
struct vtpci_internal {
|
||||
const struct virtio_pci_ops *vtpci_ops;
|
||||
};
|
||||
|
||||
struct virtio_driver {
|
||||
struct vtpci_internal internal[VIRTIO_MAX_DEVICES];
|
||||
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;
|
||||
@ -145,8 +136,6 @@ void vtpci_read_dev_config(struct virtio_dev *, size_t, void *, int);
|
||||
|
||||
const struct virtio_pci_ops *vtpci_ops(struct virtio_dev *dev);
|
||||
|
||||
void vtpci_deinit(uint32_t id);
|
||||
|
||||
void vtpci_dump_json_config(struct virtio_dev *hw, struct spdk_json_write_ctx *w);
|
||||
|
||||
extern const struct virtio_pci_ops virtio_user_ops;
|
||||
|
Loading…
Reference in New Issue
Block a user