summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-01-17 20:47:27 +0300
committerTom Rini <trini@konsulko.com>2023-01-24 02:11:39 +0300
commitf43b2df3e068cc7be1aa5656c0c3223e270bba63 (patch)
tree9c29daf5a2cd8180687b3ee4887bca40923bb658 /arch
parentb85fc8dbabd7c027ad7ad6133578a0d679dbe2ba (diff)
downloadu-boot-f43b2df3e068cc7be1aa5656c0c3223e270bba63.tar.xz
sandbox: Allow ethernet to be disabled at runtime
For bootstd tests it is seldom useful to have ethernet enabled. Add a way to disable it, so that ethernet operations like tftpboot do nothing. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/sandbox/cpu/state.c16
-rw-r--r--arch/sandbox/include/asm/state.h1
-rw-r--r--arch/sandbox/include/asm/test.h16
3 files changed, 33 insertions, 0 deletions
diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c
index dd7978cfce..267f280df1 100644
--- a/arch/sandbox/cpu/state.c
+++ b/arch/sandbox/cpu/state.c
@@ -12,6 +12,7 @@
#include <os.h>
#include <asm/malloc.h>
#include <asm/state.h>
+#include <asm/test.h>
/* Main state record for the sandbox */
static struct sandbox_state main_state;
@@ -366,6 +367,7 @@ void state_reset_for_test(struct sandbox_state *state)
state->sysreset_allowed[SYSRESET_POWER_OFF] = true;
state->sysreset_allowed[SYSRESET_COLD] = true;
state->allow_memio = false;
+ sandbox_set_eth_enable(true);
memset(&state->wdt, '\0', sizeof(state->wdt));
memset(state->spi, '\0', sizeof(state->spi));
@@ -444,6 +446,20 @@ int state_load_other_fdt(const char **bufp, int *sizep)
return 0;
}
+void sandbox_set_eth_enable(bool enable)
+{
+ struct sandbox_state *state = state_get_current();
+
+ state->disable_eth = !enable;
+}
+
+bool sandbox_eth_enabled(void)
+{
+ struct sandbox_state *state = state_get_current();
+
+ return !state->disable_eth;
+}
+
int state_init(void)
{
state = &main_state;
diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h
index 49ea483d33..f125fb87af 100644
--- a/arch/sandbox/include/asm/state.h
+++ b/arch/sandbox/include/asm/state.h
@@ -96,6 +96,7 @@ struct sandbox_state {
const char *select_unittests; /* Unit test to run */
bool handle_signals; /* Handle signals within sandbox */
bool autoboot_keyed; /* Use keyed-autoboot feature */
+ bool disable_eth; /* Disable Ethernet devices */
/* Pointer to information for each SPI bus/cs */
struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS]
diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h
index 568738c16d..1c522e38f3 100644
--- a/arch/sandbox/include/asm/test.h
+++ b/arch/sandbox/include/asm/test.h
@@ -344,4 +344,20 @@ void sandbox_set_fake_efi_mgr_dev(struct udevice *dev, bool fake_dev);
*/
int sandbox_load_other_fdt(void **fdtp, int *sizep);
+/**
+ * sandbox_set_eth_enable() - Enable / disable Ethernet
+ *
+ * Allows control of whether Ethernet packets are actually send/received
+ *
+ * @enable: true to enable Ethernet, false to disable
+ */
+void sandbox_set_eth_enable(bool enable);
+
+/**
+ * sandbox_eth_enabled() - Check if Ethernet is enabled
+ *
+ * Returns: true if Ethernet is enabled on sandbox, False if not
+ */
+bool sandbox_eth_enabled(void);
+
#endif