From: Renjaya Raga Zenta Date: Fri, 16 Feb 2024 07:01:47 +0000 (+0700) Subject: test-network: Add test for rps_cpu_mask option X-Git-Tag: v256-rc1~710^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a6f5673c99f050d4a5e13b23bede3dfea9f1270c;p=thirdparty%2Fsystemd.git test-network: Add test for rps_cpu_mask option --- diff --git a/test/test-network/conf/24-rps-cpu-disable.link b/test/test-network/conf/24-rps-cpu-disable.link new file mode 100644 index 00000000000..fb3451ac3c8 --- /dev/null +++ b/test/test-network/conf/24-rps-cpu-disable.link @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +[Match] +OriginalName=dummy98 + +[Link] +ReceivePacketSteeringCPUMask=disable diff --git a/test/test-network/conf/24-rps-cpu-empty.link b/test/test-network/conf/24-rps-cpu-empty.link new file mode 100644 index 00000000000..fc1342bb8c2 --- /dev/null +++ b/test/test-network/conf/24-rps-cpu-empty.link @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +[Match] +OriginalName=dummy98 + +[Link] +ReceivePacketSteeringCPUMask= diff --git a/test/test-network/conf/24-rps-cpu-invalid.link b/test/test-network/conf/24-rps-cpu-invalid.link new file mode 100644 index 00000000000..76d6713b545 --- /dev/null +++ b/test/test-network/conf/24-rps-cpu-invalid.link @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +[Match] +OriginalName=dummy98 + +[Link] +ReceivePacketSteeringCPUMask=0 3 8-invalid diff --git a/test/test-network/conf/25-rps-cpu-0-1.link b/test/test-network/conf/25-rps-cpu-0-1.link new file mode 100644 index 00000000000..d026248b391 --- /dev/null +++ b/test/test-network/conf/25-rps-cpu-0-1.link @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +[Match] +OriginalName=dummy98 + +[Link] +ReceivePacketSteeringCPUMask=0 1 diff --git a/test/test-network/conf/25-rps-cpu-0-empty.link b/test/test-network/conf/25-rps-cpu-0-empty.link new file mode 100644 index 00000000000..b25b417f47d --- /dev/null +++ b/test/test-network/conf/25-rps-cpu-0-empty.link @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +[Match] +OriginalName=dummy98 + +[Link] +ReceivePacketSteeringCPUMask=0 +ReceivePacketSteeringCPUMask= diff --git a/test/test-network/conf/25-rps-cpu-0-invalid.link b/test/test-network/conf/25-rps-cpu-0-invalid.link new file mode 100644 index 00000000000..26147a098ea --- /dev/null +++ b/test/test-network/conf/25-rps-cpu-0-invalid.link @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +[Match] +OriginalName=dummy98 + +[Link] +ReceivePacketSteeringCPUMask=0 +ReceivePacketSteeringCPUMask=invalid diff --git a/test/test-network/conf/25-rps-cpu-0.link b/test/test-network/conf/25-rps-cpu-0.link new file mode 100644 index 00000000000..b1f4bc2c203 --- /dev/null +++ b/test/test-network/conf/25-rps-cpu-0.link @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +[Match] +OriginalName=dummy98 + +[Link] +ReceivePacketSteeringCPUMask=0 diff --git a/test/test-network/conf/25-rps-cpu-1.link b/test/test-network/conf/25-rps-cpu-1.link new file mode 100644 index 00000000000..d24d7135df6 --- /dev/null +++ b/test/test-network/conf/25-rps-cpu-1.link @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +[Match] +OriginalName=dummy98 + +[Link] +ReceivePacketSteeringCPUMask=1 diff --git a/test/test-network/conf/25-rps-cpu-all.link b/test/test-network/conf/25-rps-cpu-all.link new file mode 100644 index 00000000000..b7a8eda5228 --- /dev/null +++ b/test/test-network/conf/25-rps-cpu-all.link @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +[Match] +OriginalName=dummy98 + +[Link] +ReceivePacketSteeringCPUMask=all diff --git a/test/test-network/conf/25-rps-cpu-multi.link b/test/test-network/conf/25-rps-cpu-multi.link new file mode 100644 index 00000000000..d7d4d042685 --- /dev/null +++ b/test/test-network/conf/25-rps-cpu-multi.link @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +[Match] +OriginalName=dummy98 + +[Link] +ReceivePacketSteeringCPUMask=0 1 +ReceivePacketSteeringCPUMask=2,3 diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index aa7bd1e87aa..4f088f3f76e 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -2459,6 +2459,131 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities): self.wait_online('ifb99:degraded') + def test_rps_cpu_0(self): + copy_network_unit('12-dummy.netdev', '25-rps-cpu-0.link') + start_networkd() + + self.wait_links('dummy98') + + output = check_output('cat /sys/class/net/dummy98/queues/rx-0/rps_cpus') + print(output) + self.assertEqual(int(output.replace(',', ''), base=16), 1) + + @unittest.skipUnless(os.cpu_count() >= 2, reason="CPU count should be >= 2 to pass this test") + def test_rps_cpu_1(self): + copy_network_unit('12-dummy.netdev', '25-rps-cpu-1.link') + start_networkd() + + self.wait_links('dummy98') + + output = check_output('cat /sys/class/net/dummy98/queues/rx-0/rps_cpus') + print(output) + self.assertEqual(int(output.replace(',', ''), base=16), 2) + + @unittest.skipUnless(os.cpu_count() >= 2, reason="CPU count should be >= 2 to pass this test") + def test_rps_cpu_0_1(self): + copy_network_unit('12-dummy.netdev', '25-rps-cpu-0-1.link') + start_networkd() + + self.wait_links('dummy98') + + output = check_output('cat /sys/class/net/dummy98/queues/rx-0/rps_cpus') + print(output) + self.assertEqual(int(output.replace(',', ''), base=16), 3) + + @unittest.skipUnless(os.cpu_count() >= 4, reason="CPU count should be >= 4 to pass this test") + def test_rps_cpu_multi(self): + copy_network_unit('12-dummy.netdev', '25-rps-cpu-multi.link') + start_networkd() + + self.wait_links('dummy98') + + output = check_output('cat /sys/class/net/dummy98/queues/rx-0/rps_cpus') + print(output) + self.assertEqual(int(output.replace(',', ''), base=16), 15) + + def test_rps_cpu_all(self): + cpu_count = os.cpu_count() + + copy_network_unit('12-dummy.netdev', '25-rps-cpu-all.link') + start_networkd() + + self.wait_links('dummy98') + + output = check_output('cat /sys/class/net/dummy98/queues/rx-0/rps_cpus') + print(output) + self.assertEqual(f"{int(output.replace(',', ''), base=16):x}", f'{(1 << cpu_count) - 1:x}') + + def test_rps_cpu_disable(self): + copy_network_unit('12-dummy.netdev', '25-rps-cpu-all.link', '24-rps-cpu-disable.link') + start_networkd() + + self.wait_links('dummy98') + + output = check_output('cat /sys/class/net/dummy98/queues/rx-0/rps_cpus') + print(output) + self.assertEqual(int(output.replace(',', ''), base=16), 0) + + def test_rps_cpu_empty(self): + copy_network_unit('12-dummy.netdev', '24-rps-cpu-empty.link') + start_networkd() + + self.wait_links('dummy98') + + output = check_output('cat /sys/class/net/dummy98/queues/rx-0/rps_cpus') + print(output) + self.assertEqual(int(output.replace(',', ''), base=16), 0) + + def test_rps_cpu_0_empty(self): + copy_network_unit('12-dummy.netdev', '25-rps-cpu-0-empty.link') + start_networkd() + + self.wait_links('dummy98') + + output = check_output('cat /sys/class/net/dummy98/queues/rx-0/rps_cpus') + print(output) + self.assertEqual(int(output.replace(',', ''), base=16), 0) + + def test_rps_cpu_0_and_empty(self): + copy_network_unit('12-dummy.netdev', '25-rps-cpu-0.link', '24-rps-cpu-empty.link') + start_networkd() + + self.wait_links('dummy98') + + output = check_output('cat /sys/class/net/dummy98/queues/rx-0/rps_cpus') + print(output) + self.assertEqual(int(output.replace(',', ''), base=16), 0) + + def test_rps_cpu_invalid(self): + copy_network_unit('12-dummy.netdev', '24-rps-cpu-invalid.link') + start_networkd() + + self.wait_links('dummy98') + + output = check_output('cat /sys/class/net/dummy98/queues/rx-0/rps_cpus') + print(output) + self.assertEqual(int(output.replace(',', ''), base=16), 0) + + def test_rps_cpu_0_invalid(self): + copy_network_unit('12-dummy.netdev', '25-rps-cpu-0-invalid.link') + start_networkd() + + self.wait_links('dummy98') + + output = check_output('cat /sys/class/net/dummy98/queues/rx-0/rps_cpus') + print(output) + self.assertEqual(int(output.replace(',', ''), base=16), 1) + + def test_rps_cpu_0_and_invalid(self): + copy_network_unit('12-dummy.netdev', '25-rps-cpu-0.link', '24-rps-cpu-invalid.link') + start_networkd() + + self.wait_links('dummy98') + + output = check_output('cat /sys/class/net/dummy98/queues/rx-0/rps_cpus') + print(output) + self.assertEqual(int(output.replace(',', ''), base=16), 0) + class NetworkdL2TPTests(unittest.TestCase, Utilities): def setUp(self):