From 27cd0345db0e071120659cfd86568ede4ee2fb85 Mon Sep 17 00:00:00 2001 From: mcgov Date: Mon, 3 Oct 2022 14:07:22 -0700 Subject: [PATCH] SRIOV: allow old sriov switch behavior that doesn't kill connection (#2294) --- lisa/features/network_interface.py | 4 +++- lisa/sut_orchestrator/aws/features.py | 4 +++- lisa/sut_orchestrator/azure/features.py | 13 +++++++++---- microsoft/testsuites/dpdk/dpdksuite.py | 1 + microsoft/testsuites/dpdk/dpdkutil.py | 8 ++++++-- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/lisa/features/network_interface.py b/lisa/features/network_interface.py index 4c6be2dd0..f53727c95 100644 --- a/lisa/features/network_interface.py +++ b/lisa/features/network_interface.py @@ -21,7 +21,9 @@ class NetworkInterface(Feature): def enabled(self) -> bool: return True - def switch_sriov(self, enable: bool, wait: bool = True) -> None: + def switch_sriov( + self, enable: bool, wait: bool = True, reset_connections: bool = True + ) -> None: raise NotImplementedError def is_enabled_sriov(self) -> bool: diff --git a/lisa/sut_orchestrator/aws/features.py b/lisa/sut_orchestrator/aws/features.py index b5b3e6525..addafb6b2 100644 --- a/lisa/sut_orchestrator/aws/features.py +++ b/lisa/sut_orchestrator/aws/features.py @@ -167,7 +167,9 @@ class NetworkInterface(AwsFeatureMixin, features.NetworkInterface): raise LisaException(f"fail to find primary nic for vm {self._node.name}") return nic - def switch_sriov(self, enable: bool, wait: bool = True) -> None: + def switch_sriov( + self, enable: bool, wait: bool = True, reset_connections: bool = True + ) -> None: aws_platform: AwsPlatform = self._platform # type: ignore instance = boto3.resource("ec2").Instance(self._instance_id) diff --git a/lisa/sut_orchestrator/azure/features.py b/lisa/sut_orchestrator/azure/features.py index 6c06eeee2..574e61594 100644 --- a/lisa/sut_orchestrator/azure/features.py +++ b/lisa/sut_orchestrator/azure/features.py @@ -601,7 +601,9 @@ class NetworkInterface(AzureFeatureMixin, features.NetworkInterface): len(all_nics) - self.origin_extra_synthetic_nics_count - 1 ) - def switch_sriov(self, enable: bool, wait: bool = True) -> None: + def switch_sriov( + self, enable: bool, wait: bool = True, reset_connections: bool = True + ) -> None: azure_platform: AzurePlatform = self._platform # type: ignore network_client = get_network_client(azure_platform) vm = get_vm(azure_platform, self._node) @@ -639,7 +641,7 @@ class NetworkInterface(AzureFeatureMixin, features.NetworkInterface): # wait settings effective if wait: - self._check_sriov_enabled(enable) + self._check_sriov_enabled(enable, reset_connections) def is_enabled_sriov(self) -> bool: azure_platform: AzurePlatform = self._platform # type: ignore @@ -774,8 +776,11 @@ class NetworkInterface(AzureFeatureMixin, features.NetworkInterface): modprobe_tool.reload(["hv_netvsc"]) @retry(tries=60, delay=10) - def _check_sriov_enabled(self, enabled: bool) -> None: - self._node.close() + def _check_sriov_enabled( + self, enabled: bool, reset_connections: bool = True + ) -> None: + if reset_connections: + self._node.close() self._node.nics.reload() default_nic = self._node.nics.get_nic_by_index(0) diff --git a/microsoft/testsuites/dpdk/dpdksuite.py b/microsoft/testsuites/dpdk/dpdksuite.py index 1b3024842..cc06784dd 100644 --- a/microsoft/testsuites/dpdk/dpdksuite.py +++ b/microsoft/testsuites/dpdk/dpdksuite.py @@ -665,4 +665,5 @@ class Dpdk(TestSuite): if modprobe.module_exists("uio_hv_generic"): node.tools[Service].stop_service("vpp") modprobe.remove(["uio_hv_generic"]) + node.close() modprobe.reload(["hv_netvsc"]) diff --git a/microsoft/testsuites/dpdk/dpdkutil.py b/microsoft/testsuites/dpdk/dpdkutil.py index 0cdcfb633..428c27625 100644 --- a/microsoft/testsuites/dpdk/dpdkutil.py +++ b/microsoft/testsuites/dpdk/dpdkutil.py @@ -333,14 +333,18 @@ def run_testpmd_concurrent( # disable sriov (and wait for change to apply) for node_resources in [x for x in test_kits if x.switch_sriov]: - node_resources.nic_controller.switch_sriov(enable=False, wait=True) + node_resources.nic_controller.switch_sriov( + enable=False, wait=True, reset_connections=False + ) # let run for a bit with SRIOV disabled time.sleep(10) # re-enable sriov for node_resources in [x for x in test_kits if x.switch_sriov]: - node_resources.nic_controller.switch_sriov(enable=True, wait=True) + node_resources.nic_controller.switch_sriov( + enable=True, wait=True, reset_connections=False + ) # run for a bit with SRIOV re-enabled time.sleep(10)