2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.networking.rxe;
|
|
|
|
|
|
|
|
in {
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
networking.rxe = {
|
2022-09-09 14:08:57 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "RDMA over converged ethernet");
|
2020-04-24 23:36:52 +00:00
|
|
|
interfaces = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ ];
|
|
|
|
example = [ "eth0" ];
|
2022-09-09 14:08:57 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Enable RDMA on the listed interfaces. The corresponding virtual
|
2022-09-09 14:08:57 +00:00
|
|
|
RDMA interfaces will be named rxe_\<interface\>.
|
2020-04-24 23:36:52 +00:00
|
|
|
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" ];
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = true;
|
|
|
|
ExecStart = map ( x:
|
2021-04-08 16:26:57 +00:00
|
|
|
"${pkgs.iproute2}/bin/rdma link add rxe_${x} type rxe netdev ${x}"
|
2020-04-24 23:36:52 +00:00
|
|
|
) cfg.interfaces;
|
|
|
|
|
|
|
|
ExecStop = map ( x:
|
2021-04-08 16:26:57 +00:00
|
|
|
"${pkgs.iproute2}/bin/rdma link delete rxe_${x}"
|
2020-04-24 23:36:52 +00:00
|
|
|
) cfg.interfaces;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|