Skip to content

Commit

Permalink
draft: Fix eSwitch mode switchdev for the ice driver
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Panattoni <[email protected]>
  • Loading branch information
zeeke committed Aug 19, 2024
1 parent 2c4885a commit 5450ebd
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions pkg/host/internal/sriov/sriov.go
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,18 @@ func (s *sriov) setEswitchMode(pciAddr, eswitchMode string) error {
return nil
}

type switchdevConfigureOrder int

const (
eswitchFirstThenVfs switchdevConfigureOrder = iota
vfsFirstThenEswitch
)

var driverToSwitchdevConfigureOrder map[string]switchdevConfigureOrder = map[string]switchdevConfigureOrder{
"ice": vfsFirstThenEswitch,

Check failure on line 1011 in pkg/host/internal/sriov/sriov.go

View workflow job for this annotation

GitHub Actions / Golangci-lint

File is not `gofmt`-ed with `-s` (gofmt)
"mlx5_core": eswitchFirstThenVfs,
}

func (s *sriov) setEswitchModeAndNumVFs(pciAddr string, desiredEswitchMode string, numVFs int) error {
log.Log.V(2).Info("setEswitchModeAndNumVFs(): configure VFs for device",
"device", pciAddr, "count", numVFs, "mode", desiredEswitchMode)
Expand All @@ -1011,13 +1023,32 @@ func (s *sriov) setEswitchModeAndNumVFs(pciAddr string, desiredEswitchMode strin
return err
}
}
if err := s.SetSriovNumVfs(pciAddr, numVFs); err != nil {


pfDriverName, err := s.dputilsLib.GetDriverName(pciAddr)
if err != nil {
return err
}

if desiredEswitchMode == sriovnetworkv1.ESwithModeSwitchDev {
return s.setEswitchMode(pciAddr, sriovnetworkv1.ESwithModeSwitchDev)
configureOrder, ok := driverToSwitchdevConfigureOrder[pfDriverName]
if !ok || configureOrder == eswitchFirstThenVfs {
if err := s.SetSriovNumVfs(pciAddr, numVFs); err != nil {
return err
}

if desiredEswitchMode == sriovnetworkv1.ESwithModeSwitchDev {
return s.setEswitchMode(pciAddr, sriovnetworkv1.ESwithModeSwitchDev)
}
} else {
if desiredEswitchMode == sriovnetworkv1.ESwithModeSwitchDev {
return s.setEswitchMode(pciAddr, sriovnetworkv1.ESwithModeSwitchDev)
}

if err := s.SetSriovNumVfs(pciAddr, numVFs); err != nil {
return err
}
}

return nil
}

Expand All @@ -1035,3 +1066,5 @@ func (s *sriov) unbindAllVFsOnPF(addr string) error {
}
return nil
}


0 comments on commit 5450ebd

Please sign in to comment.