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
32 RTE_DEVTYPE_WHITELISTED_PCI,
33 RTE_DEVTYPE_BLACKLISTED_PCI,
38 * Structure that stores a device given by the user with its arguments
40 * A user device is a physical or a virtual device given by the user to
41 * the DPDK application at startup through command line arguments.
43 * The structure stores the configuration of the device, its PCI
44 * identifier if it's a PCI device or the driver name if it's a virtual
49 TAILQ_ENTRY(rte_devargs) next;
50 /** Type of device. */
51 enum rte_devtype type;
53 enum rte_dev_policy policy;
54 /** Name of the device. */
55 char name[RTE_DEV_NAME_MAX_LEN];
58 /** Arguments string as given by user or "" for no argument. */
62 struct rte_bus *bus; /**< bus handle. */
63 struct rte_class *cls; /**< class handle. */
64 const char *bus_str; /**< bus-related part of device string. */
65 const char *cls_str; /**< class-related part of device string. */
66 const char *data; /**< Device string storage. */
70 * Parse a device string.
72 * Verify that a bus is capable of handling the device passed
73 * in argument. Store which bus will handle the device, its name
74 * and the eventual device parameters.
78 * bus:device_identifier,arg1=val1,arg2=val2
80 * where "bus:" is the bus name followed by any character separator.
81 * The bus name is optional. If no bus name is specified, each bus
82 * will attempt to recognize the device identifier. The first one
83 * to succeed will be used.
87 * pci:0000:05.00.0,arg=val
92 * The devargs structure holding the device information.
95 * String describing a device.
99 * - Negative errno on error.
102 rte_devargs_parse(struct rte_devargs *da, const char *dev);
105 * Parse a device string.
107 * Verify that a bus is capable of handling the device passed
108 * in argument. Store which bus will handle the device, its name
109 * and the eventual device parameters.
111 * The device string is built with a printf-like syntax.
115 * bus:device_identifier,arg1=val1,arg2=val2
117 * where "bus:" is the bus name followed by any character separator.
118 * The bus name is optional. If no bus name is specified, each bus
119 * will attempt to recognize the device identifier. The first one
120 * to succeed will be used.
124 * pci:0000:05.00.0,arg=val
129 * The devargs structure holding the device information.
131 * Format string describing a device.
135 * - Negative errno on error.
138 rte_devargs_parsef(struct rte_devargs *da,
139 const char *format, ...)
140 __attribute__((format(printf, 2, 0)));
143 * Insert an rte_devargs in the global list.
146 * The devargs structure to insert.
147 * If a devargs for the same device is already inserted,
148 * it will be updated and returned. It means *da pointer can change.
152 * - Negative on error.
155 rte_devargs_insert(struct rte_devargs **da);
158 * Add a device to the user device list
159 * See rte_devargs_parse() for details.
162 * The type of the device.
164 * The arguments as given by the user.
168 * - A negative value on error
170 int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str);
173 * Remove a device from the user device list.
174 * Its resources are freed.
175 * If the devargs cannot be found, nothing happens.
178 * The instance or a copy of devargs to remove.
183 * >0 if the devargs was not within the user device list.
185 int rte_devargs_remove(struct rte_devargs *devargs);
188 * Count the number of user devices of a specified type
191 * The type of the devices to counted.
194 * The number of devices.
197 rte_devargs_type_count(enum rte_devtype devtype);
200 * This function dumps the list of user device and their arguments.
203 * A pointer to a file for output
205 void rte_devargs_dump(FILE *f);
208 * Find next rte_devargs matching the provided bus name.
211 * Limit the iteration to devargs related to buses
212 * matching this name.
213 * Will return any next rte_devargs if NULL.
216 * Starting iteration point. The iteration will start at
217 * the first rte_devargs if NULL.
220 * Next rte_devargs entry matching the requested bus,
221 * NULL if there is none.
224 rte_devargs_next(const char *busname, const struct rte_devargs *start);
227 * Iterate over all rte_devargs for a specific bus.
229 #define RTE_EAL_DEVARGS_FOREACH(busname, da) \
230 for (da = rte_devargs_next(busname, NULL); \
232 da = rte_devargs_next(busname, da)) \
238 #endif /* _RTE_DEVARGS_H_ */