aboutsummaryrefslogtreecommitdiff
path: root/drivers/net
diff options
context:
space:
mode:
authorJoe Hershberger2015-04-21 13:57:19 -0500
committerSimon Glass2015-05-05 20:58:18 -0600
commit6f2707c6b135681f821b55cac484a7512f5fe79a (patch)
tree78979b30fec39a6050430b0bafeb88425d24d737 /drivers/net
parent909bd6d9729cb0c6ba6b80cdc283bbd3e1e12770 (diff)
sandbox: eth: Add a function to skip ping timeouts
When called, the next call to receive will trigger a 10-second leap forward in time to avoid waiting for time to pass when tests are evaluating timeout behavior. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/sandbox.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/net/sandbox.c b/drivers/net/sandbox.c
index e239ff44479..4e083d32ae6 100644
--- a/drivers/net/sandbox.c
+++ b/drivers/net/sandbox.c
@@ -11,6 +11,7 @@
#include <dm.h>
#include <malloc.h>
#include <net.h>
+#include <asm/test.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -30,6 +31,7 @@ struct eth_sandbox_priv {
};
static bool disabled[8] = {false};
+static bool skip_timeout;
/*
* sandbox_eth_disable_response()
@@ -42,6 +44,16 @@ void sandbox_eth_disable_response(int index, bool disable)
disabled[index] = disable;
}
+/*
+ * sandbox_eth_skip_timeout()
+ *
+ * When the first packet read is attempted, fast-forward time
+ */
+void sandbox_eth_skip_timeout(void)
+{
+ skip_timeout = true;
+}
+
static int sb_eth_start(struct udevice *dev)
{
struct eth_sandbox_priv *priv = dev_get_priv(dev);
@@ -144,6 +156,11 @@ static int sb_eth_recv(struct udevice *dev, uchar **packetp)
{
struct eth_sandbox_priv *priv = dev_get_priv(dev);
+ if (skip_timeout) {
+ sandbox_timer_add_offset(10000UL);
+ skip_timeout = false;
+ }
+
if (priv->recv_packet_length) {
int lcl_recv_packet_length = priv->recv_packet_length;