]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
sandbox: eth: Add a function to skip ping timeouts
authorJoe Hershberger <joe.hershberger@ni.com>
Tue, 21 Apr 2015 18:57:19 +0000 (13:57 -0500)
committerSimon Glass <sjg@chromium.org>
Wed, 6 May 2015 02:58:18 +0000 (20:58 -0600)
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>
arch/sandbox/include/asm/eth.h
drivers/net/sandbox.c

index 4b79ede9b99ca8f9dcff7018f54c49cb462fcd60..88804fb8e2647677d85f4da9c05c516c2e61da4e 100644 (file)
@@ -12,4 +12,6 @@
 
 void sandbox_eth_disable_response(int index, bool disable);
 
+void sandbox_eth_skip_timeout(void);
+
 #endif /* __ETH_H */
index e239ff44479d07cbd04d3906c46646bae2f3c9c1..4e083d32ae6fe7aad839b84c5875ed98bbc4d627 100644 (file)
@@ -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;