81 #include <sys/queue.h>
94 #define PCI_PRI_FMT "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
95 #define PCI_PRI_STR_SIZE sizeof("XXXX:XX:XX.X")
98 #define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
101 #define PCI_FMT_NVAL 4
104 #define PCI_RESOURCE_FMT_NVAL 3
107 #define PCI_MAX_RESOURCE 6
110 #define PCI_BUS_NAME "PCI"
122 #define FOREACH_DEVICE_ON_PCIBUS(p) \
123 TAILQ_FOREACH(p, &(rte_pci_bus.device_list), next)
125 #define FOREACH_DRIVER_ON_PCIBUS(p) \
126 TAILQ_FOREACH(p, &(rte_pci_bus.driver_list), next)
152 enum rte_kernel_driver {
153 RTE_KDRV_UNKNOWN = 0,
156 RTE_KDRV_UIO_GENERIC,
182 #define RTE_DEV_TO_PCI(ptr) container_of(ptr, struct rte_pci_device, device)
185 #define PCI_ANY_ID (0xffff)
186 #define RTE_CLASS_ANY_ID (0xffffff)
190 #define RTE_PCI_DEVICE(vend, dev) \
198 #define RTE_PCI_DEVICE(vend, dev) \
199 .class_id = RTE_CLASS_ANY_ID, \
200 .vendor_id = (vend), \
201 .device_id = (dev), \
202 .subsystem_vendor_id = PCI_ANY_ID, \
203 .subsystem_device_id = PCI_ANY_ID
239 #define RTE_PCI_DRV_NEED_MAPPING 0x0001
241 #define RTE_PCI_DRV_INTR_LSC 0x0008
243 #define RTE_PCI_DRV_INTR_RMV 0x0010
267 struct pci_map maps[PCI_MAX_RESOURCE];
274 #define GET_PCIADDR_FIELD(in, fd, lim, dlm) \
279 val = strtoul((in), &end, 16); \
280 if (errno != 0 || end[0] != (dlm) || val > (lim)) \
282 (fd) = (typeof (fd))val; \
303 GET_PCIADDR_FIELD(input, dev_addr->
bus, UINT8_MAX,
':');
304 GET_PCIADDR_FIELD(input, dev_addr->
devid, UINT8_MAX,
'.');
305 GET_PCIADDR_FIELD(input, dev_addr->
function, UINT8_MAX, 0);
324 GET_PCIADDR_FIELD(input, dev_addr->
domain, UINT16_MAX,
':');
325 GET_PCIADDR_FIELD(input, dev_addr->
bus, UINT8_MAX,
':');
326 GET_PCIADDR_FIELD(input, dev_addr->
devid, UINT8_MAX,
'.');
327 GET_PCIADDR_FIELD(input, dev_addr->
function, UINT8_MAX, 0);
330 #undef GET_PCIADDR_FIELD
346 char *output,
size_t size)
348 RTE_VERIFY(size >= PCI_PRI_STR_SIZE);
371 uint64_t dev_addr, dev_addr2;
373 if ((addr == NULL) || (addr2 == NULL))
376 dev_addr = (addr->
domain << 24) | (addr->
bus << 16) |
378 dev_addr2 = (addr2->
domain << 24) | (addr2->
bus << 16) |
381 if (dev_addr > dev_addr2)
383 else if (dev_addr < dev_addr2)
452 void *pci_map_resource(
void *requested_addr,
int fd, off_t offset,
453 size_t size,
int additional_flags);
464 void pci_unmap_resource(
void *requested_addr,
size_t size);
514 #define RTE_PMD_REGISTER_PCI(nm, pci_drv) \
515 RTE_INIT(pciinitfn_ ##nm); \
516 static void pciinitfn_ ##nm(void) \
518 (pci_drv).driver.name = RTE_STR(nm);\
519 rte_pci_register(&pci_drv); \
521 RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
546 void *buf,
size_t len, off_t offset);
562 const void *buf,
size_t len, off_t offset);
616 void *data,
size_t len, off_t offset);
631 const void *data,
size_t len, off_t offset);