From: Mingxia Liu <mingxia.liu@intel.com>
To: dev@dpdk.org, qi.z.zhang@intel.com, jingjing.wu@intel.com,
beilei.xing@intel.com
Cc: Mingxia Liu <mingxia.liu@intel.com>
Subject: [PATCH v5 6/6] common/idpf: add xstats ops
Date: Tue, 7 Feb 2023 10:08:59 +0000 [thread overview]
Message-ID: <20230207100859.2401709-7-mingxia.liu@intel.com> (raw)
In-Reply-To: <20230207100859.2401709-1-mingxia.liu@intel.com>
Add support for these device ops:
-idpf_dev_xstats_get
-idpf_dev_xstats_get_names
-idpf_dev_xstats_reset
Signed-off-by: Mingxia Liu <mingxia.liu@intel.com>
---
drivers/net/idpf/idpf_ethdev.c | 80 ++++++++++++++++++++++++++++++++++
1 file changed, 80 insertions(+)
diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index 751c0d8717..38cbbf369d 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -80,6 +80,30 @@ static const uint64_t idpf_ipv6_rss = RTE_ETH_RSS_NONFRAG_IPV6_UDP |
RTE_ETH_RSS_NONFRAG_IPV6_OTHER |
RTE_ETH_RSS_FRAG_IPV6;
+struct rte_idpf_xstats_name_off {
+ char name[RTE_ETH_XSTATS_NAME_SIZE];
+ unsigned int offset;
+};
+
+static const struct rte_idpf_xstats_name_off rte_idpf_stats_strings[] = {
+ {"rx_bytes", offsetof(struct virtchnl2_vport_stats, rx_bytes)},
+ {"rx_unicast_packets", offsetof(struct virtchnl2_vport_stats, rx_unicast)},
+ {"rx_multicast_packets", offsetof(struct virtchnl2_vport_stats, rx_multicast)},
+ {"rx_broadcast_packets", offsetof(struct virtchnl2_vport_stats, rx_broadcast)},
+ {"rx_dropped_packets", offsetof(struct virtchnl2_vport_stats, rx_discards)},
+ {"rx_errors", offsetof(struct virtchnl2_vport_stats, rx_errors)},
+ {"rx_unknown_protocol_packets", offsetof(struct virtchnl2_vport_stats,
+ rx_unknown_protocol)},
+ {"tx_bytes", offsetof(struct virtchnl2_vport_stats, tx_bytes)},
+ {"tx_unicast_packets", offsetof(struct virtchnl2_vport_stats, tx_unicast)},
+ {"tx_multicast_packets", offsetof(struct virtchnl2_vport_stats, tx_multicast)},
+ {"tx_broadcast_packets", offsetof(struct virtchnl2_vport_stats, tx_broadcast)},
+ {"tx_dropped_packets", offsetof(struct virtchnl2_vport_stats, tx_discards)},
+ {"tx_error_packets", offsetof(struct virtchnl2_vport_stats, tx_errors)}};
+
+#define IDPF_NB_XSTATS (sizeof(rte_idpf_stats_strings) / \
+ sizeof(rte_idpf_stats_strings[0]))
+
static int
idpf_dev_link_update(struct rte_eth_dev *dev,
__rte_unused int wait_to_complete)
@@ -313,6 +337,59 @@ idpf_dev_stats_reset(struct rte_eth_dev *dev)
return 0;
}
+static int idpf_dev_xstats_reset(struct rte_eth_dev *dev)
+{
+ idpf_dev_stats_reset(dev);
+ return 0;
+}
+
+static int idpf_dev_xstats_get(struct rte_eth_dev *dev,
+ struct rte_eth_xstat *xstats, unsigned int n)
+{
+ struct idpf_vport *vport =
+ (struct idpf_vport *)dev->data->dev_private;
+ struct virtchnl2_vport_stats *pstats = NULL;
+ unsigned int i;
+ int ret;
+
+ if (n < IDPF_NB_XSTATS)
+ return IDPF_NB_XSTATS;
+
+ if (!xstats)
+ return 0;
+
+ ret = idpf_vc_stats_query(vport, &pstats);
+ if (ret) {
+ PMD_DRV_LOG(ERR, "Get statistics failed");
+ return 0;
+ }
+
+ idpf_vport_stats_update(&vport->eth_stats_offset, pstats);
+
+ /* loop over xstats array and values from pstats */
+ for (i = 0; i < IDPF_NB_XSTATS; i++) {
+ xstats[i].id = i;
+ xstats[i].value = *(uint64_t *)(((char *)pstats) +
+ rte_idpf_stats_strings[i].offset);
+ }
+ return IDPF_NB_XSTATS;
+}
+
+static int idpf_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)
+ for (i = 0; i < IDPF_NB_XSTATS; i++) {
+ snprintf(xstats_names[i].name,
+ sizeof(xstats_names[i].name),
+ "%s", rte_idpf_stats_strings[i].name);
+ }
+ return IDPF_NB_XSTATS;
+}
+
static int idpf_config_rss_hf(struct idpf_vport *vport, uint64_t rss_hf)
{
uint64_t hena = 0;
@@ -1122,6 +1199,9 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
.reta_query = idpf_rss_reta_query,
.rss_hash_update = idpf_rss_hash_update,
.rss_hash_conf_get = idpf_rss_hash_conf_get,
+ .xstats_get = idpf_dev_xstats_get,
+ .xstats_get_names = idpf_dev_xstats_get_names,
+ .xstats_reset = idpf_dev_xstats_reset,
};
static uint16_t
--
2.25.1
prev parent reply other threads:[~2023-02-07 11:06 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-16 9:36 [PATCH 0/7] add idpf pmd enhancement features Mingxia Liu
2022-12-16 9:37 ` [PATCH 1/7] common/idpf: add hw statistics Mingxia Liu
2022-12-16 9:37 ` [PATCH 2/7] common/idpf: add RSS set/get ops Mingxia Liu
2022-12-16 9:37 ` [PATCH 3/7] common/idpf: support single q scatter RX datapath Mingxia Liu
2022-12-16 9:37 ` [PATCH 4/7] common/idpf: add rss_offload hash in singleq rx Mingxia Liu
2022-12-16 9:37 ` [PATCH 5/7] common/idpf: add alarm to support handle vchnl message Mingxia Liu
2022-12-16 9:37 ` [PATCH 6/7] common/idpf: add xstats ops Mingxia Liu
2022-12-16 9:37 ` [PATCH 7/7] common/idpf: update mbuf_alloc_failed multi-thread process Mingxia Liu
2023-01-11 7:15 ` [PATCH 0/6] add idpf pmd enhancement features Mingxia Liu
2023-01-11 7:15 ` [PATCH v2 1/6] common/idpf: add hw statistics Mingxia Liu
2023-01-11 7:15 ` [PATCH v2 2/6] common/idpf: add RSS set/get ops Mingxia Liu
2023-01-11 7:15 ` [PATCH v2 3/6] common/idpf: support single q scatter RX datapath Mingxia Liu
2023-01-11 7:15 ` [PATCH v2 4/6] common/idpf: add rss_offload hash in singleq rx Mingxia Liu
2023-01-11 7:15 ` [PATCH v2 5/6] common/idpf: add alarm to support handle vchnl message Mingxia Liu
2023-01-11 7:15 ` [PATCH v2 6/6] common/idpf: add xstats ops Mingxia Liu
2023-01-18 7:14 ` [PATCH v3 0/6] add idpf pmd enhancement features Mingxia Liu
2023-01-18 7:14 ` [PATCH v3 1/6] common/idpf: add hw statistics Mingxia Liu
2023-02-01 8:48 ` Wu, Jingjing
2023-02-01 12:34 ` Liu, Mingxia
2023-01-18 7:14 ` [PATCH v3 2/6] common/idpf: add RSS set/get ops Mingxia Liu
2023-02-02 3:28 ` Wu, Jingjing
2023-02-07 3:10 ` Liu, Mingxia
2023-01-18 7:14 ` [PATCH v3 3/6] common/idpf: support single q scatter RX datapath Mingxia Liu
2023-02-02 3:45 ` Wu, Jingjing
2023-02-02 7:19 ` Liu, Mingxia
2023-01-18 7:14 ` [PATCH v3 4/6] common/idpf: add rss_offload hash in singleq rx Mingxia Liu
2023-01-18 7:14 ` [PATCH v3 5/6] common/idpf: add alarm to support handle vchnl message Mingxia Liu
2023-02-02 4:23 ` Wu, Jingjing
2023-02-02 7:39 ` Liu, Mingxia
2023-02-02 8:46 ` Wu, Jingjing
2023-01-18 7:14 ` [PATCH v3 6/6] common/idpf: add xstats ops Mingxia Liu
2023-02-07 9:56 ` [PATCH v4 0/6] add idpf pmd enhancement features Mingxia Liu
2023-02-07 9:56 ` [PATCH v4 1/6] common/idpf: add hw statistics Mingxia Liu
2023-02-07 9:56 ` [PATCH v4 2/6] common/idpf: add RSS set/get ops Mingxia Liu
2023-02-07 9:56 ` [PATCH v4 3/6] common/idpf: support single q scatter RX datapath Mingxia Liu
2023-02-07 9:56 ` [PATCH v4 4/6] common/idpf: add rss_offload hash in singleq rx Mingxia Liu
2023-02-07 9:57 ` [PATCH v4 5/6] common/idpf: add alarm to support handle vchnl message Mingxia Liu
2023-02-07 9:57 ` [PATCH v4 6/6] common/idpf: add xstats ops Mingxia Liu
2023-02-07 10:08 ` [PATCH v4 0/6] add idpf pmd enhancement features Mingxia Liu
2023-02-07 10:08 ` [PATCH v5 1/6] common/idpf: add hw statistics Mingxia Liu
2023-02-07 10:16 ` [PATCH v6 0/6] add idpf pmd enhancement features Mingxia Liu
2023-02-07 10:16 ` [PATCH v6 1/6] common/idpf: add hw statistics Mingxia Liu
2023-02-08 2:00 ` Zhang, Qi Z
2023-02-08 8:28 ` Liu, Mingxia
2023-02-07 10:16 ` [PATCH v6 2/6] common/idpf: add RSS set/get ops Mingxia Liu
2023-02-07 10:16 ` [PATCH v6 3/6] common/idpf: support single q scatter RX datapath Mingxia Liu
2023-02-07 10:16 ` [PATCH v6 4/6] common/idpf: add rss_offload hash in singleq rx Mingxia Liu
2023-02-07 10:16 ` [PATCH v6 5/6] common/idpf: add alarm to support handle vchnl message Mingxia Liu
2023-02-07 10:16 ` [PATCH v6 6/6] common/idpf: add xstats ops Mingxia Liu
2023-02-08 0:28 ` [PATCH v6 0/6] add idpf pmd enhancement features Wu, Jingjing
2023-02-08 7:33 ` [PATCH v7 " Mingxia Liu
2023-02-08 7:33 ` [PATCH v7 1/6] net/idpf: add hw statistics Mingxia Liu
2023-02-08 7:33 ` [PATCH v7 2/6] net/idpf: add RSS set/get ops Mingxia Liu
2023-02-08 7:33 ` [PATCH v7 3/6] net/idpf: support single q scatter RX datapath Mingxia Liu
2023-02-08 7:33 ` [PATCH v7 4/6] net/idpf: add rss_offload hash in singleq rx Mingxia Liu
2023-02-08 7:34 ` [PATCH v7 5/6] net/idpf: add alarm to support handle vchnl message Mingxia Liu
2023-02-08 7:34 ` [PATCH v7 6/6] net/idpf: add xstats ops Mingxia Liu
2023-02-08 9:32 ` [PATCH v7 0/6] add idpf pmd enhancement features Zhang, Qi Z
2023-02-07 10:08 ` [PATCH v5 2/6] common/idpf: add RSS set/get ops Mingxia Liu
2023-02-07 10:08 ` [PATCH v5 3/6] common/idpf: support single q scatter RX datapath Mingxia Liu
2023-02-07 10:08 ` [PATCH v5 4/6] common/idpf: add rss_offload hash in singleq rx Mingxia Liu
2023-02-07 10:08 ` [PATCH v5 5/6] common/idpf: add alarm to support handle vchnl message Mingxia Liu
2023-02-07 10:08 ` Mingxia Liu [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=20230207100859.2401709-7-mingxia.liu@intel.com \
--to=mingxia.liu@intel.com \
--cc=beilei.xing@intel.com \
--cc=dev@dpdk.org \
--cc=jingjing.wu@intel.com \
--cc=qi.z.zhang@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).