diff --git a/3rdparty/dpdk-confs/common_linuxapp-17.11 b/3rdparty/dpdk-confs/common_linuxapp-17.11 new file mode 100644 index 0000000000..3c35bbdf64 --- /dev/null +++ b/3rdparty/dpdk-confs/common_linuxapp-17.11 @@ -0,0 +1,550 @@ +# BSD LICENSE +# +# Copyright(c) 2010-2015 Intel Corporation. All rights reserved. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +#include "common_base" + +# +# define executive environment +# +# CONFIG_RTE_EXEC_ENV can be linuxapp, bsdapp +# +CONFIG_RTE_EXEC_ENV="linuxapp" +CONFIG_RTE_EXEC_ENV_LINUXAPP=y + +## +## machine can define specific variables or action for a specific board +## RTE_MACHINE can be: +## default nothing specific +## native current machine +## atm Intel® Atom™ microarchitecture +## nhm Intel® microarchitecture code name Nehalem +## wsm Intel® microarchitecture code name Westmere +## snb Intel® microarchitecture code name Sandy Bridge +## ivb Intel® microarchitecture code name Ivy Bridge +## +## Note: if your compiler does not support the relevant -march options, +## it will be compiled with whatever latest processor the compiler supports! +## +CONFIG_RTE_MACHINE="native" +# +## +## define the architecture we compile for. +## CONFIG_RTE_ARCH can be i686, x86_64, x86_64_32 +## +#CONFIG_RTE_ARCH="x86_64" +#CONFIG_RTE_ARCH_X86_64=y +# +## +## The compiler we use. +## Can be gcc, icc or clang. +## +#CONFIG_RTE_TOOLCHAIN="gcc" +#CONFIG_RTE_TOOLCHAIN_GCC=y + +# +# Use intrinsics or assembly code for key routines +# +CONFIG_RTE_FORCE_INTRINSICS=n + +# +# Machine forces strict alignment constraints. +# +CONFIG_RTE_ARCH_STRICT_ALIGN=n + +# +# Compile to share library +# +CONFIG_RTE_BUILD_SHARED_LIB=n + +# +# Combine to one single library +# +CONFIG_RTE_BUILD_COMBINE_LIBS=y + +# +# Use newest code breaking previous ABI +# +CONFIG_RTE_NEXT_ABI=y + +# +# Compile Environment Abstraction Layer +# +CONFIG_RTE_LIBRTE_EAL=y +CONFIG_RTE_MAX_LCORE=128 +CONFIG_RTE_MAX_NUMA_NODES=8 +CONFIG_RTE_MAX_MEMSEG=256 +CONFIG_RTE_MAX_MEMZONE=2560 +CONFIG_RTE_MAX_TAILQ=32 +CONFIG_RTE_LOG_LEVEL=8 +CONFIG_RTE_LOG_HISTORY=256 +CONFIG_RTE_LIBEAL_USE_HPET=n +CONFIG_RTE_EAL_ALLOW_INV_SOCKET_ID=n +CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n +CONFIG_RTE_EAL_IGB_UIO=y +CONFIG_RTE_EAL_VFIO=y +CONFIG_RTE_MALLOC_DEBUG=n + +# Default driver path (or "" to disable) +CONFIG_RTE_EAL_PMD_PATH="" + +# +# Special configurations in PCI Config Space for high performance +# +CONFIG_RTE_PCI_CONFIG=y +CONFIG_RTE_PCI_EXTENDED_TAG="on" +CONFIG_RTE_PCI_MAX_READ_REQUEST_SIZE=128 + +# +# Compile Environment Abstraction Layer for linux +# +CONFIG_RTE_LIBRTE_EAL_LINUXAPP=y + +# +# Compile Environment Abstraction Layer to support Vmware TSC map +# +CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT=y + +# +# Compile the argument parser library +# +CONFIG_RTE_LIBRTE_KVARGS=y + +# +# Compile generic ethernet library +# +CONFIG_RTE_LIBRTE_ETHER=y +CONFIG_RTE_LIBRTE_ETHDEV_DEBUG=n +CONFIG_RTE_MAX_ETHPORTS=32 +CONFIG_RTE_MAX_QUEUES_PER_PORT=1024 +CONFIG_RTE_LIBRTE_IEEE1588=n +CONFIG_RTE_ETHDEV_QUEUE_STAT_CNTRS=16 +CONFIG_RTE_ETHDEV_RXTX_CALLBACKS=y + +# +# Support NIC bypass logic +# +CONFIG_RTE_NIC_BYPASS=n + +# +# Compile burst-oriented IGB & EM PMD drivers +# +CONFIG_RTE_LIBRTE_EM_PMD=y +CONFIG_RTE_LIBRTE_IGB_PMD=y +CONFIG_RTE_LIBRTE_E1000_DEBUG_INIT=n +CONFIG_RTE_LIBRTE_E1000_DEBUG_RX=n +CONFIG_RTE_LIBRTE_E1000_DEBUG_TX=n +CONFIG_RTE_LIBRTE_E1000_DEBUG_TX_FREE=n +CONFIG_RTE_LIBRTE_E1000_DEBUG_DRIVER=n +CONFIG_RTE_LIBRTE_E1000_PF_DISABLE_STRIP_CRC=n + +# +# Compile burst-oriented IXGBE PMD driver +# +CONFIG_RTE_LIBRTE_IXGBE_PMD=y +CONFIG_RTE_LIBRTE_IXGBE_DEBUG_INIT=n +CONFIG_RTE_LIBRTE_IXGBE_DEBUG_RX=n +CONFIG_RTE_LIBRTE_IXGBE_DEBUG_TX=n +CONFIG_RTE_LIBRTE_IXGBE_DEBUG_TX_FREE=n +CONFIG_RTE_LIBRTE_IXGBE_DEBUG_DRIVER=n +CONFIG_RTE_LIBRTE_IXGBE_PF_DISABLE_STRIP_CRC=n +CONFIG_RTE_IXGBE_INC_VECTOR=y +CONFIG_RTE_IXGBE_RX_OLFLAGS_ENABLE=y + +# +# Compile burst-oriented I40E PMD driver +# +CONFIG_RTE_LIBRTE_I40E_PMD=y +CONFIG_RTE_LIBRTE_I40E_DEBUG_INIT=n +CONFIG_RTE_LIBRTE_I40E_DEBUG_RX=n +CONFIG_RTE_LIBRTE_I40E_DEBUG_TX=n +CONFIG_RTE_LIBRTE_I40E_DEBUG_TX_FREE=n +CONFIG_RTE_LIBRTE_I40E_DEBUG_DRIVER=n +CONFIG_RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC=y +CONFIG_RTE_LIBRTE_I40E_INC_VECTOR=y +CONFIG_RTE_LIBRTE_I40E_RX_OLFLAGS_ENABLE=y +CONFIG_RTE_LIBRTE_I40E_16BYTE_RX_DESC=y +CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_PF=64 +CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VF=4 +CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VM=4 +# interval up to 8160 us, aligned to 2 (or default value) +CONFIG_RTE_LIBRTE_I40E_ITR_INTERVAL=-1 + +# +# Compile burst-oriented FM10K PMD +# +CONFIG_RTE_LIBRTE_FM10K_PMD=y +CONFIG_RTE_LIBRTE_FM10K_DEBUG_INIT=n +CONFIG_RTE_LIBRTE_FM10K_DEBUG_RX=n +CONFIG_RTE_LIBRTE_FM10K_DEBUG_TX=n +CONFIG_RTE_LIBRTE_FM10K_DEBUG_TX_FREE=n +CONFIG_RTE_LIBRTE_FM10K_DEBUG_DRIVER=n +CONFIG_RTE_LIBRTE_FM10K_RX_OLFLAGS_ENABLE=y +CONFIG_RTE_LIBRTE_FM10K_INC_VECTOR=y + +# +# Compile burst-oriented Mellanox ConnectX-3 (MLX4) PMD +# +CONFIG_RTE_LIBRTE_MLX4_PMD=n +CONFIG_RTE_LIBRTE_MLX4_DEBUG=n +CONFIG_RTE_LIBRTE_MLX4_SGE_WR_N=4 +CONFIG_RTE_LIBRTE_MLX4_MAX_INLINE=0 +CONFIG_RTE_LIBRTE_MLX4_TX_MP_CACHE=8 +CONFIG_RTE_LIBRTE_MLX4_SOFT_COUNTERS=1 + +# +# Compile burst-oriented Mellanox ConnectX-4 (MLX5) PMD +# +CONFIG_RTE_LIBRTE_MLX5_PMD=n +CONFIG_RTE_LIBRTE_MLX5_DEBUG=n +CONFIG_RTE_LIBRTE_MLX5_SGE_WR_N=4 +CONFIG_RTE_LIBRTE_MLX5_MAX_INLINE=0 +CONFIG_RTE_LIBRTE_MLX5_TX_MP_CACHE=8 + +# +# Compile burst-oriented Broadcom PMD driver +# +CONFIG_RTE_LIBRTE_BNX2X_PMD=n +CONFIG_RTE_LIBRTE_BNX2X_DEBUG=n +CONFIG_RTE_LIBRTE_BNX2X_DEBUG_INIT=n +CONFIG_RTE_LIBRTE_BNX2X_DEBUG_RX=n +CONFIG_RTE_LIBRTE_BNX2X_DEBUG_TX=n +CONFIG_RTE_LIBRTE_BNX2X_MF_SUPPORT=n +CONFIG_RTE_LIBRTE_BNX2X_DEBUG_PERIODIC=n + +# +# Compile burst-oriented Chelsio Terminator 10GbE/40GbE (CXGBE) PMD +# +CONFIG_RTE_LIBRTE_CXGBE_PMD=y +CONFIG_RTE_LIBRTE_CXGBE_DEBUG=n +CONFIG_RTE_LIBRTE_CXGBE_DEBUG_REG=n +CONFIG_RTE_LIBRTE_CXGBE_DEBUG_MBOX=n +CONFIG_RTE_LIBRTE_CXGBE_DEBUG_TX=n +CONFIG_RTE_LIBRTE_CXGBE_DEBUG_RX=n + +# +# Compile burst-oriented Cisco ENIC PMD driver +# +CONFIG_RTE_LIBRTE_ENIC_PMD=y +CONFIG_RTE_LIBRTE_ENIC_DEBUG=n + +# +# Compile burst-oriented Netronome NFP PMD driver +# +CONFIG_RTE_LIBRTE_NFP_PMD=n +CONFIG_RTE_LIBRTE_NFP_DEBUG=n + +# +# Compile software PMD backed by SZEDATA2 device +# +CONFIG_RTE_LIBRTE_PMD_SZEDATA2=n + +# +# Compile burst-oriented VIRTIO PMD driver +# +CONFIG_RTE_LIBRTE_VIRTIO_PMD=y +CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_INIT=n +CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_RX=n +CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_TX=n +CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_DRIVER=n +CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_DUMP=n + +# +# Compile burst-oriented VMXNET3 PMD driver +# +CONFIG_RTE_LIBRTE_VMXNET3_PMD=y +CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_INIT=n +CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_RX=n +CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_TX=n +CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_TX_FREE=n +CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_DRIVER=n + +# +# Compile example software rings based PMD +# +CONFIG_RTE_LIBRTE_PMD_RING=y +CONFIG_RTE_PMD_RING_MAX_RX_RINGS=16 +CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16 + +# +# Compile software PMD backed by PCAP files +# +CONFIG_RTE_LIBRTE_PMD_PCAP=y + +# +# Compile link bonding PMD library +# +CONFIG_RTE_LIBRTE_PMD_BOND=y +CONFIG_RTE_LIBRTE_BOND_DEBUG_ALB=n +CONFIG_RTE_LIBRTE_BOND_DEBUG_ALB_L1=n + +# +# Compile software PMD backed by AF_PACKET sockets (Linux only) +# +CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y + +# +# Compile Xen PMD +# +CONFIG_RTE_LIBRTE_PMD_XENVIRT=n + +# +# Compile null PMD +# +CONFIG_RTE_LIBRTE_PMD_NULL=y + +# +# Do prefetch of packet data within PMD driver receive function +# +CONFIG_RTE_PMD_PACKET_PREFETCH=y + +# +# Compile generic crypto device library +# EXPERIMENTAL: API may change without prior notice +# +CONFIG_RTE_LIBRTE_CRYPTODEV=y +CONFIG_RTE_LIBRTE_CRYPTODEV_DEBUG=n +CONFIG_RTE_CRYPTO_MAX_DEVS=64 +CONFIG_RTE_CRYPTODEV_NAME_LEN=64 + +# +# Compile PMD for QuickAssist based devices +# +CONFIG_RTE_LIBRTE_PMD_QAT=n +CONFIG_RTE_LIBRTE_PMD_QAT_DEBUG_INIT=n +CONFIG_RTE_LIBRTE_PMD_QAT_DEBUG_TX=n +CONFIG_RTE_LIBRTE_PMD_QAT_DEBUG_RX=n +CONFIG_RTE_LIBRTE_PMD_QAT_DEBUG_DRIVER=n +# +# Number of sessions to create in the session memory pool +# on a single QuickAssist device. +# +CONFIG_RTE_QAT_PMD_MAX_NB_SESSIONS=2048 + +# +# Compile PMD for AESNI backed device +# +CONFIG_RTE_LIBRTE_PMD_AESNI_MB=n +CONFIG_RTE_LIBRTE_PMD_AESNI_MB_DEBUG=n +CONFIG_RTE_AESNI_MB_PMD_MAX_NB_QUEUE_PAIRS=8 +CONFIG_RTE_AESNI_MB_PMD_MAX_NB_SESSIONS=2048 + +# +# Compile librte_ring +# +CONFIG_RTE_LIBRTE_RING=y +CONFIG_RTE_LIBRTE_RING_DEBUG=n +CONFIG_RTE_RING_SPLIT_PROD_CONS=n +CONFIG_RTE_RING_PAUSE_REP_COUNT=0 + +# +# Compile librte_mempool +# +CONFIG_RTE_LIBRTE_MEMPOOL=y +CONFIG_RTE_MEMPOOL_CACHE_MAX_SIZE=512 +CONFIG_RTE_LIBRTE_MEMPOOL_DEBUG=n + +# +# Compile librte_mbuf +# +CONFIG_RTE_LIBRTE_MBUF=y +CONFIG_RTE_LIBRTE_MBUF_DEBUG=n +CONFIG_RTE_MBUF_REFCNT_ATOMIC=y +CONFIG_RTE_PKTMBUF_HEADROOM=128 + +# +# Compile librte_mbuf_offload +# EXPERIMENTAL: API may change without prior notice +# +CONFIG_RTE_LIBRTE_MBUF_OFFLOAD=y +CONFIG_RTE_LIBRTE_MBUF_OFFLOAD_DEBUG=n + +# +# Compile librte_timer +# +CONFIG_RTE_LIBRTE_TIMER=y +CONFIG_RTE_LIBRTE_TIMER_DEBUG=n + +# +# Compile librte_cfgfile +# +CONFIG_RTE_LIBRTE_CFGFILE=y + +# +# Compile librte_cmdline +# +CONFIG_RTE_LIBRTE_CMDLINE=y +CONFIG_RTE_LIBRTE_CMDLINE_DEBUG=n + +# +# Compile librte_hash +# +CONFIG_RTE_LIBRTE_HASH=y +CONFIG_RTE_LIBRTE_HASH_DEBUG=n + +# +# Compile librte_jobstats +# +CONFIG_RTE_LIBRTE_JOBSTATS=y + +# +# Compile librte_lpm +# +CONFIG_RTE_LIBRTE_LPM=y +CONFIG_RTE_LIBRTE_LPM_DEBUG=n + +# +# Compile librte_acl +# +CONFIG_RTE_LIBRTE_ACL=y +CONFIG_RTE_LIBRTE_ACL_DEBUG=n + +# +# Compile librte_power +# +CONFIG_RTE_LIBRTE_POWER=y +CONFIG_RTE_LIBRTE_POWER_DEBUG=n +CONFIG_RTE_MAX_LCORE_FREQS=64 + +# +# Compile librte_net +# +CONFIG_RTE_LIBRTE_NET=y + +# +# Compile librte_ip_frag +# +CONFIG_RTE_LIBRTE_IP_FRAG=y +CONFIG_RTE_LIBRTE_IP_FRAG_DEBUG=n +CONFIG_RTE_LIBRTE_IP_FRAG_MAX_FRAG=4 +CONFIG_RTE_LIBRTE_IP_FRAG_TBL_STAT=n + +# +# Compile librte_meter +# +CONFIG_RTE_LIBRTE_METER=y + +# +# Compile librte_sched +# +CONFIG_RTE_LIBRTE_SCHED=y +CONFIG_RTE_SCHED_DEBUG=n +CONFIG_RTE_SCHED_RED=n +CONFIG_RTE_SCHED_COLLECT_STATS=n +CONFIG_RTE_SCHED_SUBPORT_TC_OV=n +CONFIG_RTE_SCHED_PORT_N_GRINDERS=8 +CONFIG_RTE_SCHED_VECTOR=n + +# +# Compile the distributor library +# +CONFIG_RTE_LIBRTE_DISTRIBUTOR=y + +# +# Compile the reorder library +# +CONFIG_RTE_LIBRTE_REORDER=y + +# +# Compile librte_port +# +CONFIG_RTE_LIBRTE_PORT=y +CONFIG_RTE_PORT_STATS_COLLECT=n + +# +# Compile librte_table +# +CONFIG_RTE_LIBRTE_TABLE=y +CONFIG_RTE_TABLE_STATS_COLLECT=n + +# +# Compile librte_pipeline +# +CONFIG_RTE_LIBRTE_PIPELINE=y +CONFIG_RTE_PIPELINE_STATS_COLLECT=n + +# +# Compile librte_kni +# +CONFIG_RTE_LIBRTE_KNI=y +CONFIG_RTE_KNI_KMOD=y +CONFIG_RTE_KNI_PREEMPT_DEFAULT=y +CONFIG_RTE_KNI_KO_DEBUG=n +CONFIG_RTE_KNI_VHOST=n +CONFIG_RTE_KNI_VHOST_MAX_CACHE_SIZE=1024 +CONFIG_RTE_KNI_VHOST_VNET_HDR_EN=n +CONFIG_RTE_KNI_VHOST_DEBUG_RX=n +CONFIG_RTE_KNI_VHOST_DEBUG_TX=n + +# +# Compile vhost library +# fuse-devel is needed to run vhost-cuse. +# fuse-devel enables user space char driver development +# vhost-user is turned on by default. +# +CONFIG_RTE_LIBRTE_VHOST=y +CONFIG_RTE_LIBRTE_VHOST_USER=y +CONFIG_RTE_LIBRTE_VHOST_NUMA=n +CONFIG_RTE_LIBRTE_VHOST_DEBUG=n + +# +#Compile Xen domain0 support +# +CONFIG_RTE_LIBRTE_XEN_DOM0=n + +# +# Enable warning directives +# +CONFIG_RTE_INSECURE_FUNCTION_WARNING=n + +# +# Compile the test application +# +CONFIG_RTE_APP_TEST=y + +# +# Compile the PMD test application +# +CONFIG_RTE_TEST_PMD=y +CONFIG_RTE_TEST_PMD_RECORD_CORE_CYCLES=n +CONFIG_RTE_TEST_PMD_RECORD_BURST_STATS=n +CONFIG_RTE_LIBRTE_PMD_VHOST=y + +CONFIG_RTE_EAL_NUMA_AWARE_HUGEPAGES=y +CONFIG_RTE_LIBRTE_KNI=y +CONFIG_RTE_LIBRTE_PMD_KNI=y +CONFIG_RTE_LIBRTE_VHOST=y +CONFIG_RTE_LIBRTE_VHOST_NUMA=y +CONFIG_RTE_LIBRTE_PMD_VHOST=y +CONFIG_RTE_LIBRTE_PMD_TAP=y +CONFIG_RTE_LIBRTE_AVP_PMD=y +CONFIG_RTE_LIBRTE_NFP_PMD=y +CONFIG_RTE_VIRTIO_USER=y diff --git a/3rdparty/dpdk-confs/common_linuxapp-17.11.container b/3rdparty/dpdk-confs/common_linuxapp-17.11.container new file mode 100644 index 0000000000..8638d8baa1 --- /dev/null +++ b/3rdparty/dpdk-confs/common_linuxapp-17.11.container @@ -0,0 +1,550 @@ +# BSD LICENSE +# +# Copyright(c) 2010-2015 Intel Corporation. All rights reserved. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +#include "common_base" + +# +# define executive environment +# +# CONFIG_RTE_EXEC_ENV can be linuxapp, bsdapp +# +CONFIG_RTE_EXEC_ENV="linuxapp" +CONFIG_RTE_EXEC_ENV_LINUXAPP=y + +## +## machine can define specific variables or action for a specific board +## RTE_MACHINE can be: +## default nothing specific +## native current machine +## atm Intel® Atom™ microarchitecture +## nhm Intel® microarchitecture code name Nehalem +## wsm Intel® microarchitecture code name Westmere +## snb Intel® microarchitecture code name Sandy Bridge +## ivb Intel® microarchitecture code name Ivy Bridge +## +## Note: if your compiler does not support the relevant -march options, +## it will be compiled with whatever latest processor the compiler supports! +## +CONFIG_RTE_MACHINE="native" +# +## +## define the architecture we compile for. +## CONFIG_RTE_ARCH can be i686, x86_64, x86_64_32 +## +#CONFIG_RTE_ARCH="x86_64" +#CONFIG_RTE_ARCH_X86_64=y +# +## +## The compiler we use. +## Can be gcc, icc or clang. +## +#CONFIG_RTE_TOOLCHAIN="gcc" +#CONFIG_RTE_TOOLCHAIN_GCC=y + +# +# Use intrinsics or assembly code for key routines +# +CONFIG_RTE_FORCE_INTRINSICS=n + +# +# Machine forces strict alignment constraints. +# +CONFIG_RTE_ARCH_STRICT_ALIGN=n + +# +# Compile to share library +# +CONFIG_RTE_BUILD_SHARED_LIB=n + +# +# Combine to one single library +# +CONFIG_RTE_BUILD_COMBINE_LIBS=y + +# +# Use newest code breaking previous ABI +# +CONFIG_RTE_NEXT_ABI=y + +# +# Compile Environment Abstraction Layer +# +CONFIG_RTE_LIBRTE_EAL=y +CONFIG_RTE_MAX_LCORE=128 +CONFIG_RTE_MAX_NUMA_NODES=8 +CONFIG_RTE_MAX_MEMSEG=256 +CONFIG_RTE_MAX_MEMZONE=2560 +CONFIG_RTE_MAX_TAILQ=32 +CONFIG_RTE_LOG_LEVEL=8 +CONFIG_RTE_LOG_HISTORY=256 +CONFIG_RTE_LIBEAL_USE_HPET=n +CONFIG_RTE_EAL_ALLOW_INV_SOCKET_ID=n +CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n +CONFIG_RTE_EAL_IGB_UIO=n +CONFIG_RTE_EAL_VFIO=y +CONFIG_RTE_MALLOC_DEBUG=n + +# Default driver path (or "" to disable) +CONFIG_RTE_EAL_PMD_PATH="" + +# +# Special configurations in PCI Config Space for high performance +# +CONFIG_RTE_PCI_CONFIG=y +CONFIG_RTE_PCI_EXTENDED_TAG="on" +CONFIG_RTE_PCI_MAX_READ_REQUEST_SIZE=128 + +# +# Compile Environment Abstraction Layer for linux +# +CONFIG_RTE_LIBRTE_EAL_LINUXAPP=y + +# +# Compile Environment Abstraction Layer to support Vmware TSC map +# +CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT=y + +# +# Compile the argument parser library +# +CONFIG_RTE_LIBRTE_KVARGS=y + +# +# Compile generic ethernet library +# +CONFIG_RTE_LIBRTE_ETHER=y +CONFIG_RTE_LIBRTE_ETHDEV_DEBUG=n +CONFIG_RTE_MAX_ETHPORTS=32 +CONFIG_RTE_MAX_QUEUES_PER_PORT=1024 +CONFIG_RTE_LIBRTE_IEEE1588=n +CONFIG_RTE_ETHDEV_QUEUE_STAT_CNTRS=16 +CONFIG_RTE_ETHDEV_RXTX_CALLBACKS=y + +# +# Support NIC bypass logic +# +CONFIG_RTE_NIC_BYPASS=n + +# +# Compile burst-oriented IGB & EM PMD drivers +# +CONFIG_RTE_LIBRTE_EM_PMD=y +CONFIG_RTE_LIBRTE_IGB_PMD=y +CONFIG_RTE_LIBRTE_E1000_DEBUG_INIT=n +CONFIG_RTE_LIBRTE_E1000_DEBUG_RX=n +CONFIG_RTE_LIBRTE_E1000_DEBUG_TX=n +CONFIG_RTE_LIBRTE_E1000_DEBUG_TX_FREE=n +CONFIG_RTE_LIBRTE_E1000_DEBUG_DRIVER=n +CONFIG_RTE_LIBRTE_E1000_PF_DISABLE_STRIP_CRC=n + +# +# Compile burst-oriented IXGBE PMD driver +# +CONFIG_RTE_LIBRTE_IXGBE_PMD=y +CONFIG_RTE_LIBRTE_IXGBE_DEBUG_INIT=n +CONFIG_RTE_LIBRTE_IXGBE_DEBUG_RX=n +CONFIG_RTE_LIBRTE_IXGBE_DEBUG_TX=n +CONFIG_RTE_LIBRTE_IXGBE_DEBUG_TX_FREE=n +CONFIG_RTE_LIBRTE_IXGBE_DEBUG_DRIVER=n +CONFIG_RTE_LIBRTE_IXGBE_PF_DISABLE_STRIP_CRC=n +CONFIG_RTE_IXGBE_INC_VECTOR=y +CONFIG_RTE_IXGBE_RX_OLFLAGS_ENABLE=y + +# +# Compile burst-oriented I40E PMD driver +# +CONFIG_RTE_LIBRTE_I40E_PMD=y +CONFIG_RTE_LIBRTE_I40E_DEBUG_INIT=n +CONFIG_RTE_LIBRTE_I40E_DEBUG_RX=n +CONFIG_RTE_LIBRTE_I40E_DEBUG_TX=n +CONFIG_RTE_LIBRTE_I40E_DEBUG_TX_FREE=n +CONFIG_RTE_LIBRTE_I40E_DEBUG_DRIVER=n +CONFIG_RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC=y +CONFIG_RTE_LIBRTE_I40E_INC_VECTOR=y +CONFIG_RTE_LIBRTE_I40E_RX_OLFLAGS_ENABLE=y +CONFIG_RTE_LIBRTE_I40E_16BYTE_RX_DESC=y +CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_PF=64 +CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VF=4 +CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VM=4 +# interval up to 8160 us, aligned to 2 (or default value) +CONFIG_RTE_LIBRTE_I40E_ITR_INTERVAL=-1 + +# +# Compile burst-oriented FM10K PMD +# +CONFIG_RTE_LIBRTE_FM10K_PMD=y +CONFIG_RTE_LIBRTE_FM10K_DEBUG_INIT=n +CONFIG_RTE_LIBRTE_FM10K_DEBUG_RX=n +CONFIG_RTE_LIBRTE_FM10K_DEBUG_TX=n +CONFIG_RTE_LIBRTE_FM10K_DEBUG_TX_FREE=n +CONFIG_RTE_LIBRTE_FM10K_DEBUG_DRIVER=n +CONFIG_RTE_LIBRTE_FM10K_RX_OLFLAGS_ENABLE=y +CONFIG_RTE_LIBRTE_FM10K_INC_VECTOR=y + +# +# Compile burst-oriented Mellanox ConnectX-3 (MLX4) PMD +# +CONFIG_RTE_LIBRTE_MLX4_PMD=n +CONFIG_RTE_LIBRTE_MLX4_DEBUG=n +CONFIG_RTE_LIBRTE_MLX4_SGE_WR_N=4 +CONFIG_RTE_LIBRTE_MLX4_MAX_INLINE=0 +CONFIG_RTE_LIBRTE_MLX4_TX_MP_CACHE=8 +CONFIG_RTE_LIBRTE_MLX4_SOFT_COUNTERS=1 + +# +# Compile burst-oriented Mellanox ConnectX-4 (MLX5) PMD +# +CONFIG_RTE_LIBRTE_MLX5_PMD=n +CONFIG_RTE_LIBRTE_MLX5_DEBUG=n +CONFIG_RTE_LIBRTE_MLX5_SGE_WR_N=4 +CONFIG_RTE_LIBRTE_MLX5_MAX_INLINE=0 +CONFIG_RTE_LIBRTE_MLX5_TX_MP_CACHE=8 + +# +# Compile burst-oriented Broadcom PMD driver +# +CONFIG_RTE_LIBRTE_BNX2X_PMD=n +CONFIG_RTE_LIBRTE_BNX2X_DEBUG=n +CONFIG_RTE_LIBRTE_BNX2X_DEBUG_INIT=n +CONFIG_RTE_LIBRTE_BNX2X_DEBUG_RX=n +CONFIG_RTE_LIBRTE_BNX2X_DEBUG_TX=n +CONFIG_RTE_LIBRTE_BNX2X_MF_SUPPORT=n +CONFIG_RTE_LIBRTE_BNX2X_DEBUG_PERIODIC=n + +# +# Compile burst-oriented Chelsio Terminator 10GbE/40GbE (CXGBE) PMD +# +CONFIG_RTE_LIBRTE_CXGBE_PMD=y +CONFIG_RTE_LIBRTE_CXGBE_DEBUG=n +CONFIG_RTE_LIBRTE_CXGBE_DEBUG_REG=n +CONFIG_RTE_LIBRTE_CXGBE_DEBUG_MBOX=n +CONFIG_RTE_LIBRTE_CXGBE_DEBUG_TX=n +CONFIG_RTE_LIBRTE_CXGBE_DEBUG_RX=n + +# +# Compile burst-oriented Cisco ENIC PMD driver +# +CONFIG_RTE_LIBRTE_ENIC_PMD=y +CONFIG_RTE_LIBRTE_ENIC_DEBUG=n + +# +# Compile burst-oriented Netronome NFP PMD driver +# +CONFIG_RTE_LIBRTE_NFP_PMD=n +CONFIG_RTE_LIBRTE_NFP_DEBUG=n + +# +# Compile software PMD backed by SZEDATA2 device +# +CONFIG_RTE_LIBRTE_PMD_SZEDATA2=n + +# +# Compile burst-oriented VIRTIO PMD driver +# +CONFIG_RTE_LIBRTE_VIRTIO_PMD=y +CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_INIT=n +CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_RX=n +CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_TX=n +CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_DRIVER=n +CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_DUMP=n + +# +# Compile burst-oriented VMXNET3 PMD driver +# +CONFIG_RTE_LIBRTE_VMXNET3_PMD=y +CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_INIT=n +CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_RX=n +CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_TX=n +CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_TX_FREE=n +CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_DRIVER=n + +# +# Compile example software rings based PMD +# +CONFIG_RTE_LIBRTE_PMD_RING=y +CONFIG_RTE_PMD_RING_MAX_RX_RINGS=16 +CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16 + +# +# Compile software PMD backed by PCAP files +# +CONFIG_RTE_LIBRTE_PMD_PCAP=y + +# +# Compile link bonding PMD library +# +CONFIG_RTE_LIBRTE_PMD_BOND=y +CONFIG_RTE_LIBRTE_BOND_DEBUG_ALB=n +CONFIG_RTE_LIBRTE_BOND_DEBUG_ALB_L1=n + +# +# Compile software PMD backed by AF_PACKET sockets (Linux only) +# +CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y + +# +# Compile Xen PMD +# +CONFIG_RTE_LIBRTE_PMD_XENVIRT=n + +# +# Compile null PMD +# +CONFIG_RTE_LIBRTE_PMD_NULL=y + +# +# Do prefetch of packet data within PMD driver receive function +# +CONFIG_RTE_PMD_PACKET_PREFETCH=y + +# +# Compile generic crypto device library +# EXPERIMENTAL: API may change without prior notice +# +CONFIG_RTE_LIBRTE_CRYPTODEV=y +CONFIG_RTE_LIBRTE_CRYPTODEV_DEBUG=n +CONFIG_RTE_CRYPTO_MAX_DEVS=64 +CONFIG_RTE_CRYPTODEV_NAME_LEN=64 + +# +# Compile PMD for QuickAssist based devices +# +CONFIG_RTE_LIBRTE_PMD_QAT=n +CONFIG_RTE_LIBRTE_PMD_QAT_DEBUG_INIT=n +CONFIG_RTE_LIBRTE_PMD_QAT_DEBUG_TX=n +CONFIG_RTE_LIBRTE_PMD_QAT_DEBUG_RX=n +CONFIG_RTE_LIBRTE_PMD_QAT_DEBUG_DRIVER=n +# +# Number of sessions to create in the session memory pool +# on a single QuickAssist device. +# +CONFIG_RTE_QAT_PMD_MAX_NB_SESSIONS=2048 + +# +# Compile PMD for AESNI backed device +# +CONFIG_RTE_LIBRTE_PMD_AESNI_MB=n +CONFIG_RTE_LIBRTE_PMD_AESNI_MB_DEBUG=n +CONFIG_RTE_AESNI_MB_PMD_MAX_NB_QUEUE_PAIRS=8 +CONFIG_RTE_AESNI_MB_PMD_MAX_NB_SESSIONS=2048 + +# +# Compile librte_ring +# +CONFIG_RTE_LIBRTE_RING=y +CONFIG_RTE_LIBRTE_RING_DEBUG=n +CONFIG_RTE_RING_SPLIT_PROD_CONS=n +CONFIG_RTE_RING_PAUSE_REP_COUNT=0 + +# +# Compile librte_mempool +# +CONFIG_RTE_LIBRTE_MEMPOOL=y +CONFIG_RTE_MEMPOOL_CACHE_MAX_SIZE=512 +CONFIG_RTE_LIBRTE_MEMPOOL_DEBUG=n + +# +# Compile librte_mbuf +# +CONFIG_RTE_LIBRTE_MBUF=y +CONFIG_RTE_LIBRTE_MBUF_DEBUG=n +CONFIG_RTE_MBUF_REFCNT_ATOMIC=y +CONFIG_RTE_PKTMBUF_HEADROOM=128 + +# +# Compile librte_mbuf_offload +# EXPERIMENTAL: API may change without prior notice +# +CONFIG_RTE_LIBRTE_MBUF_OFFLOAD=y +CONFIG_RTE_LIBRTE_MBUF_OFFLOAD_DEBUG=n + +# +# Compile librte_timer +# +CONFIG_RTE_LIBRTE_TIMER=y +CONFIG_RTE_LIBRTE_TIMER_DEBUG=n + +# +# Compile librte_cfgfile +# +CONFIG_RTE_LIBRTE_CFGFILE=y + +# +# Compile librte_cmdline +# +CONFIG_RTE_LIBRTE_CMDLINE=y +CONFIG_RTE_LIBRTE_CMDLINE_DEBUG=n + +# +# Compile librte_hash +# +CONFIG_RTE_LIBRTE_HASH=y +CONFIG_RTE_LIBRTE_HASH_DEBUG=n + +# +# Compile librte_jobstats +# +CONFIG_RTE_LIBRTE_JOBSTATS=y + +# +# Compile librte_lpm +# +CONFIG_RTE_LIBRTE_LPM=y +CONFIG_RTE_LIBRTE_LPM_DEBUG=n + +# +# Compile librte_acl +# +CONFIG_RTE_LIBRTE_ACL=y +CONFIG_RTE_LIBRTE_ACL_DEBUG=n + +# +# Compile librte_power +# +CONFIG_RTE_LIBRTE_POWER=y +CONFIG_RTE_LIBRTE_POWER_DEBUG=n +CONFIG_RTE_MAX_LCORE_FREQS=64 + +# +# Compile librte_net +# +CONFIG_RTE_LIBRTE_NET=y + +# +# Compile librte_ip_frag +# +CONFIG_RTE_LIBRTE_IP_FRAG=y +CONFIG_RTE_LIBRTE_IP_FRAG_DEBUG=n +CONFIG_RTE_LIBRTE_IP_FRAG_MAX_FRAG=4 +CONFIG_RTE_LIBRTE_IP_FRAG_TBL_STAT=n + +# +# Compile librte_meter +# +CONFIG_RTE_LIBRTE_METER=y + +# +# Compile librte_sched +# +CONFIG_RTE_LIBRTE_SCHED=y +CONFIG_RTE_SCHED_DEBUG=n +CONFIG_RTE_SCHED_RED=n +CONFIG_RTE_SCHED_COLLECT_STATS=n +CONFIG_RTE_SCHED_SUBPORT_TC_OV=n +CONFIG_RTE_SCHED_PORT_N_GRINDERS=8 +CONFIG_RTE_SCHED_VECTOR=n + +# +# Compile the distributor library +# +CONFIG_RTE_LIBRTE_DISTRIBUTOR=y + +# +# Compile the reorder library +# +CONFIG_RTE_LIBRTE_REORDER=y + +# +# Compile librte_port +# +CONFIG_RTE_LIBRTE_PORT=y +CONFIG_RTE_PORT_STATS_COLLECT=n + +# +# Compile librte_table +# +CONFIG_RTE_LIBRTE_TABLE=y +CONFIG_RTE_TABLE_STATS_COLLECT=n + +# +# Compile librte_pipeline +# +CONFIG_RTE_LIBRTE_PIPELINE=y +CONFIG_RTE_PIPELINE_STATS_COLLECT=n + +# +# Compile librte_kni +# +CONFIG_RTE_LIBRTE_KNI=y +CONFIG_RTE_KNI_KMOD=n +CONFIG_RTE_KNI_PREEMPT_DEFAULT=y +CONFIG_RTE_KNI_KO_DEBUG=n +CONFIG_RTE_KNI_VHOST=n +CONFIG_RTE_KNI_VHOST_MAX_CACHE_SIZE=1024 +CONFIG_RTE_KNI_VHOST_VNET_HDR_EN=n +CONFIG_RTE_KNI_VHOST_DEBUG_RX=n +CONFIG_RTE_KNI_VHOST_DEBUG_TX=n + +# +# Compile vhost library +# fuse-devel is needed to run vhost-cuse. +# fuse-devel enables user space char driver development +# vhost-user is turned on by default. +# +CONFIG_RTE_LIBRTE_VHOST=y +CONFIG_RTE_LIBRTE_VHOST_USER=y +CONFIG_RTE_LIBRTE_VHOST_NUMA=n +CONFIG_RTE_LIBRTE_VHOST_DEBUG=n + +# +#Compile Xen domain0 support +# +CONFIG_RTE_LIBRTE_XEN_DOM0=n + +# +# Enable warning directives +# +CONFIG_RTE_INSECURE_FUNCTION_WARNING=n + +# +# Compile the test application +# +CONFIG_RTE_APP_TEST=y + +# +# Compile the PMD test application +# +CONFIG_RTE_TEST_PMD=y +CONFIG_RTE_TEST_PMD_RECORD_CORE_CYCLES=n +CONFIG_RTE_TEST_PMD_RECORD_BURST_STATS=n +CONFIG_RTE_LIBRTE_PMD_VHOST=y + +CONFIG_RTE_EAL_NUMA_AWARE_HUGEPAGES=y +CONFIG_RTE_LIBRTE_KNI=y +CONFIG_RTE_LIBRTE_PMD_KNI=y +CONFIG_RTE_LIBRTE_VHOST=y +CONFIG_RTE_LIBRTE_VHOST_NUMA=y +CONFIG_RTE_LIBRTE_PMD_VHOST=y +CONFIG_RTE_LIBRTE_PMD_TAP=y +CONFIG_RTE_LIBRTE_AVP_PMD=y +CONFIG_RTE_LIBRTE_NFP_PMD=y +CONFIG_RTE_VIRTIO_USER=y diff --git a/3rdparty/get-dpdk.sh b/3rdparty/get-dpdk.sh index 055ca963c1..1c1eb97250 100755 --- a/3rdparty/get-dpdk.sh +++ b/3rdparty/get-dpdk.sh @@ -4,7 +4,7 @@ set -e BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)" DOWNLOAD_BASE="${1-$BASE_DIR}" echo Using "$DOWNLOAD_BASE" for downloads -DPDK_VER=${DPDK_VER-"17.08"} +DPDK_VER=${DPDK_VER-"17.11"} MODE=download # or git DOWNLOAD_PATH="${DOWNLOAD_BASE}/dpdk.tar.gz" DPDK_RESULT="${BASE_DIR}/dpdk" diff --git a/build-container/Dockerfile b/build-container/Dockerfile index 5f0d552eed..11d3ff7365 100644 --- a/build-container/Dockerfile +++ b/build-container/Dockerfile @@ -14,5 +14,4 @@ RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly -y ENV PATH /root/.cargo/bin:$PATH RUN rustup component add rustfmt-preview --toolchain=nightly RUN rustup update -# RUN cargo install rustfmt-nightly || true CMD [/bin/bash] diff --git a/build.sh b/build.sh index a9f482475c..85428cce14 100755 --- a/build.sh +++ b/build.sh @@ -93,8 +93,8 @@ rust_static() { } rust () { - echo "Building rust" if [ ! -z ${RUST_STATIC} ]; then + echo "Building rust" rust_static fi if [ ! -d ${BIN_DIR} ]; then diff --git a/framework/build.rs b/framework/build.rs index becd9a1536..c28c59015e 100644 --- a/framework/build.rs +++ b/framework/build.rs @@ -54,39 +54,39 @@ fn main() { .join("build"); let dpdk_libs = dpdk_build.clone().join("lib"); - let native_path = Path::new(&cargo_dir) - .parent() - .unwrap() - .join("target") - .join("native"); + let native_path = Path::new(&cargo_dir).parent().unwrap().join("target").join("native"); //println!("DPDK {:?}", dpdk_libs.to_str()); // Use DPDK directory as -L - println!( - "cargo:rustc-link-search=native={}", - dpdk_libs.to_str().unwrap() - ); + println!("cargo:rustc-link-search=native={}", dpdk_libs.to_str().unwrap()); if dpdk_libs.join("libdpdk.so").exists() { println!("cargo:rustc-link-lib=dpdk"); } - println!( - "cargo:rustc-link-search=native={}", - native_path.to_str().unwrap() - ); - let header_path = Path::new(&cargo_dir) + println!("cargo:rustc-link-search=native={}", native_path.to_str().unwrap()); + println!("cargo:rustc-link-lib=numa"); + + let out_dir = env::var("OUT_DIR").unwrap(); + + let dpdk_header_path = Path::new(&cargo_dir) .join("src") .join("native_include") .join("dpdk-headers.h"); let dpdk_include_path = dpdk_build.clone().join("include"); - println!("Header path {:?}", header_path.to_str()); + println!("Header path {:?}", dpdk_header_path.to_str()); let bindings = bindgen::Builder::default() - .header(header_path.to_str().unwrap()) + .header(dpdk_header_path.to_str().unwrap()) .rust_target(bindgen::RustTarget::Nightly) .clang_args(vec!["-I", dpdk_include_path.to_str().unwrap()].iter()) .generate() .expect("Unable to generate DPDK bindings"); - let out_dir = env::var("OUT_DIR").unwrap(); let dpdk_bindings = Path::new(&out_dir).join("dpdk_bindings.rs"); - bindings - .write_to_file(dpdk_bindings) - .expect("Could not write bindings"); + bindings.write_to_file(dpdk_bindings).expect("Could not write bindings"); + + let numa_header_path = Path::new(&cargo_dir).join("src").join("native").join("numa.h"); + let bindings = bindgen::Builder::default() + .header(numa_header_path.to_str().unwrap()) + .rust_target(bindgen::RustTarget::Nightly) + .generate() + .expect("Unable to generate libnuma bindings"); + let numa_bindings = Path::new(&out_dir).join("numa.rs"); + bindings.write_to_file(numa_bindings).expect("Could not write bindings"); } diff --git a/framework/src/config/config_reader.rs b/framework/src/config/config_reader.rs index f4dd343ea9..51b1aa867e 100644 --- a/framework/src/config/config_reader.rs +++ b/framework/src/config/config_reader.rs @@ -7,7 +7,6 @@ use toml::{self, Value}; /// Default configuration values pub const DEFAULT_POOL_SIZE: u32 = 2048 - 1; pub const DEFAULT_CACHE_SIZE: u32 = 32; -pub const DEFAULT_SECONDARY: bool = false; pub const DEFAULT_PRIMARY_CORE: i32 = 0; pub const DEFAULT_NAME: &'static str = "zcsi"; pub const NUM_RXD: i32 = 128; @@ -61,10 +60,7 @@ fn read_port(value: &Value) -> Result { let symmetric_queue = port_def.contains_key("cores"); if symmetric_queue && (port_def.contains_key("rx_cores") || port_def.contains_key("tx_cores")) { - println!( - "cores specified along with rx_cores and/or tx_cores for port {}", - name - ); + println!("cores specified along with rx_cores and/or tx_cores for port {}", name); return Err(ErrorKind::ConfigurationError(format!( "cores specified along with rx_cores and/or tx_cores \ for port {}", @@ -182,17 +178,6 @@ pub fn read_configuration_from_str(configuration: &str, filename: &str) -> Resul } }; - // Is process a secondary process - let secondary = match toml.get("secondary") { - Some(&Value::Boolean(secondary)) => secondary, - None => DEFAULT_SECONDARY, - _ => { - println!("Could not parse whether this is a secondary process"); - return Err(ErrorKind::ConfigurationError(String::from("Could not parse secondary processor spec")).into()); - } - }; - - // Secondary ports to instantiate. let cores = match toml.get("cores") { Some(&Value::Array(ref c)) => { let mut cores = Vec::with_capacity(c.len()); @@ -245,7 +230,6 @@ pub fn read_configuration_from_str(configuration: &str, filename: &str) -> Resul primary_core: master_lcore, cores: cores, strict: strict, - secondary: secondary, pool_size: pool_size, cache_size: cache_size, ports: ports, diff --git a/framework/src/config/flag_reader.rs b/framework/src/config/flag_reader.rs index 46af1d875b..21182dd4e8 100644 --- a/framework/src/config/flag_reader.rs +++ b/framework/src/config/flag_reader.rs @@ -11,8 +11,6 @@ use std::process; pub fn basic_opts() -> Options { let mut opts = Options::new(); opts.optflag("h", "help", "print this help menu"); - opts.optflag("", "secondary", "run as a secondary process"); - opts.optflag("", "primary", "run as a primary process"); opts.optopt("n", "name", "name to use for the current process", "name"); opts.optmulti("p", "port", "Port to use", "[type:]id"); opts.optmulti("c", "core", "Core to use", "core"); @@ -52,32 +50,23 @@ pub fn read_matches(matches: &Matches, opts: &Options) -> NetbricksConfiguration NetbricksConfiguration::new_with_name(&name[..]) }; - let configuration = if matches.opt_present("m") { + let configuration = if matches.opt_present("dpdk_args") { NetbricksConfiguration { - primary_core: matches - .opt_str("m") - .unwrap() - .parse() - .expect("Could not parse master core"), - strict: true, + dpdk_args: Some(matches.opt_strs("dpdk_args").join(" ")), ..configuration } } else { configuration }; - let configuration = if matches.opt_present("secondary") { - NetbricksConfiguration { - secondary: true, - ..configuration - } - } else { - configuration - }; - - let configuration = if matches.opt_present("primary") { + let configuration = if matches.opt_present("m") { NetbricksConfiguration { - secondary: false, + primary_core: matches + .opt_str("m") + .unwrap() + .parse() + .expect("Could not parse master core"), + strict: true, ..configuration } } else { @@ -89,11 +78,7 @@ pub fn read_matches(matches: &Matches, opts: &Options) -> NetbricksConfiguration let mut cores: Vec = cores_str .iter() - .map(|n: &String| { - n.parse() - .ok() - .expect(&format!("Core cannot be parsed {}", n)) - }) + .map(|n: &String| n.parse().ok().expect(&format!("Core cannot be parsed {}", n))) .collect(); let cores_for_port = extract_cores_for_port(&matches.opt_strs("p"), &cores); @@ -123,10 +108,7 @@ pub fn read_matches(matches: &Matches, opts: &Options) -> NetbricksConfiguration fn extract_cores_for_port(ports: &[String], cores: &[i32]) -> HashMap> { let mut cores_for_port = HashMap::>::new(); for (port, core) in ports.iter().zip(cores.iter()) { - cores_for_port - .entry(port.clone()) - .or_insert(vec![]) - .push(*core) + cores_for_port.entry(port.clone()).or_insert(vec![]).push(*core) } cores_for_port } diff --git a/framework/src/config/mod.rs b/framework/src/config/mod.rs index 07bdd93d3a..e6c53cf60a 100644 --- a/framework/src/config/mod.rs +++ b/framework/src/config/mod.rs @@ -9,8 +9,6 @@ mod flag_reader; pub struct NetbricksConfiguration { /// Name, this is passed on to DPDK. If you want to run multiple DPDK apps, this needs to be unique per application. pub name: String, - /// Should this process be run as a secondary process or a primary process? - pub secondary: bool, /// Where should the main thread (for the examples this just sits around and prints packet counts) be run. pub primary_core: i32, /// Cores that can be used by NetBricks. Note that currently we will add any cores specified in the ports @@ -40,7 +38,6 @@ impl Default for NetbricksConfiguration { primary_core: 0, cores: Default::default(), strict: false, - secondary: false, ports: vec![], dpdk_args: None, } diff --git a/framework/src/control/mod.rs b/framework/src/control/mod.rs index 5baeb7e9a8..d526b2ede8 100644 --- a/framework/src/control/mod.rs +++ b/framework/src/control/mod.rs @@ -4,9 +4,9 @@ pub use self::epoll::*; #[cfg(target_os = "linux")] #[path = "linux/epoll.rs"] mod epoll; -pub mod tcp; #[cfg(feature = "sctp")] pub mod sctp; +pub mod tcp; use std::os::unix::io::RawFd; diff --git a/framework/src/control/sctp.rs b/framework/src/control/sctp.rs index 7ef233da82..e4877d1c73 100644 --- a/framework/src/control/sctp.rs +++ b/framework/src/control/sctp.rs @@ -60,8 +60,7 @@ impl SctpControlServer { } fn listen(&mut self) { - self.handle - .schedule_read(&self.listener, self.listener_token); + self.handle.schedule_read(&self.listener, self.listener_token); } pub fn schedule(&mut self) { diff --git a/framework/src/control/tcp.rs b/framework/src/control/tcp.rs index 98c993b9d5..e001ef1204 100644 --- a/framework/src/control/tcp.rs +++ b/framework/src/control/tcp.rs @@ -103,8 +103,7 @@ impl TcpControlServer { } else { // FIXME: Report something. } - self.handle - .schedule_read(&self.listener, self.listener_token); + self.handle.schedule_read(&self.listener, self.listener_token); } fn handle_data(&mut self, token: Token, available: Available) { diff --git a/framework/src/headers/ip.rs b/framework/src/headers/ip.rs index 016fc66281..a68e2248ae 100644 --- a/framework/src/headers/ip.rs +++ b/framework/src/headers/ip.rs @@ -8,8 +8,9 @@ use std::net::Ipv4Addr; use std::slice; use utils::Flow; -/// IP header using SSE -#[derive(Default)] +/// IP header using SSE. We need copying since Debug needs to copy things out to ensure +/// aligned accesses +#[derive(Copy, Debug, Clone, Default)] #[repr(C, packed)] pub struct IpHeader { version_to_len: u32, diff --git a/framework/src/headers/mac.rs b/framework/src/headers/mac.rs index 8b2f3a1ffe..9e56d7b6f0 100644 --- a/framework/src/headers/mac.rs +++ b/framework/src/headers/mac.rs @@ -5,7 +5,7 @@ use std::fmt; use std::hash::Hash; use std::hash::Hasher; -#[derive(Default)] +#[derive(Debug, Copy, Default)] #[repr(C, packed)] pub struct MacAddress { pub addr: [u8; 6], @@ -66,7 +66,7 @@ impl Hash for MacAddress { } /// A packet's MAC header. -#[derive(Default)] +#[derive(Debug, Clone, Copy, Default)] #[repr(C, packed)] pub struct MacHeader { pub dst: MacAddress, @@ -76,13 +76,7 @@ pub struct MacHeader { impl fmt::Display for MacHeader { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!( - f, - "{} > {} 0x{:04x}", - self.src, - self.dst, - u16::from_be(self.etype) - ) + write!(f, "{} > {} 0x{:04x}", self.src, self.dst, u16::from_be(self.etype)) } } diff --git a/framework/src/headers/mod.rs b/framework/src/headers/mod.rs index e1f7a7a7f0..d03d183ba6 100644 --- a/framework/src/headers/mod.rs +++ b/framework/src/headers/mod.rs @@ -3,11 +3,11 @@ pub use self::mac::*; pub use self::null_header::*; pub use self::tcp::*; pub use self::udp::*; -mod mac; mod ip; -mod udp; -mod tcp; +mod mac; mod null_header; +mod tcp; +mod udp; /// A trait implemented by all headers, used for reading them from a mbuf. pub trait EndOffset: Send { diff --git a/framework/src/headers/null_header.rs b/framework/src/headers/null_header.rs index f3450da2e9..491b8fd086 100644 --- a/framework/src/headers/null_header.rs +++ b/framework/src/headers/null_header.rs @@ -1,7 +1,7 @@ use super::EndOffset; use std::fmt; -#[derive(Default)] +#[derive(Debug, Copy, Clone, Default)] #[repr(C, packed)] pub struct NullHeader; diff --git a/framework/src/headers/tcp.rs b/framework/src/headers/tcp.rs index 8110178d4e..e8f123dbfc 100644 --- a/framework/src/headers/tcp.rs +++ b/framework/src/headers/tcp.rs @@ -3,7 +3,7 @@ use headers::IpHeader; use std::default::Default; use std::fmt; -#[derive(Default)] +#[derive(Debug, Copy, Clone, Default)] #[repr(C, packed)] pub struct TcpHeader { src_port: u16, diff --git a/framework/src/headers/udp.rs b/framework/src/headers/udp.rs index b37f773dea..8668047783 100644 --- a/framework/src/headers/udp.rs +++ b/framework/src/headers/udp.rs @@ -4,7 +4,7 @@ use std::default::Default; use std::fmt; /// UDP header using SSE -#[derive(Default)] +#[derive(Debug, Copy, Clone, Default)] #[repr(C, packed)] pub struct UdpHeader { src_port: u16, diff --git a/framework/src/interface/dpdk.rs b/framework/src/interface/dpdk.rs index b78b7ad2cb..a90117916b 100644 --- a/framework/src/interface/dpdk.rs +++ b/framework/src/interface/dpdk.rs @@ -1,55 +1,125 @@ use super::METADATA_SLOTS; +use super::native_include as ldpdk; use config::{NetbricksConfiguration, DEFAULT_CACHE_SIZE, DEFAULT_POOL_SIZE}; +use libc; use native::libnuma; -use native::zcsi; +use native::zcsi as lzcsi; use std::cell::Cell; +use std::cmp; use std::ffi::CString; +use std::io::Error; +use std::iter; +use std::mem; +use std::ptr; + +pub struct DpdkContext { + mempools: Vec<*mut ldpdk::rte_mempool>, +} + +impl DpdkContext { + pub fn get_mempool(&self, socket: usize) -> *mut ldpdk::rte_mempool { + self.mempools[socket].clone() + } +} + +unsafe fn init_socket_mempool( + socket: i32, + pool_size: u32, + cache_size: u32, + metadata_slots: u16, +) -> *mut ldpdk::rte_mempool { + let name = CString::new(format!("pframe{}", socket)).unwrap(); + ldpdk::rte_pktmbuf_pool_create( + name.into_raw(), + pool_size, + cache_size, + metadata_slots * 64, + ldpdk::RTE_MBUF_DEFAULT_BUF_SIZE as u16, + socket, + ) +} + +/// Call into libnuma to bind thread to NUMA node. +unsafe fn bind_thread_to_numa_node(socket: u32) { + let bitmask = libnuma::numa_bitmask_setbit( + libnuma::numa_bitmask_clearall(libnuma::numa_bitmask_alloc(libnuma::numa_num_possible_nodes() as u32)), + socket, + ); + libnuma::numa_bind(bitmask); +} /// Initialize the system, whitelisting some set of NICs and allocating mempool of given size. -fn init_system_wl_with_mempool(name: &str, core: i32, pci: &[String], pool_size: u32, cache_size: u32) { +fn init_system_wl_with_mempool( + name: &str, + core: i32, + devices: &[String], + pool_size: u32, + cache_size: u32, +) -> DpdkContext { let name_cstr = CString::new(name).unwrap(); - let pci_cstr: Vec<_> = pci.iter().map(|p| CString::new(&p[..]).unwrap()).collect(); - let mut whitelist: Vec<_> = pci_cstr.iter().map(|p| p.as_ptr()).collect(); + + let mut dpdk_args = vec![]; + // FIXME: Maybe replace with placement syntax unsafe { - let ret = zcsi::init_system_whitelisted( - name_cstr.as_ptr(), - name.len() as i32, - core, - whitelist.as_mut_ptr(), - pci.len() as i32, - pool_size, - cache_size, - METADATA_SLOTS, - ); - if ret != 0 { - panic!("Could not initialize the system errno {}", ret) + // First we need to push in name. + dpdk_args.push(name_cstr.into_raw()); + dpdk_args.push(CString::new("--master-lcore").unwrap().into_raw()); + // Using RTE_MAX_LCORE as core ID for master. + let master_lcore = ldpdk::RTE_MAX_LCORE - 1; + dpdk_args.push(CString::new(master_lcore.to_string()).unwrap().into_raw()); + dpdk_args.push(CString::new("--lcore").unwrap().into_raw()); + dpdk_args.push(CString::new(format!("{}@{}", master_lcore, core)).unwrap().into_raw()); + dpdk_args.push(CString::new("--no-shconf").unwrap().into_raw()); + + let numa_available = libnuma::numa_available(); + let numa_nodes = if numa_available == -1 { + // FIXME: Warn. + 1 + } else { + // The cmp::max is to take care of any cases where libnuma is broken. + cmp::max(1, libnuma::numa_num_configured_nodes()) + } as usize; + let mem_vec: Vec<_> = iter::repeat(pool_size.to_string()).take(numa_nodes).collect(); + let mem = mem_vec.join(","); + dpdk_args.push(CString::new("--socket-mem").unwrap().into_raw()); + dpdk_args.push(CString::new(mem).unwrap().into_raw()); + dpdk_args.push(CString::new("--huge-unlink").unwrap().into_raw()); + // White list a fake card so everything is blacklisted by default. + dpdk_args.push(CString::new("-w").unwrap().into_raw()); + dpdk_args.push(CString::new("99:99.0").unwrap().into_raw()); + for dev in devices { + dpdk_args.push(CString::new("-w").unwrap().into_raw()); + dpdk_args.push(CString::new(&dev[..]).unwrap().into_raw()); + } + let arg_len = dpdk_args.len() as i32; + println!("arg_len = {}", arg_len); + dpdk_args.push(ptr::null_mut()); + let ret = ldpdk::rte_eal_init(arg_len, dpdk_args.as_mut_ptr()); + if ret == -1 { + panic!( + "Could not initialize DPDK -- errno {:?}", + Error::from_raw_os_error(-ret) + ) + } + + if numa_available != -1 { + let socket = ldpdk::lcore_config[master_lcore as usize].socket_id; + bind_thread_to_numa_node(socket); } + + let ret = DpdkContext { + mempools: (0..numa_nodes) + .map(|sock| init_socket_mempool(sock as i32, pool_size, cache_size, METADATA_SLOTS as u16)) + .collect() + }; + set_lcore_id(master_lcore as i32); + ret } } /// Initialize the system, whitelisting some set of NICs. pub fn init_system_wl(name: &str, core: i32, pci: &[String]) { init_system_wl_with_mempool(name, core, pci, DEFAULT_POOL_SIZE, DEFAULT_CACHE_SIZE); - set_numa_domain(); -} - -/// Initialize the system as a DPDK secondary process with a set of VDEVs. User must specify mempool name to use. -pub fn init_system_secondary(name: &str, core: i32) { - let name_cstr = CString::new(name).unwrap(); - let mut vdev_list = vec![]; - unsafe { - let ret = zcsi::init_secondary( - name_cstr.as_ptr(), - name.len() as i32, - core, - vdev_list.as_mut_ptr(), - 0, - ); - if ret != 0 { - panic!("Could not initialize secondary process errno {}", ret) - } - } - set_numa_domain(); } /// Initialize the system based on the supplied scheduler configuration. @@ -58,51 +128,49 @@ pub fn init_system(config: &NetbricksConfiguration) { panic!("Configuration must provide a name."); } // We init with all devices blacklisted and rely on the attach logic to white list them as necessary. - if config.secondary { - // We do not have control over any of the other settings in this case. - init_system_secondary(&config.name[..], config.primary_core); - } else { - init_system_wl_with_mempool( - &config.name[..], - config.primary_core, - &[], - config.pool_size, - config.cache_size, - ); - } - set_numa_domain(); + init_system_wl_with_mempool( + &config.name[..], + config.primary_core, + &[], + config.pool_size, + config.cache_size, + ); } -thread_local!(static NUMA_DOMAIN: Cell = Cell::new(-1)); +thread_local!(static CURRENT_LCORE: Cell = Cell::new(-1)); -fn set_numa_domain() { - let domain = unsafe { - if libnuma::numa_available() == -1 { - println!("No NUMA information found, support disabled"); - -1 - } else { - let domain = libnuma::numa_preferred(); - println!("Running on node {}", domain); - domain - } - }; - NUMA_DOMAIN.with(|f| f.set(domain)) +fn set_lcore_id(lcore: i32) { + CURRENT_LCORE.with(|f| f.set(lcore)) } /// Affinitize a pthread to a core and assign a DPDK thread ID. pub fn init_thread(tid: i32, core: i32) { - let numa = unsafe { zcsi::init_thread(tid, core) }; - NUMA_DOMAIN.with(|f| { - f.set(numa); - }); - if numa == -1 { - println!("No NUMA information found, support disabled"); - } else { - println!("Running on node {}", numa); - }; + //unsafe { zcsi::init_thread(tid, core) }; + unsafe { + let mut cset: libc::cpu_set_t = mem::uninitialized(); + libc::CPU_ZERO(&mut cset); + libc::CPU_SET(core as usize, &mut cset); + { + let mut cset_dpdk = mem::transmute(cset); + let cset = &mut cset_dpdk as *mut ldpdk::cpu_set_t; + ldpdk::rte_thread_set_affinity(cset); + } + let numa_available = libnuma::numa_available(); + let socket = ldpdk::lcore_config[core as usize].socket_id; + if numa_available != -1 { + bind_thread_to_numa_node(socket) + }; + // FIXME: Need to set lcore_id for use by mempool caches, which are accessed by some PMD drivers + let init_result = lzcsi::init_thread(tid, core); + if init_result != 1 { + panic!("init_thread failed") + } + } + set_lcore_id(tid) } #[inline] -pub fn get_domain() -> i32 { - NUMA_DOMAIN.with(|f| f.get()) +pub fn get_domain() -> u32 { + let lcore = CURRENT_LCORE.with(|f| f.get()); + unsafe { ldpdk::lcore_config[lcore as usize].socket_id } } diff --git a/framework/src/interface/mod.rs b/framework/src/interface/mod.rs index a5ba0acffe..cb8b45c1d5 100644 --- a/framework/src/interface/mod.rs +++ b/framework/src/interface/mod.rs @@ -1,8 +1,9 @@ pub use self::packet::*; pub use self::port::*; pub mod dpdk; -mod port; mod packet; +mod port; +use super::native_include; use common::*; use native::zcsi::MBuf; diff --git a/framework/src/interface/packet.rs b/framework/src/interface/packet.rs index fe50801ecb..4872006b21 100644 --- a/framework/src/interface/packet.rs +++ b/framework/src/interface/packet.rs @@ -103,10 +103,7 @@ pub fn new_packet_array(count: usize) -> Vec> if alloc_ret == 0 { array.set_len(count); } - array - .iter() - .map(|m| packet_from_mbuf_no_increment(*m, 0)) - .collect() + array.iter().map(|m| packet_from_mbuf_no_increment(*m, 0)).collect() } } diff --git a/framework/src/interface/port/phy_port.rs b/framework/src/interface/port/phy_port.rs index 180b926441..e4b1f36be2 100644 --- a/framework/src/interface/port/phy_port.rs +++ b/framework/src/interface/port/phy_port.rs @@ -1,5 +1,5 @@ -use super::PortStats; use super::super::{PacketRx, PacketTx}; +use super::PortStats; use allocators::*; use common::*; use config::{PortConfiguration, NUM_RXD, NUM_TXD}; diff --git a/framework/src/interface/port/virt_port.rs b/framework/src/interface/port/virt_port.rs index 6f49103c56..5fcce8b768 100644 --- a/framework/src/interface/port/virt_port.rs +++ b/framework/src/interface/port/virt_port.rs @@ -1,5 +1,5 @@ -use super::PortStats; use super::super::{PacketRx, PacketTx}; +use super::PortStats; use allocators::*; use common::*; use native::zcsi::*; diff --git a/framework/src/lib.rs b/framework/src/lib.rs index 3864fe1b32..527652895a 100644 --- a/framework/src/lib.rs +++ b/framework/src/lib.rs @@ -46,18 +46,18 @@ extern crate error_chain; #[cfg(unix)] extern crate nix; +pub mod allocators; +pub mod common; +pub mod config; +pub mod control; +pub mod headers; +pub mod interface; #[allow(dead_code)] mod native; mod native_include; -pub mod allocators; -pub mod headers; -pub mod scheduler; -pub mod utils; -pub mod queues; -pub mod state; pub mod operators; -pub mod interface; -pub mod common; -pub mod control; +pub mod queues; +pub mod scheduler; pub mod shared_state; -pub mod config; +pub mod state; +pub mod utils; diff --git a/framework/src/native/libnuma.rs b/framework/src/native/libnuma.rs index aecf42f7ea..89474b2976 100644 --- a/framework/src/native/libnuma.rs +++ b/framework/src/native/libnuma.rs @@ -1,211 +1,5 @@ -use libc::c_void; -use std::cmp::{Eq, PartialEq}; - -#[link(name = "numa")] -#[allow(dead_code)] -extern "C" { - /// Check if NUMA support is enabled. Returns -1 if not enabled, in which case other functions will - /// panic. - pub fn numa_available() -> i32; - /// The number of NUMA nodes supported by the system. - pub fn numa_max_possible_node() -> i32; - /// Size of NUMA mask in kernel. - pub fn numa_num_possible_nodes() -> i32; - /// Size of CPU mask in kernel. - pub fn numa_num_possible_cpus() -> i32; - /// The number of NUMA nodes available in the system. - pub fn numa_max_node() -> i32; - /// The number of memory nodes configured in the system. - pub fn numa_num_configured_nodes() -> i32; - /// The number of configured CPUs in the system - pub fn numa_num_configured_cpus() -> i32; - /// Number of CPUs current task can use. - pub fn numa_num_task_cpus() -> i32; - /// Number of nodes current task can use. - pub fn numa_num_task_nodes() -> i32; - - pub fn numa_node_size(node: i32, freep: *mut u64) -> u64; - - pub fn numa_preferred() -> i32; - pub fn numa_set_preferred(node: i32); - pub fn numa_get_interleave_node() -> i32; - // numa_interleave_memory: Leaving this aside until I figure out a safe way/reason to use this. - pub fn numa_set_localalloc(); - - pub fn numa_run_on_node(node: i32); - - pub fn numa_alloc_onnode(size: usize, node: i32) -> *mut c_void; - pub fn numa_alloc_local(size: usize) -> *mut c_void; - pub fn numa_alloc_interleaved(size: usize) -> *mut c_void; - pub fn numa_alloc(size: usize) -> *mut c_void; - pub fn numa_realloc(addr: *mut c_void, old_size: usize, new_size: usize) -> *mut c_void; - pub fn numa_free(addr: *mut c_void, size: usize); - - pub fn numa_tonode_memory(start: *mut c_void, size: usize, node: u32); - pub fn numa_setlocal_memory(start: *mut c_void, size: usize); - pub fn numa_police_memory(start: *mut c_void, size: usize); - pub fn numa_set_bind_policy(strict: i32); - pub fn numa_set_strict(strict: i32); -} - -mod wrapped { - use libc::c_void; - use native::libnuma::NumaBitmap; - extern "C" { - /// Memory nodes from which allocation is permitted. - pub fn numa_get_mems_allowed() -> *mut NumaBitmap; - - pub fn numa_get_interleave_mask() -> *mut NumaBitmap; - pub fn numa_set_interleave_mask(bitmap: *mut NumaBitmap); - - pub fn numa_bind(bitmap: *mut NumaBitmap); - - pub fn numa_set_membind(bitmap: *mut NumaBitmap); - pub fn numa_get_membind() -> *mut NumaBitmap; - - pub fn numa_run_on_node_mask(mask: *mut NumaBitmap); - pub fn numa_get_run_node_mask() -> *mut NumaBitmap; - - pub fn numa_alloc_interleaved_subset(size: usize, mask: *mut NumaBitmap) -> *mut c_void; - pub fn numa_distance(node1: i32, node2: i32) -> i32; - - pub fn numa_bitmask_alloc(bits: u32) -> *mut NumaBitmap; - pub fn numa_bitmask_free(mask: *mut NumaBitmap); - - pub fn numa_bitmask_clearall(mask: *mut NumaBitmap) -> *mut NumaBitmap; - pub fn numa_bitmask_clearbit(mask: *mut NumaBitmap, bit: u32) -> *mut NumaBitmap; - pub fn numa_bitmask_equal(mask1: *const NumaBitmap, mask2: *const NumaBitmap) -> i32; - pub fn numa_bitmask_isbitset(mask: *const NumaBitmap, n: u32) -> i32; - pub fn numa_bitmask_nbytes(mask: *mut NumaBitmap) -> u32; - pub fn numa_bitmask_setall(mask: *mut NumaBitmap) -> *mut NumaBitmap; - pub fn numa_bitmask_setbit(mask: *mut NumaBitmap, bit: u32) -> *mut NumaBitmap; - pub fn numa_tonodemask_memory(start: *mut c_void, size: usize, mask: *mut NumaBitmap); - } -} - -#[repr(C)] -pub struct NumaBitmap { - size: usize, - mask: *mut u64, -} - -pub struct Bitmask { - pub bitmask: *mut NumaBitmap, -} - -impl PartialEq for Bitmask { - fn eq(&self, other: &Bitmask) -> bool { - unsafe { wrapped::numa_bitmask_equal(self.bitmask, other.bitmask) == 0 } - } -} - -impl Eq for Bitmask {} - -impl Bitmask { - pub unsafe fn allocate_node_mask() -> Bitmask { - Bitmask { - bitmask: wrapped::numa_bitmask_clearall(wrapped::numa_bitmask_alloc(numa_num_possible_nodes() as u32)), - } - } - - pub unsafe fn allocate_cpu_mask() -> Bitmask { - Bitmask { - bitmask: wrapped::numa_bitmask_clearall(wrapped::numa_bitmask_alloc(numa_num_possible_cpus() as u32)), - } - } - - #[inline] - fn assert_size(&self, bit: usize) { - unsafe { - assert!(bit < (*self.bitmask).size); - } - } - - pub fn clear_bit(&mut self, bit: usize) { - self.assert_size(bit); - unsafe { wrapped::numa_bitmask_clearbit(self.bitmask, bit as u32) }; - } - - pub fn clear(&mut self) { - unsafe { wrapped::numa_bitmask_clearall(self.bitmask) }; - } - - pub fn get_mems_allowed() -> Bitmask { - Bitmask { - bitmask: unsafe { wrapped::numa_get_mems_allowed() }, - } - } - - pub fn get_interleaved_mask() -> Bitmask { - Bitmask { - bitmask: unsafe { wrapped::numa_get_interleave_mask() }, - } - } - - pub fn get_membind() -> Bitmask { - Bitmask { - bitmask: unsafe { wrapped::numa_get_membind() }, - } - } - - pub fn get_run_node_mask() -> Bitmask { - Bitmask { - bitmask: unsafe { wrapped::numa_get_run_node_mask() }, - } - } - - /// Set bit in bitmask. - pub fn set_bit(&mut self, bit: usize) { - self.assert_size(bit); - unsafe { wrapped::numa_bitmask_setbit(self.bitmask, bit as u32) }; - } - - /// Set all bits. - pub fn set_all(&mut self) { - unsafe { wrapped::numa_bitmask_setall(self.bitmask) }; - } - - pub fn bit(&self, idx: usize) -> bool { - self.assert_size(idx); - unsafe { wrapped::numa_bitmask_isbitset(self.bitmask, idx as u32) == 1 } - } - - pub fn size_in_bytes(&self) -> usize { - let size = unsafe { wrapped::numa_bitmask_nbytes(self.bitmask) }; - size as usize - } -} - -impl Drop for Bitmask { - fn drop(&mut self) { - unsafe { wrapped::numa_bitmask_free(self.bitmask) } - } -} - -pub fn numa_distance(node1: i32, node2: i32) -> i32 { - unsafe { wrapped::numa_distance(node1, node2) } -} - -pub unsafe fn numa_set_interleave_mask(bitmap: &mut Bitmask) { - wrapped::numa_set_interleave_mask(bitmap.bitmask) -} - -pub unsafe fn numa_bind(bitmap: &mut Bitmask) { - wrapped::numa_bind(bitmap.bitmask) -} - -pub unsafe fn numa_set_membind(bitmap: &mut Bitmask) { - wrapped::numa_set_membind(bitmap.bitmask) -} - -pub unsafe fn numa_run_on_node_mask(mask: &mut Bitmask) { - wrapped::numa_run_on_node_mask(mask.bitmask) -} - -pub unsafe fn numa_alloc_interleaved_subset(size: usize, mask: &mut Bitmask) -> *mut c_void { - wrapped::numa_alloc_interleaved_subset(size, mask.bitmask) -} - -pub unsafe fn numa_tonodemask_memory(start: *mut c_void, size: usize, mask: &mut Bitmask) { - wrapped::numa_tonodemask_memory(start, size, mask.bitmask) -} +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(dead_code)] +include!(concat!(env!("OUT_DIR"), "/numa.rs")); diff --git a/framework/src/native/numa.h b/framework/src/native/numa.h new file mode 100644 index 0000000000..46f22b6d91 --- /dev/null +++ b/framework/src/native/numa.h @@ -0,0 +1 @@ +#include diff --git a/framework/src/native/zcsi/mbuf.rs b/framework/src/native/zcsi/mbuf.rs index 5bb2e7bc67..c23ae8cb5b 100644 --- a/framework/src/native/zcsi/mbuf.rs +++ b/framework/src/native/zcsi/mbuf.rs @@ -1,28 +1,5 @@ -#[repr(C)] -pub struct MBuf { - buf_addr: *mut u8, - phys_addr: usize, - data_off: u16, - refcnt: u16, - nb_segs: u8, - port: u8, - ol_flags: u64, - packet_type: u32, - pkt_len: u32, - data_len: u16, - vlan_tci: u16, - hash: u64, - vlan_tci_outer: u32, - buf_len: u16, - timestamp: u64, - userdata: u64, - pool: u64, - next: *mut MBuf, - tx_offload: u64, - priv_size: u16, - timesync: u16, - seqn: u32, -} +use super::super::super::native_include as ldpdk; +pub type MBuf = ldpdk::rte_mbuf; // FIXME: Remove this once we start using these functions correctly #[allow(dead_code)] @@ -55,10 +32,7 @@ impl MBuf { #[inline] pub fn data_address(&self, offset: usize) -> *mut u8 { - unsafe { - self.buf_addr - .offset(self.data_off as isize + offset as isize) - } + unsafe { (self.buf_addr as *mut u8).offset(self.data_off as isize + offset as isize) } } /// Returns the total allocated size of this mbuf segment. @@ -142,11 +116,13 @@ impl MBuf { #[inline] pub fn refcnt(&self) -> u16 { - self.refcnt + unsafe { self.__bindgen_anon_1.refcnt } } #[inline] pub fn reference(&mut self) { - self.refcnt += 1; + unsafe { + self.__bindgen_anon_1.refcnt += 1; + } } } diff --git a/framework/src/native/zcsi/mod.rs b/framework/src/native/zcsi/mod.rs index b65ff4d170..9640691798 100644 --- a/framework/src/native/zcsi/mod.rs +++ b/framework/src/native/zcsi/mod.rs @@ -1,5 +1,5 @@ +mod mbuf; #[cfg_attr(feature = "dev", allow(module_inception))] mod zcsi; -mod mbuf; pub use self::mbuf::*; pub use self::zcsi::*; diff --git a/framework/src/native/zcsi/zcsi.rs b/framework/src/native/zcsi/zcsi.rs index 2ad8e38e71..692cf35d4d 100644 --- a/framework/src/native/zcsi/zcsi.rs +++ b/framework/src/native/zcsi/zcsi.rs @@ -3,19 +3,7 @@ use headers::MacAddress; use std::os::raw::c_char; #[link(name = "zcsi")] extern "C" { - pub fn init_system_whitelisted( - name: *const c_char, - nlen: i32, - core: i32, - whitelist: *mut *const c_char, - wlcount: i32, - pool_size: u32, - cache_size: u32, - slots: u16, - ) -> i32; pub fn init_thread(tid: i32, core: i32) -> i32; - pub fn init_secondary(name: *const c_char, nlen: i32, core: i32, vdevs: *mut *const c_char, vdev_count: i32) - -> i32; pub fn init_pmd_port( port: i32, rxqs: i32, diff --git a/framework/src/operators/filter_batch.rs b/framework/src/operators/filter_batch.rs index 9de94026b6..05f9bf12d5 100644 --- a/framework/src/operators/filter_batch.rs +++ b/framework/src/operators/filter_batch.rs @@ -49,11 +49,7 @@ where self.parent.act(); // Filter during the act let iter = PayloadEnumerator::::new(&mut self.parent); - while let Some(ParsedDescriptor { - mut packet, - index: idx, - }) = iter.next(&mut self.parent) - { + while let Some(ParsedDescriptor { mut packet, index: idx }) = iter.next(&mut self.parent) { if !(self.filter)(&mut packet) { self.remove.push(idx) } diff --git a/framework/src/operators/merge_batch.rs b/framework/src/operators/merge_batch.rs index 9e53d61037..a8c3e32eda 100644 --- a/framework/src/operators/merge_batch.rs +++ b/framework/src/operators/merge_batch.rs @@ -63,9 +63,7 @@ impl Act for MergeBatch { #[inline] fn capacity(&self) -> i32 { - self.parents - .iter() - .fold(0, |acc, x| cmp::max(acc, x.capacity())) + self.parents.iter().fold(0, |acc, x| cmp::max(acc, x.capacity())) } #[inline] diff --git a/framework/src/operators/mod.rs b/framework/src/operators/mod.rs index 453baf58b5..d244a968e9 100644 --- a/framework/src/operators/mod.rs +++ b/framework/src/operators/mod.rs @@ -27,6 +27,8 @@ use scheduler::Scheduler; mod macros; mod act; +mod add_metadata; +mod add_metadata_mut; mod composition_batch; mod deparsed_batch; mod filter_batch; @@ -38,11 +40,9 @@ mod packet_batch; mod parsed_batch; mod receive_batch; mod reset_parse; +mod restore_header; mod send_batch; mod transform_batch; -mod restore_header; -mod add_metadata; -mod add_metadata_mut; /// Merge a vector of batches into one batch. Currently this just round-robins between merged batches, but in the future /// the precise batch being processed will be determined by the scheduling policy used. diff --git a/framework/src/operators/packet_batch.rs b/framework/src/operators/packet_batch.rs index 1e62c0f60b..7c98f08b5d 100644 --- a/framework/src/operators/packet_batch.rs +++ b/framework/src/operators/packet_batch.rs @@ -44,8 +44,7 @@ impl PacketBatch { #[inline] pub fn allocate_batch_with_size(&mut self, len: u16) -> Result<&mut Self> { let capacity = self.array.capacity() as i32; - self.alloc_packet_batch(len, capacity) - .and_then(|_| Ok(self)) + self.alloc_packet_batch(len, capacity).and_then(|_| Ok(self)) } /// Allocate `cnt` mbufs. `len` sets the metadata field indicating how much of the mbuf should be considred when diff --git a/framework/src/operators/reset_parse.rs b/framework/src/operators/reset_parse.rs index ea620db579..70584854e9 100644 --- a/framework/src/operators/reset_parse.rs +++ b/framework/src/operators/reset_parse.rs @@ -36,9 +36,7 @@ where #[inline] unsafe fn next_payload(&mut self, idx: usize) -> Option> { match self.parent.next_payload(idx) { - Some(PacketDescriptor { packet }) => Some(PacketDescriptor { - packet: packet.reset(), - }), + Some(PacketDescriptor { packet }) => Some(PacketDescriptor { packet: packet.reset() }), None => None, } } diff --git a/framework/src/queues/mpsc_mbuf_queue.rs b/framework/src/queues/mpsc_mbuf_queue.rs index 2c6673ab9c..8f56ccdb82 100644 --- a/framework/src/queues/mpsc_mbuf_queue.rs +++ b/framework/src/queues/mpsc_mbuf_queue.rs @@ -94,9 +94,7 @@ impl MpscQueue { let producer_head = self.producer.head.load(Ordering::Acquire); let consumer_tail = self.consumer.tail.load(Ordering::Acquire); - let free = self.mask - .wrapping_add(consumer_tail) - .wrapping_sub(producer_head); + let free = self.mask.wrapping_add(consumer_tail).wrapping_sub(producer_head); let insert = min(free, len); if insert > 0 { @@ -124,9 +122,7 @@ impl MpscQueue { while { producer_head = self.producer.head.load(Ordering::Acquire); consumer_tail = self.consumer.tail.load(Ordering::Acquire); - let free = self.mask - .wrapping_add(consumer_tail) - .wrapping_sub(producer_head); + let free = self.mask.wrapping_add(consumer_tail).wrapping_sub(producer_head); insert = min(free, len); if insert == 0 { // Short circuit, no insertion @@ -135,12 +131,7 @@ impl MpscQueue { let producer_next = producer_head.wrapping_add(insert); self.producer .head - .compare_exchange( - producer_head, - producer_next, - Ordering::AcqRel, - Ordering::Relaxed, - ) + .compare_exchange(producer_head, producer_next, Ordering::AcqRel, Ordering::Relaxed) .is_err() } } {} diff --git a/framework/src/scheduler/context.rs b/framework/src/scheduler/context.rs index c93035c8e7..456ae58659 100644 --- a/framework/src/scheduler/context.rs +++ b/framework/src/scheduler/context.rs @@ -1,7 +1,7 @@ use allocators::CacheAligned; use config::NetbricksConfiguration; -use interface::{PmdPort, PortQueue, VirtualPort, VirtualQueue}; use interface::dpdk::{init_system, init_thread}; +use interface::{PmdPort, PortQueue, VirtualPort, VirtualQueue}; use scheduler::*; use std::collections::HashMap; use std::collections::HashSet; @@ -80,9 +80,7 @@ impl NetBricksContext { }; let boxed_run = run.clone(); channel - .send(SchedulerCommand::Run(Arc::new(move |s| { - boxed_run(ports.clone(), s) - }))) + .send(SchedulerCommand::Run(Arc::new(move |s| boxed_run(ports.clone(), s)))) .unwrap(); } } @@ -92,9 +90,7 @@ impl NetBricksContext { T: Fn(Vec, &mut StandaloneScheduler) + Send + Sync + 'static, { for (core, channel) in &self.scheduler_channels { - let port = self.virtual_ports - .entry(*core) - .or_insert(VirtualPort::new(1).unwrap()); + let port = self.virtual_ports.entry(*core).or_insert(VirtualPort::new(1).unwrap()); let boxed_run = run.clone(); let queue = port.new_virtual_queue(1).unwrap(); channel @@ -113,9 +109,7 @@ impl NetBricksContext { run: Arc, ) -> Result<()> { if let Some(channel) = self.scheduler_channels.get(&core) { - let port = self.virtual_ports - .entry(core) - .or_insert(VirtualPort::new(1).unwrap()); + let port = self.virtual_ports.entry(core).or_insert(VirtualPort::new(1).unwrap()); let boxed_run = run.clone(); let queue = port.new_virtual_queue(1).unwrap(); channel @@ -142,9 +136,7 @@ impl NetBricksContext { }; let boxed_run = run.clone(); channel - .send(SchedulerCommand::Run(Arc::new(move |s| { - boxed_run(ports.clone(), s) - }))) + .send(SchedulerCommand::Run(Arc::new(move |s| boxed_run(ports.clone(), s)))) .unwrap(); Ok(()) } else { @@ -163,26 +155,16 @@ impl NetBricksContext { /// Pause all schedulers, the returned `BarrierHandle` can be used to resume. pub fn barrier(&mut self) -> BarrierHandle { // TODO: If this becomes a problem, move this to the struct itself; but make sure to fix `stop` appropriately. - let channels: Vec<_> = self.scheduler_handles - .iter() - .map(|_| sync_channel(0)) - .collect(); + let channels: Vec<_> = self.scheduler_handles.iter().map(|_| sync_channel(0)).collect(); let receivers = channels.iter().map(|&(_, ref r)| r); let senders = channels.iter().map(|&(ref s, _)| s); for ((_, channel), sender) in self.scheduler_channels.iter().zip(senders) { - channel - .send(SchedulerCommand::Handshake(sender.clone())) - .unwrap(); + channel.send(SchedulerCommand::Handshake(sender.clone())).unwrap(); } for receiver in receivers { receiver.recv().unwrap(); } - BarrierHandle::with_threads( - self.scheduler_handles - .values() - .map(|j| j.thread()) - .collect(), - ) + BarrierHandle::with_threads(self.scheduler_handles.values().map(|j| j.thread()).collect()) } /// Stop all schedulers, safely shutting down the system. @@ -257,10 +239,7 @@ pub fn initialize_system(configuration: &NetbricksConfiguration) -> Result = ctx.rx_queues.keys().cloned().collect(); - let core_diff: Vec<_> = other_cores - .difference(&cores) - .map(|c| c.to_string()) - .collect(); + let core_diff: Vec<_> = other_cores.difference(&cores).map(|c| c.to_string()).collect(); if !core_diff.is_empty() { let missing_str = core_diff.join(", "); return Err(ErrorKind::ConfigurationError(format!( diff --git a/framework/src/scheduler/mod.rs b/framework/src/scheduler/mod.rs index ebab8f5e56..3517645815 100644 --- a/framework/src/scheduler/mod.rs +++ b/framework/src/scheduler/mod.rs @@ -5,8 +5,8 @@ pub use self::context::*; pub use self::standalone_scheduler::*; use common::*; -mod standalone_scheduler; pub mod embedded_scheduler; +mod standalone_scheduler; mod context; diff --git a/framework/src/shared_state/directory.rs b/framework/src/shared_state/directory.rs index 92ff81e971..d7335969b3 100644 --- a/framework/src/shared_state/directory.rs +++ b/framework/src/shared_state/directory.rs @@ -81,9 +81,7 @@ impl Directory { pub fn end_snapshot(&mut self) { unsafe { let version = (*self.head).current_version.load(Ordering::Acquire); - (*self.head) - .committed_version - .store(version, Ordering::Release); + (*self.head).committed_version.store(version, Ordering::Release); } } } diff --git a/framework/src/shared_state/mod.rs b/framework/src/shared_state/mod.rs index 82c792bd9c..4b406c3214 100644 --- a/framework/src/shared_state/mod.rs +++ b/framework/src/shared_state/mod.rs @@ -30,20 +30,12 @@ unsafe fn open_shared(name: &str, size: usize) -> SharedMemory { // Make sure size is page aligned assert!(size & !PAGE_SIZE == 0); let name = CString::new(name).unwrap(); - let mut fd = shm_open( - name.as_ptr(), - libc::O_CREAT | libc::O_EXCL | libc::O_RDWR, - 0o700, - ); + let mut fd = shm_open(name.as_ptr(), libc::O_CREAT | libc::O_EXCL | libc::O_RDWR, 0o700); if fd == -1 { if let Some(e) = Error::last_os_error().raw_os_error() { if e == libc::EEXIST { shm_unlink(name.as_ptr()); - fd = shm_open( - name.as_ptr(), - libc::O_CREAT | libc::O_EXCL | libc::O_RDWR, - 0o700, - ); + fd = shm_open(name.as_ptr(), libc::O_CREAT | libc::O_EXCL | libc::O_RDWR, 0o700); } } }; diff --git a/framework/src/state/cp_mergeable.rs b/framework/src/state/cp_mergeable.rs index a8701b79e0..3ed81d85c9 100644 --- a/framework/src/state/cp_mergeable.rs +++ b/framework/src/state/cp_mergeable.rs @@ -42,10 +42,7 @@ impl + Default + Clone> CpMergeableStoreDataPath { self.updates += 1; if self.updates >= self.delay { self.updates = 0; - if self.channel - .try_send(self.cache.drain(0..).collect()) - .is_ok() - { + if self.channel.try_send(self.cache.drain(0..).collect()).is_ok() { () } } @@ -55,9 +52,7 @@ impl + Default + Clone> CpMergeableStoreDataPath { impl + Default + Clone> CpMergeableStoreControlPlane { fn update_internal(&mut self, v: Vec<(Flow, T)>) { for (flow, c) in v { - *(self.flow_counters - .entry(flow) - .or_insert_with(Default::default)) += c; + *(self.flow_counters.entry(flow).or_insert_with(Default::default)) += c; } } @@ -91,9 +86,7 @@ impl + Default + Clone> CpMergeableStoreControlPlane { /// Remove an entry from the table. #[inline] pub fn remove(&mut self, flow: &Flow) -> T { - self.flow_counters - .remove(flow) - .unwrap_or_else(Default::default) + self.flow_counters.remove(flow).unwrap_or_else(Default::default) } } @@ -102,10 +95,7 @@ impl + Default + Clone> CpMergeableStoreControlPlane { pub fn new_cp_mergeable_store + Default + Clone>( delay: usize, channel_size: usize, -) -> ( - CpMergeableStoreDataPath, - Box>, -) { +) -> (CpMergeableStoreDataPath, Box>) { let (sender, receiver) = sync_channel(channel_size); ( CpMergeableStoreDataPath { diff --git a/framework/src/state/mergeable.rs b/framework/src/state/mergeable.rs index a9c3596eef..7c6f3214f9 100644 --- a/framework/src/state/mergeable.rs +++ b/framework/src/state/mergeable.rs @@ -38,10 +38,7 @@ impl + Default + Clone> MergeableStoreCP { } pub fn dp_store_with_cache_and_size(&mut self, cache: usize, size: usize) -> MergeableStoreDP { - let hmap = Arc::new(RwLock::new(HashMap::with_capacity_and_hasher( - size, - Default::default(), - ))); + let hmap = Arc::new(RwLock::new(HashMap::with_capacity_and_hasher(size, Default::default()))); self.hashmaps.push(hmap.clone()); MergeableStoreDP { flow_counters: hmap, diff --git a/framework/src/state/mod.rs b/framework/src/state/mod.rs index 1d96fc1239..bc57992f0d 100644 --- a/framework/src/state/mod.rs +++ b/framework/src/state/mod.rs @@ -3,8 +3,8 @@ pub use self::dp_mergeable::*; pub use self::mergeable::*; pub use self::reordered_buffer::*; pub use self::ring_buffer::*; -mod dp_mergeable; mod cp_mergeable; +mod dp_mergeable; mod mergeable; -mod ring_buffer; pub mod reordered_buffer; +mod ring_buffer; diff --git a/framework/src/state/reordered_buffer/reordered_buffer.rs b/framework/src/state/reordered_buffer/reordered_buffer.rs index 691476d533..65caeff66b 100644 --- a/framework/src/state/reordered_buffer/reordered_buffer.rs +++ b/framework/src/state/reordered_buffer/reordered_buffer.rs @@ -53,9 +53,7 @@ impl SegmentList { /// Create a segement list expecting that we will need no more than `length` segments. pub fn new(length: usize) -> SegmentList { SegmentList { - storage: (0..(length as isize)) - .map(|i| Segment::new(i, 0, 0)) - .collect(), + storage: (0..(length as isize)).map(|i| Segment::new(i, 0, 0)).collect(), available: (0..(length as isize)).collect(), head: -1, tail: -1, @@ -463,9 +461,7 @@ impl ReorderedBuffer { self.tail_seq = self.tail_seq.wrapping_add(written as u32); { // Insert into segment list. - let segment = self.segment_list - .insert_segment(seq, written as u16) - .unwrap(); + let segment = self.segment_list.insert_segment(seq, written as u16).unwrap(); // Since we are writing to the beginning, this must always be the head. assert!(self.segment_list.is_head(segment)); // Compute the end of the segment, this might in fact be larger than size diff --git a/framework/src/utils/flow.rs b/framework/src/utils/flow.rs index e8bb0b4219..94af0c0689 100644 --- a/framework/src/utils/flow.rs +++ b/framework/src/utils/flow.rs @@ -79,10 +79,7 @@ impl Flow { BigEndian::write_u32(&mut bytes[12..16], self.src_ip); BigEndian::write_u32(&mut bytes[16..20], self.dst_ip); BigEndian::write_u16(&mut bytes[(port_start)..(port_start + 2)], self.src_port); - BigEndian::write_u16( - &mut bytes[(port_start + 2)..(port_start + 4)], - self.dst_port, - ); + BigEndian::write_u16(&mut bytes[(port_start + 2)..(port_start + 4)], self.dst_port); BigEndian::write_u16(&mut bytes[10..12], 0); let csum = ipcsum(bytes); BigEndian::write_u16(&mut bytes[10..12], csum); diff --git a/framework/src/utils/mod.rs b/framework/src/utils/mod.rs index e0a44dbd4a..a92d13a8c3 100644 --- a/framework/src/utils/mod.rs +++ b/framework/src/utils/mod.rs @@ -1,7 +1,7 @@ pub use self::asm::*; pub use self::flow::*; -mod flow; mod asm; +mod flow; pub const PAGE_SIZE: usize = 4096; // Page size in bytes, not using huge pages here. diff --git a/framework/tests/tcp_window.rs b/framework/tests/tcp_window.rs index 02c8a2fe31..b324624c58 100644 --- a/framework/tests/tcp_window.rs +++ b/framework/tests/tcp_window.rs @@ -12,11 +12,7 @@ fn round_pages_test() { 4096, "Rounding up 1 byte did not result in PAGE_SIZE" ); - assert_eq!( - round_to_pages(0), - 0, - "Rounding up 0 bytes did not result in 0" - ); + assert_eq!(round_to_pages(0), 0, "Rounding up 0 bytes did not result in 0"); assert_eq!( round_to_pages(8), 4096, @@ -46,36 +42,12 @@ fn round_pages_test() { /// Test rounding up to power of 2. #[test] fn round_to_power_of_2_test() { - assert_eq!( - round_to_power_of_2(0), - 0, - "Rounding to power of 2 failed, expected 0" - ); - assert_eq!( - round_to_power_of_2(1), - 1, - "Rounding to power of 2 failed, expected 1" - ); - assert_eq!( - round_to_power_of_2(2), - 2, - "Rounding to power of 2 failed, expected 2" - ); - assert_eq!( - round_to_power_of_2(3), - 4, - "Rounding to power of 2 failed, expected 4" - ); - assert_eq!( - round_to_power_of_2(4), - 4, - "Rounding to power of 2 failed, expected 4" - ); - assert_eq!( - round_to_power_of_2(5), - 8, - "Rounding to power of 2 failed, expected 8" - ); + assert_eq!(round_to_power_of_2(0), 0, "Rounding to power of 2 failed, expected 0"); + assert_eq!(round_to_power_of_2(1), 1, "Rounding to power of 2 failed, expected 1"); + assert_eq!(round_to_power_of_2(2), 2, "Rounding to power of 2 failed, expected 2"); + assert_eq!(round_to_power_of_2(3), 4, "Rounding to power of 2 failed, expected 4"); + assert_eq!(round_to_power_of_2(4), 4, "Rounding to power of 2 failed, expected 4"); + assert_eq!(round_to_power_of_2(5), 8, "Rounding to power of 2 failed, expected 8"); } /// Test that creation proceeds without a hitch. @@ -202,11 +174,7 @@ fn test_out_of_order_insertion() { let mut read_buffer: Vec<_> = (0..read_buf_len).map(|_| 0).collect(); let read = ro.read_data(&mut read_buffer[..]); assert_eq!(read, read_buf_len, "Read less than what is available"); - assert_eq!( - ro.available(), - 0, - "Read everything but data is still available" - ); + assert_eq!(ro.available(), 0, "Read everything but data is still available"); let read = str::from_utf8(&read_buffer[..read]).unwrap(); assert_eq!( read, @@ -282,10 +250,7 @@ fn test_state_change() { data3.as_bytes(), ) { assert_eq!(written, data3.len()); - assert_eq!( - available, - data0.len() + data1.len() + data2.len() + data3.len() - ); + assert_eq!(available, data0.len() + data1.len() + data2.len() + data3.len()); } else { panic!("Writing data3 failed"); } @@ -293,11 +258,7 @@ fn test_state_change() { let mut read_buffer: Vec<_> = (0..read_buf_len).map(|_| 0).collect(); let read = ro.read_data(&mut read_buffer[..]); assert_eq!(read, read_buf_len, "Read less than what is available"); - assert_eq!( - ro.available(), - 0, - "Read everything but data is still available" - ); + assert_eq!(ro.available(), 0, "Read everything but data is still available"); let read = str::from_utf8(&read_buffer[..read]).unwrap(); assert_eq!( read, diff --git a/native/include/dpdk.h b/native/include/dpdk.h index 6c9201b02a..8d93940b74 100644 --- a/native/include/dpdk.h +++ b/native/include/dpdk.h @@ -1,9 +1,5 @@ #ifndef __DPDK_H__ #define __DPDK_H__ -/* Call this from the main thread on ZCSI to initialize things */ -int init_system(int core); - /* Called from all secondary threads on ZCSI */ int init_thread(int tid, int core); -#include "mempool.h" #endif diff --git a/native/init.c b/native/init.c index e405989671..31a845eb13 100644 --- a/native/init.c +++ b/native/init.c @@ -12,187 +12,6 @@ #include #include "mempool.h" -#define NUM_PFRAMES (2048 - 1) // Number of pframes in the mempool -#define MEMPOOL_SIZE 1024 // Default mempool size -#define CACHE_SIZE 32 // Size of per-core mempool cache - -#define MAX_ARGS 128 - -static inline void bind_to_domain(int socket_id) { - struct bitmask* numa_bitmask = numa_bitmask_setbit( - numa_bitmask_clearall(numa_bitmask_alloc(numa_num_possible_nodes())), socket_id); - numa_bind(numa_bitmask); -} - -/* Taken from SoftNIC (dpdk.c) */ -/* Get NUMA count */ -static int get_numa_count() { - FILE* fp; - - int matched; - int cnt; - - fp = fopen("/sys/devices/system/node/possible", "r"); - if (!fp) - goto fail; - - matched = fscanf(fp, "0-%d", &cnt); - if (matched == 1) - return cnt + 1; - -fail: - if (fp) - fclose(fp); - - fprintf(stderr, - "Failed to detect # of NUMA nodes from: " - "/sys/devices/system/node/possible. " - "Assuming a single-node system...\n"); - return 1; -} - -static void add_arg(int* rte_argc, char** rte_argv, char* s) { - if (*rte_argc >= MAX_ARGS) { - fprintf(stderr, "init_eal exceeded max number of args!"); - return; - } - rte_argv[(*rte_argc)++] = s; -} - -static int init_eal(char* name, int secondary, int core, int mempool_size, char* whitelist[], - int wl_count, char* vdevs[], int vdev_count) { - /* As opposed to SoftNIC, this call only initializes the master thread. - * We cannot rely on threads launched by DPDK within ZCSI, the threads - * must be launched by the runtime */ - int rte_argc = 0; - - char* rte_argv[MAX_ARGS]; - - char opt_master_lcore[1024]; - char opt_lcore_bitmap[1024]; - char opt_socket_mem[1024]; - - int numa_count = get_numa_count(); - int socket_id = 0; - - int ret; - int i; - int tid = core; - - if (core > RTE_MAX_LCORE || tid > RTE_MAX_LCORE) { - return -1; - } - - sprintf(opt_master_lcore, "%d", tid); - - /* We need to tell rte_eal_init that it should use all possible lcores. - * If not, it does an insane thing and 0s out the cpusets for any unused - * physical cores and will not work when new threads are allocated. We - * could hack around this another way, but this seems more reasonable.*/ - sprintf(opt_lcore_bitmap, "0x%x", (1u << core)); - - sprintf(opt_socket_mem, "%d", mempool_size); - for (i = 1; i < numa_count; i++) - sprintf(opt_socket_mem + strlen(opt_socket_mem), ",%d", mempool_size); - - add_arg(&rte_argc, rte_argv, "lzcsi"); - if (secondary) { - add_arg(&rte_argc, rte_argv, "--proc-type"); - add_arg(&rte_argc, rte_argv, "secondary"); - } - add_arg(&rte_argc, rte_argv, "--file-prefix"); - add_arg(&rte_argc, rte_argv, name); - add_arg(&rte_argc, rte_argv, "-c"); - add_arg(&rte_argc, rte_argv, opt_lcore_bitmap); - - for (int i = 0; i < wl_count; i++) { - add_arg(&rte_argc, rte_argv, "-w"); - add_arg(&rte_argc, rte_argv, whitelist[i]); - } - for (int i = 0; i < vdev_count; i++) { - add_arg(&rte_argc, rte_argv, "--vdev"); - add_arg(&rte_argc, rte_argv, vdevs[i]); - } - - /* This just makes sure that by default everything is blacklisted */ - add_arg(&rte_argc, rte_argv, "-w"); - add_arg(&rte_argc, rte_argv, "99:99.0"); - - add_arg(&rte_argc, rte_argv, "--master-lcore"); - add_arg(&rte_argc, rte_argv, opt_master_lcore); - - add_arg(&rte_argc, rte_argv, "-n"); - /* number of memory channels (Sandy Bridge) */ - add_arg(&rte_argc, rte_argv, "4"); // Number of memory channels on - // Sandy Bridge. - add_arg(&rte_argc, rte_argv, "--socket-mem"); - add_arg(&rte_argc, rte_argv, opt_socket_mem); - rte_argv[rte_argc] = NULL; - - /* reset getopt() */ - optind = 0; - - /* rte_eal_init: Initializes EAL */ - ret = rte_eal_init(rte_argc, rte_argv); - if (secondary && rte_eal_process_type() != RTE_PROC_SECONDARY) { - rte_panic("Not a secondary process"); - } - - /* Change lcore ID */ - RTE_PER_LCORE(_lcore_id) = tid; - RTE_PER_LCORE(_mempool_core) = core; - socket_id = rte_lcore_to_socket_id(core); - if (numa_available() != -1) { - bind_to_domain(socket_id); - } - - return ret; -} - -static void init_timer() { - rte_timer_subsystem_init(); -} - -#define MAX_NAME_LEN 256 -int init_secondary(const char* name, int nlen, int core, char* vdevs[], int vdev_count) { - int ret = 0; - char clean_name[MAX_NAME_LEN]; - if (name == NULL || nlen >= MAX_NAME_LEN) { - return -EINVAL; - } - strncpy(clean_name, name, nlen); - clean_name[nlen] = '\0'; - - init_timer(); - if ((ret = init_eal(clean_name, 1, core, MEMPOOL_SIZE, NULL, 0, vdevs, vdev_count)) < 0) { - return ret; - } - return find_secondary_mempool(); -} - -int init_system_whitelisted(const char* name, int nlen, int core, char* whitelist[], int wlcount, - unsigned int mempool_size, unsigned int mcache_size, int slots) { - int ret = 0; - if (name == NULL || nlen >= MAX_NAME_LEN) { - return -EINVAL; - } - char clean_name[MAX_NAME_LEN]; - strncpy(clean_name, name, nlen); - clean_name[nlen] = '\0'; - - init_timer(); - if ((ret = init_eal(clean_name, 0, core, mempool_size, whitelist, wlcount, NULL, 0)) < 0) { - return ret; - } - return init_mempool(core, mempool_size, mcache_size, slots); -} - -/* Call this from the main thread on ZCSI to initialize things. This initializes - * the master thread. */ -int init_system(char* name, int nlen, int core, int slots) { - return init_system_whitelisted(name, nlen, core, NULL, 0, NUM_PFRAMES, CACHE_SIZE, slots); -} - /* Declared within eal_thread.c, but not exposed */ RTE_DECLARE_PER_LCORE(unsigned, _socket_id); @@ -200,19 +19,8 @@ RTE_DECLARE_PER_LCORE(unsigned, _socket_id); * etc.*/ int init_thread(int tid, int core) { /* Among other things this affinitizes the thread */ - rte_cpuset_t cpuset; - int socket_id = rte_lcore_to_socket_id(core); - int numa_active = numa_available(); - CPU_ZERO(&cpuset); - CPU_SET(core, &cpuset); - rte_thread_set_affinity(&cpuset); - if (numa_active != -1) { - bind_to_domain(socket_id); - } - init_mempool_core(core); - /* Set thread ID correctly */ RTE_PER_LCORE(_lcore_id) = tid; RTE_PER_LCORE(_mempool_core) = core; - return numa_active == -1 ? numa_active : socket_id; + return 1; } diff --git a/scripts/bind-xl710.sh b/scripts/bind-xl710.sh index b53a17031c..142da952d9 100755 --- a/scripts/bind-xl710.sh +++ b/scripts/bind-xl710.sh @@ -1,11 +1,10 @@ #!/bin/bash -export LD_LIBRARY_PATH=/opt/e2d2/e2d2/3rdparty/dpdk/build/lib BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)" DPDK_HOME=$BASE_DIR/../3rdparty/dpdk modprobe uio insmod $DPDK_HOME/build/kmod/igb_uio.ko -$DPDK_HOME/tools/dpdk-devbind.py --status \ +$DPDK_HOME/usertools/dpdk-devbind.py --status \ | grep XL710 \ | awk '{print $1}' \ | xargs \ - $DPDK_HOME/tools/dpdk-devbind.py -b igb_uio + $DPDK_HOME/usertools/dpdk-devbind.py -b igb_uio diff --git a/test/chain-test/src/main.rs b/test/chain-test/src/main.rs index 6225c36b09..2344f73a00 100644 --- a/test/chain-test/src/main.rs +++ b/test/chain-test/src/main.rs @@ -26,10 +26,7 @@ where { println!("Receiving started"); for port in &ports { - println!( - "Receiving port {} on chain len {} pos {}", - port, chain_len, chain_pos - ); + println!("Receiving port {} on chain len {} pos {}", port, chain_len, chain_pos); } let pipelines: Vec<_> = ports @@ -45,12 +42,7 @@ where fn main() { let mut opts = basic_opts(); opts.optopt("l", "chain", "Chain length", "length"); - opts.optopt( - "j", - "position", - "Chain position (when externally chained)", - "position", - ); + opts.optopt("j", "position", "Chain position (when externally chained)", "position"); let args: Vec = env::args().collect(); let matches = match opts.parse(&args[1..]) { Ok(m) => m, diff --git a/test/delay-test/src/main.rs b/test/delay-test/src/main.rs index 15e05b5eaa..9a82feedef 100644 --- a/test/delay-test/src/main.rs +++ b/test/delay-test/src/main.rs @@ -65,13 +65,9 @@ fn main() { let delay: u64 = delay_arg; if phy_ports { - context.add_pipeline_to_run(Arc::new(move |p, s: &mut StandaloneScheduler| { - test(p, s, delay) - })); + context.add_pipeline_to_run(Arc::new(move |p, s: &mut StandaloneScheduler| test(p, s, delay))); } else { - context.add_test_pipeline(Arc::new(move |p, s: &mut StandaloneScheduler| { - test(p, s, delay) - })); + context.add_test_pipeline(Arc::new(move |p, s: &mut StandaloneScheduler| test(p, s, delay))); } context.execute(); diff --git a/test/framework-test/src/main.rs b/test/framework-test/src/main.rs index 04a13a1816..3b5f26c065 100644 --- a/test/framework-test/src/main.rs +++ b/test/framework-test/src/main.rs @@ -6,8 +6,8 @@ extern crate time; use e2d2::allocators::*; use e2d2::common::*; use e2d2::headers::*; -use e2d2::interface::*; use e2d2::interface::dpdk::*; +use e2d2::interface::*; use e2d2::operators::*; use e2d2::scheduler::Executable; use e2d2::state::*; @@ -66,7 +66,6 @@ fn main() { let program = args[0].clone(); let mut opts = Options::new(); opts.optflag("h", "help", "print this help menu"); - opts.optflag("", "secondary", "run as a secondary process"); opts.optopt("n", "name", "name to use for the current process", "name"); opts.optmulti("p", "port", "Port to use", "[type:]id"); opts.optmulti("c", "core", "Core to use", "core"); @@ -91,34 +90,20 @@ fn main() { let cores: Vec = cores_str .iter() - .map(|n: &String| { - n.parse() - .ok() - .expect(&format!("Core cannot be parsed {}", n)) - }) + .map(|n: &String| n.parse().ok().expect(&format!("Core cannot be parsed {}", n))) .collect(); fn extract_cores_for_port(ports: &[String], cores: &[i32]) -> HashMap> { let mut cores_for_port = HashMap::>::new(); for (port, core) in ports.iter().zip(cores.iter()) { - cores_for_port - .entry(port.clone()) - .or_insert(vec![]) - .push(*core) + cores_for_port.entry(port.clone()).or_insert(vec![]).push(*core) } cores_for_port } - let primary = !matches.opt_present("secondary"); - let cores_for_port = extract_cores_for_port(&matches.opt_strs("p"), &cores); - if primary { - init_system_wl(&name, master_core, &[]); - } else { - init_system_secondary(&name, master_core); - } - + init_system_wl(&name, master_core, &[]); let ports_to_activate: Vec<_> = cores_for_port.keys().collect(); let mut queues_by_core = HashMap::>::with_capacity(cores.len()); diff --git a/test/lpm-embedded/src/main.rs b/test/lpm-embedded/src/main.rs index d0751425d6..baa54ea33d 100644 --- a/test/lpm-embedded/src/main.rs +++ b/test/lpm-embedded/src/main.rs @@ -23,14 +23,8 @@ fn main() { Ok(_) => { let port = VirtualPort::new(1).unwrap(); let mut sched = embedded_scheduler::EmbeddedScheduler::new(); - let pipeline0 = lpm( - ReceiveBatch::new(port.new_virtual_queue(1).unwrap()), - &mut sched, - ); - let pipeline1 = lpm( - ReceiveBatch::new(port.new_virtual_queue(1).unwrap()), - &mut sched, - ); + let pipeline0 = lpm(ReceiveBatch::new(port.new_virtual_queue(1).unwrap()), &mut sched); + let pipeline1 = lpm(ReceiveBatch::new(port.new_virtual_queue(1).unwrap()), &mut sched); let task = sched.add_task(merge(vec![pipeline0, pipeline1])).unwrap(); println!("Dependencies for task {}", task); sched.display_dependencies(task); diff --git a/test/maglev/src/main.rs b/test/maglev/src/main.rs index 7ef5fb9f20..4442a91f61 100644 --- a/test/maglev/src/main.rs +++ b/test/maglev/src/main.rs @@ -29,13 +29,7 @@ where let pipelines: Vec<_> = ports .iter() - .map(|port| { - maglev( - ReceiveBatch::new(port.clone()), - sched, - &vec!["Larry", "Curly", "Moe"], - ).send(port.clone()) - }) + .map(|port| maglev(ReceiveBatch::new(port.clone()), sched, &vec!["Larry", "Curly", "Moe"]).send(port.clone())) .collect(); println!("Running {} pipelines", pipelines.len()); sched.add_task(merge(pipelines)).unwrap(); diff --git a/test/maglev/src/nf.rs b/test/maglev/src/nf.rs index 65adbf052c..b696f7ce0f 100644 --- a/test/maglev/src/nf.rs +++ b/test/maglev/src/nf.rs @@ -4,15 +4,14 @@ use e2d2::scheduler::*; use e2d2::utils::*; use fnv::FnvHasher; use std::collections::HashMap; -use std::hash::{BuildHasher, Hash, Hasher}; use std::hash::BuildHasherDefault; +use std::hash::{BuildHasher, Hash, Hasher}; use twox_hash::XxHash; type FnvHash = BuildHasherDefault; type XxHashFactory = BuildHasherDefault; struct Maglev { - // permutation: Box>>, lut: Box>, lut_size: usize, } @@ -89,6 +88,7 @@ pub fn maglev, S: Scheduler + Sized>( let ct = backends.len(); let lut = Maglev::new(backends, 65537); let mut cache = HashMap::::with_hasher(Default::default()); + let mut groups = parent .parse::() .transform(box move |pkt| { diff --git a/test/nat/src/main.rs b/test/nat/src/main.rs index 1cc195373a..4136e9b775 100644 --- a/test/nat/src/main.rs +++ b/test/nat/src/main.rs @@ -29,13 +29,7 @@ where let mut pipelines: Vec<_> = ports .iter() - .map(|port| { - nat( - ReceiveBatch::new(port.clone()), - sched, - &Ipv4Addr::new(10, 0, 0, 1), - ).send(port.clone()) - }) + .map(|port| nat(ReceiveBatch::new(port.clone()), sched, &Ipv4Addr::new(10, 0, 0, 1)).send(port.clone())) .collect(); println!("Running {} pipelines", pipelines.len()); if pipelines.len() > 1 { diff --git a/test/packet_generation/src/nf.rs b/test/packet_generation/src/nf.rs index e2cf5761ba..e00764c4f3 100644 --- a/test/packet_generation/src/nf.rs +++ b/test/packet_generation/src/nf.rs @@ -38,10 +38,7 @@ impl PacketCreator { #[inline] fn initialize_packet(&self, pkt: Packet) -> Packet { - pkt.push_header(&self.mac) - .unwrap() - .push_header(&self.ip) - .unwrap() + pkt.push_header(&self.mac).unwrap().push_header(&self.ip).unwrap() } #[inline] diff --git a/test/reset-parse/src/main.rs b/test/reset-parse/src/main.rs index 0bb1a5499f..6dd8c55e41 100644 --- a/test/reset-parse/src/main.rs +++ b/test/reset-parse/src/main.rs @@ -57,9 +57,7 @@ fn main() { match initialize_system(&configuration) { Ok(mut context) => { context.start_schedulers(); - context.add_pipeline_to_run(Arc::new(move |p, s: &mut StandaloneScheduler| { - test(p, s, delay_arg) - })); + context.add_pipeline_to_run(Arc::new(move |p, s: &mut StandaloneScheduler| test(p, s, delay_arg))); context.execute(); let mut pkts_so_far = (0, 0); diff --git a/test/sctp-test/control-test/src/control.rs b/test/sctp-test/control-test/src/control.rs index 52aae66003..aec04d72ee 100644 --- a/test/sctp-test/control-test/src/control.rs +++ b/test/sctp-test/control-test/src/control.rs @@ -1,7 +1,7 @@ use e2d2::control::tcp::*; -use std::net::*; -use std::io::Read; use nix::errno; +use std::io::Read; +use std::net::*; pub struct ControlListener { scheduler: TcpScheduler, @@ -13,7 +13,12 @@ impl TcpControlAgent for ControlListener { fn new(address: SocketAddr, stream: TcpStream, scheduler: TcpScheduler) -> ControlListener { println!("New connection from {}", address); scheduler.schedule_read(); - ControlListener { scheduler: scheduler, stream: stream, buffer: (0..14).map(|_| 0).collect(), read_till: 0 } + ControlListener { + scheduler: scheduler, + stream: stream, + buffer: (0..14).map(|_| 0).collect(), + read_till: 0, + } } fn handle_read_ready(&mut self) -> bool { @@ -22,7 +27,7 @@ impl TcpControlAgent for ControlListener { let read_till = self.read_till; let r = self.stream.read(&mut self.buffer[read_till..]); match r { - Ok(r) => { + Ok(r) => { if r > 0 { if read_till + r == 14 { //println!("Complete message"); @@ -30,7 +35,7 @@ impl TcpControlAgent for ControlListener { } }; r > 0 - }, + } Err(e) => { if let Some(e) = e.raw_os_error() { if errno::from_i32(e) != errno::Errno::EAGAIN { @@ -42,20 +47,19 @@ impl TcpControlAgent for ControlListener { schedule = false; } false - }, + } } - } { - } + } {} if schedule { self.scheduler.schedule_read(); }; schedule } - + fn handle_write_ready(&mut self) -> bool { panic!("No writes expected"); } - + fn handle_hup(&mut self) -> bool { println!("Hanging up"); false diff --git a/test/sctp-test/control-test/src/main.rs b/test/sctp-test/control-test/src/main.rs index ef8e0bf57f..f747f98fe5 100644 --- a/test/sctp-test/control-test/src/main.rs +++ b/test/sctp-test/control-test/src/main.rs @@ -2,10 +2,13 @@ #![feature(asm)] extern crate e2d2; extern crate fnv; -extern crate time; extern crate getopts; -extern crate rand; extern crate nix; +extern crate rand; +extern crate time; +use self::control::*; +use self::nf::*; +use e2d2::control::tcp::*; use e2d2::interface::*; use e2d2::interface::dpdk::*; use e2d2::operators::*; @@ -13,15 +16,12 @@ use e2d2::scheduler::*; use getopts::Options; use std::collections::HashMap; use std::env; -use std::time::Duration; -use std::thread; -use std::sync::Arc; -use self::nf::*; -use self::control::*; -use e2d2::control::tcp::*; use std::net::*; use std::process; -use std::str::{FromStr}; +use std::str::FromStr; +use std::sync::Arc; +use std::thread; +use std::time::Duration; mod nf; mod control; @@ -31,17 +31,20 @@ fn recv_thread(ports: Vec, core: i32, delay_arg: u64) { init_thread(core, core); println!("Receiving started"); for port in &ports { - println!("Receiving port {} rxq {} txq {} on core {} delay {}", - port.port.mac_address(), - port.rxq(), - port.txq(), - core, - delay_arg); + println!( + "Receiving port {} rxq {} txq {} on core {} delay {}", + port.port.mac_address(), + port.rxq(), + port.txq(), + core, + delay_arg + ); } - let pipelines: Vec<_> = ports.iter() - .map(|port| delay(ReceiveBatch::new(port.clone()), delay_arg).send(port.clone())) - .collect(); + let pipelines: Vec<_> = ports + .iter() + .map(|port| delay(ReceiveBatch::new(port.clone()), delay_arg).send(port.clone())) + .collect(); println!("Running {} pipelines", pipelines.len()); let mut sched = StandaloneScheduler::new(); for pipeline in pipelines { @@ -58,7 +61,6 @@ fn main() { let program = args[0].clone(); let mut opts = Options::new(); opts.optflag("h", "help", "print this help menu"); - opts.optflag("", "secondary", "run as a secondary process"); opts.optopt("n", "name", "name to use for the current process", "name"); opts.optmulti("p", "port", "Port to use", "[type:]id"); opts.optmulti("c", "core", "Core to use", "core"); @@ -73,41 +75,44 @@ fn main() { process::exit(0) } - let delay_arg = matches.opt_str("d") - .unwrap_or_else(|| String::from("100")) - .parse() - .expect("Could not parse delay"); + let delay_arg = matches + .opt_str("d") + .unwrap_or_else(|| String::from("100")) + .parse() + .expect("Could not parse delay"); let cores_str = matches.opt_strs("c"); - let master_core = matches.opt_str("m") - .unwrap_or_else(|| String::from("0")) - .parse() - .expect("Could not parse master core spec"); + let master_core = matches + .opt_str("m") + .unwrap_or_else(|| String::from("0")) + .parse() + .expect("Could not parse master core spec"); println!("Using master core {}", master_core); let name = matches.opt_str("n").unwrap_or_else(|| String::from("recv")); - let cores: Vec = cores_str.iter() - .map(|n: &String| n.parse().ok().expect(&format!("Core cannot be parsed {}", n))) - .collect(); - + let cores: Vec = cores_str + .iter() + .map(|n: &String| { + n.parse() + .ok() + .expect(&format!("Core cannot be parsed {}", n)) + }) + .collect(); fn extract_cores_for_port(ports: &[String], cores: &[i32]) -> HashMap> { let mut cores_for_port = HashMap::>::new(); for (port, core) in ports.iter().zip(cores.iter()) { - cores_for_port.entry(port.clone()).or_insert(vec![]).push(*core) + cores_for_port + .entry(port.clone()) + .or_insert(vec![]) + .push(*core) } cores_for_port } - let primary = !matches.opt_present("secondary"); - let cores_for_port = extract_cores_for_port(&matches.opt_strs("p"), &cores); - if primary { - init_system_wl(&name, master_core, &[]); - } else { - init_system_secondary(&name, master_core); - } + init_system_wl(&name, master_core, &[]); let ports_to_activate: Vec<_> = cores_for_port.keys().collect(); @@ -116,26 +121,28 @@ fn main() { for port in &ports_to_activate { let cores = cores_for_port.get(*port).unwrap(); let queues = cores.len() as i32; - let pmd_port = PmdPort::new_with_queues(*port, queues, queues, cores, cores) - .expect("Could not initialize port"); + let pmd_port = + PmdPort::new_with_queues(*port, queues, queues, cores, cores).expect("Could not initialize port"); for (idx, core) in cores.iter().enumerate() { let queue = idx as i32; - queues_by_core.entry(*core) - .or_insert(vec![]) - .push(PmdPort::new_queue_pair(&pmd_port, queue, queue).unwrap()); + queues_by_core + .entry(*core) + .or_insert(vec![]) + .push(PmdPort::new_queue_pair(&pmd_port, queue, queue).unwrap()); } ports.push(pmd_port); } const _BATCH: usize = 1 << 10; const _CHANNEL_SIZE: usize = 256; - let _thread: Vec<_> = queues_by_core.iter() - .map(|(core, ports)| { - let c = core.clone(); - let p: Vec<_> = ports.iter().map(|p| p.clone()).collect(); - std::thread::spawn(move || recv_thread(p, c, delay_arg)) - }) - .collect(); + let _thread: Vec<_> = queues_by_core + .iter() + .map(|(core, ports)| { + let c = core.clone(); + let p: Vec<_> = ports.iter().map(|p| p.clone()).collect(); + std::thread::spawn(move || recv_thread(p, c, delay_arg)) + }) + .collect(); let mut pkts_so_far = (0, 0); let mut last_printed = 0.; const MAX_PRINT_INTERVAL: f64 = 30.; @@ -160,10 +167,12 @@ fn main() { let pkts = (rx, tx); let rx_pkts = pkts.0 - pkts_so_far.0; if rx_pkts > 0 || now - last_printed > MAX_PRINT_INTERVAL { - println!("{:.2} OVERALL RX {:.2} TX {:.2}", - now - start, - rx_pkts as f64 / (now - start), - (pkts.1 - pkts_so_far.1) as f64 / (now - start)); + println!( + "{:.2} OVERALL RX {:.2} TX {:.2}", + now - start, + rx_pkts as f64 / (now - start), + (pkts.1 - pkts_so_far.1) as f64 / (now - start) + ); last_printed = now; start = now; pkts_so_far = pkts; diff --git a/test/sctp-test/control-test/src/nf.rs b/test/sctp-test/control-test/src/nf.rs index 44b3cd5ad0..5909608939 100644 --- a/test/sctp-test/control-test/src/nf.rs +++ b/test/sctp-test/control-test/src/nf.rs @@ -21,14 +21,14 @@ fn delay_loop(delay: u64) { } } -pub fn delay>(parent: T, - delay: u64) - -> TransformBatch> { - parent.parse::() - .transform(box move |pkt| { - assert!(pkt.refcnt() == 1); - let hdr = pkt.get_mut_header(); - hdr.swap_addresses(); - delay_loop(delay); - }) +pub fn delay>( + parent: T, + delay: u64, +) -> TransformBatch> { + parent.parse::().transform(box move |pkt| { + assert!(pkt.refcnt() == 1); + let hdr = pkt.get_mut_header(); + hdr.swap_addresses(); + delay_loop(delay); + }) } diff --git a/test/sctp-test/src/main.rs b/test/sctp-test/src/main.rs index ac0d240040..c2686d98da 100644 --- a/test/sctp-test/src/main.rs +++ b/test/sctp-test/src/main.rs @@ -22,8 +22,8 @@ use std::str::FromStr; use std::sync::Arc; use std::thread; use std::time::Duration; -mod nf; mod control; +mod nf; const CONVERSION_FACTOR: f64 = 1000000000.; @@ -66,9 +66,7 @@ fn main() { match initialize_system(&configuration) { Ok(mut context) => { context.start_schedulers(); - context.add_pipeline_to_run(Arc::new(move |p, s: &mut StandaloneScheduler| { - test(p, s, delay_arg) - })); + context.add_pipeline_to_run(Arc::new(move |p, s: &mut StandaloneScheduler| test(p, s, delay_arg))); context.execute(); let mut pkts_so_far = (0, 0); diff --git a/test/shutdown-test/src/main.rs b/test/shutdown-test/src/main.rs index a8d9be3fa7..c03da28087 100644 --- a/test/shutdown-test/src/main.rs +++ b/test/shutdown-test/src/main.rs @@ -63,9 +63,7 @@ fn main() { context.start_schedulers(); let delay: u64 = delay_arg; - context.add_pipeline_to_run(Arc::new(move |p, s: &mut StandaloneScheduler| { - test(p, s, delay) - })); + context.add_pipeline_to_run(Arc::new(move |p, s: &mut StandaloneScheduler| test(p, s, delay))); context.execute(); let mut pkts_so_far = (0, 0);