Skip to content

Commit

Permalink
samples: net: zperf: Convert to use the new shell
Browse files Browse the repository at this point in the history
Use new shell instead of the legacy one. This commit also fixes
the configuration file mess and allows the program to be run on
more hardware.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
  • Loading branch information
jukkar committed Oct 12, 2018
1 parent 96e553e commit 1cdd478
Show file tree
Hide file tree
Showing 20 changed files with 1,033 additions and 1,039 deletions.
34 changes: 8 additions & 26 deletions samples/net/zperf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,48 +1,30 @@
cmake_minimum_required(VERSION 3.8.2)

macro(set_conf_file)
if(PROFILER)
set(CONF_FILE prj_${BOARD}_prof.conf)
if(EXISTS ${APPLICATION_SOURCE_DIR}/prj_${BOARD}.conf)
set(CONF_FILE "${APPLICATION_SOURCE_DIR}/prj_${BOARD}.conf")
elseif(EXISTS ${APPLICATION_SOURCE_DIR}/boards/${BOARD}.conf)
set(CONF_FILE
"prj.conf ${APPLICATION_SOURCE_DIR}/boards/${BOARD}.conf")
else()
set(CONF_FILE prj_${BOARD}.conf)
set(CONF_FILE "prj.conf")
endif()
endmacro()

include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
project(NONE)

