rte_virtio: removed virtio_user_dev->max_queues

Generic virtio_dev has the same field already.

The field was previously used to store vhost-user
GET_QUEUE_NUM response, that will be later assigned
to virtio_dev->max_queues via virtio_user_read_dev_config.

This patch removes virtio_user_dev->max_queues
with entire virtio_user_read_dev_config functionality
for virtio_user.

Change-Id: I508f728215a95cf977d6b0b20350fcf2ae11fe3a
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/379155
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Dariusz Stojaczyk 2017-09-29 10:37:09 +02:00 committed by Jim Harris
parent 3c6f063845
commit b9ebf948ba
7 changed files with 20 additions and 20 deletions

View File

@ -608,7 +608,7 @@ bdev_virtio_initialize(void)
SPDK_ERRLOG("No path specified for index %d\n", i);
continue;
}
vdev = virtio_user_dev_init(path, 1, 512);
vdev = virtio_user_dev_init(path, 512);
if (vdev == NULL) {
goto out;
}

View File

@ -300,8 +300,6 @@ virtio_init_device(struct virtio_dev *dev, uint64_t req_features)
if (virtio_negotiate_features(dev, req_features) < 0)
return -1;
vtpci_read_dev_config(dev, offsetof(struct virtio_scsi_config, num_queues),
&dev->max_queues, sizeof(dev->max_queues));
/* FIXME
* Hardcode num_queues to 3 until we add proper
* mutli-queue support. This value should be limited

View File

@ -45,7 +45,10 @@
struct virtio_dev {
struct virtqueue **vqs;
uint16_t started;
uint32_t max_queues;
/** Max number of queues the host supports. */
uint16_t max_queues;
uint8_t port_id;
uint64_t req_guest_features;
uint64_t guest_features;

View File

@ -37,6 +37,7 @@
#include <fcntl.h>
#endif
#include <linux/virtio_scsi.h>
#include <rte_io.h>
#include "virtio_pci.h"
@ -731,6 +732,9 @@ pci_enum_virtio_probe_cb(void *ctx, struct spdk_pci_device *pci_dev)
VTPCI_OPS(vdev) = &legacy_ops;
vdev->modern = 0;
vtpci_read_dev_config(vdev, offsetof(struct virtio_scsi_config, num_queues),
&vdev->max_queues, sizeof(vdev->max_queues));
TAILQ_INSERT_TAIL(&g_virtio_driver.init_ctrlrs, vdev, tailq);
return 0;
}

View File

@ -57,10 +57,7 @@ static void
virtio_user_read_dev_config(struct virtio_dev *vdev, size_t offset,
void *dst, int length)
{
struct virtio_user_dev *dev = virtio_dev_get_user_dev(vdev);
if (offset == offsetof(struct virtio_scsi_config, num_queues))
*(uint16_t *)dst = dev->max_queues;
PMD_DRV_LOG(ERR, "not supported offset=%zu, len=%d", offset, length);
}
static void

View File

@ -105,7 +105,7 @@ virtio_user_queue_setup(struct virtio_user_dev *dev,
{
uint32_t i;
for (i = 0; i < dev->max_queues; ++i) {
for (i = 0; i < dev->vdev.max_queues; ++i) {
if (fn(dev, i) < 0) {
PMD_DRV_LOG(INFO, "setup tx vq fails: %u", i);
return -1;
@ -174,7 +174,7 @@ virtio_user_dev_init_notify(struct virtio_user_dev *dev)
int kickfd;
for (i = 0; i < VIRTIO_MAX_VIRTQUEUES; ++i) {
if (i >= dev->max_queues) {
if (i >= dev->vdev.max_queues) {
dev->kickfds[i] = -1;
dev->callfds[i] = -1;
continue;
@ -229,7 +229,7 @@ virtio_user_dev_setup(struct virtio_user_dev *dev)
}
struct virtio_dev *
virtio_user_dev_init(char *path, int queues, int queue_size)
virtio_user_dev_init(char *path, int queue_size)
{
struct virtio_dev *vdev;
struct virtio_user_dev *dev;
@ -242,8 +242,6 @@ virtio_user_dev_init(char *path, int queues, int queue_size)
VTPCI_OPS(vdev) = &virtio_user_ops;
snprintf(dev->path, PATH_MAX, "%s", path);
/* Account for control and event queue. */
dev->max_queues = queues + 2;
dev->queue_size = queue_size;
if (virtio_user_dev_setup(dev) < 0) {
@ -256,11 +254,13 @@ virtio_user_dev_init(char *path, int queues, int queue_size)
goto err;
}
if (dev->max_queues > max_queues) {
PMD_INIT_LOG(ERR, "%d queues requested but only %lu supported", dev->max_queues, max_queues);
if (max_queues >= VIRTIO_MAX_VIRTQUEUES) {
PMD_INIT_LOG(ERR, "invalid get_queue_num value: %lu", max_queues);
goto err;
}
vdev->max_queues = max_queues;
if (dev->ops->send_request(dev, VHOST_USER_SET_OWNER, NULL) < 0) {
PMD_INIT_LOG(ERR, "set_owner fails: %s", strerror(errno));
goto err;
@ -287,7 +287,7 @@ virtio_user_dev_uninit(struct virtio_user_dev *dev)
virtio_user_stop_device(dev);
for (i = 0; i < dev->max_queues; ++i) {
for (i = 0; i < dev->vdev.max_queues; ++i) {
close(dev->callfds[i]);
close(dev->kickfds[i]);
}
@ -295,7 +295,7 @@ virtio_user_dev_uninit(struct virtio_user_dev *dev)
close(dev->vhostfd);
if (dev->vhostfds) {
for (i = 0; i < dev->max_queues; ++i)
for (i = 0; i < dev->vdev.max_queues; ++i)
close(dev->vhostfds[i]);
free(dev->vhostfds);
free(dev->tapfds);

View File

@ -57,8 +57,6 @@ struct virtio_user_dev {
/* for both vhost_user and vhost_kernel */
int callfds[VIRTIO_MAX_VIRTQUEUES];
int kickfds[VIRTIO_MAX_VIRTQUEUES];
uint32_t max_queues;
uint32_t num_queues;
uint32_t queue_size;
uint64_t features; /* the negotiated features with driver,
* and will be sync with device
@ -74,7 +72,7 @@ struct virtio_user_dev {
int is_vhost_user_by_type(const char *path);
int virtio_user_start_device(struct virtio_user_dev *dev);
int virtio_user_stop_device(struct virtio_user_dev *dev);
struct virtio_dev *virtio_user_dev_init(char *path, int queues, int queue_size);
struct virtio_dev *virtio_user_dev_init(char *path, int queue_size);
void virtio_user_dev_uninit(struct virtio_user_dev *dev);
void virtio_user_handle_cq(struct virtio_user_dev *dev, uint16_t queue_idx);
#endif