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 047B243AA0; Wed, 7 Feb 2024 16:56:34 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0728F42E16; Wed, 7 Feb 2024 16:56:06 +0100 (CET) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2055.outbound.protection.outlook.com [40.107.95.55]) by mails.dpdk.org (Postfix) with ESMTP id E80FD42DFC for ; Wed, 7 Feb 2024 16:56:02 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a9jnXvN4uZmEtRVT4XBclJkwfNf/IH3LIA6KDsoNreOhjkJPOPSym8u1Qi9NRKXOp6243dJCPWXKJ307OxAK7fKViuIE/u+YF4zg49ocAQUdOwEj7ShR6jUW/8yEYkLYMvkMhQ4tltjtOaz3eRsAT/hDrX7H8WPjeKLyB806kppIS1AOYzuslPL79dGV0A/ycmpWXOj4T1DgKuqX5W/JIazM5wK1O069pAmK2F7OFeZFlAA+VTXW2Ei91M/X/rr57rXKM0uNpVDzhLR5b/mFjZi+HuTsol/IxkyJX5bD1mI9lxHvj1KK2K0sUupGxdAuBfyZRYcfpAxyjEfN5gpyig== 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=/MNZUKjWWFSgfOlU1U+QqBs80oCtcNQ9jRpjTtT6KbU=; b=BqO0i8qDjtSj4hZXXJffmxI9UCEwv+JWncfW681qjex3LzyWwXVxcmRuL3PobBw+IunHkj2x5Eyq5IrFsv15p/jQbq6/inyUD810MVH+NWLBjdJvMVB+8yff4bAwmTFK2+O0U9qRzOR5AkXc2Ip9eNJ43+aR1TWMKlzpg4LN78a4/Gr3qHqiE2TkxVKouHq2tI55B7IvFysFs13AuH0LM0tejJp9j9YbbP/Aoxc1WX64FfUx7A35ImC6F2pRShPnt3csCUDl+NxYVCVEXUSVm7h5GmfadQp3SSLrcufnAmmasa5T3Oq9TYLJQIyO0bMIIJjby3hw+nr6kInG1DaZFw== 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 (0) 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=/MNZUKjWWFSgfOlU1U+QqBs80oCtcNQ9jRpjTtT6KbU=; b=sgV8Cpt1FgtKyQ05gKmMI6NnVGBJo9cjx9Wa4ULYvGKQIpcx5ZTkiKy5ncqIgzI5QmOsK0BTja1G5d9BwfoQ8JMzdp7vtjKY2rOQvhP5Y62aG5TbjJeGMJ/cRAMGSj4aVWDOktOJhCVdZdK0CEgXkZdkTk1prpnXuoL+7vUSsklzY8pNek2dDhAxQjZTfXSJqHzgFtyYh3e3HaThqzXwgk5/VK0ZpFA3F0Q2u4yZz/ehAfCXs4krel8pshv+yne+cdEeSUYJbLZUgwn/lB5F8eQn62a3RicciIXOkhNF89rSrKiKRkDDvQrNI/Dp+p3Sg2nfHOwnU2pKzrs27NVdLg== Received: from SA1P222CA0191.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:3c4::24) by CH0PR12MB5106.namprd12.prod.outlook.com (2603:10b6:610:bd::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.14; Wed, 7 Feb 2024 15:56:00 +0000 Received: from SA2PEPF000015CD.namprd03.prod.outlook.com (2603:10b6:806:3c4:cafe::94) by SA1P222CA0191.outlook.office365.com (2603:10b6:806:3c4::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.38 via Frontend Transport; Wed, 7 Feb 2024 15:55:59 +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 SA2PEPF000015CD.mail.protection.outlook.com (10.167.241.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.19 via Frontend Transport; Wed, 7 Feb 2024 15:55:59 +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.41; Wed, 7 Feb 2024 07:55:52 -0800 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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.1258.12; Wed, 7 Feb 2024 07:55:51 -0800 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12 via Frontend Transport; Wed, 7 Feb 2024 07:55:49 -0800 From: Michael Baum To: CC: Matan Azrad , Dariusz Sosnowski , Raslan Darawsheh , Viacheslav Ovsiienko , Ori Kam , Suanming Mou Subject: [PATCH v2 5/7] net/mlx5: add support for modify inner fields Date: Wed, 7 Feb 2024 17:55:31 +0200 Message-ID: <20240207155533.1582031-6-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240207155533.1582031-1-michaelba@nvidia.com> References: <20240206143950.1499532-1-michaelba@nvidia.com> <20240207155533.1582031-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015CD:EE_|CH0PR12MB5106:EE_ X-MS-Office365-Filtering-Correlation-Id: a0301cf1-1b26-40d9-18d0-08dc27f54753 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IOjAK4deK8kCcRiiqQAEcWtEwwqoDjK7In75tI2CZqbtSCmpRdAFcCDO8+xXmv9RzoBkkERJGwBw2MAJahiorebRb+IyVfqUzqVDcHDX/R2GibS2qaweKF8N//XtfKSHwJ8DTGNyBqbkU+ahF3PyoCSHKKmj951QjwPcUiiQ2nvIllHQmNmuzx7A5VCImZXfGEzIpBFkT5IiircRqnrEGo4gUJK27REMJlXOr28+32ukMcdHTd4zPjMa3jDMfB3I2QtznLcmwjM1Emnzpz9Q1ojcsxo1pVSJLK/i/Otvd1iAWKvwTrFKqqqqg6ESdMMIRWtfoUlK4xXYDktZU+CuXHXHF7Qhlyt8p+PbHvRlfuBFyomziYVlS4bOdYq2Nwo8GnIf7ZMq1eochm3CftqhVi7QJ3NjDO7KyGV3EqqrpgPd3W0CVc5Lc50urZLZq8AtVEufHO0azuOyu2UPxnm8+leSh/ct6PYQJ2uNHCn5n4csPa/LumFARIliPZkTfzub75S2Deix/ZivC4/q1th546EhQaHjY1D9kJP13gE2T4Z1RZTB9O1cwMvp5eXPL+hrCHgtw7g4kfvOJcqCmXh95IEQAkHcG2EXbdBy7EM8syGkofdrmG7ajFmjd9POwXrIRWHoZ3Rj8Bi52RQmkKEZVxeuuDy9l5jNsGqkEIOUcsr+i30v3St6ybWJdI1joYoVKa68yKsJOvWSTzYo3lMnD9IKo7qutAtHBVqz47X61oC/W4bA+t937YkQRoEkBCF7 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:(13230031)(4636009)(346002)(39860400002)(396003)(136003)(376002)(230273577357003)(230922051799003)(64100799003)(82310400011)(186009)(1800799012)(451199024)(36840700001)(46966006)(40470700004)(6916009)(83380400001)(7636003)(54906003)(82740400003)(316002)(356005)(4326008)(426003)(2616005)(86362001)(107886003)(70206006)(26005)(6286002)(6666004)(47076005)(7696005)(2906002)(70586007)(5660300002)(30864003)(55016003)(478600001)(8676002)(336012)(8936002)(1076003)(40480700001)(40460700003)(36756003)(36860700001)(41300700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2024 15:55:59.5460 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a0301cf1-1b26-40d9-18d0-08dc27f54753 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: SA2PEPF000015CD.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5106 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 This patch adds support for copying from inner fields using "level" 2. Signed-off-by: Michael Baum --- doc/guides/nics/mlx5.rst | 28 +++++- doc/guides/rel_notes/release_24_03.rst | 2 + drivers/net/mlx5/mlx5_flow.c | 12 ++- drivers/net/mlx5/mlx5_flow_dv.c | 113 +++++++++++---------- drivers/net/mlx5/mlx5_flow_hw.c | 130 ++++++++++++++++++++++++- 5 files changed, 224 insertions(+), 61 deletions(-) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index fa013b03bb..5439e8fd7d 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -595,7 +595,6 @@ Limitations Only DWs configured in :ref:`parser creation ` can be modified, 'type' and 'class' fields can be modified when ``match_on_class_mode=2``. - Modification of GENEVE TLV option data supports one DW per action. - - Encapsulation levels are not supported, can modify outermost header fields only. - Offsets cannot skip past the boundary of a field. - If the field type is ``RTE_FLOW_FIELD_MAC_TYPE`` and packet contains one or more VLAN headers, @@ -609,6 +608,33 @@ Limitations - For flow metadata fields (e.g. META or TAG) offset specifies the number of bits to skip from field's start, starting from LSB in the least significant byte, in the host order. + - Modification of the MPLS header is supported with some limitations: + + - Only in HW steering. + - Only in ``src`` field. + - Only for outermost tunnel header (``level=2``). + For ``RTE_FLOW_FIELD_MPLS``, + the default encapsulation level ``0`` describes the outermost tunnel header. + + .. note:: + + the default encapsulation level ``0`` describes the "outermost that match is supported", + currently it is first tunnel, but it can be changed to outer when it is supported. + + - Default encapsulation level ``0`` describes outermost. + - Encapsulation level ``1`` is supported. + - Encapsulation level ``2`` is supported with some limitations: + + - Only in HW steering. + - Only in ``src`` field. + - ``RTE_FLOW_FIELD_VLAN_ID`` is not supported. + - ``RTE_FLOW_FIELD_IPV4_PROTO`` is not supported. + - ``RTE_FLOW_FIELD_IPV6_PROTO/DSCP/ECN`` are not supported. + - ``RTE_FLOW_FIELD_ESP_PROTO/SPI/SEQ_NUM`` are not supported. + - ``RTE_FLOW_FIELD_TCP_SEQ/ACK_NUM`` are not supported. + - Second tunnel fields are not supported. + + - Encapsulation levels greater than ``2`` are not supported. - Age action: diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst index f548eacc5e..a504aebe15 100644 --- a/doc/guides/rel_notes/release_24_03.rst +++ b/doc/guides/rel_notes/release_24_03.rst @@ -92,6 +92,8 @@ New Features * Added support for accumulating from src field to dst field. + * Added support for copy inner fields in HW Steering flow engine. + * Added support for VXLAN-GPE flags/rsvd0/rsvd fields matching in DV flow engine (``dv_flow_en`` = 1). diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 40376c99ba..b8cb385564 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -2507,10 +2507,14 @@ flow_validate_modify_field_level(const struct rte_flow_field_data *data, if (data->level == 0) return 0; if (data->field != RTE_FLOW_FIELD_TAG && - data->field != (enum rte_flow_field_id)MLX5_RTE_FLOW_FIELD_META_REG) - return rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ACTION, NULL, - "inner header fields modification is not supported"); + data->field != (enum rte_flow_field_id)MLX5_RTE_FLOW_FIELD_META_REG) { + if (data->level > 1) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION, + NULL, + "inner header fields modification is not supported"); + return 0; + } if (data->tag_index != 0) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, NULL, diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 6fded15d91..46f9f59e67 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -82,6 +82,9 @@ } \ } while (0) +#define CALC_MODI_ID(field, level) \ + (((level) > 1) ? MLX5_MODI_IN_##field : MLX5_MODI_OUT_##field) + union flow_dv_attr { struct { uint32_t valid:1; @@ -1638,8 +1641,8 @@ mlx5_flow_field_id_to_modify_info MLX5_ASSERT(data->offset + width <= 48); off_be = 48 - (data->offset + width); if (off_be < 16) { - info[idx] = (struct field_modify_info){2, 4, - MLX5_MODI_OUT_DMAC_15_0}; + modi_id = CALC_MODI_ID(DMAC_15_0, data->level); + info[idx] = (struct field_modify_info){2, 4, modi_id}; length = off_be + width <= 16 ? width : 16 - off_be; if (mask) mask[1] = flow_modify_info_mask_16(length, @@ -1654,8 +1657,8 @@ mlx5_flow_field_id_to_modify_info } else { off_be -= 16; } - info[idx] = (struct field_modify_info){4, 0, - MLX5_MODI_OUT_DMAC_47_16}; + modi_id = CALC_MODI_ID(DMAC_47_16, data->level); + info[idx] = (struct field_modify_info){4, 0, modi_id}; if (mask) mask[0] = flow_modify_info_mask_32(width, off_be); else @@ -1665,8 +1668,8 @@ mlx5_flow_field_id_to_modify_info MLX5_ASSERT(data->offset + width <= 48); off_be = 48 - (data->offset + width); if (off_be < 16) { - info[idx] = (struct field_modify_info){2, 4, - MLX5_MODI_OUT_SMAC_15_0}; + modi_id = CALC_MODI_ID(SMAC_15_0, data->level); + info[idx] = (struct field_modify_info){2, 4, modi_id}; length = off_be + width <= 16 ? width : 16 - off_be; if (mask) mask[1] = flow_modify_info_mask_16(length, @@ -1681,8 +1684,8 @@ mlx5_flow_field_id_to_modify_info } else { off_be -= 16; } - info[idx] = (struct field_modify_info){4, 0, - MLX5_MODI_OUT_SMAC_47_16}; + modi_id = CALC_MODI_ID(SMAC_47_16, data->level); + info[idx] = (struct field_modify_info){4, 0, modi_id}; if (mask) mask[0] = flow_modify_info_mask_32(width, off_be); else @@ -1704,8 +1707,8 @@ mlx5_flow_field_id_to_modify_info case RTE_FLOW_FIELD_MAC_TYPE: MLX5_ASSERT(data->offset + width <= 16); off_be = 16 - (data->offset + width); - info[idx] = (struct field_modify_info){2, 0, - MLX5_MODI_OUT_ETHERTYPE}; + modi_id = CALC_MODI_ID(ETHERTYPE, data->level); + info[idx] = (struct field_modify_info){2, 0, modi_id}; if (mask) mask[idx] = flow_modify_info_mask_16(width, off_be); else @@ -1714,8 +1717,8 @@ mlx5_flow_field_id_to_modify_info case RTE_FLOW_FIELD_IPV4_IHL: MLX5_ASSERT(data->offset + width <= 4); off_be = 4 - (data->offset + width); - info[idx] = (struct field_modify_info){1, 0, - MLX5_MODI_OUT_IPV4_IHL}; + modi_id = CALC_MODI_ID(IPV4_IHL, data->level); + info[idx] = (struct field_modify_info){1, 0, modi_id}; if (mask) mask[idx] = flow_modify_info_mask_8(width, off_be); else @@ -1724,8 +1727,8 @@ mlx5_flow_field_id_to_modify_info case RTE_FLOW_FIELD_IPV4_DSCP: MLX5_ASSERT(data->offset + width <= 6); off_be = 6 - (data->offset + width); - info[idx] = (struct field_modify_info){1, 0, - MLX5_MODI_OUT_IP_DSCP}; + modi_id = CALC_MODI_ID(IP_DSCP, data->level); + info[idx] = (struct field_modify_info){1, 0, modi_id}; if (mask) mask[idx] = flow_modify_info_mask_8(width, off_be); else @@ -1734,8 +1737,8 @@ mlx5_flow_field_id_to_modify_info case RTE_FLOW_FIELD_IPV4_TOTAL_LEN: MLX5_ASSERT(data->offset + width <= 16); off_be = 16 - (data->offset + width); - info[idx] = (struct field_modify_info){2, 0, - MLX5_MODI_OUT_IPV4_TOTAL_LEN}; + modi_id = CALC_MODI_ID(IPV4_TOTAL_LEN, data->level); + info[idx] = (struct field_modify_info){2, 0, modi_id}; if (mask) mask[idx] = flow_modify_info_mask_16(width, off_be); else @@ -1744,8 +1747,8 @@ mlx5_flow_field_id_to_modify_info case RTE_FLOW_FIELD_IPV4_TTL: MLX5_ASSERT(data->offset + width <= 8); off_be = 8 - (data->offset + width); - info[idx] = (struct field_modify_info){1, 0, - MLX5_MODI_OUT_IPV4_TTL}; + modi_id = CALC_MODI_ID(IPV4_TTL, data->level); + info[idx] = (struct field_modify_info){1, 0, modi_id}; if (mask) mask[idx] = flow_modify_info_mask_8(width, off_be); else @@ -1754,8 +1757,8 @@ mlx5_flow_field_id_to_modify_info case RTE_FLOW_FIELD_IPV4_SRC: MLX5_ASSERT(data->offset + width <= 32); off_be = 32 - (data->offset + width); - info[idx] = (struct field_modify_info){4, 0, - MLX5_MODI_OUT_SIPV4}; + modi_id = CALC_MODI_ID(SIPV4, data->level); + info[idx] = (struct field_modify_info){4, 0, modi_id}; if (mask) mask[idx] = flow_modify_info_mask_32(width, off_be); else @@ -1764,8 +1767,8 @@ mlx5_flow_field_id_to_modify_info case RTE_FLOW_FIELD_IPV4_DST: MLX5_ASSERT(data->offset + width <= 32); off_be = 32 - (data->offset + width); - info[idx] = (struct field_modify_info){4, 0, - MLX5_MODI_OUT_DIPV4}; + modi_id = CALC_MODI_ID(DIPV4, data->level); + info[idx] = (struct field_modify_info){4, 0, modi_id}; if (mask) mask[idx] = flow_modify_info_mask_32(width, off_be); else @@ -1795,8 +1798,8 @@ mlx5_flow_field_id_to_modify_info case RTE_FLOW_FIELD_IPV6_PAYLOAD_LEN: MLX5_ASSERT(data->offset + width <= 16); off_be = 16 - (data->offset + width); - info[idx] = (struct field_modify_info){2, 0, - MLX5_MODI_OUT_IPV6_PAYLOAD_LEN}; + modi_id = CALC_MODI_ID(IPV6_PAYLOAD_LEN, data->level); + info[idx] = (struct field_modify_info){2, 0, modi_id}; if (mask) mask[idx] = flow_modify_info_mask_16(width, off_be); else @@ -1805,8 +1808,8 @@ mlx5_flow_field_id_to_modify_info case RTE_FLOW_FIELD_IPV6_HOPLIMIT: MLX5_ASSERT(data->offset + width <= 8); off_be = 8 - (data->offset + width); - info[idx] = (struct field_modify_info){1, 0, - MLX5_MODI_OUT_IPV6_HOPLIMIT}; + modi_id = CALC_MODI_ID(IPV6_HOPLIMIT, data->level); + info[idx] = (struct field_modify_info){1, 0, modi_id}; if (mask) mask[idx] = flow_modify_info_mask_8(width, off_be); else @@ -1818,10 +1821,10 @@ mlx5_flow_field_id_to_modify_info * arranged according to network byte ordering. */ struct field_modify_info fields[] = { - { 4, 0, MLX5_MODI_OUT_SIPV6_127_96 }, - { 4, 4, MLX5_MODI_OUT_SIPV6_95_64 }, - { 4, 8, MLX5_MODI_OUT_SIPV6_63_32 }, - { 4, 12, MLX5_MODI_OUT_SIPV6_31_0 }, + { 4, 0, CALC_MODI_ID(SIPV6_127_96, data->level)}, + { 4, 4, CALC_MODI_ID(SIPV6_95_64, data->level)}, + { 4, 8, CALC_MODI_ID(SIPV6_63_32, data->level)}, + { 4, 12, CALC_MODI_ID(SIPV6_31_0, data->level)}, }; /* First mask to be modified is the mask of 4th address byte. */ uint32_t midx = 3; @@ -1861,10 +1864,10 @@ mlx5_flow_field_id_to_modify_info * arranged according to network byte ordering. */ struct field_modify_info fields[] = { - { 4, 0, MLX5_MODI_OUT_DIPV6_127_96 }, - { 4, 4, MLX5_MODI_OUT_DIPV6_95_64 }, - { 4, 8, MLX5_MODI_OUT_DIPV6_63_32 }, - { 4, 12, MLX5_MODI_OUT_DIPV6_31_0 }, + { 4, 0, CALC_MODI_ID(DIPV6_127_96, data->level)}, + { 4, 4, CALC_MODI_ID(DIPV6_95_64, data->level)}, + { 4, 8, CALC_MODI_ID(DIPV6_63_32, data->level)}, + { 4, 12, CALC_MODI_ID(DIPV6_31_0, data->level)}, }; /* First mask to be modified is the mask of 4th address byte. */ uint32_t midx = 3; @@ -1901,8 +1904,8 @@ mlx5_flow_field_id_to_modify_info case RTE_FLOW_FIELD_TCP_PORT_SRC: MLX5_ASSERT(data->offset + width <= 16); off_be = 16 - (data->offset + width); - info[idx] = (struct field_modify_info){2, 0, - MLX5_MODI_OUT_TCP_SPORT}; + modi_id = CALC_MODI_ID(TCP_SPORT, data->level); + info[idx] = (struct field_modify_info){2, 0, modi_id}; if (mask) mask[idx] = flow_modify_info_mask_16(width, off_be); else @@ -1911,8 +1914,8 @@ mlx5_flow_field_id_to_modify_info case RTE_FLOW_FIELD_TCP_PORT_DST: MLX5_ASSERT(data->offset + width <= 16); off_be = 16 - (data->offset + width); - info[idx] = (struct field_modify_info){2, 0, - MLX5_MODI_OUT_TCP_DPORT}; + modi_id = CALC_MODI_ID(TCP_DPORT, data->level); + info[idx] = (struct field_modify_info){2, 0, modi_id}; if (mask) mask[idx] = flow_modify_info_mask_16(width, off_be); else @@ -1921,8 +1924,8 @@ mlx5_flow_field_id_to_modify_info case RTE_FLOW_FIELD_TCP_SEQ_NUM: MLX5_ASSERT(data->offset + width <= 32); off_be = 32 - (data->offset + width); - info[idx] = (struct field_modify_info){4, 0, - MLX5_MODI_OUT_TCP_SEQ_NUM}; + modi_id = CALC_MODI_ID(TCP_SEQ_NUM, data->level); + info[idx] = (struct field_modify_info){4, 0, modi_id}; if (mask) mask[idx] = flow_modify_info_mask_32(width, off_be); else @@ -1931,8 +1934,8 @@ mlx5_flow_field_id_to_modify_info case RTE_FLOW_FIELD_TCP_ACK_NUM: MLX5_ASSERT(data->offset + width <= 32); off_be = 32 - (data->offset + width); - info[idx] = (struct field_modify_info){4, 0, - MLX5_MODI_OUT_TCP_ACK_NUM}; + modi_id = CALC_MODI_ID(TCP_ACK_NUM, data->level); + info[idx] = (struct field_modify_info){4, 0, modi_id}; if (mask) mask[idx] = flow_modify_info_mask_32(width, off_be); else @@ -1941,8 +1944,8 @@ mlx5_flow_field_id_to_modify_info case RTE_FLOW_FIELD_TCP_FLAGS: MLX5_ASSERT(data->offset + width <= 9); off_be = 9 - (data->offset + width); - info[idx] = (struct field_modify_info){2, 0, - MLX5_MODI_OUT_TCP_FLAGS}; + modi_id = CALC_MODI_ID(TCP_FLAGS, data->level); + info[idx] = (struct field_modify_info){2, 0, modi_id}; if (mask) mask[idx] = flow_modify_info_mask_16(width, off_be); else @@ -1951,8 +1954,8 @@ mlx5_flow_field_id_to_modify_info case RTE_FLOW_FIELD_TCP_DATA_OFFSET: MLX5_ASSERT(data->offset + width <= 4); off_be = 4 - (data->offset + width); - info[idx] = (struct field_modify_info){1, 0, - MLX5_MODI_OUT_TCP_DATA_OFFSET}; + modi_id = CALC_MODI_ID(TCP_DATA_OFFSET, data->level); + info[idx] = (struct field_modify_info){1, 0, modi_id}; if (mask) mask[idx] = flow_modify_info_mask_8(width, off_be); else @@ -1961,8 +1964,8 @@ mlx5_flow_field_id_to_modify_info case RTE_FLOW_FIELD_UDP_PORT_SRC: MLX5_ASSERT(data->offset + width <= 16); off_be = 16 - (data->offset + width); - info[idx] = (struct field_modify_info){2, 0, - MLX5_MODI_OUT_UDP_SPORT}; + modi_id = CALC_MODI_ID(UDP_SPORT, data->level); + info[idx] = (struct field_modify_info){2, 0, modi_id}; if (mask) mask[idx] = flow_modify_info_mask_16(width, off_be); else @@ -1971,8 +1974,8 @@ mlx5_flow_field_id_to_modify_info case RTE_FLOW_FIELD_UDP_PORT_DST: MLX5_ASSERT(data->offset + width <= 16); off_be = 16 - (data->offset + width); - info[idx] = (struct field_modify_info){2, 0, - MLX5_MODI_OUT_UDP_DPORT}; + modi_id = CALC_MODI_ID(UDP_DPORT, data->level); + info[idx] = (struct field_modify_info){2, 0, modi_id}; if (mask) mask[idx] = flow_modify_info_mask_16(width, off_be); else @@ -2124,8 +2127,8 @@ mlx5_flow_field_id_to_modify_info case RTE_FLOW_FIELD_IPV4_ECN: MLX5_ASSERT(data->offset + width <= 2); off_be = 2 - (data->offset + width); - info[idx] = (struct field_modify_info){1, 0, - MLX5_MODI_OUT_IP_ECN}; + modi_id = CALC_MODI_ID(IP_ECN, data->level); + info[idx] = (struct field_modify_info){1, 0, modi_id}; if (mask) mask[idx] = flow_modify_info_mask_8(width, off_be); else @@ -2221,7 +2224,8 @@ mlx5_flow_field_id_to_modify_info case RTE_FLOW_FIELD_ESP_SPI: MLX5_ASSERT(data->offset + width <= 32); off_be = 32 - (data->offset + width); - info[idx] = (struct field_modify_info){4, 0, MLX5_MODI_OUT_ESP_SPI}; + modi_id = CALC_MODI_ID(ESP_SPI, data->level); + info[idx] = (struct field_modify_info){4, 0, modi_id}; if (mask) mask[idx] = flow_modify_info_mask_32(width, off_be); else @@ -2230,7 +2234,8 @@ mlx5_flow_field_id_to_modify_info case RTE_FLOW_FIELD_ESP_SEQ_NUM: MLX5_ASSERT(data->offset + width <= 32); off_be = 32 - (data->offset + width); - info[idx] = (struct field_modify_info){4, 0, MLX5_MODI_OUT_ESP_SEQ_NUM}; + modi_id = CALC_MODI_ID(ESP_SEQ_NUM, data->level); + info[idx] = (struct field_modify_info){4, 0, modi_id}; if (mask) mask[idx] = flow_modify_info_mask_32(width, off_be); else diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 3af5e1f160..7a1821f457 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -4999,6 +4999,131 @@ flow_hw_modify_field_is_add_dst_valid(const struct rte_flow_action_modify_field return false; } +/** + * Validate the level value for modify field action. + * + * @param[in] data + * Pointer to the rte_flow_field_data structure either src or dst. + * @param[in] inner_supported + * Indicator whether inner should be supported. + * @param[out] error + * Pointer to error structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +static int +flow_hw_validate_modify_field_level(const struct rte_flow_field_data *data, + bool inner_supported, + struct rte_flow_error *error) +{ + switch ((int)data->field) { + case RTE_FLOW_FIELD_START: + case RTE_FLOW_FIELD_VLAN_TYPE: + case RTE_FLOW_FIELD_RANDOM: + case RTE_FLOW_FIELD_FLEX_ITEM: + /* + * Level shouldn't be valid since field isn't supported or + * doesn't use 'level'. + */ + break; + case RTE_FLOW_FIELD_MARK: + case RTE_FLOW_FIELD_META: + case RTE_FLOW_FIELD_METER_COLOR: + case RTE_FLOW_FIELD_HASH_RESULT: + /* For meta data fields encapsulation level is don't-care. */ + break; + case RTE_FLOW_FIELD_TAG: + case MLX5_RTE_FLOW_FIELD_META_REG: + /* + * 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. + * Therefore, for meta tag field only, level is matter. It is + * taken as tag index when 'tag_index' field isn't set, and + * return error otherwise. + */ + if (data->level > 0) { + if (data->tag_index > 0) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + data, + "tag array can be provided using 'level' or 'tag_index' fields, not both"); + DRV_LOG(WARNING, + "tag array provided in 'level' field instead of 'tag_index' field."); + } + break; + case RTE_FLOW_FIELD_MAC_DST: + case RTE_FLOW_FIELD_MAC_SRC: + case RTE_FLOW_FIELD_MAC_TYPE: + case RTE_FLOW_FIELD_IPV4_IHL: + case RTE_FLOW_FIELD_IPV4_TOTAL_LEN: + case RTE_FLOW_FIELD_IPV4_DSCP: + case RTE_FLOW_FIELD_IPV4_ECN: + case RTE_FLOW_FIELD_IPV4_TTL: + case RTE_FLOW_FIELD_IPV4_SRC: + case RTE_FLOW_FIELD_IPV4_DST: + case RTE_FLOW_FIELD_IPV6_PAYLOAD_LEN: + case RTE_FLOW_FIELD_IPV6_HOPLIMIT: + case RTE_FLOW_FIELD_IPV6_SRC: + case RTE_FLOW_FIELD_IPV6_DST: + case RTE_FLOW_FIELD_TCP_PORT_SRC: + case RTE_FLOW_FIELD_TCP_PORT_DST: + case RTE_FLOW_FIELD_TCP_FLAGS: + case RTE_FLOW_FIELD_TCP_DATA_OFFSET: + case RTE_FLOW_FIELD_UDP_PORT_SRC: + case RTE_FLOW_FIELD_UDP_PORT_DST: + if (data->level > 2) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION, + data, + "second inner header fields modification is not supported"); + if (inner_supported) + break; + /* Fallthrough */ + case RTE_FLOW_FIELD_VLAN_ID: + case RTE_FLOW_FIELD_IPV4_PROTO: + case RTE_FLOW_FIELD_IPV6_PROTO: + case RTE_FLOW_FIELD_IPV6_DSCP: + case RTE_FLOW_FIELD_IPV6_ECN: + case RTE_FLOW_FIELD_TCP_SEQ_NUM: + case RTE_FLOW_FIELD_TCP_ACK_NUM: + case RTE_FLOW_FIELD_ESP_PROTO: + case RTE_FLOW_FIELD_ESP_SPI: + case RTE_FLOW_FIELD_ESP_SEQ_NUM: + case RTE_FLOW_FIELD_VXLAN_VNI: + case RTE_FLOW_FIELD_GENEVE_VNI: + case RTE_FLOW_FIELD_GENEVE_OPT_TYPE: + case RTE_FLOW_FIELD_GENEVE_OPT_CLASS: + case RTE_FLOW_FIELD_GENEVE_OPT_DATA: + case RTE_FLOW_FIELD_GTP_TEID: + case RTE_FLOW_FIELD_GTP_PSC_QFI: + if (data->level > 1) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION, + data, + "inner header fields modification is not supported"); + break; + case RTE_FLOW_FIELD_MPLS: + if (data->level == 1) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION, + data, + "outer MPLS header modification is not supported"); + if (data->level > 2) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION, + data, + "inner MPLS header modification is not supported"); + break; + case RTE_FLOW_FIELD_POINTER: + case RTE_FLOW_FIELD_VALUE: + default: + MLX5_ASSERT(false); + } + return 0; +} + static int flow_hw_validate_action_modify_field(struct rte_eth_dev *dev, const struct rte_flow_action *action, @@ -5029,7 +5154,7 @@ flow_hw_validate_action_modify_field(struct rte_eth_dev *dev, return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, action, "immediate value, pointer and hash result cannot be used as destination"); - ret = flow_validate_modify_field_level(&action_conf->dst, error); + ret = flow_hw_validate_modify_field_level(&action_conf->dst, false, error); if (ret) return ret; if (!flow_hw_modify_field_is_geneve_opt(action_conf->dst.field)) { @@ -5076,7 +5201,7 @@ flow_hw_validate_action_modify_field(struct rte_eth_dev *dev, return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, action, "source offset level must be fully masked"); - ret = flow_validate_modify_field_level(&action_conf->src, error); + ret = flow_hw_validate_modify_field_level(&action_conf->src, true, error); if (ret) return ret; } @@ -5141,6 +5266,7 @@ flow_hw_validate_action_modify_field(struct rte_eth_dev *dev, "invalid add_field destination"); return 0; } + static int flow_hw_validate_action_port_representor(struct rte_eth_dev *dev __rte_unused, const struct rte_flow_actions_template_attr *attr, -- 2.25.1