From patchwork Sat Mar 1 01:35:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 13997258 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2059.outbound.protection.outlook.com [40.107.223.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 362CAB676; Sat, 1 Mar 2025 01:37:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740793029; cv=fail; b=Rs6YAYCvN9nRgMAgX689EeK4FRERe1XHgM5IqfTxOhcN5gUKaU4ksbmebm8D2SWkQcAIxuIrSQnVVk63XqjTVL85w+4EajthDb3jLhw1VwPNyMSTtnG5/aG86Y5cCVLewI8YKRjOJniKiL0X7jUAerFunqHXFZ485wvlbtYifuw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740793029; c=relaxed/simple; bh=KzbuNZ/0Za0zdLRZCLKpXE0+zihQIgNbkJ2CHAIInXI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MRSWA5jlytWfVb8skGvh2BrOF7+Y9oT85AAJqvD2Kd4UtmAi2tOAoOZUVE6/rZ/+ZyoQ2uxsCK3xdeXH3fZI6AKQ1i+il8pztpBnv58Hwr8rZsw1TOCphQE3Wp4k2RO9wWENYmZazizQHgxd7a8/zHqujGLxS3t3Iv9xivRgsco= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=x/JM0p5C; arc=fail smtp.client-ip=40.107.223.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="x/JM0p5C" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sYzbt6vCZno5PwQv5UPfs9//Y6VEgETjPUCzQCnUDTHXrhEaLIG5cH8v2RBO4V1QgdOC4bs7o6Jxd4PbXyhoXii6EkMDVb2nbkKAQmuSiUugqw2Zdkz1dmurOhVc8Lnllfq8PuRFD9Be5mX30Y4z8P0fGP/Rx2ioDfGQZOOGDYDiCvlGfXF2mYOcl0qRnCksmWuC/FWgneCJ5kYlsPmCw1lZgVBJAv6PzOY44Oe4KJMN9PwtkBdxvOpZnEvmizPKeOSZ9D4wtAsSJODXBOUJwC6ceJQLAMnrMEbw+oE+3NaEjRQdeeFNcUdlPx/HzzkkQqxHLF+3Aat16VJzymW4rg== 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=jgMcuvs5RUw5JjOTIa4NKzWNtTbTXgjyDUbajiUwinA=; b=OnYK4OxRbRCdNmIAQmxzCCwtniEiRh+FNxkq4oJRRPW/aJcn+/wIUXl8hwcmFa4gi45cleSTlmswU1u2CdIisTRTNJ2KTp6p51WfsGuuWSqcRHe1X+Jvypv4N+beRMR06MHO9VcxBkrsE7AK8rsNAnhmCTUceC8JBxDOTtdhXceiFCoe8RyxFJwsP7ghmyLhjDJM3PlWTENhXCLR2xEp3GMRh+Kaa2EsZqE/K+pVj0v8GZaa9mEGPUjXFmJDgfUfGUL46EJnfXUkmtN0PJpQZfvv1vf07agdJuwUiQCcPn77ontpHNnoNPL4MVyD/PWCfllSZ+xNNJEl5uUrdX7qxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nvidia.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jgMcuvs5RUw5JjOTIa4NKzWNtTbTXgjyDUbajiUwinA=; b=x/JM0p5CZvrMtQ1ynOUSYXiv3qIm1l1VY6NX1YIQCbxO5NSnASIZF3BY78cUIauQF1KmQ2wPC6g2wX2G9ANGIOoR7muIKuiLv/fyIBJe4mZQyjkhrElRO1nTcD3tKK8iODxqUgny1eqvTnctCNJSAtNTaQff8lNboXW6i99lkzk= Received: from SJ0PR05CA0106.namprd05.prod.outlook.com (2603:10b6:a03:334::21) by DM4PR12MB7693.namprd12.prod.outlook.com (2603:10b6:8:103::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8489.22; Sat, 1 Mar 2025 01:37:02 +0000 Received: from SJ5PEPF000001E8.namprd05.prod.outlook.com (2603:10b6:a03:334:cafe::cb) by SJ0PR05CA0106.outlook.office365.com (2603:10b6:a03:334::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8511.10 via Frontend Transport; Sat, 1 Mar 2025 01:37:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ5PEPF000001E8.mail.protection.outlook.com (10.167.242.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8489.16 via Frontend Transport; Sat, 1 Mar 2025 01:37:02 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 28 Feb 2025 19:36:59 -0600 From: Shannon Nelson To: , , , , , , , , , , , , , , , , , , CC: , Shannon Nelson Subject: [PATCH v2 1/6] pds_core: make pdsc_auxbus_dev_del() void Date: Fri, 28 Feb 2025 17:35:49 -0800 Message-ID: <20250301013554.49511-2-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20250301013554.49511-1-shannon.nelson@amd.com> References: <20250301013554.49511-1-shannon.nelson@amd.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001E8:EE_|DM4PR12MB7693:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e4b7bc1-c225-43df-6306-08dd586190e6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|36860700013|82310400026|921020; X-Microsoft-Antispam-Message-Info: 0fS9s5diWRWPlMkIG6fHEjXm4KGcWZ14W1m7FqfaflXimqIhQqy+JXu8m38JLfcyxG/cwBGn1uXymVgNkIRC3LJzN4AfTpBkQlK6b+/B/45gEkirIJ/F7D8yc1q9f+qJnygKrDFud/FGYbNFK71LS5hryDoYnqa1brcxI+MZprGYgx24rLfqHmGp3t4UyZt8evpMd/7VtgMnRkv0leK40FWZrBM9GIkBZAvc+jGQhbrNuRAD9EWy2SvRZf26FRix2nUoED2L8L+ghnZEDyUAtuOyabciIskMv+Z6RkI4Y5s0+33TggSfw7e7oO3xW5XpD7N5ShuVWkZi9XJQY9q0niV+cBA8BXfhZmn4oMju0I/1zA3i9AoKleVnaA0j12SqJKu73OlCX5IlRFYBr0PgPpjch9CVq7t4ns8oiZjft94c+UJTI/yEh5G2+MrnYymWDuDtvBvpPRETB86SM2oLiylmtc0/5nm1LYrx90BhGCAmRYPjEH8p+TpOQxvrGYfoy7KFK1XSMYoa6G2N4A4quBmCXPMXiNyjnIf+yxam50Mj8kCNPTqnEU0lZNyYO8x+vrHkrVX59ylANS0auH3ILDMyeLYJUm53u0u87DMf5Cu7YtDh9tNzAHNUTywYdiMkg5jdXuHjs+cUOzDo8a9AJFHvimVPopbVbU60dlmVfCUn4cLKXOYvHcxI+nZxB63shwavAmpxQehjKCvaKQqSM+6jyy33YrGSrA2mUSVXQ48bFKCY+/EahJJM7U/UkawwW7xdpQmipBDvA8UGuUe1uCtFIHTNcqeOmQBB3DwaeuaHYAuZunj/LrKllM5hIr/Xyc5UAL0MqiGkGnX5IL7Srq42Qn2aRlJi7jXTArElNmBlVvirxlh+MwPBD1ecxUbdoSgEt+4PhWnno6k1tbWfX6AbwR7lVQbwNqlslQqAsp6PQl2t/F5XfeWxMoGyrj6SorvfcBG05FEeGbS4IfyTGBEco7rUnl828jbJsKhJVMCVo5I0eWopnQzjtX+ERHoFfiqy+pGA7EcesS8PIdrfHfM8xDT+2z7qSsA2iQMETYlnanj9w2C7nRkamk5tkoZ2ccNZ/S5mCvSCEff6attsJxJnY+WEt+ESoV8q461thxmFlxFWaPGhryrKLdPXPEOAA15NGympO+bwLQk+JR1nJ1dZNlH9lEOtgLY985c445OQbYp8MelTVMyUNsKjxbQBSA48yW+x5jIF1FhBfD6dSYrawpLjMrau1qtErX9XQGcD4pZEjNbu40Ceg7Pg+3bozfl+A9cVCcDdRZ/CqzEEM/jfK4vhQrTw3GIJNL3boyte3dO5yBV4EIDTYthhuo2SDfanIMuqcK6iEyp2bLxfFA1X3qlFCBfwZLzOsl8f4HrAgnLOCZQ7MUa+EuH2ZDC/5vj0Fn/hKKsoP4VkqGNb0jpH9En8iESG4z4eq6Dpe+ZKb0Ywd8UXZrEpaRK4dRFbs3QzVMFfEXUOgX5yVslz+AY/B+JDa50sgf/Jc2D7Be+iqi1uwnanOZJEo4EMXXNz X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(36860700013)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2025 01:37:02.1004 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3e4b7bc1-c225-43df-6306-08dd586190e6 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001E8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7693 Since there really is no useful return, advertising a return value is rather misleading. Make pdsc_auxbus_dev_del() a void function. Signed-off-by: Shannon Nelson --- drivers/net/ethernet/amd/pds_core/auxbus.c | 8 ++------ drivers/net/ethernet/amd/pds_core/core.h | 2 +- drivers/net/ethernet/amd/pds_core/devlink.c | 6 ++++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/amd/pds_core/auxbus.c b/drivers/net/ethernet/amd/pds_core/auxbus.c index 2babea110991..b1fab95f7eeb 100644 --- a/drivers/net/ethernet/amd/pds_core/auxbus.c +++ b/drivers/net/ethernet/amd/pds_core/auxbus.c @@ -175,13 +175,9 @@ static struct pds_auxiliary_dev *pdsc_auxbus_dev_register(struct pdsc *cf, return padev; } -int pdsc_auxbus_dev_del(struct pdsc *cf, struct pdsc *pf) +void pdsc_auxbus_dev_del(struct pdsc *cf, struct pdsc *pf) { struct pds_auxiliary_dev *padev; - int err = 0; - - if (!cf) - return -ENODEV; mutex_lock(&pf->config_lock); @@ -195,7 +191,6 @@ int pdsc_auxbus_dev_del(struct pdsc *cf, struct pdsc *pf) pf->vfs[cf->vf_id].padev = NULL; mutex_unlock(&pf->config_lock); - return err; } int pdsc_auxbus_dev_add(struct pdsc *cf, struct pdsc *pf) diff --git a/drivers/net/ethernet/amd/pds_core/core.h b/drivers/net/ethernet/amd/pds_core/core.h index 14522d6d5f86..631a59cfdd7e 100644 --- a/drivers/net/ethernet/amd/pds_core/core.h +++ b/drivers/net/ethernet/amd/pds_core/core.h @@ -304,7 +304,7 @@ int pdsc_register_notify(struct notifier_block *nb); void pdsc_unregister_notify(struct notifier_block *nb); void pdsc_notify(unsigned long event, void *data); int pdsc_auxbus_dev_add(struct pdsc *cf, struct pdsc *pf); -int pdsc_auxbus_dev_del(struct pdsc *cf, struct pdsc *pf); +void pdsc_auxbus_dev_del(struct pdsc *cf, struct pdsc *pf); void pdsc_process_adminq(struct pdsc_qcq *qcq); void pdsc_work_thread(struct work_struct *work); diff --git a/drivers/net/ethernet/amd/pds_core/devlink.c b/drivers/net/ethernet/amd/pds_core/devlink.c index 44971e71991f..4e2b92ddef6f 100644 --- a/drivers/net/ethernet/amd/pds_core/devlink.c +++ b/drivers/net/ethernet/amd/pds_core/devlink.c @@ -56,8 +56,10 @@ int pdsc_dl_enable_set(struct devlink *dl, u32 id, for (vf_id = 0; vf_id < pdsc->num_vfs; vf_id++) { struct pdsc *vf = pdsc->vfs[vf_id].vf; - err = ctx->val.vbool ? pdsc_auxbus_dev_add(vf, pdsc) : - pdsc_auxbus_dev_del(vf, pdsc); + if (ctx->val.vbool) + err = pdsc_auxbus_dev_add(vf, pdsc); + else + pdsc_auxbus_dev_del(vf, pdsc); } return err; From patchwork Sat Mar 1 01:35:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 13997259 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2049.outbound.protection.outlook.com [40.107.93.49]) (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 350253EA83; Sat, 1 Mar 2025 01:37:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740793030; cv=fail; b=SqxEe5XH/qGbKDOx4m6gaxQJMHdgivEbK23kkEqlapeCgzkUNRe3gxpKh9kDgHVAmHYW2wb80hxFEfQhCBVFdY48Z9b+tfwa97ZXKzF57e3fHQlnuk7AbH1oNoL2o+5RJMDeLMH/ATnWumCi4tvdIvpMbj2dhq/ZKpbZYHr57PQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740793030; c=relaxed/simple; bh=kPcqmdqYVZiHfGRts1Jq0/rtxjzGObBRWganL6IYEic=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=b8nLxTf9Br0WWQHtDwX1RHeUeRaysEUFaJqE4zaib2wH2UiKllr9gvNP5U6b4B4K9fOWGpBp7suIv1aWtnljZWQq/b0VfqpOvqwcBY6LKUYVVQmg5cUqzu3Y+3n8dFra9La0FpPv4EDjiNLkRM4S0IhjZqgPLvv0o7QPR9l3gLs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=iFfbl4uj; arc=fail smtp.client-ip=40.107.93.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="iFfbl4uj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ciq7omZZBUKV8zwmT78i6Eqp6AvCH5rNFDJXTvWY+TAIAKLpmmgr3qtRHFVO+Z2PagQeCp9A/41MoczNuPOWutOGbzGNkfqBvCadaEXlydKps4KMyZMnt/jbigOdDByeZT4YDVtlKrJTI0Gw/IU7I91M0N+91iGVp5FxVzC0lCDnFHSwE9MED52POIGdmlJgJXMmp96mqqP+6GsRpYWCoAYt6HZcy5dd90IfyH34cDNM9+9bhTUuKapjyCR5igrvbH6BUrWZWu8eBDIsfX6ywdysxLwYdKHC+RuABK9Tjd7OQgmFxefYFm0a5j3gewo/YQzCVXP1mob+XWL3XXru1g== 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=w8kk36rj6OwE+deFnJBKav+O7cx8pClWxkagblUyr7A=; b=cniUtZpBEmZmgAaHvzBoTQJ6RFecu3KfrCl8tRU27CTY9EN70bHf9/uQxgo7F5jsgbFdSjk9KQqAxHYT2UX69PnBPi3+fOgw01bexy9mOI7z6Xu6rYb77I487LtsEiA+soOOtTmD+42V3M2i4pN3DQm+Spd3mfP1b2pjFq3s5jMIHPLkEzP/lD62p8wVfiAXztlIEggxI8KpjfUkbKlYx2Y+GA8BY6mUcw3jylaLPLLPIJXknn+VGOjCX1oM3PliQx4f2JPcY5p+tKQPyWSECIqJr5NoD7OSSl6HNOp/bwanyg/Xf4IxMRqYpv/mxKI7fQuLec2KrE80S8F+UNUn9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nvidia.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=w8kk36rj6OwE+deFnJBKav+O7cx8pClWxkagblUyr7A=; b=iFfbl4ujM9gQfxieLQwo/Eg31tu7xdS03mQCtaCEIN64IhWuzprR5lxr+MeayIOXYXteMuytP25yrMV8ofpjrtyvYCvOFr7EQqLcj9gy9qprhVyeIEBj9SyGaxB6oZenBL30cdmLoBv7Mw16uNnjRxIWU6DQxPXlzR9yboUpchU= Received: from BYAPR01CA0045.prod.exchangelabs.com (2603:10b6:a03:94::22) by SA0PR12MB4461.namprd12.prod.outlook.com (2603:10b6:806:9c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8489.25; Sat, 1 Mar 2025 01:37:04 +0000 Received: from SJ5PEPF000001EB.namprd05.prod.outlook.com (2603:10b6:a03:94:cafe::e) by BYAPR01CA0045.outlook.office365.com (2603:10b6:a03:94::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8489.22 via Frontend Transport; Sat, 1 Mar 2025 01:37:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ5PEPF000001EB.mail.protection.outlook.com (10.167.242.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8489.16 via Frontend Transport; Sat, 1 Mar 2025 01:37:03 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 28 Feb 2025 19:37:01 -0600 From: Shannon Nelson To: , , , , , , , , , , , , , , , , , , CC: , Shannon Nelson Subject: [PATCH v2 2/6] pds_core: specify auxiliary_device to be created Date: Fri, 28 Feb 2025 17:35:50 -0800 Message-ID: <20250301013554.49511-3-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20250301013554.49511-1-shannon.nelson@amd.com> References: <20250301013554.49511-1-shannon.nelson@amd.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001EB:EE_|SA0PR12MB4461:EE_ X-MS-Office365-Filtering-Correlation-Id: 33aa4081-5173-4e98-0c99-08dd586191d8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|7416014|376014|921020; X-Microsoft-Antispam-Message-Info: 64oEQ5OSYzdEMnxnKSUbSBr6fgLFVklMa2ev6DAY5tLbJzkI0nZk+WI0NvCLJFBNwdG1NQ8wbIDWeiI2hm6fcf84OPRM7vg5+homqL/MxSLoNU8PwJ001Gt5itkM3CHiL2fUaD/8Xs6OZ13Pg50wUp1ab7PQCr4/Zso95EdWgV63fC1XAYrC+fiE3ixRw5wYWrldrTCbXcytNX3JXJk3Vd29F9ioWnDac0JDwWNgrH7QWbzsxe8TrRPLIpmCFYJOaGC5KwIVRv6P2+Hs/6SiNalqWi7idFX5rmFOaFpWEGAnE1Cw0Pn777htDvOkD4mk7C4f5H0ueEef3PIwOmTGU3QStBRt+WoeLDWit4dc99lC96RBZHK2ZlhcLkLmEdKuYNlalC+L5ukb1H9skYIglQhpiNU7WGVqko6xaA1zneXvx4eyypMFqG0k7yV2DaMCebfaI+iX3ebZWm4ikCUKzEDNCY5yMiWycZP8Cb4PKQCotWvmHed6VzqTHgUjapd6Kh5DI80d5d/nMoUwQAvmywpFK34DfqGv4zWwg6ux/svqKEpNkYZLWGIOfrNefU9Ss38sLXQNonwfa19KUIqlFSi+i5aYtiwoCZFSfn0BrDYY6dVIgjJDnliXSmBOuC/0aOCFulQdin4Ge6+/qxu3OULpNQ5qkcCbCggLEw/UyL5rh7mpQ29DR65c3Os0TodtC1RR++nX1qfbTOdm6sQnryz/KWfjkKCErveVNjaEk2y0EKPGEgz1FmLU+PghQIpHrl/u4kVD3YjW1muvdY2arIRSz7ZdTYuIhGCBp3TJhyGvOWsv1yizWsQltemh2SicQ9oOUdKbEghbc8UobhBcXN/Q2xziCcMp6/gPaPYcQ2QsGaibCec2ixuof5B1Dk38HYuS3EyQhovOVHVtSQfEwm1WVP7JjpjBb6eomcZifiJH3RSASBb+vLzkHOkHEofWFGDmr6fkRoDjxSPotfQVCT8ZeWwvpj7f/KriQWFR2HTls4oM9naGLD1rXjpphjWKppa3s7f8JYwHFN3UkbP98cv9RygI+hHA/Ol4zrvGrQssfgyD5g3gT4J4XW1AcGtKohNLr/6Qt6WNLQwU2tAtcYXVwqoasYvyJIuz/CbbJNR5jNSm22Er0nhCuJqcBBb1/2Nkwuti9XWK+jBSM9l+VQxmynIFIYCUHcm5a/RLXx75yM/Sve3VVlJ/ZM2K1VQ2KytLkcIbAlQuvayzvqLUsz7MlBzOtk4D6/PIaS9wpxShhqsVDIND5LA1aWfdtLsLyFyMwIx4gve7+2BISNjtMw4Vs3CgLmzIVoJ3VlTKXcgdLYvkfGyH/9QeBFN7Inhxx+moYeKQtKF+b8qvWVhXV61qvNnTyl+H5U1v6YOsWC4jVF59YMd4oSS1ueZ2lkYOqSuSq6o71xWlUiPMPnCwVssEOBQcZdbyO+7F8zxWKEVMJK3FsSaOXiCH2NhHWAeNMBzWIBRZO03Hn0eTZw6Pz87ywu278ZAmlDfG5Ip1tMk= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(82310400026)(7416014)(376014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2025 01:37:03.6687 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 33aa4081-5173-4e98-0c99-08dd586191d8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001EB.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4461 In preparation for adding a new auxiliary_device for the PF, make the vif type an argument to pdsc_auxbus_dev_add(). We also now pass in the address to where we'll keep the new padev pointer so that the caller can specify where to save it but we can still change it under the mutex and keep the mutex usage within the function. Signed-off-by: Shannon Nelson --- drivers/net/ethernet/amd/pds_core/auxbus.c | 37 ++++++++++----------- drivers/net/ethernet/amd/pds_core/core.h | 7 ++-- drivers/net/ethernet/amd/pds_core/devlink.c | 5 +-- drivers/net/ethernet/amd/pds_core/main.c | 11 +++--- 4 files changed, 33 insertions(+), 27 deletions(-) diff --git a/drivers/net/ethernet/amd/pds_core/auxbus.c b/drivers/net/ethernet/amd/pds_core/auxbus.c index b1fab95f7eeb..db950a9c9d30 100644 --- a/drivers/net/ethernet/amd/pds_core/auxbus.c +++ b/drivers/net/ethernet/amd/pds_core/auxbus.c @@ -175,30 +175,33 @@ static struct pds_auxiliary_dev *pdsc_auxbus_dev_register(struct pdsc *cf, return padev; } -void pdsc_auxbus_dev_del(struct pdsc *cf, struct pdsc *pf) +void pdsc_auxbus_dev_del(struct pdsc *cf, struct pdsc *pf, + struct pds_auxiliary_dev **pd_ptr) { struct pds_auxiliary_dev *padev; + if (!*pd_ptr) + return; + mutex_lock(&pf->config_lock); - padev = pf->vfs[cf->vf_id].padev; - if (padev) { - pds_client_unregister(pf, padev->client_id); - auxiliary_device_delete(&padev->aux_dev); - auxiliary_device_uninit(&padev->aux_dev); - padev->client_id = 0; - } - pf->vfs[cf->vf_id].padev = NULL; + padev = *pd_ptr; + pds_client_unregister(pf, padev->client_id); + auxiliary_device_delete(&padev->aux_dev); + auxiliary_device_uninit(&padev->aux_dev); + padev->client_id = 0; + *pd_ptr = NULL; mutex_unlock(&pf->config_lock); return; } -int pdsc_auxbus_dev_add(struct pdsc *cf, struct pdsc *pf) +int pdsc_auxbus_dev_add(struct pdsc *cf, struct pdsc *pf, + enum pds_core_vif_types vt, + struct pds_auxiliary_dev **pd_ptr) { struct pds_auxiliary_dev *padev; char devname[PDS_DEVNAME_LEN]; - enum pds_core_vif_types vt; unsigned long mask; u16 vt_support; int client_id; @@ -207,6 +210,9 @@ int pdsc_auxbus_dev_add(struct pdsc *cf, struct pdsc *pf) if (!cf) return -ENODEV; + if (vt >= PDS_DEV_TYPE_MAX) + return -EINVAL; + mutex_lock(&pf->config_lock); mask = BIT_ULL(PDSC_S_FW_DEAD) | @@ -218,17 +224,10 @@ int pdsc_auxbus_dev_add(struct pdsc *cf, struct pdsc *pf) goto out_unlock; } - /* We only support vDPA so far, so it is the only one to - * be verified that it is available in the Core device and - * enabled in the devlink param. In the future this might - * become a loop for several VIF types. - */ - /* Verify that the type is supported and enabled. It is not * an error if there is no auxbus device support for this * VF, it just means something else needs to happen with it. */ - vt = PDS_DEV_TYPE_VDPA; vt_support = !!le16_to_cpu(pf->dev_ident.vif_types[vt]); if (!(vt_support && pf->viftype_status[vt].supported && @@ -254,7 +253,7 @@ int pdsc_auxbus_dev_add(struct pdsc *cf, struct pdsc *pf) err = PTR_ERR(padev); goto out_unlock; } - pf->vfs[cf->vf_id].padev = padev; + *pd_ptr = padev; out_unlock: mutex_unlock(&pf->config_lock); diff --git a/drivers/net/ethernet/amd/pds_core/core.h b/drivers/net/ethernet/amd/pds_core/core.h index 631a59cfdd7e..f075e68c64db 100644 --- a/drivers/net/ethernet/amd/pds_core/core.h +++ b/drivers/net/ethernet/amd/pds_core/core.h @@ -303,8 +303,11 @@ void pdsc_health_thread(struct work_struct *work); int pdsc_register_notify(struct notifier_block *nb); void pdsc_unregister_notify(struct notifier_block *nb); void pdsc_notify(unsigned long event, void *data); -int pdsc_auxbus_dev_add(struct pdsc *cf, struct pdsc *pf); -void pdsc_auxbus_dev_del(struct pdsc *cf, struct pdsc *pf); +int pdsc_auxbus_dev_add(struct pdsc *cf, struct pdsc *pf, + enum pds_core_vif_types vt, + struct pds_auxiliary_dev **pd_ptr); +void pdsc_auxbus_dev_del(struct pdsc *cf, struct pdsc *pf, + struct pds_auxiliary_dev **pd_ptr); void pdsc_process_adminq(struct pdsc_qcq *qcq); void pdsc_work_thread(struct work_struct *work); diff --git a/drivers/net/ethernet/amd/pds_core/devlink.c b/drivers/net/ethernet/amd/pds_core/devlink.c index 4e2b92ddef6f..c5c787df61a4 100644 --- a/drivers/net/ethernet/amd/pds_core/devlink.c +++ b/drivers/net/ethernet/amd/pds_core/devlink.c @@ -57,9 +57,10 @@ int pdsc_dl_enable_set(struct devlink *dl, u32 id, struct pdsc *vf = pdsc->vfs[vf_id].vf; if (ctx->val.vbool) - err = pdsc_auxbus_dev_add(vf, pdsc); + err = pdsc_auxbus_dev_add(vf, pdsc, vt_entry->vif_id, + &pdsc->vfs[vf_id].padev); else - pdsc_auxbus_dev_del(vf, pdsc); + pdsc_auxbus_dev_del(vf, pdsc, &pdsc->vfs[vf_id].padev); } return err; diff --git a/drivers/net/ethernet/amd/pds_core/main.c b/drivers/net/ethernet/amd/pds_core/main.c index 660268ff9562..a3a68889137b 100644 --- a/drivers/net/ethernet/amd/pds_core/main.c +++ b/drivers/net/ethernet/amd/pds_core/main.c @@ -190,7 +190,8 @@ static int pdsc_init_vf(struct pdsc *vf) devl_unlock(dl); pf->vfs[vf->vf_id].vf = vf; - err = pdsc_auxbus_dev_add(vf, pf); + err = pdsc_auxbus_dev_add(vf, pf, PDS_DEV_TYPE_VDPA, + &pf->vfs[vf->vf_id].padev); if (err) { devl_lock(dl); devl_unregister(dl); @@ -417,7 +418,7 @@ static void pdsc_remove(struct pci_dev *pdev) pf = pdsc_get_pf_struct(pdsc->pdev); if (!IS_ERR(pf)) { - pdsc_auxbus_dev_del(pdsc, pf); + pdsc_auxbus_dev_del(pdsc, pf, &pf->vfs[pdsc->vf_id].padev); pf->vfs[pdsc->vf_id].vf = NULL; } } else { @@ -482,7 +483,8 @@ static void pdsc_reset_prepare(struct pci_dev *pdev) pf = pdsc_get_pf_struct(pdsc->pdev); if (!IS_ERR(pf)) - pdsc_auxbus_dev_del(pdsc, pf); + pdsc_auxbus_dev_del(pdsc, pf, + &pf->vfs[pdsc->vf_id].padev); } pdsc_unmap_bars(pdsc); @@ -527,7 +529,8 @@ static void pdsc_reset_done(struct pci_dev *pdev) pf = pdsc_get_pf_struct(pdsc->pdev); if (!IS_ERR(pf)) - pdsc_auxbus_dev_add(pdsc, pf); + pdsc_auxbus_dev_add(pdsc, pf, PDS_DEV_TYPE_VDPA, + &pf->vfs[pdsc->vf_id].padev); } } From patchwork Sat Mar 1 01:35:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 13997260 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2044.outbound.protection.outlook.com [40.107.101.44]) (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 0F98E14F117; Sat, 1 Mar 2025 01:37:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740793033; cv=fail; b=kRfJtMAhrFOmJgz2AYNYCbtaGtQPy/4Du31H2BQzft/oCcnd4Y6L1Gdi3GcbAdOwFo1ijwn+9KPgtmzffFM5RLlAx24rydYBRNdVE4CN0qrU4oRTI0R6X7e7QscSWAy51SftlQwHM5Esud5ppmbLXE37eOnmxZvuZ1CPFn/9BR4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740793033; c=relaxed/simple; bh=KqwarlUW7CLTDrhukmLJQujh8LLiTyO2N6CpUqNFfjQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=g1DDkpWZFSB7bNLwB9+LHlrlzTwMSI9xavSNSXQLUXbBvYgI3KrwOxjMSc1w77xKngcISztxU4JCKXQckgvN770KVyu5fR2UXHcrC3tGVUlUS5BoppQPWQqDBiBvFV0zSWB110hVDSaJS1YnyXZJ/4X3OTK+tSChZQBtLEVrPRY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=Y9hvHAPR; arc=fail smtp.client-ip=40.107.101.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Y9hvHAPR" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GM/XNFVv3Hwsq7/zHyqx6KCrYpqItME1yC2yyz3nAQ2O1ETvnbCJZ9QBuDK3OLGPKxfDj+Q1dCCyT0rs5B7DBGsunTh0efb0j+5WvJ3ncRLXoK6kjXWhnWWzUc/cmZs+8lt00kWt/+Axg0MeoY7PrzL6WJcdtUhEza8k//b+LPg1CJWXAU9sriDoGR0NDP031B+srW7tXgsDPS2K5FVVRW3th82E5FM+V9QXvWKQX6PyERBCS16+uVsA8BBVGsn9H94MMPDQZGoqNOOZthDZGcNvg04AW1yOcMVLJDVQ1mhjTq4C+wubxJLU/k6Yz+NFiHtDc2pKekX9cxlHL5edXQ== 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=U0aM42oLwKje/OoZGBOrj1A0HKwfxHx6V3QxAhkvm4c=; b=p52PXABo/ApGIHwK1ejOjfZOSkbdSQIwopQTRN7wbl4Jdmo88muhUnS+ORcFMYC7hahUvh7ha9nM77+rJYUXJT0SzLMstHEeb8NvRG+gGwmbT0F7OrW0lK3gmUocJs7c4LoXZvOuYDoiH9PJmkSJVhn0EpSWP78sj9NBsnhil/H0BZ55z8SCedbEE+0MU2f/8szV55TTgD6fAqvnFfzlZarebiJQXDamVk3paw7UjpCyHZlSvpbHW9XnpGjNRoWBQnwIsPQebQrp+yEwIbLdhnCwZKX+D8/G9NGs425OJNuimTYtR/3ksOb2wZhUdgx6c1mvozS5nLf94XAFj/rLaw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nvidia.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U0aM42oLwKje/OoZGBOrj1A0HKwfxHx6V3QxAhkvm4c=; b=Y9hvHAPRvc+01zN2nwEd6HbaEBXDAXozBfET4ubiWgIROL5DttgwTcjcfPDn71iVaovNmzxvm5DdoEO0C4tT86QgBm4qWsljEygwY2urc8hGVbD8BFnCfQNUR3JzuOe0lCz0L/n4DYFCuNaynUov2EmYXm02qdYs1egHPIrhwtY= Received: from BYAPR06CA0014.namprd06.prod.outlook.com (2603:10b6:a03:d4::27) by PH7PR12MB5949.namprd12.prod.outlook.com (2603:10b6:510:1d8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8489.22; Sat, 1 Mar 2025 01:37:06 +0000 Received: from SJ5PEPF000001ED.namprd05.prod.outlook.com (2603:10b6:a03:d4:cafe::a5) by BYAPR06CA0014.outlook.office365.com (2603:10b6:a03:d4::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8489.22 via Frontend Transport; Sat, 1 Mar 2025 01:37:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ5PEPF000001ED.mail.protection.outlook.com (10.167.242.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8489.16 via Frontend Transport; Sat, 1 Mar 2025 01:37:06 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 28 Feb 2025 19:37:02 -0600 From: Shannon Nelson To: , , , , , , , , , , , , , , , , , , CC: , Shannon Nelson Subject: [PATCH v2 3/6] pds_core: add new fwctl auxiliary_device Date: Fri, 28 Feb 2025 17:35:51 -0800 Message-ID: <20250301013554.49511-4-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20250301013554.49511-1-shannon.nelson@amd.com> References: <20250301013554.49511-1-shannon.nelson@amd.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001ED:EE_|PH7PR12MB5949:EE_ X-MS-Office365-Filtering-Correlation-Id: f9e160bc-234e-45ec-80fc-08dd5861934a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|1800799024|7416014|376014|921020; X-Microsoft-Antispam-Message-Info: RbbbNlNpW0WuYFxZIBGqvxWOyOBk4Ma97P4QFKxPg41T3SJvJ97JW1bV79Tlf++CCxIbSWhoJ6SZWm+bsHl5HijbrkqjOxDJJ9VtTWcDvMNZybHcw/h5FnSORyDjlCjSZfAQSAGM+C7fSaol7hRFRuPijz+Xs6D9toe0acpNTKhFXI2iTuwS6uoeKpNyqMLCADBEppF57rIEW7VXoGQHvkHb+KVbZAjvJqb4pmLv/Gjpqmmz56FhLbXL4qjL34j47L5sMsGIhW+ZW4ef26Q53tP9XyB2UplQqRSb6y1aljV7RRRNbE5B1gDzytH4xncEOrGlMA6A41RlvXNHHCF35nzIS8d3w1DrOc8vZK+qGeWVSjKllNgU4AC16ywPATvh770RGfKngKbsKtqtxYW66Qdpe6NuVx/ASuNGgjnUSjU8DkaXC0S7hruLcJe10jpquvBPDWfw/sBWatpP2fS4ljqHcCuCj/XID0RS/gLUw4ih1fNwvrBUQlnRhzVCU9qVc3Q7zUh70NWGgfStp7evgYngY5osLGQmx1bhaK6XvZ0di4f7Q44LtpqdUhnXsHXoJ+Lg9UDv4Zs1Aqi5vcXoVxpkW9Cow8X3r9LuhDUkJttvmXye4w/l2fZ9O2s96ts2yqILPctgGBHnrV1t4wyi7/Wd+9fJN6iy3jXqUo9xxelfhQe8BV3Ly4Ss+bJNo2uZ4hhqZwiFd6/hzO1qR3jkrTu9imR7j235o+Kqt0S9ZgjDDZssEP52MDzMB7zw/S0MVgdMDnMpUB3Cau7zPI7UHq9V1/P8Y3t15WwlWCMeQjb9U6nCFHi+VHkEdPe7UUlTHr0D6WTjx2a5M/7gVDIPXQqtpfqIKclmUYMAJwt0Ym+uTFPOsgCp9fHVnukQ5ucwyh63qO0y5+nG62Ml/2lCifMNZ9LWbBPKaW/izoQELUtC3kkOSz61V9HijYJnOLRR1jN1w4dgKnPrQkZBCyv9nsGeAip4AXAXMBMyY+tak6WIUq67ppSDrXkdJX7zO/xdpQQZGlPPhli2QhXd2sdC7IDWjcFQ88Y7uGQ1cwEEx9V+XCGCE7tccOJMY6ZWBuYLkhvY0qrHJyCgTxtpygDJbyQnkNjrczCMXBCLz79zI7HBCz/9BX/8gVLC+6+bya83Q3Wq/Y/LS5xB6H2DHenp55gUkgb6C/6w2saTCs0bQzldK8/C/5jFjsQioi0ZaY96bQ5eVgTzzhca7xoqA2MPRcVDLeGw7jWNt27d8We3/wtMuQQALcdXTGKGKSjZHiHIckdRwZL76qmQsgY42W9eEcK55BQOm7qgPz6KscmKHDsDQmwMDCZrO6wDSrhq/TmJKpqZvvBI6lEtm1psboo5MVPkLQ+H1gGUoSDS55g2GQ0gRXAfylozQMqTB3gVW/e1LYnAcC1heuegotWCK8jmKQH68mGPiON6xOaZfGgTiGPfgK6LPbiNj9AtrlmkHTzIWTdn99olStQEinnnmilcnh5Yk0YGL/iM+CrzfxW3u42eMgn+gT6TZlg6efvMdmfg X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(1800799024)(7416014)(376014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2025 01:37:06.0965 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f9e160bc-234e-45ec-80fc-08dd5861934a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001ED.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5949 Add support for a new fwctl-based auxiliary_device for creating a channel for fwctl support into the AMD/Pensando DSC. Signed-off-by: Shannon Nelson --- drivers/net/ethernet/amd/pds_core/auxbus.c | 3 +-- drivers/net/ethernet/amd/pds_core/core.c | 7 +++++++ drivers/net/ethernet/amd/pds_core/core.h | 1 + drivers/net/ethernet/amd/pds_core/main.c | 11 +++++++++++ include/linux/pds/pds_common.h | 2 ++ 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/amd/pds_core/auxbus.c b/drivers/net/ethernet/amd/pds_core/auxbus.c index db950a9c9d30..ac6f76c161f2 100644 --- a/drivers/net/ethernet/amd/pds_core/auxbus.c +++ b/drivers/net/ethernet/amd/pds_core/auxbus.c @@ -225,8 +225,7 @@ int pdsc_auxbus_dev_add(struct pdsc *cf, struct pdsc *pf, } /* Verify that the type is supported and enabled. It is not - * an error if there is no auxbus device support for this - * VF, it just means something else needs to happen with it. + * an error if there is no auxbus device support. */ vt_support = !!le16_to_cpu(pf->dev_ident.vif_types[vt]); if (!(vt_support && diff --git a/drivers/net/ethernet/amd/pds_core/core.c b/drivers/net/ethernet/amd/pds_core/core.c index 536635e57727..1eb0d92786f7 100644 --- a/drivers/net/ethernet/amd/pds_core/core.c +++ b/drivers/net/ethernet/amd/pds_core/core.c @@ -402,6 +402,9 @@ static int pdsc_core_init(struct pdsc *pdsc) } static struct pdsc_viftype pdsc_viftype_defaults[] = { + [PDS_DEV_TYPE_FWCTL] = { .name = PDS_DEV_TYPE_FWCTL_STR, + .vif_id = PDS_DEV_TYPE_FWCTL, + .dl_id = -1 }, [PDS_DEV_TYPE_VDPA] = { .name = PDS_DEV_TYPE_VDPA_STR, .vif_id = PDS_DEV_TYPE_VDPA, .dl_id = DEVLINK_PARAM_GENERIC_ID_ENABLE_VNET }, @@ -428,6 +431,10 @@ static int pdsc_viftypes_init(struct pdsc *pdsc) /* See what the Core device has for support */ vt_support = !!le16_to_cpu(pdsc->dev_ident.vif_types[vt]); + + if (vt == PDS_DEV_TYPE_FWCTL) + pdsc->viftype_status[vt].enabled = true; + dev_dbg(pdsc->dev, "VIF %s is %ssupported\n", pdsc->viftype_status[vt].name, vt_support ? "" : "not "); diff --git a/drivers/net/ethernet/amd/pds_core/core.h b/drivers/net/ethernet/amd/pds_core/core.h index f075e68c64db..0bf320c43083 100644 --- a/drivers/net/ethernet/amd/pds_core/core.h +++ b/drivers/net/ethernet/amd/pds_core/core.h @@ -156,6 +156,7 @@ struct pdsc { struct dentry *dentry; struct device *dev; struct pdsc_dev_bar bars[PDS_CORE_BARS_MAX]; + struct pds_auxiliary_dev *padev; struct pdsc_vf *vfs; int num_vfs; int vf_id; diff --git a/drivers/net/ethernet/amd/pds_core/main.c b/drivers/net/ethernet/amd/pds_core/main.c index a3a68889137b..41575c7a148d 100644 --- a/drivers/net/ethernet/amd/pds_core/main.c +++ b/drivers/net/ethernet/amd/pds_core/main.c @@ -265,6 +265,10 @@ static int pdsc_init_pf(struct pdsc *pdsc) mutex_unlock(&pdsc->config_lock); + err = pdsc_auxbus_dev_add(pdsc, pdsc, PDS_DEV_TYPE_FWCTL, &pdsc->padev); + if (err) + goto err_out_stop; + dl = priv_to_devlink(pdsc); devl_lock(dl); err = devl_params_register(dl, pdsc_dl_params, @@ -297,6 +301,7 @@ static int pdsc_init_pf(struct pdsc *pdsc) devlink_params_unregister(dl, pdsc_dl_params, ARRAY_SIZE(pdsc_dl_params)); err_out_stop: + pdsc_auxbus_dev_del(pdsc, pdsc, &pdsc->padev); pdsc_stop(pdsc); err_out_teardown: pdsc_teardown(pdsc, PDSC_TEARDOWN_REMOVING); @@ -427,6 +432,7 @@ static void pdsc_remove(struct pci_dev *pdev) * shut themselves down. */ pdsc_sriov_configure(pdev, 0); + pdsc_auxbus_dev_del(pdsc, pdsc, &pdsc->padev); timer_shutdown_sync(&pdsc->wdtimer); if (pdsc->wq) @@ -485,6 +491,8 @@ static void pdsc_reset_prepare(struct pci_dev *pdev) if (!IS_ERR(pf)) pdsc_auxbus_dev_del(pdsc, pf, &pf->vfs[pdsc->vf_id].padev); + } else { + pdsc_auxbus_dev_del(pdsc, pdsc, &pdsc->padev); } pdsc_unmap_bars(pdsc); @@ -531,6 +539,9 @@ static void pdsc_reset_done(struct pci_dev *pdev) if (!IS_ERR(pf)) pdsc_auxbus_dev_add(pdsc, pf, PDS_DEV_TYPE_VDPA, &pf->vfs[pdsc->vf_id].padev); + } else { + pdsc_auxbus_dev_add(pdsc, pdsc, PDS_DEV_TYPE_FWCTL, + &pdsc->padev); } } diff --git a/include/linux/pds/pds_common.h b/include/linux/pds/pds_common.h index 5802e1deef24..b193adbe7cc3 100644 --- a/include/linux/pds/pds_common.h +++ b/include/linux/pds/pds_common.h @@ -29,6 +29,7 @@ enum pds_core_vif_types { PDS_DEV_TYPE_ETH = 3, PDS_DEV_TYPE_RDMA = 4, PDS_DEV_TYPE_LM = 5, + PDS_DEV_TYPE_FWCTL = 6, /* new ones added before this line */ PDS_DEV_TYPE_MAX = 16 /* don't change - used in struct size */ @@ -40,6 +41,7 @@ enum pds_core_vif_types { #define PDS_DEV_TYPE_ETH_STR "Eth" #define PDS_DEV_TYPE_RDMA_STR "RDMA" #define PDS_DEV_TYPE_LM_STR "LM" +#define PDS_DEV_TYPE_FWCTL_STR "fwctl" #define PDS_VDPA_DEV_NAME PDS_CORE_DRV_NAME "." PDS_DEV_TYPE_VDPA_STR #define PDS_VFIO_LM_DEV_NAME PDS_CORE_DRV_NAME "." PDS_DEV_TYPE_LM_STR "." PDS_DEV_TYPE_VFIO_STR From patchwork Sat Mar 1 01:35:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 13997261 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2058.outbound.protection.outlook.com [40.107.237.58]) (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 2638B14F11E; Sat, 1 Mar 2025 01:37:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740793034; cv=fail; b=sWnkLUjUebNz2cBL7cyD65FbMFprq3XDwVYsejL2vFo/iEXjFuhKynz6JqCxfYqyQMSJdzYCWEiSHT6hh0a9FTKaYaS4+fNW4t5rzhuMG8QHxjStWtY4aPwAZrqrfOMn5w2F8Yq2zmn9DnO7MwZ/3eu+AXDPsn83yyeFyU62jio= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740793034; c=relaxed/simple; bh=CS16NNCN+l+5VXz3hnOdTOFWmbhMlyEzH6qGvXPgHu0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aVT33Wo7JQQyGKZYYR7j865+ypwOg9yhFrvVw3MBqycYB3BKFb8KcYPVeyNppLg41/QmeMQwPP6FIC1AWs/iQq5kKW0mWrYhHw2AWG1ziA6JQVHJLrbsfaqX5n7xorBl6zSQwqtJA6Mah1L80jbKxnGCLL7Prp+rnHcQd3AZj1Y= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=o97HbJK3; arc=fail smtp.client-ip=40.107.237.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="o97HbJK3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tIhwuKnD0KY4+7OxOdNWm0qP6pjIkpyaqk+25RU8+MkJAUPwPZa5hASPI9O5/95OGp71HdJrrPxrLCt5laJgpjILpmJdGpKJ3s2mZGn9Mg0gTw/ypmc747mNkQmslp1nx8TqAHgmnrzDGAYoUkN+gJ07qEmvUqRK4PkUFvjGZovarxS7t9AyIAiFGoIKRpZKcL2PjvKmAnLLoeIBw/lYyiUd6qQylqvf3Cdto5qqIKNTiODiPYUOAgq8Ts/l9uoK/3lLmHiNpPFoBxc8fg+j/GxlE4Bbuf01zyEscC5MCyQO6rEfMtFmoKVzoWPFlP/Gcz4canK5/5YDhz1DKttEHA== 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=yVzIar3JZghH5aECOcgFIQevgIfTEY51M1qE3c8WLP4=; b=Az2MJBPRgTNaEhVi9TOgSO7gVi/4PxLO8xAVdZXM8kWZP0H1MiFytvWBHcTLzIC3EqGocEBCyzZox3bRjjvBesM9NIy5wtxFDHBQPk1OWAdwPpTYZP4BDUblHyaU9k1qxcQV4dP6+3VtpZx8cRMScpi6ssx+yQVvNfI3m5ba1FeirQqAmvHNSV6aM1TVmCcjOo6RgoacxPmzPZ45so2vw2aCQ+geceKf5BgDdHfJoorp3uiG/1v72RB4RH/QoYDJ6neifwxkyWb3nFld1+qbe7S2/IF3bGnxRMOUBP/Ss8iqYkkzHxfn2pOV2EQgV4v5H5o4V92Z4I4H/DwafJtuZw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nvidia.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yVzIar3JZghH5aECOcgFIQevgIfTEY51M1qE3c8WLP4=; b=o97HbJK3vKKcosbTe1Mf4GM7JfhBXVTLKnY/KiliWEB76KV3y6ahxfEL5tzTmLyA8vk6sWKQPHnm4hpDnUkGea7XOQNeqMRDjNf4H6RsgPg7tRhb6gZlVE21Q97Eyi/yviF7nZU1uYWCmrt+wpi1CY/PkA7PXhoNwM+rLbUeZ3Y= Received: from BYAPR06CA0002.namprd06.prod.outlook.com (2603:10b6:a03:d4::15) by DS0PR12MB9324.namprd12.prod.outlook.com (2603:10b6:8:1b6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8489.22; Sat, 1 Mar 2025 01:37:07 +0000 Received: from SJ5PEPF000001ED.namprd05.prod.outlook.com (2603:10b6:a03:d4:cafe::5) by BYAPR06CA0002.outlook.office365.com (2603:10b6:a03:d4::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8489.22 via Frontend Transport; Sat, 1 Mar 2025 01:37:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ5PEPF000001ED.mail.protection.outlook.com (10.167.242.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8489.16 via Frontend Transport; Sat, 1 Mar 2025 01:37:07 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 28 Feb 2025 19:37:04 -0600 From: Shannon Nelson To: , , , , , , , , , , , , , , , , , , CC: , Shannon Nelson Subject: [PATCH v2 4/6] pds_fwctl: initial driver framework Date: Fri, 28 Feb 2025 17:35:52 -0800 Message-ID: <20250301013554.49511-5-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20250301013554.49511-1-shannon.nelson@amd.com> References: <20250301013554.49511-1-shannon.nelson@amd.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001ED:EE_|DS0PR12MB9324:EE_ X-MS-Office365-Filtering-Correlation-Id: e8fdcf45-cbb1-4356-db64-08dd58619406 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|30052699003|376014|7416014|921020; X-Microsoft-Antispam-Message-Info: /m3ZAy61oYsEhpvzmp6RvrlgguLS91bfMF7kAe5dSM4m9vy2Igo/tnGIa7NKgYzsQEXR6Bmxe28O+8bS/pRt6VmppktOeETEYE9wnK6usysCrXXiP1F+/lb8MEyw+8kjTXWO5qPDJl7B6olP6OJRz352sE11oR0j9mqU4gUAumFoW1sRG7aJK+zw2QJhI+X+iS3oJCxDBIiC3y/ltG+HHjtRKnHt5+/2p0bswOs+S0x0pHw49CplFOufzn/cEdKYfaonMyB2TfLXR7BuOz6tAeJHJzYIWdXCcpJ78MUJmspZIEn6r8ULrEMQVD+UCMl93ebEEqC97wweTwPAWLWRZZh/hx4Ij5VWzcAbYoh8dRFEPclMkuC4aJxRAoqR+swCHgVAEXloJy8xIejGzRGtsSD4SHp4acz69HxeLZimTjB5V2dzylx8+VFhoJW79ab8NvkuGbfEYaLJt4eGTqpJxhtr6y32oeVmKU6Db8tr7w3gMmpxrYx8o4IrVWfJtcCkgTCiiotVQHcNV3PBeRAt9904Bp/NPoTu97GPgXdzCfgigaQ5nmTnnhUzipx+rUp8qG4drsZF4pAvheEx7OFoqPXMzaTDXJmPAlUSGNx3rWnEzzUGsTXIqA7yT3FEMzKmmTNrrf3pUmNDspoQ9gkc+0CO03wqt0mb3i/LJqzWtC8ivl5Ox/s2Prky+BjM3/f0w+O1fqjyTeD1S5EzNuFf8VEcbtm+QsSua5k77Dqbkw4/6v3g5SYmAmjqW+CUtBJh2U368kBqAb3tVgkzvd36QgifWMCJ4bsQ4yuTuhIjU34nHJ4LPWPoyH1xLCpKLF0ddbsO/GP89llBcW7GBcn2bOgxA19jvZT60kO3oSrwITJqxSQWD1UV5j07so094e+1N0BxvjMcI2GqaaD8+StiZ/0eHQk52CO91T9UFEgLgdBo+IdZMoH1ebm579HYTwDVS5r8i7/JL2Z8hfImFPyL+w1CxphL+B5tKE+03UOSlm76+BNFbTfnlDAQAIOeQjmzmDChGWG1UjwAMLYxdPtEg8O/OAuBb6VSwl3XvZPPdcHKKyXPTt++lxRhyHSUJsCVyEtdhHGOOUpkG3w1a/oNyc2a0350vtTvfAUvEdDjxO/+jx+TMDC1B+zp4ULKh7TVZWDmGqQ4XA+e18IeJf6nGoCYNJOkugPxqGXf0Efuz0GlNid18I4xrymUGI9q7uo+qUgXVgcbc3qUfPaUfyCCKzBB+6/Dkpiq5Ry/on+A5YMsB0UgWzJS6QJjVE6DaoDRKV6bOzahV3RGXbcDDBeWLJ6mUp/35iYD9g0xPrSupOVF09AhADeXxQ7WlbOlYsSHgaySlhT8NFgxWrtTgFPoiASb1guwowPKENt30LgBtp7ULsbjYaJIrd27eoKCPY3ozjEHqiOZH5pWlRJjPhxPtvt7+yKZ96vFKvxyWFNzL0pcW8Yiod59Y8y1ZePwyed3IfremjIQiQy2d8svwWdUAx4ezQmMsQfhMMCzLJNZCi+AT0hFu0vP4ublYd2+kouF X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(82310400026)(30052699003)(376014)(7416014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2025 01:37:07.3309 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e8fdcf45-cbb1-4356-db64-08dd58619406 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001ED.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB9324 Initial files for adding a new fwctl driver for the AMD/Pensando PDS devices. This sets up a simple auxiliary_bus driver that registers with fwctl subsystem. It expects that a pds_core device has set up the auxiliary_device pds_core.fwctl Signed-off-by: Shannon Nelson --- MAINTAINERS | 7 ++ drivers/fwctl/Kconfig | 10 ++ drivers/fwctl/Makefile | 1 + drivers/fwctl/pds/Makefile | 4 + drivers/fwctl/pds/main.c | 169 +++++++++++++++++++++++++++++++++ include/linux/pds/pds_adminq.h | 77 +++++++++++++++ include/uapi/fwctl/fwctl.h | 1 + include/uapi/fwctl/pds.h | 27 ++++++ 8 files changed, 296 insertions(+) create mode 100644 drivers/fwctl/pds/Makefile create mode 100644 drivers/fwctl/pds/main.c create mode 100644 include/uapi/fwctl/pds.h diff --git a/MAINTAINERS b/MAINTAINERS index 7d2700d1ba0f..a396726feb6f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9601,6 +9601,13 @@ T: git git://linuxtv.org/media.git F: Documentation/devicetree/bindings/media/i2c/galaxycore,gc2145.yaml F: drivers/media/i2c/gc2145.c +FWCTL PDS DRIVER +M: Brett Creeley +R: Shannon Nelson +L: linux-kernel@vger.kernel.org +S: Maintained +F: drivers/fwctl/pds/ + GATEWORKS SYSTEM CONTROLLER (GSC) DRIVER M: Tim Harvey S: Maintained diff --git a/drivers/fwctl/Kconfig b/drivers/fwctl/Kconfig index 0a542a247303..df87ce5bd8aa 100644 --- a/drivers/fwctl/Kconfig +++ b/drivers/fwctl/Kconfig @@ -28,5 +28,15 @@ config FWCTL_MLX5 This will allow configuration and debug tools to work out of the box on mainstream kernel. + If you don't know what to do here, say N. + +config FWCTL_PDS + tristate "AMD/Pensando pds fwctl driver" + depends on PDS_CORE + help + The pds_fwctl driver provides an fwctl interface for a user process + to access the debug and configuration information of the AMD/Pensando + DSC hardware family. + If you don't know what to do here, say N. endif diff --git a/drivers/fwctl/Makefile b/drivers/fwctl/Makefile index 5fb289243286..692e4b8d7beb 100644 --- a/drivers/fwctl/Makefile +++ b/drivers/fwctl/Makefile @@ -2,4 +2,5 @@ obj-$(CONFIG_FWCTL) += fwctl.o obj-$(CONFIG_FWCTL_MLX5) += mlx5/ +obj-$(CONFIG_FWCTL_PDS) += pds/ fwctl-y += main.o diff --git a/drivers/fwctl/pds/Makefile b/drivers/fwctl/pds/Makefile new file mode 100644 index 000000000000..c14cba128e3b --- /dev/null +++ b/drivers/fwctl/pds/Makefile @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause +obj-$(CONFIG_FWCTL_PDS) += pds_fwctl.o + +pds_fwctl-y += main.o diff --git a/drivers/fwctl/pds/main.c b/drivers/fwctl/pds/main.c new file mode 100644 index 000000000000..afc7dc283ad5 --- /dev/null +++ b/drivers/fwctl/pds/main.c @@ -0,0 +1,169 @@ +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause +/* Copyright(c) Advanced Micro Devices, Inc */ + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +struct pdsfc_uctx { + struct fwctl_uctx uctx; + u32 uctx_caps; + u32 uctx_uid; +}; + +struct pdsfc_dev { + struct fwctl_device fwctl; + struct pds_auxiliary_dev *padev; + struct pdsc *pdsc; + u32 caps; + struct pds_fwctl_ident ident; +}; +DEFINE_FREE(pdsfc_dev, struct pdsfc_dev *, if (_T) fwctl_put(&_T->fwctl)); + +static int pdsfc_open_uctx(struct fwctl_uctx *uctx) +{ + struct pdsfc_dev *pdsfc = container_of(uctx->fwctl, struct pdsfc_dev, fwctl); + struct pdsfc_uctx *pdsfc_uctx = container_of(uctx, struct pdsfc_uctx, uctx); + + pdsfc_uctx->uctx_caps = pdsfc->caps; + + return 0; +} + +static void pdsfc_close_uctx(struct fwctl_uctx *uctx) +{ +} + +static void *pdsfc_info(struct fwctl_uctx *uctx, size_t *length) +{ + struct pdsfc_uctx *pdsfc_uctx = container_of(uctx, struct pdsfc_uctx, uctx); + struct fwctl_info_pds *info; + + info = kzalloc(sizeof(*info), GFP_KERNEL); + if (!info) + return ERR_PTR(-ENOMEM); + + info->uctx_caps = pdsfc_uctx->uctx_caps; + + return info; +} + +static int pdsfc_identify(struct pdsfc_dev *pdsfc) +{ + struct device *dev = &pdsfc->fwctl.dev; + union pds_core_adminq_comp comp = {0}; + union pds_core_adminq_cmd cmd; + struct pds_fwctl_ident *ident; + dma_addr_t ident_pa; + int err = 0; + + ident = dma_alloc_coherent(dev->parent, sizeof(*ident), &ident_pa, GFP_KERNEL); + err = dma_mapping_error(dev->parent, ident_pa); + if (err) { + dev_err(dev, "Failed to map ident buffer\n"); + return err; + } + + cmd = (union pds_core_adminq_cmd) { + .fwctl_ident = { + .opcode = PDS_FWCTL_CMD_IDENT, + .version = 0, + .len = cpu_to_le32(sizeof(*ident)), + .ident_pa = cpu_to_le64(ident_pa), + } + }; + + err = pds_client_adminq_cmd(pdsfc->padev, &cmd, sizeof(cmd), &comp, 0); + if (err) + dev_err(dev, "Failed to send adminq cmd opcode: %u err: %d\n", + cmd.fwctl_ident.opcode, err); + else + pdsfc->ident = *ident; + + dma_free_coherent(dev->parent, sizeof(*ident), ident, ident_pa); + + return 0; +} + +static void *pdsfc_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope, + void *in, size_t in_len, size_t *out_len) +{ + return NULL; +} + +static const struct fwctl_ops pdsfc_ops = { + .device_type = FWCTL_DEVICE_TYPE_PDS, + .uctx_size = sizeof(struct pdsfc_uctx), + .open_uctx = pdsfc_open_uctx, + .close_uctx = pdsfc_close_uctx, + .info = pdsfc_info, + .fw_rpc = pdsfc_fw_rpc, +}; + +static int pdsfc_probe(struct auxiliary_device *adev, + const struct auxiliary_device_id *id) +{ + struct pds_auxiliary_dev *padev = + container_of(adev, struct pds_auxiliary_dev, aux_dev); + struct pdsfc_dev *pdsfc __free(pdsfc_dev) = + fwctl_alloc_device(&padev->vf_pdev->dev, &pdsfc_ops, + struct pdsfc_dev, fwctl); + struct device *dev = &adev->dev; + int err; + + if (!pdsfc) { + dev_err(dev, "Failed to allocate fwctl device struct\n"); + return -ENOMEM; + } + pdsfc->padev = padev; + + err = pdsfc_identify(pdsfc); + if (err) + return dev_err_probe(dev, err, "Failed to identify device\n"); + + err = fwctl_register(&pdsfc->fwctl); + if (err) + return dev_err_probe(dev, err, "Failed to register device\n"); + + auxiliary_set_drvdata(adev, no_free_ptr(pdsfc)); + + return 0; +} + +static void pdsfc_remove(struct auxiliary_device *adev) +{ + struct pdsfc_dev *pdsfc __free(pdsfc_dev) = auxiliary_get_drvdata(adev); + + fwctl_unregister(&pdsfc->fwctl); +} + +static const struct auxiliary_device_id pdsfc_id_table[] = { + {.name = PDS_CORE_DRV_NAME "." PDS_DEV_TYPE_FWCTL_STR }, + {} +}; +MODULE_DEVICE_TABLE(auxiliary, pdsfc_id_table); + +static struct auxiliary_driver pdsfc_driver = { + .name = "pds_fwctl", + .probe = pdsfc_probe, + .remove = pdsfc_remove, + .id_table = pdsfc_id_table, +}; + +module_auxiliary_driver(pdsfc_driver); + +MODULE_IMPORT_NS("FWCTL"); +MODULE_DESCRIPTION("pds fwctl driver"); +MODULE_AUTHOR("Shannon Nelson "); +MODULE_AUTHOR("Brett Creeley "); +MODULE_LICENSE("Dual BSD/GPL"); diff --git a/include/linux/pds/pds_adminq.h b/include/linux/pds/pds_adminq.h index 4b4e9a98b37b..ae6886ebc841 100644 --- a/include/linux/pds/pds_adminq.h +++ b/include/linux/pds/pds_adminq.h @@ -1179,6 +1179,78 @@ struct pds_lm_host_vf_status_cmd { u8 status; }; +enum pds_fwctl_cmd_opcode { + PDS_FWCTL_CMD_IDENT = 70, +}; + +/** + * struct pds_fwctl_cmd - Firmware control command structure + * @opcode: Opcode + * @rsvd: Word boundary padding + * @ep: Endpoint identifier. + * @op: Operation identifier. + */ +struct pds_fwctl_cmd { + u8 opcode; + u8 rsvd[3]; + __le32 ep; + __le32 op; +} __packed; + +/** + * struct pds_fwctl_comp - Firmware control completion structure + * @status: Status of the firmware control operation + * @rsvd: Word boundary padding + * @comp_index: Completion index in little-endian format + * @rsvd2: Word boundary padding + * @color: Color bit indicating the state of the completion + */ +struct pds_fwctl_comp { + u8 status; + u8 rsvd; + __le16 comp_index; + u8 rsvd2[11]; + u8 color; +} __packed; + +/** + * struct pds_fwctl_ident_cmd - Firmware control identification command structure + * @opcode: Operation code for the command + * @rsvd: Word boundary padding + * @version: Interface version + * @rsvd2: Word boundary padding + * @len: Length of the identification data + * @ident_pa: Physical address of the identification data + */ +struct pds_fwctl_ident_cmd { + u8 opcode; + u8 rsvd; + u8 version; + u8 rsvd2; + __le32 len; + __le64 ident_pa; +} __packed; + +/** + * struct pds_fwctl_ident - Firmware control identification structure + * @features: Supported features + * @version: Interface version + * @rsvd: Word boundary padding + * @max_req_sz: Maximum request size + * @max_resp_sz: Maximum response size + * @max_req_sg_elems: Maximum number of request SGs + * @max_resp_sg_elems: Maximum number of response SGs + */ +struct pds_fwctl_ident { + __le64 features; + u8 version; + u8 rsvd[3]; + __le32 max_req_sz; + __le32 max_resp_sz; + u8 max_req_sg_elems; + u8 max_resp_sg_elems; +} __packed; + union pds_core_adminq_cmd { u8 opcode; u8 bytes[64]; @@ -1216,6 +1288,9 @@ union pds_core_adminq_cmd { struct pds_lm_dirty_enable_cmd lm_dirty_enable; struct pds_lm_dirty_disable_cmd lm_dirty_disable; struct pds_lm_dirty_seq_ack_cmd lm_dirty_seq_ack; + + struct pds_fwctl_cmd fwctl; + struct pds_fwctl_ident_cmd fwctl_ident; }; union pds_core_adminq_comp { @@ -1243,6 +1318,8 @@ union pds_core_adminq_comp { struct pds_lm_state_size_comp lm_state_size; struct pds_lm_dirty_status_comp lm_dirty_status; + + struct pds_fwctl_comp fwctl; }; #ifndef __CHECKER__ diff --git a/include/uapi/fwctl/fwctl.h b/include/uapi/fwctl/fwctl.h index 518f054f02d2..a884e9f6dc2c 100644 --- a/include/uapi/fwctl/fwctl.h +++ b/include/uapi/fwctl/fwctl.h @@ -44,5 +44,6 @@ enum fwctl_device_type { FWCTL_DEVICE_TYPE_ERROR = 0, FWCTL_DEVICE_TYPE_MLX5 = 1, + FWCTL_DEVICE_TYPE_PDS = 4, }; /** diff --git a/include/uapi/fwctl/pds.h b/include/uapi/fwctl/pds.h new file mode 100644 index 000000000000..a01b032cbdb1 --- /dev/null +++ b/include/uapi/fwctl/pds.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* Copyright(c) Advanced Micro Devices, Inc */ + +/* + * fwctl interface info for pds_fwctl + */ + +#ifndef _UAPI_FWCTL_PDS_H_ +#define _UAPI_FWCTL_PDS_H_ + +#include + +/* + * struct fwctl_info_pds + * + * Return basic information about the FW interface available. + */ +struct fwctl_info_pds { + __u32 uid; + __u32 uctx_caps; +}; + +enum pds_fwctl_capabilities { + PDS_FWCTL_QUERY_CAP = 0, + PDS_FWCTL_SEND_CAP, +}; +#endif /* _UAPI_FWCTL_PDS_H_ */ From patchwork Sat Mar 1 01:35:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 13997263 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2070.outbound.protection.outlook.com [40.107.212.70]) (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 DC02D18DB24; Sat, 1 Mar 2025 01:37:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740793037; cv=fail; b=fPtYxOLiGX5gUzYVBZbp7nM0EJYx+CarLzAbB2U8+z3m0Av7Gs0ew5tfm36HIqG1n4U2H9Vwrez05nyBnPsRqO4HpzfC+ZkGUso4QtuDK8Ta+yiMPD6xpHBAaz/pg01bQcO/l8jqM/RYadzF0jir2ze9uhdLWzHHtM2m25Q79qk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740793037; c=relaxed/simple; bh=Q64pr+JiltuWlwnDW85+vBt1FeGkuI27mJ0Ey94yZSo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ozZIlRXraawbu0FzEHJ8TrrWc1R6pwvqNRyqQxWwYcBcni+dfZhiobf7GhiGjVK7BbQDlbedrujYRe97Y7SPWY2ng8PRQJbd7Sd2y1OU1U4fYRNox18AZeuMOOy+vAeSwwTDepPCBj7aHqKfw9eEzFPxDcWYac6L56rRPC0a+BA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=G5AlhSOQ; arc=fail smtp.client-ip=40.107.212.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="G5AlhSOQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iUAAKmSi2veAf3RE3lyc15kHvQNuRTSflUbWHz5vnRZ0R5RW8nc/QCnxtbjAqtTBjArL9g9Hmwdv+4T7nPaIhImM8Jo5stcFw7lxphvr81z6keVixcmcP3vaX/DJ++GO3p+uRyTZJwOc+s1Ab4nolgV2eVoEmGDVoKSQPu4+SJpHfbts72eXMjCu8pCsbQ/wlgq3qV2VbLjSo1vOcMKOgPJ3Qjql92vKY5+vzPsAXfocgZl2coXEDuya2HGRGth+sDuS7XYPl6qiHqiDVvdrFT7KcU9T1y2+WVsICWhcbwycJ72BlOqbq0upQHPQhtQQLJtG1ImPsogQPGDBtfJ+xQ== 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=dGuegh5toK3BdGPMRHTxXMojx1MfXCaGLC24/108eEo=; b=tSF1WijwxXo+XjJ+WjvkLjF8xfkE3acg15/ns+8MfifVo6DvsPPgeHyY/Y0qpWc79LTqjEwyEGfbC4aKM6zbjX1VKlX7mHByx8QZB57cVC7694CNAh5nEod+G5IdqkpmDwcNONna8sXDmh92u8EHhlTcUoUSSzEqjVOvZrhv+/zzJNt+Ea4GT6ogkwcYtJtndwpWFsVJ8aSS07FF0ft86a1AEdD1a4lAqOOE786oQxCc+4ZwcVnCVVsBigrciCDnKEHwehhA3LROfMQx4dEigiieGULb/wxdJuKWx68L3IdrRT6LA2xvhadCwmO1VWdf129f1OI4s+AlIXKZrZbmsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nvidia.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dGuegh5toK3BdGPMRHTxXMojx1MfXCaGLC24/108eEo=; b=G5AlhSOQGdvGrSBz3ANkK+C+Q1d3RabQBRc8tnTgfIddFiimHzNqK33LLs7Zr9DgjJra69NsMvKat6siB9bi3JoZ+IBK5W2yrVqu5WaB+ngeIvl+u/401c/Hb4q3OLhZLSm7r19UMR5gDBV2zUnwi6nZzkT7SXTL5Tt++euxczs= Received: from BYAPR06CA0017.namprd06.prod.outlook.com (2603:10b6:a03:d4::30) by MN2PR12MB4342.namprd12.prod.outlook.com (2603:10b6:208:264::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8489.25; Sat, 1 Mar 2025 01:37:08 +0000 Received: from SJ5PEPF000001ED.namprd05.prod.outlook.com (2603:10b6:a03:d4:cafe::44) by BYAPR06CA0017.outlook.office365.com (2603:10b6:a03:d4::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8489.21 via Frontend Transport; Sat, 1 Mar 2025 01:37:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ5PEPF000001ED.mail.protection.outlook.com (10.167.242.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8489.16 via Frontend Transport; Sat, 1 Mar 2025 01:37:08 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 28 Feb 2025 19:37:06 -0600 From: Shannon Nelson To: , , , , , , , , , , , , , , , , , , CC: , Shannon Nelson Subject: [PATCH v2 5/6] pds_fwctl: add rpc and query support Date: Fri, 28 Feb 2025 17:35:53 -0800 Message-ID: <20250301013554.49511-6-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20250301013554.49511-1-shannon.nelson@amd.com> References: <20250301013554.49511-1-shannon.nelson@amd.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001ED:EE_|MN2PR12MB4342:EE_ X-MS-Office365-Filtering-Correlation-Id: 1b789cf3-58c8-4d2a-c327-08dd5861946f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|376014|7416014|921020; X-Microsoft-Antispam-Message-Info: BeJPbIUYUn6ji/A3iSXGKcobqQUwXM4C4pdhJlM7osmAcHnKuSK5pP1158UYbTk4cX+Rf8Bmw3xMhvITYfXgq5+3GPPYfsSSgstdUqDW9gQxDUwMwKdeeRG8Qb0+U8lhhB7e7StuSZKntTxsFNXKIJsz/pVKE3R8vKmnQIwLKXA0eSN7NO6VcQ+mKRsysfWIeJfd6FUOQAegXQRTYsRe7g257514VUDod5iURY0Eb6XKyUtjR78J3XHHerItg1Hs8ZBwqr+g/UkOJjfFcC4dHCtulHVvcGYBPxD5bhlm+S0AqkHkLUP22yO+8GhpBaiOmdXYiDUai+oYXtojHSQFB98GmF4psy/UoYZeXHa+laGK7EYrHPCVJs2YrOnDAHLDqjjwLbXAv9RNB+My7c5Y5ymZ8rsvpBvVKrjhQ2/5tWd681f5p+JRdjriiqqTPU14pe5+GZupBvm7ntcq6MDavGrIjFdjfWFd5UQTfIm72RlVzITMtzVFweMaf7L98pxECrfrb6Lbbtwjmv2i5owsrZtRzP/N+DT+G9A204j9IWqae/4BWVbAxGa8I86wsoTVTFJPg+LOmA3OwN20H8YOlalbiDUqdGa+FMU0TY7/iquZvhJR68TiCk7PtqfWuFiyojciOh4cH9zHf7OO/zaYnmh+EQ+VUryWfGLSgJ649kC20x7DJPRzveJrrJMlbqXM7R2VQFJd0MiQXqNISqyRvOIsH7dOfz2EvuVnpJgeJdhnsyAGFjLDInTEva4hgJcBfVzrH7KnLPEs+mqj3E893qc5xmPAz28YF5sfX+oAeuuId3fnWBcEAvIhh5D9OuyECkR4jO4ciX7fdpSNushrcTWEmZiyTZKjyzoqGNJjEME32QIpMHv7ojpHRxWs5toVCjvMC1N/43m4N/KEgOzmeC76+NcBWTufjKP9a3WYa0imZgBwiJrPPnG2eEc6yCJXsYl/MKSOhkY2oNtGUl8eW7Di5GpL58ryVrtp+l4NbED+IWuOm52jw0L682tEpUq6uc6EPOqqXN8usChrxvqOUDng9Dil49d6q5wh8xOD4UB/ep0c0fIhnDxmzl+/fAw2tpSu/jnr8GAuyUqrSnWF8SRuQV8ZAEg6UnOmRw07gIUNGc9wYZmtCTvY/CrudUD1Wn4orM3XQY8tFd8Infmmv912ELYEVMWRN7MvI3pBYfVfgXMw0IHJlUi0hpcC+Ej/Ck5sErK9W2hxiIiGmzOY0GkqKVSlMwAMyzUH6pqNgTtww49tcOl6psoJZV5dRgKSDkP91pPd97q+M30MFcz+ZlsCEM+MmrSg6FT2YPKddwjWQmKnSYeM5p3xid2BIbHkKyQ56N/j+WronL7Xa0uua8N6a2epDgniC1jBglyghjCU842ANkMXx+gn3oRt6xQInfCF8KQLCtNkKEuW8PSyvdNnvDe8zJFAbqEWWqyQkXwNng3XcKOecnhYoXHzkXhGrcGINkUQ/zf90jIuIAx0Sva8vTn0hPsV3oIWM9ksorWSB4RAY5pqOTCqBdUSVmWp X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(36860700013)(376014)(7416014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2025 01:37:08.0184 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1b789cf3-58c8-4d2a-c327-08dd5861946f X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001ED.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4342 From: Brett Creeley The pds_fwctl driver doesn't know what RPC operations are available in the firmware, so also doesn't know what scope they might have. The userland utility supplies the firmware "endpoint" and "operation" id values and this driver queries the firmware for endpoints and their available operations. The operation descriptions include the scope information which the driver uses for scope testing. Signed-off-by: Brett Creeley Signed-off-by: Shannon Nelson --- drivers/fwctl/pds/main.c | 343 ++++++++++++++++++++++++++++++++- include/linux/pds/pds_adminq.h | 187 ++++++++++++++++++ include/uapi/fwctl/pds.h | 16 ++ 3 files changed, 544 insertions(+), 2 deletions(-) diff --git a/drivers/fwctl/pds/main.c b/drivers/fwctl/pds/main.c index afc7dc283ad5..bb2ac0ca3963 100644 --- a/drivers/fwctl/pds/main.c +++ b/drivers/fwctl/pds/main.c @@ -21,12 +21,22 @@ struct pdsfc_uctx { u32 uctx_uid; }; +struct pdsfc_rpc_endpoint_info { + u32 endpoint; + dma_addr_t operations_pa; + struct pds_fwctl_query_data *operations; + struct mutex lock; /* lock for endpoint info management */ +}; + struct pdsfc_dev { struct fwctl_device fwctl; struct pds_auxiliary_dev *padev; struct pdsc *pdsc; u32 caps; struct pds_fwctl_ident ident; + dma_addr_t endpoints_pa; + struct pds_fwctl_query_data *endpoints; + struct pdsfc_rpc_endpoint_info *endpoint_info; }; DEFINE_FREE(pdsfc_dev, struct pdsfc_dev *, if (_T) fwctl_put(&_T->fwctl)); @@ -95,10 +105,331 @@ static int pdsfc_identify(struct pdsfc_dev *pdsfc) return 0; } +static void pdsfc_free_endpoints(struct pdsfc_dev *pdsfc) +{ + struct device *dev = &pdsfc->fwctl.dev; + int i; + + if (!pdsfc->endpoints) + return; + + for (i = 0; pdsfc->endpoint_info && i < pdsfc->endpoints->num_entries; i++) + mutex_destroy(&pdsfc->endpoint_info[i].lock); + vfree(pdsfc->endpoint_info); + pdsfc->endpoint_info = NULL; + dma_free_coherent(dev->parent, PAGE_SIZE, + pdsfc->endpoints, pdsfc->endpoints_pa); + pdsfc->endpoints = NULL; + pdsfc->endpoints_pa = DMA_MAPPING_ERROR; +} + +static void pdsfc_free_operations(struct pdsfc_dev *pdsfc) +{ + struct device *dev = &pdsfc->fwctl.dev; + u32 num_endpoints; + int i; + + num_endpoints = le32_to_cpu(pdsfc->endpoints->num_entries); + for (i = 0; i < num_endpoints; i++) { + struct pdsfc_rpc_endpoint_info *ei = &pdsfc->endpoint_info[i]; + + if (ei->operations) { + dma_free_coherent(dev->parent, PAGE_SIZE, + ei->operations, ei->operations_pa); + ei->operations = NULL; + ei->operations_pa = DMA_MAPPING_ERROR; + } + } +} + +static struct pds_fwctl_query_data *pdsfc_get_endpoints(struct pdsfc_dev *pdsfc, + dma_addr_t *pa) +{ + struct device *dev = &pdsfc->fwctl.dev; + union pds_core_adminq_comp comp = {0}; + struct pds_fwctl_query_data *data; + union pds_core_adminq_cmd cmd; + dma_addr_t data_pa; + int err; + + data = dma_alloc_coherent(dev->parent, PAGE_SIZE, &data_pa, GFP_KERNEL); + err = dma_mapping_error(dev, data_pa); + if (err) { + dev_err(dev, "Failed to map endpoint list\n"); + return ERR_PTR(err); + } + + cmd = (union pds_core_adminq_cmd) { + .fwctl_query = { + .opcode = PDS_FWCTL_CMD_QUERY, + .entity = PDS_FWCTL_RPC_ROOT, + .version = 0, + .query_data_buf_len = cpu_to_le32(PAGE_SIZE), + .query_data_buf_pa = cpu_to_le64(data_pa), + } + }; + + err = pds_client_adminq_cmd(pdsfc->padev, &cmd, sizeof(cmd), &comp, 0); + if (err) { + dev_err(dev, "Failed to send adminq cmd opcode: %u entity: %u err: %d\n", + cmd.fwctl_query.opcode, cmd.fwctl_query.entity, err); + dma_free_coherent(dev->parent, PAGE_SIZE, data, data_pa); + return ERR_PTR(err); + } + + *pa = data_pa; + + return data; +} + +static int pdsfc_init_endpoints(struct pdsfc_dev *pdsfc) +{ + struct pds_fwctl_query_data_endpoint *ep_entry; + u32 num_endpoints; + int i; + + pdsfc->endpoints = pdsfc_get_endpoints(pdsfc, &pdsfc->endpoints_pa); + if (IS_ERR(pdsfc->endpoints)) + return PTR_ERR(pdsfc->endpoints); + + num_endpoints = le32_to_cpu(pdsfc->endpoints->num_entries); + pdsfc->endpoint_info = vcalloc(num_endpoints, + sizeof(*pdsfc->endpoint_info)); + if (!pdsfc->endpoint_info) { + pdsfc_free_endpoints(pdsfc); + return -ENOMEM; + } + + ep_entry = (struct pds_fwctl_query_data_endpoint *)pdsfc->endpoints->entries; + for (i = 0; i < num_endpoints; i++) { + mutex_init(&pdsfc->endpoint_info[i].lock); + pdsfc->endpoint_info[i].endpoint = ep_entry[i].id; + } + + return 0; +} + +static struct pds_fwctl_query_data *pdsfc_get_operations(struct pdsfc_dev *pdsfc, + dma_addr_t *pa, u32 ep) +{ + struct device *dev = &pdsfc->fwctl.dev; + union pds_core_adminq_comp comp = {0}; + struct pds_fwctl_query_data *data; + union pds_core_adminq_cmd cmd; + dma_addr_t data_pa; + int err; + + /* Query the operations list for the given endpoint */ + data = dma_alloc_coherent(dev->parent, PAGE_SIZE, &data_pa, GFP_KERNEL); + err = dma_mapping_error(dev->parent, data_pa); + if (err) { + dev_err(dev, "Failed to map operations list\n"); + return ERR_PTR(err); + } + + cmd = (union pds_core_adminq_cmd) { + .fwctl_query = { + .opcode = PDS_FWCTL_CMD_QUERY, + .entity = PDS_FWCTL_RPC_ENDPOINT, + .version = 0, + .query_data_buf_len = cpu_to_le32(PAGE_SIZE), + .query_data_buf_pa = cpu_to_le64(data_pa), + .ep = cpu_to_le32(ep), + } + }; + + err = pds_client_adminq_cmd(pdsfc->padev, &cmd, sizeof(cmd), &comp, 0); + if (err) { + dev_err(dev, "Failed to send adminq cmd opcode: %u entity: %u err: %d\n", + cmd.fwctl_query.opcode, cmd.fwctl_query.entity, err); + dma_free_coherent(dev->parent, PAGE_SIZE, data, data_pa); + return ERR_PTR(err); + } + + *pa = data_pa; + + return data; +} + +static int pdsfc_validate_rpc(struct pdsfc_dev *pdsfc, + struct fwctl_rpc_pds *rpc, + enum fwctl_rpc_scope scope) +{ + struct pds_fwctl_query_data_operation *op_entry; + struct pdsfc_rpc_endpoint_info *ep_info = NULL; + struct device *dev = &pdsfc->fwctl.dev; + int i; + + /* validate rpc in_len & out_len based + * on ident.max_req_sz & max_resp_sz + */ + if (rpc->in.len > pdsfc->ident.max_req_sz) { + dev_err(dev, "Invalid request size %u, max %u\n", + rpc->in.len, pdsfc->ident.max_req_sz); + return -EINVAL; + } + + if (rpc->out.len > pdsfc->ident.max_resp_sz) { + dev_err(dev, "Invalid response size %u, max %u\n", + rpc->out.len, pdsfc->ident.max_resp_sz); + return -EINVAL; + } + + for (i = 0; i < pdsfc->endpoints->num_entries; i++) { + if (pdsfc->endpoint_info[i].endpoint == rpc->in.ep) { + ep_info = &pdsfc->endpoint_info[i]; + break; + } + } + if (!ep_info) { + dev_err(dev, "Invalid endpoint %d\n", rpc->in.ep); + return -EINVAL; + } + + /* query and cache this endpoint's operations */ + mutex_lock(&ep_info->lock); + if (!ep_info->operations) { + ep_info->operations = pdsfc_get_operations(pdsfc, + &ep_info->operations_pa, + rpc->in.ep); + if (!ep_info->operations) { + mutex_unlock(&ep_info->lock); + dev_err(dev, "Failed to allocate operations list\n"); + return -ENOMEM; + } + } + mutex_unlock(&ep_info->lock); + + /* reject unsupported and/or out of scope commands */ + op_entry = (struct pds_fwctl_query_data_operation *)ep_info->operations->entries; + for (i = 0; i < ep_info->operations->num_entries; i++) { + if (PDS_FWCTL_RPC_OPCODE_CMP(rpc->in.op, op_entry[i].id)) { + if (scope < op_entry[i].scope) + return -EPERM; + return 0; + } + } + + dev_err(dev, "Invalid operation %d for endpoint %d\n", rpc->in.op, rpc->in.ep); + + return -EINVAL; +} + static void *pdsfc_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope, void *in, size_t in_len, size_t *out_len) { - return NULL; + struct pdsfc_dev *pdsfc = container_of(uctx->fwctl, struct pdsfc_dev, fwctl); + struct fwctl_rpc_pds *rpc = (struct fwctl_rpc_pds *)in; + struct device *dev = &uctx->fwctl->dev; + union pds_core_adminq_comp comp = {0}; + dma_addr_t out_payload_dma_addr = 0; + dma_addr_t in_payload_dma_addr = 0; + union pds_core_adminq_cmd cmd; + void *out_payload = NULL; + void *in_payload = NULL; + void *out = NULL; + int err; + + err = pdsfc_validate_rpc(pdsfc, rpc, scope); + if (err) { + dev_err(dev, "Invalid RPC request\n"); + return ERR_PTR(err); + } + + if (rpc->in.len > 0) { + in_payload = kzalloc(rpc->in.len, GFP_KERNEL); + if (!in_payload) { + dev_err(dev, "Failed to allocate in_payload\n"); + out = ERR_PTR(-ENOMEM); + goto done; + } + + if (copy_from_user(in_payload, u64_to_user_ptr(rpc->in.payload), + rpc->in.len)) { + dev_err(dev, "Failed to copy in_payload from user\n"); + out = ERR_PTR(-EFAULT); + goto done; + } + + in_payload_dma_addr = dma_map_single(dev->parent, in_payload, + rpc->in.len, DMA_TO_DEVICE); + err = dma_mapping_error(dev->parent, in_payload_dma_addr); + if (err) { + dev_err(dev, "Failed to map in_payload\n"); + in_payload_dma_addr = 0; + out = ERR_PTR(err); + goto done; + } + } + + if (rpc->out.len > 0) { + out_payload = kzalloc(rpc->out.len, GFP_KERNEL); + if (!out_payload) { + dev_err(dev, "Failed to allocate out_payload\n"); + out = ERR_PTR(-ENOMEM); + goto done; + } + + out_payload_dma_addr = dma_map_single(dev->parent, out_payload, + rpc->out.len, DMA_FROM_DEVICE); + err = dma_mapping_error(dev->parent, out_payload_dma_addr); + if (err) { + dev_err(dev, "Failed to map out_payload\n"); + out_payload_dma_addr = 0; + out = ERR_PTR(err); + goto done; + } + } + + cmd = (union pds_core_adminq_cmd) { + .fwctl_rpc = { + .opcode = PDS_FWCTL_CMD_RPC, + .flags = PDS_FWCTL_RPC_IND_REQ | PDS_FWCTL_RPC_IND_RESP, + .ep = cpu_to_le32(rpc->in.ep), + .op = cpu_to_le32(rpc->in.op), + .req_pa = cpu_to_le64(in_payload_dma_addr), + .req_sz = cpu_to_le32(rpc->in.len), + .resp_pa = cpu_to_le64(out_payload_dma_addr), + .resp_sz = cpu_to_le32(rpc->out.len), + } + }; + + err = pds_client_adminq_cmd(pdsfc->padev, &cmd, sizeof(cmd), &comp, 0); + if (err) { + dev_err(dev, "%s: ep %d op %x req_pa %llx req_sz %d req_sg %d resp_pa %llx resp_sz %d resp_sg %d err %d\n", + __func__, rpc->in.ep, rpc->in.op, + cmd.fwctl_rpc.req_pa, cmd.fwctl_rpc.req_sz, cmd.fwctl_rpc.req_sg_elems, + cmd.fwctl_rpc.resp_pa, cmd.fwctl_rpc.resp_sz, cmd.fwctl_rpc.resp_sg_elems, + err); + out = ERR_PTR(err); + goto done; + } + + dynamic_hex_dump("out ", DUMP_PREFIX_OFFSET, 16, 1, out_payload, rpc->out.len, true); + + if (copy_to_user(u64_to_user_ptr(rpc->out.payload), out_payload, rpc->out.len)) { + dev_err(dev, "Failed to copy out_payload to user\n"); + out = ERR_PTR(-EFAULT); + goto done; + } + + rpc->out.retval = le32_to_cpu(comp.fwctl_rpc.err); + *out_len = in_len; + out = in; + +done: + if (in_payload_dma_addr) + dma_unmap_single(dev->parent, in_payload_dma_addr, + rpc->in.len, DMA_TO_DEVICE); + + if (out_payload_dma_addr) + dma_unmap_single(dev->parent, out_payload_dma_addr, + rpc->out.len, DMA_FROM_DEVICE); + + kfree(in_payload); + kfree(out_payload); + + return out; } static const struct fwctl_ops pdsfc_ops = { @@ -131,9 +462,15 @@ static int pdsfc_probe(struct auxiliary_device *adev, if (err) return dev_err_probe(dev, err, "Failed to identify device\n"); - err = fwctl_register(&pdsfc->fwctl); + err = pdsfc_init_endpoints(pdsfc); if (err) + return dev_err_probe(dev, err, "Failed to init endpoints\n"); + + err = fwctl_register(&pdsfc->fwctl); + if (err) { + pdsfc_free_endpoints(pdsfc); return dev_err_probe(dev, err, "Failed to register device\n"); + } auxiliary_set_drvdata(adev, no_free_ptr(pdsfc)); @@ -145,6 +482,8 @@ static void pdsfc_remove(struct auxiliary_device *adev) struct pdsfc_dev *pdsfc __free(pdsfc_dev) = auxiliary_get_drvdata(adev); fwctl_unregister(&pdsfc->fwctl); + pdsfc_free_operations(pdsfc); + pdsfc_free_endpoints(pdsfc); } static const struct auxiliary_device_id pdsfc_id_table[] = { diff --git a/include/linux/pds/pds_adminq.h b/include/linux/pds/pds_adminq.h index ae6886ebc841..03bca2d27de0 100644 --- a/include/linux/pds/pds_adminq.h +++ b/include/linux/pds/pds_adminq.h @@ -1181,6 +1181,8 @@ struct pds_lm_host_vf_status_cmd { enum pds_fwctl_cmd_opcode { PDS_FWCTL_CMD_IDENT = 70, + PDS_FWCTL_CMD_RPC = 71, + PDS_FWCTL_CMD_QUERY = 72, }; /** @@ -1251,6 +1253,187 @@ struct pds_fwctl_ident { u8 max_resp_sg_elems; } __packed; +enum pds_fwctl_query_entity { + PDS_FWCTL_RPC_ROOT = 0, + PDS_FWCTL_RPC_ENDPOINT = 1, + PDS_FWCTL_RPC_OPERATION = 2, +}; + +#define PDS_FWCTL_RPC_OPCODE_CMD_SHIFT 0 +#define PDS_FWCTL_RPC_OPCODE_CMD_MASK GENMASK(15, PDS_FWCTL_RPC_OPCODE_CMD_SHIFT) +#define PDS_FWCTL_RPC_OPCODE_VER_SHIFT 16 +#define PDS_FWCTL_RPC_OPCODE_VER_MASK GENMASK(23, PDS_FWCTL_RPC_OPCODE_VER_SHIFT) + +#define PDS_FWCTL_RPC_OPCODE_GET_CMD(op) \ + (((op) & PDS_FWCTL_RPC_OPCODE_CMD_MASK) >> PDS_FWCTL_RPC_OPCODE_CMD_SHIFT) +#define PDS_FWCTL_RPC_OPCODE_GET_VER(op) \ + (((op) & PDS_FWCTL_RPC_OPCODE_VER_MASK) >> PDS_FWCTL_RPC_OPCODE_VER_SHIFT) + +#define PDS_FWCTL_RPC_OPCODE_CMP(op1, op2) \ + (PDS_FWCTL_RPC_OPCODE_GET_CMD(op1) == PDS_FWCTL_RPC_OPCODE_GET_CMD(op2) && \ + PDS_FWCTL_RPC_OPCODE_GET_VER(op1) <= PDS_FWCTL_RPC_OPCODE_GET_VER(op2)) + +/** + * struct pds_fwctl_query_cmd - Firmware control query command structure + * @opcode: Operation code for the command + * @entity: Entity type to query (enum pds_fwctl_query_entity) + * @version: Version of the query data structure supported by the driver + * @rsvd: Word boundary padding + * @query_data_buf_len: Length of the query data buffer + * @query_data_buf_pa: Physical address of the query data buffer + * @ep: Endpoint identifier to query (when entity is PDS_FWCTL_RPC_ENDPOINT) + * @op: Operation identifier to query (when entity is PDS_FWCTL_RPC_OPERATION) + * + * This structure is used to send a query command to the firmware control + * interface. The structure is packed to ensure there is no padding between + * the fields. + */ +struct pds_fwctl_query_cmd { + u8 opcode; + u8 entity; + u8 version; + u8 rsvd; + __le32 query_data_buf_len; + __le64 query_data_buf_pa; + union { + __le32 ep; + __le32 op; + }; +} __packed; + +/** + * struct pds_fwctl_query_comp - Firmware control query completion structure + * @status: Status of the query command + * @rsvd: Word boundary padding + * @comp_index: Completion index in little-endian format + * @version: Version of the query data structure returned by firmware. This + * should be less than or equal to the version supported by the driver. + * @rsvd2: Word boundary padding + * @color: Color bit indicating the state of the completion + */ +struct pds_fwctl_query_comp { + u8 status; + u8 rsvd; + __le16 comp_index; + u8 version; + u8 rsvd2[2]; + u8 color; +} __packed; + +/** + * struct pds_fwctl_query_data_endpoint - query data for entity PDS_FWCTL_RPC_ROOT + * @id: The identifier for the data endpoint. + */ +struct pds_fwctl_query_data_endpoint { + __le32 id; +} __packed; + +/** + * struct pds_fwctl_query_data_operation - query data for entity PDS_FWCTL_RPC_ENDPOINT + * @id: Operation identifier. + * @scope: Scope of the operation (enum fwctl_rpc_scope). + * @rsvd: Word boundary padding + */ +struct pds_fwctl_query_data_operation { + __le32 id; + u8 scope; + u8 rsvd[3]; +} __packed; + +/** + * struct pds_fwctl_query_data - query data structure + * @version: Version of the query data structure + * @rsvd: Word boundary padding + * @num_entries: Number of entries in the union + * @entries: Array of query data entries, depending on the entity type. + */ +struct pds_fwctl_query_data { + u8 version; + u8 rsvd[3]; + __le32 num_entries; + uint8_t entries[]; +} __packed; + +/** + * struct pds_fwctl_rpc_cmd - Firmware control RPC command. + * @opcode: opcode PDS_FWCTL_CMD_RPC + * @rsvd: Word boundary padding + * @flags: Indicates indirect request and/or response handling + * @ep: Endpoint identifier. + * @op: Operation identifier. + * @inline_req0: Buffer for inline request + * @inline_req1: Buffer for inline request + * @req_pa: Physical address of request data. + * @req_sz: Size of the request. + * @req_sg_elems: Number of request SGs + * @req_rsvd: Word boundary padding + * @inline_req2: Buffer for inline request + * @resp_pa: Physical address of response data. + * @resp_sz: Size of the response. + * @resp_sg_elems: Number of response SGs + * @resp_rsvd: Word boundary padding + */ +struct pds_fwctl_rpc_cmd { + u8 opcode; + u8 rsvd; + __le16 flags; +#define PDS_FWCTL_RPC_IND_REQ 0x1 +#define PDS_FWCTL_RPC_IND_RESP 0x2 + __le32 ep; + __le32 op; + u8 inline_req0[16]; + union { + u8 inline_req1[16]; + struct { + __le64 req_pa; + __le32 req_sz; + u8 req_sg_elems; + u8 req_rsvd[3]; + }; + }; + union { + u8 inline_req2[16]; + struct { + __le64 resp_pa; + __le32 resp_sz; + u8 resp_sg_elems; + u8 resp_rsvd[3]; + }; + }; +} __packed; + +/** + * struct pds_sg_elem - Transmit scatter-gather (SG) descriptor element + * @addr: DMA address of SG element data buffer + * @len: Length of SG element data buffer, in bytes + * @rsvd: Word boundary padding + */ +struct pds_sg_elem { + __le64 addr; + __le32 len; + __le16 rsvd[2]; +} __packed; + +/** + * struct pds_fwctl_rpc_comp - Completion of a firmware control RPC. + * @status: Status of the command + * @rsvd: Word boundary padding + * @comp_index: Completion index of the command + * @err: Error code, if any, from the RPC. + * @resp_sz: Size of the response. + * @rsvd2: Word boundary padding + * @color: Color bit indicating the state of the completion. + */ +struct pds_fwctl_rpc_comp { + u8 status; + u8 rsvd; + __le16 comp_index; + __le32 err; + __le32 resp_sz; + u8 rsvd2[3]; + u8 color; +} __packed; + union pds_core_adminq_cmd { u8 opcode; u8 bytes[64]; @@ -1291,6 +1474,8 @@ union pds_core_adminq_cmd { struct pds_fwctl_cmd fwctl; struct pds_fwctl_ident_cmd fwctl_ident; + struct pds_fwctl_rpc_cmd fwctl_rpc; + struct pds_fwctl_query_cmd fwctl_query; }; union pds_core_adminq_comp { @@ -1320,6 +1505,8 @@ union pds_core_adminq_comp { struct pds_lm_dirty_status_comp lm_dirty_status; struct pds_fwctl_comp fwctl; + struct pds_fwctl_rpc_comp fwctl_rpc; + struct pds_fwctl_query_comp fwctl_query; }; #ifndef __CHECKER__ diff --git a/include/uapi/fwctl/pds.h b/include/uapi/fwctl/pds.h index a01b032cbdb1..da6cd2d1c6fa 100644 --- a/include/uapi/fwctl/pds.h +++ b/include/uapi/fwctl/pds.h @@ -24,4 +24,20 @@ enum pds_fwctl_capabilities { PDS_FWCTL_QUERY_CAP = 0, PDS_FWCTL_SEND_CAP, }; + +struct fwctl_rpc_pds { + struct { + __u32 op; + __u32 ep; + __u32 rsvd; + __u32 len; + __u64 payload; + } in; + struct { + __u32 retval; + __u32 rsvd[2]; + __u32 len; + __u64 payload; + } out; +}; #endif /* _UAPI_FWCTL_PDS_H_ */ From patchwork Sat Mar 1 01:35:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 13997262 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2071.outbound.protection.outlook.com [40.107.243.71]) (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 E4719154BE0; Sat, 1 Mar 2025 01:37:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740793035; cv=fail; b=IwxNS7IX/JDRpAqxalF6VOT/h0YIuLZC5MfXOfZnNO2YrQPbSfqk0KR/fBV7ivx9++ysZV5odo4cafcQmifzy4r17gv90G0cj90RyzbairPv21yPu8E//tb+nfFjYcdveTfSoLuo9vego94Co7VPllg9by/UkR2jK9Y68Uym8UM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740793035; c=relaxed/simple; bh=KjJ1lArG8cVwGGbFPGo2jQtIRdd3kTKxVRHUD2+Smug=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=e/qwSKmgmbTaX2GpAUu3PaYz3v5WUQl4q0gST3+QXfQGD086MYQK0OiFAzDWwNS+nW6J28GK8agBnDXI9R+lvmyW3bey9uMinfL7TXTNpmCLBoJ6TMIhtubXO43KVh0Ve9ZH8jm/zdWYMSeLE512UJ3lwD9UBhLDR7eozLSS3Cs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=KnRB0nBd; arc=fail smtp.client-ip=40.107.243.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="KnRB0nBd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=c7CP4seHzpmogvBWm5ClyobEJGk8ZWVHDPxabEKOC73fvje8R3r7Unt1lht5cGlNLYQKvEFIEKkqqgmhASrWkrSiE5mN8IjZoCcyP7IietcK8v49gt6pAD3ussKnyTTHzOXdXQjEAbaI07LQTGE7MpPPpDdVRaaU9d3P9RfBZnOw4Mi0YKoTbM2AZCvFO5An+qb7TE+mD/h/uJXjCIoHXS8q33IwtzIi70ZWoOqxxr+ivPRnCFZquX+wLKWsHWejIg5imfnxvPV+e8UiKPdyyJwknFG1qaFPzK+pYt8YEEF9UYQFxuJLcAYTSZwDqekVFUwuaQGar5Ymdt76zUFSOg== 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=BeBSIyHStw6Dg795Gj76pj9fWvSEaBUjalkfmMohgUY=; b=TS5KcflHgFl6Oc+JFWiXi1RIu2AqiwUydD7hFJyT751Ti5jXUbmScZLCKPtmjDWuYz4Rh9ANajy6FQgl09znblb4t/GTyE1kCKunGBpmlN7mjPHcYGps0Jm6B2zezGhCHszR3Ir1xJc11PvebtgEbH+A9/FO4/aaTuLJORWTUEDL1WJZJ0SQjLswmKL1lhZyFheZYtcPhCUgm8wdtjeaJ/jOvu5syDkqbxprmT5ZpWmF6Z+SIdy5w7w5xq1fDzNUIGSjqfJTAM0LHVsdW0jHMgl0eicViMUFjG/09Loek5X7AnwyTwMiSQNvfbaFF7y4Ecd9IPnfo0+mGqDuvyEv5w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nvidia.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BeBSIyHStw6Dg795Gj76pj9fWvSEaBUjalkfmMohgUY=; b=KnRB0nBdM05On7Xhd7EX5pKh24S6qKiro5c1sJ80MX379IGzqse14v/2S7xkf3WGgvWq+T1Tx9M4JyGdHWORBrctEtcFYmJglQGrXbC3o5RK+o47GkcfK5bo5kq2wOqPqIWkkdHyuHbSB5txNnz8jCl6KIpAJ0t/Z6n4kiqI0wg= Received: from BYAPR01CA0053.prod.exchangelabs.com (2603:10b6:a03:94::30) by DS7PR12MB5864.namprd12.prod.outlook.com (2603:10b6:8:7b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8489.25; Sat, 1 Mar 2025 01:37:10 +0000 Received: from SJ5PEPF000001EB.namprd05.prod.outlook.com (2603:10b6:a03:94:cafe::b9) by BYAPR01CA0053.outlook.office365.com (2603:10b6:a03:94::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8489.23 via Frontend Transport; Sat, 1 Mar 2025 01:37:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ5PEPF000001EB.mail.protection.outlook.com (10.167.242.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8489.16 via Frontend Transport; Sat, 1 Mar 2025 01:37:09 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 28 Feb 2025 19:37:07 -0600 From: Shannon Nelson To: , , , , , , , , , , , , , , , , , , CC: , Shannon Nelson Subject: [PATCH v2 6/6] pds_fwctl: add Documentation entries Date: Fri, 28 Feb 2025 17:35:54 -0800 Message-ID: <20250301013554.49511-7-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20250301013554.49511-1-shannon.nelson@amd.com> References: <20250301013554.49511-1-shannon.nelson@amd.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001EB:EE_|DS7PR12MB5864:EE_ X-MS-Office365-Filtering-Correlation-Id: 0ec57954-7dc6-475f-a7c0-08dd5861959d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|376014|7416014|921020; X-Microsoft-Antispam-Message-Info: pyG4CZjucrFmEQk+50jjgYmT0/BBoCXIlDjWADtNTkkP8Pp6Z8LhAfbs6i5KOnWk9D8Oqp4tuIgF9FkEeeSdQ0BYF/DKcX9p8bGGPStXgSqsttN/oMmfqpERiTrlYy8dYWnYjHD97UGqjmLbR8sBBStmE4fLQefV/gORFCevbQ0m4HHu04wUM9drXaC1lARV4c86/NcxUARG9AYdxhQMiXRRnNO4/l2Tz65eBEZOXmFZou7t1U3gjWXWVundOqZKOnnYgwN92rLFFSoTXNk2mJxD+CVdxQF4Il5xc3w02MgOL4j1B+Tk1ANiTDpISkGNSbnttTqnNM2uJ96vkgyEuMYvSlZ7Lr7huIdJu+j1CXSYrLSPYXm0Sj+CmYwqmHKHOMcR812EN46ytiBcbdU9Cagm4lQYDSo2Uhj3VFV2wvi5D99VfN2BTUFWoOoA5y1pWIxnkJbGOPDI9gUY/hsdQKCq/glGZ0yedNCjReSbRw4LfVBPq0D1gZCdpZnxSCSON4In/yP8HmA47Rjies3aOhJF6iy8jwnyBZqKy8t1xNoB+sZVFPdTDTci6hF7GbUCVHXWGpMl+pViHxLlqUtGqkufA1F29oij+SYdwK5lAMSK1otRYZXZT4VEUKSqelEp+mJMwfS4xYW+PiZH7ZIrboMJsLR56qTlhHMfToRpKeTpc39U4jdteYXbrChIdNOMUMES/K1ISbU6A3xnCitqTx15UHgBDuQl2+dCOAnbTnvp8/KlAPhHeaNPyRDddJi4LCOgB34lpkpKJ0G0hsnA+UqKSHRUMfliWYDmihi1Tai7iZho7EX3GkFMHevkmlLAVdOnH6YtWh7ym98M7/fLYO4Hhn9nHasQEsQasqLFHkoCqBiaBmib7mfXYGS6qoyVYqf8AGl1RIQUT+ucl04f/J0Po+kAkxtBHoeSj5SKrzMBEVJuNnQYd3+fystKgbfWX4vxCG7tC0y2Ppq9keZ0LJupjlVf8rRb1Nh2t0f9aRZyca9C4JpqwRVfkUYZKnOXl210uyRlidywjhrm8Pp95wlhRXl459KaxPVUn4bNYtP5Ua92v1I2y676+Gp7ZmNUC86ApDclEKFRMAuB3yPUti1s9Hdrdba76Djv/i4em4qNqDhC9IVcf+nwyQo5F9Qv0IrvzSzhfM78cHV4hCGXBCgFWhE8stR/RqMKhl/Y3BD19cChrPau1vBVhJnVdchYpZl5IE3NbgHVLHfpCG+1sS+29mDn1APJB8ZYWZZw7SdvElEqHZZA6HSI7SZ2xHcddG5q/esFjXvGQKN30lwDJr1azh+ModcBcuOlBgPPZoVNEYivDh/2O2u7toSUeBkhBVoje5JD8D0F19nRZvK+IOzAouv4R9oWh+vNcDg4hWWfU167x1l7yMvn/WQMzxGmbqqXpaPS3wNN+1c9s0Cvf0m32Y0/f7wItUpsM1LgL9n8Hvn0tP2x4NmqEM8Q8KnfNod9EeWoSMkXp3CrO6GT/gsqW5JXc47pvbm9SJWqAQ6LlJJUenKzcVoEfd3l45Bt X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(82310400026)(376014)(7416014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2025 01:37:09.9187 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0ec57954-7dc6-475f-a7c0-08dd5861959d X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001EB.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5864 Add pds_fwctl to the driver and fwctl documentation pages. Signed-off-by: Shannon Nelson --- Documentation/userspace-api/fwctl/fwctl.rst | 1 + Documentation/userspace-api/fwctl/index.rst | 1 + .../userspace-api/fwctl/pds_fwctl.rst | 41 +++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 Documentation/userspace-api/fwctl/pds_fwctl.rst diff --git a/Documentation/userspace-api/fwctl/fwctl.rst b/Documentation/userspace-api/fwctl/fwctl.rst index 428f6f5bb9b4..72853b0d3dc8 100644 --- a/Documentation/userspace-api/fwctl/fwctl.rst +++ b/Documentation/userspace-api/fwctl/fwctl.rst @@ -150,6 +150,7 @@ fwctl User API .. kernel-doc:: include/uapi/fwctl/fwctl.h .. kernel-doc:: include/uapi/fwctl/mlx5.h +.. kernel-doc:: include/uapi/fwctl/pds.h sysfs Class ----------- diff --git a/Documentation/userspace-api/fwctl/index.rst b/Documentation/userspace-api/fwctl/index.rst index 06959fbf1547..12a559fcf1b2 100644 --- a/Documentation/userspace-api/fwctl/index.rst +++ b/Documentation/userspace-api/fwctl/index.rst @@ -10,3 +10,4 @@ to securely construct and execute RPCs inside device firmware. :maxdepth: 1 fwctl + pds_fwctl diff --git a/Documentation/userspace-api/fwctl/pds_fwctl.rst b/Documentation/userspace-api/fwctl/pds_fwctl.rst new file mode 100644 index 000000000000..f34645dbf5ea --- /dev/null +++ b/Documentation/userspace-api/fwctl/pds_fwctl.rst @@ -0,0 +1,40 @@ +.. SPDX-License-Identifier: GPL-2.0 + +================ +fwctl pds driver +================ + +:Author: Shannon Nelson + +Overview +======== + +The PDS Core device makes an fwctl service available through an +auxiliary_device named pds_core.fwctl.N. The pds_fwctl driver binds +to this device and registers itself with the fwctl bus. The resulting +userspace interface is used by an application that is a part of the +AMD/Pensando software package for the Distributed Service Card (DSC). + +The pds_fwctl driver has little knowledge of the firmware's internals, +only knows how to send commands through pds_core's message queue to the +firmware for fwctl requests. The set of operations available through this +interface depends on the firmware in the DSC, and the userspace application +version must match the firmware so that they can talk to each other. + +This set of available operations is not known to the pds_fwctl driver. +When a connection is created the pds_fwctl driver requests from the +firmware list of endpoints and a list of operations for each endpoint. +This list of operations includes a minimum scope level that the pds_fwctl +driver can use for filtering privilege levels. + +pds_fwctl User API +================== + +.. kernel-doc:: include/uapi/fwctl/pds.h + +Each RPC request includes the target endpoint and the operation id, and in +and out buffer lengths and pointers. The driver verifies the existence +of the requested endpoint and operations, then checks the current scope +against the required scope of the operation. The request is then put +together with the request data and sent through pds_core's message queue +to the firmware, and the results are returned to the caller.