From patchwork Thu Jun 1 07:59:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dong Zhou X-Patchwork-Id: 127820 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 24B5542C01; Thu, 1 Jun 2023 10:00:41 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 146FA427F2; Thu, 1 Jun 2023 10:00:41 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2067.outbound.protection.outlook.com [40.107.94.67]) by mails.dpdk.org (Postfix) with ESMTP id D24E6427E9 for ; Thu, 1 Jun 2023 10:00:39 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IYg3NzZRIANem26VoKd3Y/jgkOsewQWlTB79DTkZNyuc8rNiQCTguLz6lmULl+NQEmuG6/oD4zXrGeH/isFPVcQ8BXODmtWB7LgWCsHAy/BTSEUzfoIUNXdggBUPe0ZaX/ixIQX3meLOfzwbq7ecLMYYmY2GkG2EIPhCWyXmm18y+AJSAHC7FX1oSdWIv4RYJG51t+jxOT8MFiPA9Kj8+boqlXQhOh0faiGB0tYafLa20fH83UxCohUbhMCqZGalUdUMBbHzKxs7IuBF2/bYEnEH20AVAB0Z7W9J09+w4E3WuBbtE7uDrRQ0dKQPqJOMktIl6/3GRyMwskEt8p4QaA== 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=wWBNN6Pja01WJ/uJxXsfxX6UZRHNWZLxFQzAGZnoF60=; b=ZZFP1FG2k/QH2syp3QM5gPmiHpKKzJcZ6ljPLHuHPF/Mi0iWjTAXRxzQh53DJ2OsDZJN1Qx4Xj2esfJtrgaTHKRA5kxnLO5RnLuXl9YakfR2W79gQ/SEOls9IkT8PqY6BZ92FpMS7ELAGA6OHZjPhUCZoZ18NwEiIM9FfEgMLNmxzVY3dPyjFghSM9H45eRbdJImG4hzT6H1++oapEXJL3V8Ww6cbQ2IL91EJDDsSU4NThSMIJ0i3YF4wVSD+iMAHwSFl/bvHqM2Uti5RQ5QGULXG6YG2jgP4jIJNz71ItGXJGSmgz0iYem5+qAnri7yoETlJTFYtR7Vrkn/i13SSQ== 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=wWBNN6Pja01WJ/uJxXsfxX6UZRHNWZLxFQzAGZnoF60=; b=LLTkykzyWf6KsdmlKQHcMNujkuDEIOGN+k1Hkj0PQn+icIJZKngNzCeqLu7jrISH4K9l+ijQiizkGQQLPAMwFdOMQuNfE/BT1KrbLzIJcT8WEjeOVFoG5Tv0yVRnKkBa58wIp178gF4mh6vUjUDzIx1M1G3RjqhfOPDU4x4gah3T1AHnyBE9GS+66kkXe+fAGnTNxDPBSiMGL0YoBlZbZFnJHjizLQzKRslKdmi45OhZTyk5eUek7P9w/7To65Gnttlv73TzsB9BRBDmvGFT2a8a2iwzema38lYk01hsvsiMoB+bekvY3lh1Jd76PlGs7RAb9Eqs+fdMHPVQYI43/Q== Received: from MW4P223CA0008.NAMP223.PROD.OUTLOOK.COM (2603:10b6:303:80::13) by MN0PR12MB6342.namprd12.prod.outlook.com (2603:10b6:208:3c1::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.24; Thu, 1 Jun 2023 08:00:37 +0000 Received: from CO1NAM11FT114.eop-nam11.prod.protection.outlook.com (2603:10b6:303:80:cafe::b6) by MW4P223CA0008.outlook.office365.com (2603:10b6:303:80::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.23 via Frontend Transport; Thu, 1 Jun 2023 08:00:36 +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 CO1NAM11FT114.mail.protection.outlook.com (10.13.174.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.23 via Frontend Transport; Thu, 1 Jun 2023 08:00:36 +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.5; Thu, 1 Jun 2023 01:00:17 -0700 Received: from nvidia.com (10.126.231.35) 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.37; Thu, 1 Jun 2023 01:00:14 -0700 From: Dong Zhou To: , , , , Matan Azrad , Suanming Mou CC: , Subject: [PATCH 1/2] net/mlx5: add support for infiniband BTH match Date: Thu, 1 Jun 2023 10:59:59 +0300 Message-ID: <20230601080001.3310444-2-dongzhou@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230601080001.3310444-1-dongzhou@nvidia.com> References: <20230601080001.3310444-1-dongzhou@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] 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: CO1NAM11FT114:EE_|MN0PR12MB6342:EE_ X-MS-Office365-Filtering-Correlation-Id: 099182e4-584f-445c-4c77-08db627648a6 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: IPrTs0APnJGRt5+bP1sE9N/k9j6l1Snu/KYrkBAkWjhIXFnJHXIB6VvMUWQiB2r32VjzXIAMRapcjv02ge+I+XmK+IStiSOVGIJO4xogpH9JiakYi073fegEllAX+nNF6xymMCB7fKyJXPvMulMXPDYKDevR/s60PtZu00GdpiuX3RQXnSpBzPMk/Q5JAJT3hF79oKTHNdzhKUMFSByoicvqEbxg4QvOg2BvRT+gi13tD/4+VR2gRlB6PXaI5fUFXc7H1PMMzPGgInOmRu9n+wJVjoXDsLXbCT15pbXIklEa6gweMFCuWDzL8l3VUreUHejYwHsv5I/wsxnKi+aJPcnvjTM0nChvZG3tdWJohAVxjZs6DjJUIQKumurtEZR8/8TBF8VRjIVHafmI0JzwMmxSyHd+fohfOasUA0Qg9NvMHfayg3Gwc+VXAwtZxmQ6057zII0SpmIDnp1K/SLVmWe1vVONz2cZIk/iP0jDCSBpJ6LyuCRaK6JC7uA8xNBt+T6UD8JAi6CI0cdMmPa6D5KLgs7SNJyA51PEjgr4659cNa28IYsY2MuYYbM0PqeplYqLUz57VZ8GbRGSSk2Z1Mwx7dgFyu2Y6EPBGfX4mKPU39uTk5g2O9nRXd7hrcVD/IbDQNcJn7yqQ+2zXfO4WjGyzBzsgRYZK8zUCvDojrAhqmeYCQgVZRL1XvWOHfo8OT/WixY2LxYb1KIS3qEzIjnXOGHgrXili2SgFZ9vJVbWFXE1m0C95SjCVhoPlERf 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:(13230028)(4636009)(346002)(376002)(39860400002)(396003)(136003)(451199021)(46966006)(40470700004)(36840700001)(40460700003)(7696005)(478600001)(6666004)(36860700001)(1076003)(36756003)(426003)(186003)(83380400001)(47076005)(336012)(6286002)(86362001)(2616005)(16526019)(82310400005)(82740400003)(356005)(7636003)(26005)(55016003)(40480700001)(107886003)(316002)(8936002)(41300700001)(4326008)(70586007)(70206006)(6636002)(5660300002)(8676002)(2906002)(54906003)(110136005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2023 08:00:36.6015 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 099182e4-584f-445c-4c77-08db627648a6 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: CO1NAM11FT114.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6342 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 to match opcode and dst_qp fields in infiniband BTH. Currently, only the RoCEv2 packet is supported, the input BTH match item is defaulted to match one RoCEv2 packet. Signed-off-by: Dong Zhou Acked-by: Ori Kam --- drivers/common/mlx5/mlx5_prm.h | 5 +- drivers/net/mlx5/mlx5_flow.h | 6 ++ drivers/net/mlx5/mlx5_flow_dv.c | 102 ++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 2 deletions(-) diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h index ed3d5efbb7..8f55fd59b3 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -932,7 +932,7 @@ struct mlx5_ifc_fte_match_set_misc_bits { u8 gre_key_h[0x18]; u8 gre_key_l[0x8]; u8 vxlan_vni[0x18]; - u8 reserved_at_b8[0x8]; + u8 bth_opcode[0x8]; u8 geneve_vni[0x18]; u8 lag_rx_port_affinity[0x4]; u8 reserved_at_e8[0x2]; @@ -945,7 +945,8 @@ struct mlx5_ifc_fte_match_set_misc_bits { u8 reserved_at_120[0xa]; u8 geneve_opt_len[0x6]; u8 geneve_protocol_type[0x10]; - u8 reserved_at_140[0x20]; + u8 reserved_at_140[0x8]; + u8 bth_dst_qp[0x18]; u8 inner_esp_spi[0x20]; u8 outer_esp_spi[0x20]; u8 reserved_at_1a0[0x60]; diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 1d116ea0f6..c1d6a71708 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -227,6 +227,9 @@ enum mlx5_feature_name { /* Aggregated affinity item */ #define MLX5_FLOW_ITEM_AGGR_AFFINITY (UINT64_C(1) << 49) +/* IB BTH ITEM. */ +#define MLX5_FLOW_ITEM_IB_BTH (1ull << 51) + /* Outer Masks. */ #define MLX5_FLOW_LAYER_OUTER_L3 \ (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6) @@ -364,6 +367,9 @@ enum mlx5_feature_name { #define MLX5_UDP_PORT_VXLAN 4789 #define MLX5_UDP_PORT_VXLAN_GPE 4790 +/* UDP port numbers for RoCEv2. */ +#define MLX5_UDP_PORT_ROCEv2 4791 + /* UDP port numbers for GENEVE. */ #define MLX5_UDP_PORT_GENEVE 6081 diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index d14661298c..a3b72dbb5f 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -7193,6 +7193,65 @@ flow_dv_validate_item_flex(struct rte_eth_dev *dev, return 0; } +/** + * Validate IB BTH item. + * + * @param[in] dev + * Pointer to the rte_eth_dev structure. + * @param[in] udp_dport + * UDP destination port + * @param[in] item + * Item specification. + * @param root + * Whether action is on root table. + * @param[out] error + * Pointer to the error structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +static int +mlx5_flow_validate_item_ib_bth(struct rte_eth_dev *dev, + uint16_t udp_dport, + const struct rte_flow_item *item, + bool root, + struct rte_flow_error *error) +{ + const struct rte_flow_item_ib_bth *mask = item->mask; + struct mlx5_priv *priv = dev->data->dev_private; + const struct rte_flow_item_ib_bth *valid_mask; + int ret; + + valid_mask = &rte_flow_item_ib_bth_mask; + if (udp_dport && udp_dport != MLX5_UDP_PORT_ROCEv2) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "protocol filtering not compatible" + " with UDP layer"); + if (mask && (mask->hdr.se || mask->hdr.m || mask->hdr.padcnt || + mask->hdr.tver || mask->hdr.pkey || mask->hdr.f || mask->hdr.b || + mask->hdr.rsvd0 || mask->hdr.a || mask->hdr.rsvd1 || + mask->hdr.psn[0] || mask->hdr.psn[1] || mask->hdr.psn[2])) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "only opcode and dst_qp are supported"); + if (root || priv->sh->steering_format_version == + MLX5_STEERING_LOGIC_FORMAT_CONNECTX_5) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "IB BTH item is not supported"); + if (!mask) + mask = &rte_flow_item_ib_bth_mask; + ret = mlx5_flow_item_acceptable(item, (const uint8_t *)mask, + (const uint8_t *)valid_mask, + sizeof(struct rte_flow_item_ib_bth), + MLX5_ITEM_RANGE_NOT_ACCEPTED, error); + if (ret < 0) + return ret; + return 0; +} + /** * Internal validation function. For validating both actions and items. * @@ -7700,6 +7759,14 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, return ret; last_item = MLX5_FLOW_ITEM_AGGR_AFFINITY; break; + case RTE_FLOW_ITEM_TYPE_IB_BTH: + ret = mlx5_flow_validate_item_ib_bth(dev, udp_dport, + items, is_root, error); + if (ret < 0) + return ret; + + last_item = MLX5_FLOW_ITEM_IB_BTH; + break; default: return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, @@ -10971,6 +11038,37 @@ flow_dv_translate_item_aggr_affinity(void *key, affinity_v->affinity & affinity_m->affinity); } +static void +flow_dv_translate_item_ib_bth(void *key, + const struct rte_flow_item *item, + int inner, uint32_t key_type) +{ + const struct rte_flow_item_ib_bth *bth_m; + const struct rte_flow_item_ib_bth *bth_v; + void *headers_v, *misc_v; + uint16_t udp_dport; + char *qpn_v; + int i, size; + + headers_v = inner ? MLX5_ADDR_OF(fte_match_param, key, inner_headers) : + MLX5_ADDR_OF(fte_match_param, key, outer_headers); + if (!MLX5_GET16(fte_match_set_lyr_2_4, headers_v, udp_dport)) { + udp_dport = key_type & MLX5_SET_MATCHER_M ? + 0xFFFF : MLX5_UDP_PORT_ROCEv2; + MLX5_SET(fte_match_set_lyr_2_4, headers_v, udp_dport, udp_dport); + } + if (MLX5_ITEM_VALID(item, key_type)) + return; + MLX5_ITEM_UPDATE(item, key_type, bth_v, bth_m, &rte_flow_item_ib_bth_mask); + misc_v = MLX5_ADDR_OF(fte_match_param, key, misc_parameters); + MLX5_SET(fte_match_set_misc, misc_v, bth_opcode, + bth_v->hdr.opcode & bth_m->hdr.opcode); + qpn_v = MLX5_ADDR_OF(fte_match_set_misc, misc_v, bth_dst_qp); + size = sizeof(bth_m->hdr.dst_qp); + for (i = 0; i < size; ++i) + qpn_v[i] = bth_m->hdr.dst_qp[i] & bth_v->hdr.dst_qp[i]; +} + static uint32_t matcher_zero[MLX5_ST_SZ_DW(fte_match_param)] = { 0 }; #define HEADER_IS_ZERO(match_criteria, headers) \ @@ -13772,6 +13870,10 @@ flow_dv_translate_items(struct rte_eth_dev *dev, flow_dv_translate_item_aggr_affinity(key, items, key_type); last_item = MLX5_FLOW_ITEM_AGGR_AFFINITY; break; + case RTE_FLOW_ITEM_TYPE_IB_BTH: + flow_dv_translate_item_ib_bth(key, items, tunnel, key_type); + last_item = MLX5_FLOW_ITEM_IB_BTH; + break; default: break; } From patchwork Thu Jun 1 08:00:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dong Zhou X-Patchwork-Id: 127821 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4139B42C01; Thu, 1 Jun 2023 10:00:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 337C642C4D; Thu, 1 Jun 2023 10:00:47 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2068.outbound.protection.outlook.com [40.107.237.68]) by mails.dpdk.org (Postfix) with ESMTP id 5122C427E9 for ; Thu, 1 Jun 2023 10:00:46 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NfmYVsJglv3Q9baMPzI8fQItC3tjDTjfsw9DDSfw4HO4BxRoXl5zPwABxbsPV0JYKeG8hPihdZDJDtRHoGo6Xm34WT9crwHDxIvNTUhj5+dASjXxF76mXwdClP5372eHZncWqcOifLL8uI/R/rL58BgqUjilfrwV88TbgZRJcyEZ2t+aSmZMccdJvWxHsHS4jej0wit1mTkUvRGDlmoHY/UHiTESCGPd3XfwklZg+Dsdt5pRZ72cvAstD4aGIVETHnL/GN0TEMgiH+qfusZWvLPG79SDBcFo4l5AWMAmzEGbycna7UlHuuL5dY22tJLwbgbu51f156i+9tdqdPNU1g== 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=/cAhWcDzqtUXa/rGn0ddg9WxEobXTc7QHeax3Uo5XKE=; b=oQ59l85PewZ9xK8iHzMVmm0vNVkIx/O7UsoFZZS/ZrNn5jeCEB+b8V/q8rUe+yofB+P5L1e55xZuYTWsY400MrHAnxxER1tvVSJP3i7MevKHkoI5Iu4jRsBWt25BeeiMjNSvflbGizOp+neAtiRWw9Yi7ajGuZpa4TkrGAl1qHD+QGgpT9b4LWtuMR1D4th9UZXWuWCsF5wCvhnnPQbxwwTiL1XCrgbrM2dAOFE3AXdEvHPOS6ts8yymz2uiXgfqs3S4VhPAiq55pPYQTLCdvw8bhCvKMeBRpTX+Yw36/J4H1P2+6mrwTFuRWuQz2kqk7v74WBmpXZGJ1bg1N8RkNA== 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=/cAhWcDzqtUXa/rGn0ddg9WxEobXTc7QHeax3Uo5XKE=; b=c3OqZzvdzKx+Iaxaq5tL3m6rTnzJi7gpqZi3arAzvLCL/NUtCsXOfREGdFntikWTSc+prOJyZ8uO0ruRf+yFUPdTA7ZLjRZtQtTBDM5bGwRG88lYDukVefncvkW8wnYFMxkw9j0pI29Vri5gqujZAu4CObGadPh4Luk0kr4bgQdLyhJkDbtWg9IGdMYLq0qG6ro4oVUWsWJ131UWcmFdHSHowdI4FltfyzlaZiROk8ckt6arCFWCtfA3XUyry3EueHP33JKgks+JPa8lvJeMQJkQFZPz2bHlzTjZhJtBvQ1uMiMafY49p/QQL2ZzB6jwTiocrNzKuN6i4jjQ3PqiCw== Received: from MW4PR03CA0300.namprd03.prod.outlook.com (2603:10b6:303:b5::35) by DS7PR12MB6238.namprd12.prod.outlook.com (2603:10b6:8:96::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.24; Thu, 1 Jun 2023 08:00:44 +0000 Received: from CO1NAM11FT079.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b5:cafe::a) by MW4PR03CA0300.outlook.office365.com (2603:10b6:303:b5::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.23 via Frontend Transport; Thu, 1 Jun 2023 08:00:44 +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 CO1NAM11FT079.mail.protection.outlook.com (10.13.175.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.23 via Frontend Transport; Thu, 1 Jun 2023 08:00:43 +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.5; Thu, 1 Jun 2023 01:00:22 -0700 Received: from nvidia.com (10.126.231.35) 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.37; Thu, 1 Jun 2023 01:00:19 -0700 From: Dong Zhou To: , , , , Matan Azrad , Suanming Mou CC: , Subject: [PATCH 2/2] net/mlx5/hws: add support for infiniband BTH match Date: Thu, 1 Jun 2023 11:00:00 +0300 Message-ID: <20230601080001.3310444-3-dongzhou@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230601080001.3310444-1-dongzhou@nvidia.com> References: <20230601080001.3310444-1-dongzhou@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] 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: CO1NAM11FT079:EE_|DS7PR12MB6238:EE_ X-MS-Office365-Filtering-Correlation-Id: 3de20d95-4f64-44eb-60f4-08db62764cc9 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: 9GMhq4iMYJikFbXZNyfJJvoF2cLIDvye3TJodpoaWVUeLyrSEoZIn9WrR1bFK3Tk52D7lRDtphAkw1rTx6aXiX1EuYrMWyPy7PRVgoM/kog0YFPgJTKnioClBOmZeHv6uXf4sdCiDIz1+e4HDqUHBVYSSwZfCdHMUQXBl0hsf0IifBgLZg4dnx774OIMsgXiL5a03uknq2Luyou8OIvVGPjS2YOz/72KG8j71ocmas0nbfIM5JeDFJ2ShhE3iNgIexD4o4TjPJ9lxZedqOqFErA3rmjL0qqq2/WfOcTLlZWTwQ5zX4m1JIFcwYNnDq9fDvZoJZtOEfjIlp9PnIECde+rFWpPm+sePC1yGm2to31ks2rIaEaeucjLlkQeCR67mY2cHTf33o5mOKoiSuVG1+7eVP5hgEQoGFB6wkCsaPyIyBPigzssOTbfqts7gIyT6/1tce70eJd/8ugTo7LHjP5pfIl50XI1t8tGt2z/ro6O9RUkWhzKM39SsO/6xAwcosUcodnwd5t9smgrnQ+fNrj7k5u8uEL4hHdq5Sa7inBpqJuaJKAnfXlQ3aR57qacGjEUcZn6q1yD0PYRHpWho5AQI/2mzpvigRB2e5Lx+lc8TlGramN0da1TNF4hkUatmzEcmxX+m56Jn55MA8dJtYy5VlstCydbAiouDQ6xsEbmRe1l5BK6/gdgG4W1m/vtbQphGt9Zi47lsIQ4haxE2RcLp+sEiEMxlXghAHZs7GCdJ/NnxN9rKbBdk4eI1hR9 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:(13230028)(4636009)(39860400002)(136003)(396003)(346002)(376002)(451199021)(46966006)(40470700004)(36840700001)(54906003)(110136005)(5660300002)(8936002)(8676002)(6636002)(2906002)(4326008)(70586007)(70206006)(41300700001)(316002)(478600001)(40460700003)(107886003)(7696005)(6666004)(7636003)(1076003)(82740400003)(40480700001)(6286002)(186003)(16526019)(26005)(36756003)(426003)(83380400001)(47076005)(336012)(36860700001)(82310400005)(55016003)(356005)(86362001)(2616005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2023 08:00:43.5423 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3de20d95-4f64-44eb-60f4-08db62764cc9 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: CO1NAM11FT079.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6238 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 to match opcode and dst_qp fields in infiniband BTH. Currently, only the RoCEv2 packet is supported, the input BTH match item is defaulted to match one RoCEv2 packet. Signed-off-by: Dong Zhou Acked-by: Alex Vesker --- drivers/net/mlx5/hws/mlx5dr_definer.c | 76 ++++++++++++++++++++++++++- drivers/net/mlx5/hws/mlx5dr_definer.h | 2 + drivers/net/mlx5/mlx5_flow_hw.c | 1 + 3 files changed, 78 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/hws/mlx5dr_definer.c b/drivers/net/mlx5/hws/mlx5dr_definer.c index f92d3e8e1f..1a427c9b64 100644 --- a/drivers/net/mlx5/hws/mlx5dr_definer.c +++ b/drivers/net/mlx5/hws/mlx5dr_definer.c @@ -10,6 +10,7 @@ #define ETH_TYPE_IPV6_VXLAN 0x86DD #define ETH_VXLAN_DEFAULT_PORT 4789 #define IP_UDP_PORT_MPLS 6635 +#define UDP_ROCEV2_PORT 4791 #define DR_FLOW_LAYER_TUNNEL_NO_MPLS (MLX5_FLOW_LAYER_TUNNEL & ~MLX5_FLOW_LAYER_MPLS) #define STE_NO_VLAN 0x0 @@ -171,7 +172,9 @@ struct mlx5dr_definer_conv_data { X(SET_BE16, gre_opt_checksum, v->checksum_rsvd.checksum, rte_flow_item_gre_opt) \ X(SET, meter_color, rte_col_2_mlx5_col(v->color), rte_flow_item_meter_color) \ X(SET_BE32, ipsec_spi, v->hdr.spi, rte_flow_item_esp) \ - X(SET_BE32, ipsec_sequence_number, v->hdr.seq, rte_flow_item_esp) + X(SET_BE32, ipsec_sequence_number, v->hdr.seq, rte_flow_item_esp) \ + X(SET, ib_l4_udp_port, UDP_ROCEV2_PORT, rte_flow_item_ib_bth) \ + X(SET, ib_l4_opcode, v->hdr.opcode, rte_flow_item_ib_bth) /* Item set function format */ #define X(set_type, func_name, value, item_type) \ @@ -583,6 +586,16 @@ mlx5dr_definer_mpls_label_set(struct mlx5dr_definer_fc *fc, memcpy(tag + fc->byte_off + sizeof(v->label_tc_s), &v->ttl, sizeof(v->ttl)); } +static void +mlx5dr_definer_ib_l4_qp_set(struct mlx5dr_definer_fc *fc, + const void *item_spec, + uint8_t *tag) +{ + const struct rte_flow_item_ib_bth *v = item_spec; + + memcpy(tag + fc->byte_off, &v->hdr.dst_qp, sizeof(v->hdr.dst_qp)); +} + static int mlx5dr_definer_conv_item_eth(struct mlx5dr_definer_conv_data *cd, struct rte_flow_item *item, @@ -2041,6 +2054,63 @@ mlx5dr_definer_conv_item_flex_parser(struct mlx5dr_definer_conv_data *cd, return 0; } +static int +mlx5dr_definer_conv_item_ib_l4(struct mlx5dr_definer_conv_data *cd, + struct rte_flow_item *item, + int item_idx) +{ + const struct rte_flow_item_ib_bth *m = item->mask; + struct mlx5dr_definer_fc *fc; + bool inner = cd->tunnel; + + /* In order to match on RoCEv2(layer4 ib), we must match + * on ip_protocol and l4_dport. + */ + if (!cd->relaxed) { + fc = &cd->fc[DR_CALC_FNAME(IP_PROTOCOL, inner)]; + if (!fc->tag_set) { + fc->item_idx = item_idx; + fc->tag_mask_set = &mlx5dr_definer_ones_set; + fc->tag_set = &mlx5dr_definer_udp_protocol_set; + DR_CALC_SET(fc, eth_l2, l4_type_bwc, inner); + } + + fc = &cd->fc[DR_CALC_FNAME(L4_DPORT, inner)]; + if (!fc->tag_set) { + fc->item_idx = item_idx; + fc->tag_mask_set = &mlx5dr_definer_ones_set; + fc->tag_set = &mlx5dr_definer_ib_l4_udp_port_set; + DR_CALC_SET(fc, eth_l4, destination_port, inner); + } + } + + if (!m) + return 0; + + if (m->hdr.se || m->hdr.m || m->hdr.padcnt || m->hdr.tver || + m->hdr.pkey || m->hdr.f || m->hdr.b || m->hdr.rsvd0 || + m->hdr.a || m->hdr.rsvd1 || !is_mem_zero(m->hdr.psn, 3)) { + rte_errno = ENOTSUP; + return rte_errno; + } + + if (m->hdr.opcode) { + fc = &cd->fc[MLX5DR_DEFINER_FNAME_IB_L4_OPCODE]; + fc->item_idx = item_idx; + fc->tag_set = &mlx5dr_definer_ib_l4_opcode_set; + DR_CALC_SET_HDR(fc, ib_l4, opcode); + } + + if (!is_mem_zero(m->hdr.dst_qp, 3)) { + fc = &cd->fc[MLX5DR_DEFINER_FNAME_IB_L4_QPN]; + fc->item_idx = item_idx; + fc->tag_set = &mlx5dr_definer_ib_l4_qp_set; + DR_CALC_SET_HDR(fc, ib_l4, qp); + } + + return 0; +} + static int mlx5dr_definer_conv_items_to_hl(struct mlx5dr_context *ctx, struct mlx5dr_match_template *mt, @@ -2182,6 +2252,10 @@ mlx5dr_definer_conv_items_to_hl(struct mlx5dr_context *ctx, item_flags |= MLX5_FLOW_LAYER_MPLS; cd.mpls_idx++; break; + case RTE_FLOW_ITEM_TYPE_IB_BTH: + ret = mlx5dr_definer_conv_item_ib_l4(&cd, items, i); + item_flags |= MLX5_FLOW_ITEM_IB_BTH; + break; default: DR_LOG(ERR, "Unsupported item type %d", items->type); rte_errno = ENOTSUP; diff --git a/drivers/net/mlx5/hws/mlx5dr_definer.h b/drivers/net/mlx5/hws/mlx5dr_definer.h index 90ec4ce845..6b645f4cf0 100644 --- a/drivers/net/mlx5/hws/mlx5dr_definer.h +++ b/drivers/net/mlx5/hws/mlx5dr_definer.h @@ -134,6 +134,8 @@ enum mlx5dr_definer_fname { MLX5DR_DEFINER_FNAME_OKS2_MPLS2_I, MLX5DR_DEFINER_FNAME_OKS2_MPLS3_I, MLX5DR_DEFINER_FNAME_OKS2_MPLS4_I, + MLX5DR_DEFINER_FNAME_IB_L4_OPCODE, + MLX5DR_DEFINER_FNAME_IB_L4_QPN, MLX5DR_DEFINER_FNAME_MAX, }; diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 853c94af9c..f9e7f844ea 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -4969,6 +4969,7 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT: case RTE_FLOW_ITEM_TYPE_ESP: case RTE_FLOW_ITEM_TYPE_FLEX: + case RTE_FLOW_ITEM_TYPE_IB_BTH: break; case RTE_FLOW_ITEM_TYPE_INTEGRITY: /*