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 C1A8543251; Tue, 31 Oct 2023 11:52:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8C25640A8A; Tue, 31 Oct 2023 11:52:08 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2046.outbound.protection.outlook.com [40.107.244.46]) by mails.dpdk.org (Postfix) with ESMTP id C6641406B6 for ; Tue, 31 Oct 2023 11:52:06 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VUAz/5kxD2JvOG9MB7RCct21y5hWprVtrRFAeI4/PTMvhwNOoa23t0wCaJLB5+lRuHU7qgr7l83sIm9Q1hovl+1pLlqciTFw21c+M/8pWHlea4zsiE1270uDYNc32qFYJ0W4bn/nsjXnq/sbrlODQJELBAtk7Weh6UZzBvhtveiFO0JHBfyRV2FreJFkeqXAjs4Bsl9p4W7O9EWI++wesIJQIXPHF/jHT2c1imQy0HFVs7qbldUz4ZkqWdDBSenDEU2X3gCTcidzz8a/kIOpXE2oZMqAEyxrIoW+ZSFJvLxtgS3EcIj4sygynzQeimB7F7GD6gT9qTTmhhc5ef73eQ== 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=1JRgpKTtJPO2evBsL0c+9T0FBOToPXXX5YJN1Jbp+8Q=; b=U6FAPkcTJlSO3vF/7RiBXeIDfC0uGpKBSiy7zU7Jq6WSZ541irkN5znv3nS8OgyDVN883JrsQ42DsxZbtBez0m9a+cE+SRmq7cOLqYBqPi9z72G/oBEZpdYJmvhAMMahInZUvL+ZGxNhsitxyUv3vNgiX2WSqJ/isi20gV1zw/dbc6PR4JfS8s81dWjyHbnR71Hpd/UnolL/mCk2Iz37+1s1esrHShUJ12pCQoukKScq9nHwfwh+Ukv6UMDCZqlJH0XyUgk20bxvrS2YSjECeXBgE0V7d8UGjJmad+S37TMNshmske51V/W7lZ7yBsVDuP9mY27iPEQ+E+wLdeS2mQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=1JRgpKTtJPO2evBsL0c+9T0FBOToPXXX5YJN1Jbp+8Q=; b=t5m5Dov0qwfOCmzfe/JdI8o1gyXs1DH1Rh92Tm/kS2B0IKP2w6XxRL18WZWdze3yznP6zIqPDaumApozk6lYuSbxaYCpLsrOxVu3zuvPMW5rY4+UJYPNJ+wqvx/2mi6hI8ysbpV7s+ul6s+n0sr1dFEk0ClrNFUSjJnLmKHBlpNRm3kJzfrr4gO24c6WQL79w1nZT6Wzy23mV9DOKb2NXzKTpbEXchFfaoPHABL0vwQ+7fK/JJUFcmu8GaKH1AMCHx2o4mCkkfpaqL0WklKiv8mdJhmG8HRY63Zdml85QfqhzC5lQebOFkRtqQ2DCuzHtZNUC/yCKBZn7L2kjIZP4Q== Received: from CY5PR15CA0142.namprd15.prod.outlook.com (2603:10b6:930:67::8) by MN6PR12MB8543.namprd12.prod.outlook.com (2603:10b6:208:47b::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.29; Tue, 31 Oct 2023 10:52:04 +0000 Received: from CY4PEPF0000EE3F.namprd03.prod.outlook.com (2603:10b6:930:67:cafe::71) by CY5PR15CA0142.outlook.office365.com (2603:10b6:930:67::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.19 via Frontend Transport; Tue, 31 Oct 2023 10:52:04 +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 CY4PEPF0000EE3F.mail.protection.outlook.com (10.167.242.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.19 via Frontend Transport; Tue, 31 Oct 2023 10:52:04 +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.41; Tue, 31 Oct 2023 03:51:55 -0700 Received: from nvidia.com (10.126.230.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; Tue, 31 Oct 2023 03:51:53 -0700 From: Rongwei Liu To: , , , , , CC: Alex Vesker Subject: [PATCH v3 4/6] net/mlx5/hws: add setter for IPv6 routing push remove Date: Tue, 31 Oct 2023 12:51:29 +0200 Message-ID: <20231031105131.441078-5-rongweil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231031105131.441078-1-rongweil@nvidia.com> References: <20231031094244.381557-1-rongweil@nvidia.com> <20231031105131.441078-1-rongweil@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.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: CY4PEPF0000EE3F:EE_|MN6PR12MB8543:EE_ X-MS-Office365-Filtering-Correlation-Id: ce41780a-0c25-4401-d3fb-08dbd9ff6b4a 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: NPhXqyjl7pcM6fBML5shvjEX/qs8KOLEVpp3yN+/STw8VUcB/jPeDRMBkP2XfYgOaBZaxtnZT4bgYElrpPZXTPmgRN2jcP9fjGfM0MoDdZOXk+Z66Km2MB3eNOv9kQK6FfBAAuuw1RJDG+5cLCtKPOEUj7GMQcOYLejR9DshaFK7HLdLcoic7OEAQLaiEQHO/Sc230leFZf3+TsQuahJ2MSQlvn7fu+/zhVQHti/2rE4+FVdg8WleU6KemN6D9i3qcbCxsMLy20lvFcUPSraHgLa7mxrRB/dWcpHBLbjEMy0nH4zjKw1ddEuDxAFU7XbF7wJdAKvCUOqnIe4nIvGSw9oDpoHCGIa/ILwybc6kkJafL0ozcJXM8ppNJUy+BZzWIiV3w9Ty4DVNc9CzGnbdJmhTYw0VS44k22r0lumRblJPpfsZh2J7WbjkiIcHs5xRxhRcd9nW86J7B23qnlaUEM2avJFp19BegpUu2cKtsp9uZzODQu5sj+9H8rZR/m28/prUhC7zffW6hkrgnasL9FZEApMXUqS9C1l0/f6qz6Y3FO2nFdrsQLMUOgfcut4V7bJ1UzzJHBZzqVToFV1puW2HuuLodVnEIxauz5euEieM6tua3As/WuxuLJSnR+cf4ZapB/xnFHfu8+8OWAdMzdR/5UFBO+zDF7fbu+zI0KFYfeY0eh/fXoRBEymi8opHNcIB4GC30W6s2xbVTM5ngtEmT8gUwG503TG3zh4+Ie1jHezxeq0P8kcO8VtXEbl 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:(13230031)(4636009)(346002)(136003)(376002)(396003)(39860400002)(230922051799003)(64100799003)(451199024)(186009)(82310400011)(1800799009)(36840700001)(46966006)(40470700004)(36756003)(40460700003)(86362001)(7696005)(6666004)(5660300002)(26005)(478600001)(41300700001)(2906002)(426003)(336012)(83380400001)(2616005)(16526019)(6286002)(107886003)(1076003)(8936002)(8676002)(4326008)(110136005)(316002)(70586007)(70206006)(7636003)(356005)(82740400003)(40480700001)(47076005)(55016003)(36860700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2023 10:52:04.1917 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ce41780a-0c25-4401-d3fb-08dbd9ff6b4a 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: CY4PEPF0000EE3F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR12MB8543 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 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.27.0