DPDK  18.02.0
rte_eal.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2018 Intel Corporation
3  */
4 
5 #ifndef _RTE_EAL_H_
6 #define _RTE_EAL_H_
7 
14 #include <stdint.h>
15 #include <sched.h>
16 #include <time.h>
17 
18 #include <rte_config.h>
19 #include <rte_compat.h>
20 #include <rte_per_lcore.h>
21 #include <rte_bus.h>
22 
23 #include <rte_pci_dev_feature_defs.h>
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #define RTE_MAGIC 19820526
31 /* Maximum thread_name length. */
32 #define RTE_MAX_THREAD_NAME_LEN 16
33 
38  ROLE_RTE,
39  ROLE_OFF,
40  ROLE_SERVICE,
41 };
42 
47  RTE_PROC_AUTO = -1, /* allow auto-detection of primary/secondary */
48  RTE_PROC_PRIMARY = 0, /* set to zero, so primary is the default */
49  RTE_PROC_SECONDARY,
50 
51  RTE_PROC_INVALID
52 };
53 
57 struct rte_config {
58  uint32_t master_lcore;
59  uint32_t lcore_count;
61  enum rte_lcore_role_t lcore_role[RTE_MAX_LCORE];
65 
68 
74 } __attribute__((__packed__));
75 
83 
92 enum rte_lcore_role_t rte_eal_lcore_role(unsigned lcore_id);
93 
94 
102 
112 int rte_eal_iopl_init(void);
113 
172 int rte_eal_init(int argc, char **argv);
173 
188 int __rte_experimental rte_eal_cleanup(void);
189 
205 int rte_eal_primary_proc_alive(const char *config_file_path);
206 
207 #define RTE_MP_MAX_FD_NUM 8 /* The max amount of fds */
208 #define RTE_MP_MAX_NAME_LEN 64 /* The max length of action name */
209 #define RTE_MP_MAX_PARAM_LEN 256 /* The max length of param */
210 struct rte_mp_msg {
211  char name[RTE_MP_MAX_NAME_LEN];
212  int len_param;
213  int num_fds;
214  uint8_t param[RTE_MP_MAX_PARAM_LEN];
215  int fds[RTE_MP_MAX_FD_NUM];
216 };
217 
218 struct rte_mp_reply {
219  int nb_sent;
220  int nb_received;
221  struct rte_mp_msg *msgs; /* caller to free */
222 };
223 
230 typedef int (*rte_mp_t)(const struct rte_mp_msg *msg, const void *peer);
231 
252 int __rte_experimental
253 rte_mp_action_register(const char *name, rte_mp_t action);
254 
269 void __rte_experimental
270 rte_mp_action_unregister(const char *name);
271 
288 int __rte_experimental
289 rte_mp_sendmsg(struct rte_mp_msg *msg);
290 
316 int __rte_experimental
317 rte_mp_request(struct rte_mp_msg *req, struct rte_mp_reply *reply,
318  const struct timespec *ts);
319 
339 int __rte_experimental
340 rte_mp_reply(struct rte_mp_msg *msg, const char *peer);
341 
348 typedef void (*rte_usage_hook_t)(const char * prgname);
349 
373 
377 #define RTE_EAL_TAILQ_RWLOCK (&rte_eal_get_configuration()->mem_config->qlock)
378 
382 #define RTE_EAL_MEMPOOL_RWLOCK (&rte_eal_get_configuration()->mem_config->mplock)
383 
394 int rte_eal_has_hugepages(void);
395 
403 int rte_eal_has_pci(void);
404 
411 int rte_eal_create_uio_dev(void);
412 
420 enum rte_intr_mode rte_eal_vfio_intr_mode(void);
421 
429 int rte_sys_gettid(void);
430 
438 static inline int rte_gettid(void)
439 {
440  static RTE_DEFINE_PER_LCORE(int, _thread_id) = -1;
441  if (RTE_PER_LCORE(_thread_id) == -1)
442  RTE_PER_LCORE(_thread_id) = rte_sys_gettid();
443  return RTE_PER_LCORE(_thread_id);
444 }
445 
453 
463 const char * __rte_experimental
465 
472 const char *
474 
475 #ifdef __cplusplus
476 }
477 #endif
478 
479 #endif /* _RTE_EAL_H_ */
uint32_t lcore_count
Definition: rte_eal.h:59
int rte_sys_gettid(void)
enum rte_iova_mode rte_eal_iova_mode(void)
int __rte_experimental rte_mp_reply(struct rte_mp_msg *msg, const char *peer)
int __rte_experimental rte_mp_action_register(const char *name, rte_mp_t action)
rte_lcore_role_t
Definition: rte_eal.h:37
enum rte_lcore_role_t rte_eal_lcore_role(unsigned lcore_id)
int rte_eal_create_uio_dev(void)
int __rte_experimental rte_eal_cleanup(void)
const char *__rte_experimental rte_eal_mbuf_user_pool_ops(void)
const char * rte_eal_mbuf_default_mempool_ops(void)
int rte_eal_has_hugepages(void)
rte_iova_mode
Definition: rte_bus.h:67
enum rte_intr_mode rte_eal_vfio_intr_mode(void)
enum rte_proc_type_t rte_eal_process_type(void)
int __rte_experimental rte_mp_request(struct rte_mp_msg *req, struct rte_mp_reply *reply, const struct timespec *ts)
uint32_t service_lcore_count
Definition: rte_eal.h:60
#define RTE_DEFINE_PER_LCORE(type, name)
Definition: rte_per_lcore.h:32
enum rte_iova_mode iova_mode
Definition: rte_eal.h:67
struct rte_mem_config * mem_config
Definition: rte_eal.h:73
enum rte_lcore_role_t lcore_role[RTE_MAX_LCORE]
Definition: rte_eal.h:61
struct rte_config * rte_eal_get_configuration(void)
void(* rte_usage_hook_t)(const char *prgname)
Definition: rte_eal.h:348
int rte_eal_primary_proc_alive(const char *config_file_path)
uint32_t master_lcore
Definition: rte_eal.h:58
void __rte_experimental rte_mp_action_unregister(const char *name)
rte_usage_hook_t rte_set_application_usage_hook(rte_usage_hook_t usage_func)
#define RTE_PER_LCORE(name)
Definition: rte_per_lcore.h:44
rte_proc_type_t
Definition: rte_eal.h:46
int rte_eal_init(int argc, char **argv)
int(* rte_mp_t)(const struct rte_mp_msg *msg, const void *peer)
Definition: rte_eal.h:230
int rte_eal_has_pci(void)
enum rte_proc_type_t process_type
Definition: rte_eal.h:64
static int rte_gettid(void)
Definition: rte_eal.h:438
int rte_eal_iopl_init(void)
int __rte_experimental rte_mp_sendmsg(struct rte_mp_msg *msg)