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 D6CD942B81; Tue, 23 May 2023 14:49:12 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 639C842D65; Tue, 23 May 2023 14:48:46 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2055.outbound.protection.outlook.com [40.107.237.55]) by mails.dpdk.org (Postfix) with ESMTP id A629B42D65 for ; Tue, 23 May 2023 14:48:44 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zz1ErGXNICTgHhEsbVwM+sddyinmWaXu0y5TNW3Kmcf//I3M5BKCk6vv7Ofewv6H34XBFvDc94IkGa2c8elJOFAyxokkNygWMB6k+3rRPAuuVY2cYQye37mUiIYroIgCgQwvwvnu17l1M0trAITo7WD/VL9Qz5jXID9ZelYQEZ9XumkziOd3LqGd15VyE3M0ftIpBSM6nzzrZn0eNrRA6l5+4N/ytZUomRL/joQFbOEw6xMcQHz5uUHnlg99EpKGmOytv7q0At9gyPJ+G3YUCxLC6bCPaT8sqWb2ODqkSMf4anxHD08f3VZGqoiqq65z0aSTuuoef6WqVa2wwP+kOA== 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=Qz03AHerhlB4jXZFtzs60GKRJ+Xfa7MIaBEfywMmIfY=; b=dtyvZ3tpj4RjZ7z3wNgWL3rCkDZ8rDb9lPI4obJpkxq+cdthzj7gMKn5QAwCdkm0VRPRzObWNvY/8RB/nIKepHgJpVBZUtijxEu4q6A2oTJh1wY5U7Q591DPHdCMcNC1iC2rxHAMapBtfmpXfgHB2s23GkpY0MdkQIdj4tDdE0WXx5j7Q1bcefbI9xm9hybgs8GNrWTOne20Cez+aaxpRuS7LroYJ7BAq1KM1elnjxMUJQBLF4wH5sgqSklcJb5YtWBFRsq5sYrNrlOTyeH/SqKmOMXSvIuxcxJXq+VLHJraRn/iqZZdUaeFhlZYFr8lQ6zID2QRq7v3Iy5/U8j4Sg== 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=Qz03AHerhlB4jXZFtzs60GKRJ+Xfa7MIaBEfywMmIfY=; b=bxqisOAHcls5ak244LrWfzjuVPT5HIzwzBUm+N6MVee2qxak9RRx0QfyUjIw3N9YAKnCxwg0057lJxh9HoN07xx07+gds6Bz3f9X4+CkarBaP50Mhoxhvonbj+P/+ShCOq4UosOrKyhmflxAssicYn8KpG+JWBvyvIE9LkdD1nvoqDQEKKKKtF1uZ2HnYcWA6nQjUaOcAqAyzGRH6k8Haczyt//RE52NNMZ+69fXAEDcTG+yVmcuN0kPwead5gtoVMjWjciAukKm4u2FEkk2yKl0uQh+wL+Ck1rtHo7sfT/6DlW7qoLvWSQax5l04htgHZoydGXLynMVXrJ9Br6FuA== Received: from CYZPR05CA0034.namprd05.prod.outlook.com (2603:10b6:930:a3::20) by CH3PR12MB9145.namprd12.prod.outlook.com (2603:10b6:610:19b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Tue, 23 May 2023 12:48:42 +0000 Received: from CY4PEPF0000C967.namprd02.prod.outlook.com (2603:10b6:930:a3:cafe::6e) by CYZPR05CA0034.outlook.office365.com (2603:10b6:930:a3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.14 via Frontend Transport; Tue, 23 May 2023 12:48:42 +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 CY4PEPF0000C967.mail.protection.outlook.com (10.167.241.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.13 via Frontend Transport; Tue, 23 May 2023 12:48:41 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) 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.5; Tue, 23 May 2023 05:48:25 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 23 May 2023 05:48:24 -0700 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37 via Frontend Transport; Tue, 23 May 2023 05:48:23 -0700 From: Michael Baum To: CC: Ori Kam , Aman Singh , "Yuying Zhang" , Ferruh Yigit , "Thomas Monjalon" Subject: [PATCH v4 5/5] ethdev: add MPLS header modification support Date: Tue, 23 May 2023 15:48:05 +0300 Message-ID: <20230523124805.3846360-6-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230523124805.3846360-1-michaelba@nvidia.com> References: <20230522192804.3759072-1-michaelba@nvidia.com> <20230523124805.3846360-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000C967:EE_|CH3PR12MB9145:EE_ X-MS-Office365-Filtering-Correlation-Id: 9fb42d52-e982-4497-2cc5-08db5b8c09bd 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: +ARdQZeBBhxlxHicP+aNlKZHId92qXTNnuhg+RN5oFKKV4QfxopMYgsoLhPETKM/D40t5tcAcLiUGJA0wdKxuWFK6cicV9y0BH98tih7wgS0o0TiZxxNTZMf4F9QPOi0ImTlYGnMKOgvougp025e8sFHETq6KngbP1vXQkoElKIdrE4qKzUXXOOHvPrcDAFomE1ZO1g582gBJ6J7bNvfH6DgXl/BQh+JgQcNdj75X+Kc1SrUFT7Qe+RHQHpCRCuklMf/DMVRFtANeLztwGT8DBaB2sfxhUwpE78yqBRHEvatpeghlu6oXIZ3J0E42RrO2BRpvgOZCtW3NdhZZojzvcAG3VZrpQesZnNOdkQNoPmACPeybYXdgUcmZ3w5/aEVLmqRn64yIxIssccuaIAUxRnLQVUEzHv18KYUO3mDEO00qKDYiTzyymbTW1KBSwc7op2oNWQQ+44InmGAJdLqkoEtXWSmuF9Wba5g9Qi7Js5+vVHeGuMtjVYMMZBajBTkaGXPQm/ZQ+b2vKWqs5+Gky1rWwPAhpXZY5pvuD9kwLonbDaJw3fOCr4Yv/8s03M9dt+jj/eiRzUStc5psNMfId4CWpsUq6MVl3Xmvemi1ez5QGjpWZIxAvL4U0ffpR2BDvO6/hhBT9PyeXafc05pwydX0OvxoFReBltcS+sAXzAch9YaPIZw88KLCNpnkaoVvSiiE5oonwfNr8T/nIaCA+E1s1TB9uaEl6wzUwHUEUMn6540uipCSIfGPEPeAUfJ 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:(13230028)(4636009)(396003)(376002)(136003)(39860400002)(346002)(451199021)(36840700001)(40470700004)(46966006)(82310400005)(6916009)(4326008)(70206006)(70586007)(478600001)(86362001)(54906003)(6666004)(41300700001)(7696005)(316002)(5660300002)(8936002)(8676002)(1076003)(26005)(40460700003)(186003)(7636003)(356005)(82740400003)(6286002)(40480700001)(55016003)(2906002)(30864003)(36860700001)(36756003)(426003)(83380400001)(336012)(2616005)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 12:48:41.8748 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9fb42d52-e982-4497-2cc5-08db5b8c09bd 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: CY4PEPF0000C967.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9145 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 support for MPLS modify header using "RTE_FLOW_FIELD_MPLS" id. Since MPLS heaser might appear more the one time in inner/outer/tunnel, a new field was added to "rte_flow_action_modify_data" structure in addition to "level" field. The "tag_index" field is the index of the header inside encapsulation level. It is used for modify multiple MPLS headers in same encapsulation level. This addition enables to modify multiple VLAN headers too, so the description of "RTE_FLOW_FIELD_VLAN_XXXX" was updated. Since the "tag_index" field is added, the "RTE_FLOW_FIELD_TAG" type moves to use it for tag array instead of using "level" field. Using "level" is still supported for backwards compatibility when "tag_index" field is zero. Signed-off-by: Michael Baum Acked-by: Ori Kam --- app/test-pmd/cmdline_flow.c | 24 +++++++++++- doc/guides/prog_guide/rte_flow.rst | 18 ++++++--- doc/guides/rel_notes/release_23_07.rst | 8 +++- drivers/net/mlx5/mlx5_flow.c | 34 +++++++++++++++++ drivers/net/mlx5/mlx5_flow.h | 23 ++++++++++++ drivers/net/mlx5/mlx5_flow_dv.c | 29 +++++++-------- drivers/net/mlx5/mlx5_flow_hw.c | 21 ++++++++--- lib/ethdev/rte_flow.h | 51 ++++++++++++++++++-------- 8 files changed, 162 insertions(+), 46 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 8c1dea53c0..a51e37276b 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -636,6 +636,7 @@ enum index { ACTION_MODIFY_FIELD_DST_TYPE_VALUE, ACTION_MODIFY_FIELD_DST_LEVEL, ACTION_MODIFY_FIELD_DST_LEVEL_VALUE, + ACTION_MODIFY_FIELD_DST_TAG_INDEX, ACTION_MODIFY_FIELD_DST_TYPE_ID, ACTION_MODIFY_FIELD_DST_CLASS_ID, ACTION_MODIFY_FIELD_DST_OFFSET, @@ -643,6 +644,7 @@ enum index { ACTION_MODIFY_FIELD_SRC_TYPE_VALUE, ACTION_MODIFY_FIELD_SRC_LEVEL, ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE, + ACTION_MODIFY_FIELD_SRC_TAG_INDEX, ACTION_MODIFY_FIELD_SRC_TYPE_ID, ACTION_MODIFY_FIELD_SRC_CLASS_ID, ACTION_MODIFY_FIELD_SRC_OFFSET, @@ -859,7 +861,7 @@ static const char *const modify_field_ids[] = { "ipv6_proto", "flex_item", "hash_result", - "geneve_opt_type", "geneve_opt_class", "geneve_opt_data", + "geneve_opt_type", "geneve_opt_class", "geneve_opt_data", "mpls", NULL }; @@ -2301,6 +2303,7 @@ static const enum index next_action_sample[] = { static const enum index action_modify_field_dst[] = { ACTION_MODIFY_FIELD_DST_LEVEL, + ACTION_MODIFY_FIELD_DST_TAG_INDEX, ACTION_MODIFY_FIELD_DST_TYPE_ID, ACTION_MODIFY_FIELD_DST_CLASS_ID, ACTION_MODIFY_FIELD_DST_OFFSET, @@ -2310,6 +2313,7 @@ static const enum index action_modify_field_dst[] = { static const enum index action_modify_field_src[] = { ACTION_MODIFY_FIELD_SRC_LEVEL, + ACTION_MODIFY_FIELD_SRC_TAG_INDEX, ACTION_MODIFY_FIELD_SRC_TYPE_ID, ACTION_MODIFY_FIELD_SRC_CLASS_ID, ACTION_MODIFY_FIELD_SRC_OFFSET, @@ -6398,6 +6402,15 @@ static const struct token token_list[] = { .call = parse_vc_modify_field_level, .comp = comp_none, }, + [ACTION_MODIFY_FIELD_DST_TAG_INDEX] = { + .name = "dst_tag_index", + .help = "destination field tag array", + .next = NEXT(action_modify_field_dst, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + dst.tag_index)), + .call = parse_vc_conf, + }, [ACTION_MODIFY_FIELD_DST_TYPE_ID] = { .name = "dst_type_id", .help = "destination field type ID", @@ -6451,6 +6464,15 @@ static const struct token token_list[] = { .call = parse_vc_modify_field_level, .comp = comp_none, }, + [ACTION_MODIFY_FIELD_SRC_TAG_INDEX] = { + .name = "stc_tag_index", + .help = "source field tag array", + .next = NEXT(action_modify_field_src, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.tag_index)), + .call = parse_vc_conf, + }, [ACTION_MODIFY_FIELD_SRC_TYPE_ID] = { .name = "src_type_id", .help = "source field type ID", diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index ec812de335..e4328e7ed6 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -2925,8 +2925,7 @@ See ``enum rte_flow_field_id`` for the list of supported fields. ``width`` defines a number of bits to use from ``src`` field. -``level`` is used to access any packet field on any encapsulation level -as well as any tag element in the tag array: +``level`` is used to access any packet field on any encapsulation level: - ``0`` means the default behaviour. Depending on the packet type, it can mean outermost, innermost or anything in between. @@ -2934,8 +2933,15 @@ as well as any tag element in the tag array: - ``2`` and subsequent values requests access to the specified packet 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. +``tag_index`` is the index of the header inside encapsulation level. +It is used for modify either ``VLAN`` or ``MPLS`` or ``TAG`` headers which +multiple of them might be supported in same encapsulation level. + +.. note:: + + For ``RTE_FLOW_FIELD_TAG`` type, the tag array was provided in ``level`` + field and it is still supported for backwards compatibility. + When ``tag_index`` is zero, the tag array is taken from ``level`` field. ``type`` is used to specify (along with ``class_id``) the Geneve option which is being modified. @@ -3011,7 +3017,9 @@ and provide immediate value 0xXXXX85XX. +=================+==========================================================+ | ``field`` | ID: packet field, mark, meta, tag, immediate, pointer | +-----------------+----------------------------------------------------------+ - | ``level`` | encapsulation level of a packet field or tag array index | + | ``level`` | encapsulation level of a packet field | + +-----------------+----------------------------------------------------------+ + | ``tag_index`` | tag index inside encapsulation level | +-----------------+----------------------------------------------------------+ | ``type`` | geneve option type | +-----------------+----------------------------------------------------------+ diff --git a/doc/guides/rel_notes/release_23_07.rst b/doc/guides/rel_notes/release_23_07.rst index ce1755096f..fd3e35eea3 100644 --- a/doc/guides/rel_notes/release_23_07.rst +++ b/doc/guides/rel_notes/release_23_07.rst @@ -84,8 +84,12 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= -* The ``level`` field in experimental structure - ``struct rte_flow_action_modify_data`` was reduced to 8 bits. +* ethdev: in experimental structure ``struct rte_flow_action_modify_data``: + + * ``level`` field was reduced to 8 bits. + + * ``tag_index`` field replaced ``level`` field in representing tag array for + ``RTE_FLOW_FIELD_TAG`` type. ABI Changes diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 19f7f92717..867b7b8ea2 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -2318,6 +2318,40 @@ mlx5_validate_action_ct(struct rte_eth_dev *dev, return 0; } +/** + * Validate the level value for modify field action. + * + * @param[in] data + * Pointer to the rte_flow_action_modify_data structure either src or dst. + * @param[out] error + * Pointer to error structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +int +flow_validate_modify_field_level(const struct rte_flow_action_modify_data *data, + struct rte_flow_error *error) +{ + if (data->level == 0) + return 0; + if (data->field != RTE_FLOW_FIELD_TAG) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION, NULL, + "inner header fields modification is not supported"); + if (data->tag_index != 0) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, NULL, + "tag array can be provided using 'level' or 'tag_index' fields, not both"); + /* + * The tag array for RTE_FLOW_FIELD_TAG type is provided using + * 'tag_index' field. In old API, it was provided using 'level' field + * and it is still supported for backwards compatibility. + */ + DRV_LOG(WARNING, "tag array provided in 'level' field instead of 'tag_index' field."); + return 0; +} + /** * Validate ICMP6 item. * diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 1d116ea0f6..cba04b4f45 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1045,6 +1045,26 @@ flow_items_to_tunnel(const struct rte_flow_item items[]) return items[0].spec; } +/** + * Gets the tag array given for RTE_FLOW_FIELD_TAG type. + * + * In old API the value was provided in "level" field, but in new API + * it is provided in "tag_array" field. Since encapsulation level is not + * relevant for metadata, the tag array can be still provided in "level" + * for backwards compatibility. + * + * @param[in] data + * Pointer to tag modify data structure. + * + * @return + * Tag array index. + */ +static inline uint8_t +flow_tag_index_get(const struct rte_flow_action_modify_data *data) +{ + return data->tag_index ? data->tag_index : data->level; +} + /** * Fetch 1, 2, 3 or 4 byte field from the byte array * and return as unsigned integer in host-endian format. @@ -2276,6 +2296,9 @@ int mlx5_flow_validate_action_rss(const struct rte_flow_action *action, int mlx5_flow_validate_action_default_miss(uint64_t action_flags, const struct rte_flow_attr *attr, struct rte_flow_error *error); +int flow_validate_modify_field_level + (const struct rte_flow_action_modify_data *data, + struct rte_flow_error *error); int mlx5_flow_item_acceptable(const struct rte_flow_item *item, const uint8_t *mask, const uint8_t *nic_mask, diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index f136f43b0a..729962a488 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -1896,16 +1896,17 @@ mlx5_flow_field_id_to_modify_info case RTE_FLOW_FIELD_TAG: { MLX5_ASSERT(data->offset + width <= 32); + uint8_t tag_index = flow_tag_index_get(data); int reg; - off_be = (data->level == MLX5_LINEAR_HASH_TAG_INDEX) ? + off_be = (tag_index == MLX5_LINEAR_HASH_TAG_INDEX) ? 16 - (data->offset + width) + 16 : data->offset; if (priv->sh->config.dv_flow_en == 2) reg = flow_hw_get_reg_id(RTE_FLOW_ITEM_TYPE_TAG, - data->level); + tag_index); else reg = mlx5_flow_get_reg_id(dev, MLX5_APP_TAG, - data->level, error); + tag_index, error); if (reg < 0) return; MLX5_ASSERT(reg != REG_NON); @@ -1985,7 +1986,7 @@ mlx5_flow_field_id_to_modify_info { uint32_t meta_mask = priv->sh->dv_meta_mask; uint32_t meta_count = __builtin_popcount(meta_mask); - uint32_t reg = data->level; + uint8_t reg = flow_tag_index_get(data); RTE_SET_USED(meta_count); MLX5_ASSERT(data->offset + width <= meta_count); @@ -5250,6 +5251,14 @@ flow_dv_validate_action_modify_field(struct rte_eth_dev *dev, uint32_t dst_width, src_width; ret = flow_dv_validate_action_modify_hdr(action_flags, action, error); + if (ret) + return ret; + ret = flow_validate_modify_field_level(&action_modify_field->dst, + error); + if (ret) + return ret; + ret = flow_validate_modify_field_level(&action_modify_field->src, + error); if (ret) return ret; if (action_modify_field->src.field == RTE_FLOW_FIELD_FLEX_ITEM || @@ -5279,12 +5288,6 @@ flow_dv_validate_action_modify_field(struct rte_eth_dev *dev, return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, action, "destination offset is too big"); - if (action_modify_field->dst.level && - action_modify_field->dst.field != RTE_FLOW_FIELD_TAG) - return rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ACTION, action, - "inner header fields modification" - " is not supported"); } if (action_modify_field->src.field != RTE_FLOW_FIELD_VALUE && action_modify_field->src.field != RTE_FLOW_FIELD_POINTER) { @@ -5298,12 +5301,6 @@ flow_dv_validate_action_modify_field(struct rte_eth_dev *dev, return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, action, "source offset is too big"); - if (action_modify_field->src.level && - action_modify_field->src.field != RTE_FLOW_FIELD_TAG) - return rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ACTION, action, - "inner header fields modification" - " is not supported"); } if ((action_modify_field->dst.field == action_modify_field->src.field) && diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 1b68a19900..e55e3d6c1a 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -1022,9 +1022,11 @@ flow_hw_modify_field_compile(struct rte_eth_dev *dev, conf->dst.field == RTE_FLOW_FIELD_TAG || conf->dst.field == RTE_FLOW_FIELD_METER_COLOR || conf->dst.field == (enum rte_flow_field_id)MLX5_RTE_FLOW_FIELD_META_REG) { + uint8_t tag_index = flow_tag_index_get(&conf->dst); + value = *(const unaligned_uint32_t *)item.spec; if (conf->dst.field == RTE_FLOW_FIELD_TAG && - conf->dst.level == MLX5_LINEAR_HASH_TAG_INDEX) + tag_index == MLX5_LINEAR_HASH_TAG_INDEX) value = rte_cpu_to_be_32(value << 16); else value = rte_cpu_to_be_32(value); @@ -2055,9 +2057,11 @@ flow_hw_modify_field_construct(struct mlx5_hw_q_job *job, mhdr_action->dst.field == RTE_FLOW_FIELD_TAG || mhdr_action->dst.field == RTE_FLOW_FIELD_METER_COLOR || mhdr_action->dst.field == (enum rte_flow_field_id)MLX5_RTE_FLOW_FIELD_META_REG) { + uint8_t tag_index = flow_tag_index_get(&mhdr_action->dst); + value_p = (unaligned_uint32_t *)values; if (mhdr_action->dst.field == RTE_FLOW_FIELD_TAG && - mhdr_action->dst.level == MLX5_LINEAR_HASH_TAG_INDEX) + tag_index == MLX5_LINEAR_HASH_TAG_INDEX) *value_p = rte_cpu_to_be_32(*value_p << 16); else *value_p = rte_cpu_to_be_32(*value_p); @@ -3546,11 +3550,16 @@ flow_hw_validate_action_modify_field(const struct rte_flow_action *action, const struct rte_flow_action *mask, struct rte_flow_error *error) { - const struct rte_flow_action_modify_field *action_conf = - action->conf; - const struct rte_flow_action_modify_field *mask_conf = - mask->conf; + const struct rte_flow_action_modify_field *action_conf = action->conf; + const struct rte_flow_action_modify_field *mask_conf = mask->conf; + int ret; + ret = flow_validate_modify_field_level(&action_conf->dst, error); + if (ret) + return ret; + ret = flow_validate_modify_field_level(&action_conf->src, error); + if (ret) + return ret; if (action_conf->operation != mask_conf->operation) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, action, diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index f30d4b033f..1df4b49219 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -3740,8 +3740,8 @@ enum rte_flow_field_id { RTE_FLOW_FIELD_START = 0, /**< Start of a packet. */ RTE_FLOW_FIELD_MAC_DST, /**< Destination MAC Address. */ RTE_FLOW_FIELD_MAC_SRC, /**< Source MAC Address. */ - RTE_FLOW_FIELD_VLAN_TYPE, /**< 802.1Q Tag Identifier. */ - RTE_FLOW_FIELD_VLAN_ID, /**< 802.1Q VLAN Identifier. */ + RTE_FLOW_FIELD_VLAN_TYPE, /**< VLAN Tag Identifier. */ + RTE_FLOW_FIELD_VLAN_ID, /**< VLAN Identifier. */ RTE_FLOW_FIELD_MAC_TYPE, /**< EtherType. */ RTE_FLOW_FIELD_IPV4_DSCP, /**< IPv4 DSCP. */ RTE_FLOW_FIELD_IPV4_TTL, /**< IPv4 Time To Live. */ @@ -3775,7 +3775,8 @@ enum rte_flow_field_id { RTE_FLOW_FIELD_HASH_RESULT, /**< Hash result. */ RTE_FLOW_FIELD_GENEVE_OPT_TYPE, /**< GENEVE option type */ RTE_FLOW_FIELD_GENEVE_OPT_CLASS,/**< GENEVE option class */ - RTE_FLOW_FIELD_GENEVE_OPT_DATA /**< GENEVE option data */ + RTE_FLOW_FIELD_GENEVE_OPT_DATA, /**< GENEVE option data */ + RTE_FLOW_FIELD_MPLS /**< MPLS header. */ }; /** @@ -3789,7 +3790,7 @@ struct rte_flow_action_modify_data { RTE_STD_C11 union { struct { - /** Encapsulation level or tag index or flex item handle. */ + /** Encapsulation level and tag index or flex item handle. */ union { struct { /** @@ -3820,20 +3821,38 @@ struct rte_flow_action_modify_data { * * Values other than @p 0 are not * necessarily supported. + * + * @note that for MPLS field, + * encapsulation level also include + * tunnel since MPLS may appear in + * outer, inner or tunnel. */ uint8_t level; - /** - * Geneve option type. relevant only - * for RTE_FLOW_FIELD_GENEVE_OPT_XXXX - * modification type. - */ - uint8_t type; - /** - * Geneve option class. relevant only - * for RTE_FLOW_FIELD_GENEVE_OPT_XXXX - * modification type. - */ - rte_be16_t class_id; + union { + /** + * Tag index array inside + * encapsulation level. + * Used for VLAN, MPLS or TAG + * types. + */ + uint8_t tag_index; + /** + * Geneve option identifier. + * relevant only for + * RTE_FLOW_FIELD_GENEVE_OPT_XXXX + * modification type. + */ + struct { + /** + * Geneve option type. + */ + uint8_t type; + /** + * Geneve option class. + */ + rte_be16_t class_id; + }; + }; }; struct rte_flow_item_flex_handle *flex_handle; }; -- 2.25.1