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 /** Bus handle for the device. */
56 /** Name of the device. */
57 char name[RTE_DEV_NAME_MAX_LEN];
58 /** Arguments string as given by user or "" for no argument. */
64 * Parse a devargs string.
66 * For PCI devices, the format of arguments string is "PCI_ADDR" or
67 * "PCI_ADDR,key=val,key2=val2,...". Examples: "08:00.1", "0000:5:00.0",
70 * For virtual devices, the format of arguments string is "DRIVER_NAME*"
71 * or "DRIVER_NAME*,key=val,key2=val2,...". Examples: "net_ring",
72 * "net_ring0", "net_pmdAnything,arg=0:arg2=1".
74 * The function parses the arguments string to get driver name and driver
78 * The arguments as given by the user.
80 * The pointer to the string to store parsed driver name.
82 * The pointer to the string to store parsed driver arguments.
86 * - A negative value on error
89 int rte_eal_parse_devargs_str(const char *devargs_str,
90 char **drvname, char **drvargs);
93 * Parse a device string.
95 * Verify that a bus is capable of handling the device passed
96 * in argument. Store which bus will handle the device, its name
97 * and the eventual device parameters.
99 * The device string is built with a printf-like syntax.
103 * bus:device_identifier,arg1=val1,arg2=val2
105 * where "bus:" is the bus name followed by any character separator.
106 * The bus name is optional. If no bus name is specified, each bus
107 * will attempt to recognize the device identifier. The first one
108 * to succeed will be used.
112 * pci:0000:05.00.0,arg=val
117 * The devargs structure holding the device information.
119 * Format string describing a device.
123 * - Negative errno on error.
127 rte_devargs_parse(struct rte_devargs *da,
128 const char *format, ...)
129 __attribute__((format(printf, 2, 0)));
132 * Insert an rte_devargs in the global list.
135 * The devargs structure to insert.
139 * - Negative on error.
143 rte_devargs_insert(struct rte_devargs *da);
146 * Add a device to the user device list
147 * See rte_devargs_parse() for details.
150 * The type of the device.
152 * The arguments as given by the user.
156 * - A negative value on error
159 int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str);
163 * Add a device to the user device list
164 * See rte_devargs_parse() for details.
167 * The type of the device.
169 * The arguments as given by the user.
173 * - A negative value on error
176 int rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str);
179 * Remove a device from the user device list.
180 * Its resources are freed.
181 * If the devargs cannot be found, nothing happens.
184 * bus name of the devargs to remove.
187 * device name of the devargs to remove.
192 * >0 if the devargs was not within the user device list.
195 int rte_devargs_remove(const char *busname,
196 const char *devname);
199 * Count the number of user devices of a specified type
202 * The type of the devices to counted.
205 * The number of devices.
209 rte_devargs_type_count(enum rte_devtype devtype);
213 * Count the number of user devices of a specified type
216 * The type of the devices to counted.
219 * The number of devices.
223 rte_eal_devargs_type_count(enum rte_devtype devtype);
226 * This function dumps the list of user device and their arguments.
229 * A pointer to a file for output
232 void rte_devargs_dump(FILE *f);
236 * This function dumps the list of user device and their arguments.
239 * A pointer to a file for output
242 void rte_eal_devargs_dump(FILE *f);
245 * Find next rte_devargs matching the provided bus name.
248 * Limit the iteration to devargs related to buses
249 * matching this name.
250 * Will return any next rte_devargs if NULL.
253 * Starting iteration point. The iteration will start at
254 * the first rte_devargs if NULL.
257 * Next rte_devargs entry matching the requested bus,
258 * NULL if there is none.
262 rte_devargs_next(const char *busname, const struct rte_devargs *start);
265 * Iterate over all rte_devargs for a specific bus.
267 #define RTE_EAL_DEVARGS_FOREACH(busname, da) \
268 for (da = rte_devargs_next(busname, NULL); \
270 da = rte_devargs_next(busname, da)) \
276 #endif /* _RTE_DEVARGS_H_ */