[PATCH v11 04/29] sandbox: add dummy driver ETH_SANDBOX_LWIP

Ilias Apalodimas ilias.apalodimas at linaro.org
Fri Oct 4 09:13:09 CEST 2024


On Thu, 3 Oct 2024 at 18:23, Jerome Forissier
<jerome.forissier at linaro.org> wrote:
>
> Introduce ETH_SANDBOX_LWIP which enables a mock driver similar to
> ETH_SANDOX but without the dependencies on the legacy network stack
> (NET) so that it may be enabled when the lwIP stack (NET_LWIP) is
> introduced. The driver does nothing at this stage but its presence
> will allow dm_test_iommu_noiommu [1] to pass.
>
> [1] ./u-boot -T -c "ut dm dm_test_iommu_noiommu"
>
> Signed-off-by: Jerome Forissier <jerome.forissier at linaro.org>
> ---
>  drivers/net/Kconfig        | 11 +++++
>  drivers/net/Makefile       |  1 +
>  drivers/net/sandbox-lwip.c | 85 ++++++++++++++++++++++++++++++++++++++
>  3 files changed, 97 insertions(+)
>  create mode 100644 drivers/net/sandbox-lwip.c
>
> diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
> index e7d0ddfe25a..2f39ec05ac7 100644
> --- a/drivers/net/Kconfig
> +++ b/drivers/net/Kconfig
> @@ -350,6 +350,17 @@ config ETH_SANDBOX
>
>           This driver is particularly useful in the test/dm/eth.c tests
>
> +config ETH_SANDBOX_LWIP
> +       depends on SANDBOX
> +       depends on NET_LWIP
> +       default y
> +       bool "Sandbox: Mocked Ethernet driver (for NET_LWIP)"
> +       help
> +         This driver is meant as a replacement for ETH_SANDBOX when
> +         the network stack is NET_LWIP rather than NET. It currently
> +         does nothing, i.e. it drops the sent packets and never receives
> +         data.
> +
>  config ETH_SANDBOX_RAW
>         depends on SANDBOX
>         default y
> diff --git a/drivers/net/Makefile b/drivers/net/Makefile
> index 4946a63f80f..f5ab1f5dedf 100644
> --- a/drivers/net/Makefile
> +++ b/drivers/net/Makefile
> @@ -39,6 +39,7 @@ obj-$(CONFIG_ETH_DESIGNWARE_SOCFPGA) += dwmac_socfpga.o
>  obj-$(CONFIG_ETH_SANDBOX) += sandbox.o
>  obj-$(CONFIG_ETH_SANDBOX_RAW) += sandbox-raw-bus.o
>  obj-$(CONFIG_ETH_SANDBOX_RAW) += sandbox-raw.o
> +obj-$(CONFIG_ETH_SANDBOX_LWIP) += sandbox-lwip.o
>  obj-$(CONFIG_FEC_MXC) += fec_mxc.o
>  obj-$(CONFIG_FMAN_ENET) += fm/
>  obj-$(CONFIG_FMAN_ENET) += fsl_mdio.o
> diff --git a/drivers/net/sandbox-lwip.c b/drivers/net/sandbox-lwip.c
> new file mode 100644
> index 00000000000..3721033c310
> --- /dev/null
> +++ b/drivers/net/sandbox-lwip.c
> @@ -0,0 +1,85 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2015 National Instruments
> + *
> + * (C) Copyright 2015
> + * Joe Hershberger <joe.hershberger at ni.com>
> + */
> +
> +#include <dm.h>
> +#include <log.h>
> +#include <malloc.h>
> +#include <net.h>
> +#include <asm/eth.h>
> +#include <asm/global_data.h>
> +#include <asm/test.h>
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +static int sb_lwip_eth_start(struct udevice *dev)
> +{
> +       debug("eth_sandbox_lwip: Start\n");
> +
> +       return 0;
> +}
> +
> +static int sb_lwip_eth_send(struct udevice *dev, void *packet, int length)
> +{
> +       debug("eth_sandbox_lwip: Send packet %d\n", length);
> +
> +       return -ENOTSUPP;
> +}
> +
> +static int sb_lwip_eth_recv(struct udevice *dev, int flags, uchar **packetp)
> +{
> +       return -EAGAIN;
> +}
> +
> +static int sb_lwip_eth_free_pkt(struct udevice *dev, uchar *packet, int length)
> +{
> +       return 0;
> +}
> +
> +static void sb_lwip_eth_stop(struct udevice *dev)
> +{
> +}
> +
> +static int sb_lwip_eth_write_hwaddr(struct udevice *dev)
> +{
> +       return 0;
> +}
> +
> +static const struct eth_ops sb_eth_ops = {
> +       .start                  = sb_lwip_eth_start,
> +       .send                   = sb_lwip_eth_send,
> +       .recv                   = sb_lwip_eth_recv,
> +       .free_pkt               = sb_lwip_eth_free_pkt,
> +       .stop                   = sb_lwip_eth_stop,
> +       .write_hwaddr           = sb_lwip_eth_write_hwaddr,
> +};
> +
> +static int sb_lwip_eth_remove(struct udevice *dev)
> +{
> +       return 0;
> +}
> +
> +static int sb_lwip_eth_of_to_plat(struct udevice *dev)
> +{
> +       return 0;
> +}
> +
> +static const struct udevice_id sb_eth_ids[] = {
> +       { .compatible = "sandbox,eth" },
> +       { }
> +};
> +
> +U_BOOT_DRIVER(eth_sandbox) = {
> +       .name   = "eth_lwip_sandbox",
> +       .id     = UCLASS_ETH,
> +       .of_match = sb_eth_ids,
> +       .of_to_plat = sb_lwip_eth_of_to_plat,
> +       .remove = sb_lwip_eth_remove,
> +       .ops    = &sb_eth_ops,
> +       .priv_auto      = 0,
> +       .plat_auto      = sizeof(struct eth_pdata),
> +};
> --
> 2.40.1
>

Acked-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>


More information about the U-Boot mailing list