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 D2DFD42B95; Thu, 25 May 2023 09:41:40 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 701E842D3A; Thu, 25 May 2023 09:41:39 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2050.outbound.protection.outlook.com [40.107.223.50]) by mails.dpdk.org (Postfix) with ESMTP id 3130542D31 for ; Thu, 25 May 2023 09:41:37 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V2O+FyYBT6UKtIlJZAClSbGtlxTVLn5XYyNkNeN2lrs/fEdYEzCGvZVuGdSAZ7uHmjRuD7i6eWnFxaFfhZYuUbtT3AtN/ST8+t1BoVcpP5rwAzsyY9MNykMQnuyCFz4y6Q0/2MkROfFq7b0/dD3BOExkv7gGe165SNShhQnazoxI8h1jJoJ/MgzWRlFKNjSqcrQOgvoU+zUHfXXBjiTReBehsodudmW6SThSA0wurPAho5CQWOlKGB9rsKj5p6UHPojWfuRZQyJupilCiYbjwwd9dbETUdox2BIEyhkrVAB1/Gs/LbfCk8/NgTOPAizVx4KppUs4+J7+mOx5MmhnQg== 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=OtwSRcZbkeDwKpTPBU0tDyvkfx9bdSfUchQQipwuW2g=; b=BsLHpOLFkPWxfOT7+BXU0xqSp0c0yHyu1JGGQTp/wFWtJ4UswI/kjYZ6kz+Yq4NXjmeqLwo2Nhg55NuBs9kn7i/zxmrQdiqIg+Z4FuBDj3ZclLJnk7LAUa4YwU+Ya3eEovNZvHm50IXlSLGAy7xdSYbwnRjRQO7c3A2/0QsYs4xcbp6lYXVeWQcBj0JzQyI22bq9d9SJ3VFCdSqG3Kk1/meT+mfUwkjcZZLc2W06boKF6PPLtkvV4Q6Gv/tkJocnFxrmTldgw4bY/1/8O4EdV7PS5f+oWDOXWE/5hq2vFMqgbUwPJ7EM1qwOoyWGzeqvWnPZUX4MyspIVVss8547KA== 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=OtwSRcZbkeDwKpTPBU0tDyvkfx9bdSfUchQQipwuW2g=; b=Nnsw8/28kLdUXNv9iW9YQ2h3XhvG1pvMpBAX2JVlHQ/qgqZAbgn2oJfxL/nWO5kJJAKtNG0vCsUHoZUDS8eYNAD5Vu9+gq0kxqgZHDfY91Vt1TcT8EfrA08lZmYHVC2KthELi0LGvsZjGwMXfRLrETCV3zRmcUPDlblOH4xlAhju6JgZScrTXoLq637P2nFdUX7KVhJET+fw2qUG07MdYxzUcaQ6UOU81ZTtKIETIbgvGBuySjYM+rf9a5ycKf3TZz7MV9PFPQL4ae+htihCo/1oXQQKf0spgBK/wLKJj+dzMNSlVqWQezBTVAefkmr4SMjBacFRNOy3m3a0XJQE5A== Received: from MW4PR03CA0313.namprd03.prod.outlook.com (2603:10b6:303:dd::18) by BL3PR12MB6452.namprd12.prod.outlook.com (2603:10b6:208:3bb::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.16; Thu, 25 May 2023 07:41:35 +0000 Received: from CO1NAM11FT076.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dd:cafe::c6) by MW4PR03CA0313.outlook.office365.com (2603:10b6:303:dd::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.15 via Frontend Transport; Thu, 25 May 2023 07:41:34 +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 CO1NAM11FT076.mail.protection.outlook.com (10.13.174.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.30 via Frontend Transport; Thu, 25 May 2023 07:41:34 +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, 25 May 2023 00:41:19 -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, 25 May 2023 00:41:17 -0700 From: Dong Zhou To: , , , "Matan Azrad" , Suanming Mou CC: , Subject: [PATCH v3 3/3] net/mlx5/hws: add support for infiniband BTH match Date: Thu, 25 May 2023 10:40:41 +0300 Message-ID: <20230525074041.2370704-4-dongzhou@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230525074041.2370704-1-dongzhou@nvidia.com> References: <20230524100805.2215154-1-dongzhou@nvidia.com> <20230525074041.2370704-1-dongzhou@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT076:EE_|BL3PR12MB6452:EE_ X-MS-Office365-Filtering-Correlation-Id: 653295e1-5c8d-419f-ed88-08db5cf37710 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: oM0P3hLoIJQ7gWP4BWE9EzvD9+FtEJw0xWBUk76RNCW2GMpFyqt6b5wt9Ab5QHlRCxnVc3Zlilj7J/Zf5X93PBivL/qRZj9kf9KToH82BFkP8zOAE1dILU2SrnnSWrileS1EheSW3EDEGiTHUwV6+oNEfH2pJ3GL1Fx7oCR6UvUABqfpq+xrFxYKzd1lIEcx6Rj6ik8X+L/ughhmK5eJzufyl6zIk3zDcr3XTAlj2aPK2vkPxJJmu7Ye2CIBNpTqjKdyf0A+e7fwWxixjgTwaekgyDeknqJWSAgp1sw700GlSAsKvmdQ1XePQlNZjY3b1U3FAnye6Fwpm1Nl0W/FIw81SoonSCc5uhpEZnhXVzuI4PevuxJ9eQoTH6dzRx8N4oFhqJm7aPf+dbN25c+8LXhfxch08IkCMReO+lNGupPy+JuBp7Womfshhh/n39Jn/eYtgM9kkplbcSsUeemuanikHIQu51w0WnjdShi6tC3t8xCcNJtRge+yizhLwWZHh2cNXpQXmu5L+ooOjAqGL5UOYCR5ZpPaVT/JIEl1sJkQ4fKomo9Vph1b6jirnO6JSLLYqqDWWyt/1ZjZVVPtykDzg2gnkIVO497o/72wdpL1R4RJaoei3BIFWJwhJFg8od5aF8dyLMY49cjHJvz6ddK/dmSYVZZKAUt8W2UEDT93xq5M0yYTfDWwrpeTp9E/nQTaadVQg2ZC34VxjbgpUvqHHOt+uzWhY+hf3a4ggnec4NnPqsiIs+WLHljDB8F3 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)(396003)(39860400002)(136003)(376002)(346002)(451199021)(40470700004)(46966006)(36840700001)(70586007)(6636002)(4326008)(36756003)(8676002)(8936002)(5660300002)(107886003)(70206006)(316002)(110136005)(54906003)(478600001)(41300700001)(7696005)(40460700003)(6666004)(40480700001)(55016003)(7636003)(356005)(82740400003)(36860700001)(2906002)(16526019)(6286002)(186003)(83380400001)(47076005)(426003)(336012)(1076003)(86362001)(2616005)(82310400005)(26005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2023 07:41:34.5901 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 653295e1-5c8d-419f-ed88-08db5cf37710 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: CO1NAM11FT076.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6452 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 --- 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: /* -- 2.27.0