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;