DPDK  18.02.2
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_ */