DPDK  22.03.0
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 
23 #include <rte_log.h>
24 #include <rte_dev.h>
25 
27 RTE_TAILQ_HEAD(rte_bus_list, rte_bus);
28 
29 
39  RTE_IOVA_DC = 0, /* Don't care mode */
40  RTE_IOVA_PA = (1 << 0), /* DMA using physical address */
41  RTE_IOVA_VA = (1 << 1) /* DMA using virtual address */
42 };
43 
55 typedef int (*rte_bus_scan_t)(void);
56 
67 typedef int (*rte_bus_probe_t)(void);
68 
91 typedef struct rte_device *
92 (*rte_bus_find_device_t)(const struct rte_device *start, rte_dev_cmp_t cmp,
93  const void *data);
94 
106 typedef int (*rte_bus_plug_t)(struct rte_device *dev);
107 
119 typedef int (*rte_bus_unplug_t)(struct rte_device *dev);
120 
139 typedef int (*rte_bus_parse_t)(const char *name, void *addr);
140 
155 typedef int (*rte_bus_devargs_parse_t)(struct rte_devargs *da);
156 
175 typedef int (*rte_dev_dma_map_t)(struct rte_device *dev, void *addr,
176  uint64_t iova, size_t len);
177 
196 typedef int (*rte_dev_dma_unmap_t)(struct rte_device *dev, void *addr,
197  uint64_t iova, size_t len);
198 
211 typedef int (*rte_bus_hot_unplug_handler_t)(struct rte_device *dev);
212 
226 typedef int (*rte_bus_sigbus_handler_t)(const void *failure_addr);
227 
232  RTE_BUS_SCAN_UNDEFINED,
233  RTE_BUS_SCAN_ALLOWLIST,
234  RTE_BUS_SCAN_BLOCKLIST,
235 };
236 
240 struct rte_bus_conf {
242 };
243 
244 
256 
257 
261 struct rte_bus {
262  RTE_TAILQ_ENTRY(rte_bus) next;
263  const char *name;
273  struct rte_bus_conf conf;
281 };
282 
290 void rte_bus_register(struct rte_bus *bus);
291 
299 void rte_bus_unregister(struct rte_bus *bus);
300 
308 int rte_bus_scan(void);
309 
318 int rte_bus_probe(void);
319 
326 void rte_bus_dump(FILE *f);
327 
343 typedef int (*rte_bus_cmp_t)(const struct rte_bus *bus, const void *data);
344 
367 struct rte_bus *rte_bus_find(const struct rte_bus *start, rte_bus_cmp_t cmp,
368  const void *data);
369 
373 struct rte_bus *rte_bus_find_by_device(const struct rte_device *dev);
374 
378 struct rte_bus *rte_bus_find_by_name(const char *busname);
379 
380 
389 
394 #define RTE_REGISTER_BUS(nm, bus) \
395 RTE_INIT_PRIO(businitfn_ ##nm, BUS) \
396 {\
397  (bus).name = RTE_STR(nm);\
398  rte_bus_register(&bus); \
399 }
400 
401 #ifdef __cplusplus
402 }
403 #endif
404 
405 #endif /* _RTE_BUS_H */
enum rte_iova_mode(* rte_bus_get_iommu_class_t)(void)
Definition: rte_bus.h:255
void *(* rte_dev_iterate_t)(const void *start, const char *devstr, const struct rte_dev_iterator *it)
Definition: rte_dev.h:269
int(* rte_bus_sigbus_handler_t)(const void *failure_addr)
Definition: rte_bus.h:226
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:196
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:92
int(* rte_bus_devargs_parse_t)(struct rte_devargs *da)
Definition: rte_bus.h:155
rte_bus_unplug_t unplug
Definition: rte_bus.h:268
rte_bus_find_device_t find_device
Definition: rte_bus.h:266
rte_iova_mode
Definition: rte_bus.h:38
int rte_bus_probe(void)
int(* rte_bus_cmp_t)(const struct rte_bus *bus, const void *data)
Definition: rte_bus.h:343
rte_dev_dma_unmap_t dma_unmap
Definition: rte_bus.h:272
rte_dev_dma_map_t dma_map
Definition: rte_bus.h:271
rte_bus_devargs_parse_t devargs_parse
Definition: rte_bus.h:270
rte_bus_hot_unplug_handler_t hot_unplug_handler
Definition: rte_bus.h:276
int(* rte_dev_dma_map_t)(struct rte_device *dev, void *addr, uint64_t iova, size_t len)
Definition: rte_bus.h:175
int(* rte_bus_plug_t)(struct rte_device *dev)
Definition: rte_bus.h:106
void rte_bus_dump(FILE *f)
rte_bus_parse_t parse
Definition: rte_bus.h:269
rte_dev_iterate_t dev_iterate
Definition: rte_bus.h:275
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:139
rte_bus_sigbus_handler_t sigbus_handler
Definition: rte_bus.h:278
const char * name
Definition: rte_bus.h:263
rte_bus_scan_t scan
Definition: rte_bus.h:264
rte_bus_scan_mode
Definition: rte_bus.h:231
struct rte_bus * rte_bus_find(const struct rte_bus *start, rte_bus_cmp_t cmp, const void *data)
RTE_TAILQ_HEAD(rte_bus_list, rte_bus)
int(* rte_bus_probe_t)(void)
Definition: rte_bus.h:67
rte_bus_probe_t probe
Definition: rte_bus.h:265
int(* rte_bus_hot_unplug_handler_t)(struct rte_device *dev)
Definition: rte_bus.h:211
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:274
const char * name
Definition: rte_dev.h:87
void rte_bus_unregister(struct rte_bus *bus)
rte_bus_plug_t plug
Definition: rte_bus.h:267
enum rte_bus_scan_mode scan_mode
Definition: rte_bus.h:241
int(* rte_bus_scan_t)(void)
Definition: rte_bus.h:55
int(* rte_bus_unplug_t)(struct rte_device *dev)
Definition: rte_bus.h:119
int(* rte_dev_cmp_t)(const struct rte_device *dev, const void *data)
Definition: rte_dev.h:183
int rte_bus_scan(void)