DPDK  19.08.0-rc0
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;
60  uint32_t numa_node_count;
61  uint32_t numa_nodes[RTE_MAX_NUMA_NODES];
63  enum rte_lcore_role_t lcore_role[RTE_MAX_LCORE];
67 
70 
76 } __attribute__((__packed__));
77 
85 
94 enum rte_lcore_role_t rte_eal_lcore_role(unsigned lcore_id);
95 
96 
104 
114 int rte_eal_iopl_init(void);
115 
174 int rte_eal_init(int argc, char **argv);
175 
187 int rte_eal_cleanup(void);
188 
204 int rte_eal_primary_proc_alive(const char *config_file_path);
205 
206 #define RTE_MP_MAX_FD_NUM 8 /* The max amount of fds */
207 #define RTE_MP_MAX_NAME_LEN 64 /* The max length of action name */
208 #define RTE_MP_MAX_PARAM_LEN 256 /* The max length of param */
209 struct rte_mp_msg {
210  char name[RTE_MP_MAX_NAME_LEN];
211  int len_param;
212  int num_fds;
213  uint8_t param[RTE_MP_MAX_PARAM_LEN];
214  int fds[RTE_MP_MAX_FD_NUM];
215 };
216 
217 struct rte_mp_reply {
218  int nb_sent;
219  int nb_received;
220  struct rte_mp_msg *msgs; /* caller to free */
221 };
222 
236 typedef int (*rte_mp_t)(const struct rte_mp_msg *msg, const void *peer);
237 
252 typedef int (*rte_mp_async_reply_t)(const struct rte_mp_msg *request,
253  const struct rte_mp_reply *reply);
254 
278 int __rte_experimental
279 rte_mp_action_register(const char *name, rte_mp_t action);
280 
298 void __rte_experimental
299 rte_mp_action_unregister(const char *name);
300 
317 int __rte_experimental
318 rte_mp_sendmsg(struct rte_mp_msg *msg);
319 
351 int __rte_experimental
352 rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply,
353  const struct timespec *ts);
354 
380 int __rte_experimental
381 rte_mp_request_async(struct rte_mp_msg *req, const struct timespec *ts,
383 
408 int __rte_experimental
409 rte_mp_reply(struct rte_mp_msg *msg, const char *peer);
410 
417 int __rte_experimental
419 
426 typedef void (*rte_usage_hook_t)(const char * prgname);
427 
451 
455 #define RTE_EAL_TAILQ_RWLOCK (&rte_eal_get_configuration()->mem_config->qlock)
456 
460 #define RTE_EAL_MEMPOOL_RWLOCK (&rte_eal_get_configuration()->mem_config->mplock)
461 
472 int rte_eal_has_hugepages(void);
473 
481 int rte_eal_has_pci(void);
482 
489 int rte_eal_create_uio_dev(void);
490 
498 enum rte_intr_mode rte_eal_vfio_intr_mode(void);
499 
507 int rte_sys_gettid(void);
508 
516 static inline int rte_gettid(void)
517 {
518  static RTE_DEFINE_PER_LCORE(int, _thread_id) = -1;
519  if (RTE_PER_LCORE(_thread_id) == -1)
520  RTE_PER_LCORE(_thread_id) = rte_sys_gettid();
521  return RTE_PER_LCORE(_thread_id);
522 }
523 
531 
538 const char *
540 
547 const char *
549 
550 #ifdef __cplusplus
551 }
552 #endif
553 
554 #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_mp_async_reply_t)(const struct rte_mp_msg *request, const struct rte_mp_reply *reply)
Definition: rte_eal.h:252
int rte_eal_create_uio_dev(void)
int __rte_experimental rte_mp_request_async(struct rte_mp_msg *req, const struct timespec *ts, rte_mp_async_reply_t clb)
int rte_eal_has_hugepages(void)
rte_iova_mode
Definition: rte_bus.h:67
enum rte_intr_mode rte_eal_vfio_intr_mode(void)
const char * rte_eal_mbuf_user_pool_ops(void)
const char * rte_eal_get_runtime_dir(void)
uint32_t numa_nodes[RTE_MAX_NUMA_NODES]
Definition: rte_eal.h:61
enum rte_proc_type_t rte_eal_process_type(void)
uint32_t service_lcore_count
Definition: rte_eal.h:62
#define RTE_DEFINE_PER_LCORE(type, name)
Definition: rte_per_lcore.h:32
enum rte_iova_mode iova_mode
Definition: rte_eal.h:69
struct rte_mem_config * mem_config
Definition: rte_eal.h:75
int __rte_experimental rte_mp_dev_hotplug_init(void)
enum rte_lcore_role_t lcore_role[RTE_MAX_LCORE]
Definition: rte_eal.h:63
int rte_eal_cleanup(void)
struct rte_config * rte_eal_get_configuration(void)
void(* rte_usage_hook_t)(const char *prgname)
Definition: rte_eal.h:426
int rte_eal_primary_proc_alive(const char *config_file_path)
uint32_t numa_node_count
Definition: rte_eal.h:60
uint32_t master_lcore
Definition: rte_eal.h:58
void __rte_experimental rte_mp_action_unregister(const char *name)
int __rte_experimental rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply, const struct timespec *ts)
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:236
int rte_eal_has_pci(void)
enum rte_proc_type_t process_type
Definition: rte_eal.h:66
static int rte_gettid(void)
Definition: rte_eal.h:516
int rte_eal_iopl_init(void)
int __rte_experimental rte_mp_sendmsg(struct rte_mp_msg *msg)