New upstream version 18.08
[deb_dpdk.git] / lib / librte_eal / common / include / generic / rte_cpuflags.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4
5 #ifndef _RTE_CPUFLAGS_H_
6 #define _RTE_CPUFLAGS_H_
7
8 /**
9  * @file
10  * Architecture specific API to determine available CPU features at runtime.
11  */
12
13 #include "rte_common.h"
14 #include <errno.h>
15
16 /**
17  * Enumeration of all CPU features supported
18  */
19 __extension__
20 enum rte_cpu_flag_t;
21
22 /**
23  * Get name of CPU flag
24  *
25  * @param feature
26  *     CPU flag ID
27  * @return
28  *     flag name
29  *     NULL if flag ID is invalid
30  */
31 __extension__
32 const char *
33 rte_cpu_get_flag_name(enum rte_cpu_flag_t feature);
34
35 /**
36  * Function for checking a CPU flag availability
37  *
38  * @param feature
39  *     CPU flag to query CPU for
40  * @return
41  *     1 if flag is available
42  *     0 if flag is not available
43  *     -ENOENT if flag is invalid
44  */
45 __extension__
46 int
47 rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature);
48
49 /**
50  * This function checks that the currently used CPU supports the CPU features
51  * that were specified at compile time. It is called automatically within the
52  * EAL, so does not need to be used by applications.
53  */
54 __rte_deprecated
55 void
56 rte_cpu_check_supported(void);
57
58 /**
59  * This function checks that the currently used CPU supports the CPU features
60  * that were specified at compile time. It is called automatically within the
61  * EAL, so does not need to be used by applications.  This version returns a
62  * result so that decisions may be made (for instance, graceful shutdowns).
63  */
64 int
65 rte_cpu_is_supported(void);
66
67 /**
68  * This function attempts to retrieve a value from the auxiliary vector.
69  * If it is unsuccessful, the result will be 0, and errno will be set.
70  *
71  * @return A value from the auxiliary vector.  When the value is 0, check
72  * errno to determine if an error occurred.
73  */
74 unsigned long
75 rte_cpu_getauxval(unsigned long type);
76
77 /**
78  * This function retrieves a value from the auxiliary vector, and compares it
79  * as a string against the value retrieved.
80  *
81  * @return The result of calling strcmp() against the value retrieved from
82  * the auxiliary vector.  When the value is 0 (meaning a match is found),
83  * check errno to determine if an error occurred.
84  */
85 int
86 rte_cpu_strcmp_auxval(unsigned long type, const char *str);
87
88 #endif /* _RTE_CPUFLAGS_H_ */