From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4C714A0C4D; Wed, 21 Jul 2021 09:06:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B2A14410DB; Wed, 21 Jul 2021 09:05:59 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2070.outbound.protection.outlook.com [40.107.223.70]) by mails.dpdk.org (Postfix) with ESMTP id E9459410DA for ; Wed, 21 Jul 2021 09:05:57 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lnM6dywJLQ7zyWttUTdwJ+76F71QTusYjqeFdyFYhaTD3raKhlcBk+MdbyuuoMg/TVZxdu0dP9Dh6UdiUP7+u/Rw57J+dfIArSG80cnJvLPCgiXL6S56PSN3yoRRmplevZYRu1X9PmG42HCx19x9OXtT2SuZ7fObpMo5d3pv0OY8HbXOrFmIl620Gcg1Yq7xFCmnIWkWYbHbj/e5pI6rG1zSpRc9nU88RptaPIrBZTJsZ2a/gS8z7V7IHIi+/78BOhODS6AbgpHoQ66e+/lteld23F5P29S/kIMq5jZzU+Xb/zFpQuln+wQMHc4dNk2+G5MdzuWUEyAnsmkWc7iXuA== 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=0m80+RElsjfkjoRdusHj5jjCU/zdPovxlmaK1uk79cs=; b=XJjRyt3RJ1vnjfAnoITk4bzjlkPRFKejochadJtMXBJbo3+8vYzrRI5lVIxXZKkbA9cq361v4zHX9sZJb2ITr11kQn8UMptk5XHxMuufem5rpW6Tq4g9VAyKpWvJbzezqO0c6llER2kFQnMqViJtSzPq9iz/HNaBcqjZSWVOOsZA+HmXQYP2j7lq70vPGnfTd+JYHcC4fMoi1WXxQ+lkUsGEUt9I9qEQT0i0xK7+EsLa+4y0hTqkso+MMB5OOhOjX4FO+a04E2PNJCXeOYt5mgrOPEzSTyWfv2Z8LYpZJzejuT1En5jlokhJPlJNNjUzijM4khx3WV37lxD576tkyg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0m80+RElsjfkjoRdusHj5jjCU/zdPovxlmaK1uk79cs=; b=cbStBfUwYFmxBWfdDySnjcaUQGRbvRLNwvLCAR2y3ojrPikao9Fv7mUI9bsXlNyU2h+jvK+QNMVO9DGj6at70b9t6bFqhvtb2ebs+qfSEFWeOt/AVKvDkfUIOU+rdsBUzI98280u0YRVDhR2n+HO1wy8jBmU2CCYYHyd08xQoNk4NAn5yh+xsAbz4muyHg9116Vx9xT8v2pEfsT2CDzTXb8B+7RtvQpfh+Tlx6RgDyxlqPhM4Uj7Qgul6ZmGY5heQyqOc+f6GJb7K8amnMWDQqkmm0LSt8zLVJ5BrsisuhsdWaGLz2yvdmcJt2ZDeBZwhhixeGCrlR0n3DC4VAdmQw== Received: from BN6PR22CA0041.namprd22.prod.outlook.com (2603:10b6:404:37::27) by DM5PR12MB1372.namprd12.prod.outlook.com (2603:10b6:3:77::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.26; Wed, 21 Jul 2021 07:05:56 +0000 Received: from BN8NAM11FT034.eop-nam11.prod.protection.outlook.com (2603:10b6:404:37:cafe::a5) by BN6PR22CA0041.outlook.office365.com (2603:10b6:404:37::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Wed, 21 Jul 2021 07:05:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT034.mail.protection.outlook.com (10.13.176.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4352.24 via Frontend Transport; Wed, 21 Jul 2021 07:05:55 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 21 Jul 2021 07:05:53 +0000 From: Rongwei Liu To: , , , , Wisam Jaddo CC: , , Haifei Luo , Jiawei Wang Date: Wed, 21 Jul 2021 10:05:40 +0300 Message-ID: <20210721070542.1153843-2-rongweil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210721070542.1153843-1-rongweil@nvidia.com> References: <1617691848-94564-1-git-send-email-haifeil@nvidia.com> <20210721070542.1153843-1-rongweil@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 306315f8-3e02-416b-24d2-08d94c15fc47 X-MS-TrafficTypeDiagnostic: DM5PR12MB1372: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:75; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4TitjYtprjfbHvv1EBHvDCoLDhd80r3SeMjLlKILbx5RqdFy++Hi9xzTHIt9Zs/RpteO4eddAONyFbkXXlzB+7bPzaDXuP+YIyDkEkjuyYoAFKQ77zh7FxYBkL5uc3Y8tPgODjBJpko2y+ejcCgD6hcl8deWVyEEsU/G7YL6sdTsBsJCUJ2XJRS9sidUG6Twv+fxRxCfsmsugvSQYw2ijsQETMW+OcGp4OgJbSpjCr+zz/VC628e0rjmmx/E88NyHcX8wiMa5IqG8PaApeIRy9PYTRjTXNdvn6chA4bSq7sHw+1dgGtl1b95WUg/LEdZVsgevHvwcsZ/DFGc36gv+UgwKA9m0SroUfsbklObxt/PQh+GbJZfulfrgejd5CDsM3pnimsX9hxUjCxif0Qxgz9CcHL2sqjU/y/G4wjv2dc+B7ELa5lQ5LabwyDSnJyjY3pggodaHtPFRQYiVO3CQyudXGodGBUg6xMQlIRpZEKk1mnqjSGIFhUZhwJJk4QEXzXYSBSQexQ50pgEqju/loauZGItz6p4FihFSCePzvxSgWrRpPWuApjKH/2O0I7q6fc3XVaJpQVeuogOMPWutj5X7D1J8XVf9mKPAkYg79L6H3jh0D7mD549+aAbqjhnAS4MrSXth5WFMnqgKp0yYjS7CWs0m4Sc9O63QxmjqGEgB4R4BV/W85RG1T3CUzZVC61Y2EqucuHtfI+foH5qdg== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(136003)(396003)(39860400002)(376002)(346002)(46966006)(36840700001)(316002)(55016002)(1076003)(26005)(6666004)(54906003)(6286002)(36756003)(8676002)(86362001)(83380400001)(36906005)(7696005)(82740400003)(36860700001)(426003)(4326008)(336012)(2906002)(107886003)(2616005)(82310400003)(16526019)(186003)(478600001)(5660300002)(8936002)(70586007)(7636003)(356005)(110136005)(70206006)(47076005)(6636002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2021 07:05:55.7742 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 306315f8-3e02-416b-24d2-08d94c15fc47 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT034.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1372 Subject: [dpdk-dev] [PATCH v2 1/3] app/flow-perf: support meter policy API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add option "policy-mtr" to indicate if meter creation will include policy or not. Meter creation will keep same without it. With "policy-mtr", policy is introduced. API create_meter_policy is to create a policy. API create_meter_rule will use it to create meter. Add option "policy-g_actions" to specify meter policy green color actions. W/o this, policy creation will fail since there is no default one. Signed-off-by: Haifei Luo Signed-off-by: Jiawei Wang Signed-off-by: Rongwei Liu --- app/test-flow-perf/main.c | 121 ++++++++++++++++++++++++++++++--- doc/guides/tools/flow-perf.rst | 6 ++ 2 files changed, 119 insertions(+), 8 deletions(-) diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c index 9be8edc31d..e0d94f943a 100644 --- a/app/test-flow-perf/main.c +++ b/app/test-flow-perf/main.c @@ -37,6 +37,7 @@ #include #include "config.h" +#include "actions_gen.h" #include "flow_gen.h" #define MAX_BATCHES_COUNT 100 @@ -49,10 +50,12 @@ static uint8_t flow_group; static uint64_t encap_data; static uint64_t decap_data; +static uint64_t g_actions; static uint64_t flow_items[MAX_ITEMS_NUM]; static uint64_t flow_actions[MAX_ACTIONS_NUM]; static uint64_t flow_attrs[MAX_ATTRS_NUM]; +static uint32_t g_policy_id[MAX_PORTS]; static uint8_t items_idx, actions_idx, attrs_idx; static uint64_t ports_mask; @@ -62,6 +65,7 @@ static bool delete_flag; static bool dump_socket_mem_flag; static bool enable_fwd; static bool unique_data; +static bool policy_mtr; static struct rte_mempool *mbuf_mp; static uint32_t nb_lcores; @@ -69,6 +73,7 @@ static uint32_t rules_count; static uint32_t rules_batch; static uint32_t hairpin_queues_num; /* total hairpin q number - default: 0 */ static uint32_t nb_lcores; +static uint64_t meter_cir; #define MAX_PKT_BURST 32 #define LCORE_MODE_PKT 1 @@ -134,6 +139,8 @@ usage(char *progname) printf(" --portmask=N: hexadecimal bitmask of ports used\n"); printf(" --unique-data: flag to set using unique data for all" " actions that support data, such as header modify and encap actions\n"); + printf(" --policy-mtr: To create meter with policy\n"); + printf(" --policy-g_actions: To set meter policy green color actions\n"); printf("To set flow attributes:\n"); printf(" --ingress: set ingress attribute in flows\n"); @@ -573,6 +580,9 @@ args_parse(int argc, char **argv) { "unique-data", 0, 0, 0 }, { "portmask", 1, 0, 0 }, { "cores", 1, 0, 0 }, + { "policy-mtr", 0, 0, 0 }, + { "policy-g_actions", 1, 0, 0 }, + { "meter-profile-alg", 1, 0, 0 }, /* Attributes */ { "ingress", 0, 0, 0 }, { "egress", 0, 0, 0 }, @@ -802,6 +812,32 @@ args_parse(int argc, char **argv) RTE_MAX_LCORE); } } + if (strcmp(lgopts[opt_idx].name, "policy-mtr") == 0) + policy_mtr = true; + if (strcmp(lgopts[opt_idx].name, + "policy-g_actions") == 0) { + token = strtok(optarg, ","); + while (token != NULL) { + for (i = 0; + i < RTE_DIM(flow_options); i++) { + if (strcmp(optarg, + flow_options[i].str) == 0) { + g_actions |= + flow_options[i].mask; + break; + } + } + /* Reached last item with no match */ + if (i == (RTE_DIM(flow_options) - 1)) { + fprintf(stderr, + "Invalid g_actions " + "item: %s\n", token); + usage(argv[0]); + rte_exit(EXIT_SUCCESS, "Invalid g_actions item\n"); + } + token = strtok(NULL, ","); + } + } break; default: usage(argv[0]); @@ -912,6 +948,62 @@ has_meter(void) return 0; } +static void +create_meter_policy(void) +{ + struct rte_mtr_error error; + uint32_t policy_id; + int ret, i, port_id; + struct rte_mtr_meter_policy_params policy; + struct rte_flow_action r_actions[2]; + uint16_t nr_ports; + struct rte_flow_action actions[MAX_ACTIONS_NUM]; + uint64_t flow_actions[MAX_ACTIONS_NUM]; + int lcore_counter = 0; + int lcore_id = rte_lcore_id(); + + memset(actions, 0, sizeof(actions)); + memset(flow_actions, 0, sizeof(flow_actions)); + memset(&policy, 0, sizeof(policy)); + RTE_LCORE_FOREACH(i) { + /* If core not needed return. */ + if (lcore_id == i) { + if (lcore_counter >= (int) mc_pool.cores_count) + return; + break; + } + lcore_counter++; + } + lcore_id = lcore_counter; + + if (lcore_id >= (int) mc_pool.cores_count) + return; + + flow_actions[0] = g_actions; + fill_actions(actions, flow_actions, 0, 0, 0, + 0, 0, lcore_id, unique_data); + + r_actions[0].type = RTE_FLOW_ACTION_TYPE_DROP; + r_actions[0].conf = NULL; + r_actions[1].type = RTE_FLOW_ACTION_TYPE_END; + r_actions[1].conf = NULL; + + policy.actions[RTE_COLOR_GREEN] = &actions[0]; + policy.actions[RTE_COLOR_YELLOW] = NULL; + policy.actions[RTE_COLOR_RED] = &r_actions[0]; + + nr_ports = rte_eth_dev_count_avail(); + for (port_id = 0; port_id < nr_ports; port_id++) { + policy_id = port_id + 10; + ret = rte_mtr_meter_policy_add(port_id, policy_id, + &policy, &error); + if (ret) + printf("meter policy add failed " + "port_id %d\n", port_id); + g_policy_id[port_id] = policy_id; + } +} + static void create_meter_rule(int port_id, uint32_t counter) { @@ -928,7 +1020,14 @@ create_meter_rule(int port_id, uint32_t counter) /*create meter*/ params.meter_profile_id = default_prof_id; - ret = rte_mtr_create(port_id, counter, ¶ms, 1, &error); + + if (!policy_mtr) { + ret = rte_mtr_create(port_id, counter, ¶ms, 1, &error); + } else { + params.meter_policy_id = g_policy_id[port_id]; + ret = rte_mtr_create(port_id, counter, ¶ms, 0, &error); + } + if (ret != 0) { printf("Port %u create meter idx(%d) error(%d) message: %s\n", port_id, counter, error.type, @@ -942,11 +1041,16 @@ destroy_meter_rule(int port_id, uint32_t counter) { struct rte_mtr_error error; - if (rte_mtr_destroy(port_id, counter, &error)) { - printf("Port %u destroy meter(%d) error(%d) message: %s\n", + if (policy_mtr) { + if (rte_mtr_meter_policy_delete(port_id, counter+1, &error)) + printf("error delete policy %d\n", counter+1); + } else { + if (rte_mtr_destroy(port_id, counter, &error)) { + printf("Port %u destroy meter(%d) error(%d) message: %s\n", port_id, counter, error.type, error.message ? error.message : "(no stated reason)"); - rte_exit(EXIT_FAILURE, "Error in deleting meter rule\n"); + rte_exit(EXIT_FAILURE, "Error in deleting meter rule"); + } } } @@ -1051,12 +1155,10 @@ create_meter_profile(void) /* If port outside portmask */ if (!((ports_mask >> port_id) & 0x1)) continue; - mp.alg = RTE_MTR_SRTCM_RFC2697; - mp.srtcm_rfc2697.cir = METER_CIR; - mp.srtcm_rfc2697.cbs = METER_CIR / 8; + mp.srtcm_rfc2697.cir = meter_cir; + mp.srtcm_rfc2697.cbs = meter_cir / 8; mp.srtcm_rfc2697.ebs = 0; - ret = rte_mtr_meter_profile_add (port_id, DEFAULT_METER_PROF_ID, &mp, &error); if (ret != 0) { @@ -1875,6 +1977,7 @@ main(int argc, char **argv) dump_socket_mem_flag = false; flow_group = DEFAULT_GROUP; unique_data = false; + meter_cir = METER_CIR; signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); @@ -1894,6 +1997,8 @@ main(int argc, char **argv) if (has_meter()) create_meter_profile(); + if (policy_mtr) + create_meter_policy(); rte_eal_mp_remote_launch(run_rte_flow_handler_cores, NULL, CALL_MAIN); if (enable_fwd) { diff --git a/doc/guides/tools/flow-perf.rst b/doc/guides/tools/flow-perf.rst index 280bf7e0e0..90b6934537 100644 --- a/doc/guides/tools/flow-perf.rst +++ b/doc/guides/tools/flow-perf.rst @@ -354,3 +354,9 @@ Actions: * ``--meter`` Add meter action to all flows actions. Currently, 1 meter profile -> N meter rules -> N rte flows. + +* ``--policy-mtr`` + Add policy-mtr to create meter with policy. + +* ``--policy-g_actions`` + Add policy-g_actions to specify policy green color actions. -- 2.27.0