From patchwork Wed Nov 30 15:56:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 120366 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 AF3C0A00C2; Wed, 30 Nov 2022 16:57:50 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DAF4342D29; Wed, 30 Nov 2022 16:57:05 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 99D3442D3C for ; Wed, 30 Nov 2022 16:57:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669823822; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xWJ1aeOTqDd5dNsjuYnWJM18lV53ZyzPPQzc9fz+Y4g=; b=NCxDy8ZlWhsgvGSA3HQBXbP8W2i8IX4LkJq8OjsXC/zz42/GKOtINq2SQP3LvWlmzLhfvB XSqW6BiZIaVN3dnBe8Xd2Lo+6nuKpNQydX+Pi3EpIDVXhmEjjXObC2NG8DE3S1j7EWb3dX NOeFJtxt6dsTJEl5BwqgAEjeZS+99lA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-503-H8tyDx90PtWRg8x92wON4A-1; Wed, 30 Nov 2022 10:57:00 -0500 X-MC-Unique: H8tyDx90PtWRg8x92wON4A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 43D97299E76A; Wed, 30 Nov 2022 15:57:00 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.39.208.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23AB340C2144; Wed, 30 Nov 2022 15:56:58 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, chenbo.xia@intel.com, david.marchand@redhat.com, eperezma@redhat.com Cc: Maxime Coquelin Subject: [PATCH v1 08/21] net/virtio: move vring memzone to virtqueue struct Date: Wed, 30 Nov 2022 16:56:26 +0100 Message-Id: <20221130155639.150553-9-maxime.coquelin@redhat.com> In-Reply-To: <20221130155639.150553-1-maxime.coquelin@redhat.com> References: <20221130155639.150553-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 Whatever its type (Rx, Tx or Ctl), all the virtqueue require a memzone for the vrings. This patch moves its pointer to the virtqueue struct, simplifying the code. Signed-off-by: Maxime Coquelin Reviewed-by: Chenbo Xia --- drivers/net/virtio/virtio_cvq.h | 1 - drivers/net/virtio/virtio_ethdev.c | 11 ++--------- drivers/net/virtio/virtio_rxtx.h | 4 ---- drivers/net/virtio/virtqueue.c | 6 ++---- drivers/net/virtio/virtqueue.h | 1 + 5 files changed, 5 insertions(+), 18 deletions(-) diff --git a/drivers/net/virtio/virtio_cvq.h b/drivers/net/virtio/virtio_cvq.h index 0ff326b063..70739ae04b 100644 --- a/drivers/net/virtio/virtio_cvq.h +++ b/drivers/net/virtio/virtio_cvq.h @@ -108,7 +108,6 @@ typedef uint8_t virtio_net_ctrl_ack; struct virtnet_ctl { const struct rte_memzone *hdr_mz; /**< memzone to populate hdr. */ rte_iova_t hdr_mem; /**< hdr for each xmit packet */ - const struct rte_memzone *mz; /**< mem zone to populate CTL ring. */ rte_spinlock_t lock; /**< spinlock for control queue. */ void (*notify_queue)(struct virtqueue *vq, void *cookie); /**< notify ops. */ void *notify_cookie; /**< cookie for notify ops */ diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index a581fae408..b546916a9f 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -423,6 +423,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx) memset(mz->addr, 0, mz->len); + vq->mz = mz; if (hw->use_va) vq->vq_ring_mem = (uintptr_t)mz->addr; else @@ -462,14 +463,11 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx) vq->sw_ring = sw_ring; rxvq = &vq->rxq; - rxvq->mz = mz; rxvq->fake_mbuf = fake_mbuf; } else if (queue_type == VTNET_TQ) { txvq = &vq->txq; - txvq->mz = mz; } else if (queue_type == VTNET_CQ) { cvq = &vq->cq; - cvq->mz = mz; hw->cvq = cvq; vq->cq.notify_queue = &virtio_control_queue_notify; } @@ -550,15 +548,10 @@ virtio_free_queues(struct virtio_hw *hw) if (queue_type == VTNET_RQ) { rte_free(vq->rxq.fake_mbuf); rte_free(vq->sw_ring); - rte_memzone_free(vq->rxq.mz); - } else if (queue_type == VTNET_TQ) { - rte_memzone_free(vq->txq.mz); - } else { - rte_memzone_free(vq->cq.mz); } virtio_free_queue_headers(vq); - + rte_memzone_free(vq->mz); rte_free(vq); hw->vqs[i] = NULL; } diff --git a/drivers/net/virtio/virtio_rxtx.h b/drivers/net/virtio/virtio_rxtx.h index a5fe3ea95c..57af630110 100644 --- a/drivers/net/virtio/virtio_rxtx.h +++ b/drivers/net/virtio/virtio_rxtx.h @@ -25,8 +25,6 @@ struct virtnet_rx { /* Statistics */ struct virtnet_stats stats; - - const struct rte_memzone *mz; /**< mem zone to populate RX ring. */ }; struct virtnet_tx { @@ -34,8 +32,6 @@ struct virtnet_tx { rte_iova_t hdr_mem; /**< hdr for each xmit packet */ struct virtnet_stats stats; /* Statistics */ - - const struct rte_memzone *mz; /**< mem zone to populate TX ring. */ }; int virtio_rxq_vec_setup(struct virtnet_rx *rxvq); diff --git a/drivers/net/virtio/virtqueue.c b/drivers/net/virtio/virtqueue.c index 3b174a5923..41e3529546 100644 --- a/drivers/net/virtio/virtqueue.c +++ b/drivers/net/virtio/virtqueue.c @@ -148,7 +148,6 @@ virtqueue_rxvq_reset_packed(struct virtqueue *vq) { int size = vq->vq_nentries; struct vq_desc_extra *dxp; - struct virtnet_rx *rxvq; uint16_t desc_idx; vq->vq_used_cons_idx = 0; @@ -162,8 +161,7 @@ virtqueue_rxvq_reset_packed(struct virtqueue *vq) vq->vq_packed.event_flags_shadow = 0; vq->vq_packed.cached_flags |= VRING_DESC_F_WRITE; - rxvq = &vq->rxq; - memset(rxvq->mz->addr, 0, rxvq->mz->len); + memset(vq->mz->addr, 0, vq->mz->len); for (desc_idx = 0; desc_idx < vq->vq_nentries; desc_idx++) { dxp = &vq->vq_descx[desc_idx]; @@ -201,7 +199,7 @@ virtqueue_txvq_reset_packed(struct virtqueue *vq) txvq = &vq->txq; txr = txvq->hdr_mz->addr; - memset(txvq->mz->addr, 0, txvq->mz->len); + memset(vq->mz->addr, 0, vq->mz->len); memset(txvq->hdr_mz->addr, 0, txvq->hdr_mz->len); for (desc_idx = 0; desc_idx < vq->vq_nentries; desc_idx++) { diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h index f5058f362c..8b7bfae643 100644 --- a/drivers/net/virtio/virtqueue.h +++ b/drivers/net/virtio/virtqueue.h @@ -201,6 +201,7 @@ struct virtqueue { struct virtnet_ctl cq; }; + const struct rte_memzone *mz; /**< mem zone to populate ring. */ rte_iova_t vq_ring_mem; /**< physical address of vring, * or virtual address for virtio_user. */