Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 48 additions & 50 deletions pkg/plugins/mellanox/mellanox_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,56 +92,54 @@ func (p *MellanoxPlugin) OnNodeStateChange(new *sriovnetworkv1.SriovNetworkNodeS
return
}

// for _, ifaceSpec := range mellanoxNicsSpec {
// pciPrefix := mlx.GetPciAddressPrefix(ifaceSpec.PciAddress)
// // skip processed nics, help not running the same logic 2 times for dual port NICs
// if _, ok := processedNics[pciPrefix]; ok {
// continue
// }
// processedNics[pciPrefix] = true
// fwCurrent, fwNext, err := p.helpers.GetMlxNicFwData(ifaceSpec.PciAddress)
// if err != nil {
// return false, false, err
// }

// // isDualPort := mlx.IsDualPort(ifaceSpec.PciAddress, mellanoxNicsStatus)
// // Attributes to change
// attrs := &mlx.MlxNic{TotalVfs: -1}
// var changeWithoutReboot bool

// // totalVfs, totalVfsNeedReboot, totalVfsChangeWithoutReboot := mlx.HandleTotalVfs(fwCurrent, fwNext, attrs, ifaceSpec, isDualPort, mellanoxNicsSpec)
// // sriovEnNeedReboot, sriovEnChangeWithoutReboot := mlx.HandleEnableSriov(totalVfs, fwCurrent, fwNext, attrs)
// // needReboot = totalVfsNeedReboot || sriovEnNeedReboot
// // changeWithoutReboot = totalVfsChangeWithoutReboot || sriovEnChangeWithoutReboot
// needReboot = false
// changeWithoutReboot = false

// needLinkChange, err := mlx.HandleLinkType(pciPrefix, fwCurrent, attrs, mellanoxNicsSpec, mellanoxNicsStatus)
// if err != nil {
// return false, false, err
// }
// needReboot = needReboot || needLinkChange

// // no FW changes allowed when NIC is externally managed
// if ifaceSpec.ExternallyManaged {
// // if totalVfsNeedReboot || totalVfsChangeWithoutReboot {
// // return false, false, fmt.Errorf(
// // "interface %s required a change in the TotalVfs but the policy is externally managed failing: firmware TotalVf %d requested TotalVf %d",
// // ifaceSpec.PciAddress, fwCurrent.TotalVfs, totalVfs)
// // }
// if needLinkChange {
// return false, false, fmt.Errorf("change required for link type but the policy is externally managed, failing")
// }
// }

// if needReboot || changeWithoutReboot {
// attributesToChange[ifaceSpec.PciAddress] = *attrs
// }

// if needReboot {
// pciAddressesToReset = append(pciAddressesToReset, ifaceSpec.PciAddress)
// }
// }
for _, ifaceSpec := range mellanoxNicsSpec {
pciPrefix := mlx.GetPciAddressPrefix(ifaceSpec.PciAddress)
// skip processed nics, help not running the same logic 2 times for dual port NICs
if _, ok := processedNics[pciPrefix]; ok {
continue
}
processedNics[pciPrefix] = true
fwCurrent, fwNext, err := p.helpers.GetMlxNicFwData(ifaceSpec.PciAddress)
if err != nil {
return false, false, err
}

isDualPort := mlx.IsDualPort(ifaceSpec.PciAddress, mellanoxNicsStatus)
// Attributes to change
attrs := &mlx.MlxNic{TotalVfs: -1}
var changeWithoutReboot bool

totalVfs, totalVfsNeedReboot, totalVfsChangeWithoutReboot := mlx.HandleTotalVfs(fwCurrent, fwNext, attrs, ifaceSpec, isDualPort, mellanoxNicsSpec)
sriovEnNeedReboot, sriovEnChangeWithoutReboot := mlx.HandleEnableSriov(totalVfs, fwCurrent, fwNext, attrs)
needReboot = totalVfsNeedReboot || sriovEnNeedReboot
changeWithoutReboot = totalVfsChangeWithoutReboot || sriovEnChangeWithoutReboot

needLinkChange, err := mlx.HandleLinkType(pciPrefix, fwCurrent, attrs, mellanoxNicsSpec, mellanoxNicsStatus)
if err != nil {
return false, false, err
}
needReboot = needReboot || needLinkChange

// no FW changes allowed when NIC is externally managed
if ifaceSpec.ExternallyManaged {
if totalVfsNeedReboot || totalVfsChangeWithoutReboot {
return false, false, fmt.Errorf(
"interface %s required a change in the TotalVfs but the policy is externally managed failing: firmware TotalVf %d requested TotalVf %d",
ifaceSpec.PciAddress, fwCurrent.TotalVfs, totalVfs)
}
if needLinkChange {
return false, false, fmt.Errorf("change required for link type but the policy is externally managed, failing")
}
}

if needReboot || changeWithoutReboot {
attributesToChange[ifaceSpec.PciAddress] = *attrs
}

if needReboot {
pciAddressesToReset = append(pciAddressesToReset, ifaceSpec.PciAddress)
}
}

// Set total VFs to 0 for mellanox interfaces with no spec
for pciPrefix, portsMap := range mellanoxNicsStatus {
Expand Down
Loading