Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/140068/?format=api
http://patches.dpdk.org/api/patches/140068/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20240514153845.42489-3-stephen@networkplumber.org/", "project": { "id": 1, "url": "http://patches.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": "<20240514153845.42489-3-stephen@networkplumber.org>", "list_archive_url": "https://inbox.dpdk.org/dev/20240514153845.42489-3-stephen@networkplumber.org", "date": "2024-05-14T15:35:05", "name": "[v3,2/7] ethdev: add internal helper of SW driver statistics", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "a0ce7d80a4f5f0bdb14659255446ace64b72861a", "submitter": { "id": 27, "url": "http://patches.dpdk.org/api/people/27/?format=api", "name": "Stephen Hemminger", "email": "stephen@networkplumber.org" }, "delegate": { "id": 1, "url": "http://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20240514153845.42489-3-stephen@networkplumber.org/mbox/", "series": [ { "id": 31926, "url": "http://patches.dpdk.org/api/series/31926/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=31926", "date": "2024-05-14T15:35:03", "name": "Generic SW counters", "version": 3, "mbox": "http://patches.dpdk.org/series/31926/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/140068/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/140068/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 3F4454401F;\n\tTue, 14 May 2024 17:39:10 +0200 (CEST)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 4B7AA40685;\n\tTue, 14 May 2024 17:39:01 +0200 (CEST)", "from mail-pl1-f178.google.com (mail-pl1-f178.google.com\n [209.85.214.178])\n by mails.dpdk.org (Postfix) with ESMTP id 2DABF4067C\n for <dev@dpdk.org>; Tue, 14 May 2024 17:38:58 +0200 (CEST)", "by mail-pl1-f178.google.com with SMTP id\n d9443c01a7336-1eca195a7c8so47009105ad.2\n for <dev@dpdk.org>; Tue, 14 May 2024 08:38:58 -0700 (PDT)", "from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226])\n by smtp.gmail.com with ESMTPSA id\n d9443c01a7336-1ef0c137f14sm99256415ad.259.2024.05.14.08.38.56\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 14 May 2024 08:38:56 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1715701137;\n x=1716305937; 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=gts8uUcExwIpR02Zi6vufTEVJNOtGoO1fl5kRPEjhj4=;\n b=BjFlTFdIksoh1JsHtnyORuM6YOfPBnPLjV2Bt5AdhHkufHKoSI24r4TBW9h5iahHds\n 0Bv5YHs51GmjsSypEIMfPu6tAWaMlBxE8t45OHM9ZyHm45P0JNc6+M3+df86gxiI+6r1\n 1VKjxuEebo/hydWUdFofwY/7ZG8RIrtVTMkX9Ue9WJBf3TbYgihz1Ue4LOyZRThhZseb\n bgFWyBAK2AQFJlqEW3WXnhEMwloWaNvLZqOlINSzVFa3Qf9jFB1fF4dsBbgS6bF7dNka\n YPkZzvakk7AgzCfAEmIwYyKOhku7IY4Ujo4c5TbMEslGGOG5IM6FeBYixZOuuwdl/gkx\n I76Q==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1715701137; x=1716305937;\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=gts8uUcExwIpR02Zi6vufTEVJNOtGoO1fl5kRPEjhj4=;\n b=EeMwprhQinGgh7fetT8qLBXuZ+hqUiAvnw0HHkVefO4dg3TYCXVsftZWwTKF0rAaqY\n ayCCGSww6jY+FSdTRNaIdvyv68b1Huwv1cecVyCDKAk0jjitacSStfPf20OlWdPvZl2f\n 0ENIAdACUvdasMYyNTpB/KCPwGli/ztmoquINSs2Bdly1Nom3m5DMMqhkOfI//4XRVXy\n qSkT7Kur0l+l2SQQmJ8VWL75IAm1xabwiddk31hRMn2c4KYSK75+CAI0riVaKnK30Qf+\n MT11fh8GPKvFCM2ViYyiRv7sTRoj83VpyhlniW9wfH4WL9+iRtymHqmqR5IpjbvtkOgD\n djng==", "X-Gm-Message-State": "AOJu0YxJPbYAAAYH6ZEwYHGPOmXIJWKZvqxwULv67izNxsVI86II8/rg\n GYKxhVKo8GbT7iO8RNpIzwULkLkmV93s4fE5kZ6eTChmaAlQjqyo81A3Aixx2NUaR08oqBWkD9l\n wQqc=", "X-Google-Smtp-Source": "\n AGHT+IGly15ruXHJoH3KCrqM26UaoOryuepJRfDulmIW0du8JOgeoiFclomse7z6kxhPbiQcQD0j2w==", "X-Received": "by 2002:a17:903:298c:b0:1eb:7ba:a4ba with SMTP id\n d9443c01a7336-1ef440495f7mr142642515ad.45.1715701137188;\n Tue, 14 May 2024 08:38:57 -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 v3 2/7] ethdev: add internal helper of SW driver statistics", "Date": "Tue, 14 May 2024 08:35:05 -0700", "Message-ID": "<20240514153845.42489-3-stephen@networkplumber.org>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20240514153845.42489-1-stephen@networkplumber.org>", "References": "<20240510050507.14381-1-stephen@networkplumber.org>\n <20240514153845.42489-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 | 106 ++++++++++++++++++++++++++++++\n lib/ethdev/ethdev_swstats.h | 124 ++++++++++++++++++++++++++++++++++++\n lib/ethdev/meson.build | 2 +\n lib/ethdev/version.map | 3 +\n 4 files changed, 235 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..4421b59930\n--- /dev/null\n+++ b/lib/ethdev/ethdev_swstats.c\n@@ -0,0 +1,106 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright (c) Stephen Hemminger <stephen@networkplumber.org>\n+ */\n+\n+#include <stdbool.h>\n+\n+#include <rte_common.h>\n+#include <ethdev_driver.h>\n+\n+#include \"rte_ethdev.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+\tunsigned int i;\n+\tuint64_t packets, bytes, errors;\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/* Prevent compiler for fetching these values twice */\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\t/* Prevent compiler for fetching these values twice */\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": [ "v3", "2/7" ] }{ "id": 140068, "url": "