X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_eal%2Fcommon%2Finclude%2Frte_pci.h;h=1550d49d858be8d72c959aced1087d451b57f4ab;hb=dbe6b4b61b0ec0a2ea3d6b1f8107003a8cbdad10;hp=66ed7933af4fbd4f85cefa4eb0d46b70213f4b3d;hpb=b10eef348d1a2919e0b1cc06743256a73548da63;p=dpdk.git diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index 66ed7933af..1550d49d85 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -93,10 +93,10 @@ extern struct pci_device_list pci_device_list; /**< Global list of PCI devices. #define SYSFS_PCI_DEVICES "/sys/bus/pci/devices" /** Formatting string for PCI device identifier: Ex: 0000:00:01.0 */ -#define PCI_PRI_FMT "%.4"PRIx16":%.2"PRIx8":%.2"PRIx8".%"PRIx8 +#define PCI_PRI_FMT "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8 /** Short formatting string, without domain, for PCI device: Ex: 00:01.0 */ -#define PCI_SHORT_PRI_FMT "%.2"PRIx8":%.2"PRIx8".%"PRIx8 +#define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8 /** Nb. of values in PCI device identifier format string. */ #define PCI_FMT_NVAL 4 @@ -104,6 +104,9 @@ extern struct pci_device_list pci_device_list; /**< Global list of PCI devices. /** Nb. of values in PCI resource format. */ #define PCI_RESOURCE_FMT_NVAL 3 +/** IO resource type: memory address space */ +#define IORESOURCE_MEM 0x00000200 + /** * A structure describing a PCI resource. */ @@ -114,7 +117,7 @@ struct rte_pci_resource { }; /** Maximum number of PCI resources. */ -#define PCI_MAX_RESOURCE 7 +#define PCI_MAX_RESOURCE 6 /** * A structure describing an ID for a PCI driver. Each driver provides a @@ -139,6 +142,13 @@ struct rte_pci_addr { struct rte_devargs; +enum rte_pt_driver { + RTE_PT_UNKNOWN = 0, + RTE_PT_IGB_UIO = 1, + RTE_PT_VFIO = 2, + RTE_PT_UIO_GENERIC = 3, +}; + /** * A structure describing a PCI device. */ @@ -152,6 +162,7 @@ struct rte_pci_device { uint16_t max_vfs; /**< sriov enable if not zero */ int numa_node; /**< NUMA node connection */ struct rte_devargs *devargs; /**< Device user arguments */ + enum rte_pt_driver pt_driver; /**< Driver of passthrough */ }; /** Any PCI device identifier (vendor, device, ...) */ @@ -180,6 +191,11 @@ struct rte_pci_driver; */ typedef int (pci_devinit_t)(struct rte_pci_driver *, struct rte_pci_device *); +/** + * Uninitialisation function for the driver called during hotplugging. + */ +typedef int (pci_devuninit_t)(struct rte_pci_device *); + /** * A structure describing a PCI driver. */ @@ -187,6 +203,7 @@ struct rte_pci_driver { TAILQ_ENTRY(rte_pci_driver) next; /**< Next in list. */ const char *name; /**< Driver name. */ pci_devinit_t *devinit; /**< Device init. function. */ + pci_devuninit_t *devuninit; /**< Device uninit function. */ struct rte_pci_id *id_table; /**< ID table, NULL terminated. */ uint32_t drv_flags; /**< Flags contolling handling of device. */ }; @@ -259,6 +276,40 @@ eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr) } #undef GET_PCIADDR_FIELD +/* Compare two PCI device addresses. */ +/** + * Utility function to compare two PCI device addresses. + * + * @param addr + * The PCI Bus-Device-Function address to compare + * @param addr2 + * The PCI Bus-Device-Function address to compare + * @return + * 0 on equal PCI address. + * Positive on addr is greater than addr2. + * Negative on addr is less than addr2, or error. + */ +static inline int +rte_eal_compare_pci_addr(struct rte_pci_addr *addr, struct rte_pci_addr *addr2) +{ + uint64_t dev_addr, dev_addr2; + + if ((addr == NULL) || (addr2 == NULL)) + return -1; + + dev_addr = (addr->domain << 24) | (addr->bus << 16) | + (addr->devid << 8) | addr->function; + dev_addr2 = (addr2->domain << 24) | (addr2->bus << 16) | + (addr2->devid << 8) | addr2->function; + + if (dev_addr > dev_addr2) + return 1; + else if (dev_addr < dev_addr2) + return -1; + else + return 0; +} + /** * Probe the PCI bus for registered drivers. * @@ -272,6 +323,38 @@ eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr) */ int rte_eal_pci_probe(void); +#ifdef RTE_LIBRTE_EAL_HOTPLUG +/** + * Probe the single PCI device. + * + * Scan the content of the PCI bus, and find the pci device specified by pci + * address, then call the probe() function for registered driver that has a + * matching entry in its id_table for discovered device. + * + * @param addr + * The PCI Bus-Device-Function address to probe. + * @return + * - 0 on success. + * - Negative on error. + */ +int rte_eal_pci_probe_one(struct rte_pci_addr *addr); + +/** + * Close the single PCI device. + * + * Scan the content of the PCI bus, and find the pci device specified by pci + * address, then call the close() function for registered driver that has a + * matching entry in its id_table for discovered device. + * + * @param addr + * The PCI Bus-Device-Function address to close. + * @return + * - 0 on success. + * - Negative on error. + */ +int rte_eal_pci_close_one(struct rte_pci_addr *addr); +#endif /* RTE_LIBRTE_EAL_HOTPLUG */ + /** * Dump the content of the PCI bus. *