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 A1277A00C2; Thu, 6 Oct 2022 17:04:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BF63C42C9E; Thu, 6 Oct 2022 17:04:07 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2050.outbound.protection.outlook.com [40.107.93.50]) by mails.dpdk.org (Postfix) with ESMTP id 884C842C9D for ; Thu, 6 Oct 2022 17:04:06 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F1FN9B6hkNqYazKlXEQFaqumCl8ZCQrj58J1nCccQmdAjbT00DDUvglneMuQw5mlC45EBFOEGM/w3e5gkTC6LmN1Mw15ozQTEG5MZ1PLW7LZk9AHyYEcW6PldDITq+DgZGyVnBCRRhyb1sVZaTQmR2pZMToYA54ODnKAAkfhX4rvP5ZYq+zErdAXy+xzYBomax6jIkYvxJvX1oLPm/M3jgKmBPl7vODX+y6sW8tEZ5AFXYiOHp1lPtVIR5+1Lu8Xh0HX8xqRi7NxZ3W0ZfTl0yk9xy/9jIPhhoCjrzMstzz+ETUXIL9FeZnxsjkubKYuFLowL8nIykWx1lLlcDW+RQ== 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=PNE3zv4wkq5HS0rhCbTIkCCCmp/nB3fLc10qBWeh3SA=; b=N3S3ipq0JroOp0fjyY8eyKgrv2YJ/3pY71oGZK/lthiMo21mxihVTozlLi1OebgSyZB8bFAkWMwWvdXRN5VinelP9RTx9uj8mthver4U09pjrkemNTo48mZNjEtFjKmMHoENzMY86+0VwHVZIgJz8hBMBYIlRTAcbNelTIC9uoCBR+St6bve7FA3v+YAoYv8Px0YdoEoEeXCy6vsdzzND5WIQA3YRkKCChaH0bLMfaWGZz/8BjbqgScrXxZ7FIDrU39DWff2PGEgyQ3fhHJIR3rlPHoW+GYP+dAvNrDKSIbCMAdCbFUNQJuB6Rs3rZCCrH60B3FCCvtNWybTRVZwEA== 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=PNE3zv4wkq5HS0rhCbTIkCCCmp/nB3fLc10qBWeh3SA=; b=fre+m9DtLhuJq475gR64CxrSLOjCaAQsWeIv28EvLUr0jTOtw+e3f33xubiWhMNrzmhvrgGB7vdjt+JdR8BIf0+lGcyYRAIUGkonr7TfGFSipD2uw/3dMtil1jRvAkyDySV8g9ONt7xbSeUxNkImGfqfnlb0QU1z/sq7PBusGnCQLrv7wvZ3NQwzf9c+2FyA1NVeYD96isxm3n+zdgs488hKg5UaJZgkvIPuZGDelgpLFs+J/lftUyhkL9i5Y/TMcqS5Kaq0+fGPT9pECplmMZhQIHYwCRKhoGRpeJ4TlHXz0nIG6yHr0di3PrGFuDUgXLAEUX38Of1uum9Eq0uaZA== Received: from BN0PR03CA0051.namprd03.prod.outlook.com (2603:10b6:408:e7::26) by DM4PR12MB5104.namprd12.prod.outlook.com (2603:10b6:5:393::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24; Thu, 6 Oct 2022 15:04:04 +0000 Received: from BN8NAM11FT014.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e7:cafe::78) by BN0PR03CA0051.outlook.office365.com (2603:10b6:408:e7::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24 via Frontend Transport; Thu, 6 Oct 2022 15:04: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 BN8NAM11FT014.mail.protection.outlook.com (10.13.177.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Thu, 6 Oct 2022 15:04: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.26; Thu, 6 Oct 2022 08:03:51 -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.29; Thu, 6 Oct 2022 08:03:48 -0700 From: Alex Vesker To: , , , , Matan Azrad CC: , Subject: [v2 03/19] net/mlx5: add hardware steering item translation function Date: Thu, 6 Oct 2022 18:03:09 +0300 Message-ID: <20221006150325.660-4-valex@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20221006150325.660-1-valex@nvidia.com> References: <20220922190345.394-1-valex@nvidia.com> <20221006150325.660-1-valex@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT014:EE_|DM4PR12MB5104:EE_ X-MS-Office365-Filtering-Correlation-Id: ac6e2be9-97e1-47f5-24d4-08daa7ac028a 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: ccVlAYcMYNdnICxJbJjhYJO3Cj8CySibHit7ocHCukut1Hbd1+zg9A0ElL5hQJusgtVqERSDOQFP5Q2twBhpw7qRm5HBvRv1wF3MdbvWKlhl+R4ZK1MCCLkd5Cuky2t8N9FFL6D2+6ECz+7/ioN1HhEpnYa6iHSLqdk060oFSXwKu/IMcsk+3jnAJXDHcOCbZY9BKzrHCY8eQjFBXtq9rjNoCVZdcoPLVIyWoykZAQ9aruAIximHXTFsws+5F41mNcaLZPougHUOnIPycCKNJeHF6dMG1VxbVrWYUh5SUJAMYshRPhXZL78XwBtPDYbgPrpVIIxQi0ELfyS5vGP4ejVS4NbC5haaXP4k/BC4YcQT7i+eyquuggndeojk8scFt62fQCFMScHzUp159XbaC96+sq05ND1qv3f23m1EzGKWUrxgAbMzsN9fRPeBgXz2KCYE+gYOjMiTuOGpcp0yhqp4/iZFcEkgUmBcpTIPXkHE8Dw+FAvSVQ4HJXoef43W+NkHviNcg+G/RQ8S7o5POCC6oUP3FIE4u6c1L2PBe6BGq0izuoghSUZMiJQsMqO/0K/QWmjDhSktaOes/nl52zgKL9dwhpNNQlzHrA76W983p6Wj4TFcbeQ9sTfOpnsJFbYVfW4OTNzjESAcdelWvmCAU90pKW/BfFONMOo4XQu6S7tnNCxPn9+MbKR8EQj1T0Ro6g8mkqlr/0Z6S/qwQta5FUV8GMBahfIkD28WZ7EUevfHccGdlWDwwgdkI/BOztOQoR79BrxKghh8jyR37w== 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:(13230022)(4636009)(136003)(39860400002)(346002)(396003)(376002)(451199015)(46966006)(40470700004)(36840700001)(4326008)(70586007)(70206006)(8936002)(8676002)(86362001)(55016003)(82310400005)(5660300002)(40480700001)(107886003)(54906003)(36860700001)(110136005)(356005)(6636002)(6666004)(41300700001)(7636003)(316002)(478600001)(2906002)(7696005)(2616005)(36756003)(6286002)(426003)(26005)(186003)(1076003)(40460700003)(336012)(16526019)(82740400003)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2022 15:04:04.2824 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ac6e2be9-97e1-47f5-24d4-08daa7ac028a 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: BN8NAM11FT014.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5104 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: Suanming Mou As hardware steering root table flows still work under FW steering mode. This commit provides shared item tranlsation code for hardware steering root table flows. Signed-off-by: Suanming Mou --- drivers/net/mlx5/mlx5_flow.h | 17 ++++++ drivers/net/mlx5/mlx5_flow_dv.c | 93 +++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 2ebb8496f2..86a08074dc 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1006,6 +1006,18 @@ flow_items_to_tunnel(const struct rte_flow_item items[]) return items[0].spec; } +/* HW steering flow attributes. */ +struct mlx5_flow_attr { + uint32_t port_id; /* Port index. */ + uint32_t group; /* Flow group. */ + uint32_t priority; /* Original Priority. */ + /* rss level, used by priority adjustment. */ + uint32_t rss_level; + /* Action flags, used by priority adjustment. */ + uint32_t act_flags; + uint32_t tbl_type; /* Flow table type. */ +}; + /* Flow structure. */ struct rte_flow { uint32_t dev_handles; @@ -2122,4 +2134,9 @@ int mlx5_flow_get_item_vport_id(struct rte_eth_dev *dev, bool *all_ports, struct rte_flow_error *error); +int flow_dv_translate_items_hws(const struct rte_flow_item *items, + struct mlx5_flow_attr *attr, void *key, + uint32_t key_type, uint64_t *item_flags, + uint8_t *match_criteria, + struct rte_flow_error *error); #endif /* RTE_PMD_MLX5_FLOW_H_ */ diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index a2704f0b98..a4c59f3762 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -13229,6 +13229,99 @@ flow_dv_translate_items(struct rte_eth_dev *dev, return 0; } +/** + * Fill the HW steering flow with DV spec. + * + * @param[in] items + * Pointer to the list of items. + * @param[in] attr + * Pointer to the flow attributes. + * @param[in] key + * Pointer to the flow matcher key. + * @param[in] key_type + * Key type. + * @param[in, out] item_flags + * Pointer to the flow item flags. + * @param[out] error + * Pointer to the error structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +int +flow_dv_translate_items_hws(const struct rte_flow_item *items, + struct mlx5_flow_attr *attr, void *key, + uint32_t key_type, uint64_t *item_flags, + uint8_t *match_criteria, + struct rte_flow_error *error) +{ + struct mlx5_flow_rss_desc rss_desc = { .level = attr->rss_level }; + struct rte_flow_attr rattr = { + .group = attr->group, + .priority = attr->priority, + .ingress = !!(attr->tbl_type == MLX5DR_TABLE_TYPE_NIC_RX), + .egress = !!(attr->tbl_type == MLX5DR_TABLE_TYPE_NIC_TX), + .transfer = !!(attr->tbl_type == MLX5DR_TABLE_TYPE_FDB), + }; + struct mlx5_dv_matcher_workspace wks = { + .action_flags = attr->act_flags, + .item_flags = item_flags ? *item_flags : 0, + .external = 0, + .next_protocol = 0xff, + .attr = &rattr, + .rss_desc = &rss_desc, + }; + int ret; + + for (; items->type != RTE_FLOW_ITEM_TYPE_END; items++) { + if (!mlx5_flow_os_item_supported(items->type)) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + NULL, "item not supported"); + ret = flow_dv_translate_items(&rte_eth_devices[attr->port_id], + items, &wks, key, key_type, NULL); + if (ret) + return ret; + } + if (wks.item_flags & MLX5_FLOW_LAYER_VXLAN_GPE) { + flow_dv_translate_item_vxlan_gpe(key, + wks.tunnel_item, + wks.item_flags, + key_type); + } else if (wks.item_flags & MLX5_FLOW_LAYER_GENEVE) { + flow_dv_translate_item_geneve(key, + wks.tunnel_item, + wks.item_flags, + key_type); + } else if (wks.item_flags & MLX5_FLOW_LAYER_GRE) { + if (wks.tunnel_item->type == RTE_FLOW_ITEM_TYPE_GRE) { + flow_dv_translate_item_gre(key, + wks.tunnel_item, + wks.item_flags, + key_type); + } else if (wks.tunnel_item->type == RTE_FLOW_ITEM_TYPE_GRE_OPTION) { + flow_dv_translate_item_gre_option(key, + wks.tunnel_item, + wks.gre_item, + wks.item_flags, + key_type); + } else if (wks.tunnel_item->type == RTE_FLOW_ITEM_TYPE_NVGRE) { + flow_dv_translate_item_nvgre(key, + wks.tunnel_item, + wks.item_flags, + key_type); + } else { + MLX5_ASSERT(false); + } + } + + if (match_criteria) + *match_criteria = flow_dv_matcher_enable(key); + if (item_flags) + *item_flags = wks.item_flags; + return 0; +} + /** * Fill the SW steering flow with DV spec. * -- 2.18.1