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 D7EA0439D2; Fri, 26 Jan 2024 14:21:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6A3C740289; Fri, 26 Jan 2024 14:21:48 +0100 (CET) Received: from egress-ip11b.ess.de.barracuda.com (egress-ip11b.ess.de.barracuda.com [18.185.115.215]) by mails.dpdk.org (Postfix) with ESMTP id D9A674021D for ; Fri, 26 Jan 2024 14:21:46 +0100 (CET) Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02lp2040.outbound.protection.outlook.com [104.47.11.40]) by mx-outbound17-19.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 26 Jan 2024 13:21:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c8v74uJ32OsdtG/JaxAxt6rJHe7xnY4/15eBQS/2PsE4h8lFLBoS9h1XjNrONYgwczdRobdySSBCmzkumdKbeVhQupwpI2O1jUtWh9BGJYCkSnOSM6qTt3VOC5m+OHOeLDRHB/R4dE+HSSeH6E5O2CzGHqTxo8klC5pDHnTJOHYhWFFGBpeVoJ3KCRh+h7dZhCXMb+8f4NV2Qy/oKk3r7FcoPk1XMvXvV3Yot40M5zvGwdXyAXkCtgSGtQhddipu/6pwxz1ROUIOTdRwrMnPUUjF9sLM2y1xyhe2jy6iZHLY9yDeofuXINP+nlXn1oxywCZIqO7Hb9z4W2XznwmFLA== 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=erfwCe0lUPB0UnOss0v2c8be785Vr8ULAHRIBM6lLaQ=; b=fJDpBLqhmoJ3iK/LwiJ3xk0hsba3L0ftZYoReuCJVP5tB1LgPXtww7+VkHb7WbRGqTuidxs8R8pcTRB5vnR0LjxpbiN6MBxdVIyHKjBirBXJ9ZdwgUYW0nYJL07tppUBBoKAfdmESEBwZyU5I/z69enaVevOfMEnk6h8+JTKfP7e33M5O7lPKjcrwLs+1iZlsSFuiWchcIltvm6tsIQCIopnMNXItvzini2aDXH+F1eBrufcHTZw6nJWq+RDayfAPtb0xcKiYpb0n5vOtqWBJMjbfMcaOqDcOh9qVVT1arg4e6nP80835Znwi91cr4TSo7cj0sJGhOLjAPltMz/b7Q== 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=erfwCe0lUPB0UnOss0v2c8be785Vr8ULAHRIBM6lLaQ=; b=jMx5OX2Zh1Whhn+7OIny5NLfEStmhgTic1xaCac+ALEbo+h4nHaGScxEcq4UE4H/kmKeYvEChhhnVwQoqtxQM4t9PeXH2U7Gzv9GDlNS6rtGcmMG47rHA1uCxgh6UWV4hFAyJSRvqJoOAIPD5S7asxjhJqK90o/LqsfM1GOCsB8= Received: from DU2PR04CA0024.eurprd04.prod.outlook.com (2603:10a6:10:3b::29) by GV1P190MB1947.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:56::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.14; Fri, 26 Jan 2024 13:21:21 +0000 Received: from DU6PEPF0000A7E0.eurprd02.prod.outlook.com (2603:10a6:10:3b:cafe::4e) by DU2PR04CA0024.outlook.office365.com (2603:10a6:10:3b::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.27 via Frontend Transport; Fri, 26 Jan 2024 13:21:21 +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 DU6PEPF0000A7E0.mail.protection.outlook.com (10.167.8.42) with Microsoft SMTP Server id 15.20.7228.16 via Frontend Transport; Fri, 26 Jan 2024 13:21:20 +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] app/testpmd: support updating flow rule actions Date: Fri, 26 Jan 2024 14:21:42 +0100 Message-ID: <20240126132142.2649250-1-okl-plv@napatech.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU6PEPF0000A7E0:EE_|GV1P190MB1947:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 9ae7dc21-aef3-49b8-624e-08dc1e71afa8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: av5l/FWB5INUQsrb0p6ytXCZAKgN9jamsScAg7Kkl11sU4bfa0q/WDtKac1EOf6bfdoQHJonq1HaVs/nShcjQotbbA76MFwg6BwzwMY6xIBLHrOQ+rANKQxG/HfyKvcqCCJeQORg1roELIrLQVFVUEVnxpH4ARB+XJyoVnDK4jO0dmwerwfiHvU4PlFxJ8woH2kgNk9D75/40NpcJf8Fkm1Xsti/0Z9g5WlGCEvf9wbEHvt06GDwnYWpQ2wAyDblndcscoyMlUEmwPSuXrPmMxnfpdT9/KGVHcDrlcxYW5BD5z+IYeR6ft7HaD3lVIyllSha7qkqw8Ej9qktVfR308YSsyAmckO8Up+NNPAG7u0428cLQsuuLbcvuMCWGhVIaa7sq8iKU8Haud5C9HAwbz7ziW0eXkhMqX/PLqJxqptE+yO3XBzSAVPWiDnZlRLSRxEg7IYlQJQ5MEbyTy+2SH4bOzd5ROkweoJRdqtwjH4KisubVehF35+0BE1Uq9fRjRYr9z4q0imTmgyoj/vtDOT4MD/cyxZUbUHWfPJF4NV7fVJ3LhoWC6x/NUULWlrrupwIityI7Jm1czaiKNBfOG1r2J/BlR1cWM7Jl4G71KAU9zI6oYC6ABqzeHcoQbA/S5yPR1OjdoLTy7c7vEguo3zi0FGui2EwBE3e9sO2v03UQ0o4mjHQ2Ranhp16N+Y76sbdffjPVCra8n5YD4MCyP09oAJr6urmchkiiLekO0Dd6tB0GMjzlRnZwW8MH3GLKZheX9QQOXvbmcmPq9AJsg== 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)(6069001)(39840400004)(396003)(346002)(376002)(136003)(230922051799003)(64100799003)(186009)(1800799012)(451199024)(82310400011)(36840700001)(46966006)(6666004)(41300700001)(6486002)(478600001)(40480700001)(36860700001)(356005)(81166007)(47076005)(336012)(9316004)(83380400001)(6512007)(6506007)(118246002)(36736006)(316002)(5660300002)(6636002)(26005)(8936002)(36756003)(4326008)(8676002)(70206006)(70586007)(2906002)(86362001)(1076003)(2616005)(956004)(15866825006)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: SfCeD3DK0YxpgI6GtL6QOGAxMLiBXO2mYkF+uDHtSRePnuVJPOrKi67pEtbyzgG6irF0K01z4pW6HvoLtyKwwBUkb5fGLxQE6RmjX3AB5Ryibfv3NvO0GWbNrm8l1DG118FJrRh48OBiw2IiomrL60hilGcdgYisSd7/WDmTcuqc8jOEhrOtu4VDv/NTsMWFOWrdkFcYeakPV5X/QaMvJLWcOsEXIZ6JM3oCo/vSNzKbzIMOt1bS+jEEBOccAjg4jgEI2WWu6lc4MoZJg4PLGQfyv0t+404c0guyXpbPvIxqKF0IpmkHiKrz2ouIrsufP7xyieK5bkcIdKO5/Hun5u+pahzH1x0Jn7NctWvlveG3p0Bom7WMNLYYBgjxsuJofX7vPU5GX8CrqhCnIovbOjSGWw8cq19BijFSs5eJ7JiMrIahwar6fmLGn/JGco8subX/pIOGI22CZuPBNy80GUqk5htjl68mlDofYrBWCZiSUlasb8c7ORZw3fZ70tGKTBEZ8W3dgLL8sQYYywo+u2/m9WxgYhpxnezD81Wg0UnOsvKNVA+rf+hCcSF/THXmIP2x8sDrr3h9qA6fpREHEy1DeHfjssxtFfhJbNs4z+sqfKcxVsa4DBcg0eycD1EFygcQ6a9EOHt++dyyb87W+w== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2024 13:21:20.3984 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9ae7dc21-aef3-49b8-624e-08dc1e71afa8 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: DU6PEPF0000A7E0.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P190MB1947 X-BESS-ID: 1706275305-304371-12433-15996-1 X-BESS-VER: 2019.1_20240125.1952 X-BESS-Apparent-Source-IP: 104.47.11.40 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVpYWBuZAVgZQ0CIpySQ1zTwl1T DNxMTYLNEi1cgozdDQJMXc1DjZwCRRqTYWAB5K2uNBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.253769 [from cloudscan20-110.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_SC0_MISMATCH_TO META: Envelope rcpt doesn't match header 0.00 MAILTO_TO_SPAM_ADDR META: Includes a link to a likely spammer email 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_SC0_MISMATCH_TO, MAILTO_TO_SPAM_ADDR, BSF_BESS_OUTBOUND 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 actions_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 actions_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 actions_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 --- .mailmap | 3 ++ app/test-pmd/cmdline.c | 4 ++ app/test-pmd/cmdline_flow.c | 34 +++++++++++++++- app/test-pmd/config.c | 43 ++++++++++++++++++++ app/test-pmd/testpmd.h | 3 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 44 +++++++++++++++++++++ 6 files changed, 130 insertions(+), 1 deletion(-) diff --git a/.mailmap b/.mailmap index 6011526cae..44da31c1c2 100644 --- a/.mailmap +++ b/.mailmap @@ -232,6 +232,7 @@ Chintu Hetam Choonho Son Chris Metcalf Christian Ehrhardt +Christian Koue Muf Christian Maciocco Christophe Fontaine Christophe Grosse @@ -986,6 +987,7 @@ Mukesh Dua Murphy Yang Murthy NSSR Muthurajan Jayakumar +Mykola Kostenok Nachiketa Prachanda Nagadheeraj Rottela Naga Harish K S V @@ -1040,6 +1042,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 f704319771..8249e4eb92 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -852,6 +852,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 actions_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 359c187b3c..0af8d13121 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -91,6 +91,7 @@ enum index { VALIDATE, CREATE, DESTROY, + ACTIONS_UPDATE, FLUSH, DUMP, QUERY, @@ -250,6 +251,7 @@ enum index { VC_TUNNEL_SET, VC_TUNNEL_MATCH, VC_USER_ID, + VC_IS_USER_ID, /* Dump arguments */ DUMP_ALL, @@ -3084,6 +3086,7 @@ static const struct token token_list[] = { VALIDATE, CREATE, DESTROY, + ACTIONS_UPDATE, FLUSH, DUMP, LIST, @@ -3888,6 +3891,17 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, port)), .call = parse_destroy, }, + [ACTIONS_UPDATE] = { + .name = "actions_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", @@ -4134,6 +4148,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", @@ -8083,8 +8102,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 != ACTIONS_UPDATE) return -1; + if (ctx->curr == ACTIONS_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; @@ -8156,6 +8180,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; @@ -12713,6 +12740,11 @@ cmd_flow_parsed(const struct buffer *in) in->args.destroy.rule, in->args.destroy.is_user_id); break; + case ACTIONS_UPDATE: + port_flow_actions_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 cad7537bc6..09d44908b0 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -3696,6 +3696,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_actions_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 9b10a9ea1c..7ff76658e7 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -1034,6 +1034,9 @@ 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_actions_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 ab18a80b30..274cb96724 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3046,6 +3046,11 @@ following sections. flow destroy {port_id} rule {rule_id} [...] [user_id] +- Update a flow rule with new actions:: + + flow actions_update {port_id} {rule_id} + actions {action} [/ {action} [...]] / end [user_id] + - Destroy all flow rules:: flow flush {port_id} @@ -4235,6 +4240,45 @@ Non-existent rule IDs are ignored:: Flow rule #0 destroyed testpmd> +Updating flow rules with new actions +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``flow actions_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 actions_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 actions_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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- 2.43.0