svn commit: r302175 - in head: share/man/man9 sys/dev/pci
John Baldwin
jhb at FreeBSD.org
Fri Jun 24 17:26:44 UTC 2016
Author: jhb
Date: Fri Jun 24 17:26:42 2016
New Revision: 302175
URL: https://svnweb.freebsd.org/changeset/base/302175
Log:
Add pci_get_max_payload() to fetch the PCI-express maximum payload size.
Approved by: re (gjb)
MFC after: 2 weeks
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D6951
Modified:
head/share/man/man9/pci.9
head/sys/dev/pci/pci.c
head/sys/dev/pci/pcivar.h
Modified: head/share/man/man9/pci.9
==============================================================================
--- head/share/man/man9/pci.9 Fri Jun 24 14:58:37 2016 (r302174)
+++ head/share/man/man9/pci.9 Fri Jun 24 17:26:42 2016 (r302175)
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd May 16, 2016
+.Dd June 24, 2016
.Dt PCI 9
.Os
.Sh NAME
@@ -44,6 +44,7 @@
.Nm pci_find_htcap ,
.Nm pci_find_pcie_root_port ,
.Nm pci_get_id ,
+.Nm pci_get_max_payload ,
.Nm pci_get_max_read_req ,
.Nm pci_get_powerstate ,
.Nm pci_get_vpd_ident ,
@@ -100,6 +101,8 @@
.Ft int
.Fn pci_get_id "device_t dev" "enum pci_id_type type" "uintptr_t *id"
.Ft int
+.Fn pci_get_max_payload "device_t dev"
+.Ft int
.Fn pci_get_max_read_req "device_t dev"
.Ft int
.Fn pci_get_powerstate "device_t dev"
@@ -461,6 +464,16 @@ or
.Xr bus_activate_resource 9 .
.Pp
The
+.Fn pci_get_max_payload
+function returns the current maximum TLP payload size in bytes for a
+PCI-express device.
+If the
+.Fa dev
+device is not a PCI-express device,
+.Fn pci_get_max_payload
+returns zero.
+.Pp
+The
.Fn pci_get_max_read_req
function returns the current maximum read request size in bytes for a
PCI-express device.
Modified: head/sys/dev/pci/pci.c
==============================================================================
--- head/sys/dev/pci/pci.c Fri Jun 24 14:58:37 2016 (r302174)
+++ head/sys/dev/pci/pci.c Fri Jun 24 17:26:42 2016 (r302175)
@@ -1993,6 +1993,22 @@ pci_ht_map_msi(device_t dev, uint64_t ad
}
int
+pci_get_max_payload(device_t dev)
+{
+ struct pci_devinfo *dinfo = device_get_ivars(dev);
+ int cap;
+ uint16_t val;
+
+ cap = dinfo->cfg.pcie.pcie_location;
+ if (cap == 0)
+ return (0);
+ val = pci_read_config(dev, cap + PCIER_DEVICE_CTL, 2);
+ val &= PCIEM_CTL_MAX_PAYLOAD;
+ val >>= 5;
+ return (1 << (val + 7));
+}
+
+int
pci_get_max_read_req(device_t dev)
{
struct pci_devinfo *dinfo = device_get_ivars(dev);
Modified: head/sys/dev/pci/pcivar.h
==============================================================================
--- head/sys/dev/pci/pcivar.h Fri Jun 24 14:58:37 2016 (r302174)
+++ head/sys/dev/pci/pcivar.h Fri Jun 24 17:26:42 2016 (r302175)
@@ -585,6 +585,7 @@ int pci_msix_device_blacklisted(device_t
void pci_ht_map_msi(device_t dev, uint64_t addr);
device_t pci_find_pcie_root_port(device_t dev);
+int pci_get_max_payload(device_t dev);
int pci_get_max_read_req(device_t dev);
void pci_restore_state(device_t dev);
void pci_save_state(device_t dev);
More information about the svn-src-head
mailing list