From patchwork Thu Feb 29 02:15:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Kolomeiets X-Patchwork-Id: 137459 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 283BC43BAE; Thu, 29 Feb 2024 03:12:42 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F029D402AF; Thu, 29 Feb 2024 03:12:41 +0100 (CET) Received: from egress-ip11a.ess.de.barracuda.com (egress-ip11a.ess.de.barracuda.com [18.184.203.234]) by mails.dpdk.org (Postfix) with ESMTP id 25D0F402A3 for ; Thu, 29 Feb 2024 03:12:40 +0100 (CET) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03lp2233.outbound.protection.outlook.com [104.47.51.233]) by mx-outbound46-194.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 29 Feb 2024 02:12:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cE/dxNOnARzAFJXAgdk6rkMRajej1EpMKFuK11M5DSBlHhVoVdL/Xo9z0fpqYqZBK2HEpHjTMPCCxsk5kMYVWpJZgXSbrZm0hhg458nPj5AFaobisYBeh/F1PNy9oTHRRqNhbymyaLPpWFpRGjYNdzjOgfPTH58bs12qCAErp+Kowue+LSnVS4qsAdK6/N1jWoJiIgc5qRR0/KKMWZh/eMQcJq1BtY93Lhokm09SAtVD1HZlRli1DYDBPEADcMymmH9UY83GAHCB3RTez0fHSfbe+Ps89O4k0GS176bfhIS2c4NhWZlLFtjX2WEsgEabkthtKqu4+L7teZ4M9On9VQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MeKUz7WnvOI6sfqjeAHtWKzbS8ChI+1NhYyd2toucjI=; b=WyjwnKZwXLwuqQ6A5SI3saUmRT0AHDmdU9gbLJAjwqpOrjuhTDCvPsXOkIE3rF0jxYT/ITiBl+elljx6HdxbOq2nuhYqUk/6+prAVC3d5jS5W3sqFyWvydXkchkpFqX+ihgXdbeMeUHSVaw5pm2/yJ63dd5sm5OstYU/ISFcfVIf9hHZhjlGO1h0F0BXHChpkU1cFuuihbO5XvinNpMdxf2E/fTyvReyvWPJ3h2WUrTvpPlPGPjvHmSVYtpqh/paCzZNRXStu0nReR+u7w8ZPYW1M7ZcdREnidndOQU77sVsPyl0vVJyK1tmbYu6lu/Yu7B+TgwBwozQxXCT/jHIiA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 178.72.21.4) smtp.rcpttodomain=monjalon.net smtp.mailfrom=napatech.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=napatech.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=napatech.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MeKUz7WnvOI6sfqjeAHtWKzbS8ChI+1NhYyd2toucjI=; b=LxCoHRfrZGh2qcQQ8rB9N4p7D985h0UnabZFeN8yrKFePwRVQc/Zbl1Y2S8ZJuLJVD5VlDd1KbAUuda7Qk1wKuHSRp5z5dn8Dgy8UsH2UTpPSuVn/ZcmNi0+qQG218gE/xbsztISzEnhVYiKEk6nZGr4Fy6OMzSH4ZNiUMisYOs= Received: from AM0PR01CA0169.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::38) by PRAP190MB1738.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:27b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.36; Thu, 29 Feb 2024 02:12:37 +0000 Received: from AM3PEPF0000A79A.eurprd04.prod.outlook.com (2603:10a6:208:aa:cafe::18) by AM0PR01CA0169.outlook.office365.com (2603:10a6:208:aa::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.28 via Frontend Transport; Thu, 29 Feb 2024 02:12:37 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 178.72.21.4) smtp.mailfrom=napatech.com; dkim=none (message not signed) header.d=none;dmarc=fail action=none header.from=napatech.com; Received-SPF: Fail (protection.outlook.com: domain of napatech.com does not designate 178.72.21.4 as permitted sender) receiver=protection.outlook.com; client-ip=178.72.21.4; helo=localhost.localdomain.com; Received: from localhost.localdomain.com (178.72.21.4) by AM3PEPF0000A79A.mail.protection.outlook.com (10.167.16.105) with Microsoft SMTP Server id 15.20.7292.25 via Frontend Transport; Thu, 29 Feb 2024 02:12:36 +0000 From: Oleksandr Kolomeiets To: thomas@monjalon.net, aman.deep.singh@intel.com, yuying.zhang@intel.com, orika@nvidia.com, mko-plv@napatech.com, ckm@napatech.com Cc: dev@dpdk.org Subject: [PATCH v5] app/testpmd: support updating flow rule actions Date: Thu, 29 Feb 2024 03:15:11 +0100 Message-ID: <20240229021511.5850-1-okl-plv@napatech.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240223041919.131526-1-okl-plv@napatech.com> References: <20240223041919.131526-1-okl-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM3PEPF0000A79A:EE_|PRAP190MB1738:EE_ X-MS-Office365-Filtering-Correlation-Id: b833ffcf-7c36-45b0-8879-08dc38cbe5e8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VR7T1FlAdWvXuqwp4vR1NVMsvSI+ZwU7RSgrJcbnBSJC2OlmFA17ESKLSznDXOh3vjOehhstZmckjit8qPkEs28CZP+Divy45WaZ5n2by6qKRLNODq2DTm9csM7IptW1gwbqBno3p0Kv4aGjfmeVgqO7sLRMIQw1cCSiyqy7Z30iFTu6lWZaNl1vG4zFP+ZGHfSlZOf9tp8sTmE+QBhtyqAsfm4+Pm/jpm3jlFlnmb43IPz13w/JLoH+AJVd0NBN0Wt7WfYAuzVbytZfduMYWZ2w2Q2UJaSuGVJqrDPid//er1jHY2HoCIgbwY9AcR/seh0BXVyGgtvb81PBMczffXvH2wL7wW0ucpJxkI7YCznVVVtdLKBEGiq46gxqjZNY3UJAPU4ZtBDDby3I01EcChUMO+8IHe60wcxWOZ80Ol5o0G59Y1gwmzlWljC4J7MOPZ1Yl8dBf76seYkXsWLICJbRdWB80d5/zaA8ZosU1RmoTROX5UEm72JnffXdvRtN2uxfSrdV/Gw8+zM577XPcurUzqIrzpxcK15ieSt2nCMh6HHZJYM6h0UpSzyKLjyEgKzgfJgrRdK77MZDMDccJbbNJMKMUID0qRhNSIItHQ3ctK7743CJ8WviAG/LFhS8pAzNPnZt9PcfTWgwE2rtRpZgfFnu73sjCiYwRbvq+V3xFSQeXlTcE4Fttzy8l+JeMcqat1/CJXkuHobiXBc0ejhoIZC96G/mbhEUI1I42piVvl9LTOnKvGDBqMq+B6iFmIrc6M1vW3svs6fdidauWU9E6p2gi4UzvJTRSxs5kSs= X-Forefront-Antispam-Report: CIP:178.72.21.4; CTRY:DK; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:localhost.localdomain.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(36860700004)(82310400014)(15866825006); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: rVOSLL4oLtSSbQHWvYBKaI3rBWI/zEnFVnYW9EzsRtOXwvQtye88NYNc6ihituecIgbsgKZpCPfOhOpS8m2/YvJcPpV3QwFbMG9HgYLD0q445afiDx+/t1NKR1tN52cPIJoVgMGhzGirAr9Em8O/M5q43VyP+PXZcgVYHoaAQsDMKV2IHp5j45wFV5lAgsEWrQyeFmihSJDgn56SCKIDrJRfeQH1s7vGF0Ns8TUvpUHjorv1hTyYBhPMHbMCqnKuyRD1fXaJFDogVvS0FWgsfRSnLjDylv1xlk9FsnciX9HEKcfbudbKA7GYIwWcA0Q4xa3Agi40/cZKMmkLwDLwX8cTaRnBm3Zk+JLvnT72CxWkMntxI831Xwz+V5uvCG2pF9+7nnIXIRNsAihVK/pUuU20s+t2mBmnzKFcps/Hw0/MXLp25TDCLTCOwe0IFc2hNNS/N2o6xSRBzOHol+0vG+uLGLP0FFpgYw2D7nbGRdgoSxed2Kg1lQ9PktfDROrPQ94cBNGu6BFWZJoajCQnNjehRvkhu1lgH63v8jEIPcBioqXfSlHZ7kUj3LjgmxHq+px4qWqv+8x99mAZ3rq6vhNFCJ3e7rfCvCkgg+2AHpPZO8Y38HebRZwqrvOIc/0ATgbHrdbMCYmY6jmq1H4AkQ== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Feb 2024 02:12:36.4787 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b833ffcf-7c36-45b0-8879-08dc38cbe5e8 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain.com] X-MS-Exchange-CrossTenant-AuthSource: AM3PEPF0000A79A.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PRAP190MB1738 X-BESS-ID: 1709172759-311970-12432-40573-1 X-BESS-VER: 2019.1_20240227.2356 X-BESS-Apparent-Source-IP: 104.47.51.233 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVpbmZmZAVgZQ0CQl2dTc3NjCIN nYyCAxxcjSxDTV2MLc0tQAyE82MlKqjQUAxTbQE0EAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.254540 [from cloudscan8-245.eu-central-1a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 MAILTO_TO_SPAM_ADDR META: Includes a link to a likely spammer email 0.00 BSF_BESS_OUTBOUND META: BESS Outbound 0.00 BSF_SC0_MISMATCH_TO META: Envelope rcpt doesn't match header X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=MAILTO_TO_SPAM_ADDR, BSF_BESS_OUTBOUND, BSF_SC0_MISMATCH_TO X-BESS-BRTS-Status: 1 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 "flow update" updates a flow rule specified by a rule ID with a new action list by making a call to "rte_flow_actions_update()": flow update {port_id} {rule_id} actions {action} [/ {action} [...]] / end [user_id] Creating, updating and destroying a flow rule: testpmd> flow create 0 group 1 pattern eth / end actions drop / end Flow rule #0 created testpmd> flow update 0 0 actions queue index 1 / end Flow rule #0 updated with new actions testpmd> flow destroy 0 rule 0 Flow rule #0 destroyed Signed-off-by: Oleksandr Kolomeiets Reviewed-by: Mykola Kostenok Reviewed-by: Christian Koue Muf Acked-by: Ferruh Yigit --- v5: * No changes. v4: * No changes. v3: * Renamed "flow actions_update" command to "flow update". v2: * No changes. --- .mailmap | 3 ++ app/test-pmd/cmdline.c | 4 ++ app/test-pmd/cmdline_flow.c | 33 +++++++++++++++- app/test-pmd/config.c | 43 ++++++++++++++++++++ app/test-pmd/testpmd.h | 2 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 44 +++++++++++++++++++++ 6 files changed, 128 insertions(+), 1 deletion(-) diff --git a/.mailmap b/.mailmap index 58cca13ef6..157ccab909 100644 --- a/.mailmap +++ b/.mailmap @@ -236,6 +236,7 @@ Chintu Hetam Choonho Son Chris Metcalf Christian Ehrhardt +Christian Koue Muf Christian Maciocco Christophe Fontaine Christophe Grosse @@ -993,6 +994,7 @@ Mukesh Dua Murphy Yang Murthy NSSR Muthurajan Jayakumar +Mykola Kostenok Nachiketa Prachanda Nagadheeraj Rottela Naga Harish K S V @@ -1047,6 +1049,7 @@ Odi Assli Ognjen Joldzic Ola Liljedahl Oleg Polyakov +Oleksandr Kolomeiets Olga Shern Olivier Gournet Olivier Matz diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 566057caa5..f521a1fe9e 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -851,6 +851,10 @@ static void cmd_help_long_parsed(void *parsed_result, "flow destroy {port_id} rule {rule_id} [...]\n" " Destroy specific flow rules.\n\n" + "flow update {port_id} {rule_id}" + " actions {action} [/ {action} [...]] / end [user_id]\n" + " Update a flow rule with new actions.\n\n" + "flow flush {port_id}\n" " Destroy all flow rules.\n\n" diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index f69516faf2..5f761903c1 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -91,6 +91,7 @@ enum index { VALIDATE, CREATE, DESTROY, + UPDATE, FLUSH, DUMP, QUERY, @@ -260,6 +261,7 @@ enum index { VC_TUNNEL_SET, VC_TUNNEL_MATCH, VC_USER_ID, + VC_IS_USER_ID, /* Dump arguments */ DUMP_ALL, @@ -3209,6 +3211,7 @@ static const struct token token_list[] = { VALIDATE, CREATE, DESTROY, + UPDATE, FLUSH, DUMP, LIST, @@ -4074,6 +4077,17 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, port)), .call = parse_destroy, }, + [UPDATE] = { + .name = "update", + .help = "update a flow rule with new actions", + .next = NEXT(NEXT_ENTRY(VC_IS_USER_ID, END), + NEXT_ENTRY(ACTIONS), + NEXT_ENTRY(COMMON_RULE_ID), + NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.rule_id), + ARGS_ENTRY(struct buffer, port)), + .call = parse_vc, + }, [FLUSH] = { .name = "flush", .help = "destroy all flow rules", @@ -4320,6 +4334,11 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.user_id)), .call = parse_vc, }, + [VC_IS_USER_ID] = { + .name = "user_id", + .help = "rule identifier is user-id", + .call = parse_vc, + }, /* Validate/create pattern. */ [ITEM_PATTERN] = { .name = "pattern", @@ -8483,8 +8502,13 @@ parse_vc(struct context *ctx, const struct token *token, if (!out->command) { if (ctx->curr != VALIDATE && ctx->curr != CREATE && ctx->curr != PATTERN_TEMPLATE_CREATE && - ctx->curr != ACTIONS_TEMPLATE_CREATE) + ctx->curr != ACTIONS_TEMPLATE_CREATE && + ctx->curr != UPDATE) return -1; + if (ctx->curr == UPDATE) + out->args.vc.pattern = + (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1), + sizeof(double)); if (sizeof(*out) > size) return -1; out->command = ctx->curr; @@ -8556,6 +8580,9 @@ parse_vc(struct context *ctx, const struct token *token, ctx->object = out->args.vc.actions; ctx->objmask = NULL; return len; + case VC_IS_USER_ID: + out->args.vc.user_id = true; + return len; default: if (!token->priv) return -1; @@ -13289,6 +13316,10 @@ cmd_flow_parsed(const struct buffer *in) in->args.destroy.rule, in->args.destroy.is_user_id); break; + case UPDATE: + port_flow_update(in->port, in->args.vc.rule_id, + in->args.vc.actions, in->args.vc.user_id); + break; case FLUSH: port_flow_flush(in->port); break; diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 08d7d0e2f8..cd2a436cd7 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -3829,6 +3829,49 @@ port_flow_destroy(portid_t port_id, uint32_t n, const uint64_t *rule, return ret; } +/** Update a flow rule with new actions. */ +int +port_flow_update(portid_t port_id, uint32_t rule_id, + const struct rte_flow_action *actions, bool is_user_id) +{ + struct rte_port *port; + struct port_flow **flow_list; + + if (port_id_is_invalid(port_id, ENABLED_WARN) || + port_id == (portid_t)RTE_PORT_ALL) + return -EINVAL; + port = &ports[port_id]; + flow_list = &port->flow_list; + while (*flow_list) { + struct port_flow *flow = *flow_list; + struct rte_flow_error error; + + if (rule_id != (is_user_id ? flow->user_id : flow->id)) { + flow_list = &flow->next; + continue; + } + /* + * Poisoning to make sure PMDs update it in case + * of error. + */ + memset(&error, 0x33, sizeof(error)); + if (rte_flow_actions_update(port_id, flow->flow, actions, + &error)) + return port_flow_complain(&error); + if (is_user_id) + printf("Flow rule #%"PRIu64" updated with new actions," + " user-id 0x%"PRIx64"\n", + flow->id, flow->user_id); + else + printf("Flow rule #%"PRIu64 + " updated with new actions\n", + flow->id); + return 0; + } + printf("Failed to find flow %"PRIu32"\n", rule_id); + return -EINVAL; +} + /** Remove all flow rules. */ int port_flow_flush(portid_t port_id) diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 467ef3a8ab..55df12033a 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -1043,6 +1043,8 @@ void update_age_action_context(const struct rte_flow_action *actions, int mcast_addr_pool_destroy(portid_t port_id); int port_flow_destroy(portid_t port_id, uint32_t n, const uint64_t *rule, bool is_user_id); +int port_flow_update(portid_t port_id, uint32_t rule, + const struct rte_flow_action *actions, bool is_user_id); int port_flow_flush(portid_t port_id); int port_flow_dump(portid_t port_id, bool dump_all, uint64_t rule, const char *file_name, diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index d837aa797f..2fbf9220d8 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3057,6 +3057,11 @@ following sections. flow destroy {port_id} rule {rule_id} [...] [user_id] +- Update a flow rule with new actions:: + + flow update {port_id} {rule_id} + actions {action} [/ {action} [...]] / end [user_id] + - Destroy all flow rules:: flow flush {port_id} @@ -4278,6 +4283,45 @@ Non-existent rule IDs are ignored:: Flow rule #0 destroyed testpmd> +Updating flow rules with new actions +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``flow update`` updates a flow rule specified by a rule ID with a new action +list by making a call to ``rte_flow_actions_update()``:: + + flow update {port_id} {rule_id} + actions {action} [/ {action} [...]] / end [user_id] + +If successful, it will show:: + + Flow rule #[...] updated with new actions + +Or if ``user_id`` flag is provided:: + + Flow rule #[...] updated with new actions, user-id [...] + +If a flow rule can not be found:: + + Failed to find flow [...] + +Otherwise it will show the usual error message of the form:: + + Caught error type [...] ([...]): [...] + +Optional ``user_id`` is a flag that signifies the rule ID is the one provided +by the user at creation. + +Action list is identical to the one described for the ``flow create``. + +Creating, updating and destroying a flow rule:: + + testpmd> flow create 0 group 1 pattern eth / end actions drop / end + Flow rule #0 created + testpmd> flow update 0 0 actions queue index 1 / end + Flow rule #0 updated with new actions + testpmd> flow destroy 0 rule 0 + Flow rule #0 destroyed + Enqueueing destruction of flow rules ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~