Commit d2aa401a authored by Alessandro Rubini's avatar Alessandro Rubini

net: use net_verbose(), with a Kconfig option, instead of TRACE_WRAP

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 9d928453
...@@ -230,6 +230,13 @@ config UART_SW ...@@ -230,6 +230,13 @@ config UART_SW
are routed to the software uart. The interactive wrpc shell are routed to the software uart. The interactive wrpc shell
and diagnostics run on the hardware UART if available. and diagnostics run on the hardware UART if available.
config NET_VERBOSE
depends on DEVELOPER && WR_NODE
boolean "Extra verbose messages for networking"
help
This is mainly a debug tool, to be left off unless you hack
in the network subsystem.
config SDB_STORAGE config SDB_STORAGE
depends on WR_NODE depends on WR_NODE
default y default y
......
...@@ -26,6 +26,7 @@ CONFIG_PRINTF_FULL=y ...@@ -26,6 +26,7 @@ CONFIG_PRINTF_FULL=y
# CONFIG_PRINTF_NONE is not set # CONFIG_PRINTF_NONE is not set
CONFIG_DETERMINISTIC_BINARY=y CONFIG_DETERMINISTIC_BINARY=y
CONFIG_UART_SW=y CONFIG_UART_SW=y
CONFIG_NET_VERBOSE=y
CONFIG_SDB_STORAGE=y CONFIG_SDB_STORAGE=y
# CONFIG_LEGACY_EEPROM is not set # CONFIG_LEGACY_EEPROM is not set
CONFIG_VLAN_ARRAY_SIZE=1 CONFIG_VLAN_ARRAY_SIZE=1
#ifndef __FREESTANDING_TRACE_H__ #ifndef __FREESTANDING_TRACE_H__
#define __FREESTANDING_TRACE_H__ #define __FREESTANDING_TRACE_H__
#ifdef CONFIG_NET_VERBOSE
#define NET_IS_VERBOSE 1
#else
#define NET_IS_VERBOSE 0
#endif
#ifdef CONFIG_WR_NODE #ifdef CONFIG_WR_NODE
#include <wrc.h> #include <wrc.h>
#define TRACE_WRAP(...)
#define TRACE_DEV(...) wrc_debug_printf(0, __VA_ARGS__) #define TRACE_DEV(...) wrc_debug_printf(0, __VA_ARGS__)
#else /* WR_SWITCH */ #else /* WR_SWITCH */
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <stdarg.h>
#include "hal_exports.h" #include "hal_exports.h"
#include <wrpc.h> #include <wrpc.h>
...@@ -54,13 +55,27 @@ struct my_socket { ...@@ -54,13 +55,27 @@ struct my_socket {
static struct my_socket socks[NET_MAX_SOCKETS]; static struct my_socket socks[NET_MAX_SOCKETS];
static int net_verbose(const char *fmt, ...)
{
va_list args;
int ret = 0;
if (NET_IS_VERBOSE) {
va_start(args, fmt);
ret = pp_vprintf(fmt, args);
va_end(args);
}
return ret;
}
int ptpd_netif_init() int ptpd_netif_init()
{ {
memset(socks, 0, sizeof(socks)); memset(socks, 0, sizeof(socks));
return PTPD_NETIF_OK; return PTPD_NETIF_OK;
} }
//#define TRACE_WRAP pp_printf //#define net_verbose pp_printf
int ptpd_netif_get_hw_addr(wr_socket_t * sock, mac_addr_t * mac) int ptpd_netif_get_hw_addr(wr_socket_t * sock, mac_addr_t * mac)
{ {
get_mac_addr((uint8_t *) mac); get_mac_addr((uint8_t *) mac);
...@@ -93,7 +108,7 @@ wr_socket_t *ptpd_netif_create_socket(int unused, int unusd2, ...@@ -93,7 +108,7 @@ wr_socket_t *ptpd_netif_create_socket(int unused, int unusd2,
} }
if (!sock) { if (!sock) {
TRACE_WRAP("No sockets left.\n"); net_verbose("No sockets left.\n");
return NULL; return NULL;
} }
...@@ -206,7 +221,7 @@ static int wrap_copy_in(void *dst, struct sockq *q, size_t len) ...@@ -206,7 +221,7 @@ static int wrap_copy_in(void *dst, struct sockq *q, size_t len)
char *dptr = dst; char *dptr = dst;
int i = len; int i = len;
TRACE_WRAP("copy_in: tail %d avail %d len %d\n", q->tail, q->avail, net_verbose("copy_in: tail %d avail %d len %d\n", q->tail, q->avail,
len); len);
while (i--) { while (i--) {
...@@ -223,7 +238,7 @@ static int wrap_copy_out(struct sockq *q, void *src, size_t len) ...@@ -223,7 +238,7 @@ static int wrap_copy_out(struct sockq *q, void *src, size_t len)
char *sptr = src; char *sptr = src;
int i = len; int i = len;
TRACE_WRAP("copy_out: head %d avail %d len %d\n", q->head, q->avail, net_verbose("copy_out: head %d avail %d len %d\n", q->head, q->avail,
len); len);
while (i--) { while (i--) {
...@@ -278,7 +293,7 @@ int ptpd_netif_recvfrom(wr_socket_t * sock, wr_sockaddr_t * from, void *data, ...@@ -278,7 +293,7 @@ int ptpd_netif_recvfrom(wr_socket_t * sock, wr_sockaddr_t * from, void *data,
REF_CLOCK_PERIOD_PS); REF_CLOCK_PERIOD_PS);
} }
TRACE_WRAP("RX: Size %d tail %d Smac %x:%x:%x:%x:%x:%x\n", size, net_verbose("RX: Size %d tail %d Smac %x:%x:%x:%x:%x:%x\n", size,
q->tail, hdr.srcmac[0], hdr.srcmac[1], hdr.srcmac[2], q->tail, hdr.srcmac[0], hdr.srcmac[1], hdr.srcmac[2],
hdr.srcmac[3], hdr.srcmac[4], hdr.srcmac[5]); hdr.srcmac[3], hdr.srcmac[4], hdr.srcmac[5]);
...@@ -338,7 +353,7 @@ void update_rx_queues() ...@@ -338,7 +353,7 @@ void update_rx_queues()
} }
if (!s) { if (!s) {
TRACE_WRAP("%s: could not find socket for packet\n", net_verbose("%s: could not find socket for packet\n",
__FUNCTION__); __FUNCTION__);
return; return;
} }
...@@ -348,7 +363,7 @@ void update_rx_queues() ...@@ -348,7 +363,7 @@ void update_rx_queues()
sizeof(struct ethhdr) + recvd + sizeof(struct hw_timestamp) + 2; sizeof(struct ethhdr) + recvd + sizeof(struct hw_timestamp) + 2;
if (q->avail < q_required) { if (q->avail < q_required) {
TRACE_WRAP net_verbose
("%s: queue for socket full; [avail %d required %d]\n", ("%s: queue for socket full; [avail %d required %d]\n",
__FUNCTION__, q->avail, q_required); __FUNCTION__, q->avail, q_required);
return; return;
...@@ -362,10 +377,10 @@ void update_rx_queues() ...@@ -362,10 +377,10 @@ void update_rx_queues()
q->avail -= wrap_copy_out(q, payload, size); q->avail -= wrap_copy_out(q, payload, size);
q->n++; q->n++;
TRACE_WRAP("Q: Size %d head %d Smac %x:%x:%x:%x:%x:%x\n", recvd, net_verbose("Q: Size %d head %d Smac %x:%x:%x:%x:%x:%x\n", recvd,
q->head, hdr.srcmac[0], hdr.srcmac[1], hdr.srcmac[2], q->head, hdr.srcmac[0], hdr.srcmac[1], hdr.srcmac[2],
hdr.srcmac[3], hdr.srcmac[4], hdr.srcmac[5]); hdr.srcmac[3], hdr.srcmac[4], hdr.srcmac[5]);
TRACE_WRAP("%s: saved packet to queue [avail %d n %d size %d]\n", net_verbose("%s: saved packet to queue [avail %d n %d size %d]\n",
__FUNCTION__, q->avail, q->n, q_required); __FUNCTION__, q->avail, q->n, q_required);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment