New upstream version 18.11-rc1
[deb_dpdk.git] / lib / librte_eal / common / include / rte_option.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018 Intel Corporation.
3  */
4
5 #ifndef __INCLUDE_RTE_OPTION_H__
6 #define __INCLUDE_RTE_OPTION_H__
7
8 /**
9  * @file
10  *
11  * This API offers the ability to register options to the EAL command line and
12  * map those options to functions that will be executed at the end of EAL
13  * initialization. These options will be available as part of the EAL command
14  * line of applications and are dynamically managed.
15  *
16  * This is used primarily by DPDK libraries offering command line options.
17  * Currently, this API is limited to registering options without argument.
18  *
19  * The register API can be used to resolve circular dependency issues
20  * between EAL and the library. The library uses EAL, but is also initialized
21  * by EAL. Hence, EAL depends on the init function of the library. The API
22  * introduced in rte_option allows us to register the library init with EAL
23  * (passing a function pointer) and avoid the circular dependency.
24  */
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 typedef int (*rte_option_cb)(void);
31
32 /*
33  * Structure describing the EAL command line option being registered.
34  */
35 struct rte_option {
36         TAILQ_ENTRY(rte_option) next; /**< Next entry in the list. */
37         char *opt_str;             /**< The option name. */
38         rte_option_cb cb;          /**< Function called when option is used. */
39         int enabled;               /**< Set when the option is used. */
40 };
41
42 /**
43  * @warning
44  * @b EXPERIMENTAL: this API may change without prior notice
45  *
46  * Register an option to the EAL command line.
47  * When recognized, the associated function will be executed at the end of EAL
48  * initialization.
49  *
50  * The associated structure must be available the whole time this option is
51  * registered (i.e. not stack memory).
52  *
53  * @param opt
54  *  Structure describing the option to parse.
55  */
56 void __rte_experimental
57 rte_option_register(struct rte_option *opt);
58
59 #ifdef __cplusplus
60 }
61 #endif
62
63 #endif