Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 736C8C47089 for ; Wed, 7 Dec 2022 08:57:49 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6045C855EB; Wed, 7 Dec 2022 09:55:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="AzpLdgBc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3CDEC84EA1; Wed, 7 Dec 2022 09:54:59 +0100 (CET) Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8D6D585590 for ; Wed, 7 Dec 2022 09:54:55 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-pj1-x102f.google.com with SMTP id b11so16960320pjp.2 for ; Wed, 07 Dec 2022 00:54:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=21/iO76L5ru58VsRak/iqfh6zKKHyO2f+oUfIfXqnfw=; b=AzpLdgBctT9ElRajvUVHU8TWqW++6O0cXtxRs7ygsmgPwr4IHTRRv6mLPJ70sx6OxV LmpqbCtIOq3gXsjUVq1Z5FAYTpeHHVu2z+buRs4y/FYSySHsqajjdMI9dpmI9tR+B6XE uRbwa0zRI+0lj0yFQ16JgafpGyN78NKs6ubL4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=21/iO76L5ru58VsRak/iqfh6zKKHyO2f+oUfIfXqnfw=; b=E+zjSR3e7TQFT6iAkBrbLB2Zblv7V0NzRnC3Re6EeKlvCmjIYuzIs99eXRZjgM4cQv tzhgmSDZqdyPpqmQkOcwplgo7BdCpI+xmoiZEyA75mJo2sjNUPUC8rjT6krIm3Jd457r UB90NLtXw/ZAGXR+i6nRYH4jY7VAX0biuLJtbQ62fCJXJFKNqCwksN+yDcsPmUicBm4G yS6FrvoeWzQ3mELwkpunIWr3QmMletuvKYXIb/FomKs2uAVCAQlK0XoI3xYTr/RvBs2j sLwdXfA8o6hiKnDajdfdu1hBbkYZUG5FVqrheOiryD27OEf0jUFaQzT+3Xc/FY3jZaAd 40Uw== X-Gm-Message-State: ANoB5pmQkBqZG20phzLNETlLK12S1uKFuPMdd1QscWZJvqGQHAAeNzFI nOI+bWDizJ8dpmnlFfIrA1GIETQpMK77pO08 X-Google-Smtp-Source: AA0mqf7v+ATsQD5H7+KVZh5N4ICyf0MgakMezhO3cOhwOdzU8XCSp/cQvW2eLxRbamHZH+2xO3BEAA== X-Received: by 2002:a17:902:6b8b:b0:188:a40b:47c9 with SMTP id p11-20020a1709026b8b00b00188a40b47c9mr74207614plk.75.1670403293707; Wed, 07 Dec 2022 00:54:53 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.54.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:54:53 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Heinrich Schuchardt , Joe Hershberger , Michal Suchanek , Ramon Fried , Stefan Roese Subject: [PATCH 18/71] sandbox: Allow ethernet bootdevs to be disabled for tests Date: Wed, 7 Dec 2022 21:50:44 +1300 Message-Id: <20221207085137.445249-19-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Most tests don't want these and can create a lot of noise. Add a way to disable them. Use that in tests, with a flag provided to enable them for tests that need this feature. Signed-off-by: Simon Glass --- include/net.h | 16 ++++++++++++++++ include/test/test.h | 12 ++++++++++++ net/eth-uclass.c | 14 +++++++++++++- test/test-main.c | 8 +++++++- 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/include/net.h b/include/net.h index 1a99009959d..749f20fa967 100644 --- a/include/net.h +++ b/include/net.h @@ -957,4 +957,20 @@ static inline struct in_addr env_get_ip(char *var) */ void reset_phy(void); +#if CONFIG_IS_ENABLED(NET) +/** + * eth_set_enable_bootdevs() - Enable or disable binding of Ethernet bootdevs + * + * These get in the way of bootstd testing, so are normally disabled by tests. + * This provide control of this setting. It only affects binding of Ethernet + * devices, so if that has already happened, this flag does nothing. + * + * @enable: true to enable binding of bootdevs when binding new Ethernet + * devices, false to disable it + */ +void eth_set_enable_bootdevs(bool enable); +#else +static inline void eth_set_enable_bootdevs(bool enable) {} +#endif + #endif /* __NET_H__ */ diff --git a/include/test/test.h b/include/test/test.h index 76ec4d739a3..beabe9333dc 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -71,6 +71,7 @@ enum { * since it cannot access the flags. */ UT_TESTF_MANUAL = BIT(8), + UT_TESTF_ETH_BOOTDEV = BIT(9), /* enable Ethernet bootdevs */ }; /** @@ -194,4 +195,15 @@ static inline bool test_eth_enabled(void) return enabled; } +/* Allow ethernet bootdev to be ignored for testing purposes */ +static inline bool test_eth_bootdev_enabled(void) +{ + bool enabled = true; + +#ifdef CONFIG_SANDBOX + enabled = sandbox_eth_enabled(); +#endif + return enabled; +} + #endif /* __TEST_TEST_H */ diff --git a/net/eth-uclass.c b/net/eth-uclass.c index f41da4b37b3..b01a910938e 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c @@ -38,9 +38,12 @@ struct eth_device_priv { * struct eth_uclass_priv - The structure attached to the uclass itself * * @current: The Ethernet device that the network functions are using + * @no_bootdevs: true to skip binding Ethernet bootdevs (this is a negative flag + * so that the default value enables it) */ struct eth_uclass_priv { struct udevice *current; + bool no_bootdevs; }; /* eth_errno - This stores the most recent failure code from DM functions */ @@ -59,6 +62,14 @@ static struct eth_uclass_priv *eth_get_uclass_priv(void) return uclass_get_priv(uc); } +void eth_set_enable_bootdevs(bool enable) +{ + struct eth_uclass_priv *priv = eth_get_uclass_priv(); + + if (priv) + priv->no_bootdevs = !enable; +} + void eth_set_current_to_next(void) { struct eth_uclass_priv *uc_priv; @@ -477,6 +488,7 @@ int eth_initialize(void) static int eth_post_bind(struct udevice *dev) { + struct eth_uclass_priv *priv = uclass_get_priv(dev->uclass); int ret; if (strchr(dev->name, ' ')) { @@ -488,7 +500,7 @@ static int eth_post_bind(struct udevice *dev) #ifdef CONFIG_DM_ETH_PHY eth_phy_binds_nodes(dev); #endif - if (CONFIG_IS_ENABLED(BOOTDEV_ETH)) { + if (CONFIG_IS_ENABLED(BOOTDEV_ETH) && !priv->no_bootdevs) { ret = bootdev_setup_for_dev(dev, "eth_bootdev"); if (ret) return log_msg_ret("bootdev", ret); diff --git a/test/test-main.c b/test/test-main.c index 72aa3a0aa8f..9d0f6643d5e 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -303,8 +304,13 @@ static int test_pre_run(struct unit_test_state *uts, struct unit_test *test) ut_assertok(do_autoprobe(uts)); if (!CONFIG_IS_ENABLED(OF_PLATDATA) && - (test->flags & UT_TESTF_SCAN_FDT)) + (test->flags & UT_TESTF_SCAN_FDT)) { + /* + * only set this if we know the ethernet uclass will be created + */ + eth_set_enable_bootdevs(test->flags & UT_TESTF_ETH_BOOTDEV); ut_assertok(dm_extended_scan(false)); + } /* * Do this after FDT scan since dm_scan_other() in bootstd-uclass.c -- 2.39.0.rc0.267.gcb52ba06e7-goog