From 2d571212a5c5556386eb5a224eb6b084184bd1871d6efe84efbbbe3fe0221f6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ismail=20D=C3=B6nmez?= Date: Tue, 26 Apr 2016 09:01:32 +0000 Subject: [PATCH] Accepting request 390534 from home:markoschandras:network I want to maintain dpdk in Factory and would like to use network as the devel project. OBS-URL: https://build.opensuse.org/request/show/390534 OBS-URL: https://build.opensuse.org/package/show/network/dpdk?expand=0&rev=1 --- .gitattributes | 23 ++ .gitignore | 1 + ...-punning-and-strict-aliasing-warning.patch | 36 +++ ...line-fix-implicit-declaration-of-fun.patch | 27 ++ ...ed-library-dependencies-of-libraries.patch | 152 +++++++++ 0004-mk-fix-gcc-5-version-on-suse.patch | 41 +++ dpdk-stable-2.2.0.tar.gz | 3 + dpdk.changes | 44 +++ dpdk.spec | 288 ++++++++++++++++++ 9 files changed, 615 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 0001-enic-fix-Type-punning-and-strict-aliasing-warning.patch create mode 100644 0002-examples-ip_pipeline-fix-implicit-declaration-of-fun.patch create mode 100644 0003-mk-fix-external-shared-library-dependencies-of-libraries.patch create mode 100644 0004-mk-fix-gcc-5-version-on-suse.patch create mode 100644 dpdk-stable-2.2.0.tar.gz create mode 100644 dpdk.changes create mode 100644 dpdk.spec diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/0001-enic-fix-Type-punning-and-strict-aliasing-warning.patch b/0001-enic-fix-Type-punning-and-strict-aliasing-warning.patch new file mode 100644 index 0000000..59dae45 --- /dev/null +++ b/0001-enic-fix-Type-punning-and-strict-aliasing-warning.patch @@ -0,0 +1,36 @@ +From 8b7d703c5d892060c663697c74e30e2ee91362a8 Mon Sep 17 00:00:00 2001 +From: Nirmoy Das +Date: Mon, 11 Apr 2016 15:01:06 +0200 +Subject: [PATCH 1/2] enic: fix "Type-punning and strict-aliasing" warning + +Inspired by http://pkgs.fedoraproject.org/cgit/rpms/dpdk.git/tree/dpdk-2.2-punning.patch +--- + drivers/net/enic/enic_ethdev.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c +index 6bea940..d0214b6 100644 +--- a/drivers/net/enic/enic_ethdev.c ++++ b/drivers/net/enic/enic_ethdev.c +@@ -372,13 +372,15 @@ static void enicpmd_dev_stop(struct rte_eth_dev *eth_dev) + { + struct rte_eth_link link; + struct enic *enic = pmd_priv(eth_dev); ++ uint64_t *dev_link_ptr = (uint64_t *)ð_dev->data->dev_link; ++ uint64_t *link_ptr = (uint64_t *)&link; + + ENICPMD_FUNC_TRACE(); + enic_disable(enic); + memset(&link, 0, sizeof(link)); +- rte_atomic64_cmpset((uint64_t *)ð_dev->data->dev_link, +- *(uint64_t *)ð_dev->data->dev_link, +- *(uint64_t *)&link); ++ rte_atomic64_cmpset(dev_link_ptr, ++ *dev_link_ptr, ++ *link_ptr); + } + + /* +-- +2.6.2 + diff --git a/0002-examples-ip_pipeline-fix-implicit-declaration-of-fun.patch b/0002-examples-ip_pipeline-fix-implicit-declaration-of-fun.patch new file mode 100644 index 0000000..f7b24b6 --- /dev/null +++ b/0002-examples-ip_pipeline-fix-implicit-declaration-of-fun.patch @@ -0,0 +1,27 @@ +From 760a997d09d671d3d90f738bae7d0c6e466bf058 Mon Sep 17 00:00:00 2001 +From: Nirmoy Das +Date: Mon, 11 Apr 2016 15:28:31 +0200 +Subject: [PATCH 2/2] examples/ip_pipeline: fix implicit declaration of + function '_mm_crc32_u64' + +Inspired by http://pkgs.fedoraproject.org/cgit/rpms/dpdk.git/tree/dpdk-2.2-examples.patch +--- + examples/ip_pipeline/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile +index 10fe1ba..472dc5d 100644 +--- a/examples/ip_pipeline/Makefile ++++ b/examples/ip_pipeline/Makefile +@@ -73,7 +73,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_routing_be.c + SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_routing.c + + CFLAGS += -I$(SRCDIR) -I$(SRCDIR)/pipeline +-CFLAGS += -O3 ++CFLAGS += -O3 -msse4 + CFLAGS += $(WERROR_FLAGS) -Wno-error=unused-function -Wno-error=unused-variable + + include $(RTE_SDK)/mk/rte.extapp.mk +-- +2.6.2 + diff --git a/0003-mk-fix-external-shared-library-dependencies-of-libraries.patch b/0003-mk-fix-external-shared-library-dependencies-of-libraries.patch new file mode 100644 index 0000000..18608ce --- /dev/null +++ b/0003-mk-fix-external-shared-library-dependencies-of-libraries.patch @@ -0,0 +1,152 @@ +commit f85ab16a916be178a4cb61575f414c43fc98313d +Author: Panu Matilainen +Date: Tue Dec 8 13:42:26 2015 +0200 + + mk: fix external shared library dependencies of libraries + + Similar to commit 5f9115e58cc6f304ff4ade694cf5823d32887d1a etc, but + for libraries. Clean up librte_vhost CFLAGS/LDFLAGS/LDLIBS confusion + while at it. + + Requiring applications to know about library internal details like + dependencies to external helper libraries is a limitation of + static linkage, shared libraries should always know their own + dependencies for sane operation. + + Linking with the combined library (whether shared or not) still + requires knowing the internal dependencies, and intra-dpdk + dependencies are also not currently recorded. + + Signed-off-by: Panu Matilainen + +diff --git a/app/test/Makefile b/app/test/Makefile +index ec33e1a..abb0545 100644 +--- a/app/test/Makefile ++++ b/app/test/Makefile +@@ -182,6 +182,8 @@ endif + endif + endif + ++LDLIBS += -lm ++ + include $(RTE_SDK)/mk/rte.app.mk + + endif +diff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile +index 65b293f..b7b6016 100644 +--- a/lib/librte_eal/bsdapp/eal/Makefile ++++ b/lib/librte_eal/bsdapp/eal/Makefile +@@ -42,6 +42,9 @@ CFLAGS += -I$(RTE_SDK)/lib/librte_ring + CFLAGS += -I$(RTE_SDK)/lib/librte_mempool + CFLAGS += $(WERROR_FLAGS) -O3 + ++LDLIBS += -lpthread ++LDLIBS += -ldl ++ + EXPORT_MAP := rte_eal_version.map + + LIBABIVER := 2 +diff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile +index 26eced5..0efb9e4 100644 +--- a/lib/librte_eal/linuxapp/eal/Makefile ++++ b/lib/librte_eal/linuxapp/eal/Makefile +@@ -47,6 +47,9 @@ CFLAGS += -I$(RTE_SDK)/lib/librte_mempool + CFLAGS += -I$(RTE_SDK)/lib/librte_ivshmem + CFLAGS += $(WERROR_FLAGS) -O3 + ++LDLIBS += -lpthread ++LDLIBS += -ldl ++ + # specific to linuxapp exec-env + SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) := eal.c + SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_hugepage_info.c +diff --git a/lib/librte_sched/Makefile b/lib/librte_sched/Makefile +index b1cb285..4d631f6 100644 +--- a/lib/librte_sched/Makefile ++++ b/lib/librte_sched/Makefile +@@ -41,6 +41,9 @@ CFLAGS += $(WERROR_FLAGS) + + CFLAGS_rte_red.o := -D_GNU_SOURCE + ++LDLIBS += -lm ++LDLIBS += -lrt ++ + EXPORT_MAP := rte_sched_version.map + + LIBABIVER := 1 +diff --git a/lib/librte_vhost/Makefile b/lib/librte_vhost/Makefile +index 6681f22..4aecc69 100644 +--- a/lib/librte_vhost/Makefile ++++ b/lib/librte_vhost/Makefile +@@ -42,12 +42,12 @@ CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3 -D_FILE_OFFSET_BITS=64 + ifeq ($(CONFIG_RTE_LIBRTE_VHOST_USER),y) + CFLAGS += -I vhost_user + else +-CFLAGS += -I vhost_cuse -lfuse +-LDFLAGS += -lfuse ++CFLAGS += -I vhost_cuse ++LDLIBS += -lfuse + endif + + ifeq ($(CONFIG_RTE_LIBRTE_VHOST_NUMA),y) +-LDFLAGS += -lnuma ++LDLIBS += -lnuma + endif + + # all source are stored in SRCS-y +diff --git a/mk/exec-env/linuxapp/rte.vars.mk b/mk/exec-env/linuxapp/rte.vars.mk +index 5fd7d85..d51bd17 100644 +--- a/mk/exec-env/linuxapp/rte.vars.mk ++++ b/mk/exec-env/linuxapp/rte.vars.mk +@@ -48,7 +48,7 @@ endif + # Workaround lack of DT_NEEDED entry + EXECENV_LDFLAGS = --no-as-needed + +-EXECENV_LDLIBS = -lrt -lm ++EXECENV_LDLIBS = + EXECENV_ASFLAGS = + + ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y) +diff --git a/mk/rte.app.mk b/mk/rte.app.mk +index 8ecab41..4ecaa6c 100644 +--- a/mk/rte.app.mk ++++ b/mk/rte.app.mk +@@ -81,23 +81,11 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_LPM) += -lrte_lpm + _LDLIBS-$(CONFIG_RTE_LIBRTE_POWER) += -lrte_power + _LDLIBS-$(CONFIG_RTE_LIBRTE_ACL) += -lrte_acl + _LDLIBS-$(CONFIG_RTE_LIBRTE_METER) += -lrte_meter +- + _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED) += -lrte_sched +-_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED) += -lm +-_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED) += -lrt +- + _LDLIBS-$(CONFIG_RTE_LIBRTE_VHOST) += -lrte_vhost + + endif # ! CONFIG_RTE_BUILD_COMBINE_LIBS + +-ifeq ($(CONFIG_RTE_LIBRTE_VHOST_NUMA),y) +-_LDLIBS-$(CONFIG_RTE_LIBRTE_VHOST) += -lnuma +-endif +- +-ifeq ($(CONFIG_RTE_LIBRTE_VHOST_USER),n) +-_LDLIBS-$(CONFIG_RTE_LIBRTE_VHOST) += -lfuse +-endif +- + # The static libraries do not know their dependencies. + # The combined library fails also to store this information. + # So linking with static or combined library requires explicit dependencies. +@@ -111,6 +99,14 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += -lxenstore + _LDLIBS-$(CONFIG_RTE_LIBRTE_MPIPE_PMD) += -lgxio + # QAT PMD has a dependency on libcrypto (from openssl) for calculating HMAC precomputes + _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_QAT) += -lcrypto ++_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED) += -lm ++_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED) += -lrt ++ifeq ($(CONFIG_RTE_LIBRTE_VHOST_NUMA),y) ++_LDLIBS-$(CONFIG_RTE_LIBRTE_VHOST) += -lnuma ++endif ++ifeq ($(CONFIG_RTE_LIBRTE_VHOST_USER),n) ++_LDLIBS-$(CONFIG_RTE_LIBRTE_VHOST) += -lfuse ++endif + endif # CONFIG_RTE_BUILD_COMBINE_LIBS or not CONFIG_RTE_BUILD_SHARED_LIBS + + _LDLIBS-y += --start-group diff --git a/0004-mk-fix-gcc-5-version-on-suse.patch b/0004-mk-fix-gcc-5-version-on-suse.patch new file mode 100644 index 0000000..f74d42a --- /dev/null +++ b/0004-mk-fix-gcc-5-version-on-suse.patch @@ -0,0 +1,41 @@ +From a5c5b9f76767badb3f198326bd5cbbebba803e36 Mon Sep 17 00:00:00 2001 +From: Markos Chandras +Date: Tue, 22 Mar 2016 17:13:36 +0000 +Subject: [PATCH] mk: fix gcc-5 version on Suse + +In openSUSE Tumbleweed (and in any other SUSE distribution which +uses (or will use) gcc >= 5), gcc -dumpversion returns '5'. This is on +purpose as discussed in https://bugzilla.opensuse.org/show_bug.cgi?id=941428 +As a result of which, the gcc-4.x comparison (40 against 5) does not +work leading to tons of warnings and failures during build. + +This patch aims to change the way the gcc version is obtained by using +the gcc macros directly. +This is similar to what's being used in the Linux kernel. Querying the +GCC macros directly gives more accurate results compared to -dumpversion +which could vary across distributions. + +Signed-off-by: Markos Chandras +Acked-by: Thomas Monjalon +--- + mk/toolchain/gcc/rte.toolchain-compat.mk | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/mk/toolchain/gcc/rte.toolchain-compat.mk b/mk/toolchain/gcc/rte.toolchain-compat.mk +index e144216..6eed20c 100644 +--- a/mk/toolchain/gcc/rte.toolchain-compat.mk ++++ b/mk/toolchain/gcc/rte.toolchain-compat.mk +@@ -38,7 +38,9 @@ + + #find out GCC version + +-GCC_VERSION = $(subst .,,$(shell $(CC) -dumpversion | cut -f1-2 -d.)) ++GCC_MAJOR = $(shell echo __GNUC__ | $(CC) -E -x c - | tail -n 1) ++GCC_MINOR = $(shell echo __GNUC_MINOR__ | $(CC) -E -x c - | tail -n 1) ++GCC_VERSION = $(GCC_MAJOR)$(GCC_MINOR) + + # if GCC is older than 4.x + ifeq ($(shell test $(GCC_VERSION) -lt 40 && echo 1), 1) +-- +2.7.3 + diff --git a/dpdk-stable-2.2.0.tar.gz b/dpdk-stable-2.2.0.tar.gz new file mode 100644 index 0000000..23dd792 --- /dev/null +++ b/dpdk-stable-2.2.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6bdf2202a063f999c2fbea727efd990dea56304f5ee63873df48b9ee2e4a55c1 +size 16160932 diff --git a/dpdk.changes b/dpdk.changes new file mode 100644 index 0000000..f8259aa --- /dev/null +++ b/dpdk.changes @@ -0,0 +1,44 @@ +------------------------------------------------------------------- +Mon Apr 18 08:45:58 UTC 2016 - mchandras@suse.de + +- Use fdupes to manage duplicate files + +------------------------------------------------------------------- +Wed Apr 13 10:56:08 UTC 2016 - mchandras@suse.de + +- Move the combined library back to the devel package (bsc#975123) + Ever since we dropped the CONFIG_RTE_BUILD_COMBINE_LIBS=y option, the + libdpdk.so is no longer a shared object but rather a linker script + generated by the spec file. This means that it is only used during + linking and the linker will add the individual DPDK libraries to the + DT_NEEDED tag on the dependent binaries. + +------------------------------------------------------------------- +Tue Apr 12 12:45:40 UTC 2016 - mchandras@suse.de + +- Fix shared linking against libdpdk.so (bsc#975123) + * Restore the 0003-mk-fix-external-shared-library-dependencies-of-libraries.patch + patch which sets the correct dependencies for the shared libraries. + * Drop CONFIG_RTE_BUILD_COMBINE_LIBS since a custom linker script + is used to create and install a more lightweight version of libdpdk.so. + * Include the combined libdpdk.so library to the regular package since it + is also necessary during runtime. + +------------------------------------------------------------------- +Mon Apr 11 16:12:09 CEST 2016 - ndas@suse.de + +- Removed unwnated patch and reformated patch file names(bsc#974903). + [- dpdk-2.2-dtneeded.patch, + - dpdk-2.2-examples.patch, + - enic-pun-fix.patch, + - dpdk-2.2-warningflags.patch, + + 0001-enic-fix-Type-punning-and-strict-aliasing-warning.patch + + 0002-examples-ip_pipeline-fix-implicit-declaration-of-fun.patch] +- Added CONFIG_RTE_BUILD_COMBINE_LIBS flags to club all all *.so into + one library + +------------------------------------------------------------------- +Mon Mar 21 14:15:08 UTC 2016 - nirmoy.das@suse.com + +- Intial version 2.2.0(fate#319169) + diff --git a/dpdk.spec b/dpdk.spec new file mode 100644 index 0000000..dbce1f0 --- /dev/null +++ b/dpdk.spec @@ -0,0 +1,288 @@ +# +# spec file for package dpdk +# +# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# + + +%define machine native +%define target x86_64-%{machine}-linuxapp-gcc +%bcond_without shared +# Add option to build without examples +%bcond_without examples +# Add option to build without tools +%bcond_without tools +Name: dpdk +Version: 2.2.0 +Release: 0 +Summary: Set of libraries and drivers for fast packet processing +License: BSD-3-Clause +Group: System/Libraries +Url: http://dpdk.org +Source: http://dpdk.org/browse/dpdk/snapshot/dpdk-stable-%{version}.tar.gz +Patch1: 0001-enic-fix-Type-punning-and-strict-aliasing-warning.patch +Patch2: 0002-examples-ip_pipeline-fix-implicit-declaration-of-fun.patch +Patch3: 0003-mk-fix-external-shared-library-dependencies-of-libraries.patch +# PATCH-FIX-UPSTREAM: 0004-mk-fix-gcc-5-version-on-suse.patch +Patch4: 0004-mk-fix-gcc-5-version-on-suse.patch +BuildRequires: fdupes +BuildRequires: doxygen +BuildRequires: libnuma-devel +BuildRequires: libpcap-devel +BuildRequires: zlib-devel +# +# The DPDK is designed to optimize througput of network traffic using, among +# other techniques, carefully crafted x86 assembly instructions. As such it +# currently (and likely never will) run on non-x86 platforms +# +ExclusiveArch: x86_64 + +%description +The Data Plane Development Kit is a set of libraries and drivers for +fast packet processing in the user space. + +%package devel +Summary: Data Plane Development Kit development files +Group: Development/Libraries/C and C++ +Requires: %{name} = %{version} + +%description devel +This package contains the headers and other files needed for developing +applications with the Data Plane Development Kit. + +%package doc +Summary: Data Plane Development Kit API documentation +BuildArch: noarch + +%description doc +API programming documentation for the Data Plane Development Kit. + +%if %{with tools} +%package tools +Summary: Tools for setting up Data Plane Development Kit environment +Requires: %{name} = %{version} +Requires: findutils +Requires: iproute +Requires: kmod +Requires: pciutils + +%description tools +This package contains tools for setting up Data Plane Development Kit environment +%endif + +%if %{with examples} +%package examples +Summary: Data Plane Development Kit example applications +BuildRequires: libvirt-devel + +%description examples +Example applications utilizing the Data Plane Development Kit, such +as L2 and L3 forwarding. +%endif + +%define sdkdir %{_datadir}/%{name} +%define docdir %{_docdir}/%{name} +%define incdir %{_includedir}/%{name} +%define pmddir %{_libdir}/%{name}-pmds + +%prep +%setup -q -n dpdk-stable-2.2.0 +%patch1 -p1 -z .enic +%patch2 -p1 -z .examples +%patch3 -p1 -z .dtneeded +%patch4 -p1 -z .rtetoolchain + +%build +# set up a method for modifying the resulting .config file +function setconf() { + if grep -q ^$1= %{target}/.config; then + sed -i "s:^$1=.*$:$1=$2:g" %{target}/.config + else + echo $1=$2 >> %{target}/.config + fi +} + +# In case dpdk-devel is installed, we should ignore its hints about the SDK directories +unset RTE_SDK RTE_INCLUDE RTE_TARGET + +# For the release, '-Wno-error=array-bounds' is done to prevent a spurious error +# generated by gcc 5.X against the 2.1 branch +export EXTRA_CFLAGS="%{optflags} -Wformat -fPIC -Wno-error=array-bounds" + +# DPDK defaults to using builder-specific compiler flags. However, +# the config has been changed by specifying CONFIG_RTE_MACHINE=default +# in order to build for a more generic host. NOTE: It is possible that +# the compiler flags used still won't work for all Fedora-supported +# machines, but runtime checks in DPDK will catch those situations. + +make V=1 O=%{target} T=%{target} %{?_smp_mflags} config + +setconf CONFIG_RTE_MACHINE '"default"' +# Disable experimental features +setconf CONFIG_RTE_NEXT_ABI n +setconf CONFIG_RTE_LIBRTE_CRYPTODEV n +setconf CONFIG_RTE_LIBRTE_MBUF_OFFLOAD n + +# Enable automatic driver loading from this path +setconf CONFIG_RTE_EAL_PMD_PATH '"%{pmddir}"' + +setconf CONFIG_RTE_LIBRTE_BNX2X_PMD y +setconf CONFIG_RTE_LIBRTE_PMD_PCAP y +setconf CONFIG_RTE_LIBRTE_VHOST_NUMA y + +setconf CONFIG_RTE_EAL_IGB_UIO n +setconf CONFIG_RTE_LIBRTE_KNI n +setconf CONFIG_RTE_KNI_KMOD n +setconf CONFIG_RTE_KNI_PREEMPT_DEFAULT n + +%if %{with shared} +setconf CONFIG_RTE_BUILD_SHARED_LIB y +%endif + +make V=1 O=%{target} %{?_smp_mflags} +make V=1 O=%{target} %{?_smp_mflags} doc-api-html + +%if %{with examples} +make V=1 O=%{target}/examples T=%{target} %{?_smp_mflags} examples +%endif + +%install +# In case dpdk-devel is installed +unset RTE_SDK RTE_INCLUDE RTE_TARGET + +%make_install O=%{target} prefix=%{_usr} libdir=%{_libdir} + +%if ! %{with tools} +rm -rf %{buildroot}%{sdkdir}/tools +rm -rf %{buildroot}%{_sbindir}/dpdk_nic_bind +%endif +rm -f %{buildroot}%{sdkdir}/tools/setup.sh + +%if %{with examples} +find %{target}/examples/ -name "*.map" | xargs rm -f +for f in %{target}/examples/*/%{target}/app/*; do + bn=`basename ${f}` + cp -p ${f} %{buildroot}%{_bindir}/dpdk_example_${bn} +done +%endif + +# Create a driver directory with symlinks to all pmds +mkdir -p %{buildroot}/%{pmddir} +for f in %{buildroot}/%{_libdir}/*_pmd_*.so; do + bn=$(basename ${f}) + ln -s ../${bn} %{buildroot}%{pmddir}/${bn} +done + +# Setup RTE_SDK environment as expected by apps etc +mkdir -p %{buildroot}/%{_sysconfdir}/profile.d +cat << EOF > %{buildroot}/%{_sysconfdir}/profile.d/dpdk-sdk-%{_arch}.sh +if [ -z "\${RTE_SDK}" ]; then + export RTE_SDK="%{sdkdir}" + export RTE_TARGET="%{target}" + export RTE_INCLUDE="%{incdir}" +fi +EOF + +cat << EOF > %{buildroot}/%{_sysconfdir}/profile.d/dpdk-sdk-%{_arch}.csh +if ( ! \$RTE_SDK ) then + setenv RTE_SDK "%{sdkdir}" + setenv RTE_TARGET "%{target}" + setenv RTE_INCLUDE "%{incdir}" +endif +EOF + +# Fixup target machine mismatch +sed -i -e 's:-%{machine}-:-default-:g' %{buildroot}/%{_sysconfdir}/profile.d/dpdk-sdk* + +# Upstream has an option to build a combined library but it's bloatware which +# wont work at all when library versions start moving, replace it with a +# linker script which avoids these issues. Linking against the script during +# build resolves into links to the actual used libraries which is just fine +# for us, so this combined library is a build-time only construct now. +%if %{with shared} +libext=so +%else +libext=a +%endif +comblib=libdpdk.${libext} + +echo "GROUP (" > ${comblib} +find %{buildroot}/%{_libdir}/ -name "*.${libext}" |\ + sed -e "s:^%{buildroot}/: :g" >> ${comblib} +echo ")" >> ${comblib} +install -m 644 ${comblib} %{buildroot}/%{_libdir}/${comblib} +#doc +mkdir %{buildroot}%{_docdir}/ +mv %{buildroot}%{_datadir}/doc/dpdk %{buildroot}%{_docdir}/ + +# Remove duplicates +%fdupes %{buildroot}/%{_prefix} + +%post devel -p /sbin/ldconfig +%postun devel -p /sbin/ldconfig +%post -p /sbin/ldconfig +%postun -p /sbin/ldconfig + +%files +%defattr(-,root,root) +# BSD +%{_bindir}/testpmd +%{_bindir}/dpdk_proc_info + +%if %{with shared} +%dir %{_libdir}/dpdk-pmds + +%{_libdir}/*.so.* +%{pmddir}/ +%endif + +%files doc +%defattr(-,root,root) +#BSD +%docdir +%doc LICENSE.GPL LICENSE.LGPL + +%files devel +%defattr(-,root,root) +#BSD +%{incdir}/ +%{sdkdir} +%if %{with tools} +%exclude %{sdkdir}/tools/ +%endif +%if %{with examples} +%exclude %{sdkdir}/examples/ +%endif +%{_sysconfdir}/profile.d/dpdk-sdk-*.* +%if ! %{with shared} +%{_libdir}/*.a +%else +%{_libdir}/*.so +%endif + +%if %{with tools} +%files tools +%defattr(-,root,root) +%{sdkdir}/tools/ +%{_sbindir}/dpdk_nic_bind +%endif + +%if %{with examples} +%files examples +%defattr(-,root,root) +%{_bindir}/dpdk_example_* +%doc %{sdkdir}/examples +%endif + +%changelog