DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com, thomas@monjalon.net, arybchenko@solarflare.com
Subject: [dpdk-dev] [RFC PATCH 2/2] net/af_packet: convert to new rxq/txq stats API
Date: Thu, 14 Mar 2019 16:13:16 +0100	[thread overview]
Message-ID: <1552576396-19906-2-git-send-email-david.marchand@redhat.com> (raw)
Message-ID: <20190314151316.pwitivF4KZAPPfdhGIyZG1Ezt3ynS7toj7Z8EVsZUjE@z> (raw)
In-Reply-To: <1552576396-19906-1-git-send-email-david.marchand@redhat.com>

Nothing more than the title.

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/net/af_packet/rte_eth_af_packet.c | 49 +++++++++++++++++++++----------
 1 file changed, 33 insertions(+), 16 deletions(-)

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index ec90cc0..cd36eb6 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -310,28 +310,20 @@ struct pmd_internals {
 static int
 eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats)
 {
-	unsigned i, imax;
+	const struct pmd_internals *internal = dev->data->dev_private;
 	unsigned long rx_total = 0, tx_total = 0, tx_err_total = 0;
 	unsigned long rx_bytes_total = 0, tx_bytes_total = 0;
-	const struct pmd_internals *internal = dev->data->dev_private;
+	unsigned int i;
 
-	imax = (internal->nb_queues < RTE_ETHDEV_QUEUE_STAT_CNTRS ?
-	        internal->nb_queues : RTE_ETHDEV_QUEUE_STAT_CNTRS);
-	for (i = 0; i < imax; i++) {
-		igb_stats->q_ipackets[i] = internal->rx_queue[i].rx_pkts;
-		igb_stats->q_ibytes[i] = internal->rx_queue[i].rx_bytes;
-		rx_total += igb_stats->q_ipackets[i];
-		rx_bytes_total += igb_stats->q_ibytes[i];
+	for (i = 0; i < internal->nb_queues; i++) {
+		rx_total += internal->rx_queue[i].rx_pkts;
+		rx_bytes_total += internal->rx_queue[i].rx_bytes;
 	}
 
-	imax = (internal->nb_queues < RTE_ETHDEV_QUEUE_STAT_CNTRS ?
-	        internal->nb_queues : RTE_ETHDEV_QUEUE_STAT_CNTRS);
-	for (i = 0; i < imax; i++) {
-		igb_stats->q_opackets[i] = internal->tx_queue[i].tx_pkts;
-		igb_stats->q_obytes[i] = internal->tx_queue[i].tx_bytes;
-		tx_total += igb_stats->q_opackets[i];
+	for (i = 0; i < internal->nb_queues; i++) {
+		tx_total += internal->tx_queue[i].tx_pkts;
 		tx_err_total += internal->tx_queue[i].err_pkts;
-		tx_bytes_total += igb_stats->q_obytes[i];
+		tx_bytes_total += internal->tx_queue[i].tx_bytes;
 	}
 
 	igb_stats->ipackets = rx_total;
@@ -342,6 +334,29 @@ struct pmd_internals {
 	return 0;
 }
 
+static int
+rxq_stats_get(struct rte_eth_dev *dev, uint16_t rx_queue_id,
+	      struct pmd_eth_rxq_stats *rxq_stats)
+{
+	const struct pmd_internals *internal = dev->data->dev_private;
+
+	rxq_stats->packets = internal->rx_queue[rx_queue_id].rx_pkts;
+	rxq_stats->bytes = internal->rx_queue[rx_queue_id].rx_bytes;
+	return 0;
+}
+
+static int
+txq_stats_get(struct rte_eth_dev *dev, uint16_t tx_queue_id,
+	      struct pmd_eth_txq_stats *txq_stats)
+{
+	const struct pmd_internals *internal = dev->data->dev_private;
+
+	txq_stats->packets = internal->tx_queue[tx_queue_id].tx_pkts;
+	txq_stats->bytes = internal->tx_queue[tx_queue_id].tx_bytes;
+	txq_stats->errors = internal->tx_queue[tx_queue_id].err_pkts;
+	return 0;
+}
+
 static void
 eth_stats_reset(struct rte_eth_dev *dev)
 {
@@ -503,6 +518,8 @@ struct pmd_internals {
 	.tx_queue_release = eth_queue_release,
 	.link_update = eth_link_update,
 	.stats_get = eth_stats_get,
+	.rxq_stats_get = rxq_stats_get,
+	.txq_stats_get = txq_stats_get,
 	.stats_reset = eth_stats_reset,
 };
 
-- 
1.8.3.1


  parent reply	other threads:[~2019-03-14 15:13 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-04 11:18 [dpdk-dev] [PATCH 00/12] rxq q_errors[] statistics fixes David Marchand
2019-03-04 11:18 ` [dpdk-dev] [PATCH 01/12] net/af_packet: fix incorrect rxq errors stat David Marchand
2019-03-04 11:18 ` [dpdk-dev] [PATCH 02/12] net/avp: " David Marchand
2019-03-04 12:18   ` Legacy, Allain
2019-03-04 11:18 ` [dpdk-dev] [PATCH 03/12] net/bnxt: " David Marchand
2019-03-04 11:18 ` [dpdk-dev] [PATCH 04/12] net/cxgbe: " David Marchand
2019-03-04 11:18 ` [dpdk-dev] [PATCH 05/12] net/kni: " David Marchand
2019-03-04 11:18 ` [dpdk-dev] [PATCH 06/12] net/mlx4: " David Marchand
2019-03-05  8:19   ` Shahaf Shuler
2019-03-04 11:18 ` [dpdk-dev] [PATCH 07/12] net/mlx5: " David Marchand
2019-03-05  8:18   ` Shahaf Shuler
2019-03-04 11:18 ` [dpdk-dev] [PATCH 08/12] net/null: " David Marchand
2019-03-04 11:18 ` [dpdk-dev] [PATCH 09/12] net/pcap: " David Marchand
2019-03-04 11:18 ` [dpdk-dev] [PATCH 10/12] net/ring: " David Marchand
2019-03-04 11:18 ` [dpdk-dev] [PATCH 11/12] net/szedata2: " David Marchand
2019-03-04 11:18 ` [dpdk-dev] [PATCH 12/12] net/tap: " David Marchand
2019-03-04 13:58   ` Wiles, Keith
2019-03-11 17:22 ` [dpdk-dev] [PATCH 00/12] rxq q_errors[] statistics fixes Ferruh Yigit
2019-03-11 18:09   ` David Marchand
2019-03-14 15:12     ` David Marchand
2019-03-14 15:12       ` David Marchand
2019-03-14 15:13       ` [dpdk-dev] [RFC PATCH 1/2] ethdev: introduce internal rxq/txq stats API David Marchand
2019-03-14 15:13         ` David Marchand
2019-03-14 15:13         ` David Marchand [this message]
2019-03-14 15:13           ` [dpdk-dev] [RFC PATCH 2/2] net/af_packet: convert to new " David Marchand
2019-03-15 13:30         ` [dpdk-dev] [RFC PATCH 1/2] ethdev: introduce internal " David Marchand
2019-03-15 13:30           ` David Marchand
2019-03-19 17:18         ` Ferruh Yigit
2019-03-19 17:18           ` Ferruh Yigit
2019-03-19 17:54           ` Stephen Hemminger
2019-03-19 17:54             ` Stephen Hemminger
2019-04-12 13:18             ` Thomas Monjalon
2019-04-12 13:18               ` Thomas Monjalon
2019-03-26  9:29           ` David Marchand
2019-03-26  9:29             ` David Marchand
2019-04-12 13:29             ` Thomas Monjalon
2019-04-12 13:29               ` Thomas Monjalon
2019-04-12 14:32               ` David Marchand
2019-04-12 14:32                 ` David Marchand
2019-04-12 16:05                 ` Stephen Hemminger
2019-04-12 16:05                   ` Stephen Hemminger
2019-04-12 15:07   ` [dpdk-dev] [PATCH 00/12] rxq q_errors[] statistics fixes Thomas Monjalon
2019-04-12 15:07     ` Thomas Monjalon
2019-04-12 15:38     ` Ferruh Yigit
2019-04-12 15:38       ` Ferruh Yigit
2019-04-12 15:45       ` Thomas Monjalon
2019-04-12 15:45         ` Thomas Monjalon
2019-04-12 15:57         ` Ferruh Yigit
2019-04-12 15:57           ` Ferruh Yigit
2019-05-28 21:38 ` Yigit, Ferruh

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=1552576396-19906-2-git-send-email-david.marchand@redhat.com \
    --to=david.marchand@redhat.com \
    --cc=arybchenko@solarflare.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=thomas@monjalon.net \
    /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).