summaryrefslogtreecommitdiffstats
path: root/nixos/modules/services/networking/rxe.nix
blob: f4617d900358d7afdd13766045480d9f3a06ed06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{
  config,
  lib,
  pkgs,
  ...
}:

with lib;

let
  cfg = config.networking.rxe;

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 rxe_\<interface\>.
          UDP port 4791 must be open on the respective ethernet interfaces.
        '';
      };
    };
  };

  ###### implementation

  config = mkIf cfg.enable {

    systemd.services.rxe = {
      description = "RoCE interfaces";

      wantedBy = [ "multi-user.target" ];
      after = [
        "systemd-modules-load.service"
        "network-online.target"
      ];
      wants = [
        "network-pre.target"
        "network-online.target"
      ];

      serviceConfig = {
        Type = "oneshot";
        RemainAfterExit = true;
        ExecStart = map (
          x: "${pkgs.iproute2}/bin/rdma link add rxe_${x} type rxe netdev ${x}"
        ) cfg.interfaces;

        ExecStop = map (x: "${pkgs.iproute2}/bin/rdma link delete rxe_${x}") cfg.interfaces;
      };
    };
  };
}