Browse Source

DPDK: upgrade to 17.11.2 LTS.

Changes:
1. This version is downloaded from
https://fast.dpdk.org/rel/dpdk-17.11.2.tar.xz.
2. Adapt the new interface `rte_ring_dequeue_burst`.
3. Change the type of `port_id` from uint8_t to uint16_t.
4. Just link libdpdk.a instead of the other libaries.
5. Install libnuma-dev first.
6. Update the documents.
dev
logwang 3 years ago
parent
commit
2bfe3f2e55
  1. 10
      README.md
  2. 8
      app/micro_thread/Makefile
  3. 9
      app/nginx-1.11.10/auto/make
  4. 11
      app/redis-3.2.8/src/Makefile
  5. 16
      doc/F-Stack_Development_Guide.md
  6. 31
      doc/F-Stack_Quick_Start_Guide.md
  7. 11
      doc/Launch_F-Stack_on_AWS_EC2_in_one_minute.md
  8. 3
      dpdk/.gitattributes
  9. 14
      dpdk/.gitignore
  10. 1
      dpdk/GNUmakefile
  11. 679
      dpdk/MAINTAINERS
  12. 14
      dpdk/app/Makefile
  13. 55
      dpdk/app/cmdline_test/Makefile
  14. 113
      dpdk/app/cmdline_test/cmdline_test.py
  15. 311
      dpdk/app/cmdline_test/cmdline_test_data.py
  16. 3
      dpdk/app/pdump/Makefile
  17. 15
      dpdk/app/pdump/main.c
  18. 3
      dpdk/app/proc_info/Makefile
  19. 371
      dpdk/app/proc_info/main.c
  20. 48
      dpdk/app/test-acl/Makefile
  21. 1121
      dpdk/app/test-acl/main.c
  22. 54
      dpdk/app/test-crypto-perf/Makefile
  23. 61
      dpdk/app/test-crypto-perf/cperf.h
  24. 651
      dpdk/app/test-crypto-perf/cperf_ops.c
  25. 65
      dpdk/app/test-crypto-perf/cperf_ops.h
  26. 140
      dpdk/app/test-crypto-perf/cperf_options.h
  27. 1138
      dpdk/app/test-crypto-perf/cperf_options_parsing.c
  28. 244
      dpdk/app/test-crypto-perf/cperf_test_common.c
  29. 52
      dpdk/app/test-crypto-perf/cperf_test_common.h
  30. 405
      dpdk/app/test-crypto-perf/cperf_test_latency.c
  31. 60
      dpdk/app/test-crypto-perf/cperf_test_latency.h
  32. 520
      dpdk/app/test-crypto-perf/cperf_test_pmd_cyclecount.c
  33. 61
      dpdk/app/test-crypto-perf/cperf_test_pmd_cyclecount.h
  34. 357
      dpdk/app/test-crypto-perf/cperf_test_throughput.c
  35. 61
      dpdk/app/test-crypto-perf/cperf_test_throughput.h
  36. 620
      dpdk/app/test-crypto-perf/cperf_test_vector_parsing.c
  37. 73
      dpdk/app/test-crypto-perf/cperf_test_vector_parsing.h
  38. 568
      dpdk/app/test-crypto-perf/cperf_test_vectors.c
  39. 114
      dpdk/app/test-crypto-perf/cperf_test_vectors.h
  40. 455
      dpdk/app/test-crypto-perf/cperf_test_verify.c
  41. 61
      dpdk/app/test-crypto-perf/cperf_test_verify.h
  42. 502
      dpdk/app/test-crypto-perf/data/aes_cbc_128_sha.data
  43. 504
      dpdk/app/test-crypto-perf/data/aes_cbc_192_sha.data
  44. 504
      dpdk/app/test-crypto-perf/data/aes_cbc_256_sha.data
  45. 615
      dpdk/app/test-crypto-perf/main.c
  46. 54
      dpdk/app/test-eventdev/Makefile
  47. 135
      dpdk/app/test-eventdev/evt_common.h
  48. 227
      dpdk/app/test-eventdev/evt_main.c
  49. 331
      dpdk/app/test-eventdev/evt_options.c
  50. 269
      dpdk/app/test-eventdev/evt_options.h
  51. 70
      dpdk/app/test-eventdev/evt_test.c
  52. 125
      dpdk/app/test-eventdev/evt_test.h
  53. 388
      dpdk/app/test-eventdev/parser.c
  54. 79
      dpdk/app/test-eventdev/parser.h
  55. 238
      dpdk/app/test-eventdev/test_order_atq.c
  56. 377
      dpdk/app/test-eventdev/test_order_common.c
  57. 153
      dpdk/app/test-eventdev/test_order_common.h
  58. 248
      dpdk/app/test-eventdev/test_order_queue.c
  59. 283
      dpdk/app/test-eventdev/test_perf_atq.c
  60. 454
      dpdk/app/test-eventdev/test_perf_common.c
  61. 170
      dpdk/app/test-eventdev/test_perf_common.h
  62. 294
      dpdk/app/test-eventdev/test_perf_queue.c
  63. 64
      dpdk/app/test-pipeline/Makefile
  64. 247
      dpdk/app/test-pipeline/config.c
  65. 280
      dpdk/app/test-pipeline/init.c
  66. 179
      dpdk/app/test-pipeline/main.c
  67. 142
      dpdk/app/test-pipeline/main.h
  68. 493
      dpdk/app/test-pipeline/pipeline_hash.c
  69. 184
      dpdk/app/test-pipeline/runtime.c
  70. 34
      dpdk/app/test-pmd/Makefile
  71. 6299
      dpdk/app/test-pmd/cmdline.c
  72. 2959
      dpdk/app/test-pmd/cmdline_flow.c
  73. 1018
      dpdk/app/test-pmd/cmdline_mtr.c
  74. 49
      dpdk/app/test-pmd/cmdline_mtr.h
  75. 2059
      dpdk/app/test-pmd/cmdline_tm.c
  76. 56
      dpdk/app/test-pmd/cmdline_tm.h
  77. 1241
      dpdk/app/test-pmd/config.c
  78. 280
      dpdk/app/test-pmd/csumonly.c
  79. 17
      dpdk/app/test-pmd/flowgen.c
  80. 6
      dpdk/app/test-pmd/icmpecho.c
  81. 27
      dpdk/app/test-pmd/ieee1588fwd.c
  82. 4
      dpdk/app/test-pmd/iofwd.c
  83. 6
      dpdk/app/test-pmd/macfwd.c
  84. 6
      dpdk/app/test-pmd/macswap.c
  85. 235
      dpdk/app/test-pmd/parameters.c
  86. 224
      dpdk/app/test-pmd/rxonly.c
  87. 760
      dpdk/app/test-pmd/testpmd.c
  88. 184
      dpdk/app/test-pmd/testpmd.h
  89. 865
      dpdk/app/test-pmd/tm.c
  90. 16
      dpdk/app/test-pmd/txonly.c
  91. 136
      dpdk/buildtools/auto-config-h.sh
  92. 0
      dpdk/buildtools/gen-build-mk.sh
  93. 0
      dpdk/buildtools/gen-config-h.sh
  94. 2
      dpdk/buildtools/pmdinfogen/Makefile
  95. 30
      dpdk/buildtools/pmdinfogen/pmdinfogen.c
  96. 11
      dpdk/buildtools/pmdinfogen/pmdinfogen.h
  97. 105
      dpdk/buildtools/relpath.sh
  98. 51
      dpdk/config/common_armv8a_linuxapp
  99. 333
      dpdk/config/common_base
  100. 7
      dpdk/config/common_linuxapp

