blob: d161e75752bbb8790954afb9c69ede8e5c5250b1 (
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.rshim;
rshimCommand = [
"${cfg.package}/bin/rshim"
]
++ lib.optionals (cfg.backend != null) [ "--backend ${cfg.backend}" ]
++ lib.optionals (cfg.device != null) [ "--device ${cfg.device}" ]
++ lib.optionals (cfg.index != null) [ "--index ${toString cfg.index}" ]
++ [ "--log-level ${toString cfg.log-level}" ];
in
{
options.services.rshim = {
enable = lib.mkEnableOption "user-space rshim driver for the BlueField SoC";
package = lib.mkPackageOption pkgs "rshim-user-space" { };
backend = lib.mkOption {
type =
with lib.types;
nullOr (enum [
"usb"
"pcie"
"pcie_lf"
]);
description = ''
Specify the backend to attach. If not specified, the driver will scan
all rshim backends unless the `device` option is given with a device
name specified.
'';
default = null;
example = "pcie";
};
device = lib.mkOption {
type = with lib.types; nullOr str;
description = ''
Specify the device name to attach. The backend driver can be deduced
from the device name, thus the `backend` option is not needed.
'';
default = null;
example = "pcie-04:00.2";
};
index = lib.mkOption {
type = with lib.types; nullOr int;
description = ''
Specify the index to create device path `/dev/rshim<index>`. It's also
used to create network interface name `tmfifo_net<index>`. This option
is needed when multiple rshim instances are running.
'';
default = null;
example = 1;
};
log-level = lib.mkOption {
type = lib.types.ints.between 0 4;
description = ''
Specify the log level (0:none, 1:error, 2:warning, 3:notice, 4:debug).
'';
default = 2;
example = 4;
};
config = lib.mkOption {
type =
with lib.types;
attrsOf (oneOf [
int
str
]);
description = ''
Structural setting for the rshim configuration file
(`/etc/rshim.conf`). It can be used to specify the static mapping
between rshim devices and rshim names. It can also be used to ignore
some rshim devices.
'';
default = { };
example = {
DISPLAY_LEVEL = 0;
rshim0 = "usb-2-1.7";
none = "usb-1-1.4";
};
};
};
config = lib.mkIf cfg.enable {
environment.etc = lib.mkIf (cfg.config != { }) {
"rshim.conf".text = lib.generators.toKeyValue {
mkKeyValue = lib.generators.mkKeyValueDefault { } " ";
} cfg.config;
};
systemd.services.rshim = {
after = [ "network.target" ];
serviceConfig = {
Restart = "always";
Type = "forking";
ExecStart = [
(lib.concatStringsSep " \\\n" rshimCommand)
];
KillMode = "control-group";
};
wantedBy = [ "multi-user.target" ];
};
};
meta.maintainers = with lib.maintainers; [ nikstur ];
}
|