Commit 29df0140 authored by Dariusz Stojaczyk's avatar Dariusz Stojaczyk Committed by Daniel Verkamp
Browse files

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: default avatarDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/377090


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
parent 146061e9
Loading
Loading
Loading
Loading
+17 −9
Original line number Diff line number Diff line
@@ -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,19 +270,23 @@ 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 (dev->modern) {
			PMD_INIT_LOG(ERR,
				     "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;
}
+2 −0
Original line number Diff line number Diff line
@@ -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;
};