rte_virtio: set FEATURES_OK for modern virtio-user devices

This patch also sets virtio_dev->modern for vhost-user
devices.

A word of explanation of what's happening now:
For virtio_pci, dev->modern is set when reading config,
as legacy devices have no Virtio PCI Capability in their
capability list. For virtio_user, the dev->modern should
be set if VIRTIO_F_VERSION_1 feature has been negotiated.

Change-Id: I056b1dcf65a5a6a87cda6499771399befdc59cb5
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/377090
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Dariusz Stojaczyk 2017-09-04 15:54:42 +02:00 committed by Daniel Verkamp
parent 146061e9c6
commit 29df0140f0
2 changed files with 19 additions and 9 deletions

View File

@ -243,6 +243,10 @@ virtio_alloc_queues(struct virtio_dev *dev)
return 0;
}
/* Negotiate virtio features. This will also set dev->modern if virtio
* device offers VIRTIO_F_VERSION_1 flag. If dev->modern has been set before,
* the mentioned flag must be offered. Otherwise an error is returned.
*/
static int
virtio_negotiate_features(struct virtio_dev *dev, uint64_t req_features)
{
@ -266,18 +270,22 @@ virtio_negotiate_features(struct virtio_dev *dev, uint64_t req_features)
PMD_INIT_LOG(DEBUG, "features after negotiate = %" PRIx64,
dev->guest_features);
if (dev->modern) {
if (!vtpci_with_feature(dev, VIRTIO_F_VERSION_1)) {
if (!vtpci_with_feature(dev, VIRTIO_F_VERSION_1)) {
if (dev->modern) {
PMD_INIT_LOG(ERR,
"VIRTIO_F_VERSION_1 features is not enabled.");
return -1;
}
vtpci_set_status(dev, VIRTIO_CONFIG_STATUS_FEATURES_OK);
if (!(vtpci_get_status(dev) & VIRTIO_CONFIG_STATUS_FEATURES_OK)) {
PMD_INIT_LOG(ERR,
"failed to set FEATURES_OK status!");
"VIRTIO_F_VERSION_1 features is not enabled.");
return -1;
}
return 0;
}
dev->modern = 1;
vtpci_set_status(dev, VIRTIO_CONFIG_STATUS_FEATURES_OK);
if (!(vtpci_get_status(dev) & VIRTIO_CONFIG_STATUS_FEATURES_OK)) {
PMD_INIT_LOG(ERR,
"failed to set FEATURES_OK status!");
return -1;
}
return 0;

View File

@ -49,6 +49,8 @@ struct virtio_dev {
uint64_t req_guest_features;
uint64_t guest_features;
int is_hw;
/** Modern/legacy virtio device flag. */
uint8_t modern;
};