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 04CA3A00C3; Mon, 19 Sep 2022 18:39:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7DC83427F7; Mon, 19 Sep 2022 18:39:33 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2063.outbound.protection.outlook.com [40.107.92.63]) by mails.dpdk.org (Postfix) with ESMTP id 7C4E34284D for ; Mon, 19 Sep 2022 18:39:31 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oBx6kLeclYE96h7OYiLqBSZQiQLBRhb2a+7B6OEoJ+K8HX4yeaV7Rnjr39hCEgHV0diIdAq3LGKOo3uYqYICfctiVuKIN7wLqHUdEc2IMz4TX5JP9EpNDCrTGeaD2tz81JdxKxS8t84aY7/sTUJZCyMjfxeYVw9A0ZI49Jpe4VKyzRziymeC3lQ/j5ID7eGaBFK+cIFtxyHqiT7nLv6kOYY+c9XwgPhiaNLfCE1W6Gz8XUL5YIVTsKehrtO7xJcSwVE/ltn6tusJNP3I1ik6Q4JUaYYEE9T8DrL6IMG/3wdmTkBald2gTrqzTlDfRjpvONdhlhkvbszeigMUAG4QXQ== 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=HHTdYeo2sRKVS/cYwU1yHNm1VnuqyCejnuyyqXS6j8U=; b=c2uxuxNaP9FjL1mfk8C/OlVHSBSYfflcjc3ww/GlGb+y/1SzV+AoFIbTG1/w5rO0y35AWkBLo+0pb6dfq1J5mammBSBu6ovs8R0hKWI/1ErXJJ/p485N3LcfI+B/zDlz2n7nVmRXm+K5+Gm+OgID6Ghp1GrFRK470LXXeuwodptG+k1iBViLv1bi+inVD+jvp+WF7bdn0GQbsWY5w15S/pL0CN7IvHkugOR/11JaKvsgSsE8LNzyuyoziMyZg5f4asx90kKizRRar7Ur7B+k90007O4/ZVwPtD+oZOsLGsN0LWFhTI1ldWw2NpIHToeSrln0GRzUk876IgNkQwVHWQ== 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=HHTdYeo2sRKVS/cYwU1yHNm1VnuqyCejnuyyqXS6j8U=; b=XcH02XZLqSvDOpPkgzL7MVm2nf8IRCjmgferdIwL9Yg6IjBGE5VJTfx9iLVgxpV6Ddr4ijBWPCTgeUlDcKfzEQpVBqkBS+zLz8TiBcKGRInWUhr8dR3UpeIaz3B+UNzNQteZmpUX8DrYyL+YnoGojss1Qcyi931KndywzuGQ55/JCOczNxhjGdiAxZWhIGLQN4cvYgFGrmlEIxovSgEw9swKyEF+DV7H5Vq1Jo2idGYHvC9N0IfokyGImvKngKvBJxppLh2vo7V1kBARW/RiM9telAX/ognIb+acO8Nw+dhbMg/78G9spIgaFlz8TelyALZP8fEWchCCg6tO8dqoAg== Received: from DM6PR05CA0050.namprd05.prod.outlook.com (2603:10b6:5:335::19) by CH2PR12MB4858.namprd12.prod.outlook.com (2603:10b6:610:67::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.21; Mon, 19 Sep 2022 16:39:29 +0000 Received: from DM6NAM11FT017.eop-nam11.prod.protection.outlook.com (2603:10b6:5:335:cafe::dc) by DM6PR05CA0050.outlook.office365.com (2603:10b6:5:335::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.6 via Frontend Transport; Mon, 19 Sep 2022 16:39:29 +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 DM6NAM11FT017.mail.protection.outlook.com (10.13.172.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.12 via Frontend Transport; Mon, 19 Sep 2022 16:39:29 +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; Mon, 19 Sep 2022 09:39:18 -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; Mon, 19 Sep 2022 09:39:17 -0700 From: Dariusz Sosnowski To: Matan Azrad , Viacheslav Ovsiienko CC: Subject: [PATCH 5/7] net/mlx5: allow hairpin Rx queue in locked memory Date: Mon, 19 Sep 2022 16:37:28 +0000 Message-ID: <20220919163731.1540454-6-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220919163731.1540454-1-dsosnowski@nvidia.com> References: <20220919163731.1540454-1-dsosnowski@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: DM6NAM11FT017:EE_|CH2PR12MB4858:EE_ X-MS-Office365-Filtering-Correlation-Id: f5643d0a-7d70-4ec5-f4c9-08da9a5d8612 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gFMcjy/Ltzq6mXFHgO+077/gxxq+MiM14bTSlyHvL7XgQv/Cpu+IFs5xuj5rRjx2+1WrCmZYbBdkYtW0q9tR3ITjOTVv/yXM19iD7kTQh8Om9kSZ6rK1gEDVPdJVowWJB6ByjlJi+kifrNbq40wohty0QgSh3lsl5AbXhQFGb15n+YnusuWjB8E70kybVYWMt5T7LdOEXturQM0tJ+Q+vYuZkPiqy7ebzG0zZB0R4SuifImDbIjI9r22Z2Y9ZbQC4WQicLyozOXE+fqU6/ePYRoUb+S67EpsaLKhgJuOrdYJlkXm8Im/lYOdglScrvJY/J4f6oiX9TuzwK88Z1n20T1CuIotCs081gac+rXu2UteMlkjQBpX+FXBJUOqsJP0DoqrlH7ppn7ZI2fkL/8W2YmfHAIqbanBpGEqaKqj6gKJugdIRfMgBgpDRmBT35UGQ5Ok4wypNgZ1zjnVBl65jbIlj2kyG4ZIutJSGO9ejwxRwKaU46GNdIJL0TTJ4B8kq9e16CRAbb6LJsTrCJgJMxUqHui6YQTTMYWz1foSoURRE9+NMktWu5gUhN3j7WqR1vwU7mIKmPPvIP+ExRiMh9a+UIaZJI6twxlaZ+S1k2HQEB+Y9bQv9Mj2Fkl9Qw0dU2hp2rAG3zsutY62Dr3X2kRmR7yqO6LMW5GBL4HlxVA6O2SJSGF9bIr+hmYziMV5JcDmIuCo71zyAn+yxD1IWdm5/7IZDh8YSbAlAZ3Qw/pJtrAgi9Uc+5izuHtEnH8e6uJufWKMQ3td7O7rvBE63Q== 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)(346002)(396003)(376002)(136003)(39860400002)(451199015)(36840700001)(46966006)(40470700004)(70586007)(186003)(36756003)(82740400003)(2616005)(16526019)(1076003)(8936002)(336012)(40460700003)(82310400005)(83380400001)(426003)(2906002)(7696005)(316002)(110136005)(41300700001)(86362001)(70206006)(6636002)(6666004)(4326008)(6286002)(40480700001)(55016003)(356005)(26005)(8676002)(478600001)(7636003)(36860700001)(47076005)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2022 16:39:29.6965 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f5643d0a-7d70-4ec5-f4c9-08da9a5d8612 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: DM6NAM11FT017.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4858 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 This patch adds a capability to place hairpin Rx queue in locked device memory. This capability is equivalent to storing hairpin RQ's data buffers in locked internal device memory. Hairpin Rx queue creation is extended with requesting that RQ is allocated in locked internal device memory. If allocation fails and force_memory hairpin configuration is set, then hairpin queue creation (and, as a result, device start) fails. If force_memory is unset, then PMD will fallback to allocating memory for hairpin RQ in unlocked internal device memory. To allow such allocation, the user must set HAIRPIN_DATA_BUFFER_LOCK flag in FW using mlxconfig tool. Signed-off-by: Dariusz Sosnowski --- doc/guides/platform/mlx5.rst | 5 ++++ drivers/net/mlx5/mlx5_devx.c | 51 ++++++++++++++++++++++++++++------ drivers/net/mlx5/mlx5_ethdev.c | 2 ++ 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/doc/guides/platform/mlx5.rst b/doc/guides/platform/mlx5.rst index 38c1fdce4c..88a2961bb4 100644 --- a/doc/guides/platform/mlx5.rst +++ b/doc/guides/platform/mlx5.rst @@ -548,6 +548,11 @@ Below are some firmware configurations listed. REAL_TIME_CLOCK_ENABLE=1 +- allow locking hairpin RQ data buffer in device memory:: + + HAIRPIN_DATA_BUFFER_LOCK=1 + MEMIC_SIZE_LIMIT=0 + .. _mlx5_common_driver_options: diff --git a/drivers/net/mlx5/mlx5_devx.c b/drivers/net/mlx5/mlx5_devx.c index a81b1bae47..e65350bd7c 100644 --- a/drivers/net/mlx5/mlx5_devx.c +++ b/drivers/net/mlx5/mlx5_devx.c @@ -468,14 +468,16 @@ mlx5_rxq_obj_hairpin_new(struct mlx5_rxq_priv *rxq) { uint16_t idx = rxq->idx; struct mlx5_priv *priv = rxq->priv; + struct mlx5_hca_attr *hca_attr __rte_unused = &priv->sh->cdev->config.hca_attr; struct mlx5_rxq_ctrl *rxq_ctrl = rxq->ctrl; - struct mlx5_devx_create_rq_attr attr = { 0 }; + struct mlx5_devx_create_rq_attr unlocked_attr = { 0 }; + struct mlx5_devx_create_rq_attr locked_attr = { 0 }; struct mlx5_rxq_obj *tmpl = rxq_ctrl->obj; uint32_t max_wq_data; MLX5_ASSERT(rxq != NULL && rxq->ctrl != NULL && tmpl != NULL); tmpl->rxq_ctrl = rxq_ctrl; - attr.hairpin = 1; + unlocked_attr.hairpin = 1; max_wq_data = priv->sh->cdev->config.hca_attr.log_max_hairpin_wq_data_sz; /* Jumbo frames > 9KB should be supported, and more packets. */ @@ -487,20 +489,50 @@ mlx5_rxq_obj_hairpin_new(struct mlx5_rxq_priv *rxq) rte_errno = ERANGE; return -rte_errno; } - attr.wq_attr.log_hairpin_data_sz = priv->config.log_hp_size; + unlocked_attr.wq_attr.log_hairpin_data_sz = priv->config.log_hp_size; } else { - attr.wq_attr.log_hairpin_data_sz = + unlocked_attr.wq_attr.log_hairpin_data_sz = (max_wq_data < MLX5_HAIRPIN_JUMBO_LOG_SIZE) ? max_wq_data : MLX5_HAIRPIN_JUMBO_LOG_SIZE; } /* Set the packets number to the maximum value for performance. */ - attr.wq_attr.log_hairpin_num_packets = - attr.wq_attr.log_hairpin_data_sz - + unlocked_attr.wq_attr.log_hairpin_num_packets = + unlocked_attr.wq_attr.log_hairpin_data_sz - MLX5_HAIRPIN_QUEUE_STRIDE; - attr.counter_set_id = priv->counter_set_id; + unlocked_attr.counter_set_id = priv->counter_set_id; rxq_ctrl->rxq.delay_drop = priv->config.hp_delay_drop; - attr.delay_drop_en = priv->config.hp_delay_drop; - tmpl->rq = mlx5_devx_cmd_create_rq(priv->sh->cdev->ctx, &attr, + unlocked_attr.delay_drop_en = priv->config.hp_delay_drop; + unlocked_attr.hairpin_data_buffer_type = + MLX5_RQC_HAIRPIN_DATA_BUFFER_TYPE_UNLOCKED_INTERNAL_BUFFER; + if (rxq->hairpin_conf.use_locked_device_memory) { + /* + * It is assumed that configuration is verified against capabilities + * during queue setup. + */ + MLX5_ASSERT(hca_attr->hairpin_data_buffer_locked); + rte_memcpy(&locked_attr, &unlocked_attr, sizeof(locked_attr)); + locked_attr.hairpin_data_buffer_type = + MLX5_RQC_HAIRPIN_DATA_BUFFER_TYPE_LOCKED_INTERNAL_BUFFER; + tmpl->rq = mlx5_devx_cmd_create_rq(priv->sh->cdev->ctx, &locked_attr, + rxq_ctrl->socket); + if (!tmpl->rq && rxq->hairpin_conf.force_memory) { + DRV_LOG(ERR, "Port %u Rx hairpin queue %u can't create RQ object" + " with locked memory buffer", + priv->dev_data->port_id, idx); + return -rte_errno; + } else if (!tmpl->rq && !rxq->hairpin_conf.force_memory) { + DRV_LOG(WARNING, "Port %u Rx hairpin queue %u can't create RQ object" + " with locked memory buffer. Falling back to unlocked" + " device memory.", + priv->dev_data->port_id, idx); + rte_errno = 0; + goto create_rq_unlocked; + } + goto create_rq_set_state; + } + +create_rq_unlocked: + tmpl->rq = mlx5_devx_cmd_create_rq(priv->sh->cdev->ctx, &unlocked_attr, rxq_ctrl->socket); if (!tmpl->rq) { DRV_LOG(ERR, @@ -509,6 +541,7 @@ mlx5_rxq_obj_hairpin_new(struct mlx5_rxq_priv *rxq) rte_errno = errno; return -rte_errno; } +create_rq_set_state: priv->dev_data->rx_queue_state[idx] = RTE_ETH_QUEUE_STATE_HAIRPIN; return 0; } diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index 7f5b01ac74..7f400da103 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -740,6 +740,8 @@ mlx5_hairpin_cap_get(struct rte_eth_dev *dev, struct rte_eth_hairpin_cap *cap) cap->max_tx_2_rx = 1; cap->max_nb_desc = 8192; hca_attr = &priv->sh->cdev->config.hca_attr; + cap->rx_cap.locked_device_memory = hca_attr->hairpin_data_buffer_locked; + cap->rx_cap.rte_memory = 0; cap->tx_cap.locked_device_memory = 0; cap->tx_cap.rte_memory = hca_attr->hairpin_sq_wq_in_host_mem; return 0; -- 2.25.1