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 6A10C41BE9; Mon, 6 Feb 2023 10:53:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5D9E842D3C; Mon, 6 Feb 2023 10:53:20 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2061.outbound.protection.outlook.com [40.107.244.61]) by mails.dpdk.org (Postfix) with ESMTP id ED08040A7A for ; Mon, 6 Feb 2023 10:53:18 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TFtVp0F5keWuNs5UqNaJKDT5Dkz5xRDHzlUj2kMc++TAP0K2yx6sH4s+lQbHOH1GvpZGY0pi+gyhq3lLYV0J5dMTVUpXezTq8/z8E2CzQgHBE7Mib4AvGMpRkYXXmBAuXGIX1YAli55Y0dGY8hLxzP7mf2DenJCdGYyPgBWDjhJkKfdN7nbByvSbSjX87NrYDHhrW9HWoa8BmO3SZOjRjOr76p/pTud8SWcbidbsfPaN9AAVGhAVnqD/XBSHDBLCjLHzzMOHKxnsdmIXHwu5klk31vNYoidMXQynzsJu2tLAp0ptiKI6UDGcKrw9LYvhjtgD2AmdYVBsff9LR8MiuA== 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=8LRv1Lys7I6GRpyWD28yXDC7Ey2ibUnWtNPsOeY8KQU=; b=THdgbYpbKWeJhta4BQD6Wa3stZ0Hjva7xcruJ8CIODruCOPIF8EjIpzf4FaqYbHMNfybA6lvVV+fxQjg4v6afB61VaA4kYSHCOaHPXVmyBcjRRU5xWfTH/JY8pPRCHMpIauMJkIobZo6KhOFFRu9+K5D+vGUCD7y3kbaJ/oE3Poanm235tf971XwzyrZ46Ekhtj3MU1lOeB6yMD2SjakNpFQ+NUVpG2b5CSOIWtF3LZ1J8JDBZCjettvFRciz06Elqlk5uFlqwAPhfZf0z/Zk7USlChgUJOOvvFnUtpPbxtkEHTQIGwQDuE8IPUrd36N3yIAuP7NwkbLgfrU+iQFAw== 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 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=8LRv1Lys7I6GRpyWD28yXDC7Ey2ibUnWtNPsOeY8KQU=; b=MSL+4zut4aq1+w/LtSSzjPCOJcqSOsP7e/bSpMMH/+g0m669QNJ4OovQMCthGGGOv8l4IoFfgYwXM5MrNFiaTE3ug0tlcj56BDHuKev7hY2cziit7goxQmNIuZzcRAT7roPpZe7ePpi8s4apOFJhHCYRGZyOsrD494c+++Dmevv2hmX8jfFYwvq/On1mqOsVi7WNjFXl3GQrTaKJQgM+IBa2KFqM0ETf5AyYir2J7H3Yap3HbI/m0XqXS5Vah6BGkp2/MhenTMGJ/A0JVvQV22t64yL34otl1Ilfs2zAzAJ4Un8gKXurFlYjcdIsrFCVSBhBih2jOb4m4UXXUNJAYw== Received: from CY8PR10CA0007.namprd10.prod.outlook.com (2603:10b6:930:4f::14) by CH3PR12MB7713.namprd12.prod.outlook.com (2603:10b6:610:14d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Mon, 6 Feb 2023 09:53:17 +0000 Received: from CY4PEPF0000C971.namprd02.prod.outlook.com (2603:10b6:930:4f:cafe::9c) by CY8PR10CA0007.outlook.office365.com (2603:10b6:930:4f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34 via Frontend Transport; Mon, 6 Feb 2023 09:53:16 +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 CY4PEPF0000C971.mail.protection.outlook.com (10.167.242.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.21 via Frontend Transport; Mon, 6 Feb 2023 09:53:16 +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.36; Mon, 6 Feb 2023 01:53:05 -0800 Received: from nvidia.com (10.126.230.37) 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.36; Mon, 6 Feb 2023 01:53:03 -0800 From: Viacheslav Ovsiienko To: CC: , , , , Subject: [PATCH 5/9] net/mlx5: add cross port shared mode for HW steering Date: Mon, 6 Feb 2023 11:52:25 +0200 Message-ID: <20230206095229.23027-5-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20230206095229.23027-1-viacheslavo@nvidia.com> References: <20221228165433.18185-1-viacheslavo@nvidia.com> <20230206095229.23027-1-viacheslavo@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.126.230.37] 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: CY4PEPF0000C971:EE_|CH3PR12MB7713:EE_ X-MS-Office365-Filtering-Correlation-Id: 98a6ccb3-3ea7-413b-a559-08db0827f873 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nDSNqqRZe0eBJ4Eq2vBTkAWDeKvF/hCkXiTgziEvivVvgVLAoMOohzXW5PjaPz0nmCIWUaBbf2NDmoMNIy+Gvwn8xp9CEpJ8GO0gSOXdfc8rVs0SmDhVc4v25Oi8WAoTEDu2c+K6Yo2K3y1cywFn6fOJaGmx1+nClAsxkX/6DQMCyV5L/FN7yLZkuU5/9PkC1rWSOUrw62/xoMqYbgO8kzgt2rupmkc0yaVRWW0hW5SGvXTQnZolYx+KbjBY4QOf9PiAyp/tT4UDboR2hGon2+XDhfEs8SE9uFzve4hP7e24djTwViOnSu5sDMLPtGqLM0lk8NL+Wd8Q7ulQUx7nJBvcJ68Jmq/G9lVP4Ginqek/OrjY/4CiXXqw7HQav6MfP8Hom22a5T6+qhTy/OEcHx3w46VtSul0FTj4UntP6UBPKbHzGyARkDgTJkmlmlPWgYVbeg4yAWmbJN9WrlV9nbMZ7mMYTBNKEhvXPs8/bEUDevkqpYZZJEBHI3+2xA/kMyVQpJtcCvV2xEnLo/pYdHI6ueTQjUeniCv6y+to4Az0sgo5lD8UBI3kcTjmCBmt7IA3OmaCaHJXWohstToPc5IHBEFs7owIvagLGTabDHBUoUj3ke3fRXCokr8dtT11pyaoWVwjOkb9oBBUAnrmtoVXN4XjcesRVGe2WnC2jBS1Q+SsFB9gXa+ArREhssxrsIc1iMmhNNUK8h5qYl11ow== 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:(13230025)(4636009)(346002)(396003)(376002)(136003)(39860400002)(451199018)(46966006)(40470700004)(36840700001)(55016003)(40480700001)(47076005)(336012)(70206006)(83380400001)(7636003)(40460700003)(426003)(82740400003)(8936002)(41300700001)(36860700001)(6916009)(70586007)(4326008)(8676002)(2906002)(356005)(1076003)(186003)(26005)(16526019)(6666004)(82310400005)(2616005)(6286002)(54906003)(316002)(478600001)(7696005)(36756003)(86362001)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2023 09:53:16.6569 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 98a6ccb3-3ea7-413b-a559-08db0827f873 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: CY4PEPF0000C971.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7713 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 Add host port option for sharing steering objects between multiple ports of the same physical NIC. Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5.c | 6 +++ drivers/net/mlx5/mlx5.h | 2 + drivers/net/mlx5/mlx5_flow_hw.c | 78 +++++++++++++++++++++++++++++++-- drivers/net/mlx5/mlx5_hws_cnt.c | 12 +++++ 4 files changed, 94 insertions(+), 4 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index b8643cebdd..2eca2cceef 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -2013,6 +2013,12 @@ mlx5_dev_close(struct rte_eth_dev *dev) } if (!priv->sh) return 0; + if (priv->shared_refcnt) { + DRV_LOG(ERR, "port %u is shared host in use (%u)", + dev->data->port_id, priv->shared_refcnt); + rte_errno = EBUSY; + return -EBUSY; + } DRV_LOG(DEBUG, "port %u closing device \"%s\"", dev->data->port_id, ((priv->sh->cdev->ctx != NULL) ? diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 16b33e1548..525bdd47f7 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1780,6 +1780,8 @@ struct mlx5_priv { struct mlx5_flow_hw_ctrl_rx *hw_ctrl_rx; /**< HW steering templates used to create control flow rules. */ #endif + struct rte_eth_dev *shared_host; /* Host device for HW steering. */ + uint16_t shared_refcnt; /* HW steering host reference counter. */ }; #define PORT_ID(priv) ((priv)->dev_data->port_id) diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index ce9e0219e1..fc87e687c9 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -5,6 +5,8 @@ #include #include + +#include "mlx5.h" #include "mlx5_defs.h" #include "mlx5_flow.h" #include "mlx5_rx.h" @@ -6302,6 +6304,12 @@ flow_hw_ct_pool_create(struct rte_eth_dev *dev, int reg_id; uint32_t flags; + if (port_attr->flags & RTE_FLOW_PORT_FLAG_SHARE_INDIRECT) { + DRV_LOG(ERR, "Connection tracking is not supported " + "in cross vHCA sharing mode"); + rte_errno = ENOTSUP; + return NULL; + } pool = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*pool), 0, SOCKET_ID_ANY); if (!pool) { rte_errno = ENOMEM; @@ -6786,6 +6794,7 @@ flow_hw_configure(struct rte_eth_dev *dev, struct rte_flow_error *error) { struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_priv *host_priv = NULL; struct mlx5dr_context *dr_ctx = NULL; struct mlx5dr_context_attr dr_ctx_attr = {0}; struct mlx5_hw_q *hw_q; @@ -6800,7 +6809,8 @@ flow_hw_configure(struct rte_eth_dev *dev, .free = mlx5_free, .type = "mlx5_hw_action_construct_data", }; - /* Adds one queue to be used by PMD. + /* + * Adds one queue to be used by PMD. * The last queue will be used by the PMD. */ uint16_t nb_q_updated = 0; @@ -6919,6 +6929,57 @@ flow_hw_configure(struct rte_eth_dev *dev, dr_ctx_attr.queues = nb_q_updated; /* Queue size should all be the same. Take the first one. */ dr_ctx_attr.queue_size = _queue_attr[0]->size; + if (port_attr->flags & RTE_FLOW_PORT_FLAG_SHARE_INDIRECT) { + struct rte_eth_dev *host_dev = NULL; + uint16_t port_id; + + MLX5_ASSERT(rte_eth_dev_is_valid_port(port_attr->host_port_id)); + if (is_proxy) { + DRV_LOG(ERR, "cross vHCA shared mode not supported " + " for E-Switch confgiurations"); + rte_errno = ENOTSUP; + goto err; + } + MLX5_ETH_FOREACH_DEV(port_id, dev->device) { + if (port_id == port_attr->host_port_id) { + host_dev = &rte_eth_devices[port_id]; + break; + } + } + if (!host_dev || host_dev == dev || + !host_dev->data || !host_dev->data->dev_private) { + DRV_LOG(ERR, "Invalid cross vHCA host port %u", + port_attr->host_port_id); + rte_errno = EINVAL; + goto err; + } + host_priv = host_dev->data->dev_private; + if (host_priv->sh->cdev->ctx == priv->sh->cdev->ctx) { + DRV_LOG(ERR, "Sibling ports %u and %u do not " + "require cross vHCA sharing mode", + dev->data->port_id, port_attr->host_port_id); + rte_errno = EINVAL; + goto err; + } + if (host_priv->shared_host) { + DRV_LOG(ERR, "Host port %u is not the sharing base", + port_attr->host_port_id); + rte_errno = EINVAL; + goto err; + } + if (port_attr->nb_counters || + port_attr->nb_aging_objects || + port_attr->nb_meters || + port_attr->nb_conn_tracks) { + DRV_LOG(ERR, + "Object numbers on guest port must be zeros"); + rte_errno = EINVAL; + goto err; + } + dr_ctx_attr.shared_ibv_ctx = host_priv->sh->cdev->ctx; + priv->shared_host = host_dev; + __atomic_fetch_add(&host_priv->shared_refcnt, 1, __ATOMIC_RELAXED); + } dr_ctx = mlx5dr_context_open(priv->sh->cdev->ctx, &dr_ctx_attr); /* rte_errno has been updated by HWS layer. */ if (!dr_ctx) @@ -6934,7 +6995,7 @@ flow_hw_configure(struct rte_eth_dev *dev, goto err; } /* Initialize meter library*/ - if (port_attr->nb_meters) + if (port_attr->nb_meters || (host_priv && host_priv->hws_mpool)) if (mlx5_flow_meter_init(dev, port_attr->nb_meters, 1, 1, nb_q_updated)) goto err; /* Add global actions. */ @@ -6971,7 +7032,7 @@ flow_hw_configure(struct rte_eth_dev *dev, goto err; } } - if (port_attr->nb_conn_tracks) { + if (port_attr->nb_conn_tracks || (host_priv && host_priv->hws_ctpool)) { mem_size = sizeof(struct mlx5_aso_sq) * nb_q_updated + sizeof(*priv->ct_mng); priv->ct_mng = mlx5_malloc(MLX5_MEM_ZERO, mem_size, @@ -6985,7 +7046,7 @@ flow_hw_configure(struct rte_eth_dev *dev, goto err; priv->sh->ct_aso_en = 1; } - if (port_attr->nb_counters) { + if (port_attr->nb_counters || (host_priv && host_priv->hws_cpool)) { priv->hws_cpool = mlx5_hws_cnt_pool_create(dev, port_attr, nb_queue); if (priv->hws_cpool == NULL) @@ -7054,6 +7115,10 @@ flow_hw_configure(struct rte_eth_dev *dev, } if (_queue_attr) mlx5_free(_queue_attr); + if (priv->shared_host) { + __atomic_fetch_sub(&host_priv->shared_refcnt, 1, __ATOMIC_RELAXED); + priv->shared_host = NULL; + } /* Do not overwrite the internal errno information. */ if (ret) return ret; @@ -7132,6 +7197,11 @@ flow_hw_resource_release(struct rte_eth_dev *dev) mlx5_free(priv->hw_q); priv->hw_q = NULL; claim_zero(mlx5dr_context_close(priv->dr_ctx)); + if (priv->shared_host) { + struct mlx5_priv *host_priv = priv->shared_host->data->dev_private; + __atomic_fetch_sub(&host_priv->shared_refcnt, 1, __ATOMIC_RELAXED); + priv->shared_host = NULL; + } priv->dr_ctx = NULL; priv->nb_queue = 0; } diff --git a/drivers/net/mlx5/mlx5_hws_cnt.c b/drivers/net/mlx5/mlx5_hws_cnt.c index 51704ef754..afc93821e4 100644 --- a/drivers/net/mlx5/mlx5_hws_cnt.c +++ b/drivers/net/mlx5/mlx5_hws_cnt.c @@ -618,6 +618,12 @@ mlx5_hws_cnt_pool_create(struct rte_eth_dev *dev, int ret = 0; size_t sz; + if (pattr->flags & RTE_FLOW_PORT_FLAG_SHARE_INDIRECT) { + DRV_LOG(ERR, "Counters are not supported " + "in cross vHCA sharing mode"); + rte_errno = ENOTSUP; + return NULL; + } /* init cnt service if not. */ if (priv->sh->cnt_svc == NULL) { ret = mlx5_hws_cnt_svc_init(priv->sh); @@ -1189,6 +1195,12 @@ mlx5_hws_age_pool_init(struct rte_eth_dev *dev, strict_queue = !!(attr->flags & RTE_FLOW_PORT_FLAG_STRICT_QUEUE); MLX5_ASSERT(priv->hws_cpool); + if (attr->flags & RTE_FLOW_PORT_FLAG_SHARE_INDIRECT) { + DRV_LOG(ERR, "Aging sn not supported " + "in cross vHCA sharing mode"); + rte_errno = ENOTSUP; + return -ENOTSUP; + } nb_alloc_cnts = mlx5_hws_cnt_pool_get_size(priv->hws_cpool); if (strict_queue) { rsize = mlx5_hws_aged_out_q_ring_size_get(nb_alloc_cnts, -- 2.18.1