From e2d31ad8102b650a5d2a7a522ad62126a1deb00b Mon Sep 17 00:00:00 2001 From: Sebastian Sch Date: Thu, 20 Jan 2022 19:41:32 +0200 Subject: [PATCH] Implement a rebind to default driver This commit add a w/a to an issue observed on intel nics where not all the vfs are created. Signed-off-by: Sebastian Sch --- pkg/utils/utils.go | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index ca8ad4f10b..4da97e2073 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -291,12 +291,16 @@ func configSriovDevice(iface *sriovnetworkv1.Interface, ifaceStatus *sriovnetwor if err = setVfGuid(addr, pfLink); err != nil { return err } + } else if driver != "" { + glog.V(2).Infof("configSriovDevice(): skip setVfAdminMac as the nic %s is bind to a dpdk driver %s", addr, driver) } else if err = setVfAdminMac(addr, pfLink); err != nil { return err } + if err = unbindDriverIfNeeded(addr, isRdma); err != nil { return err } + if driver == "" { if err := BindDefaultDriver(addr); err != nil { glog.Warningf("configSriovDevice(): fail to bind default driver for device %s", addr) @@ -565,8 +569,19 @@ func setVfAdminMac(vfAddr string, pfLink netlink.Link) error { } vfLink, err := vfIsReady(vfAddr) if err != nil { - glog.Errorf("setVfAdminMac(): VF link is not ready for device %+v %q", vfAddr, err) - return err + err = RebindVfToDefaultDriver(vfAddr) + if err != nil { + glog.Errorf("setVfAdminMac(): failed to rebind VF %s %q", vfAddr, err) + return err + } + + // Try to check the VF status again + vfLink, err = vfIsReady(vfAddr) + if err != nil { + glog.Errorf("setVfAdminMac(): VF link is not ready for device %s %q", vfAddr, err) + return err + } + } if err := netlink.LinkSetVfHardwareAddr(pfLink, vfID, vfLink.Attrs().HardwareAddr); err != nil { return err @@ -722,3 +737,20 @@ func hasMellanoxInterfacesInSpec(newState *sriovnetworkv1.SriovNetworkNodeState) } return false } + +// Workaround function to handle a case where the vf default driver is stuck and not able to create the vf kernel interface. +// This function unbind the VF from the default driver and try to bind it again +// bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2045087 +func RebindVfToDefaultDriver(vfAddr string) error { + glog.Infof("RebindVfToDefaultDriver(): VF %s", vfAddr) + if err := Unbind(vfAddr); err != nil { + return err + } + if err := BindDefaultDriver(vfAddr); err != nil { + glog.Errorf("RebindVfToDefaultDriver(): fail to bind default driver for device %s", vfAddr) + return err + } + + glog.Warningf("RebindVfToDefaultDriver(): workaround implemented for VF %s", vfAddr) + return nil +}