4 * Copyright (C) IBM Corporation 2014.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of IBM Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #ifndef _RTE_CPUFLAGS_PPC_64_H_
34 #define _RTE_CPUFLAGS_PPC_64_H_
45 #include "generic/rte_cpuflags.h"
47 extern const struct feature_entry rte_cpu_feature_table[];
49 /* Symbolic values for the entries in the auxiliary table */
53 /* software based registers */
60 * Enumeration of all CPU features supported
63 RTE_CPUFLAG_PPC_LE = 0,
65 RTE_CPUFLAG_PSERIES_PERFMON_COMPAT,
67 RTE_CPUFLAG_ARCH_2_06,
68 RTE_CPUFLAG_POWER6_EXT,
71 RTE_CPUFLAG_ARCH_2_05,
72 RTE_CPUFLAG_ICACHE_SNOOP,
76 RTE_CPUFLAG_POWER5_PLUS,
80 RTE_CPUFLAG_EFP_DOUBLE,
81 RTE_CPUFLAG_EFP_SINGLE,
83 RTE_CPUFLAG_UNIFIED_CACHE,
96 RTE_CPUFLAG_ARCH_2_07,
98 RTE_CPUFLAG_NUMFLAGS,/**< This should always be the last! */
102 * Read AUXV software register and get cpu features for Power
105 rte_cpu_get_features(__attribute__((unused)) uint32_t leaf,
106 __attribute__((unused)) uint32_t subleaf, cpuid_registers_t out)
111 auxv_fd = open("/proc/self/auxv", O_RDONLY);
113 while (read(auxv_fd, &auxv,
114 sizeof(Elf64_auxv_t)) == sizeof(Elf64_auxv_t)) {
115 if (auxv.a_type == AT_HWCAP)
116 out[REG_HWCAP] = auxv.a_un.a_val;
117 else if (auxv.a_type == AT_HWCAP2)
118 out[REG_HWCAP2] = auxv.a_un.a_val;
123 * Checks if a particular flag is available on current machine.
126 rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature)
128 const struct feature_entry *feat;
129 cpuid_registers_t regs = {0};
131 if (feature >= RTE_CPUFLAG_NUMFLAGS)
132 /* Flag does not match anything in the feature tables */
135 feat = &rte_cpu_feature_table[feature];
138 /* This entry in the table wasn't filled out! */
141 /* get the cpuid leaf containing the desired feature */
142 rte_cpu_get_features(feat->leaf, feat->subleaf, regs);
144 /* check if the feature is enabled */
145 return (regs[feat->reg] >> feat->bit) & 1;
152 #endif /* _RTE_CPUFLAGS_PPC_64_H_ */