1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2014 6WIND S.A.
5 #ifndef _RTE_DEVARGS_H_
6 #define _RTE_DEVARGS_H_
11 * RTE devargs: list of devices and their user arguments
13 * This file stores a list of devices and their arguments given by
14 * the user when a DPDK application is started. These devices can be PCI
15 * devices or virtual devices. These devices are stored at startup in a
16 * list of rte_devargs structures.
24 #include <sys/queue.h>
25 #include <rte_compat.h>
29 * Type of generic device
37 /* Backwards compatibility will be removed later */
38 #define RTE_DEVTYPE_WHITELISTED_PCI \
39 RTE_DEPRECATED(RTE_DEVTYPE_WHITELISTED_PCI) RTE_DEVTYPE_ALLOWED
40 #define RTE_DEVTYPE_BLACKLISTED_PCI \
41 RTE_DEPRECATED(RTE_DEVTYPE_BLACKLISTED_PCI) RTE_DEVTYPE_BLOCKED
44 * Structure that stores a device given by the user with its arguments
46 * A user device is a physical or a virtual device given by the user to
47 * the DPDK application at startup through command line arguments.
49 * The structure stores the configuration of the device, its PCI
50 * identifier if it's a PCI device or the driver name if it's a virtual
55 TAILQ_ENTRY(rte_devargs) next;
56 /** Type of device. */
57 enum rte_devtype type;
59 enum rte_dev_policy policy;
60 /** Name of the device. */
61 char name[RTE_DEV_NAME_MAX_LEN];
64 const char *args; /**< legacy name. */
65 const char *drv_str; /**< driver-related part of device string. */
67 struct rte_bus *bus; /**< bus handle. */
68 struct rte_class *cls; /**< class handle. */
69 const char *bus_str; /**< bus-related part of device string. */
70 const char *cls_str; /**< class-related part of device string. */
71 char *data; /**< raw string including bus, class and driver parts. */
75 * Parse a device string.
77 * Verify that a bus is capable of handling the device passed
78 * in argument. Store which bus will handle the device, its name
79 * and the eventual device parameters.
83 * bus:device_identifier,arg1=val1,arg2=val2
85 * where "bus:" is the bus name followed by any character separator.
86 * The bus name is optional. If no bus name is specified, each bus
87 * will attempt to recognize the device identifier. The first one
88 * to succeed will be used.
92 * pci:0000:05.00.0,arg=val
97 * The devargs structure holding the device information.
100 * String describing a device.
104 * - Negative errno on error.
107 rte_devargs_parse(struct rte_devargs *da, const char *dev);
110 * Parse a device string.
112 * Verify that a bus is capable of handling the device passed
113 * in argument. Store which bus will handle the device, its name
114 * and the eventual device parameters.
116 * The device string is built with a printf-like syntax.
120 * bus:device_identifier,arg1=val1,arg2=val2
122 * where "bus:" is the bus name followed by any character separator.
123 * The bus name is optional. If no bus name is specified, each bus
124 * will attempt to recognize the device identifier. The first one
125 * to succeed will be used.
129 * pci:0000:05.00.0,arg=val
134 * The devargs structure holding the device information.
136 * Format string describing a device.
140 * - Negative errno on error.
143 rte_devargs_parsef(struct rte_devargs *da,
144 const char *format, ...)
145 __rte_format_printf(2, 0);
148 * Free resources in devargs.
151 * The devargs structure holding the device information.
155 rte_devargs_reset(struct rte_devargs *da);
158 * Insert an rte_devargs in the global list.
161 * The devargs structure to insert.
162 * If a devargs for the same device is already inserted,
163 * it will be updated and returned. It means *da pointer can change.
167 * - Negative on error.
170 rte_devargs_insert(struct rte_devargs **da);
173 * Add a device to the user device list
174 * See rte_devargs_parse() for details.
177 * The type of the device.
179 * The arguments as given by the user.
183 * - A negative value on error
185 int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str);
188 * Remove a device from the user device list.
189 * Its resources are freed.
190 * If the devargs cannot be found, nothing happens.
193 * The instance or a copy of devargs to remove.
198 * >0 if the devargs was not within the user device list.
200 int rte_devargs_remove(struct rte_devargs *devargs);
203 * Count the number of user devices of a specified type
206 * The type of the devices to counted.
209 * The number of devices.
212 rte_devargs_type_count(enum rte_devtype devtype);
215 * This function dumps the list of user device and their arguments.
218 * A pointer to a file for output
220 void rte_devargs_dump(FILE *f);
223 * Find next rte_devargs matching the provided bus name.
226 * Limit the iteration to devargs related to buses
227 * matching this name.
228 * Will return any next rte_devargs if NULL.
231 * Starting iteration point. The iteration will start at
232 * the first rte_devargs if NULL.
235 * Next rte_devargs entry matching the requested bus,
236 * NULL if there is none.
239 rte_devargs_next(const char *busname, const struct rte_devargs *start);
242 * Iterate over all rte_devargs for a specific bus.
244 #define RTE_EAL_DEVARGS_FOREACH(busname, da) \
245 for (da = rte_devargs_next(busname, NULL); \
247 da = rte_devargs_next(busname, da)) \
253 #endif /* _RTE_DEVARGS_H_ */