查看PCI网卡
# lspci | grep Eth
19:00.0 Ethernet controller: Intel Corporation Ethernet Controller X710 for 10GbE SFP+ (rev 02)
19:00.1 Ethernet controller: Intel Corporation Ethernet Controller X710 for 10GbE SFP+ (rev 02)
寻找对应的网络设备
# ls /sys/class/net/ -l | grep "19:00"
lrwxrwxrwx 1 root root 0 Sep 1 09:47 eth6 -> ../../devices/pci0000:17/0000:17:02.0/0000:19:00.0/net/eth6/
lrwxrwxrwx 1 root root 0 Sep 1 09:47 eth7 -> ../../devices/pci0000:17/0000:17:02.0/0000:19:00.1/net/eth7/
查看支持的vf数量
/sys/class/net/eth6 # cat device/sriov_totalvfs
64
/sys/class/net/eth6 # cat device/sriov_numvfs
0
上面的eth6物理网卡支持的VF的数量最大为64,当前添加的数量为0
设置VF的数量
/sys/class/net/eth6 # echo 2 > device/sriov_numvfs
查看VF对应的网络设备
/sys/class/net/eth6 # ls device/virtfn* -l
lrwxrwxrwx 1 root root 0 Sep 1 14:45 device/virtfn0 -> ../0000:1a:02.0/
lrwxrwxrwx 1 root root 0 Sep 1 14:45 device/virtfn1 -> ../0000:1a:02.1/
/sys/class/net/eth6 # ls device/virtfn0/net/
eth11/
/sys/class/net/eth6 # ls device/virtfn1/net/
eth10/
/sys/class/net # ls -l
total 0
lrwxrwxrwx 1 root root 0 Aug 30 15:28 bond0 -> ../../devices/virtual/net/bond0/
-rw-r--r-- 1 root root 4096 Sep 1 14:37 bonding_masters
lrwxrwxrwx 1 root root 0 Sep 1 14:45 eth10 -> ../../devices/pci0000:17/0000:17:02.0/0000:1a:02.1/net/eth10/
lrwxrwxrwx 1 root root 0 Sep 1 14:45 eth11 -> ../../devices/pci0000:17/0000:17:02.0/0000:1a:02.0/net/eth11/
lrwxrwxrwx 1 root root 0 Sep 1 14:48 eth12 -> ../../devices/pci0000:17/0000:17:02.0/0000:1a:0a.1/net/eth12/
lrwxrwxrwx 1 root root 0 Sep 1 14:48 eth13 -> ../../devices/pci0000:17/0000:17:02.0/0000:1a:0a.0/net/eth13/
lrwxrwxrwx 1 root root 0 Sep 1 09:47 eth6 -> ../../devices/pci0000:17/0000:17:02.0/0000:19:00.0/net/eth6/
lrwxrwxrwx 1 root root 0 Sep 1 09:47 eth7 -> ../../devices/pci0000:17/0000:17:02.0/0000:19:00.1/net/eth7/
# lspci | grep Eth
19:00.0 Ethernet controller: Intel Corporation Ethernet Controller X710 for 10GbE SFP+ (rev 02)
19:00.1 Ethernet controller: Intel Corporation Ethernet Controller X710 for 10GbE SFP+ (rev 02)
1a:02.0 Ethernet controller: Intel Corporation Ethernet Virtual Function 700 Series (rev 02)
1a:02.1 Ethernet controller: Intel Corporation Ethernet Virtual Function 700 Series (rev 02)
1a:0a.0 Ethernet controller: Intel Corporation Ethernet Virtual Function 700 Series (rev 02)
1a:0a.1 Ethernet controller: Intel Corporation Ethernet Virtual Function 700 Series (rev 02)
# ip link
51: eth6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT qlen 1000
link/ether 28:c1:3c:89:b6:dd brd ff:ff:ff:ff:ff:ff
vf 0 MAC 00:00:00:00:00:00, spoof checking on
vf 1 MAC 00:00:00:00:00:00, spoof checking on
52: eth7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT qlen 1000
link/ether 28:c1:3c:89:b6:de brd ff:ff:ff:ff:ff:ff
vf 0 MAC 00:00:00:00:00:00, spoof checking on
vf 1 MAC 00:00:00:00:00:00, spoof checking on
给VF设置VLAN
# ip link set eth6 vf 1 vlan 200
# ip link set eth7 vf 1 vlan 200
# ip link set eth6 vf 0 vlan 300
# ip link set eth7 vf 0 vlan 300
添加和删除聚合口
/sys/class/net # echo +channel30 > bonding_masters
/sys/class/net # ls channel30 -l
lrwxrwxrwx 1 root root 0 Sep 1 14:56 channel30 -> ../../devices/virtual/net/channel30/
/sys/class/net # echo -channel30 > bonding_masters
添加和删除网口到聚合网口
/sys/class/net # echo +eth10 > channel30/bonding/slaves
/sys/class/net # echo +eth12 > channel30/bonding/slaves
/sys/class/net # echo -eth10 > channel30/bonding/slaves
/sys/class/net # echo -eth12 > channel30/bonding/slaves
查看聚合口之下的网口
/sys/class/net/channel30 # cat bonding/slaves
eth10 eth12
/sys/class/net/channel30 # ls -l lower_eth* -l
lrwxrwxrwx 1 root root 0 Sep 1 15:00 lower_eth10 -> ../../../pci0000:17/0000:17:02.0/0000:1a:02.1/net/eth10/
lrwxrwxrwx 1 root root 0 Sep 1 15:00 lower_eth12 -> ../../../pci0000:17/0000:17:02.0/0000:1a:0a.1/net/eth12/
标签:00,聚合,VF,..,网口,17,0000,net,root
From: https://www.cnblogs.com/pengdonglin137/p/16646503.html