A user application can establish connections with multiple virtual functions, and one virtual function can be connected to a single application only. The Napatech SmartNIC running Link-Inline™ Software supports a maximum of 128 virtual functions.
Patched virtio PMD
The user application running on virtual functions must use the standard DPDK virtio PMD with the Napatech patch. This patch enhances support for hardware offloading features of the DPDK rte_flow API.
See Kubernetes architecture with the Napatech SmartNIC running Link-Inline™ Software and Configuring flows in a user-application container.
Configuring default flows
ntinl_package-<version>-linux/dpdk_v<version>/dpdk_v<version>-nt_<version>/examples/nt_examples/forward/where version is the version identifier of the corresponding package.
- Group 0 is used to filter IPv4 traffic using the RTE_FLOW_ITEM_TYPE_IPV4 pattern, and RTE_FLOW_ACTION_TYPE_JUMP is included to jump to group 1.
- Group 0 is used to filter IPv6 traffic using the RTE_FLOW_ITEM_TYPE_IPV6 pattern, and RTE_FLOW_ACTION_TYPE_JUMP is included to jump to group 2.
If default flows are not configured, received frames are discarded in the SmartNIC or delivered to the ntmain application using the exception_path=1 option. See Handling non-matched frames.
Flow configuration for offloading
When received frames are delivered to the user application via each virtual function, the user application can configure the SmartNIC with new flow rules if hardware offload is required. The user application uses the DPDK rte_flow API for configuring these flows. See Configuring flows in a user-application container.
ntinl_package-<version>-linux/dpdk_v<version>/dpdk_v<version>-nt_<version>/examples/nt_examples/forward/where version is the version identifier of the corresponding package.
The filter.c example shows how group 1 is used for IPv4 flows, and group 2 is used for IPv6 flows. IP and UDP/TCP/SCTP/ICMP headers are used for defining flows. After the SmartNIC is configured with new flows, received frames that are matched the learned flows are transmitted on the specified port without being delivered to the host.
Mandatory DPDK EAL command-line parameters
- --file-prefix: Specifies a prefix for all files created by DPDK, such as shared memory files, log files, and statistics files. This option is required to ensure uniqueness when multiple DPDK applications are running on the same system. It's helpful for identifying which DPDK application instance is generating the logs.
- --no-pci: Configures DPDK not to use any physical PCIe devices as the user application uses virtio interfaces.
For a list of available EAL command-line parameters, see https://doc.dpdk.org/guides-22.11/linux_gsg/linux_eal_parameters.html.
--vdev options
--vdev=virtio_user<number>where number represents the instance number of the virtio PMD. Each instance of the virtio PMD handles one virtual function. Consequently, if multiple virtual functions are connected to the user-application pod, multiple instances of the virtio PMD must run. The number for the first instance is 0, and it increments for the subsequent instances. For example:
--vdev=virtio_user0
- path=<socket_if>: Specifies the vHost socket file directory.
- If the shared vHost-user socket directory is used, set as
follows:
path=/usr/local/var/run/stdvio<VF_number>
where VF_number is the virtual function. The VF_number for the first virtual function is 4, and it increments for the subsequent virtual functions. For example:path=/usr/local/var/run/stdvio4
- If a separated directory is used, set as follows:
/usr/local/var/run/stdvio<VF_number>/stdvio<VF_number>
For example:path=/usr/local/var/run/stdvio4/stdvio5
- If the shared vHost-user socket directory is used, set as
follows:
- server=1: The virtio PMD / vHost must run as a server.
- mac=<mac_address>: Specifies the MAC address for the virtual function. The MAC address of the first virtual function can be configured using the vfMacStart parameter in the ntdevplugin.yaml file.
- packed_vq=1: Only packed virtqueue is supported.
- queues=<number_of_queues>: Specifies the number of queues for RSS. It is set to 1 by default using the vfNumberOfQueues parameter in the ntdevplugin.yaml file.
Receive side scaling (RSS)
RSS can be enabled in the application using rte_flow. Additionally, the user applications should include a command line parameter to pass the number of queues which has been specified in the main-app container. The parameter is then used to initialize the specified number of queues.
- Enabling RSS in the user application: API: Setting up Receive Side Scaling (RSS).
- Setting up multiple queues in the ntmain application: Setting up multiple queues.
Accessing the SmartNIC in Kubernetes
resources: limits: napatech.com/nt_vf: 2 hugepages-1Gi: 2Gi memory: 2GiSee manifest file examples for demo application pods included in the following directory of the Napatech Link-Inline™ Software package.
ntinl_package-<version>-linux/kubernetes_v<version>/manifest/where version is the version identifier of the corresponding package.
Environment variables in a user-application container
After virtual functions are allocated, the Napatech device plugin creates environment variables in a user-application container. This table shows environment variables that are set by the Napatech device plugin in user-application containers.
Environment variable | Description |
---|---|
NT_VF_NUM | Allocated virtual function list. For example, 4 5 6 7. |
NT_VF_QUEUES | Number of queues to be configured per virtual function. For example, 3. |
NT_VF_DEV | PCI ID list for all allocated virtual functions. For example, 0000:65:00.4 0000:65:00.5. |
NT_VF_MAC | MAC address list for all allocated virtual functions. For example, 02:11:22:33:44:01 02:11:22:33:44:02. |
NT_VF_VLAN | VLAN ID list for all configured virtual functions. For example, 44 45. |
NT_VF_SOCKET | Socket list for all configured virtual functions. For example, /usr/local/var/run/stdvio4/stdvio4 /usr/local/var/run/stdvio5/stdvio5. |
NT_DPDK_PREFIX | Unique DPDK prefix to avoid clash with other DPDK based applications For example, nt-container4. |
Mounting host directories
Directories on the host | Mounted directories on the main-app container |
---|---|
/var/run/ntconnect | /var/run/ntconnect |
/usr/local/var/run/stdvio4 | /usr/local/var/run/stdvio4 |
/usr/local/var/run/stdvio5 | /usr/local/var/run/stdvio5 |
… | … |
Host path | Pod path |
---|---|
/dev/vfio/vfio | /dev/vfio/vfio |
/dev/vfio/<VF_group_number> | /dev/vfio/<group_number> |
… | … |
Configuring the application manifest file
- napatech.com/nt_pf: 1: The physical function can be allocated to only one container. The target container will receive information about the physical function's PCI bus ID as well as details regarding all configured virtual functions.
- napatech.com/nt_vf: <number_of_vf>: number_of_vf specifies the number of virtual functions per container. The specified number of virtual functions can be allocated to multiple containers. If the requested number of virtual functions is not available, then the container will remain in a pending state. The valid value range is 1 to 128.
… … spec: containers: - name: forward image: k8s.io/ntforward:1.1 imagePullPolicy: IfNotPresent command: ["/opt/kubernetes/start.sh"] resources: limits: napatech.com/nt_vf: 2 hugepages-1Gi: 2Gi memory: 512Mi volumeMounts: - name: hugepage mountPath: /hugepages volumes: - name: hugepage emptyDir: medium: HugePagesUsing this manifest file, 2 virtual functions are requested for the container.
ntinl_package-<version>/kubernetes_v<version>/manifest/k8s-forward.yamlwhere version is the version identifier of the corresponding package.
Startup script
#!/usr/bin/env bash NT_VF_MAC_ARRAY=($NT_VF_MAC) NT_VF_SOCKET_ARRAY=($NT_VF_SOCKET) # prepare dpdk vdev configuration for allocated virtual functions APP_VDEV="" for i in ${!NT_VF_MAC_ARRAY[@]}; do APP_VDEV="$APP_VDEV \ --vdev=virtio_user${i},path=${NT_VF_SOCKET_ARRAY[$i]},server=1,mac=${NT_VF_MAC_ARRAY[$i]},packed_vq=1,queues=${NT_VF_QUEUES}" # remove old socket rm -f ${NT_VF_SOCKET_ARRAY[$i]} done # Execute app dpdk-forward -c 0xfff0 -n 4 --no-pci ${APP_VDEV} --file-prefix=${NT_DPDK_PREFIX} -- -i 0 -e 1 -q ${NT_VF_QUEUES}