From patchwork Wed Nov 13 20:30:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Ratiu X-Patchwork-Id: 13874271 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2059.outbound.protection.outlook.com [40.107.237.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A2EC15AAC1 for ; Wed, 13 Nov 2024 20:34:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731530047; cv=fail; b=fvIQw6W5AuUEVJ6KxtIMg3nfQfi9vk8Q3NbkhREqePKsHxI+Lw3pErPJhY172HgEpxjvttXq1wGkn80z6tYmz+/DQjuLTImtInHSmHFUK9wuH30+wNLBTSUfBvvPTTWPVWF7u7ckq8KslpmSuw9i/JbtNTnPaOtQqUF8yUWBOz0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731530047; c=relaxed/simple; bh=WaYjU+/chHKVDe/Gd5NE5wSzK+eMz84WJi4+wdjql5Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BCf5ZfkST/Ws+Ofhr0qH9mIB+z20gi6vZPYPNMS1wpvfZkYwvCzyDe3q25uMI2+ipS5GevnSKHpPQJo7JLT8u1ECeHvRgC0XPLyej7Y5/9ZrcwkzcyP3HEQez6ObLlchhxemCUVj+gATiamJxN2b2UYIYang9m/eckK5u7iux88= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=NWIUQ9vG; arc=fail smtp.client-ip=40.107.237.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="NWIUQ9vG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xnc0GRQkyw5adxgUaLQofaqT9HkvRyiVwGiCUamlFJLIB35SS+6WaeSruGDAc9jfrrYnpPqkrBTaA+XPOELgSHEoa3VeknTcsr0UA4qCPNXu5l7lX7k0+H4jg78jptDjcOJrQOjDkODAVCIfVTFP5o0nqaQSybViEtanYg/hlvqvNe6YOY8mbFRhhPBfTjo2qaV9gAP+9xeMVwtjRjcNKqxvLdTtSraGEm6I8hbagyvOm5FjZiYWZE27GAknmtsDjkIapSde/tn3YVAGdaBDXxWcQBQQwLPCsCdTk0dRLyhGTvntejghTUBmvbmn1VTXv7Mt8bBnQYn9azbxtw3R2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=v3gheygQIItbY1gTunBELYYJMjosAw7hlwnmwkjej/Q=; b=vVFjbrGSxXmTzfEsC2A4R35gk8xWIhPVOovML80zI+BJPXSQvCw6qnVOiPM6v4CtS0qHQNJBEmS3mSYVF4Rn3J/xLD2zWbz9tykwcvL0FCTnvcpqRWAHh3uO15gpw+dc4XJPeza6J6rW7N+dJf9yUy/kJhA5bBFGA8K6Ehkqn8zJP/TuMmFgtKQkNJUw6Lyi3qRa46NZ6eAoCwqzQ6AQDCUn1CsuhUN0umpdGTQxg1SPkMJ5TaP424aCmSIofdki2MSKOlHKVJWH67llEOm9478sfUnEKnqt/rNpoNSOvGtWxkrW/UWNkBXv08oNFEhtbz3EODBt4n5vsW0QXdvxhw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.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=v3gheygQIItbY1gTunBELYYJMjosAw7hlwnmwkjej/Q=; b=NWIUQ9vGtuI+DEwnwb0vE8J2edOy2/Kgm1DdRiCmhVF9OB9tS1eglQ/xYetX3EDPpYTwVisg6wwLUcjYFPDfmmngKUwHeNElP8LffgDmnUEA7+AHGP87dZDBSTkB+VVbCw+AoCA4P1VZJnCxQiCdVNapwaLoAc1Y/4wojYXnV0mnS1GGjtbR7w1RV7UYw9e6yOlpW3o4PEMotTaZI7qG2jdOEp6Db/WkgB3UtK7EfvYkQP/hXff1JovOB35ooftCeBuh5jZifJ9FCc8b6Uyu80c2OjADKtNJpz+V6OzZYYedthZ8w9YujmmaLU8vTZlUQHgppDZbUul8wUIcAc1B8A== Received: from DM6PR01CA0021.prod.exchangelabs.com (2603:10b6:5:296::26) by MN2PR12MB4157.namprd12.prod.outlook.com (2603:10b6:208:1db::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.17; Wed, 13 Nov 2024 20:33:57 +0000 Received: from DS1PEPF0001708E.namprd03.prod.outlook.com (2603:10b6:5:296:cafe::91) by DM6PR01CA0021.outlook.office365.com (2603:10b6:5:296::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.17 via Frontend Transport; Wed, 13 Nov 2024 20:33:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS1PEPF0001708E.mail.protection.outlook.com (10.167.17.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Wed, 13 Nov 2024 20:33:56 +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.1544.4; Wed, 13 Nov 2024 12:33:44 -0800 Received: from nexus.mtl.labs.mlnx (10.126.231.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.1544.4; Wed, 13 Nov 2024 12:33:42 -0800 From: Cosmin Ratiu To: CC: , , , , Subject: [PATCH 02/10] devlink: Remove unused param of devlink_rate_nodes_check Date: Wed, 13 Nov 2024 22:30:39 +0200 Message-ID: <20241113203317.2507537-3-cratiu@nvidia.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20241113203317.2507537-1-cratiu@nvidia.com> References: <20241113203317.2507537-1-cratiu@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001708E:EE_|MN2PR12MB4157:EE_ X-MS-Office365-Filtering-Correlation-Id: 6784e266-5fef-49d3-ccde-08dd04227f83 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: QIZoDSPC0gdPaoKJOMfcr8SoUaMy8GzBmUSRwkPpTnhT/dMHxE1uptmtJdCDfsTTKZQLVOhW+1uibF/88zWB+MAXaWfzdGkb9lSB441Djun61Z6/uqvNnpA7W4aUt/tff7UWzOtIFdEBSKxJM6bNW+8a/h6W4m0Fle9pUSwJXlfeDJxJPGzYwcQ0LC+FIbtzkxopQ0XeUbXmRN1FGMUMgW67JfllVYitQKuohxUu9um4UbBkJDJsYbPbV9I+SAzBUt/9b1yUqrRE3PuO/6HHMjDPQkjToYYkj6+VZup0k8vnsgNB8QvrxoDEzxkPS1bTzJWOIB27ZP45iZJ/nXpzkmiCGQhFgEa6R25oHzUQhHRSvDJNR4Rp6Ygdi1kThxFK+QPcHNRRHwkbDXcqMP5fk6pytq8luJyxTtadf8Vao9nXzu/0Dnvwetny/6tjR+hWn8Ahzwmia3WkO5fXRVFwuZ/7rv3PxbAJ4DLMMoCyIcioGZxDbNeW9zY0XA51N7D6no6iDPw0IiJ9e41xWCYqvweqq/dw02UT73URVd7zEeq691lTVzIltPywpY0MFCCzN9o+vVfvwv7IUOECJW9zL5l3mRSukwqNCxNwjkHhafjeU1SFZ51PViS7dTRe+zDIS7yrcARyZWmUJMJcp0Scbn9PYnQzXfg4y+8vlGSeFwrmH4p+r2EvcxUqWXoGD9y07mZccM/DUb7b3oM2WUOu6nNtb/3RUUR53RNqJ6gBLdziEu75qszDzzvgt5+Js/M3GbC59XO0czPtutxkzXoBLU3NSLBBuVKh28ja1c+iBzPZmTMrQ5iCbjssViaB2XG3xUK4cpCiBtTUH61g1XYIj3pM9VxVNFdHqOuGyN8K/W5XYoHFnTxwMlBTAkIO0otgwJDOqKrkUUepBOh0WinGWO/BwCbHsxCOS+ipSjT9Q3gig7a/qS0+0F+/qlf4DbW/6WfRp1U9Cu16wOFO1eLCE3XGATtabbdmh+2EJkCp+omlbLnKo9eeFSU3aOtQXA+PyHSdMPi3tmsLefF4bM3vRRoHfoBzT2mMzoTJvQo22oep38sUJCFTTKbaZm7Ut4Vtsnd7akaP0Di1jSJxEgCPJ95VxXpPoxGTwajeG3ZBYhA8WkBNYBnggsoR5Asw4KGT+QhNi555GWEY1/uC/RfzbyAy2gwFJSCYxwfROBxCFk5nD1FGc/5QmD4yeklQGHsMmh7qGRYantrXdvraYxFkKvo8pFfn8bDnKWeWGHF1jLmgF/eQY5pFnDrW9QMyq8ZEzibU3BJcxdwP4uUhptu9P9iMkLwf4yQ+OUxzFQPdxaovuQjL42aqN+OnHhSt65mxdqBY+pPHk4VAteJoJUshvew4f8lrCNl9WuVaeNMsIbjoPrPSrhNFzkN22iZq11ts7eXMGjHRL2kHO9gQQV77uA== 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:(13230040)(1800799024)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2024 20:33:56.9346 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6784e266-5fef-49d3-ccde-08dd04227f83 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: DS1PEPF0001708E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4157 X-Patchwork-Delegate: kuba@kernel.org The 'mode' param is unused so remove it. Issue: 3645895 Change-Id: I89175a3693e399044f7761b03d93b6feeef653ec Signed-off-by: Cosmin Ratiu --- net/devlink/dev.c | 4 ++-- net/devlink/devl_internal.h | 3 +-- net/devlink/rate.c | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/net/devlink/dev.c b/net/devlink/dev.c index d6e3db300acb..5ff5d9055a8d 100644 --- a/net/devlink/dev.c +++ b/net/devlink/dev.c @@ -713,10 +713,10 @@ int devlink_nl_eswitch_set_doit(struct sk_buff *skb, struct genl_info *info) if (info->attrs[DEVLINK_ATTR_ESWITCH_MODE]) { if (!ops->eswitch_mode_set) return -EOPNOTSUPP; - mode = nla_get_u16(info->attrs[DEVLINK_ATTR_ESWITCH_MODE]); - err = devlink_rate_nodes_check(devlink, mode, info->extack); + err = devlink_rate_nodes_check(devlink, info->extack); if (err) return err; + mode = nla_get_u16(info->attrs[DEVLINK_ATTR_ESWITCH_MODE]); err = ops->eswitch_mode_set(devlink, mode, info->extack); if (err) return err; diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h index 14eaad9cfe35..9cc7a5f4a19f 100644 --- a/net/devlink/devl_internal.h +++ b/net/devlink/devl_internal.h @@ -297,8 +297,7 @@ int devlink_resources_validate(struct devlink *devlink, struct genl_info *info); /* Rates */ -int devlink_rate_nodes_check(struct devlink *devlink, u16 mode, - struct netlink_ext_ack *extack); +int devlink_rate_nodes_check(struct devlink *devlink, struct netlink_ext_ack *extack); /* Linecards */ unsigned int devlink_linecard_index(struct devlink_linecard *linecard); diff --git a/net/devlink/rate.c b/net/devlink/rate.c index 9bffda6783f9..c9e471b9734e 100644 --- a/net/devlink/rate.c +++ b/net/devlink/rate.c @@ -615,8 +615,7 @@ int devlink_nl_rate_del_doit(struct sk_buff *skb, struct genl_info *info) return err; } -int devlink_rate_nodes_check(struct devlink *devlink, u16 mode, - struct netlink_ext_ack *extack) +int devlink_rate_nodes_check(struct devlink *devlink, struct netlink_ext_ack *extack) { struct devlink_rate *devlink_rate; From patchwork Wed Nov 13 20:30:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Ratiu X-Patchwork-Id: 13874275 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2041.outbound.protection.outlook.com [40.107.100.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0FBC204024 for ; Wed, 13 Nov 2024 20:34:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731530058; cv=fail; b=tSxhGf8meyem2r7a4MmQ0sTAwo2RhJ0hIMcXcPeqw3H82sXHLKf8uPHvY87goBVxOuASSNv/FqKF6O6xFm35IoC+eD9vZNN8NCAv7d/IeiTjTppQ3iKgp16PVug8j9ExlfcktDd2IPq9UCyLbrezzz2O6sC5Rnl/WcKQmR/L4+s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731530058; c=relaxed/simple; bh=rxQI0Yj9z8KAJWM87Vl+nl5ii+IX1Ekuxco+wObW7To=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jnVqHSSh87UWSA0NC7QMUHalf/y7UMGV7Q0jmcPveAXiGbWyKh9XUja+H3LT1IZs6fJIPAQVqEtkOjnxelWd6NWJtYlevVcGQtaidPk0hFXmwDCb3b8v662deeuqVArtfit6632R+PUgkHx40jg5WqM0yYNaqwD45P/W3otWBBw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=fCEuAVCa; arc=fail smtp.client-ip=40.107.100.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="fCEuAVCa" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Z/UDjkZ0p//Lg6Wj4Is5pzY0acse1uyuZQvdz10Pxa9Om8PHxnA8Y+rQBsLSaQbFpei6fSImhM1ZLq16W1FpfdX9xgUN5ryNz5COw3QDzDJuDnkGb99WhZovqDnEm6caxRvYUZSEiQFtAfMc4f3kXN1cdaTclGA8uxy5ZCFQc967FDqdFA3dpKNRyj4jrm6a+LpcDSERI63WfU/cuzQ0+6rXFEFiDo3ydRyBJOsusiO0QHfZGzMGKRrp7uz4wwERBofV1KejCO+bynTDb3kIfM7PjMvwY6ZoLXYHAOzftFYwvzIY6YITduvRp/RWr/5WRtoNDxBZlexh7AeSL/W8aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=WnsBS5CFHGhHbKNOuS++9ZDJ3GeiCjLv+33CExf5Nqw=; b=kKE+bti3M03RrKmXnae8G6BEOxTIhxF0wMGVCRiP8war3Vvk8LncCOnuM+sm1Bw8d6xIDAI2E74EP+vk4RIoReKxJHh7yE790blxmcrymEVmezRsyke6Sik60FyhuAQrxIznAHAqOag3SlkgZxx9BFkPLNEy6CskOcX9RO9V77tJ4BqmfOovsciXSYOYRVR/BNxnDmm1MlbAENh8bIVyr9cBE4mbz7Mgqgam0xtcZ8VFy5MmUw0HC0K7CX/cjG8MD43HVpVADM/UFEcvO7lI007a6PuK0kq8nwNe3dnyUeJZyvs/f1ikREJov8u1s1rDZEnqwH3pcQCcT7YiF6uOIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.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=WnsBS5CFHGhHbKNOuS++9ZDJ3GeiCjLv+33CExf5Nqw=; b=fCEuAVCa0ppokSRX9ne97zwmbKtTCLMVNZeOkq7qIzhbgVTH8QoXncj2tbOHuupI29qiA3Je0hRrZB0GBT/nYGerqLqVGHLmYazNuwbyU8nnoC514nGNxk7r32xddr+krltYWLn6hPwta0eXXrratLeB2CTU1oHJPwGDSiCAtpw6wtenL7ZChIrKw+mjnMKlUhuV6j8KV9HS8W3X4xLSP6l6Cq+3SRumcQrmSwmAPAwSbz8nYOToDeTMicdpTi+piY4Q7VG8ucM4Wq+gRuGj0hM28biLYDqSQ8dlfGQrwTjZsruJJQsOeO3Y5lyHuzJZGfzd/FWVKjRv+V+hkXsL8A== Received: from MW4PR02CA0014.namprd02.prod.outlook.com (2603:10b6:303:16d::29) by IA0PR12MB8974.namprd12.prod.outlook.com (2603:10b6:208:488::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.17; Wed, 13 Nov 2024 20:34:09 +0000 Received: from CO1PEPF000044FA.namprd21.prod.outlook.com (2603:10b6:303:16d:cafe::22) by MW4PR02CA0014.outlook.office365.com (2603:10b6:303:16d::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.16 via Frontend Transport; Wed, 13 Nov 2024 20:34:09 +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 CO1PEPF000044FA.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.1 via Frontend Transport; Wed, 13 Nov 2024 20:34:08 +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.1544.4; Wed, 13 Nov 2024 12:33:46 -0800 Received: from nexus.mtl.labs.mlnx (10.126.231.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.1544.4; Wed, 13 Nov 2024 12:33:44 -0800 From: Cosmin Ratiu To: CC: , , , , Subject: [PATCH 03/10] devlink: Store devlink rates in a rate domain Date: Wed, 13 Nov 2024 22:30:40 +0200 Message-ID: <20241113203317.2507537-4-cratiu@nvidia.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20241113203317.2507537-1-cratiu@nvidia.com> References: <20241113203317.2507537-1-cratiu@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044FA:EE_|IA0PR12MB8974:EE_ X-MS-Office365-Filtering-Correlation-Id: 5911225f-9862-4558-df96-08dd04228696 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: qtXIlU0mtsLZBW67ImpsMHNVD/pdGYWEFnvQN8xfnaZy6ZU/3LWSXoUG2Y+0WnkTvGfRMz04Pwao9ENHQ2rzjrtJFCpeACAmD7/5rkeTM3Fb1Kv5plBY1PWubzu7oawdHRQmx7GjW9ly1Ohr5N2ok2hhA2Cz0IYRupVmbhthduccDlLOlRAR4+c4G3NEzCnOigKzQN/q58379gX8z7VS59UsFezkSieUpKZVVoFEAh3w4nLZPEPILtbnIRC7Uf5lg+mZnxc2DE0DrN5ZD6pC/So67USR1Cr6DpYziMCnsCh0ZGXjs/lqvPRoG9YTIBsuoRNtm/2h5EbR3gERMvO8vjZ19ga1AJTzvtmk1mpTvdxgOe53U+lWc48szUhjMjZ711wc9p03qyGf23yhxD0iu2HLbyApwdkZEAFP6ea+yd8yDL+pf4ushns6CgcuuVSP7hyYDcRbeOKqs/a1NxhM3cpmCmKczHGf6Xer3Lr1jFcAyFmxUxPbdaewAVDhLPJuBh5I+fC2kdBNgGovR9zK7OWV4ZTJiZnpzxNGdrlA52Nhag2ahjjxyFB7r3Bysd0JSRR1Ok+rX1++vRmVJpbuFYKirIiF6rhes4JG+xgMOiP21hWQe5fVg4mK/AszpR8ZvwuICZS2X+uAIYo3lbAyzHli+UhX49W9HdMAWVl+DswYxXLHvS9GvJwU3ZgNTWlddiNs+ojcl74fAZcBGwToe13aOXjRDX9Ik9gnfDWQ8NAX0s6Itbn/khFEA4S9Zlj4ERhurCA3bLUS5J5MZQNF+RSRpq/h6JKjHb+rUsF1wBAUfYNR6KOc3FaqjMV2cavFSNoY9cx5iPShcafqI4mXMn2BrYhzyRs8sIsY363Bh6p4GNwJ64AK6Ajm9EnG54KhbDQhSJSjZIU2EQ4UnIXyAOulZnSM5dk6akQYntkJA6JXlx6Uc+R6NNZ+NxXnh3G7OWAlgzB8c6REcSaiGGJT6luS9tHj1kpuMIBvstCh/qx74Ywn5be8RV9lZWfncch1VsezsnbWs/8xlyQhl8YgfSuw4AcknOJeSGCp7qxcFU2RSsmywC+2+hilQfL0XF3OFAYf6elZWJJ4tBwThxwx05M6Slpo60VTSjvqiFdbmPyI4P2YozV31g0GLg2cXIBMMYixatWKZfcJ+i/Du1p878r3viZuDATEQRPHsvDgdtFmxCqOi76xlei0X84UzTOmtl3/s9Sf/y0lNmEExbflqBUbJA/1ms907szXmme+oeyoaOZWZz9XRdzlqB+f8s7Cz47zUdsB+H5gt7NgJa7EX7ymCnoAZPToKW3THLkHztjl4qGOM2woLNnaOgrISITWzRCA9GObaDDmFzacaMjrnmB5dpb4/CgUBl7N6znUGjd47sh6z+aOhekNFhuxyJ1DdKX1Fhr7E31+BPATGz+oeg== 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:(13230040)(1800799024)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2024 20:34:08.8818 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5911225f-9862-4558-df96-08dd04228696 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: CO1PEPF000044FA.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8974 X-Patchwork-Delegate: kuba@kernel.org Introduce the concept of a rate domain, a data structure aiming to store devlink rates of one or more devlink objects such that rate nodes within a rate domain can be parents of other rate nodes from the same domain. This commit takes the first steps in that direction by: - introducing a new 'devlink_rate_domain' data structure, allocated on devlink init. - storing devlink rates from the devlink object into the rate domain. - converting all accesses to the new data structure. - adding checks for everything that walks rates in a rate domain so that the correct devlink object is looked at. These checks are now spurious since all rate domains are private to their devlink object, but that is about to change and this is a good moment to add those checks. Issue: 3645895 Change-Id: I950064c3e86be0339a818e091dea9011d692c556 Signed-off-by: Cosmin Ratiu --- net/devlink/core.c | 11 ++++++++-- net/devlink/dev.c | 2 +- net/devlink/devl_internal.h | 7 ++++++- net/devlink/rate.c | 41 ++++++++++++++++++++++--------------- 4 files changed, 40 insertions(+), 21 deletions(-) diff --git a/net/devlink/core.c b/net/devlink/core.c index f49cd83f1955..06a2e2dce558 100644 --- a/net/devlink/core.c +++ b/net/devlink/core.c @@ -314,6 +314,7 @@ static void devlink_release(struct work_struct *work) mutex_destroy(&devlink->lock); lockdep_unregister_key(&devlink->lock_key); put_device(devlink->dev); + kvfree(devlink->rate_domain); kvfree(devlink); } @@ -424,6 +425,11 @@ struct devlink *devlink_alloc_ns(const struct devlink_ops *ops, if (!devlink) return NULL; + devlink->rate_domain = kvzalloc(sizeof(*devlink->rate_domain), GFP_KERNEL); + if (!devlink->rate_domain) + goto err_rate_domain; + INIT_LIST_HEAD(&devlink->rate_domain->rate_list); + ret = xa_alloc_cyclic(&devlinks, &devlink->index, devlink, xa_limit_31b, &last_id, GFP_KERNEL); if (ret < 0) @@ -436,7 +442,6 @@ struct devlink *devlink_alloc_ns(const struct devlink_ops *ops, xa_init_flags(&devlink->snapshot_ids, XA_FLAGS_ALLOC); xa_init_flags(&devlink->nested_rels, XA_FLAGS_ALLOC); write_pnet(&devlink->_net, net); - INIT_LIST_HEAD(&devlink->rate_list); INIT_LIST_HEAD(&devlink->linecard_list); INIT_LIST_HEAD(&devlink->sb_list); INIT_LIST_HEAD_RCU(&devlink->dpipe_table_list); @@ -455,6 +460,8 @@ struct devlink *devlink_alloc_ns(const struct devlink_ops *ops, return devlink; err_xa_alloc: + kvfree(devlink->rate_domain); +err_rate_domain: kvfree(devlink); return NULL; } @@ -477,7 +484,7 @@ void devlink_free(struct devlink *devlink) WARN_ON(!list_empty(&devlink->resource_list)); WARN_ON(!list_empty(&devlink->dpipe_table_list)); WARN_ON(!list_empty(&devlink->sb_list)); - WARN_ON(!list_empty(&devlink->rate_list)); + WARN_ON(!list_empty(&devlink->rate_domain->rate_list)); WARN_ON(!list_empty(&devlink->linecard_list)); WARN_ON(!xa_empty(&devlink->ports)); diff --git a/net/devlink/dev.c b/net/devlink/dev.c index 5ff5d9055a8d..c926c75cc10d 100644 --- a/net/devlink/dev.c +++ b/net/devlink/dev.c @@ -434,7 +434,7 @@ static void devlink_reload_reinit_sanity_check(struct devlink *devlink) WARN_ON(!list_empty(&devlink->trap_list)); WARN_ON(!list_empty(&devlink->dpipe_table_list)); WARN_ON(!list_empty(&devlink->sb_list)); - WARN_ON(!list_empty(&devlink->rate_list)); + WARN_ON(!list_empty(&devlink->rate_domain->rate_list)); WARN_ON(!list_empty(&devlink->linecard_list)); WARN_ON(!xa_empty(&devlink->ports)); } diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h index 9cc7a5f4a19f..209b4a4c7070 100644 --- a/net/devlink/devl_internal.h +++ b/net/devlink/devl_internal.h @@ -30,10 +30,14 @@ struct devlink_dev_stats { u32 remote_reload_stats[DEVLINK_RELOAD_STATS_ARRAY_SIZE]; }; +/* Stores devlink rates associated with a rate domain. */ +struct devlink_rate_domain { + struct list_head rate_list; +}; + struct devlink { u32 index; struct xarray ports; - struct list_head rate_list; struct list_head sb_list; struct list_head dpipe_table_list; struct list_head resource_list; @@ -55,6 +59,7 @@ struct devlink { */ struct mutex lock; struct lock_class_key lock_key; + struct devlink_rate_domain *rate_domain; u8 reload_failed:1; refcount_t refcount; struct rcu_work rwork; diff --git a/net/devlink/rate.c b/net/devlink/rate.c index c9e471b9734e..58108567b352 100644 --- a/net/devlink/rate.c +++ b/net/devlink/rate.c @@ -36,8 +36,9 @@ devlink_rate_node_get_by_name(struct devlink *devlink, const char *node_name) { static struct devlink_rate *devlink_rate; - list_for_each_entry(devlink_rate, &devlink->rate_list, list) { - if (devlink_rate_is_node(devlink_rate) && + list_for_each_entry(devlink_rate, &devlink->rate_domain->rate_list, list) { + if (devlink_rate->devlink == devlink && + devlink_rate_is_node(devlink_rate) && !strcmp(node_name, devlink_rate->name)) return devlink_rate; } @@ -177,16 +178,18 @@ void devlink_rates_notify_register(struct devlink *devlink) { struct devlink_rate *rate_node; - list_for_each_entry(rate_node, &devlink->rate_list, list) - devlink_rate_notify(rate_node, DEVLINK_CMD_RATE_NEW); + list_for_each_entry(rate_node, &devlink->rate_domain->rate_list, list) + if (rate_node->devlink == devlink) + devlink_rate_notify(rate_node, DEVLINK_CMD_RATE_NEW); } void devlink_rates_notify_unregister(struct devlink *devlink) { struct devlink_rate *rate_node; - list_for_each_entry_reverse(rate_node, &devlink->rate_list, list) - devlink_rate_notify(rate_node, DEVLINK_CMD_RATE_DEL); + list_for_each_entry_reverse(rate_node, &devlink->rate_domain->rate_list, list) + if (rate_node->devlink == devlink) + devlink_rate_notify(rate_node, DEVLINK_CMD_RATE_DEL); } static int @@ -198,7 +201,7 @@ devlink_nl_rate_get_dump_one(struct sk_buff *msg, struct devlink *devlink, int idx = 0; int err = 0; - list_for_each_entry(devlink_rate, &devlink->rate_list, list) { + list_for_each_entry(devlink_rate, &devlink->rate_domain->rate_list, list) { enum devlink_command cmd = DEVLINK_CMD_RATE_NEW; u32 id = NETLINK_CB(cb->skb).portid; @@ -206,6 +209,9 @@ devlink_nl_rate_get_dump_one(struct sk_buff *msg, struct devlink *devlink, idx++; continue; } + if (devlink_rate->devlink != devlink) + continue; + err = devlink_nl_rate_fill(msg, devlink_rate, cmd, id, cb->nlh->nlmsg_seq, flags, NULL); if (err) { @@ -576,7 +582,7 @@ int devlink_nl_rate_new_doit(struct sk_buff *skb, struct genl_info *info) goto err_rate_set; refcount_set(&rate_node->refcnt, 1); - list_add(&rate_node->list, &devlink->rate_list); + list_add(&rate_node->list, &devlink->rate_domain->rate_list); devlink_rate_notify(rate_node, DEVLINK_CMD_RATE_NEW); return 0; @@ -619,8 +625,9 @@ int devlink_rate_nodes_check(struct devlink *devlink, struct netlink_ext_ack *ex { struct devlink_rate *devlink_rate; - list_for_each_entry(devlink_rate, &devlink->rate_list, list) - if (devlink_rate_is_node(devlink_rate)) { + list_for_each_entry(devlink_rate, &devlink->rate_domain->rate_list, list) + if (devlink_rate->devlink == devlink && + devlink_rate_is_node(devlink_rate)) { NL_SET_ERR_MSG(extack, "Rate node(s) exists."); return -EBUSY; } @@ -666,7 +673,7 @@ devl_rate_node_create(struct devlink *devlink, void *priv, char *node_name, } refcount_set(&rate_node->refcnt, 1); - list_add(&rate_node->list, &devlink->rate_list); + list_add(&rate_node->list, &devlink->rate_domain->rate_list); devlink_rate_notify(rate_node, DEVLINK_CMD_RATE_NEW); return rate_node; } @@ -704,7 +711,7 @@ int devl_rate_leaf_create(struct devlink_port *devlink_port, void *priv, devlink_rate->devlink = devlink; devlink_rate->devlink_port = devlink_port; devlink_rate->priv = priv; - list_add_tail(&devlink_rate->list, &devlink->rate_list); + list_add_tail(&devlink_rate->list, &devlink->rate_domain->rate_list); devlink_port->devlink_rate = devlink_rate; devlink_rate_notify(devlink_rate, DEVLINK_CMD_RATE_NEW); @@ -745,13 +752,13 @@ EXPORT_SYMBOL_GPL(devl_rate_leaf_destroy); */ void devl_rate_nodes_destroy(struct devlink *devlink) { - static struct devlink_rate *devlink_rate, *tmp; + struct devlink_rate *devlink_rate, *tmp; const struct devlink_ops *ops = devlink->ops; devl_assert_locked(devlink); - list_for_each_entry(devlink_rate, &devlink->rate_list, list) { - if (!devlink_rate->parent) + list_for_each_entry(devlink_rate, &devlink->rate_domain->rate_list, list) { + if (!devlink_rate->parent || devlink_rate->devlink != devlink) continue; refcount_dec(&devlink_rate->parent->refcnt); @@ -762,8 +769,8 @@ void devl_rate_nodes_destroy(struct devlink *devlink) ops->rate_node_parent_set(devlink_rate, NULL, devlink_rate->priv, NULL, NULL); } - list_for_each_entry_safe(devlink_rate, tmp, &devlink->rate_list, list) { - if (devlink_rate_is_node(devlink_rate)) { + list_for_each_entry_safe(devlink_rate, tmp, &devlink->rate_domain->rate_list, list) { + if (devlink_rate->devlink == devlink && devlink_rate_is_node(devlink_rate)) { ops->rate_node_del(devlink_rate, devlink_rate->priv, NULL); list_del(&devlink_rate->list); kfree(devlink_rate->name); From patchwork Wed Nov 13 20:30:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Ratiu X-Patchwork-Id: 13874272 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2086.outbound.protection.outlook.com [40.107.95.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9AB3A206040 for ; Wed, 13 Nov 2024 20:34:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731530050; cv=fail; b=YaRYFB/RUPQD1gwe8yCyMYs1AxeAZ4B8VHN6iH3adD4WICRAUG7fxGb2TpzIClFAYsF8f4TtWvC4D5AE+3NPmyj5jBsle+krXoCrAOuhCWzOozYKAByF9gsUIOZbCj75I7XGHE8AfZ523Pu0t61Bzg5EPwp9zqv0jAgYWu0ehKU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731530050; c=relaxed/simple; bh=nHb4XnqNgYugP17RoRyi2pQQ2wRBpveDSqFo56/2CjA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BKiwgJh5XbMeeT63Au//LDBLoYuvzrV65LWpL2TW5M96Qw023rTSnPJUCJuQ8pvaWIi0gZ3xs1oQAP2nqBCVAtlewqf8X51RxLAm6U9nCxn8f4vFLC3oEbT6V3Z0Iv8Fcv83mseJoRPEDP2pNv2GI9z0f4J1/sCvZ8RYQ5B1h3M= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=W0DOXi43; arc=fail smtp.client-ip=40.107.95.86 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="W0DOXi43" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BPjqPwHsWXNyIDDAFZEJrG4c/CzSLgzrPJch/L60CAC+CkGKXBKejadYpIgi1q15IOtAN0HQzNmq07UPD7Mkc1yIyeCMRqTfllfda4bQA1bEM2+fpLXnbHEsPaYHLzDpd949UONqbxEzLEfHm+RhfozGCHcanQ3oYFC1FwCs+Sjk1OanPo84o0XTp3PpDkko0UjNHwXUwID8e4U5QsD/nJzqCOebvNQhJjF6dVArz9kFUEiWroWSYIu40z1a+G6MpAN1YP0t//nzeai025Elt8BjZY1WQ24/aESrHgZ2xbBV/4oxfS6oBWpRSvhrOn2hftTaFqbR1DjWN+utTDQnWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=/z2qlRDWUoYl5+kwUhBhx/M8XPGlo4NSN+1eT2H/2RU=; b=TwcNez6SDa+dt1ibOo1GskkED4Q3hrrykK5QlniqclAOEDPkNRUEq8ENZrVMxsGX9wcbd4eDEyviLRGWqcoEZUpfQDnnAtFAASobXsYOJc2s7SSe9Lc4GilP69hOE7JJ2C5jRwsIT8CDfs43tGkwZlpjA16X5QHp1k0e/6q8LNuJI1JZyG0lW93zahHJ140FgWIoPqdxWuPqqHIWZoeZhwgNeDSadwnIrxYuzaQIBchZBoR9376knb9fKuKQY8umrHJQ5GjvG8ifcb2Z58EgTl2XgXGVDEFb95/2L+H7337XcvxnznNFYMHQ6vzJ0EuolEP7nAsgKYElwXX1bvQw8A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.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=/z2qlRDWUoYl5+kwUhBhx/M8XPGlo4NSN+1eT2H/2RU=; b=W0DOXi43dxa0dMXrGpjE1OZFQ0s+j3ni07e83/D3ABUgRQCvNteenm2GCjRUWbXos7JbZii87uNmbnHMhDQXXX+EkV/rjzDM4+3tkTbycmo3ytXtT6Mehnrb5I6l+VL8FC4XUCvcg1dYMT84rqIu+hc2L8KqHqrGEm27JTIhZoFI8accmrYlg7Skq87OYR6SwniyErWC8luYIWGyjuL4fNThETMtqd9AMAMgWycSx59665AtQnW85g3ppxgEUzGx1M5b2OUJhA/0H/sMl3EApQloSIH6CmOpzJTNWbWQDR3WRQyaJBq0sVoomWNSz16T9f5BUoXOMS33blA7buOEmg== Received: from DM6PR01CA0016.prod.exchangelabs.com (2603:10b6:5:296::21) by PH7PR12MB7985.namprd12.prod.outlook.com (2603:10b6:510:27b::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.27; Wed, 13 Nov 2024 20:34:03 +0000 Received: from DS1PEPF0001708E.namprd03.prod.outlook.com (2603:10b6:5:296:cafe::ae) by DM6PR01CA0016.outlook.office365.com (2603:10b6:5:296::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28 via Frontend Transport; Wed, 13 Nov 2024 20:34:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS1PEPF0001708E.mail.protection.outlook.com (10.167.17.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Wed, 13 Nov 2024 20:34: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.1544.4; Wed, 13 Nov 2024 12:33:48 -0800 Received: from nexus.mtl.labs.mlnx (10.126.231.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.1544.4; Wed, 13 Nov 2024 12:33:46 -0800 From: Cosmin Ratiu To: CC: , , , , Subject: [PATCH 04/10] devlink: Serialize access to rate domains Date: Wed, 13 Nov 2024 22:30:41 +0200 Message-ID: <20241113203317.2507537-5-cratiu@nvidia.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20241113203317.2507537-1-cratiu@nvidia.com> References: <20241113203317.2507537-1-cratiu@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001708E:EE_|PH7PR12MB7985:EE_ X-MS-Office365-Filtering-Correlation-Id: 03a20795-e743-4893-04e5-08dd04228328 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: BRNoLKFrkSNIcGi5MPwcuS8uXNpU1w4TBxeGgj+4B+J3TdO/tvA2PvMXGpCc/ECfPYcetE5uEvPuPRve/oiMNWQPY7rlyK0dGntYYrjlnQs2RUbTwlHOyP4IZu3/YwPBAR/fONjxaJlRwOuBFig4BuKxn1i1CNb0cz9nlT5UaU6IsaZsbFq5WNzc+NYF1BqbUutvvQECpIvWq1BJJGjvrsU56OG6Euvg3YItDhYLxMevXtGEgLtDfjiGxs6rua5Yjb9DrD0ct6i/Swyy41s25p21gZhb/QInmNZR2qYnLnqEEAv7uqC3xA207NA0VbpInLmdQ2hvM/yizV0AhIg3fKTKUJ4cTiKAgU8G8DimB1G6amQcYt8cJpiYg1GwDg9wQ3asMhn1ely35aNfh/9usIoHpk9k2LyRYPO/2OqT9x5ldJLOow2oPNcW2N++Wb5Fu8LkVdk4TYZDWhEbX7zUrv68vPF/Cnib6M6w8oxr/VQLT2jMngVAsAejj2jWR2UC0txVp9xaR1su+Y2uskoVQLDj3xSD1PamwCoNTIRPjtRHRksC6fKCRR3e0L4HQcRKdq92zAkqdyZYiJIZl6gQmmVbLFGnNXcsaa+ZuzvcT2rHistWZQOKmMyqKjVPCFaj9W6XKKkUSJ+fNs6WVIM4c3DoauEGRlzcqlQyEjfxPxWHQ5ZBsD1xTp8NnoKU1seupdtDafH+sirNjl5lXYJM5MymN+PFyp79eLqx8wj/7lR3+WpCtkjW+8GgYBf2nss1dIkk3CqjcGzg9XVEmmURjw1XJ6A1OWShCMfR8oUq+jMcYYCb5Vba1bQOp/dY5gTuhfBi2Uw7xyH6IZrN/ufYKOtHa0SPGiJJKgE0c8TlbuX7BFlEuxD1tkgkTvCaaWvkHbZDGvb8wRNzbRrGqkQwxJPrjHFNJEliaxR1zYBBmohqlOFOTOVp5g5wzWwYe5xQArqRgMfVyGwk2qaVIBu9RSYGzsWus82EBx/Hz3tTLVnplzGf0sfSEnrBCyAQhl+fwUHHJLBpm4hqel1KqpYK3DYvVwcqW4VfMLoi+Gd7Q7AAua4vmUipS8oHjTbIaibZSYtmlkvOV6+V+iDqABHuXX8fYPSPejihSB7FOVrY1EYLYRFvsWFsJ4VF+1j25kALJdx7WPfG1cwKrViLhZ210/PVgEVtKuHdObnfXhHzDApmGTus+kmbrfukc3QXvO3SGlpwQialEXE13O/xQSVl3bq//FN/L6YkkbKxJj1PzHTpUtJ/NevRPV7la1Y9v+n4sTTZjFGg4VOxE7gBfFiWb0xmYJ56jZUvPnvty6VH7cD2nruJ9wuxEEkZtfyRbJEAWMF9SsJ28MZYxIR0A+wD8YbpIya4tGgpWKJUPG1mhvHXNbidH0sG/w9rx+MhPMzZ+RMeGh7UIUlSGCkrA/xNkg== 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:(13230040)(376014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2024 20:34:03.1221 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 03a20795-e743-4893-04e5-08dd04228328 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: DS1PEPF0001708E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7985 X-Patchwork-Delegate: kuba@kernel.org Access to rates in a rate domain should be serialized. This commit introduces two new functions, devl_rate_domain_lock and devl_rate_domain_unlock, and uses them whenever serial access to a rate domain is needed. For now, they are no-ops since access to a rate domain is protected by the devlink lock. Issue: 3645895 Change-Id: Ic1649ae928fdc0d30e45c615bf545e3b1745181f Signed-off-by: Cosmin Ratiu --- net/devlink/devl_internal.h | 4 ++ net/devlink/rate.c | 114 +++++++++++++++++++++++++++--------- 2 files changed, 89 insertions(+), 29 deletions(-) diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h index 209b4a4c7070..fae81dd6953f 100644 --- a/net/devlink/devl_internal.h +++ b/net/devlink/devl_internal.h @@ -121,6 +121,10 @@ static inline void devl_dev_unlock(struct devlink *devlink, bool dev_lock) device_unlock(devlink->dev); } +static inline void devl_rate_domain_lock(struct devlink *devlink) { } + +static inline void devl_rate_domain_unlock(struct devlink *devlink) { } + typedef void devlink_rel_notify_cb_t(struct devlink *devlink, u32 obj_index); typedef void devlink_rel_cleanup_cb_t(struct devlink *devlink, u32 obj_index, u32 rel_index); diff --git a/net/devlink/rate.c b/net/devlink/rate.c index 58108567b352..b888a6ecdf96 100644 --- a/net/devlink/rate.c +++ b/net/devlink/rate.c @@ -178,18 +178,22 @@ void devlink_rates_notify_register(struct devlink *devlink) { struct devlink_rate *rate_node; + devl_rate_domain_lock(devlink); list_for_each_entry(rate_node, &devlink->rate_domain->rate_list, list) if (rate_node->devlink == devlink) devlink_rate_notify(rate_node, DEVLINK_CMD_RATE_NEW); + devl_rate_domain_unlock(devlink); } void devlink_rates_notify_unregister(struct devlink *devlink) { struct devlink_rate *rate_node; + devl_rate_domain_lock(devlink); list_for_each_entry_reverse(rate_node, &devlink->rate_domain->rate_list, list) if (rate_node->devlink == devlink) devlink_rate_notify(rate_node, DEVLINK_CMD_RATE_DEL); + devl_rate_domain_unlock(devlink); } static int @@ -201,6 +205,7 @@ devlink_nl_rate_get_dump_one(struct sk_buff *msg, struct devlink *devlink, int idx = 0; int err = 0; + devl_rate_domain_lock(devlink); list_for_each_entry(devlink_rate, &devlink->rate_domain->rate_list, list) { enum devlink_command cmd = DEVLINK_CMD_RATE_NEW; u32 id = NETLINK_CB(cb->skb).portid; @@ -220,6 +225,7 @@ devlink_nl_rate_get_dump_one(struct sk_buff *msg, struct devlink *devlink, } idx++; } + devl_rate_domain_unlock(devlink); return err; } @@ -236,23 +242,33 @@ int devlink_nl_rate_get_doit(struct sk_buff *skb, struct genl_info *info) struct sk_buff *msg; int err; + devl_rate_domain_lock(devlink); devlink_rate = devlink_rate_get_from_info(devlink, info); - if (IS_ERR(devlink_rate)) - return PTR_ERR(devlink_rate); + if (IS_ERR(devlink_rate)) { + err = PTR_ERR(devlink_rate); + goto unlock; + } msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); - if (!msg) - return -ENOMEM; + if (!msg) { + err = -ENOMEM; + goto unlock; + } err = devlink_nl_rate_fill(msg, devlink_rate, DEVLINK_CMD_RATE_NEW, info->snd_portid, info->snd_seq, 0, info->extack); - if (err) { - nlmsg_free(msg); - return err; - } + if (err) + goto err_fill; + devl_rate_domain_unlock(devlink); return genlmsg_reply(msg, info); + +err_fill: + nlmsg_free(msg); +unlock: + devl_rate_domain_unlock(devlink); + return err; } static bool @@ -524,18 +540,24 @@ int devlink_nl_rate_set_doit(struct sk_buff *skb, struct genl_info *info) const struct devlink_ops *ops; int err; + devl_rate_domain_lock(devlink); devlink_rate = devlink_rate_get_from_info(devlink, info); - if (IS_ERR(devlink_rate)) - return PTR_ERR(devlink_rate); + if (IS_ERR(devlink_rate)) { + err = PTR_ERR(devlink_rate); + goto unlock; + } ops = devlink->ops; - if (!ops || !devlink_rate_set_ops_supported(ops, info, devlink_rate->type)) - return -EOPNOTSUPP; + if (!ops || !devlink_rate_set_ops_supported(ops, info, devlink_rate->type)) { + err = -EOPNOTSUPP; + goto unlock; + } err = devlink_nl_rate_set(devlink_rate, ops, info); - if (!err) devlink_rate_notify(devlink_rate, DEVLINK_CMD_RATE_NEW); +unlock: + devl_rate_domain_unlock(devlink); return err; } @@ -555,15 +577,21 @@ int devlink_nl_rate_new_doit(struct sk_buff *skb, struct genl_info *info) if (!devlink_rate_set_ops_supported(ops, info, DEVLINK_RATE_TYPE_NODE)) return -EOPNOTSUPP; + devl_rate_domain_lock(devlink); rate_node = devlink_rate_node_get_from_attrs(devlink, info->attrs); - if (!IS_ERR(rate_node)) - return -EEXIST; - else if (rate_node == ERR_PTR(-EINVAL)) - return -EINVAL; + if (!IS_ERR(rate_node)) { + err = -EEXIST; + goto unlock; + } else if (rate_node == ERR_PTR(-EINVAL)) { + err = -EINVAL; + goto unlock; + } rate_node = kzalloc(sizeof(*rate_node), GFP_KERNEL); - if (!rate_node) - return -ENOMEM; + if (!rate_node) { + err = -ENOMEM; + goto unlock; + } rate_node->devlink = devlink; rate_node->type = DEVLINK_RATE_TYPE_NODE; @@ -584,6 +612,7 @@ int devlink_nl_rate_new_doit(struct sk_buff *skb, struct genl_info *info) refcount_set(&rate_node->refcnt, 1); list_add(&rate_node->list, &devlink->rate_domain->rate_list); devlink_rate_notify(rate_node, DEVLINK_CMD_RATE_NEW); + devl_rate_domain_unlock(devlink); return 0; err_rate_set: @@ -592,6 +621,8 @@ int devlink_nl_rate_new_doit(struct sk_buff *skb, struct genl_info *info) kfree(rate_node->name); err_strdup: kfree(rate_node); +unlock: + devl_rate_domain_unlock(devlink); return err; } @@ -601,13 +632,17 @@ int devlink_nl_rate_del_doit(struct sk_buff *skb, struct genl_info *info) struct devlink_rate *rate_node; int err; + devl_rate_domain_lock(devlink); rate_node = devlink_rate_node_get_from_info(devlink, info); - if (IS_ERR(rate_node)) - return PTR_ERR(rate_node); + if (IS_ERR(rate_node)) { + err = PTR_ERR(rate_node); + goto unlock; + } if (refcount_read(&rate_node->refcnt) > 1) { NL_SET_ERR_MSG(info->extack, "Node has children. Cannot delete node."); - return -EBUSY; + err = -EBUSY; + goto unlock; } devlink_rate_notify(rate_node, DEVLINK_CMD_RATE_DEL); @@ -618,20 +653,26 @@ int devlink_nl_rate_del_doit(struct sk_buff *skb, struct genl_info *info) list_del(&rate_node->list); kfree(rate_node->name); kfree(rate_node); +unlock: + devl_rate_domain_unlock(devlink); return err; } int devlink_rate_nodes_check(struct devlink *devlink, struct netlink_ext_ack *extack) { struct devlink_rate *devlink_rate; + int err = 0; + devl_rate_domain_lock(devlink); list_for_each_entry(devlink_rate, &devlink->rate_domain->rate_list, list) if (devlink_rate->devlink == devlink && devlink_rate_is_node(devlink_rate)) { NL_SET_ERR_MSG(extack, "Rate node(s) exists."); - return -EBUSY; + err = -EBUSY; + break; } - return 0; + devl_rate_domain_unlock(devlink); + return err; } /** @@ -649,13 +690,19 @@ devl_rate_node_create(struct devlink *devlink, void *priv, char *node_name, { struct devlink_rate *rate_node; + devl_rate_domain_lock(devlink); + rate_node = devlink_rate_node_get_by_name(devlink, node_name); - if (!IS_ERR(rate_node)) - return ERR_PTR(-EEXIST); + if (!IS_ERR(rate_node)) { + rate_node = ERR_PTR(-EEXIST); + goto unlock; + } rate_node = kzalloc(sizeof(*rate_node), GFP_KERNEL); - if (!rate_node) - return ERR_PTR(-ENOMEM); + if (!rate_node) { + rate_node = ERR_PTR(-ENOMEM); + goto unlock; + } if (parent) { rate_node->parent = parent; @@ -669,12 +716,15 @@ devl_rate_node_create(struct devlink *devlink, void *priv, char *node_name, rate_node->name = kstrdup(node_name, GFP_KERNEL); if (!rate_node->name) { kfree(rate_node); - return ERR_PTR(-ENOMEM); + rate_node = ERR_PTR(-ENOMEM); + goto unlock; } refcount_set(&rate_node->refcnt, 1); list_add(&rate_node->list, &devlink->rate_domain->rate_list); devlink_rate_notify(rate_node, DEVLINK_CMD_RATE_NEW); +unlock: + devl_rate_domain_unlock(devlink); return rate_node; } EXPORT_SYMBOL_GPL(devl_rate_node_create); @@ -702,6 +752,7 @@ int devl_rate_leaf_create(struct devlink_port *devlink_port, void *priv, if (!devlink_rate) return -ENOMEM; + devl_rate_domain_lock(devlink); if (parent) { devlink_rate->parent = parent; refcount_inc(&devlink_rate->parent->refcnt); @@ -714,6 +765,7 @@ int devl_rate_leaf_create(struct devlink_port *devlink_port, void *priv, list_add_tail(&devlink_rate->list, &devlink->rate_domain->rate_list); devlink_port->devlink_rate = devlink_rate; devlink_rate_notify(devlink_rate, DEVLINK_CMD_RATE_NEW); + devl_rate_domain_unlock(devlink); return 0; } @@ -734,11 +786,13 @@ void devl_rate_leaf_destroy(struct devlink_port *devlink_port) if (!devlink_rate) return; + devl_rate_domain_lock(devlink_port->devlink); devlink_rate_notify(devlink_rate, DEVLINK_CMD_RATE_DEL); if (devlink_rate->parent) refcount_dec(&devlink_rate->parent->refcnt); list_del(&devlink_rate->list); devlink_port->devlink_rate = NULL; + devl_rate_domain_unlock(devlink_port->devlink); kfree(devlink_rate); } EXPORT_SYMBOL_GPL(devl_rate_leaf_destroy); @@ -756,6 +810,7 @@ void devl_rate_nodes_destroy(struct devlink *devlink) const struct devlink_ops *ops = devlink->ops; devl_assert_locked(devlink); + devl_rate_domain_lock(devlink); list_for_each_entry(devlink_rate, &devlink->rate_domain->rate_list, list) { if (!devlink_rate->parent || devlink_rate->devlink != devlink) @@ -777,5 +832,6 @@ void devl_rate_nodes_destroy(struct devlink *devlink) kfree(devlink_rate); } } + devl_rate_domain_unlock(devlink); } EXPORT_SYMBOL_GPL(devl_rate_nodes_destroy); From patchwork Wed Nov 13 20:30:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Ratiu X-Patchwork-Id: 13874277 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2056.outbound.protection.outlook.com [40.107.102.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F7EF433CE for ; Wed, 13 Nov 2024 20:34:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731530064; cv=fail; b=OrILS3f4Fo8VSIoQAPoNTbwXqylUwgi8LSsrzpTtqcPhbQQlU5rN3RffEkax2HpXDgAGvbSGjwzk/jC01NpJ2X+JMTHTCelViqtH8GLtrxI+tCZquDHp2nZvMAmt+4exR5nsVjcnvgwa7wLB5Qe3FgmRkj/j52VJNUpmMHJsM4Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731530064; c=relaxed/simple; bh=AoNJyR+aGh7y4SUHWoSGDahjhqIo3D3kmH7HiFuOKQA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TeWAqcxrzRwbuuSIrlP+UoevFth8+kcIriZ1ppdWtIxIVGSmtBB9G5l4fBxnPiz62td5M51327FtDdU4eN9nH0/+3HHrw6JD/9daUyf0jUmMq3F7DL/m+UNlIFJJdfGhFb4bOObzZZQ13S0JZanY7SkVTFdJ9/Ef1kSzRuSGUwc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=NbEGtwTH; arc=fail smtp.client-ip=40.107.102.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="NbEGtwTH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tzHrqZLoWAeTWhRiijU0r0Cn+yk72nftjIAXxnwQ0g+H9gF0VN08xbMvG+29pSZXYbdjljrDQvrzUAB+SSAsrdhvhlzPfJArodnOKqBwR2s4IsoQT7xzPq/tgVM6UzWDChZ2x+QlmpWkhs0UM2/+ZeaUvRQjzrf+faZH32InI1uWQ2+HDk0cfdl+6xTsByypmhMJhd0oVzUouq1wCEt2SXdvZKiN+0349Xz7ITQNMpwV5zYe66r4iSDfUIcxHbUqF/2fJoXKE8z6B5YgtDkUBrAqJ7dc1XdQL7//D31nSrIuOC3fixFyS+iQeHgesn2Qo0ILqpbt+3sONoTtLApnsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=5hOK8IxJkE2N9UWHVGimpYbuc0M/nv5+3Yd0HhzNbzc=; b=F+SPdf2dMwkViVaIVWijQ6YJlJ9bfzaows4gpShd214ZViWtGtV4a1i1rTbkivyL3P0L2WshPn+MSP+4oiIAGoyRZ2zB7Obj5NhC03B/FY3BdRCFAJTed96tOSaUw191yJIPbZAPyqKbWybN+GGtqgRKBHHBrZIFNJIr6MhIZE4Umbg8SaOIryURGJXcVOt+V69kWHugzJbJbBjKUbZ8MEKJbI61nvC6WcVObxxo8TUDrnWwA3AjZ82H6aGvzvV7bZL/vRn2GzN2vrJY2UZsuI1yMGkRKPse0QR1Yt3bCXlCGIxVYo3NJJH9jiUMn2TuaazWBFhzZRkhjPlteUgHkg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.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=5hOK8IxJkE2N9UWHVGimpYbuc0M/nv5+3Yd0HhzNbzc=; b=NbEGtwTHwl09ONatnn0u2phUrSrwtj5BLO5pFsjdQOSTn+rkJJVXZE/zehvAs1kxsyeIdXzIFaa+TT3Isy23OG4Wk7K7etAGRplxsiuDMRPOmHJUV4C6ep1hSsvNMmAIxl01p4Q5hu0zN2JZ7j33b7ok3aI3Biq8iNjLOndJefW01XKhXZJOOC9W9inecVr5sgfYmAMwYGcdt5QmSnvJN8j8ITXVrEnUbI+7JCEXjlLfJkcf15pbmXORcMb7LOhTFxRvNEqOwlMsf4968nlxwV2KkMlIOd8NeroQsL37gZKdhhg5ogumWsg+/wXPBfB2FO888en0aMuyrw1qS5OVOA== Received: from MW4PR02CA0002.namprd02.prod.outlook.com (2603:10b6:303:16d::10) by DS0PR12MB6629.namprd12.prod.outlook.com (2603:10b6:8:d3::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28; Wed, 13 Nov 2024 20:34:13 +0000 Received: from CO1PEPF000044FA.namprd21.prod.outlook.com (2603:10b6:303:16d:cafe::ae) by MW4PR02CA0002.outlook.office365.com (2603:10b6:303:16d::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.17 via Frontend Transport; Wed, 13 Nov 2024 20:34:12 +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 CO1PEPF000044FA.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.1 via Frontend Transport; Wed, 13 Nov 2024 20:34:12 +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.1544.4; Wed, 13 Nov 2024 12:33:51 -0800 Received: from nexus.mtl.labs.mlnx (10.126.231.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.1544.4; Wed, 13 Nov 2024 12:33:49 -0800 From: Cosmin Ratiu To: CC: , , , , Subject: [PATCH 05/10] devlink: Introduce shared rate domains Date: Wed, 13 Nov 2024 22:30:42 +0200 Message-ID: <20241113203317.2507537-6-cratiu@nvidia.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20241113203317.2507537-1-cratiu@nvidia.com> References: <20241113203317.2507537-1-cratiu@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044FA:EE_|DS0PR12MB6629:EE_ X-MS-Office365-Filtering-Correlation-Id: fe87dcd1-4607-483c-d778-08dd042288f6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|82310400026|30052699003|1800799024; X-Microsoft-Antispam-Message-Info: nkosOxCH+1bZhIDgT7KD3er3kXVejOMdU88VIHJUYMHIUQ2vK6OiLBEDa1E7hj1ocI0jpBZvJJR8AzW+cH0ntcidbF5gOJlB0n1TmrOpBhKkOjAVa0HJQtxXCp7UTJMcXh5Suta+ytrb1J5Hmj2GBplKlLbrC7TlC0ZgK3Yu3wCfZXIWhUhpCgf3ucFc4clhlCN4uptZyM2u9f4HV8+1yqLiaiudRcy0V5P/FCq+HHn32LjUbTrLJRSPQGODT4fuPC3cMedYmNvHuX8ffBg87YM8BSRt92m8EyeTMKHFCF6OgvPBg7Dk0tRIScbhlHLBQOi71QaAeH1fT6UIcwK7fiUoL3fX+ZQcI5ef5UArWVBZQv8xmRjj9cfzyK4CuDLmwikCJPielfIO/SyEevpWuWaDTCtVvUwjmCtDbOBLi15oEnZlSZBK/l13382LgtND10yn0dgAG4Ncr/QuX00/J8SF0BZu1UvYMB1TwYmXgEgr/60dZDze7Lhb9h45i/bPzZ+/NNkkqGp5+mts9c4GXtD2OOaUYWbBrIRQYr7p3CZnJwAfKSwGIOX5vb0OhiItXwDtwZUDg4VGZU59y6BexNHyR0PwOmps1dC6qXoaiN16mdkHC4hJfroW/au3e3byudXPn50BbNw+0OBT8iMWUu3crjswZlzBMJEwFow8bvEMFhEb8Z+FW3ojLPQD5xeDt1qfknZDzyV+RUTXq9lRg0U0xTiEBJ6nr2pzFXQtWIR/UVdfMx0ahsc0VBkTtNTgbbOlM8AwVPdD988fryR9QCjdYqcz/kyenLMrYja4+xZ6txZFMTIZbGWDO8V0umobgeZe3yGB4dQz8tKYj3A18QcpncSVZkFqwHoL5NBm4pHWLyRi8oASA0kqAhG/pCuKWJSqr+Dc+cVNflhiuo9zPoagaBHjHd3ahrF0x+5m6smLmJhpoeahgSLk/Gmdnj/s6zw+WTvtUu4Zj9F/86TAnJ9F9tZA5O/dI0XA0pKdyk6fc14TdJGpkSzKiZMBtHsNJ6ufmoKOGlXXOOVSDMNY4HZ+i82rxzbljAfYbgcu+YTY55MOP19KHSwN5WXcuFfsSxPbSp9T/P9XyvRXD/n6FVvm1GA38Mx8gqXsyp/8PlvogalbKqmloOYJ8XFlgGuuVneBLFt072n4uMU/7kT86RKU8Y9CZpaJ5VUb8Akm4adRXlz1L0CmDlXnPR2MzSp8Z4ZUqTsu7YGn40LDksKVSLaCaayAtgidKuxwq0BHToNfqFMp9577M1wHC/CDt7t30RUbRrEsjzvonrA7JTpLQZBDfKbGu1kdcAUD0jpOT8wdjZZkjRh/v2Cni+ATMaNH9nRO0x2KXKm3D3NpxAV5suc8ynSEJWOhYo3R4YtJEadYdQEmLI6jZVfcNfmJDyYR4e5w1vrvOr08DQnSECr9zA== 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:(13230040)(376014)(36860700013)(82310400026)(30052699003)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2024 20:34:12.8818 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fe87dcd1-4607-483c-d778-08dd042288f6 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: CO1PEPF000044FA.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6629 X-Patchwork-Delegate: kuba@kernel.org The underlying idea is modeling a piece of hardware which: 1. Exposes multiple functions as separate devlink objects. 2. Is capable of instantiating a transmit scheduling tree spanning multiple functions. Modeling this requires devlink rate nodes with parents across other devlink objects. A naive approach that relies on the current one-lock-per-devlink model is impossible, as it would require in some cases acquiring multiple devlink locks in the correct order. Based on the preliminary patches in this series, this commit introduces the concept of a shared rate domain. 1. A shared rate domain stores rate nodes for a piece of hardware that has the properties described at the beginning. 2. A shared rate domain is identified by the devlink operations pointer (a proxy for the device type) and a unique u64 hardware identifier provided by the driver. 3. There is a global registry of reference counted shared rate domains. 4. A devlink object starts out with a private rate domain, and can be switched once to use a shared rate domain with devlink_shared_rate_domain_init. Further calls do nothing. 5. Shared rate domains have an additional mutex serializing access to rate nodes, acquired by the previously introduced functions devl_rate_domain_lock and devl_rate_domain_unlock. These new code paths are unused for now. A caller to devlink_shared_rate_domain_init will be added in a subsequent patch. Issue: 3645895 Change-Id: I045456c4d06fd7018ba0da345688ee43e1d0fd74 Signed-off-by: Cosmin Ratiu --- include/net/devlink.h | 8 ++++ net/devlink/core.c | 79 ++++++++++++++++++++++++++++++++++++- net/devlink/dev.c | 2 +- net/devlink/devl_internal.h | 26 ++++++++++-- net/devlink/rate.c | 15 +++++++ 5 files changed, 124 insertions(+), 6 deletions(-) diff --git a/include/net/devlink.h b/include/net/devlink.h index 917bc006a5a4..18da697f6607 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -1553,6 +1553,14 @@ void devlink_register(struct devlink *devlink); void devlink_unregister(struct devlink *devlink); void devlink_free(struct devlink *devlink); +/* Can be used to tell devlink that shared rate domains are supported. + * The same id needs to be provided for devlink objects that can share + * rate nodes in hw (e.g. contain nodes with parents in other devlink objects). + * This requires holding the devlink lock and can only be called once per object. + * Rate node relationships across different rate domains are not supported. + */ +int devlink_shared_rate_domain_init(struct devlink *devlink, u64 id); + /** * struct devlink_port_ops - Port operations * @port_split: Callback used to split the port into multiple ones. diff --git a/net/devlink/core.c b/net/devlink/core.c index 06a2e2dce558..eb96a97a9e44 100644 --- a/net/devlink/core.c +++ b/net/devlink/core.c @@ -289,6 +289,80 @@ void devl_unlock(struct devlink *devlink) } EXPORT_SYMBOL_GPL(devl_unlock); +/* A global data struct with all shared rate domains. */ +static struct { + struct mutex lock; /* Acquired AFTER the devlink lock. */ + struct list_head rate_domains; +} devlink_rate_domains = { + .lock = __MUTEX_INITIALIZER(devlink_rate_domains.lock), + .rate_domains = LIST_HEAD_INIT(devlink_rate_domains.rate_domains), +}; + +static bool devlink_rate_domain_eq(struct devlink_rate_domain *rate_domain, + const struct devlink_ops *ops, u64 id) +{ + return rate_domain->ops == ops && rate_domain->id == id; +} + +int devlink_shared_rate_domain_init(struct devlink *devlink, u64 id) +{ + struct devlink_rate_domain *rate_domain; + int err = 0; + + devl_assert_locked(devlink); + + if (devlink->rate_domain->shared) { + if (devlink_rate_domain_eq(devlink->rate_domain, devlink->ops, id)) + return 0; + return -EEXIST; + } + if (!list_empty(&devlink->rate_domain->rate_list)) + return -EINVAL; + + mutex_lock(&devlink_rate_domains.lock); + list_for_each_entry(rate_domain, &devlink_rate_domains.rate_domains, list) { + if (devlink_rate_domain_eq(rate_domain, devlink->ops, id)) { + refcount_inc(&rate_domain->refcount); + goto replace_domain; + } + } + + /* Shared domain not found, create one. */ + rate_domain = kvzalloc(sizeof(*rate_domain), GFP_KERNEL); + if (!rate_domain) { + err = -ENOMEM; + goto unlock; + } + rate_domain->shared = true; + rate_domain->ops = devlink->ops; + rate_domain->id = id; + mutex_init(&rate_domain->lock); + INIT_LIST_HEAD(&rate_domain->rate_list); + refcount_set(&rate_domain->refcount, 1); + list_add_tail(&rate_domain->list, &devlink_rate_domains.rate_domains); +replace_domain: + kvfree(devlink->rate_domain); + devlink->rate_domain = rate_domain; +unlock: + mutex_unlock(&devlink_rate_domains.lock); + return err; +} +EXPORT_SYMBOL_GPL(devlink_shared_rate_domain_init); + +static void devlink_rate_domain_put(struct devlink_rate_domain *rate_domain) +{ + if (rate_domain->shared) { + if (!refcount_dec_and_test(&rate_domain->refcount)) + return; + + WARN_ON(!list_empty(&rate_domain->rate_list)); + mutex_lock(&devlink_rate_domains.lock); + list_del(&rate_domain->list); + mutex_unlock(&devlink_rate_domains.lock); + } + kvfree(rate_domain); +} + /** * devlink_try_get() - try to obtain a reference on a devlink instance * @devlink: instance to reference @@ -314,7 +388,7 @@ static void devlink_release(struct work_struct *work) mutex_destroy(&devlink->lock); lockdep_unregister_key(&devlink->lock_key); put_device(devlink->dev); - kvfree(devlink->rate_domain); + devlink_rate_domain_put(devlink->rate_domain); kvfree(devlink); } @@ -428,6 +502,7 @@ struct devlink *devlink_alloc_ns(const struct devlink_ops *ops, devlink->rate_domain = kvzalloc(sizeof(*devlink->rate_domain), GFP_KERNEL); if (!devlink->rate_domain) goto err_rate_domain; + devlink->rate_domain->shared = false; INIT_LIST_HEAD(&devlink->rate_domain->rate_list); ret = xa_alloc_cyclic(&devlinks, &devlink->index, devlink, xa_limit_31b, @@ -484,7 +559,7 @@ void devlink_free(struct devlink *devlink) WARN_ON(!list_empty(&devlink->resource_list)); WARN_ON(!list_empty(&devlink->dpipe_table_list)); WARN_ON(!list_empty(&devlink->sb_list)); - WARN_ON(!list_empty(&devlink->rate_domain->rate_list)); + WARN_ON(devlink_rates_check(devlink)); WARN_ON(!list_empty(&devlink->linecard_list)); WARN_ON(!xa_empty(&devlink->ports)); diff --git a/net/devlink/dev.c b/net/devlink/dev.c index c926c75cc10d..84353a85e8fe 100644 --- a/net/devlink/dev.c +++ b/net/devlink/dev.c @@ -434,7 +434,7 @@ static void devlink_reload_reinit_sanity_check(struct devlink *devlink) WARN_ON(!list_empty(&devlink->trap_list)); WARN_ON(!list_empty(&devlink->dpipe_table_list)); WARN_ON(!list_empty(&devlink->sb_list)); - WARN_ON(!list_empty(&devlink->rate_domain->rate_list)); + WARN_ON(devlink_rates_check(devlink)); WARN_ON(!list_empty(&devlink->linecard_list)); WARN_ON(!xa_empty(&devlink->ports)); } diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h index fae81dd6953f..7401aab274e5 100644 --- a/net/devlink/devl_internal.h +++ b/net/devlink/devl_internal.h @@ -30,9 +30,20 @@ struct devlink_dev_stats { u32 remote_reload_stats[DEVLINK_RELOAD_STATS_ARRAY_SIZE]; }; -/* Stores devlink rates associated with a rate domain. */ +/* Stores devlink rates associated with a rate domain. + * Multiple devlink objects may share the same domain (when 'shared' is true) + * and rate nodes can have members from multiple devices. + */ struct devlink_rate_domain { + bool shared; + struct list_head list; struct list_head rate_list; + /* Fields below are only used for shared rate domains. */ + const struct devlink_ops *ops; + u64 id; + refcount_t refcount; + /* Serializes access to rates. */ + struct mutex lock; }; struct devlink { @@ -121,9 +132,17 @@ static inline void devl_dev_unlock(struct devlink *devlink, bool dev_lock) device_unlock(devlink->dev); } -static inline void devl_rate_domain_lock(struct devlink *devlink) { } +static inline void devl_rate_domain_lock(struct devlink *devlink) +{ + if (devlink->rate_domain->shared) + mutex_lock(&devlink->rate_domain->lock); +} -static inline void devl_rate_domain_unlock(struct devlink *devlink) { } +static inline void devl_rate_domain_unlock(struct devlink *devlink) +{ + if (devlink->rate_domain->shared) + mutex_unlock(&devlink->rate_domain->lock); +} typedef void devlink_rel_notify_cb_t(struct devlink *devlink, u32 obj_index); typedef void devlink_rel_cleanup_cb_t(struct devlink *devlink, u32 obj_index, @@ -307,6 +326,7 @@ int devlink_resources_validate(struct devlink *devlink, /* Rates */ int devlink_rate_nodes_check(struct devlink *devlink, struct netlink_ext_ack *extack); +int devlink_rates_check(struct devlink *devlink); /* Linecards */ unsigned int devlink_linecard_index(struct devlink_linecard *linecard); diff --git a/net/devlink/rate.c b/net/devlink/rate.c index b888a6ecdf96..daf366ca0575 100644 --- a/net/devlink/rate.c +++ b/net/devlink/rate.c @@ -675,6 +675,21 @@ int devlink_rate_nodes_check(struct devlink *devlink, struct netlink_ext_ack *ex return err; } +int devlink_rates_check(struct devlink *devlink) +{ + struct devlink_rate *devlink_rate; + int err = 0; + + devl_rate_domain_lock(devlink); + list_for_each_entry(devlink_rate, &devlink->rate_domain->rate_list, list) + if (devlink_rate->devlink == devlink) { + err = -EBUSY; + break; + } + devl_rate_domain_unlock(devlink); + return err; +} + /** * devl_rate_node_create - create devlink rate node * @devlink: devlink instance From patchwork Wed Nov 13 20:30:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Ratiu X-Patchwork-Id: 13874273 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2047.outbound.protection.outlook.com [40.107.94.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A8562071F2 for ; Wed, 13 Nov 2024 20:34:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731530053; cv=fail; b=MMnSYW1PiteYoeYuzcStakfKJPFgdbonDZ7GKku7+bjCVqHnV4ARHIFCtEzPsfV+3PzKV5gialj9xynaVLw0P43809+oIdoBvhFOHLCUpkfbdG6eFqlP62pkg6pkOlnZEpCcrqHRB7DT6iBe+i1LTkvjfb9rVyfaNAZVzPNJOmQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731530053; c=relaxed/simple; bh=NMq4drQ4kgUcIPMlIvlgp+3Wz4FXoCM7/pgrfR7FBMw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Gy8HezpatndAzMBKzcMSB4Rkvv61nrLvj4OD1GTimnMY2/8SEJNcGv7+mrwFPC4509Sb5iLTF6dFT+WxnMEelzCASaEoNIytoJ3xFxcO0qrsqebE0vLMNEEuJslFNzn5uNO5bgxPWYijBiJZMHq1TnW0fXpAHWqzFlx7+D1mz7Y= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=sWEJpZBK; arc=fail smtp.client-ip=40.107.94.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="sWEJpZBK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CxLvTopPc9sF/vkiJ8DIlWlwvs59IWWgBu9g3DSDc3iKa6t4aIQN34k1OQ5StSeqnaEH/qN+L25VMqrySTTo75TzFCc0Dsd2KoEzSeMdV+cz2riSW1weVeBV9Y2IK93C3/OgVohK6JaHOLaMsw1v+UpQ18mCx90YTz+Ni0yDNEkFx+8VF6nZAssWumYIzMq8amEnTP6J9pg7VMC08371aYB282o7SJsuJ2W+pNna5dF1uwmbI6g/N3OH8Ot6kK82NgumXZI4JDP9oUDoNHgm6BGSULEp1D5JFJV/JikzVqcFG92aJmmjpj3UQOXz2WKvbznTjxfwFd8did7HzC9Qxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=wbDWxGxLHF44rMtHEgBJ756Vs9Sk0g+dgIEzV4ObtEc=; b=kLknJaC7zCcb5a19qbOFRtceasARSmwPEp6bNOfbpLQZjVjq9R62Zu6wfsC1dG1LBSKx8Hv8bh9qh2BBmC//TX49jnprR9/9KAx4nufNPNxPYKsaI4EE0IuHo15EK9Hg/UJSDVvZ4m+NDgNDMoFJC5Fopnb+u2XFbPBa4TKfWiDnijqZzGLj6+NmBoCP0l7TbZ/EbYfdDrGp0po5FiOfttXYBN2NgcFMKtfDmcBuVIbAZiYtOQ8Tj8fa/XWD9HAym5N/OAYtaLkeVZdignXXlJ6gZEV6eJgKEJ2Vw4rsyiZn4OCcc7m37qxsHZJN7B1cqfkXQbhZrZgSpgu0UJAq7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.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=wbDWxGxLHF44rMtHEgBJ756Vs9Sk0g+dgIEzV4ObtEc=; b=sWEJpZBK/GW3Unwdqh7vMmIcHTFvLFCPVxE/FNfiiX1O7mBkwkw7ZA0E7Q+XhNf7nEbJQJ4TSnYDH32F8H4p1XGi7ajcZ5OuOa8zlHzS9/7iw4fFLudIglD+vY7yZROYNHD/lw3j98cwmoBGSXqa6DibPOfS7LfbCIvOaCi1Ol5XhvuUSPMowXn/PVR4z168y/WbdUlXIBazOwN+YkbGiQ/m6lYCP0xYYaoMqWHgnbMsIU1LzPWC7L125mgx2CRRK08Knx1qjTAZ00UAFF3D/DxrQJMBwItRqcuYN/d7LhjGBvve960dpS6CzosB/vaq7ntjLZ3CNDiP40zoxF41+w== Received: from DS7PR03CA0279.namprd03.prod.outlook.com (2603:10b6:5:3ad::14) by MN2PR12MB4336.namprd12.prod.outlook.com (2603:10b6:208:1df::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.18; Wed, 13 Nov 2024 20:34:09 +0000 Received: from DS1PEPF00017093.namprd03.prod.outlook.com (2603:10b6:5:3ad:cafe::6a) by DS7PR03CA0279.outlook.office365.com (2603:10b6:5:3ad::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.17 via Frontend Transport; Wed, 13 Nov 2024 20:34:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS1PEPF00017093.mail.protection.outlook.com (10.167.17.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Wed, 13 Nov 2024 20:34:09 +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.1544.4; Wed, 13 Nov 2024 12:33:53 -0800 Received: from nexus.mtl.labs.mlnx (10.126.231.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.1544.4; Wed, 13 Nov 2024 12:33:51 -0800 From: Cosmin Ratiu To: CC: , , , , Subject: [PATCH 06/10] devlink: Allow specifying parent device for rate commands Date: Wed, 13 Nov 2024 22:30:43 +0200 Message-ID: <20241113203317.2507537-7-cratiu@nvidia.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20241113203317.2507537-1-cratiu@nvidia.com> References: <20241113203317.2507537-1-cratiu@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017093:EE_|MN2PR12MB4336:EE_ X-MS-Office365-Filtering-Correlation-Id: 128b43fe-121b-4269-cfb4-08dd042286b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: ix7Y6lo85SP6o8XpT66ILQSVKbBVlug1QCoaZVeNgMJwREWY/yt7NSWyKcyAMYc9FSo36FD1H94xqeohNaUYePEv3q60/C67qbvYUiMYxPjZkTZsZGT/7WN+PpeUMAt69bxMgKlvWxTjpEAfvlmRFtz5e+dZ1XLQvcyeX3CG92gAMzUZobroDT38N83FQn8waBA8hMJCi5z2j+xehzOo47PgiSoq8XHz0chwlyYc2AsWRQYQ2eGdCvyOxCFOo5h5kfScIErEpeKx1Rf67KWbTmWNlct6nn6cbPdHLJ+vHN266sc66jNucSph9MW81Kbl3Om6pr1NpwN9Zb1DZ8kAVaiCbb9DAUR7HcXDBo8Ds/LhiMckFxMmmhxZr4iR0d9HUH9HxIif5BLcihVc1X0z5YGpuNKO9AX5PkqLcXt2yDSqNF/yuOmaHXaCN2/Rscqagv79x4oi3nmoPyGgYlb52m9jRz4kng+ZHZ/ulrzpOi8IqhEmWhsEgd7XC17LaUmH+JSza2BKf3VrhfxFvPDB72AjCsJQWWfMPs5ufcR/Swqxq28vDEwQ1DtLzxJ+EBqtrSpWQAp/R9ZIrDyT1mND2VoMF2TvDMA5EJBpExswF80YK47Qjp2jW43QzaGvrdCC/wEfT9H7OogTZtR5+IR527QcE+DuJbrGtspz6IcjUrZkqZ+eaCqYUBy9NqYkPuzu7BHEUmT9R6t+QfhnspMcY1Iqckm460caG4hF5W7/kOsfhJmeRyqn+vYSwj5nkPOInUINjzcQ0k/kqZ1sTkurMAdIkqQdX94vfU76GKfjVaBpT9w77WfXTe92ru5D97+r2OwolN5B9ASr7vzOrxIUB9sT/GWWiWLXR/uV9K4yZxxOet/zU6OBDOnGZlViMuj54ecGDwgZmiwXbwkwNapGodbvKQylS2iAR3V1bn3GQmsX6PD3bdXJTqBXi+6q8vpH10elyvN/NSP2ZBgFVzmhJsV0DMA48xKBzqe5YyUcm2rKfiLgi2z8/oTeGHA5yyBioiy00x21YboLTVSgUZEsgqwieZmJg3Pr+fSRltKgHaSUFcOc8jXnSlL8JgR0CJvwDRFFZ9hAsryYKkqf3YDEFENm1EaWhWWXzPWimLIogVJaEdI/fX/B59jenzjFsuhBzVkCUfUZ5Q4H2dje6hZw0wN+sKBSfRI3tW4IwJ2QQWfpDlRsU5kQ6/1Zu5O6YxHg4wUUoy3HLCX5XAJdic/JB1cMHj8cif4KmSXPrGpZRveGSHbMePH6p888S9+dZupbA/usfOby9Mtts4UKClO02icn1d4KWr7hNr+HbJjp/TK1n63cQUzICjEWYK17QaDJzw/GcLPbkkFF/QKWVuACaT45/rpbyac8zJ99EQBe5KKdGGtmZGJqBX52wdf3OCsNxV0hXkfvSXiDpu2lkst5/A== 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:(13230040)(36860700013)(82310400026)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2024 20:34:09.0336 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 128b43fe-121b-4269-cfb4-08dd042286b2 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: DS1PEPF00017093.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4336 X-Patchwork-Delegate: kuba@kernel.org Previously, the parent device was assumed to be the same one as one owning the rate node being manipulated. This patch expands that by allowing rate commands to accept two additional arguments, the parent bus name and the parent dev name. Besides introducing these two attributes in the uapi, this patch: - adds plumbing in the 'rate-new' and 'rate-set' commands to access these attributes. - extends devlink-nl-pre-doit with getting and saving a reference to the parent dev in info->user_ptr[1]. The parent dev needs to exist and be registered and is then unlocked but not put. This ensures that it will stay alive until the end of the request. - changes devlink-nl-post-doit with putting the parent reference, if obtained. Issue: 3645895 Change-Id: Ibbb7b632be2b2779d36f7de8320aeb58fcc20748 Signed-off-by: Cosmin Ratiu --- Documentation/netlink/specs/devlink.yaml | 18 ++++-- include/uapi/linux/devlink.h | 3 + net/devlink/netlink.c | 73 +++++++++++++++++++----- net/devlink/netlink_gen.c | 20 ++++--- net/devlink/netlink_gen.h | 6 ++ 5 files changed, 93 insertions(+), 27 deletions(-) diff --git a/Documentation/netlink/specs/devlink.yaml b/Documentation/netlink/specs/devlink.yaml index 41fdc2514f69..033c17da4fc0 100644 --- a/Documentation/netlink/specs/devlink.yaml +++ b/Documentation/netlink/specs/devlink.yaml @@ -849,6 +849,12 @@ attribute-sets: name: region-direct type: flag + - name: parent-dev-bus-name + type: string + + - name: parent-dev-name + type: string + - name: dl-dev-stats subset-of: devlink @@ -2185,8 +2191,8 @@ operations: dont-validate: [ strict ] flags: [ admin-perm ] do: - pre: devlink-nl-pre-doit - post: devlink-nl-post-doit + pre: devlink-nl-pre-doit-parent-dev-optional + post: devlink-nl-post-doit-parent-dev-optional request: attributes: - bus-name @@ -2198,6 +2204,8 @@ operations: - rate-tx-weight - rate-tc-bw - rate-parent-node-name + - parent-dev-bus-name + - parent-dev-name - name: rate-new @@ -2206,8 +2214,8 @@ operations: dont-validate: [ strict ] flags: [ admin-perm ] do: - pre: devlink-nl-pre-doit - post: devlink-nl-post-doit + pre: devlink-nl-pre-doit-parent-dev-optional + post: devlink-nl-post-doit-parent-dev-optional request: attributes: - bus-name @@ -2219,6 +2227,8 @@ operations: - rate-tx-weight - rate-tc-bw - rate-parent-node-name + - parent-dev-bus-name + - parent-dev-name - name: rate-del diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h index c369726a262a..8dc710b9ab8e 100644 --- a/include/uapi/linux/devlink.h +++ b/include/uapi/linux/devlink.h @@ -624,6 +624,9 @@ enum devlink_attr { DEVLINK_ATTR_RATE_TC_7_BW, /* u32 */ DEVLINK_ATTR_RATE_TC_BW, /* nested */ + DEVLINK_ATTR_PARENT_DEV_BUS_NAME, /* string */ + DEVLINK_ATTR_PARENT_DEV_NAME, /* string */ + /* Add new attributes above here, update the spec in * Documentation/netlink/specs/devlink.yaml and re-generate * net/devlink/netlink_gen.c. diff --git a/net/devlink/netlink.c b/net/devlink/netlink.c index 593605c1b1ef..1d31d8a76465 100644 --- a/net/devlink/netlink.c +++ b/net/devlink/netlink.c @@ -12,6 +12,7 @@ #define DEVLINK_NL_FLAG_NEED_PORT BIT(0) #define DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT BIT(1) #define DEVLINK_NL_FLAG_NEED_DEV_LOCK BIT(2) +#define DEVLINK_NL_FLAG_NEED_PARENT_DEV BIT(3) static const struct genl_multicast_group devlink_nl_mcgrps[] = { [DEVLINK_MCGRP_CONFIG] = { .name = DEVLINK_GENL_MCGRP_CONFIG_NAME }, @@ -177,20 +178,15 @@ int devlink_nl_msg_reply_and_new(struct sk_buff **msg, struct genl_info *info) return 0; } -struct devlink * -devlink_get_from_attrs_lock(struct net *net, struct nlattr **attrs, - bool dev_lock) +static struct devlink * +devlink_get_lock(struct net *net, struct nlattr *bus_attr, struct nlattr *dev_attr, bool dev_lock) { + char *busname, *devname; struct devlink *devlink; unsigned long index; - char *busname; - char *devname; - - if (!attrs[DEVLINK_ATTR_BUS_NAME] || !attrs[DEVLINK_ATTR_DEV_NAME]) - return ERR_PTR(-EINVAL); - busname = nla_data(attrs[DEVLINK_ATTR_BUS_NAME]); - devname = nla_data(attrs[DEVLINK_ATTR_DEV_NAME]); + busname = nla_data(bus_attr); + devname = nla_data(dev_attr); devlinks_xa_for_each_registered_get(net, index, devlink) { if (strcmp(devlink->dev->bus->name, busname) == 0 && @@ -206,19 +202,45 @@ devlink_get_from_attrs_lock(struct net *net, struct nlattr **attrs, return ERR_PTR(-ENODEV); } +struct devlink * +devlink_get_from_attrs_lock(struct net *net, struct nlattr **attrs, bool dev_lock) +{ + if (!attrs[DEVLINK_ATTR_BUS_NAME] || !attrs[DEVLINK_ATTR_DEV_NAME]) + return ERR_PTR(-EINVAL); + + return devlink_get_lock(net, attrs[DEVLINK_ATTR_BUS_NAME], + attrs[DEVLINK_ATTR_DEV_NAME], dev_lock); +} + static int __devlink_nl_pre_doit(struct sk_buff *skb, struct genl_info *info, u8 flags) { + bool parent_dev = flags & DEVLINK_NL_FLAG_NEED_PARENT_DEV; bool dev_lock = flags & DEVLINK_NL_FLAG_NEED_DEV_LOCK; + struct devlink *devlink, *parent_devlink = NULL; + struct nlattr **attrs = info->attrs; struct devlink_port *devlink_port; - struct devlink *devlink; int err; - devlink = devlink_get_from_attrs_lock(genl_info_net(info), info->attrs, - dev_lock); - if (IS_ERR(devlink)) - return PTR_ERR(devlink); + if (parent_dev && attrs[DEVLINK_ATTR_PARENT_DEV_BUS_NAME] && + attrs[DEVLINK_ATTR_PARENT_DEV_NAME]) { + parent_devlink = devlink_get_lock(genl_info_net(info), + attrs[DEVLINK_ATTR_PARENT_DEV_BUS_NAME], + attrs[DEVLINK_ATTR_PARENT_DEV_NAME], dev_lock); + if (IS_ERR(parent_devlink)) + return PTR_ERR(parent_devlink); + info->user_ptr[1] = parent_devlink; + /* Drop the parent devlink lock, but don't put it just yet. + * This will keep it alive until the end of the request. + */ + devl_dev_unlock(parent_devlink, dev_lock); + } + devlink = devlink_get_from_attrs_lock(genl_info_net(info), attrs, dev_lock); + if (IS_ERR(devlink)) { + err = PTR_ERR(devlink); + goto parent_put; + } info->user_ptr[0] = devlink; if (flags & DEVLINK_NL_FLAG_NEED_PORT) { devlink_port = devlink_port_get_from_info(devlink, info); @@ -237,6 +259,9 @@ static int __devlink_nl_pre_doit(struct sk_buff *skb, struct genl_info *info, unlock: devl_dev_unlock(devlink, dev_lock); devlink_put(devlink); +parent_put: + if (parent_dev && parent_devlink) + devlink_put(parent_devlink); return err; } @@ -265,6 +290,13 @@ int devlink_nl_pre_doit_port_optional(const struct genl_split_ops *ops, return __devlink_nl_pre_doit(skb, info, DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT); } +int devlink_nl_pre_doit_parent_dev_optional(const struct genl_split_ops *ops, + struct sk_buff *skb, + struct genl_info *info) +{ + return __devlink_nl_pre_doit(skb, info, DEVLINK_NL_FLAG_NEED_PARENT_DEV); +} + static void __devlink_nl_post_doit(struct sk_buff *skb, struct genl_info *info, u8 flags) { @@ -274,6 +306,10 @@ static void __devlink_nl_post_doit(struct sk_buff *skb, struct genl_info *info, devlink = info->user_ptr[0]; devl_dev_unlock(devlink, dev_lock); devlink_put(devlink); + if ((flags & DEVLINK_NL_FLAG_NEED_PARENT_DEV) && info->user_ptr[1]) { + devlink = info->user_ptr[1]; + devlink_put(devlink); + } } void devlink_nl_post_doit(const struct genl_split_ops *ops, @@ -289,6 +325,13 @@ devlink_nl_post_doit_dev_lock(const struct genl_split_ops *ops, __devlink_nl_post_doit(skb, info, DEVLINK_NL_FLAG_NEED_DEV_LOCK); } +void +devlink_nl_post_doit_parent_dev_optional(const struct genl_split_ops *ops, + struct sk_buff *skb, struct genl_info *info) +{ + __devlink_nl_post_doit(skb, info, DEVLINK_NL_FLAG_NEED_PARENT_DEV); +} + static int devlink_nl_inst_single_dumpit(struct sk_buff *msg, struct netlink_callback *cb, int flags, devlink_nl_dump_one_func_t *dump_one, diff --git a/net/devlink/netlink_gen.c b/net/devlink/netlink_gen.c index 546766bdd836..6e669e57d44d 100644 --- a/net/devlink/netlink_gen.c +++ b/net/devlink/netlink_gen.c @@ -507,7 +507,7 @@ static const struct nla_policy devlink_rate_get_dump_nl_policy[DEVLINK_ATTR_DEV_ }; /* DEVLINK_CMD_RATE_SET - do */ -static const struct nla_policy devlink_rate_set_nl_policy[DEVLINK_ATTR_RATE_TC_BW + 1] = { +static const struct nla_policy devlink_rate_set_nl_policy[DEVLINK_ATTR_PARENT_DEV_NAME + 1] = { [DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, }, [DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, }, [DEVLINK_ATTR_RATE_NODE_NAME] = { .type = NLA_NUL_STRING, }, @@ -517,10 +517,12 @@ static const struct nla_policy devlink_rate_set_nl_policy[DEVLINK_ATTR_RATE_TC_B [DEVLINK_ATTR_RATE_TX_WEIGHT] = { .type = NLA_U32, }, [DEVLINK_ATTR_RATE_PARENT_NODE_NAME] = { .type = NLA_NUL_STRING, }, [DEVLINK_ATTR_RATE_TC_BW] = NLA_POLICY_NESTED(devlink_dl_rate_tc_bw_nl_policy), + [DEVLINK_ATTR_PARENT_DEV_BUS_NAME] = { .type = NLA_NUL_STRING, }, + [DEVLINK_ATTR_PARENT_DEV_NAME] = { .type = NLA_NUL_STRING, }, }; /* DEVLINK_CMD_RATE_NEW - do */ -static const struct nla_policy devlink_rate_new_nl_policy[DEVLINK_ATTR_RATE_TC_BW + 1] = { +static const struct nla_policy devlink_rate_new_nl_policy[DEVLINK_ATTR_PARENT_DEV_NAME + 1] = { [DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, }, [DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, }, [DEVLINK_ATTR_RATE_NODE_NAME] = { .type = NLA_NUL_STRING, }, @@ -530,6 +532,8 @@ static const struct nla_policy devlink_rate_new_nl_policy[DEVLINK_ATTR_RATE_TC_B [DEVLINK_ATTR_RATE_TX_WEIGHT] = { .type = NLA_U32, }, [DEVLINK_ATTR_RATE_PARENT_NODE_NAME] = { .type = NLA_NUL_STRING, }, [DEVLINK_ATTR_RATE_TC_BW] = NLA_POLICY_NESTED(devlink_dl_rate_tc_bw_nl_policy), + [DEVLINK_ATTR_PARENT_DEV_BUS_NAME] = { .type = NLA_NUL_STRING, }, + [DEVLINK_ATTR_PARENT_DEV_NAME] = { .type = NLA_NUL_STRING, }, }; /* DEVLINK_CMD_RATE_DEL - do */ @@ -1173,21 +1177,21 @@ const struct genl_split_ops devlink_nl_ops[74] = { { .cmd = DEVLINK_CMD_RATE_SET, .validate = GENL_DONT_VALIDATE_STRICT, - .pre_doit = devlink_nl_pre_doit, + .pre_doit = devlink_nl_pre_doit_parent_dev_optional, .doit = devlink_nl_rate_set_doit, - .post_doit = devlink_nl_post_doit, + .post_doit = devlink_nl_post_doit_parent_dev_optional, .policy = devlink_rate_set_nl_policy, - .maxattr = DEVLINK_ATTR_RATE_TC_BW, + .maxattr = DEVLINK_ATTR_PARENT_DEV_NAME, .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, }, { .cmd = DEVLINK_CMD_RATE_NEW, .validate = GENL_DONT_VALIDATE_STRICT, - .pre_doit = devlink_nl_pre_doit, + .pre_doit = devlink_nl_pre_doit_parent_dev_optional, .doit = devlink_nl_rate_new_doit, - .post_doit = devlink_nl_post_doit, + .post_doit = devlink_nl_post_doit_parent_dev_optional, .policy = devlink_rate_new_nl_policy, - .maxattr = DEVLINK_ATTR_RATE_TC_BW, + .maxattr = DEVLINK_ATTR_PARENT_DEV_NAME, .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, }, { diff --git a/net/devlink/netlink_gen.h b/net/devlink/netlink_gen.h index 084ad5026d4f..9d41bbaed05b 100644 --- a/net/devlink/netlink_gen.h +++ b/net/devlink/netlink_gen.h @@ -28,10 +28,16 @@ int devlink_nl_pre_doit_dev_lock(const struct genl_split_ops *ops, int devlink_nl_pre_doit_port_optional(const struct genl_split_ops *ops, struct sk_buff *skb, struct genl_info *info); +int devlink_nl_pre_doit_parent_dev_optional(const struct genl_split_ops *ops, + struct sk_buff *skb, + struct genl_info *info); void devlink_nl_post_doit(const struct genl_split_ops *ops, struct sk_buff *skb, struct genl_info *info); void +devlink_nl_post_doit_parent_dev_optional(const struct genl_split_ops *ops, struct sk_buff *skb, + struct genl_info *info); +void devlink_nl_post_doit_dev_lock(const struct genl_split_ops *ops, struct sk_buff *skb, struct genl_info *info); From patchwork Wed Nov 13 20:30:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Ratiu X-Patchwork-Id: 13874274 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2047.outbound.protection.outlook.com [40.107.92.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66FA62071F2 for ; Wed, 13 Nov 2024 20:34:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731530058; cv=fail; b=NO5WNXKIFMF07e+tksm6iB6PhcfxK09YZVgR+CeR5qCPqmbnXcePOtSRRmbjvaw0NW/re+9nnZdBEVasNUr/JhuvrPDitBO8/fJsywgoRZ5lCiiYw7swH0VpzM3owJsLfmfPOs7KL/H/eyHnILH3JUzrOx10lkS02Ajg8LWQW0Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731530058; c=relaxed/simple; bh=4TrUrb7H+gY2Z71y/PA6ORO8l2uT8S5KbtPDLHsrYHU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GaUZ6Bcgczi2DbiZlONRsFRHvE6V3GI8XiGO0eWN22IqsJpJDJkP/trXB+FrGaGtcR67RNZJzeafQllWdpZKr44YpPuyhcthcPC1Ji90ojSzS8u5ymq5XmSn33la65nupkfaZrHahW1MUy8vdzrgTXnArISHffkmL6eaOb7fIZw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=d9JOiwBM; arc=fail smtp.client-ip=40.107.92.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="d9JOiwBM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WhqSJpCh1JrF5yjQSo0vwhZCQqrkcuG/zPBa71mRlszbKY7zEFgkD5IAsNCUajNEuEAbiengiPmrWcJFNkW6lSKGBa67rYuwmeVtYCxuSp/2QJlZRj1cVkGxovhAH5wXz4WIavsgCR+53le80Sm6CJXhOQ1QfLrx3dawkj4YHYEJ1/d+ABBCbZpi4cShDLF+Ni1LoTDOXGlb7XoGox6hANein4Yr54VsZ+tLnQ8ngFAWd5/b/KlNqau3NtrAmv2VUObIzjn7FxIb/nskUv8MSx7/gzNG90XWZAq3zKfyFKrkHn10DhgHq3qlGTLemxK5KMqzNoDsXFvUep+Hh3sS9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=NoS0u0cALuxQswpijIQS8x3wtkg/CkxxUTBHANtONp8=; b=UuidCIbdxblDzQ3IcmS4SKOrFMCDNWASCr9EHZAaPU7jZi3D+7xNkSpnZho7dMRjDFAM3RPlc7JoUoPaGUX84uErQrUIuM4I6aX6ZrpZA9xUplvW549jffHws/v2wMWsHERSuC0Yh21yXGjbheLWUEM3ng4KDLJq5tzboom+g3m2Zab7Qg9ypU606EjM6swK6sRK1LyoMBuTivfttzCB77/LxZ3HWv8dDheB0RICSKihojdACFZF3u78slzaAG83H2s9Ac9OX47H0ZuM9Z4fwJwFGb92z4PVQbYvrkT/j/Ajx3oYZ3/QcNH6BCRanroGZ6Vx1FHhTg9X6Pa6/m11IQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.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=NoS0u0cALuxQswpijIQS8x3wtkg/CkxxUTBHANtONp8=; b=d9JOiwBMS3apyVNd82Rw/TeTGqlBH6L3euuQ9gfZjX4duUnpXRV5j2n+YJaeshdBv1jNRZjPMbmBrOvDKK/VccpCC9Ki2QCd1Qj/uEhtlEgEYfY5B4utkIDDZ6GokOJq9D5kG7eCW04en/Z32VtudFf3xQY4P/jggNmdSqDLkZjr3BAJs1SEkj2cVjd7WLa5TdSHUq8Pj0bWux8Ge236N0UIpMpDl8KJVfFXys4K+MtXgn+zOVId1Zm4KjR6pPmExQ4hCQKRuA8yyvCGp/ZDtn9k+ENxNdSRT7Hkrxjy9PyxnuQDtIk3wic6ZG9W5dJ3NXSASGxc4YwP6pcPyoyS/w== Received: from DS7PR03CA0285.namprd03.prod.outlook.com (2603:10b6:5:3ad::20) by DS0PR12MB6606.namprd12.prod.outlook.com (2603:10b6:8:d2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.17; Wed, 13 Nov 2024 20:34:10 +0000 Received: from DS1PEPF00017093.namprd03.prod.outlook.com (2603:10b6:5:3ad:cafe::80) by DS7PR03CA0285.outlook.office365.com (2603:10b6:5:3ad::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28 via Frontend Transport; Wed, 13 Nov 2024 20:34:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS1PEPF00017093.mail.protection.outlook.com (10.167.17.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Wed, 13 Nov 2024 20:34:10 +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.1544.4; Wed, 13 Nov 2024 12:33:55 -0800 Received: from nexus.mtl.labs.mlnx (10.126.231.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.1544.4; Wed, 13 Nov 2024 12:33:53 -0800 From: Cosmin Ratiu To: CC: , , , , Subject: [PATCH 07/10] devlink: Allow rate node parents from other devlinks Date: Wed, 13 Nov 2024 22:30:44 +0200 Message-ID: <20241113203317.2507537-8-cratiu@nvidia.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20241113203317.2507537-1-cratiu@nvidia.com> References: <20241113203317.2507537-1-cratiu@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017093:EE_|DS0PR12MB6606:EE_ X-MS-Office365-Filtering-Correlation-Id: 1b6cb3f5-9205-44de-ffad-08dd042287a5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: QcMknFRUMxPss0rNAxTqBzA3Su6NkSfNgF9Acwke4UrKpK5Jhv/Ge+PZvjHbu61Qw2N8U+aGLpEqMzcmkUwr1scLZKWXWjQ6Wald71Bn/SJplyHGhkb1OpM3WkaVeuLxj/DkXtu6JQsAqKtfPNuGRT8Z8HkWBTHyD4tJRYBbojnm2drFEouLcqDt2Bq9SaC8l1IADTLZesv5UIbtFwfGNDppymlG6Pau3BdRZOkpzfnMHRA27sq0/3VTyxWpJLCYG8VRt+xcqOyJMM5osmoAVmG85Ndua2c3h9CVEiaZ54Uybz2tDKsO5B/XIZSPAwgt5YE+Hfd+3mypD2g55IvubzR2ieeyd6PRjqQYEIStlt0VCzk5sbjpzk0ZuOnLFQsyeZo77sgUE7+30UYBGrgEDWP3cS2dlkkISc++3rFH/xpN/BhZjqWLguHwcwKQ5Pr9FrOqGyN7Obv+Aa7Bmxk55goahJnFLMgxib2fd9Xo8ymZ1SuK+u40VZX5VCgzlQuk6GUVxzn81dWMZdCTWIuY8frUQvgv82LnF4NGRZp0HQWhoxlZp5oulkCvsM/kRGTdgF16HeU5fT4uYgPe8e4E+D5Q5YGgglY2XyTvZaQnyQnRZSSOlfzIGH3ivp8971iNzLRLs19FJHdxfObx3xg1VuYy1RJdHD5xWwR5m51sIIWqkKVJnbZEzWV/DZ8Lu5E90JltS7QO2cztjPhX0wZFw9qa7910q0VmUPQHi+0xveLq0i8snNFxkT/jYm/YGVKGTWeollc0joTjTMBWjQxevfTovmRrVbUeshJc6k0jzTMGKCb64S1A6WTALG525S4uINvVIOt3dekW1oa4OFiXLnslu/LkJZqQJEDpaB09WI1gRFX6SiKvi6JkkM7se6TIgQffA3QQSXwBwHRVPjD8hrLWsNJmblAz5HgidCJcS2vN/DVmC5nQlLWv2VKkbQSVGvo5QffrJ4RSV0zcULsm/gK6hTT8JtjUYpvzh6dJ+bNYg8mm8V+3afYxeuPtJBbbN5p2C2xb/NUQaphzAI2nR5OCZw7gnq19IsOnaiV4VN6THAUrD3UhW/X8Vpme1aUAJU4M+gOhRL+M+QzKdclXs7ZWZQhd8ZbCwsZ3Qq48wYgrLsCUC/KvN0sx/5MsMq0HsRTYo0Z2fg3RAOb0vbrkAvDylKDb9Aa8/XpeBBFW5c2id+vZf4SwZFnAe5pRjixGXJgtdnoiCTmTn5O0N5GJOeOx3hsD+41kXLQKO1mSxgBHiVt9ohrBLtjp1/UCmUdSTEGZ++JCR2xovon9Kzyq3iHVFehDhp9gJWN3bgataZU3XIk24HZLtfFMu3M9oWtZh30AZdwUIgb85ErtADO5ncLZD1BtYALqmrbDxtRw2A36o2XGjRZ8EkWv0RobEyTj2gV8Uv8I627VySMvmcE/aA== 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:(13230040)(376014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2024 20:34:10.6118 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1b6cb3f5-9205-44de-ffad-08dd042287a5 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: DS1PEPF00017093.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6606 X-Patchwork-Delegate: kuba@kernel.org This commit make use of the unlocked parent devlink from info->user_ptr[1] to assign a devlink rate node to the requested parent node. Because it is not locked, none of its mutable fields can be used. But parent setting only requires: 1. Verifying that the same rate domain is used. The rate domain is immutable once set, so this is safe. 2. Comparing devlink_rate->devlink with the requested parent devlink. As the shared devlink rate domain is locked, other entities cannot concurrently make changes to any of its rates. Issue: 3645895 Change-Id: Iffd9ccb012c3bd2dec97648161b182679eb5ca78 Signed-off-by: Cosmin Ratiu --- net/devlink/rate.c | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/net/devlink/rate.c b/net/devlink/rate.c index daf366ca0575..2f12d65b6709 100644 --- a/net/devlink/rate.c +++ b/net/devlink/rate.c @@ -141,6 +141,27 @@ static int devlink_nl_rate_fill(struct sk_buff *msg, nla_nest_end(msg, nla_tc_bw); + if (devlink_rate->parent) { + struct devlink_rate *parent = devlink_rate->parent; + + if (nla_put_string(msg, DEVLINK_ATTR_RATE_PARENT_NODE_NAME, parent->name)) + goto nla_put_failure; + if (parent->devlink != devlink) { + /* The parent devlink isn't locked, but a reference to + * it is held so it cannot suddenly disappear. + * And since there are rate nodes pointing to it, + * the parent devlink is fully initialized and + * the fields accessed here are valid and immutable. + */ + if (nla_put_string(msg, DEVLINK_ATTR_PARENT_DEV_BUS_NAME, + parent->devlink->dev->bus->name)) + goto nla_put_failure; + if (nla_put_string(msg, DEVLINK_ATTR_PARENT_DEV_NAME, + dev_name(parent->devlink->dev))) + goto nla_put_failure; + } + } + genlmsg_end(msg, hdr); return 0; @@ -292,9 +313,17 @@ devlink_nl_rate_parent_node_set(struct devlink_rate *devlink_rate, const char *parent_name = nla_data(nla_parent); const struct devlink_ops *ops = devlink->ops; size_t len = strlen(parent_name); + struct devlink *parent_devlink; struct devlink_rate *parent; int err = -EOPNOTSUPP; + parent_devlink = info->user_ptr[1] ? : devlink; + if (parent_devlink != devlink) { + if (parent_devlink->rate_domain != devlink->rate_domain) { + NL_SET_ERR_MSG(info->extack, "Cross rate-domain parent is not allowed"); + return -EINVAL; + } + } parent = devlink_rate->parent; if (parent && !len) { @@ -312,7 +341,11 @@ devlink_nl_rate_parent_node_set(struct devlink_rate *devlink_rate, refcount_dec(&parent->refcnt); devlink_rate->parent = NULL; } else if (len) { - parent = devlink_rate_node_get_by_name(devlink, parent_name); + /* parent_devlink (if != devlink) isn't locked, but the rate + * domain, immutable once set, is already locked and the parent + * is only used to determine node owner via pointer comparison. + */ + parent = devlink_rate_node_get_by_name(parent_devlink, parent_name); if (IS_ERR(parent)) return -ENODEV; @@ -816,8 +849,8 @@ EXPORT_SYMBOL_GPL(devl_rate_leaf_destroy); * devl_rate_nodes_destroy - destroy all devlink rate nodes on device * @devlink: devlink instance * - * Unset parent for all rate objects and destroy all rate nodes - * on specified device. + * Unset parent for all rate objects that involve this device and destroy all + * rate nodes on it. */ void devl_rate_nodes_destroy(struct devlink *devlink) { @@ -828,7 +861,9 @@ void devl_rate_nodes_destroy(struct devlink *devlink) devl_rate_domain_lock(devlink); list_for_each_entry(devlink_rate, &devlink->rate_domain->rate_list, list) { - if (!devlink_rate->parent || devlink_rate->devlink != devlink) + if (!devlink_rate->parent || + (devlink_rate->devlink != devlink && + devlink_rate->parent->devlink != devlink)) continue; refcount_dec(&devlink_rate->parent->refcnt); @@ -838,6 +873,7 @@ void devl_rate_nodes_destroy(struct devlink *devlink) else if (devlink_rate_is_node(devlink_rate)) ops->rate_node_parent_set(devlink_rate, NULL, devlink_rate->priv, NULL, NULL); + devlink_rate->parent = NULL; } list_for_each_entry_safe(devlink_rate, tmp, &devlink->rate_domain->rate_list, list) { if (devlink_rate->devlink == devlink && devlink_rate_is_node(devlink_rate)) { From patchwork Wed Nov 13 20:30:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Ratiu X-Patchwork-Id: 13874276 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2063.outbound.protection.outlook.com [40.107.223.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8ECB205AB3 for ; Wed, 13 Nov 2024 20:34:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731530062; cv=fail; b=P99jz+kXXM/3XrhPx0GRP60jQyaU271YWnZ9bdVV3fgpo7Mp/2VPm0APb/2HDk5O08Q9lni6CVSC+cjkenXc6jjwsYPK2Otb560u3+5IBXRUdMJ2489k8MIo/Ww+TgPDZQHtz4N57YBtwmMdGd0NcZMNuq601s7fU930vDKKgIE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731530062; c=relaxed/simple; bh=5kU0MsvS0HKgsObW9YwvATntg3QnhQ36R+bTGXnyct8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=llJJiOJZFUetf6nBSemXAuu3vGkMXVpkm4SB9SE20nd7cOJKhwiwoVbR9guEFPTCWyyftDGCo+CpkQ/wlJZ9obg59TzJFLVP5881EtbGIF5qsyMqztuC0TPmPPeRoa0TVSMbKKDH6tyCPJu2JulvtlcOEodQdRQb8hKr7RIF23U= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=cwJPAxLy; arc=fail smtp.client-ip=40.107.223.63 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="cwJPAxLy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BDLCPdbcAP7OqM2MQi8v53RGEjxYLberoi5a1M1DfHNDPfe/UddkEiJRBAaSzSudU4e538PoMQi6xPIDhqj6risa+zEAwD2NqUgq5S43pJ/22iWiIImJPDoL1Y7Rjyp1GtUpB2c4PhrMwx0Nt8oxSjwHsJen3R7VQzqNqAmfdfPcvMtIyxBsbOASP/vopFbeN/fgVSwExQQnhkjqhhzi+L8Q/72KKxt53iSWpLX6GUit6Gwzdh/9iOMQCBFyWUW0XkQjA4MSMd2Uv/OeouRmbXPYkN8Uts71OBqi5QJGxI1GzgBhU5g4W+naTgeWaAYoe9RB3CtRxdoXVZ5V3B3gAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=IE4UkLYPAkUfXQEXzr5TSah8LwK1Tl7/FlLf8E4ekrk=; b=IN1VRv5yzQkEgYaNSSPopLcHs/opTwheoM9nvbLoTsI/Ek+1MUl9v3wAwGvIpaA/Se5Qd2qnxeq2pnuQUs9kkwtZpK/b5qE8OyozNlbV+B619ccfkxqAVMhrXzmhUJmhfBDo/8JJx4F11AJny3Jx12puf0bonVPmdZZT1Vrm/uHX4Bbsp560Ya9umE+oXVRqaeSGNbc1PsEQGIT6Nxmo3Y4lAA67+ogj1j2M3jsEX36yTbvpTaemPIafUT5bD+g/JL18Z+wNNkTy5gAOntCK2OZQMGCPfFVEHhdhpLOQRW28Ur9x527OZLqk+viwxdl9NPGFHJsUAyPcMeoqQaqt4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.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=IE4UkLYPAkUfXQEXzr5TSah8LwK1Tl7/FlLf8E4ekrk=; b=cwJPAxLyMlwQtV3rsIGM5U/ArfNGthCPs6ntBFxh+GDwMPiWO4X2GTbjI6oEOBy/B+YEa/vV+zumSf2e0qZeITVjQ9/k55I8ziQrSoGY5rmpPyMAR+nNpiJ5bFHynctJ4N/VNQkTT3GmdxokBUrU+nW71Bqva80o5GNCKlz+hzVYI4pX3acDpaIxm2Crgyszs7ZO0mgWAGg04+Cn9nx/aYuttLsCbaOy4vJE2BTFFVCV7iRBiB57TgVuhFEE/9ODc/RrtDO8ZQ+zXHwfIXoDiThPphTYLt9myLCoXJ9kH/SodkJnkWsBSAyCup39RkVTscuvQQrRdIU3PObZGeS2fA== Received: from DS7PR03CA0149.namprd03.prod.outlook.com (2603:10b6:5:3b4::34) by BY5PR12MB4068.namprd12.prod.outlook.com (2603:10b6:a03:203::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.17; Wed, 13 Nov 2024 20:34:14 +0000 Received: from DS1PEPF0001708F.namprd03.prod.outlook.com (2603:10b6:5:3b4:cafe::fa) by DS7PR03CA0149.outlook.office365.com (2603:10b6:5:3b4::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28 via Frontend Transport; Wed, 13 Nov 2024 20:34:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS1PEPF0001708F.mail.protection.outlook.com (10.167.17.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Wed, 13 Nov 2024 20:34:13 +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.1544.4; Wed, 13 Nov 2024 12:33:57 -0800 Received: from nexus.mtl.labs.mlnx (10.126.231.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.1544.4; Wed, 13 Nov 2024 12:33:55 -0800 From: Cosmin Ratiu To: CC: , , , , Subject: [PATCH 08/10] net/mlx5: qos: Introduce shared esw qos domains Date: Wed, 13 Nov 2024 22:30:45 +0200 Message-ID: <20241113203317.2507537-9-cratiu@nvidia.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20241113203317.2507537-1-cratiu@nvidia.com> References: <20241113203317.2507537-1-cratiu@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001708F:EE_|BY5PR12MB4068:EE_ X-MS-Office365-Filtering-Correlation-Id: a3c9d3d1-015a-4e93-93dd-08dd0422898e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: TlTGmRFYfP1Lzlf05AJyoYwAPxsNWk/J0STgDEAxjw+NfEp1zEEkTZfVEGqkz9NqrXOJZASBRBx60F7ybIuc7kEnQBUMXZReqeNwhGc3yg/O9ktjjCrG/uPbkd+V4/VN/EWmnSnk8MfFhwraczJRDwqyUkK23a2xrVGEag1KJpWZJOYZEe6QokXAKZDJHIweWEK7l63LC2+++bFusLCj8e9n9RmOrWNWlFC7cT2i8Jidmju0lXJkIgE9RFw4mTP3jTQN3pa1Kz7W59+EP725/QFPe5jesGkek7Yw1aKXW9hSFFvx6yJcFBZIvg8bOvcggbGDBawt/03v/i4bTqTBHsV1Xuu0NAcDubfrBtaFCAw4cSCzbwMcmwMIBYg7CA38Q5DmfqV5sg6WrI55U/IT+tnoX5lwCY9CPO9B7mqrqre2iX+Sbch/GCFRJzsIxwpx6aQ8eMp9WgJKfzCidPFvcwTMIfWvxCJOQ8cH32qgTW6/DsxfvH7+YyLAbmTb2RkFKYzdy9Ph5jZBTmv24qyuCM8KB73tg5poNrBcuUJDXN6VozL3FbvibZdVsZGFg3HcZtcjJcI/wBk8WQDhhSKDaS5DfHPseCM9VO+p2FwFliPEX0F0zGEY5YZzCjJZiBh7sOWVDD7afWGzf50nNG3+FFkdSRYFIVJThiPKRqlMbi9RQEVO1aM7JptPwFSbii4qKPPsBdr1QJc4ExSzc9JFq/vRL//2Cu2WhO+MkMTgRTiSgDLukNGep6HpYiA8DdRKdu32xXDjfdnwZUvvGUuNChk+SIFOwnsunn8HeSOB2w9gl+kCh3J3BA55dTkRUeXQeJMjGzHpN/SEjha1bmOfSnSyYkh5dZIEe+8ekM0k+lN92P3fBa94FJ//LxtT5QI+tOt1lS4IbCqBK07VmXU4e1j8YilI6po3orKQdQvC5WaskEGtmjc1VTsQkAaCcMsTo266a96PIKAELLYPCql8BxFDHwkZidI74+JGmC+EtBpLRhO+SWqseOHbzL6EP3JxqTtT+xM5v4ILiWimmczaJ1LUtAuqjAoseU4na3Ncl+YjBuJUnd8GUeDJD33rMGrgteL7oQcC5pgxEeAfa3y3HLAhIPAPaHIVkrQ+jNbpngDOJHgaQsS2hc2/hC0T01g1AYgbOQGFUOiiHiGt6329eSZ5c/4d6KFI2A0QJ4Ae5WPa3X8HaI4EcNAbbIOJM04LV2y7AVDGyC0sHUAfvoEsS6E45NNZWA4lsOLRIAjgmg68wrhidkFYINzmusem88xNuCGFqVhPz0yq/v6Lm3Lq1WN5L48hsS4ifXYAKQuCwJh8WdQQtG9xzxa2Vr41nb7wvd6pASdw+oSMAq/xnDqnJQYJfp0+JxednD68ce0OO6ULipYgNY7F7Ek3BIqLifjJ/ovwDP9hpq/seBUaipdpFw== 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:(13230040)(1800799024)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2024 20:34:13.8137 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a3c9d3d1-015a-4e93-93dd-08dd0422898e 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: DS1PEPF0001708F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4068 X-Patchwork-Delegate: kuba@kernel.org Introduce shared esw qos domains, capable of holding rate groups for multiple E-Switches of the same NIC. Shared qos domains are reference counted and can be discovered via devcom. The devcom comp lock is used in write-mode to prevent init/cleanup races. When initializing a shared qos domain fails due to devcom errors, the code falls back to using a private qos domain while logging a message that cross-esw scheduling cannot be supported. Shared esw qos domains will be used in a future patch to support cross-eswitch scheduling. Issue: 3645895 Signed-off-by: Cosmin Ratiu Change-Id: I45afa120e2ac4c521c13389f789e02b5fd91c42e --- .../net/ethernet/mellanox/mlx5/core/esw/qos.c | 73 +++++++++++++++++-- 1 file changed, 67 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c b/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c index 87c9789c2836..4fba59137011 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c @@ -11,10 +11,17 @@ /* Minimum supported BW share value by the HW is 1 Mbit/sec */ #define MLX5_MIN_BW_SHARE 1 -/* Holds rate nodes associated with an E-Switch. */ +/* Holds rate nodes associated with one or more E-Switches. + * If cross-esw scheduling is supported, this is shared between all + * E-Switches of a NIC. + */ struct mlx5_qos_domain { /* Serializes access to all qos changes in the qos domain. */ struct mutex lock; + /* Whether this domain is shared with other E-Switches. */ + bool shared; + /* The reference count is only used for shared qos domains. */ + refcount_t refcnt; /* List of all mlx5_esw_sched_nodes. */ struct list_head nodes; }; @@ -34,7 +41,7 @@ static void esw_assert_qos_lock_held(struct mlx5_eswitch *esw) lockdep_assert_held(&esw->qos.domain->lock); } -static struct mlx5_qos_domain *esw_qos_domain_alloc(void) +static struct mlx5_qos_domain *esw_qos_domain_alloc(bool shared) { struct mlx5_qos_domain *qos_domain; @@ -44,21 +51,75 @@ static struct mlx5_qos_domain *esw_qos_domain_alloc(void) mutex_init(&qos_domain->lock); INIT_LIST_HEAD(&qos_domain->nodes); + qos_domain->shared = shared; + if (shared) + refcount_set(&qos_domain->refcnt, 1); return qos_domain; } -static int esw_qos_domain_init(struct mlx5_eswitch *esw) +static void esw_qos_devcom_lock(struct mlx5_devcom_comp_dev *devcom, bool shared) { - esw->qos.domain = esw_qos_domain_alloc(); + if (shared) + mlx5_devcom_comp_lock(devcom); +} + +static void esw_qos_devcom_unlock(struct mlx5_devcom_comp_dev *devcom, bool shared) +{ + if (shared) + mlx5_devcom_comp_unlock(devcom); +} + +static int esw_qos_domain_init(struct mlx5_eswitch *esw, bool shared) +{ + struct mlx5_devcom_comp_dev *devcom = esw->dev->priv.hca_devcom_comp; + + if (shared && IS_ERR_OR_NULL(devcom)) { + esw_info(esw->dev, "Cross-esw QoS cannot be initialized because devcom is unavailable."); + shared = false; + } + + esw_qos_devcom_lock(devcom, shared); + if (shared) { + struct mlx5_devcom_comp_dev *pos; + struct mlx5_core_dev *peer_dev; + + mlx5_devcom_for_each_peer_entry(devcom, peer_dev, pos) { + struct mlx5_eswitch *peer_esw = peer_dev->priv.eswitch; + + if (peer_esw->qos.domain && peer_esw->qos.domain->shared) { + esw->qos.domain = peer_esw->qos.domain; + refcount_inc(&esw->qos.domain->refcnt); + goto unlock; + } + } + } + + /* If no shared domain found, this esw will create one. + * Doing it with the devcom comp lock held prevents races with other + * eswitches doing concurrent init. + */ + esw->qos.domain = esw_qos_domain_alloc(shared); +unlock: + esw_qos_devcom_unlock(devcom, shared); return esw->qos.domain ? 0 : -ENOMEM; } static void esw_qos_domain_release(struct mlx5_eswitch *esw) { - kfree(esw->qos.domain); + struct mlx5_devcom_comp_dev *devcom = esw->dev->priv.hca_devcom_comp; + struct mlx5_qos_domain *domain = esw->qos.domain; + bool shared = domain->shared; + + /* Shared domains are released with the devcom comp lock held to + * prevent races with other eswitches doing concurrent init. + */ + esw_qos_devcom_lock(devcom, shared); + if (!shared || refcount_dec_and_test(&domain->refcnt)) + kfree(domain); esw->qos.domain = NULL; + esw_qos_devcom_unlock(devcom, shared); } enum sched_node_type { @@ -1495,7 +1556,7 @@ int mlx5_esw_qos_init(struct mlx5_eswitch *esw) if (esw->qos.domain) return 0; /* Nothing to change. */ - return esw_qos_domain_init(esw); + return esw_qos_domain_init(esw, false); } void mlx5_esw_qos_cleanup(struct mlx5_eswitch *esw) From patchwork Wed Nov 13 20:30:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Ratiu X-Patchwork-Id: 13874279 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2050.outbound.protection.outlook.com [40.107.223.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A36420899A for ; Wed, 13 Nov 2024 20:34:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731530066; cv=fail; b=oxkjj0Om/b683vYBe2JJwGzsU2RX3iN7ZZVlpHrzKz3mVPMyykzaUgC+EEYGaNGvC1F67rq5nZLQ27xh8PGZhT3srjpsNoYTFjWKZ+GeER1H4dsux91F+Ya8xNiaz4m4/fK0pTqDykbUkoshIuiDuIRZyDIWOJuL9UG6SIRcvTE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731530066; c=relaxed/simple; bh=UdxvrmQyB77wGBDCVVzKTdUJ7FfmD4ynELJvJFSbAoY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IPPSCsSnnrXAJDukSx/OKOwV/d4X8i2GxSpkxsIKqw6c7pdpoYBMROI+MDOl6CkbvXGrRrvdpGU+weAJu4jDFjuBDYTvIsXRilpPS5AQFdWPYGfm5foKxFwqI2nLgFW/sB89OOog8hWG1BxsMcso1ycZrBq13XiWKVO1mJoxyng= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=ePv0SaNN; arc=fail smtp.client-ip=40.107.223.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="ePv0SaNN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hU368ItmkYrRER7+f8GCtcnaV5m7vCMnAyDvpIMjG4351T6VJ1zcFzRSOXKtqMbRDZv1PG0mOOEVawb4LkX/2aMfTfnYn6fQPinQA8aM9HPXXsCmF2Gz0rvQJ9rRFGsn8l7DSzlk85auzRhO9NgpY2WOfx6+f+qYDpr91s3ywsBkai9/9o/asxWo9y5T+sDyjmaBpTEvFepn18srv5EJAaJ4u2QJEE8rpMUIqoH2IWNRvRyW2k1DxY9dQfFpY1VgWP01oX7+EIKjIn7JHsWuHEPaNtwwZaCujj19+Hjz3GtmyeKGyW6ITUj1nMASLZRj/ceHTzp8ape++CS6eWlcCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=BbdsVZedmqE2Qw3LlVSocZ3zW+XN5gGQaVJYYTVAyMU=; b=aBlCtQlurClXAFeW50JM6E6Be5CCdGWNagoqeuaG4CMEZsLluTe+P+4qg3AsG62wO9+8kWtXvtrfx7vSmVBq0VQ3ACpcrYYl4m3CHyp4Cy5Mlh/xbEs0GpTdWkD4agrjqLV7YfCQ8Wl+8cPBgmVbNNo/aERqKxaIKClmXjVVxQ1Lu82QjXc8dp2GonP9KjOyOzKIDRoWb0QJtJWP6OxhOu5Ewn2vQ+jIO22R+goDy8txxkWdJMnaG8EorhUDbdhaXdtua2NN2akV3BceSEfQmujyh5ZKz4hFjlF4lp3VN/eFKJ0dSaBJIjtxes+/TZKcJG/lE16+KLUjGDNiMoGIQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.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=BbdsVZedmqE2Qw3LlVSocZ3zW+XN5gGQaVJYYTVAyMU=; b=ePv0SaNN1HWY6/2l2UcOsPAQeBiTL2AVzjBjcB0/vQ0X68x0aalO5qfU5qEeRjmbPMCGyKYadjkZobU1Uzdjde7SkIAGIwPOo9uaO/B4L1xqZnZk7zf2eO9YojgFoYyaxudG7eJmhDv1E7KicAHSbKriWGD+zBhgvfWMKuDEdI7oaEvykoXw3jh36UwEz/Az8/DIZDSbttxCxhG/M5neD8KnsZEMADeAeXZ2PM2pa2ogJNdExuJCW6vUcIshCd+q28KHe4tCHF0fkM1L1SD1PQxGupYTVjNMfYYekcLwrd401JqDIc/7hd8PR0W+HMBIyRlzl2JsXuvRTgPzseh6mg== Received: from MW4PR02CA0002.namprd02.prod.outlook.com (2603:10b6:303:16d::10) by SA1PR12MB5613.namprd12.prod.outlook.com (2603:10b6:806:22b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28; Wed, 13 Nov 2024 20:34:19 +0000 Received: from CO1PEPF000044FA.namprd21.prod.outlook.com (2603:10b6:303:16d:cafe::ae) by MW4PR02CA0002.outlook.office365.com (2603:10b6:303:16d::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.17 via Frontend Transport; Wed, 13 Nov 2024 20:34:17 +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 CO1PEPF000044FA.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.1 via Frontend Transport; Wed, 13 Nov 2024 20:34:17 +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.1544.4; Wed, 13 Nov 2024 12:34:00 -0800 Received: from nexus.mtl.labs.mlnx (10.126.231.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.1544.4; Wed, 13 Nov 2024 12:33:57 -0800 From: Cosmin Ratiu To: CC: , , , , Subject: [PATCH 09/10] net/mlx5: qos: Support cross-esw scheduling in qos.c Date: Wed, 13 Nov 2024 22:30:46 +0200 Message-ID: <20241113203317.2507537-10-cratiu@nvidia.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20241113203317.2507537-1-cratiu@nvidia.com> References: <20241113203317.2507537-1-cratiu@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044FA:EE_|SA1PR12MB5613:EE_ X-MS-Office365-Filtering-Correlation-Id: 29045557-564b-4b8d-1943-08dd04228bc2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: pbY1QZmSKieY1+hzAN1rhTx2zZxIQQEODkxHjuF157O7GsPH+z5pn9dlLmMc30BNeppZUfldf7KomGyrNTmpp0mYxN7TgXmqS5CBybm1a/lbPhEx3J7sy1hTekVderJBJ6hLG+xgfcTSTNvy7wbgiuIZq2mYj5KmFg1uTD+/Dl4AA8tj6j0LXPN6i/pOIEN7LLWqVwbuImihJVundXooKrMQOSZY24DH0E5y8W2xoz3fuGCyKBHSSSsk4Fx4xGfmMEtuAHOUP2qEOO8h//k6L9YuMhxeT+49DXgDKrKoEeqSV0NzA6Tzsdm8zzwcuq9uQT8Vlsgfu9aIeH08OjsDXdNO5X6aGO0piA4+Folt0ht7rnAU3XuNc5bjuRvdt9gBs2gxuWgrV+q7ACB7d1ISJn//bfqIglPSxpck9QruVqKsPmthfKqHG5nxVH8RfBZrkSa23b+aw5BaU7Ao6QOCQ6Pu7lp8vb0YOTJOZDPqFtUujD1YcqiVcRCwsAN/73xUtBJFJjzpMgDtSHcEni4SUJ0IPpkt84T0Q62MX4rDdtFBDdf+UmSc5jdgMRZ/Pi/eGnUT8Wk+NEqjebDlPowydI4izH0rNPQmAy8f8k8Vg8D7e1/P8J2LcLNhNaibskbUyWsNMcdQRJVZ5GOMnyaLor4jH6SSmwAU8z+6EbA7IrHkL193cZr+c/7cdUnVLIE2gsBOk+tfTM0WuUWdahUD8e15YB4a6KSpl6LCVgzvlxtwHIOQVmFtTnh+bNYMnw/Lk6Z+y5bqltXr7OCzr/ORWioRy7nWvL7eaQODlR7kPPXIE0Dof7bHtj28BpaSiYDo3SCoV0VGytzduNjpHKyWxNN4su/2kia5g7s+RTxWlhemo4rszJBDYV+iZ6LHVxkMMBGvc15ZGepFTbxInL0webnPdmvcd+Qj9w4SXzZsfEQpW1hntD6Cmpbca3zmiJlriIJaY5rm+Mh12zV8gEMVOIv5HnPNqM3gMW7aZuSEa7l9l2KS1QXU2F0vf9u8MN+gMd9gT2cbXZUdhSG1AURT3acWUZ+LpPFvTLLXDgew04a9DfPW/BZ+lN4QtDlhcMFpkpwS+2PCdgDQ3QIwIebRtvtex1sv5OEFPMfT+o3MwJzPh9Vg5i2hPoZq7YFQcWcULQyg/3QVZ9IM3jv1BQgfCpTSnF0fFgVle82C2/Z+H8DFbyIZKWJuOHGl7SR3qrOzatGheLm7Z6il4u5pkL3rTAg7ftXbOhc/k+qUc3IQ50qWi2Bn9BjjsF2vV1q2IACa2Ue+hvc25AEz+TLqiUx9+TfaJ85OIBS92JmELZE7rAaPQChTIa/9u6jou+exbDzl/UbOHquif0PHzwVSW5/nQ5a5KnEu1TbqHdhjkvV5cn/BkU1BFx8cxpnbZgVhT8nqyKvJn/mn0NSqcCw8qydrYg== 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:(13230040)(376014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2024 20:34:17.5224 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 29045557-564b-4b8d-1943-08dd04228bc2 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: CO1PEPF000044FA.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB5613 X-Patchwork-Delegate: kuba@kernel.org Up to now, rate groups could only contain vports from the same E-Switch. This patch relaxes that restriction if the device supports it (HCA_CAP.esw_cross_esw_sched == true) and the right conditions are met: - Link AGgregation (LAG) is enabled. - The E-Switches use the same qos domain. This also enables the use of the previously added shared esw qos domains. Issue: 3645895 Change-Id: I282f0ecad258fa2dbe6a49e88cc7bc9a06ccfcce Signed-off-by: Cosmin Ratiu --- .../net/ethernet/mellanox/mlx5/core/esw/qos.c | 117 +++++++++++++----- include/linux/mlx5/mlx5_ifc.h | 11 +- 2 files changed, 92 insertions(+), 36 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c b/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c index 4fba59137011..b75f9939ae4b 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c @@ -155,7 +155,9 @@ struct mlx5_esw_sched_node { enum sched_node_type type; /* The eswitch this node belongs to. */ struct mlx5_eswitch *esw; - /* The children nodes of this node, empty list for leaf nodes. */ + /* The children nodes of this node, empty list for leaf nodes. + * Can be from multiple E-Switches. + */ struct list_head children; /* Valid only if this node is associated with a vport. */ struct mlx5_vport *vport; @@ -471,6 +473,7 @@ static int esw_qos_vport_create_sched_element(struct mlx5_esw_sched_node *vport_ { u32 sched_ctx[MLX5_ST_SZ_DW(scheduling_context)] = {}; struct mlx5_core_dev *dev = vport_node->esw->dev; + struct mlx5_vport *vport = vport_node->vport; void *attr; if (!mlx5_qos_element_type_supported(dev, @@ -481,7 +484,13 @@ static int esw_qos_vport_create_sched_element(struct mlx5_esw_sched_node *vport_ MLX5_SET(scheduling_context, sched_ctx, element_type, SCHEDULING_CONTEXT_ELEMENT_TYPE_VPORT); attr = MLX5_ADDR_OF(scheduling_context, sched_ctx, element_attributes); - MLX5_SET(vport_element, attr, vport_number, vport_node->vport->vport); + MLX5_SET(vport_element, attr, vport_number, vport->vport); + if (vport->dev != dev) { + /* The port is assigned to a node on another eswitch. */ + MLX5_SET(vport_element, attr, eswitch_owner_vhca_id_valid, true); + MLX5_SET(vport_element, attr, eswitch_owner_vhca_id, + MLX5_CAP_GEN(vport->dev, vhca_id)); + } MLX5_SET(scheduling_context, sched_ctx, parent_element_id, vport_node->parent->ix); MLX5_SET(scheduling_context, sched_ctx, max_average_bw, vport_node->max_rate); @@ -494,6 +503,7 @@ static int esw_qos_vport_tc_create_sched_element(struct mlx5_esw_sched_node *vpo { u32 sched_ctx[MLX5_ST_SZ_DW(scheduling_context)] = {}; struct mlx5_core_dev *dev = vport_tc_node->esw->dev; + struct mlx5_vport *vport = vport_tc_node->vport; void *attr; if (!mlx5_qos_element_type_supported(dev, @@ -504,9 +514,15 @@ static int esw_qos_vport_tc_create_sched_element(struct mlx5_esw_sched_node *vpo MLX5_SET(scheduling_context, sched_ctx, element_type, SCHEDULING_CONTEXT_ELEMENT_TYPE_VPORT_TC); attr = MLX5_ADDR_OF(scheduling_context, sched_ctx, element_attributes); - MLX5_SET(vport_tc_element, attr, vport_number, vport_tc_node->vport->vport); + MLX5_SET(vport_tc_element, attr, vport_number, vport->vport); MLX5_SET(vport_tc_element, attr, traffic_class, vport_tc_node->tc); MLX5_SET(scheduling_context, sched_ctx, max_bw_obj_id, rate_limit_elem_ix); + if (vport->dev != dev) { + /* The port is assigned to a node on another eswitch. */ + MLX5_SET(vport_tc_element, attr, eswitch_owner_vhca_id_valid, true); + MLX5_SET(vport_tc_element, attr, eswitch_owner_vhca_id, + MLX5_CAP_GEN(vport->dev, vhca_id)); + } MLX5_SET(scheduling_context, sched_ctx, parent_element_id, vport_tc_node->parent->ix); MLX5_SET(scheduling_context, sched_ctx, bw_share, vport_tc_node->bw_share); @@ -947,7 +963,6 @@ static int esw_qos_vport_tc_enable(struct mlx5_vport *vport, enum sched_node_typ NL_SET_ERR_MSG_MOD(extack, "Setting up TC Arbiter for a vport is not supported."); return -EOPNOTSUPP; } - esw_assert_qos_lock_held(vport->dev->priv.eswitch); if (type == SCHED_NODE_TYPE_RATE_LIMITER) @@ -1182,6 +1197,26 @@ static int esw_qos_vport_tc_check_type(enum sched_node_type curr_type, return 0; } +static bool esw_qos_validate_unsupported_tc_bw(struct mlx5_eswitch *esw, u32 *tc_bw) +{ + int i, num_tcs = esw_qos_num_tcs(esw->dev); + + for (i = num_tcs; i < IEEE_8021QAZ_MAX_TCS; i++) { + if (tc_bw[i]) + return false; + } + + return true; +} + +static bool esw_qos_vport_validate_unsupported_tc_bw(struct mlx5_vport *vport, u32 *tc_bw) +{ + struct mlx5_eswitch *esw = vport->qos.sched_node ? + vport->qos.sched_node->parent->esw : vport->dev->priv.eswitch; + + return esw_qos_validate_unsupported_tc_bw(esw, tc_bw); +} + static int esw_qos_vport_update(struct mlx5_vport *vport, enum sched_node_type type, struct mlx5_esw_sched_node *parent, struct netlink_ext_ack *extack) @@ -1200,8 +1235,14 @@ static int esw_qos_vport_update(struct mlx5_vport *vport, enum sched_node_type t if (err) return err; - if (curr_type == SCHED_NODE_TYPE_TC_ARBITER_TSAR && curr_type == type) + if (curr_type == SCHED_NODE_TYPE_TC_ARBITER_TSAR && curr_type == type) { esw_qos_tc_arbiter_get_bw_shares(vport->qos.sched_node, curr_tc_bw); + if (!esw_qos_validate_unsupported_tc_bw(parent->esw, curr_tc_bw)) { + NL_SET_ERR_MSG_MOD(extack, + "Unsupported traffic classes on the new device"); + return -EOPNOTSUPP; + } + } esw_qos_vport_disable(vport, extack); @@ -1519,26 +1560,6 @@ static int esw_qos_devlink_rate_to_mbps(struct mlx5_core_dev *mdev, const char * return 0; } -static bool esw_qos_validate_unsupported_tc_bw(struct mlx5_eswitch *esw, u32 *tc_bw) -{ - int i, num_tcs = esw_qos_num_tcs(esw->dev); - - for (i = num_tcs; i < IEEE_8021QAZ_MAX_TCS; i++) { - if (tc_bw[i]) - return false; - } - - return true; -} - -static bool esw_qos_vport_validate_unsupported_tc_bw(struct mlx5_vport *vport, u32 *tc_bw) -{ - struct mlx5_eswitch *esw = vport->qos.sched_node ? - vport->qos.sched_node->parent->esw : vport->dev->priv.eswitch; - - return esw_qos_validate_unsupported_tc_bw(esw, tc_bw); -} - static bool esw_qos_tc_bw_disabled(u32 *tc_bw) { int i; @@ -1553,10 +1574,16 @@ static bool esw_qos_tc_bw_disabled(u32 *tc_bw) int mlx5_esw_qos_init(struct mlx5_eswitch *esw) { - if (esw->qos.domain) - return 0; /* Nothing to change. */ + bool use_shared_domain = esw->mode == MLX5_ESWITCH_OFFLOADS && + MLX5_CAP_QOS(esw->dev, esw_cross_esw_sched); - return esw_qos_domain_init(esw, false); + if (esw->qos.domain) { + if (esw->qos.domain->shared == use_shared_domain) + return 0; /* Nothing to change. */ + esw_qos_domain_release(esw); + } + + return esw_qos_domain_init(esw, use_shared_domain); } void mlx5_esw_qos_cleanup(struct mlx5_eswitch *esw) @@ -1760,16 +1787,40 @@ int mlx5_esw_devlink_rate_node_del(struct devlink_rate *rate_node, void *priv, return 0; } -int mlx5_esw_qos_vport_update_parent(struct mlx5_vport *vport, struct mlx5_esw_sched_node *parent, - struct netlink_ext_ack *extack) +static bool mlx5_esw_validate_cross_esw_scheduling(struct mlx5_eswitch *esw, + struct mlx5_esw_sched_node *parent, + struct netlink_ext_ack *extack) { - struct mlx5_eswitch *esw = vport->dev->priv.eswitch; - int err = 0; + if (!parent || esw == parent->esw) + return 0; - if (parent && parent->esw != esw) { + if (!MLX5_CAP_QOS(esw->dev, esw_cross_esw_sched)) { NL_SET_ERR_MSG_MOD(extack, "Cross E-Switch scheduling is not supported"); return -EOPNOTSUPP; } + if (esw->qos.domain != parent->esw->qos.domain) { + NL_SET_ERR_MSG_MOD(extack, + "Cannot add vport to a parent belonging to a different qos domain"); + return -EOPNOTSUPP; + } + if (!mlx5_lag_is_active(esw->dev)) { + NL_SET_ERR_MSG_MOD(extack, + "Cross E-Switch scheduling requires LAG to be activated"); + return -EOPNOTSUPP; + } + + return 0; +} + +int mlx5_esw_qos_vport_update_parent(struct mlx5_vport *vport, struct mlx5_esw_sched_node *parent, + struct netlink_ext_ack *extack) +{ + struct mlx5_eswitch *esw = vport->dev->priv.eswitch; + int err; + + err = mlx5_esw_validate_cross_esw_scheduling(esw, parent, extack); + if (err) + return err; esw_qos_lock(esw); if (!vport->qos.sched_node && parent) { diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h index b9eef877c061..10cb9aa52f06 100644 --- a/include/linux/mlx5/mlx5_ifc.h +++ b/include/linux/mlx5/mlx5_ifc.h @@ -1095,7 +1095,9 @@ struct mlx5_ifc_qos_cap_bits { u8 log_esw_max_sched_depth[0x4]; u8 reserved_at_10[0x10]; - u8 reserved_at_20[0xb]; + u8 reserved_at_20[0x9]; + u8 esw_cross_esw_sched[0x1]; + u8 reserved_at_2a[0x1]; u8 log_max_qos_nic_queue_group[0x5]; u8 reserved_at_30[0x10]; @@ -4130,13 +4132,16 @@ struct mlx5_ifc_tsar_element_bits { }; struct mlx5_ifc_vport_element_bits { - u8 reserved_at_0[0x10]; + u8 reserved_at_0[0x4]; + u8 eswitch_owner_vhca_id_valid[0x1]; + u8 eswitch_owner_vhca_id[0xb]; u8 vport_number[0x10]; }; struct mlx5_ifc_vport_tc_element_bits { u8 traffic_class[0x4]; - u8 reserved_at_4[0xc]; + u8 eswitch_owner_vhca_id_valid[0x1]; + u8 eswitch_owner_vhca_id[0xb]; u8 vport_number[0x10]; }; From patchwork Wed Nov 13 20:30:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Ratiu X-Patchwork-Id: 13874278 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2050.outbound.protection.outlook.com [40.107.101.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E651D20651B for ; Wed, 13 Nov 2024 20:34:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731530064; cv=fail; b=MXLxhHLDndIJ3HTJ2RZDsW4m3iWiBrOycVavEMsMfIDl3UTFr5H+v1w1o7zTeA9QH159bKGFzTa4oby+Z4eiEFohWm4fFEL/nyTPLE9tUOq4XK+fF+K7InoJTFxaYbhVHJcwGwwbK/tsgokJSz3c/qBf5VNRTEOKFssb9wMQAtM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731530064; c=relaxed/simple; bh=JQIMpO3MG7TIvSwENnIkWVQpA88wm5cGzNVFJDAoH04=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KwsADj0llNM+mUDT9R+OSAAknDfeQKWgPcLkpnG6KAVzk43WbQ0IqtPSLdvS3Xth7xvB8dwyxRXpI7tU/30AsMdu0ksHWE39bLGNpmnBsAxMSfXzYm3To3rwFjtEsriyFYz5g9ADvQGZHni+/EX9ZLh+01neJUxurqXq03twfLU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=pzUhwVmt; arc=fail smtp.client-ip=40.107.101.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="pzUhwVmt" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bpG02Bom9AErToRzdIX3LHyeVq+kCqf5k2b39JRpJQ0LTBWQRzHOLB5D913SNvgHwRG5BTzHpszrraYO8RjcqVrBThrwANf1mbIV7Bs8mU2IGuhga7P0Ov4ExlLGUzvUgV+aEFBLwMzocHalbW4YMx9x8aRS1jJtnJpQdask3ohmXdqIO9CnWU3gsmhmBNkSL3tokoISJNUzQAEoPaQetPcAO4Mdco3hameWlhXbLyihd5gKm5kM6IYZ3HpRiGmtqDkNcx4pYGQepml1ehiIobI5Q21MdZUkD0oJuclHvHoc3teJ2EVzij49ylKffWAiNZhZ5S6Sf4x/sjqXByz19g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=oiYZMcqiGHfPkht4Cd15ogoh5oGL0pLLt1W8ozlCV/A=; b=Gb4feL3UN9WD0AB+d0/U4z0jG+UxfSLysf08UA5UOqwGA77Is1ueMoNdfq0abxWMl1KhCYH9geQsGlnEB+GnGbb9DUKceugGGQI6CC/zzS5ui3TkZMRuLEO8ToHQ4VdqMqHpLidrDAT3botZvlzaU5Ee8xn9DGauizbWf7dYqDgC3X9wax40HNSamY2aXAkXvONOokVvBJ02aV7IB9TIu8gmQzJ2aT/sHfJMywslKi0vM53C7iQB8q7d5VZ1AlrTu4a4l/EslRoiy74hrtolwO1rEkhPysMM2zHtHeIYefwN+bEQQxCZpKTRrA480bMol5sDoRodFK6GHXHPJGOOmw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.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=oiYZMcqiGHfPkht4Cd15ogoh5oGL0pLLt1W8ozlCV/A=; b=pzUhwVmtUGv7HR1TQj01UpLy95BGk2yoI5kaHWTUiRehRZL8Jqpl6ExHZ67V109j1dRo7A1F5MxeexPCGru8cebGk3e0gggicv+ivdFKWe4H8Ya8mbg9xX1OYdTF8LCDezaUPCC7jcCSUInI/WRgdTGuxAeETdUYzo+KqlKvJ7vNM9rt5/XU2bC/zItFxsIbo5wk4ACLPbSpqUt/E2t1zOuIu5heZs0gdEhIcRj+ftloITcn/jRjvqVy8K+Mh5a+7fpH5oq56BQKp6yae3nEolXjd8mX3BQpe1cUa5+IvrZ99/cnpKhg3aWwp76qH2+731/S2HZzNPOu5U3XdjXPYw== Received: from DS7PR03CA0295.namprd03.prod.outlook.com (2603:10b6:5:3ad::30) by PH8PR12MB7423.namprd12.prod.outlook.com (2603:10b6:510:229::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.17; Wed, 13 Nov 2024 20:34:19 +0000 Received: from DS1PEPF00017093.namprd03.prod.outlook.com (2603:10b6:5:3ad:cafe::59) by DS7PR03CA0295.outlook.office365.com (2603:10b6:5:3ad::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.16 via Frontend Transport; Wed, 13 Nov 2024 20:34:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS1PEPF00017093.mail.protection.outlook.com (10.167.17.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Wed, 13 Nov 2024 20:34:19 +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.1544.4; Wed, 13 Nov 2024 12:34:02 -0800 Received: from nexus.mtl.labs.mlnx (10.126.231.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.1544.4; Wed, 13 Nov 2024 12:34:00 -0800 From: Cosmin Ratiu To: CC: , , , , Subject: [PATCH 10/10] net/mlx5: qos: Init shared devlink rate domain Date: Wed, 13 Nov 2024 22:30:47 +0200 Message-ID: <20241113203317.2507537-11-cratiu@nvidia.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20241113203317.2507537-1-cratiu@nvidia.com> References: <20241113203317.2507537-1-cratiu@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017093:EE_|PH8PR12MB7423:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a740570-27ec-4eb3-71d5-08dd04228d0a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: kD6NKbv/J7y0QQ3ubmhPr8dh0ZQ/gCMncMjoj0mhu/KRLbs+kEjqs3Nrp3TlISRdIZgcPHSEall/vVytnx5J0ZkDW7bc1BPD0eWAmXfpIkvIwKU3oRXTo0KXh/EGfpktNtCQwsVA2YN4yEYGgOBHo8m/dNzDxBT9x5082I+14EWu0IC9O5qXKnQ2W196i386Uu9ynWbn7Wg1Tyuthxs0XnkvJQl6v61ZfqUFHGbrebzh8E52pEVJD2HpRPjzHnKbK6uyAy1nCRtHNv0eVKRELvKC/IFx5J8GUfM7wCGzWJgSkpwrCyZwwI33u8ckxN2i67W6q2VvZwqmRSDZ+OYZjoY0gKfV7JTcObkNBPJSmHO9RpIPQb+YZ6cauP2O4P2rSDkGINrLRw9hkw+UW569GrkcbQiDJznFL9/jJtVytqxp0xpLVeZxQpHEDptcAFMiH3dO8tKRTQkIpeEAo2JCEd4W3myRoFc11D+v7gZfxwRSpEBfjvsMPAZ1aYAL/InzdCPhu7+pesv0P/WY3/DQ+St6LkmZ6MByIYvkJj4djizsf9MuAJEF+4WI9vsOP806hmMsHZQ9efPX5Ov95iB0a9XNDk3rkEjNIC2JnpEPoSnbB9xu7dIOGDV7HrcCLDfGLe8qSiss2PyLarq/1DJgv+SqWvoXLW4Wi2Nj4B2C3AGtFCuATO2Zi9w1dawdXs2+T80mOLC8h2RMdOlriUeOoSUvZ/rVTNNRn1uUVcw5MSmq17spamw6SvWAwUMrmLFncjjI83CIMYYrY1RpLwALO5u2eAlik58RHp+hWf9/8cMSNbzKtRnSWKTq9rGsUA33dlMfj/3MSI9GdHqxFFeT1D29N9dmPlN+yCT/B5QtJ0cy6z0ghIsC6bxTCRiMwxYaDPO0IqkkxN3sc6ydVNKlMjunh7nFdooiQ1tl3Ga+kliEMWbpx4eZFzBZt5FVUHB+qpi65tXQTJUhI4Vc92hXjitBuy3iH9dH+fBli0+F3JmDLJROcDg1hrXM89c/VFdCN6k0JZaWb+QsG33lY5bYJxqeZkbzQSkClabN073tq0lJNPlgyL1gdMTW/eIKvdT3id3l0tq8Hd3SYlcrqTfLrlmS5ju11CxWT4g4gViUtIVlWZ7BA3OdyPmyOGs8fU4AKQ4HThuLuttfyyPxOTQb44W1bfs1KlyL+x+QFrCzsdUznB499cq+YzyYGp/u540a1erAkcqMdlQhT0lgukXGzSTsDHgD9kqlKyCJ+mCzz0AVHJNxG8q4RrAHPSdIp8e1F99CVUwqbLP9QrkFz5/59S7jVGnWKCEGOTPFlIgv5GrHgV1gqK8f3atH194s8koWMPIwDkisxEnQfgN9dhB5tD8+BsJ/BVisXAqVqqM5g2VnPW+O3L795u6p3wWRFx06A0IoJnd6Uh+rxg4o1psBEw== 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:(13230040)(376014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2024 20:34:19.6743 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8a740570-27ec-4eb3-71d5-08dd04228d0a 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: DS1PEPF00017093.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7423 X-Patchwork-Delegate: kuba@kernel.org If the device can do cross-esw scheduling, switch to using a shared rate domain so that devlink rate nodes can have parents from other functions of the same device. As a fallback mechanism, if switching to a shared rate domain failed, a warning is logged and the code proceeds with trying to use a private qos domain since cross-esw scheduling cannot be supported. Issue: 3645895 Signed-off-by: Cosmin Ratiu Change-Id: I6ccb5e29f316f97ad8a559fcf5d59ee70f2b9315 --- drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c b/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c index b75f9939ae4b..7230637b4303 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c @@ -1577,6 +1577,20 @@ int mlx5_esw_qos_init(struct mlx5_eswitch *esw) bool use_shared_domain = esw->mode == MLX5_ESWITCH_OFFLOADS && MLX5_CAP_QOS(esw->dev, esw_cross_esw_sched); + if (use_shared_domain) { + u64 guid = mlx5_query_nic_system_image_guid(esw->dev); + int err; + + err = devlink_shared_rate_domain_init(priv_to_devlink(esw->dev), guid); + if (err) { + /* On failure, issue a warning and switch to using a private domain. */ + esw_warn(esw->dev, + "Shared devlink rate domain init failed (err %d), cross-esw QoS not available", + err); + use_shared_domain = false; + } + } + if (esw->qos.domain) { if (esw->qos.domain->shared == use_shared_domain) return 0; /* Nothing to change. */