]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
PCI: Add pcie_bandwidth_available() to compute bandwidth available to device
authorTal Gilboa <talgi@mellanox.com>
Fri, 30 Mar 2018 13:37:44 +0000 (08:37 -0500)
committerBjorn Helgaas <helgaas@kernel.org>
Tue, 3 Apr 2018 13:58:29 +0000 (08:58 -0500)
commit6db79a88c67e4679d9c1e4a3f05c6385e21f6e9a
tree0a382af9924ea5146d648539fb4ea993c940e499
parentb852f63aa6cee3f4846383377c414ae9c4fbc166
PCI: Add pcie_bandwidth_available() to compute bandwidth available to device

Add pcie_bandwidth_available() to compute the bandwidth available to a
device.  This may be limited by the device itself or by a slower upstream
link leading to the device.

The available bandwidth at each link along the path is computed as:

  link_width * link_speed * (1 - encoding_overhead)

2.5 and 5.0 GT/s links use 8b/10b encoding, which reduces the raw bandwidth
available by 20%; 8.0 GT/s and faster links use 128b/130b encoding, which
reduces it by about 1.5%.

The result is in Mb/s, i.e., megabits/second, of raw bandwidth.

Also return the device with the slowest link and the speed and width of
that link.

Signed-off-by: Tal Gilboa <talgi@mellanox.com>
[bhelgaas: changelog, leave pcie_get_minimum_link() alone for now, return
bw directly, use pci_upstream_bridge(), check "next_bw <= bw" to find
uppermost limiting device, return speed/width of the limiting device]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/pci.c
include/linux/pci.h