2 * Minimal wrappers to allow compiling igb_uio on older kernels.
6 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
7 #define pci_cfg_access_lock pci_block_user_cfg_access
8 #define pci_cfg_access_unlock pci_unblock_user_cfg_access
11 #ifndef PCI_MSIX_ENTRY_SIZE
12 #define PCI_MSIX_ENTRY_SIZE 16
13 #define PCI_MSIX_ENTRY_LOWER_ADDR 0
14 #define PCI_MSIX_ENTRY_UPPER_ADDR 4
15 #define PCI_MSIX_ENTRY_DATA 8
16 #define PCI_MSIX_ENTRY_VECTOR_CTRL 12
17 #define PCI_MSIX_ENTRY_CTRL_MASKBIT 1
20 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34)
21 static int pci_num_vf(struct pci_dev *dev)
31 } *iov = (struct iov *)dev->sriov;
36 return iov->nr_virtfn;
41 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
43 /* Check if INTX works to control irq's.
44 * Set's INTX_DISABLE flag and reads it back
46 static bool pci_intx_mask_supported(struct pci_dev *pdev)
48 bool mask_supported = false;
51 pci_block_user_cfg_access(pdev);
52 pci_read_config_word(pdev, PCI_COMMAND, &orig);
53 pci_write_config_word(pdev, PCI_COMMAND,
54 orig ^ PCI_COMMAND_INTX_DISABLE);
55 pci_read_config_word(pdev, PCI_COMMAND, &new);
57 if ((new ^ orig) & ~PCI_COMMAND_INTX_DISABLE) {
58 dev_err(&pdev->dev, "Command register changed from "
59 "0x%x to 0x%x: driver or hardware bug?\n", orig, new);
60 } else if ((new ^ orig) & PCI_COMMAND_INTX_DISABLE) {
61 mask_supported = true;
62 pci_write_config_word(pdev, PCI_COMMAND, orig);
64 pci_unblock_user_cfg_access(pdev);
66 return mask_supported;
69 static bool pci_check_and_mask_intx(struct pci_dev *pdev)
74 pci_block_user_cfg_access(pdev);
75 pci_read_config_dword(pdev, PCI_COMMAND, &status);
77 /* interrupt is not ours, goes to out */
78 pending = (((status >> 16) & PCI_STATUS_INTERRUPT) != 0);
84 new = old & (~PCI_COMMAND_INTX_DISABLE);
86 new = old | PCI_COMMAND_INTX_DISABLE;
89 pci_write_config_word(pdev, PCI_COMMAND, new);
91 pci_unblock_user_cfg_access(pdev);
97 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
98 /* Compatability wrapper for new kernel API for IRQ */
99 #define irq_data irq_desc
100 #define irq_get_irq_data(irq) irq_to_desc(irq)
101 #define irq_data_get_msi(data) get_irq_desc_msi(data)