summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/bootp.c2
-rw-r--r--net/dsa-uclass.c56
-rw-r--r--net/fastboot.c2
-rw-r--r--net/mdio-uclass.c4
-rw-r--r--net/net6.c9
-rw-r--r--net/tftp.c10
6 files changed, 63 insertions, 20 deletions
diff --git a/net/bootp.c b/net/bootp.c
index cae041988db..8b1a4ae2ef8 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -1078,7 +1078,7 @@ static void dhcp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
#endif /* CONFIG_SYS_BOOTFILE_PREFIX */
dhcp_packet_process_options(bp);
if (CONFIG_IS_ENABLED(EFI_LOADER) &&
- CONFIG_IS_ENABLED(NETDEVICES))
+ IS_ENABLED(CONFIG_NETDEVICES))
efi_net_set_dhcp_ack(pkt, len);
#if defined(CONFIG_SERVERIP_FROM_PROXYDHCP)
diff --git a/net/dsa-uclass.c b/net/dsa-uclass.c
index 5b7046432ff..dd78e5744d5 100644
--- a/net/dsa-uclass.c
+++ b/net/dsa-uclass.c
@@ -142,20 +142,22 @@ static int dsa_port_send(struct udevice *pdev, void *packet, int length)
struct dsa_port_pdata *port_pdata;
int err;
- if (length + head + tail > PKTSIZE_ALIGN)
- return -EINVAL;
+ if (ops->xmit) {
+ if (length + head + tail > PKTSIZE_ALIGN)
+ return -EINVAL;
- memset(dsa_packet_tmp, 0, head);
- memset(dsa_packet_tmp + head + length, 0, tail);
- memcpy(dsa_packet_tmp + head, packet, length);
- length += head + tail;
- /* copy back to preserve original buffer alignment */
- memcpy(packet, dsa_packet_tmp, length);
+ memset(dsa_packet_tmp, 0, head);
+ memset(dsa_packet_tmp + head + length, 0, tail);
+ memcpy(dsa_packet_tmp + head, packet, length);
+ length += head + tail;
+ /* copy back to preserve original buffer alignment */
+ memcpy(packet, dsa_packet_tmp, length);
- port_pdata = dev_get_parent_plat(pdev);
- err = ops->xmit(dev, port_pdata->index, packet, length);
- if (err)
- return err;
+ port_pdata = dev_get_parent_plat(pdev);
+ err = ops->xmit(dev, port_pdata->index, packet, length);
+ if (err)
+ return err;
+ }
return eth_get_ops(master)->send(master, packet, length);
}
@@ -172,7 +174,7 @@ static int dsa_port_recv(struct udevice *pdev, int flags, uchar **packetp)
int length, port_index, err;
length = eth_get_ops(master)->recv(master, flags, packetp);
- if (length <= 0)
+ if (length <= 0 || !ops->rcv)
return length;
/*
@@ -342,6 +344,19 @@ U_BOOT_DRIVER(dsa_port) = {
.plat_auto = sizeof(struct eth_pdata),
};
+static int dsa_sanitize_ops(struct udevice *dev)
+{
+ struct dsa_ops *ops = dsa_get_ops(dev);
+
+ if ((!ops->xmit || !ops->rcv) &&
+ (!ops->port_enable && !ops->port_disable)) {
+ dev_err(dev, "Packets cannot be steered to ports\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
/*
* This function mostly deals with pulling information out of the device tree
* into the pdata structure.
@@ -358,6 +373,10 @@ static int dsa_post_bind(struct udevice *dev)
if (!ofnode_valid(node))
return -ENODEV;
+ err = dsa_sanitize_ops(dev);
+ if (err)
+ return err;
+
pdata->master_node = ofnode_null();
node = ofnode_find_subnode(node, "ports");
@@ -466,7 +485,6 @@ static int dsa_pre_probe(struct udevice *dev)
{
struct dsa_pdata *pdata = dev_get_uclass_plat(dev);
struct dsa_priv *priv = dev_get_uclass_priv(dev);
- struct dsa_ops *ops = dsa_get_ops(dev);
int err;
priv->num_ports = pdata->num_ports;
@@ -482,6 +500,15 @@ static int dsa_pre_probe(struct udevice *dev)
if (err)
return err;
+ return 0;
+}
+
+static int dsa_post_probe(struct udevice *dev)
+{
+ struct dsa_priv *priv = dev_get_uclass_priv(dev);
+ struct dsa_ops *ops = dsa_get_ops(dev);
+ int err;
+
/* Simulate a probing event for the CPU port */
if (ops->port_probe) {
err = ops->port_probe(dev, priv->cpu_port,
@@ -498,6 +525,7 @@ UCLASS_DRIVER(dsa) = {
.name = "dsa",
.post_bind = dsa_post_bind,
.pre_probe = dsa_pre_probe,
+ .post_probe = dsa_post_probe,
.per_device_auto = sizeof(struct dsa_priv),
.per_device_plat_auto = sizeof(struct dsa_pdata),
.per_child_plat_auto = sizeof(struct dsa_port_pdata),
diff --git a/net/fastboot.c b/net/fastboot.c
index 96bdf5486fa..e9569d88d2a 100644
--- a/net/fastboot.c
+++ b/net/fastboot.c
@@ -307,7 +307,7 @@ void fastboot_start_server(void)
fastboot_our_port = CONFIG_UDP_FUNCTION_FASTBOOT_PORT;
- if (CONFIG_IS_ENABLED(FASTBOOT_FLASH))
+ if (IS_ENABLED(CONFIG_FASTBOOT_FLASH))
fastboot_set_progress_callback(fastboot_timed_send_info);
net_set_udp_handler(fastboot_handler);
diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c
index 4401492ca01..d80037d0ac7 100644
--- a/net/mdio-uclass.c
+++ b/net/mdio-uclass.c
@@ -49,7 +49,11 @@ static int dm_mdio_post_bind(struct udevice *dev)
return -EINVAL;
}
+#if CONFIG_IS_ENABLED(OF_REAL)
+ return dm_scan_fdt_dev(dev);
+#else
return 0;
+#endif
}
int dm_mdio_read(struct udevice *mdio_dev, int addr, int devad, int reg)
diff --git a/net/net6.c b/net/net6.c
index fdea0787885..75577bcea17 100644
--- a/net/net6.c
+++ b/net/net6.c
@@ -47,10 +47,13 @@ static int on_ip6addr(const char *name, const char *value, enum env_op op,
}
mask = strchr(value, '/');
- len = strlen(value);
- if (mask)
- net_prefix_length = simple_strtoul(value + len, NULL, 10);
+ if (mask) {
+ net_prefix_length = simple_strtoul(mask + 1, NULL, 10);
+ len = mask - value;
+ } else {
+ len = strlen(value);
+ }
return string_to_ip6(value, len, &net_ip6);
}
diff --git a/net/tftp.c b/net/tftp.c
index c780c33f379..88e71e67de3 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -593,6 +593,14 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
ntohs(*(__be16 *)pkt),
(ushort)(tftp_cur_block + 1));
/*
+ * Only ACK if the block count received is greater than
+ * the expected block count, otherwise skip ACK.
+ * (required to properly handle the server retransmitting
+ * the window)
+ */
+ if ((ushort)(tftp_cur_block + 1) - (short)(ntohs(*(__be16 *)pkt)) > 0)
+ break;
+ /*
* If one packet is dropped most likely
* all other buffers in the window
* that will arrive will cause a sending NACK.
@@ -837,7 +845,7 @@ void tftp_start(enum proto_t protocol)
e = strchr(net_boot_file_name, ']');
len = e - s;
if (s && e) {
- string_to_ip6(s + 1, len, &tftp_remote_ip6);
+ string_to_ip6(s + 1, len - 1, &tftp_remote_ip6);
strlcpy(tftp_filename, e + 2, MAX_LEN);
} else {
strlcpy(tftp_filename, net_boot_file_name, MAX_LEN);