Skip to content

Commit

Permalink
Merge pull request #643 from ykulazhenkov/pr-turn-on-switchdev
Browse files Browse the repository at this point in the history
[switchdev 9/9] Enable new switchdev implementation
  • Loading branch information
zeeke authored Mar 28, 2024
2 parents f2ca884 + 0bdf464 commit 160d177
Show file tree
Hide file tree
Showing 28 changed files with 600 additions and 1,160 deletions.
26 changes: 22 additions & 4 deletions api/v1/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,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 @@ -255,7 +261,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 @@ -296,11 +307,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
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

0 comments on commit 160d177

Please sign in to comment.