From patchwork Mon May 11 11:08:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wisam Jaddo X-Patchwork-Id: 70071 X-Patchwork-Delegate: thomas@monjalon.net 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 92AF3A00C5; Mon, 11 May 2020 13:08:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A83271C1E5; Mon, 11 May 2020 13:08:38 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2064.outbound.protection.outlook.com [40.107.21.64]) by dpdk.org (Postfix) with ESMTP id 38BA41C1C6 for ; Mon, 11 May 2020 13:08:37 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SKLNivylODnBrTl7Z3HxdY9F0+WZqFvfy6BOYYnhP4rrVVr1D7sP6yusHLKRT+boPHH3jneFleyClLgPqqFKFS0rzp0UUGHzJeVwsyC5KOgs4c93924CfH0cXFtIoLt7sx6uomBeNHbZqGMxlTVMfbpYxp1G/ERQFiafwJaZHrI/wBOPwjHC/K3RwW1F4AZo6WHbt3iOkZSAcQ6nCKKpXQz+yGpavYgjCzjEIvWDgYQTknIy5vYj0jhGr7ZL9vbtqarZFyFwzdH+rPWdgGxLueHRnXhFcarhaDMXnnoGkleMnFo11boc9fZMDLvgg9mgi948lmuaPfT/7E77tulGtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iv3zPGgWA+dl+K5sQ5TI+AMO78Lau1mH+Gldt4iNTec=; b=Y3OKjqaR3htUBuD2v4d9NmNYxbsaiW+XAHpj7oR5r2mf4Us+AWpk9hhZU/egnGjAy+RvHa7EEsXtzLdd2/F23ixsuQBH1mVlwrZ6rVhvr7mgjD0B71escDkix82LsFcLmXnj144S5zhV/isZCzdr0S36P9IYUFj5wlAlo4sROTLZuGYbtetYZdLrp1cUJ6SkQvRJbEJQbb3Bnd5XBB5hdUE4MhAjCVuR8M+0EcHbpw85GNSnLMbHeaPbc6nYD5fmN7WpljpjqXnVKktj1nEAb5Kp+Y7qnX3GwB++a5wICKzW36p404sweVRrVstHDsuvLGeHXE4rJ9u3i7q5nXQynA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iv3zPGgWA+dl+K5sQ5TI+AMO78Lau1mH+Gldt4iNTec=; b=gWt+UOBh3jvoxNMsn2OMM1s6K0VwF7EsZKdVn3VellirIeIc7XbP039cSpbGFYonxFcO7+U+G6OnPw8ryYUjY+qZYcU9OsMFRWv4K49MkNf5/KkEOO6Z/xRpM3HXhjji9vJsOL5wTv1QeU27e8WeqvNDVAdPDRBfT3hAqWQmQh0= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=mellanox.com; Received: from AM0PR05MB6610.eurprd05.prod.outlook.com (2603:10a6:208:12f::18) by AM0PR05MB5891.eurprd05.prod.outlook.com (2603:10a6:208:133::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.33; Mon, 11 May 2020 11:08:35 +0000 Received: from AM0PR05MB6610.eurprd05.prod.outlook.com ([fe80::900:c0ac:78bd:18fc]) by AM0PR05MB6610.eurprd05.prod.outlook.com ([fe80::900:c0ac:78bd:18fc%6]) with mapi id 15.20.2958.035; Mon, 11 May 2020 11:08:35 +0000 From: Wisam Jaddo To: dev@dpdk.org, jackmin@mellanox.com, thomas@monjalon.net, jerinjacobk@gmail.com, ajit.khaparde@broadcom.com, arybchenko@solarflare.com Date: Mon, 11 May 2020 11:08:07 +0000 Message-Id: <20200511110811.11474-2-wisamm@mellanox.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200511110811.11474-1-wisamm@mellanox.com> References: <20200506123627.22340-2-wisamm@mellanox.com> <20200511110811.11474-1-wisamm@mellanox.com> X-ClientProxiedBy: PR0P264CA0122.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1a::14) To AM0PR05MB6610.eurprd05.prod.outlook.com (2603:10a6:208:12f::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mellanox.com (37.142.13.130) by PR0P264CA0122.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27 via Frontend Transport; Mon, 11 May 2020 11:08:34 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [37.142.13.130] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c22e54c7-b143-4a77-bd00-08d7f59ba627 X-MS-TrafficTypeDiagnostic: AM0PR05MB5891:|AM0PR05MB5891: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:270; X-Forefront-PRVS: 04004D94E2 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xT2JUo1UwSe57Rh54ZQaumUuI9b3F6rLTusLqrgNLaBbVoexJzDOh6PST28cN46TzdDu4FdE+b+75CYOuQwdMN87yOx8gBvNB6mSpHCT73qbJSRwFM0F8eSRuaipJQ6BlyZ/TdMqFOlXEfy5xYJe8nchkowWqJfQ19hn8LWpQQSA9e5ZVYtqTr8iBNed2RmLp8UpRLDl/LuNQli9eVyVRcqoOUgWeQRmhYZtRUsx/okrWIXaLWR2bLXFtvcuOi+0k7VtaO8BkvqkSEnc6zaEVdA1+wkDQ4jAH5JTmzqiZSE2quof4l09qx05wtlZSyKXTcQLLiC+STA3DFu5HsUqQVXo+OgmipxY6sOekVUMpCwvDnXtjntxBwVKmDUe0MrH7EijRbu4gX/pbzsODQCuk4znY3z3I3+jw7uW/OlTfF+HibhAkq90tcdX5CkfVRMH0kowMI1kZfRpzwuTxH4W4fEzMh39hjakughw6rzLDtpFcqEn9U+Qhk2mkahbbE1nA6Vq5xQwK4+8zTuTBrDanw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR05MB6610.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(376002)(136003)(39860400002)(396003)(366004)(346002)(33430700001)(66556008)(36756003)(30864003)(478600001)(5660300002)(1076003)(33440700001)(316002)(6666004)(8886007)(2906002)(8936002)(55016002)(86362001)(66476007)(8676002)(66946007)(52116002)(26005)(2616005)(956004)(16526019)(186003)(7696005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 5bDZCDNyOIrPQx022HMdgfqthJGmdTXqqOT4BG1j5xQQ1u5Fq9Ztgcg8fN/je7fD28QK2p61kHwVbfbTnxb4rOWIvBIekmnNnXLSry1TEmG7U5uGgtGrjHt8Fyw3yzZ+YFlajcg69aVOHAXRqJ4HNqYJECKAR5C9XZVpIg0FicjUfIPZsp55zQkgpTnsto5/JtsWRmmhkZAQouZmNdTMx0l2ttm/JPiQWoRSmuhsYDxWUMmA8XucPQk9U/pLGqPb/r3nTsrDizCUvdmAmUFU/nvXNS+B+0uHPHSrh/7HcfiniyUgWqXU3a6bsrG57x5x/8c7hrTeHahShiavK0NFAHXHHCTwFZeIPjkWdIjMmrmoQ2ll8wiTmXss8Pe1sInz2du5E2CsaNJ35D1hozMYeVFB9N3KZeNpPcrW4mv165H2fdEzXt3OXRXnioAvMxjmxgGUSpXDO8j8iy4a7Wxqa7NwEFdwioLUqB4kkrNKId8= X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: c22e54c7-b143-4a77-bd00-08d7f59ba627 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2020 11:08:35.6860 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HX60T+hthYsETFw506DKY6tg0yh5U2x3jAZGIzAutWjkY39a2QvyJiYBHToF7RrHiNgJmWH08m9WXkSdKmhlzA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB5891 Subject: [dpdk-dev] [PATCH v6 1/5] app/flow-perf: add flow performance skeleton 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" Add flow performance application skeleton. Signed-off-by: Wisam Jaddo --- MAINTAINERS | 5 + app/Makefile | 1 + app/meson.build | 1 + app/test-flow-perf/Makefile | 23 +++ app/test-flow-perf/config.h | 14 ++ app/test-flow-perf/main.c | 194 +++++++++++++++++++++++++ app/test-flow-perf/meson.build | 8 + config/common_base | 5 + doc/guides/rel_notes/release_20_05.rst | 4 + doc/guides/tools/flow-perf.rst | 44 ++++++ doc/guides/tools/index.rst | 1 + 11 files changed, 300 insertions(+) create mode 100644 app/test-flow-perf/Makefile create mode 100644 app/test-flow-perf/config.h create mode 100644 app/test-flow-perf/main.c create mode 100644 app/test-flow-perf/meson.build create mode 100644 doc/guides/tools/flow-perf.rst diff --git a/MAINTAINERS b/MAINTAINERS index e05c80504..7d678e15d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1506,6 +1506,11 @@ T: git://dpdk.org/next/dpdk-next-net F: app/test-pmd/ F: doc/guides/testpmd_app_ug/ +Flow performance tool +M: Wisam Jaddo +F: app/test-flow-perf +F: doc/guides/flow-perf.rst + Compression performance test application T: git://dpdk.org/next/dpdk-next-crypto F: app/test-compress-perf/ diff --git a/app/Makefile b/app/Makefile index 823771c5f..0392a7de0 100644 --- a/app/Makefile +++ b/app/Makefile @@ -10,6 +10,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_PDUMP) += pdump DIRS-$(CONFIG_RTE_LIBRTE_ACL) += test-acl DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test-cmdline DIRS-$(CONFIG_RTE_LIBRTE_FIB) += test-fib +DIRS-$(CONFIG_RTE_TEST_FLOW_PERF) += test-flow-perf DIRS-$(CONFIG_RTE_LIBRTE_PIPELINE) += test-pipeline DIRS-$(CONFIG_RTE_LIBRTE_IPSEC) += test-sad diff --git a/app/meson.build b/app/meson.build index 0f7fe9464..408676b06 100644 --- a/app/meson.build +++ b/app/meson.build @@ -15,6 +15,7 @@ apps = [ 'test-crypto-perf', 'test-eventdev', 'test-fib', + 'test-flow-perf', 'test-pipeline', 'test-pmd', 'test-sad'] diff --git a/app/test-flow-perf/Makefile b/app/test-flow-perf/Makefile new file mode 100644 index 000000000..db043c17a --- /dev/null +++ b/app/test-flow-perf/Makefile @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2020 Mellanox Technologies, Ltd + +include $(RTE_SDK)/mk/rte.vars.mk + +ifeq ($(CONFIG_RTE_TEST_FLOW_PERF),y) + +# +# library name +# +APP = dpdk-test-flow-perf + +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) + +# +# all source are stored in SRCS-y +# +SRCS-y += main.c + +include $(RTE_SDK)/mk/rte.app.mk + +endif diff --git a/app/test-flow-perf/config.h b/app/test-flow-perf/config.h new file mode 100644 index 000000000..cf41e0345 --- /dev/null +++ b/app/test-flow-perf/config.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: BSD-3-Claus + * Copyright 2020 Mellanox Technologies, Ltd + */ + +#define GET_RSS_HF() (ETH_RSS_IP | ETH_RSS_TCP) + +/* Configuration */ +#define RXQ_NUM 4 +#define TXQ_NUM 4 +#define TOTAL_MBUF_NUM 32000 +#define MBUF_SIZE 2048 +#define MBUF_CACHE_SIZE 512 +#define NR_RXD 256 +#define NR_TXD 256 diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c new file mode 100644 index 000000000..8659870af --- /dev/null +++ b/app/test-flow-perf/main.c @@ -0,0 +1,194 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2020 Mellanox Technologies, Ltd + * + * This file contain the application main file + * This application provides the user the ability to test the + * insertion rate for specific rte_flow rule under stress state ~4M rule/ + * + * Then it will also provide packet per second measurement after installing + * all rules, the user may send traffic to test the PPS that match the rules + * after all rules are installed, to check performance or functionality after + * the stress. + * + * The flows insertion will go for all ports first, then it will print the + * results, after that the application will go into forwarding packets mode + * it will start receiving traffic if any and then forwarding it back and + * gives packet per second measurement. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "config.h" + +static uint32_t nb_lcores; +static struct rte_mempool *mbuf_mp; + +static void +usage(char *progname) +{ + printf("\nusage: %s\n", progname); +} + +static void +args_parse(int argc, char **argv) +{ + char **argvopt; + int opt; + int opt_idx; + static struct option lgopts[] = { + /* Control */ + { "help", 0, 0, 0 }, + }; + + argvopt = argv; + + while ((opt = getopt_long(argc, argvopt, "", + lgopts, &opt_idx)) != EOF) { + switch (opt) { + case 0: + if (strcmp(lgopts[opt_idx].name, "help") == 0) { + usage(argv[0]); + rte_exit(EXIT_SUCCESS, "Displayed help\n"); + } + break; + default: + fprintf(stderr, "Invalid option: %s\n", argv[optind]); + usage(argv[0]); + rte_exit(EXIT_SUCCESS, "Invalid option\n"); + break; + } + } +} + +static void +init_port(void) +{ + int ret; + uint16_t std_queue; + uint16_t port_id; + uint16_t nr_ports; + struct rte_eth_conf port_conf = { + .rx_adv_conf = { + .rss_conf.rss_hf = + GET_RSS_HF(), + } + }; + struct rte_eth_txconf txq_conf; + struct rte_eth_rxconf rxq_conf; + struct rte_eth_dev_info dev_info; + + nr_ports = rte_eth_dev_count_avail(); + if (nr_ports == 0) + rte_exit(EXIT_FAILURE, "Error: no port detected\n"); + + mbuf_mp = rte_pktmbuf_pool_create("mbuf_pool", + TOTAL_MBUF_NUM, MBUF_CACHE_SIZE, + 0, MBUF_SIZE, + rte_socket_id()); + if (mbuf_mp == NULL) + rte_exit(EXIT_FAILURE, "Error: can't init mbuf pool\n"); + + for (port_id = 0; port_id < nr_ports; port_id++) { + ret = rte_eth_dev_info_get(port_id, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device" + " (port %u) info: %s\n", + port_id, strerror(-ret)); + + port_conf.txmode.offloads &= dev_info.tx_offload_capa; + port_conf.rxmode.offloads &= dev_info.rx_offload_capa; + + printf(":: initializing port: %d\n", port_id); + + ret = rte_eth_dev_configure(port_id, RXQ_NUM, + TXQ_NUM, &port_conf); + if (ret < 0) + rte_exit(EXIT_FAILURE, + ":: cannot configure device: err=%d, port=%u\n", + ret, port_id); + + rxq_conf = dev_info.default_rxconf; + for (std_queue = 0; std_queue < RXQ_NUM; std_queue++) { + ret = rte_eth_rx_queue_setup(port_id, std_queue, NR_RXD, + rte_eth_dev_socket_id(port_id), + &rxq_conf, + mbuf_mp); + if (ret < 0) + rte_exit(EXIT_FAILURE, + ":: Rx queue setup failed: err=%d, port=%u\n", + ret, port_id); + } + + txq_conf = dev_info.default_txconf; + for (std_queue = 0; std_queue < TXQ_NUM; std_queue++) { + ret = rte_eth_tx_queue_setup(port_id, std_queue, NR_TXD, + rte_eth_dev_socket_id(port_id), + &txq_conf); + if (ret < 0) + rte_exit(EXIT_FAILURE, + ":: Tx queue setup failed: err=%d, port=%u\n", + ret, port_id); + } + + /* Catch all packets from traffic generator. */ + ret = rte_eth_promiscuous_enable(port_id); + if (ret != 0) + rte_exit(EXIT_FAILURE, + ":: promiscuous mode enable failed: err=%s, port=%u\n", + rte_strerror(-ret), port_id); + + ret = rte_eth_dev_start(port_id); + if (ret < 0) + rte_exit(EXIT_FAILURE, + "rte_eth_dev_start:err=%d, port=%u\n", + ret, port_id); + + printf(":: initializing port: %d done\n", port_id); + } +} + +int +main(int argc, char **argv) +{ + int ret; + uint16_t port; + struct rte_flow_error error; + + ret = rte_eal_init(argc, argv); + if (ret < 0) + rte_exit(EXIT_FAILURE, "EAL init failed\n"); + + argc -= ret; + argv += ret; + if (argc > 1) + args_parse(argc, argv); + + init_port(); + + nb_lcores = rte_lcore_count(); + if (nb_lcores <= 1) + rte_exit(EXIT_FAILURE, "This app needs at least two cores\n"); + + RTE_ETH_FOREACH_DEV(port) { + rte_flow_flush(port, &error); + rte_eth_dev_stop(port); + rte_eth_dev_close(port); + } + return 0; +} diff --git a/app/test-flow-perf/meson.build b/app/test-flow-perf/meson.build new file mode 100644 index 000000000..25711378f --- /dev/null +++ b/app/test-flow-perf/meson.build @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2020 Mellanox Technologies, Ltd + +sources = files( + 'main.c', +) + +deps += ['ethdev'] diff --git a/config/common_base b/config/common_base index 14000ba07..b2edd5267 100644 --- a/config/common_base +++ b/config/common_base @@ -1105,6 +1105,11 @@ CONFIG_RTE_TEST_PMD=y CONFIG_RTE_TEST_PMD_RECORD_CORE_CYCLES=n CONFIG_RTE_TEST_PMD_RECORD_BURST_STATS=n +# +# Compile the rte flow perf application +# +CONFIG_RTE_TEST_FLOW_PERF=y + # # Compile the bbdev test application # diff --git a/doc/guides/rel_notes/release_20_05.rst b/doc/guides/rel_notes/release_20_05.rst index b124c3f28..7abcae3aa 100644 --- a/doc/guides/rel_notes/release_20_05.rst +++ b/doc/guides/rel_notes/release_20_05.rst @@ -212,6 +212,10 @@ New Features * Added IPsec inbound load-distribution support for ipsec-secgw application using NIC load distribution feature(Flow Director). +* **Added flow performance application.** + + Add new application to test rte_flow performance. + Removed Items ------------- diff --git a/doc/guides/tools/flow-perf.rst b/doc/guides/tools/flow-perf.rst new file mode 100644 index 000000000..49eb450ae --- /dev/null +++ b/doc/guides/tools/flow-perf.rst @@ -0,0 +1,44 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright 2020 Mellanox Technologies, Ltd + +Flow performance tool +===================== + +Application for rte_flow performance testing. + + +Compiling the Application +========================= + +The ``test-flow-perf`` application is compiled as part of the main compilation +of the DPDK libraries and tools. + +Refer to the DPDK Getting Started Guides for details. + + +Running the Application +======================= + +EAL Command-line Options +------------------------ + +Please refer to :doc:`EAL parameters (Linux) <../linux_gsg/linux_eal_parameters>` +or :doc:`EAL parameters (FreeBSD) <../freebsd_gsg/freebsd_eal_parameters>` for +a list of available EAL command-line options. + + +Flow performance Options +------------------------ + +The following are the command-line options for the flow performance application. +They must be separated from the EAL options, shown in the previous section, +with a ``--`` separator: + +.. code-block:: console + + sudo ./dpdk-test-flow-perf -n 4 -w 08:00.0 -- + +The command line options are: + +* ``--help`` + Display a help message and quit. diff --git a/doc/guides/tools/index.rst b/doc/guides/tools/index.rst index 782b30864..7279daebc 100644 --- a/doc/guides/tools/index.rst +++ b/doc/guides/tools/index.rst @@ -16,3 +16,4 @@ DPDK Tools User Guides cryptoperf comp_perf testeventdev + flow-perf From patchwork Mon May 11 11:08:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wisam Jaddo X-Patchwork-Id: 70072 X-Patchwork-Delegate: thomas@monjalon.net 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 C5C9EA00C5; Mon, 11 May 2020 13:08:54 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E47F81C209; Mon, 11 May 2020 13:08:41 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2071.outbound.protection.outlook.com [40.107.21.71]) by dpdk.org (Postfix) with ESMTP id B007F1C202 for ; Mon, 11 May 2020 13:08:39 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CgnKLeQM55elqutGLZyxmelYwYCEsofinpOu5qBebZbWxIt/iFVHdQF6xpJwpkgMDp4Wh94NZRL3mLlgObLwBAiPyAANugoXrBn0beQoxCNsdENpNuWRXehZ5uNZevPsXvztpwE6ThHpFsLopHO5kln9nzpBqspZMjXjQ7Dlg4KoqLAaCeU42QL/A/SGQ2MB1xxerGIaC9PZwlfnb/7Lp/r8zt08YtCSsopSx4/7PW3PLNbFYqoTsEP6VTVskqxTHfjBK8YxRaxM8VlTJ2BPwoM1Nyl7YIrPpv9JfkvoJUrgyJNnHrJTATf5J2QTFiuJjHNIQVRqyC8tm1npAw0Jxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5apt3/xBUrN0FGj0zxA9eSbmnDwgeJG4zS5JjjMSdm4=; b=Dq8JLcSULx+BELaX0WX/TwEzgXdKA4N/pNaB0ikkvMCjL97cHC49USf1BxcfhV1aCm61BZnZXQ9dNBWG7O7kttjTNjsQm2poe3MYPdgW9IlnnNZRABM8UXXjDhYtmfgI8QQJveq7Us/iEnRbr8sjB6ForHhc900EBvg8e5xJWz78B5vZW3VDT3GT8MjqFwsFYkBA6fpJ3T9+IU1ErUY5eaLpVMfkcFs+7HKc5ISUAvTdux53kogvYPcWcMy/Y4xCg7/pfWhwbdFSOh+SEUIeXAt+ot4Rjw9S+cG3fKyjAg28ejZW7Ro1qn9DPI7R3FJaZiBIUiWrLPBi8/CCJ+Ge6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5apt3/xBUrN0FGj0zxA9eSbmnDwgeJG4zS5JjjMSdm4=; b=UUku8shhGn7755tTGPy++h6qnVA8c/N71yb+9U667GlqN6692p1JUl73AEfvEESoHG0G8ixQNEaojfpE8M2gRy/Gki8PbaJgTnAM9hPYcndEm3tYnbMx8ei51meG7kDnODyTl3VpQC4uc91Lf8yOONo1ENRaWOjNbp/l/w4/NV4= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=mellanox.com; Received: from AM0PR05MB6610.eurprd05.prod.outlook.com (2603:10a6:208:12f::18) by AM0PR05MB6803.eurprd05.prod.outlook.com (2603:10a6:20b:145::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.29; Mon, 11 May 2020 11:08:37 +0000 Received: from AM0PR05MB6610.eurprd05.prod.outlook.com ([fe80::900:c0ac:78bd:18fc]) by AM0PR05MB6610.eurprd05.prod.outlook.com ([fe80::900:c0ac:78bd:18fc%6]) with mapi id 15.20.2958.035; Mon, 11 May 2020 11:08:37 +0000 From: Wisam Jaddo To: dev@dpdk.org, jackmin@mellanox.com, thomas@monjalon.net, jerinjacobk@gmail.com, ajit.khaparde@broadcom.com, arybchenko@solarflare.com Date: Mon, 11 May 2020 11:08:08 +0000 Message-Id: <20200511110811.11474-3-wisamm@mellanox.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200511110811.11474-1-wisamm@mellanox.com> References: <20200506123627.22340-2-wisamm@mellanox.com> <20200511110811.11474-1-wisamm@mellanox.com> X-ClientProxiedBy: PR0P264CA0122.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1a::14) To AM0PR05MB6610.eurprd05.prod.outlook.com (2603:10a6:208:12f::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mellanox.com (37.142.13.130) by PR0P264CA0122.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27 via Frontend Transport; Mon, 11 May 2020 11:08:36 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [37.142.13.130] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f28b3562-122c-4dac-0f2d-08d7f59ba723 X-MS-TrafficTypeDiagnostic: AM0PR05MB6803:|AM0PR05MB6803: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2582; X-Forefront-PRVS: 04004D94E2 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ItNkQog4wg2GVHT1aM/YCByodyzKYJAJS3WOwsqtebt55cxPVEjyXwb+HhF1KrO4idSd0I2P3ioAc5j0VftKSfup+VPX8Z/T3aipq9nSbqYtkCNyieww7zr0hoRNBBK0P0x6kd2Y0n1SmZwItkuVCCdUSmDjGAdtdtBFoalw/CQd9kEoNXufAFZmwkKkh+9WCLxOMTpCGW8A8S5ggOF/gMHxeaqH6rrCJK0A6Cno79LNGmUHUlPKHHx3jUaCjcYofrJlY1/HPbSw0KepMLymGYecQItaASQBXeBPb267M7d7DKN8xJS8DJNmmqPD3BjlhS80O0hGCoObH+ydWSkjRtIrQ8XzcQ1OCBRVO62Kwk80OwjkJCDAkroyfxySzx6abVxth/AYqcRoajnPAnPAIWUW5DAvGyaaStfpmH9Uk47Daetg4OAmVnFwY97L8+Sh9OYgKGMQZYUZzVWPsitD57zc0ybSPMjA9K1XFp7aLyR+YIO6h3BaUWCvAa87XdV3jGqg6pLsqIrbagiVpRWr+g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR05MB6610.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(376002)(39860400002)(136003)(396003)(346002)(366004)(33430700001)(316002)(1076003)(36756003)(30864003)(5660300002)(66946007)(52116002)(7696005)(86362001)(186003)(956004)(66556008)(8676002)(66476007)(2906002)(33440700001)(16526019)(2616005)(478600001)(6666004)(26005)(8886007)(8936002)(55016002)(579004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 7gurCrit+coEun25aueOey8vGESjlwQhKaQrinv3JKw4kQxUJFMRgAPmCGUd4mR6EUfV5aU9dJUtnLou7TS5RHI6RGAs4H5HUVCF4anJ7EZrWxHHqlXXcO/pdonLZCP1ov/q6g8+SGcbQpbJkZR9QNubPHGB47t1ciytBBNr+zUiSQxvxO3ZjtN7K1ceWjGTEJzHR7ZcJLSclpDzEUBSnmlgZxhG5ShghJqwuNOi7huehoWfgQUnATRRwHVoAthQfp3ZQVo61hH21Fyl7eq2BID6MP9TN/jRe42zCHiXP/7yCMXLQDcs0S07GeYHi5bNSM5zRWRhFhDr0Ho8gnVQQTBvGyrFOyGmEZBFkPp+Q0oOrKEJlQdeSOFPMSg3Y+t65gN3k1yW8KGVoLCORyr4f3ECQc6AeW67cLhJ2fk0CAKsse44q3KMS1ISAJnLIFV/F6LpNdwUQkUHpUDa0DT428KNNMrw24eZD6hRNwRI0/Y= X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: f28b3562-122c-4dac-0f2d-08d7f59ba723 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2020 11:08:37.3770 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: S7PLs0F4XAVP1eBwATpswkrD6+CSWKluS5Mxb8nfg7NubYqfICuZZMzZ/IQBoCGv+Ob2hq2QOhe4u9RfubSVKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB6803 Subject: [dpdk-dev] [PATCH v6 2/5] app/flow-perf: add insertion rate calculation 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" Add insertion rate calculation feature into flow performance application. The application now provide the ability to test insertion rate of specific rte_flow rule, by stressing it to the NIC, and calculate the insertion rate. The application offers some options in the command line, to configure which rule to apply. After that the application will start producing rules with same pattern but increasing the outer IP source address by 1 each time, thus it will give different flow each time, and all other items will have open masks. The current design have single core insertion rate. In the future we may have a multi core insertion rate measurement support in the app. Signed-off-by: Wisam Jaddo --- app/test-flow-perf/Makefile | 3 + app/test-flow-perf/actions_gen.c | 164 +++++++++ app/test-flow-perf/actions_gen.h | 29 ++ app/test-flow-perf/config.h | 16 + app/test-flow-perf/flow_gen.c | 145 ++++++++ app/test-flow-perf/flow_gen.h | 37 ++ app/test-flow-perf/items_gen.c | 277 +++++++++++++++ app/test-flow-perf/items_gen.h | 31 ++ app/test-flow-perf/main.c | 472 ++++++++++++++++++++++++- app/test-flow-perf/meson.build | 3 + doc/guides/rel_notes/release_20_05.rst | 3 + doc/guides/tools/flow-perf.rst | 195 +++++++++- 12 files changed, 1368 insertions(+), 7 deletions(-) create mode 100644 app/test-flow-perf/actions_gen.c create mode 100644 app/test-flow-perf/actions_gen.h create mode 100644 app/test-flow-perf/flow_gen.c create mode 100644 app/test-flow-perf/flow_gen.h create mode 100644 app/test-flow-perf/items_gen.c create mode 100644 app/test-flow-perf/items_gen.h diff --git a/app/test-flow-perf/Makefile b/app/test-flow-perf/Makefile index db043c17a..4f2db7591 100644 --- a/app/test-flow-perf/Makefile +++ b/app/test-flow-perf/Makefile @@ -16,6 +16,9 @@ CFLAGS += $(WERROR_FLAGS) # # all source are stored in SRCS-y # +SRCS-y += actions_gen.c +SRCS-y += flow_gen.c +SRCS-y += items_gen.c SRCS-y += main.c include $(RTE_SDK)/mk/rte.app.mk diff --git a/app/test-flow-perf/actions_gen.c b/app/test-flow-perf/actions_gen.c new file mode 100644 index 000000000..16bb3cf20 --- /dev/null +++ b/app/test-flow-perf/actions_gen.c @@ -0,0 +1,164 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2020 Mellanox Technologies, Ltd + * + * The file contains the implementations of actions generators. + * Each generator is responsible for preparing it's action instance + * and initializing it with needed data. + */ + +#include +#include +#include +#include + +#include "actions_gen.h" +#include "config.h" + +/* Storage for struct rte_flow_action_rss including external data. */ +struct action_rss_data { + struct rte_flow_action_rss conf; + uint8_t key[40]; + uint16_t queue[128]; +}; + +void +add_mark(struct rte_flow_action *actions, + uint8_t actions_counter) +{ + static struct rte_flow_action_mark mark_action; + + do { + mark_action.id = MARK_ID; + } while (0); + + actions[actions_counter].type = RTE_FLOW_ACTION_TYPE_MARK; + actions[actions_counter].conf = &mark_action; +} + +void +add_queue(struct rte_flow_action *actions, + uint8_t actions_counter, uint16_t queue) +{ + static struct rte_flow_action_queue queue_action; + + do { + queue_action.index = queue; + } while (0); + + actions[actions_counter].type = RTE_FLOW_ACTION_TYPE_QUEUE; + actions[actions_counter].conf = &queue_action; +} + +void +add_jump(struct rte_flow_action *actions, + uint8_t actions_counter, uint16_t next_table) +{ + static struct rte_flow_action_jump jump_action; + + do { + jump_action.group = next_table; + } while (0); + + actions[actions_counter].type = RTE_FLOW_ACTION_TYPE_JUMP; + actions[actions_counter].conf = &jump_action; +} + +void +add_rss(struct rte_flow_action *actions, + uint8_t actions_counter, uint16_t *queues, + uint16_t queues_number) +{ + static struct rte_flow_action_rss *rss_action; + static struct action_rss_data *rss_data; + uint16_t queue; + + rss_data = rte_malloc("rss_data", + sizeof(struct action_rss_data), 0); + + if (rss_data == NULL) + rte_exit(EXIT_FAILURE, "No Memory available!"); + + *rss_data = (struct action_rss_data){ + .conf = (struct rte_flow_action_rss){ + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, + .types = GET_RSS_HF(), + .key_len = sizeof(rss_data->key), + .queue_num = queues_number, + .key = rss_data->key, + .queue = rss_data->queue, + }, + .key = { 1 }, + .queue = { 0 }, + }; + + for (queue = 0; queue < queues_number; queue++) + rss_data->queue[queue] = queues[queue]; + + rss_action = &rss_data->conf; + + actions[actions_counter].type = RTE_FLOW_ACTION_TYPE_RSS; + actions[actions_counter++].conf = rss_action; +} + +void +add_set_meta(struct rte_flow_action *actions, + uint8_t actions_counter) +{ + static struct rte_flow_action_set_meta meta_action; + + do { + meta_action.data = RTE_BE32(META_DATA); + meta_action.mask = RTE_BE32(0xffffffff); + } while (0); + + actions[actions_counter].type = RTE_FLOW_ACTION_TYPE_SET_META; + actions[actions_counter++].conf = &meta_action; +} + +void +add_set_tag(struct rte_flow_action *actions, + uint8_t actions_counter) +{ + static struct rte_flow_action_set_tag tag_action; + + do { + tag_action.data = RTE_BE32(META_DATA); + tag_action.mask = RTE_BE32(0xffffffff); + tag_action.index = TAG_INDEX; + } while (0); + + actions[actions_counter].type = RTE_FLOW_ACTION_TYPE_SET_TAG; + actions[actions_counter++].conf = &tag_action; +} + +void +add_port_id(struct rte_flow_action *actions, + uint8_t actions_counter) +{ + static struct rte_flow_action_port_id port_id; + + do { + port_id.id = PORT_ID_DST; + } while (0); + + actions[actions_counter].type = RTE_FLOW_ACTION_TYPE_PORT_ID; + actions[actions_counter++].conf = &port_id; +} + +void +add_drop(struct rte_flow_action *actions, + uint8_t actions_counter) +{ + actions[actions_counter++].type = RTE_FLOW_ACTION_TYPE_DROP; +} + +void +add_count(struct rte_flow_action *actions, + uint8_t actions_counter) +{ + static struct rte_flow_action_count count_action; + + actions[actions_counter].type = RTE_FLOW_ACTION_TYPE_COUNT; + actions[actions_counter++].conf = &count_action; +} diff --git a/app/test-flow-perf/actions_gen.h b/app/test-flow-perf/actions_gen.h new file mode 100644 index 000000000..bc7d084f3 --- /dev/null +++ b/app/test-flow-perf/actions_gen.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2020 Mellanox Technologies, Ltd + * + * This file contains the functions definitions to + * generate each supported action. + */ + +#ifndef FLOW_PERF_ACTION_GEN +#define FLOW_PERF_ACTION_GEN + +#include + +#include "config.h" + +void add_mark(struct rte_flow_action *actions, uint8_t actions_counter); +void add_queue(struct rte_flow_action *actions, + uint8_t actions_counter, uint16_t queue); +void add_jump(struct rte_flow_action *actions, + uint8_t actions_counter, uint16_t next_table); +void add_rss(struct rte_flow_action *actions, + uint8_t actions_counter, uint16_t *queues, + uint16_t queues_number); +void add_set_meta(struct rte_flow_action *actions, uint8_t actions_counter); +void add_set_tag(struct rte_flow_action *actions, uint8_t actions_counter); +void add_port_id(struct rte_flow_action *actions, uint8_t actions_counter); +void add_drop(struct rte_flow_action *actions, uint8_t actions_counter); +void add_count(struct rte_flow_action *actions, uint8_t actions_counter); + +#endif /* FLOW_PERF_ACTION_GEN */ diff --git a/app/test-flow-perf/config.h b/app/test-flow-perf/config.h index cf41e0345..f16d0de77 100644 --- a/app/test-flow-perf/config.h +++ b/app/test-flow-perf/config.h @@ -2,6 +2,7 @@ * Copyright 2020 Mellanox Technologies, Ltd */ +#define FLOW_ITEM_MASK(_x) (UINT64_C(1) << _x) #define GET_RSS_HF() (ETH_RSS_IP | ETH_RSS_TCP) /* Configuration */ @@ -12,3 +13,18 @@ #define MBUF_CACHE_SIZE 512 #define NR_RXD 256 #define NR_TXD 256 + +/* Items/Actions parameters */ +#define JUMP_ACTION_TABLE 2 +#define VLAN_VALUE 1 +#define VNI_VALUE 1 +#define GRE_PROTO 0x6558 +#define META_DATA 1 +#define TAG_INDEX 0 +#define PORT_ID_DST 1 +#define MARK_ID 1 +#define TEID_VALUE 1 + +/* Flow items/acctions max size */ +#define MAX_ITEMS_NUM 32 +#define MAX_ACTIONS_NUM 32 diff --git a/app/test-flow-perf/flow_gen.c b/app/test-flow-perf/flow_gen.c new file mode 100644 index 000000000..50066d99e --- /dev/null +++ b/app/test-flow-perf/flow_gen.c @@ -0,0 +1,145 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2020 Mellanox Technologies, Ltd + * + * The file contains the implementations of the method to + * fill items, actions & attributes in their corresponding + * arrays, and then generate rte_flow rule. + * + * After the generation. The rule goes to validation then + * creation state and then return the results. + */ + +#include + +#include "flow_gen.h" +#include "items_gen.h" +#include "actions_gen.h" +#include "config.h" + +static void +fill_attributes(struct rte_flow_attr *attr, + uint32_t flow_attrs, uint16_t group) +{ + if (flow_attrs & INGRESS) + attr->ingress = 1; + if (flow_attrs & EGRESS) + attr->egress = 1; + if (flow_attrs & TRANSFER) + attr->transfer = 1; + attr->group = group; +} + +static void +fill_items(struct rte_flow_item *items, + uint32_t flow_items, uint32_t outer_ip_src) +{ + uint8_t items_counter = 0; + + /* Support outer items up to tunnel layer only. */ + + if (flow_items & FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_META)) + add_meta_data(items, items_counter++); + if (flow_items & FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_TAG)) + add_meta_tag(items, items_counter++); + if (flow_items & FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_ETH)) + add_ether(items, items_counter++); + if (flow_items & FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_VLAN)) + add_vlan(items, items_counter++); + if (flow_items & FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_IPV4)) + add_ipv4(items, items_counter++, outer_ip_src); + if (flow_items & FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_IPV6)) + add_ipv6(items, items_counter++, outer_ip_src); + if (flow_items & FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_TCP)) + add_tcp(items, items_counter++); + if (flow_items & FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_UDP)) + add_udp(items, items_counter++); + if (flow_items & FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_VXLAN)) + add_vxlan(items, items_counter++); + if (flow_items & FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_VXLAN_GPE)) + add_vxlan_gpe(items, items_counter++); + if (flow_items & FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_GRE)) + add_gre(items, items_counter++); + if (flow_items & FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_GENEVE)) + add_geneve(items, items_counter++); + if (flow_items & FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_GTP)) + add_gtp(items, items_counter++); + + items[items_counter].type = RTE_FLOW_ITEM_TYPE_END; +} + +static void +fill_actions(struct rte_flow_action *actions, + uint32_t flow_actions, uint32_t counter, uint16_t next_table, + uint16_t hairpinq) +{ + uint8_t actions_counter = 0; + uint16_t hairpin_queues[hairpinq]; + uint16_t queues[RXQ_NUM]; + uint16_t i; + + /* None-fate actions */ + if (flow_actions & FLOW_ITEM_MASK(RTE_FLOW_ACTION_TYPE_MARK)) + add_mark(actions, actions_counter++); + if (flow_actions & FLOW_ITEM_MASK(RTE_FLOW_ACTION_TYPE_COUNT)) + add_count(actions, actions_counter++); + if (flow_actions & FLOW_ITEM_MASK(RTE_FLOW_ACTION_TYPE_SET_META)) + add_set_meta(actions, actions_counter++); + if (flow_actions & FLOW_ITEM_MASK(RTE_FLOW_ACTION_TYPE_SET_TAG)) + add_set_tag(actions, actions_counter++); + + /* Fate actions */ + if (flow_actions & FLOW_ITEM_MASK(RTE_FLOW_ACTION_TYPE_QUEUE)) + add_queue(actions, actions_counter++, counter % RXQ_NUM); + if (flow_actions & FLOW_ITEM_MASK(RTE_FLOW_ACTION_TYPE_RSS)) { + for (i = 0; i < RXQ_NUM; i++) + queues[i] = i; + add_rss(actions, actions_counter++, queues, RXQ_NUM); + } + if (flow_actions & FLOW_ITEM_MASK(RTE_FLOW_ACTION_TYPE_JUMP)) + add_jump(actions, actions_counter++, next_table); + if (flow_actions & FLOW_ITEM_MASK(RTE_FLOW_ACTION_TYPE_PORT_ID)) + add_port_id(actions, actions_counter++); + if (flow_actions & FLOW_ITEM_MASK(RTE_FLOW_ACTION_TYPE_DROP)) + add_drop(actions, actions_counter++); + if (flow_actions & HAIRPIN_QUEUE_ACTION) + add_queue(actions, actions_counter++, + (counter % hairpinq) + RXQ_NUM); + if (flow_actions & HAIRPIN_RSS_ACTION) { + for (i = 0; i < hairpinq; i++) + hairpin_queues[i] = i + RXQ_NUM; + add_rss(actions, actions_counter++, hairpin_queues, hairpinq); + } + + actions[actions_counter].type = RTE_FLOW_ACTION_TYPE_END; +} + +struct rte_flow * +generate_flow(uint16_t port_id, + uint16_t group, + uint32_t flow_attrs, + uint32_t flow_items, + uint32_t flow_actions, + uint16_t next_table, + uint32_t outer_ip_src, + uint16_t hairpinq, + struct rte_flow_error *error) +{ + struct rte_flow_attr attr; + struct rte_flow_item items[MAX_ITEMS_NUM]; + struct rte_flow_action actions[MAX_ACTIONS_NUM]; + struct rte_flow *flow = NULL; + + memset(items, 0, sizeof(items)); + memset(actions, 0, sizeof(actions)); + memset(&attr, 0, sizeof(struct rte_flow_attr)); + + fill_attributes(&attr, flow_attrs, group); + + fill_actions(actions, flow_actions, + outer_ip_src, next_table, hairpinq); + + fill_items(items, flow_items, outer_ip_src); + + flow = rte_flow_create(port_id, &attr, items, actions, error); + return flow; +} diff --git a/app/test-flow-perf/flow_gen.h b/app/test-flow-perf/flow_gen.h new file mode 100644 index 000000000..6b30a4ae2 --- /dev/null +++ b/app/test-flow-perf/flow_gen.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2020 Mellanox Technologies, Ltd + * + * This file contains the items, actions and attributes + * definition. And the methods to prepare and fill items, + * actions and attributes to generate rte_flow rule. + */ + +#ifndef FLOW_PERF_FLOW_GEN +#define FLOW_PERF_FLOW_GEN + +#include +#include + +#include "config.h" + +/* Actions */ +#define HAIRPIN_QUEUE_ACTION FLOW_ITEM_MASK(0) +#define HAIRPIN_RSS_ACTION FLOW_ITEM_MASK(1) + +/* Attributes */ +#define INGRESS FLOW_ITEM_MASK(0) +#define EGRESS FLOW_ITEM_MASK(1) +#define TRANSFER FLOW_ITEM_MASK(2) + +struct rte_flow * +generate_flow(uint16_t port_id, + uint16_t group, + uint32_t flow_attrs, + uint32_t flow_items, + uint32_t flow_actions, + uint16_t next_table, + uint32_t outer_ip_src, + uint16_t hairpinq, + struct rte_flow_error *error); + +#endif /* FLOW_PERF_FLOW_GEN */ diff --git a/app/test-flow-perf/items_gen.c b/app/test-flow-perf/items_gen.c new file mode 100644 index 000000000..c84f45040 --- /dev/null +++ b/app/test-flow-perf/items_gen.c @@ -0,0 +1,277 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2020 Mellanox Technologies, Ltd + * + * This file contain the implementations of the items + * related methods. Each Item have a method to prepare + * the item and add it into items array in given index. + */ + +#include +#include + +#include "items_gen.h" +#include "config.h" + +void +add_ether(struct rte_flow_item *items, uint8_t items_counter) +{ + static struct rte_flow_item_eth eth_spec; + static struct rte_flow_item_eth eth_mask; + + memset(ð_spec, 0, sizeof(struct rte_flow_item_eth)); + memset(ð_mask, 0, sizeof(struct rte_flow_item_eth)); + + items[items_counter].type = RTE_FLOW_ITEM_TYPE_ETH; + items[items_counter].spec = ð_spec; + items[items_counter].mask = ð_mask; +} + +void +add_vlan(struct rte_flow_item *items, uint8_t items_counter) +{ + static struct rte_flow_item_vlan vlan_spec; + static struct rte_flow_item_vlan vlan_mask; + uint16_t vlan_value = VLAN_VALUE; + + memset(&vlan_spec, 0, sizeof(struct rte_flow_item_vlan)); + memset(&vlan_mask, 0, sizeof(struct rte_flow_item_vlan)); + + vlan_spec.tci = RTE_BE16(vlan_value); + vlan_mask.tci = RTE_BE16(0xffff); + + items[items_counter].type = RTE_FLOW_ITEM_TYPE_VLAN; + items[items_counter].spec = &vlan_spec; + items[items_counter].mask = &vlan_mask; +} + +void +add_ipv4(struct rte_flow_item *items, + uint8_t items_counter, rte_be32_t src_ipv4) +{ + static struct rte_flow_item_ipv4 ipv4_spec; + static struct rte_flow_item_ipv4 ipv4_mask; + + memset(&ipv4_spec, 0, sizeof(struct rte_flow_item_ipv4)); + memset(&ipv4_mask, 0, sizeof(struct rte_flow_item_ipv4)); + + ipv4_spec.hdr.src_addr = src_ipv4; + ipv4_mask.hdr.src_addr = RTE_BE32(0xffffffff); + + items[items_counter].type = RTE_FLOW_ITEM_TYPE_IPV4; + items[items_counter].spec = &ipv4_spec; + items[items_counter].mask = &ipv4_mask; +} + + +void +add_ipv6(struct rte_flow_item *items, + uint8_t items_counter, rte_be32_t src_ipv6) +{ + static struct rte_flow_item_ipv6 ipv6_spec; + static struct rte_flow_item_ipv6 ipv6_mask; + + memset(&ipv6_spec, 0, sizeof(struct rte_flow_item_ipv6)); + memset(&ipv6_mask, 0, sizeof(struct rte_flow_item_ipv6)); + + /** Set ipv6 src **/ + memset(&ipv6_spec.hdr.src_addr, src_ipv6, + sizeof(ipv6_spec.hdr.src_addr) / 2); + + /** Full mask **/ + memset(&ipv6_mask.hdr.src_addr, 0xff, + sizeof(ipv6_spec.hdr.src_addr)); + + items[items_counter].type = RTE_FLOW_ITEM_TYPE_IPV6; + items[items_counter].spec = &ipv6_spec; + items[items_counter].mask = &ipv6_mask; +} + +void +add_tcp(struct rte_flow_item *items, uint8_t items_counter) +{ + static struct rte_flow_item_tcp tcp_spec; + static struct rte_flow_item_tcp tcp_mask; + + memset(&tcp_spec, 0, sizeof(struct rte_flow_item_tcp)); + memset(&tcp_mask, 0, sizeof(struct rte_flow_item_tcp)); + + items[items_counter].type = RTE_FLOW_ITEM_TYPE_TCP; + items[items_counter].spec = &tcp_spec; + items[items_counter].mask = &tcp_mask; +} + +void +add_udp(struct rte_flow_item *items, uint8_t items_counter) +{ + static struct rte_flow_item_udp udp_spec; + static struct rte_flow_item_udp udp_mask; + + memset(&udp_spec, 0, sizeof(struct rte_flow_item_udp)); + memset(&udp_mask, 0, sizeof(struct rte_flow_item_udp)); + + items[items_counter].type = RTE_FLOW_ITEM_TYPE_UDP; + items[items_counter].spec = &udp_spec; + items[items_counter].mask = &udp_mask; +} + +void +add_vxlan(struct rte_flow_item *items, uint8_t items_counter) +{ + static struct rte_flow_item_vxlan vxlan_spec; + static struct rte_flow_item_vxlan vxlan_mask; + uint32_t vni_value; + uint8_t i; + + vni_value = VNI_VALUE; + + memset(&vxlan_spec, 0, sizeof(struct rte_flow_item_vxlan)); + memset(&vxlan_mask, 0, sizeof(struct rte_flow_item_vxlan)); + + /* Set standard vxlan vni */ + for (i = 0; i < 3; i++) { + vxlan_spec.vni[2 - i] = vni_value >> (i * 8); + vxlan_mask.vni[2 - i] = 0xff; + } + + /* Standard vxlan flags */ + vxlan_spec.flags = 0x8; + + items[items_counter].type = RTE_FLOW_ITEM_TYPE_VXLAN; + items[items_counter].spec = &vxlan_spec; + items[items_counter].mask = &vxlan_mask; +} + +void +add_vxlan_gpe(struct rte_flow_item *items, uint8_t items_counter) +{ + static struct rte_flow_item_vxlan_gpe vxlan_gpe_spec; + static struct rte_flow_item_vxlan_gpe vxlan_gpe_mask; + uint32_t vni_value; + uint8_t i; + + vni_value = VNI_VALUE; + + memset(&vxlan_gpe_spec, 0, sizeof(struct rte_flow_item_vxlan_gpe)); + memset(&vxlan_gpe_mask, 0, sizeof(struct rte_flow_item_vxlan_gpe)); + + /* Set vxlan-gpe vni */ + for (i = 0; i < 3; i++) { + vxlan_gpe_spec.vni[2 - i] = vni_value >> (i * 8); + vxlan_gpe_mask.vni[2 - i] = 0xff; + } + + /* vxlan-gpe flags */ + vxlan_gpe_spec.flags = 0x0c; + + items[items_counter].type = RTE_FLOW_ITEM_TYPE_VXLAN_GPE; + items[items_counter].spec = &vxlan_gpe_spec; + items[items_counter].mask = &vxlan_gpe_mask; +} + +void +add_gre(struct rte_flow_item *items, uint8_t items_counter) +{ + static struct rte_flow_item_gre gre_spec; + static struct rte_flow_item_gre gre_mask; + uint16_t proto; + + proto = GRE_PROTO; + + memset(&gre_spec, 0, sizeof(struct rte_flow_item_gre)); + memset(&gre_mask, 0, sizeof(struct rte_flow_item_gre)); + + gre_spec.protocol = RTE_BE16(proto); + gre_mask.protocol = RTE_BE16(0xffff); + + items[items_counter].type = RTE_FLOW_ITEM_TYPE_GRE; + items[items_counter].spec = &gre_spec; + items[items_counter].mask = &gre_mask; +} + +void +add_geneve(struct rte_flow_item *items, uint8_t items_counter) +{ + static struct rte_flow_item_geneve geneve_spec; + static struct rte_flow_item_geneve geneve_mask; + uint32_t vni_value; + uint8_t i; + + vni_value = VNI_VALUE; + + memset(&geneve_spec, 0, sizeof(struct rte_flow_item_geneve)); + memset(&geneve_mask, 0, sizeof(struct rte_flow_item_geneve)); + + for (i = 0; i < 3; i++) { + geneve_spec.vni[2 - i] = vni_value >> (i * 8); + geneve_mask.vni[2 - i] = 0xff; + } + + items[items_counter].type = RTE_FLOW_ITEM_TYPE_GENEVE; + items[items_counter].spec = &geneve_spec; + items[items_counter].mask = &geneve_mask; +} + +void +add_gtp(struct rte_flow_item *items, uint8_t items_counter) +{ + static struct rte_flow_item_gtp gtp_spec; + static struct rte_flow_item_gtp gtp_mask; + uint32_t teid_value; + + teid_value = TEID_VALUE; + + memset(>p_spec, 0, sizeof(struct rte_flow_item_gtp)); + memset(>p_mask, 0, sizeof(struct rte_flow_item_gtp)); + + gtp_spec.teid = RTE_BE32(teid_value); + gtp_mask.teid = RTE_BE32(0xffffffff); + + items[items_counter].type = RTE_FLOW_ITEM_TYPE_GTP; + items[items_counter].spec = >p_spec; + items[items_counter].mask = >p_mask; +} + +void +add_meta_data(struct rte_flow_item *items, uint8_t items_counter) +{ + static struct rte_flow_item_meta meta_spec; + static struct rte_flow_item_meta meta_mask; + uint32_t data; + + data = META_DATA; + + memset(&meta_spec, 0, sizeof(struct rte_flow_item_meta)); + memset(&meta_mask, 0, sizeof(struct rte_flow_item_meta)); + + meta_spec.data = RTE_BE32(data); + meta_mask.data = RTE_BE32(0xffffffff); + + items[items_counter].type = RTE_FLOW_ITEM_TYPE_META; + items[items_counter].spec = &meta_spec; + items[items_counter].mask = &meta_mask; +} + + +void +add_meta_tag(struct rte_flow_item *items, uint8_t items_counter) +{ + static struct rte_flow_item_tag tag_spec; + static struct rte_flow_item_tag tag_mask; + uint32_t data; + uint8_t index; + + data = META_DATA; + index = TAG_INDEX; + + memset(&tag_spec, 0, sizeof(struct rte_flow_item_tag)); + memset(&tag_mask, 0, sizeof(struct rte_flow_item_tag)); + + tag_spec.data = RTE_BE32(data); + tag_mask.data = RTE_BE32(0xffffffff); + tag_spec.index = index; + tag_mask.index = 0xff; + + items[items_counter].type = RTE_FLOW_ITEM_TYPE_TAG; + items[items_counter].spec = &tag_spec; + items[items_counter].mask = &tag_mask; +} diff --git a/app/test-flow-perf/items_gen.h b/app/test-flow-perf/items_gen.h new file mode 100644 index 000000000..0edbc0b37 --- /dev/null +++ b/app/test-flow-perf/items_gen.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2020 Mellanox Technologies, Ltd + * + * This file contains the items related methods + */ + +#ifndef FLOW_PERF_ITEMS_GEN +#define FLOW_PERF_ITEMS_GEN + +#include +#include + +#include "config.h" + +void add_ether(struct rte_flow_item *items, uint8_t items_counter); +void add_vlan(struct rte_flow_item *items, uint8_t items_counter); +void add_ipv4(struct rte_flow_item *items, + uint8_t items_counter, rte_be32_t src_ipv4); +void add_ipv6(struct rte_flow_item *items, + uint8_t items_counter, rte_be32_t src_ipv6); +void add_udp(struct rte_flow_item *items, uint8_t items_counter); +void add_tcp(struct rte_flow_item *items, uint8_t items_counter); +void add_vxlan(struct rte_flow_item *items, uint8_t items_counter); +void add_vxlan_gpe(struct rte_flow_item *items, uint8_t items_counter); +void add_gre(struct rte_flow_item *items, uint8_t items_counter); +void add_geneve(struct rte_flow_item *items, uint8_t items_counter); +void add_gtp(struct rte_flow_item *items, uint8_t items_counter); +void add_meta_data(struct rte_flow_item *items, uint8_t items_counter); +void add_meta_tag(struct rte_flow_item *items, uint8_t items_counter); + +#endif /* FLOW_PERF_ITEMS_GEN */ diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c index 8659870af..1feb73e6f 100644 --- a/app/test-flow-perf/main.c +++ b/app/test-flow-perf/main.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -34,29 +35,257 @@ #include #include "config.h" +#include "flow_gen.h" -static uint32_t nb_lcores; +#define MAX_ITERATIONS 100 +#define DEFAULT_RULES_COUNT 4000000 +#define DEFAULT_ITERATION 100000 + +struct rte_flow *flow; +static uint8_t flow_group; + +static uint32_t flow_items; +static uint32_t flow_actions; +static uint32_t flow_attrs; +static volatile bool force_quit; +static bool dump_iterations; static struct rte_mempool *mbuf_mp; +static uint32_t nb_lcores; +static uint32_t flows_count; +static uint32_t iterations_number; +static uint32_t hairpinq; static void usage(char *progname) { printf("\nusage: %s\n", progname); + printf("\nControl configurations:\n"); + printf(" --flows-count=N: to set the number of needed" + " flows to insert, default is 4,000,000\n"); + printf(" --dump-iterations: To print rates for each" + " iteration\n"); + + printf("To set flow attributes:\n"); + printf(" --ingress: set ingress attribute in flows\n"); + printf(" --egress: set egress attribute in flows\n"); + printf(" --transfer: set transfer attribute in flows\n"); + printf(" --group=N: set group for all flows," + " default is 0\n"); + + printf("To set flow items:\n"); + printf(" --ether: add ether layer in flow items\n"); + printf(" --vlan: add vlan layer in flow items\n"); + printf(" --ipv4: add ipv4 layer in flow items\n"); + printf(" --ipv6: add ipv6 layer in flow items\n"); + printf(" --tcp: add tcp layer in flow items\n"); + printf(" --udp: add udp layer in flow items\n"); + printf(" --vxlan: add vxlan layer in flow items\n"); + printf(" --vxlan-gpe: add vxlan-gpe layer in flow items\n"); + printf(" --gre: add gre layer in flow items\n"); + printf(" --geneve: add geneve layer in flow items\n"); + printf(" --gtp: add gtp layer in flow items\n"); + printf(" --meta: add meta layer in flow items\n"); + printf(" --tag: add tag layer in flow items\n"); + + printf("To set flow actions:\n"); + printf(" --port-id: add port-id action in flow actions\n"); + printf(" --rss: add rss action in flow actions\n"); + printf(" --queue: add queue action in flow actions\n"); + printf(" --jump: add jump action in flow actions\n"); + printf(" --mark: add mark action in flow actions\n"); + printf(" --count: add count action in flow actions\n"); + printf(" --set-meta: add set meta action in flow actions\n"); + printf(" --set-tag: add set tag action in flow actions\n"); + printf(" --drop: add drop action in flow actions\n"); + printf(" --hairpin-queue=N: add hairpin-queue action in flow actions\n"); + printf(" --hairpin-rss=N: add hairping-rss action in flow actions\n"); } static void args_parse(int argc, char **argv) { char **argvopt; - int opt; + int n, opt; int opt_idx; + size_t i; + + static const struct option_dict { + const char *str; + const uint64_t mask; + uint32_t *bitmap; + } flow_options[] = { + { + .str = "ether", + .mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_ETH), + .bitmap = &flow_items + }, + { + .str = "ipv4", + .mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_IPV4), + .bitmap = &flow_items + }, + { + .str = "ipv6", + .mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_IPV6), + .bitmap = &flow_items + }, + { + .str = "vlan", + .mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_VLAN), + .bitmap = &flow_items + }, + { + .str = "tcp", + .mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_TCP), + .bitmap = &flow_items + }, + { + .str = "udp", + .mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_UDP), + .bitmap = &flow_items + }, + { + .str = "vxlan", + .mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_VXLAN), + .bitmap = &flow_items + }, + { + .str = "vxlan-gpe", + .mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_VXLAN_GPE), + .bitmap = &flow_items + }, + { + .str = "gre", + .mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_GRE), + .bitmap = &flow_items + }, + { + .str = "geneve", + .mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_GENEVE), + .bitmap = &flow_items + }, + { + .str = "gtp", + .mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_GTP), + .bitmap = &flow_items + }, + { + .str = "meta", + .mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_META), + .bitmap = &flow_items + }, + { + .str = "tag", + .mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_TAG), + .bitmap = &flow_items + }, + { + .str = "ingress", + .mask = INGRESS, + .bitmap = &flow_attrs + }, + { + .str = "egress", + .mask = EGRESS, + .bitmap = &flow_attrs + }, + { + .str = "transfer", + .mask = TRANSFER, + .bitmap = &flow_attrs + }, + { + .str = "port-id", + .mask = FLOW_ITEM_MASK(RTE_FLOW_ACTION_TYPE_PORT_ID), + .bitmap = &flow_actions + }, + { + .str = "rss", + .mask = FLOW_ITEM_MASK(RTE_FLOW_ACTION_TYPE_RSS), + .bitmap = &flow_actions + }, + { + .str = "queue", + .mask = FLOW_ITEM_MASK(RTE_FLOW_ACTION_TYPE_QUEUE), + .bitmap = &flow_actions + }, + { + .str = "jump", + .mask = FLOW_ITEM_MASK(RTE_FLOW_ACTION_TYPE_JUMP), + .bitmap = &flow_actions + }, + { + .str = "mark", + .mask = FLOW_ITEM_MASK(RTE_FLOW_ACTION_TYPE_MARK), + .bitmap = &flow_actions + }, + { + .str = "count", + .mask = FLOW_ITEM_MASK(RTE_FLOW_ACTION_TYPE_COUNT), + .bitmap = &flow_actions + }, + { + .str = "set-meta", + .mask = FLOW_ITEM_MASK(RTE_FLOW_ACTION_TYPE_SET_META), + .bitmap = &flow_actions + }, + { + .str = "set-tag", + .mask = FLOW_ITEM_MASK(RTE_FLOW_ACTION_TYPE_SET_TAG), + .bitmap = &flow_actions + }, + { + .str = "drop", + .mask = FLOW_ITEM_MASK(RTE_FLOW_ACTION_TYPE_DROP), + .bitmap = &flow_actions + } + }; + static struct option lgopts[] = { /* Control */ { "help", 0, 0, 0 }, + { "flows-count", 1, 0, 0 }, + { "dump-iterations", 0, 0, 0 }, + /* Attributes */ + { "ingress", 0, 0, 0 }, + { "egress", 0, 0, 0 }, + { "transfer", 0, 0, 0 }, + { "group", 1, 0, 0 }, + /* Items */ + { "ether", 0, 0, 0 }, + { "vlan", 0, 0, 0 }, + { "ipv4", 0, 0, 0 }, + { "ipv6", 0, 0, 0 }, + { "tcp", 0, 0, 0 }, + { "udp", 0, 0, 0 }, + { "vxlan", 0, 0, 0 }, + { "vxlan-gpe", 0, 0, 0 }, + { "gre", 0, 0, 0 }, + { "geneve", 0, 0, 0 }, + { "gtp", 0, 0, 0 }, + { "meta", 0, 0, 0 }, + { "tag", 0, 0, 0 }, + /* Actions */ + { "port-id", 0, 0, 0 }, + { "rss", 0, 0, 0 }, + { "queue", 0, 0, 0 }, + { "jump", 0, 0, 0 }, + { "mark", 0, 0, 0 }, + { "count", 0, 0, 0 }, + { "set-meta", 0, 0, 0 }, + { "set-tag", 0, 0, 0 }, + { "drop", 0, 0, 0 }, + { "hairpin-queue", 1, 0, 0 }, + { "hairpin-rss", 1, 0, 0 }, }; + flow_items = 0; + flow_actions = 0; + flow_attrs = 0; + hairpinq = 0; argvopt = argv; + printf(":: Flow -> "); while ((opt = getopt_long(argc, argvopt, "", lgopts, &opt_idx)) != EOF) { switch (opt) { @@ -65,6 +294,65 @@ args_parse(int argc, char **argv) usage(argv[0]); rte_exit(EXIT_SUCCESS, "Displayed help\n"); } + + if (strcmp(lgopts[opt_idx].name, "group") == 0) { + n = atoi(optarg); + if (n >= 0) + flow_group = n; + else + rte_exit(EXIT_SUCCESS, + "flow group should be >= 0"); + printf("group %d ", flow_group); + } + + for (i = 0; i < RTE_DIM(flow_options); i++) + if (strcmp(lgopts[opt_idx].name, + flow_options[i].str) == 0) { + *flow_options[i].bitmap |= + flow_options[i].mask; + printf("%s / ", flow_options[i].str); + } + + if (strcmp(lgopts[opt_idx].name, + "hairpin-rss") == 0) { + n = atoi(optarg); + if (n > 0) + hairpinq = n; + else + rte_exit(EXIT_SUCCESS, + "Hairpin queues should be > 0 "); + + flow_actions |= HAIRPIN_RSS_ACTION; + printf("hairpin-rss / "); + } + if (strcmp(lgopts[opt_idx].name, + "hairpin-queue") == 0) { + n = atoi(optarg); + if (n > 0) + hairpinq = n; + else + rte_exit(EXIT_SUCCESS, + "Hairpin queues should be > 0 "); + + flow_actions |= HAIRPIN_QUEUE_ACTION; + printf("hairpin-queue / "); + } + + /* Control */ + if (strcmp(lgopts[opt_idx].name, + "flows-count") == 0) { + n = atoi(optarg); + if (n > (int) iterations_number) + flows_count = n; + else { + printf("\n\nflows_count should be > %d", + iterations_number); + rte_exit(EXIT_SUCCESS, " "); + } + } + if (strcmp(lgopts[opt_idx].name, + "dump-iterations") == 0) + dump_iterations = true; break; default: fprintf(stderr, "Invalid option: %s\n", argv[optind]); @@ -73,6 +361,130 @@ args_parse(int argc, char **argv) break; } } + printf("end_flow\n"); +} + +static void +print_flow_error(struct rte_flow_error error) +{ + printf("Flow can't be created %d message: %s\n", + error.type, + error.message ? error.message : "(no stated reason)"); +} + +static inline void +flows_handler(void) +{ + struct rte_flow_error error; + clock_t start_iter, end_iter; + double cpu_time_used; + double flows_rate; + double cpu_time_per_iter[MAX_ITERATIONS]; + double delta; + uint16_t nr_ports; + uint32_t i; + int port_id; + int iter_id; + uint32_t eagain_counter = 0; + + nr_ports = rte_eth_dev_count_avail(); + + for (i = 0; i < MAX_ITERATIONS; i++) + cpu_time_per_iter[i] = -1; + + if (iterations_number > flows_count) + iterations_number = flows_count; + + printf(":: Flows Count per port: %d\n", flows_count); + + for (port_id = 0; port_id < nr_ports; port_id++) { + cpu_time_used = 0; + if (flow_group > 0) { + /* + * Create global rule to jump into flow_group, + * this way the app will avoid the default rules. + * + * Golbal rule: + * group 0 eth / end actions jump group + * + */ + flow = generate_flow(port_id, 0, flow_attrs, + FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_ETH), + FLOW_ITEM_MASK(RTE_FLOW_ACTION_TYPE_JUMP), + flow_group, 0, 0, &error); + + if (flow == NULL) { + print_flow_error(error); + rte_exit(EXIT_FAILURE, "error in creating flow"); + } + } + + /* Insertion Rate */ + printf("Flows insertion on port = %d\n", port_id); + start_iter = clock(); + for (i = 0; i < flows_count; i++) { + do { + rte_errno = 0; + flow = generate_flow(port_id, flow_group, + flow_attrs, flow_items, flow_actions, + JUMP_ACTION_TABLE, i, hairpinq, &error); + if (flow == NULL) + eagain_counter++; + } while (rte_errno == EAGAIN); + + if (force_quit) + i = flows_count; + + if (!flow) { + print_flow_error(error); + rte_exit(EXIT_FAILURE, "error in creating flow"); + } + + if (i && !((i + 1) % iterations_number)) { + /* Save the insertion rate of each iter */ + end_iter = clock(); + delta = (double) (end_iter - start_iter); + iter_id = ((i + 1) / iterations_number) - 1; + cpu_time_per_iter[iter_id] = + delta / CLOCKS_PER_SEC; + cpu_time_used += cpu_time_per_iter[iter_id]; + start_iter = clock(); + } + } + + /* Iteration rate per iteration */ + if (dump_iterations) + for (i = 0; i < MAX_ITERATIONS; i++) { + if (cpu_time_per_iter[i] == -1) + continue; + delta = (double)(iterations_number / + cpu_time_per_iter[i]); + flows_rate = delta / 1000; + printf(":: Iteration #%d: %d flows " + "in %f sec[ Rate = %f K/Sec ]\n", + i, iterations_number, + cpu_time_per_iter[i], flows_rate); + } + + /* Insertion rate for all flows */ + flows_rate = ((double) (flows_count / cpu_time_used) / 1000); + printf("\n:: Total flow insertion rate -> %f K/Sec\n", + flows_rate); + printf(":: The time for creating %d in flows %f seconds\n", + flows_count, cpu_time_used); + printf(":: EAGAIN counter = %d\n", eagain_counter); + } +} + +static void +signal_handler(int signum) +{ + if (signum == SIGINT || signum == SIGTERM) { + printf("\n\nSignal %d received, preparing to exit...\n", + signum); + printf("Error: Stats are wrong due to sudden signal!\n\n"); + force_quit = true; + } } static void @@ -80,8 +492,13 @@ init_port(void) { int ret; uint16_t std_queue; + uint16_t hairpin_q; uint16_t port_id; uint16_t nr_ports; + uint16_t nr_queues; + struct rte_eth_hairpin_conf hairpin_conf = { + .peer_count = 1, + }; struct rte_eth_conf port_conf = { .rx_adv_conf = { .rss_conf.rss_hf = @@ -92,6 +509,10 @@ init_port(void) struct rte_eth_rxconf rxq_conf; struct rte_eth_dev_info dev_info; + nr_queues = RXQ_NUM; + if (hairpinq != 0) + nr_queues = RXQ_NUM + hairpinq; + nr_ports = rte_eth_dev_count_avail(); if (nr_ports == 0) rte_exit(EXIT_FAILURE, "Error: no port detected\n"); @@ -116,8 +537,8 @@ init_port(void) printf(":: initializing port: %d\n", port_id); - ret = rte_eth_dev_configure(port_id, RXQ_NUM, - TXQ_NUM, &port_conf); + ret = rte_eth_dev_configure(port_id, nr_queues, + nr_queues, &port_conf); if (ret < 0) rte_exit(EXIT_FAILURE, ":: cannot configure device: err=%d, port=%u\n", @@ -153,6 +574,38 @@ init_port(void) ":: promiscuous mode enable failed: err=%s, port=%u\n", rte_strerror(-ret), port_id); + if (hairpinq != 0) { + for (hairpin_q = RXQ_NUM, std_queue = 0; + std_queue < nr_queues; + hairpin_q++, std_queue++) { + hairpin_conf.peers[0].port = port_id; + hairpin_conf.peers[0].queue = + std_queue + TXQ_NUM; + ret = rte_eth_rx_hairpin_queue_setup( + port_id, hairpin_q, + NR_RXD, &hairpin_conf); + if (ret != 0) + rte_exit(EXIT_FAILURE, + ":: Hairpin rx queue setup failed: err=%d, port=%u\n", + ret, port_id); + } + + for (hairpin_q = TXQ_NUM, std_queue = 0; + std_queue < nr_queues; + hairpin_q++, std_queue++) { + hairpin_conf.peers[0].port = port_id; + hairpin_conf.peers[0].queue = + std_queue + RXQ_NUM; + ret = rte_eth_tx_hairpin_queue_setup( + port_id, hairpin_q, + NR_TXD, &hairpin_conf); + if (ret != 0) + rte_exit(EXIT_FAILURE, + ":: Hairpin tx queue setup failed: err=%d, port=%u\n", + ret, port_id); + } + } + ret = rte_eth_dev_start(port_id); if (ret < 0) rte_exit(EXIT_FAILURE, @@ -174,6 +627,15 @@ main(int argc, char **argv) if (ret < 0) rte_exit(EXIT_FAILURE, "EAL init failed\n"); + force_quit = false; + dump_iterations = false; + flows_count = DEFAULT_RULES_COUNT; + iterations_number = DEFAULT_ITERATION; + flow_group = 0; + + signal(SIGINT, signal_handler); + signal(SIGTERM, signal_handler); + argc -= ret; argv += ret; if (argc > 1) @@ -185,6 +647,8 @@ main(int argc, char **argv) if (nb_lcores <= 1) rte_exit(EXIT_FAILURE, "This app needs at least two cores\n"); + flows_handler(); + RTE_ETH_FOREACH_DEV(port) { rte_flow_flush(port, &error); rte_eth_dev_stop(port); diff --git a/app/test-flow-perf/meson.build b/app/test-flow-perf/meson.build index 25711378f..6eaf83b41 100644 --- a/app/test-flow-perf/meson.build +++ b/app/test-flow-perf/meson.build @@ -2,6 +2,9 @@ # Copyright(c) 2020 Mellanox Technologies, Ltd sources = files( + 'actions_gen.c', + 'flow_gen.c', + 'items_gen.c', 'main.c', ) diff --git a/doc/guides/rel_notes/release_20_05.rst b/doc/guides/rel_notes/release_20_05.rst index 7abcae3aa..0e4dcf1ad 100644 --- a/doc/guides/rel_notes/release_20_05.rst +++ b/doc/guides/rel_notes/release_20_05.rst @@ -216,6 +216,9 @@ New Features Add new application to test rte_flow performance. + Application features: + * Measure rte_flow insertion rate. + Removed Items ------------- diff --git a/doc/guides/tools/flow-perf.rst b/doc/guides/tools/flow-perf.rst index 49eb450ae..6f3f7dafb 100644 --- a/doc/guides/tools/flow-perf.rst +++ b/doc/guides/tools/flow-perf.rst @@ -1,10 +1,29 @@ .. SPDX-License-Identifier: BSD-3-Clause Copyright 2020 Mellanox Technologies, Ltd -Flow performance tool +Flow Performance Tool ===================== Application for rte_flow performance testing. +The application provide the ability to test insertion rate of specific +rte_flow rule, by stressing it to the NIC, and calculate the insertion +rate. + +The application offers some options in the command line, to configure +which rule to apply. + +After that the application will start producing rules with same pattern +but increasing the outer IP source address by 1 each time, thus it will +give different flow each time, and all other items will have open masks. + + +Known Limitations +================= + +The current version has limitations which can be removed in future: + +* Support outer items up to tunnel layer only. +* Single core insertion only. Compiling the Application @@ -27,7 +46,7 @@ or :doc:`EAL parameters (FreeBSD) <../freebsd_gsg/freebsd_eal_parameters>` for a list of available EAL command-line options. -Flow performance Options +Flow Performance Options ------------------------ The following are the command-line options for the flow performance application. @@ -36,9 +55,179 @@ with a ``--`` separator: .. code-block:: console - sudo ./dpdk-test-flow-perf -n 4 -w 08:00.0 -- + sudo ./dpdk-test-flow_perf -n 4 -w 08:00.0 -- --ingress --ether --ipv4 --queue --flows-count=1000000 The command line options are: * ``--help`` Display a help message and quit. + +* ``--flows-count=N`` + Set the number of needed flows to insert, + where 1 <= N <= "number of flows". + The default value is 4,000,000. + +* ``--dump-iterations`` + Print rates for each iteration of flows. + Default iteration is 1,00,000. + + +Attributes: + +* ``--ingress`` + Set Ingress attribute to all flows attributes. + +* ``--egress`` + Set Egress attribute to all flows attributes. + +* ``--transfer`` + Set Transfer attribute to all flows attributes. + +* ``--group=N`` + Set group for all flows, where N >= 0. + Default group is 0. + +Items: + +* ``--ether`` + Add Ether item to all flows items, This item have open mask. + +* ``--vlan`` + Add VLAN item to all flows items, + This item have VLAN value defined in user_parameters.h + under ``VNI_VALUE`` with full mask, default value = 1. + Other fields are open mask. + +* ``--ipv4`` + Add IPv4 item to all flows items, + This item have incremental source IP, with full mask. + Other fields are open mask. + +* ``--ipv6`` + Add IPv6 item to all flows item, + This item have incremental source IP, with full mask. + Other fields are open mask. + +* ``--tcp`` + Add TCP item to all flows items, This item have open mask. + +* ``--udp`` + Add UDP item to all flows items, This item have open mask. + +* ``--vxlan`` + Add VXLAN item to all flows items, + This item have VNI value defined in user_parameters.h + under ``VNI_VALUE`` with full mask, default value = 1. + Other fields are open mask. + +* ``--vxlan-gpe`` + Add VXLAN-GPE item to all flows items, + This item have VNI value defined in user_parameters.h + under ``VNI_VALUE`` with full mask, default value = 1. + Other fields are open mask. + +* ``--gre`` + Add GRE item to all flows items, + This item have protocol value defined in user_parameters.h + under ``GRE_PROTO`` with full mask, default protocol = 0x6558 "Ether" + Other fields are open mask. + +* ``--geneve`` + Add GENEVE item to all flows items, + This item have VNI value defined in user_parameters.h + under ``VNI_VALUE`` with full mask, default value = 1. + Other fields are open mask. + +* ``--gtp`` + Add GTP item to all flows items, + This item have TEID value defined in user_parameters.h + under ``TEID_VALUE`` with full mask, default value = 1. + Other fields are open mask. + +* ``--meta`` + Add Meta item to all flows items, + This item have data value defined in user_parameters.h + under ``META_DATA`` with full mask, default value = 1. + Other fields are open mask. + +* ``--tag`` + Add Tag item to all flows items, + This item have data value defined in user_parameters.h + under ``META_DATA`` with full mask, default value = 1. + + Also it have tag value defined in user_parameters.h + under ``TAG_INDEX`` with full mask, default value = 0. + Other fields are open mask. + + +Actions: + +* ``--port-id`` + Add port redirection action to all flows actions. + Port redirection destination is defined in user_parameters.h + under PORT_ID_DST, default value = 1. + +* ``--rss`` + Add RSS action to all flows actions, + The queues in RSS action will be all queues configured + in the app. + +* ``--queue`` + Add queue action to all flows items, + The queue will change in round robin state for each flow. + + For example: + The app running with 4 RX queues + Flow #0: queue index 0 + Flow #1: queue index 1 + Flow #2: queue index 2 + Flow #3: queue index 3 + Flow #4: queue index 0 + ... + +* ``--jump`` + Add jump action to all flows actions. + Jump action destination is defined in user_parameters.h + under ``JUMP_ACTION_TABLE``, default value = 2. + +* ``--mark`` + Add mark action to all flows actions. + Mark action id is defined in user_parameters.h + under ``MARK_ID``, default value = 1. + +* ``--count`` + Add count action to all flows actions. + +* ``--set-meta`` + Add set-meta action to all flows actions. + Meta data is defined in user_parameters.h under ``META_DATA`` + with full mask, default value = 1. + +* ``--set-tag`` + Add set-tag action to all flows actions. + Meta data is defined in user_parameters.h under ``META_DATA`` + with full mask, default value = 1. + + Tag index is defined in user_parameters.h under ``TAG_INDEX`` + with full mask, default value = 0. + +* ``--drop`` + Add drop action to all flows actions. + +* ``--hairpin-queue=N`` + Add hairpin queue action to all flows actions. + The queue will change in round robin state for each flow. + + For example: + The app running with 4 RX hairpin queues and 4 normal RX queues + Flow #0: queue index 4 + Flow #1: queue index 5 + Flow #2: queue index 6 + Flow #3: queue index 7 + Flow #4: queue index 4 + ... + +* ``--hairpin-rss=N`` + Add hairpin RSS action to all flows actions. + The queues in RSS action will be all hairpin queues configured + in the app. From patchwork Mon May 11 11:08:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wisam Jaddo X-Patchwork-Id: 70073 X-Patchwork-Delegate: thomas@monjalon.net 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 466E4A00C5; Mon, 11 May 2020 13:09:08 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2F1DA1C22A; Mon, 11 May 2020 13:08:43 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2069.outbound.protection.outlook.com [40.107.20.69]) by dpdk.org (Postfix) with ESMTP id 32DEE1C202 for ; Mon, 11 May 2020 13:08:40 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LABKkNXOojFPwUdGtzbKD+zUaJqpuaKKhFGF4bmPP4uBiyu+KZnR+gU/QomHoT4T2rqQiJoo1HrCpt0PUF7sa1aszDOE1StApLLEKMfzDeeWv4mrTMPxlX4e6rC7xWkNL0UrWL3noT68SD0rJE2gED5Q3IT/ivIi5W/1tiUe05TK8Q/czCxrz7/jXGg/+wQ7y55bc1eY2ZBiM4GJwyKvgig2VxdMp9NgE0y8w4wjIwJ4wj8uKNLux3crCXh5nfr5bY6vG5HVxgEhGpx55sapp5ZTfgsr2sOaADTwLLA2WKzvpPFaCtj3DSN43pZwgyJGr7/3BnPUvm5w+BCbkYqhSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LVoddsExgJluQtnT0d+Klwyre2vejkcQz54MUosVMFY=; b=PUa2OTYZ7Lzw/x4zAct7jkzAoX2Y3mpKOZRNCR/ozAqZEjar6fB+joF8b+7mqZZTtl0YDMvnJh2OUAsZtlL74BqGNeDtaVobheuylbxkoOV+XjmKwAiw69fqZlaqPKCTPHRJd9dwlhEBzI+92Ab01qbao7IHUwPOaJoKObDYbOntZByVil4L/iVBfzjHcS1EVXBGpomwdn/RcRh+qyDKo6eFCOF4XUvFCcvr7Xz4vzOOQAOngjLQRHPUQ/s03LTFDq0iDmZyTRRJkzfoX9M11UKfiDdCMG/avUQN4/+AFWMsfgh9XKKPIxoHuw6XZd4ILmQxoPn6mOtNS8Gu3B9wTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LVoddsExgJluQtnT0d+Klwyre2vejkcQz54MUosVMFY=; b=ElJNukQFqZusmJ1e7Lx5R3CvHYLjFaO/fpWJESyBi2IRFO+62J6pglhgUAlVJjQLU+aKNLZ44/GPyLxkUnczj8tZKRFr7nZx0ESkIJcmALoNZUaMx7vBwDAgwghFyAMYL7ma+AGLekmkhWryM/1PUtnQO24c7l2tT2zOGfANweA= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=mellanox.com; Received: from AM0PR05MB6610.eurprd05.prod.outlook.com (2603:10a6:208:12f::18) by AM0PR05MB4996.eurprd05.prod.outlook.com (2603:10a6:208:c6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.28; Mon, 11 May 2020 11:08:38 +0000 Received: from AM0PR05MB6610.eurprd05.prod.outlook.com ([fe80::900:c0ac:78bd:18fc]) by AM0PR05MB6610.eurprd05.prod.outlook.com ([fe80::900:c0ac:78bd:18fc%6]) with mapi id 15.20.2958.035; Mon, 11 May 2020 11:08:38 +0000 From: Wisam Jaddo To: dev@dpdk.org, jackmin@mellanox.com, thomas@monjalon.net, jerinjacobk@gmail.com, ajit.khaparde@broadcom.com, arybchenko@solarflare.com Date: Mon, 11 May 2020 11:08:09 +0000 Message-Id: <20200511110811.11474-4-wisamm@mellanox.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200511110811.11474-1-wisamm@mellanox.com> References: <20200506123627.22340-2-wisamm@mellanox.com> <20200511110811.11474-1-wisamm@mellanox.com> X-ClientProxiedBy: PR0P264CA0122.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1a::14) To AM0PR05MB6610.eurprd05.prod.outlook.com (2603:10a6:208:12f::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mellanox.com (37.142.13.130) by PR0P264CA0122.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27 via Frontend Transport; Mon, 11 May 2020 11:08:37 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [37.142.13.130] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: b598dca0-5a6a-4df3-97c4-08d7f59ba7fd X-MS-TrafficTypeDiagnostic: AM0PR05MB4996:|AM0PR05MB4996: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1388; X-Forefront-PRVS: 04004D94E2 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8CvPPzpzHDFBceGNGnaD5dWsTZ9O2jzHRwHmND/yOPYPh+RRZWZoxiwwxBIBLCJsZzQd+5qvSbJ8sidbQmxoHKUaVZ0HzgaR6NExdxZsd3tYchwp+tzfwL7g7b6zCv4eNOtSU1qETPI5qReZfJ8Suo0dmyxuHZuYTEUllgsoB8CcpVVXWLMvak7YBkhtubEMXTtiGx+cpM7tLk72jeCCk2dxf9mCV7Wgki3BHlZBGpREYxCjFkrCS1Pf5lmYr4HJ8beYLJezJNR+NvIT9uXvdWwAsgZGSIxfDaMWNvYq8RdJDs832UA89dmrbc+1zmHQJtC8EnXDtPk/eg7IBbTJxKpLYU+U5A54Gx2nb4+gtBIyl8cycZ0dQ9C2wRxjwbdgHafLDDOxesf0nPspE0sRP/47QvTNWwdURVeU6LftoGwluB4gOVFnnXTOZQZtE0AYvF+u8ILwOPcpqUQfYNnixm+ptbul6An4RZdNOmroJjcGjnjQdljAou4NyNMaFrmYh0jZ3NEJ9JRHLodYPtywBA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR05MB6610.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(366004)(39860400002)(376002)(346002)(136003)(396003)(33430700001)(6666004)(316002)(86362001)(66476007)(66556008)(52116002)(7696005)(956004)(55016002)(66946007)(33440700001)(2616005)(1076003)(36756003)(8676002)(2906002)(8936002)(5660300002)(8886007)(26005)(16526019)(186003)(478600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: raMhLkh0HQMsfZY0X3Sgszvc4QePQogUTK6v4pmMnAOE04dMHnxgj4BZvoKd/9oQg7yxRPMj9tL7GfTzPXaF3A+QTfEkxcBM3fGECqd4FEImF0rpXPNqFMrDn7vcRwHflbkz41I/AdaoJ7KBj+fxia7bUey1zMs24A9MtXlTRaQ5xNRyGKWQD53u8zcV+N3Pg6wPYMqDG5a/7Rt283tm6e4FDdnmzl1rKs17sunDOYGpYrOZPxJYRBiGRQv8G7Nk+zCXma5IpkAnyjsYRC3yfpyM/6o7Tmv9Y3GIl/ONrN8elm50sw2CNYu3wTiZmWjM0LnVsegqW/UnP0hAFOzqeZlgdZ0Nzy0RUJra4hnGj0ekUNC1eofxZlbs6dXBPvMY7fOO9XT7DBzZWlAU6oRdDBZNxZTQh1YfMLmeuwTAlQYzbmhuMLouVVuE4qvKkA+0CgWzI5q09UCAsOPICax/5iW2cBeOmodzmheM2T88lr0= X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: b598dca0-5a6a-4df3-97c4-08d7f59ba7fd X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2020 11:08:38.6213 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ht0y2R4bCCVGhJ7LL8g9uaAUOg/jmFxljXv8LNstRRwAZqcQvv4O8oHIio2pNPM9x1389ZSG9sWizmAx6QDPOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB4996 Subject: [dpdk-dev] [PATCH v6 3/5] app/flow-perf: add deletion rate calculation 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" Add the ability to test deletion rate for flow performance application. This feature is disabled by default, and can be enabled by add "--deletion-rate" in the application command line options. Signed-off-by: Wisam Jaddo --- app/test-flow-perf/main.c | 87 ++++++++++++++++++++++++++ doc/guides/rel_notes/release_20_05.rst | 1 + doc/guides/tools/flow-perf.rst | 4 ++ 3 files changed, 92 insertions(+) diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c index 1feb73e6f..b177025fa 100644 --- a/app/test-flow-perf/main.c +++ b/app/test-flow-perf/main.c @@ -49,6 +49,7 @@ static uint32_t flow_actions; static uint32_t flow_attrs; static volatile bool force_quit; static bool dump_iterations; +static bool delete_flag; static struct rte_mempool *mbuf_mp; static uint32_t nb_lcores; static uint32_t flows_count; @@ -64,6 +65,8 @@ usage(char *progname) " flows to insert, default is 4,000,000\n"); printf(" --dump-iterations: To print rates for each" " iteration\n"); + printf(" --deletion-rate: Enable deletion rate" + " calculations\n"); printf("To set flow attributes:\n"); printf(" --ingress: set ingress attribute in flows\n"); @@ -246,6 +249,7 @@ args_parse(int argc, char **argv) { "help", 0, 0, 0 }, { "flows-count", 1, 0, 0 }, { "dump-iterations", 0, 0, 0 }, + { "deletion-rate", 0, 0, 0 }, /* Attributes */ { "ingress", 0, 0, 0 }, { "egress", 0, 0, 0 }, @@ -353,6 +357,9 @@ args_parse(int argc, char **argv) if (strcmp(lgopts[opt_idx].name, "dump-iterations") == 0) dump_iterations = true; + if (strcmp(lgopts[opt_idx].name, + "deletion-rate") == 0) + delete_flag = true; break; default: fprintf(stderr, "Invalid option: %s\n", argv[optind]); @@ -372,9 +379,75 @@ print_flow_error(struct rte_flow_error error) error.message ? error.message : "(no stated reason)"); } +static inline void +destroy_flows(int port_id, struct rte_flow **flow_list) +{ + struct rte_flow_error error; + clock_t start_iter, end_iter; + double cpu_time_used = 0; + double flows_rate; + double cpu_time_per_iter[MAX_ITERATIONS]; + double delta; + uint32_t i; + int iter_id; + + for (i = 0; i < MAX_ITERATIONS; i++) + cpu_time_per_iter[i] = -1; + + if (iterations_number > flows_count) + iterations_number = flows_count; + + /* Deletion Rate */ + printf("Flows Deletion on port = %d\n", port_id); + start_iter = clock(); + for (i = 0; i < flows_count; i++) { + if (flow_list[i] == 0) + break; + + memset(&error, 0x33, sizeof(error)); + if (rte_flow_destroy(port_id, flow_list[i], &error)) { + print_flow_error(error); + rte_exit(EXIT_FAILURE, "Error in deleting flow"); + } + + if (i && !((i + 1) % iterations_number)) { + /* Save the deletion rate of each iter */ + end_iter = clock(); + delta = (double) (end_iter - start_iter); + iter_id = ((i + 1) / iterations_number) - 1; + cpu_time_per_iter[iter_id] = + delta / CLOCKS_PER_SEC; + cpu_time_used += cpu_time_per_iter[iter_id]; + start_iter = clock(); + } + } + + /* Deletion rate per iteration */ + if (dump_iterations) + for (i = 0; i < MAX_ITERATIONS; i++) { + if (cpu_time_per_iter[i] == -1) + continue; + delta = (double)(iterations_number / + cpu_time_per_iter[i]); + flows_rate = delta / 1000; + printf(":: Iteration #%d: %d flows " + "in %f sec[ Rate = %f K/Sec ]\n", + i, iterations_number, + cpu_time_per_iter[i], flows_rate); + } + + /* Deletion rate for all flows */ + flows_rate = ((double) (flows_count / cpu_time_used) / 1000); + printf("\n:: Total flow deletion rate -> %f K/Sec\n", + flows_rate); + printf(":: The time for deleting %d in flows %f seconds\n", + flows_count, cpu_time_used); +} + static inline void flows_handler(void) { + struct rte_flow **flow_list; struct rte_flow_error error; clock_t start_iter, end_iter; double cpu_time_used; @@ -386,6 +459,7 @@ flows_handler(void) int port_id; int iter_id; uint32_t eagain_counter = 0; + uint32_t flow_index; nr_ports = rte_eth_dev_count_avail(); @@ -397,8 +471,14 @@ flows_handler(void) printf(":: Flows Count per port: %d\n", flows_count); + flow_list = rte_zmalloc("flow_list", + (sizeof(struct rte_flow *) * flows_count) + 1, 0); + if (flow_list == NULL) + rte_exit(EXIT_FAILURE, "No Memory available!"); + for (port_id = 0; port_id < nr_ports; port_id++) { cpu_time_used = 0; + flow_index = 0; if (flow_group > 0) { /* * Create global rule to jump into flow_group, @@ -417,6 +497,7 @@ flows_handler(void) print_flow_error(error); rte_exit(EXIT_FAILURE, "error in creating flow"); } + flow_list[flow_index++] = flow; } /* Insertion Rate */ @@ -440,6 +521,8 @@ flows_handler(void) rte_exit(EXIT_FAILURE, "error in creating flow"); } + flow_list[flow_index++] = flow; + if (i && !((i + 1) % iterations_number)) { /* Save the insertion rate of each iter */ end_iter = clock(); @@ -473,6 +556,9 @@ flows_handler(void) printf(":: The time for creating %d in flows %f seconds\n", flows_count, cpu_time_used); printf(":: EAGAIN counter = %d\n", eagain_counter); + + if (delete_flag) + destroy_flows(port_id, flow_list); } } @@ -631,6 +717,7 @@ main(int argc, char **argv) dump_iterations = false; flows_count = DEFAULT_RULES_COUNT; iterations_number = DEFAULT_ITERATION; + delete_flag = false; flow_group = 0; signal(SIGINT, signal_handler); diff --git a/doc/guides/rel_notes/release_20_05.rst b/doc/guides/rel_notes/release_20_05.rst index 0e4dcf1ad..e511e9c1a 100644 --- a/doc/guides/rel_notes/release_20_05.rst +++ b/doc/guides/rel_notes/release_20_05.rst @@ -218,6 +218,7 @@ New Features Application features: * Measure rte_flow insertion rate. + * Measure rte_flow deletion rate. Removed Items diff --git a/doc/guides/tools/flow-perf.rst b/doc/guides/tools/flow-perf.rst index 6f3f7dafb..1f8b1fa15 100644 --- a/doc/guides/tools/flow-perf.rst +++ b/doc/guides/tools/flow-perf.rst @@ -25,6 +25,8 @@ The current version has limitations which can be removed in future: * Support outer items up to tunnel layer only. * Single core insertion only. +The application also provide the ability to measure rte flow deletion rate. + Compiling the Application ========================= @@ -71,6 +73,8 @@ The command line options are: Print rates for each iteration of flows. Default iteration is 1,00,000. +* ``--deletion-rate`` + Enable deletion rate calculations. Attributes: From patchwork Mon May 11 11:08:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wisam Jaddo X-Patchwork-Id: 70074 X-Patchwork-Delegate: thomas@monjalon.net 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 03A05A00C5; Mon, 11 May 2020 13:09:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E52231BFF0; Mon, 11 May 2020 13:08:44 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2084.outbound.protection.outlook.com [40.107.20.84]) by dpdk.org (Postfix) with ESMTP id D8AB81C202 for ; Mon, 11 May 2020 13:08:40 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZI6gZRH5z8+4P4yD/cg0Vh5Ho7rWm5BIGnmpVNyb4Yy1ejOIw/by6FAT8PuX2Mo1djzSfQwy/BJOogY5ZYA5cYLA4oe/Onp0D+GPBiam4WPLkTWOIrg/QeJOoGXaLrf2JOYddZUZ6dQGS1gFzjyAbi6cnDSJc65eW8oxxiJXs8xHPt/HVvRMIPqCGgQPqhEfG7YFpedyt9QofMooPn+f4Mm4+EgaFImY+FdStFE2seuzYvuFWK+8KVWiBo15/Ue3G0JSGJcurR5uaVFJB6NraWc/kZSX+FWPKjmx0U+Yo+YzzWtkBs/rbtUeNypGFcIouj/G6lR0Pm8goHcP1LHb3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BqjpVC0uEMDDz9VqacPj3Gegqb60Vpq0T3WlHEn7JYw=; b=eY4k/olcyahYqOpy68npzOpQ2AmIyyMp50ubIdF+Yfe7Zma7wodEIFEQWiQOwkDNWoHJ+i63DYt+dDyF+PNPEThQKA60U07RK7KNAGtE//yNhSZVOx4/gvmvYBs6RiAUicuSWWNHsL6UeVh2LUwV9feyZ3CcJvEIfeqJjgv1BF8wOUuc32Q3MYYDlYzkPbAVOZic6yuG/RwhGVNgmyGd5Q41ta1EfcxlZ/JQzk8bkbdnaIbcBIYG+lD7l7Un6b525s7iTYyU1KccJJahdolMk0iQvkcBrNi0py3zZoZ5h+fWfwKYkJzwM4pg8jrtosa3I4/0FwTFO338ScHumvATLA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BqjpVC0uEMDDz9VqacPj3Gegqb60Vpq0T3WlHEn7JYw=; b=WwjAp0K/AHa+/0MN9Nyi4Z8XorXdp/SwR8E0q7eXKk1lzTULNGVatpIvalhnI/cTGMEdj9yEj63V3MsdIn+DdYYlwK0oie7um+eEVW63ewEQcOQpDDWk5yLDEaJ2jrSTHqnSagID0h2dsiD3769Z7TnceeUvDcQvnldUfqQREDU= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=mellanox.com; Received: from AM0PR05MB6610.eurprd05.prod.outlook.com (2603:10a6:208:12f::18) by AM0PR05MB4996.eurprd05.prod.outlook.com (2603:10a6:208:c6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.28; Mon, 11 May 2020 11:08:39 +0000 Received: from AM0PR05MB6610.eurprd05.prod.outlook.com ([fe80::900:c0ac:78bd:18fc]) by AM0PR05MB6610.eurprd05.prod.outlook.com ([fe80::900:c0ac:78bd:18fc%6]) with mapi id 15.20.2958.035; Mon, 11 May 2020 11:08:39 +0000 From: Wisam Jaddo To: dev@dpdk.org, jackmin@mellanox.com, thomas@monjalon.net, jerinjacobk@gmail.com, ajit.khaparde@broadcom.com, arybchenko@solarflare.com Cc: Suanming Mou Date: Mon, 11 May 2020 11:08:10 +0000 Message-Id: <20200511110811.11474-5-wisamm@mellanox.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200511110811.11474-1-wisamm@mellanox.com> References: <20200506123627.22340-2-wisamm@mellanox.com> <20200511110811.11474-1-wisamm@mellanox.com> X-ClientProxiedBy: PR0P264CA0122.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1a::14) To AM0PR05MB6610.eurprd05.prod.outlook.com (2603:10a6:208:12f::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mellanox.com (37.142.13.130) by PR0P264CA0122.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27 via Frontend Transport; Mon, 11 May 2020 11:08:38 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [37.142.13.130] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 99a0ff8b-9d9b-44c0-f238-08d7f59ba8c0 X-MS-TrafficTypeDiagnostic: AM0PR05MB4996:|AM0PR05MB4996: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2512; X-Forefront-PRVS: 04004D94E2 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Au6AjU6piFwAuENGiibhB28gRCt9QmE0IK6ZR4ns2k3+9N2XYATWuQ0sN3Ul82PAoLtsR0rdoFXmQq1gS67e2brLdM4B1eNGqgoRCTJDYukmFfVUbkWqjDf6IttXk9zu3l3ueB3FIckr4XcfjvZI1y6mIZqwK13FvtcHYCaWnpEaqmueFUg6GR+RwTcnz4849/Af29fLmI6+/Xx2OpVPRtpsprad7bISgl/+riuDou1vdfsyNZh6NqAuhbsj88wvOKimraIZrhtz/BjUYXMKIjZz8id3sbgoOcSdxowjtYExn0fqZjp/qFc1LwE9Z8okZq/+c0grLmhtxr73Ip8lH+lsgaGW/tTb0QjzVgCKtwWGet/WgD8Q7fjQwM8tJfsfRmtMhqkaw9W33D8SAjVx81FZHmhZZnH+W1OO5ryHj5TUmgHwjat8HMYdqhoilLYBHqdzNB7ozGpGFqaDdHOrg7XsUDB90xLofOpxR4W4HLBHifaM8Qd6FbO/iE9t2zzmrBvTnwGdI8RvG2xpWQpmEQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR05MB6610.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(366004)(39860400002)(376002)(346002)(136003)(396003)(33430700001)(6666004)(107886003)(316002)(86362001)(66476007)(66556008)(52116002)(7696005)(956004)(55016002)(66946007)(33440700001)(2616005)(1076003)(36756003)(8676002)(2906002)(8936002)(5660300002)(8886007)(26005)(16526019)(186003)(4326008)(478600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 4+90/HsTOSX5DJFxT9kUrE31WLqAn0JHgnzQO3dehOnmuYIWKbH4l9412xLmmvQZ9Dm/OE801kJTuqbWJPg7kGMj9V1dgISPqPBzIJK3HfXn8Q4vS+kRM5zsqX57aUszxWmQfmR5ABftaaMXjEitsOMjRRLVqDmJeGpLvsim9PWIDbRqbfU54eReAdpYYsRWjgx4Dzrs2593AujpccWg+a9KV6Edn4L9pwlAQVPiA9tpKBSdy3Mc51o5Y9bOp5aYmB8AuZ4lr0/oA1UpJm5Na0kh7hChUE+W3KUUZvVoFGgqOU8CDVKUc2LwSKBhNTtPvN3nFDlSzU8brekoO92qDviI58q1D8fpEfus0O+L/iT+JYvhgXZt4XICOa70UQ+6FAC41h1z0TbEAQzdBwJOBjXjhkKpSjUctm0KEFiZYIS5Dkik298qQ1jcG8oPoqjVlQReNdY3nGmR0qObr4nMeHvBpzDJlDygwPkPK4jzvrE= X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99a0ff8b-9d9b-44c0-f238-08d7f59ba8c0 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2020 11:08:39.8516 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BUzP0JH4mVCYxjtTJaxsK4h4JZoncg114ox9saTtjp76OoHj8nwj2dgKIloa6AULEM9e5kD6RvcIv7MG1awWgg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB4996 Subject: [dpdk-dev] [PATCH v6 4/5] app/flow-perf: add memory dump to app 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" Introduce new feature to dump memory statistics of each socket and a total for all before and after the creation. This will give two main advantage: 1- Check the memory consumption for large number of flows "insertion rate scenario alone" 2- Check that no memory leackage after doing insertion then deletion. Signed-off-by: Suanming Mou Signed-off-by: Wisam Jaddo --- app/test-flow-perf/main.c | 72 +++++++++++++++++++++++++- doc/guides/rel_notes/release_20_05.rst | 1 + doc/guides/tools/flow-perf.rst | 6 ++- 3 files changed, 77 insertions(+), 2 deletions(-) diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c index b177025fa..da54bbdef 100644 --- a/app/test-flow-perf/main.c +++ b/app/test-flow-perf/main.c @@ -49,7 +49,8 @@ static uint32_t flow_actions; static uint32_t flow_attrs; static volatile bool force_quit; static bool dump_iterations; -static bool delete_flag; +static bool delete_flag; +static bool dump_socket_mem_flag; static struct rte_mempool *mbuf_mp; static uint32_t nb_lcores; static uint32_t flows_count; @@ -67,6 +68,7 @@ usage(char *progname) " iteration\n"); printf(" --deletion-rate: Enable deletion rate" " calculations\n"); + printf(" --dump-socket-mem: To dump all socket memory\n"); printf("To set flow attributes:\n"); printf(" --ingress: set ingress attribute in flows\n"); @@ -250,6 +252,7 @@ args_parse(int argc, char **argv) { "flows-count", 1, 0, 0 }, { "dump-iterations", 0, 0, 0 }, { "deletion-rate", 0, 0, 0 }, + { "dump-socket-mem", 0, 0, 0 }, /* Attributes */ { "ingress", 0, 0, 0 }, { "egress", 0, 0, 0 }, @@ -360,6 +363,9 @@ args_parse(int argc, char **argv) if (strcmp(lgopts[opt_idx].name, "deletion-rate") == 0) delete_flag = true; + if (strcmp(lgopts[opt_idx].name, + "dump-socket-mem") == 0) + dump_socket_mem_flag = true; break; default: fprintf(stderr, "Invalid option: %s\n", argv[optind]); @@ -371,6 +377,62 @@ args_parse(int argc, char **argv) printf("end_flow\n"); } +/* Dump the socket memory statistics on console */ +static size_t +dump_socket_mem(FILE *f) +{ + struct rte_malloc_socket_stats socket_stats; + unsigned int i = 0; + size_t total = 0; + size_t alloc = 0; + size_t free = 0; + unsigned int n_alloc = 0; + unsigned int n_free = 0; + bool active_nodes = false; + + + for (i = 0; i < RTE_MAX_NUMA_NODES; i++) { + if (rte_malloc_get_socket_stats(i, &socket_stats) || + !socket_stats.heap_totalsz_bytes) + continue; + active_nodes = true; + total += socket_stats.heap_totalsz_bytes; + alloc += socket_stats.heap_allocsz_bytes; + free += socket_stats.heap_freesz_bytes; + n_alloc += socket_stats.alloc_count; + n_free += socket_stats.free_count; + if (dump_socket_mem_flag) { + fprintf(f, "::::::::::::::::::::::::::::::::::::::::"); + fprintf(f, + "\nSocket %u:\nsize(M) total: %.6lf\nalloc:" + " %.6lf(%.3lf%%)\nfree: %.6lf" + "\nmax: %.6lf" + "\ncount alloc: %u\nfree: %u\n", + i, + socket_stats.heap_totalsz_bytes / 1.0e6, + socket_stats.heap_allocsz_bytes / 1.0e6, + (double)socket_stats.heap_allocsz_bytes * 100 / + (double)socket_stats.heap_totalsz_bytes, + socket_stats.heap_freesz_bytes / 1.0e6, + socket_stats.greatest_free_size / 1.0e6, + socket_stats.alloc_count, + socket_stats.free_count); + fprintf(f, "::::::::::::::::::::::::::::::::::::::::"); + } + } + if (dump_socket_mem_flag && active_nodes) { + fprintf(f, + "\nTotal: size(M)\ntotal: %.6lf" + "\nalloc: %.6lf(%.3lf%%)\nfree: %.6lf" + "\ncount alloc: %u\nfree: %u\n", + total / 1.0e6, alloc / 1.0e6, + (double)alloc * 100 / (double)total, free / 1.0e6, + n_alloc, n_free); + fprintf(f, "::::::::::::::::::::::::::::::::::::::::\n"); + } + return alloc; +} + static void print_flow_error(struct rte_flow_error error) { @@ -708,6 +770,7 @@ main(int argc, char **argv) int ret; uint16_t port; struct rte_flow_error error; + int64_t alloc, last_alloc; ret = rte_eal_init(argc, argv); if (ret < 0) @@ -718,6 +781,7 @@ main(int argc, char **argv) flows_count = DEFAULT_RULES_COUNT; iterations_number = DEFAULT_ITERATION; delete_flag = false; + dump_socket_mem_flag = false; flow_group = 0; signal(SIGINT, signal_handler); @@ -734,7 +798,13 @@ main(int argc, char **argv) if (nb_lcores <= 1) rte_exit(EXIT_FAILURE, "This app needs at least two cores\n"); + last_alloc = (int64_t)dump_socket_mem(stdout); flows_handler(); + alloc = (int64_t)dump_socket_mem(stdout); + + if (last_alloc) + fprintf(stdout, ":: Memory allocation change(M): %.6lf\n", + (alloc - last_alloc) / 1.0e6); RTE_ETH_FOREACH_DEV(port) { rte_flow_flush(port, &error); diff --git a/doc/guides/rel_notes/release_20_05.rst b/doc/guides/rel_notes/release_20_05.rst index e511e9c1a..aae1c5492 100644 --- a/doc/guides/rel_notes/release_20_05.rst +++ b/doc/guides/rel_notes/release_20_05.rst @@ -219,6 +219,7 @@ New Features Application features: * Measure rte_flow insertion rate. * Measure rte_flow deletion rate. + * Dump rte_flow memory consumption. Removed Items diff --git a/doc/guides/tools/flow-perf.rst b/doc/guides/tools/flow-perf.rst index 1f8b1fa15..c8cce187e 100644 --- a/doc/guides/tools/flow-perf.rst +++ b/doc/guides/tools/flow-perf.rst @@ -25,7 +25,8 @@ The current version has limitations which can be removed in future: * Support outer items up to tunnel layer only. * Single core insertion only. -The application also provide the ability to measure rte flow deletion rate. +The application also provide the ability to measure rte flow deletion rate, +in addition to memory consumption before and after the flows creation. Compiling the Application @@ -76,6 +77,9 @@ The command line options are: * ``--deletion-rate`` Enable deletion rate calculations. +* ``--dump-socket-mem`` + Dump the memory stats for each socket before the insertion and after. + Attributes: * ``--ingress`` From patchwork Mon May 11 11:08:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wisam Jaddo X-Patchwork-Id: 70075 X-Patchwork-Delegate: thomas@monjalon.net 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 C3908A00C5; Mon, 11 May 2020 13:09:33 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 720EC1C300; Mon, 11 May 2020 13:08:46 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2080.outbound.protection.outlook.com [40.107.20.80]) by dpdk.org (Postfix) with ESMTP id E90471C222 for ; Mon, 11 May 2020 13:08:42 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eipvBrX91bMRvucJV5Yxki48YN5p2/TKhV7/0yAo+6ccQEMgET0HjP9jPLaa2aiAj878+Lx/jHpaXxhWG5R4BajdbeynzHWOmQF+gFHtG2+HixdD5jAgnV++PE9U9Gs19NPEzqyCoZSZXGb7ROgm8M7wgF8Cu1lNqFsOc39PEGo3hHbWbbH5RmkITVjmyvYmMJyS3DPIwEbs4HpidXGF5ABj2Hp/o2vgg5NJlyX3rUPp/UPXclCLykrhYGS8ZTfpv6IuXc+OvGVFu1ixe5alGoza2VXG6M8BL4ywBAeYTglV2n5V4dx2A/1K8r7lWR+px3GjcXQD7FtPyHkmBx08bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Cm+SDpDyg1/c12iw7cq+GcSu7LuU9xAY0Kc2jOknBbQ=; b=U1EPJNs4e7jfE1vg2TUM422scFzwotExq3TpniHM29cmFFIIIFiiFbe/QssQO75TIOIuvNHjlk2UJsgrXMGTruLfV519Fup5gMP7tCD52MZNJiUaK5C3tdxQz9Zft6ZpogDizb3SbJoG5vxfISdMX7lJRc5qbemKqA5HsgH5/8IgAC0Dl0t8XMVS14a2rVKBvuvGsLG4JU5jvVmOLNij3xBVk9/56782emJKgvRJf7XUOLOeBb3IBIpiisRM3t/US7YtnSvoADceqCru+BzghyGNw2xROhCHWdnw/58iDj+hct7dEnD81PFUwG4HyWfBdju0BE9W0/ggftYP0JYmYA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Cm+SDpDyg1/c12iw7cq+GcSu7LuU9xAY0Kc2jOknBbQ=; b=ZM/Heia7c/feBWePE8cUk4re32TuQmhylnXhYXE7omohxsTiEDzQGCw8EgQ4l3hV+4tAZKaG+9lld9WO7stEAjj+mmVhBNzyXbLaLMmD7DZ+FySYky2eiAGLugad2XhSsyOXrO7xUlm8UjmhGcsDMVv05i85ndwbCysQHGPhrIs= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=mellanox.com; Received: from AM0PR05MB6610.eurprd05.prod.outlook.com (2603:10a6:208:12f::18) by AM0PR05MB4996.eurprd05.prod.outlook.com (2603:10a6:208:c6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.28; Mon, 11 May 2020 11:08:41 +0000 Received: from AM0PR05MB6610.eurprd05.prod.outlook.com ([fe80::900:c0ac:78bd:18fc]) by AM0PR05MB6610.eurprd05.prod.outlook.com ([fe80::900:c0ac:78bd:18fc%6]) with mapi id 15.20.2958.035; Mon, 11 May 2020 11:08:41 +0000 From: Wisam Jaddo To: dev@dpdk.org, jackmin@mellanox.com, thomas@monjalon.net, jerinjacobk@gmail.com, ajit.khaparde@broadcom.com, arybchenko@solarflare.com Date: Mon, 11 May 2020 11:08:11 +0000 Message-Id: <20200511110811.11474-6-wisamm@mellanox.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200511110811.11474-1-wisamm@mellanox.com> References: <20200506123627.22340-2-wisamm@mellanox.com> <20200511110811.11474-1-wisamm@mellanox.com> X-ClientProxiedBy: PR0P264CA0122.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1a::14) To AM0PR05MB6610.eurprd05.prod.outlook.com (2603:10a6:208:12f::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mellanox.com (37.142.13.130) by PR0P264CA0122.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27 via Frontend Transport; Mon, 11 May 2020 11:08:40 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [37.142.13.130] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 7f413a6f-2ff6-461b-51c4-08d7f59ba979 X-MS-TrafficTypeDiagnostic: AM0PR05MB4996:|AM0PR05MB4996: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:295; X-Forefront-PRVS: 04004D94E2 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6hPffXaz3N3yW4S0zaLWNp7YhXkWTxiIrgGrzt8Z25eeLGzaxmGHmmDTeCzSxynpswFoA0Faje3PMeMA3IaRkMFfo3BGtodc+9sMgXFHDuTbCYN2vdG/y9SCryC1TLZbEbBw6oXWtbd6qVFCmV+ZaWb1wO8XhEd2rPfi0THLlRcS69YLXPvXTuVe2lFZ+Ts8wRxwTq0ck+XwjeOP/myR8lgw9swxCuhP0Q3OGX46ucMVXtReBfhVzwb3LRmjm4if2iWLklFUe7VIKHpM+EvyL2jUxcyKjwao9h7dST6psvlLkLrJX2glkVGmlK9SrO+fFWC3Y9c4dL7suVU5QoJ4gsWPVE3bJogfnbAmVaYQTTqWyVZCqbc7d5J7EJu5DKW2pg2IAUaVAR8/lee2ENA2xhHSLFOjaRjDVs8jzsxs8QWJv+lNH2SHFuJ2WmJHv3Gc9vEUqtx9d5M1hOP6eTl4ESKPxBNTGX3V2W3aBPhxLTFC9eExJhKeGXgWX0FxoAoNM0Aq/rtar8mXKRhlKpK3ZQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR05MB6610.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(366004)(39860400002)(376002)(346002)(136003)(396003)(33430700001)(6666004)(316002)(86362001)(66476007)(66556008)(52116002)(30864003)(7696005)(956004)(55016002)(66946007)(33440700001)(2616005)(1076003)(36756003)(8676002)(2906002)(8936002)(5660300002)(8886007)(26005)(16526019)(186003)(478600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: EH/pZKiiET6TSxax+2Ki1PE4hcBPBsZxcheWV0+nvSn3WOL42CjtOI619BM/a7XJhl56sr83XRhuyItSLRxk+t6oCtl3j/dIsG/4dwwbd8ow2tLBr22ixSJoiLiIb1czo0w8N/PS6cNPycB/KYqSmzAXZdSdh0CY2vdFeNXo+Rzn5NqoR8TdLxTXIWBi/Wn/Nw2I+xipLudxjTeGDinfOFjSWroLpoNSHBmLv6uef95wWW3YbpxeB8g7XSdxpno4anTIpVQP4NvYal/6xIxmgf+d3gbBgYCC0wQum8BxpNv/VOUfDwLNJQveQwcfHQw9pz4XOXhhxU3F6L4biT18cXGgg5gWqWdfVVM83uXRSB2jCAj4zenFEn5Okk4UHWkJ70MtyAutzVYpZRKCYWYxp6K0QsmdqDSUpmKEg8EUgm3ky18Wt0z/R9+Q4tF4L7QbIhMCp31549CkNDElp1aMWBzE8buM3l76p+CQPlADIjY= X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7f413a6f-2ff6-461b-51c4-08d7f59ba979 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2020 11:08:41.7385 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: v8iBNcrrXi+CZQwsJpKruGjNZe+4fcT82hsxwwfFU4H8vjvTJmBapagN4aWdBdYk/oCCr/z1xVGcDgufqrruBg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB4996 Subject: [dpdk-dev] [PATCH v6 5/5] app/flow-perf: add packet forwarding support 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" Introduce packet forwarding support to the app to do some performance measurements. The measurements are reported in term of packet per second unit. The forwarding will start after the end of insertion/deletion operations. The support has single and multi performance measurements. Signed-off-by: Wisam Jaddo --- app/test-flow-perf/main.c | 301 +++++++++++++++++++++++++ doc/guides/rel_notes/release_20_05.rst | 1 + doc/guides/tools/flow-perf.rst | 6 + 3 files changed, 308 insertions(+) diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c index da54bbdef..3918cc132 100644 --- a/app/test-flow-perf/main.c +++ b/app/test-flow-perf/main.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -47,15 +48,45 @@ static uint8_t flow_group; static uint32_t flow_items; static uint32_t flow_actions; static uint32_t flow_attrs; + static volatile bool force_quit; static bool dump_iterations; static bool delete_flag; static bool dump_socket_mem_flag; +static bool enable_fwd; + static struct rte_mempool *mbuf_mp; static uint32_t nb_lcores; static uint32_t flows_count; static uint32_t iterations_number; static uint32_t hairpinq; +static uint32_t nb_lcores; + +#define MAX_PKT_BURST 32 +#define LCORE_MODE_PKT 1 +#define LCORE_MODE_STATS 2 +#define MAX_STREAMS 64 +#define MAX_LCORES 64 + +struct stream { + int tx_port; + int tx_queue; + int rx_port; + int rx_queue; +}; + +struct lcore_info { + int mode; + int streams_nb; + struct stream streams[MAX_STREAMS]; + /* stats */ + uint64_t tx_pkts; + uint64_t tx_drops; + uint64_t rx_pkts; + struct rte_mbuf *pkts[MAX_PKT_BURST]; +} __attribute__((__aligned__(64))); /* let it be cacheline aligned */ + +static struct lcore_info lcore_infos[MAX_LCORES]; static void usage(char *progname) @@ -69,6 +100,8 @@ usage(char *progname) printf(" --deletion-rate: Enable deletion rate" " calculations\n"); printf(" --dump-socket-mem: To dump all socket memory\n"); + printf(" --enable-fwd: To enable packets forwarding" + " after insertion\n"); printf("To set flow attributes:\n"); printf(" --ingress: set ingress attribute in flows\n"); @@ -253,6 +286,7 @@ args_parse(int argc, char **argv) { "dump-iterations", 0, 0, 0 }, { "deletion-rate", 0, 0, 0 }, { "dump-socket-mem", 0, 0, 0 }, + { "enable-fwd", 0, 0, 0 }, /* Attributes */ { "ingress", 0, 0, 0 }, { "egress", 0, 0, 0 }, @@ -366,6 +400,9 @@ args_parse(int argc, char **argv) if (strcmp(lgopts[opt_idx].name, "dump-socket-mem") == 0) dump_socket_mem_flag = true; + if (strcmp(lgopts[opt_idx].name, + "enable-fwd") == 0) + enable_fwd = true; break; default: fprintf(stderr, "Invalid option: %s\n", argv[optind]); @@ -635,6 +672,265 @@ signal_handler(int signum) } } +static inline uint16_t +do_rx(struct lcore_info *li, uint16_t rx_port, uint16_t rx_queue) +{ + uint16_t cnt = 0; + cnt = rte_eth_rx_burst(rx_port, rx_queue, li->pkts, MAX_PKT_BURST); + li->rx_pkts += cnt; + return cnt; +} + +static inline void +do_tx(struct lcore_info *li, uint16_t cnt, uint16_t tx_port, + uint16_t tx_queue) +{ + uint16_t nr_tx = 0; + uint16_t i; + + nr_tx = rte_eth_tx_burst(tx_port, tx_queue, li->pkts, cnt); + li->tx_pkts += nr_tx; + li->tx_drops += cnt - nr_tx; + + for (i = nr_tx; i < cnt; i++) + rte_pktmbuf_free(li->pkts[i]); +} + +/* + * Method to convert numbers into pretty numbers that easy + * to read. The design here is to add comma after each three + * digits and set all of this inside buffer. + * + * For example if n = 1799321, the output will be + * 1,799,321 after this method which is easier to read. + */ +static char * +pretty_number(uint64_t n, char *buf) +{ + char p[6][4]; + int i = 0; + int off = 0; + + while (n > 1000) { + sprintf(p[i], "%03d", (int)(n % 1000)); + n /= 1000; + i += 1; + } + + sprintf(p[i++], "%d", (int)n); + + while (i--) + off += sprintf(buf + off, "%s,", p[i]); + buf[strlen(buf) - 1] = '\0'; + + return buf; +} + +static void +packet_per_second_stats(void) +{ + struct lcore_info *old; + struct lcore_info *li, *oli; + int nr_lines = 0; + int i; + + old = rte_zmalloc("old", + sizeof(struct lcore_info) * MAX_LCORES, 0); + if (old == NULL) + rte_exit(EXIT_FAILURE, "No Memory available!"); + + memcpy(old, lcore_infos, + sizeof(struct lcore_info) * MAX_LCORES); + + while (!force_quit) { + uint64_t total_tx_pkts = 0; + uint64_t total_rx_pkts = 0; + uint64_t total_tx_drops = 0; + uint64_t tx_delta, rx_delta, drops_delta; + char buf[3][32]; + int nr_valid_core = 0; + + sleep(1); + + if (nr_lines) { + char go_up_nr_lines[16]; + + sprintf(go_up_nr_lines, "%c[%dA\r", 27, nr_lines); + printf("%s\r", go_up_nr_lines); + } + + printf("\n%6s %16s %16s %16s\n", "core", "tx", "tx drops", "rx"); + printf("%6s %16s %16s %16s\n", "------", "----------------", + "----------------", "----------------"); + nr_lines = 3; + for (i = 0; i < MAX_LCORES; i++) { + li = &lcore_infos[i]; + oli = &old[i]; + if (li->mode != LCORE_MODE_PKT) + continue; + + tx_delta = li->tx_pkts - oli->tx_pkts; + rx_delta = li->rx_pkts - oli->rx_pkts; + drops_delta = li->tx_drops - oli->tx_drops; + printf("%6d %16s %16s %16s\n", i, + pretty_number(tx_delta, buf[0]), + pretty_number(drops_delta, buf[1]), + pretty_number(rx_delta, buf[2])); + + total_tx_pkts += tx_delta; + total_rx_pkts += rx_delta; + total_tx_drops += drops_delta; + + nr_valid_core++; + nr_lines += 1; + } + + if (nr_valid_core > 1) { + printf("%6s %16s %16s %16s\n", "total", + pretty_number(total_tx_pkts, buf[0]), + pretty_number(total_tx_drops, buf[1]), + pretty_number(total_rx_pkts, buf[2])); + nr_lines += 1; + } + + memcpy(old, lcore_infos, + sizeof(struct lcore_info) * MAX_LCORES); + } +} + +static int +start_forwarding(void *data __rte_unused) +{ + int lcore = rte_lcore_id(); + int stream_id; + uint16_t cnt; + struct lcore_info *li = &lcore_infos[lcore]; + + if (!li->mode) + return 0; + + if (li->mode == LCORE_MODE_STATS) { + printf(":: started stats on lcore %u\n", lcore); + packet_per_second_stats(); + return 0; + } + + while (!force_quit) + for (stream_id = 0; stream_id < MAX_STREAMS; stream_id++) { + if (li->streams[stream_id].rx_port == -1) + continue; + + cnt = do_rx(li, + li->streams[stream_id].rx_port, + li->streams[stream_id].rx_queue); + if (cnt) + do_tx(li, cnt, + li->streams[stream_id].tx_port, + li->streams[stream_id].tx_queue); + } + return 0; +} + +static void +init_lcore_info(void) +{ + int i, j; + unsigned int lcore; + uint16_t nr_port; + uint16_t queue; + int port; + int stream_id = 0; + int streams_per_core; + int unassigned_streams; + int nb_fwd_streams; + nr_port = rte_eth_dev_count_avail(); + + /* First logical core is reserved for stats printing */ + lcore = rte_get_next_lcore(-1, 0, 0); + lcore_infos[lcore].mode = LCORE_MODE_STATS; + + /* + * Initialize all cores + * All cores at first must have -1 value in all streams + * This means that this stream is not used, or not set + * yet. + */ + for (i = 0; i < MAX_LCORES; i++) + for (j = 0; j < MAX_STREAMS; j++) { + lcore_infos[i].streams[j].tx_port = -1; + lcore_infos[i].streams[j].rx_port = -1; + lcore_infos[i].streams[j].tx_queue = -1; + lcore_infos[i].streams[j].rx_queue = -1; + lcore_infos[i].streams_nb = 0; + } + + /* + * Calculate the total streams count. + * Also distribute those streams count between the available + * logical cores except first core, since it's reserved for + * stats prints. + */ + nb_fwd_streams = nr_port * RXQ_NUM; + if ((int)(nb_lcores - 1) >= nb_fwd_streams) + for (i = 0; i < (int)(nb_lcores - 1); i++) { + lcore = rte_get_next_lcore(lcore, 0, 0); + lcore_infos[lcore].streams_nb = 1; + } + else { + streams_per_core = nb_fwd_streams / (nb_lcores - 1); + unassigned_streams = nb_fwd_streams % (nb_lcores - 1); + for (i = 0; i < (int)(nb_lcores - 1); i++) { + lcore = rte_get_next_lcore(lcore, 0, 0); + lcore_infos[lcore].streams_nb = streams_per_core; + if (unassigned_streams) { + lcore_infos[lcore].streams_nb++; + unassigned_streams--; + } + } + } + + /* + * Set the streams for the cores according to each logical + * core stream count. + * The streams is built on the design of what received should + * forward as well, this means that if you received packets on + * port 0 queue 0 then the same queue should forward the + * packets, using the same logical core. + */ + lcore = rte_get_next_lcore(-1, 0, 0); + for (port = 0; port < nr_port; port++) { + /* Create FWD stream */ + for (queue = 0; queue < RXQ_NUM; queue++) { + if (!lcore_infos[lcore].streams_nb || + !(stream_id % lcore_infos[lcore].streams_nb)) { + lcore = rte_get_next_lcore(lcore, 0, 0); + lcore_infos[lcore].mode = LCORE_MODE_PKT; + stream_id = 0; + } + lcore_infos[lcore].streams[stream_id].rx_queue = queue; + lcore_infos[lcore].streams[stream_id].tx_queue = queue; + lcore_infos[lcore].streams[stream_id].rx_port = port; + lcore_infos[lcore].streams[stream_id].tx_port = port; + stream_id++; + } + } + + /* Print all streams */ + printf(":: Stream -> core id[N]: (rx_port, rx_queue)->(tx_port, tx_queue)\n"); + for (i = 0; i < MAX_LCORES; i++) + for (j = 0; j < MAX_STREAMS; j++) { + /* No streams for this core */ + if (lcore_infos[i].streams[j].tx_port == -1) + break; + printf("Stream -> core id[%d]: (%d,%d)->(%d,%d)\n", + i, + lcore_infos[i].streams[j].rx_port, + lcore_infos[i].streams[j].rx_queue, + lcore_infos[i].streams[j].tx_port, + lcore_infos[i].streams[j].tx_queue); + } +} + static void init_port(void) { @@ -806,6 +1102,11 @@ main(int argc, char **argv) fprintf(stdout, ":: Memory allocation change(M): %.6lf\n", (alloc - last_alloc) / 1.0e6); + if (enable_fwd) { + init_lcore_info(); + rte_eal_mp_remote_launch(start_forwarding, NULL, CALL_MASTER); + } + RTE_ETH_FOREACH_DEV(port) { rte_flow_flush(port, &error); rte_eth_dev_stop(port); diff --git a/doc/guides/rel_notes/release_20_05.rst b/doc/guides/rel_notes/release_20_05.rst index aae1c5492..258b1e03e 100644 --- a/doc/guides/rel_notes/release_20_05.rst +++ b/doc/guides/rel_notes/release_20_05.rst @@ -220,6 +220,7 @@ New Features * Measure rte_flow insertion rate. * Measure rte_flow deletion rate. * Dump rte_flow memory consumption. + * Measure packet per second forwarding. Removed Items diff --git a/doc/guides/tools/flow-perf.rst b/doc/guides/tools/flow-perf.rst index c8cce187e..6eb3080a3 100644 --- a/doc/guides/tools/flow-perf.rst +++ b/doc/guides/tools/flow-perf.rst @@ -28,6 +28,8 @@ The current version has limitations which can be removed in future: The application also provide the ability to measure rte flow deletion rate, in addition to memory consumption before and after the flows creation. +The app supports single and multi core performance measurements. + Compiling the Application ========================= @@ -80,6 +82,10 @@ The command line options are: * ``--dump-socket-mem`` Dump the memory stats for each socket before the insertion and after. +* ``enable-fwd`` + Enable packets forwarding after insertion/deletion operations. + + Attributes: * ``--ingress``