1 { config, lib, pkgs, ... }:
4 cfg = config.services.rshim;
6 rshimCommand = [ "${cfg.package}/bin/rshim" ]
7 ++ lib.optionals (cfg.backend != null) [ "--backend ${cfg.backend}" ]
8 ++ lib.optionals (cfg.device != null) [ "--device ${cfg.device}" ]
9 ++ lib.optionals (cfg.index != null) [ "--index ${builtins.toString cfg.index}" ]
10 ++ [ "--log-level ${builtins.toString cfg.log-level}" ]
14 options.services.rshim = {
15 enable = lib.mkEnableOption "user-space rshim driver for the BlueField SoC";
17 package = lib.mkPackageOption pkgs "rshim-user-space" { };
19 backend = lib.mkOption {
20 type = with lib.types; nullOr (enum [ "usb" "pcie" "pcie_lf" ]);
22 Specify the backend to attach. If not specified, the driver will scan
23 all rshim backends unless the `device` option is given with a device
30 device = lib.mkOption {
31 type = with lib.types; nullOr str;
33 Specify the device name to attach. The backend driver can be deduced
34 from the device name, thus the `backend` option is not needed.
37 example = "pcie-04:00.2";
40 index = lib.mkOption {
41 type = with lib.types; nullOr int;
43 Specify the index to create device path `/dev/rshim<index>`. It's also
44 used to create network interface name `tmfifo_net<index>`. This option
45 is needed when multiple rshim instances are running.
51 log-level = lib.mkOption {
54 Specify the log level (0:none, 1:error, 2:warning, 3:notice, 4:debug).
60 config = lib.mkOption {
61 type = with lib.types; attrsOf (oneOf [ int str ]);
63 Structural setting for the rshim configuration file
64 (`/etc/rshim.conf`). It can be used to specify the static mapping
65 between rshim devices and rshim names. It can also be used to ignore
77 config = lib.mkIf cfg.enable {
78 environment.etc = lib.mkIf (cfg.config != { }) {
79 "rshim.conf".text = lib.generators.toKeyValue
80 { mkKeyValue = lib.generators.mkKeyValueDefault { } " "; }
84 systemd.services.rshim = {
85 after = [ "network.target" ];
90 (lib.concatStringsSep " \\\n" rshimCommand)
92 KillMode = "control-group";
94 wantedBy = [ "multi-user.target" ];
98 meta.maintainers = with lib.maintainers; [ nikstur ];