Skip to content

Commit

Permalink
Additional cleanup
Browse files Browse the repository at this point in the history
format
  • Loading branch information
atyronesmith committed Nov 20, 2020
1 parent dfcbe28 commit 2f8a221
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 38 deletions.
5 changes: 2 additions & 3 deletions pkg/daemon/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ type VendorPlugin interface {
}

var pluginMap = map[string]string{
"8086": "intel_plugin",
"15b3": "mellanox_plugin",
"virtual": "virtual_plugin",
"8086": "intel_plugin",
"15b3": "mellanox_plugin",
}

const (
Expand Down
8 changes: 0 additions & 8 deletions pkg/plugins/virtual/virtual_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,10 @@ func (p *VirtualPlugin) Spec() string {
// OnNodeStateAdd Invoked when SriovNetworkNodeState CR is created, return if need dain and/or reboot node
func (p *VirtualPlugin) OnNodeStateAdd(state *sriovnetworkv1.SriovNetworkNodeState) (needDrain bool, needReboot bool, err error) {
glog.Info("virtual-plugin OnNodeStateAdd()")
needDrain = false
needReboot = false
err = nil
p.DesireState = state

needDrain = needDrainNode(state.Spec.Interfaces, state.Status.Interfaces)

if p.LoadVfioDriver != loaded {
if needVfioDriver(state) {
p.LoadVfioDriver = loading
Expand Down Expand Up @@ -134,8 +131,3 @@ func isCommandNotFound(err error) bool {
}
return false
}

func needDrainNode(desired sriovnetworkv1.Interfaces, current sriovnetworkv1.InterfaceExts) (needDrain bool) {
needDrain = false
return
}
51 changes: 24 additions & 27 deletions pkg/utils/utils_virtual.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,35 +143,32 @@ func configSriovDeviceVirtual(iface *sriovnetworkv1.Interface, ifaceStatus *srio
glog.Warningf("configSriovDeviceVirtual(): missing VFGroup")
return errors.New("NumVfs != 1")
}
vfAddrs := []string{iface.PciAddress}
glog.V(2).Infof("configSriovDeviceVirtual(): vfaddrs %v", vfAddrs)
for _, addr := range vfAddrs {
glog.V(2).Infof("configSriovDeviceVirtual(): addr %s", addr)
driver := ""
vfID := 0
for _, group := range iface.VfGroups {
glog.V(2).Infof("configSriovDeviceVirtual(): group %v", group)
if sriovnetworkv1.IndexInRange(vfID, group.VfRange) {
glog.V(2).Infof("configSriovDeviceVirtual(): indexInRange %d", vfID)
if sriovnetworkv1.StringInArray(group.DeviceType, DpdkDrivers) {
glog.V(2).Infof("configSriovDeviceVirtual(): driver %s", group.DeviceType)
driver = group.DeviceType
}
break
addr := iface.PciAddress
glog.V(2).Infof("configSriovDeviceVirtual(): addr %s", addr)
driver := ""
vfID := 0
for _, group := range iface.VfGroups {
glog.V(2).Infof("configSriovDeviceVirtual(): group %v", group)
if sriovnetworkv1.IndexInRange(vfID, group.VfRange) {
glog.V(2).Infof("configSriovDeviceVirtual(): indexInRange %d", vfID)
if sriovnetworkv1.StringInArray(group.DeviceType, DpdkDrivers) {
glog.V(2).Infof("configSriovDeviceVirtual(): driver %s", group.DeviceType)
driver = group.DeviceType
}
break
}
if driver == "" {
glog.V(2).Infof("configSriovDeviceVirtual(): bind default")
if err := BindDefaultDriver(addr); err != nil {
glog.Warningf("configSriovDeviceVirtual(): fail to bind default driver for device %s", addr)
return err
}
} else {
glog.V(2).Infof("configSriovDeviceVirtual(): bind driver %s", driver)
if err := BindDpdkDriver(addr, driver); err != nil {
glog.Warningf("configSriovDeviceVirtual(): fail to bind driver %s for device %s", driver, addr)
return err
}
}
if driver == "" {
glog.V(2).Infof("configSriovDeviceVirtual(): bind default")
if err := BindDefaultDriver(addr); err != nil {
glog.Warningf("configSriovDeviceVirtual(): fail to bind default driver for device %s", addr)
return err
}
} else {
glog.V(2).Infof("configSriovDeviceVirtual(): bind driver %s", driver)
if err := BindDpdkDriver(addr, driver); err != nil {
glog.Warningf("configSriovDeviceVirtual(): fail to bind driver %s for device %s", driver, addr)
return err
}
}
}
Expand Down

0 comments on commit 2f8a221

Please sign in to comment.