summaryrefslogtreecommitdiff
path: root/python/vyos/ethtool.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-08-31 23:03:01 +0200
committerChristian Poessinger <christian@poessinger.com>2021-08-31 23:34:25 +0200
commit0229645c8248decb5664056df8aa5cd5dff41802 (patch)
tree087ffff33d98fa816c9eddf007e4d2e400616021 /python/vyos/ethtool.py
parent8834c22dc3f5758c1d2364579acc428cfc0fe650 (diff)
downloadvyos-1x-0229645c8248decb5664056df8aa5cd5dff41802.tar.gz
vyos-1x-0229645c8248decb5664056df8aa5cd5dff41802.zip
vyos.ethtool: T3163: purify code to read and change flow-control settings
It makes no sense to have a parser for the ethtool values in ethtool.py and ethernet.py - one instance ios more then enough!
Diffstat (limited to 'python/vyos/ethtool.py')
-rw-r--r--python/vyos/ethtool.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/python/vyos/ethtool.py b/python/vyos/ethtool.py
index f5796358d..87b9d7dd0 100644
--- a/python/vyos/ethtool.py
+++ b/python/vyos/ethtool.py
@@ -46,6 +46,8 @@ class Ethtool:
_ring_buffers_max = { }
_driver_name = None
_auto_negotiation = None
+ _flow_control = None
+ _flow_control_enabled = None
def __init__(self, ifname):
# Get driver used for interface
@@ -123,6 +125,15 @@ class Ethtool:
if value.isdigit():
self._ring_buffers[key] = int(value)
+ # Get current flow control settings, but this is not supported by
+ # all NICs (e.g. vmxnet3 does not support is)
+ out, err = popen(f'ethtool --show-pause {ifname}')
+ if len(out.splitlines()) > 1:
+ self._flow_control = True
+ # read current flow control setting, this returns:
+ # ['Autonegotiate:', 'on']
+ self._flow_control_enabled = out.splitlines()[1].split()[-1]
+
def _get_generic(self, feature):
"""
Generic method to read self._features and return a tuple for feature
@@ -186,5 +197,17 @@ class Ethtool:
return True
return False
+ def check_flow_control(self):
+ """ Check if the NIC supports flow-control """
+ if self._driver_name in ['vmxnet3', 'virtio_net', 'xen_netfront']:
+ return False
+ return self._flow_control
+
+ def get_flow_control(self):
+ if self._flow_control_enabled == None:
+ raise ValueError('Interface does not support changing '\
+ 'flow-control settings!')
+ return self._flow_control_enabled
+
def get_auto_negotiation(self):
return self._auto_negotiation