All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com
Subject: [PATCH v4 11/24] net/bnxt: add support for xstats get by id
Date: Thu, 28 Sep 2017 16:43:32 -0500	[thread overview]
Message-ID: <20170928214345.87655-12-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <20170928214345.87655-1-ajit.khaparde@broadcom.com>

This patch adds support for xstats_get_by_id/xstats_get_names_by_id.

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
--
v1->v2: incorporate review comments.
v2->v3: fix an issue observed while testing.
---
 drivers/net/bnxt/bnxt_ethdev.c | 11 +++++++++
 drivers/net/bnxt/bnxt_stats.c  | 51 ++++++++++++++++++++++++++++++++++++++++++
 drivers/net/bnxt/bnxt_stats.h  |  5 +++++
 3 files changed, 67 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 6e5cb8854..05e601b66 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1569,6 +1569,8 @@ static const struct eth_dev_ops bnxt_dev_ops = {
 	.txq_info_get = bnxt_txq_info_get_op,
 	.dev_led_on = bnxt_dev_led_on_op,
 	.dev_led_off = bnxt_dev_led_off_op,
+	.xstats_get_by_id = bnxt_dev_xstats_get_by_id_op,
+	.xstats_get_names_by_id = bnxt_dev_xstats_get_names_by_id_op,
 };
 
 static bool bnxt_vf_pciid(uint16_t id)
@@ -1648,6 +1650,9 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
 	rte_atomic64_init(&bp->rx_mbuf_alloc_fail);
 	bp->dev_stopped = 1;
 
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		goto skip_init;
+
 	if (bnxt_vf_pciid(pci_dev->id.device_id))
 		bp->flags |= BNXT_FLAG_VF;
 
@@ -1657,7 +1662,10 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
 			"Board initialization failed rc: %x\n", rc);
 		goto error;
 	}
+skip_init:
 	eth_dev->dev_ops = &bnxt_dev_ops;
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
 	eth_dev->rx_pkt_burst = &bnxt_recv_pkts;
 	eth_dev->tx_pkt_burst = &bnxt_xmit_pkts;
 
@@ -1882,6 +1890,9 @@ bnxt_dev_uninit(struct rte_eth_dev *eth_dev) {
 	struct bnxt *bp = eth_dev->data->dev_private;
 	int rc;
 
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return -EPERM;
+
 	bnxt_disable_int(bp);
 	bnxt_free_int(bp);
 	bnxt_free_mem(bp);
diff --git a/drivers/net/bnxt/bnxt_stats.c b/drivers/net/bnxt/bnxt_stats.c
index d7d0e35c1..225f98830 100644
--- a/drivers/net/bnxt/bnxt_stats.c
+++ b/drivers/net/bnxt/bnxt_stats.c
@@ -358,3 +358,54 @@ void bnxt_dev_xstats_reset_op(struct rte_eth_dev *eth_dev)
 	if (!(bp->flags & BNXT_FLAG_PORT_STATS))
 		RTE_LOG(ERR, PMD, "Operation not supported\n");
 }
+
+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;
+	struct rte_eth_xstat xstats[stat_cnt];
+	uint64_t values_copy[stat_cnt];
+	uint16_t i;
+
+	if (!ids)
+		return bnxt_dev_xstats_get_op(dev, xstats, stat_cnt);
+
+	bnxt_dev_xstats_get_by_id_op(dev, NULL, values_copy, stat_cnt);
+	for (i = 0; i < limit; i++) {
+		if (ids[i] >= stat_cnt) {
+			RTE_LOG(ERR, PMD, "id value isn't valid");
+			return -1;
+		}
+		values[i] = values_copy[ids[i]];
+	}
+	return stat_cnt;
+}
+
+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;
+	struct rte_eth_xstat_name xstats_names_copy[stat_cnt];
+	uint16_t i;
+
+	if (!ids)
+		return bnxt_dev_xstats_get_names_op(dev, xstats_names,
+						    stat_cnt);
+	bnxt_dev_xstats_get_names_by_id_op(dev, xstats_names_copy, NULL,
+			stat_cnt);
+
+	for (i = 0; i < limit; i++) {
+		if (ids[i] >= stat_cnt) {
+			RTE_LOG(ERR, PMD, "id value isn't valid");
+			return -1;
+		}
+		strcpy(xstats_names[i].name,
+				xstats_names_copy[ids[i]].name);
+	}
+	return stat_cnt;
+}
diff --git a/drivers/net/bnxt/bnxt_stats.h b/drivers/net/bnxt/bnxt_stats.h
index b6d133ef2..daeb3d9b9 100644
--- a/drivers/net/bnxt/bnxt_stats.h
+++ b/drivers/net/bnxt/bnxt_stats.h
@@ -46,6 +46,11 @@ int bnxt_dev_xstats_get_names_op(__rte_unused struct rte_eth_dev *eth_dev,
 int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev,
 			   struct rte_eth_xstat *xstats, unsigned int n);
 void 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);
