Commit 3b780518 authored by Alessandro Rubini's avatar Alessandro Rubini Committed by Adam Wujek

arch-wrpc: add delay-rx fault

This tool can be used to force overflows of the input fifo.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent e9af8b78
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "syscon.h" #include "syscon.h"
extern struct pp_instance ppi_static; extern struct pp_instance ppi_static;
extern int frame_rx_delay_us;
static int cmd_fault(const char *args[]) static int cmd_fault(const char *args[])
{ {
...@@ -26,7 +27,14 @@ static int cmd_fault(const char *args[]) ...@@ -26,7 +27,14 @@ static int cmd_fault(const char *args[])
ppg->rxdrop, ppg->txdrop); ppg->rxdrop, ppg->txdrop);
return 0; return 0;
} }
if (args[0] && !strcmp(args[0], "delay")) {
if (args[1])
fromdec(args[1], &frame_rx_delay_us);
pp_printf("delaying %i us on rx frame\n", frame_rx_delay_us);
return 0;
}
pp_printf("Use: \"fault drop [<rxdrop> <txdrop>]\" (0..999)\n"); pp_printf("Use: \"fault drop [<rxdrop> <txdrop>]\" (0..999)\n");
pp_printf(" \"fault delay [<usecs>]\"\n");
return -EINVAL; return -EINVAL;
} }
......
...@@ -7,8 +7,11 @@ ...@@ -7,8 +7,11 @@
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
#include "ptpdump.h" #include "ptpdump.h"
#include <syscon.h> /* wrpc-sw */
#include <ptpd_netif.h> /* wrpc-sw */ #include <ptpd_netif.h> /* wrpc-sw */
int frame_rx_delay_us; /* set by faults.c */
/* /*
* we know we create one socket only in wrpc. The buffer size used to be * we know we create one socket only in wrpc. The buffer size used to be
* 512. Let's keep it unchanged, because we might enqueue a few frames. * 512. Let's keep it unchanged, because we might enqueue a few frames.
...@@ -79,6 +82,7 @@ static int wrpc_net_recv(struct pp_instance *ppi, void *pkt, int len, ...@@ -79,6 +82,7 @@ static int wrpc_net_recv(struct pp_instance *ppi, void *pkt, int len,
pp_diag(ppi, frames, 1, "Drop received frame\n"); pp_diag(ppi, frames, 1, "Drop received frame\n");
return -2; return -2;
} }
usleep(frame_rx_delay_us);
return got; return got;
} }
......
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