[v2,4/4] net/virtio: enable feature checking on virtio-user

Message ID 20200804072431.86441-5-amorenoz@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series Add support for GET/SET_STATUS on virtio-user pmd |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK
ci/travis-robot success Travis build: passed

Commit Message

Adrian Moreno Aug. 4, 2020, 7:24 a.m. UTC
virtio 1.0 introduced a mechanism for the driver to verify that the
feature bits it sets are accepted by the device. This mechanism consists
in setting the VIRTIO_STATUS_FEATURE_OK status bit and re-reading it,
whitch gives a chance for the device to clear it if the the features
were not accepted.

This is currently being done only in modern virtio-pci devices but since
the appropriate vhost-user messages have been added, it can also be done
in virtio-user (vhost-user only).

This patch activates this mechanism on virtio-user.

Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
---
 drivers/net/virtio/virtio_ethdev.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
  

Comments

Chenbo Xia Aug. 5, 2020, 10:57 a.m. UTC | #1
> -----Original Message-----
> From: Adrian Moreno <amorenoz@redhat.com>
> Sent: Tuesday, August 4, 2020 3:25 PM
> To: dev@dpdk.org
> Cc: Wang, Zhihong <zhihong.wang@intel.com>; Xia, Chenbo
> <chenbo.xia@intel.com>; maxime.coquelin@redhat.com; Adrian Moreno
> <amorenoz@redhat.com>
> Subject: [PATCH v2 4/4] net/virtio: enable feature checking on virtio-user
> 
> virtio 1.0 introduced a mechanism for the driver to verify that the
> feature bits it sets are accepted by the device. This mechanism consists
> in setting the VIRTIO_STATUS_FEATURE_OK status bit and re-reading it,
> whitch gives a chance for the device to clear it if the the features
> were not accepted.
> 
> This is currently being done only in modern virtio-pci devices but since
> the appropriate vhost-user messages have been added, it can also be done
> in virtio-user (vhost-user only).
> 
> This patch activates this mechanism on virtio-user.
> 
> Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
> ---
>  drivers/net/virtio/virtio_ethdev.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/virtio/virtio_ethdev.c
> b/drivers/net/virtio/virtio_ethdev.c
> index dc0093bdf..9063bfeb2 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -1355,12 +1355,13 @@ virtio_negotiate_features(struct virtio_hw *hw,
> uint64_t req_features)
>  	PMD_INIT_LOG(DEBUG, "features after negotiate = %" PRIx64,
>  		hw->guest_features);
> 
> -	if (hw->modern) {
> -		if (!vtpci_with_feature(hw, VIRTIO_F_VERSION_1)) {
> -			PMD_INIT_LOG(ERR,
> -				"VIRTIO_F_VERSION_1 features is not enabled.");
> -			return -1;
> -		}
> +	if (hw->modern && !vtpci_with_feature(hw, VIRTIO_F_VERSION_1)) {
> +		PMD_INIT_LOG(ERR,
> +			"VIRTIO_F_VERSION_1 features is not enabled.");
> +		return -1;
> +	}
> +
> +	if (hw->modern || hw->virtio_user_dev) {
>  		vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_FEATURES_OK);
>  		if (!(vtpci_get_status(hw) & VIRTIO_CONFIG_STATUS_FEATURES_OK))
> {
>  			PMD_INIT_LOG(ERR,
> --
> 2.26.2

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
  

Patch

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index dc0093bdf..9063bfeb2 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1355,12 +1355,13 @@  virtio_negotiate_features(struct virtio_hw *hw, uint64_t req_features)
 	PMD_INIT_LOG(DEBUG, "features after negotiate = %" PRIx64,
 		hw->guest_features);
 
-	if (hw->modern) {
-		if (!vtpci_with_feature(hw, VIRTIO_F_VERSION_1)) {
-			PMD_INIT_LOG(ERR,
-				"VIRTIO_F_VERSION_1 features is not enabled.");
-			return -1;
-		}
+	if (hw->modern && !vtpci_with_feature(hw, VIRTIO_F_VERSION_1)) {
+		PMD_INIT_LOG(ERR,
+			"VIRTIO_F_VERSION_1 features is not enabled.");
+		return -1;
+	}
+
+	if (hw->modern || hw->virtio_user_dev) {
 		vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_FEATURES_OK);
 		if (!(vtpci_get_status(hw) & VIRTIO_CONFIG_STATUS_FEATURES_OK)) {
 			PMD_INIT_LOG(ERR,