From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id C597FA0096 for ; Thu, 14 Mar 2019 16:13:39 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B032B4CC3; Thu, 14 Mar 2019 16:13:32 +0100 (CET) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 243384C96 for ; Thu, 14 Mar 2019 16:13:31 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 585733001877; Thu, 14 Mar 2019 15:13:30 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.205.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7795F17DC4; Thu, 14 Mar 2019 15:13:28 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: ferruh.yigit@intel.com, thomas@monjalon.net, arybchenko@solarflare.com Date: Thu, 14 Mar 2019 16:13:16 +0100 Message-Id: <1552576396-19906-2-git-send-email-david.marchand@redhat.com> In-Reply-To: <1552576396-19906-1-git-send-email-david.marchand@redhat.com> References: <1552576396-19906-1-git-send-email-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 14 Mar 2019 15:13:30 +0000 (UTC) Subject: [dpdk-dev] [RFC PATCH 2/2] net/af_packet: convert to new rxq/txq stats API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190314151316.pwitivF4KZAPPfdhGIyZG1Ezt3ynS7toj7Z8EVsZUjE@z> Nothing more than the title. Signed-off-by: David Marchand --- 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