From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dmarchan@redhat.com>
Received: from mail-ua1-f42.google.com (mail-ua1-f42.google.com
 [209.85.222.42]) by dpdk.org (Postfix) with ESMTP id 243E72C17
 for <dev@dpdk.org>; Mon,  4 Mar 2019 12:35:00 +0100 (CET)
Received: by mail-ua1-f42.google.com with SMTP id g1so4067749uae.10
 for <dev@dpdk.org>; Mon, 04 Mar 2019 03:35:00 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to:cc;
 bh=xKK36UpTHapr+D11PLzpolvoPQ9grSjEcf/vUDKd7mM=;
 b=jZ8FZ0kOxe8gkOYeYOJf7xADpvKfkviItuwSX4eaNydIaKyDf6PxhYkI9PZL+ltMvc
 kTWdCcl0hd0ak+++A6V5TtLignCvO6NnMCBYrB+vRn9OX/r2SMbsOXoxrafVk2SBc/uW
 NTcPFzpz0oaH29qAR9supQxMBThDqfQ+hXAFmZl7kZO7ypyvSys1AFfEVc4hxtU1wJQ4
 w6y6U8CRK08xcpGu06desWzmpgRFdolFtcDtVKQXWLZjhF32aXPgaoE7BBqhyNLZBMaM
 TnIXEN8ma73fGyczsv6eJnPbOtt+6DTHEzJ8d6Gtw1d54Th4uamr0hi5k6W92U1XIRkn
 abtQ==
X-Gm-Message-State: APjAAAU2ogYqmHAnE7xGopjXhG0mhO+kpy0uSv5XVDjurnfUiAK51Odl
 CEsV0olUqf79NsR6H0G94+hSEZRx/pnN34EffhptUg==
X-Google-Smtp-Source: APXvYqwExKarItF0XJADb+oAIFThVusliPF9p9+euCepoQJk2w9JKvf+Vh6yucKWjK4knLl0Q2G+JVIsSPTDpwasKBk=
X-Received: by 2002:ab0:7c1:: with SMTP id d1mr2829718uaf.39.1551699299498;
 Mon, 04 Mar 2019 03:34:59 -0800 (PST)
MIME-Version: 1.0
References: <1551185824-5501-2-git-send-email-cernay@netcope.com>
 <1551451054-111249-1-git-send-email-cernay@netcope.com>
In-Reply-To: <1551451054-111249-1-git-send-email-cernay@netcope.com>
From: David Marchand <david.marchand@redhat.com>
Date: Mon, 4 Mar 2019 12:34:48 +0100
Message-ID: <CAJFAV8yD8dzps6vu7Twp54SvPF9wqd9vgWR9FAzJBhTLdAhWCw@mail.gmail.com>
To: Rastislav Cernay <cernay@netcope.com>
Cc: dev@dpdk.org, "Yigit, Ferruh" <ferruh.yigit@intel.com>
Content-Type: text/plain; charset="UTF-8"
X-Content-Filtered-By: Mailman/MimeDel 2.1.15
Subject: Re: [dpdk-dev] [PATCH v3] net/nfb: new netcope driver
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Mon, 04 Mar 2019 11:35:00 -0000

On Fri, Mar 1, 2019 at 3:38 PM Rastislav Cernay <cernay@netcope.com> wrote:

> diff --git a/drivers/net/nfb/nfb_stats.c b/drivers/net/nfb/nfb_stats.c
> new file mode 100644
> index 0000000..ffc27a5
> --- /dev/null
> +++ b/drivers/net/nfb/nfb_stats.c
> @@ -0,0 +1,78 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2018 Cesnet
> + * Copyright(c) 2018 Netcope Technologies, a.s. <info@netcope.com>
> + * All rights reserved.
> + */
> +
> +#include "nfb_stats.h"
> +#include "nfb.h"
> +
> +int
> +nfb_eth_stats_get(struct rte_eth_dev *dev,
> +       struct rte_eth_stats *stats)
> +{
> +       uint16_t i;
> +       uint16_t nb_rx = dev->data->nb_rx_queues;
> +       uint16_t nb_tx = dev->data->nb_tx_queues;
> +       uint64_t rx_total = 0;
> +       uint64_t tx_total = 0;
> +       uint64_t tx_err_total = 0;
> +       uint64_t rx_total_bytes = 0;
> +       uint64_t tx_total_bytes = 0;
> +
> +       struct ndp_rx_queue *rx_queue = *((struct ndp_rx_queue **)
> +               dev->data->rx_queues);
> +       struct ndp_tx_queue *tx_queue = *((struct ndp_tx_queue **)
> +               dev->data->tx_queues);
> +
> +       for (i = 0; i < nb_rx; i++) {
> +               if (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) {
> +                       stats->q_ipackets[i] = rx_queue[i].rx_pkts;
> +                       stats->q_ibytes[i] = rx_queue[i].rx_bytes;
> +               }
> +               rx_total += stats->q_ipackets[i];
> +               rx_total_bytes += stats->q_ibytes[i];
> +       }
>

What is the point of adding when i >= RTE_ETHDEV_QUEUE_STAT_CNTRS ?
Hopefully, ethdev passes a zero'd structure, but still I find it confusing.



> +
> +       for (i = 0; i < nb_tx; i++) {
> +               if (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) {
> +                       stats->q_opackets[i] = tx_queue[i].tx_pkts;
> +                       stats->q_obytes[i] = tx_queue[i].tx_bytes;
> +                       stats->q_errors[i] = tx_queue[i].err_pkts;
> +               }
> +               tx_total += stats->q_opackets[i];
> +               tx_total_bytes += stats->q_obytes[i];
> +               tx_err_total += stats->q_errors[i];
> +       }
>

Idem.
Besides, q_errors[] is for reception errors.

+
> +       stats->ipackets = rx_total;
> +       stats->opackets = tx_total;
> +       stats->ibytes = rx_total_bytes;
> +       stats->obytes = tx_total_bytes;
> +       stats->oerrors = tx_err_total;
> +       return 0;
> +}
>
>
-- 
David Marchand