summaryrefslogtreecommitdiff
path: root/python/vyos/ethtool.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-08-31 21:50:05 +0200
committerChristian Poessinger <christian@poessinger.com>2021-08-31 22:01:44 +0200
commitde3c476ccb60d66a844f9e12a9ca2963ae2206e6 (patch)
tree7d82387a6ce75f8771c9875acc7b7f8bf55ebbbe /python/vyos/ethtool.py
parent5cbb1f3e4adba39d790f378afabb1e45416aff7c (diff)
downloadvyos-1x-de3c476ccb60d66a844f9e12a9ca2963ae2206e6.tar.gz
vyos-1x-de3c476ccb60d66a844f9e12a9ca2963ae2206e6.zip
ethernet: T3163: only change ring-buffer settings if required
Only update the RX/TX ring-buffer settings if they are different from the ones currently programmed to the hardware. There is no need to write the same value to the hardware again - this could cause traffic disruption on some NICs. (cherry picked from commit 29082959e0efc02462fba8560d6726096e8743e9)
Diffstat (limited to 'python/vyos/ethtool.py')
-rw-r--r--python/vyos/ethtool.py29
1 files changed, 22 insertions, 7 deletions
diff --git a/python/vyos/ethtool.py b/python/vyos/ethtool.py
index e803e28a1..f5796358d 100644
--- a/python/vyos/ethtool.py
+++ b/python/vyos/ethtool.py
@@ -43,6 +43,7 @@ class Ethtool:
# }
_speed_duplex = { }
_ring_buffers = { }
+ _ring_buffers_max = { }
_driver_name = None
_auto_negotiation = None
@@ -99,7 +100,7 @@ class Ethtool:
'fixed' : fixed
}
- out, err = popen(f'ethtool -g {ifname}')
+ out, err = popen(f'ethtool --show-ring {ifname}')
# We are only interested in line 2-5 which contains the device maximum
# ringbuffers
for line in out.splitlines()[2:6]:
@@ -110,6 +111,16 @@ class Ethtool:
# output format from 0 -> n/a. As we are only interested in the
# tx/rx keys we do not care about RX Mini/Jumbo.
if value.isdigit():
+ self._ring_buffers_max[key] = int(value)
+ # Now we wan't to get the current RX/TX ringbuffer values - used for
+ for line in out.splitlines()[7:11]:
+ if ':' in line:
+ key, value = [s.strip() for s in line.strip().split(":", 1)]
+ key = key.lower().replace(' ', '_')
+ # T3645: ethtool version used on Debian Bullseye changed the
+ # output format from 0 -> n/a. As we are only interested in the
+ # tx/rx keys we do not care about RX Mini/Jumbo.
+ if value.isdigit():
self._ring_buffers[key] = int(value)
def _get_generic(self, feature):
@@ -143,15 +154,19 @@ class Ethtool:
def get_tcp_segmentation_offload(self):
return self._get_generic('tcp-segmentation-offload')
- def get_rx_buffer(self):
- # Configuration of RX ring-buffers is not supported on every device,
+ def get_ring_buffer_max(self, rx_tx):
+ # Configuration of RX/TX ring-buffers is not supported on every device,
# thus when it's impossible return None
- return self._ring_buffers.get('rx', None)
+ if rx_tx not in ['rx', 'tx']:
+ ValueError('Ring-buffer type must be either "rx" or "tx"')
+ return self._ring_buffers_max.get(rx_tx, None)
- def get_tx_buffer(self):
- # Configuration of TX ring-buffers is not supported on every device,
+ def get_ring_buffer(self, rx_tx):
+ # Configuration of RX/TX ring-buffers is not supported on every device,
# thus when it's impossible return None
- return self._ring_buffers.get('tx', None)
+ if rx_tx not in ['rx', 'tx']:
+ ValueError('Ring-buffer type must be either "rx" or "tx"')
+ return self._ring_buffers.get(rx_tx, None)
def check_speed_duplex(self, speed, duplex):
""" Check if the passed speed and duplex combination is supported by