DPDK  19.11.10
rte_pci.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2015 Intel Corporation.
3  * Copyright 2013-2014 6WIND S.A.
4  */
5 
6 #ifndef _RTE_PCI_H_
7 #define _RTE_PCI_H_
8 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 #include <stdio.h>
20 #include <limits.h>
21 #include <sys/queue.h>
22 #include <inttypes.h>
23 
25 #define PCI_PRI_FMT "%.4" PRIx32 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
26 #define PCI_PRI_STR_SIZE sizeof("XXXXXXXX:XX:XX.X")
27 
29 #define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
30 
32 #define PCI_FMT_NVAL 4
33 
35 #define PCI_RESOURCE_FMT_NVAL 3
36 
38 #define PCI_MAX_RESOURCE 6
39 
44 struct rte_pci_id {
45  uint32_t class_id;
46  uint16_t vendor_id;
47  uint16_t device_id;
50 };
51 
55 struct rte_pci_addr {
56  uint32_t domain;
57  uint8_t bus;
58  uint8_t devid;
59  uint8_t function;
60 };
61 
63 #define PCI_ANY_ID (0xffff)
64 #define RTE_CLASS_ANY_ID (0xffffff)
65 
69 struct pci_map {
70  void *addr;
71  char *path;
72  uint64_t offset;
73  uint64_t size;
74  uint64_t phaddr;
75 };
76 
77 struct pci_msix_table {
78  int bar_index;
79  uint32_t offset;
80  uint32_t size;
81 };
82 
89  TAILQ_ENTRY(mapped_pci_resource) next;
90 
91  struct rte_pci_addr pci_addr;
92  char path[PATH_MAX];
93  int nb_maps;
94  struct pci_map maps[PCI_MAX_RESOURCE];
95  struct pci_msix_table msix_table;
96 };
97 
98 
100 TAILQ_HEAD(mapped_pci_res_list, mapped_pci_resource);
101 
114 void rte_pci_device_name(const struct rte_pci_addr *addr,
115  char *output, size_t size);
116 
129 int rte_pci_addr_cmp(const struct rte_pci_addr *addr,
130  const struct rte_pci_addr *addr2);
131 
132 
145 int rte_pci_addr_parse(const char *str, struct rte_pci_addr *addr);
146 
164 void *pci_map_resource(void *requested_addr, int fd, off_t offset,
165  size_t size, int additional_flags);
166 
175 void pci_unmap_resource(void *requested_addr, size_t size);
176 
177 #ifdef __cplusplus
178 }
179 #endif
180 
181 #endif /* _RTE_PCI_H_ */
int rte_pci_addr_parse(const char *str, struct rte_pci_addr *addr)
uint16_t device_id
Definition: rte_pci.h:47
uint8_t bus
Definition: rte_pci.h:57
uint32_t class_id
Definition: rte_pci.h:45
uint8_t devid
Definition: rte_pci.h:58
uint16_t subsystem_device_id
Definition: rte_pci.h:49
uint32_t domain
Definition: rte_pci.h:56
void rte_pci_device_name(const struct rte_pci_addr *addr, char *output, size_t size)
uint16_t subsystem_vendor_id
Definition: rte_pci.h:48
TAILQ_HEAD(mapped_pci_res_list, mapped_pci_resource)
void pci_unmap_resource(void *requested_addr, size_t size)
int rte_pci_addr_cmp(const struct rte_pci_addr *addr, const struct rte_pci_addr *addr2)
uint16_t vendor_id
Definition: rte_pci.h:46
void * pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size, int additional_flags)