feat(ethtool): add automatic tuning
diff --git a/playbooks/kubernetes.yml b/playbooks/kubernetes.yml
index dbad10f..ebd5dc1 100644
--- a/playbooks/kubernetes.yml
+++ b/playbooks/kubernetes.yml
@@ -15,6 +15,9 @@
- hosts: all
become: true
roles:
+ - role: ethtool
+ tags:
+ - ethtool
- role: containerd
- role: kubernetes
diff --git a/roles/ethtool/files/ethtool b/roles/ethtool/files/ethtool
new file mode 100644
index 0000000..d5f7721
--- /dev/null
+++ b/roles/ethtool/files/ethtool
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+logger -sp info "atmosphere: bumping network rx/tx buffers"
+
+for i in $(ls -l /sys/class/net/*/device/driver/module | cut -d/ -f5); do
+ logger -sp info "atmosphere: ${i} bumping network rx/tx buffers"
+
+ CURRENT_RX=$(ethtool -g ${i} | tac | grep -m1 '^RX:' | awk '{ print $2 }')
+ CURRENT_RX_MINI=$(ethtool -g ${i} | tac | grep -m1 '^RX Mini:' | awk '{ print $3 }')
+ CURRENT_RX_JUMBO=$(ethtool -g ${i} | tac | grep -m1 '^RX Jumbo:' | awk '{ print $3 }')
+ CURRENT_TX=$(ethtool -g ${i} | tac | grep -m1 '^TX:' | awk '{ print $2 }')
+
+ logger -sp info "atmosphere: ${i} current rx:${CURRENT_RX}, rxmini:${CURRENT_RX_MINI}, rxjumbo:${CURRENT_RX_JUMBO}, tx:${CURRENT_TX}"
+
+ MAX_RX=$(ethtool -g ${i} | grep -m1 '^RX:' | awk '{ print $2 }')
+ MAX_RX_MINI=$(ethtool -g ${i} | grep -m1 '^RX Mini:' | awk '{ print $3 }')
+ MAX_RX_JUMBO=$(ethtool -g ${i} | grep -m1 '^RX Jumbo:' | awk '{ print $3 }')
+ MAX_TX=$(ethtool -g ${i} | grep -m1 '^TX:' | awk '{ print $2 }')
+
+ logger -sp info "atmosphere: ${i} max rx:${MAX_RX}, rxmini:${MAX_RX_MINI}, rxjumbo:${MAX_RX_JUMBO}, tx:${MAX_TX}"
+
+ ethtool -G ${i} rx ${MAX_RX} rx-mini ${MAX_RX_MINI} rx-jumbo ${MAX_RX_JUMBO} tx ${MAX_TX} || :
+done
diff --git a/roles/ethtool/tasks/main.yml b/roles/ethtool/tasks/main.yml
new file mode 100644
index 0000000..742b7c0
--- /dev/null
+++ b/roles/ethtool/tasks/main.yml
@@ -0,0 +1,17 @@
+- name: Create folder for persistent configuration
+ ansible.builtin.file:
+ path: /etc/networkd-dispatcher/configuring.d
+ state: directory
+
+- name: Install persistent "ethtool" tuning
+ ansible.builtin.copy:
+ src: ethtool
+ dest: /etc/networkd-dispatcher/configuring.d/01-ethtool
+ mode: 0755
+ owner: root
+ group: root
+
+- name: Run "ethtool" tuning
+ ansible.builtin.command:
+ /etc/networkd-dispatcher/configuring.d/01-ethtool
+ changed_when: false