#endif
#include <rte_pci_dev_features.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
-#define pci_cfg_access_lock pci_block_user_cfg_access
-#define pci_cfg_access_unlock pci_unblock_user_cfg_access
-#endif
+#include "compat.h"
#ifdef RTE_PCI_CONFIG
#define PCI_SYS_FILE_BUF_SIZE 10
}
/* sriov sysfs */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34)
-static int pci_num_vf(struct pci_dev *dev)
-{
- struct iov {
- int pos;
- int nres;
- u32 cap;
- u16 ctrl;
- u16 total;
- u16 initial;
- u16 nr_virtfn;
- } *iov = (struct iov *)dev->sriov;
-
- if (!dev->is_physfn)
- return 0;
-
- return iov->nr_virtfn;
-}
-#endif
-
static ssize_t
show_max_vfs(struct device *dev, struct device_attribute *attr,
char *buf)
static const struct attribute_group dev_attr_grp = {
.attrs = dev_attrs,
};
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
-/* Check if INTX works to control irq's.
- * Set's INTX_DISABLE flag and reads it back
- */
-static bool pci_intx_mask_supported(struct pci_dev *pdev)
-{
- bool mask_supported = false;
- uint16_t orig, new;
-
- pci_block_user_cfg_access(pdev);
- pci_read_config_word(pdev, PCI_COMMAND, &orig);
- pci_write_config_word(pdev, PCI_COMMAND,
- orig ^ PCI_COMMAND_INTX_DISABLE);
- pci_read_config_word(pdev, PCI_COMMAND, &new);
-
- if ((new ^ orig) & ~PCI_COMMAND_INTX_DISABLE) {
- dev_err(&pdev->dev, "Command register changed from "
- "0x%x to 0x%x: driver or hardware bug?\n", orig, new);
- } else if ((new ^ orig) & PCI_COMMAND_INTX_DISABLE) {
- mask_supported = true;
- pci_write_config_word(pdev, PCI_COMMAND, orig);
- }
- pci_unblock_user_cfg_access(pdev);
-
- return mask_supported;
-}
-
-static bool pci_check_and_mask_intx(struct pci_dev *pdev)
-{
- bool pending;
- uint32_t status;
-
- pci_block_user_cfg_access(pdev);
- pci_read_config_dword(pdev, PCI_COMMAND, &status);
-
- /* interrupt is not ours, goes to out */
- pending = (((status >> 16) & PCI_STATUS_INTERRUPT) != 0);
- if (pending) {
- uint16_t old, new;
-
- old = status;
- if (status != 0)
- new = old & (~PCI_COMMAND_INTX_DISABLE);
- else
- new = old | PCI_COMMAND_INTX_DISABLE;
-
- if (old != new)
- pci_write_config_word(pdev, PCI_COMMAND, new);
- }
- pci_unblock_user_cfg_access(pdev);
-
- return pending;
-}
-#endif
-
/*
* It masks the msix on/off of generating MSI-X messages.
*/