Skip to content

Commit 9d3add7

Browse files
committed
Make ovs-vswitchd service 'other_config' option configurable
Signed-off-by: Ivan Kolodiazhnyi <[email protected]>
1 parent daf65ad commit 9d3add7

20 files changed

+240
-41
lines changed

api/v1/sriovnetworknodestate_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ type System struct {
119119
// +kubebuilder:validation:Enum=shared;exclusive
120120
//RDMA subsystem. Allowed value "shared", "exclusive".
121121
RdmaMode string `json:"rdmaMode,omitempty"`
122+
// OVS config. It will be provided for ovs-vswitchd service as other_config option
123+
// +kubebuilder:default:={hw-offload: "true"}
124+
OvsConfig map[string]string `json:"ovsConfig,omitempty"`
122125
}
123126

124127
// SriovNetworkNodeStateStatus defines the observed state of SriovNetworkNodeState

api/v1/sriovnetworkpoolconfig_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ type OvsHardwareOffloadConfig struct {
3434
// On OpenShift:
3535
// Name is the name of MachineConfigPool to be enabled with OVS hardware offload
3636
Name string `json:"name,omitempty"`
37+
// OVS config. It will be provided for ovs-vswitchd service as other_config option
38+
// +kubebuilder:default:={hw-offload: "true"}
39+
OvsConfig map[string]string `json:"otherConfig,omitempty"`
3740
}
3841

3942
// SriovNetworkPoolConfigStatus defines the observed state of SriovNetworkPoolConfig

api/v1/zz_generated.deepcopy.go

Lines changed: 17 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindata/manifests/switchdev-config/ovs-units/ovs-vswitchd.service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ dropins:
33
- name: 10-hw-offload.conf
44
contents: |
55
[Service]
6-
ExecStartPre=/bin/ovs-vsctl --no-wait set Open_vSwitch . other_config:hw-offload=true
6+
ExecStartPre=/bin/ovs-vsctl/ovs-vsctl -t 5 set Open_vSwitch . external_ids:sriov-operator-owned-keys='{{ .ExternalIds }}' && /bin/ovs-vsctl/ovs-vsctl -t 5 get Open_vSwitch . external_ids:sriov-operator-owned-keys | xargs /bin/ovs-vsctl --no-wait remove Open_vSwitch . other_config && /bin/ovs-vsctl --no-wait set Open_vSwitch . {{ .OtherOvsConfig }}

config/crd/bases/sriovnetwork.openshift.io_sriovnetworknodestates.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,14 @@ spec:
180180
type: array
181181
system:
182182
properties:
183+
ovsConfig:
184+
additionalProperties:
185+
type: string
186+
default:
187+
hw-offload: "true"
188+
description: OVS config. It will be provided for ovs-vswitchd
189+
service as other_config option
190+
type: object
183191
rdmaMode:
184192
description: RDMA subsystem. Allowed value "shared", "exclusive".
185193
enum:
@@ -354,6 +362,14 @@ spec:
354362
type: string
355363
system:
356364
properties:
365+
ovsConfig:
366+
additionalProperties:
367+
type: string
368+
default:
369+
hw-offload: "true"
370+
description: OVS config. It will be provided for ovs-vswitchd
371+
service as other_config option
372+
type: object
357373
rdmaMode:
358374
description: RDMA subsystem. Allowed value "shared", "exclusive".
359375
enum:

config/crd/bases/sriovnetwork.openshift.io_sriovnetworkpoolconfigs.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ spec:
112112
On OpenShift:
113113
Name is the name of MachineConfigPool to be enabled with OVS hardware offload
114114
type: string
115+
otherConfig:
116+
additionalProperties:
117+
type: string
118+
default:
119+
hw-offload: "true"
120+
description: OVS config. It will be provided for ovs-vswitchd
121+
service as other_config option
122+
type: object
115123
type: object
116124
rdmaMode:
117125
description: RDMA subsystem. Allowed value "shared", "exclusive".

controllers/sriovnetworknodepolicy_controller.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,12 @@ func (r *SriovNetworkNodePolicyReconciler) syncAllSriovNetworkNodeStates(ctx con
309309
}
310310
if netPoolConfig != nil {
311311
ns.Spec.System.RdmaMode = netPoolConfig.Spec.RdmaMode
312+
if netPoolConfig.Spec.OvsHardwareOffloadConfig.OvsConfig != nil {
313+
ns.Spec.System.OvsConfig = make(map[string]string, len(netPoolConfig.Spec.OvsHardwareOffloadConfig.OvsConfig))
314+
for k, v := range netPoolConfig.Spec.OvsHardwareOffloadConfig.OvsConfig {
315+
ns.Spec.System.OvsConfig[k] = v
316+
}
317+
}
312318
}
313319
j, _ := json.Marshal(ns)
314320
logger.V(2).Info("SriovNetworkNodeState CR", "content", j)

controllers/sriovnetworkpoolconfig_controller.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ func (r *SriovNetworkPoolConfigReconciler) syncOvsHardwareOffloadMachineConfigs(
159159
}
160160

161161
data := render.MakeRenderData()
162+
data.Data["OtherOvsConfig"] = "other_config:hw-offload=true"
163+
data.Data["ExternalIds"] = "hw-offload"
162164
mc, err := render.GenerateMachineConfig("bindata/manifests/switchdev-config", mcName, mcpName, true, &data)
163165
if err != nil {
164166
return err

deployment/sriov-network-operator-chart/crds/sriovnetwork.openshift.io_sriovnetworknodestates.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,14 @@ spec:
180180
type: array
181181
system:
182182
properties:
183+
ovsConfig:
184+
additionalProperties:
185+
type: string
186+
default:
187+
hw-offload: "true"
188+
description: OVS config. It will be provided for ovs-vswitchd
189+
service as other_config option
190+
type: object
183191
rdmaMode:
184192
description: RDMA subsystem. Allowed value "shared", "exclusive".
185193
enum:
@@ -354,6 +362,14 @@ spec:
354362
type: string
355363
system:
356364
properties:
365+
ovsConfig:
366+
additionalProperties:
367+
type: string
368+
default:
369+
hw-offload: "true"
370+
description: OVS config. It will be provided for ovs-vswitchd
371+
service as other_config option
372+
type: object
357373
rdmaMode:
358374
description: RDMA subsystem. Allowed value "shared", "exclusive".
359375
enum:

deployment/sriov-network-operator-chart/crds/sriovnetwork.openshift.io_sriovnetworkpoolconfigs.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ spec:
112112
On OpenShift:
113113
Name is the name of MachineConfigPool to be enabled with OVS hardware offload
114114
type: string
115+
otherConfig:
116+
additionalProperties:
117+
type: string
118+
default:
119+
hw-offload: "true"
120+
description: OVS config. It will be provided for ovs-vswitchd
121+
service as other_config option
122+
type: object
115123
type: object
116124
rdmaMode:
117125
description: RDMA subsystem. Allowed value "shared", "exclusive".

0 commit comments

Comments
 (0)