[dpdk-dev] [PATCH v3 04/21] net/virtio: add packed virtqueue helpers
Tiwei Bie
tiwei.bie at intel.com
Thu Apr 5 16:40:29 CEST 2018
On Thu, Apr 05, 2018 at 04:27:51PM +0200, Maxime Coquelin wrote:
> On 04/05/2018 12:10 PM, Jens Freimann wrote:
> > Add helper functions to set/clear and check descriptor flags.
> >
> > Signed-off-by: Jens Freimann <jfreimann at redhat.com>
> > ---
> > drivers/net/virtio/virtio_ring.h | 33 +++++++++++++++++++++++++++++++++
> > drivers/net/virtio/virtqueue.c | 10 ++++++++++
> > 2 files changed, 43 insertions(+)
[...]
> > diff --git a/drivers/net/virtio/virtqueue.c b/drivers/net/virtio/virtqueue.c
> > index a7d0a9cbe..4f95ed5c8 100644
> > --- a/drivers/net/virtio/virtqueue.c
> > +++ b/drivers/net/virtio/virtqueue.c
> > @@ -58,6 +58,7 @@ virtqueue_detach_unused(struct virtqueue *vq)
> > void
> > virtqueue_rxvq_flush(struct virtqueue *vq)
> > {
> > + struct vring_desc_packed *descs = vq->vq_ring.desc_packed;
> > struct virtnet_rx *rxq = &vq->rxq;
> > struct virtio_hw *hw = vq->hw;
> > struct vring_used_elem *uep;
> > @@ -65,6 +66,15 @@ virtqueue_rxvq_flush(struct virtqueue *vq)
> > uint16_t used_idx, desc_idx;
> > uint16_t nb_used, i;
> > + if (vtpci_packed_queue(vq->hw)) {
> > + i = vq->vq_used_cons_idx & (vq->vq_nentries - 1);
> > + while (desc_is_used(&descs[i])) {
> > + rte_pktmbuf_free(vq->sw_ring[i]);
> > + vq->vq_free_cnt++;
> > + }
You need to increase i here. Otherwise you are looping
on the same entry. To increase i, you also need to keep
track of the number of descriptors need to be skipped
for each used descriptor.
> > + return;
> > + }
> > +
> > nb_used = VIRTQUEUE_NUSED(vq);
> > for (i = 0; i < nb_used; i++) {
> >
>
> With style comments taken into account:
>
> Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>
>
More information about the dev
mailing list