Skip to content

Commit 82d7675

Browse files
JordanYateskartben
authored andcommitted
net: lib: zperf: optional server support
Make the zperf server support optional, if only upload throughput testing is required. This reduces the resources required to operate. Signed-off-by: Jordan Yates <jordan@embeint.com>
1 parent 05d5779 commit 82d7675

File tree

5 files changed

+42
-5
lines changed

5 files changed

+42
-5
lines changed

doc/releases/migration-guide-4.2.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ Networking
296296
:c:macro:`HTTPS_SERVICE_DEFINE_EMPTY`, :c:macro:`HTTP_SERVICE_DEFINE` and
297297
:c:macro:`HTTPS_SERVICE_DEFINE`.
298298

299+
* :kconfig:option:`NET_ZPERF` no longer includes server support by default. To use
300+
the server commands, enable :kconfig:option:`NET_ZPERF_SERVER`. If server support
301+
is not needed, :kconfig:option:`ZVFS_POLL_MAX` can possibly be reduced.
302+
299303
SPI
300304
===
301305

subsys/net/lib/zperf/CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ zephyr_library_named(zperf)
44

55
zephyr_library_sources(
66
zperf_common.c
7-
zperf_session.c
8-
zperf_udp_receiver.c
97
zperf_udp_uploader.c
10-
zperf_tcp_receiver.c
118
zperf_tcp_uploader.c
129
)
1310

11+
if(CONFIG_NET_ZPERF_SERVER)
12+
zephyr_library_sources(zperf_session.c)
13+
zephyr_library_sources(zperf_udp_receiver.c)
14+
zephyr_library_sources(zperf_tcp_receiver.c)
15+
endif()
16+
1417
zephyr_library_sources_ifdef(CONFIG_NET_SHELL
1518
zperf_shell.c
1619
)

subsys/net/lib/zperf/Kconfig

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
menuconfig NET_ZPERF
66
bool "zperf library"
77
select NET_CONTEXT_RCVTIMEO if NET_NATIVE_UDP
8-
select NET_SOCKETS_SERVICE
98
select NET_SOCKETS
109
help
1110
This option enables zperf library, which allows to generate
@@ -47,8 +46,15 @@ config NET_ZPERF_MAX_PACKET_SIZE
4746
help
4847
Upper size limit for packets sent by zperf.
4948

49+
config NET_ZPERF_SERVER
50+
bool "zperf server support"
51+
select NET_SOCKETS_SERVICE
52+
help
53+
Support running a zperf server for testing downloads from the application
54+
5055
config NET_ZPERF_MAX_SESSIONS
5156
int "Maximum number of zperf sessions"
57+
depends on NET_ZPERF_SERVER
5258
default 4
5359
help
5460
Upper size limit for connections handled by zperf.

subsys/net/lib/zperf/zperf_common.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,9 @@ static int zperf_init(void)
237237
zperf_udp_uploader_init();
238238
zperf_tcp_uploader_init();
239239

240-
zperf_session_init();
240+
if (IS_ENABLED(CONFIG_NET_ZPERF_SERVER)) {
241+
zperf_session_init();
242+
}
241243

242244
if (IS_ENABLED(CONFIG_NET_SHELL)) {
243245
zperf_shell_init();

subsys/net/lib/zperf/zperf_shell.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ static int parse_ipv4_addr(const struct shell *sh, char *host, char *port,
200200
return 0;
201201
}
202202

203+
#ifdef CONFIG_NET_ZPERF_SERVER
204+
203205
static int zperf_bind_host(const struct shell *sh,
204206
size_t argc, char *argv[],
205207
struct zperf_download_params *param)
@@ -233,6 +235,8 @@ static int zperf_bind_host(const struct shell *sh,
233235
return 0;
234236
}
235237

238+
#endif
239+
236240
static int cmd_setip(const struct shell *sh, size_t argc, char *argv[])
237241
{
238242
int start = 0;
@@ -311,6 +315,8 @@ static int cmd_setip(const struct shell *sh, size_t argc, char *argv[])
311315
return 0;
312316
}
313317

318+
#ifdef CONFIG_NET_ZPERF_SERVER
319+
314320
static void udp_session_cb(enum zperf_status status,
315321
struct zperf_results *result,
316322
void *user_data)
@@ -475,6 +481,8 @@ static int cmd_udp_download(const struct shell *sh, size_t argc,
475481
}
476482
}
477483

