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 11BE543238; Sun, 29 Oct 2023 17:36:51 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D687142DB1; Sun, 29 Oct 2023 17:34:35 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by mails.dpdk.org (Postfix) with ESMTP id 6A8FD409FA for ; Sun, 29 Oct 2023 17:34:02 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K/J5xEnVptzQnpqzTFsI0qLi1FJLZORfQUYEKhCGtF+cOy/RXOI7E04jfmaYZvTHK33kHJp5Azo2/Ma331lOPIVRCCIZOqoQnsVw0VVZfJJ1Ppk+rTkkz/gI1mD2NJFbfMhrNAF+rVT/waiDnax0y6leTxg8NBlFdVbwNyNFfKl7D9Xog1NjNiw8D6p3P40BOIOKQ4BwYF8PcaD9L/Wtobx2d2E6LOrhgaMgb+FGwrosh0snYCwaWB9cfPp0JDJtlbHTfusfqd/cN6Uaff0zUFIQqZrJdPE3YQco4fBrzoH3TSfSW6r9Xn4hH5/RldQgL3mi5B9EMP+cTrlIj/pETw== 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=d76TQz7UcdzCZaX6z5CGw1EeECdfp09gCN5PFKBgwbM=; b=HZLlVIME9Rv+8TCvq2EBnNkSoHHJ0HpXY78R8nf/R+Zs6FaLgHZbn9GPoMFcCD6aA9t+zgJ5I60hjA5rW/4Ar69nhK6DDN5eIJYThXHk18n08dDHGGUr4rZ5HehBLZMJjcy2BvDNQljeio0p/gkcSw25lBP4YOLizN52RsEAwClk7AqrR1/ph6L7kJTEvZSH65Ewq/GP33MmdPNOtpIdWcb0IO6qbPVnTgi6Wc4S3OLK0NIr5H56HeLDkTwojzy0OVtN+ZnYFrLXKIHelFeTKPLGlLQwiqU9UNTr9cJdnEKV8/E5rqievKzciaYpP+N9XWrgcGlz1yoWjfBds0zRrA== 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=d76TQz7UcdzCZaX6z5CGw1EeECdfp09gCN5PFKBgwbM=; b=Llf7d6wpdS1ae2kmd7DWUIg8PfSBYbmlHVLqe1SWz/oEmECQ+S0r6eKjNlNjjqT+sll+uiWx1cwY59IAN/1baSAxISFpWweokPpo/zJvmzqXT4j/T5qF/qATWX7JXNn6AhHlB645NvacQmqtJYUlUKGoHa9ZKecElpKaQIyBPRi7R99ia6P0hEKCJGX/5WLKE1DRARm4mbGNFl2Of8W+g729EpPH2elZJVFyBBjlqTtnKSxsRAVuhaQ3g06DfqOnCd0YphwNG8IkiFemUWaXZhb+rupHeg/JVgtZukS0fyEJpBN+87iG9NUD+Wg5sxXewis8Q6MtCuoRC9vaCpDFSQ== Received: from BY3PR05CA0048.namprd05.prod.outlook.com (2603:10b6:a03:39b::23) by CH3PR12MB7690.namprd12.prod.outlook.com (2603:10b6:610:14e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.26; Sun, 29 Oct 2023 16:34:00 +0000 Received: from DS2PEPF00003448.namprd04.prod.outlook.com (2603:10b6:a03:39b:cafe::1) by BY3PR05CA0048.outlook.office365.com (2603:10b6:a03:39b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.14 via Frontend Transport; Sun, 29 Oct 2023 16:34:00 +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 DS2PEPF00003448.mail.protection.outlook.com (10.167.17.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.15 via Frontend Transport; Sun, 29 Oct 2023 16:33: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; Sun, 29 Oct 2023 09:33:48 -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.41; Sun, 29 Oct 2023 09:33:45 -0700 From: Gregory Etelson To: CC: , , , Rongwei Liu , Alex Vesker , Ori Kam , Matan Azrad , Viacheslav Ovsiienko , Suanming Mou Subject: [PATCH 28/30] net/mlx5/hws: add setter for IPv6 routing push remove Date: Sun, 29 Oct 2023 18:32:00 +0200 Message-ID: <20231029163202.216450-28-getelson@nvidia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231029163202.216450-1-getelson@nvidia.com> References: <20231029163202.216450-1-getelson@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: DS2PEPF00003448:EE_|CH3PR12MB7690:EE_ X-MS-Office365-Filtering-Correlation-Id: eb4f306d-fff7-49a6-ad0c-08dbd89cdad5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D5d0LGDH/YMkfy3A84OzlcwENVyNvQvqovVfzHIglnPSawe6mp/3Tf+f99+2/Wj6k3IJKaSxuRCqWEtIaHoaUCac9grpZsiHr5Mt5xhmO4ye8JR91jHbMS+62nojqmE8KGgWzESvRNFW9b4bXD/Tn039pQanVqWA2Sl/iPTO0XzpiRMyN2pKaJpXHX1/GUWqSiNCKzpyaWP5PCODXnSs1iwzdR7D660OBOgrw0rZa9xEn6lOVxEsEVBlK20q1fCobbHNX3/Xg9jyAvJJM+RnWFfmZUOt3Wx2YissUbldTbSsrDeCXmUcnHOJdTYv9TmqR/a1ExQlZPiBLtBewbeHE02Jxr3qLieNpL7tRaHqkq8hEGNr+vS5HYYNcu9n0vrXwY9L7UrwPw+aF8oV1uOzlTydjjUhd47cxU8uTIzg19oZFsfVPUWWXm+9y8pF6QL2hoe3ITJIPcGp+x15pn+EB7TGXJyAgSUG5W3vM+L1nNlOELRcu6bc9r5q9x5LJazBQ1QagVUa4sPGLvUSs+ZDy0UYh82diSnTZMDbeh2Rq5kFResBpnj4S/ls9EfS4rcyQqHwPuDh0b4UQEGMnzYSxt4Yv22JmLoSw0RxQmhrJ+quYbl/BCs284i3KyUll+LGO1iJusqnfT978J/vrdIkWqLPMkMlHCO8VIjdm26CfYXsNFl8qApBI4aJ7Kv5Lwq5HnHURSEJv22MlHWX5E64+b+Y/codZsvtbF2hHXfe398iCFEnI8qkCh9w+UochbQG 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)(39860400002)(396003)(136003)(376002)(346002)(230922051799003)(451199024)(186009)(64100799003)(1800799009)(82310400011)(46966006)(40470700004)(36840700001)(40480700001)(40460700003)(55016003)(478600001)(70586007)(70206006)(7696005)(6666004)(83380400001)(36860700001)(36756003)(47076005)(82740400003)(7636003)(356005)(1076003)(107886003)(2616005)(2906002)(41300700001)(26005)(426003)(16526019)(6286002)(336012)(86362001)(4326008)(8936002)(8676002)(316002)(54906003)(6916009)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2023 16:33:59.9429 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eb4f306d-fff7-49a6-ad0c-08dbd89cdad5 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: DS2PEPF00003448.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7690 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 From: Rongwei Liu The rte action will be translated to multiple dr_actions which need different setters to program them. In order to leverage the existing setter logic, there is a new callback introduce which called fetch_opt with unique parameter. For each setter, it may have different reparsing properties. Setter which requires no reparse can't share the same one with the one has reparse enabled even if there is spare space. Signed-off-by: Rongwei Liu Reviewed-by: Alex Vesker Acked-by: Ori Kam --- drivers/net/mlx5/hws/mlx5dr_action.c | 174 +++++++++++++++++++++++++++ drivers/net/mlx5/hws/mlx5dr_action.h | 3 +- 2 files changed, 176 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/hws/mlx5dr_action.c b/drivers/net/mlx5/hws/mlx5dr_action.c index 6ac3c2f782..281b09a582 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.c +++ b/drivers/net/mlx5/hws/mlx5dr_action.c @@ -3311,6 +3311,121 @@ mlx5dr_action_setter_reformat_trailer(struct mlx5dr_actions_apply_data *apply, apply->wqe_data[MLX5DR_ACTION_OFFSET_DW7] = 0; } +static void +mlx5dr_action_setter_ipv6_route_ext_gen_push_mhdr(uint8_t *data, void *mh_data) +{ + uint8_t *action_ptr = mh_data; + uint32_t *ipv6_dst_addr; + uint8_t seg_left; + uint32_t i; + + /* Fetch the last IPv6 address in the segment list which is the next hop */ + seg_left = MLX5_GET(header_ipv6_routing_ext, data, segments_left) - 1; + ipv6_dst_addr = (uint32_t *)data + MLX5_ST_SZ_DW(header_ipv6_routing_ext) + + seg_left * MLX5_ST_SZ_DW(definer_hl_ipv6_addr); + + /* Load next hop IPv6 address in reverse order to ipv6.dst_address */ + for (i = 0; i < MLX5_ST_SZ_DW(definer_hl_ipv6_addr); i++) { + MLX5_SET(set_action_in, action_ptr, data, be32toh(*ipv6_dst_addr++)); + action_ptr += MLX5DR_MODIFY_ACTION_SIZE; + } + + /* Set ipv6_route_ext.next_hdr per user input */ + MLX5_SET(set_action_in, action_ptr, data, *data); +} + +static void +mlx5dr_action_setter_ipv6_route_ext_mhdr(struct mlx5dr_actions_apply_data *apply, + struct mlx5dr_actions_wqe_setter *setter) +{ + struct mlx5dr_rule_action *rule_action = apply->rule_action; + struct mlx5dr_actions_wqe_setter tmp_setter = {0}; + struct mlx5dr_rule_action tmp_rule_action; + __be64 cmd[MLX5_SRV6_SAMPLE_NUM] = {0}; + struct mlx5dr_action *ipv6_ext_action; + uint8_t *header; + + header = rule_action[setter->idx_double].ipv6_ext.header; + ipv6_ext_action = rule_action[setter->idx_double].action; + tmp_rule_action.action = ipv6_ext_action->ipv6_route_ext.action[setter->extra_data]; + + if (tmp_rule_action.action->flags & MLX5DR_ACTION_FLAG_SHARED) { + tmp_rule_action.modify_header.offset = 0; + tmp_rule_action.modify_header.pattern_idx = 0; + tmp_rule_action.modify_header.data = NULL; + } else { + /* + * Copy ipv6_dst from ipv6_route_ext.last_seg. + * Set ipv6_route_ext.next_hdr. + */ + mlx5dr_action_setter_ipv6_route_ext_gen_push_mhdr(header, cmd); + tmp_rule_action.modify_header.data = (uint8_t *)cmd; + tmp_rule_action.modify_header.pattern_idx = 0; + tmp_rule_action.modify_header.offset = + rule_action[setter->idx_double].ipv6_ext.offset; + } + + apply->rule_action = &tmp_rule_action; + + /* Reuse regular */ + mlx5dr_action_setter_modify_header(apply, &tmp_setter); + + /* Swap rule actions from backup */ + apply->rule_action = rule_action; +} + +static void +mlx5dr_action_setter_ipv6_route_ext_insert_ptr(struct mlx5dr_actions_apply_data *apply, + struct mlx5dr_actions_wqe_setter *setter) +{ + struct mlx5dr_rule_action *rule_action = apply->rule_action; + struct mlx5dr_actions_wqe_setter tmp_setter = {0}; + struct mlx5dr_rule_action tmp_rule_action; + struct mlx5dr_action *ipv6_ext_action; + uint8_t header[MLX5_PUSH_MAX_LEN]; + + ipv6_ext_action = rule_action[setter->idx_double].action; + tmp_rule_action.action = ipv6_ext_action->ipv6_route_ext.action[setter->extra_data]; + + if (tmp_rule_action.action->flags & MLX5DR_ACTION_FLAG_SHARED) { + tmp_rule_action.reformat.offset = 0; + tmp_rule_action.reformat.hdr_idx = 0; + tmp_rule_action.reformat.data = NULL; + } else { + memcpy(header, rule_action[setter->idx_double].ipv6_ext.header, + tmp_rule_action.action->reformat.header_size); + /* Clear ipv6_route_ext.next_hdr for right checksum */ + MLX5_SET(header_ipv6_routing_ext, header, next_hdr, 0); + tmp_rule_action.reformat.data = header; + tmp_rule_action.reformat.hdr_idx = 0; + tmp_rule_action.reformat.offset = + rule_action[setter->idx_double].ipv6_ext.offset; + } + + apply->rule_action = &tmp_rule_action; + + /* Reuse regular */ + mlx5dr_action_setter_insert_ptr(apply, &tmp_setter); + + /* Swap rule actions from backup */ + apply->rule_action = rule_action; +} + +static void +mlx5dr_action_setter_ipv6_route_ext_pop(struct mlx5dr_actions_apply_data *apply, + struct mlx5dr_actions_wqe_setter *setter) +{ + struct mlx5dr_rule_action *rule_action = &apply->rule_action[setter->idx_single]; + uint8_t idx = MLX5DR_ACTION_IPV6_EXT_MAX_SA - 1; + struct mlx5dr_action *action; + + /* Pop the ipv6_route_ext as set_single logic */ + action = rule_action->action->ipv6_route_ext.action[idx]; + apply->wqe_data[MLX5DR_ACTION_OFFSET_DW5] = 0; + apply->wqe_ctrl->stc_ix[MLX5DR_ACTION_STC_IDX_DW5] = + htobe32(action->stc[apply->tbl_type].offset); +} + int mlx5dr_action_template_process(struct mlx5dr_action_template *at) { struct mlx5dr_actions_wqe_setter *start_setter = at->setters + 1; @@ -3374,6 +3489,65 @@ int mlx5dr_action_template_process(struct mlx5dr_action_template *at) setter->idx_double = i; break; + case MLX5DR_ACTION_TYP_POP_IPV6_ROUTE_EXT: + /* + * Backup ipv6_route_ext.next_hdr to ipv6_route_ext.seg_left. + * Set ipv6_route_ext.next_hdr to 0 for checksum bug. + */ + setter = mlx5dr_action_setter_find_first(last_setter, ASF_DOUBLE | ASF_REMOVE); + setter->flags |= ASF_DOUBLE | ASF_MODIFY; + setter->set_double = &mlx5dr_action_setter_ipv6_route_ext_mhdr; + setter->idx_double = i; + setter->extra_data = 0; + setter++; + + /* + * Restore ipv6_route_ext.next_hdr from ipv6_route_ext.seg_left. + * Load the final destination address from flex parser sample 1->4. + */ + setter->flags |= ASF_DOUBLE | ASF_MODIFY; + setter->set_double = &mlx5dr_action_setter_ipv6_route_ext_mhdr; + setter->idx_double = i; + setter->extra_data = 1; + setter++; + + /* Set the ipv6.protocol per ipv6_route_ext.next_hdr */ + setter->flags |= ASF_DOUBLE | ASF_MODIFY; + setter->set_double = &mlx5dr_action_setter_ipv6_route_ext_mhdr; + setter->idx_double = i; + setter->extra_data = 2; + /* Pop ipv6_route_ext */ + setter->flags |= ASF_SINGLE1 | ASF_REMOVE; + setter->set_single = &mlx5dr_action_setter_ipv6_route_ext_pop; + setter->idx_single = i; + break; + + case MLX5DR_ACTION_TYP_PUSH_IPV6_ROUTE_EXT: + /* Insert ipv6_route_ext with next_hdr as 0 due to checksum bug */ + setter = mlx5dr_action_setter_find_first(last_setter, ASF_DOUBLE | ASF_REMOVE); + setter->flags |= ASF_DOUBLE | ASF_INSERT; + setter->set_double = &mlx5dr_action_setter_ipv6_route_ext_insert_ptr; + setter->idx_double = i; + setter->extra_data = 0; + setter++; + + /* Set ipv6.protocol as IPPROTO_ROUTING: 0x2b */ + setter->flags |= ASF_DOUBLE | ASF_MODIFY; + setter->set_double = &mlx5dr_action_setter_ipv6_route_ext_mhdr; + setter->idx_double = i; + setter->extra_data = 1; + setter++; + + /* + * Load the right ipv6_route_ext.next_hdr per user input buffer. + * Load the next dest_addr from the ipv6_route_ext.seg_list[last]. + */ + setter->flags |= ASF_DOUBLE | ASF_MODIFY; + setter->set_double = &mlx5dr_action_setter_ipv6_route_ext_mhdr; + setter->idx_double = i; + setter->extra_data = 2; + break; + case MLX5DR_ACTION_TYP_MODIFY_HDR: /* Double modify header list */ setter = mlx5dr_action_setter_find_first(last_setter, ASF_DOUBLE | ASF_REMOVE); diff --git a/drivers/net/mlx5/hws/mlx5dr_action.h b/drivers/net/mlx5/hws/mlx5dr_action.h index d0152dde3b..ce9091a336 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.h +++ b/drivers/net/mlx5/hws/mlx5dr_action.h @@ -6,7 +6,7 @@ #define MLX5DR_ACTION_H_ /* Max number of STEs needed for a rule (including match) */ -#define MLX5DR_ACTION_MAX_STE 10 +#define MLX5DR_ACTION_MAX_STE 20 /* Max number of internal subactions of ipv6_ext */ #define MLX5DR_ACTION_IPV6_EXT_MAX_SA 4 @@ -109,6 +109,7 @@ struct mlx5dr_actions_wqe_setter { uint8_t idx_ctr; uint8_t idx_hit; uint8_t flags; + uint8_t extra_data; }; struct mlx5dr_action_template { -- 2.39.2