summaryrefslogtreecommitdiff
path: root/python/vyos/ethtool.py
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-05-04 22:18:12 +0200
committerChristian Breunig <christian@breunig.cc>2023-05-04 22:21:10 +0200
commitf2ecc9710d49d320409700bc72f42632f72b369d (patch)
tree4b8213949d669d5a1f72176338c8c323fc4e922c /python/vyos/ethtool.py
parentdd59e375bee722c220c58b047ff5c6e533cc7a00 (diff)
downloadvyos-1x-f2ecc9710d49d320409700bc72f42632f72b369d.tar.gz
vyos-1x-f2ecc9710d49d320409700bc72f42632f72b369d.zip
ethernet: T3891: honor auto-negotiation support per NIC
Not all drivers/NICs or combination of NIC + transceiver support auto- negotiation. The current auto-negotiation capability is evaluated and taken into account when applying spped/duplex settings. If auto-negotiation is not supported - we skip the setting to avoid errors during configuration.
Diffstat (limited to 'python/vyos/ethtool.py')
-rw-r--r--python/vyos/ethtool.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/python/vyos/ethtool.py b/python/vyos/ethtool.py
index bc3402059..9d016e5cc 100644
--- a/python/vyos/ethtool.py
+++ b/python/vyos/ethtool.py
@@ -51,6 +51,7 @@ class Ethtool:
_ring_buffers_max = { }
_driver_name = None
_auto_negotiation = False
+ _auto_negotiation_supported = None
_flow_control = False
_flow_control_enabled = None
@@ -80,7 +81,13 @@ class Ethtool:
self._speed_duplex.update({ speed : {}})
if duplex not in self._speed_duplex[speed]:
self._speed_duplex[speed].update({ duplex : ''})
- if 'Auto-negotiation:' in line:
+ if 'Supports auto-negotiation:':
+ # Split the following string: Auto-negotiation: off
+ # we are only interested in off or on
+ tmp = line.split()[-1]
+ self._auto_negotiation_supported = bool(tmp == 'Yes')
+ # Only read in if Auto-negotiation is supported
+ if self._auto_negotiation_supported and 'Auto-negotiation:' in line:
# Split the following string: Auto-negotiation: off
# we are only interested in off or on
tmp = line.split()[-1]
@@ -132,8 +139,12 @@ class Ethtool:
# ['Autonegotiate:', 'on']
self._flow_control_enabled = out.splitlines()[1].split()[-1]
+ def check_auto_negotiation_supported(self):
+ """ Check if the NIC supports changing auto-negotiation """
+ return self._auto_negotiation_supported
+
def get_auto_negotiation(self):
- return self._auto_negotiation
+ return self._auto_negotiation_supported and self._auto_negotiation
def get_driver_name(self):
return self._driver_name