Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Nov 2017 05:05:05 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r325793 - head/sys/dev/pci
Message-ID:  <201711140505.vAE555QF042553@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201711140505.vAE555QF042553>