From nobody Mon Oct 17 20:41:37 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MrpnF3CQ1z4fQsj; Mon, 17 Oct 2022 20:41:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MrpnF23VCz460m; Mon, 17 Oct 2022 20:41:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666039297; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0es5/uvkGuHK/PjL6MYJEl0JBTeckza+29TI+MNH3YQ=; b=nI4Epe/uFNK7QXPzdM+tA4pg72FcKQ5sgKUGPrtj0mC4OgGrpo/uhCxHwBjY+8LhK3U1EQ UPypvHq2AORlidV8IBuKhpJIr2Cey0z2YmumzJji3xie0DjdmoHmG5qzUzsfLCRQ+sXdnO fTHg4rm2ea3DsRneCWF6rXImTQkrBXIX1i3ZP9eczyoVEyeybQo7RGJX7koY/8Sp1OVYsy 7Zq1Z5HbGQ++vUFOTegEfMiO87NcAWTX9e/RvqIvZOsNrJrfMthtLJywQ6bZ5Z+OaMON/l az4lr3SlmPxNbVzHxlKXqwSpRsmg9D2p70btUr8Qy27anQYTAdVpavVkrC5lpw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MrpnF19P5zxGT; Mon, 17 Oct 2022 20:41:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 29HKfbYO096499; Mon, 17 Oct 2022 20:41:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29HKfbv6096498; Mon, 17 Oct 2022 20:41:37 GMT (envelope-from git) Date: Mon, 17 Oct 2022 20:41:37 GMT Message-Id: <202210172041.29HKfbv6096498@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: e3c5f195a573 - stable/13 - LinuxKPI: pci.h add more defines and functions List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e3c5f195a57330e5881901c04e149d2704051b85 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666039297; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0es5/uvkGuHK/PjL6MYJEl0JBTeckza+29TI+MNH3YQ=; b=YLHM5Z+FMQ5AkIM6ThBRTTQ2+V71DMxTJqTxeJRnAtTopBoHhhBYNHT3Df4CFCg4oJGGve vPRKjAvVKaSvvwuYR/C/E+/p71N45AvsP20bg22/5dChPYZr9yGcioVwslN4QEKTRE11OL HPXTmz4Hp7VIAVlLkQLvHAkpiy3CbMJW2uZWmWSAUaSf7wyfu7v4ete3Zc0Kp/sLxl7UyE 2nh+o9DX3n/JpZrDZoUXRtaQpF1YeV5BWtIasJ/dTJpVC587L75p7/3BbqRncI5YzLrQEk SRMbIy2TzEHkCFLWUquBWERJ+7NXThv+sA9S1SZdQnIQrb2og+ujYMX+7fiSQQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666039297; a=rsa-sha256; cv=none; b=AqrBIiPZ9cMifpLKzYvWIIUdstQUCPKEtERblfLXgzitpcuQFY7ayM1OyettgKnEYvRq01 y8Gykek7z2cQtlrMr0+AQdLS8aYPIhUSPi1LEKhiK+JRG/551KWu4MNgZ6AR8Vg034wBGq dls82vN++8rrGBCYDw0Og6M3MeQsXRK3ciTfxBtiW7R2tcpRUh6r+kzMyrra6yI+OxEKHt h05wVarl8TKgRDtgcm/Cx9P1eXiNxvyJc37tCcv9HZQ7KkmRycR2EbaOIERSwT7TLFP7tv idqnIaKsth40OVbfMTVadcDhzboGnKqOCmDZ5Kb+InJYxVnmuhqK+Kaj2cfH2Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=e3c5f195a57330e5881901c04e149d2704051b85 commit e3c5f195a57330e5881901c04e149d2704051b85 Author: Bjoern A. Zeeb AuthorDate: 2022-09-21 19:39:01 +0000 Commit: Bjoern A. Zeeb CommitDate: 2022-10-17 20:37:04 +0000 LinuxKPI: pci.h add more defines and functions Add #defines for PCI_DEVICE_ID and repoint the PCI_VENDOR_ID one. Add dev_is_pci(). Add pcie_capability_clear_word() according to similar implementations. Sponsored by: The FreeBSD Foundation Reviewed by: hselasky, emaste Differential Revision: https://reviews.freebsd.org/D36653 (cherry picked from commit c41d83548b6cf18b48af974ad995354f38cf04a4) --- sys/compat/linuxkpi/common/include/linux/pci.h | 29 ++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index 6493391926e2..79999c3912f7 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -4,7 +4,7 @@ * Copyright (c) 2010 Panasas, Inc. * Copyright (c) 2013-2016 Mellanox Technologies, Ltd. * All rights reserved. - * Copyright (c) 2020-2021 The FreeBSD Foundation + * Copyright (c) 2020-2022 The FreeBSD Foundation * * Portions of this software were developed by Björn Zeeb * under sponsorship from the FreeBSD Foundation. @@ -108,7 +108,8 @@ MODULE_PNP_INFO("U32:vendor;U32:device;V32:subvendor;V32:subdevice", \ #define to_pci_dev(n) container_of(n, struct pci_dev, dev) -#define PCI_VENDOR_ID PCIR_DEVVENDOR +#define PCI_VENDOR_ID PCIR_VENDOR +#define PCI_DEVICE_ID PCIR_DEVICE #define PCI_COMMAND PCIR_COMMAND #define PCI_COMMAND_INTX_DISABLE PCIM_CMD_INTxDIS #define PCI_EXP_DEVCTL PCIER_DEVICE_CTL /* Device Control */ @@ -215,6 +216,7 @@ typedef int pci_power_t; #define PCI_IRQ_LEGACY 0x01 #define PCI_IRQ_MSI 0x02 #define PCI_IRQ_MSIX 0x04 +#define PCI_IRQ_ALL_TYPES (PCI_IRQ_MSIX|PCI_IRQ_MSI|PCI_IRQ_LEGACY) struct pci_dev; @@ -352,6 +354,13 @@ struct resource *_lkpi_pci_iomap(struct pci_dev *pdev, int bar, int mmio_size); struct pcim_iomap_devres *lkpi_pcim_iomap_devres_find(struct pci_dev *pdev); void lkpi_pcim_iomap_table_release(struct device *, void *); +static inline bool +dev_is_pci(struct device *dev) +{ + + return (device_get_devclass(dev->bsddev) == devclass_find("pci")); +} + static inline int pci_resource_type(struct pci_dev *pdev, int bar) { @@ -1183,6 +1192,22 @@ pcie_capability_set_word(struct pci_dev *dev, int pos, uint16_t val) return (error); } +static inline int +pcie_capability_clear_word(struct pci_dev *dev, int pos, uint16_t val) +{ + int error; + uint16_t v; + + error = pcie_capability_read_word(dev, pos, &v); + if (error != 0) + return (error); + + v &= ~val; + + error = pcie_capability_write_word(dev, pos, v); + return (error); +} + static inline int pcie_get_minimum_link(struct pci_dev *dev, enum pci_bus_speed *speed, enum pcie_link_width *width) {