From 7d325cb87bfd21ccfd07a80a4c722b8ce98552ec Mon Sep 17 00:00:00 2001 From: Moshe Levi Date: Tue, 21 Feb 2017 14:18:04 +0200 Subject: [PATCH] reset driver using bind/unbind when vm is deleted Change-Id: I047c0c37cbb3f90ae4703f54da4cc8c14559ba7c --- networking_mlnx/eswitchd/common/constants.py | 3 ++- networking_mlnx/eswitchd/eswitch_handler.py | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/networking_mlnx/eswitchd/common/constants.py b/networking_mlnx/eswitchd/common/constants.py index a312890..ef8e02b 100644 --- a/networking_mlnx/eswitchd/common/constants.py +++ b/networking_mlnx/eswitchd/common/constants.py @@ -37,7 +37,8 @@ CX4_GUID_PORT_PATH = ('/sys/class/infiniband/%(module)s/device/sriov/' '%(vf_num)s/port') CX4_GUID_POLICY_PATH = ('/sys/class/infiniband/%(module)s/device/sriov/' '%(vf_num)s/policy') - +UNBIND_PATH = '/sys/bus/pci/drivers/mlx5_core/unbind' +BIND_PATH = '/sys/bus/pci/drivers/mlx5_core/bind' INVALID_GUID_CX3 = 'ffffffffffffffff' INVALID_GUID_CX4 = 'ff:ff:ff:ff:ff:ff:ff:ff' diff --git a/networking_mlnx/eswitchd/eswitch_handler.py b/networking_mlnx/eswitchd/eswitch_handler.py index 91a3ad2..7b443b7 100644 --- a/networking_mlnx/eswitchd/eswitch_handler.py +++ b/networking_mlnx/eswitchd/eswitch_handler.py @@ -316,8 +316,16 @@ class eSwitchHandler(object): cmd = ['ebrctl', 'write-sys', path, vguid] command_utils.execute(*cmd) - cmd = ['ebrctl', 'write-sys', guid_poliy, 'Up\n'] - command_utils.execute(*cmd) + if vguid == constants.INVALID_GUID_CX4: + cmd = ['ebrctl', 'write-sys', guid_poliy, 'Down\n'] + command_utils.execute(*cmd) + cmd = ['ebrctl', 'write-sys', constants.UNBIND_PATH, dev] + command_utils.execute(*cmd) + cmd = ['ebrctl', 'write-sys', constants.BIND_PATH, dev] + command_utils.execute(*cmd) + else: + cmd = ['ebrctl', 'write-sys', guid_poliy, 'Up\n'] + command_utils.execute(*cmd) def _config_vlan_ib(self, fabric, dev, vlan): fabric_details = self.rm.get_fabric_details(fabric)