+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);
 
 struct bnxt_xstats_name_off {
 	char name[RTE_ETH_XSTATS_NAME_SIZE];
-- 
2.13.5 (Apple Git-94)

  parent reply	other threads:[~2017-09-28 21:43 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-28 21:43 [PATCH v4 00/24] bnxt patchset Ajit Khaparde
2017-09-28 21:43 ` [PATCH v4 01/24] net/bnxt: fix HWRM_*() macros and locking Ajit Khaparde
2017-09-28 21:43 ` [PATCH v4 02/24] net/bnxt: use 64-bits of address for vlan_table Ajit Khaparde
2017-09-28 21:43 ` [PATCH v4 03/24] net/bnxt: fix an issue with group id calculation Ajit Khaparde
2017-09-28 21:43 ` [PATCH v4 04/24] net/bnxt: fix calculation of number of pools Ajit Khaparde
2017-09-28 21:43 ` [PATCH v4 05/24] net/bnxt: handle multi queue mode properly Ajit Khaparde
2017-09-28 21:43 ` [PATCH v4 06/24] net/bnxt: fix rx handling and buffer allocation logic Ajit Khaparde
2017-09-28 21:43 ` [PATCH v4 07/24] net/bnxt: fix an issue with broadcast traffic Ajit Khaparde
2017-09-28 21:43 ` [PATCH v4 08/24] net/bnxt: fix usage of ETH_VMDQ_* flags Ajit Khaparde
2017-09-28 21:43 ` [PATCH v4 09/24] net/bnxt: set checksum offload flags correctly Ajit Khaparde
2017-09-28 21:43 ` [PATCH v4 10/24] net/bnxt: update status of Rx IP/L4 CKSUM Ajit Khaparde
2017-09-28 21:43 ` Ajit Khaparde [this message]
2017-09-28 21:43 ` [PATCH v4 12/24] net/bnxt: fix config rss update Ajit Khaparde
2017-09-28 21:43 ` [PATCH v4 13/24] net/bnxt: set the hash_key_size Ajit Khaparde
2017-09-28 21:43 ` [PATCH v4 14/24] net/bnxt: add support for rx_queue_count Ajit Khaparde
2017-09-28 21:43 ` [PATCH v4 15/24] net/bnxt: add support for rx_descriptor_status Ajit Khaparde
2017-09-28 21:43 ` [PATCH v4 16/24] net/bnxt: add support for tx_descriptor_status Ajit Khaparde
2017-09-28 21:43 ` [PATCH v4 17/24] net/bnxt: add new HWRM structs to support flow filtering Ajit Khaparde
2017-09-28 21:43 ` [PATCH v4 18/24] net/bnxt: add support for flow filter ops Ajit Khaparde
2017-09-28 21:43 ` [PATCH v4 19/24] doc: update release notes Ajit Khaparde
2017-09-28 21:43 ` [PATCH v4 20/24] net/bnxt: fix per queue stats display in xstats Ajit Khaparde
2017-09-28 21:43 ` [PATCH v4 21/24] net/bnxt: prevent interrupt handler from accessing freed memory Ajit Khaparde
2017-09-28 21:43 ` [PATCH v4 22/24] net/bnxt: add dev_supported_ptypes_get dev_op Ajit Khaparde
2017-09-28 21:43 ` [PATCH v4 23/24] net/bnxt: add support for get/set EEPROM Ajit Khaparde
2017-09-28 21:43 ` [PATCH v4 24/24] net/bnxt: add support for rx_queue_intr_enable/disable APIs Ajit Khaparde
2017-10-02 21:28 ` [PATCH v4 00/24] bnxt patchset Ferruh Yigit

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=20170928214345.87655-12-ajit.khaparde@broadcom.com \
    --to=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.