summaryrefslogtreecommitdiff
path: root/include/pci.h
diff options
context:
space:
mode:
authorSuneel Garapati <sgarapati@marvell.com>2019-10-20 02:07:20 +0300
committerStefan Roese <sr@denx.de>2020-08-25 09:01:16 +0300
commitb8852dcfcb0facb37839a8cf9b01cb549153fba8 (patch)
tree777f664b0fbe7a1afce8c24e91a1c7fdac0bb952 /include/pci.h
parent636cc1773a461de83f69f69cd3f22f9bcad2f589 (diff)
downloadu-boot-b8852dcfcb0facb37839a8cf9b01cb549153fba8.tar.xz
pci: pci-uclass: Add support for Single-Root I/O Virtualization
SR-IOV - Single Root I/O Virtualization PF - Physical Function VF - Virtual Function If SR-IOV capability is present, use it to initialize Virtual Function PCI device instances. pci_sriov_init function will read SR-IOV registers to create VF devices under the PF PCI device and also bind driver if available. This function needs to be invoked from Physical function device driver which expects VF device support, creating minimal impact on existing framework. Signed-off-by: Suneel Garapati <sgarapati@marvell.com> Cc: Simon Glass <sjg@chromium.org> Cc: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'include/pci.h')
-rw-r--r--include/pci.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/include/pci.h b/include/pci.h
index da755af852..115d3312a4 100644
--- a/include/pci.h
+++ b/include/pci.h
@@ -493,6 +493,17 @@
#define PCI_EXP_SLTCAP 20 /* Slot Capabilities */
#define PCI_EXP_SLTCAP_PSN 0xfff80000 /* Physical Slot Number */
#define PCI_EXP_LNKCTL2 48 /* Link Control 2 */
+/* Single Root I/O Virtualization Registers */
+#define PCI_SRIOV_CAP 0x04 /* SR-IOV Capabilities */
+#define PCI_SRIOV_CTRL 0x08 /* SR-IOV Control */
+#define PCI_SRIOV_CTRL_VFE 0x01 /* VF Enable */
+#define PCI_SRIOV_CTRL_MSE 0x08 /* VF Memory Space Enable */
+#define PCI_SRIOV_INITIAL_VF 0x0c /* Initial VFs */
+#define PCI_SRIOV_TOTAL_VF 0x0e /* Total VFs */
+#define PCI_SRIOV_NUM_VF 0x10 /* Number of VFs */
+#define PCI_SRIOV_VF_OFFSET 0x14 /* First VF Offset */
+#define PCI_SRIOV_VF_STRIDE 0x16 /* Following VF Stride */
+#define PCI_SRIOV_VF_DID 0x1a /* VF Device ID */
/* Include the ID list */
@@ -890,12 +901,20 @@ struct udevice;
* @vendor: PCI vendor ID (see pci_ids.h)
* @device: PCI device ID (see pci_ids.h)
* @class: PCI class, 3 bytes: (base, sub, prog-if)
+ * @is_virtfn: True for Virtual Function device
+ * @pfdev: Handle to Physical Function device
+ * @virtid: Virtual Function Index
*/
struct pci_child_platdata {
int devfn;
unsigned short vendor;
unsigned short device;
unsigned int class;
+
+ /* Variables for CONFIG_PCI_SRIOV */
+ bool is_virtfn;
+ struct udevice *pfdev;
+ int virtid;
};
/* PCI bus operations */
@@ -1208,6 +1227,25 @@ int pci_generic_mmap_read_config(
ulong *valuep,
enum pci_size_t size);
+#if defined(CONFIG_PCI_SRIOV)
+/**
+ * pci_sriov_init() - Scan Virtual Function devices
+ *
+ * @pdev: Physical Function udevice handle
+ * @vf_en: Number of Virtual Function devices to enable
+ * @return 0 on success, -ve on error
+ */
+int pci_sriov_init(struct udevice *pdev, int vf_en);
+
+/**
+ * pci_sriov_get_totalvfs() - Get total available Virtual Function devices
+ *
+ * @pdev: Physical Function udevice handle
+ * @return count on success, -ve on error
+ */
+int pci_sriov_get_totalvfs(struct udevice *pdev);
+#endif
+
#ifdef CONFIG_DM_PCI_COMPAT
/* Compatibility with old naming */
static inline int pci_write_config_dword(pci_dev_t pcidev, int offset,