target_sources(
app PRIVATE
target_sources(app PRIVATE
src/shell_utils.c
src/zperf_session.c
src/zperf_shell.c
)
target_sources_ifdef(
CONFIG_NET_UDP
app PRIVATE
src/zperf_udp_receiver.c
src/zperf_udp_uploader.c
)
target_sources_ifdef(
CONFIG_NET_TCP
app PRIVATE
src/zperf_tcp_receiver.c
src/zperf_tcp_uploader.c
)

target_compile_definitions_ifdef(
PROFILER
app PRIVATE
PROFILER
)

target_include_directories(app PRIVATE
$ENV{ZEPHYR_BASE}/subsys/net/ip
$ENV{ZEPHYR_BASE}/samples/task_profiler/profiler/src
)

if(PROFILER)
assert(0 "PROFILER is not supported yet")
# KBuild did this, but this did not work, not sure why.
# export PROFILER_NO_SHELL_REGISTER=1
# obj-y += ../../../task_profiler/profiler/
endif()
13 changes: 6 additions & 7 deletions samples/net/zperf/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Features

- Compatible with iPerf_2.0.5.
- Client or server mode allowed without need to modify the source code.
- Working with task profiler (PROFILER=1 to be set when building zperf)

Supported Boards
****************
Expand Down Expand Up @@ -58,43 +57,43 @@ In the Zephyr console, zperf can be executed as follows:

.. code-block:: console
zperf> udp.upload 2001:db8::2 5001 10 1K 1M
zperf> udp upload 2001:db8::2 5001 10 1K 1M
For TCP the zperf command would look like this:

.. code-block:: console
zperf> tcp.upload 2001:db8::2 5001 10 1K 1M
zperf> tcp upload 2001:db8::2 5001 10 1K 1M
If the IP addresses of Zephyr and the host machine are specified in the
config file, zperf can be started as follows:

.. code-block:: console
zperf> udp.upload2 v6 10 1K 1M
zperf> udp upload2 v6 10 1K 1M
or like this if you want to test TCP:

.. code-block:: console
zperf> tcp.upload2 v6 10 1K 1M
zperf> tcp upload2 v6 10 1K 1M
If Zephyr is acting as a server, set the download mode as follows for UDP:

.. code-block:: console
zperf> udp.download 5001
zperf> udp download 5001
or like this for TCP:

.. code-block:: console
zperf> tcp.download 5001
zperf> tcp download 5001
and in the host side, iPerf must be executed with the following
Expand Down
9 changes: 9 additions & 0 deletions samples/net/zperf/boards/quark_se_c1000_devboard.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CONFIG_NET_L2_IEEE802154=y
CONFIG_IEEE802154_CC2520=y
CONFIG_NET_6LO_CONTEXT=y

CONFIG_NET_PKT_RX_COUNT=24
CONFIG_NET_PKT_TX_COUNT=24
CONFIG_NET_BUF_RX_COUNT=48
CONFIG_NET_BUF_TX_COUNT=48
CONFIG_NET_BUF_DATA_SIZE=128
2 changes: 2 additions & 0 deletions samples/net/zperf/overlay-bt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_NET_L2_BT=y
CONFIG_NET_L2_BT_SHELL=y
6 changes: 6 additions & 0 deletions samples/net/zperf/overlay-netusb.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# USB Device Settings
CONFIG_USB=y
CONFIG_USB_DEVICE_STACK=y

# Select USB Configurations
CONFIG_USB_DEVICE_NETWORK_ECM=y
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ CONFIG_NET_IPV6=y
CONFIG_NET_IPV4=y
CONFIG_NET_DHCPV4=n
CONFIG_NET_UDP=y
CONFIG_NET_TCP=n
CONFIG_NET_TCP=y
CONFIG_NET_STATISTICS=y

CONFIG_NET_PKT_RX_COUNT=14
CONFIG_NET_PKT_TX_COUNT=14
CONFIG_NET_BUF_RX_COUNT=28
CONFIG_NET_BUF_TX_COUNT=28
CONFIG_NET_BUF_DATA_SIZE=512
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=5
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=4
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=5
CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=1
CONFIG_NET_MAX_CONTEXTS=3
Expand All @@ -24,12 +23,10 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_L2_ETHERNET=y
CONFIG_NET_SHELL=y

CONFIG_CONSOLE_HANDLER=y
CONFIG_CONSOLE_SHELL=y
CONFIG_PRINTK=y

CONFIG_NET_CONFIG_SETTINGS=y
CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::1"
CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::2"
CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.2"

CONFIG_LOG=y
32 changes: 0 additions & 32 deletions samples/net/zperf/prj_bt.conf

This file was deleted.

36 changes: 0 additions & 36 deletions samples/net/zperf/prj_frdm_k64f.conf

This file was deleted.

39 changes: 0 additions & 39 deletions samples/net/zperf/prj_netusb.conf

This file was deleted.

35 changes: 0 additions & 35 deletions samples/net/zperf/prj_quark_se_c1000_devboard.conf

This file was deleted.

37 changes: 18 additions & 19 deletions samples/net/zperf/sample.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
common:
harness: net
tags: net zperf samples
# TODO: Does not work properly with native_posix, need more TLC
platform_exclude: native_posix
sample:
description: TBD
name: TBD
description: Network performance measurement tool for Zephyr
name: zperf
tests:
test:
harness: net
platform_whitelist: qemu_x86
tags: samples net
test_netusb_ecm:
harness: net
extra_args: CONF_FILE="prj_netusb.conf"
extra_args: OVERLAY_CONFIG="overlay-netusb.conf"
extra_configs:
- CONFIG_NET_PKT_RX_COUNT=10
- CONFIG_NET_PKT_TX_COUNT=10
- CONFIG_NET_TCP=n
platform_whitelist: quark_se_c1000_devboard 96b_carbon
tags: samples usb net
tags: samples usb net zperf
test_netusb_eem:
harness: net
extra_args: CONF_FILE="prj_netusb.conf"
extra_args: OVERLAY_CONFIG="overlay-netusb.conf"
extra_configs:
- CONFIG_USB_DEVICE_NETWORK_ECM=n
- CONFIG_USB_DEVICE_NETWORK_EEM=y
- CONFIG_NET_PKT_RX_COUNT=10
- CONFIG_NET_PKT_TX_COUNT=10
- CONFIG_NET_TCP=n
platform_whitelist: quark_se_c1000_devboard 96b_carbon
tags: samples usb net
tags: samples usb net zperf
test_netusb_rndis:
harness: net
extra_args: CONF_FILE="prj_netusb.conf"
extra_args: OVERLAY_CONFIG="overlay-netusb.conf"
extra_configs:
- CONFIG_USB_DEVICE_NETWORK_ECM=n
- CONFIG_USB_DEVICE_NETWORK_RNDIS=y
- CONFIG_NET_PKT_RX_COUNT=10
- CONFIG_NET_PKT_TX_COUNT=10
- CONFIG_NET_PKT_RX_COUNT=32
- CONFIG_NET_PKT_TX_COUNT=32
- CONFIG_NET_TCP=n
platform_whitelist: quark_se_c1000_devboard 96b_carbon
tags: samples usb net
tags: samples usb net zperf
9 changes: 5 additions & 4 deletions samples/net/zperf/src/shell_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ const char *KBPS_UNIT[] = { "Mbps", "Kbps" };
const u32_t K[] = { 1024 * 1024, 1024, 0 };
const char *K_UNIT[] = { "M", "K", "" };

void print_number(u32_t value, const u32_t *divisor,
const char **units)
void print_number(const struct shell *shell, u32_t value,
const u32_t *divisor, const char **units)
{
const char **unit;
const u32_t *div;
Expand All @@ -42,9 +42,10 @@ void print_number(u32_t value, const u32_t *divisor,
if (*div != 0) {
radix = value / *div;
dec = (value % *div) * 100 / *div;
printk("%u.%s%u %s", radix, (dec < 10) ? "0" : "", dec, *unit);
shell_fprintf(shell, SHELL_NORMAL, "%u.%s%u %s", radix,
(dec < 10) ? "0" : "", dec, *unit);
} else {
printk("%u %s", value, *unit);
shell_fprintf(shell, SHELL_NORMAL, "%u %s", value, *unit);
}
}

Expand Down
Loading

0 comments on commit 1cdd478

Please sign in to comment.