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 #include <rte_compat.h> 17 18 #ifdef __cplusplus 19 extern "C" { 20 #endif 21 22 /** 23 * Structure used to describe platform-specific intrinsics that may or may not 24 * be supported at runtime. 25 */ 26 struct rte_cpu_intrinsics { 27 uint32_t power_monitor : 1; 28 /**< indicates support for rte_power_monitor function */ 29 uint32_t power_pause : 1; 30 /**< indicates support for rte_power_pause function */ 31 uint32_t power_monitor_multi : 1; 32 /**< indicates support for rte_power_monitor_multi function */ 33 }; 34 35 /** 36 * @warning 37 * @b EXPERIMENTAL: this API may change without prior notice 38 * 39 * Check CPU support for various intrinsics at runtime. 40 * 41 * @param intrinsics 42 * Pointer to a structure to be filled. 43 */ 44 __rte_experimental 45 void 46 rte_cpu_get_intrinsics_support(struct rte_cpu_intrinsics *intrinsics); 47 48 /** 49 * Enumeration of all CPU features supported 50 */ 51 __extension__ 52 enum rte_cpu_flag_t; 53 54 /** 55 * Get name of CPU flag 56 * 57 * @param feature 58 * CPU flag ID 59 * @return 60 * flag name 61 * NULL if flag ID is invalid 62 */ 63 __extension__ 64 const char * 65 rte_cpu_get_flag_name(enum rte_cpu_flag_t feature); 66 67 /** 68 * Function for checking a CPU flag availability 69 * 70 * @param feature 71 * CPU flag to query CPU for 72 * @return 73 * 1 if flag is available 74 * 0 if flag is not available 75 * -ENOENT if flag is invalid 76 */ 77 __extension__ 78 int 79 rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature); 80 81 /** 82 * This function checks that the currently used CPU supports the CPU features 83 * that were specified at compile time. It is called automatically within the 84 * EAL, so does not need to be used by applications. This version returns a 85 * result so that decisions may be made (for instance, graceful shutdowns). 86 */ 87 int 88 rte_cpu_is_supported(void); 89 90 /** 91 * This function attempts to retrieve a value from the auxiliary vector. 92 * If it is unsuccessful, the result will be 0, and errno will be set. 93 * 94 * @return A value from the auxiliary vector. When the value is 0, check 95 * errno to determine if an error occurred. 96 */ 97 unsigned long 98 rte_cpu_getauxval(unsigned long type); 99 100 /** 101 * This function retrieves a value from the auxiliary vector, and compares it 102 * as a string against the value retrieved. 103 * 104 * @return The result of calling strcmp() against the value retrieved from 105 * the auxiliary vector. When the value is 0 (meaning a match is found), 106 * check errno to determine if an error occurred. 107 */ 108 int 109 rte_cpu_strcmp_auxval(unsigned long type, const char *str); 110 111 #ifdef __cplusplus 112 } 113 #endif 114 115 #endif /* _RTE_CPUFLAGS_H_ */ 116