2019-11-10 00:46:26 +00:00
|
|
|
{ stdenv, lib
|
|
|
|
, kernel
|
|
|
|
, fetchurl
|
2021-01-19 06:50:56 +00:00
|
|
|
, pkg-config, meson, ninja
|
2019-11-10 00:46:26 +00:00
|
|
|
, libbsd, numactl, libbpf, zlib, libelf, jansson, openssl, libpcap
|
|
|
|
, doxygen, python3
|
2021-07-23 07:25:30 +01:00
|
|
|
, withExamples ? []
|
2019-11-10 00:46:26 +00:00
|
|
|
, shared ? false }:
|
2016-04-20 16:11:34 +01:00
|
|
|
|
2018-05-20 23:43:35 +01:00
|
|
|
let
|
|
|
|
mod = kernel != null;
|
2021-06-17 09:57:04 +01:00
|
|
|
dpdkVersion = "21.05";
|
2018-05-20 23:43:35 +01:00
|
|
|
in stdenv.mkDerivation rec {
|
2021-05-11 15:02:37 +01:00
|
|
|
pname = "dpdk";
|
|
|
|
version = "${dpdkVersion}" + lib.optionalString mod "-${kernel.version}";
|
2016-04-20 16:11:34 +01:00
|
|
|
|
|
|
|
src = fetchurl {
|
2021-05-11 15:02:37 +01:00
|
|
|
url = "https://fast.dpdk.org/rel/dpdk-${dpdkVersion}.tar.xz";
|
2021-06-17 09:57:04 +01:00
|
|
|
sha256 = "sha256-HhJJm0xfzbV8g+X+GE6mvs3ffPCSiTwsXvLvsO7BLws=";
|
2016-04-20 16:11:34 +01:00
|
|
|
};
|
|
|
|
|
2019-11-10 00:46:26 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
doxygen
|
|
|
|
meson
|
|
|
|
ninja
|
2021-01-19 06:50:56 +00:00
|
|
|
pkg-config
|
2019-11-10 00:46:26 +00:00
|
|
|
python3
|
|
|
|
python3.pkgs.sphinx
|
2021-05-11 15:02:37 +01:00
|
|
|
python3.pkgs.pyelftools
|
2019-11-10 00:46:26 +00:00
|
|
|
];
|
|
|
|
buildInputs = [
|
|
|
|
jansson
|
|
|
|
libbpf
|
|
|
|
libbsd
|
|
|
|
libelf
|
|
|
|
libpcap
|
|
|
|
numactl
|
|
|
|
openssl.dev
|
|
|
|
zlib
|
|
|
|
] ++ lib.optionals mod kernel.moduleBuildDependencies;
|
2016-05-31 13:35:54 +01:00
|
|
|
|
2018-05-21 03:32:18 +01:00
|
|
|
postPatch = ''
|
2020-06-30 11:40:58 +01:00
|
|
|
patchShebangs config/arm buildtools
|
2018-05-20 23:43:35 +01:00
|
|
|
'';
|
|
|
|
|
2019-11-10 00:46:26 +00:00
|
|
|
mesonFlags = [
|
2021-05-11 15:02:37 +01:00
|
|
|
"-Dtests=false"
|
2019-11-10 00:46:26 +00:00
|
|
|
"-Denable_docs=true"
|
2020-10-14 00:46:17 +01:00
|
|
|
"-Denable_kmods=${lib.boolToString mod}"
|
2019-11-10 00:46:26 +00:00
|
|
|
]
|
2021-05-11 15:02:37 +01:00
|
|
|
# kni kernel driver is currently not compatble with 5.11
|
|
|
|
++ lib.optional (mod && kernel.kernelOlder "5.11") "-Ddisable_drivers=kni"
|
2019-12-23 08:49:35 +00:00
|
|
|
++ lib.optional (!shared) "-Ddefault_library=static"
|
2019-11-10 00:46:26 +00:00
|
|
|
++ lib.optional stdenv.isx86_64 "-Dmachine=nehalem"
|
2021-07-23 07:25:30 +01:00
|
|
|
++ lib.optional mod "-Dkernel_dir=${placeholder "kmod"}/lib/modules/${kernel.modDirVersion}"
|
|
|
|
++ lib.optional (withExamples != []) "-Dexamples=${builtins.concatStringsSep "," withExamples}";
|
2019-12-23 08:49:35 +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
|
|
|
|
'';
|
2018-05-20 23:43:35 +01:00
|
|
|
|
2021-07-23 07:25:30 +01:00
|
|
|
postInstall = lib.optionalString (withExamples != []) ''
|
|
|
|
find examples -type f -executable -exec install {} $out/bin \;
|
|
|
|
'';
|
|
|
|
|
2018-05-20 23:43:35 +01:00
|
|
|
outputs = [ "out" ] ++ lib.optional mod "kmod";
|
|
|
|
|
|
|
|
meta = with lib; {
|
2016-04-20 16:11:34 +01:00
|
|
|
description = "Set of libraries and drivers for fast packet processing";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "http://dpdk.org/";
|
2016-04-20 16:11:34 +01:00
|
|
|
license = with licenses; [ lgpl21 gpl2 bsd2 ];
|
2019-11-10 00:46:26 +00:00
|
|
|
platforms = platforms.linux;
|
2021-07-23 07:25:30 +01:00
|
|
|
maintainers = with maintainers; [ magenbluten orivej mic92 zhaofengli ];
|
2016-04-20 16:11:34 +01:00
|
|
|
};
|
|
|
|
}
|