Skip to content

Commit

Permalink
Implement a rebind to default driver
Browse files Browse the repository at this point in the history
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 <sebassch@gmail.com>
  • Loading branch information
SchSeba committed Jan 27, 2022
1 parent dec7774 commit e2d31ad
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

0 comments on commit e2d31ad

Please sign in to comment.