10
README.md

@ -33,12 +33,16 @@ Currently, besides authorized DNS server of DNSPod, there are various products i
# clone F-Stack
mkdir /data/f-stack
git clone https://github.com/F-Stack/f-stack.git /data/f-stack
# install libnuma-dev
yum install numactl-devel # on Centos
#sudo apt-get install libnuma-dev # on Ubuntu
cd f-stack
# compile DPDK
cd dpdk/tools
cd dpdk/usertools
./dpdk-setup.sh # compile with x86_64-native-linuxapp-gcc
# Set hugepage
# single-node system
echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages

8
app/micro_thread/Makefile

@ -29,11 +29,9 @@ endif
DEBUG= -g
BINARY = libmt.a
FF_LIBS+= -L${FF_PATH}/lib -L${FF_DPDK}/lib -Wl,--whole-archive,-lfstack,--no-whole-archive
FF_LIBS+= -Wl,--whole-archive -lrte_pmd_vmxnet3_uio -lrte_pmd_i40e -lrte_pmd_ixgbe -lrte_pmd_e1000 -lrte_pmd_ring
FF_LIBS+= -Wl,--whole-archive -lrte_hash -lrte_kvargs -Wl,-lrte_mbuf -lethdev -lrte_eal -Wl,-lrte_mempool
FF_LIBS+= -lrte_ring -lrte_cmdline -lrte_cfgfile -lrte_kni -lrte_timer -Wl,-lrte_pmd_virtio
FF_LIBS+= -Wl,--no-whole-archive -lrt -lm -ldl -lcrypto -pthread
FF_LIBS+= -L${FF_PATH}/lib -Wl,--whole-archive,-lfstack,--no-whole-archive
FF_LIBS+= -L${FF_DPDK}/lib -Wl,--whole-archive,-ldpdk,--no-whole-archive
FF_LIBS+= -Wl,--no-whole-archive -lrt -lm -ldl -lcrypto -lpthread -lnuma
# Comment the following line if you are not using the gnu c compiler
#C_ARGS = -Wall -g -fPIC -D_DEBUG

9
app/nginx-1.11.10/auto/make

@ -28,12 +28,9 @@ if [ ! $FF_DPDK ]; then
echo "FF_DPDK environment variable not defined, default:$FF_DPDK"
fi
CORE_LIBS="$CORE_LIBS -L$FF_PATH/lib -L$FF_DPDK/lib -Wl,--whole-archive,-lfstack,--no-whole-archive"
CORE_LIBS="$CORE_LIBS -g -Wl,--no-as-needed -fvisibility=default -pthread -lm -lrt"
CORE_LIBS="$CORE_LIBS -Wl,--whole-archive -lrte_pmd_vmxnet3_uio -lrte_pmd_i40e -lrte_pmd_ixgbe -lrte_pmd_e1000 -lrte_pmd_ring"
CORE_LIBS="$CORE_LIBS -Wl,--whole-archive -lrte_hash -lrte_kvargs -Wl,-lrte_mbuf -lethdev -lrte_eal -Wl,-lrte_mempool"
CORE_LIBS="$CORE_LIBS -lrte_ring -lrte_cmdline -lrte_cfgfile -lrte_kni -lrte_timer -Wl,-lrte_pmd_virtio"
CORE_LIBS="$CORE_LIBS -Wl,--no-whole-archive -lrt -lm -ldl -lcrypto"
CORE_LIBS="$CORE_LIBS -L$FF_PATH/lib -Wl,--whole-archive,-lfstack,--no-whole-archive"
CORE_LIBS="$CORE_LIBS -L$FF_DPDK/lib -Wl,--whole-archive,-ldpdk,--no-whole-archive"
CORE_LIBS="$CORE_LIBS -Wl,--no-whole-archive -lrt -lm -ldl -lcrypto -lpthread -lnuma"
cat << END > $NGX_MAKEFILE

11
app/redis-3.2.8/src/Makefile

@ -16,7 +16,7 @@ ifeq ($(FF_PATH),)
$(error variable FF_PATH is not set)
endif
ifeq ($(FF_DPDK),)
$(error variable FF_DPDK is not set)
FF_DPDK= $(FF_PATH)/dpdk/x86_64-native-linuxapp-gcc
endif
release_hdr := $(shell sh -c './mkreleasehdr.sh')
@ -119,12 +119,9 @@ endif
FINAL_CFLAGS+= -DHAVE_FF_KQUEUE
FINAL_CFLAGS+= -I$(FF_PATH)/lib
FINAL_LIBS+= -L$(FF_PATH)/lib -L$(FF_DPDK)/lib -Wl,--whole-archive,-lfstack,--no-whole-archive
FINAL_LIBS+= -g -Wl,--no-as-needed -fvisibility=default -pthread -lm -lrt
FINAL_LIBS+= -Wl,--whole-archive -lrte_pmd_vmxnet3_uio -lrte_pmd_i40e -lrte_pmd_ixgbe -lrte_pmd_e1000 -lrte_pmd_ring
FINAL_LIBS+= -Wl,--whole-archive -lrte_hash -lrte_kvargs -Wl,-lrte_mbuf -lethdev -lrte_eal -Wl,-lrte_mempool
FINAL_LIBS+= -lrte_ring -lrte_cmdline -lrte_cfgfile -lrte_kni -lrte_timer -Wl,-lrte_pmd_virtio
FINAL_LIBS+= -Wl,--no-whole-archive -lrt -lm -ldl -lm -lcrypto
FINAL_LIBS+= -L${FF_PATH}/lib -Wl,--whole-archive,-lfstack,--no-whole-archive
FINAL_LIBS+= -L${FF_DPDK}/lib -Wl,--whole-archive,-ldpdk,--no-whole-archive
FINAL_LIBS+= -Wl,--no-whole-archive -lrt -lm -ldl -lcrypto -lpthread -lnuma
REDIS_CC=$(QUIET_CC)$(CC) $(FINAL_CFLAGS)
REDIS_LD=$(QUIET_LINK)$(CC) $(FINAL_LDFLAGS)

16
doc/F-Stack_Development_Guide.md

