Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid reconfiguring unmentioned DPDK VFs #710

Merged
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ VF groups** (when #-notation is used in pfName field) are merged, otherwise only
the highest priority policy is applied. In case of same-priority policies and
overlapping VF groups, only the last processed policy is applied.

When using #-notation to define VF group, no actions are taken on virtual functions that
are not mentioned in any policy (e.g. if a policy defines a `vfio-pci` device group for a device, when
it is deleted the VF are not reset to the default driver).

#### Externally Manage virtual functions

When `ExternallyManage` is request on a policy the operator will only skip the virtual function creation.
Expand Down
8 changes: 0 additions & 8 deletions api/v1/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,8 @@ func NeedToUpdateSriov(ifaceSpec *Interface, ifaceStatus *InterfaceExt) bool {

if ifaceSpec.NumVfs > 0 {
for _, vfStatus := range ifaceStatus.VFs {
ingroup := false
for _, groupSpec := range ifaceSpec.VfGroups {
if IndexInRange(vfStatus.VfID, groupSpec.VfRange) {
ingroup = true
if vfStatus.Driver == "" {
log.V(2).Info("NeedToUpdateSriov(): Driver needs update - has no driver",
"desired", groupSpec.DeviceType)
Expand Down Expand Up @@ -332,12 +330,6 @@ func NeedToUpdateSriov(ifaceSpec *Interface, ifaceStatus *InterfaceExt) bool {
break
}
}
if !ingroup && (StringInArray(vfStatus.Driver, vars.DpdkDrivers) || vfStatus.VdpaType != "") {
adrianchiris marked this conversation as resolved.
Show resolved Hide resolved
// need to reset VF if it is not a part of a group and:
// a. has DPDK driver loaded
// b. has VDPA device
return true
}
}
}
return false
Expand Down
68 changes: 68 additions & 0 deletions api/v1/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1054,3 +1054,71 @@ func TestSriovNetworkPoolConfig_MaxUnavailable(t *testing.T) {
})
}
}

func TestNeedToUpdateSriov(t *testing.T) {
type args struct {
ifaceSpec *v1.Interface
ifaceStatus *v1.InterfaceExt
}
tests := []struct {
name string
args args
want bool
}{
{
name: "number of VFs changed",
args: args{
ifaceSpec: &v1.Interface{NumVfs: 1},
ifaceStatus: &v1.InterfaceExt{NumVfs: 0},
},
want: true,
},
{
name: "no update",
args: args{
ifaceSpec: &v1.Interface{NumVfs: 1},
ifaceStatus: &v1.InterfaceExt{NumVfs: 1},
},
want: false,
},
{
name: "vfio-pci VF is not configured for any group",
args: args{
ifaceSpec: &v1.Interface{
NumVfs: 3,
VfGroups: []v1.VfGroup{
{
VfRange: "1-2",
DeviceType: consts.DeviceTypeNetDevice,
},
},
},
ifaceStatus: &v1.InterfaceExt{
NumVfs: 3,
VFs: []v1.VirtualFunction{
{
VfID: 0,
Driver: "vfio-pci",
},
{
VfID: 1,
Driver: "iavf",
},
{
VfID: 2,
Driver: "iavf",
},
},
},
},
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := v1.NeedToUpdateSriov(tt.args.ifaceSpec, tt.args.ifaceStatus); got != tt.want {
t.Errorf("NeedToUpdateSriov() = %v, want %v", got, tt.want)
}
})
}
}
Loading