From nobody Fri Nov 29 17:43:18 2024 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2086.outbound.protection.outlook.com [40.107.243.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F76A15B97E; Mon, 16 Sep 2024 20:51:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726519891; cv=fail; b=AkD2ynp/fH2DUtYt4E4umoNI+DMOyA21NTQ/1xFIeJqWD4wD5GhuoUZI4OIX194VwDcLcAqm4XpRFYhDWtVIbg/vfeJm4RBwxjYHTSqeaH3NCcGVNajka0raxchkIUTHR92EX8YXLUvbL4Yuz56mqDG6FMPKklZ5ySJRPDM3TrQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726519891; c=relaxed/simple; bh=4xz4L5cHBRS4/lfXuu69Vf2gDGFi7Km1EFzSkNcZPXg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aVJbzikGzKHpxrnGsAOJ1zGn3mLW4GEw5VoJWsprbhWWsIw52DAEG2NCmvi6GT1dPC8jB11Qxgv22zo8PyPWlMvBEhE5kyNcj5aRWRGMz7UVGUXnpI+GCdOy7zbNQ5G+suR1Jw5LvhCQRgfgSK3SjZ1noxZniG9+Vzpkuh7oZUU= 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=OpVGUKU5; arc=fail smtp.client-ip=40.107.243.86 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="OpVGUKU5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=g9NuttBZJ99cMUBH0LL+BQKWIqpyN6gbwiE72fCU0Ow0VucjeoJ8Cx+XSUB9hUsZ9XSQPzxmMXTagdGFB5o8LvLpxhVosW2CfPV4iMoWWfMBuzmmL82FHA8Jmt8EAABLMI7Clinh3sHwwd+GAmkpE4T/RrAaX4oUw4Dye3Ss3F48aXrd0dCWy+KH4RrHTi+cGIwBI4CHVT0uKrt+DPUomSaFjGV1JK5gWfCBmwHxac3VVc0t7dCY1zj20z0lklPW2Io2zQE60htREu7s+T9kS+tDlJTNF2gYZP+3yH5WQx11B1XEtdICi6z6ZH/8Dz1XcJURwZnu/XYn+DE448mpcg== 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=FKtIvIccbUe2ws4r9L6LxZKPzp9wEujUe/XQAHI58Kk=; b=Am8YbnfpqvAPnq3fvGR/7ajWv7WTDuP5AfmK54P759jfP35R4a0y3t76DgW32dELurtMVegKsXkaEvBoSeT9G28dMKLwf0RSdT6FLTgdixkzM74/7TjYOGx8eKMVLCQyudhJ5T9foItqBZfBBcsHFBChmFAvBs+KNof5kS2UQuEvT3p9vFcDJYEW0PWGWkKYjpHud3TX1bBuFmodeJB+ILQHhYMnJd1vBZ5Vd81lIcoPT/4ooyP5V38CQjS6Ja7jT6LBVbrWlTKt3mH3haS4jU+8MQjSBeIP5N2W2TZcTbyTuxQElaju5IBPpQ+E6AAdmJrSl1OSE1ScJYACJ2GIWw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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=FKtIvIccbUe2ws4r9L6LxZKPzp9wEujUe/XQAHI58Kk=; b=OpVGUKU5Ix5OvXOplki4L+FwFHrTgKsOHTloXEvTG3jXHJwtnY39cuS6ypVaS4De5YD2KKNwBLszX3DdHWTT2kqBYB5poDfzHTzC4JTTDQiF49pNLPFhztUbwsmhdDG2YXwhjUEUjJ1uSwv9F3IMtmymTPa21rc7FXbrkCxlS2Y= Received: from BN0PR10CA0014.namprd10.prod.outlook.com (2603:10b6:408:143::12) by MN2PR12MB4253.namprd12.prod.outlook.com (2603:10b6:208:1de::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.23; Mon, 16 Sep 2024 20:51:22 +0000 Received: from BL02EPF00021F6D.namprd02.prod.outlook.com (2603:10b6:408:143:cafe::f5) by BN0PR10CA0014.outlook.office365.com (2603:10b6:408:143::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.29 via Frontend Transport; Mon, 16 Sep 2024 20:51:22 +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 BL02EPF00021F6D.mail.protection.outlook.com (10.167.249.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Mon, 16 Sep 2024 20:51:22 +0000 Received: from weiserver.amd.com (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; Mon, 16 Sep 2024 15:51:20 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V5 1/5] PCI: Add TLP Processing Hints (TPH) support Date: Mon, 16 Sep 2024 15:50:59 -0500 Message-ID: <20240916205103.3882081-2-wei.huang2@amd.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240916205103.3882081-1-wei.huang2@amd.com> References: <20240916205103.3882081-1-wei.huang2@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: BL02EPF00021F6D:EE_|MN2PR12MB4253:EE_ X-MS-Office365-Filtering-Correlation-Id: 5e90af6c-b233-4b8b-7c58-08dcd69152a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?xbT80MeEVJhZPzyBDonYngnLtNnwTp9ytPc8/y6NW63xmWxjLLPFXU4zFv7H?= =?us-ascii?Q?Gbj5mf9fRUbuLtHvTxt4SbfF1tXUdd761BfXCBq8Olu2PmaCRdOUHLv/uxg3?= =?us-ascii?Q?jXaG4jo8kPCB1l0m7U4LIld5UiYI2m6LhhxC43EVv89i09zZhh5CtpshPNcN?= =?us-ascii?Q?uV9/7Z1YiAGf1ZBQjl22Jdnc75EeT9kYHHWdHCwn4tUkWE/VpqpyDpLsZGpZ?= =?us-ascii?Q?xv+xfbyqBGaFcSojqQXtuoYjeGfEX6wFh6ECKvEOYwaG2nwGojI/kxBV50Oq?= =?us-ascii?Q?7Xy+1nboSRM7PBlEpf4JyOjzTaZjl9p8Q5YkAK4lXlyID6aeOt4+twZHqv6X?= =?us-ascii?Q?gkJx3ot9esDkqJXKwGYqsC3jI+I7OaFf9SWN9YTeJhKzSz7vGdZQi4zjA9qf?= =?us-ascii?Q?flklmwYcWqwnufmIjMa7VCr3gfjPbvu+0bdQ8yeYjEDzndq/Jb+FaisAbNdB?= =?us-ascii?Q?zebZFL2YEwixd+r8xpRVlc0iBJImlRbeWcpnjDBqRXBnOFRX23jXuZs97/0t?= =?us-ascii?Q?zj4Sop9GyjpJ72jz+MJyPTFd4Yaf/7worZbMmOJgVLSiUwofKWvyJBLQazNI?= =?us-ascii?Q?dr5++zE2TJNli69T6gBqHCwODg4+gVEn9GOruVL4H3l6uwh0Qzj8jy8lNG16?= =?us-ascii?Q?QjX68V0ZtmpfwbojcOP6TzZXdt4H3FBlNqe8HMmMBw3rwdJFbs9/p2w1yca0?= =?us-ascii?Q?U2S2hF59gmB4adfvB3lOvJbEiEjUvIe+IBY+I5usGnuqTlg2PbwXNfGkBURP?= =?us-ascii?Q?1qCbO0LLMEJaFv+8Pm+AOwbxO4NA7Q9jMepaEWBDFV4ggVraoHBnQ6CEjhsy?= =?us-ascii?Q?j5v9/MrKM0ydM048A/vG/q8rK/7f0bPZ8etQqsX+YrXIYZCfw5XquTZ33/qo?= =?us-ascii?Q?EhikdlYezzgS0r7635sc6eBBXEdIVAQ3F7RkSpCo18Of6Gupejy/FDQoR1Yd?= =?us-ascii?Q?My+q6viRB5K7ZJB4h0PA0s1zjFlHsk4PFLPi8cjjwC4+JqV/k0AGTTSAMtVX?= =?us-ascii?Q?OfEirl+qbHJFHrgw+/h0xpx95o20ljUlpSpup8FfsqQTQXVRJ1KATcMuhhzW?= =?us-ascii?Q?neDir8h/NBFxCOEIykP72v+GuHYZJLU8zbnFtdW3x2mP6X/mchXFzC17qJO7?= =?us-ascii?Q?YMf94Au2gUUxKnPv8ZOc38GR82FKYqdahezObuA9iQUANjo85So2rKf8N/ic?= =?us-ascii?Q?A3Ovog9br1gAdWGhRnzcilIaqSwrbHSP3hwcTSS3gLd5xI6ndTrqAmzv2xOC?= =?us-ascii?Q?eWfj5+ajl1uHugmDzFUmNgoCM0R5H2rLN5pg95PlFbQOP6wCx6eDFsYvqzBX?= =?us-ascii?Q?TFID8qWSO6TiRMXZIiqjOrN7Kx8KI6Qi2WoZFzLIr7ILiivMxw/+kgokwqem?= =?us-ascii?Q?8b4BCAMJL4657q0icCYR2DEMqrmp5FqVO8Li3yPcfp4EXC/TSjTxzUUve4r3?= =?us-ascii?Q?J2ZS9Y0uSUQ8ZGoKTUpCeYyVGY4PnFPV?= 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)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2024 20:51:22.2643 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5e90af6c-b233-4b8b-7c58-08dcd69152a8 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: BL02EPF00021F6D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4253 Content-Type: text/plain; charset="utf-8" Add support for PCIe TLP Processing Hints (TPH) support (see PCIe r6.2, sec 6.17). Add missing TPH register definitions in pci_regs.h, including the TPH Requester capability register, TPH Requester control register, TPH Completer capability, and the ST fields of MSI-X entry. Introduce pcie_enable_tph() and pcie_disable_tph(), enabling drivers to toggle TPH support and configure specific ST mode as needed. Also add a new kernel parameter, "pci=3Dnotph", allowing users to disable TPH support across the entire system. Co-developed-by: Jing Liu Signed-off-by: Jing Liu Co-developed-by: Paul Luse Signed-off-by: Paul Luse Co-developed-by: Eric Van Tassell Signed-off-by: Eric Van Tassell Signed-off-by: Wei Huang Reviewed-by: Ajit Khaparde Reviewed-by: Somnath Kotur Reviewed-by: Andy Gospodarek Reviewed-by: Jonathan Cameron Reviewed-by: Lukas Wunner --- .../admin-guide/kernel-parameters.txt | 4 + drivers/pci/pci.c | 4 + drivers/pci/pci.h | 12 ++ drivers/pci/pcie/Kconfig | 11 + drivers/pci/pcie/Makefile | 1 + drivers/pci/pcie/tph.c | 199 ++++++++++++++++++ drivers/pci/probe.c | 1 + include/linux/pci-tph.h | 21 ++ include/linux/pci.h | 7 + include/uapi/linux/pci_regs.h | 38 +++- 10 files changed, 290 insertions(+), 8 deletions(-) create mode 100644 drivers/pci/pcie/tph.c create mode 100644 include/linux/pci-tph.h diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index 09126bb8cc9f..8579d0fbcd33 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -4617,6 +4617,10 @@ nomio [S390] Do not use MIO instructions. norid [S390] ignore the RID field and force use of one PCI domain per PCI function + notph [PCIE] If the PCIE_TPH kernel config parameter + is enabled, this kernel boot option can be used + to disable PCIe TLP Processing Hints support + system-wide. =20 pcie_aspm=3D [PCIE] Forcibly enable or ignore PCIe Active State Power Management. diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index ffaaca0978cb..b6f60f7476cc 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1813,6 +1813,7 @@ int pci_save_state(struct pci_dev *dev) pci_save_dpc_state(dev); pci_save_aer_state(dev); pci_save_ptm_state(dev); + pci_save_tph_state(dev); return pci_save_vc_state(dev); } EXPORT_SYMBOL(pci_save_state); @@ -1917,6 +1918,7 @@ void pci_restore_state(struct pci_dev *dev) pci_restore_vc_state(dev); pci_restore_rebar_state(dev); pci_restore_dpc_state(dev); + pci_restore_tph_state(dev); pci_restore_ptm_state(dev); =20 pci_aer_clear_status(dev); @@ -6869,6 +6871,8 @@ static int __init pci_setup(char *str) pci_no_domains(); } else if (!strncmp(str, "noari", 5)) { pcie_ari_disabled =3D true; + } else if (!strncmp(str, "notph", 5)) { + pci_no_tph(); } else if (!strncmp(str, "cbiosize=3D", 9)) { pci_cardbus_io_size =3D memparse(str + 9, &str); } else if (!strncmp(str, "cbmemsize=3D", 10)) { diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 79c8398f3938..8eeabbbfa137 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -571,6 +571,18 @@ static inline int pci_iov_bus_range(struct pci_bus *bu= s) =20 #endif /* CONFIG_PCI_IOV */ =20 +#ifdef CONFIG_PCIE_TPH +void pci_restore_tph_state(struct pci_dev *dev); +void pci_save_tph_state(struct pci_dev *dev); +void pci_no_tph(void); +void pci_tph_init(struct pci_dev *dev); +#else +static inline void pci_restore_tph_state(struct pci_dev *dev) { } +static inline void pci_save_tph_state(struct pci_dev *dev) { } +static inline void pci_no_tph(void) { } +static inline void pci_tph_init(struct pci_dev *dev) { } +#endif + #ifdef CONFIG_PCIE_PTM void pci_ptm_init(struct pci_dev *dev); void pci_save_ptm_state(struct pci_dev *dev); diff --git a/drivers/pci/pcie/Kconfig b/drivers/pci/pcie/Kconfig index 17919b99fa66..61e4bd16eaf1 100644 --- a/drivers/pci/pcie/Kconfig +++ b/drivers/pci/pcie/Kconfig @@ -155,3 +155,14 @@ config PCIE_EDR the PCI Firmware Specification r3.2. Enable this if you want to support hybrid DPC model which uses both firmware and OS to implement DPC. + +config PCIE_TPH + bool "TLP Processing Hints" + depends on ACPI + default n + help + This option adds support for PCIe TLP Processing Hints (TPH). + TPH allows endpoint devices to provide optimization hints, such as + desired caching behavior, for requests that target memory space. + These hints, called Steering Tags, can empower the system hardware + to optimize the utilization of platform resources. diff --git a/drivers/pci/pcie/Makefile b/drivers/pci/pcie/Makefile index 6461aa93fe76..3542b42ea0b9 100644 --- a/drivers/pci/pcie/Makefile +++ b/drivers/pci/pcie/Makefile @@ -13,3 +13,4 @@ obj-$(CONFIG_PCIE_PME) +=3D pme.o obj-$(CONFIG_PCIE_DPC) +=3D dpc.o obj-$(CONFIG_PCIE_PTM) +=3D ptm.o obj-$(CONFIG_PCIE_EDR) +=3D edr.o +obj-$(CONFIG_PCIE_TPH) +=3D tph.o diff --git a/drivers/pci/pcie/tph.c b/drivers/pci/pcie/tph.c new file mode 100644 index 000000000000..1efd76c8dd30 --- /dev/null +++ b/drivers/pci/pcie/tph.c @@ -0,0 +1,199 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * TPH (TLP Processing Hints) support + * + * Copyright (C) 2024 Advanced Micro Devices, Inc. + * Eric Van Tassell + * Wei Huang + */ +#include +#include +#include +#include +#include + +#include "../pci.h" + +/* System-wide TPH disabled */ +static bool pci_tph_disabled; + +static u8 get_st_modes(struct pci_dev *pdev) +{ + u32 reg; + + pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CAP, ®); + reg &=3D PCI_TPH_CAP_ST_NS | PCI_TPH_CAP_ST_IV | PCI_TPH_CAP_ST_DS; + + return reg; +} + +/* Return device's Root Port completer capability */ +static u8 get_rp_completer_type(struct pci_dev *pdev) +{ + struct pci_dev *rp; + u32 reg; + int ret; + + rp =3D pcie_find_root_port(pdev); + if (!rp) + return 0; + + ret =3D pcie_capability_read_dword(rp, PCI_EXP_DEVCAP2, ®); + if (ret) + return 0; + + return FIELD_GET(PCI_EXP_DEVCAP2_TPH_COMP_MASK, reg); +} + +/** + * pcie_disable_tph - Turn off TPH support for device + * @pdev: PCI device + * + * Return: none + */ +void pcie_disable_tph(struct pci_dev *pdev) +{ + if (!pdev->tph_cap) + return; + + if (!pdev->tph_enabled) + return; + + pci_write_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, 0); + + pdev->tph_mode =3D 0; + pdev->tph_req_type =3D 0; + pdev->tph_enabled =3D 0; +} +EXPORT_SYMBOL(pcie_disable_tph); + +/** + * pcie_enable_tph - Enable TPH support for device using a specific ST mode + * @pdev: PCI device + * @mode: ST mode to enable. Current supported modes include: + * + * - PCI_TPH_ST_NS_MODE: NO ST Mode + * - PCI_TPH_ST_IV_MODE: Interrupt Vector Mode + * - PCI_TPH_ST_DS_MODE: Device Specific Mode + * + * Checks whether the mode is actually supported by the device before enab= ling + * and returns an error if not. Additionally determines what types of requ= ests, + * TPH or extended TPH, can be issued by the device based on its TPH reque= ster + * capability and the Root Port's completer capability. + * + * Return: 0 on success, otherwise negative value (-errno) + */ +int pcie_enable_tph(struct pci_dev *pdev, int mode) +{ + u32 reg; + u8 dev_modes; + u8 rp_req_type; + + /* Honor "notph" kernel parameter */ + if (pci_tph_disabled) + return -EINVAL; + + if (!pdev->tph_cap) + return -EINVAL; + + if (pdev->tph_enabled) + return -EBUSY; + + /* Sanitize and check ST mode comptability */ + mode &=3D PCI_TPH_CTRL_MODE_SEL_MASK; + dev_modes =3D get_st_modes(pdev); + if (!((1 << mode) & dev_modes)) + return -EINVAL; + + pdev->tph_mode =3D mode; + + /* Get req_type supported by device and its Root Port */ + pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CAP, ®); + if (FIELD_GET(PCI_TPH_CAP_EXT_TPH, reg)) + pdev->tph_req_type =3D PCI_TPH_REQ_EXT_TPH; + else + pdev->tph_req_type =3D PCI_TPH_REQ_TPH_ONLY; + + rp_req_type =3D get_rp_completer_type(pdev); + + /* Final req_type is the smallest value of two */ + pdev->tph_req_type =3D min(pdev->tph_req_type, rp_req_type); + + if (pdev->tph_req_type =3D=3D PCI_TPH_REQ_DISABLE) + return -EINVAL; + + /* Write them into TPH control register */ + pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, ®); + + reg &=3D ~PCI_TPH_CTRL_MODE_SEL_MASK; + reg |=3D FIELD_PREP(PCI_TPH_CTRL_MODE_SEL_MASK, pdev->tph_mode); + + reg &=3D ~PCI_TPH_CTRL_REQ_EN_MASK; + reg |=3D FIELD_PREP(PCI_TPH_CTRL_REQ_EN_MASK, pdev->tph_req_type); + + pci_write_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, reg); + + pdev->tph_enabled =3D 1; + + return 0; +} +EXPORT_SYMBOL(pcie_enable_tph); + +void pci_restore_tph_state(struct pci_dev *pdev) +{ + struct pci_cap_saved_state *save_state; + u32 *cap; + + if (!pdev->tph_cap) + return; + + if (!pdev->tph_enabled) + return; + + save_state =3D pci_find_saved_ext_cap(pdev, PCI_EXT_CAP_ID_TPH); + if (!save_state) + return; + + /* Restore control register and all ST entries */ + cap =3D &save_state->cap.data[0]; + pci_write_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, *cap++); +} + +void pci_save_tph_state(struct pci_dev *pdev) +{ + struct pci_cap_saved_state *save_state; + u32 *cap; + + if (!pdev->tph_cap) + return; + + if (!pdev->tph_enabled) + return; + + save_state =3D pci_find_saved_ext_cap(pdev, PCI_EXT_CAP_ID_TPH); + if (!save_state) + return; + + /* Save control register */ + cap =3D &save_state->cap.data[0]; + pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, cap++); +} + +void pci_no_tph(void) +{ + pci_tph_disabled =3D true; + + pr_info("PCIe TPH is disabled\n"); +} + +void pci_tph_init(struct pci_dev *pdev) +{ + u32 save_size; + + pdev->tph_cap =3D pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_TPH); + if (!pdev->tph_cap) + return; + + save_size =3D sizeof(u32); + pci_add_ext_cap_save_buffer(pdev, PCI_EXT_CAP_ID_TPH, save_size); +} diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index b14b9876c030..c74adcdee52b 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2498,6 +2498,7 @@ static void pci_init_capabilities(struct pci_dev *dev) pci_dpc_init(dev); /* Downstream Port Containment */ pci_rcec_init(dev); /* Root Complex Event Collector */ pci_doe_init(dev); /* Data Object Exchange */ + pci_tph_init(dev); /* TLP Processing Hints */ =20 pcie_report_downtraining(dev); pci_init_reset_methods(dev); diff --git a/include/linux/pci-tph.h b/include/linux/pci-tph.h new file mode 100644 index 000000000000..58654a334ffb --- /dev/null +++ b/include/linux/pci-tph.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * TPH (TLP Processing Hints) + * + * Copyright (C) 2024 Advanced Micro Devices, Inc. + * Eric Van Tassell + * Wei Huang + */ +#ifndef LINUX_PCI_TPH_H +#define LINUX_PCI_TPH_H + +#ifdef CONFIG_PCIE_TPH +void pcie_disable_tph(struct pci_dev *pdev); +int pcie_enable_tph(struct pci_dev *pdev, int mode); +#else +static inline void pcie_disable_tph(struct pci_dev *pdev) { } +static inline int pcie_enable_tph(struct pci_dev *pdev, int mode) +{ return -EINVAL; } +#endif + +#endif /* LINUX_PCI_TPH_H */ diff --git a/include/linux/pci.h b/include/linux/pci.h index 4cf89a4b4cbc..6f05deb6a0bf 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -433,6 +433,7 @@ struct pci_dev { unsigned int ats_enabled:1; /* Address Translation Svc */ unsigned int pasid_enabled:1; /* Process Address Space ID */ unsigned int pri_enabled:1; /* Page Request Interface */ + unsigned int tph_enabled:1; /* TLP Processing Hints */ unsigned int is_managed:1; /* Managed via devres */ unsigned int is_msi_managed:1; /* MSI release via devres installed */ unsigned int needs_freset:1; /* Requires fundamental reset */ @@ -530,6 +531,12 @@ struct pci_dev { =20 /* These methods index pci_reset_fn_methods[] */ u8 reset_methods[PCI_NUM_RESET_METHODS]; /* In priority order */ + +#ifdef CONFIG_PCIE_TPH + u16 tph_cap; /* TPH capability offset */ + u8 tph_mode; /* TPH mode */ + u8 tph_req_type; /* TPH requester type */ +#endif }; =20 static inline struct pci_dev *pci_physfn(struct pci_dev *dev) diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index 94c00996e633..25af1976953c 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -340,7 +340,9 @@ #define PCI_MSIX_ENTRY_UPPER_ADDR 0x4 /* Message Upper Address */ #define PCI_MSIX_ENTRY_DATA 0x8 /* Message Data */ #define PCI_MSIX_ENTRY_VECTOR_CTRL 0xc /* Vector Control */ -#define PCI_MSIX_ENTRY_CTRL_MASKBIT 0x00000001 +#define PCI_MSIX_ENTRY_CTRL_MASKBIT 0x00000001 /* Mask Bit */ +#define PCI_MSIX_ENTRY_CTRL_ST_LOWER 0x00ff0000 /* ST Lower */ +#define PCI_MSIX_ENTRY_CTRL_ST_UPPER 0xff000000 /* ST Upper */ =20 /* CompactPCI Hotswap Register */ =20 @@ -657,6 +659,7 @@ #define PCI_EXP_DEVCAP2_ATOMIC_COMP64 0x00000100 /* 64b AtomicOp completi= on */ #define PCI_EXP_DEVCAP2_ATOMIC_COMP128 0x00000200 /* 128b AtomicOp comple= tion */ #define PCI_EXP_DEVCAP2_LTR 0x00000800 /* Latency tolerance reporting */ +#define PCI_EXP_DEVCAP2_TPH_COMP_MASK 0x00003000 /* TPH completer support= */ #define PCI_EXP_DEVCAP2_OBFF_MASK 0x000c0000 /* OBFF support mechanism */ #define PCI_EXP_DEVCAP2_OBFF_MSG 0x00040000 /* New message signaling */ #define PCI_EXP_DEVCAP2_OBFF_WAKE 0x00080000 /* Re-use WAKE# for OBFF */ @@ -1020,15 +1023,34 @@ #define PCI_DPA_CAP_SUBSTATE_MASK 0x1F /* # substates - 1 */ #define PCI_DPA_BASE_SIZEOF 16 /* size with 0 substates */ =20 +/* TPH Completer Support */ +#define PCI_EXP_DEVCAP2_TPH_COMP_NONE 0x0 /* None */ +#define PCI_EXP_DEVCAP2_TPH_COMP_TPH_ONLY 0x1 /* TPH only */ +#define PCI_EXP_DEVCAP2_TPH_COMP_EXT_TPH 0x3 /* TPH and Extended TPH */ + /* TPH Requester */ #define PCI_TPH_CAP 4 /* capability register */ -#define PCI_TPH_CAP_LOC_MASK 0x600 /* location mask */ -#define PCI_TPH_LOC_NONE 0x000 /* no location */ -#define PCI_TPH_LOC_CAP 0x200 /* in capability */ -#define PCI_TPH_LOC_MSIX 0x400 /* in MSI-X */ -#define PCI_TPH_CAP_ST_MASK 0x07FF0000 /* ST table mask */ -#define PCI_TPH_CAP_ST_SHIFT 16 /* ST table shift */ -#define PCI_TPH_BASE_SIZEOF 0xc /* size with no ST table */ +#define PCI_TPH_CAP_ST_NS 0x00000001 /* No ST Mode Supported */ +#define PCI_TPH_CAP_ST_IV 0x00000002 /* Interrupt Vector Mode Supported */ +#define PCI_TPH_CAP_ST_DS 0x00000004 /* Device Specific Mode Supported */ +#define PCI_TPH_CAP_EXT_TPH 0x00000100 /* Ext TPH Requester Supported */ +#define PCI_TPH_CAP_LOC_MASK 0x00000600 /* ST Table Location */ +#define PCI_TPH_LOC_NONE 0x00000000 /* Not present */ +#define PCI_TPH_LOC_CAP 0x00000200 /* In capability */ +#define PCI_TPH_LOC_MSIX 0x00000400 /* In MSI-X */ +#define PCI_TPH_CAP_ST_MASK 0x07FF0000 /* ST Table Size */ +#define PCI_TPH_CAP_ST_SHIFT 16 /* ST Table Size shift */ +#define PCI_TPH_BASE_SIZEOF 0xc /* Size with no ST table */ + +#define PCI_TPH_CTRL 8 /* control register */ +#define PCI_TPH_CTRL_MODE_SEL_MASK 0x00000007 /* ST Mode Select */ +#define PCI_TPH_ST_NS_MODE 0x0 /* No ST Mode */ +#define PCI_TPH_ST_IV_MODE 0x1 /* Interrupt Vector Mode */ +#define PCI_TPH_ST_DS_MODE 0x2 /* Device Specific Mode */ +#define PCI_TPH_CTRL_REQ_EN_MASK 0x00000300 /* TPH Requester Enable */ +#define PCI_TPH_REQ_DISABLE 0x0 /* No TPH requests allowed */ +#define PCI_TPH_REQ_TPH_ONLY 0x1 /* TPH only requests allowed */ +#define PCI_TPH_REQ_EXT_TPH 0x3 /* Extended TPH requests allowed */ =20 /* Downstream Port Containment */ #define PCI_EXP_DPC_CAP 0x04 /* DPC Capability */ --=20 2.45.1 From nobody Fri Nov 29 17:43:18 2024 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2089.outbound.protection.outlook.com [40.107.236.89]) (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 12BC313A86A; Mon, 16 Sep 2024 20:51:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726519902; cv=fail; b=IhYlxIl1uukFPe5tX2f2STVRCxbBN/eAFND/Kytn7PAiO2egEjuDeGuGByBA4aEwYS6J9fu+BUoEjctISntoB5MKUhNsopvGuYSpc/7u6m22kUb/MN7RNxeicFjrIhVj599qW8NoRVzk5ZRCvX2Rg2dn2QnkYehq6ct6GTHakyI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726519902; c=relaxed/simple; bh=QnfquOj+gXkcuHeGLYc6rix0rKS4AOOsJMLq8Z0QO+s=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SDtA64Y4lDewG6+KFf+yFgB1mXgRJTyJUOm3CM+TNVO/BgCL+KwAze0m2s6Ba03J72/qFAusIjINEjDQFTN18u/+iykylApB/WgoJq+IpbRdA7m8rHH4Jv6OkfWEvOHK/Oe+0uCIQsjRnye54qA5DfnEd5rvCPKnPpEwOajHDR0= 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=G7+iWlBk; arc=fail smtp.client-ip=40.107.236.89 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="G7+iWlBk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BBWx+sRcO+UcSWTZlu4fDI+pb9GhE4KlytNO9/JpOozEVroABdtheckRaQfEuWJcOp5tTd3HrshgNb1WzvXgNyhP6GQR8bhwv0Y6PY+ZiijXUxhZ0vVUFpEfv+w/PVSctQFry7vdpioMr02kCRSFD7113t7A+cL50vr0zJzQG5YnP61359KWTWitTlRV6j6clbFUMKxCOt40OnyYnu2fU40kNtODblqfn2wAmbH2bgvmNk2xNU5sCIF7nfdAViCA3gOOkg5Dy39uknIjqUou5py+GWALExIbOgHVmJcJxC8T80EN7AayK2t0VRFy/uYD+fkDKKllFCxVdadRnIMC2g== 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=AbL6cqZI0y2u7z0spJ+25eumiGVxbOFvSJYnPrkvd30=; b=ohSyReiTyHYy077D9y08PnH9s2HM3TDAYyDyoMyB3eGu/zpPQVBHBTCks1Dm73K9VsqbSoO1CCZVDpvgfVmnqbb7k+t0js+dU+yp/gnNTct6uYtVL30av0XawqRltgdSvJFIdUflGd9VhBT/qx+GFioIkPcHCWZ7TT4jSy1k9tazxEb2hxYA4SR23SkLqVvdl/PQP7SkR1+q7e0G+aCYDPex9kmamPGbe5EwEzs9DVFS+w+V/tB6z1glBE127rwUiw7RXEfZq3EknK5KrYD8iwt99hPOCxHabo8VggJYsHeDDWmcClJfBirl5/1t6jf2wjMyRjYUe/BJeXIhcyeXUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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=AbL6cqZI0y2u7z0spJ+25eumiGVxbOFvSJYnPrkvd30=; b=G7+iWlBkwpmFT7LPK+0l5l4117gK999Z3RxDa0ujLCpLIztaxqWzCU6hUpFR5aKq6+YrymPnYzhyZWwugdYVqnX+odtGMDCxanIi3G/PX4gF+73/pjkinbbi+OhmHbr4sgYbcRT62HIC9E8Hra07AkK6cMvi7bJ0Jo17ugAp+YU= Received: from BL0PR02CA0051.namprd02.prod.outlook.com (2603:10b6:207:3d::28) by PH7PR12MB5998.namprd12.prod.outlook.com (2603:10b6:510:1da::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.23; Mon, 16 Sep 2024 20:51:34 +0000 Received: from BL02EPF00021F68.namprd02.prod.outlook.com (2603:10b6:207:3d:cafe::34) by BL0PR02CA0051.outlook.office365.com (2603:10b6:207:3d::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24 via Frontend Transport; Mon, 16 Sep 2024 20:51:34 +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 BL02EPF00021F68.mail.protection.outlook.com (10.167.249.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Mon, 16 Sep 2024 20:51:33 +0000 Received: from weiserver.amd.com (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; Mon, 16 Sep 2024 15:51:31 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V5 2/5] PCI/TPH: Add Steering Tag support Date: Mon, 16 Sep 2024 15:51:00 -0500 Message-ID: <20240916205103.3882081-3-wei.huang2@amd.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240916205103.3882081-1-wei.huang2@amd.com> References: <20240916205103.3882081-1-wei.huang2@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: BL02EPF00021F68:EE_|PH7PR12MB5998:EE_ X-MS-Office365-Filtering-Correlation-Id: c3cd4159-ced4-412b-3c4f-08dcd6915980 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?8Se8EG3GFE4xk0nbMJwR2CVUnc114wRnImUqupW1TFvlEHbTUsryauAbrpF3?= =?us-ascii?Q?9Q03FM0M0iHl2AVgrTFS/IhP3ONmoNOSvF10za7LBvG0jnXuhtp8cJSNZ1gx?= =?us-ascii?Q?CmMmlulLQFWosxnJKEfOpKGdecWzk7lQaSoYEHW6pL42wtPeOfcGS1lS7HlW?= =?us-ascii?Q?mwoTH/tgfgGptGBAA+sxhpISdQKxthJj1Ggf5fHrwHpauiEDMonc1bLMtyPQ?= =?us-ascii?Q?IsiTXYpMN6oqW7fo3DlD45WeEgTxoRh60jOaTEx1/fLMWeC8TGk/trwpPUTR?= =?us-ascii?Q?qy7cohl9Jy+8J26MqaB7NsMhHAjjWsbGkN51ioJomE/eg2cqjeK1+F2zMv41?= =?us-ascii?Q?qvIGuCfcwZItVnBPnN57+24wusuFHnaQDpWrEs9ifVvs9/XycVUfSWhUntMB?= =?us-ascii?Q?MzQ7jZ4QpwryiZiZHYfNWhpfK3pVi/cKfIWqes1aYQDuHRmve2MlPCCt83wY?= =?us-ascii?Q?B3JDDdaOeixiDSwmysCSROITkGkxvhvQcZJz+s3N09d06Qfp2mnQw0GwU2j8?= =?us-ascii?Q?cOQENSV+2ML6fVNHiqY7B4c0KzC3q4zFtPL193unwJRxjVPp+WWqb4XIzUxy?= =?us-ascii?Q?DYPedLvCzag+HkpgTPCI1yQ+vC3d/Bd1njKdlzh0QdHi83cl1Hy6mhTv/rwx?= =?us-ascii?Q?dJEH2XYWwqI900Vid6SmjGEBiQzjJPXBXIjDdAhQCTqVoH0nvkVb2bDvBnUL?= =?us-ascii?Q?1hW2wGMHT2tjTWzbqHdTm7P+XdF7WSIeX03FvSL2xJz1YQLrm81xjLi3idJK?= =?us-ascii?Q?/sbrSgo1v10FgQCWVzJfeXzUl4mJ0rZwB28n7sVSbb0xm6EA+sGXwXlEg1pN?= =?us-ascii?Q?nhRbjzd6TQvY4BP7uCgqzqy1VycDqGqC0J5hvZhHCa6ORKq2Fp6P1Loep7nS?= =?us-ascii?Q?68m75RVBaBvWYt6JmmYW83WSNfULR9WfpT2VAcm+deNzlZQivvutxxPftge+?= =?us-ascii?Q?fkQ/DF0fCbRz0gRu3WyMFgSBKjwVogNvxS6iXBF4iCN//eyrlfUgaVg5G698?= =?us-ascii?Q?AFI4HnZwoqecTiFCA3DScGXYONWd9vYeJ21SqUqPyhOwQKM1pS9SWRqz9khZ?= =?us-ascii?Q?WMowRXr58DVgnben0nhRy2+gM0GHPjWWb59x0USzUoiN+bqVO4hcNMdI7k+F?= =?us-ascii?Q?/hv+rRa1NwtnyPa7r5nOm5Ok6padj8BkqyanHK7a1loWkTVfNn3U3ftwjANp?= =?us-ascii?Q?KLqIKyYZzP7zAYQpa41OeMLHWqiOE9W+WxQd1lOFwj3einy3utFwsoqep8kC?= =?us-ascii?Q?Kk/WM9B7HQnl9rcFyBQzDTpRNrrBD9B2UvQdgtZJ7c0gbPI86lkdtzFHJ+nf?= =?us-ascii?Q?0LEcViCE/AI/IKBsY6BNQ0hD9lIdsNW0f732rLFVtP/W+smXz8v4qWblupcb?= =?us-ascii?Q?ucz3AFtFh+Ank9FJaDduHVBLcMT39nTsDZNDzyCIi16ZwhK+L90GYyMyxVNA?= =?us-ascii?Q?2VGsolc6iToZdkK52wJArVI02QoH5PxE?= 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)(36860700013)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2024 20:51:33.7602 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c3cd4159-ced4-412b-3c4f-08dcd6915980 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: BL02EPF00021F68.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5998 Content-Type: text/plain; charset="utf-8" pcie_tph_get_cpu_st() is added to allow a caller to retrieve Steering Tags for a target memory that is associated with a specific CPU. The ST tag is retrieved by invoking ACPI _DSM of the device's Root Port device. pcie_tph_set_st_entry() is added to support updating the device's Steering Tags. The tags will be written into the device's MSI-X table or the ST table located in the TPH Extended Capability space. Co-developed-by: Eric Van Tassell Signed-off-by: Eric Van Tassell Signed-off-by: Wei Huang Reviewed-by: Ajit Khaparde Reviewed-by: Somnath Kotur Reviewed-by: Andy Gospodarek --- drivers/pci/pcie/tph.c | 339 +++++++++++++++++++++++++++++++++++++++- include/linux/pci-tph.h | 23 +++ 2 files changed, 361 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pcie/tph.c b/drivers/pci/pcie/tph.c index 1efd76c8dd30..4b386616fc28 100644 --- a/drivers/pci/pcie/tph.c +++ b/drivers/pci/pcie/tph.c @@ -14,9 +14,134 @@ =20 #include "../pci.h" =20 +/* + * The st_info struct defines the Steering Tag (ST) info returned by the + * firmware _DSM method defined in the approved ECN for PCI Firmware Spec, + * available at https://members.pcisig.com/wg/PCI-SIG/document/15470. + * + * @vm_st_valid: 8-bit ST for volatile memory is valid + * @vm_xst_valid: 16-bit extended ST for volatile memory is valid + * @vm_ph_ignore: 1 =3D> PH was and will be ignored, 0 =3D> PH should be s= upplied + * @vm_st: 8-bit ST for volatile mem + * @vm_xst: 16-bit extended ST for volatile mem + * @pm_st_valid: 8-bit ST for persistent memory is valid + * @pm_xst_valid: 16-bit extended ST for persistent memory is valid + * @pm_ph_ignore: 1 =3D> PH was and will be ignored, 0 =3D> PH should be s= upplied + * @pm_st: 8-bit ST for persistent mem + * @pm_xst: 16-bit extended ST for persistent mem + */ +union st_info { + struct { + u64 vm_st_valid : 1; + u64 vm_xst_valid : 1; + u64 vm_ph_ignore : 1; + u64 rsvd1 : 5; + u64 vm_st : 8; + u64 vm_xst : 16; + u64 pm_st_valid : 1; + u64 pm_xst_valid : 1; + u64 pm_ph_ignore : 1; + u64 rsvd2 : 5; + u64 pm_st : 8; + u64 pm_xst : 16; + }; + u64 value; +}; + /* System-wide TPH disabled */ static bool pci_tph_disabled; =20 +static u16 tph_extract_tag(enum tph_mem_type mem_type, u8 req_type, + union st_info *info) +{ + switch (req_type) { + case PCI_TPH_REQ_TPH_ONLY: /* 8-bit tag */ + switch (mem_type) { + case TPH_MEM_TYPE_VM: + if (info->vm_st_valid) + return info->vm_st; + break; + case TPH_MEM_TYPE_PM: + if (info->pm_st_valid) + return info->pm_st; + break; + } + break; + case PCI_TPH_REQ_EXT_TPH: /* 16-bit tag */ + switch (mem_type) { + case TPH_MEM_TYPE_VM: + if (info->vm_xst_valid) + return info->vm_xst; + break; + case TPH_MEM_TYPE_PM: + if (info->pm_xst_valid) + return info->pm_xst; + break; + } + break; + default: + return 0; + } + + return 0; +} + +#define TPH_ST_DSM_FUNC_INDEX 0xF +static acpi_status tph_invoke_dsm(acpi_handle handle, u32 cpu_uid, + union st_info *st_out) +{ + union acpi_object arg3[3], in_obj, *out_obj; + + if (!acpi_check_dsm(handle, &pci_acpi_dsm_guid, 7, + BIT(TPH_ST_DSM_FUNC_INDEX))) + return AE_ERROR; + + /* DWORD: feature ID (0 for processor cache ST query) */ + arg3[0].integer.type =3D ACPI_TYPE_INTEGER; + arg3[0].integer.value =3D 0; + + /* DWORD: target UID */ + arg3[1].integer.type =3D ACPI_TYPE_INTEGER; + arg3[1].integer.value =3D cpu_uid; + + /* QWORD: properties, all 0's */ + arg3[2].integer.type =3D ACPI_TYPE_INTEGER; + arg3[2].integer.value =3D 0; + + in_obj.type =3D ACPI_TYPE_PACKAGE; + in_obj.package.count =3D ARRAY_SIZE(arg3); + in_obj.package.elements =3D arg3; + + out_obj =3D acpi_evaluate_dsm(handle, &pci_acpi_dsm_guid, 7, + TPH_ST_DSM_FUNC_INDEX, &in_obj); + if (!out_obj) + return AE_ERROR; + + if (out_obj->type !=3D ACPI_TYPE_BUFFER) { + ACPI_FREE(out_obj); + return AE_ERROR; + } + + st_out->value =3D *((u64 *)(out_obj->buffer.pointer)); + + ACPI_FREE(out_obj); + + return AE_OK; +} + +/* Update the TPH Requester Enable field of TPH Control Register */ +static void set_ctrl_reg_req_en(struct pci_dev *pdev, u8 req_type) +{ + u32 reg; + + pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, ®); + + reg &=3D ~PCI_TPH_CTRL_REQ_EN_MASK; + reg |=3D FIELD_PREP(PCI_TPH_CTRL_REQ_EN_MASK, req_type); + + pci_write_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, reg); +} + static u8 get_st_modes(struct pci_dev *pdev) { u32 reg; @@ -27,6 +152,37 @@ static u8 get_st_modes(struct pci_dev *pdev) return reg; } =20 +static u32 get_st_table_loc(struct pci_dev *pdev) +{ + u32 reg; + + pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CAP, ®); + + return FIELD_GET(PCI_TPH_CAP_LOC_MASK, reg); +} + +/* + * Return the size of ST table. If ST table is not in TPH Requester Extend= ed + * Capability space, return 0. Otherwise return the ST Table Size + 1. + */ +static u16 get_st_table_size(struct pci_dev *pdev) +{ + u32 reg; + u32 loc; + + /* Check ST table location first */ + loc =3D get_st_table_loc(pdev); + + /* Convert loc to match with PCI_TPH_LOC_* defined in pci_regs.h */ + loc =3D FIELD_PREP(PCI_TPH_CAP_LOC_MASK, loc); + if (loc !=3D PCI_TPH_LOC_CAP) + return 0; + + pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CAP, ®); + + return FIELD_GET(PCI_TPH_CAP_ST_MASK, reg) + 1; +} + /* Return device's Root Port completer capability */ static u8 get_rp_completer_type(struct pci_dev *pdev) { @@ -45,6 +201,163 @@ static u8 get_rp_completer_type(struct pci_dev *pdev) return FIELD_GET(PCI_EXP_DEVCAP2_TPH_COMP_MASK, reg); } =20 +/* Write ST to MSI-X vector control reg - Return 0 if OK, otherwise -errno= */ +static int write_tag_to_msix(struct pci_dev *pdev, int msix_idx, u16 tag) +{ + struct msi_desc *msi_desc =3D NULL; + void __iomem *vec_ctrl; + u32 val, mask; + int err =3D 0; + + msi_lock_descs(&pdev->dev); + + /* Find the msi_desc entry with matching msix_idx */ + msi_for_each_desc(msi_desc, &pdev->dev, MSI_DESC_ASSOCIATED) { + if (msi_desc->msi_index =3D=3D msix_idx) + break; + } + + if (!msi_desc) { + err =3D -ENXIO; + goto err_out; + } + + /* Get the vector control register (offset 0xc) pointed by msix_idx */ + vec_ctrl =3D pdev->msix_base + msix_idx * PCI_MSIX_ENTRY_SIZE; + vec_ctrl +=3D PCI_MSIX_ENTRY_VECTOR_CTRL; + + val =3D readl(vec_ctrl); + mask =3D PCI_MSIX_ENTRY_CTRL_ST_LOWER | PCI_MSIX_ENTRY_CTRL_ST_UPPER; + val &=3D ~mask; + val |=3D FIELD_PREP(mask, (u32)tag); + writel(val, vec_ctrl); + + /* Read back to flush the update */ + val =3D readl(vec_ctrl); + +err_out: + msi_unlock_descs(&pdev->dev); + return err; +} + +/* Write tag to ST table - Return 0 if OK, otherwise -errno */ +static int write_tag_to_st_table(struct pci_dev *pdev, int index, u16 tag) +{ + int st_table_size; + int offset; + + /* Check if index is out of bound */ + st_table_size =3D get_st_table_size(pdev); + if (index >=3D st_table_size) + return -ENXIO; + + offset =3D pdev->tph_cap + PCI_TPH_BASE_SIZEOF + index * sizeof(u16); + + return pci_write_config_word(pdev, offset, tag); +} + +/** + * pcie_tph_get_cpu_st() - Retrieve Steering Tag for a target memory assoc= iated + * with a specific CPU + * @pdev: PCI device + * @mem_type: target memory type (volatile or persistent RAM) + * @cpu_uid: associated CPU id + * @tag: Steering Tag to be returned + * + * This function returns the Steering Tag for a target memory that is + * associated with a specific CPU as indicated by cpu_uid. + * + * Returns: 0 if success, otherwise negative value (-errno) + */ +int pcie_tph_get_cpu_st(struct pci_dev *pdev, enum tph_mem_type mem_type, + unsigned int cpu_uid, u16 *tag) +{ + struct pci_dev *rp; + acpi_handle rp_acpi_handle; + union st_info info; + + rp =3D pcie_find_root_port(pdev); + if (!rp || !rp->bus || !rp->bus->bridge) + return -ENODEV; + + rp_acpi_handle =3D ACPI_HANDLE(rp->bus->bridge); + + if (tph_invoke_dsm(rp_acpi_handle, cpu_uid, &info) !=3D AE_OK) { + *tag =3D 0; + return -EINVAL; + } + + *tag =3D tph_extract_tag(mem_type, pdev->tph_req_type, &info); + + pci_dbg(pdev, "get steering tag: mem_type=3D%s, cpu_uid=3D%d, tag=3D%#04x= \n", + (mem_type =3D=3D TPH_MEM_TYPE_VM) ? "volatile" : "persistent", + cpu_uid, *tag); + + return 0; +} +EXPORT_SYMBOL(pcie_tph_get_cpu_st); + +/** + * pcie_tph_set_st_entry() - Set Steering Tag in the ST table entry + * @pdev: PCI device + * @index: ST table entry index + * @tag: Steering Tag to be written + * + * This function will figure out the proper location of ST table, either i= n the + * MSI-X table or in the TPH Extended Capability space, and write the Stee= ring + * Tag into the ST entry pointed by index. + * + * Returns: 0 if success, otherwise negative value (-errno) + */ +int pcie_tph_set_st_entry(struct pci_dev *pdev, unsigned int index, u16 ta= g) +{ + u32 loc; + int err =3D 0; + + if (!pdev->tph_cap) + return -EINVAL; + + if (!pdev->tph_enabled) + return -EINVAL; + + /* No need to write tag if device is in "No ST Mode" */ + if (pdev->tph_mode =3D=3D PCI_TPH_ST_NS_MODE) + return 0; + + /* Disable TPH before updating ST to avoid potential instability as + * cautioned in PCIe r6.2, sec 6.17.3, "ST Modes of Operation" + */ + set_ctrl_reg_req_en(pdev, PCI_TPH_REQ_DISABLE); + + loc =3D get_st_table_loc(pdev); + /* Convert loc to match with PCI_TPH_LOC_* defined in pci_regs.h */ + loc =3D FIELD_PREP(PCI_TPH_CAP_LOC_MASK, loc); + + switch (loc) { + case PCI_TPH_LOC_MSIX: + err =3D write_tag_to_msix(pdev, index, tag); + break; + case PCI_TPH_LOC_CAP: + err =3D write_tag_to_st_table(pdev, index, tag); + break; + default: + err =3D -EINVAL; + } + + if (err) { + pcie_disable_tph(pdev); + return err; + } + + set_ctrl_reg_req_en(pdev, pdev->tph_mode); + + pci_dbg(pdev, "set steering tag: %s table, index=3D%d, tag=3D%#04x\n", + (loc =3D=3D PCI_TPH_LOC_MSIX) ? "MSI-X" : "ST", index, tag); + + return 0; +} +EXPORT_SYMBOL(pcie_tph_set_st_entry); + /** * pcie_disable_tph - Turn off TPH support for device * @pdev: PCI device @@ -142,6 +455,8 @@ EXPORT_SYMBOL(pcie_enable_tph); void pci_restore_tph_state(struct pci_dev *pdev) { struct pci_cap_saved_state *save_state; + int num_entries, i, offset; + u16 *st_entry; u32 *cap; =20 if (!pdev->tph_cap) @@ -157,11 +472,21 @@ void pci_restore_tph_state(struct pci_dev *pdev) /* Restore control register and all ST entries */ cap =3D &save_state->cap.data[0]; pci_write_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, *cap++); + st_entry =3D (u16 *)cap; + offset =3D PCI_TPH_BASE_SIZEOF; + num_entries =3D get_st_table_size(pdev); + for (i =3D 0; i < num_entries; i++) { + pci_write_config_word(pdev, pdev->tph_cap + offset, + *st_entry++); + offset +=3D sizeof(u16); + } } =20 void pci_save_tph_state(struct pci_dev *pdev) { struct pci_cap_saved_state *save_state; + int num_entries, i, offset; + u16 *st_entry; u32 *cap; =20 if (!pdev->tph_cap) @@ -177,6 +502,16 @@ void pci_save_tph_state(struct pci_dev *pdev) /* Save control register */ cap =3D &save_state->cap.data[0]; pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, cap++); + + /* Save all ST entries in extended capability structure */ + st_entry =3D (u16 *)cap; + offset =3D PCI_TPH_BASE_SIZEOF; + num_entries =3D get_st_table_size(pdev); + for (i =3D 0; i < num_entries; i++) { + pci_read_config_word(pdev, pdev->tph_cap + offset, + st_entry++); + offset +=3D sizeof(u16); + } } =20 void pci_no_tph(void) @@ -188,12 +523,14 @@ void pci_no_tph(void) =20 void pci_tph_init(struct pci_dev *pdev) { + int num_entries; u32 save_size; =20 pdev->tph_cap =3D pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_TPH); if (!pdev->tph_cap) return; =20 - save_size =3D sizeof(u32); + num_entries =3D get_st_table_size(pdev); + save_size =3D sizeof(u32) + num_entries * sizeof(u16); pci_add_ext_cap_save_buffer(pdev, PCI_EXT_CAP_ID_TPH, save_size); } diff --git a/include/linux/pci-tph.h b/include/linux/pci-tph.h index 58654a334ffb..c3e806c13d64 100644 --- a/include/linux/pci-tph.h +++ b/include/linux/pci-tph.h @@ -9,10 +9,33 @@ #ifndef LINUX_PCI_TPH_H #define LINUX_PCI_TPH_H =20 +/* + * According to the ECN for PCI Firmware Spec, Steering Tag can be differe= nt + * depending on the memory type: Volatile Memory or Persistent Memory. Whe= n a + * caller query about a target's Steering Tag, it must provide the target's + * tph_mem_type. ECN link: https://members.pcisig.com/wg/PCI-SIG/document/= 15470. + */ +enum tph_mem_type { + TPH_MEM_TYPE_VM, /* volatile memory */ + TPH_MEM_TYPE_PM /* persistent memory */ +}; + #ifdef CONFIG_PCIE_TPH +int pcie_tph_set_st_entry(struct pci_dev *pdev, + unsigned int index, u16 tag); +int pcie_tph_get_cpu_st(struct pci_dev *dev, + enum tph_mem_type mem_type, + unsigned int cpu_uid, u16 *tag); void pcie_disable_tph(struct pci_dev *pdev); int pcie_enable_tph(struct pci_dev *pdev, int mode); #else +static inline int pcie_tph_set_st_entry(struct pci_dev *pdev, + unsigned int index, u16 tag) +{ return -EINVAL; } +static inline int pcie_tph_get_cpu_st(struct pci_dev *dev, + enum tph_mem_type mem_type, + unsigned int cpu_uid, u16 *tag) +{ return -EINVAL; } static inline void pcie_disable_tph(struct pci_dev *pdev) { } static inline int pcie_enable_tph(struct pci_dev *pdev, int mode) { return -EINVAL; } --=20 2.45.1 From nobody Fri Nov 29 17:43:18 2024 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2051.outbound.protection.outlook.com [40.107.244.51]) (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 C206513A86A; Mon, 16 Sep 2024 20:51:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726519911; cv=fail; b=CzY4qg8IivmC/sl6ytSLRsLJ2/NbirbUAo4KrSCZmOWQSMVgxItcEEQhhRxROnqs086pXRuPRlHxCDW43VWD37uaHqWqbLPuy8W+nbsA+1dYnMFtUzWkpVg/2ZugzdLRgK5dmn8+tRrGHz7/WOT90QDQDawOQyZiUbNkrwOUdNo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726519911; c=relaxed/simple; bh=F8nKWDdjldVlhOb9xZycwYYTCYjYKKf5IK4O7Ls+5gw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=b2l4ioCAVSOD4tf5OrtCP4gYpNz+IwsbF9QrtUqjECJ1CXyxOhmU1GgOlM+g+bJIzKliPbwud5BULIH8lPF48pKWqNMpoHPvVPUiSO9p1dL0P1jpPm/PlGO/uwkOjFqXkN5u4uNOsxAneG9UDli7r8YP7y2v2pfHqw4XWry5l1s= 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=QPVYeqS/; arc=fail smtp.client-ip=40.107.244.51 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="QPVYeqS/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dmHUh/0vr5GJGS6EpR5E7ydlYC8Sie1WSRaS/tAAIveFhoe7vN43Ahq/kDzSXRwy3GqLCfEeD0oTfJ9jrHB0lwAq+Cb9rLUkK8b7ccrubVNPtDBHb1dYf8XhB60oVJLoMdwZoXRgh33QoTD4qEVqndrXrm35K177MZMlJ4Cl0BydQN3W41ukO2gwSKgY5B5PL2BL4xtWL4/m3dBQLzgVUzUgAWAaHT69NGNtHpmvjSJXM37VzIsIgmIyfRO+w3aJHRCthRtnEKvidL2TtscC8Mn7Kgt7sz9Poz7VbunU1r5g9oHpYd3k75erMRGUYNkULmeUGrqaWBRAKp53xaSc7w== 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=DUrvCAuSCUQhItX8VKljviXxPJ8ev70dZEI9tr4LzwE=; b=D8m2Cbe52Yv4g4U+mhq7KrezE9ImUDB9FSI8B/VM4HjHbfXj1aRytg5Fgi/HeREepRT7pklDgcRPEr9vA+GHmzX1SDmVVRVwnA2Y06aAb7TyIurQPPM619Q8BSQGvpLh5azUJavwAVTMwTw5rMTQBEw9QcHRR2F4PeKnFE0eFoklC30+qxJ2uYmffZbSzq0CnLm4GHIoWeLg4GdfQisnkoVvrjjHY8yixdk/MQGzQwhea/rgnOU5RSp+vSKURYgJzAKTGyb5jC6B88WyqL6Y9lTqmrlMr+KprgtRsLg3gAWTZZc2eucqa3BaqESJhjiDHybK9TlFQfZDHE9PKxp5zw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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=DUrvCAuSCUQhItX8VKljviXxPJ8ev70dZEI9tr4LzwE=; b=QPVYeqS/UxsZ2Tnc1C0hgflaqFLrEgB9N4YoMMdzu4jUPq6ltcftKSwI5AHaWxG4olbpl4CHuldguEe4yzrdqkqFV++mTVA9X+FkHdonk2s6v4AL3aNpDVrDv3KNXzE12vcilSYN0xN3hTyCEwKj+pSYXqFV6C9eUeCEE7+djV4= Received: from BN9P222CA0002.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::7) by DM4PR12MB6423.namprd12.prod.outlook.com (2603:10b6:8:bd::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.24; Mon, 16 Sep 2024 20:51:45 +0000 Received: from BL02EPF00021F6C.namprd02.prod.outlook.com (2603:10b6:408:10c:cafe::bd) by BN9P222CA0002.outlook.office365.com (2603:10b6:408:10c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.26 via Frontend Transport; Mon, 16 Sep 2024 20:51:45 +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 BL02EPF00021F6C.mail.protection.outlook.com (10.167.249.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Mon, 16 Sep 2024 20:51:45 +0000 Received: from weiserver.amd.com (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; Mon, 16 Sep 2024 15:51:43 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V5 3/5] PCI/TPH: Add TPH documentation Date: Mon, 16 Sep 2024 15:51:01 -0500 Message-ID: <20240916205103.3882081-4-wei.huang2@amd.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240916205103.3882081-1-wei.huang2@amd.com> References: <20240916205103.3882081-1-wei.huang2@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: BL02EPF00021F6C:EE_|DM4PR12MB6423:EE_ X-MS-Office365-Filtering-Correlation-Id: 3cd2e683-76ab-4259-4b5f-08dcd6916048 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?TMTUz+JDlPRlHJvCCpcOJ9J1fUzlaWfln9gbYN59Hbr6Ax3tV1l+hmqAilLQ?= =?us-ascii?Q?4Wxe49k5QuBd/ZZG8joJXThFXNoISUK3dW/ac0evzxWiF/6lWEkGscKFF9U3?= =?us-ascii?Q?hHkPzriR7FcknElXAKBwbENtbqLJjob3N4WDfNh9368cCZdFTVpbEnfEEalh?= =?us-ascii?Q?e1/57xMXlocSvWEwvNM2dmkOkr3W6/NMy0kx86dulbvGqUF4sf8+iyqzcAMu?= =?us-ascii?Q?xnBF5MHmxhstPRp0PbO/C0DOojvfNEXiiGgK9AVJ1AfxjWRxfG3+w5l3pyHn?= =?us-ascii?Q?dJ/HIJNmBtOqYBL/+mcKIH5J9Dafw1hmBHbXb8iGnQQAgYAT4dz5rx4EjS1W?= =?us-ascii?Q?4/Dds8gZbUW9T1AmBtow95L3PTcs6ub3eSOEsrYPGzu6eLJ9PdfVyFoojc7a?= =?us-ascii?Q?Gd/hECH6+VbQJri51tc9ZbnwebEkNf7p6K8xEtpltaHVc3qmcZvFqnAPoqMs?= =?us-ascii?Q?2rVuX3ntMSEy+SJIZpGEibPMYmZWZNq48yex63YWULT0iJxvlf8zQhY0s765?= =?us-ascii?Q?hZutEYxSWvHWUOVmhRYqh6htomSK42xSMd2M2nGVqalLbgoZiGFcDQ9gRSpG?= =?us-ascii?Q?uRusSPcdIjMTF9Hee9SZ/qGRP2bil5NGjJD8VmY7/41bWw8qrjgUOSAWEPLj?= =?us-ascii?Q?WrqjvkqIBFrUZFFppWI9Cmx/JHCg5yN2qfx/x4E94yIkKyw2pDfx+FwzNsEu?= =?us-ascii?Q?5e1zeKvIjBjP0OU0JF4gTPO3kHCURYrVz5DnDss7CjHckzj3K8yfuRtj7PvY?= =?us-ascii?Q?nwUhc9SrbKMYZqyoecInxCPGcNzvAqdKEw7K0gNpEC+q1VEqbYyAnEfOFmai?= =?us-ascii?Q?jhx9N+mXrTGDJF6U6UxryOkK5VfBmA32SmqveHlXDzdBvgT2080iWrmAlOQ1?= =?us-ascii?Q?ZUYBd+NjDhaV3Q6YDqb0ZmdjraTLxADVjiZ93fK5LdB+IuZcufZRdnLlCA5I?= =?us-ascii?Q?bl9If8/8kN5dgBTdh/OlzLs8L0+YQRMe/S2WbC+Ms35h+jJlFLe652boTPtK?= =?us-ascii?Q?2XRWXi1TVLRjkL7GA2yZCjjAjc9S0LhE4KfHXF3z3fBm02hiG9iE8+NdJWL0?= =?us-ascii?Q?Lszs69e9LjMGWeX1kYQHFbDQTz0dq13t7dzdDBNJpJKB67WXUZ8CxiZ7XtTk?= =?us-ascii?Q?H0Vbtam6PMOuN2LAN+xPSLOMW09OsP2XXDd6UspApzHk0tzuOFyOpXs8PeuS?= =?us-ascii?Q?LUWpfGbayoZ6OHhsuclOfrslp38u0lexpLuEM+Xu/OCredsKnj6hVRBG0KtK?= =?us-ascii?Q?/nw7TDzK2yLH6pTxZHvuOnqtnyzfGEk4/9Yxg6ecNx2JWGh60BTuOw25TCjf?= =?us-ascii?Q?bwl2ojfj3yMwVrC3qgBW/fr/iHCjgaG6TkJCURP9UWlNDa5kR3vxSNAlSMKr?= =?us-ascii?Q?oYpVBmegztnundVvhNIxKSCFvW/8X/txSJLOxw/n16cLc3CMwFs8KTIVVR1S?= =?us-ascii?Q?VXmELJk+DVPOJvfnCvZI262YRasleMCH?= 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);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2024 20:51:45.1376 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3cd2e683-76ab-4259-4b5f-08dcd6916048 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: BL02EPF00021F6C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6423 Content-Type: text/plain; charset="utf-8" Provide a document for TPH feature, including the description of "notph" kernel parameter and the API interface. Co-developed-by: Eric Van Tassell Signed-off-by: Eric Van Tassell Signed-off-by: Wei Huang Reviewed-by: Ajit Khaparde Reviewed-by: Somnath Kotur Reviewed-by: Andy Gospodarek --- Documentation/PCI/index.rst | 1 + Documentation/PCI/tph.rst | 132 +++++++++++++++++++++++++++ Documentation/driver-api/pci/pci.rst | 3 + 3 files changed, 136 insertions(+) create mode 100644 Documentation/PCI/tph.rst diff --git a/Documentation/PCI/index.rst b/Documentation/PCI/index.rst index e73f84aebde3..5e7c4e6e726b 100644 --- a/Documentation/PCI/index.rst +++ b/Documentation/PCI/index.rst @@ -18,3 +18,4 @@ PCI Bus Subsystem pcieaer-howto endpoint/index boot-interrupts + tph diff --git a/Documentation/PCI/tph.rst b/Documentation/PCI/tph.rst new file mode 100644 index 000000000000..7c4b27789f87 --- /dev/null +++ b/Documentation/PCI/tph.rst @@ -0,0 +1,132 @@ +.. SPDX-License-Identifier: GPL-2.0 + + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +TPH Support +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +:Copyright: 2024 Advanced Micro Devices, Inc. +:Authors: - Eric van Tassell + - Wei Huang + + +Overview +=3D=3D=3D=3D=3D=3D=3D=3D + +TPH (TLP Processing Hints) is a PCIe feature that allows endpoint devices +to provide optimization hints for requests that target memory space. +These hints, in a format called Steering Tags (STs), are embedded in the +requester's TLP headers, enabling the system hardware, such as the Root +Complex, to better manage platform resources for these requests. + +For example, on platforms with TPH-based direct data cache injection +support, an endpoint device can include appropriate STs in its DMA +traffic to specify which cache the data should be written to. This allows +the CPU core to have a higher probablity of getting data from cache, +potentially improving performance and reducing latency in data +processing. + + +How to Use TPH +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +TPH is presented as an optional extended capability in PCIe. The Linux +kernel handles TPH discovery during boot, but it is up to the device +driver to request TPH enablement if it is to be utilized. Once enabled, +the driver uses the provided API to obtain the Steering Tag for the +target memory and to program the ST into the device's ST table. + +Enable TPH support in Linux +--------------------------- + +To support TPH, the kernel must be built with the CONFIG_PCIE_TPH option +enabled. + +Manage TPH +---------- + +To enable TPH for a device, use the following function:: + + int pcie_enable_tph(struct pci_dev *pdev, int mode); + +This function enables TPH support for device with a specific ST mode. +Current supported modes include: + + * PCI_TPH_ST_NS_MODE - NO ST Mode + * PCI_TPH_ST_IV_MODE - Interrupt Vector Mode + * PCI_TPH_ST_DS_MODE - Device Specific Mode + +`pcie_enable_tph()` checks whether the requested mode is actually +supported by the device before enabling. The device driver can figure out +which TPH mode is supported and can be properly enabled based on the +return value of `pcie_enable_tph()`. + +To disable TPH, use the following function:: + + void pcie_disable_tph(struct pci_dev *pdev); + +Manage ST +--------- + +Steering Tags are platform specific. PCIe spec does not specify where STs +are from. Instead PCI Firmware Specification defines an ACPI _DSM method +(see the `Revised _DSM for Cache Locality TPH Features ECN +`_) for retrieving +STs for a target memory of various properties. This method is what is +supported in this implementation. + +To retrieve a Steering Tag for a target memory associated with a specific +CPU, use the following function:: + + int pcie_tph_get_cpu_st(struct pci_dev *pdev, enum tph_mem_type type, + unsigned int cpu_uid, u16 *tag); + +The `type` argument is used to specify the memory type, either volatile +or persistent, of the target memory. The `cpu_uid` argument specifies the +CPU where the memory is associated to. + +After the ST value is retrieved, the device driver can use the following +function to write the ST into the device:: + + int pcie_tph_set_st_entry(struct pci_dev *pdev, unsigned int index, + u16 tag); + +The `index` argument is the ST table entry index the ST tag will be +written into. `pcie_tph_set_st_entry()` will figure out the proper +location of ST table, either in the MSI-X table or in the TPH Extended +Capability space, and write the Steering Tag into the ST entry pointed by +the `index` argument. + +It is completely up to the driver to decide how to use these TPH +functions. For example a network device driver can use the TPH APIs above +to update the Steering Tag when interrupt affinity of a RX/TX queue has +been changed. Here is a sample code for IRQ affinity notifier: + +.. code-block:: c + + static void irq_affinity_notified(struct irq_affinity_notify *notify, + const cpumask_t *mask) + { + struct drv_irq *irq; + unsigned int cpu_id; + u16 tag; + + irq =3D container_of(notify, struct drv_irq, affinity_notify); + cpumask_copy(irq->cpu_mask, mask); + + /* Pick a right CPU as the target - here is just an example */ + cpu_id =3D cpumask_first(irq->cpu_mask); + + if (pcie_tph_get_cpu_st(irq->pdev, TPH_MEM_TYPE_VM, cpu_id, + &tag)) + return; + + if (pcie_tph_set_st_entry(irq->pdev, irq->msix_nr, tag)) + return; + } + +Disable TPH system-wide +----------------------- + +There is a kernel command line option available to control TPH feature: + * "notph": TPH will be disabled for all endpoint devices. diff --git a/Documentation/driver-api/pci/pci.rst b/Documentation/driver-ap= i/pci/pci.rst index aa40b1cc243b..3d896b2cf16e 100644 --- a/Documentation/driver-api/pci/pci.rst +++ b/Documentation/driver-api/pci/pci.rst @@ -46,6 +46,9 @@ PCI Support Library .. kernel-doc:: drivers/pci/pci-sysfs.c :internal: =20 +.. kernel-doc:: drivers/pci/pcie/tph.c + :export: + PCI Hotplug Support Library --------------------------- =20 --=20 2.45.1 From nobody Fri Nov 29 17:43:18 2024 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2052.outbound.protection.outlook.com [40.107.93.52]) (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 CA00C13A86A; Mon, 16 Sep 2024 20:52:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726519928; cv=fail; b=keU6EzwYyR5Qfv+oDjEFi7c9yN4bXcnSxF+AOR1a0OPSp8GkHBKFoDP0ht3Rjv5DmQOLD6M7TSh2kk+AbBP3FXsRInQROFMhlBLa+JbpkMzXIqnOFL+jC0kvb+qBsC22V9oe6PFYe3ZZ+mkdgpsJfKzrXJSXXfKibMMWZNrNB30= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726519928; c=relaxed/simple; bh=x1POr8P8O7rnaDonW0oa0APOJhygk/Ug5mg2BLSX1kE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GG1IhUMHZhPeDTM3mXqcPkZlcmIxwQfJZZmPPnbR4s207Wg0umMAAV59XUL9aV1+rPRfUSOqCe3zAlgEuqeHDq8+3AqZqbBAWHDmE9G5hgUEe7rxoNpXUOCX+jmiYSet2mK70D5QtKYSAHoxsOGPlac7KHfqisunTxQolXoWWV0= 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=mjK7qYZH; arc=fail smtp.client-ip=40.107.93.52 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="mjK7qYZH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=w1w2wJEyE7rckmWRFFFh0pr8wZKePRwsGfkRc0K10CN022LByrPnZc+ePpDHSWXDgHnlz1UOP0DM0mtx/Iby0QdQpnzwVZBvPHGLGhyE4dZPkjDLi9zf22YiRXr3V+czwsyENzMmDtBNmS+BH+O85myttADTqk8RX1L5eS6AQcl80Cnyd3V/BHs06N7M+uWuhomRXm0qKrbxaXyR8rcHVgv2Rz3YckHfoCZvkqZOIxfHU+YsjtH/1PvSe7p7etcmcDNtz/9Px06exI3GH39/xoHaM/8qthzyYx1XmgC27qZEFbEOMaqGWyMAqQAHnWAZBJmWfnkbQMBeJ/rwBvMOAQ== 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=14zAmmF0QoSasvl09XlLz1Xxt7N+OU4FvXFchR/f1co=; b=vgQY6cIIaUM4snYZazMZ5m1uFo7sK1GWr8VrNSLPhhin+GivyVXz7aGJaf8Cb/Jws+knq9iDgQlVuAHH+EIk1b8ZvVsjMW77zgh5mGkLPl4NEQddVsBHECBG6e6dZ3jxjB3iUeYMHLMe2WwPGSMdbbkb/rOCocEO2tSpi8VmGx2l9B78tzEY9eUnOS3ENjpNH9riIAO46oRQrZK6QjXT7R9+sBSv6hQY4FoeCV/Qm5EYx9MbEEMNmpemrycu6yIfZdxrXP8l1ljlKkGfOSbRq61WIfOCaqqXFpOwhRsIw91993leKt4mF6zZpkuosOtFHUX3TKSj0zc2hvUGxOHtxQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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=14zAmmF0QoSasvl09XlLz1Xxt7N+OU4FvXFchR/f1co=; b=mjK7qYZHiJVXEkwCLZ3l+LagXTVv3O0wpGH2DrI9uXX+bZthr5rw8DW5ccRbpRm023ktNGowbVRtwVY66lRHtUieO/gCvpD1dwbduH1B6OlNz7x5WNBNXCZiCrvq2mIBxdpLIpgnZkUiIOkB/W0gGCAAdbCIZw31Jfs/d6poGQ8= Received: from MN2PR14CA0025.namprd14.prod.outlook.com (2603:10b6:208:23e::30) by PH8PR12MB7184.namprd12.prod.outlook.com (2603:10b6:510:227::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.23; Mon, 16 Sep 2024 20:52:02 +0000 Received: from BL02EPF00021F6E.namprd02.prod.outlook.com (2603:10b6:208:23e:cafe::6a) by MN2PR14CA0025.outlook.office365.com (2603:10b6:208:23e::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.26 via Frontend Transport; Mon, 16 Sep 2024 20:52:01 +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 BL02EPF00021F6E.mail.protection.outlook.com (10.167.249.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Mon, 16 Sep 2024 20:52:01 +0000 Received: from weiserver.amd.com (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; Mon, 16 Sep 2024 15:51:59 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V5 4/5] bnxt_en: Add TPH support in BNXT driver Date: Mon, 16 Sep 2024 15:51:02 -0500 Message-ID: <20240916205103.3882081-5-wei.huang2@amd.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240916205103.3882081-1-wei.huang2@amd.com> References: <20240916205103.3882081-1-wei.huang2@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: BL02EPF00021F6E:EE_|PH8PR12MB7184:EE_ X-MS-Office365-Filtering-Correlation-Id: 25ef7829-5dfd-482d-9572-08dcd6916a07 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?FTgi9VvPE2UIIuA9f3Xkx62U9c0QWxiWCHCyaU/JtwSNZVb+PqH2fF7Z5p5j?= =?us-ascii?Q?fqrnlxCFmmWuN6senCSZpQbnFgw1WsCoaMzTYxSIvHxakqqD+W2+PDqxYx9l?= =?us-ascii?Q?LKvAP8+rE4ayjBy+rp/3IfWN4bypys7KWrBYWGyvTg1PA5n/tozIZq2D88C5?= =?us-ascii?Q?0miv+vdCraMJ76zYRBZhcVtFRGN0qb7ZaqH9Ci5h9KbTuwcaYZ1FAJOV5R9F?= =?us-ascii?Q?XSCfLBy19Ewez1LMQr3j91M5Y7sdlaTUw0Mb0LRnBccOMzDMZZi0PiMJYUQ7?= =?us-ascii?Q?OeCfybAlI6uIr5lI5vK7uKmygRMmhUbWg5M8he622NxcOvA5opEkpsgev5c4?= =?us-ascii?Q?I75l1vUOoJ4oBUF91JrdSvxrEAyxFRfRQ8SrxUiXC51ldXP/R2nUjbXeWhC1?= =?us-ascii?Q?oEBQxM63bXGFE7RTFp8fAvXrLANpteO5fEeVkhkPVsPVr0m4Q7f4aKk2PCVP?= =?us-ascii?Q?Bfb8FGE8yNCiQJBvsuC43BbKxvez1VUzLSnySvexBGPvPgKEODeXSA3aafiv?= =?us-ascii?Q?YGIg7vEo1TwE+8Wu4urGEGtGFsZBdMvVVPf8bc5VIhRP9ebW6I1XNZYMNRvV?= =?us-ascii?Q?ZoxPPs81R0PhxctUJt9AWmBMOqzE3r3GGK3hX8Nu5LSfBf5UALK6J1T81WkA?= =?us-ascii?Q?6GfhByzlewgnFJ63fc4Bfm0txZ2G6PDX6v9duKEXB6GFYhpso/XguimmkkRt?= =?us-ascii?Q?oXRnmetEVYCKMz9uMzJL8j6meQ4n+CJqhMU1Er78yn7/++qEnHtO4MOmNI0i?= =?us-ascii?Q?E46tqm0+4SW5P54LMKA4L0/DYS/uN+myVZaUmMMhs9oQe6tV73ca6EMniUyf?= =?us-ascii?Q?XwixuicpoFb/MMQC/euTQ5X3BjymejjF75+v1x5MIp5qTioGSim/NMU0Gcbo?= =?us-ascii?Q?XpL2EfrfV//UfvRylHCwmSmv2gypGzDnDCsRDyYoM+b6nZC3WDfvOTHMIJE+?= =?us-ascii?Q?gN5GH0eLGfPhD+2o0TLyvQn6GK5hLYx6X6LybuwhS4K6kMZvdqe02ExAqUoU?= =?us-ascii?Q?B2sactakfqNy4Um9zPimKMb7REEbk/c41p8o+9tKhf0uSCB1yRbn/5vqhnFc?= =?us-ascii?Q?zMS0lqhNaCm2CbOcdbjO/N9lJ08nUH94oAmCjbXxJoEM/bZMpX20bejL8DU5?= =?us-ascii?Q?mgvnrUX5lT7jYcfIAfWSHreRwWsC2xCZxpKEVIhtlJRQVqptQIl8x8Eu6RQP?= =?us-ascii?Q?IL8e9ExoMR5pPG6DLVncjeax829adhRUazd+XJqLxPqy5muYbvuYjJK2rlTf?= =?us-ascii?Q?RGEQQ4oSfU7+t/9wcI6Lgx8cYNHO6ITLWq8HdNMI02x2iSr4QLrCv31v48GL?= =?us-ascii?Q?LMqrOdNKNag0u8a+DiUVbalN7D+xpMbjKlXIp6elyIefooVT7JYzF/GPRvno?= =?us-ascii?Q?OyCdTN8uoc3lvklxOHbDHImBCuSdpXJ/G/hV9xCa+feLYCaVByb++CLITLsS?= =?us-ascii?Q?FHIx3Mh5ZsGIj9wrirErgY3z5Bwbqhhk?= 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)(36860700013)(7416014)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2024 20:52:01.4751 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 25ef7829-5dfd-482d-9572-08dcd6916a07 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: BL02EPF00021F6E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7184 Content-Type: text/plain; charset="utf-8" From: Manoj Panicker Implement TPH support in Broadcom BNXT device driver. The driver uses TPH functions to retrieve and configure the device's Steering Tags when its interrupt affinity is being changed. With appropriate firmware, we see sustancial memory bandwidth savings and other benefits using real network benchmarks. Co-developed-by: Somnath Kotur Signed-off-by: Somnath Kotur Co-developed-by: Wei Huang Signed-off-by: Wei Huang Signed-off-by: Manoj Panicker Reviewed-by: Ajit Khaparde Reviewed-by: Andy Gospodarek --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 85 +++++++++++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 7 ++ net/core/netdev_rx_queue.c | 1 + 3 files changed, 93 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethern= et/broadcom/bnxt/bnxt.c index 6e422e24750a..ea0bd25d1efb 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -55,6 +55,8 @@ #include #include #include +#include +#include =20 #include "bnxt_hsi.h" #include "bnxt.h" @@ -10865,6 +10867,63 @@ int bnxt_reserve_rings(struct bnxt *bp, bool irq_r= e_init) return 0; } =20 +static void __bnxt_irq_affinity_notify(struct irq_affinity_notify *notify, + const cpumask_t *mask) +{ + struct bnxt_rx_ring_info *rxr; + struct bnxt_irq *irq; + u16 tag; + int err; + + irq =3D container_of(notify, struct bnxt_irq, affinity_notify); + cpumask_copy(irq->cpu_mask, mask); + + if (pcie_tph_get_cpu_st(irq->bp->pdev, TPH_MEM_TYPE_VM, + cpumask_first(irq->cpu_mask), &tag)) + return; + + if (pcie_tph_set_st_entry(irq->bp->pdev, irq->msix_nr, tag)) + return; + + if (netif_running(irq->bp->dev)) { + rxr =3D &irq->bp->rx_ring[irq->ring_nr]; + rtnl_lock(); + err =3D netdev_rx_queue_restart(irq->bp->dev, irq->ring_nr); + if (err) + netdev_err(irq->bp->dev, + "rx queue restart failed: err=3D%d\n", err); + rtnl_unlock(); + } +} + +static void __bnxt_irq_affinity_release(struct kref __always_unused *ref) +{ +} + +static void bnxt_release_irq_notifier(struct bnxt_irq *irq) +{ + irq_set_affinity_notifier(irq->vector, NULL); +} + +static void bnxt_register_irq_notifier(struct bnxt *bp, struct bnxt_irq *i= rq) +{ + struct irq_affinity_notify *notify; + + /* Nothing to do if TPH is not enabled */ + if (!bp->tph_mode) + return; + + irq->bp =3D bp; + + /* Register IRQ affinity notifier */ + notify =3D &irq->affinity_notify; + notify->irq =3D irq->vector; + notify->notify =3D __bnxt_irq_affinity_notify; + notify->release =3D __bnxt_irq_affinity_release; + + irq_set_affinity_notifier(irq->vector, notify); +} + static void bnxt_free_irq(struct bnxt *bp) { struct bnxt_irq *irq; @@ -10887,11 +10946,18 @@ static void bnxt_free_irq(struct bnxt *bp) free_cpumask_var(irq->cpu_mask); irq->have_cpumask =3D 0; } + + bnxt_release_irq_notifier(irq); + free_irq(irq->vector, bp->bnapi[i]); } =20 irq->requested =3D 0; } + + /* Disable TPH support */ + pcie_disable_tph(bp->pdev); + bp->tph_mode =3D 0; } =20 static int bnxt_request_irq(struct bnxt *bp) @@ -10911,6 +10977,12 @@ static int bnxt_request_irq(struct bnxt *bp) #ifdef CONFIG_RFS_ACCEL rmap =3D bp->dev->rx_cpu_rmap; #endif + + /* Enable TPH support as part of IRQ request */ + rc =3D pcie_enable_tph(bp->pdev, PCI_TPH_ST_IV_MODE); + if (!rc) + bp->tph_mode =3D PCI_TPH_ST_IV_MODE; + for (i =3D 0, j =3D 0; i < bp->cp_nr_rings; i++) { int map_idx =3D bnxt_cp_num_to_irq_num(bp, i); struct bnxt_irq *irq =3D &bp->irq_tbl[map_idx]; @@ -10934,8 +11006,11 @@ static int bnxt_request_irq(struct bnxt *bp) =20 if (zalloc_cpumask_var(&irq->cpu_mask, GFP_KERNEL)) { int numa_node =3D dev_to_node(&bp->pdev->dev); + u16 tag; =20 irq->have_cpumask =3D 1; + irq->msix_nr =3D map_idx; + irq->ring_nr =3D i; cpumask_set_cpu(cpumask_local_spread(i, numa_node), irq->cpu_mask); rc =3D irq_set_affinity_hint(irq->vector, irq->cpu_mask); @@ -10945,6 +11020,16 @@ static int bnxt_request_irq(struct bnxt *bp) irq->vector); break; } + + bnxt_register_irq_notifier(bp, irq); + + /* Init ST table entry */ + if (pcie_tph_get_cpu_st(irq->bp->pdev, TPH_MEM_TYPE_VM, + cpumask_first(irq->cpu_mask), + &tag)) + continue; + + pcie_tph_set_st_entry(irq->bp->pdev, irq->msix_nr, tag); } } return rc; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethern= et/broadcom/bnxt/bnxt.h index 69231e85140b..641d25646367 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1227,6 +1227,11 @@ struct bnxt_irq { u8 have_cpumask:1; char name[IFNAMSIZ + BNXT_IRQ_NAME_EXTRA]; cpumask_var_t cpu_mask; + + struct bnxt *bp; + int msix_nr; + int ring_nr; + struct irq_affinity_notify affinity_notify; }; =20 #define HWRM_RING_ALLOC_TX 0x1 @@ -2183,6 +2188,8 @@ struct bnxt { struct net_device *dev; struct pci_dev *pdev; =20 + u8 tph_mode; + atomic_t intr_sem; =20 u32 flags; diff --git a/net/core/netdev_rx_queue.c b/net/core/netdev_rx_queue.c index e217a5838c87..10e95d7b6892 100644 --- a/net/core/netdev_rx_queue.c +++ b/net/core/netdev_rx_queue.c @@ -79,3 +79,4 @@ int netdev_rx_queue_restart(struct net_device *dev, unsig= ned int rxq_idx) =20 return err; } +EXPORT_SYMBOL_GPL(netdev_rx_queue_restart); --=20 2.45.1 From nobody Fri Nov 29 17:43:18 2024 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2042.outbound.protection.outlook.com [40.107.237.42]) (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 940EC15DBDD; Mon, 16 Sep 2024 20:52:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726519947; cv=fail; b=ThS7IY+ZA3RGtXHt7/nqTQKKMgpaOlDC+HVHKUrsdA0FwhrN41/QOFGiTY9Z7nZXcOy90QHv+YZVQa+CMTbSnKFW29GXJ7qi1ZTwSBc3gdOPFhKauUmKNo1C9C8qsnuFrlQVvKM2SUTHTj+u00Mrw4o2HT8kH0eeGjuicuvQ3nQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726519947; c=relaxed/simple; bh=+SHu1cz4TmSIS5szBMQrR2ftPjmoRxXWc04Tu5ERSM8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DCVpKDC11oy8q92TDQNEmQu+geHaaf5XQ2hs447ZqRneZigXIeg6y6PtsM81C3T+/H4zXzoKy+5dXCGKwAy0T/e3ssOBiAdTs/xrD+DAQiKxJQpaJ0sqoCmDfwH5zRPB/El2BhX1+yRJYwT725XW6KASEswl2uELirZlab1ohek= 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=VFYVwgoi; arc=fail smtp.client-ip=40.107.237.42 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="VFYVwgoi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BLI17whfhCg2+a2URYFw0/9mTxOr5GlcEcbLLM69Pn7JC6l+cBdddX4MBJMma/ql17y7bSIIrFzW1NkHvvCa4mN4JpY1cP1RJ5RAdCip0CVk8/OxL3WYihLsLRp6XlQbDoNOnB1HUI0axAZss3hhPWdrMf2Xvlp5QnZDRaTxrUt0tHDNG0RPiqZwMYow5D4mJu+B9/DOpA5BYZ8qAQjSR3gmb5qJIxL+TBlfbT5XnsJbBUDoipLOJgel13RzPlErBjQwxX6EeE0A6REzaowGQuRBG6Nawbj+PAN9yOuPdmUeQEEC/IAEIVduRYZqxlnO10xgGn7LS41CscV1FVo10A== 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=NyNJGi/6ZYPbBp24yZ6fsr4GtEu6YRSWKr+SNRgzekI=; b=GRB+mYnPvAei9IDzyPDF0YsQb6PP42efYpZ/OCcPBieNNHZkVN6FaRfGnxTCHQnWtQc5xIRzDtJxScy7u6m4tSBTiQAPycnoqH3Z5TIJtxlwdwhl2DEkKXOK4+hvSqjOpOtslK08VvuSUYz2RJ3jZ/7vW3fm7uZVA2qsZIIyCRTRBF6PgI+tN8trXBeqNTXdW3BMK8PuoMV6+ii+/bqW1gzJ1bPvfsCRYr27gv6EqbS7+0LeTPcdK3LHZxO+yZm8XX0ydD2XEwZevB+4IzNTu+dI74FB707/1bF2JN7JMVQXakQ+NGGceXvzCBVwP4uInYFfekMYoZIU5fn0qrJpAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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=NyNJGi/6ZYPbBp24yZ6fsr4GtEu6YRSWKr+SNRgzekI=; b=VFYVwgoixWh+WkmdaEJ3HtPt5NIlvNtLKSBavR2UpqvnO7krJ0wKs+RCbAGFzqTxI87dzfoHkPWWLGLrVxTfpc0WC1Y5ZnP6Q+ch1RMx1J+JGTP3Vu+vOw/8sb6gle+LNhaXCRXmLKKuPPbrECL9x5sHK6qnvZ+f3PiXhDJIXNI= Received: from BL0PR02CA0046.namprd02.prod.outlook.com (2603:10b6:207:3d::23) by MW3PR12MB4473.namprd12.prod.outlook.com (2603:10b6:303:56::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.24; Mon, 16 Sep 2024 20:52:20 +0000 Received: from BL02EPF00021F68.namprd02.prod.outlook.com (2603:10b6:207:3d:cafe::c3) by BL0PR02CA0046.outlook.office365.com (2603:10b6:207:3d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24 via Frontend Transport; Mon, 16 Sep 2024 20:52: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 BL02EPF00021F68.mail.protection.outlook.com (10.167.249.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Mon, 16 Sep 2024 20:52:20 +0000 Received: from weiserver.amd.com (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; Mon, 16 Sep 2024 15:52:18 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V5 5/5] bnxt_en: Pass NQ ID to the FW when allocating RX/RX AGG rings Date: Mon, 16 Sep 2024 15:51:03 -0500 Message-ID: <20240916205103.3882081-6-wei.huang2@amd.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240916205103.3882081-1-wei.huang2@amd.com> References: <20240916205103.3882081-1-wei.huang2@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: BL02EPF00021F68:EE_|MW3PR12MB4473:EE_ X-MS-Office365-Filtering-Correlation-Id: 92bc06b9-004d-47a9-84c5-08dcd6917524 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?1fnyGcQ+DdEE19cBLCzmf5XRItLxtSeQSNEi1aQrIKXxHZvs0LiUB6tMkHL9?= =?us-ascii?Q?lxewKzwbuqpanWfRY60aIVTxLTqQdzn9g62cOs8sNJ3kOtIQZxC73Xsgv3Fx?= =?us-ascii?Q?Vn3inzAJdMW+Ilt4CVTKu8lL6+KGlBje5ZMrHcLZVbcsDjD2KC+QJNeyvn9x?= =?us-ascii?Q?CHTEIkVaddS+lH9QWTTvAnLEHqOw/jPX1Ujrm0cnd5fVDXMr4Hj1EWfUVz1c?= =?us-ascii?Q?9jMVgOAmTjDZVQyh3azz5HvvIF9okDJgTDmiGYJpnc611lfNcOiBH+VMiX17?= =?us-ascii?Q?ueuV3AERBywr7m4PIpupPAV5LZ9y9zl4gD/AGPquSg9DE4o8Foka5cQkt3Hm?= =?us-ascii?Q?nJeugzN/SKpdxEgzGa4X2Cgm+5/o+1+7MCmE+jhlC929RMfadVfz4vVrIHiD?= =?us-ascii?Q?1S/f2BrzrFNt8XXPeqtEWY8MT5fxkFCvYOVEh8zv2ByqHbnreJdB3j7LJLmZ?= =?us-ascii?Q?Sx1VOZuagBYFVgWud1Fa+kwoukSBUgaJkJmkt5c9GHMS/qsHboY592bVj3OZ?= =?us-ascii?Q?a4igCxQAGhXTQEmA+eebT0sKkGd1ZEWHLxrnUeq++zz37oVUqhntsI3Z+JkC?= =?us-ascii?Q?RZ3ytEWoToeeXvuqGZSyEHmFx47drc9klhTYOeeh8Jv7Fy9vo1u3rBYdBYqK?= =?us-ascii?Q?qxTAW4wTMy9NzOt6Wuc1S9ggaQkRoeYLK6JGDodx+il3xClPMYNHzve+N5IV?= =?us-ascii?Q?JtbivFMAG0NzLwXRpgAz8iKjTUhomwOhJtRpJQ+G9e01/VnDgAflk25EysvN?= =?us-ascii?Q?MJmnHEGTYPpEZHm5MRcJjkq2mPBqh+SQgr1Eh55mI0uzNLq+a07YDoQMH+mz?= =?us-ascii?Q?mme8doHwpiab4YN3YWJx2SfJApm7GXWh+fqM03AK5jQZOeXZ2M47Y2DPyaEv?= =?us-ascii?Q?+innqZkmGUIaJUkUkL9Re8uh0jMcw+vvYYR2bJXVDhZCiySj2kNdCnHl3OJ+?= =?us-ascii?Q?+s9g6hvvdvRay9fWv9Z5zvbURiGr4evg5+cMPTNZ83sJ3TWH2uEvWdFLEYkC?= =?us-ascii?Q?5qsqnb/zQNwVHlYW7lD6LYWIWMIxnjbqs0DlxP/px/crU01trwKZgLRBBDPm?= =?us-ascii?Q?ukGwZEINd9M8kcPGdtN5T4tr7w8X8XK5kvvMZbvX7kD1JYbAGUFE6O3eJJh+?= =?us-ascii?Q?1lpC6g6CSoqrI16vordIublPaRR4dsy/9A8xvGiuhhUfjkBXxZjtiCY3QxpD?= =?us-ascii?Q?2X+ZXyvYiQNECJA5oURWn4AoJE3xU28p30NpZg68qJKQVp7JcWbpi8sXtfR1?= =?us-ascii?Q?3RXyhU0GNN+RKPXCvIXxOegfCMY5vra5mTKl1zgZa1N65xHLyaMCGO+nI9xs?= =?us-ascii?Q?lvQ2wU8yqFKQykrHVMdNippDuhcMskXhSN+wDQz5Qw1Yof8uWbfsDMINYi19?= =?us-ascii?Q?vxngDdy8G60NNNw0shAEFBnsQfClC/JgVq7Wi4bYAtJA/w26mP7+JZwqR4fY?= =?us-ascii?Q?VqICHkv/fwZLJeP7TqzIwYCUrGCdFakq?= 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)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2024 20:52:20.1197 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 92bc06b9-004d-47a9-84c5-08dcd6917524 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: BL02EPF00021F68.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4473 Content-Type: text/plain; charset="utf-8" From: Michael Chan Newer firmware can use the NQ ring ID associated with each RX/RX AGG ring to enable PCIe steering tag. Older firmware will just ignore the information. Signed-off-by: Michael Chan Signed-off-by: Andy Gospodarek Reviewed-by: Hongguang Gao Reviewed-by: Ajit Khaparde --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethern= et/broadcom/bnxt/bnxt.c index ea0bd25d1efb..48ca3095ef2e 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -6811,10 +6811,12 @@ static int hwrm_ring_alloc_send_msg(struct bnxt *bp, =20 /* Association of rx ring with stats context */ grp_info =3D &bp->grp_info[ring->grp_idx]; + req->nq_ring_id =3D cpu_to_le16(grp_info->cp_fw_ring_id); req->rx_buf_size =3D cpu_to_le16(bp->rx_buf_use_size); req->stat_ctx_id =3D cpu_to_le32(grp_info->fw_stats_ctx); req->enables |=3D cpu_to_le32( - RING_ALLOC_REQ_ENABLES_RX_BUF_SIZE_VALID); + RING_ALLOC_REQ_ENABLES_RX_BUF_SIZE_VALID | + RING_ALLOC_REQ_ENABLES_NQ_RING_ID_VALID); if (NET_IP_ALIGN =3D=3D 2) flags =3D RING_ALLOC_REQ_FLAGS_RX_SOP_PAD; req->flags =3D cpu_to_le16(flags); @@ -6826,11 +6828,13 @@ static int hwrm_ring_alloc_send_msg(struct bnxt *bp, /* Association of agg ring with rx ring */ grp_info =3D &bp->grp_info[ring->grp_idx]; req->rx_ring_id =3D cpu_to_le16(grp_info->rx_fw_ring_id); + req->nq_ring_id =3D cpu_to_le16(grp_info->cp_fw_ring_id); req->rx_buf_size =3D cpu_to_le16(BNXT_RX_PAGE_SIZE); req->stat_ctx_id =3D cpu_to_le32(grp_info->fw_stats_ctx); req->enables |=3D cpu_to_le32( RING_ALLOC_REQ_ENABLES_RX_RING_ID_VALID | - RING_ALLOC_REQ_ENABLES_RX_BUF_SIZE_VALID); + RING_ALLOC_REQ_ENABLES_RX_BUF_SIZE_VALID | + RING_ALLOC_REQ_ENABLES_NQ_RING_ID_VALID); } else { req->ring_type =3D RING_ALLOC_REQ_RING_TYPE_RX; } --=20 2.45.1