[dpdk-dev] [PATCH 4/5] virtio: fix ring size negotiation

Stephen Hemminger stephen at networkplumber.org
Thu Apr 16 07:47:39 CEST 2015


No warning is needed, it just works.

On Wed, Apr 15, 2015 at 8:39 PM, Ouyang, Changchun <
changchun.ouyang at intel.com> wrote:

>
>
> > -----Original Message-----
> > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Stephen
> > Hemminger
> > Sent: Wednesday, April 15, 2015 11:20 PM
> > To: dev at dpdk.org
> > Subject: [dpdk-dev] [PATCH 4/5] virtio: fix ring size negotiation
> >
> > This fixes another of the issues with running virtio on non-KVM
> > envirionments. For example, Google Compute Engine reports a ring size of
> > 16K.
> >
> > If guest virtio requests more slots than available then the queue should
> just
>
> I suspect 'more' here should be 'less'?
>
> > be initialized to the smaller value.
> >
> > Conversely, if the number of descriptors requested exceeds the virtio
> host
> > queue size, then just silently use the smaller host size.
> >
> > Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
> > ---
> >  lib/librte_pmd_virtio/virtio_ethdev.c | 18 +++++++++++++-----
> >  1 file changed, 13 insertions(+), 5 deletions(-)
> >
> > diff --git a/lib/librte_pmd_virtio/virtio_ethdev.c
> > b/lib/librte_pmd_virtio/virtio_ethdev.c
> > index 3cb9c6a..db0232e 100644
> > --- a/lib/librte_pmd_virtio/virtio_ethdev.c
> > +++ b/lib/librte_pmd_virtio/virtio_ethdev.c
> > @@ -267,13 +267,21 @@ int virtio_dev_queue_setup(struct rte_eth_dev
> > *dev,
> >       if (vq_size == 0) {
> >               PMD_INIT_LOG(ERR, "%s: virtqueue does not exist",
> > __func__);
> >               return -EINVAL;
> > -     } else if (!rte_is_power_of_2(vq_size)) {
> > +     }
> > +
> > +     if (!rte_is_power_of_2(vq_size)) {
> >               PMD_INIT_LOG(ERR, "%s: virtqueue size is not powerof 2",
> > __func__);
> >               return -EINVAL;
> > -     } else if (nb_desc != vq_size) {
> > -             PMD_INIT_LOG(ERR, "Warning: nb_desc(%d) is not equal to
> > vq size (%d), fall to vq size",
> > -                     nb_desc, vq_size);
> > -             nb_desc = vq_size;
> > +     }
> > +
> > +     if (nb_desc < vq_size) {
> > +             if (!rte_is_power_of_2(nb_desc)) {
> > +                     PMD_INIT_LOG(ERR,
> > +                                  "nb_desc(%u) size is not powerof 2",
> > +                                  nb_desc);
> > +                     return -EINVAL;
> > +             }
> > +             vq_size = nb_desc;
>
> Don't we need a warning when nb_desc > vq_size?
>
> >       }
> >
> >       if (queue_type == VTNET_RQ) {
> > --
> > 2.1.4
>
>


More information about the dev mailing list