199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause 299a2dd95SBruce Richardson * Copyright(c) 2010-2018 Intel Corporation 399a2dd95SBruce Richardson */ 499a2dd95SBruce Richardson 599a2dd95SBruce Richardson #ifndef _RTE_EAL_H_ 699a2dd95SBruce Richardson #define _RTE_EAL_H_ 799a2dd95SBruce Richardson 899a2dd95SBruce Richardson /** 999a2dd95SBruce Richardson * @file 1099a2dd95SBruce Richardson * 1199a2dd95SBruce Richardson * EAL Configuration API 1299a2dd95SBruce Richardson */ 1399a2dd95SBruce Richardson 1499a2dd95SBruce Richardson #include <stdint.h> 1599a2dd95SBruce Richardson #include <time.h> 1699a2dd95SBruce Richardson 1799a2dd95SBruce Richardson #include <rte_config.h> 1899a2dd95SBruce Richardson #include <rte_compat.h> 1999a2dd95SBruce Richardson #include <rte_per_lcore.h> 2099a2dd95SBruce Richardson #include <rte_uuid.h> 2199a2dd95SBruce Richardson 2299a2dd95SBruce Richardson #include <rte_pci_dev_feature_defs.h> 2399a2dd95SBruce Richardson 2499a2dd95SBruce Richardson #ifdef __cplusplus 2599a2dd95SBruce Richardson extern "C" { 2699a2dd95SBruce Richardson #endif 2799a2dd95SBruce Richardson 2899a2dd95SBruce Richardson #define RTE_MAGIC 19820526 /**< Magic number written by the main partition when ready. */ 2999a2dd95SBruce Richardson 3099a2dd95SBruce Richardson /** 3199a2dd95SBruce Richardson * The type of process in a linux, multi-process setup 3299a2dd95SBruce Richardson */ 3399a2dd95SBruce Richardson enum rte_proc_type_t { 3499a2dd95SBruce Richardson RTE_PROC_AUTO = -1, /* allow auto-detection of primary/secondary */ 3599a2dd95SBruce Richardson RTE_PROC_PRIMARY = 0, /* set to zero, so primary is the default */ 3699a2dd95SBruce Richardson RTE_PROC_SECONDARY, 3799a2dd95SBruce Richardson 3899a2dd95SBruce Richardson RTE_PROC_INVALID 3999a2dd95SBruce Richardson }; 4099a2dd95SBruce Richardson 4199a2dd95SBruce Richardson /** 4299a2dd95SBruce Richardson * Get the process type in a multi-process setup 4399a2dd95SBruce Richardson * 4499a2dd95SBruce Richardson * @return 4599a2dd95SBruce Richardson * The process type 4699a2dd95SBruce Richardson */ 4799a2dd95SBruce Richardson enum rte_proc_type_t rte_eal_process_type(void); 4899a2dd95SBruce Richardson 4999a2dd95SBruce Richardson /** 5099a2dd95SBruce Richardson * Request iopl privilege for all RPL. 5199a2dd95SBruce Richardson * 5299a2dd95SBruce Richardson * This function should be called by pmds which need access to ioports. 5399a2dd95SBruce Richardson 5499a2dd95SBruce Richardson * @return 5599a2dd95SBruce Richardson * - On success, returns 0. 5699a2dd95SBruce Richardson * - On failure, returns -1. 5799a2dd95SBruce Richardson */ 5899a2dd95SBruce Richardson int rte_eal_iopl_init(void); 5999a2dd95SBruce Richardson 6099a2dd95SBruce Richardson /** 6199a2dd95SBruce Richardson * Initialize the Environment Abstraction Layer (EAL). 6299a2dd95SBruce Richardson * 6399a2dd95SBruce Richardson * This function is to be executed on the MAIN lcore only, as soon 6499a2dd95SBruce Richardson * as possible in the application's main() function. 6599a2dd95SBruce Richardson * It puts the WORKER lcores in the WAIT state. 6699a2dd95SBruce Richardson * 6799a2dd95SBruce Richardson * @param argc 6899a2dd95SBruce Richardson * A non-negative value. If it is greater than 0, the array members 6999a2dd95SBruce Richardson * for argv[0] through argv[argc] (non-inclusive) shall contain pointers 7099a2dd95SBruce Richardson * to strings. 7199a2dd95SBruce Richardson * @param argv 7299a2dd95SBruce Richardson * An array of strings. The contents of the array, as well as the strings 7399a2dd95SBruce Richardson * which are pointed to by the array, may be modified by this function. 74cb1ef54eSThomas Monjalon * The program name pointer argv[0] is copied into the last parsed argv 75cb1ef54eSThomas Monjalon * so that argv[0] is still the same after deducing the parsed arguments. 7699a2dd95SBruce Richardson * @return 7799a2dd95SBruce Richardson * - On success, the number of parsed arguments, which is greater or 7899a2dd95SBruce Richardson * equal to zero. After the call to rte_eal_init(), 7999a2dd95SBruce Richardson * all arguments argv[x] with x < ret may have been modified by this 8099a2dd95SBruce Richardson * function call and should not be further interpreted by the 8199a2dd95SBruce Richardson * application. The EAL does not take any ownership of the memory used 8299a2dd95SBruce Richardson * for either the argv array, or its members. 8399a2dd95SBruce Richardson * - On failure, -1 and rte_errno is set to a value indicating the cause 8499a2dd95SBruce Richardson * for failure. In some instances, the application will need to be 8599a2dd95SBruce Richardson * restarted as part of clearing the issue. 8699a2dd95SBruce Richardson * 8799a2dd95SBruce Richardson * Error codes returned via rte_errno: 8899a2dd95SBruce Richardson * EACCES indicates a permissions issue. 8999a2dd95SBruce Richardson * 9099a2dd95SBruce Richardson * EAGAIN indicates either a bus or system resource was not available, 9199a2dd95SBruce Richardson * setup may be attempted again. 9299a2dd95SBruce Richardson * 9399a2dd95SBruce Richardson * EALREADY indicates that the rte_eal_init function has already been 9499a2dd95SBruce Richardson * called, and cannot be called again. 9599a2dd95SBruce Richardson * 9699a2dd95SBruce Richardson * EFAULT indicates the tailq configuration name was not found in 9799a2dd95SBruce Richardson * memory configuration. 9899a2dd95SBruce Richardson * 9999a2dd95SBruce Richardson * EINVAL indicates invalid parameters were passed as argv/argc. 10099a2dd95SBruce Richardson * 10199a2dd95SBruce Richardson * ENOMEM indicates failure likely caused by an out-of-memory condition. 10299a2dd95SBruce Richardson * 10399a2dd95SBruce Richardson * ENODEV indicates memory setup issues. 10499a2dd95SBruce Richardson * 10599a2dd95SBruce Richardson * ENOTSUP indicates that the EAL cannot initialize on this system. 10699a2dd95SBruce Richardson * 10799a2dd95SBruce Richardson * EPROTO indicates that the PCI bus is either not present, or is not 10899a2dd95SBruce Richardson * readable by the eal. 10999a2dd95SBruce Richardson * 11099a2dd95SBruce Richardson * ENOEXEC indicates that a service core failed to launch successfully. 11199a2dd95SBruce Richardson */ 11299a2dd95SBruce Richardson int rte_eal_init(int argc, char **argv); 11399a2dd95SBruce Richardson 11499a2dd95SBruce Richardson /** 11599a2dd95SBruce Richardson * Clean up the Environment Abstraction Layer (EAL) 11699a2dd95SBruce Richardson * 11799a2dd95SBruce Richardson * This function must be called to release any internal resources that EAL has 11899a2dd95SBruce Richardson * allocated during rte_eal_init(). After this call, no DPDK function calls may 11999a2dd95SBruce Richardson * be made. It is expected that common usage of this function is to call it 12099a2dd95SBruce Richardson * just before terminating the process. 12199a2dd95SBruce Richardson * 12299a2dd95SBruce Richardson * @return 12399a2dd95SBruce Richardson * - 0 Successfully released all internal EAL resources. 12499a2dd95SBruce Richardson * - -EFAULT There was an error in releasing all resources. 12599a2dd95SBruce Richardson */ 12699a2dd95SBruce Richardson int rte_eal_cleanup(void); 12799a2dd95SBruce Richardson 12899a2dd95SBruce Richardson /** 12999a2dd95SBruce Richardson * Check if a primary process is currently alive 13099a2dd95SBruce Richardson * 13199a2dd95SBruce Richardson * This function returns true when a primary process is currently 13299a2dd95SBruce Richardson * active. 13399a2dd95SBruce Richardson * 13499a2dd95SBruce Richardson * @param config_file_path 13599a2dd95SBruce Richardson * The config_file_path argument provided should point at the location 13699a2dd95SBruce Richardson * that the primary process will create its config file. If NULL, the default 13799a2dd95SBruce Richardson * config file path is used. 13899a2dd95SBruce Richardson * 13999a2dd95SBruce Richardson * @return 14099a2dd95SBruce Richardson * - If alive, returns 1. 14199a2dd95SBruce Richardson * - If dead, returns 0. 14299a2dd95SBruce Richardson */ 14399a2dd95SBruce Richardson int rte_eal_primary_proc_alive(const char *config_file_path); 14499a2dd95SBruce Richardson 14599a2dd95SBruce Richardson /** 14699a2dd95SBruce Richardson * Disable multiprocess. 14799a2dd95SBruce Richardson * 14899a2dd95SBruce Richardson * This function can be called to indicate that multiprocess won't be used for 14999a2dd95SBruce Richardson * the rest of the application life. 15099a2dd95SBruce Richardson * 15199a2dd95SBruce Richardson * @return 15299a2dd95SBruce Richardson * - true if called from a primary process that had no secondary processes 15399a2dd95SBruce Richardson * attached, 15499a2dd95SBruce Richardson * - false, otherwise. 15599a2dd95SBruce Richardson */ 15699a2dd95SBruce Richardson bool rte_mp_disable(void); 15799a2dd95SBruce Richardson 158*5ff00bbcSStephen Hemminger #define RTE_MP_MAX_FD_NUM 253 /* The max amount of fds (see SCM_MAX_FD) */ 15999a2dd95SBruce Richardson #define RTE_MP_MAX_NAME_LEN 64 /* The max length of action name */ 16099a2dd95SBruce Richardson #define RTE_MP_MAX_PARAM_LEN 256 /* The max length of param */ 16199a2dd95SBruce Richardson struct rte_mp_msg { 16299a2dd95SBruce Richardson char name[RTE_MP_MAX_NAME_LEN]; 16399a2dd95SBruce Richardson int len_param; 16499a2dd95SBruce Richardson int num_fds; 16599a2dd95SBruce Richardson uint8_t param[RTE_MP_MAX_PARAM_LEN]; 16699a2dd95SBruce Richardson int fds[RTE_MP_MAX_FD_NUM]; 16799a2dd95SBruce Richardson }; 16899a2dd95SBruce Richardson 16999a2dd95SBruce Richardson struct rte_mp_reply { 17099a2dd95SBruce Richardson int nb_sent; 17199a2dd95SBruce Richardson int nb_received; 17299a2dd95SBruce Richardson struct rte_mp_msg *msgs; /* caller to free */ 17399a2dd95SBruce Richardson }; 17499a2dd95SBruce Richardson 17599a2dd95SBruce Richardson /** 17699a2dd95SBruce Richardson * Action function typedef used by other components. 17799a2dd95SBruce Richardson * 17899a2dd95SBruce Richardson * As we create socket channel for primary/secondary communication, use 17999a2dd95SBruce Richardson * this function typedef to register action for coming messages. 18099a2dd95SBruce Richardson * 18199a2dd95SBruce Richardson * @note When handling IPC request callbacks, the reply must be sent even in 18299a2dd95SBruce Richardson * cases of error handling. Simply returning success or failure will *not* 18399a2dd95SBruce Richardson * send a response to the requestor. 18499a2dd95SBruce Richardson * Implementation of error signalling mechanism is up to the application. 18599a2dd95SBruce Richardson * 18699a2dd95SBruce Richardson * @note No memory allocations should take place inside the callback. 18799a2dd95SBruce Richardson */ 18899a2dd95SBruce Richardson typedef int (*rte_mp_t)(const struct rte_mp_msg *msg, const void *peer); 18999a2dd95SBruce Richardson 19099a2dd95SBruce Richardson /** 19199a2dd95SBruce Richardson * Asynchronous reply function typedef used by other components. 19299a2dd95SBruce Richardson * 19399a2dd95SBruce Richardson * As we create socket channel for primary/secondary communication, use 19499a2dd95SBruce Richardson * this function typedef to register action for coming responses to asynchronous 19599a2dd95SBruce Richardson * requests. 19699a2dd95SBruce Richardson * 19799a2dd95SBruce Richardson * @note When handling IPC request callbacks, the reply must be sent even in 19899a2dd95SBruce Richardson * cases of error handling. Simply returning success or failure will *not* 19999a2dd95SBruce Richardson * send a response to the requestor. 20099a2dd95SBruce Richardson * Implementation of error signalling mechanism is up to the application. 20199a2dd95SBruce Richardson * 20299a2dd95SBruce Richardson * @note No memory allocations should take place inside the callback. 20399a2dd95SBruce Richardson */ 20499a2dd95SBruce Richardson typedef int (*rte_mp_async_reply_t)(const struct rte_mp_msg *request, 20599a2dd95SBruce Richardson const struct rte_mp_reply *reply); 20699a2dd95SBruce Richardson 20799a2dd95SBruce Richardson /** 20899a2dd95SBruce Richardson * Register an action function for primary/secondary communication. 20999a2dd95SBruce Richardson * 21099a2dd95SBruce Richardson * Call this function to register an action, if the calling component wants 21199a2dd95SBruce Richardson * to response the messages from the corresponding component in its primary 21299a2dd95SBruce Richardson * process or secondary processes. 21399a2dd95SBruce Richardson * 21499a2dd95SBruce Richardson * @note IPC may be unsupported in certain circumstances, so caller should check 21599a2dd95SBruce Richardson * for ENOTSUP error. 21699a2dd95SBruce Richardson * 21799a2dd95SBruce Richardson * @param name 21899a2dd95SBruce Richardson * The name argument plays as the nonredundant key to find the action. 21999a2dd95SBruce Richardson * 22099a2dd95SBruce Richardson * @param action 22199a2dd95SBruce Richardson * The action argument is the function pointer to the action function. 22299a2dd95SBruce Richardson * 22399a2dd95SBruce Richardson * @return 22499a2dd95SBruce Richardson * - 0 on success. 22599a2dd95SBruce Richardson * - (<0) on failure. 22699a2dd95SBruce Richardson */ 22799a2dd95SBruce Richardson int 22899a2dd95SBruce Richardson rte_mp_action_register(const char *name, rte_mp_t action); 22999a2dd95SBruce Richardson 23099a2dd95SBruce Richardson /** 23199a2dd95SBruce Richardson * Unregister an action function for primary/secondary communication. 23299a2dd95SBruce Richardson * 23399a2dd95SBruce Richardson * Call this function to unregister an action if the calling component does 23499a2dd95SBruce Richardson * not want to response the messages from the corresponding component in its 23599a2dd95SBruce Richardson * primary process or secondary processes. 23699a2dd95SBruce Richardson * 23799a2dd95SBruce Richardson * @note IPC may be unsupported in certain circumstances, so caller should check 23899a2dd95SBruce Richardson * for ENOTSUP error. 23999a2dd95SBruce Richardson * 24099a2dd95SBruce Richardson * @param name 24199a2dd95SBruce Richardson * The name argument plays as the nonredundant key to find the action. 24299a2dd95SBruce Richardson */ 24399a2dd95SBruce Richardson void 24499a2dd95SBruce Richardson rte_mp_action_unregister(const char *name); 24599a2dd95SBruce Richardson 24699a2dd95SBruce Richardson /** 24799a2dd95SBruce Richardson * Send a message to the peer process. 24899a2dd95SBruce Richardson * 24999a2dd95SBruce Richardson * This function will send a message which will be responded by the action 25099a2dd95SBruce Richardson * identified by name in the peer process. 25199a2dd95SBruce Richardson * 25299a2dd95SBruce Richardson * @param msg 25399a2dd95SBruce Richardson * The msg argument contains the customized message. 25499a2dd95SBruce Richardson * 25599a2dd95SBruce Richardson * @return 25699a2dd95SBruce Richardson * - On success, return 0. 25799a2dd95SBruce Richardson * - On failure, return -1, and the reason will be stored in rte_errno. 25899a2dd95SBruce Richardson */ 25999a2dd95SBruce Richardson int 26099a2dd95SBruce Richardson rte_mp_sendmsg(struct rte_mp_msg *msg); 26199a2dd95SBruce Richardson 26299a2dd95SBruce Richardson /** 26399a2dd95SBruce Richardson * Send a request to the peer process and expect a reply. 26499a2dd95SBruce Richardson * 26599a2dd95SBruce Richardson * This function sends a request message to the peer process, and will 26699a2dd95SBruce Richardson * block until receiving reply message from the peer process. 26799a2dd95SBruce Richardson * 26899a2dd95SBruce Richardson * @note The caller is responsible to free reply->replies. 26999a2dd95SBruce Richardson * 27099a2dd95SBruce Richardson * @note This API must not be used inside memory-related or IPC callbacks, and 27199a2dd95SBruce Richardson * no memory allocations should take place inside such callback. 27299a2dd95SBruce Richardson * 27399a2dd95SBruce Richardson * @note IPC may be unsupported in certain circumstances, so caller should check 27499a2dd95SBruce Richardson * for ENOTSUP error. 27599a2dd95SBruce Richardson * 27699a2dd95SBruce Richardson * @param req 27799a2dd95SBruce Richardson * The req argument contains the customized request message. 27899a2dd95SBruce Richardson * 27999a2dd95SBruce Richardson * @param reply 28099a2dd95SBruce Richardson * The reply argument will be for storing all the replied messages; 28199a2dd95SBruce Richardson * the caller is responsible for free reply->msgs. 28299a2dd95SBruce Richardson * 28399a2dd95SBruce Richardson * @param ts 28499a2dd95SBruce Richardson * The ts argument specifies how long we can wait for the peer(s) to reply. 28599a2dd95SBruce Richardson * 28699a2dd95SBruce Richardson * @return 28799a2dd95SBruce Richardson * - On success, return 0. 28899a2dd95SBruce Richardson * - On failure, return -1, and the reason will be stored in rte_errno. 28999a2dd95SBruce Richardson */ 29099a2dd95SBruce Richardson int 29199a2dd95SBruce Richardson rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply, 29299a2dd95SBruce Richardson const struct timespec *ts); 29399a2dd95SBruce Richardson 29499a2dd95SBruce Richardson /** 29599a2dd95SBruce Richardson * Send a request to the peer process and expect a reply in a separate callback. 29699a2dd95SBruce Richardson * 29799a2dd95SBruce Richardson * This function sends a request message to the peer process, and will not 29899a2dd95SBruce Richardson * block. Instead, reply will be received in a separate callback. 29999a2dd95SBruce Richardson * 30099a2dd95SBruce Richardson * @note IPC may be unsupported in certain circumstances, so caller should check 30199a2dd95SBruce Richardson * for ENOTSUP error. 30299a2dd95SBruce Richardson * 30399a2dd95SBruce Richardson * @param req 30499a2dd95SBruce Richardson * The req argument contains the customized request message. 30599a2dd95SBruce Richardson * 30699a2dd95SBruce Richardson * @param ts 30799a2dd95SBruce Richardson * The ts argument specifies how long we can wait for the peer(s) to reply. 30899a2dd95SBruce Richardson * 30999a2dd95SBruce Richardson * @param clb 31099a2dd95SBruce Richardson * The callback to trigger when all responses for this request have arrived. 31199a2dd95SBruce Richardson * 31299a2dd95SBruce Richardson * @return 31399a2dd95SBruce Richardson * - On success, return 0. 31499a2dd95SBruce Richardson * - On failure, return -1, and the reason will be stored in rte_errno. 31599a2dd95SBruce Richardson */ 31699a2dd95SBruce Richardson int 31799a2dd95SBruce Richardson rte_mp_request_async(struct rte_mp_msg *req, const struct timespec *ts, 31899a2dd95SBruce Richardson rte_mp_async_reply_t clb); 31999a2dd95SBruce Richardson 32099a2dd95SBruce Richardson /** 32199a2dd95SBruce Richardson * Send a reply to the peer process. 32299a2dd95SBruce Richardson * 32399a2dd95SBruce Richardson * This function will send a reply message in response to a request message 32499a2dd95SBruce Richardson * received previously. 32599a2dd95SBruce Richardson * 32699a2dd95SBruce Richardson * @note When handling IPC request callbacks, the reply must be sent even in 32799a2dd95SBruce Richardson * cases of error handling. Simply returning success or failure will *not* 32899a2dd95SBruce Richardson * send a response to the requestor. 32999a2dd95SBruce Richardson * Implementation of error signalling mechanism is up to the application. 33099a2dd95SBruce Richardson * 33199a2dd95SBruce Richardson * @param msg 33299a2dd95SBruce Richardson * The msg argument contains the customized message. 33399a2dd95SBruce Richardson * 33499a2dd95SBruce Richardson * @param peer 33599a2dd95SBruce Richardson * The peer argument is the pointer to the peer socket path. 33699a2dd95SBruce Richardson * 33799a2dd95SBruce Richardson * @return 33899a2dd95SBruce Richardson * - On success, return 0. 33999a2dd95SBruce Richardson * - On failure, return -1, and the reason will be stored in rte_errno. 34099a2dd95SBruce Richardson */ 34199a2dd95SBruce Richardson int 34299a2dd95SBruce Richardson rte_mp_reply(struct rte_mp_msg *msg, const char *peer); 34399a2dd95SBruce Richardson 34499a2dd95SBruce Richardson /** 34599a2dd95SBruce Richardson * Usage function typedef used by the application usage function. 34699a2dd95SBruce Richardson * 34799a2dd95SBruce Richardson * Use this function typedef to define and call rte_set_application_usage_hook() 34899a2dd95SBruce Richardson * routine. 34999a2dd95SBruce Richardson */ 35099a2dd95SBruce Richardson typedef void (*rte_usage_hook_t)(const char * prgname); 35199a2dd95SBruce Richardson 35299a2dd95SBruce Richardson /** 35399a2dd95SBruce Richardson * Add application usage routine callout from the eal_usage() routine. 35499a2dd95SBruce Richardson * 35599a2dd95SBruce Richardson * This function allows the application to include its usage message 35699a2dd95SBruce Richardson * in the EAL system usage message. The routine rte_set_application_usage_hook() 35799a2dd95SBruce Richardson * needs to be called before the rte_eal_init() routine in the application. 35899a2dd95SBruce Richardson * 35999a2dd95SBruce Richardson * This routine is optional for the application and will behave as if the set 36099a2dd95SBruce Richardson * routine was never called as the default behavior. 36199a2dd95SBruce Richardson * 36299a2dd95SBruce Richardson * @param usage_func 36399a2dd95SBruce Richardson * The func argument is a function pointer to the application usage routine. 36499a2dd95SBruce Richardson * Called function is defined using rte_usage_hook_t typedef, which is of 36599a2dd95SBruce Richardson * the form void rte_usage_func(const char * prgname). 36699a2dd95SBruce Richardson * 36799a2dd95SBruce Richardson * Calling this routine with a NULL value will reset the usage hook routine and 36899a2dd95SBruce Richardson * return the current value, which could be NULL. 36999a2dd95SBruce Richardson * @return 37099a2dd95SBruce Richardson * - Returns the current value of the rte_application_usage pointer to allow 37199a2dd95SBruce Richardson * the caller to daisy chain the usage routines if needing more then one. 37299a2dd95SBruce Richardson */ 37399a2dd95SBruce Richardson rte_usage_hook_t 37499a2dd95SBruce Richardson rte_set_application_usage_hook(rte_usage_hook_t usage_func); 37599a2dd95SBruce Richardson 37699a2dd95SBruce Richardson /** 37799a2dd95SBruce Richardson * Whether EAL is using huge pages (disabled by --no-huge option). 37899a2dd95SBruce Richardson * The no-huge mode is not compatible with all drivers or features. 37999a2dd95SBruce Richardson * 38099a2dd95SBruce Richardson * @return 38199a2dd95SBruce Richardson * Nonzero if hugepages are enabled. 38299a2dd95SBruce Richardson */ 38399a2dd95SBruce Richardson int rte_eal_has_hugepages(void); 38499a2dd95SBruce Richardson 38599a2dd95SBruce Richardson /** 38699a2dd95SBruce Richardson * Whether EAL is using PCI bus. 38799a2dd95SBruce Richardson * Disabled by --no-pci option. 38899a2dd95SBruce Richardson * 38999a2dd95SBruce Richardson * @return 39099a2dd95SBruce Richardson * Nonzero if the PCI bus is enabled. 39199a2dd95SBruce Richardson */ 39299a2dd95SBruce Richardson int rte_eal_has_pci(void); 39399a2dd95SBruce Richardson 39499a2dd95SBruce Richardson /** 39599a2dd95SBruce Richardson * Whether the EAL was asked to create UIO device. 39699a2dd95SBruce Richardson * 39799a2dd95SBruce Richardson * @return 39899a2dd95SBruce Richardson * Nonzero if true. 39999a2dd95SBruce Richardson */ 40099a2dd95SBruce Richardson int rte_eal_create_uio_dev(void); 40199a2dd95SBruce Richardson 40299a2dd95SBruce Richardson /** 40399a2dd95SBruce Richardson * The user-configured vfio interrupt mode. 40499a2dd95SBruce Richardson * 40599a2dd95SBruce Richardson * @return 40699a2dd95SBruce Richardson * Interrupt mode configured with the command line, 40799a2dd95SBruce Richardson * RTE_INTR_MODE_NONE by default. 40899a2dd95SBruce Richardson */ 40999a2dd95SBruce Richardson enum rte_intr_mode rte_eal_vfio_intr_mode(void); 41099a2dd95SBruce Richardson 41199a2dd95SBruce Richardson /** 41299a2dd95SBruce Richardson * Copy the user-configured vfio VF token. 41399a2dd95SBruce Richardson * 41499a2dd95SBruce Richardson * @param vf_token 41599a2dd95SBruce Richardson * vfio VF token configured with the command line is copied 41699a2dd95SBruce Richardson * into this parameter, zero uuid by default. 41799a2dd95SBruce Richardson */ 41899a2dd95SBruce Richardson void rte_eal_vfio_get_vf_token(rte_uuid_t vf_token); 41999a2dd95SBruce Richardson 42099a2dd95SBruce Richardson /** 42199a2dd95SBruce Richardson * A wrap API for syscall gettid. 42299a2dd95SBruce Richardson * 42399a2dd95SBruce Richardson * @return 42499a2dd95SBruce Richardson * On success, returns the thread ID of calling process. 42599a2dd95SBruce Richardson * It is always successful. 42699a2dd95SBruce Richardson */ 42799a2dd95SBruce Richardson int rte_sys_gettid(void); 42899a2dd95SBruce Richardson 42999a2dd95SBruce Richardson RTE_DECLARE_PER_LCORE(int, _thread_id); 43099a2dd95SBruce Richardson 43199a2dd95SBruce Richardson /** 43299a2dd95SBruce Richardson * Get system unique thread id. 43399a2dd95SBruce Richardson * 43499a2dd95SBruce Richardson * @return 43599a2dd95SBruce Richardson * On success, returns the thread ID of calling process. 43699a2dd95SBruce Richardson * It is always successful. 43799a2dd95SBruce Richardson */ 43899a2dd95SBruce Richardson static inline int rte_gettid(void) 43999a2dd95SBruce Richardson { 44099a2dd95SBruce Richardson if (RTE_PER_LCORE(_thread_id) == -1) 44199a2dd95SBruce Richardson RTE_PER_LCORE(_thread_id) = rte_sys_gettid(); 44299a2dd95SBruce Richardson return RTE_PER_LCORE(_thread_id); 44399a2dd95SBruce Richardson } 44499a2dd95SBruce Richardson 44599a2dd95SBruce Richardson /** 446f3ca33bbSSrikanth Yalavarthi * Get the OS-specific EAL base address. 447f3ca33bbSSrikanth Yalavarthi * 448f3ca33bbSSrikanth Yalavarthi * @return 449f3ca33bbSSrikanth Yalavarthi * The base address. 450f3ca33bbSSrikanth Yalavarthi */ 451f3ca33bbSSrikanth Yalavarthi __rte_internal 452f3ca33bbSSrikanth Yalavarthi uint64_t rte_eal_get_baseaddr(void); 453f3ca33bbSSrikanth Yalavarthi 454f3ca33bbSSrikanth Yalavarthi /** 455770ebc06SDavid Marchand * IOVA mapping mode. 456770ebc06SDavid Marchand * 457770ebc06SDavid Marchand * IOVA mapping mode is iommu programming mode of a device. 458770ebc06SDavid Marchand * That device (for example: IOMMU backed DMA device) based 459770ebc06SDavid Marchand * on rte_iova_mode will generate physical or virtual address. 460770ebc06SDavid Marchand */ 461770ebc06SDavid Marchand enum rte_iova_mode { 462770ebc06SDavid Marchand RTE_IOVA_DC = 0, /* Don't care mode */ 463770ebc06SDavid Marchand RTE_IOVA_PA = (1 << 0), /* DMA using physical address */ 464770ebc06SDavid Marchand RTE_IOVA_VA = (1 << 1) /* DMA using virtual address */ 465770ebc06SDavid Marchand }; 466770ebc06SDavid Marchand 467770ebc06SDavid Marchand /** 46899a2dd95SBruce Richardson * Get the iova mode 46999a2dd95SBruce Richardson * 47099a2dd95SBruce Richardson * @return 47199a2dd95SBruce Richardson * enum rte_iova_mode value. 47299a2dd95SBruce Richardson */ 47399a2dd95SBruce Richardson enum rte_iova_mode rte_eal_iova_mode(void); 47499a2dd95SBruce Richardson 47599a2dd95SBruce Richardson /** 47699a2dd95SBruce Richardson * Get user provided pool ops name for mbuf 47799a2dd95SBruce Richardson * 47899a2dd95SBruce Richardson * @return 47999a2dd95SBruce Richardson * returns user provided pool ops name. 48099a2dd95SBruce Richardson */ 48199a2dd95SBruce Richardson const char * 48299a2dd95SBruce Richardson rte_eal_mbuf_user_pool_ops(void); 48399a2dd95SBruce Richardson 48499a2dd95SBruce Richardson /** 48599a2dd95SBruce Richardson * Get the runtime directory of DPDK 48699a2dd95SBruce Richardson * 48799a2dd95SBruce Richardson * @return 48899a2dd95SBruce Richardson * The runtime directory path of DPDK 48999a2dd95SBruce Richardson */ 49099a2dd95SBruce Richardson const char * 49199a2dd95SBruce Richardson rte_eal_get_runtime_dir(void); 49299a2dd95SBruce Richardson 493aec322ceSAbdullah Sevincer /** 494aec322ceSAbdullah Sevincer * Convert a string describing a mask of core ids into an array of core ids. 495aec322ceSAbdullah Sevincer * 496aec322ceSAbdullah Sevincer * On success, the passed array is filled with the orders of the core ids 497aec322ceSAbdullah Sevincer * present in the mask (-1 indicating that a core id is absent). 498aec322ceSAbdullah Sevincer * For example, passing a 0xa coremask results in cores[1] = 0, cores[3] = 1, 499aec322ceSAbdullah Sevincer * and the rest of the array is set to -1. 500aec322ceSAbdullah Sevincer * 501aec322ceSAbdullah Sevincer * @param coremask 502aec322ceSAbdullah Sevincer * A string describing a mask of core ids. 503aec322ceSAbdullah Sevincer * @param cores 504aec322ceSAbdullah Sevincer * An array where to store the core ids orders. 505aec322ceSAbdullah Sevincer * This array must be at least RTE_MAX_LCORE large. 506aec322ceSAbdullah Sevincer * @return 507aec322ceSAbdullah Sevincer * 0 on success, -1 if the string content was invalid. 508aec322ceSAbdullah Sevincer */ 509aec322ceSAbdullah Sevincer __rte_internal 510aec322ceSAbdullah Sevincer int 511aec322ceSAbdullah Sevincer rte_eal_parse_coremask(const char *coremask, int *cores); 512aec322ceSAbdullah Sevincer 51399a2dd95SBruce Richardson #ifdef __cplusplus 51499a2dd95SBruce Richardson } 51599a2dd95SBruce Richardson #endif 51699a2dd95SBruce Richardson 51799a2dd95SBruce Richardson #endif /* _RTE_EAL_H_ */ 518