From: Robin Zhang <robinx.zhang@intel.com>
To: dev@dpdk.org
Cc: beilei.xing@intel.com, jingjing.wu@intel.com,
qiming.yang@intel.com, stevex.yang@intel.com,
Robin Zhang <robinx.zhang@intel.com>
Subject: [dpdk-dev] [PATCH 7/8] net/iavf: add extended stats
Date: Sun, 27 Sep 2020 07:26:25 +0000 [thread overview]
Message-ID: <20200927072626.28374-8-robinx.zhang@intel.com> (raw)
In-Reply-To: <20200927072626.28374-1-robinx.zhang@intel.com>
Add implementation of xstats() functions in iavf PMD.
Signed-off-by: Robin Zhang <robinx.zhang@intel.com>
---
drivers/net/iavf/iavf_ethdev.c | 81 ++++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 5b3c68f2e..836c09f58 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -40,6 +40,11 @@ static const uint32_t *iavf_dev_supported_ptypes_get(struct rte_eth_dev *dev);
static int iavf_dev_stats_get(struct rte_eth_dev *dev,
struct rte_eth_stats *stats);
static int iavf_dev_stats_reset(struct rte_eth_dev *dev);
+static int iavf_dev_xstats_get(struct rte_eth_dev *dev,
+ struct rte_eth_xstat *xstats, unsigned int n);
+static int iavf_dev_xstats_get_names(struct rte_eth_dev *dev,
+ struct rte_eth_xstat_name *xstats_names,
+ unsigned int limit);
static int iavf_dev_promiscuous_enable(struct rte_eth_dev *dev);
static int iavf_dev_promiscuous_disable(struct rte_eth_dev *dev);
static int iavf_dev_allmulticast_enable(struct rte_eth_dev *dev);
@@ -82,6 +87,30 @@ static const struct rte_pci_id pci_id_iavf_map[] = {
{ .vendor_id = 0, /* sentinel */ },
};
+struct rte_iavf_xstats_name_off {
+ char name[RTE_ETH_XSTATS_NAME_SIZE];
+ unsigned int offset;
+};
+
+static const struct rte_iavf_xstats_name_off rte_iavf_stats_strings[] = {
+ {"rx_bytes", offsetof(struct iavf_eth_stats, rx_bytes)},
+ {"rx_unicast_packets", offsetof(struct iavf_eth_stats, rx_unicast)},
+ {"rx_multicast_packets", offsetof(struct iavf_eth_stats, rx_multicast)},
+ {"rx_broadcast_packets", offsetof(struct iavf_eth_stats, rx_broadcast)},
+ {"rx_dropped_packets", offsetof(struct iavf_eth_stats, rx_discards)},
+ {"rx_unknown_protocol_packets", offsetof(struct iavf_eth_stats,
+ rx_unknown_protocol)},
+ {"tx_bytes", offsetof(struct iavf_eth_stats, tx_bytes)},
+ {"tx_unicast_packets", offsetof(struct iavf_eth_stats, tx_unicast)},
+ {"tx_multicast_packets", offsetof(struct iavf_eth_stats, tx_multicast)},
+ {"tx_broadcast_packets", offsetof(struct iavf_eth_stats, tx_broadcast)},
+ {"tx_dropped_packets", offsetof(struct iavf_eth_stats, tx_discards)},
+ {"tx_error_packets", offsetof(struct iavf_eth_stats, tx_errors)},
+};
+
+#define IAVF_NB_XSTATS (sizeof(rte_iavf_stats_strings) / \
+ sizeof(rte_iavf_stats_strings[0]))
+
static const struct eth_dev_ops iavf_eth_dev_ops = {
.dev_configure = iavf_dev_configure,
.dev_start = iavf_dev_start,
@@ -93,6 +122,9 @@ static const struct eth_dev_ops iavf_eth_dev_ops = {
.link_update = iavf_dev_link_update,
.stats_get = iavf_dev_stats_get,
.stats_reset = iavf_dev_stats_reset,
+ .xstats_get = iavf_dev_xstats_get,
+ .xstats_get_names = iavf_dev_xstats_get_names,
+ .xstats_reset = iavf_dev_stats_reset,
.promiscuous_enable = iavf_dev_promiscuous_enable,
.promiscuous_disable = iavf_dev_promiscuous_disable,
.allmulticast_enable = iavf_dev_allmulticast_enable,
@@ -1092,6 +1124,55 @@ iavf_dev_stats_reset(struct rte_eth_dev *dev)
return 0;
}
+static int iavf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+ struct rte_eth_xstat_name *xstats_names,
+ __rte_unused unsigned int limit)
+{
+ unsigned int i;
+
+ if (xstats_names != NULL)
+ for (i = 0; i < IAVF_NB_XSTATS; i++) {
+ snprintf(xstats_names[i].name,
+ sizeof(xstats_names[i].name),
+ "%s", rte_iavf_stats_strings[i].name);
+ }
+ return IAVF_NB_XSTATS;
+}
+
+static int iavf_dev_xstats_get(struct rte_eth_dev *dev,
+ struct rte_eth_xstat *xstats, unsigned int n)
+{
+ int ret;
+ unsigned int i;
+ struct iavf_adapter *adapter =
+ IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+ struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+ struct iavf_vsi *vsi = &vf->vsi;
+ struct virtchnl_eth_stats *pstats = NULL;
+
+ if (n < IAVF_NB_XSTATS)
+ return IAVF_NB_XSTATS;
+
+ ret = iavf_query_stats(adapter, &pstats);
+ if (ret != 0)
+ return 0;
+
+ if (!xstats)
+ return 0;
+
+ iavf_update_stats(vsi, pstats);
+
+ /* loop over xstats array and values from pstats */
+ for (i = 0; i < IAVF_NB_XSTATS; i++) {
+ xstats[i].id = i;
+ xstats[i].value = *(uint64_t *)(((char *)pstats) +
+ rte_iavf_stats_strings[i].offset);
+ }
+
+ return IAVF_NB_XSTATS;
+}
+
+
static int
iavf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
{
--
2.17.1
next prev parent reply other threads:[~2020-09-27 7:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-27 7:26 [dpdk-dev] [PATCH 0/8] feature porting from i40evf to iavf Robin Zhang
2020-09-27 7:26 ` [dpdk-dev] [PATCH 1/8] net/iavf: use link status helper functions Robin Zhang
2020-09-27 7:26 ` [dpdk-dev] [PATCH 2/8] net/iavf: set min and max MTU for VF Robin Zhang
2020-09-27 7:26 ` [dpdk-dev] [PATCH 3/8] net/iavf: re-program promiscuous mode on VF interface Robin Zhang
2020-09-27 7:26 ` [dpdk-dev] [PATCH 4/8] net/iavf: optimize promiscuous ops Robin Zhang
2020-09-27 7:26 ` [dpdk-dev] [PATCH 5/8] net/iavf: add workaround promiscuous disable Robin Zhang
2020-09-27 7:26 ` [dpdk-dev] [PATCH 6/8] net/iavf: cleanup Tx buffers Robin Zhang
2020-09-27 7:26 ` Robin Zhang [this message]
2020-09-27 7:26 ` [dpdk-dev] [PATCH 8/8] net/iavf: support check DD bit of a RX descriptor Robin Zhang
2020-10-08 15:05 ` Ferruh Yigit
[not found] ` <fe7a8f1f1a1f45908c4094ccfc6b547d@intel.com>
2020-10-12 8:32 ` Ferruh Yigit
2020-10-13 5:58 ` Zhang, Qi Z
2020-10-08 12:23 ` [dpdk-dev] [PATCH 0/8] feature porting from i40evf to iavf Zhang, Qi Z
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=20200927072626.28374-8-robinx.zhang@intel.com \
--to=robinx.zhang@intel.com \
--cc=beilei.xing@intel.com \
--cc=dev@dpdk.org \
--cc=jingjing.wu@intel.com \
--cc=qiming.yang@intel.com \
--cc=stevex.yang@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 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).