DPDK  19.11.14
rte_bus.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2016 NXP
3  */
4 
5 #ifndef _RTE_BUS_H_
6 #define _RTE_BUS_H_
7 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 #include <stdio.h>
22 #include <sys/queue.h>
23 
24 #include <rte_log.h>
25 #include <rte_dev.h>
26 
28 TAILQ_HEAD(rte_bus_list, rte_bus);
29 
30 
40  RTE_IOVA_DC = 0, /* Don't care mode */
41  RTE_IOVA_PA = (1 << 0), /* DMA using physical address */
42  RTE_IOVA_VA = (1 << 1) /* DMA using virtual address */
43 };
44 
56 typedef int (*rte_bus_scan_t)(void);
57 
68 typedef int (*rte_bus_probe_t)(void);
69 
92 typedef struct rte_device *
93 (*rte_bus_find_device_t)(const struct rte_device *start, rte_dev_cmp_t cmp,
94  const void *data);
95 
107 typedef int (*rte_bus_plug_t)(struct rte_device *dev);
108 
120 typedef int (*rte_bus_unplug_t)(struct rte_device *dev);
121 
140 typedef int (*rte_bus_parse_t)(const char *name, void *addr);
141 
160 typedef int (*rte_dev_dma_map_t)(struct rte_device *dev, void *addr,
161  uint64_t iova, size_t len);
162 
181 typedef int (*rte_dev_dma_unmap_t)(struct rte_device *dev, void *addr,
182  uint64_t iova, size_t len);
183 
196 typedef int (*rte_bus_hot_unplug_handler_t)(struct rte_device *dev);
197 
211 typedef int (*rte_bus_sigbus_handler_t)(const void *failure_addr);
212 
217  RTE_BUS_SCAN_UNDEFINED,
218  RTE_BUS_SCAN_WHITELIST,
219  RTE_BUS_SCAN_BLACKLIST,
220 };
221 
225 struct rte_bus_conf {
227 };
228 
229 
241 
242 
246 struct rte_bus {
247  TAILQ_ENTRY(rte_bus) next;
248  const char *name;
257  struct rte_bus_conf conf;
265 };
266 
274 void rte_bus_register(struct rte_bus *bus);
275 
283 void rte_bus_unregister(struct rte_bus *bus);
284 
292 int rte_bus_scan(void);
293 
302 int rte_bus_probe(void);
303 
310 void rte_bus_dump(FILE *f);
311 
327 typedef int (*rte_bus_cmp_t)(const struct rte_bus *bus, const void *data);
328 
351 struct rte_bus *rte_bus_find(const struct rte_bus *start, rte_bus_cmp_t cmp,
352  const void *data);
353 
357 struct rte_bus *rte_bus_find_by_device(const struct rte_device *dev);
358 
362 struct rte_bus *rte_bus_find_by_name(const char *busname);
363 
364 
373 
378 #define RTE_REGISTER_BUS(nm, bus) \
379 RTE_INIT_PRIO(businitfn_ ##nm, BUS) \
380 {\
381  (bus).name = RTE_STR(nm);\
382  rte_bus_register(&bus); \
383 }
384 
385 #ifdef __cplusplus
386 }
387 #endif
388 
389 #endif /* _RTE_BUS_H */
enum rte_iova_mode(* rte_bus_get_iommu_class_t)(void)
Definition: rte_bus.h:240
void *(* rte_dev_iterate_t)(const void *start, const char *devstr, const struct rte_dev_iterator *it)
Definition: rte_dev.h:288
int(* rte_bus_sigbus_handler_t)(const void *failure_addr)
Definition: rte_bus.h:211
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:181
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:93
rte_bus_unplug_t unplug
Definition: rte_bus.h:253
TAILQ_HEAD(rte_bus_list, rte_bus)
rte_bus_find_device_t find_device
Definition: rte_bus.h:251
rte_iova_mode
Definition: rte_bus.h:39
int rte_bus_probe(void)
int(* rte_bus_cmp_t)(const struct rte_bus *bus, const void *data)
Definition: rte_bus.h:327
rte_dev_dma_unmap_t dma_unmap
Definition: rte_bus.h:256
rte_dev_dma_map_t dma_map
Definition: rte_bus.h:255
rte_bus_hot_unplug_handler_t hot_unplug_handler
Definition: rte_bus.h:260
int(* rte_dev_dma_map_t)(struct rte_device *dev, void *addr, uint64_t iova, size_t len)
Definition: rte_bus.h:160
int(* rte_bus_plug_t)(struct rte_device *dev)
Definition: rte_bus.h:107
void rte_bus_dump(FILE *f)
rte_bus_parse_t parse
Definition: rte_bus.h:254
rte_dev_iterate_t dev_iterate
Definition: rte_bus.h:259
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:140
rte_bus_sigbus_handler_t sigbus_handler
Definition: rte_bus.h:262
const char * name
Definition: rte_bus.h:248
rte_bus_scan_t scan
Definition: rte_bus.h:249
rte_bus_scan_mode
Definition: rte_bus.h:216
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:68
rte_bus_probe_t probe
Definition: rte_bus.h:250
int(* rte_bus_hot_unplug_handler_t)(struct rte_device *dev)
Definition: rte_bus.h:196
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:258
const char * name
Definition: rte_dev.h:106
void rte_bus_unregister(struct rte_bus *bus)
rte_bus_plug_t plug
Definition: rte_bus.h:252
enum rte_bus_scan_mode scan_mode
Definition: rte_bus.h:226
int(* rte_bus_scan_t)(void)
Definition: rte_bus.h:56
int(* rte_bus_unplug_t)(struct rte_device *dev)
Definition: rte_bus.h:120
int(* rte_dev_cmp_t)(const struct rte_device *dev, const void *data)
Definition: rte_dev.h:202
int rte_bus_scan(void)