Message ID | 20250306143224.3080316-3-jerome.forissier@linaro.org |
---|---|
State | New |
Headers | show |
Series | net: lwip: rename output function, add packet dump | expand |
On Thu, 6 Mar 2025 at 16:32, Jerome Forissier <jerome.forissier@linaro.org> wrote: > > Add Kconfig symbol LWIP_DEBUG_RXTX to dump the incoming and outgoing > packets when NET_LWIP=y. > > Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> > --- > net/lwip/Kconfig | 6 ++++++ > net/lwip/net-lwip.c | 14 ++++++++++++++ > 2 files changed, 20 insertions(+) > > diff --git a/net/lwip/Kconfig b/net/lwip/Kconfig > index 40345ced9c9..d28a8a7df94 100644 > --- a/net/lwip/Kconfig > +++ b/net/lwip/Kconfig > @@ -10,6 +10,12 @@ config LWIP_DEBUG > Prints messages to the console regarding network packets that go in > and out of the lwIP library. > > +config LWIP_DEBUG_RXTX > + bool "Dump packets sent and received by lwIP" > + help > + Performs an hexadecimal & ASCII dump of the data received and sent by > + the lwIP network stack. > + > config LWIP_ASSERT > bool "Enable assertions in the lwIP library" > help > diff --git a/net/lwip/net-lwip.c b/net/lwip/net-lwip.c > index 5a2a86686f4..c00a7fe97cd 100644 > --- a/net/lwip/net-lwip.c > +++ b/net/lwip/net-lwip.c > @@ -5,6 +5,7 @@ > #include <command.h> > #include <dm/device.h> > #include <dm/uclass.h> > +#include <hexdump.h> > #include <lwip/ip4_addr.h> > #include <lwip/err.h> > #include <lwip/netif.h> > @@ -36,6 +37,12 @@ static err_t net_lwip_tx(struct netif *netif, struct pbuf *p) > void *pp = NULL; > int err; > > + if (CONFIG_IS_ENABLED(LWIP_DEBUG_RXTX)) { > + printf("net_lwip_tx: %u bytes, udev %s\n", p->len, udev->name); > + print_hex_dump("net_lwip_tx: ", 0, 16, 1, p->payload, p->len, > + true); > + } > + > if ((unsigned long)p->payload % PKTALIGN) { > /* > * Some net drivers have strict alignment requirements and may > @@ -265,6 +272,13 @@ int net_lwip_rx(struct udevice *udev, struct netif *netif) > flags = 0; > > if (len > 0) { > + if (CONFIG_IS_ENABLED(LWIP_DEBUG_RXTX)) { > + printf("net_lwip_tx: %u bytes, udev %s \n", len, > + udev->name); > + print_hex_dump("net_lwip_rx: ", 0, 16, 1, > + packet, len, true); > + } > + > pbuf = alloc_pbuf_and_copy(packet, len); > if (pbuf) > netif->input(pbuf, netif); > -- > 2.43.0 > Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
diff --git a/net/lwip/Kconfig b/net/lwip/Kconfig index 40345ced9c9..d28a8a7df94 100644 --- a/net/lwip/Kconfig +++ b/net/lwip/Kconfig @@ -10,6 +10,12 @@ config LWIP_DEBUG Prints messages to the console regarding network packets that go in and out of the lwIP library. +config LWIP_DEBUG_RXTX + bool "Dump packets sent and received by lwIP" + help + Performs an hexadecimal & ASCII dump of the data received and sent by + the lwIP network stack. + config LWIP_ASSERT bool "Enable assertions in the lwIP library" help diff --git a/net/lwip/net-lwip.c b/net/lwip/net-lwip.c index 5a2a86686f4..c00a7fe97cd 100644 --- a/net/lwip/net-lwip.c +++ b/net/lwip/net-lwip.c @@ -5,6 +5,7 @@ #include <command.h> #include <dm/device.h> #include <dm/uclass.h> +#include <hexdump.h> #include <lwip/ip4_addr.h> #include <lwip/err.h> #include <lwip/netif.h> @@ -36,6 +37,12 @@ static err_t net_lwip_tx(struct netif *netif, struct pbuf *p) void *pp = NULL; int err; + if (CONFIG_IS_ENABLED(LWIP_DEBUG_RXTX)) { + printf("net_lwip_tx: %u bytes, udev %s\n", p->len, udev->name); + print_hex_dump("net_lwip_tx: ", 0, 16, 1, p->payload, p->len, + true); + } + if ((unsigned long)p->payload % PKTALIGN) { /* * Some net drivers have strict alignment requirements and may @@ -265,6 +272,13 @@ int net_lwip_rx(struct udevice *udev, struct netif *netif) flags = 0; if (len > 0) { + if (CONFIG_IS_ENABLED(LWIP_DEBUG_RXTX)) { + printf("net_lwip_tx: %u bytes, udev %s \n", len, + udev->name); + print_hex_dump("net_lwip_rx: ", 0, 16, 1, + packet, len, true); + } + pbuf = alloc_pbuf_and_copy(packet, len); if (pbuf) netif->input(pbuf, netif);
Add Kconfig symbol LWIP_DEBUG_RXTX to dump the incoming and outgoing packets when NET_LWIP=y. Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> --- net/lwip/Kconfig | 6 ++++++ net/lwip/net-lwip.c | 14 ++++++++++++++ 2 files changed, 20 insertions(+)