From 145e9a29777cc660bd031670a7aeb8a4d3cb88a8 Mon Sep 17 00:00:00 2001
From: zhuhengbo <zhuhengbo1@huawei.com>
Date: Thu, 30 Apr 2020 02:53:08 -0400
Subject: [PATCH] dpdk: fix cpu flag error in Intel(R) Xeon(R) CPU E5-2620 v3 @
 2.40GHz

Signed-off-by: zhuhengbo <zhuhengbo1@huawei.com>
---
 config/defconfig_x86_64-cpu_v2-linux-gcc    |  1 +
 config/defconfig_x86_64-cpu_v2-linuxapp-gcc | 14 ++++++++
 mk/machine/cpu_v2/rte.vars.mk               | 39 +++++++++++++++++++++
 3 files changed, 54 insertions(+)
 create mode 120000 config/defconfig_x86_64-cpu_v2-linux-gcc
 create mode 100644 config/defconfig_x86_64-cpu_v2-linuxapp-gcc
 create mode 100644 mk/machine/cpu_v2/rte.vars.mk

diff --git a/config/defconfig_x86_64-cpu_v2-linux-gcc b/config/defconfig_x86_64-cpu_v2-linux-gcc
new file mode 120000
index 0000000..64f21b6
--- /dev/null
+++ b/config/defconfig_x86_64-cpu_v2-linux-gcc
@@ -0,0 +1 @@
+defconfig_x86_64-cpu_v2-linuxapp-gcc
\ No newline at end of file
diff --git a/config/defconfig_x86_64-cpu_v2-linuxapp-gcc b/config/defconfig_x86_64-cpu_v2-linuxapp-gcc
new file mode 100644
index 0000000..2748e30
--- /dev/null
+++ b/config/defconfig_x86_64-cpu_v2-linuxapp-gcc
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2010-2014 Intel Corporation
+
+#include "common_linux"
+
+CONFIG_RTE_MACHINE="cpu_v2"
+
+CONFIG_RTE_ARCH="x86_64"
+CONFIG_RTE_ARCH_X86_64=y
+CONFIG_RTE_ARCH_X86=y
+CONFIG_RTE_ARCH_64=y
+
+CONFIG_RTE_TOOLCHAIN="gcc"
+CONFIG_RTE_TOOLCHAIN_GCC=y
diff --git a/mk/machine/cpu_v2/rte.vars.mk b/mk/machine/cpu_v2/rte.vars.mk
new file mode 100644
index 0000000..ffa7d3f
--- /dev/null
+++ b/mk/machine/cpu_v2/rte.vars.mk
@@ -0,0 +1,39 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2010-2014 Intel Corporation
+
+#
+# machine:
+#
+#   - can define ARCH variable (overridden by cmdline value)
+#   - can define CROSS variable (overridden by cmdline value)
+#   - define MACHINE_CFLAGS variable (overridden by cmdline value)
+#   - define MACHINE_LDFLAGS variable (overridden by cmdline value)
+#   - define MACHINE_ASFLAGS variable (overridden by cmdline value)
+#   - can define CPU_CFLAGS variable (overridden by cmdline value) that
+#     overrides the one defined in arch.
+#   - can define CPU_LDFLAGS variable (overridden by cmdline value) that
+#     overrides the one defined in arch.
+#   - can define CPU_ASFLAGS variable (overridden by cmdline value) that
+#     overrides the one defined in arch.
+#   - may override any previously defined variable
+#
+
+# ARCH =
+# CROSS =
+# MACHINE_CFLAGS =
+# MACHINE_LDFLAGS =
+# MACHINE_ASFLAGS =
+# CPU_CFLAGS =
+# CPU_LDFLAGS =
+# CPU_ASFLAGS =
+
+MACHINE_CFLAGS = -march=core-avx-i
+
+# On FreeBSD systems, sometimes the correct CPU type is not picked up.
+# To get everything to compile, we need SSE4.2 support, so check if that is
+# reported by compiler. If not, check if the CPU actually supports it, and if
+# so, set the compilation target to be a corei7, minimum target with SSE4.2.
+SSE42_SUPPORT=$(shell $(CC) -march=native -dM -E - </dev/null | grep SSE4_2)
+ifeq ($(SSE42_SUPPORT),)
+    MACHINE_CFLAGS = -march=corei7
+endif
-- 
2.19.1

