Skip to content

Commit

Permalink
Drop MAC address check and rename LinkAdmState
Browse files Browse the repository at this point in the history
Signed-off-by: Vasilis Remmas <vremmas@nvidia.com>
  • Loading branch information
vasrem committed May 8, 2024
1 parent 1f7786e commit b30ab24
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 310 deletions.
17 changes: 4 additions & 13 deletions api/v1/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ func NeedToUpdateSriov(ifaceSpec *Interface, ifaceStatus *InterfaceExt) bool {
return true
}

if ifaceStatus.LinkAdmState == "down" {
log.V(2).Info("NeedToUpdateSriov(): PF link status needs update", "desired to include", "up", "current", ifaceStatus.LinkAdmState)
if ifaceStatus.LinkAdminState == "down" {
log.V(2).Info("NeedToUpdateSriov(): PF link status needs update", "desired to include", "up", "current", ifaceStatus.LinkAdminState)
return true
}

Expand Down Expand Up @@ -307,20 +307,11 @@ func NeedToUpdateSriov(ifaceSpec *Interface, ifaceStatus *InterfaceExt) bool {
}

if strings.EqualFold(ifaceStatus.LinkType, consts.LinkTypeETH) {
// We do this check only if a MAC address is set to ensure that we were able to read the MAC
// address. We intentionally skip empty MAC address in vfStatus because this may happen
// when the VF is allocated to a workload.
if vfStatus.Mac == consts.DefaultMAC {
log.V(2).Info("NeedToUpdateSriov(): VF MAC Address needs update",
"vf", vfStatus.VfID, "current", vfStatus.Mac)
return true
}

if groupSpec.IsRdma {
// We do this check only if a Node GUID is set to ensure that we were able to read the
// Node GUID. We intentionally skip empty Node GUID in vfStatus because this may happen
// when the VF is allocated to a workload.
if vfStatus.GUID == consts.DefaultNodeGUID {
if vfStatus.GUID == consts.UninitializedNodeGUID {
log.V(2).Info("NeedToUpdateSriov(): VF GUID needs update",
"vf", vfStatus.VfID, "current", vfStatus.GUID)
return true
Expand All @@ -330,7 +321,7 @@ func NeedToUpdateSriov(ifaceSpec *Interface, ifaceStatus *InterfaceExt) bool {
// We do this check only if a Node GUID is set to ensure that we were able to read the
// Node GUID. We intentionally skip empty Node GUID in vfStatus because this may happen
// when the VF is allocated to a workload.
if vfStatus.GUID == consts.DefaultNodeGUID {
if vfStatus.GUID == consts.UninitializedNodeGUID {
log.V(2).Info("NeedToUpdateSriov(): VF GUID needs update",
"vf", vfStatus.VfID, "current", vfStatus.GUID)
return true
Expand Down
2 changes: 1 addition & 1 deletion api/v1/sriovnetworknodestate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type InterfaceExt struct {
NumVfs int `json:"numVfs,omitempty"`
LinkSpeed string `json:"linkSpeed,omitempty"`
LinkType string `json:"linkType,omitempty"`
LinkAdmState string `json:"linkAdmState,omitempty"`
LinkAdminState string `json:"linkAdminState,omitempty"`
EswitchMode string `json:"eSwitchMode,omitempty"`
ExternallyManaged bool `json:"externallyManaged,omitempty"`
TotalVfs int `json:"totalvfs,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ spec:
type: string
externallyManaged:
type: boolean
linkAdmState:
linkAdminState:
type: string
linkSpeed:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ spec:
type: string
externallyManaged:
type: boolean
linkAdmState:
linkAdminState:
type: string
linkSpeed:
type: string
Expand Down
3 changes: 1 addition & 2 deletions pkg/consts/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ const (
LinkTypeIB = "IB"
LinkTypeETH = "ETH"

DefaultNodeGUID = "0000:0000:0000:0000"
DefaultMAC = "00:00:00:00:00:00"
UninitializedNodeGUID = "0000:0000:0000:0000"

DeviceTypeVfioPci = "vfio-pci"
DeviceTypeNetDevice = "netdevice"
Expand Down
20 changes: 10 additions & 10 deletions pkg/host/internal/sriov/sriov.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,16 +261,16 @@ func (s *sriov) DiscoverSriovDevices(storeManager store.ManagerInterface) ([]sri
}

iface := sriovnetworkv1.InterfaceExt{
Name: pfNetName,
PciAddress: device.Address,
Driver: driver,
Vendor: device.Vendor.ID,
DeviceID: device.Product.ID,
Mtu: link.Attrs().MTU,
Mac: link.Attrs().HardwareAddr.String(),
LinkType: s.encapTypeToLinkType(link.Attrs().EncapType),
LinkSpeed: s.networkHelper.GetNetDevLinkSpeed(pfNetName),
LinkAdmState: s.networkHelper.GetNetDevLinkAdminState(pfNetName),
Name: pfNetName,
PciAddress: device.Address,
Driver: driver,
Vendor: device.Vendor.ID,
DeviceID: device.Product.ID,
Mtu: link.Attrs().MTU,
Mac: link.Attrs().HardwareAddr.String(),
LinkType: s.encapTypeToLinkType(link.Attrs().EncapType),
LinkSpeed: s.networkHelper.GetNetDevLinkSpeed(pfNetName),
LinkAdminState: s.networkHelper.GetNetDevLinkAdminState(pfNetName),
}

pfStatus, exist, err := storeManager.LoadPfsStatus(iface.PciAddress)
Expand Down
Loading

0 comments on commit b30ab24

Please sign in to comment.