1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation
11 * EAL Configuration API
17 #include <rte_config.h>
18 #include <rte_per_lcore.h>
21 #include <rte_pci_dev_feature_defs.h>
27 #define RTE_MAGIC 19820526 /**< Magic number written by the main partition when ready. */
29 /* Maximum thread_name length. */
30 #define RTE_MAX_THREAD_NAME_LEN 16
33 * The lcore role (used in RTE or not).
35 enum rte_lcore_role_t {
42 * The type of process in a linuxapp, multi-process setup
44 enum rte_proc_type_t {
45 RTE_PROC_AUTO = -1, /* allow auto-detection of primary/secondary */
46 RTE_PROC_PRIMARY = 0, /* set to zero, so primary is the default */
53 * The global RTE configuration structure.
56 uint32_t master_lcore; /**< Id of the master lcore */
57 uint32_t lcore_count; /**< Number of available logical cores. */
58 uint32_t service_lcore_count;/**< Number of available service cores. */
59 enum rte_lcore_role_t lcore_role[RTE_MAX_LCORE]; /**< State of cores. */
61 /** Primary or secondary configuration */
62 enum rte_proc_type_t process_type;
64 /** PA or VA mapping mode */
65 enum rte_iova_mode iova_mode;
68 * Pointer to memory configuration, which may be shared across multiple
71 struct rte_mem_config *mem_config;
72 } __attribute__((__packed__));
75 * Get the global configuration structure.
78 * A pointer to the global configuration structure.
80 struct rte_config *rte_eal_get_configuration(void);
86 * The identifier of the lcore.
88 * The role of the lcore.
90 enum rte_lcore_role_t rte_eal_lcore_role(unsigned lcore_id);
94 * Get the process type in a multi-process setup
99 enum rte_proc_type_t rte_eal_process_type(void);
102 * Request iopl privilege for all RPL.
104 * This function should be called by pmds which need access to ioports.
107 * - On success, returns 0.
108 * - On failure, returns -1.
110 int rte_eal_iopl_init(void);
113 * Initialize the Environment Abstraction Layer (EAL).
115 * This function is to be executed on the MASTER lcore only, as soon
116 * as possible in the application's main() function.
118 * The function finishes the initialization process before main() is called.
119 * It puts the SLAVE lcores in the WAIT state.
121 * When the multi-partition feature is supported, depending on the
122 * configuration (if CONFIG_RTE_EAL_MAIN_PARTITION is disabled), this
123 * function waits to ensure that the magic number is set before
124 * returning. See also the rte_eal_get_configuration() function. Note:
125 * This behavior may change in the future.
128 * A non-negative value. If it is greater than 0, the array members
129 * for argv[0] through argv[argc] (non-inclusive) shall contain pointers
132 * An array of strings. The contents of the array, as well as the strings
133 * which are pointed to by the array, may be modified by this function.
135 * - On success, the number of parsed arguments, which is greater or
136 * equal to zero. After the call to rte_eal_init(),
137 * all arguments argv[x] with x < ret may have been modified by this
138 * function call and should not be further interpreted by the
139 * application. The EAL does not take any ownership of the memory used
140 * for either the argv array, or its members.
141 * - On failure, -1 and rte_errno is set to a value indicating the cause
142 * for failure. In some instances, the application will need to be
143 * restarted as part of clearing the issue.
145 * Error codes returned via rte_errno:
146 * EACCES indicates a permissions issue.
148 * EAGAIN indicates either a bus or system resource was not available,
149 * setup may be attempted again.
151 * EALREADY indicates that the rte_eal_init function has already been
152 * called, and cannot be called again.
154 * EFAULT indicates the tailq configuration name was not found in
155 * memory configuration.
157 * EINVAL indicates invalid parameters were passed as argv/argc.
159 * ENOMEM indicates failure likely caused by an out-of-memory condition.
161 * ENODEV indicates memory setup issues.
163 * ENOTSUP indicates that the EAL cannot initialize on this system.
165 * EPROTO indicates that the PCI bus is either not present, or is not
166 * readable by the eal.
168 * ENOEXEC indicates that a service core failed to launch successfully.
170 int rte_eal_init(int argc, char **argv);
173 * Check if a primary process is currently alive
175 * This function returns true when a primary process is currently
178 * @param config_file_path
179 * The config_file_path argument provided should point at the location
180 * that the primary process will create its config file. If NULL, the default
181 * config file path is used.
184 * - If alive, returns 1.
185 * - If dead, returns 0.
187 int rte_eal_primary_proc_alive(const char *config_file_path);
190 * Usage function typedef used by the application usage function.
192 * Use this function typedef to define and call rte_set_application_usage_hook()
195 typedef void (*rte_usage_hook_t)(const char * prgname);
198 * Add application usage routine callout from the eal_usage() routine.
200 * This function allows the application to include its usage message
201 * in the EAL system usage message. The routine rte_set_application_usage_hook()
202 * needs to be called before the rte_eal_init() routine in the application.
204 * This routine is optional for the application and will behave as if the set
205 * routine was never called as the default behavior.
208 * The func argument is a function pointer to the application usage routine.
209 * Called function is defined using rte_usage_hook_t typedef, which is of
210 * the form void rte_usage_func(const char * prgname).
212 * Calling this routine with a NULL value will reset the usage hook routine and
213 * return the current value, which could be NULL.
215 * - Returns the current value of the rte_application_usage pointer to allow
216 * the caller to daisy chain the usage routines if needing more then one.
219 rte_set_application_usage_hook(rte_usage_hook_t usage_func);
222 * macro to get the lock of tailq in mem_config
224 #define RTE_EAL_TAILQ_RWLOCK (&rte_eal_get_configuration()->mem_config->qlock)
227 * macro to get the multiple lock of mempool shared by mutiple-instance
229 #define RTE_EAL_MEMPOOL_RWLOCK (&rte_eal_get_configuration()->mem_config->mplock)
232 * Whether EAL is using huge pages (disabled by --no-huge option).
233 * The no-huge mode cannot be used with UIO poll-mode drivers like igb/ixgbe.
234 * It is useful for NIC drivers (e.g. librte_pmd_mlx4, librte_pmd_vmxnet3) or
235 * crypto drivers (e.g. librte_crypto_nitrox) provided by third-parties such
239 * Nonzero if hugepages are enabled.
241 int rte_eal_has_hugepages(void);
244 * Whether EAL is using PCI bus.
245 * Disabled by --no-pci option.
248 * Nonzero if the PCI bus is enabled.
250 int rte_eal_has_pci(void);
253 * Whether the EAL was asked to create UIO device.
258 int rte_eal_create_uio_dev(void);
261 * The user-configured vfio interrupt mode.
264 * Interrupt mode configured with the command line,
265 * RTE_INTR_MODE_NONE by default.
267 enum rte_intr_mode rte_eal_vfio_intr_mode(void);
270 * A wrap API for syscall gettid.
273 * On success, returns the thread ID of calling process.
274 * It is always successful.
276 int rte_sys_gettid(void);
279 * Get system unique thread id.
282 * On success, returns the thread ID of calling process.
283 * It is always successful.
285 static inline int rte_gettid(void)
287 static RTE_DEFINE_PER_LCORE(int, _thread_id) = -1;
288 if (RTE_PER_LCORE(_thread_id) == -1)
289 RTE_PER_LCORE(_thread_id) = rte_sys_gettid();
290 return RTE_PER_LCORE(_thread_id);
297 * enum rte_iova_mode value.
299 enum rte_iova_mode rte_eal_iova_mode(void);
302 * Get default pool ops name for mbuf
305 * returns default pool ops name.
308 rte_eal_mbuf_default_mempool_ops(void);
314 #endif /* _RTE_EAL_H_ */