xref: /f-stack/dpdk/lib/librte_eal/include/rte_dev.h (revision 2d9fd380)
1*2d9fd380Sjfb8856606 /* SPDX-License-Identifier: BSD-3-Clause
2*2d9fd380Sjfb8856606  * Copyright(c) 2014 6WIND S.A.
3*2d9fd380Sjfb8856606  */
4*2d9fd380Sjfb8856606 
5*2d9fd380Sjfb8856606 #ifndef _RTE_DEV_H_
6*2d9fd380Sjfb8856606 #define _RTE_DEV_H_
7*2d9fd380Sjfb8856606 
8*2d9fd380Sjfb8856606 /**
9*2d9fd380Sjfb8856606  * @file
10*2d9fd380Sjfb8856606  *
11*2d9fd380Sjfb8856606  * RTE PMD Driver Registration Interface
12*2d9fd380Sjfb8856606  *
13*2d9fd380Sjfb8856606  * This file manages the list of device drivers.
14*2d9fd380Sjfb8856606  */
15*2d9fd380Sjfb8856606 
16*2d9fd380Sjfb8856606 #ifdef __cplusplus
17*2d9fd380Sjfb8856606 extern "C" {
18*2d9fd380Sjfb8856606 #endif
19*2d9fd380Sjfb8856606 
20*2d9fd380Sjfb8856606 #include <stdio.h>
21*2d9fd380Sjfb8856606 #include <sys/queue.h>
22*2d9fd380Sjfb8856606 
23*2d9fd380Sjfb8856606 #include <rte_config.h>
24*2d9fd380Sjfb8856606 #include <rte_compat.h>
25*2d9fd380Sjfb8856606 #include <rte_log.h>
26*2d9fd380Sjfb8856606 
27*2d9fd380Sjfb8856606 /**
28*2d9fd380Sjfb8856606  * The device event type.
29*2d9fd380Sjfb8856606  */
30*2d9fd380Sjfb8856606 enum rte_dev_event_type {
31*2d9fd380Sjfb8856606 	RTE_DEV_EVENT_ADD,	/**< device being added */
32*2d9fd380Sjfb8856606 	RTE_DEV_EVENT_REMOVE,	/**< device being removed */
33*2d9fd380Sjfb8856606 	RTE_DEV_EVENT_MAX	/**< max value of this enum */
34*2d9fd380Sjfb8856606 };
35*2d9fd380Sjfb8856606 
36*2d9fd380Sjfb8856606 typedef void (*rte_dev_event_cb_fn)(const char *device_name,
37*2d9fd380Sjfb8856606 					enum rte_dev_event_type event,
38*2d9fd380Sjfb8856606 					void *cb_arg);
39*2d9fd380Sjfb8856606 
40*2d9fd380Sjfb8856606 /* Macros to check for invalid function pointers */
41*2d9fd380Sjfb8856606 #define RTE_FUNC_PTR_OR_ERR_RET(func, retval) do { \
42*2d9fd380Sjfb8856606 	if ((func) == NULL) \
43*2d9fd380Sjfb8856606 		return retval; \
44*2d9fd380Sjfb8856606 } while (0)
45*2d9fd380Sjfb8856606 
46*2d9fd380Sjfb8856606 #define RTE_FUNC_PTR_OR_RET(func) do { \
47*2d9fd380Sjfb8856606 	if ((func) == NULL) \
48*2d9fd380Sjfb8856606 		return; \
49*2d9fd380Sjfb8856606 } while (0)
50*2d9fd380Sjfb8856606 
51*2d9fd380Sjfb8856606 /**
52*2d9fd380Sjfb8856606  * Device policies.
53*2d9fd380Sjfb8856606  */
54*2d9fd380Sjfb8856606 enum rte_dev_policy {
55*2d9fd380Sjfb8856606 	RTE_DEV_ALLOWED,
56*2d9fd380Sjfb8856606 	RTE_DEV_BLOCKED,
57*2d9fd380Sjfb8856606 };
58*2d9fd380Sjfb8856606 
59*2d9fd380Sjfb8856606 /* Backwards compatibility will be removed */
60*2d9fd380Sjfb8856606 #define RTE_DEV_WHITELISTED \
61*2d9fd380Sjfb8856606 	RTE_DEPRECATED(RTE_DEV_WHITELISTED) RTE_DEV_ALLOWED
62*2d9fd380Sjfb8856606 #define RTE_DEV_BLACKLISTED \
63*2d9fd380Sjfb8856606 	RTE_DEPRECATED(RTE_DEV_BLACKLISTED) RTE_DEV_BLOCKED
64*2d9fd380Sjfb8856606 
65*2d9fd380Sjfb8856606 /**
66*2d9fd380Sjfb8856606  * A generic memory resource representation.
67*2d9fd380Sjfb8856606  */
68*2d9fd380Sjfb8856606 struct rte_mem_resource {
69*2d9fd380Sjfb8856606 	uint64_t phys_addr; /**< Physical address, 0 if not resource. */
70*2d9fd380Sjfb8856606 	uint64_t len;       /**< Length of the resource. */
71*2d9fd380Sjfb8856606 	void *addr;         /**< Virtual address, NULL when not mapped. */
72*2d9fd380Sjfb8856606 };
73*2d9fd380Sjfb8856606 
74*2d9fd380Sjfb8856606 /**
75*2d9fd380Sjfb8856606  * A structure describing a device driver.
76*2d9fd380Sjfb8856606  */
77*2d9fd380Sjfb8856606 struct rte_driver {
78*2d9fd380Sjfb8856606 	TAILQ_ENTRY(rte_driver) next;  /**< Next in list. */
79*2d9fd380Sjfb8856606 	const char *name;                   /**< Driver name. */
80*2d9fd380Sjfb8856606 	const char *alias;              /**< Driver alias. */
81*2d9fd380Sjfb8856606 };
82*2d9fd380Sjfb8856606 
83*2d9fd380Sjfb8856606 /*
84*2d9fd380Sjfb8856606  * Internal identifier length
85*2d9fd380Sjfb8856606  * Sufficiently large to allow for UUID or PCI address
86*2d9fd380Sjfb8856606  */
87*2d9fd380Sjfb8856606 #define RTE_DEV_NAME_MAX_LEN 64
88*2d9fd380Sjfb8856606 
89*2d9fd380Sjfb8856606 /**
90*2d9fd380Sjfb8856606  * A structure describing a generic device.
91*2d9fd380Sjfb8856606  */
92*2d9fd380Sjfb8856606 struct rte_device {
93*2d9fd380Sjfb8856606 	TAILQ_ENTRY(rte_device) next; /**< Next device */
94*2d9fd380Sjfb8856606 	const char *name;             /**< Device name */
95*2d9fd380Sjfb8856606 	const struct rte_driver *driver; /**< Driver assigned after probing */
96*2d9fd380Sjfb8856606 	const struct rte_bus *bus;    /**< Bus handle assigned on scan */
97*2d9fd380Sjfb8856606 	int numa_node;                /**< NUMA node connection */
98*2d9fd380Sjfb8856606 	struct rte_devargs *devargs;  /**< Arguments for latest probing */
99*2d9fd380Sjfb8856606 };
100*2d9fd380Sjfb8856606 
101*2d9fd380Sjfb8856606 /**
102*2d9fd380Sjfb8856606  * Query status of a device.
103*2d9fd380Sjfb8856606  *
104*2d9fd380Sjfb8856606  * @param dev
105*2d9fd380Sjfb8856606  *   Generic device pointer.
106*2d9fd380Sjfb8856606  * @return
107*2d9fd380Sjfb8856606  *   (int)true if already probed successfully, 0 otherwise.
108*2d9fd380Sjfb8856606  */
109*2d9fd380Sjfb8856606 int rte_dev_is_probed(const struct rte_device *dev);
110*2d9fd380Sjfb8856606 
111*2d9fd380Sjfb8856606 /**
112*2d9fd380Sjfb8856606  * Hotplug add a given device to a specific bus.
113*2d9fd380Sjfb8856606  *
114*2d9fd380Sjfb8856606  * In multi-process, it will request other processes to add the same device.
115*2d9fd380Sjfb8856606  * A failure, in any process, will rollback the action
116*2d9fd380Sjfb8856606  *
117*2d9fd380Sjfb8856606  * @param busname
118*2d9fd380Sjfb8856606  *   The bus name the device is added to.
119*2d9fd380Sjfb8856606  * @param devname
120*2d9fd380Sjfb8856606  *   The device name. Based on this device name, eal will identify a driver
121*2d9fd380Sjfb8856606  *   capable of handling it and pass it to the driver probing function.
122*2d9fd380Sjfb8856606  * @param drvargs
123*2d9fd380Sjfb8856606  *   Device arguments to be passed to the driver.
124*2d9fd380Sjfb8856606  * @return
125*2d9fd380Sjfb8856606  *   0 on success, negative on error.
126*2d9fd380Sjfb8856606  */
127*2d9fd380Sjfb8856606 int rte_eal_hotplug_add(const char *busname, const char *devname,
128*2d9fd380Sjfb8856606 			const char *drvargs);
129*2d9fd380Sjfb8856606 
130*2d9fd380Sjfb8856606 /**
131*2d9fd380Sjfb8856606  * Add matching devices.
132*2d9fd380Sjfb8856606  *
133*2d9fd380Sjfb8856606  * In multi-process, it will request other processes to add the same device.
134*2d9fd380Sjfb8856606  * A failure, in any process, will rollback the action
135*2d9fd380Sjfb8856606  *
136*2d9fd380Sjfb8856606  * @param devargs
137*2d9fd380Sjfb8856606  *   Device arguments including bus, class and driver properties.
138*2d9fd380Sjfb8856606  * @return
139*2d9fd380Sjfb8856606  *   0 on success, negative on error.
140*2d9fd380Sjfb8856606  */
141*2d9fd380Sjfb8856606 int rte_dev_probe(const char *devargs);
142*2d9fd380Sjfb8856606 
143*2d9fd380Sjfb8856606 /**
144*2d9fd380Sjfb8856606  * Hotplug remove a given device from a specific bus.
145*2d9fd380Sjfb8856606  *
146*2d9fd380Sjfb8856606  * In multi-process, it will request other processes to remove the same device.
147*2d9fd380Sjfb8856606  * A failure, in any process, will rollback the action
148*2d9fd380Sjfb8856606  *
149*2d9fd380Sjfb8856606  * @param busname
150*2d9fd380Sjfb8856606  *   The bus name the device is removed from.
151*2d9fd380Sjfb8856606  * @param devname
152*2d9fd380Sjfb8856606  *   The device name being removed.
153*2d9fd380Sjfb8856606  * @return
154*2d9fd380Sjfb8856606  *   0 on success, negative on error.
155*2d9fd380Sjfb8856606  */
156*2d9fd380Sjfb8856606 int rte_eal_hotplug_remove(const char *busname, const char *devname);
157*2d9fd380Sjfb8856606 
158*2d9fd380Sjfb8856606 /**
159*2d9fd380Sjfb8856606  * Remove one device.
160*2d9fd380Sjfb8856606  *
161*2d9fd380Sjfb8856606  * In multi-process, it will request other processes to remove the same device.
162*2d9fd380Sjfb8856606  * A failure, in any process, will rollback the action
163*2d9fd380Sjfb8856606  *
164*2d9fd380Sjfb8856606  * @param dev
165*2d9fd380Sjfb8856606  *   Data structure of the device to remove.
166*2d9fd380Sjfb8856606  * @return
167*2d9fd380Sjfb8856606  *   0 on success, negative on error.
168*2d9fd380Sjfb8856606  */
169*2d9fd380Sjfb8856606 int rte_dev_remove(struct rte_device *dev);
170*2d9fd380Sjfb8856606 
171*2d9fd380Sjfb8856606 /**
172*2d9fd380Sjfb8856606  * Device comparison function.
173*2d9fd380Sjfb8856606  *
174*2d9fd380Sjfb8856606  * This type of function is used to compare an rte_device with arbitrary
175*2d9fd380Sjfb8856606  * data.
176*2d9fd380Sjfb8856606  *
177*2d9fd380Sjfb8856606  * @param dev
178*2d9fd380Sjfb8856606  *   Device handle.
179*2d9fd380Sjfb8856606  *
180*2d9fd380Sjfb8856606  * @param data
181*2d9fd380Sjfb8856606  *   Data to compare against. The type of this parameter is determined by
182*2d9fd380Sjfb8856606  *   the kind of comparison performed by the function.
183*2d9fd380Sjfb8856606  *
184*2d9fd380Sjfb8856606  * @return
185*2d9fd380Sjfb8856606  *   0 if the device matches the data.
186*2d9fd380Sjfb8856606  *   !0 if the device does not match.
187*2d9fd380Sjfb8856606  *   <0 if ordering is possible and the device is lower than the data.
188*2d9fd380Sjfb8856606  *   >0 if ordering is possible and the device is greater than the data.
189*2d9fd380Sjfb8856606  */
190*2d9fd380Sjfb8856606 typedef int (*rte_dev_cmp_t)(const struct rte_device *dev, const void *data);
191*2d9fd380Sjfb8856606 
192*2d9fd380Sjfb8856606 #define RTE_PMD_EXPORT_NAME_ARRAY(n, idx) n##idx[]
193*2d9fd380Sjfb8856606 
194*2d9fd380Sjfb8856606 #define RTE_PMD_EXPORT_NAME(name, idx) \
195*2d9fd380Sjfb8856606 static const char RTE_PMD_EXPORT_NAME_ARRAY(this_pmd_name, idx) \
196*2d9fd380Sjfb8856606 __rte_used = RTE_STR(name)
197*2d9fd380Sjfb8856606 
198*2d9fd380Sjfb8856606 #define DRV_EXP_TAG(name, tag) __##name##_##tag
199*2d9fd380Sjfb8856606 
200*2d9fd380Sjfb8856606 #define RTE_PMD_REGISTER_PCI_TABLE(name, table) \
201*2d9fd380Sjfb8856606 static const char DRV_EXP_TAG(name, pci_tbl_export)[] __rte_used = \
202*2d9fd380Sjfb8856606 RTE_STR(table)
203*2d9fd380Sjfb8856606 
204*2d9fd380Sjfb8856606 #define RTE_PMD_REGISTER_PARAM_STRING(name, str) \
205*2d9fd380Sjfb8856606 static const char DRV_EXP_TAG(name, param_string_export)[] \
206*2d9fd380Sjfb8856606 __rte_used = str
207*2d9fd380Sjfb8856606 
208*2d9fd380Sjfb8856606 /**
209*2d9fd380Sjfb8856606  * Advertise the list of kernel modules required to run this driver
210*2d9fd380Sjfb8856606  *
211*2d9fd380Sjfb8856606  * This string lists the kernel modules required for the devices
212*2d9fd380Sjfb8856606  * associated to a PMD. The format of each line of the string is:
213*2d9fd380Sjfb8856606  * "<device-pattern> <kmod-expression>".
214*2d9fd380Sjfb8856606  *
215*2d9fd380Sjfb8856606  * The possible formats for the device pattern are:
216*2d9fd380Sjfb8856606  *   "*"                     all devices supported by this driver
217*2d9fd380Sjfb8856606  *   "pci:*"                 all PCI devices supported by this driver
218*2d9fd380Sjfb8856606  *   "pci:v8086:d*:sv*:sd*"  all PCI devices supported by this driver
219*2d9fd380Sjfb8856606  *                           whose vendor id is 0x8086.
220*2d9fd380Sjfb8856606  *
221*2d9fd380Sjfb8856606  * The format of the kernel modules list is a parenthesized expression
222*2d9fd380Sjfb8856606  * containing logical-and (&) and logical-or (|).
223*2d9fd380Sjfb8856606  *
224*2d9fd380Sjfb8856606  * The device pattern and the kmod expression are separated by a space.
225*2d9fd380Sjfb8856606  *
226*2d9fd380Sjfb8856606  * Example:
227*2d9fd380Sjfb8856606  * - "* igb_uio | uio_pci_generic | vfio"
228*2d9fd380Sjfb8856606  */
229*2d9fd380Sjfb8856606 #define RTE_PMD_REGISTER_KMOD_DEP(name, str) \
230*2d9fd380Sjfb8856606 static const char DRV_EXP_TAG(name, kmod_dep_export)[] \
231*2d9fd380Sjfb8856606 __rte_used = str
232*2d9fd380Sjfb8856606 
233*2d9fd380Sjfb8856606 /**
234*2d9fd380Sjfb8856606  * Iteration context.
235*2d9fd380Sjfb8856606  *
236*2d9fd380Sjfb8856606  * This context carries over the current iteration state.
237*2d9fd380Sjfb8856606  */
238*2d9fd380Sjfb8856606 struct rte_dev_iterator {
239*2d9fd380Sjfb8856606 	const char *dev_str; /**< device string. */
240*2d9fd380Sjfb8856606 	const char *bus_str; /**< bus-related part of device string. */
241*2d9fd380Sjfb8856606 	const char *cls_str; /**< class-related part of device string. */
242*2d9fd380Sjfb8856606 	struct rte_bus *bus; /**< bus handle. */
243*2d9fd380Sjfb8856606 	struct rte_class *cls; /**< class handle. */
244*2d9fd380Sjfb8856606 	struct rte_device *device; /**< current position. */
245*2d9fd380Sjfb8856606 	void *class_device; /**< additional specialized context. */
246*2d9fd380Sjfb8856606 };
247*2d9fd380Sjfb8856606 
248*2d9fd380Sjfb8856606 /**
249*2d9fd380Sjfb8856606  * Device iteration function.
250*2d9fd380Sjfb8856606  *
251*2d9fd380Sjfb8856606  * Find the next device matching properties passed in parameters.
252*2d9fd380Sjfb8856606  * The function takes an additional ``start`` parameter, that is
253*2d9fd380Sjfb8856606  * used as starting context when relevant.
254*2d9fd380Sjfb8856606  *
255*2d9fd380Sjfb8856606  * The function returns the current element in the iteration.
256*2d9fd380Sjfb8856606  * This return value will potentially be used as a start parameter
257*2d9fd380Sjfb8856606  * in subsequent calls to the function.
258*2d9fd380Sjfb8856606  *
259*2d9fd380Sjfb8856606  * The additional iterator parameter is only there if a specific
260*2d9fd380Sjfb8856606  * implementation needs additional context. It must not be modified by
261*2d9fd380Sjfb8856606  * the iteration function itself.
262*2d9fd380Sjfb8856606  *
263*2d9fd380Sjfb8856606  * @param start
264*2d9fd380Sjfb8856606  *   Starting iteration context.
265*2d9fd380Sjfb8856606  *
266*2d9fd380Sjfb8856606  * @param devstr
267*2d9fd380Sjfb8856606  *   Device description string.
268*2d9fd380Sjfb8856606  *
269*2d9fd380Sjfb8856606  * @param it
270*2d9fd380Sjfb8856606  *   Device iterator.
271*2d9fd380Sjfb8856606  *
272*2d9fd380Sjfb8856606  * @return
273*2d9fd380Sjfb8856606  *   The address of the current element matching the device description
274*2d9fd380Sjfb8856606  *   string.
275*2d9fd380Sjfb8856606  */
276*2d9fd380Sjfb8856606 typedef void *(*rte_dev_iterate_t)(const void *start,
277*2d9fd380Sjfb8856606 				   const char *devstr,
278*2d9fd380Sjfb8856606 				   const struct rte_dev_iterator *it);
279*2d9fd380Sjfb8856606 
280*2d9fd380Sjfb8856606 /**
281*2d9fd380Sjfb8856606  * Initializes a device iterator.
282*2d9fd380Sjfb8856606  *
283*2d9fd380Sjfb8856606  * This iterator allows accessing a list of devices matching a criteria.
284*2d9fd380Sjfb8856606  * The device matching is made among all buses and classes currently registered,
285*2d9fd380Sjfb8856606  * filtered by the device description given as parameter.
286*2d9fd380Sjfb8856606  *
287*2d9fd380Sjfb8856606  * This function will not allocate any memory. It is safe to stop the
288*2d9fd380Sjfb8856606  * iteration at any moment and let the iterator go out of context.
289*2d9fd380Sjfb8856606  *
290*2d9fd380Sjfb8856606  * @param it
291*2d9fd380Sjfb8856606  *   Device iterator handle.
292*2d9fd380Sjfb8856606  *
293*2d9fd380Sjfb8856606  * @param str
294*2d9fd380Sjfb8856606  *   Device description string.
295*2d9fd380Sjfb8856606  *
296*2d9fd380Sjfb8856606  * @return
297*2d9fd380Sjfb8856606  *   0 on successful initialization.
298*2d9fd380Sjfb8856606  *   <0 on error.
299*2d9fd380Sjfb8856606  */
300*2d9fd380Sjfb8856606 __rte_experimental
301*2d9fd380Sjfb8856606 int
302*2d9fd380Sjfb8856606 rte_dev_iterator_init(struct rte_dev_iterator *it, const char *str);
303*2d9fd380Sjfb8856606 
304*2d9fd380Sjfb8856606 /**
305*2d9fd380Sjfb8856606  * Iterates on a device iterator.
306*2d9fd380Sjfb8856606  *
307*2d9fd380Sjfb8856606  * Generates a new rte_device handle corresponding to the next element
308*2d9fd380Sjfb8856606  * in the list described in comprehension by the iterator.
309*2d9fd380Sjfb8856606  *
310*2d9fd380Sjfb8856606  * The next object is returned, and the iterator is updated.
311*2d9fd380Sjfb8856606  *
312*2d9fd380Sjfb8856606  * @param it
313*2d9fd380Sjfb8856606  *   Device iterator handle.
314*2d9fd380Sjfb8856606  *
315*2d9fd380Sjfb8856606  * @return
316*2d9fd380Sjfb8856606  *   An rte_device handle if found.
317*2d9fd380Sjfb8856606  *   NULL if an error occurred (rte_errno is set).
318*2d9fd380Sjfb8856606  *   NULL if no device could be found (rte_errno is not set).
319*2d9fd380Sjfb8856606  */
320*2d9fd380Sjfb8856606 __rte_experimental
321*2d9fd380Sjfb8856606 struct rte_device *
322*2d9fd380Sjfb8856606 rte_dev_iterator_next(struct rte_dev_iterator *it);
323*2d9fd380Sjfb8856606 
324*2d9fd380Sjfb8856606 #define RTE_DEV_FOREACH(dev, devstr, it) \
325*2d9fd380Sjfb8856606 	for (rte_dev_iterator_init(it, devstr), \
326*2d9fd380Sjfb8856606 	     dev = rte_dev_iterator_next(it); \
327*2d9fd380Sjfb8856606 	     dev != NULL; \
328*2d9fd380Sjfb8856606 	     dev = rte_dev_iterator_next(it))
329*2d9fd380Sjfb8856606 
330*2d9fd380Sjfb8856606 #ifdef __cplusplus
331*2d9fd380Sjfb8856606 }
332*2d9fd380Sjfb8856606 #endif
333*2d9fd380Sjfb8856606 
334*2d9fd380Sjfb8856606 /**
335*2d9fd380Sjfb8856606  * @warning
336*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice
337*2d9fd380Sjfb8856606  *
338*2d9fd380Sjfb8856606  * It registers the callback for the specific device.
339*2d9fd380Sjfb8856606  * Multiple callbacks can be registered at the same time.
340*2d9fd380Sjfb8856606  *
341*2d9fd380Sjfb8856606  * @param device_name
342*2d9fd380Sjfb8856606  *  The device name, that is the param name of the struct rte_device,
343*2d9fd380Sjfb8856606  *  null value means for all devices.
344*2d9fd380Sjfb8856606  * @param cb_fn
345*2d9fd380Sjfb8856606  *  callback address.
346*2d9fd380Sjfb8856606  * @param cb_arg
347*2d9fd380Sjfb8856606  *  address of parameter for callback.
348*2d9fd380Sjfb8856606  *
349*2d9fd380Sjfb8856606  * @return
350*2d9fd380Sjfb8856606  *  - On success, zero.
351*2d9fd380Sjfb8856606  *  - On failure, a negative value.
352*2d9fd380Sjfb8856606  */
353*2d9fd380Sjfb8856606 __rte_experimental
354*2d9fd380Sjfb8856606 int
355*2d9fd380Sjfb8856606 rte_dev_event_callback_register(const char *device_name,
356*2d9fd380Sjfb8856606 				rte_dev_event_cb_fn cb_fn,
357*2d9fd380Sjfb8856606 				void *cb_arg);
358*2d9fd380Sjfb8856606 
359*2d9fd380Sjfb8856606 /**
360*2d9fd380Sjfb8856606  * @warning
361*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice
362*2d9fd380Sjfb8856606  *
363*2d9fd380Sjfb8856606  * It unregisters the callback according to the specified device.
364*2d9fd380Sjfb8856606  *
365*2d9fd380Sjfb8856606  * @param device_name
366*2d9fd380Sjfb8856606  *  The device name, that is the param name of the struct rte_device,
367*2d9fd380Sjfb8856606  *  null value means for all devices and their callbacks.
368*2d9fd380Sjfb8856606  * @param cb_fn
369*2d9fd380Sjfb8856606  *  callback address.
370*2d9fd380Sjfb8856606  * @param cb_arg
371*2d9fd380Sjfb8856606  *  address of parameter for callback, (void *)-1 means to remove all
372*2d9fd380Sjfb8856606  *  registered which has the same callback address.
373*2d9fd380Sjfb8856606  *
374*2d9fd380Sjfb8856606  * @return
375*2d9fd380Sjfb8856606  *  - On success, return the number of callback entities removed.
376*2d9fd380Sjfb8856606  *  - On failure, a negative value.
377*2d9fd380Sjfb8856606  */
378*2d9fd380Sjfb8856606 __rte_experimental
379*2d9fd380Sjfb8856606 int
380*2d9fd380Sjfb8856606 rte_dev_event_callback_unregister(const char *device_name,
381*2d9fd380Sjfb8856606 				  rte_dev_event_cb_fn cb_fn,
382*2d9fd380Sjfb8856606 				  void *cb_arg);
383*2d9fd380Sjfb8856606 
384*2d9fd380Sjfb8856606 /**
385*2d9fd380Sjfb8856606  * @warning
386*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice
387*2d9fd380Sjfb8856606  *
388*2d9fd380Sjfb8856606  * Executes all the user application registered callbacks for
389*2d9fd380Sjfb8856606  * the specific device.
390*2d9fd380Sjfb8856606  *
391*2d9fd380Sjfb8856606  * @param device_name
392*2d9fd380Sjfb8856606  *  The device name.
393*2d9fd380Sjfb8856606  * @param event
394*2d9fd380Sjfb8856606  *  the device event type.
395*2d9fd380Sjfb8856606  */
396*2d9fd380Sjfb8856606 __rte_experimental
397*2d9fd380Sjfb8856606 void
398*2d9fd380Sjfb8856606 rte_dev_event_callback_process(const char *device_name,
399*2d9fd380Sjfb8856606 			       enum rte_dev_event_type event);
400*2d9fd380Sjfb8856606 
401*2d9fd380Sjfb8856606 /**
402*2d9fd380Sjfb8856606  * @warning
403*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice
404*2d9fd380Sjfb8856606  *
405*2d9fd380Sjfb8856606  * Start the device event monitoring.
406*2d9fd380Sjfb8856606  *
407*2d9fd380Sjfb8856606  * @return
408*2d9fd380Sjfb8856606  *   - On success, zero.
409*2d9fd380Sjfb8856606  *   - On failure, a negative value.
410*2d9fd380Sjfb8856606  */
411*2d9fd380Sjfb8856606 __rte_experimental
412*2d9fd380Sjfb8856606 int
413*2d9fd380Sjfb8856606 rte_dev_event_monitor_start(void);
414*2d9fd380Sjfb8856606 
415*2d9fd380Sjfb8856606 /**
416*2d9fd380Sjfb8856606  * @warning
417*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice
418*2d9fd380Sjfb8856606  *
419*2d9fd380Sjfb8856606  * Stop the device event monitoring.
420*2d9fd380Sjfb8856606  *
421*2d9fd380Sjfb8856606  * @return
422*2d9fd380Sjfb8856606  *   - On success, zero.
423*2d9fd380Sjfb8856606  *   - On failure, a negative value.
424*2d9fd380Sjfb8856606  */
425*2d9fd380Sjfb8856606 __rte_experimental
426*2d9fd380Sjfb8856606 int
427*2d9fd380Sjfb8856606 rte_dev_event_monitor_stop(void);
428*2d9fd380Sjfb8856606 
429*2d9fd380Sjfb8856606 /**
430*2d9fd380Sjfb8856606  * @warning
431*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice
432*2d9fd380Sjfb8856606  *
433*2d9fd380Sjfb8856606  * Enable hotplug handling for devices.
434*2d9fd380Sjfb8856606  *
435*2d9fd380Sjfb8856606  * @return
436*2d9fd380Sjfb8856606  *   - On success, zero.
437*2d9fd380Sjfb8856606  *   - On failure, a negative value.
438*2d9fd380Sjfb8856606  */
439*2d9fd380Sjfb8856606 __rte_experimental
440*2d9fd380Sjfb8856606 int
441*2d9fd380Sjfb8856606 rte_dev_hotplug_handle_enable(void);
442*2d9fd380Sjfb8856606 
443*2d9fd380Sjfb8856606 /**
444*2d9fd380Sjfb8856606  * @warning
445*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice
446*2d9fd380Sjfb8856606  *
447*2d9fd380Sjfb8856606  * Disable hotplug handling for devices.
448*2d9fd380Sjfb8856606  *
449*2d9fd380Sjfb8856606  * @return
450*2d9fd380Sjfb8856606  *   - On success, zero.
451*2d9fd380Sjfb8856606  *   - On failure, a negative value.
452*2d9fd380Sjfb8856606  */
453*2d9fd380Sjfb8856606 __rte_experimental
454*2d9fd380Sjfb8856606 int
455*2d9fd380Sjfb8856606 rte_dev_hotplug_handle_disable(void);
456*2d9fd380Sjfb8856606 
457*2d9fd380Sjfb8856606 /**
458*2d9fd380Sjfb8856606  * Device level DMA map function.
459*2d9fd380Sjfb8856606  * After a successful call, the memory segment will be mapped to the
460*2d9fd380Sjfb8856606  * given device.
461*2d9fd380Sjfb8856606  *
462*2d9fd380Sjfb8856606  * @note: Memory must be registered in advance using rte_extmem_* APIs.
463*2d9fd380Sjfb8856606  *
464*2d9fd380Sjfb8856606  * @param dev
465*2d9fd380Sjfb8856606  *	Device pointer.
466*2d9fd380Sjfb8856606  * @param addr
467*2d9fd380Sjfb8856606  *	Virtual address to map.
468*2d9fd380Sjfb8856606  * @param iova
469*2d9fd380Sjfb8856606  *	IOVA address to map.
470*2d9fd380Sjfb8856606  * @param len
471*2d9fd380Sjfb8856606  *	Length of the memory segment being mapped.
472*2d9fd380Sjfb8856606  *
473*2d9fd380Sjfb8856606  * @return
474*2d9fd380Sjfb8856606  *	0 if mapping was successful.
475*2d9fd380Sjfb8856606  *	Negative value and rte_errno is set otherwise.
476*2d9fd380Sjfb8856606  */
477*2d9fd380Sjfb8856606 __rte_experimental
478*2d9fd380Sjfb8856606 int
479*2d9fd380Sjfb8856606 rte_dev_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len);
480*2d9fd380Sjfb8856606 
481*2d9fd380Sjfb8856606 /**
482*2d9fd380Sjfb8856606  * Device level DMA unmap function.
483*2d9fd380Sjfb8856606  * After a successful call, the memory segment will no longer be
484*2d9fd380Sjfb8856606  * accessible by the given device.
485*2d9fd380Sjfb8856606  *
486*2d9fd380Sjfb8856606  * @note: Memory must be registered in advance using rte_extmem_* APIs.
487*2d9fd380Sjfb8856606  *
488*2d9fd380Sjfb8856606  * @param dev
489*2d9fd380Sjfb8856606  *	Device pointer.
490*2d9fd380Sjfb8856606  * @param addr
491*2d9fd380Sjfb8856606  *	Virtual address to unmap.
492*2d9fd380Sjfb8856606  * @param iova
493*2d9fd380Sjfb8856606  *	IOVA address to unmap.
494*2d9fd380Sjfb8856606  * @param len
495*2d9fd380Sjfb8856606  *	Length of the memory segment being mapped.
496*2d9fd380Sjfb8856606  *
497*2d9fd380Sjfb8856606  * @return
498*2d9fd380Sjfb8856606  *	0 if un-mapping was successful.
499*2d9fd380Sjfb8856606  *	Negative value and rte_errno is set otherwise.
500*2d9fd380Sjfb8856606  */
501*2d9fd380Sjfb8856606 __rte_experimental
502*2d9fd380Sjfb8856606 int
503*2d9fd380Sjfb8856606 rte_dev_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova,
504*2d9fd380Sjfb8856606 		  size_t len);
505*2d9fd380Sjfb8856606 
506*2d9fd380Sjfb8856606 #endif /* _RTE_DEV_H_ */
507