81 #include <sys/queue.h>
99 #define PCI_PRI_FMT "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
100 #define PCI_PRI_STR_SIZE sizeof("XXXX:XX:XX.X")
103 #define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
106 #define PCI_FMT_NVAL 4
109 #define PCI_RESOURCE_FMT_NVAL 3
112 #define PCI_MAX_RESOURCE 6
138 enum rte_kernel_driver {
139 RTE_KDRV_UNKNOWN = 0,
142 RTE_KDRV_UIO_GENERIC,
164 #define PCI_ANY_ID (0xffff)
165 #define RTE_CLASS_ANY_ID (0xffffff)
169 #define RTE_PCI_DEVICE(vend, dev) \
177 #define RTE_PCI_DEVICE(vend, dev) \
178 .class_id = RTE_CLASS_ANY_ID, \
179 .vendor_id = (vend), \
180 .device_id = (dev), \
181 .subsystem_vendor_id = PCI_ANY_ID, \
182 .subsystem_device_id = PCI_ANY_ID
210 #define RTE_PCI_DRV_NEED_MAPPING 0x0001
212 #define RTE_PCI_DRV_FORCE_UNBIND 0x0004
214 #define RTE_PCI_DRV_INTR_LSC 0x0008
216 #define RTE_PCI_DRV_DETACHABLE 0x0010
240 struct pci_map maps[PCI_MAX_RESOURCE];
247 #define GET_PCIADDR_FIELD(in, fd, lim, dlm) \
254 val = strtoul((in), &end, 16); \
255 if (errno != 0 || end[0] != (dlm) || val > (lim)) \
257 (fd) = (typeof (fd))val; \
278 GET_PCIADDR_FIELD(input, dev_addr->
bus, UINT8_MAX,
':');
279 GET_PCIADDR_FIELD(input, dev_addr->
devid, UINT8_MAX,
'.');
280 GET_PCIADDR_FIELD(input, dev_addr->
function, UINT8_MAX, 0);
299 GET_PCIADDR_FIELD(input, dev_addr->
domain, UINT16_MAX,
':');
300 GET_PCIADDR_FIELD(input, dev_addr->
bus, UINT8_MAX,
':');
301 GET_PCIADDR_FIELD(input, dev_addr->
devid, UINT8_MAX,
'.');
302 GET_PCIADDR_FIELD(input, dev_addr->
function, UINT8_MAX, 0);
305 #undef GET_PCIADDR_FIELD
321 char *output,
size_t size)
323 RTE_VERIFY(size >= PCI_PRI_STR_SIZE);
346 uint64_t dev_addr, dev_addr2;
348 if ((addr == NULL) || (addr2 == NULL))
351 dev_addr = (addr->
domain << 24) | (addr->
bus << 16) |
353 dev_addr2 = (addr2->
domain << 24) | (addr2->
bus << 16) |
356 if (dev_addr > dev_addr2)
358 else if (dev_addr < dev_addr2)
430 void *pci_map_resource(
void *requested_addr,
int fd, off_t offset,
431 size_t size,
int additional_flags);
442 void pci_unmap_resource(
void *requested_addr,
size_t size);
492 #define RTE_PMD_REGISTER_PCI(nm, pci_drv) \
493 RTE_INIT(pciinitfn_ ##nm); \
494 static void pciinitfn_ ##nm(void) \
496 (pci_drv).driver.name = RTE_STR(nm);\
497 rte_eal_pci_register(&pci_drv); \
499 RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
524 void *buf,
size_t len, off_t offset);
540 const void *buf,
size_t len, off_t offset);
594 void *data,
size_t len, off_t offset);
609 const void *data,
size_t len, off_t offset);
int rte_eal_pci_ioport_map(struct rte_pci_device *dev, int bar, struct rte_pci_ioport *p)
struct rte_pci_driver * driver
void rte_eal_pci_register(struct rte_pci_driver *driver)
int rte_eal_pci_scan(void)
TAILQ_HEAD(pci_device_list, rte_pci_device)
int( pci_probe_t)(struct rte_pci_driver *, struct rte_pci_device *)
struct pci_driver_list pci_driver_list
int rte_eal_pci_probe(void)
void rte_eal_pci_ioport_write(struct rte_pci_ioport *p, const void *data, size_t len, off_t offset)
int rte_eal_pci_write_config(const struct rte_pci_device *device, const void *buf, size_t len, off_t offset)
enum rte_kernel_driver kdrv
TAILQ_ENTRY(rte_pci_device) next
int rte_eal_pci_read_config(const struct rte_pci_device *device, void *buf, size_t len, off_t offset)
int rte_eal_pci_map_device(struct rte_pci_device *dev)
static void rte_eal_pci_device_name(const struct rte_pci_addr *addr, char *output, size_t size)
static int eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr)
static int eal_parse_pci_BDF(const char *input, struct rte_pci_addr *dev_addr)
TAILQ_ENTRY(rte_pci_driver) next
const struct rte_pci_id * id_table
int rte_eal_pci_ioport_unmap(struct rte_pci_ioport *p)
uint16_t subsystem_device_id
struct rte_intr_handle intr_handle
void rte_eal_pci_dump(FILE *f)
int rte_eal_pci_probe_one(const struct rte_pci_addr *addr)
void rte_eal_pci_unmap_device(struct rte_pci_device *dev)
int rte_eal_pci_detach(const struct rte_pci_addr *addr)
void rte_eal_pci_ioport_read(struct rte_pci_ioport *p, void *data, size_t len, off_t offset)
struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE]
int( pci_remove_t)(struct rte_pci_device *)
void rte_eal_pci_unregister(struct rte_pci_driver *driver)
uint16_t subsystem_vendor_id
struct pci_device_list pci_device_list
const char * pci_get_sysfs_path(void)
static int rte_eal_compare_pci_addr(const struct rte_pci_addr *addr, const struct rte_pci_addr *addr2)