From owner-svn-src-head@freebsd.org Tue Nov 14 05:05:06 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AAD9DD1F354; Tue, 14 Nov 2017 05:05:06 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 77FC46EE0A; Tue, 14 Nov 2017 05:05:06 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vAE555Db042555; Tue, 14 Nov 2017 05:05:05 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vAE555QF042553; Tue, 14 Nov 2017 05:05:05 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201711140505.vAE555QF042553@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Tue, 14 Nov 2017 05:05:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r325793 - head/sys/dev/pci X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/dev/pci X-SVN-Commit-Revision: 325793 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Nov 2017 05:05:06 -0000 Author: imp Date: Tue Nov 14 05:05:05 2017 New Revision: 325793 URL: https://svnweb.freebsd.org/changeset/base/325793 Log: Provide pcie_link_status and pcie_link_cap convenience functions. Sponsored by: Netflix Modified: head/sys/dev/pci/pci.c head/sys/dev/pci/pcivar.h Modified: head/sys/dev/pci/pci.c ============================================================================== --- head/sys/dev/pci/pci.c Tue Nov 14 05:03:38 2017 (r325792) +++ head/sys/dev/pci/pci.c Tue Nov 14 05:05:05 2017 (r325793) @@ -6115,3 +6115,31 @@ pcie_flr(device_t dev, u_int max_delay, bool force) pci_printf(&dinfo->cfg, "Transactions pending after FLR!\n"); return (true); } + +uint16_t +pcie_link_status(device_t dev) +{ + struct pci_devinfo *dinfo; + struct pcicfg_pcie *cfg; + int pos; + + dinfo = device_get_ivars(dev); + cfg = &dinfo->cfg.pcie; + pos = cfg->pcie_location; + + return pci_read_config(dev, pos + PCIER_LINK_STA, 2); +} + +uint16_t +pcie_link_caps(device_t dev) +{ + struct pci_devinfo *dinfo; + struct pcicfg_pcie *cfg; + int pos; + + dinfo = device_get_ivars(dev); + cfg = &dinfo->cfg.pcie; + pos = cfg->pcie_location; + + return pci_read_config(dev, pos + PCIER_LINK_CAP, 2); +} Modified: head/sys/dev/pci/pcivar.h ============================================================================== --- head/sys/dev/pci/pcivar.h Tue Nov 14 05:03:38 2017 (r325792) +++ head/sys/dev/pci/pcivar.h Tue Nov 14 05:05:05 2017 (r325793) @@ -598,6 +598,8 @@ uint32_t pcie_adjust_config(device_t dev, int reg, uin bool pcie_flr(device_t dev, u_int max_delay, bool force); int pcie_get_max_completion_timeout(device_t dev); bool pcie_wait_for_pending_transactions(device_t dev, u_int max_delay); +uint16_t pcie_link_status(device_t dev); +uint16_t pcie_link_caps(device_t dev); #ifdef BUS_SPACE_MAXADDR #if (BUS_SPACE_MAXADDR > 0xFFFFFFFF)