5.22. Linux SockXdp - emllSockXdp

The Real-time Ethernet Driver SockXdp does not need the atemsys driver and uses already established Ethernet adapters, e.g. eth0, eth1, etc. It is strongly recommended to use a separate network adapter to connect EtherCAT devices. If the main network adapter is used for both EtherCAT devices and the local area network there may be a main impact on the local area network operation.

Note

Root privileges are required.

The parameters to the Real-time Ethernet Driver SockXdp are setup-specific. The function CreateLinkParmsFromCmdLineSockXdp() in EcSelectLinkLayer.cpp demonstrates how to initialize the Real-time Ethernet Driver instance.

Public Members

Common link parameters. Signature must be set to EC_LINK_PARMS_SIGNATURE_SOCKXDP

Native ETH device name, e.g. “eth0” (zero terminated)

Used NIC Queue Id

XDP mode

Don’t change target MAC address to FF:FF:FF:FF:FF:FF

Prevent adding Ethernet padding to work-around EtherCAT corruption bugs from native Linux driver(s).

enum EC_T_XDP_MODE

Values:

enumerator eXDP_SKB_MODE

Generic XDP, XDP runs in the standard network stack

enumerator eXDP_DRV_MODE

Native XDP, Runs XDP directly in the NIC driver

enumerator eXDP_HW_MODE

Offloaded XDP, XDP programs are offloaded to the network card itself, running on the NIC firmware, not tested

enumerator eXDP_DRV_ZEROCOPY

Native XDP with ZEROCOPY

5.22.1. Linux System Requirements

To use the XDP Real-time Ethernet Driver the following system requirements need to be met:

  • Your kernel have to support XDP, check if the following entry is activated in your .config file.

    CONFIG_XDP_SOCKETS=y

    If it is not activated you need to rebuild your kernel with CONFIG_XDP_SOCKETS.

5.22.2. Getting started

  • Download libxdp Version 1.4.3 from https://github.com/xdp-project/xdp-tools and install it.

  • Download libbpf Version 1.5.0 from https://github.com/libbpf/libbpf and install it.

  • Update the linux drivers of the NIC that would be used

  • If the NIC supports XDP, turn off xdp generic mode:
    ip link set dev eth0 xdpgeneric off
    
  • If the NIC have multiple queue support, use one queue instead of multiple queues:
    ethtool -L eth0 combined 1