From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B8DD04408C; Tue, 21 May 2024 19:05:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6F68C4068A; Tue, 21 May 2024 19:05:14 +0200 (CEST) Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by mails.dpdk.org (Postfix) with ESMTP id 2861E40395 for ; Tue, 21 May 2024 19:05:09 +0200 (CEST) Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-662aeb8d157so547603a12.1 for ; Tue, 21 May 2024 10:05:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1716311108; x=1716915908; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bN+U3MlFvHBy6Y5Ch8EA2M37+2VY2m8EGSXVGyhuBX4=; b=zOWa0diMw3Yq6rxIAdFBBJ4F1tRGCVW12aVTWnHlYiYTK3hZgTMkdAL0s/CyvBDBKD jqykPxvTvnZG40ZeUudBlSTO3c9neYTkj5DxERLJ6XoYs2D7RRkAeqMa7zjHhhuFu36s DB7C/DuL/0BWgCJcIOEhBsUM0DniNfgS0ySzcYEpnw0uuTA1jUkzlN9ZffHsKrX6IqjH XNVRAs5ZX9Etz+C7lW8jKgNEzBSOGrcxgkFpKyMh0D+dRNK5HLOjQgeQNAVT+i4nBG9W zVA1riymKRSTOcu2EFkC42IHlKucew60aG6aJ1k3jccUG9CwqD2ukw9FQVv4nBWHhel/ EsrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716311108; x=1716915908; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bN+U3MlFvHBy6Y5Ch8EA2M37+2VY2m8EGSXVGyhuBX4=; b=uve7HWSYEwYNgafLgSlXbK7sPwKVMXcC8KREl1TWgGZRJiQeYAbIRfUkZrz8IwBu4u /gP8lRBifWD8GcprDUuqpvVUh5eBFon1hGGmtQRaCTVhXqjUdsxNF/+18fCfoOFXObrY wIM2MBqmyW8yhgRO6QJ1EclQ6F3zfGzY1Lye+cQl1p0JtO54YSEViK0ZG0ZMIfjIANa9 KIgod5pm0kie5OcJSIGgDmU2wB1FT5wLDWFES6JLcPyixoQ+QdMfvF9acjsIHqGK2Eoa cD5YJigWPtWhxqlKT0LAuO8MPmAhyZNEK7C6SKO2yfM3C3Au9dyh8hQCj+L+SfGETNlk S3Ew== X-Gm-Message-State: AOJu0YxcqctJtYBmArY0r5Njd2W0RcThSPGH0JIijBD6AV21+ALNEp2H TgtrucKFCteMoQysWGa5U2qxETVJy6ID7ms1nIKPKUpevdEl2yCq0guUfSn1P5p8hSrs9uZLT5m s X-Google-Smtp-Source: AGHT+IETERD4FnEyg1nkf2ts5z9J0kYbD4xxyOGkl1ZDJc7VcEmRPlAOBjDWZb32iXlWL/Fo5CvHqQ== X-Received: by 2002:a17:90a:730a:b0:2ad:6294:7112 with SMTP id 98e67ed59e1d1-2b6cc34294dmr3511799a91.14.1716311108138; Tue, 21 May 2024 10:05:08 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2bd7a0867fcsm4297018a91.29.2024.05.21.10.05.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 10:05:07 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson Subject: [PATCH v8 6/8] net/ring: use generic SW stats Date: Tue, 21 May 2024 10:00:53 -0700 Message-ID: <20240521170453.119036-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240521170453.119036-1-stephen@networkplumber.org> References: <20240510050507.14381-1-stephen@networkplumber.org> <20240521170453.119036-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Use generic per-queue infrastructure. Signed-off-by: Stephen Hemminger --- drivers/net/ring/rte_eth_ring.c | 63 +++++++++++---------------------- 1 file changed, 20 insertions(+), 43 deletions(-) diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index b16f5d55f2..36053e4038 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -7,6 +7,7 @@ #include "rte_eth_ring.h" #include #include +#include #include #include #include @@ -44,8 +45,8 @@ enum dev_action { struct ring_queue { struct rte_ring *rng; - RTE_ATOMIC(uint64_t) rx_pkts; - RTE_ATOMIC(uint64_t) tx_pkts; + + struct rte_eth_counters stats; }; struct pmd_internals { @@ -77,12 +78,12 @@ eth_ring_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) { void **ptrs = (void *)&bufs[0]; struct ring_queue *r = q; - const uint16_t nb_rx = (uint16_t)rte_ring_dequeue_burst(r->rng, - ptrs, nb_bufs, NULL); - if (r->rng->flags & RING_F_SC_DEQ) - r->rx_pkts += nb_rx; - else - rte_atomic_fetch_add_explicit(&r->rx_pkts, nb_rx, rte_memory_order_relaxed); + uint16_t nb_rx; + + nb_rx = (uint16_t)rte_ring_dequeue_burst(r->rng, ptrs, nb_bufs, NULL); + + rte_counter64_add(&r->stats.packets, nb_rx); + return nb_rx; } @@ -91,12 +92,12 @@ eth_ring_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) { void **ptrs = (void *)&bufs[0]; struct ring_queue *r = q; - const uint16_t nb_tx = (uint16_t)rte_ring_enqueue_burst(r->rng, - ptrs, nb_bufs, NULL); - if (r->rng->flags & RING_F_SP_ENQ) - r->tx_pkts += nb_tx; - else - rte_atomic_fetch_add_explicit(&r->tx_pkts, nb_tx, rte_memory_order_relaxed); + uint16_t nb_tx; + + nb_tx = (uint16_t)rte_ring_enqueue_burst(r->rng, ptrs, nb_bufs, NULL); + + rte_counter64_add(&r->stats.packets, nb_tx); + return nb_tx; } @@ -193,40 +194,16 @@ eth_dev_info(struct rte_eth_dev *dev, static int eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { - unsigned int i; - unsigned long rx_total = 0, tx_total = 0; - const struct pmd_internals *internal = dev->data->dev_private; - - for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS && - i < dev->data->nb_rx_queues; i++) { - stats->q_ipackets[i] = internal->rx_ring_queues[i].rx_pkts; - rx_total += stats->q_ipackets[i]; - } - - for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS && - i < dev->data->nb_tx_queues; i++) { - stats->q_opackets[i] = internal->tx_ring_queues[i].tx_pkts; - tx_total += stats->q_opackets[i]; - } - - stats->ipackets = rx_total; - stats->opackets = tx_total; - - return 0; + return rte_eth_counters_stats_get(dev, offsetof(struct ring_queue, stats), + offsetof(struct ring_queue, stats), + stats); } static int eth_stats_reset(struct rte_eth_dev *dev) { - unsigned int i; - struct pmd_internals *internal = dev->data->dev_private; - - for (i = 0; i < dev->data->nb_rx_queues; i++) - internal->rx_ring_queues[i].rx_pkts = 0; - for (i = 0; i < dev->data->nb_tx_queues; i++) - internal->tx_ring_queues[i].tx_pkts = 0; - - return 0; + return rte_eth_counters_reset(dev, offsetof(struct ring_queue, stats), + offsetof(struct ring_queue, stats)); } static void -- 2.43.0