mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-25 23:06:15 +00:00
net: Add option for tracing packets
Add an option to trace all packets send/received. This can be helpful when debugging protocol issues, as the packets can then be imported into wireshark [1] and analyzed further. [1] https://www.wireshark.org/docs/wsug_html_chunked/ChIOImportSection.html Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
a56e30e65f
commit
798962cedd
2 changed files with 7 additions and 0 deletions
|
@ -16,6 +16,7 @@
|
||||||
#include <asm/cache.h>
|
#include <asm/cache.h>
|
||||||
#include <asm/byteorder.h> /* for nton* / ntoh* stuff */
|
#include <asm/byteorder.h> /* for nton* / ntoh* stuff */
|
||||||
#include <env.h>
|
#include <env.h>
|
||||||
|
#include <hexdump.h>
|
||||||
#include <log.h>
|
#include <log.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <linux/if_ether.h>
|
#include <linux/if_ether.h>
|
||||||
|
@ -29,6 +30,7 @@ struct udevice;
|
||||||
#define DEBUG_DEV_PKT 0 /* Packets or info directed to the device */
|
#define DEBUG_DEV_PKT 0 /* Packets or info directed to the device */
|
||||||
#define DEBUG_NET_PKT 0 /* Packets on info on the network at large */
|
#define DEBUG_NET_PKT 0 /* Packets on info on the network at large */
|
||||||
#define DEBUG_INT_STATE 0 /* Internal network state changes */
|
#define DEBUG_INT_STATE 0 /* Internal network state changes */
|
||||||
|
#define DEBUG_NET_PKT_TRACE 0 /* Trace all packet data */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The number of receive packet buffers, and the required packet buffer
|
* The number of receive packet buffers, and the required packet buffer
|
||||||
|
@ -640,6 +642,8 @@ uchar * net_get_async_tx_pkt_buf(void);
|
||||||
/* Transmit a packet */
|
/* Transmit a packet */
|
||||||
static inline void net_send_packet(uchar *pkt, int len)
|
static inline void net_send_packet(uchar *pkt, int len)
|
||||||
{
|
{
|
||||||
|
if (DEBUG_NET_PKT_TRACE)
|
||||||
|
print_hex_dump_bytes("tx: ", DUMP_PREFIX_OFFSET, pkt, len);
|
||||||
/* Currently no way to return errors from eth_send() */
|
/* Currently no way to return errors from eth_send() */
|
||||||
(void) eth_send(pkt, len);
|
(void) eth_send(pkt, len);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1201,6 +1201,9 @@ void net_process_received_packet(uchar *in_packet, int len)
|
||||||
ushort cti = 0, vlanid = VLAN_NONE, myvlanid, mynvlanid;
|
ushort cti = 0, vlanid = VLAN_NONE, myvlanid, mynvlanid;
|
||||||
|
|
||||||
debug_cond(DEBUG_NET_PKT, "packet received\n");
|
debug_cond(DEBUG_NET_PKT, "packet received\n");
|
||||||
|
if (DEBUG_NET_PKT_TRACE)
|
||||||
|
print_hex_dump_bytes("rx: ", DUMP_PREFIX_OFFSET, in_packet,
|
||||||
|
len);
|
||||||
|
|
||||||
#if defined(CONFIG_CMD_PCAP)
|
#if defined(CONFIG_CMD_PCAP)
|
||||||
pcap_post(in_packet, len, false);
|
pcap_post(in_packet, len, false);
|
||||||
|
|
Loading…
Add table
Reference in a new issue