@ -1,15 +1,15 @@
# F-Stack Development Guide
With the rapid development of NIC, the poor performance of data packets processing with Linux kernel has become the bottleneck. However the rapid development of the Internet needs high performance of network processing, kernel bypass has caught more and more attention. There are various similar technologies appear, such as DPDK, NETMAP and PF_RING. The main idea of kernel bypass is that Linux is only used to deal with control flow, all data streams are processed in user space. Therefore kernel bypass can avoid performance bottlenecks caused by kernel packet copy, thread scheduling, system calls and interrupt. Further more, kernel bypass can achieve higher performance with multi optimizing methods. Within various techniques, DPDK has been widely used because of its more thorough isolation from kernel scheduling and active community support.
With the rapid development of Network Interface Cards the poor performance of data packet processing with the Linux kernel has become the bottleneck in modern network systems. Yet, the increasing demands of the Internet's growth demand a higher performant network processing solution. Kernel bypass has emerged to catch more and more attention. There are various similar technologies such as: DPDK, NETMAP and PF_RING. The main idea of kernel bypass is that Linux is only used to deal with control flow; all data streams are processed in user space. Therefore, kernel bypass can avoid performance bottlenecks caused by kernel packet copying, thread scheduling, system calls, and interrupts. Furthermore, kernel bypass can achieve higher performance with multi-optimizing methods. Within various techniques, DPDK has been widely used because of it's more thorough isolation from kernel scheduling and active community support.
F-Stack is an open source network framework with high performance based on DPDK. With follow characteristics
F-Stack is an open source high performant network framework based on DPDK with the following characteristics:
1. Ultra high network performance which can achieve network card under full load, 10 million concurrent, five million RPS, 1 million CPS.
2. Transplant FreeBSD 11.01 user space stack, provides a complete stack function, cut a great amount of irrelevant features. Therefore greatly enhance the performance.
3. Support Nginx, Redis and other mature applications, service can easily use F-Stack
4. With Multi-process architecture, easy to extend
5. Provide micro thread interface. Various applications with long time consuming can easily use F-Stack to get high performance without processing complex asynchronous logic.
6. Provide Epoll/kqueue interface that allow many kinds of applications easily use F-Stack
1. Ultra high network performance which the network card can achieve under full load: 10 million concurrent connections, 5 million RPS, 1 million CPS.
2. Transplant FreeBSD 11.01 user space stack, which provides a complete stack function, and cut a great amount of irrelevant features. This greatly enhances network performance.
3. Support Nginx, Redis, and other mature applications. Services can easily use F-Stack.
4. Easy to extend with multi-process architecture.
5. Provides micro thread interface. Various applications with stateful applications can easily use F-Stack to get high performance without processing complex asynchronous logic.
6. Provide an Epoll/Kqueue interface that allow many kinds of applications to easily use F-Stack.
## Structure of F-Stack code

31
doc/F-Stack_Quick_Start_Guide.md

@ -7,11 +7,18 @@
See Intel DPDK [linux_gsg](http://dpdk.org/doc/guides/linux_gsg/index.html)
## clone F-Stack
## Clone F-Stack
mkdir /data/f-stack
git clone https://github.com/F-Stack/f-stack.git /data/f-stack
## Install libnuma-dev
# on Centos
yum install numactl-devel
# on Ubuntu
sudo apt-get install libnuma-dev
## Compile DPDK
Read DPDK Quick Started Guide or run the command below
@ -43,20 +50,20 @@ The mount point can be made permanent across reboots, by adding the following li
## offload NIC
modprobe uio
insmod /data/f-stack/dpdk/x86_64-native-linuxapp-gcc/kmod/igb_uio.ko
insmod /data/f-stack/dpdk/x86_64-native-linuxapp-gcc/kmod/rte_kni.ko
python dpdk-devbind.py --status
ifconfig eth0 down
python dpdk-devbind.py --bind=igb_uio eth0 # assuming that use 10GE NIC and eth0
modprobe uio
insmod /data/f-stack/dpdk/x86_64-native-linuxapp-gcc/kmod/igb_uio.ko
insmod /data/f-stack/dpdk/x86_64-native-linuxapp-gcc/kmod/rte_kni.ko
python dpdk-devbind.py --status
ifconfig eth0 down
python dpdk-devbind.py --bind=igb_uio eth0 # assuming that use 10GE NIC and eth0
## Compile lib
export FF_PATH=/data/f-stack
export FF_DPDK=/data/f-stack/dpdk/x86_64-native-linuxapp-gcc
cd ../../
cd lib
make
export FF_PATH=/data/f-stack
export FF_DPDK=/data/f-stack/dpdk/x86_64-native-linuxapp-gcc
cd ../../
cd lib
make
### Compile Nginx

11
doc/Launch_F-Stack_on_AWS_EC2_in_one_minute.md

@ -3,8 +3,8 @@
If you have a Redhat7.3 EC2 instance,and then execute the following cmds, you will get the F-Stack server in one minute
sudo -i
yum install -y git gcc openssl-devel kernel-devel-$(uname -r) bc
yum install -y git gcc openssl-devel kernel-devel-$(uname -r) bc numactl-devel
mkdir /data/f-stack
git clone https://github.com/F-Stack/f-stack.git /data/f-stack
@ -17,7 +17,7 @@
echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
mkdir /mnt/huge
mount -t hugetlbfs nodev /mnt/huge
# close ASLR; it is necessary in multiple process
echo 0 > /proc/sys/kernel/randomize_va_space
@ -40,7 +40,7 @@
#export mybc=`ifconfig eth0 | grep "Bcast" | awk -F ' ' '{print $3}' | awk -F ':' '{print $2}'`
#export myhw=`ifconfig eth0 | grep "HWaddr" | awk -F ' ' '{print $5}'`
#export mygw=`route -n | grep 0.0.0.0 | grep eth0 | grep UG | awk -F ' ' '{print $2}'
sed "s/addr=192.168.1.2/addr=${myaddr}/" -i /data/f-stack/config.ini
sed "s/netmask=255.255.255.0/netmask=${mymask}/" -i /data/f-stack/config.ini
sed "s/broadcast=192.168.1.255/broadcast=${mybc}/" -i /data/f-stack/config.ini
@ -53,7 +53,6 @@
sed "s/#tcp_port=80/tcp_port=80/" -i /data/f-stack/config.ini
sed "s/#vlanstrip=1/vlanstrip=1/" -i /data/f-stack/config.ini
# Compile F-Stack lib
export FF_PATH=/data/f-stack
export FF_DPDK=/data/f-stack/dpdk/build
@ -68,7 +67,7 @@
# offload NIC(if there is only one NIC,the follow commands must run in a script)
ifconfig eth0 down
python /data/f-stack/dpdk/tools/dpdk-devbind.py --bind=igb_uio eth0
python /data/f-stack/dpdk/usertools/dpdk-devbind.py --bind=igb_uio eth0
# copy config.ini to $NGX_PREFIX/conf/f-stack.conf
cp /data/f-stack/config.ini /usr/local/nginx_fstack/conf/f-stack.conf

3
dpdk/.gitattributes

@ -0,0 +1,3 @@
*.c diff=cpp
*.h diff=cpp
*.py diff=python

14
dpdk/.gitignore

@ -0,0 +1,14 @@
doc/guides/nics/overview_table.txt
doc/guides/cryptodevs/overview_feature_table.txt
doc/guides/cryptodevs/overview_cipher_table.txt
doc/guides/cryptodevs/overview_auth_table.txt
doc/guides/cryptodevs/overview_aead_table.txt
cscope.out.po
cscope.out.in
cscope.out
cscope.files
GTAGS
GPATH
GRTAGS
tags
TAGS

1
dpdk/GNUmakefile

@ -41,5 +41,6 @@ export RTE_SDK
#
ROOTDIRS-y := buildtools lib drivers app
ROOTDIRS- := test
include $(RTE_SDK)/mk/rte.sdkroot.mk

679
dpdk/MAINTAINERS
File diff suppressed because it is too large
View File

14
dpdk/app/Makefile

@ -31,12 +31,16 @@
include $(RTE_SDK)/mk/rte.vars.mk
DIRS-$(CONFIG_RTE_APP_TEST) += test
DIRS-$(CONFIG_RTE_LIBRTE_ACL) += test-acl
DIRS-$(CONFIG_RTE_LIBRTE_PIPELINE) += test-pipeline
DIRS-$(CONFIG_RTE_TEST_PMD) += test-pmd
DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) += cmdline_test
DIRS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += proc_info
DIRS-$(CONFIG_RTE_PROC_INFO) += proc_info
DIRS-$(CONFIG_RTE_LIBRTE_PDUMP) += pdump
ifeq ($(CONFIG_RTE_LIBRTE_CRYPTODEV),y)
DIRS-$(CONFIG_RTE_APP_CRYPTO_PERF) += test-crypto-perf
endif
ifeq ($(CONFIG_RTE_LIBRTE_EVENTDEV),y)
DIRS-$(CONFIG_RTE_APP_EVENTDEV) += test-eventdev
endif
include $(RTE_SDK)/mk/rte.subdir.mk

