PCI: Add pcie_bandwidth_capable() to compute max supported link bandwidth
authorTal Gilboa <talgi@mellanox.com>
Fri, 30 Mar 2018 13:32:03 +0000 (08:32 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 30 Mar 2018 20:33:38 +0000 (15:33 -0500)
commitb852f63aa6cee3f4846383377c414ae9c4fbc166
tree55fd810d9b5c8b029cf63bc4e70ee4990275b66a
parentc70b65fb7f121da7d01f62588ce6abb4741f513f
PCI: Add pcie_bandwidth_capable() to compute max supported link bandwidth

Add pcie_bandwidth_capable() to compute the max link bandwidth supported by
a device, based on the max link speed and width, adjusted by the encoding
overhead.

The maximum bandwidth of the link is computed as:

  max_link_width * max_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.

Signed-off-by: Tal Gilboa <talgi@mellanox.com>
[bhelgaas: add 16 GT/s, adjust for pcie_get_speed_cap() and
pcie_get_width_cap() signatures, don't export outside drivers/pci]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/pci.c
drivers/pci/pci.h