DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dpdk-dev <dev@dpdk.org>
Cc: Ferruh Yigit <ferruh.yigit@intel.com>,
	Somnath Kotur <somnath.kotur@broadcom.com>
Subject: Re: [dpdk-dev] [PATCH] net/bnxt: add PCI function stats to extended stats
Date: Fri, 17 Apr 2020 07:50:19 -0700	[thread overview]
Message-ID: <CACZ4nhvqfDcjzqZd19sQFQeRYvcMyVAb6C-uSKu1AaZNT=PbWA@mail.gmail.com> (raw)
In-Reply-To: <20200415225822.61874-1-ajit.khaparde@broadcom.com>

On Wed, Apr 15, 2020 at 3:58 PM Ajit Khaparde <ajit.khaparde@broadcom.com>
wrote:

> HWRM API allows drivers to query stats per PCI function.
> These stats can provide some useful information in certain
> circumstances.
>
> Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
> Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
>
Patch applied to dpdk-next-net-brcm.


> ---
>  drivers/net/bnxt/bnxt_hwrm.c    | 10 +++++++-
>  drivers/net/bnxt/bnxt_hwrm.h    |  4 +++-
>  drivers/net/bnxt/bnxt_stats.c   | 42 +++++++++++++++++++--------------
>  drivers/net/bnxt/rte_pmd_bnxt.c |  3 ++-
>  4 files changed, 38 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
> index 0eaf9171c..d435f6570 100644
> --- a/drivers/net/bnxt/bnxt_hwrm.c
> +++ b/drivers/net/bnxt/bnxt_hwrm.c
> @@ -2261,7 +2261,8 @@ int bnxt_hwrm_func_qstats_tx_drop(struct bnxt *bp,
> uint16_t fid,
>  }
>
>  int bnxt_hwrm_func_qstats(struct bnxt *bp, uint16_t fid,
> -                         struct rte_eth_stats *stats)
> +                         struct rte_eth_stats *stats,
> +                         struct hwrm_func_qstats_output *func_qstats)
>  {
>         int rc = 0;
>         struct hwrm_func_qstats_input req = {.req_type = 0};
> @@ -2274,6 +2275,12 @@ int bnxt_hwrm_func_qstats(struct bnxt *bp, uint16_t
> fid,
>         rc = bnxt_hwrm_send_message(bp, &req, sizeof(req),
> BNXT_USE_CHIMP_MB);
>
>         HWRM_CHECK_RESULT();
> +       if (func_qstats)
> +               memcpy(func_qstats, resp,
> +                      sizeof(struct hwrm_func_qstats_output));
> +
> +       if (!stats)
> +               goto exit;
>
>         stats->ipackets = rte_le_to_cpu_64(resp->rx_ucast_pkts);
>         stats->ipackets += rte_le_to_cpu_64(resp->rx_mcast_pkts);
> @@ -2293,6 +2300,7 @@ int bnxt_hwrm_func_qstats(struct bnxt *bp, uint16_t
> fid,
>         stats->ierrors = rte_le_to_cpu_64(resp->rx_drop_pkts);
>         stats->oerrors = rte_le_to_cpu_64(resp->tx_discard_pkts);
>
> +exit:
>         HWRM_UNLOCK();
>
>         return rc;
> diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h
> index 0079d8a97..1b7e35306 100644
> --- a/drivers/net/bnxt/bnxt_hwrm.h
> +++ b/drivers/net/bnxt/bnxt_hwrm.h
> @@ -12,6 +12,7 @@
>  struct bnxt;
>  struct bnxt_filter_info;
>  struct bnxt_cp_ring_info;
> +struct hwrm_func_qstats_output;
>
>  #define HWRM_SEQ_ID_INVALID -1U
>  /* Convert Bit field location to value */
> @@ -112,7 +113,8 @@ int bnxt_hwrm_func_qcaps(struct bnxt *bp);
>  int bnxt_hwrm_func_reset(struct bnxt *bp);
>  int bnxt_hwrm_func_driver_unregister(struct bnxt *bp, uint32_t flags);
>  int bnxt_hwrm_func_qstats(struct bnxt *bp, uint16_t fid,
> -                         struct rte_eth_stats *stats);
> +                         struct rte_eth_stats *stats,
> +                         struct hwrm_func_qstats_output *func_qstats);
>  int bnxt_hwrm_func_qstats_tx_drop(struct bnxt *bp, uint16_t fid,
>                                   uint64_t *dropped);
>  int bnxt_hwrm_func_clr_stats(struct bnxt *bp, uint16_t fid);
> diff --git a/drivers/net/bnxt/bnxt_stats.c b/drivers/net/bnxt/bnxt_stats.c
> index 29628bd64..6afd11adb 100644
> --- a/drivers/net/bnxt/bnxt_stats.c
> +++ b/drivers/net/bnxt/bnxt_stats.c
> @@ -547,7 +547,7 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev,
>                         return rc;
>         }
>
> -       rc = bnxt_hwrm_func_qstats(bp, 0xffff, bnxt_stats);
> +       rc = bnxt_hwrm_func_qstats(bp, 0xffff, bnxt_stats, NULL);
>         return rc;
>  }
>
> @@ -581,10 +581,10 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev
> *eth_dev,
>  {
>         struct bnxt *bp = eth_dev->data->dev_private;
>         unsigned int count, i;
> -       uint64_t tx_drop_pkts;
>         unsigned int rx_port_stats_ext_cnt;
>         unsigned int tx_port_stats_ext_cnt;
>         unsigned int stat_size = sizeof(uint64_t);
> +       struct hwrm_func_qstats_output func_qstats = {0};
>         unsigned int stat_count;
>         int rc;
>
> @@ -597,8 +597,8 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev,
>
>         memset(xstats, 0, sizeof(*xstats));
>
> +       bnxt_hwrm_func_qstats(bp, 0xffff, NULL, &func_qstats);
>         bnxt_hwrm_port_qstats(bp);
> -       bnxt_hwrm_func_qstats_tx_drop(bp, 0xffff, &tx_drop_pkts);
>         bnxt_hwrm_ext_port_qstats(bp);
>         rx_port_stats_ext_cnt = RTE_MIN(RTE_DIM(bnxt_rx_ext_stats_strings),
>                                         (bp->fw_rx_port_stats_ext_size /
> @@ -608,7 +608,8 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev,
>                                          stat_size));
>
>         count = RTE_DIM(bnxt_rx_stats_strings) +
> -               RTE_DIM(bnxt_tx_stats_strings) + 1/* For tx_drop_pkts */ +
> +               RTE_DIM(bnxt_tx_stats_strings) +
> +               RTE_DIM(bnxt_func_stats_strings) +
>                 RTE_DIM(bnxt_rx_ext_stats_strings) +
>                 RTE_DIM(bnxt_tx_ext_stats_strings);
>         stat_count = count;
> @@ -635,10 +636,13 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev
> *eth_dev,
>                 count++;
>         }
>
> -       /* The Tx drop pkts aka the Anti spoof coounter */
> -       xstats[count].id = count;
> -       xstats[count].value = rte_le_to_cpu_64(tx_drop_pkts);
> -       count++;
> +       for (i = 0; i < RTE_DIM(bnxt_func_stats_strings); i++) {
> +               xstats[count].id = count;
> +               xstats[count].value =
> +               rte_le_to_cpu_64(((uint64_t *)&func_qstats)[i]);
> +               count++;
> +       }
> +
>
>         for (i = 0; i < rx_port_stats_ext_cnt; i++) {
>                 uint64_t *rx_stats_ext = (uint64_t
> *)bp->hw_rx_port_stats_ext;
> @@ -667,9 +671,9 @@ int bnxt_dev_xstats_get_names_op(struct rte_eth_dev
> *eth_dev,
>                                  struct rte_eth_xstat_name *xstats_names,
>                                  __rte_unused unsigned int limit)
>  {
> -       /* Account for the Tx drop pkts aka the Anti spoof counter */
>         const unsigned int stat_cnt = RTE_DIM(bnxt_rx_stats_strings) +
> -                               RTE_DIM(bnxt_tx_stats_strings) + 1 +
> +                               RTE_DIM(bnxt_tx_stats_strings) +
> +                               RTE_DIM(bnxt_func_stats_strings) +
>                                 RTE_DIM(bnxt_rx_ext_stats_strings) +
>                                 RTE_DIM(bnxt_tx_ext_stats_strings);
>         struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
> @@ -697,10 +701,12 @@ int bnxt_dev_xstats_get_names_op(struct rte_eth_dev
> *eth_dev,
>                         count++;
>                 }
>
> -               strlcpy(xstats_names[count].name,
> -                       bnxt_func_stats_strings[4].name,
> -                       sizeof(xstats_names[count].name));
> -               count++;
> +               for (i = 0; i < RTE_DIM(bnxt_func_stats_strings); i++) {
> +                       strlcpy(xstats_names[count].name,
> +                               bnxt_func_stats_strings[i].name,
> +                               sizeof(xstats_names[count].name));
> +                       count++;
> +               }
>
>                 for (i = 0; i < RTE_DIM(bnxt_rx_ext_stats_strings); i++) {
>                         strlcpy(xstats_names[count].name,
> @@ -748,9 +754,9 @@ int bnxt_dev_xstats_reset_op(struct rte_eth_dev
> *eth_dev)
>  int bnxt_dev_xstats_get_by_id_op(struct rte_eth_dev *dev, const uint64_t
> *ids,
>                 uint64_t *values, unsigned int limit)
>  {
> -       /* Account for the Tx drop pkts aka the Anti spoof counter */
>         const unsigned int stat_cnt = RTE_DIM(bnxt_rx_stats_strings) +
> -                               RTE_DIM(bnxt_tx_stats_strings) + 1 +
> +                               RTE_DIM(bnxt_tx_stats_strings) +
> +                               RTE_DIM(bnxt_func_stats_strings) +
>                                 RTE_DIM(bnxt_rx_ext_stats_strings) +
>                                 RTE_DIM(bnxt_tx_ext_stats_strings);
>         struct bnxt *bp = dev->data->dev_private;
> @@ -781,9 +787,9 @@ int bnxt_dev_xstats_get_names_by_id_op(struct
> rte_eth_dev *dev,
>                                 struct rte_eth_xstat_name *xstats_names,
>                                 const uint64_t *ids, unsigned int limit)
>  {
> -       /* Account for the Tx drop pkts aka the Anti spoof counter */
>         const unsigned int stat_cnt = RTE_DIM(bnxt_rx_stats_strings) +
> -                               RTE_DIM(bnxt_tx_stats_strings) + 1 +
> +                               RTE_DIM(bnxt_tx_stats_strings) +
> +                               RTE_DIM(bnxt_func_stats_strings) +
>                                 RTE_DIM(bnxt_rx_ext_stats_strings) +
>                                 RTE_DIM(bnxt_tx_ext_stats_strings);
>         struct rte_eth_xstat_name xstats_names_copy[stat_cnt];
> diff --git a/drivers/net/bnxt/rte_pmd_bnxt.c
> b/drivers/net/bnxt/rte_pmd_bnxt.c
> index 4374034c3..2df486592 100644
> --- a/drivers/net/bnxt/rte_pmd_bnxt.c
> +++ b/drivers/net/bnxt/rte_pmd_bnxt.c
> @@ -614,7 +614,8 @@ int rte_pmd_bnxt_get_vf_stats(uint16_t port,
>                 return -ENOTSUP;
>         }
>
> -       return bnxt_hwrm_func_qstats(bp, bp->pf.first_vf_id + vf_id,
> stats);
> +       return bnxt_hwrm_func_qstats(bp, bp->pf.first_vf_id + vf_id, stats,
> +                                    NULL);
>  }
>
>  int rte_pmd_bnxt_reset_vf_stats(uint16_t port,
> --
> 2.21.1 (Apple Git-122.3)
>
>

      reply	other threads:[~2020-04-17 14:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-15 22:58 Ajit Khaparde
2020-04-17 14:50 ` Ajit Khaparde [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CACZ4nhvqfDcjzqZd19sQFQeRYvcMyVAb6C-uSKu1AaZNT=PbWA@mail.gmail.com' \
    --to=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=somnath.kotur@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).