rte_virtio: don't negotiate features twice for virtio-user

Moved negotiation to virtio_init_device.
This patch also cleans up feature negotiation a bit.

Change-Id: Ia67e8d694a5acebcbe37679a657d68d6c46979db
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/377089
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Dariusz Stojaczyk 2017-09-04 14:29:06 +02:00 committed by Daniel Verkamp
parent 01aba26361
commit 146061e9c6
6 changed files with 7 additions and 19 deletions

View File

@ -506,7 +506,7 @@ bdev_virtio_initialize(void)
}
/* TODO check rc, add virtio_dev_deinit() */
virtio_init_device(vdev, VIRTIO_PMD_DEFAULT_GUEST_FEATURES);
virtio_init_device(vdev, VIRTIO_SCSI_DEV_SUPPORTED_FEATURES);
virtio_dev_start(vdev);
base->vdev = vdev;

View File

@ -261,7 +261,7 @@ virtio_negotiate_features(struct virtio_dev *dev, uint64_t req_features)
* Negotiate features: Subset of device feature bits are written back
* guest feature bits.
*/
dev->guest_features = req_features;
dev->req_guest_features = req_features;
dev->guest_features = vtpci_negotiate_features(dev, host_features);
PMD_INIT_LOG(DEBUG, "features after negotiate = %" PRIx64,
dev->guest_features);
@ -280,8 +280,6 @@ virtio_negotiate_features(struct virtio_dev *dev, uint64_t req_features)
}
}
dev->req_guest_features = req_features;
return 0;
}

View File

@ -62,14 +62,11 @@ struct virtio_req {
};
/* Features desired/implemented by this driver. */
#define VIRTIO_PMD_DEFAULT_GUEST_FEATURES \
(1u << VIRTIO_SCSI_F_INOUT | \
1ULL << VIRTIO_F_VERSION_1 | \
#define VIRTIO_SCSI_DEV_SUPPORTED_FEATURES \
(1ULL << VIRTIO_SCSI_F_INOUT | \
1ULL << VIRTIO_F_VERSION_1 | \
1ULL << VIRTIO_F_IOMMU_PLATFORM)
#define VIRTIO_PMD_SUPPORTED_GUEST_FEATURES \
(VIRTIO_PMD_DEFAULT_GUEST_FEATURES)
uint16_t virtio_recv_pkts(struct virtqueue *vq, struct virtio_req **reqs,
uint16_t nb_pkts);

View File

@ -530,7 +530,7 @@ vtpci_negotiate_features(struct virtio_dev *dev, uint64_t host_features)
* Limit negotiated features to what the driver, virtqueue, and
* host all support.
*/
features = host_features & dev->guest_features;
features = host_features & dev->req_guest_features;
VTPCI_OPS(dev)->set_features(dev, features);
return features;

View File

@ -105,7 +105,7 @@ virtio_user_get_features(struct virtio_dev *vdev)
struct virtio_user_dev *dev = virtio_dev_get_user_dev(vdev);
/* unmask feature bits defined in vhost user protocol */
return dev->device_features & VIRTIO_PMD_SUPPORTED_GUEST_FEATURES;
return dev->device_features;
}
static void

View File

@ -228,11 +228,6 @@ virtio_user_dev_setup(struct virtio_user_dev *dev)
return 0;
}
/* Use below macro to filter features from vhost backend */
#define VIRTIO_USER_SUPPORTED_FEATURES \
(1ULL << VIRTIO_SCSI_F_INOUT | \
1ULL << VIRTIO_F_VERSION_1)
struct virtio_dev *
virtio_user_dev_init(char *path, int queues, int queue_size)
{
@ -277,8 +272,6 @@ virtio_user_dev_init(char *path, int queues, int queue_size)
goto err;
}
dev->device_features &= VIRTIO_USER_SUPPORTED_FEATURES;
return vdev;
err: