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 143B3424B9; Mon, 30 Jan 2023 05:53:45 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C869B410FB; Mon, 30 Jan 2023 05:53:41 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2049.outbound.protection.outlook.com [40.107.244.49]) by mails.dpdk.org (Postfix) with ESMTP id 3CE4740A8A for ; Mon, 30 Jan 2023 05:53:40 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WDqEhEFcRxLg3/lfnZE9OrRuuHO1Fm8YGkbCvbFOdjafgXLyuD4/ERFnyKod7VVrKOVOzG/Zq4VW2SzDJgDkG/pVaoVW0OvuSf8BZ00UWL9yLdi3T3Z6BvrxSP68t1TULAZG7d9eq0NEX97SbYy/jkNfKtF/qQ8C3dGSxB15lq0oUVrcQW9+Ck31MNCsfnPLyw8yVD+QPuZtvOMWZgB+ZnMWSyJS4Ce6OmpMQTJwG1LNeYLPYxHULqNHwb3j1D7mFWwdI+/FHU5tHsrl3djPRhXsQ/jnwI05aabKLTlvqEoQLmxEqV9VHZE54iAmasob4FOOpoesO8YRtFMdaBo+SQ== 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=0YCMmLl8HMEr/ExD04NINSeL8MzcPNdIbWKFkUGqpLo=; b=XwoMXLV73tZHsGwvtJgbyx6G0xayWkEDPkeG25gJ57iWOVOWFtgZx3MqVdnQuqogKWmQh5A9yAT9kluQjpRNJYZ15oPQ3+va81IBpzMOJUEQXGJLQdteoSPYc/Yt1CcgDtW6Z15IdYu8VC921YUY7V/eZ+QXrX8bRIfrdzYiCv+dJtDKBiAa0NrEv9+CpxpgZY6wlxz3ac6xmQ8ToAidnB2LV3pKF5JE0obnCHaoVO4bDeT/9LAUG8ThGS44WzdTbA5E4Cmnd0ai0ZiMW1Hmw+OeJRkv44njyBDW4/aXF7pr2ywI2jclfK5bRCxA/sr54rCrmmHaWrM2OW/VrNdJxQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=0YCMmLl8HMEr/ExD04NINSeL8MzcPNdIbWKFkUGqpLo=; b=Ln704T7YAhCFz94l5fq1IOeUrdYYoMIxGSwkLqeE66MvD+vN8Jeh8qKoxoKdgMScMljrOWxz552GzZQMRHToTjSn/Jb5DL2VsgAIaqx9mpZbVGua2WuH5Rg1dR426gG1TTat758AiwOkQR8USnmUouwNJ+aQ3CgCaaS+T4I58Nt2YCShrOz6OGxtiED4NmB4ele14husVjIDXQJUAhcWes+DJ+7f1a57knAXy+5xC0H4RDpm7B2Nuh4o7zNxOR5faL8GL2zMQbUC9/bh+odhimWXPhSDk/ugQPWlzesKQ4mfQKVwx7xD8sWQ1Ur1bL8uXyoDlz/TnHs9DiWfGRit/w== Received: from MW4PR04CA0186.namprd04.prod.outlook.com (2603:10b6:303:86::11) by IA1PR12MB7686.namprd12.prod.outlook.com (2603:10b6:208:422::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.33; Mon, 30 Jan 2023 04:53:38 +0000 Received: from CO1NAM11FT042.eop-nam11.prod.protection.outlook.com (2603:10b6:303:86:cafe::ef) by MW4PR04CA0186.outlook.office365.com (2603:10b6:303:86::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36 via Frontend Transport; Mon, 30 Jan 2023 04:53:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1NAM11FT042.mail.protection.outlook.com (10.13.174.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Mon, 30 Jan 2023 04:53:37 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Sun, 29 Jan 2023 20:53:26 -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, 29 Jan 2023 20:53:23 -0800 From: Rongwei Liu To: , , , , Aman Singh , Yuying Zhang , Ferruh Yigit , "Andrew Rybchenko" CC: , Subject: [PATCH v3 01/11] ethdev: add flex item modify field support Date: Mon, 30 Jan 2023 06:52:52 +0200 Message-ID: <20230130045302.1560006-2-rongweil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230130045302.1560006-1-rongweil@nvidia.com> References: <3ba49f25-52d0-fe07-02e6-22a71e0fbe13@oktetlabs.ru> <20230130045302.1560006-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: 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: CO1NAM11FT042:EE_|IA1PR12MB7686:EE_ X-MS-Office365-Filtering-Correlation-Id: a00a5846-6e62-4918-77c7-08db027df2f8 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: 2SJ5dz5x4hgznpMPvpoKfOoWZvIs+cOceuVu9OAjrVwvVQuUnRr4Erw900urfeazUV7sMgHU1gpK9kD6QvjuhSuFHs0FYQDAaFlGpVydhZxHBQODEMFWWNnM/x+FFUPu2MES59pndruXNXWxGgbSPVVBIwXR0aDasN5wsoFwQxX56PDe734I8fDBk9KLobpuqj4dEZwB1qazBpJ5crAQLgHjCnWexR92LrIFKN864IHUIGBX8Z9ixP4SK005infnYwscUII42tFjd3aDyjhqByv/eJwq3UVTTeE5yyHSLk/zULZJgGj9cDLrS82vOwwgv5ZjA6BamT/+/UoVgklSCiZdD00rn9xAiNlvgnKvTWbmldwx70B6/otDyspFp/Jxme/K6fkHemi7auLKzBVVxDMSULBdWSEIAzfu2D4TfDbFKolwYrizytQ1L5r1B+3GUtfy/mXiR/Ul0QmeT446NmPxbYVjgHqvJOMRXY1c61e1HmbbuPdo2i1uBCbwIhU9ggJ2g50xr8MFUpbQr0e9pZ07UUH7rB+6+GR18CGzryLwDwO6c0kUXjM9IX5Uzj/vUDPnlCPC223sJM/2C9hZKxuZMxvRFpsjAYW39NSTkurDohIYMnAuUTjkgudMyebSYQLsRlSiWD0NYvT7KgIeTKPmeTxbQNj1mEl+1bLV0ZY4EHRCYmmX5TQ9IKBIUrH3yTqT26Bw9fwdlbcP576IvZifaAddY5nZel7g+GCMexA= X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230025)(4636009)(136003)(346002)(39860400002)(396003)(376002)(451199018)(40470700004)(36840700001)(46966006)(336012)(70586007)(2616005)(70206006)(4326008)(7636003)(82740400003)(82310400005)(40460700003)(36860700001)(36756003)(86362001)(55016003)(54906003)(30864003)(110136005)(316002)(356005)(40480700001)(5660300002)(2906002)(83380400001)(426003)(8936002)(8676002)(41300700001)(47076005)(26005)(478600001)(16526019)(186003)(6666004)(1076003)(107886003)(7696005)(6286002)(21314003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 04:53:37.1875 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a00a5846-6e62-4918-77c7-08db027df2f8 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.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT042.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7686 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..323c07253d 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", + "hash_result", "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 b8c5b68d6c..27d3a0e0da 100644 --- a/doc/guides/rel_notes/release_23_03.rst +++ b/doc/guides/rel_notes/release_23_03.rst @@ -55,6 +55,10 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* 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