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 667D043A35; Thu, 1 Feb 2024 10:59:27 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E94A040299; Thu, 1 Feb 2024 10:59:26 +0100 (CET) Received: from egress-ip42a.ess.de.barracuda.com (egress-ip42a.ess.de.barracuda.com [18.185.115.201]) by mails.dpdk.org (Postfix) with ESMTP id 4E3F540275 for ; Thu, 1 Feb 2024 10:59:25 +0100 (CET) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04lp2051.outbound.protection.outlook.com [104.47.12.51]) by mx-outbound12-216.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 01 Feb 2024 09:59:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RXKdwfAX/mdyhiOHH2fS2Kw1IK5TLOPTieIpWiewIaHxhaOIEL6xZsgd4IzuIoUW1qByGDdJTxVPh4TVLdz+rlpLVUM/+mOl2XjVyb+AhJ3fCUk24+TC7dAg5nBynwES8Al2hIOv41WV3iJq6cAjCw3ylBJ2Geif4ursRjtCiHtOv5OdB/Zq+9v3auTDIAK2pwAwI7yVLer9vARi4puUt5tezxFSWMhf3ImtxlNct/7uxg/w/MkQtJGFhIfTK70i+J+t1e/zF71dGapaYP53rUf15zd4Q3CPrCjFqGkQFBfHx3pnT7V2ubCGlt6YTRHkXTPucX4CPjQPvuqaOkqtew== 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=bDMjX0sFCEvHXSSHfs82dc3Z2D9JhWe6EX6fdCyFS1M=; b=GOIYdxuai1jtm2gftPBiLgLCKlVegOrAvF8kgXC92OFncxJNM4X8kVjl+eNQZjV7g4jy9Z4NLjY1OXz8kQnTxAfuY6b7HrXyYN+YJAkojV0i4Q86FlmScTzHNdX1jCiN5PnLWBtlXIkzqXd7xxkJcO1ou3FDAOLJZvOQJbqYaWVg4cVELgCzPkEMPIl1Mr36IlODpkabV0slPiWnJIh9KKDrLSbubKNWcG+T2XcR/sycj2yzKGIXb0j4YB0EDpaL1sSGnabqzUo2pkSmPC6CVjNXD2G1OOujWsQ4rhN3zoO5Sg4njJxiECTan6M6zjSurtdv3NoUrc08ivOYyUdI+g== 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=bDMjX0sFCEvHXSSHfs82dc3Z2D9JhWe6EX6fdCyFS1M=; b=DqDQ5tBMoNWr4oLLgcK4yoip+G1J2mV0pTaLn/kKOPdtRtqOz9qCsXtQUpVpl0tlvCWDcuq9EYtnbc34cU7NN8FR+XVcriprB8BSHm7RQJH9hTYkKuYS2M87GEVrvRRZJ3uoID5kW/U79aEtF2FhsYZgIKnku14wM5vIV0LYlAE= Received: from DB8PR03CA0019.eurprd03.prod.outlook.com (2603:10a6:10:be::32) by DU0P190MB1907.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:3bd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.17; Thu, 1 Feb 2024 09:58:46 +0000 Received: from DU2PEPF00028D0C.eurprd03.prod.outlook.com (2603:10a6:10:be:cafe::6b) by DB8PR03CA0019.outlook.office365.com (2603:10a6:10:be::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.26 via Frontend Transport; Thu, 1 Feb 2024 09:58:46 +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 DU2PEPF00028D0C.mail.protection.outlook.com (10.167.242.20) with Microsoft SMTP Server id 15.20.7249.19 via Frontend Transport; Thu, 1 Feb 2024 09:58:45 +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 v2] app/testpmd: support updating flow rule actions Date: Thu, 1 Feb 2024 10:59:07 +0100 Message-ID: <20240201095907.3564286-1-okl-plv@napatech.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240126132142.2649250-1-okl-plv@napatech.com> References: <20240126132142.2649250-1-okl-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D0C:EE_|DU0P190MB1907:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 798ac624-6b9c-48ef-966a-08dc230c618b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ytVn7vEbLYf1YuVEqp2VOtkNSg/YF55VSjUXAvW7JcWBDFll+x3U90tv0xql4lE25GpS13DtbJtZ5KxSzVKN9GOvabvLdgXZZ+qXMWbEHubvuU2saQMqdu7ci5WDG2sxhtT+eOcwc8XXN2i7jzlc9WMSVIspOrltTMn+LI5WY/Ui7GtZrtthPPvSRuKlbMnKFdNHQLnIq3RcF4fN6SQLAPQD+RDH2tT+VcqUAciKeKJfd39kzv/V+dD6PyJbqdaGjarmfHKoy4vYCZDdPU6E6zHYDNPJnbbV91hwGPyMYDdoaC5apYOWBVvgZvuUJD2g6hgavlbxzpEXgWbEhb4MPj61c0AYduDSmX2+p/2AF2uSSYDe+yw/DYk4oKWIDADclNVWVhy3epEP41hdpjUv65a1ge2biv81kXoZzfTT5lgFMVAeesD2LwBqu2Pf45GP/gCp/PmCdOtYEzwh0ErLZdSUTJrYsyPARj+TpihJ4TNB34QSWvhAZSAzGwbb0jBfr8wS5ZTM1qPkX6qlvHbByWoKuN4nn5v42efYmPqDWidZ4+cwc5dNUGkVnkdgTid2kSoWj/F2mbnT01VaVJiDA/aCoueMb6Yv9FrRb0XTWrUFSsbwZGnvEgmrVlx7T4R3qtH/WQ+NHk89WKcnKnxvshqdLkEyJNqidsGSsjPVKo7p/fCFJ2u/izEvjH/xNvvFM1/UmEwOwua1Wz0w2I6GuDol/tyDDvA7KG12prGz12ZGguvByb9uSOVRGr24O4DwLbXW31DRL1V2BVHNZPz2FA== 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)(346002)(136003)(39840400004)(376002)(396003)(230922051799003)(186009)(82310400011)(64100799003)(451199024)(1800799012)(36840700001)(46966006)(9316004)(2616005)(6636002)(36756003)(6486002)(478600001)(26005)(118246002)(2906002)(4326008)(8936002)(5660300002)(70206006)(86362001)(8676002)(36736006)(316002)(36860700001)(47076005)(70586007)(356005)(81166007)(6666004)(6512007)(83380400001)(6506007)(1076003)(336012)(41300700001)(40480700001)(956004)(36900700001)(15866825006); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: iG4m5OvbHbgn+17ZPW3tf+8mYLCj/V7Uz8y3Z9CboIXkEL6zzvzh36DMDYeSllWXGO3VOLhvlo1a2M0PA8SBQ8IjJF8teBeyEHJ6nvBoadygQlXc74yVE66SgfAC2t2QIRpaVggM+dcUieuWfZBpnrklN+JRiUp4E5O7CNYk7noSg0KvVy7inKBayKy4PVTKCI3Da89J/ix6kaXiG7j3mDPfKO69zLZX0N3bBlAXnsSZy/AVGxpaQnva3cqfjVqogO+BJ6yIh5KvJV8ai1tuLY1J2K0dcCAbZSH8rc9AHri9IAWkd+1ufG8bIPGqPR0iEF2XgSaC4tMNfZJTIgWQyU0K46LLqKryVqWFxU4eWpGxapl+ti1XziIbVKRN1Mds14Mm8RZXpJTEAv67yXZPv1ZMpmHX+nfMD590iV9Ngy+3o81Bde8pklBadzDBOr27RWw3ilFvnEgWQUa7ZapD2fZ8cSod1oiifzOF+cnqYJiHp/0Cpu8jCE7BoIzEeVyshZgv7+cUinRiURSSXXcIQtByN5e2a5Be/RoaUtQPOgcfrk+pGOzO1voH9/wuoFnWWLYlZlD2Kt5RLCl305H9ZtgotmokMHXOE/EXeUTDe6y/inxlAWpwJz7TknXRWUnc/74oSPZhCS6G8V0syOjx9w== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2024 09:58:45.9916 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 798ac624-6b9c-48ef-966a-08dc230c618b 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: DU2PEPF00028D0C.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0P190MB1907 X-BESS-ID: 1706781563-303288-12393-4500-1 X-BESS-VER: 2019.1_20240130.2130 X-BESS-Apparent-Source-IP: 104.47.12.51 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVpYWRpZAVgZQMMUoxTg1LdEsMT XZNMkozSI1LSXNMMnCJDHR3NTA0sBCqTYWALk9jp1BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.253908 [from cloudscan17-55.eu-central-1b.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 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 --- v2: * No changes. --- .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