| 1 |
# Kernel Module Loading |
| 2 |
|
| 3 |
The RDMA subsystem relies on the kernel, udev and systemd to load modules on |
| 4 |
demand when RDMA hardware is present. The RDMA subsystem is unique since it |
| 5 |
does not load the optional RDMA hardware modules unless the system has the |
| 6 |
rdma-core package installed. |
| 7 |
|
| 8 |
This is to avoid exposing systems not using RDMA from having RDMA enabled, for |
| 9 |
instance if a system has a multi-protocol ethernet adapter, but is only using |
| 10 |
the net stack interface. |
| 11 |
|
| 12 |
## Boot ordering with systemd |
| 13 |
|
| 14 |
systemd assumes everything is hot pluggable and runs in an event driven |
| 15 |
manner. This creates a chain of hot plug events as each part of the system |
| 16 |
autoloads based on earlier parts. The first step in the process is udev |
| 17 |
loading the physical hardware driver. |
| 18 |
|
| 19 |
This can happen in several spots along the bootup: |
| 20 |
|
| 21 |
- From the initrd or built into the kernel. If hardware modules are present |
| 22 |
in the initrd then they are loaded into the kernel before booting the |
| 23 |
system. This is done largely synchronously with the boot process. |
| 24 |
|
| 25 |
- From udev when it auto detects PCI hardware or otherwise. |
| 26 |
This happens asynchronously in the boot process, systemd does not wait for |
| 27 |
udev to finish loading modules before it continues on. |
| 28 |
|
| 29 |
This path makes it very likely the system will experience an RDMA 'hot plug' |
| 30 |
scenario. |
| 31 |
|
| 32 |
- From systemd's fixed module loader systemd-modules-load.service, e.g. from |
| 33 |
the list in /etc/modules-load.d/. In this case the modules load happens |
| 34 |
synchronously within systemd and it will hold off sysinit.target until |
| 35 |
modules are loaded |
| 36 |
|
| 37 |
Once the hardware module is loaded it may be necessary to load a protocol |
| 38 |
module, e.g. to enable RDMA support on an ethernet device. |
| 39 |
|
| 40 |
This is triggered automatically by udev rules that match the master devices |
| 41 |
and load the protocol module with udev's module loader. This happens |
| 42 |
asynchronously to the rest of the systemd startup. |
| 43 |
|
| 44 |
Once an RDMA device is created by the kernel then udev will cause systemd to |
| 45 |
schedule ULP module loading services (e.g. [email protected]) specific |
| 46 |
to the plugged hardware. If sysinit.target has not yet been passed, then these |
| 47 |
loaders will defer sysinit.target until they complete, otherwise this is a hot |
| 48 |
plug event and things will load asynchronously to the boot up process. |
| 49 |
|
| 50 |
Finally, udev will cause systemd to start RDMA specific daemons like |
| 51 |
srp_daemon, rdma-ndd and iwpmd. These starts are linked to the detection of |
| 52 |
the first RDMA hardware, and the daemons internally handle hot plug events for |
| 53 |
other hardware. |
| 54 |
|
| 55 |
## Hot Plug compatible services |
| 56 |
|
| 57 |
Services using RDMA need to have device specific systemd dependencies in their |
| 58 |
unit files, either created by hand by the admin or by using udev rules. |
| 59 |
|
| 60 |
For instance, a service that uses /dev/infiniband/umad0 requires: |
| 61 |
|
| 62 |
``` |
| 63 |
After=dev-infiniband-umad0.device |
| 64 |
BindsTo=dev-infiniband-umad0.device |
| 65 |
``` |
| 66 |
|
| 67 |
Which will ensure the service will not run until the required umad device |
| 68 |
appears, and will be stopped if the umad device is unplugged. |
| 69 |
|
| 70 |
This is similar to how systemd handles mounting filesystems and configuring |
| 71 |
ethernet devices. |
| 72 |
|
| 73 |
## Interaction with legacy non-hotplug services |
| 74 |
|
| 75 |
Services that cannot handle hot plug must be ordered after |
| 76 |
systemd-udev-settle.service, which will wait for udev to complete loading |
| 77 |
modules and scheduling systemd services. This ensures that all RDMA hardware |
| 78 |
present at boot is setup before proceeding to run the legacy service. |
| 79 |
|
| 80 |
Admins using legacy services can also place their RDMA hardware modules |
| 81 |
(e.g. mlx4_ib) directly in /etc/modules-load.d/ or in their initrd which will |
| 82 |
cause systemd to defer passing to sysinit.target until all RDMA hardware is |
| 83 |
setup, this is usually sufficient for legacy services. This is probably the |
| 84 |
default behavior in many configurations. |
| 85 |
|
| 86 |
# Systemd Ordering |
| 87 |
|
| 88 |
Within rdma-core we have a series of units which run in the pre `basic.target` |
| 89 |
world to setup kernel services: |
| 90 |
|
| 91 |
- `iwpmd` |
| 92 |
- `rdma-ndd` |
| 93 |
- `[email protected]` |
| 94 |
- `ibacmd.socket` |
| 95 |
|
| 96 |
These special units use DefaultDependencies=no and order before any other unit that |
| 97 |
uses DefaultDependencies=yes. This will happen even in the case of hotplug. |
| 98 |
|
| 99 |
Units for normal rdma-using daemons should use DefaultDependencies=yes, and |
| 100 |
either this pattern for 'any RDMA device': |
| 101 |
|
| 102 |
``` |
| 103 |
[Unit] |
| 104 |
# Order after rdma-hw.target has become active and setup the kernel services |
| 105 |
Requires=rdma-hw.target |
| 106 |
After=rdma-hw.target |
| 107 |
|
| 108 |
[Install] |
| 109 |
# Autostart when RDMA hardware is present |
| 110 |
WantedBy=rdma-hw.target |
| 111 |
``` |
| 112 |
|
| 113 |
Or this pattern for a specific RDMA device: |
| 114 |
|
| 115 |
``` |
| 116 |
[Unit] |
| 117 |
# Order after RDMA services are setup |
| 118 |
After=rdma-hw.target |
| 119 |
# Run only while a specific umad device is present |
| 120 |
After=dev-infiniband-umad0.device |
| 121 |
BindsTo=dev-infiniband-umad0.device |
| 122 |
|
| 123 |
[Install] |
| 124 |
# Schedule the unit to be runnable when RDMA hardware is present, but |
| 125 |
# it will only start once the requested device actually appears. |
| 126 |
WantedBy=rdma-hw.target |
| 127 |
``` |
| 128 |
|
| 129 |
Note, the above does explicitly reference `After=rdma-hw.target` even though |
| 130 |
all the current constituents of that target order before |
| 131 |
`sysinit.target`. This is to provide greater flexibility in the future. |
| 132 |
|
| 133 |
## rdma-hw.target |
| 134 |
|
| 135 |
This target is Wanted automatically by udev as soon as any RDMA hardware is |
| 136 |
plugged in or becomes available at boot. |
| 137 |
|
| 138 |
This may be used to pull in rdma management daemons dynamically when RDMA |
| 139 |
hardware is found. Such daemons should use: |
| 140 |
|
| 141 |
``` |
| 142 |
[Install] |
| 143 |
WantedBy=rdma-hw.target |
| 144 |
``` |
| 145 |
|
| 146 |
In their unit files. |
| 147 |
|
| 148 |
`rdma-hw.target` is also a synchronization point that orders after the low level, |
| 149 |
pre `sysinit.target` RDMA related units have been started. |
| 150 |
|
| 151 |
# Stable names |
| 152 |
|
| 153 |
The library provides general utility and udev rule to automatically perform |
| 154 |
stable IB device name assignments, so users will always see names based on |
| 155 |
topology/GUID information. Such naming scheme has big advantage that the |
| 156 |
names are fully automatic, fully predictable and they stay fixed even if |
| 157 |
hardware is added or removed (i.e. no renumeration takes place) and that |
| 158 |
broken hardware can be replaced seamlessly. |
| 159 |
|
| 160 |
The name is combination of link type (Infiniband, RoCE, iWARP, OPA or USNIC) |
| 161 |
and the chosen naming policy, like NAME_KERNEL, NAME_PCI, NAME_GUID, NAME_ONBOARD |
| 162 |
or NAME_FALLBACK. Those naming policies are controlled by udev rule and can be |
| 163 |
overwritten by placing own rename policy udev rules into /etc/udev/rules.d/ |
| 164 |
directory. |
| 165 |
|
| 166 |
* NAME_KERNEL - don't change names and rely on kernel assignment. This |
| 167 |
will keep RDMA names as before. Example: "mlx5_0". |
| 168 |
* NAME_PCI - read PCI location and topology as a source for stable names, |
| 169 |
which won't change in any software event (reset, PCI probe etc.). |
| 170 |
Example: "ibp0s12f4". |
| 171 |
* NAME_GUID - read node GUID information in similar manner to |
| 172 |
net MAC naming policy. Example "rocex525400c0fe123455". |
| 173 |
* NAME_ONBOARD - read Firmware/BIOS provided index numbers for on-board devices. |
| 174 |
Example: "ibo3". |
| 175 |
* NAME_FALLBACK - automatic fallback: NAME_ONBOARD->NAME_PCI->NAME_KERNEL |
| 176 |
|
| 177 |
No doubts that new names are harder to read than the "mlx5_0" everybody, |
| 178 |
is used to, but being consistent in scripts is much more important. |
| 179 |
|
| 180 |
There is a distinction between real devices and virtual ones like RXE or SIW. |
| 181 |
For real devices, the naming policy is NAME_FALLBACK, while virtual devices keep |
| 182 |
their kernel name. |
| 183 |
|
| 184 |
In similar way to netdev, NAME_GUID scheme is not participating in fallback mechanism |
| 185 |
and needs to be enabled explicitly by the users. |
| 186 |
|
| 187 |
Type of names: |
| 188 |
|
| 189 |
* o<index> - on-board device index number |
| 190 |
* s<slot>[f<function>] - hotplug slot index number |
| 191 |
* x<GUID> - Node GUID |
| 192 |
* [P<domain>]p<bus>s<slot>[f<function>] - PCI geographical location |
| 193 |
|
| 194 |
Notes: |
| 195 |
|
| 196 |
* All multi-function PCI devices will carry the [f<function>] number in the |
| 197 |
device name, including the function 0 device. |
| 198 |
* When using PCI geography, The PCI domain is only prepended when it is not 0. |
| 199 |
* SR-IOV virtual devices are named based on the name of the parent interface, |
| 200 |
with a suffix of "v<N>", where <N> is the virtual device number. |