52 #include <sys/queue.h>
65 #define PCI_PRI_FMT "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
66 #define PCI_PRI_STR_SIZE sizeof("XXXXXXXX:XX:XX.X")
69 #define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
72 #define PCI_FMT_NVAL 4
75 #define PCI_RESOURCE_FMT_NVAL 3
78 #define PCI_MAX_RESOURCE 6
90 #define FOREACH_DEVICE_ON_PCIBUS(p) \
91 TAILQ_FOREACH(p, &(rte_pci_bus.device_list), next)
93 #define FOREACH_DRIVER_ON_PCIBUS(p) \
94 TAILQ_FOREACH(p, &(rte_pci_bus.driver_list), next)
141 #define RTE_DEV_TO_PCI(ptr) container_of(ptr, struct rte_pci_device, device)
144 #define PCI_ANY_ID (0xffff)
145 #define RTE_CLASS_ANY_ID (0xffffff)
149 #define RTE_PCI_DEVICE(vend, dev) \
157 #define RTE_PCI_DEVICE(vend, dev) \
158 .class_id = RTE_CLASS_ANY_ID, \
159 .vendor_id = (vend), \
160 .device_id = (dev), \
161 .subsystem_vendor_id = PCI_ANY_ID, \
162 .subsystem_device_id = PCI_ANY_ID
198 #define RTE_PCI_DRV_NEED_MAPPING 0x0001
200 #define RTE_PCI_DRV_INTR_LSC 0x0008
202 #define RTE_PCI_DRV_INTR_RMV 0x0010
204 #define RTE_PCI_DRV_KEEP_MAPPED_RES 0x0020
228 struct pci_map maps[PCI_MAX_RESOURCE];
235 #define GET_PCIADDR_FIELD(in, fd, lim, dlm) \
240 val = strtoul((in), &end, 16); \
241 if (errno != 0 || end[0] != (dlm) || val > (lim)) \
243 (fd) = (typeof (fd))val; \
264 GET_PCIADDR_FIELD(input, dev_addr->
bus, UINT8_MAX,
':');
265 GET_PCIADDR_FIELD(input, dev_addr->
devid, UINT8_MAX,
'.');
266 GET_PCIADDR_FIELD(input, dev_addr->
function, UINT8_MAX, 0);
285 GET_PCIADDR_FIELD(input, dev_addr->
domain, UINT16_MAX,
':');
286 GET_PCIADDR_FIELD(input, dev_addr->
bus, UINT8_MAX,
':');
287 GET_PCIADDR_FIELD(input, dev_addr->
devid, UINT8_MAX,
'.');
288 GET_PCIADDR_FIELD(input, dev_addr->
function, UINT8_MAX, 0);
291 #undef GET_PCIADDR_FIELD
307 char *output,
size_t size)
309 RTE_VERIFY(size >= PCI_PRI_STR_SIZE);
332 uint64_t dev_addr, dev_addr2;
334 if ((addr == NULL) || (addr2 == NULL))
337 dev_addr = ((uint64_t)addr->
domain << 24) |
339 dev_addr2 = ((uint64_t)addr2->
domain << 24) |
342 if (dev_addr > dev_addr2)
344 else if (dev_addr < dev_addr2)
413 void *pci_map_resource(
void *requested_addr,
int fd, off_t offset,
414 size_t size,
int additional_flags);
425 void pci_unmap_resource(
void *requested_addr,
size_t size);
475 #define RTE_PMD_REGISTER_PCI(nm, pci_drv) \
476 RTE_INIT(pciinitfn_ ##nm); \
477 static void pciinitfn_ ##nm(void) \
479 (pci_drv).driver.name = RTE_STR(nm);\
480 rte_pci_register(&pci_drv); \
482 RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
507 void *buf,
size_t len, off_t offset);
523 const void *buf,
size_t len, off_t offset);
577 void *data,
size_t len, off_t offset);
592 const void *data,
size_t len, off_t offset);