From patchwork Fri Dec 4 07:51:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hideyuki Yamashita X-Patchwork-Id: 84749 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id EAC61A04B0; Fri, 4 Dec 2020 08:52:05 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4D25CC8CC; Fri, 4 Dec 2020 08:51:54 +0100 (CET) Received: from dish-sg.nttdocomo.co.jp (dish-sg.nttdocomo.co.jp [202.19.227.74]) by dpdk.org (Postfix) with ESMTP id 1C92334F3 for ; Fri, 4 Dec 2020 08:51:53 +0100 (CET) X-dD-Source: Outbound Received: from zssg-mailmd106.ddreams.local (zssg-mailmd900.ddreams.local [10.160.172.63]) by zssg-mailou104.ddreams.local (Postfix) with ESMTP id 5E00B12013D; Fri, 4 Dec 2020 16:51:51 +0900 (JST) Received: from zssg-mailmf101.ddreams.local (zssg-mailmf900.ddreams.local [10.160.172.84]) by zssg-mailmd106.ddreams.local (dDREAMS) with ESMTP id <0QKT00Q8C1UFL140@dDREAMS>; Fri, 04 Dec 2020 16:51:51 +0900 (JST) Received: from zssg-mailmf101.ddreams.local (unknown [127.0.0.1]) by zssg-mailmf101.ddreams.local (Postfix) with ESMTP id 3B8017E6034; Fri, 4 Dec 2020 16:51:51 +0900 (JST) Received: from zssg-mailmf101.ddreams.local (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 39B5F8E6054; Fri, 4 Dec 2020 16:51:51 +0900 (JST) Received: from localhost (unknown [127.0.0.1]) by IMSVA (Postfix) with SMTP id 2D9238E605A; Fri, 4 Dec 2020 16:51:51 +0900 (JST) X-IMSS-HAND-OFF-DIRECTIVE: localhost:10026 Received: from zssg-mailmf101.ddreams.local (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D5EF98E6056; Fri, 4 Dec 2020 16:51:50 +0900 (JST) Received: from davinci.ntt-tx.co.jp (unknown [10.160.183.139]) by zssg-mailmf101.ddreams.local (Postfix) with ESMTP; Fri, 4 Dec 2020 16:51:50 +0900 (JST) From: Hideyuki Yamashita To: Thomas Monjalon Cc: dev@dpdk.org, Hideyuki Yamashita , Hideyuki Yamashita Date: Fri, 04 Dec 2020 16:51:05 +0900 Message-id: <20201204075109.14694-2-yamashita.hideyuki@ntt-tx.co.jp> X-Mailer: git-send-email 2.28.0 In-reply-to: <20201204075109.14694-1-yamashita.hideyuki@ntt-tx.co.jp> References: <20201204075109.14694-1-yamashita.hideyuki@ntt-tx.co.jp> MIME-version: 1.0 Content-transfer-encoding: 8bit X-TM-AS-GCONF: 00 Subject: [dpdk-dev] [PATCH 1/5] maintainers: update maintainers file for apistats 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" This patch adds maintainer of rte_apistats.c and rte_apistats.h. Signed-off-by: Hideyuki Yamashita --- MAINTAINERS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index eafe9f8..dba2acf 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -489,6 +489,9 @@ F: drivers/raw/skeleton/ F: app/test/test_rawdev.c F: doc/guides/prog_guide/rawdev.rst +API stats API -EXPERIMENTAL +M: Hideyuki Yamashita +F: lib/librte_ethdev/rte_apistats.* Memory Pool Drivers ------------------- From patchwork Fri Dec 4 07:51:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hideyuki Yamashita X-Patchwork-Id: 84750 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id BF3DCA04B0; Fri, 4 Dec 2020 08:52:25 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D5A7AC9C6; Fri, 4 Dec 2020 08:51:58 +0100 (CET) Received: from dish-sg.nttdocomo.co.jp (dish-sg.nttdocomo.co.jp [202.19.227.74]) by dpdk.org (Postfix) with ESMTP id 140D5C9C2 for ; Fri, 4 Dec 2020 08:51:57 +0100 (CET) X-dD-Source: Outbound Received: from zssg-mailmd106.ddreams.local (zssg-mailmd900.ddreams.local [10.160.172.63]) by zssg-mailou103.ddreams.local (Postfix) with ESMTP id 499D5120120; Fri, 4 Dec 2020 16:51:55 +0900 (JST) Received: from zssg-mailmf101.ddreams.local (zssg-mailmf900.ddreams.local [10.160.172.84]) by zssg-mailmd106.ddreams.local (dDREAMS) with ESMTP id <0QKT00QAC1UJL140@dDREAMS>; Fri, 04 Dec 2020 16:51:55 +0900 (JST) Received: from zssg-mailmf101.ddreams.local (unknown [127.0.0.1]) by zssg-mailmf101.ddreams.local (Postfix) with ESMTP id 1A9757E6036; Fri, 4 Dec 2020 16:51:55 +0900 (JST) Received: from zssg-mailmf101.ddreams.local (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 17F058E6060; Fri, 4 Dec 2020 16:51:55 +0900 (JST) Received: from localhost (unknown [127.0.0.1]) by IMSVA (Postfix) with SMTP id 155F38E605C; Fri, 4 Dec 2020 16:51:55 +0900 (JST) X-IMSS-HAND-OFF-DIRECTIVE: localhost:10026 Received: from zssg-mailmf101.ddreams.local (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C856C8E605A; Fri, 4 Dec 2020 16:51:54 +0900 (JST) Received: from davinci.ntt-tx.co.jp (unknown [10.160.183.139]) by zssg-mailmf101.ddreams.local (Postfix) with ESMTP; Fri, 4 Dec 2020 16:51:54 +0900 (JST) From: Hideyuki Yamashita To: Maryam Tahhan , Reshma Pattan Cc: dev@dpdk.org, Hideyuki Yamashita , Hideyuki Yamashita Date: Fri, 04 Dec 2020 16:51:06 +0900 Message-id: <20201204075109.14694-3-yamashita.hideyuki@ntt-tx.co.jp> X-Mailer: git-send-email 2.28.0 In-reply-to: <20201204075109.14694-1-yamashita.hideyuki@ntt-tx.co.jp> References: <20201204075109.14694-1-yamashita.hideyuki@ntt-tx.co.jp> MIME-version: 1.0 Content-transfer-encoding: 8bit X-TM-AS-GCONF: 00 Subject: [dpdk-dev] [PATCH 2/5] app/proc-info: add to use apistats 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" This patch modifies to use apistats by proc-info app. - change on main.c to call apistats functions - change on Makefile to include experimental API Signed-off-by: Hideyuki Yamashita --- app/proc-info/main.c | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/app/proc-info/main.c b/app/proc-info/main.c index d743209..d384b13 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -37,6 +37,7 @@ #include #include #include +#include /* Maximum long option length for option parsing. */ #define MAX_LONG_OPT_SZ 64 @@ -93,6 +94,8 @@ static char *mempool_name; /**< Enable iter mempool. */ static uint32_t enable_iter_mempool; static char *mempool_iter_name; +/**< Enable api stats. */ +static uint32_t enable_apistats; /**< display usage */ static void @@ -109,6 +112,7 @@ proc_info_usage(const char *prgname) " --xstats-name NAME: to display single xstat id by NAME\n" " --xstats-ids IDLIST: to display xstat values by id. " "The argument is comma-separated list of xstat ids to print out.\n" + " --apistats: to display api statistics, disabled by default\n" " --stats-reset: to reset port statistics\n" " --xstats-reset: to reset port extended statistics\n" " --collectd-format: to print statistics to STDOUT in expected by collectd format\n" @@ -218,6 +222,7 @@ proc_info_parse_args(int argc, char **argv) {"xstats-name", required_argument, NULL, 1}, {"collectd-format", 0, NULL, 0}, {"xstats-ids", 1, NULL, 1}, + {"apistats", 0, NULL, 0}, {"host-id", 0, NULL, 0}, {"show-port", 0, NULL, 0}, {"show-tm", 0, NULL, 0}, @@ -266,6 +271,9 @@ proc_info_parse_args(int argc, char **argv) else if (!strncmp(long_option[option_index].name, "xstats-reset", MAX_LONG_OPT_SZ)) reset_xstats = 1; + else if (!strncmp(long_option[option_index].name, "apistats", + MAX_LONG_OPT_SZ)) + enable_apistats = 1; else if (!strncmp(long_option[option_index].name, "show-port", MAX_LONG_OPT_SZ)) enable_shw_port = 1; @@ -1349,6 +1357,40 @@ iter_mempool(char *name) } } +static void +display_apistats(void) +{ + static const char *api_stats_border = "########################"; + uint16_t i; + struct rte_apistats t0_count, t1_count; + memcpy(&t0_count, rte_apicounts, sizeof(struct rte_apistats)); + sleep(1); + memcpy(&t1_count, rte_apicounts, sizeof(struct rte_apistats)); + for (i = 0; i < RTE_MAX_LCORE; i++) { + if (t1_count.lcoreid_list[i] != 0) { + uint64_t rx_count_delta = t1_count.rx_burst_counts[i] + - t0_count.rx_burst_counts[i]; + uint64_t tx_count_delta = t1_count.tx_burst_counts[i] + - t0_count.tx_burst_counts[i]; + printf("\n %s api statistics for lcoreid: %d %s\n", + api_stats_border, i, api_stats_border); + printf(" rx_burst_count: %13"PRIu64"" + " rx_burst_count_delta: %13"PRIu64"\n", + t1_count.rx_burst_counts[i], + rx_count_delta); + printf(" tx_burst_count: %13"PRIu64"" + " tx_burst_count_delta: %13"PRIu64"\n", + t1_count.tx_burst_counts[i], + tx_count_delta); + printf(" tx/rx_rate: %3.2f\n", + (rx_count_delta) ? (double)tx_count_delta + / rx_count_delta : 0.0); + printf(" %s################################%s\n", + api_stats_border, api_stats_border); + } + } +} + int main(int argc, char **argv) { @@ -1389,6 +1431,8 @@ main(int argc, char **argv) if (!rte_eal_primary_proc_alive(NULL)) rte_exit(EXIT_FAILURE, "No primary DPDK process is running.\n"); + rte_apistats_init(); + /* parse app arguments */ ret = proc_info_parse_args(argc, argv); if (ret < 0) @@ -1454,6 +1498,8 @@ main(int argc, char **argv) show_mempool(mempool_name); if (enable_iter_mempool) iter_mempool(mempool_iter_name); + if (enable_apistats) + display_apistats(); RTE_ETH_FOREACH_DEV(i) rte_eth_dev_close(i); From patchwork Fri Dec 4 07:51:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hideyuki Yamashita X-Patchwork-Id: 84751 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id EE87FA04B0; Fri, 4 Dec 2020 08:52:42 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 81983C9D3; Fri, 4 Dec 2020 08:52:01 +0100 (CET) Received: from dish-sg.nttdocomo.co.jp (dish-sg.nttdocomo.co.jp [202.19.227.74]) by dpdk.org (Postfix) with ESMTP id B8DD9C9D0 for ; Fri, 4 Dec 2020 08:52:00 +0100 (CET) X-dD-Source: Outbound Received: from zssg-mailmd102.ddreams.local (zssg-mailmd900.ddreams.local [10.160.172.63]) by zssg-mailou104.ddreams.local (Postfix) with ESMTP id F169E120142; Fri, 4 Dec 2020 16:51:58 +0900 (JST) Received: from zssg-mailmf101.ddreams.local (zssg-mailmf900.ddreams.local [10.160.172.84]) by zssg-mailmd102.ddreams.local (dDREAMS) with ESMTP id <0QKT008YJ1UMJPD0@dDREAMS>; Fri, 04 Dec 2020 16:51:58 +0900 (JST) Received: from zssg-mailmf101.ddreams.local (unknown [127.0.0.1]) by zssg-mailmf101.ddreams.local (Postfix) with ESMTP id D20F37E6036; Fri, 4 Dec 2020 16:51:58 +0900 (JST) Received: from zssg-mailmf101.ddreams.local (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D008D8E6058; Fri, 4 Dec 2020 16:51:58 +0900 (JST) Received: from localhost (unknown [127.0.0.1]) by IMSVA (Postfix) with SMTP id CC6ED8E605B; Fri, 4 Dec 2020 16:51:58 +0900 (JST) X-IMSS-HAND-OFF-DIRECTIVE: localhost:10026 Received: from zssg-mailmf101.ddreams.local (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6DAD28E605A; Fri, 4 Dec 2020 16:51:58 +0900 (JST) Received: from davinci.ntt-tx.co.jp (unknown [10.160.183.139]) by zssg-mailmf101.ddreams.local (Postfix) with ESMTP; Fri, 4 Dec 2020 16:51:58 +0900 (JST) From: Hideyuki Yamashita To: Wenzhuo Lu , Beilei Xing , Bernard Iremonger Cc: dev@dpdk.org, Hideyuki Yamashita , Hideyuki Yamashita Date: Fri, 04 Dec 2020 16:51:07 +0900 Message-id: <20201204075109.14694-4-yamashita.hideyuki@ntt-tx.co.jp> X-Mailer: git-send-email 2.28.0 In-reply-to: <20201204075109.14694-1-yamashita.hideyuki@ntt-tx.co.jp> References: <20201204075109.14694-1-yamashita.hideyuki@ntt-tx.co.jp> MIME-version: 1.0 Content-transfer-encoding: 8bit X-TM-AS-GCONF: 00 Subject: [dpdk-dev] [PATCH 3/5] app/test-pmd: add to use apistats 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" This patch modifies to use apistats by testpmd app. - change on testpmd.c to call apistats functions to accumlate stats info Signed-off-by: Hideyuki Yamashita --- app/test-pmd/testpmd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 33fc0fd..e782bfe 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -60,6 +60,8 @@ #ifdef RTE_LIB_LATENCYSTATS #include #endif +#include + #include "testpmd.h" @@ -3958,6 +3960,8 @@ main(int argc, char** argv) } #endif + rte_apistats_init(); + /* Setup bitrate stats */ #ifdef RTE_LIB_BITRATESTATS if (bitrate_enabled != 0) { From patchwork Fri Dec 4 07:51:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hideyuki Yamashita X-Patchwork-Id: 84752 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 231F8A04B0; Fri, 4 Dec 2020 08:53:01 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E88B1C9DC; Fri, 4 Dec 2020 08:52:05 +0100 (CET) Received: from dish-sg.nttdocomo.co.jp (dish-sg.nttdocomo.co.jp [202.19.227.74]) by dpdk.org (Postfix) with ESMTP id 57B6DC9D8 for ; Fri, 4 Dec 2020 08:52:04 +0100 (CET) X-dD-Source: Outbound Received: from zssg-mailmd106.ddreams.local (zssg-mailmd900.ddreams.local [10.160.172.63]) by zssg-mailou104.ddreams.local (Postfix) with ESMTP id 9AC0512013D; Fri, 4 Dec 2020 16:52:02 +0900 (JST) Received: from zssg-mailmf101.ddreams.local (zssg-mailmf900.ddreams.local [10.160.172.84]) by zssg-mailmd106.ddreams.local (dDREAMS) with ESMTP id <0QKT00QGF1UQL140@dDREAMS>; Fri, 04 Dec 2020 16:52:02 +0900 (JST) Received: from zssg-mailmf101.ddreams.local (unknown [127.0.0.1]) by zssg-mailmf101.ddreams.local (Postfix) with ESMTP id 79FCD7E603A; Fri, 4 Dec 2020 16:52:02 +0900 (JST) Received: from zssg-mailmf101.ddreams.local (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 75C158E605D; Fri, 4 Dec 2020 16:52:02 +0900 (JST) Received: from localhost (unknown [127.0.0.1]) by IMSVA (Postfix) with SMTP id 74DE28E605C; Fri, 4 Dec 2020 16:52:02 +0900 (JST) X-IMSS-HAND-OFF-DIRECTIVE: localhost:10026 Received: from zssg-mailmf101.ddreams.local (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AE5D08E6055; Fri, 4 Dec 2020 16:52:01 +0900 (JST) Received: from davinci.ntt-tx.co.jp (unknown [10.160.183.139]) by zssg-mailmf101.ddreams.local (Postfix) with ESMTP; Fri, 4 Dec 2020 16:52:01 +0900 (JST) From: Hideyuki Yamashita To: Maryam Tahhan , Reshma Pattan Cc: dev@dpdk.org, Hideyuki Yamashita , Hideyuki Yamashita Date: Fri, 04 Dec 2020 16:51:08 +0900 Message-id: <20201204075109.14694-5-yamashita.hideyuki@ntt-tx.co.jp> X-Mailer: git-send-email 2.28.0 In-reply-to: <20201204075109.14694-1-yamashita.hideyuki@ntt-tx.co.jp> References: <20201204075109.14694-1-yamashita.hideyuki@ntt-tx.co.jp> MIME-version: 1.0 Content-transfer-encoding: 8bit X-TM-AS-GCONF: 00 Subject: [dpdk-dev] [PATCH 4/5] docs: add description of apistats parameter into proc-info 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" This patch modifies document of proc-info to introduce "--apistats" parameter. Signed-off-by: Hideyuki Yamashita --- doc/guides/tools/proc_info.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst index 9772d97..4c7b79e 100644 --- a/doc/guides/tools/proc_info.rst +++ b/doc/guides/tools/proc_info.rst @@ -18,8 +18,9 @@ The application has a number of command line options: .. code-block:: console .//app/dpdk-procinfo -- -m | [-p PORTMASK] [--stats | --xstats | - --stats-reset | --xstats-reset] [ --show-port | --show-tm | --show-crypto | - --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name ] + --stats-reset | --xstats-reset | --apistats ] [ --show-port | --show-tm | + --show-crypto | --show-ring[=name] | --show-mempool[=name] | + --iter-mempool=name ] Parameters ~~~~~~~~~~ @@ -41,6 +42,11 @@ no port mask is specified, the generic stats are reset for all DPDK ports. The xstats-reset parameter controls the resetting of extended port statistics. If no port mask is specified xstats are reset for all DPDK ports. +**--apistats** +The apistats parameter controls rx_burst/tx_burst API invocation counter +statistics per core. If no port mask is specified apistats are printed for all +DPDK ports. + **-m**: Print DPDK memory information. **--show-port** From patchwork Fri Dec 4 07:51:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hideyuki Yamashita X-Patchwork-Id: 84753 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 52818A04B0; Fri, 4 Dec 2020 08:53:22 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8B508C9E7; Fri, 4 Dec 2020 08:52:07 +0100 (CET) Received: from dish-sg.nttdocomo.co.jp (dish-sg.nttdocomo.co.jp [202.19.227.74]) by dpdk.org (Postfix) with ESMTP id A5ED9C9E2 for ; Fri, 4 Dec 2020 08:52:06 +0100 (CET) X-dD-Source: Outbound Received: from zssg-mailmd106.ddreams.local (zssg-mailmd900.ddreams.local [10.160.172.63]) by zssg-mailou103.ddreams.local (Postfix) with ESMTP id E79F61200F3; Fri, 4 Dec 2020 16:52:04 +0900 (JST) Received: from zssg-mailmf101.ddreams.local (zssg-mailmf900.ddreams.local [10.160.172.84]) by zssg-mailmd106.ddreams.local (dDREAMS) with ESMTP id <0QKT00QHZ1USL140@dDREAMS>; Fri, 04 Dec 2020 16:52:04 +0900 (JST) Received: from zssg-mailmf101.ddreams.local (unknown [127.0.0.1]) by zssg-mailmf101.ddreams.local (Postfix) with ESMTP id C325D7E6036; Fri, 4 Dec 2020 16:52:04 +0900 (JST) Received: from zssg-mailmf101.ddreams.local (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C14F18E605C; Fri, 4 Dec 2020 16:52:04 +0900 (JST) Received: from localhost (unknown [127.0.0.1]) by IMSVA (Postfix) with SMTP id B5EB68E605A; Fri, 4 Dec 2020 16:52:04 +0900 (JST) X-IMSS-HAND-OFF-DIRECTIVE: localhost:10026 Received: from zssg-mailmf101.ddreams.local (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7391A8E6054; Fri, 4 Dec 2020 16:52:04 +0900 (JST) Received: from davinci.ntt-tx.co.jp (unknown [10.160.183.139]) by zssg-mailmf101.ddreams.local (Postfix) with ESMTP; Fri, 4 Dec 2020 16:52:04 +0900 (JST) From: Hideyuki Yamashita To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Ray Kinsella , Neil Horman , Anatoly Burakov Cc: dev@dpdk.org, Hideyuki Yamashita , Hideyuki Yamashita Date: Fri, 04 Dec 2020 16:51:09 +0900 Message-id: <20201204075109.14694-6-yamashita.hideyuki@ntt-tx.co.jp> X-Mailer: git-send-email 2.28.0 In-reply-to: <20201204075109.14694-1-yamashita.hideyuki@ntt-tx.co.jp> References: <20201204075109.14694-1-yamashita.hideyuki@ntt-tx.co.jp> MIME-version: 1.0 Content-transfer-encoding: 8bit X-TM-AS-GCONF: 00 Subject: [dpdk-dev] [PATCH 5/5] librte_ethdev: add to use apistats 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" This patch modifies to use apistats by librte_ethdev. Signed-off-by: Hideyuki Yamashita --- lib/librte_ethdev/meson.build | 6 ++- lib/librte_ethdev/rte_apistats.c | 64 ++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_apistats.h | 64 ++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 7 ++++ lib/librte_ethdev/version.map | 5 +++ 5 files changed, 144 insertions(+), 2 deletions(-) create mode 100644 lib/librte_ethdev/rte_apistats.c create mode 100644 lib/librte_ethdev/rte_apistats.h diff --git a/lib/librte_ethdev/meson.build b/lib/librte_ethdev/meson.build index e4b6102..d03e784 100644 --- a/lib/librte_ethdev/meson.build +++ b/lib/librte_ethdev/meson.build @@ -8,7 +8,8 @@ sources = files('ethdev_private.c', 'rte_ethdev.c', 'rte_flow.c', 'rte_mtr.c', - 'rte_tm.c') + 'rte_tm.c' , + 'rte_apistats.c') headers = files('rte_ethdev.h', 'rte_ethdev_driver.h', @@ -24,6 +25,7 @@ headers = files('rte_ethdev.h', 'rte_mtr.h', 'rte_mtr_driver.h', 'rte_tm.h', - 'rte_tm_driver.h') + 'rte_tm_driver.h', + 'rte_apistats.h') deps += ['net', 'kvargs', 'meter', 'telemetry'] diff --git a/lib/librte_ethdev/rte_apistats.c b/lib/librte_ethdev/rte_apistats.c new file mode 100644 index 0000000..c4bde34 --- /dev/null +++ b/lib/librte_ethdev/rte_apistats.c @@ -0,0 +1,64 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019 NTT TechnoCross Corporation + */ + + +#include +#include +#include +#include +#include +#include + +#include "rte_apistats.h" + +/* Macros for printing using RTE_LOG */ +#define RTE_LOGTYPE_APISTATS RTE_LOGTYPE_USER1 + +#define MZ_APISTATS "rte_apistats" + +struct rte_apistats *rte_apicounts; + +int rte_apistats_init(void) +{ + int i; + const struct rte_memzone *mz = NULL; + const unsigned int flags = 0; + + /** Allocate stats in shared memory fo multi process support */ + if (rte_eal_process_type() == RTE_PROC_SECONDARY) { + mz = rte_memzone_lookup(MZ_APISTATS); + if (mz == NULL) { + RTE_LOG(ERR, APISTATS, "Cannot get info structure\n"); + return -1; + } + rte_apicounts = mz->addr; + } else { + /* RTE_PROC_PRIMARY */ + mz = rte_memzone_reserve(MZ_APISTATS, sizeof(*rte_apicounts), + rte_socket_id(), flags); + if (mz == NULL) { + RTE_LOG(ERR, APISTATS, "Cannot reserve memory zone\n"); + return -ENOMEM; + } + rte_apicounts = mz->addr; + memset(rte_apicounts, 0, sizeof(*rte_apicounts)); + } + + /* set up array for data */ + RTE_LCORE_FOREACH(i) { + rte_apicounts->lcoreid_list[i] = 1; + RTE_LOG(INFO, APISTATS, "Enable core usage for lcore %u\n", i); + } + return 0; +} + +int rte_apistats_uninit(void) +{ + const struct rte_memzone *mz = NULL; + /* free up the memzone */ + mz = rte_memzone_lookup(MZ_APISTATS); + if (mz) + rte_memzone_free(mz); + return 0; +} diff --git a/lib/librte_ethdev/rte_apistats.h b/lib/librte_ethdev/rte_apistats.h new file mode 100644 index 0000000..afea50e --- /dev/null +++ b/lib/librte_ethdev/rte_apistats.h @@ -0,0 +1,64 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019 NTT TechnoCross Corporation + */ + +#ifndef _RTE_APISTATS_H_ +#define _RTE_APISTATS_H_ + +/** + * @file + * RTE apistats + * + * library to provide rte_rx_burst/tx_burst api stats. + */ + + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/** + * A structure for rte_rx_burst/tx_burst api statistics. + */ +struct rte_apistats { + int lcoreid_list[RTE_MAX_LCORE]; /**< In use lcoreid list */ + /**< Total rte_rx_burst call counts */ + uint64_t rx_burst_counts[RTE_MAX_LCORE]; + + /**< Total rte_tx_burst call counts */ + uint64_t tx_burst_counts[RTE_MAX_LCORE]; +}; + +extern struct rte_apistats *rte_apicounts; + +/** + * Initialize rte_rx_burst/tx_burst call count area. + * @b EXPERIMENTAL: this API may change without prior notice. + * + * @return + * -1 : On error + * -ENOMEM: On error + * 0 : On success + */ +__rte_experimental +int rte_apistats_init(void); + +/** + * Clean up and free memory. + * @b EXPERIMENTAL: this API may change without prior notice. + * + * @return + * -1: On error + * 0: On success + */ +__rte_experimental +int rte_apistats_uninit(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_APISTATS_H_ */ diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index f5f8919..bef9bc6 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -160,6 +160,7 @@ extern "C" { #include "rte_ethdev_trace_fp.h" #include "rte_dev_info.h" +#include extern int rte_eth_dev_logtype; @@ -4849,6 +4850,9 @@ rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id, nb_rx = (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id], rx_pkts, nb_pkts); + int lcore_id = rte_lcore_id(); + rte_apicounts->rx_burst_counts[lcore_id]++; + #ifdef RTE_ETHDEV_RXTX_CALLBACKS struct rte_eth_rxtx_callback *cb; @@ -5124,6 +5128,9 @@ rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id, } #endif + int lcore_id = rte_lcore_id(); + rte_apicounts->tx_burst_counts[lcore_id]++; + #ifdef RTE_ETHDEV_RXTX_CALLBACKS struct rte_eth_rxtx_callback *cb; diff --git a/lib/librte_ethdev/version.map b/lib/librte_ethdev/version.map index d3f5410..adea432 100644 --- a/lib/librte_ethdev/version.map +++ b/lib/librte_ethdev/version.map @@ -240,6 +240,11 @@ EXPERIMENTAL { rte_flow_get_restore_info; rte_flow_tunnel_action_decap_release; rte_flow_tunnel_item_release; + + # added in 21.02 + rte_apistats_init; + rte_apistats_uninit; + rte_apicounts; }; INTERNAL {