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 182BF41BE4; Mon, 6 Feb 2023 04:39:41 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 31ED842D0D; Mon, 6 Feb 2023 04:39:39 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2078.outbound.protection.outlook.com [40.107.223.78]) by mails.dpdk.org (Postfix) with ESMTP id 3AAB542C24 for ; Mon, 6 Feb 2023 04:39:37 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N3YiG6+tO/tpEvnaHFdBFUX1stH185G69MyGhbGmb7jhykt6W/eWaZztBg2v70hnSDpSvFU+EfNF5z7KkGA2oWFTYx9LI3LjEHf+B8Iz6Z5G6Ks7idUx0uMZfSvnz3mFAGm2dF05XOu/hDDzwDZKJymjzQRSK+6T+tIr6K4zeCBU6U4xpWk5a1ZFgkwQzC2zlGF9xTS7XZ1S4zvkY+AVZJlHOCRDL0CQ2DhDb+piJc+OXiu+5fSKpwEJrwLfZsWfAPApf9RZKD2f83oiz42Oq1kIVP0/NrLtci9Y5te0zqcpDUcG+ABaL59lt/gfBUE+vFGNm1Z/hmHpxa7LX8AhWg== 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=zjcBBN9JnjnVL++Y6uGtR2606yzc6aIQEtoD/PCHMY0=; b=UajHp8HmSqCRy7VfXVz5fzWhPRCEjm706YwY/+yhYkGFkn09eIcRcY1EnST1c0rCwupL0LQlC9rXMZqw1TmKo84ToPh1+CR+a3bOu4L9lhawsEdouoy0YW8Nx+prXdUrrkXkmweSQc7+nJTUSjSylLyqUrZzd0dz+ta4T8k+M5Xg7IESw2VXxMTUGtLIkGLxWEYKWbHgbQx943DaTNCzBLgUr2Myv9otIMVfZvTXp3DhyV6yXT5R/SPJ4nABPE5Hn2b0L/yNnFRajxadU2QiIpEHCwMN4jgLvMdcoPmPuWq3yPVhCPBVQ5heqJLQhNJEGgIUv6nALuDg12BNoaGl0g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=dpdk.org 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=zjcBBN9JnjnVL++Y6uGtR2606yzc6aIQEtoD/PCHMY0=; b=aFuCROciV2Xdrt/AdOJsA4THQh4xduvQXSak2bE4Fxs0Znwddje6edmksZYK8vV6HPtcQIaAMrTS5ACkd0ys3vGvdlEnHP6qIEISajp2cKIXdVaUmPxpa2if6Q7Td2Uw2JUjorBXHqGe34sanjMzH/900MAFR3sgrBSGw2yovHk6u0RC4Pn7gzr+ylwo03/9L5RdnEUwUquey+OeOwN1oX7z7GDLVxUQm4G5mLS/B30uIlwYn4A40UOPj34IWoJT2H1z+tVBBS62HUM7EiDTiaTXXs/TSMZS/3IbsthHkWQ8mJkCFjCtVaFPNG1Zy+wDNzWvwfaLJ+ZEdooYUX6M1w== Received: from DS7PR03CA0141.namprd03.prod.outlook.com (2603:10b6:5:3b4::26) by DM4PR12MB5184.namprd12.prod.outlook.com (2603:10b6:5:397::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Mon, 6 Feb 2023 03:39:34 +0000 Received: from DS1PEPF0000E650.namprd02.prod.outlook.com (2603:10b6:5:3b4:cafe::30) by DS7PR03CA0141.outlook.office365.com (2603:10b6:5:3b4::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32 via Frontend Transport; Mon, 6 Feb 2023 03:39:34 +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 DS1PEPF0000E650.mail.protection.outlook.com (10.167.18.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.21 via Frontend Transport; Mon, 6 Feb 2023 03:39:33 +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; Sun, 5 Feb 2023 19:39:28 -0800 Received: from nvidia.com (10.126.230.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; Sun, 5 Feb 2023 19:39:24 -0800 From: Rongwei Liu To: , , , , CC: , Aman Singh , Yuying Zhang , Ferruh Yigit , "Andrew Rybchenko" Subject: [PATCH v4 1/4] ethdev: add flex item modify field support Date: Mon, 6 Feb 2023 05:39:05 +0200 Message-ID: <20230206033908.2770135-2-rongweil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230206033908.2770135-1-rongweil@nvidia.com> References: <20230130132000.1715473-2-rongweil@nvidia.com> <20230206033908.2770135-1-rongweil@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.37] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E650:EE_|DM4PR12MB5184:EE_ X-MS-Office365-Filtering-Correlation-Id: 4126b7e1-15b0-431b-8e5a-08db07f3c374 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: dLfV4gF/sZJLuHWmsr5g9ga4GBPgtL+t7Pu+B9RapUNwoGfGAkmyrA0BZz/QXriJvDDsa60G8kEZckv31zQXqWkD0briAofN9/HnH1eEiGHEEDC1OuvlLAgLm56e/pQFJ5jhjts05P/KJMg5sc76fCHuXT/sD4Ecj+JP5DJXfkhDZqBz6/m2WTBFHPC2VQYP3mHsCVKbO+jkrz4EpENvExjPXoM1hrhT9RIvVDGTsi0S2qX/yw+kmLYJHt5AnBae/WBoHcrC1Rc754rW6p5Mz4YziLbrGu54uGL4cQfFp1jqfrPPsEIDGOHa9BbtAQuDNZPsv7cFCA6MEvDXJ+4KTfCAYQsMtCx5xUhtGwcswHt0XmuRstyKfeLTwUQ8sjczjq8sGka11UotSvCb73oH8VvQJfgI1/SuLYY61E0nZgHG6MPojggRi6TLMZUIZ56LZ0V1oZd8btr4fjIJjlY+mwE0scvUxjFDAzLa/K6/aRtAPY4fknL6C3ADiy7LM9U1/0Gf8p7r+H0Q2H0Em0IG5i5PXlLANTg7e5Oej73uwnZ5U8P5rQ4m7SLtcBv/MbBCd/xqjAGmAo2DtzvZWLTKBJMwC8pNLE8KHS4fTQyf+ixkMXlE/L0QMacwPwa8HCP1blKZgVuCBKSaR0r4PzFUxUBuLgcZK7iLiRUZ/qp/VsWyS6teNk6RKdS/0l8x1kQs9KupOz100fL034RoOZ8tQBAaWJkZJNcxt4tjT5MFdCI= 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:(13230025)(4636009)(346002)(136003)(376002)(39860400002)(396003)(451199018)(36840700001)(46966006)(40470700004)(186003)(16526019)(36756003)(1076003)(6286002)(6666004)(40460700003)(26005)(82310400005)(356005)(47076005)(7636003)(82740400003)(54906003)(316002)(110136005)(36860700001)(8936002)(40480700001)(55016003)(5660300002)(41300700001)(2906002)(30864003)(7696005)(336012)(83380400001)(426003)(8676002)(4326008)(70206006)(70586007)(2616005)(86362001)(478600001)(21314003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2023 03:39:33.9293 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4126b7e1-15b0-431b-8e5a-08db07f3c374 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: DS1PEPF0000E650.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5184 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 as modify field destination. Add "struct rte_flow_item_flex_handle *flex_handle" into "struct rte_flow_action_modify_data" as union with existed "level" member. This new member is dedicated for modifying flex item. 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 Acked-by: Ori Kam --- app/test-pmd/cmdline_flow.c | 89 ++++++++++++++++++++++++-- doc/guides/prog_guide/rte_flow.rst | 41 +++++++----- doc/guides/rel_notes/release_23_03.rst | 4 ++ lib/ethdev/rte_flow.h | 8 ++- 4 files changed, 116 insertions(+), 26 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, diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 3e6242803d..9ffd7baa7a 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -2905,6 +2905,9 @@ encapsulation level, from outermost to innermost (lower to higher values). For the tag array (in case of multiple tags are supported and present) ``level`` translates directly into the array index. +``flex_handle`` is used to specify the flex item pointer which is being +modified. ``flex_handle`` and ``level`` are mutually exclusive. + ``offset`` specifies the number of bits to skip from a field's start. That allows performing a partial copy of the needed part or to divide a big packet field into multiple smaller fields. Alternatively, ``offset`` allows @@ -2952,23 +2955,27 @@ value as sequence of bytes {xxx, xxx, 0x85, xxx, xxx, xxx}. .. table:: destination/source field definition - +---------------+----------------------------------------------------------+ - | Field | Value | - +===============+==========================================================+ - | ``field`` | ID: packet field, mark, meta, tag, immediate, pointer | - +---------------+----------------------------------------------------------+ - | ``level`` | encapsulation level of a packet field or tag array index | - +---------------+----------------------------------------------------------+ - | ``offset`` | number of bits to skip at the beginning | - +---------------+----------------------------------------------------------+ - | ``value`` | immediate value buffer (source field only, not | - | | applicable to destination) for RTE_FLOW_FIELD_VALUE | - | | field type | - +---------------+----------------------------------------------------------+ - | ``pvalue`` | pointer to immediate value data (source field only, not | - | | applicable to destination) for RTE_FLOW_FIELD_POINTER | - | | field type | - +---------------+----------------------------------------------------------+ + +-----------------+----------------------------------------------------------+ + | Field | Value | + +=================+==========================================================+ + | ``field`` | ID: packet field, mark, meta, tag, immediate, pointer | + +-----------------+----------------------------------------------------------+ + | ``level`` | encapsulation level of a packet field or tag array index | + +-----------------+----------------------------------------------------------+ + | ``flex_handle`` | flex item handle of a packet field | + +-----------------+----------------------------------------------------------+ + | ``offset`` | number of bits to skip at the beginning | + +-----------------+----------------------------------------------------------+ + | ``value`` | immediate value buffer (source field only, not | + | | applicable to destination) for RTE_FLOW_FIELD_VALUE | + | | field type | + | | This field is only 16 bytes, maybe not big enough for | + | | all NICs' flex item | + +-----------------+----------------------------------------------------------+ + | ``pvalue`` | pointer to immediate value data (source field only, not | + | | applicable to destination) for RTE_FLOW_FIELD_POINTER | + | | field type | + +-----------------+----------------------------------------------------------+ Action: ``CONNTRACK`` ^^^^^^^^^^^^^^^^^^^^^ diff --git a/doc/guides/rel_notes/release_23_03.rst b/doc/guides/rel_notes/release_23_03.rst index c15f6fbb9f..3fb6e738e2 100644 --- a/doc/guides/rel_notes/release_23_03.rst +++ b/doc/guides/rel_notes/release_23_03.rst @@ -69,6 +69,10 @@ New Features ``rte_event_dev_config::nb_single_link_event_port_queues`` parameter required for eth_rx, eth_tx, crypto and timer eventdev adapters. +* ethdev: added a new field: + + - modify flex item: ``rte_flow_action_modify_data.flex_handle``. + Removed Items ------------- diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index b60987db4b..ba9f3d50a3 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -3528,6 +3528,7 @@ enum rte_flow_field_id { RTE_FLOW_FIELD_IPV6_ECN, /**< IPv6 ECN. */ RTE_FLOW_FIELD_GTP_PSC_QFI, /**< GTP QFI. */ RTE_FLOW_FIELD_METER_COLOR, /**< Meter color marker. */ + RTE_FLOW_FIELD_FLEX_ITEM, /**< Flex item. */ }; /** @@ -3541,8 +3542,11 @@ struct rte_flow_action_modify_data { RTE_STD_C11 union { struct { - /** Encapsulation level or tag index. */ - uint32_t level; + /** Encapsulation level or tag index or flex item handle. */ + union { + uint32_t level; + struct rte_flow_item_flex_handle *flex_handle; + }; /** Number of bits to skip from a field. */ uint32_t offset; }; -- 2.27.0