|
@@ -5208,6 +5208,28 @@ enum pcie_link_width pcie_get_width_cap(struct pci_dev *dev)
|
|
return PCIE_LNK_WIDTH_UNKNOWN;
|
|
return PCIE_LNK_WIDTH_UNKNOWN;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * pcie_bandwidth_capable - calculate a PCI device's link bandwidth capability
|
|
|
|
+ * @dev: PCI device
|
|
|
|
+ * @speed: storage for link speed
|
|
|
|
+ * @width: storage for link width
|
|
|
|
+ *
|
|
|
|
+ * Calculate a PCI device's link bandwidth by querying for its link speed
|
|
|
|
+ * and width, multiplying them, and applying encoding overhead. The result
|
|
|
|
+ * is in Mb/s, i.e., megabits/second of raw bandwidth.
|
|
|
|
+ */
|
|
|
|
+u32 pcie_bandwidth_capable(struct pci_dev *dev, enum pci_bus_speed *speed,
|
|
|
|
+ enum pcie_link_width *width)
|
|
|
|
+{
|
|
|
|
+ *speed = pcie_get_speed_cap(dev);
|
|
|
|
+ *width = pcie_get_width_cap(dev);
|
|
|
|
+
|
|
|
|
+ if (*speed == PCI_SPEED_UNKNOWN || *width == PCIE_LNK_WIDTH_UNKNOWN)
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
|
|
+ return *width * PCIE_SPEED2MBS_ENC(*speed);
|
|
|
|
+}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* pci_select_bars - Make BAR mask from the type of resource
|
|
* pci_select_bars - Make BAR mask from the type of resource
|
|
* @dev: the PCI device for which BAR mask is made
|
|
* @dev: the PCI device for which BAR mask is made
|