summary refs log tree commit diff
path: root/nixos/modules/services
diff options
context:
space:
mode:
authormarkuskowa <markus.kowalewski@gmail.com>2018-02-09 23:52:03 -0800
committerJörg Thalheim <Mic92@users.noreply.github.com>2018-02-10 07:52:03 +0000
commitbf53dc68c256603f572fdb4a38275d22c68865d4 (patch)
tree0dc95937137212eb3b49bc914610dccf3007e295 /nixos/modules/services
parent58cf763f8b72aae1f4e23688a277414c9cae438a (diff)
downloadnixlib-bf53dc68c256603f572fdb4a38275d22c68865d4.tar
nixlib-bf53dc68c256603f572fdb4a38275d22c68865d4.tar.gz
nixlib-bf53dc68c256603f572fdb4a38275d22c68865d4.tar.bz2
nixlib-bf53dc68c256603f572fdb4a38275d22c68865d4.tar.lz
nixlib-bf53dc68c256603f572fdb4a38275d22c68865d4.tar.xz
nixlib-bf53dc68c256603f572fdb4a38275d22c68865d4.tar.zst
nixlib-bf53dc68c256603f572fdb4a38275d22c68865d4.zip
nixos/rdma-core: add module for soft RoCE and test (#34607)
Diffstat (limited to 'nixos/modules/services')
-rw-r--r--nixos/modules/services/networking/rxe.nix63
1 files changed, 63 insertions, 0 deletions
diff --git a/nixos/modules/services/networking/rxe.nix b/nixos/modules/services/networking/rxe.nix
new file mode 100644
index 000000000000..a6a069ec50c0
--- /dev/null
+++ b/nixos/modules/services/networking/rxe.nix
@@ -0,0 +1,63 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.networking.rxe;
+
+  runRxeCmd = cmd: ifcs:
+    concatStrings ( map (x: "${pkgs.rdma-core}/bin/rxe_cfg -n ${cmd} ${x};") ifcs);
+
+  startScript = pkgs.writeShellScriptBin "rxe-start" ''
+    ${pkgs.rdma-core}/bin/rxe_cfg -n start
+    ${runRxeCmd "add" cfg.interfaces}
+    ${pkgs.rdma-core}/bin/rxe_cfg
+  '';
+
+  stopScript = pkgs.writeShellScriptBin "rxe-stop" ''
+    ${runRxeCmd "remove" cfg.interfaces }
+    ${pkgs.rdma-core}/bin/rxe_cfg -n stop
+  '';
+
+in {
+  ###### interface
+
+  options = {
+    networking.rxe = {
+      enable = mkEnableOption "RDMA over converged ethernet";
+      interfaces = mkOption {
+        type = types.listOf types.str;
+        default = [ ];
+        example = [ "eth0" ];
+        description = ''
+          Enable RDMA on the listed interfaces. The corresponding virtual
+          RDMA interfaces will be named rxe0 ... rxeN where the ordering
+          will be as they are named in the list. UDP port 4791 must be
+          open on the respective ethernet interfaces.
+        '';
+      };
+    };
+  };
+
+  ###### implementation
+
+  config = mkIf cfg.enable {
+
+    systemd.services.rxe = {
+      path = with pkgs; [ kmod rdma-core ];
+      description = "RoCE interfaces";
+
+      wantedBy = [ "multi-user.target" ];
+      after = [ "systemd-modules-load.service" "network-online.target" ];
+      wants = [ "network-pre.target" ];
+
+      serviceConfig = {
+        Type = "oneshot";
+        RemainAfterExit = true;
+        ExecStart = "${startScript}/bin/rxe-start";
+        ExecStop = "${stopScript}/bin/rxe-stop";
+      };
+    };
+  };
+}
+