Q-in-Q Encapsulation per VF in Linux
This feature is supported on ConnectX-5 and ConnectX-6 adapter cards only.
This section explains how to configure IEEE 802.1ad Q-in-Q VLAN tagging (S-VLAN) for a hypervisor on a per-VF basis. A VM connected to the VF via SR-IOV can transmit traffic with or without a C-VLAN tag.
When a VF is configured for VST Q-in-Q encapsulation, the adapter hardware automatically inserts an S-VLAN tag into outgoing packets from the VF to the physical port. For incoming packets, the hardware removes the S-VLAN tag before delivering the traffic to the VF.
The setup assumes there are two servers equipped with ConnectX-5/ConnectX-6 adapter cards.
Kernel must be of v3.10 or higher, or custom/inbox kernel must support vlan-stag
Firmware version 16/20.21.0458 or higher must be installed for ConnectX-5/ConnectX-6 HCAs
The server should be enabled in SR-IOV and the VF should be attached to a VM on the hypervisor.
Network Considerations - the network switches may require increasing the MTU (to support 1522 MTU size) on the relevant switch ports.
Add the required S-VLAN (QinQ) tag (on the hypervisor) per port per VF. There are two ways to add the S-VLAN:
By using sysfs:
echo
'100:0:802.1ad'> /sys/class/net/ens1f0/device/sriov/0/vlanBy using the ip link command (available only when using the latest Kernel version):
ip link set dev ens1f0 vf
0vlan100proto802.1adCheck the configuration using the ip link show command:
# ip link show ens1f0 ens1f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu
1500qdisc mq state UP mode DEFAULT qlen1000link/ether ec:0d:9a:44:37:84brd ff:ff:ff:ff:ff:ff vf0MAC00:00:00:00:00:00, vlan100, vlan protocol802.1ad, spoof checking off, link-state auto, trust off vf1MAC00:00:00:00:00:00, spoof checking off, link-state auto, trust off vf2MAC00:00:00:00:00:00, spoof checking off, link-state auto, trust off vf3MAC00:00:00:00:00:00, spoof checking off, link-state auto, trust off vf4MAC00:00:00:00:00:00, spoof checking off, link-state auto, trust off
Optional: Add S-VLAN priority. Use the qos parameter in the ip link command (or sysfs):
ip link set dev ens1f0 vf
0vlan100qos3proto802.1adCheck the configuration using the ip link show command:
# ip link show ens1f0 ens1f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu
1500qdisc mq state UP mode DEFAULT qlen1000link/ether ec:0d:9a:44:37:84brd ff:ff:ff:ff:ff:ff vf0MAC00:00:00:00:00:00, vlan100, qos3, vlan protocol802.1ad, spoof checking off, link-state auto, trust off vf1MAC00:00:00:00:00:00, spoof checking off, link-state auto, trust off vf2MAC00:00:00:00:00:00, spoof checking off, link-state auto, trust off vf3MAC00:00:00:00:00:00, spoof checking off, link-state auto, trust off vf4MAC00:00:00:00:00:00, spoof checking off, link-state auto, trust offCreate a VLAN interface on the VM and add an IP address.
ip link add link ens5 ens5.
40type vlan protocol802.1q id40ip addr add42.134.135.7/16brd42.134.255.255dev ens5.40ip link set dev ens5.40upTo verify the setup, run ping between the two VMs and open Wireshark or tcpdump to capture the packet.