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 A1D5DA052A; Tue, 26 Jan 2021 11:20:46 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C6ADC1413AB; Tue, 26 Jan 2021 11:17:59 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id 2120F141399 for ; Tue, 26 Jan 2021 11:17:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611656276; 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=yQinrJBKfSBTWBX7CZ12GSUl1z9Ldgs6Z8fBLnWUtac=; b=h9IY/jsX4l5MXNvDjH10nhNmI8Cv3vMvG6R2MLQzdmWYwl0waoRZnoo7iIiNLxJ7gf0vqN xLL8MCzjTwoNWRhzahvGA8iQhnO2SYTX2q+h+ChXKY3pMP0wc0pP9SAT8FHi1cREFjE3BS 1Y3NMWrLXCmvvjne5OaMUjQIzr7emRI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-419-6EFTpvqRMYu6ZkU4jPjMAQ-1; Tue, 26 Jan 2021 05:17:54 -0500 X-MC-Unique: 6EFTpvqRMYu6ZkU4jPjMAQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3E3E218C8C02; Tue, 26 Jan 2021 10:17:53 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.36.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB36E6F45C; Tue, 26 Jan 2021 10:17:51 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, chenbo.xia@intel.com, olivier.matz@6wind.com, amorenoz@redhat.com, david.marchand@redhat.com Cc: Maxime Coquelin Date: Tue, 26 Jan 2021 11:16:18 +0100 Message-Id: <20210126101639.250481-24-maxime.coquelin@redhat.com> In-Reply-To: <20210126101639.250481-1-maxime.coquelin@redhat.com> References: <20210126101639.250481-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Subject: [dpdk-dev] [PATCH v4 23/44] net/virtio: move vring alignment to generic header 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 Sender: "dev" This patch moves vring alignment define to the generic Virtio header. Signed-off-by: Maxime Coquelin Reviewed-by: Chenbo Xia Reviewed-by: David Marchand --- drivers/net/virtio/virtio.h | 3 +++ drivers/net/virtio/virtio_ethdev.c | 10 +++++----- drivers/net/virtio/virtio_pci.c | 2 +- drivers/net/virtio/virtio_pci.h | 3 --- drivers/net/virtio/virtio_user_ethdev.c | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/net/virtio/virtio.h b/drivers/net/virtio/virtio.h index a7629ad16b..21d54904e7 100644 --- a/drivers/net/virtio/virtio.h +++ b/drivers/net/virtio/virtio.h @@ -131,6 +131,9 @@ /* Vector value used to disable MSI for queue. */ #define VIRTIO_MSI_NO_VECTOR 0xFFFF +/* The alignment to use between consumer and producer parts of vring. */ +#define VIRTIO_VRING_ALIGN 4096 + /* * This structure is just a reference to read net device specific * config space; it is just a shadow structure. diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 51eb5aebf3..a2195bdda8 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -407,12 +407,12 @@ virtio_init_vring(struct virtqueue *vq) 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, - VIRTIO_PCI_VRING_ALIGN, size); + 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_PCI_VRING_ALIGN, size); + vring_init_split(vr, ring_mem, VIRTIO_VRING_ALIGN, size); vring_desc_init_split(vr->desc, size); } /* @@ -497,14 +497,14 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t vtpci_queue_idx) /* * Reserve a memzone for vring elements */ - size = vring_size(hw, vq_size, VIRTIO_PCI_VRING_ALIGN); - vq->vq_ring_size = RTE_ALIGN_CEIL(size, VIRTIO_PCI_VRING_ALIGN); + size = vring_size(hw, vq_size, VIRTIO_VRING_ALIGN); + vq->vq_ring_size = RTE_ALIGN_CEIL(size, VIRTIO_VRING_ALIGN); PMD_INIT_LOG(DEBUG, "vring_size: %d, rounded_vring_size: %d", size, vq->vq_ring_size); mz = rte_memzone_reserve_aligned(vq_name, vq->vq_ring_size, numa_node, RTE_MEMZONE_IOVA_CONTIG, - VIRTIO_PCI_VRING_ALIGN); + VIRTIO_VRING_ALIGN); if (mz == NULL) { if (rte_errno == EEXIST) mz = rte_memzone_lookup(vq_name); diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c index 905534ac72..d27e9eb515 100644 --- a/drivers/net/virtio/virtio_pci.c +++ b/drivers/net/virtio/virtio_pci.c @@ -492,7 +492,7 @@ modern_setup_queue(struct virtio_hw *hw, struct virtqueue *vq) avail_addr = desc_addr + vq->vq_nentries * sizeof(struct vring_desc); used_addr = RTE_ALIGN_CEIL(avail_addr + offsetof(struct vring_avail, ring[vq->vq_nentries]), - VIRTIO_PCI_VRING_ALIGN); + VIRTIO_VRING_ALIGN); rte_write16(vq->vq_queue_index, &dev->common_cfg->queue_select); diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h index 68f36dc0dd..6cdf2c55dd 100644 --- a/drivers/net/virtio/virtio_pci.h +++ b/drivers/net/virtio/virtio_pci.h @@ -122,9 +122,6 @@ struct virtio_pci_dev { */ #define VIRTIO_PCI_QUEUE_ADDR_SHIFT 12 -/* The alignment to use between consumer and producer parts of vring. */ -#define VIRTIO_PCI_VRING_ALIGN 4096 - /* * Function declaration from virtio_pci.c */ diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index c3dc3908d6..91794b8645 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -388,7 +388,7 @@ virtio_user_setup_queue_packed(struct virtqueue *vq, sizeof(struct vring_packed_desc); used_addr = RTE_ALIGN_CEIL(avail_addr + sizeof(struct vring_packed_desc_event), - VIRTIO_PCI_VRING_ALIGN); + VIRTIO_VRING_ALIGN); vring->num = vq->vq_nentries; vring->desc = (void *)(uintptr_t)desc_addr; vring->driver = (void *)(uintptr_t)avail_addr; @@ -410,7 +410,7 @@ virtio_user_setup_queue_split(struct virtqueue *vq, struct virtio_user_dev *dev) avail_addr = desc_addr + vq->vq_nentries * sizeof(struct vring_desc); used_addr = RTE_ALIGN_CEIL(avail_addr + offsetof(struct vring_avail, ring[vq->vq_nentries]), - VIRTIO_PCI_VRING_ALIGN); + VIRTIO_VRING_ALIGN); dev->vrings[queue_idx].num = vq->vq_nentries; dev->vrings[queue_idx].desc = (void *)(uintptr_t)desc_addr; -- 2.29.2