55
dpdk/app/cmdline_test/Makefile

@ -1,55 +0,0 @@
# BSD LICENSE
#
# Copyright(c) 2010-2014 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 $(RTE_SDK)/mk/rte.vars.mk
ifeq ($(CONFIG_RTE_LIBRTE_CMDLINE),y)
#
# library name
#
APP = cmdline_test
#
# all sources are stored in SRCS-y
#
SRCS-y += cmdline_test.c
SRCS-y += commands.c
CFLAGS += -O3
CFLAGS += $(WERROR_FLAGS)
# this application needs libraries first
DEPDIRS-y += lib drivers
include $(RTE_SDK)/mk/rte.app.mk
endif

113
dpdk/app/cmdline_test/cmdline_test.py

@ -1,113 +0,0 @@
#!/usr/bin/python
# BSD LICENSE
#
# Copyright(c) 2010-2014 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.
# Script that runs cmdline_test app and feeds keystrokes into it.
import sys, pexpect, string, os, cmdline_test_data
#
# function to run test
#
def runTest(child,test):
child.send(test["Sequence"])
if test["Result"] == None:
return 0
child.expect(test["Result"],1)
#
# history test is a special case
#
# This test does the following:
# 1) fills the history with garbage up to its full capacity
# (just enough to remove last entry)
# 2) scrolls back history to the very beginning
# 3) checks if the output is as expected, that is, the first
# number in the sequence (not the last entry before it)
#
# This is a self-contained test, it needs only a pexpect child
#
def runHistoryTest(child):
# find out history size
child.sendline(cmdline_test_data.CMD_GET_BUFSIZE)
child.expect("History buffer size: \\d+", timeout=1)
history_size = int(child.after[len(cmdline_test_data.BUFSIZE_TEMPLATE):])
i = 0
# fill the history with numbers
while i < history_size / 10:
# add 1 to prevent from parsing as octals
child.send("1" + str(i).zfill(8) + cmdline_test_data.ENTER)
# the app will simply print out the number
child.expect(str(i + 100000000), timeout=1)
i += 1
# scroll back history
child.send(cmdline_test_data.UP * (i + 2) + cmdline_test_data.ENTER)
child.expect("100000000", timeout=1)
# the path to cmdline_test executable is supplied via command-line.
if len(sys.argv) < 2:
print "Error: please supply cmdline_test app path"
sys.exit(1)
test_app_path = sys.argv[1]
if not os.path.exists(test_app_path):
print "Error: please supply cmdline_test app path"
sys.exit(1)
child = pexpect.spawn(test_app_path)
print "Running command-line tests..."
for test in cmdline_test_data.tests:
print (test["Name"] + ":").ljust(30),
try:
runTest(child,test)
print "PASS"
except:
print "FAIL"
print child
sys.exit(1)
# since last test quits the app, run new instance
child = pexpect.spawn(test_app_path)
print ("History fill test:").ljust(30),
try:
runHistoryTest(child)
print "PASS"
except:
print "FAIL"
print child
sys.exit(1)
child.close()
sys.exit(0)

311
dpdk/app/cmdline_test/cmdline_test_data.py

