From patchwork Wed Jul 3 10:03:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srujana Challa X-Patchwork-Id: 142060 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 38EFE4555B; Wed, 3 Jul 2024 12:04:06 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 41ED8415D7; Wed, 3 Jul 2024 12:04:04 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 6E0AB41153 for ; Wed, 3 Jul 2024 12:04:02 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4639VLJX026180; Wed, 3 Jul 2024 03:04:01 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=j LOr00HBNbru7hkEk2i227GY6lzJ4PReTUh2LjJytoM=; b=ATPOSjc1ACoeu43eH K15rujQDRrl0F2iG6dPFYR3tCPSr+wBnmhzpL3BWvg5zUQnxcxbrUqvoHBPuIL8e F5vJBOUBhLx0ng9cAtvpYwyi/Sd6QeaaSagk+7fc0Q+/LbasxHlk15zAbu0f0J0k 7LuZB4pys3JjK2jpIjIhtUoTPtV1Yr+MX5DmWyZvVt2IxGo1DnPzUK8kF9H+Oyfc 3hhXjGNjfbsnn00MNUpdMisHHK+GfUlqeDqeyDy0IjqqzZU0R217qBpOpMVHmzaI 068oaSxoQcbyIeibMg+wkTGDQZuqFfvgIJIIC4Vodcf1bEc0ReEjXSv4iLQg1CDd xtavw== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 40542y03px-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 03 Jul 2024 03:04:01 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 3 Jul 2024 03:03:59 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 3 Jul 2024 03:03:59 -0700 Received: from localhost.localdomain (unknown [10.28.36.175]) by maili.marvell.com (Postfix) with ESMTP id 6EDE95B6921; Wed, 3 Jul 2024 03:03:57 -0700 (PDT) From: Srujana Challa To: , , CC: , , , Subject: [PATCH v3 1/3] net/virtio_user: convert cq descriptor IOVA address to Virtual address Date: Wed, 3 Jul 2024 15:33:51 +0530 Message-ID: <20240703100353.2243038-2-schalla@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240703100353.2243038-1-schalla@marvell.com> References: <20240229132919.2186118-2-schalla@marvell.com> <20240703100353.2243038-1-schalla@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: aOqDG2YdVnZNOMtZMyn93Fv1TanSbWyU X-Proofpoint-ORIG-GUID: aOqDG2YdVnZNOMtZMyn93Fv1TanSbWyU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-03_06,2024-07-02_02,2024-05-17_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This patch modifies the code to convert descriptor buffer IOVA addresses to virtual addresses during the processing of shadow control queue when IOVA mode is PA. This change enables Virtio-user to operate with IOVA as the descriptor buffer address. Signed-off-by: Srujana Challa Reviewed-by: Maxime Coquelin --- .../net/virtio/virtio_user/virtio_user_dev.c | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index 1365c8a5c8..7f35f4b06b 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -896,6 +896,15 @@ virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t q_pairs) #define CVQ_MAX_DATA_DESCS 32 +static inline void * +virtio_user_iova2virt(rte_iova_t iova) +{ + if (rte_eal_iova_mode() == RTE_IOVA_PA) + return rte_mem_iova2virt(iova); + else + return (void *)(uintptr_t)iova; +} + static uint32_t virtio_user_handle_ctrl_msg_split(struct virtio_user_dev *dev, struct vring *vring, uint16_t idx_hdr) @@ -921,17 +930,18 @@ virtio_user_handle_ctrl_msg_split(struct virtio_user_dev *dev, struct vring *vri idx_status = i; n_descs++; - hdr = (void *)(uintptr_t)vring->desc[idx_hdr].addr; + hdr = virtio_user_iova2virt(vring->desc[idx_hdr].addr); if (hdr->class == VIRTIO_NET_CTRL_MQ && hdr->cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) { - uint16_t queues; + uint16_t queues, *addr; - queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr; + addr = virtio_user_iova2virt(vring->desc[idx_data].addr); + queues = *addr; status = virtio_user_handle_mq(dev, queues); } else if (hdr->class == VIRTIO_NET_CTRL_MQ && hdr->cmd == VIRTIO_NET_CTRL_MQ_RSS_CONFIG) { struct virtio_net_ctrl_rss *rss; - rss = (struct virtio_net_ctrl_rss *)(uintptr_t)vring->desc[idx_data].addr; + rss = virtio_user_iova2virt(vring->desc[idx_data].addr); status = virtio_user_handle_mq(dev, rss->max_tx_vq); } else if (hdr->class == VIRTIO_NET_CTRL_RX || hdr->class == VIRTIO_NET_CTRL_MAC || @@ -944,7 +954,7 @@ virtio_user_handle_ctrl_msg_split(struct virtio_user_dev *dev, struct vring *vri (struct virtio_pmd_ctrl *)hdr, dlen, nb_dlen); /* Update status */ - *(virtio_net_ctrl_ack *)(uintptr_t)vring->desc[idx_status].addr = status; + *(virtio_net_ctrl_ack *)virtio_user_iova2virt(vring->desc[idx_status].addr) = status; return n_descs; } @@ -986,18 +996,18 @@ virtio_user_handle_ctrl_msg_packed(struct virtio_user_dev *dev, n_descs++; } - hdr = (void *)(uintptr_t)vring->desc[idx_hdr].addr; + hdr = virtio_user_iova2virt(vring->desc[idx_hdr].addr); if (hdr->class == VIRTIO_NET_CTRL_MQ && hdr->cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) { - uint16_t queues; + uint16_t queues, *addr; - queues = *(uint16_t *)(uintptr_t) - vring->desc[idx_data].addr; + addr = virtio_user_iova2virt(vring->desc[idx_data].addr); + queues = *addr; status = virtio_user_handle_mq(dev, queues); } else if (hdr->class == VIRTIO_NET_CTRL_MQ && hdr->cmd == VIRTIO_NET_CTRL_MQ_RSS_CONFIG) { struct virtio_net_ctrl_rss *rss; - rss = (struct virtio_net_ctrl_rss *)(uintptr_t)vring->desc[idx_data].addr; + rss = virtio_user_iova2virt(vring->desc[idx_data].addr); status = virtio_user_handle_mq(dev, rss->max_tx_vq); } else if (hdr->class == VIRTIO_NET_CTRL_RX || hdr->class == VIRTIO_NET_CTRL_MAC || @@ -1010,8 +1020,7 @@ virtio_user_handle_ctrl_msg_packed(struct virtio_user_dev *dev, (struct virtio_pmd_ctrl *)hdr, dlen, nb_dlen); /* Update status */ - *(virtio_net_ctrl_ack *)(uintptr_t) - vring->desc[idx_status].addr = status; + *(virtio_net_ctrl_ack *)virtio_user_iova2virt(vring->desc[idx_status].addr) = status; /* Update used descriptor */ vring->desc[idx_hdr].id = vring->desc[idx_status].id; From patchwork Wed Jul 3 10:03:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srujana Challa X-Patchwork-Id: 142061 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6FAC94555B; Wed, 3 Jul 2024 12:04:11 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6C5B9427AD; Wed, 3 Jul 2024 12:04:07 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 60FFE427AD for ; Wed, 3 Jul 2024 12:04:05 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4639VLJd026180; Wed, 3 Jul 2024 03:04:04 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=n G57nfZ7A5BmVI18RfZaA9srzKWYOLCtvFckdgl68fU=; b=TDUU+qREZtBLfe9lO FC1XQ43qoOo6ywYO68SJlne8E++jBo5zsqtib7mj+1XQvdg7v+z/GpFU3DobvxVP tQ4/MTrLw3w4b2iIob4n1efY+TAoYO4omHnZs3r/Diap7t0IFrggupKX5w7uN6iR vWjVN+NxTQiAuJ/kS6xb+2dLQRXMKJnW2fkRUyr15eb2umNVYXLeWRSJGas1wHeq 23jPJwvS3cBIRWasIzfeDEzue8vESySuNP4tTgmYNIjcw0QNhSnK1VHiUsH4P+X6 BrOJu06hWGVPefB3Uud9ls3D74aH/VpyTtEs27vXaUElS2idiSiG/YzY/15YPKvm Dt0CA== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 40542y03q7-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 03 Jul 2024 03:04:04 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 3 Jul 2024 03:04:02 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 3 Jul 2024 03:04:02 -0700 Received: from localhost.localdomain (unknown [10.28.36.175]) by maili.marvell.com (Postfix) with ESMTP id 3573B5B6921; Wed, 3 Jul 2024 03:03:59 -0700 (PDT) From: Srujana Challa To: , , CC: , , , Subject: [PATCH v3 2/3] net/virtio: store desc IOVA address in vring data structure Date: Wed, 3 Jul 2024 15:33:52 +0530 Message-ID: <20240703100353.2243038-3-schalla@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240703100353.2243038-1-schalla@marvell.com> References: <20240229132919.2186118-2-schalla@marvell.com> <20240703100353.2243038-1-schalla@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: UQzGfau3uXZCmpJdKgW6u0eKFuAOiBQP X-Proofpoint-ORIG-GUID: UQzGfau3uXZCmpJdKgW6u0eKFuAOiBQP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-03_06,2024-07-02_02,2024-05-17_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Stores desc IOVA in the queue's vring data structure, as preliminary work to provide a way for Virtio-user to share desc IOVA to the vhost backend. Signed-off-by: Srujana Challa Reviewed-by: Maxime Coquelin --- drivers/net/virtio/virtio_ring.h | 12 ++++++++---- drivers/net/virtio/virtqueue.c | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/net/virtio/virtio_ring.h b/drivers/net/virtio/virtio_ring.h index 2a25751152..57568c66a9 100644 --- a/drivers/net/virtio/virtio_ring.h +++ b/drivers/net/virtio/virtio_ring.h @@ -83,6 +83,7 @@ struct vring_packed_desc_event { struct vring_packed { unsigned int num; + rte_iova_t desc_iova; struct vring_packed_desc *desc; struct vring_packed_desc_event *driver; struct vring_packed_desc_event *device; @@ -90,6 +91,7 @@ struct vring_packed { struct vring { unsigned int num; + rte_iova_t desc_iova; struct vring_desc *desc; struct vring_avail *avail; struct vring_used *used; @@ -149,11 +151,12 @@ vring_size(struct virtio_hw *hw, unsigned int num, unsigned long align) return size; } static inline void -vring_init_split(struct vring *vr, uint8_t *p, unsigned long align, - unsigned int num) +vring_init_split(struct vring *vr, uint8_t *p, rte_iova_t iova, + unsigned long align, unsigned int num) { vr->num = num; vr->desc = (struct vring_desc *) p; + vr->desc_iova = iova; vr->avail = (struct vring_avail *) (p + num * sizeof(struct vring_desc)); vr->used = (void *) @@ -161,11 +164,12 @@ vring_init_split(struct vring *vr, uint8_t *p, unsigned long align, } static inline void -vring_init_packed(struct vring_packed *vr, uint8_t *p, unsigned long align, - unsigned int num) +vring_init_packed(struct vring_packed *vr, uint8_t *p, rte_iova_t iova, + unsigned long align, unsigned int num) { vr->num = num; vr->desc = (struct vring_packed_desc *)p; + vr->desc_iova = iova; vr->driver = (struct vring_packed_desc_event *)(p + vr->num * sizeof(struct vring_packed_desc)); vr->device = (struct vring_packed_desc_event *) diff --git a/drivers/net/virtio/virtqueue.c b/drivers/net/virtio/virtqueue.c index 6f419665f1..cf46abfd06 100644 --- a/drivers/net/virtio/virtqueue.c +++ b/drivers/net/virtio/virtqueue.c @@ -282,13 +282,13 @@ virtio_init_vring(struct virtqueue *vq) vq->vq_free_cnt = vq->vq_nentries; memset(vq->vq_descx, 0, sizeof(struct vq_desc_extra) * vq->vq_nentries); if (virtio_with_packed_queue(vq->hw)) { - vring_init_packed(&vq->vq_packed.ring, ring_mem, + vring_init_packed(&vq->vq_packed.ring, ring_mem, vq->vq_ring_mem, VIRTIO_VRING_ALIGN, size); vring_desc_init_packed(vq, size); } else { struct vring *vr = &vq->vq_split.ring; - vring_init_split(vr, ring_mem, VIRTIO_VRING_ALIGN, size); + vring_init_split(vr, ring_mem, vq->vq_ring_mem, VIRTIO_VRING_ALIGN, size); vring_desc_init_split(vr->desc, size); } /* From patchwork Wed Jul 3 10:03:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srujana Challa X-Patchwork-Id: 142062 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2BC664555B; Wed, 3 Jul 2024 12:04:17 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8CF01427CD; Wed, 3 Jul 2024 12:04:08 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 51C5A411F3 for ; Wed, 3 Jul 2024 12:04:07 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4639VL5w026181; Wed, 3 Jul 2024 03:04:06 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=7 35UWl32qGZsZyvtPMGsYOG/GwE/0eoRP5/az57TgVk=; b=ddce5pwvG0q7OM61d S2U25ox2Za+VfWk5gNNWoqj3fwkTvbDDTnJ78AxLJSwRvN/MAksWo6RAhKlJ2YXO LBeT4cy2SWlK3f8l/WHBK+L9Lyvw4NnGDoCg9RUwYwfVuXflotj7va/rUZ16oijc Na9+L0S4PJLiqkKOaV3/apMDC+Wke0B26+iBIOkoIUvg8dfnMPBPnXMvZMPCOshl +V3pDaGxwHV7TzaGE6Its4dQJaMWk0Xio4PmvqD/TzyRGkkf8+F+RQ3xk+J4QtvJ 1KPvfergPegllWY8vXmCSlifc3/wOLRC3pDwd6uIbuMij+eEf3tQqEJHco/j5Fqj VTfKg== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 40542y03rn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 03 Jul 2024 03:04:06 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 3 Jul 2024 03:04:05 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 3 Jul 2024 03:04:05 -0700 Received: from localhost.localdomain (unknown [10.28.36.175]) by maili.marvell.com (Postfix) with ESMTP id 0736F5B6922; Wed, 3 Jul 2024 03:04:02 -0700 (PDT) From: Srujana Challa To: , , CC: , , , Subject: [PATCH v3 3/3] net/virtio_user: support sharing vq descriptor IOVA to the backend Date: Wed, 3 Jul 2024 15:33:53 +0530 Message-ID: <20240703100353.2243038-4-schalla@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240703100353.2243038-1-schalla@marvell.com> References: <20240229132919.2186118-2-schalla@marvell.com> <20240703100353.2243038-1-schalla@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: xs8l-qTq8V5VMwtYHSdbBoSL4oUUGQLH X-Proofpoint-ORIG-GUID: xs8l-qTq8V5VMwtYHSdbBoSL4oUUGQLH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-03_06,2024-07-02_02,2024-05-17_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Adds support to share descriptor IOVA to the vhost backend. This makes virtio_user driver works in IOVA as PA mode when use_va flag is disabled. This patch also disables use_va flag for VDPA backend. Signed-off-by: Srujana Challa Reviewed-by: Maxime Coquelin --- .../net/virtio/virtio_user/virtio_user_dev.c | 26 ++++++++++++------- drivers/net/virtio/virtio_user_ethdev.c | 10 ++++++- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index 7f35f4b06b..02324501fb 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -118,6 +118,7 @@ virtio_user_kick_queue(struct virtio_user_dev *dev, uint32_t queue_sel) struct vhost_vring_state state; struct vring *vring = &dev->vrings.split[queue_sel]; struct vring_packed *pq_vring = &dev->vrings.packed[queue_sel]; + uint64_t desc_addr, avail_addr, used_addr; struct vhost_vring_addr addr = { .index = queue_sel, .log_guest_addr = 0, @@ -137,16 +138,23 @@ virtio_user_kick_queue(struct virtio_user_dev *dev, uint32_t queue_sel) } if (dev->features & (1ULL << VIRTIO_F_RING_PACKED)) { - addr.desc_user_addr = - (uint64_t)(uintptr_t)pq_vring->desc; - addr.avail_user_addr = - (uint64_t)(uintptr_t)pq_vring->driver; - addr.used_user_addr = - (uint64_t)(uintptr_t)pq_vring->device; + desc_addr = pq_vring->desc_iova; + avail_addr = desc_addr + pq_vring->num * sizeof(struct vring_packed_desc); + used_addr = RTE_ALIGN_CEIL(avail_addr + sizeof(struct vring_packed_desc_event), + VIRTIO_VRING_ALIGN); + + addr.desc_user_addr = desc_addr; + addr.avail_user_addr = avail_addr; + addr.used_user_addr = used_addr; } else { - addr.desc_user_addr = (uint64_t)(uintptr_t)vring->desc; - addr.avail_user_addr = (uint64_t)(uintptr_t)vring->avail; - addr.used_user_addr = (uint64_t)(uintptr_t)vring->used; + desc_addr = vring->desc_iova; + avail_addr = desc_addr + vring->num * sizeof(struct vring_desc); + used_addr = RTE_ALIGN_CEIL((uintptr_t)(&vring->avail->ring[vring->num]), + VIRTIO_VRING_ALIGN); + + addr.desc_user_addr = desc_addr; + addr.avail_user_addr = avail_addr; + addr.used_user_addr = used_addr; } state.index = queue_sel; diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index bf9de36d8f..ae6593ba0b 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -198,6 +198,7 @@ virtio_user_setup_queue_packed(struct virtqueue *vq, sizeof(struct vring_packed_desc_event), VIRTIO_VRING_ALIGN); vring->num = vq->vq_nentries; + vring->desc_iova = vq->vq_ring_mem; vring->desc = (void *)(uintptr_t)desc_addr; vring->driver = (void *)(uintptr_t)avail_addr; vring->device = (void *)(uintptr_t)used_addr; @@ -221,6 +222,7 @@ virtio_user_setup_queue_split(struct virtqueue *vq, struct virtio_user_dev *dev) VIRTIO_VRING_ALIGN); dev->vrings.split[queue_idx].num = vq->vq_nentries; + dev->vrings.split[queue_idx].desc_iova = vq->vq_ring_mem; dev->vrings.split[queue_idx].desc = (void *)(uintptr_t)desc_addr; dev->vrings.split[queue_idx].avail = (void *)(uintptr_t)avail_addr; dev->vrings.split[queue_idx].used = (void *)(uintptr_t)used_addr; @@ -689,7 +691,13 @@ virtio_user_pmd_probe(struct rte_vdev_device *vdev) * Virtio-user requires using virtual addresses for the descriptors * buffers, whatever other devices require */ - hw->use_va = true; + if (backend_type == VIRTIO_USER_BACKEND_VHOST_VDPA) + /* VDPA backend requires using iova for the buffers to make it + * work in IOVA as PA mode also. + */ + hw->use_va = false; + else + hw->use_va = true; /* previously called by pci probing for physical dev */ if (eth_virtio_dev_init(eth_dev) < 0) {