2020-04-24 23:36:52 +00:00
|
|
|
{ stdenv, lib
|
|
|
|
, kernel
|
|
|
|
, fetchurl
|
2021-02-05 17:12:51 +00:00
|
|
|
, pkg-config, meson, ninja
|
2021-12-19 01:06:50 +00:00
|
|
|
, libbsd, numactl, libbpf, zlib, libelf, jansson, openssl, libpcap, rdma-core
|
2020-04-24 23:36:52 +00:00
|
|
|
, doxygen, python3
|
2021-07-24 12:14:16 +00:00
|
|
|
, withExamples ? []
|
2020-04-24 23:36:52 +00:00
|
|
|
, shared ? false }:
|
|
|
|
|
|
|
|
let
|
|
|
|
mod = kernel != null;
|
2021-12-19 01:06:50 +00:00
|
|
|
dpdkVersion = "21.11";
|
2020-04-24 23:36:52 +00:00
|
|
|
in stdenv.mkDerivation rec {
|
2021-05-28 09:39:13 +00:00
|
|
|
pname = "dpdk";
|
|
|
|
version = "${dpdkVersion}" + lib.optionalString mod "-${kernel.version}";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2021-05-28 09:39:13 +00:00
|
|
|
url = "https://fast.dpdk.org/rel/dpdk-${dpdkVersion}.tar.xz";
|
2021-12-19 01:06:50 +00:00
|
|
|
sha256 = "sha256-Mkbj7WjuKzaaXYviwGzxCKZp4Vf01Bxby7sha/Wr06E=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
doxygen
|
|
|
|
meson
|
|
|
|
ninja
|
2021-02-05 17:12:51 +00:00
|
|
|
pkg-config
|
2020-04-24 23:36:52 +00:00
|
|
|
python3
|
|
|
|
python3.pkgs.sphinx
|
2021-05-28 09:39:13 +00:00
|
|
|
python3.pkgs.pyelftools
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
buildInputs = [
|
|
|
|
jansson
|
|
|
|
libbpf
|
|
|
|
libbsd
|
|
|
|
libelf
|
|
|
|
libpcap
|
|
|
|
numactl
|
|
|
|
openssl.dev
|
|
|
|
zlib
|
|
|
|
] ++ lib.optionals mod kernel.moduleBuildDependencies;
|
|
|
|
|
2021-12-19 01:06:50 +00:00
|
|
|
# Propagated to support current DPDK users in nixpkgs which statically link
|
|
|
|
# with the framework (e.g. odp-dpdk).
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
rdma-core
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
postPatch = ''
|
2020-07-18 16:06:22 +00:00
|
|
|
patchShebangs config/arm buildtools
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
mesonFlags = [
|
2021-05-28 09:39:13 +00:00
|
|
|
"-Dtests=false"
|
2020-04-24 23:36:52 +00:00
|
|
|
"-Denable_docs=true"
|
2020-10-27 00:29:36 +00:00
|
|
|
"-Denable_kmods=${lib.boolToString mod}"
|
2020-04-24 23:36:52 +00:00
|
|
|
]
|
2021-05-28 09:39:13 +00:00
|
|
|
# kni kernel driver is currently not compatble with 5.11
|
|
|
|
++ lib.optional (mod && kernel.kernelOlder "5.11") "-Ddisable_drivers=kni"
|
2020-04-24 23:36:52 +00:00
|
|
|
++ lib.optional (!shared) "-Ddefault_library=static"
|
|
|
|
++ lib.optional stdenv.isx86_64 "-Dmachine=nehalem"
|
2021-12-19 01:06:50 +00:00
|
|
|
++ lib.optional stdenv.isAarch64 "-Dmachine=generic"
|
2021-07-24 12:14:16 +00:00
|
|
|
++ lib.optional mod "-Dkernel_dir=${placeholder "kmod"}/lib/modules/${kernel.modDirVersion}"
|
|
|
|
++ lib.optional (withExamples != []) "-Dexamples=${builtins.concatStringsSep "," withExamples}";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# dpdk meson script does not support separate kernel source and installion
|
|
|
|
# dirs (except via destdir), so we temporarily link the former into the latter.
|
|
|
|
preConfigure = lib.optionalString mod ''
|
|
|
|
mkdir -p $kmod/lib/modules/${kernel.modDirVersion}
|
|
|
|
ln -sf ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \
|
|
|
|
$kmod/lib/modules/${kernel.modDirVersion}
|
|
|
|
'';
|
|
|
|
|
|
|
|
postBuild = lib.optionalString mod ''
|
|
|
|
rm -f $kmod/lib/modules/${kernel.modDirVersion}/build
|
|
|
|
'';
|
|
|
|
|
2021-12-19 01:06:50 +00:00
|
|
|
postInstall = ''
|
|
|
|
# Remove Sphinx cache files. Not only are they not useful, but they also
|
|
|
|
# contain store paths causing spurious dependencies.
|
|
|
|
rm -rf $out/share/doc/dpdk/html/.doctrees
|
|
|
|
'' + lib.optionalString (withExamples != []) ''
|
2021-07-24 12:14:16 +00:00
|
|
|
find examples -type f -executable -exec install {} $out/bin \;
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
outputs = [ "out" ] ++ lib.optional mod "kmod";
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Set of libraries and drivers for fast packet processing";
|
|
|
|
homepage = "http://dpdk.org/";
|
|
|
|
license = with licenses; [ lgpl21 gpl2 bsd2 ];
|
|
|
|
platforms = platforms.linux;
|
2021-07-24 12:14:16 +00:00
|
|
|
maintainers = with maintainers; [ magenbluten orivej mic92 zhaofengli ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|