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 B4D32A09F2; Wed, 19 Oct 2022 22:58:21 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3DA0B42C52; Wed, 19 Oct 2022 22:58:07 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2061.outbound.protection.outlook.com [40.107.92.61]) by mails.dpdk.org (Postfix) with ESMTP id 7808342C47 for ; Wed, 19 Oct 2022 22:58:05 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FizA5VWn7aupt8QlTW+bGUVlBXCJgka86acHcPzD/RiGVMVOrEEJTlQx7uD/qcCSX1wosQ0kY7aW0MAJ3l7Yp7UEe2rMyIjjPCFZ3w1bQf1SBd+GrRaQOmVHwlbwB2ox1T2SEL4lG0RE0HJXty3gJX5REE7xl+Gl+LvjtAcAWShFOJ2A/yzSTazkEs9Tzm9CaqrQBx/lSt/RT5H7PjBa1pQ3rKS5eoknpoF9LWkAWifVHal1IG0QeOeKVeFWJi/1zvJmOdmATYCBCmKLyA4Kk/BjyrUKu5eG4zx0NRlI71xKlLSdzsPTvyJoBiztWqfciN5wVrTN7yh/Tm2Ana+wMA== 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=hsAe0vcrL07SUXCFz5bgbQnq3pFv3FXFrIewr8YWOU8=; b=WQdCP+do7RxDh0AOHe8vJpmhVMjBwSXx4w7BP/c6mjDlJlSuLNiSSpbjYLy9o3nVwtW25P/vBaqAl3XhBOmuwJ904V4miOXqOsqT2w8R1lw9jfIfq3EtqBdyUDoByH4mJyyrARuj200DD2NhY6ZzsyORHURATpobwNApHVhMf6bm0tCxMdtNw9CW40QIbSpB54MPcVx4tWGdJDc7RbWGz6/jhxNwdmPZiE9fTJpvPuP1uC+I11nnLU6L3qqcwE2a7oaUFeaqBHOE4fdK/goAtsxielQJCnYQCez/5s6Vx7l4wFRNdCYSr82HBrxcDjpgyzKshck3/JMdzE0H28D1JA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 216.228.117.160) smtp.rcpttodomain=monjalon.net smtp.mailfrom=nvidia.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject 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=hsAe0vcrL07SUXCFz5bgbQnq3pFv3FXFrIewr8YWOU8=; b=BTg7b5eNF7PwQO79xzzYQy0n9hZvCMuzBbQb2pC3POZ5oHpZhpoqdDlPpyvnJUuHGGcReQXAvNJNZXgTAIANdYmpkGschoIq4B6GMK/BOT6mEWMCJ5oI8xKlxqvEbI2uE9xuTl5vL6Pgxx/lGkyIQytrtmUsNwpNtT3O9sHFsuybe7ozA2pWDrJj8vcSG07rmOuvNCEMsGZA+5Y9j7k6r+W82Blz/wb5Zdut8zuNwAVOzz65K8XkAQqQ8Gvi7UlNPmUt2mNdryz5m5tT/TWBOpXGCN3reScoc2s5Tpa9XIFGmL7zZePJQegiOQ030pbH7FvUgPjkYR8o0rUzRUpRug== Received: from DS7PR03CA0320.namprd03.prod.outlook.com (2603:10b6:8:2b::15) by SJ0PR12MB7007.namprd12.prod.outlook.com (2603:10b6:a03:486::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.30; Wed, 19 Oct 2022 20:58:03 +0000 Received: from DM6NAM11FT057.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2b:cafe::5b) by DS7PR03CA0320.outlook.office365.com (2603:10b6:8:2b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34 via Frontend Transport; Wed, 19 Oct 2022 20:58:03 +0000 X-MS-Exchange-Authentication-Results: spf=none (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=nvidia.com; Received-SPF: None (protection.outlook.com: nvidia.com does not designate permitted sender hosts) Received: from mail.nvidia.com (216.228.117.160) by DM6NAM11FT057.mail.protection.outlook.com (10.13.172.252) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.16 via Frontend Transport; Wed, 19 Oct 2022 20:58:03 +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.26; Wed, 19 Oct 2022 13:57:46 -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; Wed, 19 Oct 2022 13:57:44 -0700 From: Alex Vesker To: , , , , Matan Azrad CC: , , Dariusz Sosnowski Subject: [v5 04/18] net/mlx5: add port to metadata conversion Date: Wed, 19 Oct 2022 23:57:07 +0300 Message-ID: <20221019205721.8077-5-valex@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20221019205721.8077-1-valex@nvidia.com> References: <20220922190345.394-1-valex@nvidia.com> <20221019205721.8077-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: DM6NAM11FT057:EE_|SJ0PR12MB7007:EE_ X-MS-Office365-Filtering-Correlation-Id: 31e8d111-698f-4ffc-8ca3-08dab2149d43 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: YUtQiQHWgW8QcGRY1++mg7OWudbl96/80iJqrRT3gxOR558bu1XZbCMGT5xmFGN6Jib/PE7iyPlhJV+oKn8Xv2D3HufTDD+OTHd60eKcj/9+M5PqixFGZnA4D/nYEDkZZhckEo1UoIb1WWnRCt+HT1jLlwKBScBdz+S9whU7s5qN3Xego0BIYnaiEkcI6/ur9/wibgYXNa3SyIaGJmkkf3v4t/QrNM3Ug44aI0UtvxSQK103ukTdblsN1F+CYyDWJGWLyPvC6wdj7k4pBeGW2eilwZWL5u400yMamovvLb2kVeYIIp/ZpNELWJSjtFgxWvJ5O37n3EfFX6K013726zAXO52blDiaYvWb6zDco3nz/Beo+5O2RFF4QFY/Hl5hX5nFaCYFvOn2cp9dNV0HNFBHk/oWjAFJr6KmT6l09CPuar4LkSCcAF020tRoCW5febLm0ZwrH4AvmUH/93x0PnR1FnV1sKAhtOKKvOEZ0E4RzkwId6UZAqi2u0YebvfqZn+t4JnINGAbOnb4bUbGTTmHO+vlG2qDq2bi6XMml2VoutVOxhZ8zIWJZ9XYQhwzqSrmn3BcwRnjhEa0iAw226MZ5Om2hH1mUJ6OIS/ecPqay9OrHypKcqmaQxO6mIeGu2/AXlcTDSgcGSSEvJ7cTVzd/ZKy5On0tDg1XVF38dY9DoHVuZGsrHbbaOu2QR5SenBftv6wIqX4NOH0Jb6p0/05z9DpuSyThrWsEg9hKFNmS/awNj2NvivdlV3F3Nrf0mXLQybNmsvh5DTgcvZYqgt4CoIu+ndDWOOtv7og0a5s4u5rrBG7QBNd32dAXu/M 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:(13230022)(4636009)(136003)(39860400002)(376002)(346002)(396003)(451199015)(36840700001)(40470700004)(46966006)(2906002)(5660300002)(6636002)(70586007)(54906003)(70206006)(8676002)(4326008)(316002)(36860700001)(7696005)(36756003)(478600001)(107886003)(6666004)(8936002)(41300700001)(7636003)(6286002)(83380400001)(26005)(2616005)(426003)(47076005)(356005)(110136005)(186003)(55016003)(40460700003)(82310400005)(40480700001)(16526019)(336012)(86362001)(82740400003)(1076003)(21314003)(309714004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 20:58:03.1074 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 31e8d111-698f-4ffc-8ca3-08dab2149d43 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: DM6NAM11FT057.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB7007 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: Dariusz Sosnowski This patch initial version of functions used to: - convert between ethdev port_id and internal tag/mask value, - convert between IB context and internal tag/mask value. Signed-off-by: Dariusz Sosnowski --- drivers/net/mlx5/linux/mlx5_os.c | 10 +++++- drivers/net/mlx5/mlx5.c | 1 + drivers/net/mlx5/mlx5_flow.c | 6 ++++ drivers/net/mlx5/mlx5_flow.h | 52 ++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow_hw.c | 29 ++++++++++++++++++ 5 files changed, 97 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 60677eb8d7..98c6374547 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1541,8 +1541,16 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, if (!priv->hrxqs) goto error; rte_rwlock_init(&priv->ind_tbls_lock); - if (priv->sh->config.dv_flow_en == 2) + if (priv->sh->config.dv_flow_en == 2) { +#ifdef HAVE_IBV_FLOW_DV_SUPPORT + if (priv->vport_meta_mask) + flow_hw_set_port_info(eth_dev); return eth_dev; +#else + DRV_LOG(ERR, "DV support is missing for HWS."); + goto error; +#endif + } /* Port representor shares the same max priority with pf port. */ if (!priv->sh->flow_priority_check_flag) { /* Supported Verbs flow priority number detection. */ diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 752b60d769..1d10932619 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1944,6 +1944,7 @@ mlx5_dev_close(struct rte_eth_dev *dev) mlx5_flex_item_port_cleanup(dev); #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H) flow_hw_resource_release(dev); + flow_hw_clear_port_info(dev); #endif if (priv->rxq_privs != NULL) { /* XXX race condition if mlx5_rx_burst() is still running. */ diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 742dbd6358..9d94da0868 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -33,6 +33,12 @@ #include "mlx5_common_os.h" #include "rte_pmd_mlx5.h" +/* + * Shared array for quick translation between port_id and vport mask/values + * used for HWS rules. + */ +struct flow_hw_port_info mlx5_flow_hw_port_infos[RTE_MAX_ETHPORTS]; + struct tunnel_default_miss_ctx { uint16_t *queue; __extension__ diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 288e09d5ba..17102623c1 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1323,6 +1323,58 @@ struct mlx5_flow_split_info { uint64_t prefix_layers; /**< Prefix subflow layers. */ }; +struct flow_hw_port_info { + uint32_t regc_mask; + uint32_t regc_value; + uint32_t is_wire:1; +}; + +extern struct flow_hw_port_info mlx5_flow_hw_port_infos[RTE_MAX_ETHPORTS]; + +/* + * Get metadata match tag and mask for given rte_eth_dev port. + * Used in HWS rule creation. + */ +static __rte_always_inline const struct flow_hw_port_info * +flow_hw_conv_port_id(const uint16_t port_id) +{ + struct flow_hw_port_info *port_info; + + if (port_id >= RTE_MAX_ETHPORTS) + return NULL; + port_info = &mlx5_flow_hw_port_infos[port_id]; + return !!port_info->regc_mask ? port_info : NULL; +} + +#ifdef HAVE_IBV_FLOW_DV_SUPPORT +/* + * Get metadata match tag and mask for the uplink port represented + * by given IB context. Used in HWS context creation. + */ +static __rte_always_inline const struct flow_hw_port_info * +flow_hw_get_wire_port(struct ibv_context *ibctx) +{ + struct ibv_device *ibdev = ibctx->device; + uint16_t port_id; + + MLX5_ETH_FOREACH_DEV(port_id, NULL) { + const struct mlx5_priv *priv = + rte_eth_devices[port_id].data->dev_private; + + if (priv && priv->master) { + struct ibv_context *port_ibctx = priv->sh->cdev->ctx; + + if (port_ibctx->device == ibdev) + return flow_hw_conv_port_id(port_id); + } + } + return NULL; +} +#endif + +void flow_hw_set_port_info(struct rte_eth_dev *dev); +void flow_hw_clear_port_info(struct rte_eth_dev *dev); + typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[], diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 12498794a5..fe809a83b9 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -2208,6 +2208,35 @@ flow_hw_resource_release(struct rte_eth_dev *dev) priv->nb_queue = 0; } +/* Sets vport tag and mask, for given port, used in HWS rules. */ +void +flow_hw_set_port_info(struct rte_eth_dev *dev) +{ + struct mlx5_priv *priv = dev->data->dev_private; + uint16_t port_id = dev->data->port_id; + struct flow_hw_port_info *info; + + MLX5_ASSERT(port_id < RTE_MAX_ETHPORTS); + info = &mlx5_flow_hw_port_infos[port_id]; + info->regc_mask = priv->vport_meta_mask; + info->regc_value = priv->vport_meta_tag; + info->is_wire = priv->master; +} + +/* Clears vport tag and mask used for HWS rules. */ +void +flow_hw_clear_port_info(struct rte_eth_dev *dev) +{ + uint16_t port_id = dev->data->port_id; + struct flow_hw_port_info *info; + + MLX5_ASSERT(port_id < RTE_MAX_ETHPORTS); + info = &mlx5_flow_hw_port_infos[port_id]; + info->regc_mask = 0; + info->regc_value = 0; + info->is_wire = 0; +} + /** * Create shared action. * -- 2.18.1