]> git.openfabrics.org - ~emulex/tmp/compat/.git/commitdiff
Added pcie_get_mps/pcie_set_mps
authorVladimir Sokolovsky <vlad@mellanox.com>
Wed, 5 Nov 2014 12:50:03 +0000 (14:50 +0200)
committerVladimir Sokolovsky <vlad@mellanox.com>
Wed, 5 Nov 2014 12:50:03 +0000 (14:50 +0200)
Signed-off-by: Vladimir Sokolovsky <vlad@mellanox.com>
compat/Makefile
compat/compat-3.13.c [new file with mode: 0644]
include/linux/compat-3.13.h

index f02558052380555c371ad64a9e8790d23dd62839..b58baac0ff33c4d06bd29adc045710fc05a424c0 100644 (file)
@@ -52,6 +52,7 @@ compat-$(CONFIG_COMPAT_KERNEL_3_7) += compat-3.7.o
 compat-$(CONFIG_COMPAT_KERNEL_3_9) += compat-3.9.o
 compat-$(CONFIG_COMPAT_KERNEL_3_11) += compat-3.11.o
 compat-$(CONFIG_COMPAT_KERNEL_3_12) += compat-3.12.o
+compat-$(CONFIG_COMPAT_KERNEL_3_13) += compat-3.13.o
 compat-$(CONFIG_COMPAT_KERNEL_3_16) += compat-3.16.o
 compat-$(CONFIG_COMPAT_KERNEL_3_18) += compat-3.18.o
 
diff --git a/compat/compat-3.13.c b/compat/compat-3.13.c
new file mode 100644 (file)
index 0000000..c65634c
--- /dev/null
@@ -0,0 +1,42 @@
+#include <linux/pci.h>
+
+/**
+ * pcie_get_mps - get PCI Express maximum payload size
+ * @dev: PCI device to query
+ *
+ * Returns maximum payload size in bytes
+ */
+int pcie_get_mps(struct pci_dev *dev)
+{
+       u16 ctl;
+
+       pcie_capability_read_word(dev, PCI_EXP_DEVCTL, &ctl);
+
+       return 128 << ((ctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5);
+}
+EXPORT_SYMBOL(pcie_get_mps);
+
+/**
+ * pcie_set_mps - set PCI Express maximum payload size
+ * @dev: PCI device to query
+ * @mps: maximum payload size in bytes
+ *    valid values are 128, 256, 512, 1024, 2048, 4096
+ *
+ * If possible sets maximum payload size
+ */
+int pcie_set_mps(struct pci_dev *dev, int mps)
+{
+       u16 v;
+
+       if (mps < 128 || mps > 4096 || !is_power_of_2(mps))
+               return -EINVAL;
+
+       v = ffs(mps) - 8;
+       if (v > dev->pcie_mpss)
+               return -EINVAL;
+       v <<= 5;
+
+       return pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL,
+                                                 PCI_EXP_DEVCTL_PAYLOAD, v);
+}
+EXPORT_SYMBOL(pcie_set_mps);
index 619b8f9be8e971c23c15dc2727e94cd835ff13b2..9d405002ddda90e18bec746d8ce90633cc4f32e4 100644 (file)
@@ -16,6 +16,12 @@ static inline void reinit_completion(struct completion *x)
 
 #endif
 
+#define pcie_get_mps LINUX_BACKPORT(pcie_get_mps)
+int pcie_get_mps(struct pci_dev *dev);
+
+#define pcie_set_mps LINUX_BACKPORT(pcie_set_mps)
+int pcie_set_mps(struct pci_dev *dev, int mps);
+
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)) */
 
 #endif /* LINUX_3_13_COMPAT_H */