On Sun, 19 Feb 2023 03:30:59 +0300
Levend Sayar <levendsa...@gmail.com> wrote:

> rx no_mbufs stats counter update is added for another error case.
> 
> Fixes: 4f6b1dd8240c ("net/gve: support basic statistics")
> Cc: junfeng....@intel.com
> 
> Signed-off-by: Levend Sayar <levendsa...@gmail.com>
> ---
>  drivers/net/gve/gve_rx.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/gve/gve_rx.c b/drivers/net/gve/gve_rx.c
> index 66fbcf3930..b0427731f8 100644
> --- a/drivers/net/gve/gve_rx.c
> +++ b/drivers/net/gve/gve_rx.c
> @@ -24,6 +24,7 @@ gve_rx_refill(struct gve_rx_queue *rxq)
>                               nmb = rte_pktmbuf_alloc(rxq->mpool);
>                               if (!nmb)
>                                       break;
> +
>                               rxq->sw_ring[idx + i] = nmb;
>                       }
>                       if (i != nb_alloc) {

Looks like accidental whitespace change included in this patch.

> @@ -59,9 +60,13 @@ gve_rx_refill(struct gve_rx_queue *rxq)
>                               nmb = rte_pktmbuf_alloc(rxq->mpool);
>                               if (!nmb)
>                                       break;
> +
>                               rxq->sw_ring[idx + i] = nmb;
>                       }
> -                     nb_alloc = i;
> +                     if (i != nb_alloc) {
> +                             rxq->no_mbufs += nb_alloc - i;
> +                             nb_alloc = i;
> +                     }

Would be better to add unlikely() here like:
                        if (unlikely(i < nb_alloc)) {
                                rxq->no_mbufs += nb_alloc - i;
                                nb_alloc = i;
                        }

Or eliminate conditional branch in hot path completely.
                        rxq->no_mbufs += nb_alloc - i;
                        nb_alloc = i;

Or better yet refactor code here to use rte_pktmbuf_alloc_bulk() which
does single ring operation.

>               }
>               rxq->nb_avail -= nb_alloc;
>               next_avail += nb_alloc;

Reply via email to