From 9f2ff513ba716fdadc92a7a84a0a588a8bd15f9e Mon Sep 17 00:00:00 2001 From: Noor Azura Ahmad Tarmizi Date: Mon, 3 Oct 2022 00:30:54 +0800 Subject: [PATCH] build: Add support for no_xdp and no_xdp_tbs mode Previously, the xdp existence and xdp_tbs existence is required for tsn ref sw build. Now, we are adding additional checks to support non-xdp or non-xdp_tbs system. *XDP existence is based on if_xdp.h existence *XDP_TBS based on txtime member if_xdp.h:xdp_desc structure 1. If if_xdp.h is not there, the XDP(and XDP_TBS as well) is considered as unsupported. In this case, opcua-server will not be compiled. 2. Table of current supported application according to if_xdp.h availability on the system. if_xdp.h indicates that the XDP socket is available to the applications side. Without if_xdp.h only AF_PACKET-socket-based (tsq & txrx-tsn) test will be offered. | tsq | txrx-tsn | opcua-server | ----------------------------------------------------------------------------------- WITHOUT XDP | Y | Y | N | - if_xdp.h not detected | | | | ----------------------------------------------------------------------------------- 2. Table of current supported application according to xdp_tbs availability on the system. | tsq | txrx-tsn | opcua-server | ----------------------------------------------------------------------------------- WITH XDP_TBS | Y | Y | Y | - if_xdp.h detected (WITH_XDP) | | | | - XDP_TBS mode not disabled | | | | - txtime var is detected in if_xdp.h | | | | ----------------------------------------------------------------------------------- WITHOUT XDP_TBS | Y | Y | N(WIP) | - if_xdp.h detected (WITH_XDP) | | | | - XDP_TBS mode disabled (-t) or | | | | - txtime var is NOT detected in if_xdp.h | | | | ----------------------------------------------------------------------------------- Default build (NO -t) is enabling XDP feature and Intel-specific XDP+TBS feature (if they are supported !) Note: Effort is ongoing to decouple libopen62541-iotg fork and opcua-server from XDP_TBS Intel implementation. Signed-off-by: Noor Azura Ahmad Tarmizi --- DEPENDENCIES.md | 41 ++++++++++++++--- Makefile.am | 21 +++++++-- README.md | 2 + README_install.md | 82 ++++++++++++++++++++++++++++++++++ build.sh | 61 +++++++++++++++++++++++++- configure.ac | 109 ++++++++++++++++++++++++++++++++++++++++++---- src/txrx-afxdp.c | 6 +++ src/txrx.c | 22 +++++++--- src/txrx.h | 15 +++++-- 9 files changed, 331 insertions(+), 28 deletions(-) create mode 100644 README_install.md diff --git a/DEPENDENCIES.md b/DEPENDENCIES.md index 7377141..cec09f0 100644 --- a/DEPENDENCIES.md +++ b/DEPENDENCIES.md @@ -5,19 +5,19 @@ software dependencies would have already been installed. For compilation: * [Custom linux kernel headers](https://github.com/intel/linux-intel-lts/tree/5.4/preempt-rt) + - Include support for Intel XDP+TBS implementation * [Custom linux-libc-headers](https://github.com/intel/iotg-yocto-ese-bsp/tree/master/recipes-kernel/linux-libc-headers/linux-libc-headers) + - Include support for Intel XDP+TBS implementation * [Custom libopen62541-iotg](https://github.com/intel/iotg-yocto-ese-main/tree/master/recipes-connectivity/open62541) + - Include support for kernel implementation of Intel XDP+TBS (if_xdp.h change required) * [Custom libbpf](https://github.com/intel/iotg-yocto-ese-main/tree/master/recipes-connectivity/libbpf) + - Include support for kernel implementation of Intel XDP+TBS (if_xdp.h change required) * libelf * libjson-c -In order to compile under Ubuntu, these packages need to be installed first: -* gcc -* autoconf -* libjson-c-dev -* gawk -* build-essential -Note : Customized libbpf and libopen62541-iotg is a hard dependencies as per now (sorry). WIP to decouple tsn ref sw from the customized dependencies +**NOTE** +Customized libbpf and libopen62541-iotg is a hard dependencies as per now (sorry). WIP to decouple tsn ref sw from the customized dependencies. +See below on how to install the customized libbpf and libopen62541-iotg. For run-time: * [Custom linux kernel](https://github.com/intel/linux-intel-lts/tree/5.4/preempt-rt) @@ -28,6 +28,33 @@ For run-time: * gnuplot 5.2 * IceWM - Any GUI/window manager can be used, required to display graphs. +## Ubuntu based dependencies +In order to compile under Ubuntu, these packages need to be installed first: +* gcc +* autoconf +* libjson-c-dev +* gawk +* build-essential + +## Dependencies installer script +In order to ease the installation of the customized helper libraries needed, we have included a few installation scripts in a specific branch. +These scripts will check out a specific version of the libraries from upstream git and apply our patches on top of it. + +Branch name : **experimental/dependencies_installer** +The dependencies installer branch : https://github.com/intel/iotg_tsn_ref_sw/tree/experimental/dependencies_installer/ + +Refer to the README.md to understand the differences between the scripts provided: + +https://github.com/intel/iotg_tsn_ref_sw/blob/experimental/dependencies_installer/dependencies/README.md + +Suggestion is to use the overwriting installer script (after having kept the original libbpf and libopen62541 in a safe place). +This will ensure the tsn ref sw will be able to find/use correct libraries. + +NOTE: If you are installing the libbpf and libopen62541-iotg manually, there is a chance the related open62541-iotg.pc file is not there. Hence, you might have to comment out this line in **configure.ac**. + +**AM_CONDITIONAL([WITH_OPCUA], [test "x$no_open62541_iotg_fork" = "x0"] && test "x${HAVE_XDP}" = "xyes")** + + # Hardware dependencies * Refer to compatible platform list. diff --git a/Makefile.am b/Makefile.am index 4dafc6f..a01de47 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,21 @@ -bin_PROGRAMS = tsq txrx-tsn opcua-server +bin_PROGRAMS = tsq txrx-tsn + +if WITH_OPCUA +bin_PROGRAMS += opcua-server +endif + tsq_SOURCES = src/tsq.c -txrx_tsn_SOURCES = src/txrx.c src/txrx-afpkt.c src/txrx-afxdp.c + +txrx_tsn_SOURCES = src/txrx.c src/txrx-afpkt.c + +if WITHXDP +txrx_tsn_SOURCES += src/txrx-afxdp.c +endif + +if ! WITHXDPTBS +EXTRA_CFLAGS_NOXDPTBS = -Wno-unused-but-set-parameter -Wunused-but-set-variable +endif + opcua_server_SOURCES=src/opcua-tsn/multicallback_server.c \ src/opcua-tsn/json_helper.c \ src/opcua-tsn/opcua_common.c \ @@ -14,5 +29,5 @@ opcua_server_LDADD = $(open62451_LIBS) $(libjson_LIBS) $(libbpf_LIBS) $(libelf_L AM_CPPFLAGS = -O2 -g -fstack-protector-strong -fPIE -fPIC -D_FORTIFY_SOURCE=2 \ -Wformat -Wformat-security -Wformat-overflow -Wno-parentheses \ -Wno-missing-field-initializers -Wextra -Wall -fno-common \ - $(open62451_CFLAGS) $(libjson_CFLAGS) $(libbpf_CFLAGS) $(libelf_CFLAGS) + $(open62451_CFLAGS) $(libjson_CFLAGS) $(libbpf_CFLAGS) $(libelf_CFLAGS) $(ENABLEXDP_CPPFLAGS) $(EXTRA_CFLAGS_NOXDPTBS) AM_LDFLAGS = -Wl,-z,noexecstack,-z,relro,-z,now -pie diff --git a/README.md b/README.md index 55948ea..bcdc1cb 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,8 @@ For further configuration details, check out [README_config.md](README_config.md * [Platform specificity](README_project.md#platform-specificity) * [Optimization](README_project.md#optimization) * [Role of run.sh](README_project.md#role-of-runsh) +* [Installation](README_install.md) +* [Tsn Ref Sw Dependencies](DEPENDENCIES.md) * [File Structure & Conventions](README_project.md#file-structure-conventions) * [Configuration](README_config.md) * [Shell-based runner](README_shell.md) diff --git a/README_install.md b/README_install.md new file mode 100644 index 0000000..381de91 --- /dev/null +++ b/README_install.md @@ -0,0 +1,82 @@ +# Installation HOWTO + +## Tsn ref sw build and installation + +To build tsn ref sw, we are currently providing a single script that will build all +binaries (tsq, txrx-tsn and opcua-server). + + ```sh + cd + ./build.sh <-h|-v|-V|-x|-t> + ``` + + **Build option** + + ```/usr/share/iotg_tsn_ref_sw# ./build.sh -h + + BUILD.SH: Checking Default Shell + Default Shell: sh (Valid) + Usage: ./build.sh [-hxtVv] + + -h, -help, --help Display help + + -t, -disablexdptbs, --disablexdptbs Disable Intel specific XDP+TBS support. (By default XDP+TBS support is enabled) + + -V, -verbose, --verbose Run script in verbose mode. + + -v, -version, --version Show version. + ``` + +Default build (NO build options passed) is enabling XDP feature and Intel-specific XDP+TBS feature (if supported (if_xdp.h check)). + +### To explicitly disable Intel specific XDP+TBS support in tsn ref sw + + ```sh + cd + ./build.sh -t + ``` + +### Check version + + ```sh + cd + ./build.sh -v + ``` + +NOTE + +1. If if_xdp.h is not there, the XDP (and XDP_TBS as well) is considered as unsupported. + In this case, opcua-server will not be compiled. +2. Table of current supported application according to if_xdp.h availability on the system. + if_xdp.h indicates that the XDP socket is available to the applications side. + Without if_xdp.h, only AF_PACKET-socket-based (tsq & txrx-tsn) test will be offered. + + | tsq | txrx-tsn | opcua-server | + ----------------------------------------------------------------------------------- + WITHOUT XDP | Y | Y | N | + - if_xdp.h not detected | | | | + ----------------------------------------------------------------------------------- + +2. Table of current supported application according to xdp_tbs availability on the system. + + + | tsq | txrx-tsn | opcua-server | + ----------------------------------------------------------------------------------- + WITH XDP_TBS | Y | Y | Y | + - if_xdp.h detected (WITH_XDP) | | | | + - XDP_TBS mode not disabled | | | | + - txtime var is detected in if_xdp.h | | | | + ----------------------------------------------------------------------------------- + WITHOUT XDP_TBS | Y | Y | N(WIP) | + - if_xdp.h detected (WITH_XDP) | | | | + - XDP_TBS mode disabled (-t) or | | | | + - txtime var is NOT detected in if_xdp.h | | | | + ----------------------------------------------------------------------------------- + +Default build (NO -t) is enabling XDP feature and Intel-specific XDP+TBS feature (if XDP+TBS is supported in the system!) + +Note: Effort is ongoing to decouple libopen62541-iotg fork and opcua-server from XDP_TBS Intel implementation. + +## Tsn sw ref dependencies installation + +Refer to [Tsn Ref Sw Dependencies](DEPENDENCIES.md) diff --git a/build.sh b/build.sh index 96c38b4..d8724f5 100755 --- a/build.sh +++ b/build.sh @@ -30,6 +30,25 @@ # POSSIBILITY OF SUCH DAMAGE. # *****************************************************************************/ +showTsnRefHelp() { +cat << EOF +Usage: ./build.sh [-hxtVv] + +-h, -help, --help Display help + +-t, -disablexdptbs, --disablexdptbs Disable Intel specific XDP+TBS support. (By default XDP+TBS support is enabled) + +-V, -verbose, --verbose Run script in verbose mode. + +-v, -version, --version Show version. + +EOF +} + +showTsnRefVersion() { + sed -n '/^TSNREFSW_PACKAGE_VERSION/p' ./run.sh +} + # Check for default shell echo -e "\nBUILD.SH: Checking Default Shell" default_shell=$(echo $(realpath /usr/bin/sh) | cut -c 10-) @@ -41,6 +60,45 @@ else exit 1 fi +# By default we enable xdp and xdp+tsb(when supported) intel specific implementation. +export version=0 +export verbose=0 +export ENABLE_XDP="--enable-xdp" +export ENABLE_XDPTBS="--enable-xdptbs" + +options=$(getopt -l "help,disablexdptbs,verbose,version" -o "htVv" -a -- "$@") +eval set -- "$options" + +while true +do +case $1 in +-h|--help) + showTsnRefHelp + exit 0 + ;; +-v|--version) + showTsnRefVersion + exit 0 + ;; +-t|--disablexdptbs) + export ENABLE_XDPTBS="" + ;; +-V|--verbose) + export verbose=1 + set -xv # Set xtrace and verbose mode + ;; +--) + shift + break;; +esac +shift +done + +echo "./build.sh settings:" +echo "1. verbose = $verbose" +echo "2. enablexdp = $ENABLE_XDP" +echo "3. enablexdptbs = $ENABLE_XDPTBS" + touch Makefile.am configure.ac # Ideally, just use git reset HEAD --hard @@ -67,7 +125,8 @@ rm -rf Makefile \ echo -e "\nBUILD.SH: Configure" autoreconf --install -./configure --prefix /usr --with-open62541-headers=/usr/include/open62541 +./configure --prefix /usr $ENABLE_XDP $ENABLE_XDPTBS + if [ $? -ne 0 ]; then echo "Configure failed"; exit 1; fi echo -e "\nBUILD.SH: Compile" diff --git a/configure.ac b/configure.ac index a7ac9ef..700846f 100644 --- a/configure.ac +++ b/configure.ac @@ -2,14 +2,107 @@ AC_INIT([iotg-tsn-ref-sw], [1.0]) AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects]) AC_PROG_CC -PKG_CHECK_MODULES([libelf], [libelf]) -PKG_CHECK_MODULES([libbpf], [libbpf]) -PKG_CHECK_MODULES([libjson], [json-c]) - -# Point to the installed iotg fork of open62541 library. -# Refer to link below for the patches & commit used to creat this fork: -# https://github.com/intel/iotg-yocto-ese-main/tree/master/recipes-connectivity/open62541 -PKG_CHECK_MODULES([open62451], [open62541-iotg]) +# Check for XDP header file +AC_CHECK_HEADERS([linux/if_xdp.h], [HAVE_XDP=yes], [HAVE_XDP=no]) + +HAVE_XDPTBS=no +if test "x${HAVE_XDP}" = "xno"; then + AC_MSG_WARN([if_xdp.h is not found in the system. AF_XDP is considered as un-supported.]) + AC_MSG_NOTICE([Opcua-server will not be compiled because AF_XDP is mandatory for it. Only txrx-tsn and tsq will be compiled.]) +else + # Check if XDP+TBS Intel specific kernel implementation is available (the extra txtime var in xdp_desc) + AC_CHECK_MEMBER([struct xdp_desc.txtime],[HAVE_XDPTBS=yes], + [AC_MSG_WARN([txtime is not found in if_xdp.h:xdp_desc. Intel XDP+TBS is not supported!])], + [[#include "linux/if_xdp.h"]]) +fi + +# We can only enable xdp if we support XDP in the system (if_xdp.h exists) +AC_ARG_ENABLE([xdp], + AS_HELP_STRING([--enable-xdp], [enable xdp[default=yes]])) +AC_MSG_CHECKING([whether we choose to enable socket xdp]) +AS_IF([test "x${enable_xdp}" = "xyes"], AC_MSG_RESULT([yes]), AC_MSG_RESULT([no])) + +AS_IF([test "x${enable_xdp}" = "xyes"], + [AS_IF([test "x${HAVE_XDP}" = "xyes"], [use_xdp=yes], [use_xdp=no])], + [use_xdp=no]) + +AC_MSG_CHECKING([whether the system supports xdp socket and we are enabling xdp socket usage]) +AS_IF([test "x${use_xdp}" = "xyes"], AC_MSG_RESULT([yes]), AC_MSG_RESULT([no])) +AM_CONDITIONAL([WITHXDP], [test "x${use_xdp}" = "xyes"]) + +# We can only enable xdp_tbs if we support XDP_tbs in the system (if_xdp.h txtime var exists) +AC_ARG_ENABLE(xdptbs,[AS_HELP_STRING([--enable-xdptbs], [enable xdptbs])]) +AC_MSG_CHECKING([whether we choose to enable xdp+tbs feature]) +AS_IF([test "x${enable_xdptbs}" = "xyes" ], AC_MSG_RESULT([yes]), AC_MSG_RESULT([no])) + +AS_IF([test "x${enable_xdptbs}" = "xyes"], + [AS_IF([test "x${use_xdp}" = "xyes"], + [AS_IF([test "x${HAVE_XDPTBS}" = "xyes"],[use_xdptbs=yes],[use_xdptbs=no])], + [use_xdptbs=no])], + [use_xdptbs=no]) + +AC_MSG_CHECKING([whether the system supports xdp+tbs and we are enabling xdp+tbs feature]) +AS_IF([test "x${use_xdptbs}" = "xyes" ], AC_MSG_RESULT([yes]), AC_MSG_RESULT([no])) +AM_CONDITIONAL([WITHXDPTBS], [test "x${use_xdptbs}" = "xyes"]) + +if test "x${use_xdp}" = "xyes"; then + if test "x${use_xdptbs}" = "xyes"; then + ENABLEXDP_CPPFLAGS="-DWITH_XDP -DWITH_XDPTBS" + else + ENABLEXDP_CPPFLAGS="-DWITH_XDP" + fi +else + ENABLEXDP_CPPFLAGS="" +fi + +AC_SUBST(ENABLEXDP_CPPFLAGS) + +#TODO check using AC_SEARCH_LIBS instead of PKG_CHECK_MODULES in the next iteration. +PKG_CHECK_MODULES([libelf], [libelf],,[AC_MSG_WARN([libelf.pc is not found in the system. Pls ensure the lib is installed anyway!!])]) +PKG_CHECK_MODULES([libbpf], [libbpf],,[AC_MSG_WARN([libbpf.pc is not found in the system. Pls ensure the lib is installed anyway!!])]) +PKG_CHECK_MODULES([libjson], [json-c],,[AC_MSG_WARN([json-c.pc is not found in the system. Pls ensure the lib is installed anyway!!])]) + +no_open62541_iotg_fork=0 + +PKG_CHECK_MODULES([open62451], + [open62541-iotg], + [AC_DEFINE([HAVE_OPEN62541_IOTG], [1], [Using open62541 using iotg fork])], + [no_open62541_iotg_fork=1]) + +if test "x${no_open62541_iotg_fork}" = "x1"; then + AC_MSG_WARN([open62541-iotg.pc is not found in the system, libopen62541-iotg is considered as uninstalled. Opcua-based test(opcua-server) will NOT be compiled]) + AC_MSG_NOTICE([For libopen62541-iotg manual installation, refer to DEPENDENCIES.md]) +fi + +AM_CONDITIONAL([NO_OPEN62541_IOTG_LIB], [test "x$no_open62541_iotg_fork" = "x1"]) +# Support for af_xdp (if_xdp.h must be in) is mandatory for opcua-server +AM_CONDITIONAL([WITH_OPCUA], [test "x${no_open62541_iotg_fork}" = "x0" && test "x${HAVE_XDP}" = "xyes"]) + +if test "x${no_open62541_iotg_fork}" = "x0"; then + if test "x${HAVE_XDP}" = "xno"; then + AC_MSG_WARN([Without XDP support, opcua-server app will NOT be compiled (for now)]) + fi +fi + +# FUTURE implementation : +# (when our opcua-server code can finally use the vanilla upstream version) +# Check if libopen62541-iotg fork is available thru related pc file. Otherwise will use default libopen62541. +# If no opcua lib is found, opcua-server code will not be compiled. +#no_opcua_lib=0 +# +#PKG_CHECK_MODULES([open62451], +# [open62541-iotg], +# [AC_DEFINE([HAVE_OPEN62541_IOTG], [1], [Using open62541 using iotg fork])], +# [PKG_CHECK_MODULES([open62541], +# [open62541], +# [AC_DEFINE([HAVE_OPEN62541_VANILLA], [1], [Using open62541 using upstreamed version])], +# [no_opcua_lib=1])]) +# +#if test "x${no_opcua_lib}" = "x1"; then +# AC_MSG_WARN([Both libopen62541 and libopen62541 iot forked are not available in the system. opcua-based test will NOT be compiled.]) +#fi +# +#AM_CONDITIONAL([NO_OPCUA_LIB], [test "x$no_opcua" = "x1"]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([Makefile]) diff --git a/src/txrx-afxdp.c b/src/txrx-afxdp.c index 4dc1460..aff5942 100644 --- a/src/txrx-afxdp.c +++ b/src/txrx-afxdp.c @@ -337,7 +337,9 @@ static void afxdp_send_pkt(struct xsk_info *xsk, struct user_opt *opt, //We need to update addr every time, for cases where the umem/tx_ring is shared. xsk_ring_prod__tx_desc(&xsk->tx_ring, idx)->addr = cur_tx << XSK_UMEM__DEFAULT_FRAME_SHIFT; xsk_ring_prod__tx_desc(&xsk->tx_ring, idx)->len = packet_size; +#ifdef WITH_XDPTBS xsk_ring_prod__tx_desc(&xsk->tx_ring, idx)->txtime = tx_timestamp; +#endif /* Update counters */ xsk_ring_prod__submit(&xsk->tx_ring, pkt_per_send); @@ -619,7 +621,11 @@ void afxdp_fwd_pkt(struct xsk_info *xsk, struct pollfd *fds, struct user_opt *op xsk_ring_prod__tx_desc(&xsk->tx_ring, idx_tx)->addr = orig; xsk_ring_prod__tx_desc(&xsk->tx_ring, idx_tx)->len = len; + +#ifdef WITH_XDPTBS xsk_ring_prod__tx_desc(&xsk->tx_ring, idx_tx)->txtime = tx_timestamp; +#endif + idx_tx++; } diff --git a/src/txrx.c b/src/txrx.c index 8cf7a2e..6e1454a 100644 --- a/src/txrx.c +++ b/src/txrx.c @@ -41,8 +41,12 @@ #include #include -#include "txrx-afxdp.h" +#include +#include #include "txrx-afpkt.h" +#ifdef WITH_XDP +#include "txrx-afxdp.h" +#endif #define VLAN_ID 3 #define DEFAULT_NUM_FRAMES 1000 @@ -181,7 +185,9 @@ static error_t parser(int key, char *arg, struct argp_state *state) res = strtol((const char *)arg, &str_end, 10); if (errno || res < 0 || res >= 7 || str_end != &arg[len]) exit_with_error("Invalid queue number/socket priority. Check --help"); +#ifdef WITH_XDP opt->x_opt.queue = opt->socket_prio = (uint32_t)res; +#endif opt->vlan_prio = opt->socket_prio * 32; break; case 'X': @@ -326,7 +332,6 @@ void ts_log_stop() int main(int argc, char *argv[]) { - struct pollfd fds[1]; struct user_opt opt; int ret = 0; @@ -342,11 +347,13 @@ int main(int argc, char *argv[]) opt.packet_size = DEFAULT_PACKET_SIZE; opt.interval_ns = DEFAULT_TX_PERIOD; +#ifdef WITH_XDP opt.x_opt.frames_per_ring = DEFAULT_XDP_FRAMES_PER_RING; opt.x_opt.frame_size = DEFAULT_XDP_FRAMES_SIZE; + opt.xdp_mode = XDP_MODE_ZERO_COPY; +#endif opt.early_offset_ns = DEFAULT_EARLY_OFFSET; opt.offset_ns = DEFAULT_TXTIME_OFFSET; - opt.xdp_mode = XDP_MODE_ZERO_COPY; opt.clkid = CLOCK_REALTIME; opt.enable_poll = 0; opt.enable_hwts = 0; @@ -368,9 +375,11 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } +#ifdef WITH_XDP char buff[opt.packet_size]; pthread_t thread1; - + struct pollfd fds[1]; +#endif switch (opt.socket_mode) { case MODE_AFPKT: signal(SIGINT, afpkt_sigint_handler); @@ -428,7 +437,9 @@ int main(int argc, char *argv[]) close(sockfd); break; case MODE_AFXDP: - + #ifndef WITH_XDP + exit_with_error("AF_XDP functionality is disabled/not supported. Mode_AFXDP is not usable. Exiting."); + #else init_xdp_socket(&opt); /* Same for all modes */ if (!opt.xsk) @@ -494,6 +505,7 @@ int main(int argc, char *argv[]) /* Close XDP Application */ xdpsock_cleanup(); + #endif /* WITH_XDP */ break; default: exit_with_error("Invalid socket type: Please specify -X or -P."); diff --git a/src/txrx.h b/src/txrx.h index 4332e78..36fd605 100644 --- a/src/txrx.h +++ b/src/txrx.h @@ -34,9 +34,12 @@ #define TXRX_HEADER #include +#ifdef WITH_XDP #include +#endif #include #include +#include #define NSEC_PER_SEC 1000000000L #define ETH_VLAN_HDR_SZ (18) @@ -70,6 +73,7 @@ struct custom_payload { uint64_t rx_timestampD; }; +#ifdef WITH_XDP /* Where we keep and track umem descriptor counters */ struct pkt_buffer { struct xsk_ring_prod rx_fill_ring; @@ -106,6 +110,7 @@ struct xsk_info { uint64_t prev_tx_npkts; uint32_t outstanding_tx; }; +#endif /* WITH_XDP */ struct user_opt { uint8_t mode; //App mode: TX/RX/FWD @@ -126,15 +131,17 @@ struct user_opt { uint32_t early_offset_ns; //TXTIME early offset before transmission /* XDP-specific */ + #ifdef WITH_XDP struct xsk_info *xsk; //XDP-socket and ring information + #endif + /* x_opt can be defined regardless of if_xdp.h is available or not */ struct xsk_opt x_opt; //XDP-specific mandatory user params /* XDP-specific options*/ - uint8_t xdp_mode; //XDP mode: skb/nc/zc - uint8_t enable_poll; //XDP poll mode when sending/receiving - //TODO: need wake up & unaligned chunk - /* Currently for txrx-afxdp only. */ + uint8_t xdp_mode; //XDP mode: skb/nc/zc + uint8_t enable_poll; //XDP poll mode when sending/receiving + //TODO: need wake up & unaligned chunk uint8_t enable_txtime; bool need_wakeup; uint32_t poll_timeout;