484+
#endif
485+
478486
static void shell_udp_upload_print_stats(const struct shell *sh,
479487
struct zperf_results *results)
480488
{
@@ -1291,6 +1299,8 @@ static int cmd_connectap(const struct shell *sh, size_t argc, char *argv[])
12911299
return 0;
12921300
}
12931301

1302+
#ifdef CONFIG_NET_ZPERF_SERVER
1303+
12941304
static void tcp_session_cb(enum zperf_status status,
12951305
struct zperf_results *result,
12961306
void *user_data)
@@ -1395,6 +1405,8 @@ static int cmd_tcp_download(const struct shell *sh, size_t argc,
13951405
}
13961406
}
13971407

1408+
#endif
1409+
13981410
static int cmd_version(const struct shell *sh, size_t argc, char *argv[])
13991411
{
14001412
shell_fprintf(sh, SHELL_NORMAL, "Version: %s\nConfig: %s\n",
@@ -1454,11 +1466,15 @@ void zperf_shell_init(void)
14541466
}
14551467
}
14561468

1469+
#ifdef CONFIG_NET_ZPERF_SERVER
1470+
14571471
SHELL_STATIC_SUBCMD_SET_CREATE(zperf_cmd_tcp_download,
14581472
SHELL_CMD(stop, NULL, "Stop TCP server\n", cmd_tcp_download_stop),
14591473
SHELL_SUBCMD_SET_END
14601474
);
14611475

1476+
#endif
1477+
14621478
SHELL_STATIC_SUBCMD_SET_CREATE(zperf_cmd_tcp,
14631479
SHELL_CMD(upload, NULL,
14641480
"[<options>] <dest ip> <dest port> <duration> <packet size>[K]\n"
@@ -1510,18 +1526,22 @@ SHELL_STATIC_SUBCMD_SET_CREATE(zperf_cmd_tcp,
15101526
#endif
15111527
,
15121528
cmd_tcp_upload2),
1529+
#ifdef CONFIG_NET_ZPERF_SERVER
15131530
SHELL_CMD(download, &zperf_cmd_tcp_download,
15141531
"[<port>]: Server port to listen on/connect to\n"
15151532
"[<host>]: Bind to <host>, an interface address\n"
15161533
"Example: tcp download 5001 192.168.0.1\n",
15171534
cmd_tcp_download),
1535+
#endif
15181536
SHELL_SUBCMD_SET_END
15191537
);
15201538

1539+
#ifdef CONFIG_NET_ZPERF_SERVER
15211540
SHELL_STATIC_SUBCMD_SET_CREATE(zperf_cmd_udp_download,
15221541
SHELL_CMD(stop, NULL, "Stop UDP server\n", cmd_udp_download_stop),
15231542
SHELL_SUBCMD_SET_END
15241543
);
1544+
#endif
15251545

15261546
SHELL_STATIC_SUBCMD_SET_CREATE(zperf_cmd_udp,
15271547
SHELL_CMD(upload, NULL,
@@ -1577,6 +1597,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(zperf_cmd_udp,
15771597
#endif
15781598
,
15791599
cmd_udp_upload2),
1600+
#ifdef CONFIG_NET_ZPERF_SERVER
15801601
SHELL_CMD(download, &zperf_cmd_udp_download,
15811602
"[<options>] command options (optional): [-I eth0]\n"
15821603
"[<port>]: Server port to listen on/connect to\n"
@@ -1585,6 +1606,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(zperf_cmd_udp,
15851606
"-I <interface name>: Specify host interface name\n"
15861607
"Example: udp download 5001 192.168.0.1\n",
15871608
cmd_udp_download),
1609+
#endif
15881610
SHELL_SUBCMD_SET_END
15891611
);
15901612

0 commit comments

Comments
 (0)