@ -1,311 +0,0 @@
#!/usr/bin/python
# BSD LICENSE
#
# Copyright(c) 2010-2014 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.
# collection of static data
import sys
# keycode constants
CTRL_A = chr(1)
CTRL_B = chr(2)
CTRL_C = chr(3)
CTRL_D = chr(4)
CTRL_E = chr(5)
CTRL_F = chr(6)
CTRL_K = chr(11)
CTRL_L = chr(12)
CTRL_N = chr(14)
CTRL_P = chr(16)
CTRL_W = chr(23)
CTRL_Y = chr(25)
ALT_B = chr(27) + chr(98)
ALT_D = chr(27) + chr(100)
ALT_F = chr(27) + chr(102)
ALT_BKSPACE = chr(27) + chr(127)
DEL = chr(27) + chr(91) + chr(51) + chr(126)
TAB = chr(9)
HELP = chr(63)
BKSPACE = chr(127)
RIGHT = chr(27) + chr(91) + chr(67)
DOWN = chr(27) + chr(91) + chr(66)
LEFT = chr(27) + chr(91) + chr(68)
UP = chr(27) + chr(91) + chr(65)
ENTER2 = '\r'
ENTER = '\n'
# expected result constants
NOT_FOUND = "Command not found"
BAD_ARG = "Bad arguments"
AMBIG = "Ambiguous command"
CMD1 = "Command 1 parsed!"
CMD2 = "Command 2 parsed!"
SINGLE = "Single word command parsed!"
SINGLE_LONG = "Single long word command parsed!"
AUTO1 = "Autocomplete command 1 parsed!"
AUTO2 = "Autocomplete command 2 parsed!"
# misc defines
CMD_QUIT = "quit"
CMD_GET_BUFSIZE = "get_history_bufsize"
BUFSIZE_TEMPLATE = "History buffer size: "
PROMPT = "CMDLINE_TEST>>"
# test defines
# each test tests progressively diverse set of keys. this way for example
# if we want to use some key sequence in the test, we first need to test
# that it itself does what it is expected to do. Most of the tests are
# designed that way.
#
# example: "arrows & delete test 1". we enter a partially valid command,
# then move 3 chars left and use delete three times. this way we get to
# know that "delete", "left" and "ctrl+B" all work (because if any of
# them fails, the whole test will fail and next tests won't be run).
#
# each test consists of name, character sequence to send to child,
# and expected output (if any).
tests = [
# test basic commands
{"Name" : "command test 1",
"Sequence" : "ambiguous first" + ENTER,
"Result" : CMD1},
{"Name" : "command test 2",
"Sequence" : "ambiguous second" + ENTER,
"Result" : CMD2},
{"Name" : "command test 3",
"Sequence" : "ambiguous ambiguous" + ENTER,
"Result" : AMBIG},
{"Name" : "command test 4",
"Sequence" : "ambiguous ambiguous2" + ENTER,
"Result" : AMBIG},
{"Name" : "invalid command test 1",
"Sequence" : "ambiguous invalid" + ENTER,
"Result" : BAD_ARG},
# test invalid commands
{"Name" : "invalid command test 2",
"Sequence" : "invalid" + ENTER,
"Result" : NOT_FOUND},
{"Name" : "invalid command test 3",
"Sequence" : "ambiguousinvalid" + ENTER2,
"Result" : NOT_FOUND},
# test arrows and deletes
{"Name" : "arrows & delete test 1",
"Sequence" : "singlebad" + LEFT*2 + CTRL_B + DEL*3 + ENTER,
"Result" : SINGLE},
{"Name" : "arrows & delete test 2",
"Sequence" : "singlebad" + LEFT*5 + RIGHT + CTRL_F + DEL*3 + ENTER,
"Result" : SINGLE},
# test backspace
{"Name" : "backspace test",
"Sequence" : "singlebad" + BKSPACE*3 + ENTER,
"Result" : SINGLE},
# test goto left and goto right
{"Name" : "goto left test",
"Sequence" : "biguous first" + CTRL_A + "am" + ENTER,
"Result" : CMD1},
{"Name" : "goto right test",
"Sequence" : "biguous fir" + CTRL_A + "am" + CTRL_E + "st" + ENTER,
"Result" : CMD1},
# test goto words
{"Name" : "goto left word test",
"Sequence" : "ambiguous st" + ALT_B + "fir" + ENTER,
"Result" : CMD1},
{"Name" : "goto right word test",
"Sequence" : "ambig first" + CTRL_A + ALT_F + "uous" + ENTER,
"Result" : CMD1},
# test removing words
{"Name" : "remove left word 1",
"Sequence" : "single invalid" + CTRL_W + ENTER,
"Result" : SINGLE},
{"Name" : "remove left word 2",
"Sequence" : "single invalid" + ALT_BKSPACE + ENTER,
"Result" : SINGLE},
{"Name" : "remove right word",
"Sequence" : "single invalid" + ALT_B + ALT_D + ENTER,
"Result" : SINGLE},
# test kill buffer (copy and paste)
{"Name" : "killbuffer test 1",
"Sequence" : "ambiguous" + CTRL_A + CTRL_K + " first" + CTRL_A + CTRL_Y + ENTER,
"Result" : CMD1},
{"Name" : "killbuffer test 2",
"Sequence" : "ambiguous" + CTRL_A + CTRL_K + CTRL_Y*26 + ENTER,
"Result" : NOT_FOUND},
# test newline
{"Name" : "newline test",
"Sequence" : "invalid" + CTRL_C + "single" + ENTER,
"Result" : SINGLE},
# test redisplay (nothing should really happen)
{"Name" : "redisplay test",
"Sequence" : "single" + CTRL_L + ENTER,
"Result" : SINGLE},
# test autocomplete
{"Name" : "autocomplete test 1",
"Sequence" : "si" + TAB + ENTER,
"Result" : SINGLE},
{"Name" : "autocomplete test 2",
"Sequence" : "si" + TAB + "_" + TAB + ENTER,
"Result" : SINGLE_LONG},
{"Name" : "autocomplete test 3",
"Sequence" : "in" + TAB + ENTER,
"Result" : NOT_FOUND},
{"Name" : "autocomplete test 4",
"Sequence" : "am" + TAB + ENTER,
"Result" : BAD_ARG},
{"Name" : "autocomplete test 5",
"Sequence" : "am" + TAB + "fir" + TAB + ENTER,
"Result" : CMD1},
{"Name" : "autocomplete test 6",
"Sequence" : "am" + TAB + "fir" + TAB + TAB + ENTER,
"Result" : CMD1},
{"Name" : "autocomplete test 7",
"Sequence" : "am" + TAB + "fir" + TAB + " " + TAB + ENTER,
"Result" : CMD1},
{"Name" : "autocomplete test 8",
"Sequence" : "am" + TAB + " am" + TAB + " " + ENTER,
"Result" : AMBIG},
{"Name" : "autocomplete test 9",
"Sequence" : "am" + TAB + "inv" + TAB + ENTER,
"Result" : BAD_ARG},
{"Name" : "autocomplete test 10",
"Sequence" : "au" + TAB + ENTER,
"Result" : NOT_FOUND},
{"Name" : "autocomplete test 11",
"Sequence" : "au" + TAB + "1" + ENTER,
"Result" : AUTO1},
{"Name" : "autocomplete test 12",
"Sequence" : "au" + TAB + "2" + ENTER,
"Result" : AUTO2},
{"Name" : "autocomplete test 13",
"Sequence" : "au" + TAB + "2" + TAB + ENTER,
"Result" : AUTO2},
{"Name" : "autocomplete test 14",
"Sequence" : "au" + TAB + "2 " + TAB + ENTER,
"Result" : AUTO2},
{"Name" : "autocomplete test 15",
"Sequence" : "24" + TAB + ENTER,
"Result" : "24"},
# test history
{"Name" : "history test 1",
"Sequence" : "invalid" + ENTER + "single" + ENTER + "invalid" + ENTER + UP + CTRL_P + ENTER,
"Result" : SINGLE},
{"Name" : "history test 2",
"Sequence" : "invalid" + ENTER + "ambiguous first" + ENTER + "invalid" + ENTER + "single" + ENTER + UP * 3 + CTRL_N + DOWN + ENTER,
"Result" : SINGLE},
#
# tests that improve coverage
#
# empty space tests
{"Name" : "empty space test 1",
"Sequence" : RIGHT + LEFT + CTRL_B + CTRL_F + ENTER,
"Result" : PROMPT},
{"Name" : "empty space test 2",
"Sequence" : BKSPACE + ENTER,
"Result" : PROMPT},
{"Name" : "empty space test 3",
"Sequence" : CTRL_E*2 + CTRL_A*2 + ENTER,
"Result" : PROMPT},
{"Name" : "empty space test 4",
"Sequence" : ALT_F*2 + ALT_B*2 + ENTER,
"Result" : PROMPT},
{"Name" : "empty space test 5",
"Sequence" : " " + CTRL_E*2 + CTRL_A*2 + ENTER,
"Result" : PROMPT},
{"Name" : "empty space test 6",
"Sequence" : " " + CTRL_A + ALT_F*2 + ALT_B*2 + ENTER,
"Result" : PROMPT},
{"Name" : "empty space test 7",
"Sequence" : " " + CTRL_A + CTRL_D + CTRL_E + CTRL_D + ENTER,
"Result" : PROMPT},
{"Name" : "empty space test 8",
"Sequence" : " space" + CTRL_W*2 + ENTER,
"Result" : PROMPT},
{"Name" : "empty space test 9",
"Sequence" : " space" + ALT_BKSPACE*2 + ENTER,
"Result" : PROMPT},
{"Name" : "empty space test 10",
"Sequence" : " space " + CTRL_A + ALT_D*3 + ENTER,
"Result" : PROMPT},
# non-printable char tests
{"Name" : "non-printable test 1",
"Sequence" : chr(27) + chr(47) + ENTER,
"Result" : PROMPT},
{"Name" : "non-printable test 2",
"Sequence" : chr(27) + chr(128) + ENTER*7,
"Result" : PROMPT},
{"Name" : "non-printable test 3",
"Sequence" : chr(27) + chr(91) + chr(127) + ENTER*6,
"Result" : PROMPT},
# miscellaneous tests
{"Name" : "misc test 1",
"Sequence" : ENTER,
"Result" : PROMPT},
{"Name" : "misc test 2",
"Sequence" : "single #comment" + ENTER,
"Result" : SINGLE},
{"Name" : "misc test 3",
"Sequence" : "#empty line" + ENTER,
"Result" : PROMPT},
{"Name" : "misc test 4",
"Sequence" : " single " + ENTER,
"Result" : SINGLE},
{"Name" : "misc test 5",
"Sequence" : "single#" + ENTER,
"Result" : SINGLE},
{"Name" : "misc test 6",
"Sequence" : 'a' * 257 + ENTER,
"Result" : NOT_FOUND},
{"Name" : "misc test 7",
"Sequence" : "clear_history" + UP*5 + DOWN*5 + ENTER,
"Result" : PROMPT},
{"Name" : "misc test 8",
"Sequence" : "a" + HELP + CTRL_C,
"Result" : PROMPT},
{"Name" : "misc test 9",
"Sequence" : CTRL_D*3,
"Result" : None},
]

