Disable network card offloading in NixOS
My homelab server is an Intel NUC which has the Ethernet card e1000e on the mainboard. In the latest Linux kernel, the unit can hang when the kernel attempts to offload certain processing to the NIC. The hardware can be stabilized by disabling the offloading.
Issue Detection
In the server journal, there are entries similar to:
kernel: e1000e 0000:00:1f.6 eno1: Detected Hardware Unit Hang:
TDH <a5>
TDT <d0>
next_to_use <d0>
next_to_clean <a4>
buffer_info[next_to_clean]:
time_stamp <10307af6d>
next_to_watch <a5>
jiffies <10307b8c0>
next_to_watch.status <0>
MAC Status <40080083>
PHY Status <796d>
PHY 1000BASE-T Status <3800>
PHY Extended Status <3000>
PCI Status <10>
Solution
Disable offloading via the ethtool
command:1
ethtool -K eno1 gso off gro off tso off tx off rx off rxvlan off txvlan off
Then, check that all offloading is disabled with:
ethtool -k eno1 | grep offload
Persist in NixOS
Add a systemd service to the host configuration that executes ethtool before the network is started.2
systemd.services.ethtool-eno1 = {
description = "ethtool-eno1";
serviceConfig = {
Type = "oneshot";
User = "root";
ExecStart = "${pkgs.ethtool}/bin/ethtool -K eno1 gso off gro off tso off tx off rx off rxvlan off txvlan off";
};
# https://systemd.io/NETWORK_ONLINE/
wantedBy = [ "network-pre.target" ];
};
You can execute the check in nix-shell:
nix-shell -p ethtool --run "ethtool -k eno1" | grep offload