xref: /dpdk/drivers/bus/auxiliary/private.h (revision cf8a8a8f)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2021 NVIDIA Corporation & Affiliates
3  */
4 
5 #ifndef BUS_AUXILIARY_PRIVATE_H
6 #define BUS_AUXILIARY_PRIVATE_H
7 
8 #include <stdbool.h>
9 #include <stdio.h>
10 
11 #include "rte_bus_auxiliary.h"
12 
13 extern struct rte_auxiliary_bus auxiliary_bus;
14 extern int auxiliary_bus_logtype;
15 
16 #define AUXILIARY_LOG(level, ...) \
17 	rte_log(RTE_LOG_ ## level, auxiliary_bus_logtype, \
18 		RTE_FMT("auxiliary bus: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
19 			RTE_FMT_TAIL(__VA_ARGS__,)))
20 
21 /* Auxiliary bus iterators */
22 #define FOREACH_DEVICE_ON_AUXILIARY_BUS(p) \
23 		TAILQ_FOREACH(p, &(auxiliary_bus.device_list), next)
24 
25 #define FOREACH_DRIVER_ON_AUXILIARY_BUS(p) \
26 		TAILQ_FOREACH(p, &(auxiliary_bus.driver_list), next)
27 
28 /* List of auxiliary devices. */
29 TAILQ_HEAD(rte_auxiliary_device_list, rte_auxiliary_device);
30 /* List of auxiliary drivers. */
31 TAILQ_HEAD(rte_auxiliary_driver_list, rte_auxiliary_driver);
32 
33 /*
34  * Structure describing the auxiliary bus
35  */
36 struct rte_auxiliary_bus {
37 	struct rte_bus bus;                  /* Inherit the generic class */
38 	struct rte_auxiliary_device_list device_list;  /* List of devices */
39 	struct rte_auxiliary_driver_list driver_list;  /* List of drivers */
40 };
41 
42 /*
43  * Test whether the auxiliary device exist.
44  */
45 bool auxiliary_dev_exists(const char *name);
46 
47 /*
48  * Scan the content of the auxiliary bus, and the devices in the devices
49  * list.
50  */
51 int auxiliary_scan(void);
52 
53 /*
54  * Update a device being scanned.
55  */
56 void auxiliary_on_scan(struct rte_auxiliary_device *aux_dev);
57 
58 /*
59  * Validate whether a device with given auxiliary device should be ignored
60  * or not.
61  */
62 bool auxiliary_is_ignored_device(const char *name);
63 
64 /*
65  * Add an auxiliary device to the auxiliary bus (append to auxiliary device
66  * list). This function also updates the bus references of the auxiliary
67  * device and the generic device object embedded within.
68  */
69 void auxiliary_add_device(struct rte_auxiliary_device *aux_dev);
70 
71 /*
72  * Insert an auxiliary device in the auxiliary bus at a particular location
73  * in the device list. It also updates the auxiliary bus reference of the
74  * new devices to be inserted.
75  */
76 void auxiliary_insert_device(struct rte_auxiliary_device *exist_aux_dev,
77 			     struct rte_auxiliary_device *new_aux_dev);
78 
79 /*
80  * Match the auxiliary driver and device by driver function.
81  */
82 bool auxiliary_match(const struct rte_auxiliary_driver *aux_drv,
83 		     const struct rte_auxiliary_device *aux_dev);
84 
85 /*
86  * Iterate over devices, matching any device against the provided string.
87  */
88 void *auxiliary_dev_iterate(const void *start, const char *str,
89 			    const struct rte_dev_iterator *it);
90 
91 #endif /* BUS_AUXILIARY_PRIVATE_H */
92