diff options
author | Yu Zhao <yu.zhao@intel.com> | 2009-03-19 23:25:11 -0400 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2009-03-20 13:48:22 -0400 |
commit | d1b054da8f599905f3c18a218961dcf17f9d5f13 (patch) | |
tree | 99b62e6771c3b73142dd0622463bed0e19724342 /include | |
parent | 8293b0f629095efbe7c7e3f9b437f8c040c19eb5 (diff) |
PCI: initialize and release SR-IOV capability
If a device has the SR-IOV capability, initialize it (set the ARI
Capable Hierarchy in the lowest numbered PF if necessary; calculate
the System Page Size for the VF MMIO, probe the VF Offset, Stride
and BARs). A lock for the VF bus allocation is also initialized if
a PF is the lowest numbered PF.
Reviewed-by: Matthew Wilcox <willy@linux.intel.com>
Signed-off-by: Yu Zhao <yu.zhao@intel.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/pci.h | 11 | ||||
-rw-r--r-- | include/linux/pci_regs.h | 33 |
2 files changed, 44 insertions, 0 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h index 1f6c5ddaae36..8ce2f2d9ab63 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -93,6 +93,12 @@ enum { | |||
93 | /* #6: expansion ROM resource */ | 93 | /* #6: expansion ROM resource */ |
94 | PCI_ROM_RESOURCE, | 94 | PCI_ROM_RESOURCE, |
95 | 95 | ||
96 | /* device specific resources */ | ||
97 | #ifdef CONFIG_PCI_IOV | ||
98 | PCI_IOV_RESOURCES, | ||
99 | PCI_IOV_RESOURCE_END = PCI_IOV_RESOURCES + PCI_SRIOV_NUM_BARS - 1, | ||
100 | #endif | ||
101 | |||
96 | /* resources assigned to buses behind the bridge */ | 102 | /* resources assigned to buses behind the bridge */ |
97 | #define PCI_BRIDGE_RESOURCE_NUM 4 | 103 | #define PCI_BRIDGE_RESOURCE_NUM 4 |
98 | 104 | ||
@@ -180,6 +186,7 @@ struct pci_cap_saved_state { | |||
180 | 186 | ||
181 | struct pcie_link_state; | 187 | struct pcie_link_state; |
182 | struct pci_vpd; | 188 | struct pci_vpd; |
189 | struct pci_sriov; | ||
183 | 190 | ||
184 | /* | 191 | /* |
185 | * The pci_dev structure is used to describe PCI devices. | 192 | * The pci_dev structure is used to describe PCI devices. |
@@ -257,6 +264,7 @@ struct pci_dev { | |||
257 | unsigned int is_managed:1; | 264 | unsigned int is_managed:1; |
258 | unsigned int is_pcie:1; | 265 | unsigned int is_pcie:1; |
259 | unsigned int state_saved:1; | 266 | unsigned int state_saved:1; |
267 | unsigned int is_physfn:1; | ||
260 | pci_dev_flags_t dev_flags; | 268 | pci_dev_flags_t dev_flags; |
261 | atomic_t enable_cnt; /* pci_enable_device has been called */ | 269 | atomic_t enable_cnt; /* pci_enable_device has been called */ |
262 | 270 | ||
@@ -270,6 +278,9 @@ struct pci_dev { | |||
270 | struct list_head msi_list; | 278 | struct list_head msi_list; |
271 | #endif | 279 | #endif |
272 | struct pci_vpd *vpd; | 280 | struct pci_vpd *vpd; |
281 | #ifdef CONFIG_PCI_IOV | ||
282 | struct pci_sriov *sriov; /* SR-IOV capability related */ | ||
283 | #endif | ||
273 | }; | 284 | }; |
274 | 285 | ||
275 | extern struct pci_dev *alloc_pci_dev(void); | 286 | extern struct pci_dev *alloc_pci_dev(void); |
diff --git a/include/linux/pci_regs.h b/include/linux/pci_regs.h index b647a4df59fc..d4e663877f45 100644 --- a/include/linux/pci_regs.h +++ b/include/linux/pci_regs.h | |||
@@ -375,6 +375,7 @@ | |||
375 | #define PCI_EXP_TYPE_UPSTREAM 0x5 /* Upstream Port */ | 375 | #define PCI_EXP_TYPE_UPSTREAM 0x5 /* Upstream Port */ |
376 | #define PCI_EXP_TYPE_DOWNSTREAM 0x6 /* Downstream Port */ | 376 | #define PCI_EXP_TYPE_DOWNSTREAM 0x6 /* Downstream Port */ |
377 | #define PCI_EXP_TYPE_PCI_BRIDGE 0x7 /* PCI/PCI-X Bridge */ | 377 | #define PCI_EXP_TYPE_PCI_BRIDGE 0x7 /* PCI/PCI-X Bridge */ |
378 | #define PCI_EXP_TYPE_RC_END 0x9 /* Root Complex Integrated Endpoint */ | ||
378 | #define PCI_EXP_FLAGS_SLOT 0x0100 /* Slot implemented */ | 379 | #define PCI_EXP_FLAGS_SLOT 0x0100 /* Slot implemented */ |
379 | #define PCI_EXP_FLAGS_IRQ 0x3e00 /* Interrupt message number */ | 380 | #define PCI_EXP_FLAGS_IRQ 0x3e00 /* Interrupt message number */ |
380 | #define PCI_EXP_DEVCAP 4 /* Device capabilities */ | 381 | #define PCI_EXP_DEVCAP 4 /* Device capabilities */ |
@@ -498,6 +499,7 @@ | |||
498 | #define PCI_EXT_CAP_ID_DSN 3 | 499 | #define PCI_EXT_CAP_ID_DSN 3 |
499 | #define PCI_EXT_CAP_ID_PWR 4 | 500 | #define PCI_EXT_CAP_ID_PWR 4 |
500 | #define PCI_EXT_CAP_ID_ARI 14 | 501 | #define PCI_EXT_CAP_ID_ARI 14 |
502 | #define PCI_EXT_CAP_ID_SRIOV 16 | ||
501 | 503 | ||
502 | /* Advanced Error Reporting */ | 504 | /* Advanced Error Reporting */ |
503 | #define PCI_ERR_UNCOR_STATUS 4 /* Uncorrectable Error Status */ | 505 | #define PCI_ERR_UNCOR_STATUS 4 /* Uncorrectable Error Status */ |
@@ -615,4 +617,35 @@ | |||
615 | #define PCI_ARI_CTRL_ACS 0x0002 /* ACS Function Groups Enable */ | 617 | #define PCI_ARI_CTRL_ACS 0x0002 /* ACS Function Groups Enable */ |
616 | #define PCI_ARI_CTRL_FG(x) (((x) >> 4) & 7) /* Function Group */ | 618 | #define PCI_ARI_CTRL_FG(x) (((x) >> 4) & 7) /* Function Group */ |
617 | 619 | ||
620 | /* Single Root I/O Virtualization */ | ||
621 | #define PCI_SRIOV_CAP 0x04 /* SR-IOV Capabilities */ | ||
622 | #define PCI_SRIOV_CAP_VFM 0x01 /* VF Migration Capable */ | ||
623 | #define PCI_SRIOV_CAP_INTR(x) ((x) >> 21) /* Interrupt Message Number */ | ||
624 | #define PCI_SRIOV_CTRL 0x08 /* SR-IOV Control */ | ||
625 | #define PCI_SRIOV_CTRL_VFE 0x01 /* VF Enable */ | ||
626 | #define PCI_SRIOV_CTRL_VFM 0x02 /* VF Migration Enable */ | ||
627 | #define PCI_SRIOV_CTRL_INTR 0x04 /* VF Migration Interrupt Enable */ | ||
628 | #define PCI_SRIOV_CTRL_MSE 0x08 /* VF Memory Space Enable */ | ||
629 | #define PCI_SRIOV_CTRL_ARI 0x10 /* ARI Capable Hierarchy */ | ||
630 | #define PCI_SRIOV_STATUS 0x0a /* SR-IOV Status */ | ||
631 | #define PCI_SRIOV_STATUS_VFM 0x01 /* VF Migration Status */ | ||
632 | #define PCI_SRIOV_INITIAL_VF 0x0c /* Initial VFs */ | ||
633 | #define PCI_SRIOV_TOTAL_VF 0x0e /* Total VFs */ | ||
634 | #define PCI_SRIOV_NUM_VF 0x10 /* Number of VFs */ | ||
635 | #define PCI_SRIOV_FUNC_LINK 0x12 /* Function Dependency Link */ | ||
636 | #define PCI_SRIOV_VF_OFFSET 0x14 /* First VF Offset */ | ||
637 | #define PCI_SRIOV_VF_STRIDE 0x16 /* Following VF Stride */ | ||
638 | #define PCI_SRIOV_VF_DID 0x1a /* VF Device ID */ | ||
639 | #define PCI_SRIOV_SUP_PGSIZE 0x1c /* Supported Page Sizes */ | ||
640 | #define PCI_SRIOV_SYS_PGSIZE 0x20 /* System Page Size */ | ||
641 | #define PCI_SRIOV_BAR 0x24 /* VF BAR0 */ | ||
642 | #define PCI_SRIOV_NUM_BARS 6 /* Number of VF BARs */ | ||
643 | #define PCI_SRIOV_VFM 0x3c /* VF Migration State Array Offset*/ | ||
644 | #define PCI_SRIOV_VFM_BIR(x) ((x) & 7) /* State BIR */ | ||
645 | #define PCI_SRIOV_VFM_OFFSET(x) ((x) & ~7) /* State Offset */ | ||
646 | #define PCI_SRIOV_VFM_UA 0x0 /* Inactive.Unavailable */ | ||
647 | #define PCI_SRIOV_VFM_MI 0x1 /* Dormant.MigrateIn */ | ||
648 | #define PCI_SRIOV_VFM_MO 0x2 /* Active.MigrateOut */ | ||
649 | #define PCI_SRIOV_VFM_AV 0x3 /* Active.Available */ | ||
650 | |||
618 | #endif /* LINUX_PCI_REGS_H */ | 651 | #endif /* LINUX_PCI_REGS_H */ |