DPDK  19.08.0-rc0
rte_bus.h
Go to the documentation of this file.
1 /*-
2  * BSD LICENSE
3  *
4  * Copyright 2016 NXP
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in
14  * the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of NXP nor the names of its
17  * contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef _RTE_BUS_H_
34 #define _RTE_BUS_H_
35 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 #include <stdio.h>
50 #include <sys/queue.h>
51 
52 #include <rte_log.h>
53 #include <rte_dev.h>
54 
56 TAILQ_HEAD(rte_bus_list, rte_bus);
57 
58 
68  RTE_IOVA_DC = 0, /* Don't care mode */
69  RTE_IOVA_PA = (1 << 0), /* DMA using physical address */
70  RTE_IOVA_VA = (1 << 1) /* DMA using virtual address */
71 };
72 
84 typedef int (*rte_bus_scan_t)(void);
85 
96 typedef int (*rte_bus_probe_t)(void);
97 
120 typedef struct rte_device *
121 (*rte_bus_find_device_t)(const struct rte_device *start, rte_dev_cmp_t cmp,
122  const void *data);
123 
135 typedef int (*rte_bus_plug_t)(struct rte_device *dev);
136 
148 typedef int (*rte_bus_unplug_t)(struct rte_device *dev);
149 
168 typedef int (*rte_bus_parse_t)(const char *name, void *addr);
169 
188 typedef int (*rte_dev_dma_map_t)(struct rte_device *dev, void *addr,
189  uint64_t iova, size_t len);
190 
209 typedef int (*rte_dev_dma_unmap_t)(struct rte_device *dev, void *addr,
210  uint64_t iova, size_t len);
211 
224 typedef int (*rte_bus_hot_unplug_handler_t)(struct rte_device *dev);
225 
239 typedef int (*rte_bus_sigbus_handler_t)(const void *failure_addr);
240 
245  RTE_BUS_SCAN_UNDEFINED,
246  RTE_BUS_SCAN_WHITELIST,
247  RTE_BUS_SCAN_BLACKLIST,
248 };
249 
253 struct rte_bus_conf {
255 };
256 
257 
269 
270 
274 struct rte_bus {
275  TAILQ_ENTRY(rte_bus) next;
276  const char *name;
293 };
294 
302 void rte_bus_register(struct rte_bus *bus);
303 
311 void rte_bus_unregister(struct rte_bus *bus);
312 
320 int rte_bus_scan(void);
321 
330 int rte_bus_probe(void);
331 
338 void rte_bus_dump(FILE *f);
339 
355 typedef int (*rte_bus_cmp_t)(const struct rte_bus *bus, const void *data);
356 
379 struct rte_bus *rte_bus_find(const struct rte_bus *start, rte_bus_cmp_t cmp,
380  const void *data);
381 
385 struct rte_bus *rte_bus_find_by_device(const struct rte_device *dev);
386 
390 struct rte_bus *rte_bus_find_by_name(const char *busname);
391 
392 
401 
406 #define RTE_REGISTER_BUS(nm, bus) \
407 RTE_INIT_PRIO(businitfn_ ##nm, BUS) \
408 {\
409  (bus).name = RTE_STR(nm);\
410  rte_bus_register(&bus); \
411 }
412 
413 #ifdef __cplusplus
414 }
415 #endif
416 
417 #endif /* _RTE_BUS_H */
enum rte_iova_mode(* rte_bus_get_iommu_class_t)(void)
Definition: rte_bus.h:268
void *(* rte_dev_iterate_t)(const void *start, const char *devstr, const struct rte_dev_iterator *it)
Definition: rte_dev.h:289
int(* rte_bus_sigbus_handler_t)(const void *failure_addr)
Definition: rte_bus.h:239
enum rte_iova_mode rte_bus_get_iommu_class(void)
void rte_bus_register(struct rte_bus *bus)
int(* rte_dev_dma_unmap_t)(struct rte_device *dev, void *addr, uint64_t iova, size_t len)
Definition: rte_bus.h:209
struct rte_device *(* rte_bus_find_device_t)(const struct rte_device *start, rte_dev_cmp_t cmp, const void *data)
Definition: rte_bus.h:121
rte_bus_unplug_t unplug
Definition: rte_bus.h:281
TAILQ_HEAD(rte_bus_list, rte_bus)
rte_bus_find_device_t find_device
Definition: rte_bus.h:279
rte_iova_mode
Definition: rte_bus.h:67
int rte_bus_probe(void)
struct rte_bus_conf conf
Definition: rte_bus.h:285
int(* rte_bus_cmp_t)(const struct rte_bus *bus, const void *data)
Definition: rte_bus.h:355
rte_dev_dma_unmap_t dma_unmap
Definition: rte_bus.h:284
rte_dev_dma_map_t dma_map
Definition: rte_bus.h:283
rte_bus_hot_unplug_handler_t hot_unplug_handler
Definition: rte_bus.h:288
TAILQ_ENTRY(rte_bus) next
int(* rte_dev_dma_map_t)(struct rte_device *dev, void *addr, uint64_t iova, size_t len)
Definition: rte_bus.h:188
int(* rte_bus_plug_t)(struct rte_device *dev)
Definition: rte_bus.h:135
void rte_bus_dump(FILE *f)
rte_bus_parse_t parse
Definition: rte_bus.h:282
rte_dev_iterate_t dev_iterate
Definition: rte_bus.h:287
struct rte_bus * rte_bus_find_by_name(const char *busname)
int(* rte_bus_parse_t)(const char *name, void *addr)
Definition: rte_bus.h:168
rte_bus_sigbus_handler_t sigbus_handler
Definition: rte_bus.h:290
const char * name
Definition: rte_bus.h:276
rte_bus_scan_t scan
Definition: rte_bus.h:277
rte_bus_scan_mode
Definition: rte_bus.h:244
struct rte_bus * rte_bus_find(const struct rte_bus *start, rte_bus_cmp_t cmp, const void *data)
int(* rte_bus_probe_t)(void)
Definition: rte_bus.h:96
rte_bus_probe_t probe
Definition: rte_bus.h:278
int(* rte_bus_hot_unplug_handler_t)(struct rte_device *dev)
Definition: rte_bus.h:224
struct rte_bus * rte_bus_find_by_device(const struct rte_device *dev)
rte_bus_get_iommu_class_t get_iommu_class
Definition: rte_bus.h:286
const char * name
Definition: rte_dev.h:107
void rte_bus_unregister(struct rte_bus *bus)
rte_bus_plug_t plug
Definition: rte_bus.h:280
enum rte_bus_scan_mode scan_mode
Definition: rte_bus.h:254
int(* rte_bus_scan_t)(void)
Definition: rte_bus.h:84
int(* rte_bus_unplug_t)(struct rte_device *dev)
Definition: rte_bus.h:148
int(* rte_dev_cmp_t)(const struct rte_device *dev, const void *data)
Definition: rte_dev.h:203
int rte_bus_scan(void)