3
dpdk/app/pdump/Makefile

@ -41,9 +41,6 @@ CFLAGS += $(WERROR_FLAGS)
SRCS-y := main.c
# this application needs libraries first
DEPDIRS-y += lib
include $(RTE_SDK)/mk/rte.app.mk
endif

15
dpdk/app/pdump/main.c

@ -68,8 +68,8 @@
#define CMD_LINE_OPT_SER_SOCK_PATH "server-socket-path"
#define CMD_LINE_OPT_CLI_SOCK_PATH "client-socket-path"
#define VDEV_PCAP "eth_pcap_%s_%d,tx_pcap=%s"
#define VDEV_IFACE "eth_pcap_%s_%d,tx_iface=%s"
#define VDEV_PCAP "net_pcap_%s_%d,tx_pcap=%s"
#define VDEV_IFACE "net_pcap_%s_%d,tx_iface=%s"
#define TX_STREAM_SIZE 64
#define MP_NAME "pdump_pool_%d"
@ -92,7 +92,6 @@
#define BURST_SIZE 32
#define NUM_VDEVS 2
#define RTE_RING_SZ_MASK (unsigned)(0x0fffffff) /**< Ring size mask */
/* true if x is a power of 2 */
#define POWEROF2(x) ((((x)-1) & (x)) == 0)
@ -132,7 +131,7 @@ struct pdump_stats {
struct pdump_tuples {
/* cli params */
uint8_t port;
uint16_t port;
char *device_id;
uint16_t queue;
char rx_dev[TX_STREAM_SIZE];
@ -497,7 +496,7 @@ pdump_rxtx(struct rte_ring *ring, uint8_t vdev_id, struct pdump_stats *stats)
/* first dequeue packets from ring of primary process */
const uint16_t nb_in_deq = rte_ring_dequeue_burst(ring,
(void *)rxtx_bufs, BURST_SIZE);
(void *)rxtx_bufs, BURST_SIZE, NULL);
stats->dequeue_pkts += nb_in_deq;
if (nb_in_deq) {
@ -580,7 +579,7 @@ signal_handler(int sig_num)
}
static inline int
configure_vdev(uint8_t port_id)
configure_vdev(uint16_t port_id)
{
struct ether_addr addr;
const uint16_t rxRings = 0, txRings = 1;
@ -610,7 +609,7 @@ configure_vdev(uint8_t port_id)
rte_eth_macaddr_get(port_id, &addr);
printf("Port %u MAC: %02"PRIx8" %02"PRIx8" %02"PRIx8
" %02"PRIx8" %02"PRIx8" %02"PRIx8"\n",
(unsigned)port_id,
port_id,
addr.addr_bytes[0], addr.addr_bytes[1],
addr.addr_bytes[2], addr.addr_bytes[3],
addr.addr_bytes[4], addr.addr_bytes[5]);
@ -624,7 +623,7 @@ static void
create_mp_ring_vdev(void)
{
int i;
uint8_t portid;
uint16_t portid;
struct pdump_tuples *pt = NULL;
struct rte_mempool *mbuf_pool = NULL;
char vdev_args[SIZE];

3
dpdk/app/proc_info/Makefile

@ -39,7 +39,4 @@ CFLAGS += $(WERROR_FLAGS)
SRCS-y := main.c
# this application needs libraries first
DEPDIRS-y += lib
include $(RTE_SDK)/mk/rte.app.mk

371
dpdk/app/proc_info/main.c

@ -1,7 +1,7 @@
/*
* BSD LICENSE
*
* Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
* Copyright(c) 2010-2017 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -40,6 +40,7 @@
#include <sys/queue.h>
#include <stdlib.h>
#include <getopt.h>
#include <unistd.h>
#include <rte_eal.h>
#include <rte_common.h>
@ -52,28 +53,46 @@
#include <rte_tailq.h>
#include <rte_per_lcore.h>
#include <rte_lcore.h>
#include <rte_debug.h>
#include <rte_log.h>
#include <rte_atomic.h>
#include <rte_branch_prediction.h>
#include <rte_string_fns.h>
#include <rte_metrics.h>
/* Maximum long option length for option parsing. */
#define MAX_LONG_OPT_SZ 64
#define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1
#define MAX_STRING_LEN 256
/**< mask of enabled ports */
static uint32_t enabled_port_mask;
/**< Enable stats. */
static uint32_t enable_stats;
/**< Enable xstats. */
static uint32_t enable_xstats;
/**< Enable collectd format*/
static uint32_t enable_collectd_format;
/**< FD to send collectd format messages to STDOUT*/
static int stdout_fd;
/**< Host id process is running on */
static char host_id[MAX_LONG_OPT_SZ];
/**< Enable metrics. */
static uint32_t enable_metrics;
/**< Enable stats reset. */
static uint32_t reset_stats;
/**< Enable xstats reset. */
static uint32_t reset_xstats;
/**< Enable memory info. */
static uint32_t mem_info;
/**< Enable displaying xstat name. */
static uint32_t enable_xstats_name;
static char *xstats_name;
/**< Enable xstats by ids. */
#define MAX_NB_XSTATS_IDS 1024
static uint32_t nb_xstats_ids;
static uint64_t xstats_ids[MAX_NB_XSTATS_IDS];
/**< display usage */
static void
@ -85,8 +104,15 @@ proc_info_usage(const char *prgname)
" --stats: to display port statistics, enabled by default\n"
" --xstats: to display extended port statistics, disabled by "
"default\n"
" --metrics: to display derived metrics of the ports, disabled by "
"default\n"
" --xstats-name NAME: to display single xstat id by NAME\n"
" --xstats-ids IDLIST: to display xstat values by id. "
"The argument is comma-separated list of xstat ids to print out.\n"
" --stats-reset: to reset port statistics\n"
" --xstats-reset: to reset port extended statistics\n",
" --xstats-reset: to reset port extended statistics\n"
" --collectd-format: to print statistics to STDOUT in expected by collectd format\n"
" --host-id STRING: host id used to identify the system process is running on\n",
prgname);
}
@ -116,6 +142,66 @@ parse_portmask(const char *portmask)
}
/*
* Parse ids value list into array
*/
static int
parse_xstats_ids(char *list, uint64_t *ids, int limit) {
int length;
char *token;
char *ctx = NULL;
char *endptr;
length = 0;
token = strtok_r(list, ",", &ctx);
while (token != NULL) {
ids[length] = strtoull(token, &endptr, 10);
if (*endptr != '\0')
return -EINVAL;
length++;
if (length >= limit)
return -E2BIG;
token = strtok_r(NULL, ",", &ctx);
}
return length;
}
static int
proc_info_preparse_args(int argc, char **argv)
{
char *prgname = argv[0];
int i;
for (i = 0; i < argc; i++) {
/* Print stats or xstats to STDOUT in collectd format */
if (!strncmp(argv[i], "--collectd-format", MAX_LONG_OPT_SZ)) {
enable_collectd_format = 1;
stdout_fd = dup(STDOUT_FILENO);
close(STDOUT_FILENO);
}
if (!strncmp(argv[i], "--host-id", MAX_LONG_OPT_SZ)) {
if ((i + 1) == argc) {
printf("Invalid host id or not specified\n");
proc_info_usage(prgname);
return -1;
}
strncpy(host_id, argv[i+1], sizeof(host_id));
}
}
if (!strlen(host_id)) {
int err = gethostname(host_id, MAX_LONG_OPT_SZ-1);
if (err)
strcpy(host_id, "unknown");
}
return 0;
}
/* Parse the argument given in the command line of the application */
static int
proc_info_parse_args(int argc, char **argv)
@ -127,7 +213,12 @@ proc_info_parse_args(int argc, char **argv)
{"stats", 0, NULL, 0},
{"stats-reset", 0, NULL, 0},
{"xstats", 0, NULL, 0},
{"metrics", 0, NULL, 0},
{"xstats-reset", 0, NULL, 0},
{"xstats-name", required_argument, NULL, 1},
{"collectd-format", 0, NULL, 0},
{"xstats-ids", 1, NULL, 1},
{"host-id", 0, NULL, 0},
{NULL, 0, 0, 0}
};
@ -159,6 +250,10 @@ proc_info_parse_args(int argc, char **argv)
else if (!strncmp(long_option[option_index].name, "xstats",
MAX_LONG_OPT_SZ))
enable_xstats = 1;
else if (!strncmp(long_option[option_index].name,
"metrics",
MAX_LONG_OPT_SZ))
enable_metrics = 1;
/* Reset stats */
if (!strncmp(long_option[option_index].name, "stats-reset",
MAX_LONG_OPT_SZ))
@ -168,7 +263,28 @@ proc_info_parse_args(int argc, char **argv)
MAX_LONG_OPT_SZ))
reset_xstats = 1;
break;
case 1:
/* Print xstat single value given by name*/
if (!strncmp(long_option[option_index].name,
"xstats-name", MAX_LONG_OPT_SZ)) {
enable_xstats_name = 1;
xstats_name = optarg;
printf("name:%s:%s\n",
long_option[option_index].name,
optarg);
} else if (!strncmp(long_option[option_index].name,
"xstats-ids",
MAX_LONG_OPT_SZ)) {
nb_xstats_ids = parse_xstats_ids(optarg,
xstats_ids, MAX_NB_XSTATS_IDS);
if (nb_xstats_ids <= 0) {
printf("xstats-id list parse error.\n");
return -1;
}
}
break;
default:
proc_info_usage(prgname);
return -1;
@ -194,7 +310,7 @@ meminfo_display(void)
}
static void
nic_stats_display(uint8_t port_id)
nic_stats_display(uint16_t port_id)
{
struct rte_eth_stats stats;
uint8_t i;
@ -233,28 +349,144 @@ nic_stats_display(uint8_t port_id)
}
static void
nic_stats_clear(uint8_t port_id)
nic_stats_clear(uint16_t port_id)
{
printf("\n Clearing NIC stats for port %d\n", port_id);
rte_eth_stats_reset(port_id);
printf("\n NIC statistics for port %d cleared\n", port_id);
}
static void collectd_resolve_cnt_type(char *cnt_type, size_t cnt_type_len,
const char *cnt_name) {
char *type_end = strrchr(cnt_name, '_');
if ((type_end != NULL) &&
(strncmp(cnt_name, "rx_", strlen("rx_")) == 0)) {
if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
strncpy(cnt_type, "if_rx_errors", cnt_type_len);
else if (strncmp(type_end, "_dropped", strlen("_dropped")) == 0)
strncpy(cnt_type, "if_rx_dropped", cnt_type_len);
else if (strncmp(type_end, "_bytes", strlen("_bytes")) == 0)
strncpy(cnt_type, "if_rx_octets", cnt_type_len);
else if (strncmp(type_end, "_packets", strlen("_packets")) == 0)
strncpy(cnt_type, "if_rx_packets", cnt_type_len);
else if (strncmp(type_end, "_placement",
strlen("_placement")) == 0)
strncpy(cnt_type, "if_rx_errors", cnt_type_len);
else if (strncmp(type_end, "_buff", strlen("_buff")) == 0)
strncpy(cnt_type, "if_rx_errors", cnt_type_len);
else
/* Does not fit obvious type: use a more generic one */
strncpy(cnt_type, "derive", cnt_type_len);
} else if ((type_end != NULL) &&
(strncmp(cnt_name, "tx_", strlen("tx_"))) == 0) {
if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
strncpy(cnt_type, "if_tx_errors", cnt_type_len);
else if (strncmp(type_end, "_dropped", strlen("_dropped")) == 0)
strncpy(cnt_type, "if_tx_dropped", cnt_type_len);
else if (strncmp(type_end, "_bytes", strlen("_bytes")) == 0)
strncpy(cnt_type, "if_tx_octets", cnt_type_len);
else if (strncmp(type_end, "_packets", strlen("_packets")) == 0)
strncpy(cnt_type, "if_tx_packets", cnt_type_len);
else
/* Does not fit obvious type: use a more generic one */
strncpy(cnt_type, "derive", cnt_type_len);
} else if ((type_end != NULL) &&
(strncmp(cnt_name, "flow_", strlen("flow_"))) == 0) {
if (strncmp(type_end, "_filters", strlen("_filters")) == 0)
strncpy(cnt_type, "operations", cnt_type_len);
else if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
strncpy(cnt_type, "errors", cnt_type_len);
else if (strncmp(type_end, "_filters", strlen("_filters")) == 0)
strncpy(cnt_type, "filter_result", cnt_type_len);
} else if ((type_end != NULL) &&
(strncmp(cnt_name, "mac_", strlen("mac_"))) == 0) {
if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
strncpy(cnt_type, "errors", cnt_type_len);
} else {
/* Does not fit obvious type, or strrchr error: */
/* use a more generic type */
strncpy(cnt_type, "derive", cnt_type_len);
}
}
static void
nic_xstats_by_name_display(uint16_t port_id, char *name)
{
uint64_t id;
printf("###### NIC statistics for port %-2d, statistic name '%s':\n",
port_id, name);
if (rte_eth_xstats_get_id_by_name(port_id, name, &id) == 0)
printf("%s: %"PRIu64"\n", name, id);
else
printf("Statistic not found...\n");
}
static void
nic_xstats_by_ids_display(uint16_t port_id, uint64_t *ids, int len)
{
struct rte_eth_xstat_name *xstats_names;
uint64_t *values;
int ret, i;
static const char *nic_stats_border = "########################";
values = malloc(sizeof(*values) * len);
if (values == NULL) {
printf("Cannot allocate memory for xstats\n");
return;
}
xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * len);
if (xstats_names == NULL) {
printf("Cannot allocate memory for xstat names\n");
free(values);
return;
}
if (len != rte_eth_xstats_get_names_by_id(
port_id, xstats_names, len, ids)) {
printf("Cannot get xstat names\n");
goto err;
}
printf("###### NIC extended statistics for port %-2d #########\n",
port_id);
printf("%s############################\n", nic_stats_border);
ret = rte_eth_xstats_get_by_id(port_id, ids, values, len);
if (ret < 0 || ret > len) {
printf("Cannot get xstats\n");
goto err;
}
for (i = 0; i < len; i++)
printf("%s: %"PRIu64"\n",
xstats_names[i].name,
values[i]);
printf("%s############################\n", nic_stats_border);
err:
free(values);
free(xstats_names);
}
static void
nic_xstats_display(uint8_t port_id)
nic_xstats_display(uint16_t port_id)
{
struct rte_eth_xstat_name *xstats_names;
struct rte_eth_xstat *xstats;
uint64_t *values;
int len, ret, i;
static const char *nic_stats_border = "########################";
len = rte_eth_xstats_get_names(port_id, NULL, 0);
len = rte_eth_xstats_get_names_by_id(port_id, NULL, 0, NULL);
if (len < 0) {
printf("Cannot get xstats count\n");
return;
}
xstats = malloc(sizeof(xstats[0]) * len);
if (xstats == NULL) {
values = malloc(sizeof(*values) * len);
if (values == NULL) {
printf("Cannot allocate memory for xstats\n");
return;
}
@ -262,11 +494,11 @@ nic_xstats_display(uint8_t port_id)
xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * len);
if (xstats_names == NULL) {
printf("Cannot allocate memory for xstat names\n");
free(xstats);
free(values);
return;
}
if (len != rte_eth_xstats_get_names(
port_id, xstats_names, len)) {
if (len != rte_eth_xstats_get_names_by_id(
port_id, xstats_names, len, NULL)) {
printf("Cannot get xstat names\n");
goto err;
}
@ -275,32 +507,108 @@ nic_xstats_display(uint8_t port_id)
port_id);
printf("%s############################\n",
nic_stats_border);
ret = rte_eth_xstats_get(port_id, xstats, len);
ret = rte_eth_xstats_get_by_id(port_id, NULL, values, len);
if (ret < 0 || ret > len) {
printf("Cannot get xstats\n");
goto err;
}
for (i = 0; i < len; i++)
printf("%s: %"PRIu64"\n",
xstats_names[i].name,
xstats[i].value);
for (i = 0; i < len; i++) {
if (enable_collectd_format) {
char counter_type[MAX_STRING_LEN];
char buf[MAX_STRING_LEN];
collectd_resolve_cnt_type(counter_type,
sizeof(counter_type),
xstats_names[i].name);
sprintf(buf, "PUTVAL %s/dpdkstat-port.%u/%s-%s N:%"
PRIu64"\n", host_id, port_id, counter_type,
xstats_names[i].name, values[i]);
ret = write(stdout_fd, buf, strlen(buf));
if (ret < 0)
goto err;
} else {
printf("%s: %"PRIu64"\n", xstats_names[i].name,
values[i]);
}
}
printf("%s############################\n",
nic_stats_border);
err:
free(xstats);
free(values);
free(xstats_names);
}
static void
nic_xstats_clear(uint8_t port_id)
nic_xstats_clear(uint16_t port_id)
{
printf("\n Clearing NIC xstats for port %d\n", port_id);
rte_eth_xstats_reset(port_id);
printf("\n NIC extended statistics for port %d cleared\n", port_id);
}
static void
metrics_display(int port_id)
{
struct rte_metric_value *metrics;
struct rte_metric_name *names;
int len, ret;
static const char *nic_stats_border = "########################";
len = rte_metrics_get_names(NULL, 0);
if (len < 0) {
printf("Cannot get metrics count\n");
return;
}
if (len == 0) {
printf("No metrics to display (none have been registered)\n");
return;
}
metrics = rte_malloc("proc_info_metrics",
sizeof(struct rte_metric_value) * len, 0);
if (metrics == NULL) {
printf("Cannot allocate memory for metrics\n");
return;
}
names = rte_malloc(NULL, sizeof(struct rte_metric_name) * len, 0);
if (names == NULL) {
printf("Cannot allocate memory for metrcis names\n");
rte_free(metrics);
return;
}
if (len != rte_metrics_get_names(names, len)) {
printf("Cannot get metrics names\n");
rte_free(metrics);
rte_free(names);
return;
}
if (port_id == RTE_METRICS_GLOBAL)
printf("###### Non port specific metrics #########\n");
else
printf("###### metrics for port %-2d #########\n", port_id);
printf("%s############################\n", nic_stats_border);
ret = rte_metrics_get_values(port_id, metrics, len);
if (ret < 0 || ret > len) {
printf("Cannot get metrics values\n");
rte_free(metrics);
rte_free(names);
return;
}
int i;
for (i = 0; i < len; i++)
printf("%s: %"PRIu64"\n", names[i].name, metrics[i].value);
printf("%s############################\n", nic_stats_border);
rte_free(metrics);
rte_free(names);
}
int
main(int argc, char **argv)
{
@ -310,7 +618,14 @@ main(int argc, char **argv)
char n_flag[] = "-n4";
char mp_flag[] = "--proc-type=secondary";
char *argp[argc + 3];
uint8_t nb_ports;
uint16_t nb_ports;
/* preparse app arguments */
ret = proc_info_preparse_args(argc, argv);
if (ret < 0) {
printf("Failed to parse arguments\n");
return -1;
}
argp[0] = argv[0];
argp[1] = c_flag;
@ -329,6 +644,9 @@ main(int argc, char **argv)
argc -= ret;
argv += (ret - 3);
if (!rte_eal_primary_proc_alive(NULL))
rte_exit(EXIT_FAILURE, "No primary DPDK process is running.\n");
/* parse app arguments */
ret = proc_info_parse_args(argc, argv);
if (ret < 0)
@ -357,8 +675,19 @@ main(int argc, char **argv)
nic_stats_clear(i);
else if (reset_xstats)
nic_xstats_clear(i);
else if (enable_xstats_name)
nic_xstats_by_name_display(i, xstats_name);
else if (nb_xstats_ids > 0)
nic_xstats_by_ids_display(i, xstats_ids,
nb_xstats_ids);
else if (enable_metrics)
metrics_display(i);
}
}
/* print port independent stats */
if (enable_metrics)
metrics_display(RTE_METRICS_GLOBAL);
return 0;
}

48
dpdk/app/test-acl/Makefile

@ -1,48 +0,0 @@
# BSD LICENSE
#
# Copyright(c) 2010-2014 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