summaryrefslogtreecommitdiff
path: root/drivers/net/sandbox-lwip.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2024-10-16 08:12:28 -0600
committerTom Rini <trini@konsulko.com>2024-10-16 11:11:57 -0600
commit608a31bdec6284ad6f821226e4c62c9cd3052874 (patch)
treec43e6664c7530f354f73c05cb817e37d10d93615 /drivers/net/sandbox-lwip.c
parent1ca0ddb643f3b152439f7bb8f6ee3f5826d7102d (diff)
parent4820cb4b16c44ec332b18dbe7207ddd8c0a1d446 (diff)
Merge patch series "Introduce the lwIP network stack"
Jerome Forissier <jerome.forissier@linaro.org> says: This is a rework of a patch series by Maxim Uvarov: "net/lwip: add lwip library for the network stack" [1]. The goal is to introduce the lwIP TCP/IP stack [2] [3] as an alternative to the current implementation in net/, selectable with Kconfig, and ultimately keep only lwIP if possible. Some reasons for doing so are: - Make the support of HTTPS in the wget command easier. Javier T. and Raymond M. (CC'd) have some additional lwIP and Mbed TLS patches to do so. With that it becomes possible to fetch and launch a distro installer such as Debian etc. using a secure, authenticated connection directly from the U-Boot shell. Several use cases: * Authentication: prevent MITM attack (third party replacing the binary with a different one) * Confidentiality: prevent third parties from grabbing a copy of the image as it is being downloaded * Allow connection to servers that do not support plain HTTP anymore (this is becoming more and more common on the Internet these days) - Possibly benefit from additional features implemented in lwIP - Less code to maintain in U-Boot Prior to applying this series, the lwIP stack needs to be added as a Git subtree with the following command: $ git subtree add --squash --prefix lib/lwip/lwip \ https://github.com/lwip-tcpip/lwip.git STABLE-2_2_0_RELEASE Notes 1. A number of features are currently incompatible with NET_LWIP: DFU_TFTP, FASTBOOT, SPL_NET, ETH_SANDBOX, ETH_SANDBOX_RAW, DM_ETH. They all make assumptions on how the network stack is implemented and/or pull sybols that are not trivially exported from lwIP. Some interface rework may be needed. 2. Due to the above, and in order to provide some level of testing of the lwIP code in CI even when the legacy NET is the default, a new QEMU configuration is introduced (qemu_arm64_lwip_defconfig) which is based on qemu_arm64_defconfig with NET_LWIP and CMD_*_LWIP enabled. In addition to that, this series has some [TESTING] patches which make NET_LWIP the default. [1] https://lore.kernel.org/all/20231127125726.3735-1-maxim.uvarov@linaro.org/ [2] https://www.nongnu.org/lwip/ [3] https://en.wikipedia.org/wiki/LwIP Link: https://lore.kernel.org/r/cover.1729070678.git.jerome.forissier@linaro.org
Diffstat (limited to 'drivers/net/sandbox-lwip.c')
-rw-r--r--drivers/net/sandbox-lwip.c85
1 files changed, 85 insertions, 0 deletions
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@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),
+};