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

[switchdev 9/9] Enable new switchdev implementation #643

Merged
merged 7 commits into from
Mar 28, 2024
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
26 changes: 22 additions & 4 deletions api/v1/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,13 @@ func GetVfDeviceID(deviceID string) string {
}

func IsSwitchdevModeSpec(spec SriovNetworkNodeStateSpec) bool {
for _, iface := range spec.Interfaces {
return ContainsSwitchdevInterface(spec.Interfaces)
}

// ContainsSwitchdevInterface returns true if provided interface list contains interface
// with switchdev configuration
func ContainsSwitchdevInterface(interfaces []Interface) bool {
for _, iface := range interfaces {
if iface.EswitchMode == ESwithModeSwitchDev {
return true
}
Expand Down Expand Up @@ -259,7 +265,12 @@ func NeedToUpdateSriov(ifaceSpec *Interface, ifaceStatus *InterfaceExt) bool {
return true
}
}

currentEswitchMode := GetEswitchModeFromStatus(ifaceStatus)
desiredEswitchMode := GetEswitchModeFromSpec(ifaceSpec)
if currentEswitchMode != desiredEswitchMode {
log.V(2).Info("NeedToUpdateSriov(): EswitchMode needs update", "desired", desiredEswitchMode, "current", currentEswitchMode)
return true
}
if ifaceSpec.NumVfs != ifaceStatus.NumVfs {
log.V(2).Info("NeedToUpdateSriov(): NumVfs needs update", "desired", ifaceSpec.NumVfs, "current", ifaceStatus.NumVfs)
return true
Expand Down Expand Up @@ -300,11 +311,18 @@ func NeedToUpdateSriov(ifaceSpec *Interface, ifaceStatus *InterfaceExt) bool {
return true
}
}
if groupSpec.VdpaType != vfStatus.VdpaType {
log.V(2).Info("NeedToUpdateSriov(): VF VdpaType mismatch",
"desired", groupSpec.VdpaType, "current", vfStatus.VdpaType)
return true
}
break
}
}
if !ingroup && StringInArray(vfStatus.Driver, vars.DpdkDrivers) {
// VF which has DPDK driver loaded but not in any group, needs to be reset to default driver.
if !ingroup && (StringInArray(vfStatus.Driver, vars.DpdkDrivers) || vfStatus.VdpaType != "") {
// 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
}
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions bindata/manifests/switchdev-config/machineconfigpool.yaml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

34 changes: 5 additions & 29 deletions bindata/scripts/clean-k8s-services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,12 @@ fi

chroot_path="/host"

function clean_services() {
# Remove switchdev service files
rm -f $chroot_path/etc/systemd/system/switchdev-configuration-after-nm.service
rm -f $chroot_path/etc/systemd/system/switchdev-configuration-before-nm.service
rm -f $chroot_path/usr/local/bin/switchdev-configuration-after-nm.sh
rm -f $chroot_path/usr/local/bin/switchdev-configuration-before-nm.sh
rm -f $chroot_path/etc/switchdev.conf
rm -f $chroot_path/etc/udev/switchdev-vf-link-name.sh
# The following files are no longer created by config daemon
# Remove them in case of leftovers from earlier SR-IOV network operator
rm -f $chroot_path/usr/local/bin/configure-switchdev.sh
rm -f $chroot_path/etc/systemd/system/switchdev-configuration.service

# clean NetworkManager and ovs-vswitchd services
network_manager_service=$chroot_path/usr/lib/systemd/system/NetworkManager.service
ovs_service=$chroot_path/usr/lib/systemd/system/ovs-vswitchd.service
ovs_service=$chroot_path/usr/lib/systemd/system/ovs-vswitchd.service

if [ -f $network_manager_service ]; then
sed -i.bak '/switchdev-configuration.service/d' $network_manager_service
fi

if [ -f $ovs_service ]; then
if [ -f $ovs_service ]; then
if grep -q hw-offload $ovs_service; then
sed -i.bak '/hw-offload/d' $ovs_service
chroot $chroot_path /bin/bash -c systemctl daemon-reload >/dev/null 2>&1 || true
fi
}

clean_services
# Reload host services
chroot $chroot_path /bin/bash -c systemctl daemon-reload >/dev/null 2>&1 || true

# Restart system services
chroot $chroot_path /bin/bash -c systemctl restart NetworkManager.service >/dev/null 2>&1 || true
chroot $chroot_path /bin/bash -c systemctl restart ovs-vswitchd.service >/dev/null 2>&1 || true
fi
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do not release ovs and network manager anymore on cleanup?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't patch NetworkManager anymore so there is no need to reload it. Restart of the ovs was always useless, because it doesn't not change anything (hw-offloading option is stored in ovsdb and will be preserved after restart)

25 changes: 0 additions & 25 deletions bindata/scripts/load-udev.sh

This file was deleted.

4 changes: 4 additions & 0 deletions bindata/scripts/switchdev-vf-link-name.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -x
PORT="$1"
echo "NUMBER=${PORT##pf*vf}"
4 changes: 4 additions & 0 deletions pkg/consts/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,13 @@ const (
BusVdpa = "vdpa"

UdevFolder = "/etc/udev"
HostUdevFolder = Host + UdevFolder
UdevRulesFolder = UdevFolder + "/rules.d"
HostUdevRulesFolder = Host + UdevRulesFolder
UdevDisableNM = "/bindata/scripts/udev-find-sriov-pf.sh"
UdevRepName = "/bindata/scripts/switchdev-vf-link-name.sh"
// nolint:goconst
PFNameUdevRule = `SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", KERNELS=="%s", NAME="%s"`
// nolint:goconst
NMUdevRule = `SUBSYSTEM=="net", ` +
`ACTION=="add|change|move", ` +
Expand Down
Loading
Loading