Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/140141/?format=api
http://patchwork.dpdk.org/api/patches/140141/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20240516154327.64104-3-stephen@networkplumber.org/", "project": { "id": 1, "url": "http://patchwork.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20240516154327.64104-3-stephen@networkplumber.org>", "list_archive_url": "https://inbox.dpdk.org/dev/20240516154327.64104-3-stephen@networkplumber.org", "date": "2024-05-16T15:40:38", "name": "[v5,2/9] ethdev: add common counters for statistics", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "b743a03d877d90874b670966bdfc93c51fb5ed45", "submitter": { "id": 27, "url": "http://patchwork.dpdk.org/api/people/27/?format=api", "name": "Stephen Hemminger", "email": "stephen@networkplumber.org" }, "delegate": { "id": 1, "url": "http://patchwork.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20240516154327.64104-3-stephen@networkplumber.org/mbox/", "series": [ { "id": 31939, "url": "http://patchwork.dpdk.org/api/series/31939/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=31939", "date": "2024-05-16T15:40:36", "name": "Generic 64 bit counters", "version": 5, "mbox": "http://patchwork.dpdk.org/series/31939/mbox/" } ], "comments": "http://patchwork.dpdk.org/api/patches/140141/comments/", "check": "success", "checks": "http://patchwork.dpdk.org/api/patches/140141/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 6687543F81;\n\tThu, 16 May 2024 17:43:53 +0200 (CEST)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 973F54067C;\n\tThu, 16 May 2024 17:43:42 +0200 (CEST)", "from mail-pf1-f173.google.com (mail-pf1-f173.google.com\n [209.85.210.173])\n by mails.dpdk.org (Postfix) with ESMTP id 48621402EC\n for <dev@dpdk.org>; Thu, 16 May 2024 17:43:40 +0200 (CEST)", "by mail-pf1-f173.google.com with SMTP id\n d2e1a72fcca58-6f5053dc057so378157b3a.2\n for <dev@dpdk.org>; Thu, 16 May 2024 08:43:40 -0700 (PDT)", "from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226])\n by smtp.gmail.com with ESMTPSA id\n d2e1a72fcca58-6f67b526b44sm2457430b3a.149.2024.05.16.08.43.38\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 16 May 2024 08:43:39 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1715874219;\n x=1716479019; darn=dpdk.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=Z8eKqf5lNQlmO6QqgxdqNWvOCC2KYo8qD/rGb5b3ZPM=;\n b=0koqf56p6khI9tL8rR2jCVUp2oNTc5g/RHZ17VEPESUr0DwZtQlZFyEPN50sQaUAIE\n iKAwaMPsyF+EQWVet5b2kVpgCYNVbO7V1Klm1y8qEe9H8w3j3Wnp3/4IFLC8Zy6ihiis\n dmv9iGa4cV19ipPTw/OJZkTtBjkKaa/XM4nM7VUgkoyjeOXy35TF0DyoT4m0mE1+E3u7\n q0wpcLz3md2ATyqdcNb8PdrotFishlARxskJbWcLa603ypZ6pziKsCv8PyaaEQM54H+H\n pbaEnRaknrzTXa9TTjxIUfHXGlZ1WFp2OXGZEKkh7+BfZfA5l//hCwmwlRPQtlp62NLr\n DNKA==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1715874219; x=1716479019;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=Z8eKqf5lNQlmO6QqgxdqNWvOCC2KYo8qD/rGb5b3ZPM=;\n b=mJDgIN1zDvfRDYeN5URVWxu77klibP0c2UtGvHBzRo64lT2TP94BULAJ/fZ3zFRwg3\n dLL67PrRmoPjRYn1z0H3qoHf3VNrqds7HDng+BRqoSJRDqRw9E8a8jQIiK6ddATqC2g/\n HApgwdRuDi8UaGSlEzB8PZOa5HfyzyQAfvCntHDrj0rMQo5dvb2+rlefH6nYn57XfLaH\n 2p32UHj9UmeIW7sWIAEjTNxqueEcKn1KtEVUrLPwFMfEV/It+tYKmzvaGfdHS4FVJ7cX\n GveWSEkwUgfB+oJwxUo2TR7rPcXpxhJH1iI0+qJocLVwZt3tndhLKuxi0IBIs1JG69CN\n 20CA==", "X-Gm-Message-State": "AOJu0Yz6xyZmTHV5qlqDIISql+aKbpPt1Spq5gpa16tMWKi1T3rA/Wvu\n aLInWKRUW1qQSPYvdjg/mlZHU4sGwYNcoNW23rbirytOjGHHpgnzVgn+LDTFpODmbETkP0TCse8\n lkZM=", "X-Google-Smtp-Source": "\n AGHT+IH2Qwp8msyyY2kr2wcK2Zc1sW3Gd7XlvESqkCu9Bf/v4oOvrA8RB3s0DeLlkULHH09+IpfWnQ==", "X-Received": "by 2002:a05:6a21:150b:b0:1af:e3f1:9af7 with SMTP id\n adf61e73a8af0-1afe3f1ba98mr22826509637.36.1715874219351;\n Thu, 16 May 2024 08:43:39 -0700 (PDT)", "From": "Stephen Hemminger <stephen@networkplumber.org>", "To": "dev@dpdk.org", "Cc": "Stephen Hemminger <stephen@networkplumber.org>,\n Thomas Monjalon <thomas@monjalon.net>, Ferruh Yigit <ferruh.yigit@amd.com>,\n Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>", "Subject": "[PATCH v5 2/9] ethdev: add common counters for statistics", "Date": "Thu, 16 May 2024 08:40:38 -0700", "Message-ID": "<20240516154327.64104-3-stephen@networkplumber.org>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20240516154327.64104-1-stephen@networkplumber.org>", "References": "<20240510050507.14381-1-stephen@networkplumber.org>\n <20240516154327.64104-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 <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org" }, "content": "Introduce common helper routines for keeping track of per-queue\nstatistics in SW PMD's. The code in several drivers had\ncopy/pasted the same code for this, but had common issues\nwith 64 bit counters on 32 bit platforms.\n\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\n---\n lib/ethdev/ethdev_swstats.c | 109 +++++++++++++++++++++++++++++++\n lib/ethdev/ethdev_swstats.h | 124 ++++++++++++++++++++++++++++++++++++\n lib/ethdev/meson.build | 2 +\n lib/ethdev/version.map | 3 +\n 4 files changed, 238 insertions(+)\n create mode 100644 lib/ethdev/ethdev_swstats.c\n create mode 100644 lib/ethdev/ethdev_swstats.h", "diff": "diff --git a/lib/ethdev/ethdev_swstats.c b/lib/ethdev/ethdev_swstats.c\nnew file mode 100644\nindex 0000000000..7892b2180b\n--- /dev/null\n+++ b/lib/ethdev/ethdev_swstats.c\n@@ -0,0 +1,109 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright (c) Stephen Hemminger <stephen@networkplumber.org>\n+ */\n+\n+\n+#include <rte_config.h>\n+#include <rte_common.h>\n+#include <rte_atomic.h>\n+\n+#include \"rte_ethdev.h\"\n+#include \"ethdev_driver.h\"\n+#include \"ethdev_swstats.h\"\n+\n+int\n+rte_eth_counters_stats_get(const struct rte_eth_dev *dev,\n+\t\t\t size_t tx_offset, size_t rx_offset,\n+\t\t\t struct rte_eth_stats *stats)\n+{\n+\tuint64_t packets, bytes, errors;\n+\tunsigned int i;\n+\n+\tfor (i = 0; i < dev->data->nb_tx_queues; i++) {\n+\t\tconst void *txq = dev->data->tx_queues[i];\n+\t\tconst struct rte_eth_counters *counters;\n+\n+\t\tif (txq == NULL)\n+\t\t\tcontinue;\n+\n+\t\tcounters = (const struct rte_eth_counters *)((const char *)txq + tx_offset);\n+\t\tpackets = rte_counter64_fetch(&counters->packets);\n+\t\tbytes = rte_counter64_fetch(&counters->bytes);\n+\t\terrors = rte_counter64_fetch(&counters->errors);\n+\n+\t\t/*\n+\t\t * Prevent compiler from fetching values twice which would\n+\t\t * cause per-queue and global statistics to not match.\n+\t\t */\n+\t\trte_compiler_barrier();\n+\n+\t\tstats->opackets += packets;\n+\t\tstats->obytes += bytes;\n+\t\tstats->oerrors += errors;\n+\n+\t\tif (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) {\n+\t\t\tstats->q_opackets[i] = packets;\n+\t\t\tstats->q_obytes[i] = bytes;\n+\t\t}\n+\t}\n+\n+\tfor (i = 0; i < dev->data->nb_rx_queues; i++) {\n+\t\tconst void *rxq = dev->data->rx_queues[i];\n+\t\tconst struct rte_eth_counters *counters;\n+\n+\t\tif (rxq == NULL)\n+\t\t\tcontinue;\n+\n+\t\tcounters = (const struct rte_eth_counters *)((const char *)rxq + rx_offset);\n+\t\tpackets = rte_counter64_fetch(&counters->packets);\n+\t\tbytes = rte_counter64_fetch(&counters->bytes);\n+\t\terrors = rte_counter64_fetch(&counters->errors);\n+\n+\t\trte_compiler_barrier();\n+\n+\t\tstats->ipackets += packets;\n+\t\tstats->ibytes += bytes;\n+\t\tstats->ierrors += errors;\n+\n+\t\tif (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) {\n+\t\t\tstats->q_ipackets[i] = packets;\n+\t\t\tstats->q_ibytes[i] = bytes;\n+\t\t}\n+\t}\n+\n+\tstats->rx_nombuf = dev->data->rx_mbuf_alloc_failed;\n+\treturn 0;\n+}\n+\n+int\n+rte_eth_counters_reset(struct rte_eth_dev *dev, size_t tx_offset, size_t rx_offset)\n+{\n+\tstruct rte_eth_counters *counters;\n+\tunsigned int i;\n+\n+\tfor (i = 0; i < dev->data->nb_tx_queues; i++) {\n+\t\tvoid *txq = dev->data->tx_queues[i];\n+\n+\t\tif (txq == NULL)\n+\t\t\tcontinue;\n+\n+\t\tcounters = (struct rte_eth_counters *)((char *)txq + tx_offset);\n+\t\trte_counter64_reset(&counters->packets);\n+\t\trte_counter64_reset(&counters->bytes);\n+\t\trte_counter64_reset(&counters->errors);\n+\t}\n+\n+\tfor (i = 0; i < dev->data->nb_rx_queues; i++) {\n+\t\tvoid *rxq = dev->data->rx_queues[i];\n+\n+\t\tif (rxq == NULL)\n+\t\t\tcontinue;\n+\n+\t\tcounters = (struct rte_eth_counters *)((char *)rxq + rx_offset);\n+\t\trte_counter64_reset(&counters->packets);\n+\t\trte_counter64_reset(&counters->bytes);\n+\t\trte_counter64_reset(&counters->errors);\n+\t}\n+\n+\treturn 0;\n+}\ndiff --git a/lib/ethdev/ethdev_swstats.h b/lib/ethdev/ethdev_swstats.h\nnew file mode 100644\nindex 0000000000..808c540640\n--- /dev/null\n+++ b/lib/ethdev/ethdev_swstats.h\n@@ -0,0 +1,124 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright (c) Stephen Hemminger <stephen@networkplumber.org>\n+ */\n+\n+#ifndef _RTE_ETHDEV_SWSTATS_H_\n+#define _RTE_ETHDEV_SWSTATS_H_\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+/**\n+ * @file\n+ *\n+ * Internal statistics counters for software based devices.\n+ * Hardware PMD's should use the hardware counters instead.\n+ *\n+ * This provides a library for PMD's to keep track of packets and bytes.\n+ * It is assumed that this will be used per queue and queues are not\n+ * shared by lcores.\n+ */\n+\n+#include <rte_counter.h>\n+\n+/**\n+ * A structure to be embedded in the device driver per-queue data.\n+ */\n+struct rte_eth_counters {\n+\trte_counter64_t\tpackets;\t/**< Total number of packets. */\n+\trte_counter64_t\tbytes;\t\t/**< Total number of bytes. */\n+\trte_counter64_t\terrors;\t\t/**< Total number of packets with errors. */\n+};\n+\n+/**\n+ * @internal\n+ * Increment counters for a single packet.\n+ *\n+ * @param counters\n+ * Pointer to queue structure containing counters.\n+ * @param sz\n+ * Size of the packet in bytes.\n+ */\n+__rte_internal\n+static inline void\n+rte_eth_count_packet(struct rte_eth_counters *counters, uint32_t sz)\n+{\n+\trte_counter64_add(&counters->packets, 1);\n+\trte_counter64_add(&counters->bytes, sz);\n+}\n+\n+/**\n+ * @internal\n+ * Increment counters based on mbuf.\n+ *\n+ * @param counters\n+ * Pointer to queue structure containing counters.\n+ * @param mbuf\n+ * Received or transmitted mbuf.\n+ */\n+__rte_internal\n+static inline void\n+rte_eth_count_mbuf(struct rte_eth_counters *counters, const struct rte_mbuf *mbuf)\n+{\n+\trte_eth_count_packet(counters, rte_pktmbuf_pkt_len(mbuf));\n+}\n+\n+/**\n+ * @internal\n+ * Increment error counter.\n+ *\n+ * @param counters\n+ * Pointer to queue structure containing counters.\n+ */\n+__rte_internal\n+static inline void\n+rte_eth_count_error(struct rte_eth_counters *counters)\n+{\n+\trte_counter64_add(&counters->errors, 1);\n+}\n+\n+/**\n+ * @internal\n+ * Retrieve the general statistics for all queues.\n+ * @see rte_eth_stats_get.\n+ *\n+ * @param dev\n+ * Pointer to the Ethernet device structure.\n+ * @param tx_offset\n+ * Offset from the tx_queue structure where stats are located.\n+ * @param rx_offset\n+ * Offset from the rx_queue structure where stats are located.\n+ * @param stats\n+ * A pointer to a structure of type *rte_eth_stats* to be filled\n+ * @return\n+ * Zero if successful. Non-zero otherwise.\n+ */\n+__rte_internal\n+int rte_eth_counters_stats_get(const struct rte_eth_dev *dev,\n+\t\t\t size_t tx_offset, size_t rx_offset,\n+\t\t\t struct rte_eth_stats *stats);\n+\n+/**\n+ * @internal\n+ * Reset the statistics for all queues.\n+ * @see rte_eth_stats_reset.\n+ *\n+ * @param dev\n+ * Pointer to the Ethernet device structure.\n+ * @param tx_offset\n+ * Offset from the tx_queue structure where stats are located.\n+ * @param rx_offset\n+ * Offset from the rx_queue structure where stats are located.\n+ * @return\n+ * Zero if successful. Non-zero otherwise.\n+ */\n+__rte_internal\n+int rte_eth_counters_reset(struct rte_eth_dev *dev,\n+\t\t\t size_t tx_offset, size_t rx_offset);\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+#endif /* _RTE_ETHDEV_SWSTATS_H_ */\ndiff --git a/lib/ethdev/meson.build b/lib/ethdev/meson.build\nindex f1d2586591..7ce29a46d4 100644\n--- a/lib/ethdev/meson.build\n+++ b/lib/ethdev/meson.build\n@@ -3,6 +3,7 @@\n \n sources = files(\n 'ethdev_driver.c',\n+ 'ethdev_swstats.c',\n 'ethdev_private.c',\n 'ethdev_profile.c',\n 'ethdev_trace_points.c',\n@@ -42,6 +43,7 @@ driver_sdk_headers += files(\n 'ethdev_driver.h',\n 'ethdev_pci.h',\n 'ethdev_vdev.h',\n+ 'ethdev_swstats.h',\n )\n \n if is_linux\ndiff --git a/lib/ethdev/version.map b/lib/ethdev/version.map\nindex 79f6f5293b..fc595be278 100644\n--- a/lib/ethdev/version.map\n+++ b/lib/ethdev/version.map\n@@ -358,4 +358,7 @@ INTERNAL {\n \trte_eth_switch_domain_alloc;\n \trte_eth_switch_domain_free;\n \trte_flow_fp_default_ops;\n+\n+\trte_eth_counters_reset;\n+\trte_eth_counters_stats_get;\n };\n", "prefixes": [ "v5", "2/9" ] }{ "id": 140141, "url": "