Skip to content

Commit

Permalink
sriovnet: Skip SRIOV enablement if it is already enabled
Browse files Browse the repository at this point in the history
Skip enabling sriov if it is already enabled.

Signed-off-by: Parav Pandit <parav@mellanox.com>
  • Loading branch information
paravmellanox committed Apr 7, 2018
1 parent 13dedb2 commit 2607506
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 11 additions & 3 deletions sriovnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,19 @@ func EnableSriov(pfNetdevName string) error {
return err
}

if maxVfCount != 0 {
return setMaxVfCount(pfNetdevName, maxVfCount)
} else {
if maxVfCount == 0 {
return fmt.Errorf("sriov unsupported for device: ", pfNetdevName)
}

curVfCount, err2 := netdevGetEnabledVfCount(pfNetdevName)
if err2 != nil {
fmt.Println("Fail to read current vf count of PF %v", pfNetdevName)
return err
}
if curVfCount == 0 {
return setMaxVfCount(pfNetdevName, maxVfCount)
}
return nil
}

func DisableSriov(pfNetdevName string) error {
Expand Down
1 change: 0 additions & 1 deletion sriovnet_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package sriovnet

import (
"fmt"
"testing"
)

Expand Down

0 comments on commit 2607506

Please sign in to comment.