summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2025-08-18 10:54:44 -0600
committerTom Rini <trini@konsulko.com>2025-08-18 10:54:44 -0600
commit54fbdd408873413af86d86de03a490c5abf280f1 (patch)
tree4f08a3a23bfd457590b733893a082b15f817698d
parent6dee9a5b74972d18b0c554f31907dd0043b9e9f9 (diff)
parentc4526c390a3c4ea1c4f244b6436ebbb74902769a (diff)
Merge tag 'net-20250818' of https://source.denx.de/u-boot/custodians/u-boot-net
Pull request net-20250818. This is mostly code cleanup and fixes, mainly for issues reported by the Smatch tool, plus two small features for NET_LWIP as well as support for the BCM54612E phy. net-common: - Fix a bunch of issues reported by Smatch - Introduce CONFIG_DNS - Add support for BCM54612E phy net-legacy: - Add missing SPDX-License-Identifier for files originating from LiMon net-lwip: - ping: initialize net_try_count to 1 - sntp: remove redundant sys_check_timeouts() - tftp: resend initial request - Add Kconfig option to show ICMP unreachable errors
-rw-r--r--cmd/Kconfig2
-rw-r--r--cmd/lwip/dns.c108
-rw-r--r--cmd/lwip/ping.c1
-rw-r--r--cmd/lwip/sntp.c1
-rw-r--r--doc/usage/cmd/sntp.rst8
-rw-r--r--doc/usage/cmd/wget.rst2
-rw-r--r--drivers/net/cortina_ni.c2
-rw-r--r--drivers/net/designware.c4
-rw-r--r--drivers/net/ks8851_mll.c5
-rw-r--r--drivers/net/ldpaa_eth/ldpaa_eth.c2
-rw-r--r--drivers/net/mtk_eth/mtk_eth.c2
-rw-r--r--drivers/net/mv88e6xxx.c2
-rw-r--r--drivers/net/mvpp2.c9
-rw-r--r--drivers/net/octeontx/nicvf_main.c51
-rw-r--r--drivers/net/octeontx/smi.c12
-rw-r--r--drivers/net/octeontx2/nix.c2
-rw-r--r--drivers/net/octeontx2/rvu_af.c2
-rw-r--r--drivers/net/phy/broadcom.c37
-rw-r--r--drivers/net/phy/vitesse.c2
-rw-r--r--drivers/phy/cadence/phy-cadence-sierra.c13
-rw-r--r--drivers/phy/cadence/phy-cadence-torrent.c1
-rw-r--r--drivers/phy/marvell/comphy_core.c4
-rw-r--r--drivers/phy/marvell/comphy_core.h4
-rw-r--r--include/net-legacy.h5
-rw-r--r--include/net-lwip.h2
-rw-r--r--include/net/tftp.h2
-rw-r--r--lib/lwip/lwip/src/apps/tftp/tftp.c74
-rw-r--r--lib/lwip/lwip/src/core/ipv4/icmp.c17
-rw-r--r--lib/lwip/u-boot/arch/cc.h7
-rw-r--r--lib/lwip/u-boot/lwipopts.h4
-rw-r--r--net/Kconfig8
-rw-r--r--net/Makefile2
-rw-r--r--net/arp.c3
-rw-r--r--net/arp.h3
-rw-r--r--net/bootp.c2
-rw-r--r--net/bootp.h2
-rw-r--r--net/cdp.c3
-rw-r--r--net/cdp.h3
-rw-r--r--net/lwip/Kconfig13
-rw-r--r--net/lwip/Makefile2
-rw-r--r--net/lwip/dns.c113
-rw-r--r--net/lwip/icmp_unreach.c38
-rw-r--r--net/lwip/net-lwip.c8
-rw-r--r--net/net.c13
-rw-r--r--net/net_rand.h2
-rw-r--r--net/ping.c3
-rw-r--r--net/ping.h3
-rw-r--r--net/wget.c2
48 files changed, 395 insertions, 215 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 1a7dba2a27d..29de857ba7c 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -2117,7 +2117,7 @@ config CMD_DHCP
config CMD_DNS
bool "dns"
- select PROT_DNS_LWIP if NET_LWIP
+ select DNS
help
Lookup the IP of a hostname
diff --git a/cmd/lwip/dns.c b/cmd/lwip/dns.c
index b5fccc7433e..3eb698b3f82 100644
--- a/cmd/lwip/dns.c
+++ b/cmd/lwip/dns.c
@@ -2,115 +2,7 @@
/* Copyright (C) 2024 Linaro Ltd. */
#include <command.h>
-#include <console.h>
-#include <env.h>
-#include <lwip/dns.h>
-#include <lwip/timeouts.h>
#include <net.h>
-#include <time.h>
U_BOOT_CMD(dns, 3, 1, do_dns, "lookup the IP of a hostname",
"hostname [envvar]");
-
-#define DNS_RESEND_MS 1000
-#define DNS_TIMEOUT_MS 10000
-
-struct dns_cb_arg {
- ip_addr_t host_ipaddr;
- const char *var;
- bool done;
-};
-
-static void do_dns_tmr(void *arg)
-{
- dns_tmr();
-}
-
-static void dns_cb(const char *name, const ip_addr_t *ipaddr, void *arg)
-{
- struct dns_cb_arg *dns_cb_arg = arg;
- char *ipstr = ip4addr_ntoa(ipaddr);
-
- dns_cb_arg->done = true;
-
- if (!ipaddr) {
- printf("DNS: host not found\n");
- dns_cb_arg->host_ipaddr.addr = 0;
- return;
- }
-
- dns_cb_arg->host_ipaddr.addr = ipaddr->addr;
-
- if (dns_cb_arg->var)
- env_set(dns_cb_arg->var, ipstr);
-}
-
-static int dns_loop(struct udevice *udev, const char *name, const char *var)
-{
- struct dns_cb_arg dns_cb_arg = { };
- struct netif *netif;
- ip_addr_t ipaddr;
- ulong start;
- int ret;
-
- dns_cb_arg.var = var;
-
- netif = net_lwip_new_netif(udev);
- if (!netif)
- return CMD_RET_FAILURE;
-
- if (net_lwip_dns_init()) {
- net_lwip_remove_netif(netif);
- return CMD_RET_FAILURE;
- }
-
- dns_cb_arg.done = false;
-
- ret = dns_gethostbyname(name, &ipaddr, dns_cb, &dns_cb_arg);
-
- if (ret == ERR_OK) {
- dns_cb(name, &ipaddr, &dns_cb_arg);
- } else if (ret == ERR_INPROGRESS) {
- start = get_timer(0);
- sys_timeout(DNS_RESEND_MS, do_dns_tmr, NULL);
- do {
- net_lwip_rx(udev, netif);
- if (dns_cb_arg.done)
- break;
- if (ctrlc()) {
- printf("\nAbort\n");
- break;
- }
- } while (get_timer(start) < DNS_TIMEOUT_MS);
- sys_untimeout(do_dns_tmr, NULL);
- }
-
- net_lwip_remove_netif(netif);
-
- if (dns_cb_arg.done && dns_cb_arg.host_ipaddr.addr != 0) {
- if (!var)
- printf("%s\n", ipaddr_ntoa(&ipaddr));
- return CMD_RET_SUCCESS;
- }
-
- return CMD_RET_FAILURE;
-}
-
-int do_dns(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
-{
- char *name;
- char *var = NULL;
-
- if (argc == 1 || argc > 3)
- return CMD_RET_USAGE;
-
- name = argv[1];
-
- if (argc == 3)
- var = argv[2];
-
- if (net_lwip_eth_start() < 0)
- return CMD_RET_FAILURE;
-
- return dns_loop(eth_get_dev(), name, var);
-}
diff --git a/cmd/lwip/ping.c b/cmd/lwip/ping.c
index 87f8e958e48..6d090fc530d 100644
--- a/cmd/lwip/ping.c
+++ b/cmd/lwip/ping.c
@@ -170,6 +170,7 @@ int do_ping(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
if (net_lwip_dns_resolve(argv[1], &addr))
return CMD_RET_USAGE;
+ net_try_count = 1;
restart:
if (net_lwip_eth_start() < 0 || ping_loop(eth_get_dev(), &addr) < 0) {
if (net_start_again() == 0)
diff --git a/cmd/lwip/sntp.c b/cmd/lwip/sntp.c
index ae02bb11040..608345c873b 100644
--- a/cmd/lwip/sntp.c
+++ b/cmd/lwip/sntp.c
@@ -79,7 +79,6 @@ static int sntp_loop(struct udevice *udev, ip_addr_t *srvip)
sys_timeout(SNTP_TIMEOUT, no_response, NULL);
while (sntp_state == NOT_DONE) {
net_lwip_rx(udev, netif);
- sys_check_timeouts();
if (ctrlc()) {
printf("\nAbort\n");
sntp_state = ABORTED;
diff --git a/doc/usage/cmd/sntp.rst b/doc/usage/cmd/sntp.rst
index d97f83053f7..2046828130d 100644
--- a/doc/usage/cmd/sntp.rst
+++ b/doc/usage/cmd/sntp.rst
@@ -12,7 +12,7 @@ Synopsis
::
sntp [serverip]
- sntp [servername] # NET_LWIP=y && CMD_DNS=y only
+ sntp [servername] # NET_LWIP=y && DNS=y only
Description
@@ -27,8 +27,8 @@ The address of the NTP server does not need to be given if the DHCP server
provides one. The legacy network stack (`CONFIG_NET=y`) can only use the
first NTP server provided in the `ntp-servers` DHCP option.
-When the network stack is lwIP (`CONFIG_NET_LWIP=y`) and the dns command
-is enabled (`CONFIG_CMD_DNS=y`), then the sntp command accepts a server
+When the network stack is lwIP (`CONFIG_NET_LWIP=y`) and DNS resolution
+is enabled (`CONFIG_DNS=y`), then the sntp command accepts a server
name as an argument.
The network time is sent as UTC. So, if you want to set the RTC to any local
@@ -61,7 +61,7 @@ Examples
=> date
Date: 2025-06-16 (Monday) Time: 17:19:57
-With `CONFIG_NET_LWIP=y` and `CONFIG_CMD_DNS=y`:
+With `CONFIG_NET_LWIP=y` and `CONFIG_DNS=y`:
::
diff --git a/doc/usage/cmd/wget.rst b/doc/usage/cmd/wget.rst
index 06df2842549..8feda0248b2 100644
--- a/doc/usage/cmd/wget.rst
+++ b/doc/usage/cmd/wget.rst
@@ -38,7 +38,7 @@ address
memory address for the data downloaded
host
- IP address (or host name if `CONFIG_CMD_DNS` is enabled) of the HTTP
+ IP address (or host name if `CONFIG_DNS` is enabled) of the HTTP
server, defaults to the value of environment variable *serverip*.
path
diff --git a/drivers/net/cortina_ni.c b/drivers/net/cortina_ni.c
index 79026882800..21b7089176c 100644
--- a/drivers/net/cortina_ni.c
+++ b/drivers/net/cortina_ni.c
@@ -499,7 +499,7 @@ static int ca_phy_probe(struct udevice *dev)
dev, priv->phy_interface);
if (ext_phydev) {
ext_phydev->supported &= PHY_GBIT_FEATURES;
- ext_phydev->advertising = int_phydev->supported;
+ ext_phydev->advertising = ext_phydev->supported;
phy_config(ext_phydev);
} else {
printf("CA NI %s: There is no external phy device\n", __func__);
diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index fce3ef910cb..7ecedc3d7f0 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -486,7 +486,7 @@ static int dw_adjust_link(struct dw_eth_dev *priv, struct eth_mac_regs *mac_p,
#ifdef CONFIG_ARCH_NPCM8XX
if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
- unsigned int start;
+ ulong start;
/* Indirect access to VR_MII_MMD registers */
writew((VR_MII_MMD >> 9), PCS_BA + PCS_IND_AC);
@@ -532,7 +532,7 @@ int designware_eth_init(struct dw_eth_dev *priv, u8 *enetaddr)
{
struct eth_mac_regs *mac_p = priv->mac_regs_p;
struct eth_dma_regs *dma_p = priv->dma_regs_p;
- unsigned int start;
+ ulong start;
int ret;
writel(readl(&dma_p->busmode) | DMAMAC_SRST, &dma_p->busmode);
diff --git a/drivers/net/ks8851_mll.c b/drivers/net/ks8851_mll.c
index cc2e826257a..2c956154d09 100644
--- a/drivers/net/ks8851_mll.c
+++ b/drivers/net/ks8851_mll.c
@@ -347,11 +347,6 @@ static int ks8851_mll_detect_chip(struct ks_net *ks)
debug("Read back KS8851 id 0x%x\n", val);
- if ((val & 0xfff0) != CIDER_ID) {
- printf(DRIVERNAME ": Unknown chip ID %04x\n", val);
- return -1;
- }
-
return 0;
}
diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c b/drivers/net/ldpaa_eth/ldpaa_eth.c
index b72198ca530..94e62748239 100644
--- a/drivers/net/ldpaa_eth/ldpaa_eth.c
+++ b/drivers/net/ldpaa_eth/ldpaa_eth.c
@@ -458,7 +458,7 @@ static int ldpaa_eth_open(struct udevice *dev)
link_state.up == 1 ? printf("up\n") : printf("error state\n");
#endif
- memset(&d_queue, 0, sizeof(struct dpni_queue));
+ memset(&d_queue, 0, sizeof(struct dpni_queue_id));
err = dpni_get_queue(dflt_mc_io, MC_CMD_NO_FLAGS,
dflt_dpni->dpni_handle, DPNI_QUEUE_RX,
0, 0, &d_queue_cfg, &d_queue);
diff --git a/drivers/net/mtk_eth/mtk_eth.c b/drivers/net/mtk_eth/mtk_eth.c
index 5d6a42bceb4..b172838ba3a 100644
--- a/drivers/net/mtk_eth/mtk_eth.c
+++ b/drivers/net/mtk_eth/mtk_eth.c
@@ -1461,7 +1461,7 @@ static int mtk_eth_of_to_plat(struct udevice *dev)
priv->phy_addr = ofnode_read_s32_default(args.node, "reg", -1);
if (priv->phy_addr < 0) {
printf("error: phy address is not specified\n");
- return ret;
+ return priv->phy_addr;
}
}
diff --git a/drivers/net/mv88e6xxx.c b/drivers/net/mv88e6xxx.c
index 557b6b2c8f6..f06c73c20f8 100644
--- a/drivers/net/mv88e6xxx.c
+++ b/drivers/net/mv88e6xxx.c
@@ -631,7 +631,7 @@ static int mv88e6xxx_port_enable(struct udevice *dev, int port, struct phy_devic
dev_dbg(dev, "configure internal RGMII delays\n");
/* RGMII delays */
- val &= ~(PORT_REG_PHYS_CTRL_RGMII_DELAY_RXCLK ||
+ val &= ~(PORT_REG_PHYS_CTRL_RGMII_DELAY_RXCLK |
PORT_REG_PHYS_CTRL_RGMII_DELAY_TXCLK);
if (phy->interface == PHY_INTERFACE_MODE_RGMII_ID ||
phy->interface == PHY_INTERFACE_MODE_RGMII_RXID)
diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index 184c1f9a46a..f9e979c4d58 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -1722,8 +1722,7 @@ static struct mvpp2_prs_entry *mvpp2_prs_flow_find(struct mvpp2 *priv, int flow)
}
/* Return first free tcam index, seeking from start to end */
-static int mvpp2_prs_tcam_first_free(struct mvpp2 *priv, unsigned char start,
- unsigned char end)
+static int mvpp2_prs_tcam_first_free(struct mvpp2 *priv, int start, int end)
{
int tid;
@@ -2330,7 +2329,7 @@ static int mvpp2_prs_mac_da_accept(struct mvpp2 *priv, int port,
pe = kzalloc(sizeof(*pe), GFP_KERNEL);
if (!pe)
- return -1;
+ return -ENOMEM;
mvpp2_prs_tcam_lu_set(pe, MVPP2_PRS_LU_MAC);
pe->index = tid;
@@ -4735,7 +4734,7 @@ static int phy_info_parse(struct udevice *dev, struct mvpp2_port *port)
int port_node = dev_of_offset(dev);
int phy_node;
u32 id;
- u32 phyaddr = 0;
+ int phyaddr = 0;
int fixed_link = 0;
int ret;
@@ -5354,7 +5353,7 @@ static int mvpp2_probe(struct udevice *dev)
} else {
port->gop_id = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"gop-port-id", -1);
- if (port->id == -1) {
+ if (port->gop_id == -1) {
dev_err(dev, "missing gop-port-id value\n");
return -EINVAL;
}
diff --git a/drivers/net/octeontx/nicvf_main.c b/drivers/net/octeontx/nicvf_main.c
index 27d0327c88a..94e5d827614 100644
--- a/drivers/net/octeontx/nicvf_main.c
+++ b/drivers/net/octeontx/nicvf_main.c
@@ -232,7 +232,7 @@ static int nicvf_rcv_pkt_handler(struct nicvf *nic,
size_t pkt_len;
struct cqe_rx_t *cqe_rx = (struct cqe_rx_t *)cq_desc;
- int err = 0;
+ int err;
/* Check for errors */
err = nicvf_check_cqe_rx_errs(nic, cq, cq_desc);
@@ -245,8 +245,7 @@ static int nicvf_rcv_pkt_handler(struct nicvf *nic,
return -1;
}
- if (pkt)
- *ppkt = pkt;
+ *ppkt = pkt;
return pkt_len;
}
@@ -274,31 +273,29 @@ int nicvf_cq_handler(struct nicvf *nic, void **ppkt, int *pkt_len)
cqe_head >>= 9;
cqe_head &= 0xFFFF;
- if (cqe_count) {
- /* Get the CQ descriptor */
- cq_desc = (struct cqe_rx_t *)GET_CQ_DESC(cq, cqe_head);
- cqe_head++;
- cqe_head &= (cq->dmem.q_len - 1);
-
- switch (cq_desc->cqe_type) {
- case CQE_TYPE_RX:
- debug("%s: Got Rx CQE\n", nic->dev->name);
- *pkt_len = nicvf_rcv_pkt_handler(nic, cq, cq_desc,
- ppkt, CQE_TYPE_RX);
- processed_rq_cqe++;
- break;
- case CQE_TYPE_SEND:
- debug("%s: Got Tx CQE\n", nic->dev->name);
- nicvf_snd_pkt_handler(nic, cq, cq_desc, CQE_TYPE_SEND);
- processed_sq_cqe++;
- break;
- default:
- debug("%s: Got CQ type %u\n", nic->dev->name,
- cq_desc->cqe_type);
- break;
- }
- processed_cqe++;
+ /* Get the CQ descriptor */
+ cq_desc = (struct cqe_rx_t *)GET_CQ_DESC(cq, cqe_head);
+ cqe_head++;
+ cqe_head &= (cq->dmem.q_len - 1);
+
+ switch (cq_desc->cqe_type) {
+ case CQE_TYPE_RX:
+ debug("%s: Got Rx CQE\n", nic->dev->name);
+ *pkt_len = nicvf_rcv_pkt_handler(nic, cq, cq_desc,
+ ppkt, CQE_TYPE_RX);
+ processed_rq_cqe++;
+ break;
+ case CQE_TYPE_SEND:
+ debug("%s: Got Tx CQE\n", nic->dev->name);
+ nicvf_snd_pkt_handler(nic, cq, cq_desc, CQE_TYPE_SEND);
+ processed_sq_cqe++;
+ break;
+ default:
+ debug("%s: Got CQ type %u\n", nic->dev->name,
+ cq_desc->cqe_type);
+ break;
}
+ processed_cqe++;
/* Dequeue CQE */
nicvf_queue_reg_write(nic, NIC_QSET_CQ_0_7_DOOR,
diff --git a/drivers/net/octeontx/smi.c b/drivers/net/octeontx/smi.c
index 233c26f7319..217bcac2ce2 100644
--- a/drivers/net/octeontx/smi.c
+++ b/drivers/net/octeontx/smi.c
@@ -338,7 +338,8 @@ int octeontx_smi_probe(struct udevice *dev)
if (!bus || !priv) {
printf("Failed to allocate OcteonTX MDIO bus # %u\n",
dev_seq(dev));
- return -1;
+ ret = -ENOMEM;
+ goto error_ret;
}
bus->read = octeontx_phy_read;
@@ -355,9 +356,16 @@ int octeontx_smi_probe(struct udevice *dev)
ret = mdio_register(bus);
if (ret)
- return ret;
+ goto error_ret;
}
return 0;
+
+error_ret:
+ if (bus)
+ free(bus);
+ if (priv)
+ free(priv);
+ return ret;
}
static const struct udevice_id octeontx_smi_ids[] = {
diff --git a/drivers/net/octeontx2/nix.c b/drivers/net/octeontx2/nix.c
index f596b6bca87..87d1f7a5dbf 100644
--- a/drivers/net/octeontx2/nix.c
+++ b/drivers/net/octeontx2/nix.c
@@ -298,6 +298,8 @@ int nix_lf_setup(struct nix *nix)
goto error;
}
+ err = -1;
+
/* Alloc memory for Qints HW contexts */
nix->qint_base = nix_memalloc(nix_af->qints, nix_af->qint_ctx_sz,
"Qint CTX");
diff --git a/drivers/net/octeontx2/rvu_af.c b/drivers/net/octeontx2/rvu_af.c
index 0d3a9ffe9ee..7bdfbc52e3b 100644
--- a/drivers/net/octeontx2/rvu_af.c
+++ b/drivers/net/octeontx2/rvu_af.c
@@ -114,7 +114,7 @@ struct nix_af *rvu_af_init(struct rvu_af *rvu_af)
return nix_af;
error:
- if (nix_af->npa_af) {
+ if (nix_af && nix_af->npa_af) {
free(nix_af->npa_af);
memset(nix_af, 0, sizeof(*nix_af));
}
diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
index 0a49015eb89..1c02e3efedc 100644
--- a/drivers/net/phy/broadcom.c
+++ b/drivers/net/phy/broadcom.c
@@ -134,6 +134,33 @@ static void bcm_phy_write_misc(struct phy_device *phydev,
phy_write(phydev, MDIO_DEVAD_NONE, MIIM_BCM54XX_EXP_DATA, value);
}
+/* Broadcom BCM54612E */
+static int bcm54612e_config(struct phy_device *phydev)
+{
+ u32 reg = 0;
+
+ genphy_config_aneg(phydev);
+
+ phy_reset(phydev);
+
+ /* 125Mhz Clock Output Enable */
+ reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_BCM54XX_EXP_SEL);
+ reg |= 0xD34;
+ phy_write(phydev, MDIO_DEVAD_NONE, MIIM_BCM54XX_EXP_SEL, reg);
+
+ reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_BCM54XX_EXP_DATA);
+ reg |= (1 << 1);
+ phy_write(phydev, MDIO_DEVAD_NONE, MIIM_BCM54XX_EXP_DATA, reg);
+
+ reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_BCM54XX_EXP_SEL);
+ reg &= 0xfffff000;
+ phy_write(phydev, MDIO_DEVAD_NONE, MIIM_BCM54XX_EXP_SEL, reg);
+
+ genphy_restart_aneg(phydev);
+
+ return 0;
+}
+
/* Broadcom BCM5461S */
static int bcm5461_config(struct phy_device *phydev)
{
@@ -434,6 +461,16 @@ U_BOOT_PHY_DRIVER(bcm5461s) = {
.shutdown = &genphy_shutdown,
};
+U_BOOT_PHY_DRIVER(bcm54612e) = {
+ .name = "Broadcom BCM54612E",
+ .uid = 0x03625e6a,
+ .mask = 0xfffff0,
+ .features = PHY_GBIT_FEATURES,
+ .config = &bcm54612e_config,
+ .startup = &bcm54xx_startup,
+ .shutdown = &genphy_shutdown,
+};
+
U_BOOT_PHY_DRIVER(bcm5464s) = {
.name = "Broadcom BCM5464S",
.uid = 0x2060b0,
diff --git a/drivers/net/phy/vitesse.c b/drivers/net/phy/vitesse.c
index 4867d1931b4..821d3878236 100644
--- a/drivers/net/phy/vitesse.c
+++ b/drivers/net/phy/vitesse.c
@@ -239,7 +239,7 @@ static int vsc8514_config(struct phy_device *phydev)
while ((val & MIIM_VSC8514_18G_CMDSTAT) && timeout--)
val = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_VSC8514_GENERAL18);
- if (0 == timeout) {
+ if (timeout == -1) {
printf("PHY 8514 config failed\n");
return -1;
}
diff --git a/drivers/phy/cadence/phy-cadence-sierra.c b/drivers/phy/cadence/phy-cadence-sierra.c
index 2c9d5a12127..bd7ab9d1b77 100644
--- a/drivers/phy/cadence/phy-cadence-sierra.c
+++ b/drivers/phy/cadence/phy-cadence-sierra.c
@@ -225,11 +225,6 @@ static const struct reg_field pllctrl_lock =
static const struct reg_field phy_iso_link_ctrl_1 =
REG_FIELD(SIERRA_PHY_ISO_LINK_CTRL, 1, 1);
-static const char * const clk_names[] = {
- [CDNS_SIERRA_PLL_CMNLC] = "pll_cmnlc",
- [CDNS_SIERRA_PLL_CMNLC1] = "pll_cmnlc1",
-};
-
enum cdns_sierra_cmn_plllc {
CMN_PLLLC,
CMN_PLLLC1,
@@ -602,7 +597,7 @@ static int cdns_sierra_pll_bind_of_clocks(struct cdns_sierra_phy *sp)
struct udevice *dev = sp->dev;
struct driver *cdns_sierra_clk_drv;
struct cdns_sierra_pll_mux_sel *data = pll_clk_mux_sel;
- int i, rc;
+ int rc;
cdns_sierra_clk_drv = lists_driver_lookup_name("cdns_sierra_mux_clk");
if (!cdns_sierra_clk_drv) {
@@ -612,10 +607,8 @@ static int cdns_sierra_pll_bind_of_clocks(struct cdns_sierra_phy *sp)
rc = device_bind(dev, cdns_sierra_clk_drv, "pll_mux_clk",
data, dev_ofnode(dev), NULL);
- if (rc) {
- dev_err(dev, "cannot bind driver for clock %s\n",
- clk_names[i]);
- }
+ if (rc)
+ dev_err(dev, "cannot bind driver for clock pll_mux_clk\n");
return 0;
}
diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadence/phy-cadence-torrent.c
index 1f566d082f9..28fe026223c 100644
--- a/drivers/phy/cadence/phy-cadence-torrent.c
+++ b/drivers/phy/cadence/phy-cadence-torrent.c
@@ -719,6 +719,7 @@ static int cdns_torrent_phy_probe(struct udevice *dev)
if (total_num_lanes > MAX_NUM_LANES) {
dev_err(dev, "Invalid lane configuration\n");
+ ret = -EINVAL;
goto put_lnk_rst;
}
diff --git a/drivers/phy/marvell/comphy_core.c b/drivers/phy/marvell/comphy_core.c
index a666a4e794e..a4121423873 100644
--- a/drivers/phy/marvell/comphy_core.c
+++ b/drivers/phy/marvell/comphy_core.c
@@ -28,7 +28,7 @@ static const char *get_speed_string(u32 speed)
"10.3125 Gbps"
};
- if (speed < 0 || speed > COMPHY_SPEED_MAX)
+ if (speed < 0 || speed >= COMPHY_SPEED_MAX)
return "invalid";
return speed_strings[speed];
@@ -44,7 +44,7 @@ static const char *get_type_string(u32 type)
"IGNORE"
};
- if (type < 0 || type > COMPHY_TYPE_MAX)
+ if (type < 0 || type >= COMPHY_TYPE_MAX)
return "invalid";
return type_strings[type];
diff --git a/drivers/phy/marvell/comphy_core.h b/drivers/phy/marvell/comphy_core.h
index f3d04939387..086a4d82f26 100644
--- a/drivers/phy/marvell/comphy_core.h
+++ b/drivers/phy/marvell/comphy_core.h
@@ -47,8 +47,8 @@ struct chip_serdes_phy_config {
int (*rx_training)(struct chip_serdes_phy_config *, u32);
void __iomem *comphy_base_addr;
void __iomem *hpipe3_base_addr;
- u32 comphy_lanes_count;
- u32 comphy_mux_bitcount;
+ int comphy_lanes_count;
+ int comphy_mux_bitcount;
const fdt32_t *comphy_mux_lane_order;
u32 cp_index;
struct comphy_map comphy_map_data[MAX_LANE_OPTIONS];
diff --git a/include/net-legacy.h b/include/net-legacy.h
index a7dbcec1506..9564e97d238 100644
--- a/include/net-legacy.h
+++ b/include/net-legacy.h
@@ -1,9 +1,8 @@
-/* SPDX-License-Identifier: GPL-2.0 */
+/* SPDX-License-Identifier: GPL-2.0-only */
/*
* LiMon Monitor (LiMon) - Network.
*
* Copyright 1994 - 2000 Neil Russell.
- * (See License)
*
* History
* 9/16/00 bor adapted to TQM823L/STK8xxL board, RARP/TFTP boot added
@@ -316,7 +315,7 @@ extern u32 net_boot_file_size;
/* Boot file size in blocks as reported by the DHCP server */
extern u32 net_boot_file_expected_size_in_blocks;
-#if defined(CONFIG_CMD_DNS)
+#if defined(CONFIG_DNS)
extern char *net_dns_resolve; /* The host to resolve */
extern char *net_dns_env_var; /* the env var to put the ip into */
#endif
diff --git a/include/net-lwip.h b/include/net-lwip.h
index f54f23471f1..e88e2186635 100644
--- a/include/net-lwip.h
+++ b/include/net-lwip.h
@@ -18,6 +18,8 @@ extern size_t cacert_size;
extern enum auth_mode cacert_auth_mode;
extern bool cacert_initialized;
+extern int net_try_count;
+
int set_cacert_builtin(void);
enum proto_t {
diff --git a/include/net/tftp.h b/include/net/tftp.h
index c411c9b2e65..c7e14817280 100644
--- a/include/net/tftp.h
+++ b/include/net/tftp.h
@@ -1,10 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
/*
* LiMon - BOOTP/TFTP.
*
* Copyright 1994, 1995, 2000 Neil Russell.
* Copyright 2011 Comelit Group SpA
* Luca Ceresoli <luca.ceresoli@comelit.it>
- * (See License)
*/
#ifndef __TFTP_H__
diff --git a/lib/lwip/lwip/src/apps/tftp/tftp.c b/lib/lwip/lwip/src/apps/tftp/tftp.c
index 63b1e0e0e20..ecb6c55ae11 100644
--- a/lib/lwip/lwip/src/apps/tftp/tftp.c
+++ b/lib/lwip/lwip/src/apps/tftp/tftp.c
@@ -79,6 +79,14 @@ enum tftp_error {
#include <string.h>
+struct tftp_req {
+ ip_addr_t addr;
+ u16_t port;
+ u16_t opcode;
+ enum tftp_transfer_mode mode;
+ char* fname;
+};
+
struct tftp_state {
const struct tftp_context *ctx;
void *handle;
@@ -97,14 +105,33 @@ struct tftp_state {
};
static struct tftp_state tftp_state;
+static struct tftp_req tftp_req;
static void tftp_tmr(void *arg);
+static void tftp_req_tmr(void *arg);
+static const char *mode_to_string(enum tftp_transfer_mode mode);
+
+static void
+clear_req(void)
+{
+ ip_addr_set_any(0, &tftp_req.addr);
+ tftp_req.port = 0;
+ tftp_req.opcode = 0;
+ free(tftp_req.fname);
+ tftp_req.fname = NULL;
+ tftp_req.mode = 0;
+
+ sys_untimeout(tftp_req_tmr, NULL);
+}
static void
close_handle(void)
{
+ clear_req();
+
tftp_state.port = 0;
ip_addr_set_any(0, &tftp_state.addr);
+ tftp_state.retries = 0;
if (tftp_state.last_data != NULL) {
pbuf_free(tftp_state.last_data);
@@ -210,6 +237,12 @@ send_ack(const ip_addr_t *addr, u16_t port, u16_t blknum)
}
static err_t
+resend_request(void)
+{
+ return send_request(&tftp_req.addr, tftp_req.port, tftp_req.opcode, tftp_req.fname, mode_to_string(tftp_req.mode));
+}
+
+static err_t
resend_data(const ip_addr_t *addr, u16_t port)
{
err_t ret;
@@ -336,6 +369,9 @@ tftp_recv(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr
tftp_state.last_pkt = tftp_state.timer;
tftp_state.retries = 0;
+ if (tftp_req.fname)
+ clear_req();
+
switch (opcode) {
case PP_HTONS(TFTP_RRQ): /* fall through */
case PP_HTONS(TFTP_WRQ): {
@@ -542,6 +578,26 @@ tftp_tmr(void *arg)
}
}
+static void
+tftp_req_tmr(void *arg)
+{
+ if (tftp_state.handle == NULL) {
+ return;
+ }
+
+ sys_timeout(TFTP_TIMER_MSECS, tftp_req_tmr, NULL);
+
+ if (tftp_state.retries < TFTP_MAX_RETRIES) {
+ LWIP_DEBUGF(TFTP_DEBUG | LWIP_DBG_STATE, ("tftp: req timeout, retrying\n"));
+ resend_request();
+ tftp_state.retries++;
+ } else {
+ LWIP_DEBUGF(TFTP_DEBUG | LWIP_DBG_STATE, ("tftp: req timeout\n"));
+ tftp_state.ctx->error(tftp_state.handle, -1, "Request timeout", strlen("Request timeout"));
+ close_handle();
+ }
+}
+
/**
* Initialize TFTP client/server.
* @param mode TFTP mode (client/server)
@@ -638,6 +694,20 @@ mode_to_string(enum tftp_transfer_mode mode)
}
err_t
+start_send_requests(const ip_addr_t *addr, u16_t port, u16_t opcode, const char* fname, enum tftp_transfer_mode mode)
+{
+ tftp_req.addr = *addr;
+ tftp_req.port = port;
+ tftp_req.opcode = opcode;
+ tftp_req.fname = strdup(fname);
+ tftp_req.mode = mode;
+ if (!tftp_req.fname)
+ return ERR_MEM;
+ sys_timeout(TFTP_TIMER_MSECS, tftp_req_tmr, NULL);
+ return resend_request();
+}
+
+err_t
tftp_get(void* handle, const ip_addr_t *addr, u16_t port, const char* fname, enum tftp_transfer_mode mode)
{
LWIP_ERROR("TFTP client is not enabled (tftp_init)", (tftp_state.tftp_mode & LWIP_TFTP_MODE_CLIENT) != 0, return ERR_VAL);
@@ -647,7 +717,7 @@ tftp_get(void* handle, const ip_addr_t *addr, u16_t port, const char* fname, enu
tftp_state.handle = handle;
tftp_state.blknum = 1;
tftp_state.mode_write = 1; /* We want to receive data */
- return send_request(addr, port, TFTP_RRQ, fname, mode_to_string(mode));
+ return start_send_requests(addr, port, TFTP_RRQ, fname, mode);
}
err_t
@@ -660,7 +730,7 @@ tftp_put(void* handle, const ip_addr_t *addr, u16_t port, const char* fname, enu
tftp_state.handle = handle;
tftp_state.blknum = 1;
tftp_state.mode_write = 0; /* We want to send data */
- return send_request(addr, port, TFTP_WRQ, fname, mode_to_string(mode));
+ return start_send_requests(addr, port, TFTP_WRQ, fname, mode);
}
#endif /* LWIP_UDP */
diff --git a/lib/lwip/lwip/src/core/ipv4/icmp.c b/lib/lwip/lwip/src/core/ipv4/icmp.c
index 9a82a67aa93..6d588349c4a 100644
--- a/lib/lwip/lwip/src/core/ipv4/icmp.c
+++ b/lib/lwip/lwip/src/core/ipv4/icmp.c
@@ -80,9 +80,9 @@ void
icmp_input(struct pbuf *p, struct netif *inp)
{
u8_t type;
-#ifdef LWIP_DEBUG
+#if defined(LWIP_DEBUG) || defined(ICMP_DEST_UNREACH_CB)
u8_t code;
-#endif /* LWIP_DEBUG */
+#endif
struct icmp_echo_hdr *iecho;
const struct ip_hdr *iphdr_in;
u16_t hlen;
@@ -103,11 +103,11 @@ icmp_input(struct pbuf *p, struct netif *inp)
}
type = *((u8_t *)p->payload);
-#ifdef LWIP_DEBUG
+#if defined(LWIP_DEBUG) || defined(ICMP_DEST_UNREACH_CB)
code = *(((u8_t *)p->payload) + 1);
/* if debug is enabled but debug statement below is somehow disabled: */
LWIP_UNUSED_ARG(code);
-#endif /* LWIP_DEBUG */
+#endif
switch (type) {
case ICMP_ER:
/* This is OK, echo reply might have been parsed by a raw PCB
@@ -257,6 +257,15 @@ icmp_input(struct pbuf *p, struct netif *inp)
default:
if (type == ICMP_DUR) {
MIB2_STATS_INC(mib2.icmpindestunreachs);
+#ifdef ICMP_DEST_UNREACH_CB
+ /*
+ * The callback receives the IP packet (not the ICMP message) so that
+ * it can extract the source address for example
+ */
+ pbuf_add_header(p, IP_HLEN);
+ ICMP_DEST_UNREACH_CB(code, p);
+ pbuf_remove_header(p, IP_HLEN);
+#endif
} else if (type == ICMP_TE) {
MIB2_STATS_INC(mib2.icmpintimeexcds);
} else if (type == ICMP_PP) {
diff --git a/lib/lwip/u-boot/arch/cc.h b/lib/lwip/u-boot/arch/cc.h
index 04ab94d6b70..849c79c5a8d 100644
--- a/lib/lwip/u-boot/arch/cc.h
+++ b/lib/lwip/u-boot/arch/cc.h
@@ -56,4 +56,11 @@ static inline const char *sntp_format_time(time_t t)
}
#define sntp_format_time sntp_format_time
+
+#ifdef CONFIG_LWIP_ICMP_SHOW_UNREACH
+struct pbuf;
+void net_lwip_icmp_dest_unreach(int code, struct pbuf *p);
+
+#define ICMP_DEST_UNREACH_CB(_c, _p) net_lwip_icmp_dest_unreach(_c, _p)
+#endif
#endif /* LWIP_ARCH_CC_H */
diff --git a/lib/lwip/u-boot/lwipopts.h b/lib/lwip/u-boot/lwipopts.h
index 46af91f9410..80b93ea172d 100644
--- a/lib/lwip/u-boot/lwipopts.h
+++ b/lib/lwip/u-boot/lwipopts.h
@@ -80,7 +80,11 @@
#define IP_DEFAULT_TTL 255
+#if defined(CONFIG_PROT_ICMP_LWIP)
+#define LWIP_ICMP 1
+#else
#define LWIP_ICMP 0
+#endif
#if defined(CONFIG_PROT_RAW_LWIP)
#define LWIP_RAW 1
diff --git a/net/Kconfig b/net/Kconfig
index 24508026200..40ec6bbce76 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -244,11 +244,17 @@ config NET_RANDOM_ETHADDR
generated. It will be saved to the appropriate environment variable,
too.
+config DNS
+ bool "Enable DNS resolutions"
+ select PROT_DNS_LWIP if NET_LWIP
+ help
+ Selecting this will allow the network stack to use server names
+ in addition to IP addresses.
+
config WGET
bool "Enable wget"
select PROT_TCP if NET
select PROT_TCP_LWIP if NET_LWIP
- select PROT_DNS_LWIP if NET_LWIP
help
Selecting this will enable wget, an interface to send HTTP requests
via the network stack.
diff --git a/net/Makefile b/net/Makefile
index d63f62b7c8a..468820186cf 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -10,7 +10,7 @@ ifeq ($(CONFIG_NET),y)
obj-$(CONFIG_NET) += arp.o
obj-$(CONFIG_CMD_BOOTP) += bootp.o
obj-$(CONFIG_CMD_CDP) += cdp.o
-obj-$(CONFIG_CMD_DNS) += dns.o
+obj-$(CONFIG_DNS) += dns.o
obj-$(CONFIG_CMD_LINK_LOCAL) += link_local.o
obj-$(CONFIG_IPV6) += ndisc.o
obj-$(CONFIG_$(PHASE_)DM_ETH) += net.o
diff --git a/net/arp.c b/net/arp.c
index bc1e25f941f..4801dca6213 100644
--- a/net/arp.c
+++ b/net/arp.c
@@ -1,9 +1,8 @@
-// SPDX-License-Identifier: GPL-2.0
+// SPDX-License-Identifier: GPL-2.0-only
/*
* Copied from Linux Monitor (LiMon) - Networking.
*
* Copyright 1994 - 2000 Neil Russell.
- * (See License)
* Copyright 2000 Roland Borde
* Copyright 2000 Paolo Scaffardi
* Copyright 2000-2002 Wolfgang Denk, wd@denx.de
diff --git a/net/arp.h b/net/arp.h
index c50885fb9a5..882f3ec31fc 100644
--- a/net/arp.h
+++ b/net/arp.h
@@ -1,9 +1,8 @@
-/* SPDX-License-Identifier: GPL-2.0 */
+/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copied from Linux Monitor (LiMon) - Networking.
*
* Copyright 1994 - 2000 Neil Russell.
- * (See License)
* Copyright 2000 Roland Borde
* Copyright 2000 Paolo Scaffardi
* Copyright 2000-2002 Wolfgang Denk, wd@denx.de
diff --git a/net/bootp.c b/net/bootp.c
index 95d906e3b2d..19e7453daed 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -1,8 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Based on LiMon - BOOTP.
*
* Copyright 1994, 1995, 2000 Neil Russell.
- * (See License)
* Copyright 2000 Roland Borde
* Copyright 2000 Paolo Scaffardi
* Copyright 2000-2004 Wolfgang Denk, wd@denx.de
diff --git a/net/bootp.h b/net/bootp.h
index 68320bf66cf..47c743479e7 100644
--- a/net/bootp.h
+++ b/net/bootp.h
@@ -1,8 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copied from LiMon - BOOTP.
*
* Copyright 1994, 1995, 2000 Neil Russell.
- * (See License)
* Copyright 2000 Paolo Scaffardi
*/
diff --git a/net/cdp.c b/net/cdp.c
index d4cfc587ee3..6e404981d4a 100644
--- a/net/cdp.c
+++ b/net/cdp.c
@@ -1,9 +1,8 @@
-// SPDX-License-Identifier: GPL-2.0
+// SPDX-License-Identifier: GPL-2.0-only
/*
* Copied from Linux Monitor (LiMon) - Networking.
*
* Copyright 1994 - 2000 Neil Russell.
- * (See License)
* Copyright 2000 Roland Borde
* Copyright 2000 Paolo Scaffardi
* Copyright 2000-2002 Wolfgang Denk, wd@denx.de
diff --git a/net/cdp.h b/net/cdp.h
index 16ccbf4b59e..606fabba957 100644
--- a/net/cdp.h
+++ b/net/cdp.h
@@ -1,9 +1,8 @@
-/* SPDX-License-Identifier: GPL-2.0 */
+/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copied from Linux Monitor (LiMon) - Networking.
*
* Copyright 1994 - 2000 Neil Russell.
- * (See License)
* Copyright 2000 Roland Borde
* Copyright 2000 Paolo Scaffardi
* Copyright 2000-2002 Wolfgang Denk, wd@denx.de
diff --git a/net/lwip/Kconfig b/net/lwip/Kconfig
index d28a8a7df94..5789766fe62 100644
--- a/net/lwip/Kconfig
+++ b/net/lwip/Kconfig
@@ -4,6 +4,16 @@
if NET_LWIP
+config LWIP_ICMP_SHOW_UNREACH
+ bool "Print ICMP Destination Unreachable messages"
+ default y
+ depends on CMD_TFTPBOOT || CMD_SNTP
+ select PROT_ICMP_LWIP
+ help
+ Prints a message whenever an ICMP Destination Unreachable message is
+ received while running a network command that sends requests via UDP.
+ Enabling this can make troubleshooting easier.
+
config LWIP_DEBUG
bool "Enable debug traces in the lwIP library"
help
@@ -31,6 +41,9 @@ config PROT_DNS_LWIP
bool
select PROT_UDP_LWIP
+config PROT_ICMP_LWIP
+ bool
+
config PROT_RAW_LWIP
bool
diff --git a/net/lwip/Makefile b/net/lwip/Makefile
index 97299d9b542..1b48ae4d508 100644
--- a/net/lwip/Makefile
+++ b/net/lwip/Makefile
@@ -2,6 +2,8 @@ ccflags-y += -I$(srctree)/lib/lwip/lwip/src/include -I$(srctree)/lib/lwip/u-boot
obj-$(CONFIG_$(PHASE_)DM_ETH) += net-lwip.o
obj-$(CONFIG_CMD_DHCP) += dhcp.o
+obj-$(CONFIG_DNS) += dns.o
+obj-$(CONFIG_LWIP_ICMP_SHOW_UNREACH) += icmp_unreach.o
obj-$(CONFIG_CMD_TFTPBOOT) += tftp.o
obj-$(CONFIG_WGET) += wget.o
diff --git a/net/lwip/dns.c b/net/lwip/dns.c
new file mode 100644
index 00000000000..9964003195f
--- /dev/null
+++ b/net/lwip/dns.c
@@ -0,0 +1,113 @@
+// SPDX-License-Identifier: GPL-2.0+
+/* Copyright (C) 2024 Linaro Ltd. */
+
+#include <command.h>
+#include <console.h>
+#include <env.h>
+#include <lwip/dns.h>
+#include <lwip/timeouts.h>
+#include <net.h>
+#include <time.h>
+
+#define DNS_RESEND_MS 1000
+#define DNS_TIMEOUT_MS 10000
+
+struct dns_cb_arg {
+ ip_addr_t host_ipaddr;
+ const char *var;
+ bool done;
+};
+
+static void do_dns_tmr(void *arg)
+{
+ dns_tmr();
+}
+
+static void dns_cb(const char *name, const ip_addr_t *ipaddr, void *arg)
+{
+ struct dns_cb_arg *dns_cb_arg = arg;
+ char *ipstr = ip4addr_ntoa(ipaddr);
+
+ dns_cb_arg->done = true;
+
+ if (!ipaddr) {
+ printf("DNS: host not found\n");
+ dns_cb_arg->host_ipaddr.addr = 0;
+ return;
+ }
+
+ dns_cb_arg->host_ipaddr.addr = ipaddr->addr;
+
+ if (dns_cb_arg->var)
+ env_set(dns_cb_arg->var, ipstr);
+}
+
+static int dns_loop(struct udevice *udev, const char *name, const char *var)
+{
+ struct dns_cb_arg dns_cb_arg = { };
+ struct netif *netif;
+ ip_addr_t ipaddr;
+ ulong start;
+ int ret;
+
+ dns_cb_arg.var = var;
+
+ netif = net_lwip_new_netif(udev);
+ if (!netif)
+ return CMD_RET_FAILURE;
+
+ if (net_lwip_dns_init()) {
+ net_lwip_remove_netif(netif);
+ return CMD_RET_FAILURE;
+ }
+
+ dns_cb_arg.done = false;
+
+ ret = dns_gethostbyname(name, &ipaddr, dns_cb, &dns_cb_arg);
+
+ if (ret == ERR_OK) {
+ dns_cb(name, &ipaddr, &dns_cb_arg);
+ } else if (ret == ERR_INPROGRESS) {
+ start = get_timer(0);
+ sys_timeout(DNS_RESEND_MS, do_dns_tmr, NULL);
+ do {
+ net_lwip_rx(udev, netif);
+ if (dns_cb_arg.done)
+ break;
+ if (ctrlc()) {
+ printf("\nAbort\n");
+ break;
+ }
+ } while (get_timer(start) < DNS_TIMEOUT_MS);
+ sys_untimeout(do_dns_tmr, NULL);
+ }
+
+ net_lwip_remove_netif(netif);
+
+ if (dns_cb_arg.done && dns_cb_arg.host_ipaddr.addr != 0) {
+ if (!var)
+ printf("%s\n", ipaddr_ntoa(&ipaddr));
+ return CMD_RET_SUCCESS;
+ }
+
+ return CMD_RET_FAILURE;
+}
+
+int do_dns(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+ char *name;
+ char *var = NULL;
+
+ if (argc == 1 || argc > 3)
+ return CMD_RET_USAGE;
+
+ name = argv[1];
+
+ if (argc == 3)
+ var = argv[2];
+
+ if (net_lwip_eth_start() < 0)
+ return CMD_RET_FAILURE;
+
+ return dns_loop(eth_get_dev(), name, var);
+}
diff --git a/net/lwip/icmp_unreach.c b/net/lwip/icmp_unreach.c
new file mode 100644
index 00000000000..9e8a05f5717
--- /dev/null
+++ b/net/lwip/icmp_unreach.c
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0+
+/* Copyright (C) 2025 Linaro Ltd. */
+
+#include <lwip/icmp.h>
+#include <lwip/ip4_addr.h>
+#include <lwip/pbuf.h>
+#include <lwip/prot/ip4.h>
+
+static const char *code_to_str(int code)
+{
+ switch (code) {
+ case ICMP_DUR_NET:
+ return "network unreachable";
+ case ICMP_DUR_HOST:
+ return "host unreachable";
+ case ICMP_DUR_PROTO:
+ return "protocol unreachable";
+ case ICMP_DUR_PORT:
+ return "port unreachable";
+ case ICMP_DUR_FRAG:
+ return "fragmentation needed and DF set";
+ case ICMP_DUR_SR:
+ return "source route failed";
+ default:
+ break;
+ }
+ return "unknown cause";
+}
+
+void net_lwip_icmp_dest_unreach(int code, struct pbuf *p)
+{
+ struct ip_hdr *iphdr = (struct ip_hdr *)p->payload;
+ ip4_addr_t src;
+
+ ip4_addr_copy(src, iphdr->src);
+ printf("ICMP destination unreachable (%s) from %s\n",
+ code_to_str(code), ip4addr_ntoa(&src));
+}
diff --git a/net/lwip/net-lwip.c b/net/lwip/net-lwip.c
index 660ceb10cbe..1a70cedfb58 100644
--- a/net/lwip/net-lwip.c
+++ b/net/lwip/net-lwip.c
@@ -27,7 +27,7 @@
#if defined(CONFIG_API) || defined(CONFIG_EFI_LOADER)
void (*push_packet)(void *, int len) = 0;
#endif
-static int net_try_count;
+int net_try_count;
static int net_restarted;
int net_restart_wrap;
static uchar net_pkt_buf[(PKTBUFSRX) * PKTSIZE_ALIGN + PKTALIGN];
@@ -147,7 +147,7 @@ static int get_udev_ipv4_info(struct udevice *dev, ip4_addr_t *ip,
*/
int net_lwip_dns_init(void)
{
-#if CONFIG_IS_ENABLED(CMD_DNS)
+#if CONFIG_IS_ENABLED(DNS)
bool has_server = false;
ip_addr_t ns;
char *nsenv;
@@ -364,7 +364,7 @@ int net_lwip_rx(struct udevice *udev, struct netif *netif)
*/
int net_lwip_dns_resolve(char *name_or_ip, ip_addr_t *ip)
{
-#if defined(CONFIG_CMD_DNS)
+#if defined(CONFIG_DNS)
char *var = "_dnsres";
char *argv[] = { "dns", name_or_ip, var, NULL };
int argc = ARRAY_SIZE(argv) - 1;
@@ -373,7 +373,7 @@ int net_lwip_dns_resolve(char *name_or_ip, ip_addr_t *ip)
if (ipaddr_aton(name_or_ip, ip))
return 0;
-#if defined(CONFIG_CMD_DNS)
+#if defined(CONFIG_DNS)
if (do_dns(NULL, 0, argc, argv) != CMD_RET_SUCCESS)
return -1;
diff --git a/net/net.c b/net/net.c
index 5219367e391..f579f6ac5bc 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1,9 +1,8 @@
-// SPDX-License-Identifier: GPL-2.0
+// SPDX-License-Identifier: GPL-2.0-only
/*
* Copied from Linux Monitor (LiMon) - Networking.
*
* Copyright 1994 - 2000 Neil Russell.
- * (See License)
* Copyright 2000 Roland Borde
* Copyright 2000 Paolo Scaffardi
* Copyright 2000-2002 Wolfgang Denk, wd@denx.de
@@ -115,7 +114,7 @@
#include "bootp.h"
#include "cdp.h"
#include "dhcpv6.h"
-#if defined(CONFIG_CMD_DNS)
+#if defined(CONFIG_DNS)
#include "dns.h"
#endif
#include "link_local.h"
@@ -288,7 +287,7 @@ static int on_vlan(const char *name, const char *value, enum env_op op,
}
U_BOOT_ENV_CALLBACK(vlan, on_vlan);
-#if defined(CONFIG_CMD_DNS)
+#if defined(CONFIG_DNS)
static int on_dnsip(const char *name, const char *value, enum env_op op,
int flags)
{
@@ -582,7 +581,7 @@ restart:
nc_start();
break;
#endif
-#if defined(CONFIG_CMD_DNS)
+#if defined(CONFIG_DNS)
case DNS:
dns_start();
break;
@@ -1507,7 +1506,7 @@ static int net_check_prereq(enum proto_t protocol)
}
goto common;
#endif
-#if defined(CONFIG_CMD_DNS)
+#if defined(CONFIG_DNS)
case DNS:
if (net_dns_server.s_addr == 0) {
puts("*** ERROR: DNS server address not given\n");
@@ -1540,7 +1539,7 @@ static int net_check_prereq(enum proto_t protocol)
return 1;
}
#if defined(CONFIG_CMD_PING) || \
- defined(CONFIG_CMD_DNS) || defined(CONFIG_PROT_UDP)
+ defined(CONFIG_DNS) || defined(CONFIG_PROT_UDP)
common:
#endif
/* Fall through */
diff --git a/net/net_rand.h b/net/net_rand.h
index 686e85f2b53..e21dff8569b 100644
--- a/net/net_rand.h
+++ b/net/net_rand.h
@@ -1,8 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copied from LiMon - BOOTP.
*
* Copyright 1994, 1995, 2000 Neil Russell.
- * (See License)
* Copyright 2000 Paolo Scaffardi
*/
diff --git a/net/ping.c b/net/ping.c
index 075df3663fe..fb981f62084 100644
--- a/net/ping.c
+++ b/net/ping.c
@@ -1,9 +1,8 @@
-// SPDX-License-Identifier: GPL-2.0
+// SPDX-License-Identifier: GPL-2.0-only
/*
* Copied from Linux Monitor (LiMon) - Networking.
*
* Copyright 1994 - 2000 Neil Russell.
- * (See License)
* Copyright 2000 Roland Borde
* Copyright 2000 Paolo Scaffardi
* Copyright 2000-2002 Wolfgang Denk, wd@denx.de
diff --git a/net/ping.h b/net/ping.h
index 76ac225fc07..739f128408e 100644
--- a/net/ping.h
+++ b/net/ping.h
@@ -1,9 +1,8 @@
-/* SPDX-License-Identifier: GPL-2.0 */
+/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copied from Linux Monitor (LiMon) - Networking.
*
* Copyright 1994 - 2000 Neil Russell.
- * (See License)
* Copyright 2000 Roland Borde
* Copyright 2000 Paolo Scaffardi
* Copyright 2000-2002 Wolfgang Denk, wd@denx.de
diff --git a/net/wget.c b/net/wget.c
index 428ee072330..d3642958bf0 100644
--- a/net/wget.c
+++ b/net/wget.c
@@ -393,7 +393,7 @@ int wget_do_request(ulong dst_addr, char *uri)
if (string_to_ip(host_name).s_addr) {
s = host_name;
} else {
-#if IS_ENABLED(CONFIG_CMD_DNS)
+#if IS_ENABLED(CONFIG_DNS)
net_dns_resolve = host_name;
net_dns_env_var = "httpserverip";
if (net_loop(DNS) < 0) {