-
Notifications
You must be signed in to change notification settings - Fork 111
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
Support Switchdev for kernel 5.8 and above #75
Support Switchdev for kernel 5.8 and above #75
Conversation
@Mmduh-483 I don't quite understand the kernel change, do you have reference to the kernel patch? |
@zshi-redhat see this kernel change https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=123f0f53dd64b67e34142485fe866a8a581f12f1. I think it will effect RH 8.4 and above |
2b3afa3
to
ed7bfb9
Compare
@zshi-redhat I updated the commit message and PR description to be more clear |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick review, I need to check if the kernel change is in RHEL-8.4, otherwise we may need to support old kernel behaviour.
names=() | ||
|
||
while read pci_addr num_vfs | ||
do | ||
echo "Set $num_vfs VFs on device $pci_addr" | ||
|
||
names+=($(ls /sys/bus/pci/devices/${pci_addr}/net/)) | ||
# Create udev rule to save PF name | ||
add_udev_rule_for_sriov_pf $pci_addr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the argument of add_udev_rule_for_sriov_pf being pf name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You r right I missed it before pushing it, it should be like
cat /etc/udev/rules.d/10-persistent-net.rules
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", KERNELS=="0000:03:00.1", NAME="enp3s0f1np1"
fi | ||
} | ||
|
||
add_udev_rule_for_sriov_pf(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this will keep the PF name as it is?
On openshift, it expects the PF name to be consistent w/ and w/o switchdev mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the udev rule is to save the name of the PF
anyway we need to support old kernel. @Mmduh-483 you change support both new kernel and old ones right? |
ed7bfb9
to
5d40990
Compare
It is supporting both |
What does the output of |
~# ls /sys/bus/pci/devices/0000:03:00.0/net/ |
When |
# reset the pf name | ||
new_name=$(ls /sys/bus/pci/devices/${pci_addr}/net/) | ||
ip link set ${new_name} down | ||
ip link set ${new_name} name ${names[i]} | ||
ip link set ${names[i]} up |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
${names[i]}
could be a list of pfName + vfRepNames
, is it expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, the names where collected in the first loop before the representors created
The representors are not created yet at this stage |
@@ -38,6 +39,8 @@ const ( | |||
var InitialState sriovnetworkv1.SriovNetworkNodeState | |||
var ClusterType string | |||
|
|||
var pfPhysPortNameRe = regexp.MustCompile(`p\d+`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This regexp matches all the following names: enp3s0f0np0 enp3s0f0np0_0 enp3s0f0np0_1 enp3s0f0np0_2
Maybe put a $
at the end of expression to match the PF name only? regexp.MustCompile(p\d+$
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This regex is for /sys/class/net/<netdev>/phys_port_name
not the interface name
For PFs it is p/d+
e.g cat /sys/class/net/enp3s0f0np0/phys_port_name
p0
For VF representors it is pf/d+vf/d+
e.g cat /sys/class/net/enp3s0f0np0_2/phys_port_name
pf0vf2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack+
5d40990
to
9e9b93f
Compare
overall change looks good to me, I'll run some test on openshift and comment if any issues. |
if [ ! -f $input ]; then | ||
echo "File /etc/switchdev.conf not exist." | ||
exit | ||
fi | ||
|
||
append_to_file(){ | ||
if ! test -f "$2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be made more readable ? please assign meaningful local vars to $1 $2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
Till kernel 5.7 VF representors are exposed as virtual devices, they are not linked to a PCI address. Starting from kernel 5.8 the VF representors are linked to their PF PCI address, so /sys/bus/pci/devices/<pf-pci-address>/net contains the PF net device and it VF representors net devices. The new kernel behaviour affects 'tryGetInterfaceName' if PF in switchdev and configure-switchdev script This commit brings needed changes to cope with new kernel behviour. Signed-off-by: Mamduh Alassi <mamduhala@nvidia.com>
9e9b93f
to
e48e2da
Compare
@zshi-redhat how did the test go? Are there any comments? |
Sorry for the late update, I didn't run into any issue after applying this PR. |
Till kernel 5.7 VF representors are exposed as virtual devices, they are not linked to a PCI address.
Starting from kernel 5.8 the VF representors are linked to their PF PCI address, so /sys/bus/pci/devices//net contains the PF net device and it VF representors net devices.
The new kernel behaviour affects 'tryGetInterfaceName' if PF in switchdev and configure-switchdev script
This commit brings needed changes to cope with new kernel behviour.