Skip to content

Commit

Permalink
Merge pull request #15919 from abuibrahim/master
Browse files Browse the repository at this point in the history
dpdk: refactor to allow building extapps
  • Loading branch information
domenkozar committed Jun 2, 2016
2 parents 8ff2d76 + 6d3fcd3 commit 55b8868
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/maintainers.nix
Expand Up @@ -11,6 +11,7 @@
abaldeau = "Andreas Baldeau <andreas@baldeau.net>";
abbradar = "Nikolay Amiantov <ab@fmap.me>";
aboseley = "Adam Boseley <adam.boseley@gmail.com>";
abuibrahim = "Ruslan Babayev <ruslan@babayev.com>";
adev = "Adrien Devresse <adev@adev.name>";
Adjective-Object = "Maxwell Huang-Hobbs <mhuan13@gmail.com>";
adnelson = "Allen Nelson <ithinkican@gmail.com>";
Expand Down
34 changes: 28 additions & 6 deletions pkgs/os-specific/linux/dpdk/default.nix
@@ -1,4 +1,4 @@
{ stdenv, lib, kernel, fetchurl }:
{ stdenv, lib, kernel, fetchurl, pkgconfig, libvirt }:

assert lib.versionAtLeast kernel.version "3.18";

Expand All @@ -11,14 +11,16 @@ stdenv.mkDerivation rec {
sha256 = "0yrz3nnhv65v2jzz726bjswkn8ffqc1sr699qypc9m78qrdljcfn";
};

buildInputs = [ pkgconfig libvirt ];

RTE_KERNELDIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
RTE_TARGET = "x86_64-native-linuxapp-gcc";

# we need ssse3 instructions to build
NIX_CFLAGS_COMPILE = [ "-march=core2" ];

enableParallelBuilding = true;
outputs = [ "out" "examples" ];
outputs = [ "out" "kmod" "examples" ];

buildPhase = ''
make T=x86_64-native-linuxapp-gcc config
Expand All @@ -27,11 +29,31 @@ stdenv.mkDerivation rec {
'';

installPhase = ''
mkdir $out
cp -pr x86_64-native-linuxapp-gcc/{app,lib,include,kmod} $out/
install -m 0755 -d $out/lib
install -m 0644 ${RTE_TARGET}/lib/*.a $out/lib
install -m 0755 -d $out/include
install -m 0644 ${RTE_TARGET}/include/*.h $out/include
install -m 0755 -d $out/include/generic
install -m 0644 ${RTE_TARGET}/include/generic/*.h $out/include/generic
install -m 0755 -d $out/include/exec-env
install -m 0644 ${RTE_TARGET}/include/exec-env/*.h $out/include/exec-env
install -m 0755 -d $out/${RTE_TARGET}
install -m 0644 ${RTE_TARGET}/.config $out/${RTE_TARGET}
install -m 0755 -d $out/${RTE_TARGET}/include
install -m 0644 ${RTE_TARGET}/include/rte_config.h $out/${RTE_TARGET}/include
cp -pr mk scripts $out/
mkdir -p $kmod/lib/modules/${kernel.modDirVersion}/kernel/drivers/net
cp ${RTE_TARGET}/kmod/*.ko $kmod/lib/modules/${kernel.modDirVersion}/kernel/drivers/net
mkdir $examples
cp -pr examples/* $examples/
mkdir -p $examples/bin
find examples ${RTE_TARGET}/app -type f -executable -exec cp {} $examples/bin \;
'';

meta = with stdenv.lib; {
Expand Down
38 changes: 38 additions & 0 deletions pkgs/os-specific/linux/pktgen/default.nix
@@ -0,0 +1,38 @@
{ stdenv, fetchurl, dpdk, libpcap, utillinux }:

stdenv.mkDerivation rec {
name = "pktgen-${version}";
version = "3.0.00";

src = fetchurl {
url = "http://dpdk.org/browse/apps/pktgen-dpdk/snapshot/pktgen-${version}.tar.gz";
sha256 = "703f8bd615aa4ae3a3085055483f9889dda09d082abb58afd33c1ba7c766ea65";
};

buildInputs = [ dpdk libpcap ];

RTE_SDK = "${dpdk}";
RTE_TARGET = "x86_64-native-linuxapp-gcc";

enableParallelBuilding = true;

patchPhase = ''
sed -i -e s:/usr/local:$out:g lib/lua/src/luaconf.h
sed -i -e s:/usr/bin/lscpu:${utillinux}/bin/lscpu:g lib/common/wr_lscpu.h
'';

installPhase = ''
install -d $out/bin
install -m 0755 app/app/${RTE_TARGET}/app/pktgen $out/bin
install -d $out/lib/lua/5.3
install -m 0644 Pktgen.lua $out/lib/lua/5.3
'';

meta = with stdenv.lib; {
description = "Traffic generator powered by DPDK";
homepage = http://dpdk.org/;
license = licenses.bsdOriginal;
platforms = [ "x86_64-linux" ];
maintainers = [ maintainers.abuibrahim ];
};
}
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Expand Up @@ -10848,6 +10848,8 @@ in

dpdk = callPackage ../os-specific/linux/dpdk { };

pktgen = callPackage ../os-specific/linux/pktgen { };

e1000e = callPackage ../os-specific/linux/e1000e {};

v4l2loopback = callPackage ../os-specific/linux/v4l2loopback { };
Expand Down

0 comments on commit 55b8868

Please sign in to comment.