From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9998CA0524 for ; Fri, 5 Feb 2021 12:30:18 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 90EA140682; Fri, 5 Feb 2021 12:30:18 +0100 (CET) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by mails.dpdk.org (Postfix) with ESMTP id A76491889A0 for ; Fri, 5 Feb 2021 12:30:16 +0100 (CET) Received: by mail-wr1-f41.google.com with SMTP id l12so7334397wry.2 for ; Fri, 05 Feb 2021 03:30:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BmxZTRZBnK7yUOPSxjkswt8tlawvL3sk+XGxF33VDzE=; b=R1UUYbnsN2qZDzli3efdoOpvLpqNGQEq/dUMYlT8q4SneDx6+w1KxIKHaVDdI5bquE dBgjSkIL64+mkmCh62gDSAFxqBx7XScTHu3jt04ANkvQfYv4SkazD7fsK58xY0M7AVah ytOyitPfgXK+Jyb3dlbWog565L2yUafRaU+6tJyb7LlJx/iIlHXsiROp4PxlNJE2+y9X VWQNPTcEdDMkjtNL1Q089OcInorVYJjI9BEXV7fUjOoGBsC6xP9UVvJ3NlQ79T2PV5RN Q6GHNuXQTPunO1KZmTVMEGrBiWxHHzK9SBqAtSTkCpfGZdsoCNJDx+0XyseZw+JMN6jF 2+0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BmxZTRZBnK7yUOPSxjkswt8tlawvL3sk+XGxF33VDzE=; b=pO/+0elWvVVuVEJ0DbFl64uNljXIiEa4stWCDSC6El5FT+C3Mio1SI5QYdTqXZ4p+9 wurg0CdJ7I8OxNljXC6Yh4H3OUvyyiknz5eycFzWyDZYQjj8a00HjcgMdmwGkAsbhOmc MxEvsuvBBnZse1FvFGFvmdrxGg88nAQpj3qZZbnNlawMpmQIGTDUwspL0QoikSMql6pB vzJEN8jLdDassB5wSrrVE4i8RflQ4uwORg3e6O3QEBrBPwsQeJV86V/mu3U+EvG3JRgr hZUIscg7kKqhhIbRbBLAPmG3NqQ/2AOaUkXPxTyIpMCX0Kk4OijpdbY475SqJMoig096 o8iA== X-Gm-Message-State: AOAM533gPGhLhI7jMf3626zIS09lAn5LTUVEn2nwPMz5+luT9b37asSc gtELRp7tgGBOEY6VIBZ+rKIR3aPMMzUe0/tW X-Google-Smtp-Source: ABdhPJz8l04rNgo+PVAn5g1xjJZ8zzh19aRywE37hkXgCDqiYurcB0HRoeb+yt+7kDfwTB8LoaEsrw== X-Received: by 2002:a05:6000:2cf:: with SMTP id o15mr4459163wry.184.1612524616408; Fri, 05 Feb 2021 03:30:16 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id f6sm8064912wmq.33.2021.02.05.03.30.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 03:30:15 -0800 (PST) From: luca.boccassi@gmail.com To: Maxime Coquelin Cc: Chenbo Xia , dpdk stable Date: Fri, 5 Feb 2021 11:16:25 +0000 Message-Id: <20210205111920.1272063-99-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210205111920.1272063-1-luca.boccassi@gmail.com> References: <20210205111920.1272063-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/virtio: add missing backend features negotiation' has been queued to stable release 20.11.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 20.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/07/21. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/a1d428777e2f1acc4af57c8c6525bd90be8bb153 Thanks. Luca Boccassi --- >From a1d428777e2f1acc4af57c8c6525bd90be8bb153 Mon Sep 17 00:00:00 2001 From: Maxime Coquelin Date: Fri, 8 Jan 2021 10:41:48 +0100 Subject: [PATCH] net/virtio: add missing backend features negotiation [ upstream commit 35a6630e2b51b872cfbaf19459888045750592fd ] This patch adds missing backend features negotiation for in Vhost-vDPA. Without it, IOTLB messages v2 could be sent by Virtio-user PMD while not supported by the backend. Fixes: 6b901437056e ("net/virtio: introduce vhost-vDPA backend") Signed-off-by: Maxime Coquelin Reviewed-by: Chenbo Xia --- drivers/net/virtio/virtio_user/vhost.h | 4 ++++ drivers/net/virtio/virtio_user/vhost_vdpa.c | 14 ++++++++++++++ drivers/net/virtio/virtio_user/virtio_user_dev.c | 14 ++++++++++---- drivers/net/virtio/virtio_user/virtio_user_dev.h | 4 +--- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/drivers/net/virtio/virtio_user/vhost.h b/drivers/net/virtio/virtio_user/vhost.h index 210a3704e7..c1dcc50b58 100644 --- a/drivers/net/virtio/virtio_user/vhost.h +++ b/drivers/net/virtio/virtio_user/vhost.h @@ -86,6 +86,10 @@ enum vhost_user_request { VHOST_USER_MAX }; +#ifndef VHOST_BACKEND_F_IOTLB_MSG_V2 +#define VHOST_BACKEND_F_IOTLB_MSG_V2 1 +#endif + extern const char * const vhost_msg_strings[VHOST_USER_MAX]; struct vhost_memory_region { diff --git a/drivers/net/virtio/virtio_user/vhost_vdpa.c b/drivers/net/virtio/virtio_user/vhost_vdpa.c index c7b9349fc8..b6c81d6f17 100644 --- a/drivers/net/virtio/virtio_user/vhost_vdpa.c +++ b/drivers/net/virtio/virtio_user/vhost_vdpa.c @@ -35,6 +35,8 @@ #define VHOST_VDPA_SET_STATUS _IOW(VHOST_VIRTIO, 0x72, __u8) #define VHOST_VDPA_SET_VRING_ENABLE _IOW(VHOST_VIRTIO, 0x75, \ struct vhost_vring_state) +#define VHOST_SET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x25, __u64) +#define VHOST_GET_BACKEND_FEATURES _IOR(VHOST_VIRTIO, 0x26, __u64) static uint64_t vhost_req_user_to_vdpa[] = { [VHOST_USER_SET_OWNER] = VHOST_SET_OWNER, @@ -51,6 +53,8 @@ static uint64_t vhost_req_user_to_vdpa[] = { [VHOST_USER_SET_STATUS] = VHOST_VDPA_SET_STATUS, [VHOST_USER_GET_STATUS] = VHOST_VDPA_GET_STATUS, [VHOST_USER_SET_VRING_ENABLE] = VHOST_VDPA_SET_VRING_ENABLE, + [VHOST_USER_GET_PROTOCOL_FEATURES] = VHOST_GET_BACKEND_FEATURES, + [VHOST_USER_SET_PROTOCOL_FEATURES] = VHOST_SET_BACKEND_FEATURES, }; /* no alignment requirement */ @@ -86,6 +90,11 @@ vhost_vdpa_dma_map(struct virtio_user_dev *dev, void *addr, { struct vhost_msg msg = {}; + if (!(dev->protocol_features & (1ULL << VHOST_BACKEND_F_IOTLB_MSG_V2))) { + PMD_DRV_LOG(ERR, "IOTLB_MSG_V2 not supported by the backend."); + return -1; + } + msg.type = VHOST_IOTLB_MSG_V2; msg.iotlb.type = VHOST_IOTLB_UPDATE; msg.iotlb.iova = iova; @@ -108,6 +117,11 @@ vhost_vdpa_dma_unmap(struct virtio_user_dev *dev, __rte_unused void *addr, { struct vhost_msg msg = {}; + if (!(dev->protocol_features & (1ULL << VHOST_BACKEND_F_IOTLB_MSG_V2))) { + PMD_DRV_LOG(ERR, "IOTLB_MSG_V2 not supported by the backend."); + return -1; + } + msg.type = VHOST_IOTLB_MSG_V2; msg.iotlb.type = VHOST_IOTLB_INVALIDATE; msg.iotlb.iova = iova; diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index e1cbad0d90..39c5dfc9e4 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -440,11 +440,13 @@ virtio_user_dev_setup(struct virtio_user_dev *dev) 1ULL << VIRTIO_F_RING_PACKED | \ 1ULL << VHOST_USER_F_PROTOCOL_FEATURES) -#define VIRTIO_USER_SUPPORTED_PROTOCOL_FEATURES \ +#define VHOST_USER_SUPPORTED_PROTOCOL_FEATURES \ (1ULL << VHOST_USER_PROTOCOL_F_MQ | \ 1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK | \ 1ULL << VHOST_USER_PROTOCOL_F_STATUS) +#define VHOST_VDPA_SUPPORTED_PROTOCOL_FEATURES \ + (1ULL << VHOST_BACKEND_F_IOTLB_MSG_V2) int virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues, int cq, int queue_size, const char *mac, char **ifname, @@ -463,9 +465,13 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues, dev->mac_specified = 0; dev->frontend_features = 0; dev->unsupported_features = ~VIRTIO_USER_SUPPORTED_FEATURES; - dev->protocol_features = VIRTIO_USER_SUPPORTED_PROTOCOL_FEATURES; dev->backend_type = backend_type; + if (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_USER) + dev->protocol_features = VHOST_USER_SUPPORTED_PROTOCOL_FEATURES; + else if (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_VDPA) + dev->protocol_features = VHOST_VDPA_SUPPORTED_PROTOCOL_FEATURES; + parse_mac(dev, mac); if (*ifname) { @@ -498,8 +504,8 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues, } - if (dev->device_features & - (1ULL << VHOST_USER_F_PROTOCOL_FEATURES)) { + if ((dev->device_features & (1ULL << VHOST_USER_F_PROTOCOL_FEATURES)) || + (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_VDPA)) { if (dev->ops->send_request(dev, VHOST_USER_GET_PROTOCOL_FEATURES, &protocol_features)) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h index e053897d8f..3b5b6bc3ae 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.h +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h @@ -48,9 +48,7 @@ struct virtio_user_dev { uint64_t device_features; /* supported features by device */ uint64_t frontend_features; /* enabled frontend features */ uint64_t unsupported_features; /* unsupported features mask */ - uint64_t protocol_features; /* negotiated protocol features - * (Vhost-user only) - */ + uint64_t protocol_features; /* negotiated protocol features */ uint8_t status; uint16_t net_status; uint16_t port_id; -- 2.29.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-02-05 11:18:33.701602683 +0000 +++ 0099-net-virtio-add-missing-backend-features-negotiation.patch 2021-02-05 11:18:28.950693853 +0000 @@ -1 +1 @@ -From 35a6630e2b51b872cfbaf19459888045750592fd Mon Sep 17 00:00:00 2001 +From a1d428777e2f1acc4af57c8c6525bd90be8bb153 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 35a6630e2b51b872cfbaf19459888045750592fd ] + @@ -11 +12,0 @@ -Cc: stable@dpdk.org @@ -38 +39 @@ -index c5b59e2f95..83c60ea660 100644 +index c7b9349fc8..b6c81d6f17 100644 @@ -71 +72 @@ -@@ -111,6 +120,11 @@ vhost_vdpa_dma_unmap(struct virtio_user_dev *dev, __rte_unused void *addr, +@@ -108,6 +117,11 @@ vhost_vdpa_dma_unmap(struct virtio_user_dev *dev, __rte_unused void *addr,