xref: /dpdk/lib/eal/include/rte_dev.h (revision 28c5d600)
199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
299a2dd95SBruce Richardson  * Copyright(c) 2014 6WIND S.A.
399a2dd95SBruce Richardson  */
499a2dd95SBruce Richardson 
599a2dd95SBruce Richardson #ifndef _RTE_DEV_H_
699a2dd95SBruce Richardson #define _RTE_DEV_H_
799a2dd95SBruce Richardson 
899a2dd95SBruce Richardson /**
999a2dd95SBruce Richardson  * @file
1099a2dd95SBruce Richardson  *
11f8dbaebbSSean Morrissey  * RTE PMD Registration Interface
1299a2dd95SBruce Richardson  *
1399a2dd95SBruce Richardson  * This file manages the list of device drivers.
1499a2dd95SBruce Richardson  */
1599a2dd95SBruce Richardson 
1699a2dd95SBruce Richardson #ifdef __cplusplus
1799a2dd95SBruce Richardson extern "C" {
1899a2dd95SBruce Richardson #endif
1999a2dd95SBruce Richardson 
2099a2dd95SBruce Richardson #include <stdio.h>
2199a2dd95SBruce Richardson 
2299a2dd95SBruce Richardson #include <rte_config.h>
2399a2dd95SBruce Richardson #include <rte_compat.h>
2499a2dd95SBruce Richardson #include <rte_log.h>
2599a2dd95SBruce Richardson 
2699a2dd95SBruce Richardson /**
2799a2dd95SBruce Richardson  * The device event type.
2899a2dd95SBruce Richardson  */
2999a2dd95SBruce Richardson enum rte_dev_event_type {
3099a2dd95SBruce Richardson 	RTE_DEV_EVENT_ADD,	/**< device being added */
3199a2dd95SBruce Richardson 	RTE_DEV_EVENT_REMOVE,	/**< device being removed */
3299a2dd95SBruce Richardson 	RTE_DEV_EVENT_MAX	/**< max value of this enum */
3399a2dd95SBruce Richardson };
3499a2dd95SBruce Richardson 
3599a2dd95SBruce Richardson typedef void (*rte_dev_event_cb_fn)(const char *device_name,
3699a2dd95SBruce Richardson 					enum rte_dev_event_type event,
3799a2dd95SBruce Richardson 					void *cb_arg);
3899a2dd95SBruce Richardson 
3999a2dd95SBruce Richardson /* Macros to check for invalid function pointers */
4099a2dd95SBruce Richardson #define RTE_FUNC_PTR_OR_ERR_RET(func, retval) do { \
4199a2dd95SBruce Richardson 	if ((func) == NULL) \
4299a2dd95SBruce Richardson 		return retval; \
4399a2dd95SBruce Richardson } while (0)
4499a2dd95SBruce Richardson 
4599a2dd95SBruce Richardson #define RTE_FUNC_PTR_OR_RET(func) do { \
4699a2dd95SBruce Richardson 	if ((func) == NULL) \
4799a2dd95SBruce Richardson 		return; \
4899a2dd95SBruce Richardson } while (0)
4999a2dd95SBruce Richardson 
5099a2dd95SBruce Richardson /**
5199a2dd95SBruce Richardson  * Device policies.
5299a2dd95SBruce Richardson  */
5399a2dd95SBruce Richardson enum rte_dev_policy {
5499a2dd95SBruce Richardson 	RTE_DEV_ALLOWED,
5599a2dd95SBruce Richardson 	RTE_DEV_BLOCKED,
5699a2dd95SBruce Richardson };
5799a2dd95SBruce Richardson 
5899a2dd95SBruce Richardson /**
5999a2dd95SBruce Richardson  * A generic memory resource representation.
6099a2dd95SBruce Richardson  */
6199a2dd95SBruce Richardson struct rte_mem_resource {
6299a2dd95SBruce Richardson 	uint64_t phys_addr; /**< Physical address, 0 if not resource. */
6399a2dd95SBruce Richardson 	uint64_t len;       /**< Length of the resource. */
6499a2dd95SBruce Richardson 	void *addr;         /**< Virtual address, NULL when not mapped. */
6599a2dd95SBruce Richardson };
6699a2dd95SBruce Richardson 
6799a2dd95SBruce Richardson /**
6899a2dd95SBruce Richardson  * A structure describing a device driver.
6999a2dd95SBruce Richardson  */
7099a2dd95SBruce Richardson struct rte_driver {
71f1f6ebc0SWilliam Tu 	RTE_TAILQ_ENTRY(rte_driver) next; /**< Next in list. */
7299a2dd95SBruce Richardson 	const char *name;                   /**< Driver name. */
7399a2dd95SBruce Richardson 	const char *alias;              /**< Driver alias. */
7499a2dd95SBruce Richardson };
7599a2dd95SBruce Richardson 
7699a2dd95SBruce Richardson /*
7799a2dd95SBruce Richardson  * Internal identifier length
7899a2dd95SBruce Richardson  * Sufficiently large to allow for UUID or PCI address
7999a2dd95SBruce Richardson  */
8099a2dd95SBruce Richardson #define RTE_DEV_NAME_MAX_LEN 64
8199a2dd95SBruce Richardson 
8299a2dd95SBruce Richardson /**
8399a2dd95SBruce Richardson  * A structure describing a generic device.
8499a2dd95SBruce Richardson  */
8599a2dd95SBruce Richardson struct rte_device {
86f1f6ebc0SWilliam Tu 	RTE_TAILQ_ENTRY(rte_device) next; /**< Next device */
8799a2dd95SBruce Richardson 	const char *name;             /**< Device name */
8899a2dd95SBruce Richardson 	const struct rte_driver *driver; /**< Driver assigned after probing */
8999a2dd95SBruce Richardson 	const struct rte_bus *bus;    /**< Bus handle assigned on scan */
9099a2dd95SBruce Richardson 	int numa_node;                /**< NUMA node connection */
9199a2dd95SBruce Richardson 	struct rte_devargs *devargs;  /**< Arguments for latest probing */
9299a2dd95SBruce Richardson };
9399a2dd95SBruce Richardson 
9499a2dd95SBruce Richardson /**
9599a2dd95SBruce Richardson  * Query status of a device.
9699a2dd95SBruce Richardson  *
9799a2dd95SBruce Richardson  * @param dev
9899a2dd95SBruce Richardson  *   Generic device pointer.
9999a2dd95SBruce Richardson  * @return
10099a2dd95SBruce Richardson  *   (int)true if already probed successfully, 0 otherwise.
10199a2dd95SBruce Richardson  */
10299a2dd95SBruce Richardson int rte_dev_is_probed(const struct rte_device *dev);
10399a2dd95SBruce Richardson 
10499a2dd95SBruce Richardson /**
10599a2dd95SBruce Richardson  * Hotplug add a given device to a specific bus.
10699a2dd95SBruce Richardson  *
10799a2dd95SBruce Richardson  * In multi-process, it will request other processes to add the same device.
10899a2dd95SBruce Richardson  * A failure, in any process, will rollback the action
10999a2dd95SBruce Richardson  *
11099a2dd95SBruce Richardson  * @param busname
11199a2dd95SBruce Richardson  *   The bus name the device is added to.
11299a2dd95SBruce Richardson  * @param devname
11399a2dd95SBruce Richardson  *   The device name. Based on this device name, eal will identify a driver
11499a2dd95SBruce Richardson  *   capable of handling it and pass it to the driver probing function.
11599a2dd95SBruce Richardson  * @param drvargs
11699a2dd95SBruce Richardson  *   Device arguments to be passed to the driver.
11799a2dd95SBruce Richardson  * @return
11899a2dd95SBruce Richardson  *   0 on success, negative on error.
11999a2dd95SBruce Richardson  */
12099a2dd95SBruce Richardson int rte_eal_hotplug_add(const char *busname, const char *devname,
12199a2dd95SBruce Richardson 			const char *drvargs);
12299a2dd95SBruce Richardson 
12399a2dd95SBruce Richardson /**
12499a2dd95SBruce Richardson  * Add matching devices.
12599a2dd95SBruce Richardson  *
12699a2dd95SBruce Richardson  * In multi-process, it will request other processes to add the same device.
12799a2dd95SBruce Richardson  * A failure, in any process, will rollback the action
12899a2dd95SBruce Richardson  *
12999a2dd95SBruce Richardson  * @param devargs
13099a2dd95SBruce Richardson  *   Device arguments including bus, class and driver properties.
13199a2dd95SBruce Richardson  * @return
13299a2dd95SBruce Richardson  *   0 on success, negative on error.
13399a2dd95SBruce Richardson  */
13499a2dd95SBruce Richardson int rte_dev_probe(const char *devargs);
13599a2dd95SBruce Richardson 
13699a2dd95SBruce Richardson /**
13799a2dd95SBruce Richardson  * Hotplug remove a given device from a specific bus.
13899a2dd95SBruce Richardson  *
13999a2dd95SBruce Richardson  * In multi-process, it will request other processes to remove the same device.
14099a2dd95SBruce Richardson  * A failure, in any process, will rollback the action
14199a2dd95SBruce Richardson  *
14299a2dd95SBruce Richardson  * @param busname
14399a2dd95SBruce Richardson  *   The bus name the device is removed from.
14499a2dd95SBruce Richardson  * @param devname
14599a2dd95SBruce Richardson  *   The device name being removed.
14699a2dd95SBruce Richardson  * @return
14799a2dd95SBruce Richardson  *   0 on success, negative on error.
14899a2dd95SBruce Richardson  */
14999a2dd95SBruce Richardson int rte_eal_hotplug_remove(const char *busname, const char *devname);
15099a2dd95SBruce Richardson 
15199a2dd95SBruce Richardson /**
15299a2dd95SBruce Richardson  * Remove one device.
15399a2dd95SBruce Richardson  *
15499a2dd95SBruce Richardson  * In multi-process, it will request other processes to remove the same device.
15599a2dd95SBruce Richardson  * A failure, in any process, will rollback the action
15699a2dd95SBruce Richardson  *
15799a2dd95SBruce Richardson  * @param dev
15899a2dd95SBruce Richardson  *   Data structure of the device to remove.
15999a2dd95SBruce Richardson  * @return
16099a2dd95SBruce Richardson  *   0 on success, negative on error.
16199a2dd95SBruce Richardson  */
16299a2dd95SBruce Richardson int rte_dev_remove(struct rte_device *dev);
16399a2dd95SBruce Richardson 
16499a2dd95SBruce Richardson /**
16599a2dd95SBruce Richardson  * Device comparison function.
16699a2dd95SBruce Richardson  *
16799a2dd95SBruce Richardson  * This type of function is used to compare an rte_device with arbitrary
16899a2dd95SBruce Richardson  * data.
16999a2dd95SBruce Richardson  *
17099a2dd95SBruce Richardson  * @param dev
17199a2dd95SBruce Richardson  *   Device handle.
17299a2dd95SBruce Richardson  *
17399a2dd95SBruce Richardson  * @param data
17499a2dd95SBruce Richardson  *   Data to compare against. The type of this parameter is determined by
17599a2dd95SBruce Richardson  *   the kind of comparison performed by the function.
17699a2dd95SBruce Richardson  *
17799a2dd95SBruce Richardson  * @return
17899a2dd95SBruce Richardson  *   0 if the device matches the data.
17999a2dd95SBruce Richardson  *   !0 if the device does not match.
18099a2dd95SBruce Richardson  *   <0 if ordering is possible and the device is lower than the data.
18199a2dd95SBruce Richardson  *   >0 if ordering is possible and the device is greater than the data.
18299a2dd95SBruce Richardson  */
18399a2dd95SBruce Richardson typedef int (*rte_dev_cmp_t)(const struct rte_device *dev, const void *data);
18499a2dd95SBruce Richardson 
18599a2dd95SBruce Richardson #define RTE_PMD_EXPORT_NAME_ARRAY(n, idx) n##idx[]
18699a2dd95SBruce Richardson 
18799a2dd95SBruce Richardson #define RTE_PMD_EXPORT_NAME(name, idx) \
18899a2dd95SBruce Richardson static const char RTE_PMD_EXPORT_NAME_ARRAY(this_pmd_name, idx) \
18999a2dd95SBruce Richardson __rte_used = RTE_STR(name)
19099a2dd95SBruce Richardson 
19199a2dd95SBruce Richardson #define DRV_EXP_TAG(name, tag) __##name##_##tag
19299a2dd95SBruce Richardson 
19399a2dd95SBruce Richardson #define RTE_PMD_REGISTER_PCI_TABLE(name, table) \
19499a2dd95SBruce Richardson static const char DRV_EXP_TAG(name, pci_tbl_export)[] __rte_used = \
19599a2dd95SBruce Richardson RTE_STR(table)
19699a2dd95SBruce Richardson 
19799a2dd95SBruce Richardson #define RTE_PMD_REGISTER_PARAM_STRING(name, str) \
19899a2dd95SBruce Richardson static const char DRV_EXP_TAG(name, param_string_export)[] \
19999a2dd95SBruce Richardson __rte_used = str
20099a2dd95SBruce Richardson 
20199a2dd95SBruce Richardson /**
20299a2dd95SBruce Richardson  * Advertise the list of kernel modules required to run this driver
20399a2dd95SBruce Richardson  *
20499a2dd95SBruce Richardson  * This string lists the kernel modules required for the devices
20599a2dd95SBruce Richardson  * associated to a PMD. The format of each line of the string is:
20699a2dd95SBruce Richardson  * "<device-pattern> <kmod-expression>".
20799a2dd95SBruce Richardson  *
20899a2dd95SBruce Richardson  * The possible formats for the device pattern are:
20999a2dd95SBruce Richardson  *   "*"                     all devices supported by this driver
21099a2dd95SBruce Richardson  *   "pci:*"                 all PCI devices supported by this driver
21199a2dd95SBruce Richardson  *   "pci:v8086:d*:sv*:sd*"  all PCI devices supported by this driver
21299a2dd95SBruce Richardson  *                           whose vendor id is 0x8086.
21399a2dd95SBruce Richardson  *
21499a2dd95SBruce Richardson  * The format of the kernel modules list is a parenthesized expression
21599a2dd95SBruce Richardson  * containing logical-and (&) and logical-or (|).
21699a2dd95SBruce Richardson  *
21799a2dd95SBruce Richardson  * The device pattern and the kmod expression are separated by a space.
21899a2dd95SBruce Richardson  *
21999a2dd95SBruce Richardson  * Example:
22099a2dd95SBruce Richardson  * - "* igb_uio | uio_pci_generic | vfio"
22199a2dd95SBruce Richardson  */
22299a2dd95SBruce Richardson #define RTE_PMD_REGISTER_KMOD_DEP(name, str) \
22399a2dd95SBruce Richardson static const char DRV_EXP_TAG(name, kmod_dep_export)[] \
22499a2dd95SBruce Richardson __rte_used = str
22599a2dd95SBruce Richardson 
22699a2dd95SBruce Richardson /**
22799a2dd95SBruce Richardson  * Iteration context.
22899a2dd95SBruce Richardson  *
22999a2dd95SBruce Richardson  * This context carries over the current iteration state.
23099a2dd95SBruce Richardson  */
23199a2dd95SBruce Richardson struct rte_dev_iterator {
23299a2dd95SBruce Richardson 	const char *dev_str; /**< device string. */
23399a2dd95SBruce Richardson 	const char *bus_str; /**< bus-related part of device string. */
23499a2dd95SBruce Richardson 	const char *cls_str; /**< class-related part of device string. */
23599a2dd95SBruce Richardson 	struct rte_bus *bus; /**< bus handle. */
23699a2dd95SBruce Richardson 	struct rte_class *cls; /**< class handle. */
23799a2dd95SBruce Richardson 	struct rte_device *device; /**< current position. */
23899a2dd95SBruce Richardson 	void *class_device; /**< additional specialized context. */
23999a2dd95SBruce Richardson };
24099a2dd95SBruce Richardson 
24199a2dd95SBruce Richardson /**
24299a2dd95SBruce Richardson  * Device iteration function.
24399a2dd95SBruce Richardson  *
24499a2dd95SBruce Richardson  * Find the next device matching properties passed in parameters.
24599a2dd95SBruce Richardson  * The function takes an additional ``start`` parameter, that is
24699a2dd95SBruce Richardson  * used as starting context when relevant.
24799a2dd95SBruce Richardson  *
24899a2dd95SBruce Richardson  * The function returns the current element in the iteration.
24999a2dd95SBruce Richardson  * This return value will potentially be used as a start parameter
25099a2dd95SBruce Richardson  * in subsequent calls to the function.
25199a2dd95SBruce Richardson  *
25299a2dd95SBruce Richardson  * The additional iterator parameter is only there if a specific
25399a2dd95SBruce Richardson  * implementation needs additional context. It must not be modified by
25499a2dd95SBruce Richardson  * the iteration function itself.
25599a2dd95SBruce Richardson  *
25699a2dd95SBruce Richardson  * @param start
25799a2dd95SBruce Richardson  *   Starting iteration context.
25899a2dd95SBruce Richardson  *
25999a2dd95SBruce Richardson  * @param devstr
26099a2dd95SBruce Richardson  *   Device description string.
26199a2dd95SBruce Richardson  *
26299a2dd95SBruce Richardson  * @param it
26399a2dd95SBruce Richardson  *   Device iterator.
26499a2dd95SBruce Richardson  *
26599a2dd95SBruce Richardson  * @return
26699a2dd95SBruce Richardson  *   The address of the current element matching the device description
26799a2dd95SBruce Richardson  *   string.
26899a2dd95SBruce Richardson  */
26999a2dd95SBruce Richardson typedef void *(*rte_dev_iterate_t)(const void *start,
27099a2dd95SBruce Richardson 				   const char *devstr,
27199a2dd95SBruce Richardson 				   const struct rte_dev_iterator *it);
27299a2dd95SBruce Richardson 
27399a2dd95SBruce Richardson /**
27499a2dd95SBruce Richardson  * Initializes a device iterator.
27599a2dd95SBruce Richardson  *
27699a2dd95SBruce Richardson  * This iterator allows accessing a list of devices matching a criteria.
27799a2dd95SBruce Richardson  * The device matching is made among all buses and classes currently registered,
27899a2dd95SBruce Richardson  * filtered by the device description given as parameter.
27999a2dd95SBruce Richardson  *
28099a2dd95SBruce Richardson  * This function will not allocate any memory. It is safe to stop the
28199a2dd95SBruce Richardson  * iteration at any moment and let the iterator go out of context.
28299a2dd95SBruce Richardson  *
28399a2dd95SBruce Richardson  * @param it
28499a2dd95SBruce Richardson  *   Device iterator handle.
28599a2dd95SBruce Richardson  *
28699a2dd95SBruce Richardson  * @param str
28799a2dd95SBruce Richardson  *   Device description string.
28899a2dd95SBruce Richardson  *
28999a2dd95SBruce Richardson  * @return
29099a2dd95SBruce Richardson  *   0 on successful initialization.
29199a2dd95SBruce Richardson  *   <0 on error.
29299a2dd95SBruce Richardson  */
29399a2dd95SBruce Richardson __rte_experimental
29499a2dd95SBruce Richardson int
29599a2dd95SBruce Richardson rte_dev_iterator_init(struct rte_dev_iterator *it, const char *str);
29699a2dd95SBruce Richardson 
29799a2dd95SBruce Richardson /**
29899a2dd95SBruce Richardson  * Iterates on a device iterator.
29999a2dd95SBruce Richardson  *
30099a2dd95SBruce Richardson  * Generates a new rte_device handle corresponding to the next element
30199a2dd95SBruce Richardson  * in the list described in comprehension by the iterator.
30299a2dd95SBruce Richardson  *
30399a2dd95SBruce Richardson  * The next object is returned, and the iterator is updated.
30499a2dd95SBruce Richardson  *
30599a2dd95SBruce Richardson  * @param it
30699a2dd95SBruce Richardson  *   Device iterator handle.
30799a2dd95SBruce Richardson  *
30899a2dd95SBruce Richardson  * @return
30999a2dd95SBruce Richardson  *   An rte_device handle if found.
31099a2dd95SBruce Richardson  *   NULL if an error occurred (rte_errno is set).
31199a2dd95SBruce Richardson  *   NULL if no device could be found (rte_errno is not set).
31299a2dd95SBruce Richardson  */
31399a2dd95SBruce Richardson __rte_experimental
31499a2dd95SBruce Richardson struct rte_device *
31599a2dd95SBruce Richardson rte_dev_iterator_next(struct rte_dev_iterator *it);
31699a2dd95SBruce Richardson 
31799a2dd95SBruce Richardson #define RTE_DEV_FOREACH(dev, devstr, it) \
31899a2dd95SBruce Richardson 	for (rte_dev_iterator_init(it, devstr), \
31999a2dd95SBruce Richardson 	     dev = rte_dev_iterator_next(it); \
32099a2dd95SBruce Richardson 	     dev != NULL; \
32199a2dd95SBruce Richardson 	     dev = rte_dev_iterator_next(it))
32299a2dd95SBruce Richardson 
32399a2dd95SBruce Richardson /**
32499a2dd95SBruce Richardson  * @warning
32599a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice
32699a2dd95SBruce Richardson  *
32799a2dd95SBruce Richardson  * It registers the callback for the specific device.
32899a2dd95SBruce Richardson  * Multiple callbacks can be registered at the same time.
32999a2dd95SBruce Richardson  *
33099a2dd95SBruce Richardson  * @param device_name
33199a2dd95SBruce Richardson  *  The device name, that is the param name of the struct rte_device,
33299a2dd95SBruce Richardson  *  null value means for all devices.
33399a2dd95SBruce Richardson  * @param cb_fn
33499a2dd95SBruce Richardson  *  callback address.
33599a2dd95SBruce Richardson  * @param cb_arg
33699a2dd95SBruce Richardson  *  address of parameter for callback.
33799a2dd95SBruce Richardson  *
33899a2dd95SBruce Richardson  * @return
33999a2dd95SBruce Richardson  *  - On success, zero.
34099a2dd95SBruce Richardson  *  - On failure, a negative value.
34199a2dd95SBruce Richardson  */
34299a2dd95SBruce Richardson __rte_experimental
34399a2dd95SBruce Richardson int
34499a2dd95SBruce Richardson rte_dev_event_callback_register(const char *device_name,
34599a2dd95SBruce Richardson 				rte_dev_event_cb_fn cb_fn,
34699a2dd95SBruce Richardson 				void *cb_arg);
34799a2dd95SBruce Richardson 
34899a2dd95SBruce Richardson /**
34999a2dd95SBruce Richardson  * @warning
35099a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice
35199a2dd95SBruce Richardson  *
35299a2dd95SBruce Richardson  * It unregisters the callback according to the specified device.
35399a2dd95SBruce Richardson  *
35499a2dd95SBruce Richardson  * @param device_name
35599a2dd95SBruce Richardson  *  The device name, that is the param name of the struct rte_device,
35699a2dd95SBruce Richardson  *  null value means for all devices and their callbacks.
35799a2dd95SBruce Richardson  * @param cb_fn
35899a2dd95SBruce Richardson  *  callback address.
35999a2dd95SBruce Richardson  * @param cb_arg
36099a2dd95SBruce Richardson  *  address of parameter for callback, (void *)-1 means to remove all
36199a2dd95SBruce Richardson  *  registered which has the same callback address.
36299a2dd95SBruce Richardson  *
36399a2dd95SBruce Richardson  * @return
36499a2dd95SBruce Richardson  *  - On success, return the number of callback entities removed.
36599a2dd95SBruce Richardson  *  - On failure, a negative value.
36699a2dd95SBruce Richardson  */
36799a2dd95SBruce Richardson __rte_experimental
36899a2dd95SBruce Richardson int
36999a2dd95SBruce Richardson rte_dev_event_callback_unregister(const char *device_name,
37099a2dd95SBruce Richardson 				  rte_dev_event_cb_fn cb_fn,
37199a2dd95SBruce Richardson 				  void *cb_arg);
37299a2dd95SBruce Richardson 
37399a2dd95SBruce Richardson /**
37499a2dd95SBruce Richardson  * @warning
37599a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice
37699a2dd95SBruce Richardson  *
37799a2dd95SBruce Richardson  * Executes all the user application registered callbacks for
37899a2dd95SBruce Richardson  * the specific device.
37999a2dd95SBruce Richardson  *
38099a2dd95SBruce Richardson  * @param device_name
38199a2dd95SBruce Richardson  *  The device name.
38299a2dd95SBruce Richardson  * @param event
38399a2dd95SBruce Richardson  *  the device event type.
38499a2dd95SBruce Richardson  */
38599a2dd95SBruce Richardson __rte_experimental
38699a2dd95SBruce Richardson void
38799a2dd95SBruce Richardson rte_dev_event_callback_process(const char *device_name,
38899a2dd95SBruce Richardson 			       enum rte_dev_event_type event);
38999a2dd95SBruce Richardson 
39099a2dd95SBruce Richardson /**
39199a2dd95SBruce Richardson  * @warning
39299a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice
39399a2dd95SBruce Richardson  *
39499a2dd95SBruce Richardson  * Start the device event monitoring.
39599a2dd95SBruce Richardson  *
39699a2dd95SBruce Richardson  * @return
39799a2dd95SBruce Richardson  *   - On success, zero.
39899a2dd95SBruce Richardson  *   - On failure, a negative value.
39999a2dd95SBruce Richardson  */
40099a2dd95SBruce Richardson __rte_experimental
40199a2dd95SBruce Richardson int
40299a2dd95SBruce Richardson rte_dev_event_monitor_start(void);
40399a2dd95SBruce Richardson 
40499a2dd95SBruce Richardson /**
40599a2dd95SBruce Richardson  * @warning
40699a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice
40799a2dd95SBruce Richardson  *
40899a2dd95SBruce Richardson  * Stop the device event monitoring.
40999a2dd95SBruce Richardson  *
41099a2dd95SBruce Richardson  * @return
41199a2dd95SBruce Richardson  *   - On success, zero.
41299a2dd95SBruce Richardson  *   - On failure, a negative value.
41399a2dd95SBruce Richardson  */
41499a2dd95SBruce Richardson __rte_experimental
41599a2dd95SBruce Richardson int
41699a2dd95SBruce Richardson rte_dev_event_monitor_stop(void);
41799a2dd95SBruce Richardson 
41899a2dd95SBruce Richardson /**
41999a2dd95SBruce Richardson  * @warning
42099a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice
42199a2dd95SBruce Richardson  *
42299a2dd95SBruce Richardson  * Enable hotplug handling for devices.
42399a2dd95SBruce Richardson  *
42499a2dd95SBruce Richardson  * @return
42599a2dd95SBruce Richardson  *   - On success, zero.
42699a2dd95SBruce Richardson  *   - On failure, a negative value.
42799a2dd95SBruce Richardson  */
42899a2dd95SBruce Richardson __rte_experimental
42999a2dd95SBruce Richardson int
43099a2dd95SBruce Richardson rte_dev_hotplug_handle_enable(void);
43199a2dd95SBruce Richardson 
43299a2dd95SBruce Richardson /**
43399a2dd95SBruce Richardson  * @warning
43499a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice
43599a2dd95SBruce Richardson  *
43699a2dd95SBruce Richardson  * Disable hotplug handling for devices.
43799a2dd95SBruce Richardson  *
43899a2dd95SBruce Richardson  * @return
43999a2dd95SBruce Richardson  *   - On success, zero.
44099a2dd95SBruce Richardson  *   - On failure, a negative value.
44199a2dd95SBruce Richardson  */
44299a2dd95SBruce Richardson __rte_experimental
44399a2dd95SBruce Richardson int
44499a2dd95SBruce Richardson rte_dev_hotplug_handle_disable(void);
44599a2dd95SBruce Richardson 
44699a2dd95SBruce Richardson /**
44799a2dd95SBruce Richardson  * Device level DMA map function.
44899a2dd95SBruce Richardson  * After a successful call, the memory segment will be mapped to the
44999a2dd95SBruce Richardson  * given device.
45099a2dd95SBruce Richardson  *
45199a2dd95SBruce Richardson  * @note: Memory must be registered in advance using rte_extmem_* APIs.
45299a2dd95SBruce Richardson  *
45399a2dd95SBruce Richardson  * @param dev
45499a2dd95SBruce Richardson  *	Device pointer.
45599a2dd95SBruce Richardson  * @param addr
45699a2dd95SBruce Richardson  *	Virtual address to map.
45799a2dd95SBruce Richardson  * @param iova
45899a2dd95SBruce Richardson  *	IOVA address to map.
45999a2dd95SBruce Richardson  * @param len
46099a2dd95SBruce Richardson  *	Length of the memory segment being mapped.
46199a2dd95SBruce Richardson  *
46299a2dd95SBruce Richardson  * @return
46399a2dd95SBruce Richardson  *	0 if mapping was successful.
46499a2dd95SBruce Richardson  *	Negative value and rte_errno is set otherwise.
46599a2dd95SBruce Richardson  */
46699a2dd95SBruce Richardson __rte_experimental
46799a2dd95SBruce Richardson int
46899a2dd95SBruce Richardson rte_dev_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len);
46999a2dd95SBruce Richardson 
47099a2dd95SBruce Richardson /**
47199a2dd95SBruce Richardson  * Device level DMA unmap function.
47299a2dd95SBruce Richardson  * After a successful call, the memory segment will no longer be
47399a2dd95SBruce Richardson  * accessible by the given device.
47499a2dd95SBruce Richardson  *
47599a2dd95SBruce Richardson  * @note: Memory must be registered in advance using rte_extmem_* APIs.
47699a2dd95SBruce Richardson  *
47799a2dd95SBruce Richardson  * @param dev
47899a2dd95SBruce Richardson  *	Device pointer.
47999a2dd95SBruce Richardson  * @param addr
48099a2dd95SBruce Richardson  *	Virtual address to unmap.
48199a2dd95SBruce Richardson  * @param iova
48299a2dd95SBruce Richardson  *	IOVA address to unmap.
48399a2dd95SBruce Richardson  * @param len
48499a2dd95SBruce Richardson  *	Length of the memory segment being mapped.
48599a2dd95SBruce Richardson  *
48699a2dd95SBruce Richardson  * @return
48799a2dd95SBruce Richardson  *	0 if un-mapping was successful.
48899a2dd95SBruce Richardson  *	Negative value and rte_errno is set otherwise.
48999a2dd95SBruce Richardson  */
49099a2dd95SBruce Richardson __rte_experimental
49199a2dd95SBruce Richardson int
49299a2dd95SBruce Richardson rte_dev_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova,
49399a2dd95SBruce Richardson 		  size_t len);
49499a2dd95SBruce Richardson 
495*28c5d600STianhao Chai #ifdef __cplusplus
496*28c5d600STianhao Chai }
497*28c5d600STianhao Chai #endif
498*28c5d600STianhao Chai 
49999a2dd95SBruce Richardson #endif /* _RTE_DEV_H_ */
500