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

Add switchdev-configuration-after-NM service #202

Merged
merged 1 commit into from
Dec 15, 2021
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
mode: 0755
overwrite: true
path: "/usr/local/bin/switchdev-configuration-after-NM.sh"
contents:
inline: |
#!/bin/bash
set -eux
input="/etc/sriov_config.json"

if [ ! -f $input ]; then
echo "File /etc/sriov_config.json not exist."
exit
fi

# Required for NetworkManager configuration(e.g. bond) to settle down
sleep 3
Copy link
Collaborator

Choose a reason for hiding this comment

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

what happens if we dont have this sleep ? do you know what configurations need to settle down ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What happened was that VF LAG didn't take effect (there is the dmesg indicating the error).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@adrianchiris any follow-up questions ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

no additional questions. VF Lag has some quirks :(


jq -c '.interfaces[]' $input | while read iface;
do
eswitch_mode=$(echo $iface | jq '.eSwitchMode' -r)
if [[ "$eswitch_mode" == "switchdev" ]]; then
pci_addr=$(echo $iface | jq '.pciAddress' -r)
name=$(echo $iface | jq '.name' -r)

echo "load VF driver for $pci_addr"
VfDirs=$(ls /sys/bus/pci/devices/${pci_addr} | grep virtfn)

# load VF driver
for VfDir in $VfDirs
do
VfPciAddr=$(basename "$( readlink -f /sys/bus/pci/devices/${pci_addr}/$VfDir )")
echo $VfPciAddr > /sys/bus/pci/drivers_probe
done
fi
done
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mode: 0755
overwrite: true
path: "/usr/local/bin/configure-switchdev.sh"
path: "/usr/local/bin/switchdev-configuration-before-NM.sh"
contents:
inline: |
#!/bin/bash
Expand Down Expand Up @@ -72,12 +72,5 @@ contents:

# turn hw-tc-offload on
/usr/sbin/ethtool -K ${name} hw-tc-offload on

Copy link
Collaborator

@adrianchiris adrianchiris Dec 8, 2021

Choose a reason for hiding this comment

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

not related to this PR, but we could probably save some time during boot if we set sriov_drivers_autoprobe to 0
then there is no need to unload drivers in line 57

  1. echo 0 > /sys/bus/pci/devices/PCI_DBDF_OF_PF/sriov_drivers_autoprobe
  2. echo XXX > /sys/bus/pci/devices/PCI_DBDF_OF_PF/sriov_numvfs
  3. Restore drivers autoprobe
    echo 1 > /sys/bus/pci/devices/PCI_DBDF_OF_PF/sriov_drivers_autoprobe

if this sounds like something we like, i can open an enhancement on it

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good to me. Can echo 1 > /sys/bus/pci/devices/PCI_DBDF_OF_PF/sriov_drivers_autoprobe load the driver to VFs as we do in line 75?

Copy link
Collaborator

Choose a reason for hiding this comment

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

need to re-enable sriov_drivers_autoprobe before binding driver in L75

Copy link
Collaborator

Choose a reason for hiding this comment

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

done #214

# load VF driver
for VfDir in $VfDirs
do
VfPciAddr=$(basename "$( readlink -f /sys/bus/pci/devices/${pci_addr}/$VfDir )")
echo $VfPciAddr > /sys/bus/pci/drivers_probe
done
fi
done
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ dropins:
- name: 10-switchdev.conf
contents: |
[Unit]
Wants=switchdev-configuration.service
After=switchdev-configuration.service
Wants=switchdev-configuration-before-NM.service
After=switchdev-configuration-before-NM.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
contents: |
[Unit]
Description=Binds SRIOV VFs to switchdev driver
# Removal of this file signals firstboot completion
ConditionPathExists=!/etc/ignition-machine-config-encapsulated.json
# This service is used to rebind SR-IOV netdev driver after switchdev and NetworkManager configurations
Wants=NetworkManager.service
After=NetworkManager.service

[Service]
Type=oneshot
ExecStart=/usr/local/bin/switchdev-configuration-after-NM.sh
StandardOutput=journal+console
StandardError=journal+console

[Install]
WantedBy=network-online.target
enabled: true
name: switchdev-configuration-after-NM.service
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
contents: |
[Unit]
Description=Configures SRIOV NIC into switchdev mode
Description=Configures SRIOV NIC to switchdev mode
# Removal of this file signals firstboot completion
ConditionPathExists=!/etc/ignition-machine-config-encapsulated.json
# This service is used to move a SRIOV NIC into switchdev mode
# This service is used to move a SRIOV NIC to switchdev mode
Wants=network-pre.target
Before=network-pre.target

[Service]
Type=oneshot
ExecStart=/usr/local/bin/configure-switchdev.sh
ExecStart=/usr/local/bin/switchdev-configuration-before-NM.sh
StandardOutput=journal+console
StandardError=journal+console

[Install]
WantedBy=network-online.target
enabled: true
name: switchdev-configuration.service
name: switchdev-configuration-before-NM.service