From patchwork Tue Feb 11 23:48:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13970863 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2071.outbound.protection.outlook.com [40.107.237.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 B8A0326B95A; Tue, 11 Feb 2025 23:49:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739317760; cv=fail; b=FW6JqDASrBGlINYfvFa76Rw0zwUqvsWzEN9SEcAWoZWwiO6vM7LGJ0y1K/HM11mjJ7AogQh0xl8N8N5XqUlPYonmCM8L9oN/jKGylR5+ljNJGMrTJ0gAMASyBzjQNohdLZrOIru8VfF1MT+mmlL+znITio+IJ6KLQqY5a9+riAw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739317760; c=relaxed/simple; bh=S8exCzioc7cpuO5g71UwG4sHifhiRTTCcvPAnhwZLFM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kOYQZeCIz51QzLGMwpeNbXdm2vETWIqX4anje5fFmn9KrSzr+VCM1+wBpqXyQbIhZdJi/p+BSa/mqL7npWnRheCOM2Ozkw2omwnvEZ6PYa+7csYvrazJR/BNuc++Lt7HSgnCrewMoBiPoJo7X4EG0x0ZVqHxzTXzD9QffCq0Vp4= 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=sArK4E0h; arc=fail smtp.client-ip=40.107.237.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="sArK4E0h" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tCguYg1HCbsFwjRUcP8Q1edS48Aroepa+XL96fGXFYUHk1pqS1ubi3db2CA19OC5u2czQckn0pS9WYf/y4jQyxkVlhxxtyVrQlWlcjCyq+2I5Ve70/z3HB4yRbePJIE7VIH5n1RCLsTJMqKrRk2nUdzYA0wQM6Ei9S90OQ07ighQTz49agZthRZKKwV5OsMXFL7ndG3IPgXiefQhRqqmuwjNR2P3eHtiVUApgw3wTFNd686hYkb1Ic6OQwzWN0WRGvLS3vbkQs2JeejCmasyBtQ86GaagbBWqInZM+j+iwLqR0rBLnPFK+aHXSRMEvlfF3WUW8W8ibmJSTc48xSbtQ== 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=o2km61AXBXj/yWn0ImNA7+bAyPS3CEynSOmvh57uc68=; b=at95s5s4kuEbjSDNLaN3mjWR36e9coI+2sAD6vzGvCZKYLCvY8W2lU6+JR7yD4NRLmoSEpfBI1NHbjqzkugJ6mXBPTXVPij0E953fI9oGKvkoI/MnZXoU9EqzScn7mDe4gPYd8c3T26gPDZkJx+akVjeFcUkLAkUMWZq+oNak7htn4KlZFgosOM2Urx7FrviqBOIpugMtVUp7w1bU5TGqNu52Zo7v0rxuOGHEW+pV2aPmwpYBraXBLv/NcuznIAPHautcAGVh3fDTwxUTk1pSmuCV58m85aUWbTHZ1yYh+Vy/P8wq3s4ItvBDOAUNQ4w7Mvm+oBQqXGEMmr/vHkDGg== 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=o2km61AXBXj/yWn0ImNA7+bAyPS3CEynSOmvh57uc68=; b=sArK4E0hnjxhu3LJXjlr3wfT4gnRgGwCzu1m2s/yfqEIyEw9mYY7ByEXYkFGGNddgO5i8iuDy4OBaVayYUTNeNvmrOGMAs4FrQlmlx38wtJ66X9UPGc74x+THg8K5Zs+H1hnqJ0Ylfu+9Pbf846ujyzH/VrCanRpgsoy3KryEYs= Received: from MW4P222CA0012.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::17) by IA0PR12MB8423.namprd12.prod.outlook.com (2603:10b6:208:3dc::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8422.18; Tue, 11 Feb 2025 23:49:14 +0000 Received: from MWH0EPF000971E4.namprd02.prod.outlook.com (2603:10b6:303:114:cafe::2b) by MW4P222CA0012.outlook.office365.com (2603:10b6:303:114::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8398.31 via Frontend Transport; Tue, 11 Feb 2025 23:49:13 +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 MWH0EPF000971E4.mail.protection.outlook.com (10.167.243.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8445.10 via Frontend Transport; Tue, 11 Feb 2025 23:49:13 +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; Tue, 11 Feb 2025 17:49:11 -0600 From: Shannon Nelson To: , , , , , , , , , , , , , , , , , , CC: , Shannon Nelson Subject: [RFC PATCH fwctl 1/5] pds_core: specify auxiliary_device to be created Date: Tue, 11 Feb 2025 15:48:50 -0800 Message-ID: <20250211234854.52277-2-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20250211234854.52277-1-shannon.nelson@amd.com> References: <20250211234854.52277-1-shannon.nelson@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E4:EE_|IA0PR12MB8423:EE_ X-MS-Office365-Filtering-Correlation-Id: ba941b81-a796-4233-0560-08dd4af6b07b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|36860700013|82310400026|1800799024|921020; X-Microsoft-Antispam-Message-Info: sr8xKW6oUpIV6rson+NkCfT/Mvm8tOJnvG9WAPlQ1c6FiyUDmw1bp9/ERBxvApDkTS/XqnG6YNudEDnBORhvnDrDlubpcqcb0IqsRmxJrYyK8+TjxsQtZisoc+rw/Kw2J6FtQkBBq6rwRvDulcNX5Wx6Ft/eZWrwktgNWfOUmor6yFzq8/fQFJuoJsjk9JcS02ATnz1tP+fWuFyTI6qiyJL5mUwMXicFLlQlbnZXW9qmmaN2vCLvZjn7XVYcIatLl8sRgZopWKH8sLeDX0KrELXuBEQY4cw4gaxCrBRZ7tZX1G9JK+kesjGzqmHFp1L1cw/3Q6gWVKj9gC8GUsgg197iQMS0o0RxfxWu2CrWt2HLroROgwdPKd2W97MfYa8lD0wMR/2hWnxUpIM0utZaUG3gs107Ewk+qpP1Wu2nYWQKyy2Le2vMG4B4m2WplTiO0dXVRVaPDW+lDolaelVJkP4d3kSlb5SBd0kzqTxUkwU19xUp+RKEsXI5J5bZ2yGgFQX/o2w+ANLCtLxCAyCKRClwuToHv3KR8mWQLt2C/ZJq5tF+joi6Ck2uR0dI6QgrPVsX0t1JdfIAPXuv7bsujtMV+NHLmkEaL3Cc+Ehv6k1BqU9TRdASylLPLCSZ2tA0li6ZPzkJGXSToZ43qQyYDIb9s+IfftrdSaAscVT+f6T85OjFkdBtWxSF+UMfTc1Ugbh4rTgr7w1KhvFJpqoRjBtK16CWCpwIhjN4+DkpcLuM85rNaCLIbOuBiupb/2K2i/R1wPto4ZjSENgCmBMJTgdR0TXLRn1Dms7lUdELK1o2Wv9Tq7SOBm7SYoglqi5gtSKH569jUIF60b166lOVFgBMeREWml8tcANRGkz4+42PoEBVUIiXUDCvElvrxuErHm08TyFl/UxWTOEDea1jjl5fnr2/2/5pIVbK6y8GV2B0FoFb0UYtpVm9gJR/JQrWbOV/SHi0n46OI4cv275/2mohh/o1aGfQpMcb3TCLY9cetHcYnzj2+/9qYBKnGjHqlW9haCT7irUYZAG2YU/y5q4fzeI5apZAHeUvuhHeR+XeGtBlvtq/bEeoDGgma5rIu8ykBEtbcj/FKXuhxSxgpg/JJi2dNLNxK7lbnMJ6wTMkGYxcICrHX0pKDr3XgV7tXWvaqGP6q7tttTUl5WvNYvwilJ1kvyA5dQkfpCtfzlqpn0ogQLPqwFM7azLEgBxTr0quXYbM9ZrRt1pe1vipB+PUAxGTeNylbI4/ABMV8f/jNBDs3sxmRiCusderW1mJ4SvJrBdv/nWWJFjtVtLkkTx6Pio7Qmw6tzyURbcuoSQvgrcUhIyKl+XP5ZYnRxIeKw/cYwCkBXZuAFaWwQIRudBJsRufvLlj3mK6FopsJgOlpSHvQOUrJJ020kxMYLPGIQgoaO8Huk1pliKFJKk216rbwk08HYjb/VzGk8yniuG8tuNQ+8b6+QzHR0VZiUfj5zFgqkVs9FQyV0NXp4ohSshSQfcWW1OJ1koWqZFAMHI= 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)(36860700013)(82310400026)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2025 23:49:13.8022 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ba941b81-a796-4233-0560-08dd4af6b07b 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: MWH0EPF000971E4.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8423 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 | 41 ++++++++++----------- drivers/net/ethernet/amd/pds_core/core.h | 7 +++- drivers/net/ethernet/amd/pds_core/devlink.c | 6 ++- drivers/net/ethernet/amd/pds_core/main.c | 11 ++++-- 4 files changed, 36 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/amd/pds_core/auxbus.c b/drivers/net/ethernet/amd/pds_core/auxbus.c index 2babea110991..0a3035adda52 100644 --- a/drivers/net/ethernet/amd/pds_core/auxbus.c +++ b/drivers/net/ethernet/amd/pds_core/auxbus.c @@ -175,34 +175,37 @@ 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) +int pdsc_auxbus_dev_del(struct pdsc *cf, struct pdsc *pf, + struct pds_auxiliary_dev **pd_ptr) { struct pds_auxiliary_dev *padev; - int err = 0; if (!cf) return -ENODEV; + if (!*pd_ptr) + return 0; + 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 err; + + return 0; } -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; @@ -211,6 +214,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) | @@ -222,17 +228,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 && @@ -258,7 +257,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 14522d6d5f86..065031dd5af6 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); -int 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); +int 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 44971e71991f..c2f380f18f21 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); + err = ctx->val.vbool ? pdsc_auxbus_dev_add(vf, pdsc, vt_entry->vif_id, + &pdsc->vfs[vf_id].padev) : + 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 Tue Feb 11 23:48:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13970864 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2072.outbound.protection.outlook.com [40.107.244.72]) (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 8E38B26A0FE; Tue, 11 Feb 2025 23:49:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739317761; cv=fail; b=fJFdmA2jf4u1VtnzgK6iMryzWew2mvfVCKE9Wxu4G8IdCJ6jarrzOu9e9cMq4rVAWXXHuI8Qn5zQtZ2WyOG5qedjP3heOlsfB0w7sSbdjkot/fzP+axYyzxodredkz/PKKNPFpknNLQ5gAPYTrMZLUajbTzGyvOOs+LPykVJf9Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739317761; c=relaxed/simple; bh=zWxLyJYUytqR3M/H/4OTZ5sjFpKUaQ77Yo4La5KWvVs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=A8gNqx9GH6eihRShHHgDvGVbaDrXyUgLsHhm2spIViXxaTWepsmvpZtMIuY9uDcROu2Z6/eJ/IcsbuAj6amkw5EwA3/ejz80IWKPR/Nbeha7cPQjc7BxJ+qS/jtYwhNCi2VWcIwApgNz6ULeD2+SZRkIJQjf1lEcEAx+U6BZJ3Q= 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=t/Wamwli; arc=fail smtp.client-ip=40.107.244.72 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="t/Wamwli" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=elKafnlvnJFnj6HmLFae4jaAk7RiYwyuZvGufdNfupCmafEUPk0upLabwNrwCSgMHGdRtEmqZece7XAPCaZ+n8Ghyd8G/cuCnHNyPZ8KvA+Ho1z16mME2iWuHf8Ph8ULduWqtYMa8CmP1TvtcKuNSwsEzZcXxBziypAwztwpf5A4KW39aQz8UTWceAoHJ0zp80NjbwhZGocSoRQ2MjBgHARKuLhFaP279jC6RCukcfDSnszmKyGbE6oML3os2oXTG74P3CQDrKAxB2yLxoFp2bz0PQHH3+b5Dy3g44X595fy1SLzHRtD+3VaBD2Fi+X/87mNRZ/bFHJ9GPlFIQBHvw== 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=k04YJA2JUTVGcQjyKQ5DjFgaK6vRSQ/rTLaSQBc7S5E=; b=l+UMhO9g1ebEiO+cZCtaERNEM/EGJALUyQKQ2EHpyjd5WQreKm5fE4+2kxvMr4wPSOywWBNZKV90my25vFBZWkuFtBr238KFvr4PISv55bwuVP1E5sNAbVIWHUZHQeGENqiYpj9pMQaNXs/szZFMHvq/QkLEMH6Q7yZhzuTM9lJsjixAxL1oUZqR8pbzjV3mxNFYYO77xrgNN3Lc1EqIhEmU7GGZcDgN1WpeDd3mae+HlElCbMnmSprnkciAHgqkQbNeOqFtFnbt1Yn6Bv9H6zbunjqObWHJXykHsiSYfcvrqWskMlrfks2Da2LbtUF+vRlI73KfJaufH3kJMwfAkA== 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=k04YJA2JUTVGcQjyKQ5DjFgaK6vRSQ/rTLaSQBc7S5E=; b=t/WamwlivPu5O8ER6pO49f+CzeeGB4YdZDOSZPZCPlbs5ilreINkm18pQiKYWqPhkE1s94koaBwmD0NHs48XWCm2hVbh+3Waa1GhYzoznvR7vffft2OvLmBllRFBpOwDuJGHFQSf3PZGHfPhXme6p1Myne+FGd18Qb2/tTF7pnE= Received: from MW4P222CA0029.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::34) by BL3PR12MB6548.namprd12.prod.outlook.com (2603:10b6:208:38f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8422.18; Tue, 11 Feb 2025 23:49:15 +0000 Received: from MWH0EPF000971E4.namprd02.prod.outlook.com (2603:10b6:303:114:cafe::fd) by MW4P222CA0029.outlook.office365.com (2603:10b6:303:114::34) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8398.31 via Frontend Transport; Tue, 11 Feb 2025 23:49:14 +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 MWH0EPF000971E4.mail.protection.outlook.com (10.167.243.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8445.10 via Frontend Transport; Tue, 11 Feb 2025 23:49:14 +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; Tue, 11 Feb 2025 17:49:12 -0600 From: Shannon Nelson To: , , , , , , , , , , , , , , , , , , CC: , Shannon Nelson Subject: [RFC PATCH fwctl 2/5] pds_core: add new fwctl auxilary_device Date: Tue, 11 Feb 2025 15:48:51 -0800 Message-ID: <20250211234854.52277-3-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20250211234854.52277-1-shannon.nelson@amd.com> References: <20250211234854.52277-1-shannon.nelson@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E4:EE_|BL3PR12MB6548:EE_ X-MS-Office365-Filtering-Correlation-Id: b92390fa-02cf-44de-c44c-08dd4af6b0fb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|36860700013|82310400026|921020; X-Microsoft-Antispam-Message-Info: wSntjaCUidlUXmipUoB13Z7/zC8hqbHMAIMnpBDPZh8yf3xMCf78YS7hj+U6dGnwYlZmHgtAIC8d9d1bexWU2vms0oIyxQBRuy9owF9ijn6TLQpdiFzCPW7DV09ef1L4P+ZmDUJsm0HpkbvcKdh1HmDNelQWRAXRUeNGKsVKD/hc+bjceQmBXFXyFzMrRHafqMkb6L4oTvp3v4w6yPJ4jKYHNJPvVNeKaOF7Yw5BnSs2bBYLpBO0RjGB7maTZpoZHpnjlYw4d5Jl8gWxda1ecHf7RVI7Kt4xfcxBI9QM3lDKRspeN1zI/xBs/bHM9ZOLN9C/deKuI6jc4rSoCwZkUvPciHrw1gETolNgCTzPaBwehhKJ/zi4FfabJZzmc1trFQvpA5X/zJZs9FnvuuMhEwopjSzpS++TGwRDnYXs3cKM5Bdpsbtz5H+CMPHzhVR8dHLRmw+H/vl2hkqWfhLYpQkhii6hkEZxRaGG3tRxYTbUSs2WROnhNRLwO2+/TJ8tKf2rncvGmTkYwk9ADp/2tWaeNp/j0VxzUsFAMrrwa0LRBI9HceqPnJCtw6V+vIDmF2Mc/70uVJM0XHVt4AoQrkPhvOFbHghxP8R4/+DVNEBl5OII5SSGCRlaoT5WUo7y7HX9J73+hgmKM4ug9wZjOW90p9xvFrQyyMHKBHtW/yiSeOxqRPo3MrR6ncUQgtCp06Ueugp5sUaQd/Gh47x9IeQveT6ZZTW6tX/7C8U2iRvwTdUCDSMgz9PpGOWgC34QLoFjVV6aAKM9J89JBZzVPVsoz1FbFsMMm6w2PvoRUGUp879oaZV13upOBxt1d4VV//LuefA/n+yfxMKKqnkZct+whnqFc/PVzWMcf/uDCZwuHmkESvnUS7q8MgZBA11gU8WV77zOVRhpY9NrwMp5JvV1JwXYfEr2VF97kuvrrwGRlVg0JZ5Pe47K08lshprVL1ToggFu8iPAwjiDAm2dtaq0Ts3E8Lxzj6eBAmn2uMyrgDxqgF2X6vT/EJO+NKD4oRQ93jbW427WBBgcq98k56oKw/An/GLObRc9JfFTZRHX5U3MBVvCcwzNoaXt1u5MkmJsCl1OsLoyDktoMEAEE8VAooeamVxD5iIPLeJKxbFTY9MZP66KFuXisfoKE4k+JQGi0S3/UFZReg3c4eaM/nz+wSsbDBU3DVNjIMYEPBeF8u8vbLwLnQQeF/YzBv2qqbechwAiFKo5Z1zdAQGaN0j7FiYmS1JOh2wejKB5iifU23mHvmmjLv0ksl03naRtWp/cY1NVpia34zoPOaCG+19hiBC+EdmqlJvOjn7kAhYTckGXiUdGhqQ6S4aRUxsVjVEx3uWy63NiS+MnY9R/c4EV1gjYMCUHYR3U67Utk8EySpf1r+W2BKZij1hP+Z5JZdujfukEEtnauVJER0Vej0953h+J1Hxw2BXb/wrzDcOJfsJpPOAUr/cn7ydciO+3jIrsKdbDHhaZbc+nT6ScPEjJIvQaVGt1tohrKPZL1rENAxMy/x/Z6W4dJ+4elfNd 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)(1800799024)(7416014)(376014)(36860700013)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2025 23:49:14.6459 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b92390fa-02cf-44de-c44c-08dd4af6b0fb 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: MWH0EPF000971E4.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6548 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 | 10 ++++++++++ include/linux/pds/pds_common.h | 2 ++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/amd/pds_core/auxbus.c b/drivers/net/ethernet/amd/pds_core/auxbus.c index 0a3035adda52..857697ae1e4b 100644 --- a/drivers/net/ethernet/amd/pds_core/auxbus.c +++ b/drivers/net/ethernet/amd/pds_core/auxbus.c @@ -229,8 +229,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 065031dd5af6..218bb9c4c780 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..7f20c3f5f349 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_teardown; + dl = priv_to_devlink(pdsc); devl_lock(dl); err = devl_params_register(dl, pdsc_dl_params, @@ -427,6 +431,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 +490,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 +538,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 Tue Feb 11 23:48:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13970867 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2049.outbound.protection.outlook.com [40.107.94.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 4A03326B97E; Tue, 11 Feb 2025 23:49:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739317766; cv=fail; b=fdNmN5aGxVrgyGC3TThZ+TopLgpd+ttrSU/f92R52gBy+7k5oHmQXDHXaFwFYy7thrySmmXOwNet6RAT2d3zQ6CDZctRHIghwT1mkM+1xyqVix55RzIfEkApF9htvXa5aaMX+TCk2DYWAZkqk3UEWPc2LJmbBXP8ZiVwSf2Etzw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739317766; c=relaxed/simple; bh=046E5BeG5BDYHSfZK4/NyB6tNRTUUFTuwWGzyi9Sxmg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bPQXY3QPEL7bg1JCbCq/ZhV5jxwA0qGOLGOMPaOxpRFPQgMz9g4Sqqrwz8N9561jSBEGVAxKgbUqwfqaVYmWozAYIAvNk/bBGjrBHVEUxBUCpysnDH9mBOzPHaK+lZNxJv879E6+NHH5KtfzJ08hiBzAV0+5usb0V41Wzn7OzPA= 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=cHEp+FRU; arc=fail smtp.client-ip=40.107.94.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="cHEp+FRU" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kz2pBh/vjmr4n8VFIzxAmXDWBt8U/FuL1Pd6Xo6dW3t7AXN8k9fF6JdNbpLpqDbArdWbdNEeklZX5i8hrnpdpUw+fJXHcqDQiA7+EbE+RZv1USwwH1wl5XQq55KmXXxyH1sm0Lk/YsVmJlOD5N48sMwAWo7HMm92tS/M5eZwFfnsnQ/HGZTp6hFTGFBsqVp5arD/TKEH0qh5etuTBjGhbmgmTeJdQi2anaY5DFtuZJMcMR1WPlXdvZV7yQc6yRfZIqgWO4P4nVluy/yztFzrU+9tk6nGrtYhdCuFVsmCRDcPJUssWmNrlCk0jKyXAFjeu1EC2ITnVceun0/m+PUXXg== 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=+fqo2u3+sTnFbHlVaVgddCB01+Lkbjp5eb3eGUBeQFw=; b=cVuYIKc6z+227DevVnVGDLrcPSUy16oXELvUhUOAr8/Ndz1i1h/tA0WKNFn4kFI0MqmS9VSZl8/pPP3gfyHrSPJUR/WKPSvTvCWpt9Ccg+y3AsXAWU8zWgPii2CzSyXyNB/UsxbAWnNihPNvN2roCQLE940hhCJoXS3t7ILJucf6/q74vEkeI54XGjXrDgUnqZbOBAJEt6IiC+pn4241t++XFL8M0yFRi8r0RD1+7oixHe57dAp2QOmVgjfM00lr8CLFwx5ALaAk1Zz0tqsuy6gEq3D/s4vcy4lSUmtSw/aBOnTeW12A2KEl4q5q412ThuFUd3Vwq4s/j/yEifnrow== 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=+fqo2u3+sTnFbHlVaVgddCB01+Lkbjp5eb3eGUBeQFw=; b=cHEp+FRU6fZXX5axSxWs4gdtVzI0rcxYhxxBRPisQ6vEnlULhOmSgefM5HlKCgr16tkgb+Hes/JaE11OTFQhu1YCMRmxz4u4wZcI8zz4Yt2jwNMuQYxORgOtRkKv4SLOxOia2Ret6IhWifo1LDzqM2jv8lCxo+Irw+sKwq9lWlM= Received: from MW4P222CA0008.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::13) by PH7PR12MB6491.namprd12.prod.outlook.com (2603:10b6:510:1f4::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8422.18; Tue, 11 Feb 2025 23:49:17 +0000 Received: from MWH0EPF000971E4.namprd02.prod.outlook.com (2603:10b6:303:114:cafe::28) by MW4P222CA0008.outlook.office365.com (2603:10b6:303:114::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8398.31 via Frontend Transport; Tue, 11 Feb 2025 23:49:16 +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 MWH0EPF000971E4.mail.protection.outlook.com (10.167.243.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8445.10 via Frontend Transport; Tue, 11 Feb 2025 23:49:16 +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; Tue, 11 Feb 2025 17:49:14 -0600 From: Shannon Nelson To: , , , , , , , , , , , , , , , , , , CC: , Shannon Nelson Subject: [RFC PATCH fwctl 3/5] pds_fwctl: initial driver framework Date: Tue, 11 Feb 2025 15:48:52 -0800 Message-ID: <20250211234854.52277-4-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20250211234854.52277-1-shannon.nelson@amd.com> References: <20250211234854.52277-1-shannon.nelson@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E4:EE_|PH7PR12MB6491:EE_ X-MS-Office365-Filtering-Correlation-Id: 13608c6f-4db6-4f3e-a17d-08dd4af6b23d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|82310400026|1800799024|36860700013|376014|30052699003|921020; X-Microsoft-Antispam-Message-Info: Te9x2pV/xnGMZumRYVRdyZBcn7fCwJVX+3jQ2f3FgBFk7dEeue/cwROveKiicR8lUjfxuGDMN+bk/QpNG7W3S1j5sWP0DtWu8JnRwC72NW7od2et7e9iR4JltpaK1s4l3oth7XSWNWz7s1EmfreSeDxJeWO5okNuhFqtMBf7fAtzkNxtnA+wVYtpeey7J3QR/EMabSP2MBwCOrACgxsYA1t84783QKmk1bj6y6uDIpIBG1ZTrLw98Yl+KzRxKBTwPlJR7tdX6gHMExTPB7jxegXiNz7aYth2ssm4fxZNHzxGziZviRt+yHu1HR4K70ogcD0FzhHhVt+f81eFym6ce7eRQ57wKt0LDwH2AkldIwl1RR57q/68v8P6R8LZj8R9BKaPIeI1v70q2PjqZQjf62RmbKx1AunC3O1zHcJ0VcQF0XYT9IZD/TtGBfA/H+4sEu3bvB+Sv52WU3tRqu+5za42yjbHmwz/9cRaDOqfn3qavN9Vv7H2zub392Orc/deHqRDIYzE4NWXRxmLZt900Q5fK38hsExaN+Z4NdxBNSHE1dDGZEQPjK14QALDzk8kb7No3vTq2MQSQ6/1x7z4gtQrVkKzcIZdknLZmCxIHaMLXNzR/ET3R5d6nnUQjgr2l2Iy1MkzBb68cudHHTLzAJuDDN2Ecs2t8NiV4C4HRi9EcY/vvjKjyK42E7AP7eNCidTGqBpmIdSClaoM2TJwK8Mj2VCF6b6NlExaTdHkeHw3PyzMtfe8PFTS6dvaMx4g2hZWq99QGEkULOEQHERkeIdcnnS8kEa8pwk9LH62Xv5hPhpbZ1XGMHsMyDZuAgBN24d0Mc2yRKlUcnfPmKQG1LlAV9HT+Yy11XE6QlVhDIk+A5c+K0ATgXYw+obFjfF/3f8rKSnujtRiy86GLSaLPJAAAAe/pdoF7pMszhhLOgDkFAJrdTyx5oU81XqelhgQ2sYCsjmCjuWqaMyVPK6Qs5VKPsXiYG/e8AyqsSAzG3vg2xIn3ibL5cnTex3y4wo+W3vez0pruVjLH/jWrInmhQwl7t2XX1FmO++BmLLxJ7k+KvF8KV4m+Jr1Ya8gNLeadmKml2kvqKc5wNR6ka6zVBK34Mb02ALCW+oXlBVxdgVcK897ht+uoEoqD+egQ/y4uWE8UN0Bxw8dp84GhtBHMhxWk93KoYnY4NFr7YewPWPVePKnKyf0zeoco9qNa9kWMC268fA/2kjYDdgOghLPH7H7nf4xo1worlPIVIJ0I1sLkEASss4/0//FqiGpscyAAgf8EzjowllQqbmTBJ73g1D/cjryyZ8ezWqsGMwi4SlS2RqlKPBIhzbJwlo7/2WzbUg9Ap+vE0IRnDpCGLMYVAaBRvIW4mntqg3+6HVnh7+fq5faZ7NqREs3oTl2BbwskU22xykhyQQkWki86vZ8inKdTlBT3mtMaEguraoLYjFsW8VnhZPfHS8H+6X+wU/4pZZzqsZIq0ei2HD4YHLstlIU1NvNECvQiYCa2hCJYXA= 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)(82310400026)(1800799024)(36860700013)(376014)(30052699003)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2025 23:49:16.7397 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 13608c6f-4db6-4f3e-a17d-08dd4af6b23d 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: MWH0EPF000971E4.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6491 X-Patchwork-State: RFC 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 | 195 +++++++++++++++++++++++++++++++++ include/linux/pds/pds_adminq.h | 77 +++++++++++++ include/uapi/fwctl/fwctl.h | 1 + include/uapi/fwctl/pds.h | 27 +++++ 8 files changed, 322 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 413ab79bf2f4..123f8a9c0b26 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9602,6 +9602,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,5 +2,6 @@ obj-$(CONFIG_FWCTL) += fwctl.o obj-$(CONFIG_FWCTL_BNXT) += bnxt/ 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..24979fe0deea --- /dev/null +++ b/drivers/fwctl/pds/main.c @@ -0,0 +1,195 @@ +// 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; + dma_addr_t ident_pa; + 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); + struct device *dev = &uctx->fwctl->dev; + + dev_dbg(dev, "%s: caps = 0x%04x\n", __func__, pdsfc->caps); + 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 void pdsfc_free_ident(struct pdsfc_dev *pdsfc) +{ + struct device *dev = &pdsfc->fwctl.dev; + + if (pdsfc->ident) { + dma_free_coherent(dev, sizeof(*pdsfc->ident), + pdsfc->ident, pdsfc->ident_pa); + pdsfc->ident = NULL; + pdsfc->ident_pa = DMA_MAPPING_ERROR; + } +} + +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 = {0}; + 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\n"); + return err; + } + + cmd.fwctl_ident.opcode = PDS_FWCTL_CMD_IDENT; + cmd.fwctl_ident.version = 0; + cmd.fwctl_ident.len = cpu_to_le32(sizeof(*ident)); + cmd.fwctl_ident.ident_pa = cpu_to_le64(ident_pa); + + err = pds_client_adminq_cmd(pdsfc->padev, &cmd, sizeof(cmd), &comp, 0); + if (err) { + dma_free_coherent(dev->parent, PAGE_SIZE, ident, ident_pa); + dev_err(dev, "Failed to send adminq cmd opcode: %u entity: %u err: %d\n", + cmd.fwctl_query.opcode, cmd.fwctl_query.entity, err); + return err; + } + + pdsfc->ident = ident; + pdsfc->ident_pa = ident_pa; + + dev_dbg(dev, "ident: version %u max_req_sz %u max_resp_sz %u max_req_sg_elems %u max_resp_sg_elems %u\n", + ident->version, ident->max_req_sz, ident->max_resp_sz, + ident->max_req_sg_elems, ident->max_resp_sg_elems); + + 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 pdsfc_dev *pdsfc __free(pdsfc_dev); + struct pds_auxiliary_dev *padev; + struct device *dev = &adev->dev; + int err = 0; + + padev = container_of(adev, struct pds_auxiliary_dev, aux_dev); + pdsfc = fwctl_alloc_device(&padev->vf_pdev->dev, &pdsfc_ops, + struct pdsfc_dev, fwctl); + if (!pdsfc) { + dev_err(dev, "Failed to allocate fwctl device struct\n"); + return -ENOMEM; + } + pdsfc->padev = padev; + + err = pdsfc_identify(pdsfc); + if (err) { + dev_err(dev, "Failed to identify device, err %d\n", err); + return err; + } + + err = fwctl_register(&pdsfc->fwctl); + if (err) { + dev_err(dev, "Failed to register device, err %d\n", err); + return err; + } + + auxiliary_set_drvdata(adev, no_free_ptr(pdsfc)); + + return 0; + +free_ident: + pdsfc_free_ident(pdsfc); + return err; +} + +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_ident(pdsfc); +} + +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..7fc353b63353 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,6 +44,7 @@ enum fwctl_device_type { FWCTL_DEVICE_TYPE_ERROR = 0, FWCTL_DEVICE_TYPE_MLX5 = 1, FWCTL_DEVICE_TYPE_BNXT = 3, + 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 Tue Feb 11 23:48:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13970868 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2053.outbound.protection.outlook.com [40.107.95.53]) (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 5795626A08F; Tue, 11 Feb 2025 23:49:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739317767; cv=fail; b=VJylKxkasyS6tBRkvuOYw+638TONRwrs4g60mc7Fl9t2XlJZmKPdJGzWCfgnO99F6A95v6J545O+q+Ng3FdTiDiJQ/upNj+tkwsJa2sPwe7Z4v9HpK2NrUVYPRRs1AqupnbtpqTLB60z3jcoqeBcclYF8OowvFxKjOSuxju2gMI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739317767; c=relaxed/simple; bh=6gokwYo/qIJ+5iXK3wCe2DdKHN0/HdtbHlNOgc+WG94=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dxbI4MDvDGdHQAZAFtBW1l4abkkKS7Nhr8xPZRIv53QiBHOFd7F2t8d4maZYxo0UpauuP010Jy8ybTHvEhoaFTL5wegnFIUIYLP6EKeJDpjH4jaD1KkI4QHhXrgPhEk/t8MfCsALupnYzi0HMajISnBguuGPuHHpYy1PWe0e1QY= 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=0Luh4Qir; arc=fail smtp.client-ip=40.107.95.53 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="0Luh4Qir" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tyRdY/CavFcp33JMsVvnCzLRYWbikFmoivwPbj0wU7ux9eOvdjEuLWGnmJQ1D2YU2Cpe5K++kESxFrEU9iMEXM90x42OmMKbLqyXqHPbu9VKrw0CH1J43WNSS24zZStbIiVdfXkTyNe/L44W8Nf4HvEHhLc6OoF8W1y8lOX4UutrfmpqQ7nW/fGn4NZffxzYzEM7mDovCBgGoqvYZdS93hZ5rOWEZ7k7YKYSNmntaauUB21dOq1XTFKI7JdkvC2jcXuUGzwtVU3x85BJ7EKa6wxLoYI/AUpP1yA8TxJ+8YMOEW6PgQ0d2nEu8YO/wBo4RPe5a5ntPZBFf1yYut8A1g== 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=Fbh4Zdd2Ig7frew6Bt92q5FnJIMBMex3hWxhmQKjSmk=; b=GD873zfbcz1NCJq8bIyCyC0ieebK1Je5PN+9G+hf3hHvek7F84I9jAOxLRJSFw019SaZ96PxS1Zi1SLt3u3SMtuNYIx0cglMWCzrVh+I0nfVqFKW63V14IMZsezBlAbGC8VB3z1TIlhxuI7VI586jRhkEcr3ApunI0Ny2uYi6FQ1HpciDeIaxd99YHdyVVhaC/DTcOLXzeTb6iGYXOnFF3RWUddNU/ckQ4sJBj6RQgWESHNMde5cU9erwVyVZlK2Q49Z+6so1SMjW2NrAXN9LMBmEECBRGVEwXhwfIUAWaORQczcOcvjWhK+Uk9smiKihkok5X4OMeCztSli7aZGPQ== 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=Fbh4Zdd2Ig7frew6Bt92q5FnJIMBMex3hWxhmQKjSmk=; b=0Luh4QirGJ1uA7TqXnNqbuCiCrUFpP5VdkankSLYS8sPXmkpnM6IJCCxdyVAaVGpkN1JQMAOcmva52AWxRs5DoFkt/oSIT4x/vTiCmCL6IrxGHeJge7So5YGgzMUkXGm5m0D+uM2Z+sGx0bymg5OPyRBvwjuLK1DJk8S1MZNHkc= Received: from MW4P222CA0013.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::18) by CY5PR12MB6322.namprd12.prod.outlook.com (2603:10b6:930:21::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8422.15; Tue, 11 Feb 2025 23:49:18 +0000 Received: from MWH0EPF000971E4.namprd02.prod.outlook.com (2603:10b6:303:114:cafe::fd) by MW4P222CA0013.outlook.office365.com (2603:10b6:303:114::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8445.13 via Frontend Transport; Tue, 11 Feb 2025 23:49:18 +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 MWH0EPF000971E4.mail.protection.outlook.com (10.167.243.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8445.10 via Frontend Transport; Tue, 11 Feb 2025 23:49:18 +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; Tue, 11 Feb 2025 17:49:15 -0600 From: Shannon Nelson To: , , , , , , , , , , , , , , , , , , CC: , Shannon Nelson Subject: [RFC PATCH fwctl 4/5] pds_fwctl: add rpc and query support Date: Tue, 11 Feb 2025 15:48:53 -0800 Message-ID: <20250211234854.52277-5-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20250211234854.52277-1-shannon.nelson@amd.com> References: <20250211234854.52277-1-shannon.nelson@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E4:EE_|CY5PR12MB6322:EE_ X-MS-Office365-Filtering-Correlation-Id: 59312965-721d-4baf-ab4b-08dd4af6b30a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|82310400026|1800799024|921020; X-Microsoft-Antispam-Message-Info: SLJN6UVDAf83uTN8TGa0j/0Pkp7q0H2Vo7S+YQHpNnZxv/PVgk8B2ZaK9RKm2ncqSMB+/JJc0dnWB+AuW3iQNKWqXvQ964oXDaYkbVd6oiHIwXUluBvTQJl1TwZOr3iXFfpcNhYVON84vOF0H2fqoem/BjTps17+r6EBKDqTAPZY2hexzE5j3wnmDA64vSA4hZ2Jt4Gc0vi28lOcSc38Y52us8VgGHjr1kI0vY+tYe2TklvKZbAttQ8DuNrJ+WOFH8jOIDqIiz/r64cLkGIt3002gSXfN099wjeZtkxud/K50gPONUezWAPVUwEKJocyT14c/3+2GUUir1971bQ9MkHFci528eqiOQ7teSlAEa0R1+dULLKAMg2RrbMkgHcg8PAOzXvtrgDw6eII5YO1IPtLEoDC4tRxE0s8aRPeWUHPuqVRtovUJuZEEizVG+UFcnubBkzsSBrlWDX0G7BA5j8HoMefMl228Fo222ijjOu67eU2H/p5x9RXjlwiJoNquWOtALreIvSlHP48xdAGXr427F4D9t+UXHJsHKPBiLHjSupaG6ijFjKbFbQ4AN418+YUwyUgesz5A/QOInsVO+Mza4wM/5GK9UBCstT5nCv6dAd3o596V8Ro6DGDFoi+WQ4aDUSYVDoF5mXjabmtF6+VpQlPVXaN+lpRlZmIRWo7ymkRaNYDVsgbZNdUm9qkxiW6KSmAqp6YQZSW9X9V266cXl553MW4hCbj5v/YIAGmaoWtEZdBIXdQQr2E1Zr1EfC4/0h+uXlDmVqBcTY50iHSJjaOy5ZmHgIgagj4KbmVSebrpiYNIqXnI5ymB6emfIYF76XBUiM75LWUSLdsCG5uovuR6YuKaRSXhR/+goVF2ac7uaOiJCp4XHbZ7RzN+MdCUY6LK2F12qIm7K/X1wbO4lRx8KYyl99/YlzzZpc1JsS0mCbxtoi+cbP0iMjnSxY+2bME5f58QeO9iqDG6Z+UmeZraaB5UXd8OB4IZaRq9JApu+zPVSJKewp275r831A5XHb8J/4uUEOtGljM+h+DLaY4Km86x94KhUblBlmYIFWy2h+iYUGSf/FXxvQOX+1s6ui4STOLEWuWVxYKMKfXSN8dXyyOW/mXbJ1vbMa1xclaUfvuntpxxRfu4Ho4Ujgfj/Hq7+0ZtOmKpQ17RXOyjOuY8Qb9XW9J5LJU+I3WmJkfAKpGXm7nQYFWzZl4D79Hh1Jp+g5mNXQzJPQ/N5EqYbkYU1gil3e5R3cncpZ+FQSFxt5Yx7KrHdl3dpQuIbcDv5L6Wz3DVUKXnQsgzQXeAiloRb5etcymofTf5am+FZ87Oi8O5L7iwTy6RozifZMCBihKVFGqp+Z+xlvN3D6v0/KIGHZSrUEfpxNrgeJoEfpwU4pgdPycYbglGQQFAYc6yRA+9QNdixYd52nXpzYx0GU7rkeoHkfrU9kAQFhLvbbfUa4Laqm7nnt4YQmnwo+qIpwrflaMhnjtA6SrmEfoT/LBOLKnuLAKXG50Ugs= 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)(376014)(7416014)(36860700013)(82310400026)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2025 23:49:18.0990 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 59312965-721d-4baf-ab4b-08dd4af6b30a 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: MWH0EPF000971E4.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6322 X-Patchwork-State: RFC 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 | 369 ++++++++++++++++++++++++++++++++- include/linux/pds/pds_adminq.h | 187 +++++++++++++++++ include/uapi/fwctl/pds.h | 16 ++ 3 files changed, 569 insertions(+), 3 deletions(-) diff --git a/drivers/fwctl/pds/main.c b/drivers/fwctl/pds/main.c index 24979fe0deea..b60a66ef1fac 100644 --- a/drivers/fwctl/pds/main.c +++ b/drivers/fwctl/pds/main.c @@ -15,12 +15,22 @@ #include #include +DEFINE_FREE(kfree_errptr, void *, if (!IS_ERR_OR_NULL(_T)) kfree(_T)); +DEFINE_FREE(kvfree_errptr, void *, if (!IS_ERR_OR_NULL(_T)) kvfree(_T)); + struct pdsfc_uctx { struct fwctl_uctx uctx; u32 uctx_caps; 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; @@ -28,6 +38,9 @@ struct pdsfc_dev { u32 caps; dma_addr_t ident_pa; 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)); @@ -112,10 +125,351 @@ 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; + + if (pdsfc->endpoints) { + int i; + + 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; + int i; + + for (i = 0; i < pdsfc->endpoints->num_entries; 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 pds_fwctl_query_data_endpoint *entries = NULL; + struct device *dev = &pdsfc->fwctl.dev; + union pds_core_adminq_comp comp = {0}; + union pds_core_adminq_cmd cmd = {0}; + struct pds_fwctl_query_data *data; + dma_addr_t data_pa; + int err; + int i; + + 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.fwctl_query.opcode = PDS_FWCTL_CMD_QUERY; + cmd.fwctl_query.entity = PDS_FWCTL_RPC_ROOT; + cmd.fwctl_query.version = 0; + cmd.fwctl_query.query_data_buf_len = cpu_to_le32(PAGE_SIZE); + cmd.fwctl_query.query_data_buf_pa = cpu_to_le64(data_pa); + + dev_dbg(dev, "cmd: opcode %d entity %d version %d query_data_buf_len %d query_data_buf_pa %llx\n", + cmd.fwctl_query.opcode, cmd.fwctl_query.entity, cmd.fwctl_query.version, + le32_to_cpu(cmd.fwctl_query.query_data_buf_len), + le64_to_cpu(cmd.fwctl_query.query_data_buf_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; + + entries = (struct pds_fwctl_query_data_endpoint *)data->entries; + dev_dbg(dev, "num_entries %d\n", data->num_entries); + for (i = 0; i < data->num_entries; i++) + dev_dbg(dev, "endpoint: id %d\n", entries[i].id); + + return data; +} + +static int pdsfc_init_endpoints(struct pdsfc_dev *pdsfc) +{ + struct pds_fwctl_query_data_endpoint *ep_entry; + struct device *dev = &pdsfc->fwctl.dev; + int i; + + pdsfc->endpoints = pdsfc_get_endpoints(pdsfc, &pdsfc->endpoints_pa); + if (IS_ERR(pdsfc->endpoints)) { + dev_err(dev, "Failed to query endpoints\n"); + return PTR_ERR(pdsfc->endpoints); + } + + pdsfc->endpoint_info = vcalloc(pdsfc->endpoints->num_entries, + sizeof(*pdsfc->endpoint_info)); + if (!pdsfc->endpoint_info) { + dev_err(dev, "Failed to allocate endpoint_info array\n"); + pdsfc_free_endpoints(pdsfc); + return -ENOMEM; + } + + ep_entry = (struct pds_fwctl_query_data_endpoint *)pdsfc->endpoints->entries; + for (i = 0; i < pdsfc->endpoints->num_entries; 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 pds_fwctl_query_data_operation *entries = NULL; + struct device *dev = &pdsfc->fwctl.dev; + union pds_core_adminq_comp comp = {0}; + union pds_core_adminq_cmd cmd = {0}; + struct pds_fwctl_query_data *data; + dma_addr_t data_pa; + int err; + int i; + + /* 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.fwctl_query.opcode = PDS_FWCTL_CMD_QUERY; + cmd.fwctl_query.entity = PDS_FWCTL_RPC_ENDPOINT; + cmd.fwctl_query.version = 0; + cmd.fwctl_query.query_data_buf_len = cpu_to_le32(PAGE_SIZE); + cmd.fwctl_query.query_data_buf_pa = cpu_to_le64(data_pa); + cmd.fwctl_query.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; + + entries = (struct pds_fwctl_query_data_operation *)data->entries; + dev_dbg(dev, "num_entries %d\n", data->num_entries); + for (i = 0; i < data->num_entries; i++) + dev_dbg(dev, "endpoint %d operation: id %x scope %d\n", + ep, entries[i].id, entries[i].scope); + + 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 = NULL; + struct pdsfc_rpc_endpoint_info *ep_info = NULL; + struct device *dev = &pdsfc->fwctl.dev; + int i; + + if (!pdsfc->ident) { + dev_err(dev, "Ident not available\n"); + return -EINVAL; + } + + /* 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; + void *out_payload __free(kfree_errptr) = NULL; + void *in_payload __free(kfree_errptr) = NULL; + struct device *dev = &uctx->fwctl->dev; + union pds_core_adminq_comp comp = {0}; + dma_addr_t out_payload_dma_addr = 0; + union pds_core_adminq_cmd cmd = {0}; + dma_addr_t in_payload_dma_addr = 0; + 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"); + 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 = ERR_PTR(err); + goto done; + } + } + + cmd.fwctl_rpc.opcode = PDS_FWCTL_CMD_RPC; + cmd.fwctl_rpc.flags = PDS_FWCTL_RPC_IND_REQ | PDS_FWCTL_RPC_IND_RESP; + cmd.fwctl_rpc.ep = cpu_to_le32(rpc->in.ep); + cmd.fwctl_rpc.op = cpu_to_le32(rpc->in.op); + cmd.fwctl_rpc.req_pa = cpu_to_le64(in_payload_dma_addr); + cmd.fwctl_rpc.req_sz = cpu_to_le32(rpc->in.len); + cmd.fwctl_rpc.resp_pa = cpu_to_le64(out_payload_dma_addr); + cmd.fwctl_rpc.resp_sz = cpu_to_le32(rpc->out.len); + + dev_dbg(dev, "%s: ep %d op %x req_pa %llx req_sz %d req_sg %d resp_pa %llx resp_sz %d resp_sg %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); + + dynamic_hex_dump("in ", DUMP_PREFIX_OFFSET, 16, 1, in_payload, rpc->in.len, true); + + 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); + + dev_dbg(dev, "%s: status %d comp_index %d err %d resp_sz %d color %d\n", + __func__, comp.fwctl_rpc.status, comp.fwctl_rpc.comp_index, + comp.fwctl_rpc.err, comp.fwctl_rpc.resp_sz, + comp.fwctl_rpc.color); + + 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); + + return out; } static const struct fwctl_ops pdsfc_ops = { @@ -150,16 +504,23 @@ static int pdsfc_probe(struct auxiliary_device *adev, return err; } + err = pdsfc_init_endpoints(pdsfc); + if (err) { + dev_err(dev, "Failed to init endpoints, err %d\n", err); + goto free_ident; + } + err = fwctl_register(&pdsfc->fwctl); if (err) { dev_err(dev, "Failed to register device, err %d\n", err); - return err; + goto free_endpoints; } - auxiliary_set_drvdata(adev, no_free_ptr(pdsfc)); return 0; +free_endpoints: + pdsfc_free_endpoints(pdsfc); free_ident: pdsfc_free_ident(pdsfc); return err; @@ -170,6 +531,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); pdsfc_free_ident(pdsfc); } diff --git a/include/linux/pds/pds_adminq.h b/include/linux/pds/pds_adminq.h index 7fc353b63353..33cd03388b15 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 Tue Feb 11 23:48:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13970866 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2040.outbound.protection.outlook.com [40.107.94.40]) (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 49FC426B971; Tue, 11 Feb 2025 23:49:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739317766; cv=fail; b=NPrI32m65oDdvBbCHdOfOOrG8v7MIDmsWU0NgdftUlLU0sspIHbN0RKn/GOxKn9ec+YoGk/8S3DUYt1opMdkCkiHQbhtmZ+/n/GZtK3IEx1s9RqKxbqEQeEbKOLUmy8/TSfPqUe7Dv+AiefQJMqB54B834sHuup9LDCzC7plDP4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739317766; c=relaxed/simple; bh=3rXogz/wORLMze9KByC7imBV1rtKLLeTdH/jHdx3ubw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=me0Ig4GgpVAA/e0pwZZtpC36YqmIJpr4Ljf84Ja+11roz2pXQiPB2hhJlz+smqsflNQakZv3Gn5UqgShnEerN5fBqGHGnOva0+9IGOA1meXKW3fTNoq67pqXJPLHr8eu+iGfZoOHalgP7vvjG4eoEjxjJ+vDb2uaIQyl+dh+pRg= 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=uDLV2c3f; arc=fail smtp.client-ip=40.107.94.40 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="uDLV2c3f" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vxu/6rYXOhjLgk10JjTt0QYAOqNpP+LzwAvbx0ujnIt8ahpno1Fkh90zGamDcLKjOEeZ2h80dzYpzr8xVLS3CPazwxrjHwAiHXaU2JSRqMNHMjW+S/ZtlPXQ6X94y0suHqcVe4M0EfEUd0nomnO17TvGmsWrYSXT6WprXzfDOatz9crMitYIcY4fDBnMXwNyIonTj1DgeZszLiTGSX5otLSJOpS0mI5uMRj05xK2fACpWCyqaO6MSQCD9jV/et0OPajz0nicVc4HydL/LYtLWWm+kzqvmscJ6MhBpATKT3ljZ9UiKp8bgMt+QxacSvoIVvoudhtp6RsREieWVUmUFg== 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=V3A612y5dAH2TQJRxuNdGtK7VQVtDIH8XnD+dV1qBc4=; b=TQSEfUTQOIZ+vlEQukUAaeshrOCsuIIJozaxlWZtSZbeXD6gM9abB9wa2VEB65iuxX/d0kYCxNV5T7hqCTScCdGPPGPRG4rWKdtOvrD7XrUxyruJ5EDSbKSdz7/j8TOf+OBpDiup724zetldlteegvwZQ95LtQvXu9kHMiauho0iRHIIS3WvLF/ApuS9wNdKHraLtGIGh86zCU9z5W9g80dW4Wc0H7nLLgHKU/vVYcxDgQI2Kn5/42JYeCRjwz5+Twwl9AVjhE+7+ZomdlpVG2WqCs225GP/zBamMYWgDOuE7TUOEfssksbbPbb3z1qB2HsZbyXHQdVraCriCBPSnQ== 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=V3A612y5dAH2TQJRxuNdGtK7VQVtDIH8XnD+dV1qBc4=; b=uDLV2c3fb1/h2VjiBKXotmuR33f0BorNj6t4uteZaEkyfEzEaL9ENQHnG71WogWuGnKAiIHoXpQbGItHbxkyUrRgyPDKJqUXaMSVVcRpJ/sbn53NAxHJVDQTYwhpb2clRrYA6SYj7T5hMugZ27PAfT93xjqXg2ylye6mWBEtRqM= Received: from MW4PR04CA0155.namprd04.prod.outlook.com (2603:10b6:303:85::10) by IA1PR12MB9522.namprd12.prod.outlook.com (2603:10b6:208:594::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8422.18; Tue, 11 Feb 2025 23:49:20 +0000 Received: from MWH0EPF000971E6.namprd02.prod.outlook.com (2603:10b6:303:85:cafe::d4) by MW4PR04CA0155.outlook.office365.com (2603:10b6:303:85::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8398.31 via Frontend Transport; Tue, 11 Feb 2025 23:49:20 +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 MWH0EPF000971E6.mail.protection.outlook.com (10.167.243.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8445.10 via Frontend Transport; Tue, 11 Feb 2025 23:49:19 +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; Tue, 11 Feb 2025 17:49:17 -0600 From: Shannon Nelson To: , , , , , , , , , , , , , , , , , , CC: , Shannon Nelson Subject: [RFC PATCH fwctl 5/5] pds_fwctl: add Documentation entries Date: Tue, 11 Feb 2025 15:48:54 -0800 Message-ID: <20250211234854.52277-6-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20250211234854.52277-1-shannon.nelson@amd.com> References: <20250211234854.52277-1-shannon.nelson@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E6:EE_|IA1PR12MB9522:EE_ X-MS-Office365-Filtering-Correlation-Id: ed5e5ec9-f73c-43e6-53f9-08dd4af6b3ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|82310400026|36860700013|921020; X-Microsoft-Antispam-Message-Info: Y1iAiTMKheJlvXT8I21WaR4IGo4Idjl/OgXhroWj+kqYvs/S03h7R75iE2MmWJCL+bDEXX+CBTYphoSWY1cPYZIWVAfyIpB2Qm402TI+CZ/VZ54W/8uAB+RYj6Wl7ylBnfg6H/DkNQtNblp+76tWa9WN/UVzqpG2iI4dH/4rAL/j9EwOqVzgbxr10w3ezBVXQt3VVkj6aCoAy0pWRUcZrE3Q3QYSCZKLcSFBK+bz6PB0Bd4C5l3xt5F1QGfM1zSrHVUU+4PDXlO1sUE+5eDwbozXztc+Q4PYjylflCYCRHkDQ1/8+kqkuL34PdFOBjjTtksp53G7nbyUVkPGjnaEtH8QTwEAd7nP7iPHO3J6iolKwFa5jw+7FcVFJO+1j8FVbKPH+1im5gnZAsGhuS4j86/oywXgtlfHvV2v2eDXCOApc54C67PPgKUQqJ8oCKsNpjZNcrPzkFa6DbH63lWSci8OxNvOqrO6D1T6ROwtA4o3EpYLh9iYwLiWGWvuJJhGyuorbLcla6LIOD5Q1DIDMnzvJg8ZsHVkWESnbOnrG58zoVTO3a2D/Bhk8nRgpoQ4n8NmWVOeyry+3m6MpfoXbn2+o6CQzfbxHUecG2H4Zr/tKrsWf36g7bPKK+4BVL2NVzq7m7WXdYNSMxmpONoebnjDieeQiQc7NiFDKUoWXdTiGduFdJOH6NOTKu1STbOvvdrIhs/NNBnvtREN/wEOJH+ZimNDQuSfrZPtvpXbpAYsdnLtnBq4n7kw1PJqKxLiJx6dZfgngn/d+X9eqbTqv2/NuALLi1ZGeYMr+to9krTSqnH6yVCqh5gNBkaJhzEfb6wHzEGeBpDLSFOZsptBkSeiDOzYXgYhozGs+udkSLjUSkfXZfViowT+DUA7qDDPlS6DFINq4pSR0o+L4urnoQn5TXgglbrONGgzpxho2MzseVSBaPKR1k37JyhB6FcCpusVXSXz6lNXHSjvb2Gh8tdVTjmxPwKbZJX18ixHFyg4wBYF9n38YFRUF0klMgjlEEMoT21GOFiaQ5XqoSjLv5fUPDGwdQ1ZspriXP/bvLIRy9J8SsbaCh8ngfobocx2eADlvu3wR0VPZEzg2SfOr6Cfav/Gat790YEYe/V8v7AFt/yv444gbFGYM07/ljbJ1qLccniABBciZpEwD8vfkeRQMy8cZr5/BdyVxjIxa62Fxfi4eP/22BFgchwigC/V2QW0X1REP/Raxr+Scrv6a+boJKYfjPL52jwWnWEIqDFnlipf92VrfrMdwoOG7Y7MCey1FveZMA4k/MsFRt0nzdOQeNaj962iXVMWiyfB/F0W/qp1zM89wv8BCies/scK08+enFJts+UScU6RTVQVC0Id6iAYxB0phIWqstp7AHM/PVI0UiJbLT33qvrF7QfUsXLe4p0asypt0vXryg8y9KSn8akB/CXSzRq89tTxP1znwtkfZ/Rl4bF0rsGqIuzmglMSsLxqxXtAe+ykgzPiZxEXse3wFNLH+6NdU7pCaO/gaRoBsBC7f+Orh1Ne5tNH 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)(1800799024)(7416014)(376014)(82310400026)(36860700013)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2025 23:49:19.6132 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ed5e5ec9-f73c-43e6-53f9-08dd4af6b3ef 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: MWH0EPF000971E6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB9522 X-Patchwork-State: RFC 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..9fb1b4ac0a5e --- /dev/null +++ b/Documentation/userspace-api/fwctl/pds_fwctl.rst @@ -0,0 +1,41 @@ +.. 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 adminq commands 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 minumum 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 adminq request is then +put together with the request data and sent to the firmware, and the +results are returned to the caller. +