diff options
author | jhb <jhb@FreeBSD.org> | 2016-06-24 17:26:42 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2016-06-24 17:26:42 +0000 |
commit | 73d915a1ae17a1f5e5259b8555ff53f9c3ba1ad2 (patch) | |
tree | 42c9c5655c7b53d96282330ff2dff3f5bb7e6de4 /sys/dev/pci/pci.c | |
parent | b5c3fb9427806b740f7df3e43a1513e1f5fa840b (diff) | |
download | FreeBSD-src-73d915a1ae17a1f5e5259b8555ff53f9c3ba1ad2.zip FreeBSD-src-73d915a1ae17a1f5e5259b8555ff53f9c3ba1ad2.tar.gz |
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
Diffstat (limited to 'sys/dev/pci/pci.c')
-rw-r--r-- | sys/dev/pci/pci.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 06877b9..784dd00 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -1993,6 +1993,22 @@ pci_ht_map_msi(device_t dev, uint64_t addr) } 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); |