aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/m4/odp_cpu.m4
blob: f363813f164d3e4b6dfdbd635b517d549a901558 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2021 Nokia
#

##########################################################################
# Set ODP_CACHE_LINE_SIZE define
##########################################################################
# Currently used only for aarch64
if test "${ARCH_DIR}" = "aarch64"; then
	cache_line_size=64
	# Use default cache size if cross-compiling
	if test $build = $host; then
		cpu_implementer=""
		cpu_part=""

		AC_PROG_GREP
		AC_PROG_SED
		while read line; do
			if echo $line | $GREP -q "CPU implementer"; then
				cpu_implementer=`echo $line | $SED 's/.*\:\s*//'`
			fi
			if echo $line | $GREP -q "CPU part"; then
				cpu_part=`echo $line | $SED 's/.*\:\s*//'`
			fi
		done < /proc/cpuinfo

		# Cavium
		if test "$cpu_implementer" == "0x43"; then
			# ThunderX2 (0x0af) 64B, others 128B
			if test "$cpu_part" == "0x0af"; then
				cache_line_size=64;
			else
				cache_line_size=128;
			fi
		fi
	fi
	AC_DEFINE_UNQUOTED([_ODP_CACHE_LINE_SIZE], [$cache_line_size],
			   [Define cache line size])
fi