Skip to content

Commit 82b43d5

Browse files
jukkarkartben
authored andcommitted
net: l2: dummy: Update sent statistics
Update dummy interface sent statistics as that was missing. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
1 parent 5076f5e commit 82b43d5

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

subsys/net/l2/dummy/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ zephyr_library_compile_definitions_ifdef(
55
CONFIG_NEWLIB_LIBC __LINUX_ERRNO_EXTENSIONS__
66
)
77

8+
zephyr_library_include_directories(. ${ZEPHYR_BASE}/subsys/net/ip)
9+
810
zephyr_library_sources_ifdef(CONFIG_NET_L2_DUMMY dummy.c)
911

1012
if(CONFIG_NET_PSEUDO_IFACE)

subsys/net/l2/dummy/dummy.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ LOG_MODULE_REGISTER(net_l2_dummy, LOG_LEVEL_NONE);
1414

1515
#include <zephyr/net/dummy.h>
1616

17+
#include "net_stats.h"
18+
1719
static inline enum net_verdict dummy_recv(struct net_if *iface,
1820
struct net_pkt *pkt)
1921
{
@@ -41,7 +43,14 @@ static inline int dummy_send(struct net_if *iface, struct net_pkt *pkt)
4143

4244
ret = net_l2_send(api->send, net_if_get_device(iface), iface, pkt);
4345
if (!ret) {
44-
ret = net_pkt_get_len(pkt);
46+
size_t pkt_len = net_pkt_get_len(pkt);
47+
48+
if (IS_ENABLED(CONFIG_NET_STATISTICS)) {
49+
NET_DBG("Sending pkt %p len %zu", pkt, pkt_len);
50+
net_stats_update_bytes_sent(iface, pkt_len);
51+
}
52+
53+
ret = (int)pkt_len;
4554
net_pkt_unref(pkt);
4655
}
4756

0 commit comments

Comments
 (0)