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 8C391A034C; Wed, 21 Dec 2022 09:40:45 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C00C942D14; Wed, 21 Dec 2022 09:40:41 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2067.outbound.protection.outlook.com [40.107.237.67]) by mails.dpdk.org (Postfix) with ESMTP id 2190742D14 for ; Wed, 21 Dec 2022 09:40:41 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fXBjbFOubIgTEyaueus5sSXCjP/98vBpkaUzTNgUtC/ycggYJMCmSGfYxXz6A4gtd6X2et4zpMTXjTxIdl3yNt7G0ipzGZ50G2TD2Zo752O3knHw6I3U+4fz79o9ZrZzumvaZX7wm89jK12znN4WAdQGIn+KWcrxLGOb2gA7tPYGgSsXuLcwk6J4yPVB14ywU+LvUVsVOScSshPr2u7UqpWoRNSYgr+stQEs7FO/CKkraqgKDv4E6ZbOCIv6JjzJbbPjYKB4lgfCnWcyBEEEBXVOwKxh84XYZRrg1+3p8/1tpMvgFXIfL5YRhiqPZPEfCeqgHlKU5kPNKBq8dEg7rw== 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=2eTVissLkKk3fFX0lMv63B7YmGpOQdwVcW8t5hTYTYw=; b=kl5rS+V2TRvZuO4Imx+MB1jPN5862pT6hpV9hdRcD9nmfpHFKOCZauRcGKEt4qpgy1gB4q+TJiA1YB4prqDUO8bpCd1rABQvh5Rxa8SQ+FTHyliN+2pRt9VVty+qyO+O7hpdxYcx42uWLdrryhKFoN6RwqX38Nspu/P71cagOgGGL0913CaPTFLHsz9pP4L7Ot3rAiftrulDY6uip0FQQ2eTBGa7kyeFLOWmvnQ1uRmwgJyCp0URkL7vpNlNr8uc+EXkg61+SA2595Uq09OjFhqi6GYbEsZAW1xIsrnAKjAPRhtqGJo3Nu8/F5vKZB+O1KEa9bQXCoe5tvP8Vx+MSA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=monjalon.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject 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=2eTVissLkKk3fFX0lMv63B7YmGpOQdwVcW8t5hTYTYw=; b=eRVQ1RZ7TixQ4C4X+xvItr5TS6LbXE59S6gcKqHKxpshdbL4IEimsr9wPjrYULwraHuS35iYw5tvdw0954lqTr+V7toha4yRKldP/8Kp4YR4JCGn1iW8n6sT1jk4d7ZaBYAlZa2JfViQdnmdtNHzla4m7IhefClaCfs86QahDriUjbDV7lbAsKNdmZ1m6DuSu4x/cQkiTBm6ywqmX9cpDnkTiWDwh3ebNjRCynZq7SYxNlTK7xiulvclAYVU0qNAy77zPIfDYbSwFaYRRay5qScO4YUwiK9FYDNz1B4dU027hRkSPwjrPqWXEyZPG4wvPfAZMFOupSGFoMdIviWKlQ== Received: from BN8PR04CA0045.namprd04.prod.outlook.com (2603:10b6:408:d4::19) by PH7PR12MB7332.namprd12.prod.outlook.com (2603:10b6:510:20f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Wed, 21 Dec 2022 08:40:39 +0000 Received: from BL02EPF00010208.namprd05.prod.outlook.com (2603:10b6:408:d4:cafe::a1) by BN8PR04CA0045.outlook.office365.com (2603:10b6:408:d4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.21 via Frontend Transport; Wed, 21 Dec 2022 08:40:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BL02EPF00010208.mail.protection.outlook.com (10.167.241.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.8 via Frontend Transport; Wed, 21 Dec 2022 08:40:39 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Wed, 21 Dec 2022 00:40:22 -0800 Received: from nvidia.com (10.126.231.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Wed, 21 Dec 2022 00:40:19 -0800 From: Rongwei Liu To: , , , , Aman Singh , Yuying Zhang CC: , Subject: [RFC 2/9] app/testpmd: add flex item modify field cmdline support Date: Wed, 21 Dec 2022 10:39:53 +0200 Message-ID: <20221221084000.3680015-3-rongweil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20221221084000.3680015-1-rongweil@nvidia.com> References: <20221221084000.3680015-1-rongweil@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.37] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00010208:EE_|PH7PR12MB7332:EE_ X-MS-Office365-Filtering-Correlation-Id: 59d3a3dd-8fbb-48c0-a5ad-08dae32f09ca X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GXKHB6E+oYMy0lUR9QGIxa3B+Pcq9OOMCjErdcojURpDzuKiYd1WoQRhDDraPbTzc02imdOEen6nZpupp5VfXZ3wNhPfxvI4mU0V31nLC8ubTNCqCtd2CYCTZXY8Znv7NMUluPdWVuBafkj+Mg/7VwpFfu4pUjKPA0Dp8zahdLG4zMaNOPQrhAjKNxhxEKRTUmAvImZlcP2u85+hk+LUXVkLXEI+7x0Paoc3U8KmmfJ3AiHKSPEtAp97eJgPPx11ZAwoPgX13F6R+8pH0+uKZ0BIfHoBzWveWdUrthbc4Dy9lEBRn5a4Fidd/FJMetfRMno6VCp78HmBiRLqoKno9fjlIizV/kXJ7IH4rq2j0eZPe0JhSaKe56MHrYSlLJm0a+0RLgtqSSKy/bkGcKw3skAoXbbSHN4A2g4kHLpFPqjZ56UbniNkAT+91gFCVHiXbXnrBtfAoY/0ktMjLoBA170fgMC5U/oNce96qrAN1DDgvfKwcYCyj/kT6JZlU3Md3e3wZAifcU0seLyNIclPQZ5VjVwfngWZSKlPfX7nviEontOu9+ve8+kGI9kZZYfqmY4NtnehK4LKAOV/K+8nXYgbWv0+91GLL/8wqUPoYGLFdJwAdp/VZPw0lAD+4fAHhp4bgwDIo9xasU3nCOkypyrtH1BQ5Cz2MxKDwbZphu0O1p1cpTGFFbuq9KVHCwB3A8Yphrir7xMYdwTJzxbn/g== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(396003)(136003)(39860400002)(346002)(376002)(451199015)(46966006)(40470700004)(36840700001)(83380400001)(36756003)(186003)(478600001)(86362001)(55016003)(40480700001)(40460700003)(26005)(426003)(356005)(36860700001)(82310400005)(336012)(2616005)(82740400003)(1076003)(8676002)(47076005)(7696005)(107886003)(6666004)(4326008)(70586007)(16526019)(70206006)(6286002)(7636003)(8936002)(5660300002)(2906002)(41300700001)(110136005)(54906003)(316002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2022 08:40:39.1558 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 59d3a3dd-8fbb-48c0-a5ad-08dae32f09ca X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF00010208.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7332 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 Add flex item modify field cmdline support. Now user can use testpmd cli to specify which flex item to be modified, either source or destination. Syntax is as below: modify_field op set dst_type flex_item dst_level 0 dst_offset 16 src_type value src_value 0x123456781020 width 8 Signed-off-by: Rongwei Liu --- app/test-pmd/cmdline_flow.c | 89 ++++++++++++++++++++++++++++++++++--- 1 file changed, 82 insertions(+), 7 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 88108498e0..7c12d63cbc 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -601,10 +601,12 @@ enum index { ACTION_MODIFY_FIELD_DST_TYPE, ACTION_MODIFY_FIELD_DST_TYPE_VALUE, ACTION_MODIFY_FIELD_DST_LEVEL, + ACTION_MODIFY_FIELD_DST_LEVEL_VALUE, ACTION_MODIFY_FIELD_DST_OFFSET, ACTION_MODIFY_FIELD_SRC_TYPE, ACTION_MODIFY_FIELD_SRC_TYPE_VALUE, ACTION_MODIFY_FIELD_SRC_LEVEL, + ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE, ACTION_MODIFY_FIELD_SRC_OFFSET, ACTION_MODIFY_FIELD_SRC_VALUE, ACTION_MODIFY_FIELD_SRC_POINTER, @@ -807,7 +809,8 @@ static const char *const modify_field_ids[] = { "udp_port_src", "udp_port_dst", "vxlan_vni", "geneve_vni", "gtp_teid", "tag", "mark", "meta", "pointer", "value", - "ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color", NULL + "ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color", + "flex_item", NULL }; static const char *const meter_colors[] = { @@ -2282,6 +2285,10 @@ parse_vc_modify_field_id(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size); static int +parse_vc_modify_field_level(struct context *ctx, const struct token *token, + const char *str, unsigned int len, void *buf, + unsigned int size); +static int parse_vc_action_conntrack_update(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size); @@ -5976,11 +5983,15 @@ static const struct token token_list[] = { .name = "dst_level", .help = "destination field level", .next = NEXT(action_modify_field_dst, - NEXT_ENTRY(COMMON_UNSIGNED)), - .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, - dst.level)), + NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_LEVEL_VALUE)), .call = parse_vc_conf, }, + [ACTION_MODIFY_FIELD_DST_LEVEL_VALUE] = { + .name = "{dst_level}", + .help = "destination field level value", + .call = parse_vc_modify_field_level, + .comp = comp_none, + }, [ACTION_MODIFY_FIELD_DST_OFFSET] = { .name = "dst_offset", .help = "destination field bit offset", @@ -6007,11 +6018,15 @@ static const struct token token_list[] = { .name = "src_level", .help = "source field level", .next = NEXT(action_modify_field_src, - NEXT_ENTRY(COMMON_UNSIGNED)), - .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, - src.level)), + NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE)), .call = parse_vc_conf, }, + [ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE] = { + .name = "{src_level}", + .help = "source field level value", + .call = parse_vc_modify_field_level, + .comp = comp_none, + }, [ACTION_MODIFY_FIELD_SRC_OFFSET] = { .name = "src_offset", .help = "source field bit offset", @@ -8477,6 +8492,66 @@ parse_vc_modify_field_id(struct context *ctx, const struct token *token, return len; } +/** Parse level for modify_field command. */ +static int +parse_vc_modify_field_level(struct context *ctx, const struct token *token, + const char *str, unsigned int len, void *buf, + unsigned int size) +{ + struct rte_flow_action_modify_field *action; + struct flex_item *fp; + uint32_t val; + struct buffer *out = buf; + char *end; + + (void)token; + (void)size; + if (ctx->curr != ACTION_MODIFY_FIELD_DST_LEVEL_VALUE && + ctx->curr != ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE) + return -1; + if (!ctx->object) + return len; + action = ctx->object; + errno = 0; + val = strtoumax(str, &end, 0); + if (errno || (size_t)(end - str) != len) + return -1; + /* No need to validate action template mask value */ + if (out->args.vc.masks) { + if (ctx->curr == ACTION_MODIFY_FIELD_DST_LEVEL_VALUE) + action->dst.level = val; + else + action->src.level = val; + return len; + } + if ((ctx->curr == ACTION_MODIFY_FIELD_DST_LEVEL_VALUE && + action->dst.field == RTE_FLOW_FIELD_FLEX_ITEM) || + (ctx->curr == ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE && + action->src.field == RTE_FLOW_FIELD_FLEX_ITEM)) { + if (val >= FLEX_MAX_PARSERS_NUM) { + printf("Bad flex item handle\n"); + return -1; + } + fp = flex_items[ctx->port][val]; + if (!fp) { + printf("Bad flex item handle\n"); + return -1; + } + } + if (ctx->curr == ACTION_MODIFY_FIELD_DST_LEVEL_VALUE) { + if (action->dst.field != RTE_FLOW_FIELD_FLEX_ITEM) + action->dst.level = val; + else + action->dst.flex_handle = fp->flex_handle; + } else if (ctx->curr == ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE) { + if (action->src.field != RTE_FLOW_FIELD_FLEX_ITEM) + action->src.level = val; + else + action->src.flex_handle = fp->flex_handle; + } + return len; +} + /** Parse the conntrack update, not a rte_flow_action. */ static int parse_vc_action_conntrack_update(struct context *ctx, const struct token *token, -- 2.27.0