summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-01-13 06:47:10 +0100
committerChristian Breunig <christian@breunig.cc>2023-01-13 06:47:10 +0100
commite7ac306c31f51c1b6d6ec2dd1aef86744f3fc794 (patch)
treeb8ad6aced298e6f82bbcc24140f8764ab44c0ca7
parentc0ffb8ba4e6639254a853c18f1433d1677d7703d (diff)
downloadvyos-1x-e7ac306c31f51c1b6d6ec2dd1aef86744f3fc794.tar.gz
vyos-1x-e7ac306c31f51c1b6d6ec2dd1aef86744f3fc794.zip
ethernet: rps: T4928: adjust to Kernel ABI changes #2
Fix ValueError: Unknown format code 'x' for object of type 'str' added in commit c0ffb8ba4e663 ("ethernet: rps: T4928: adjust to Kernel ABI changes").
-rw-r--r--python/vyos/ifconfig/ethernet.py12
-rwxr-xr-xsmoketest/scripts/cli/test_interfaces_ethernet.py2
2 files changed, 9 insertions, 5 deletions
diff --git a/python/vyos/ifconfig/ethernet.py b/python/vyos/ifconfig/ethernet.py
index b45d8ea28..5080144ff 100644
--- a/python/vyos/ifconfig/ethernet.py
+++ b/python/vyos/ifconfig/ethernet.py
@@ -239,7 +239,7 @@ class EthernetIf(Interface):
if not isinstance(state, bool):
raise ValueError('Value out of range')
- rps_cpus = '0'
+ rps_cpus = 0
queues = len(glob(f'/sys/class/net/{self.ifname}/queues/rx-*'))
if state:
# Enable RPS on all available CPUs except CPU0 which we will not
@@ -248,9 +248,13 @@ class EthernetIf(Interface):
# representation of the CPUs which should participate on RPS, we
# can enable more CPUs that are physically present on the system,
# Linux will clip that internally!
- rps_cpus = os.cpu_count()
- if rps_cpus > 1:
- rps_cpus -= 1
+ rps_cpus = (1 << os.cpu_count()) -1
+
+ # XXX: we should probably reserve one core when the system is under
+ # high preasure so we can still have a core left for housekeeping.
+ # This is done by masking out the lowst bit so CPU0 is spared from
+ # receive packet steering.
+ rps_cpus &= ~1
for i in range(0, queues):
self._write_sysfs(f'/sys/class/net/{self.ifname}/queues/rx-{i}/rps_cpus', f'{rps_cpus:x}')
diff --git a/smoketest/scripts/cli/test_interfaces_ethernet.py b/smoketest/scripts/cli/test_interfaces_ethernet.py
index ed611062a..e53413f0d 100755
--- a/smoketest/scripts/cli/test_interfaces_ethernet.py
+++ b/smoketest/scripts/cli/test_interfaces_ethernet.py
@@ -160,7 +160,7 @@ class EthernetInterfaceTest(BasicInterfaceTest.TestCase):
self.assertFalse(is_intf_addr_assigned(intf, addr['addr']))
def test_offloading_rps(self):
- # enable RPS on all available CPUs, RPS works woth a CPU bitmask,
+ # enable RPS on all available CPUs, RPS works with a CPU bitmask,
# where each bit represents a CPU (core/thread). The formula below
# expands to rps_cpus = 255 for a 8 core system
rps_cpus = (1 << os.cpu_count()) -1