1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation
11 * EAL Configuration API
17 #include <rte_per_lcore.h>
20 #include <rte_pci_dev_feature_defs.h>
26 #define RTE_MAGIC 19820526 /**< Magic number written by the main partition when ready. */
28 /* Maximum thread_name length. */
29 #define RTE_MAX_THREAD_NAME_LEN 16
32 * The lcore role (used in RTE or not).
34 enum rte_lcore_role_t {
41 * The type of process in a linuxapp, multi-process setup
43 enum rte_proc_type_t {
44 RTE_PROC_AUTO = -1, /* allow auto-detection of primary/secondary */
45 RTE_PROC_PRIMARY = 0, /* set to zero, so primary is the default */
52 * The global RTE configuration structure.
55 uint32_t master_lcore; /**< Id of the master lcore */
56 uint32_t lcore_count; /**< Number of available logical cores. */
57 uint32_t service_lcore_count;/**< Number of available service cores. */
58 enum rte_lcore_role_t lcore_role[RTE_MAX_LCORE]; /**< State of cores. */
60 /** Primary or secondary configuration */
61 enum rte_proc_type_t process_type;
63 /** PA or VA mapping mode */
64 enum rte_iova_mode iova_mode;
67 * Pointer to memory configuration, which may be shared across multiple
70 struct rte_mem_config *mem_config;
71 } __attribute__((__packed__));
74 * Get the global configuration structure.
77 * A pointer to the global configuration structure.
79 struct rte_config *rte_eal_get_configuration(void);
85 * The identifier of the lcore.
87 * The role of the lcore.
89 enum rte_lcore_role_t rte_eal_lcore_role(unsigned lcore_id);
93 * Get the process type in a multi-process setup
98 enum rte_proc_type_t rte_eal_process_type(void);
101 * Request iopl privilege for all RPL.
103 * This function should be called by pmds which need access to ioports.
106 * - On success, returns 0.
107 * - On failure, returns -1.
109 int rte_eal_iopl_init(void);
112 * Initialize the Environment Abstraction Layer (EAL).
114 * This function is to be executed on the MASTER lcore only, as soon
115 * as possible in the application's main() function.
117 * The function finishes the initialization process before main() is called.
118 * It puts the SLAVE lcores in the WAIT state.
120 * When the multi-partition feature is supported, depending on the
121 * configuration (if CONFIG_RTE_EAL_MAIN_PARTITION is disabled), this
122 * function waits to ensure that the magic number is set before
123 * returning. See also the rte_eal_get_configuration() function. Note:
124 * This behavior may change in the future.
127 * A non-negative value. If it is greater than 0, the array members
128 * for argv[0] through argv[argc] (non-inclusive) shall contain pointers
131 * An array of strings. The contents of the array, as well as the strings
132 * which are pointed to by the array, may be modified by this function.
134 * - On success, the number of parsed arguments, which is greater or
135 * equal to zero. After the call to rte_eal_init(),
136 * all arguments argv[x] with x < ret may have been modified by this
137 * function call and should not be further interpreted by the
138 * application. The EAL does not take any ownership of the memory used
139 * for either the argv array, or its members.
140 * - On failure, -1 and rte_errno is set to a value indicating the cause
141 * for failure. In some instances, the application will need to be
142 * restarted as part of clearing the issue.
144 * Error codes returned via rte_errno:
145 * EACCES indicates a permissions issue.
147 * EAGAIN indicates either a bus or system resource was not available,
148 * setup may be attempted again.
150 * EALREADY indicates that the rte_eal_init function has already been
151 * called, and cannot be called again.
153 * EFAULT indicates the tailq configuration name was not found in
154 * memory configuration.
156 * EINVAL indicates invalid parameters were passed as argv/argc.
158 * ENOMEM indicates failure likely caused by an out-of-memory condition.
160 * ENODEV indicates memory setup issues.
162 * ENOTSUP indicates that the EAL cannot initialize on this system.
164 * EPROTO indicates that the PCI bus is either not present, or is not
165 * readable by the eal.
167 * ENOEXEC indicates that a service core failed to launch successfully.
169 int rte_eal_init(int argc, char **argv);
172 * Check if a primary process is currently alive
174 * This function returns true when a primary process is currently
177 * @param config_file_path
178 * The config_file_path argument provided should point at the location
179 * that the primary process will create its config file. If NULL, the default
180 * config file path is used.
183 * - If alive, returns 1.
184 * - If dead, returns 0.
186 int rte_eal_primary_proc_alive(const char *config_file_path);
189 * Usage function typedef used by the application usage function.
191 * Use this function typedef to define and call rte_set_application_usage_hook()
194 typedef void (*rte_usage_hook_t)(const char * prgname);
197 * Add application usage routine callout from the eal_usage() routine.
199 * This function allows the application to include its usage message
200 * in the EAL system usage message. The routine rte_set_application_usage_hook()
201 * needs to be called before the rte_eal_init() routine in the application.
203 * This routine is optional for the application and will behave as if the set
204 * routine was never called as the default behavior.
207 * The func argument is a function pointer to the application usage routine.
208 * Called function is defined using rte_usage_hook_t typedef, which is of
209 * the form void rte_usage_func(const char * prgname).
211 * Calling this routine with a NULL value will reset the usage hook routine and
212 * return the current value, which could be NULL.
214 * - Returns the current value of the rte_application_usage pointer to allow
215 * the caller to daisy chain the usage routines if needing more then one.
218 rte_set_application_usage_hook(rte_usage_hook_t usage_func);
221 * macro to get the lock of tailq in mem_config
223 #define RTE_EAL_TAILQ_RWLOCK (&rte_eal_get_configuration()->mem_config->qlock)
226 * macro to get the multiple lock of mempool shared by mutiple-instance
228 #define RTE_EAL_MEMPOOL_RWLOCK (&rte_eal_get_configuration()->mem_config->mplock)
231 * Whether EAL is using huge pages (disabled by --no-huge option).
232 * The no-huge mode cannot be used with UIO poll-mode drivers like igb/ixgbe.
233 * It is useful for NIC drivers (e.g. librte_pmd_mlx4, librte_pmd_vmxnet3) or
234 * crypto drivers (e.g. librte_crypto_nitrox) provided by third-parties such
238 * Nonzero if hugepages are enabled.
240 int rte_eal_has_hugepages(void);
243 * Whether EAL is using PCI bus.
244 * Disabled by --no-pci option.
247 * Nonzero if the PCI bus is enabled.
249 int rte_eal_has_pci(void);
252 * Whether the EAL was asked to create UIO device.
257 int rte_eal_create_uio_dev(void);
260 * The user-configured vfio interrupt mode.
263 * Interrupt mode configured with the command line,
264 * RTE_INTR_MODE_NONE by default.
266 enum rte_intr_mode rte_eal_vfio_intr_mode(void);
269 * A wrap API for syscall gettid.
272 * On success, returns the thread ID of calling process.
273 * It is always successful.
275 int rte_sys_gettid(void);
278 * Get system unique thread id.
281 * On success, returns the thread ID of calling process.
282 * It is always successful.
284 static inline int rte_gettid(void)
286 static RTE_DEFINE_PER_LCORE(int, _thread_id) = -1;
287 if (RTE_PER_LCORE(_thread_id) == -1)
288 RTE_PER_LCORE(_thread_id) = rte_sys_gettid();
289 return RTE_PER_LCORE(_thread_id);
296 * enum rte_iova_mode value.
298 enum rte_iova_mode rte_eal_iova_mode(void);
301 * Get default pool ops name for mbuf
304 * returns default pool ops name.
307 rte_eal_mbuf_default_mempool_ops(void);
313 #endif /* _RTE_EAL_H_ */