2 * Copyright (C) 2003-2004 Intel
3 * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com)
12 * Assume the maximum number of hot plug slots supported by the system is about
13 * ten. The worstcase is that each of these slots is hot-added with a device,
14 * which has two MSI/MSI-X capable functions. To avoid any MSI-X driver, which
15 * attempts to request all available vectors, NR_HP_RESERVED_VECTORS is defined
16 * as below to ensure at least one message is assigned to each detected MSI/
17 * MSI-X device function.
19 #define NR_HP_RESERVED_VECTORS 20
21 extern int vector_irq
[NR_VECTORS
];
22 extern cpumask_t pending_irq_balance_cpumask
[NR_IRQS
];
23 extern void (*interrupt
[NR_IRQS
])(void);
24 extern int pci_vector_resources(int last
, int nr_released
);
27 #define set_msi_irq_affinity set_msi_affinity
29 #define set_msi_irq_affinity NULL
32 #ifndef CONFIG_IRQBALANCE
33 static inline void move_msi(int vector
) {}
37 * MSI-X Address Register
39 #define PCI_MSIX_FLAGS_QSIZE 0x7FF
40 #define PCI_MSIX_FLAGS_ENABLE (1 << 15)
41 #define PCI_MSIX_FLAGS_BIRMASK (7 << 0)
42 #define PCI_MSIX_FLAGS_BITMASK (1 << 0)
44 #define PCI_MSIX_ENTRY_SIZE 16
45 #define PCI_MSIX_ENTRY_LOWER_ADDR_OFFSET 0
46 #define PCI_MSIX_ENTRY_UPPER_ADDR_OFFSET 4
47 #define PCI_MSIX_ENTRY_DATA_OFFSET 8
48 #define PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET 12
50 #define msi_control_reg(base) (base + PCI_MSI_FLAGS)
51 #define msi_lower_address_reg(base) (base + PCI_MSI_ADDRESS_LO)
52 #define msi_upper_address_reg(base) (base + PCI_MSI_ADDRESS_HI)
53 #define msi_data_reg(base, is64bit) \
54 ( (is64bit == 1) ? base+PCI_MSI_DATA_64 : base+PCI_MSI_DATA_32 )
55 #define msi_mask_bits_reg(base, is64bit) \
56 ( (is64bit == 1) ? base+PCI_MSI_MASK_BIT : base+PCI_MSI_MASK_BIT-4)
57 #define msi_disable(control) control &= ~PCI_MSI_FLAGS_ENABLE
58 #define multi_msi_capable(control) \
59 (1 << ((control & PCI_MSI_FLAGS_QMASK) >> 1))
60 #define multi_msi_enable(control, num) \
61 control |= (((num >> 1) << 4) & PCI_MSI_FLAGS_QSIZE);
62 #define is_64bit_address(control) (control & PCI_MSI_FLAGS_64BIT)
63 #define is_mask_bit_support(control) (control & PCI_MSI_FLAGS_MASKBIT)
64 #define msi_enable(control, num) multi_msi_enable(control, num); \
65 control |= PCI_MSI_FLAGS_ENABLE
67 #define msix_table_offset_reg(base) (base + 0x04)
68 #define msix_pba_offset_reg(base) (base + 0x08)
69 #define msix_enable(control) control |= PCI_MSIX_FLAGS_ENABLE
70 #define msix_disable(control) control &= ~PCI_MSIX_FLAGS_ENABLE
71 #define msix_table_size(control) ((control & PCI_MSIX_FLAGS_QSIZE)+1)
72 #define multi_msix_capable msix_table_size
73 #define msix_unmask(address) (address & ~PCI_MSIX_FLAGS_BITMASK)
74 #define msix_mask(address) (address | PCI_MSIX_FLAGS_BITMASK)
75 #define msix_is_pending(address) (address & PCI_MSIX_FLAGS_PENDMASK)
78 * MSI Defined Data Structures
80 #define MSI_ADDRESS_HEADER 0xfee
81 #define MSI_ADDRESS_HEADER_SHIFT 12
82 #define MSI_ADDRESS_HEADER_MASK 0xfff000
83 #define MSI_ADDRESS_DEST_ID_MASK 0xfff0000f
84 #define MSI_TARGET_CPU_MASK 0xff
85 #define MSI_DELIVERY_MODE 0
86 #define MSI_LEVEL_MODE 1 /* Edge always assert */
87 #define MSI_TRIGGER_MODE 0 /* MSI is edge sensitive */
88 #define MSI_PHYSICAL_MODE 0
89 #define MSI_LOGICAL_MODE 1
90 #define MSI_REDIRECTION_HINT_MODE 0
93 #if defined(__LITTLE_ENDIAN_BITFIELD)
95 __u32 delivery_mode
: 3; /* 000b: FIXED | 001b: lowest prior */
97 __u32 level
: 1; /* 0: deassert | 1: assert */
98 __u32 trigger
: 1; /* 0: edge | 1: level */
99 __u32 reserved_2
: 16;
100 #elif defined(__BIG_ENDIAN_BITFIELD)
101 __u32 reserved_2
: 16;
102 __u32 trigger
: 1; /* 0: edge | 1: level */
103 __u32 level
: 1; /* 0: deassert | 1: assert */
104 __u32 reserved_1
: 3;
105 __u32 delivery_mode
: 3; /* 000b: FIXED | 001b: lowest prior */
108 #error "Bitfield endianness not defined! Check your byteorder.h"
110 } __attribute__ ((packed
));
115 #if defined(__LITTLE_ENDIAN_BITFIELD)
116 __u32 reserved_1
: 2;
117 __u32 dest_mode
: 1; /*0:physic | 1:logic */
118 __u32 redirection_hint
: 1; /*0: dedicated CPU
119 1: lowest priority */
120 __u32 reserved_2
: 4;
121 __u32 dest_id
: 24; /* Destination ID */
122 #elif defined(__BIG_ENDIAN_BITFIELD)
123 __u32 dest_id
: 24; /* Destination ID */
124 __u32 reserved_2
: 4;
125 __u32 redirection_hint
: 1; /*0: dedicated CPU
126 1: lowest priority */
127 __u32 dest_mode
: 1; /*0:physic | 1:logic */
128 __u32 reserved_1
: 2;
130 #error "Bitfield endianness not defined! Check your byteorder.h"
136 } __attribute__ ((packed
));
140 __u8 type
: 5; /* {0: unused, 5h:MSI, 11h:MSI-X} */
141 __u8 maskbit
: 1; /* mask-pending bit supported ? */
142 __u8 state
: 1; /* {0: free, 1: busy} */
143 __u8 reserved
: 1; /* reserved */
144 __u8 entry_nr
; /* specific enabled entry */
145 __u8 default_vector
; /* default pre-assigned vector */
146 __u8 current_cpu
; /* current destination cpu */
154 void __iomem
*mask_base
;