> -----Original Message----- > From: Maxime Coquelin <maxime.coque...@redhat.com> > Sent: Monday, December 21, 2020 5:14 AM > To: dev@dpdk.org; Xia, Chenbo <chenbo....@intel.com>; olivier.m...@6wind.com; > amore...@redhat.com; david.march...@redhat.com > Cc: Maxime Coquelin <maxime.coque...@redhat.com> > Subject: [PATCH 21/40] net/virtio: move vring alignment to generic header > > This patch moves vring alignment define to the generic > Virtio header. > > Signed-off-by: Maxime Coquelin <maxime.coque...@redhat.com> > --- > 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 f44125f48a..964e15bb22 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 just a chodu structure > diff --git a/drivers/net/virtio/virtio_ethdev.c > b/drivers/net/virtio/virtio_ethdev.c > index 99a2dd24c4..1ca8715832 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 01a437a1b4..f8532c5684 100644 > --- a/drivers/net/virtio/virtio_pci.c > +++ b/drivers/net/virtio/virtio_pci.c > @@ -432,7 +432,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 4ee890ffda..2cb3ebf93d 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 eacb268297..283f5c7a36 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
Reviewed-by: Chenbo Xia <chenbo....@intel.com>