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

network: Introduce SR-IOV #16219

Merged
merged 5 commits into from Jul 2, 2020
Merged

network: Introduce SR-IOV #16219

merged 5 commits into from Jul 2, 2020

Conversation

ssahani
Copy link
Contributor

@ssahani ssahani commented Jun 19, 2020

closes #15629

cc @yuwata . I spent some time on SR-IOV. Here is the working version .

[Match]
Name=eni5np1

[SRIOV]
VirtualFunction=1
VLanId=5
QualityOfService=1
MACSpoofCheck=1
QueryReceiveSideScaling=1
Trust=1
LinkState=on

@ssahani ssahani force-pushed the network-sr-iov branch 2 times, most recently from d85bf9b to f4cbeb6 Compare June 19, 2020 12:57
@lgtm-com
Copy link

lgtm-com bot commented Jun 19, 2020

This pull request introduces 1 alert when merging f4cbeb6 into a51a324 - view on LGTM.com

new alerts:

  • 1 for Use of potentially dangerous function

@ssahani ssahani changed the title network: Introduce SR-IOV (Do#t Merge) network: Introduce SR-IOV Jun 20, 2020
@ssahani ssahani force-pushed the network-sr-iov branch 3 times, most recently from 6639924 to 36f6723 Compare June 22, 2020 02:49
@yuwata yuwata added the network label Jun 22, 2020
@yuwata
Copy link
Member

yuwata commented Jun 22, 2020

I will slightly update the commits and add tests for this.

@yuwata
Copy link
Member

yuwata commented Jun 22, 2020

@ssahani Updated. PTAL.

return func

return f

def expectedFailureIfCAKEIsNotAvailable():
def f(func):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

➜  ~ echo "99 2" > /sys/bus/netdevsim/new_device
➜  ~ ip link
9: eni99np1: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether f6:e7:ab:f4:5b:0d brd ff:ff:ff:ff:ff:ff
10: eni99np2: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 16:0a:ff:96:bf:77 brd ff:ff:ff:ff:ff:ff

➜  ~ udevadm info -w10s /sys/devices/netdevsim99/net/eni99np1
P: /devices/netdevsim99/net/eni99np1
L: 0
E: DEVPATH=/devices/netdevsim99/net/eni99np1
E: SUBSYSTEM=net
E: INTERFACE=eni99np1
E: IFINDEX=9
E: USEC_INITIALIZED=53327702503
E: ID_NET_NAMING_SCHEME=v245
E: ID_NET_NAME_PATH=eni99np1
E: ID_NET_DRIVER=netdevsim
E: ID_NET_LINK_FILE=/usr/lib/systemd/network/99-default.link
E: ID_NET_NAME=eni99np1
E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/eni99np1 /sys/subsystem/net/devices/eni99np1
E: TAGS=:systemd:

➜  ~ echo "3" /sys/class/net/eni99np1/device/sriov_numvfs
3 /sys/class/net/eni99np1/device/sriov_numvfs
➜  ~ udevadm info -w10s /sys/devices/netdevsim99/net/eni99np1
P: /devices/netdevsim99/net/eni99np1
L: 0
E: DEVPATH=/devices/netdevsim99/net/eni99np1
E: SUBSYSTEM=net
E: INTERFACE=eni99np1
E: IFINDEX=9
E: USEC_INITIALIZED=53327702503
E: ID_NET_NAMING_SCHEME=v245
E: ID_NET_NAME_PATH=eni99np1
E: ID_NET_DRIVER=netdevsim
E: ID_NET_LINK_FILE=/usr/lib/systemd/network/99-default.link
E: ID_NET_NAME=eni99np1
E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/eni99np1 /sys/subsystem/net/devices/eni99np1
E: TAGS=:systemd:

➜  ~ ip -d link show eni99np1
9: eni99np1: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether f6:e7:ab:f4:5b:0d brd ff:ff:ff:ff:ff:ff promiscuity 0 minmtu 68 maxmtu 65535 addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 portname p1 switchid efa555440bc0d5e49db2492abc36907aa49440e0256787a78ab0288dc8bb00
➜  ~
➜  ~ echo "3" > /sys/class/net/eni99np1/device/sriov_numvfs
➜  ~ ip -d link show eni99np1
9: eni99np1: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether f6:e7:ab:f4:5b:0d brd ff:ff:ff:ff:ff:ff promiscuity 0 minmtu 68 maxmtu 65535 addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 portname p1 switchid efa555440bc0d5e49db2492abc36907aa49440e0256787a78ab0288dc8bb00
    vf 0     link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff, spoof checking off, link-state auto, trust off, query_rss off
    vf 1     link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff, spoof checking off, link-state auto, trust off, query_rss off
    vf 2     link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff, spoof checking off, link-state auto, trust off, query_rss off

I tested the same manually . It's ok

@ssahani
Copy link
Contributor Author

ssahani commented Jun 22, 2020

This looks good. thanks @yuwata .

call('rmmod netdevsim', stderr=subprocess.STDOUT)
rc = call('modprobe netdevsim', stderr=subprocess.STDOUT)
if rc != 0:
return unittest.expectedFailure(func)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes fedora does not support till now.

~ sus@esx-fedora
❯ sudo modprobe netdevsim
modprobe: FATAL: Module netdevsim not found in directory /lib/modules/5.8.0-0.rc1.20200617git69119673bd50.1.fc33.x86_64

Copy link
Member

Choose a reason for hiding this comment

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

kernel-modules-internal-5.6.19-300.fc32.x86_64 provides netdevsim.

@yuwata
Copy link
Member

yuwata commented Jun 22, 2020

@mrc0mmand Have you updated the Arch image for CentOS CIs? I have no idea about the CI failures.

@ssahani
Copy link
Contributor Author

ssahani commented Jun 22, 2020

It seems some new parameters shows up in the route table.

@mrc0mmand
Copy link
Member

@mrc0mmand Have you updated the Arch image for CentOS CIs? I have no idea about the CI failures.

Nope, the image update is stuck on #16199.

@mrc0mmand
Copy link
Member

It seems some new parameters shows up in the route table.

Yeah,rt_trap appears in the routing table now, but not sure where it comes from.

@yuwata
Copy link
Member

yuwata commented Jun 22, 2020

More seriously, now test_route_static does not configure the default gateway...

@ssahani
Copy link
Contributor Author

ssahani commented Jun 22, 2020

It seems some new parameters shows up in the route table.

Yeah,rt_trap appears in the routing table now, but not sure where it comes from.

iproute update ?

@mrc0mmand
Copy link
Member

I don't think so, there are several PRs which were built before and after this one, and all of them passed:

image

And the package set of the Arch image should be unchanged since Jun 11th.

@ssahani
Copy link
Contributor Author

ssahani commented Jun 22, 2020

Please retrigger 2/3 times . If this happens again they we figure must be because of this PR and we need to do some cleanup.

@mrc0mmand
Copy link
Member

It fails consistently with the exact same issue in both runs even after reschedule, whereas other (and more recent) PRs are fine.

man/systemd.network.xml Outdated Show resolved Hide resolved
man/systemd.network.xml Outdated Show resolved Hide resolved
man/systemd.network.xml Outdated Show resolved Hide resolved
man/systemd.network.xml Outdated Show resolved Hide resolved
man/systemd.network.xml Outdated Show resolved Hide resolved
man/systemd.network.xml Outdated Show resolved Hide resolved
man/systemd.network.xml Outdated Show resolved Hide resolved
man/systemd.network.xml Outdated Show resolved Hide resolved
man/systemd.network.xml Outdated Show resolved Hide resolved
@yuwata yuwata force-pushed the network-sr-iov branch 2 times, most recently from 0e88799 to 0bacad6 Compare June 23, 2020 11:37
@yuwata
Copy link
Member

yuwata commented Jun 24, 2020

Still I do not know why the rt_trap flag is added. So, I added a workaround in test_sysctl_disable_ipv6 to ignore the flag. Now all tests are green.

ssahani and others added 4 commits July 1, 2020 13:51
SR-IOV provides the ability to partition a single physical PCI
resource into virtual PCI functions which can then be injected in
to a VM. In the case of network VFs, SR-IOV improves north-south n
etwork performance (that is, traffic with endpoints outside the
host machine) by allowing traffic to bypass the host machine’s network stack.
This also adjusts test_sysctl_disable_ipv6(), as rt_trap flag may be
added to routes on some environments.
@yuwata
Copy link
Member

yuwata commented Jul 1, 2020

@keszybz Thank you for the review. Updated version is pushed. I hope all your points are addressed. PTAL.

@keszybz
Copy link
Member

keszybz commented Jul 1, 2020

LGTM.

@keszybz keszybz added the good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed label Jul 1, 2020
@yuwata yuwata merged commit 1447dc6 into systemd:master Jul 2, 2020
@ssahani ssahani deleted the network-sr-iov branch July 2, 2020 11:53
@daiaji
Copy link

daiaji commented Jan 23, 2022

How should I use it?

cat /etc/systemd/network/sr-iov.network 
[Match]
Name=enp7s0f2

[SR-IOV]
VirtualFunction=2

I created the relevant configuration file, but it doesn't seem to work.

@yuwata
Copy link
Member

yuwata commented Jan 23, 2022

@daiaji Does the interface already has virtual functions? The [SR-IOV] section in .network file only configures existing virtual function. If the interface does not have it, then you need to add it by the following:

# echo 3 > /sys/class/net/enp7s0f2/device/sriov_numvfs

Note, recently I posted PR #21865 which adds the support of the same section into .link file, which creates relevant virtual function(s) on demand. If you'd like, please test the current git HEAD.

@daiaji
Copy link

daiaji commented Jan 24, 2022

@yuwata After compiling with this version of systemd, is there no need to manually use the sysfs user interface or add the kernel boot parameters to enable vf?

@yuwata
Copy link
Member

yuwata commented Jan 24, 2022

I am not familiar with kernel boot params about SR-IOV. But, at least with the current git HEAD, it is not necessary to change sysfs attribute manually.

One note, as you may know, to make SR-IOV setting work, the interface needs to support the functionality.

@daiaji
Copy link

daiaji commented Jan 24, 2022

@yuwata

cat /etc/systemd/network/sr-iov.link   
[Match]
MACAddress=a0:36:9f:xx:xx:xx

[SR-IOV]
VirtualFunction=2

The link file does not appear to create VF.
Still need to use the command # echo 3 > /sys/class/net/enp7s0f2/device/sriov_numvfs
Or am I misunderstanding, systemd doesn't create vf for users?

@yuwata
Copy link
Member

yuwata commented Jan 24, 2022

Did you reboot the system or run udevadm control --reload; udevadm trigger --action add /sys/class/net/enp7s0f2? If these do not work for you, then please open a new issue page with debugging logs.

@daiaji
Copy link

daiaji commented Jan 24, 2022

@yuwata I rebooted the system, and I confirmed that this Intel I350-T4 supports SR-IOV.
I will probably have more tests at this time tomorrow, so I should probably rest now.😀

@yuwata
Copy link
Member

yuwata commented Jan 24, 2022

Thanks. Testing the feature is highly appreciated. I am waiting for your report in a new issue page.

@daiaji
Copy link

daiaji commented Jan 25, 2022

Until then, what logs do I need to provide? And how to access these logs.

@yuwata
Copy link
Member

yuwata commented Jan 25, 2022

I noticed that your .link file shown in the above does not have number prefix. One of the matching .link file in the earliest in alphanumerical order is used, so, I guess still 99-default.link is applied to the interface. Please try to rename the file to e.g. 10-sr-iov.link.

And how to access these logs.

Do you use systemd-udevd from the current git HEAD with .link files? If so, create the following rules:

# /etc/udev/rules.d/00-debug-net.rules
SUBSYSTEM=="net", OPTIONS="log_level=debug"

Then, udevadm control --reload; udevadm trigger --action add /sys/class/net/enp7s0f2, and journalctl -b -u systemd-udevd.service shows the debugging logs. Try to export the logs with

journalctl -o short --no-hostname -b -u systemd-udevd.service > /tmp/udevd.log

and provide it.

Also, please provide udevadm info /sys/class/net/enp7s0f2.

Thank you!

@daiaji
Copy link

daiaji commented Jan 25, 2022

I noticed that your .link file shown in the above does not have number prefix. One of the matching .link file in the earliest in alphanumerical order is used, so, I guess still 99-default.link is applied to the interface. Please try to rename the file to e.g. 10-sr-iov.link.

OK, after changing the file name of the link file to 10-sr-iov.link, the VF is allocated normally.
But it seems that the interface name has changed to eth3, why is this?
and PF doesn't seem to be online after restarting the computer, how to make it online?

@yuwata
Copy link
Member

yuwata commented Jan 25, 2022

OK, after changing the file name of the link file to 10-sr-iov.link, the VF is allocated normally.

Yay! Nice!

But it seems that the interface name has changed to eth3, why is this?

That's expected. As the .link file does not contain any naming (and MAC address) related settings. Copy the following lines from the 99-default.link:

[Link]
NamePolicy=keep kernel database onboard slot path
AlternativeNamesPolicy=database onboard slot path
MACAddressPolicy=persistent

and PF doesn't seem to be online after restarting the computer, how to make it online?

Set the link state to yes:

[SR-IOV]
VirtualFunction=2
LinkState=yes

For details, please see section about [SR-IOV] section in systemd.network(5) or systemd.link(5). There exists multiple settings in the section.

Note, if you want to online all VFs, then you need to specify multiple [SR-IOV] sections for each VF.

[SR-IOV]
VirtualFunction=0
LinkState=yes

[SR-IOV]
VirtualFunction=1
LinkState=yes

[SR-IOV]
VirtualFunction=2
LinkState=yes

@daiaji
Copy link

daiaji commented Jan 26, 2022

cat /etc/systemd/network/sr-iov.network
[Match]
Name=enp7s0f2

[Link]
ActivationPolicy=always-up

These configs worked for me.

@yuwata
Copy link
Member

yuwata commented Jan 26, 2022

Yeah, that should also work. And from the logs in your recent issue about wait-online, it seems [SR-IOV] settings work fine for you.

@daiaji
Copy link

daiaji commented Jan 26, 2022

It seems to be more of a problem with the SR-IOV itself. I did not insert a network cable into the enp7s0f2 interface, so even if I use the VF as the network card of the VM, it seems that the network is still not available.

The ActivationPolicy=always-up parameter doesn't seem to help me.😅

But actually because SR-IOV and MACVLAN have similar characteristics (poor compatibility with IEEE 802.11), I can't access my AP, I have given up using SR-IOV and MACVLAN to build my soft router.

Will setting a VLAN help me?

@yuwata
Copy link
Member

yuwata commented Jan 26, 2022

Hm, LinkState=yes doe not help you?

How about setting ConfigureWithoutCarrier=yes (probably with ActivationPolicy=always-up) in .network file for the VF?

Unfortunately, I do not have any SR-IOV supporting real interfaces, but only dummy virtual interface... So, I have almost no way to debug the issue...

@yuwata
Copy link
Member

yuwata commented Jan 26, 2022

If they do not work, how about to also set ConfigureWithoutCarrier=yes (and ActivationPolicy=always-up) in PF?

@yuwata
Copy link
Member

yuwata commented Jan 26, 2022

If you have any good way, then please let me know.

Thank you for your help of testing the [SR-IOV] feature and investigating the root cause of the wait-online issue!

@daiaji
Copy link

daiaji commented Jan 26, 2022

LinkState=yes seems to cause enp7s0f2 to not work directly.

@daiaji
Copy link

daiaji commented Jan 26, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed network
Development

Successfully merging this pull request may close these issues.

networkd: add SR-IOV support
6 participants