]> git.sur5r.net Git - u-boot/blobdiff - net/net.c
spi_flash: add a bunch of winbond flashes to id-table
[u-boot] / net / net.c
index 4259c9e321d6905efef6ca5abe441e89943eab9f..f35695b4fc9f0b62ffd8189c4cc9693c9dc41f87 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  *     Copied from Linux Monitor (LiMon) - Networking.
  *
@@ -6,7 +7,6 @@
  *     Copyright 2000 Roland Borde
  *     Copyright 2000 Paolo Scaffardi
  *     Copyright 2000-2002 Wolfgang Denk, wd@denx.de
- *     SPDX-License-Identifier:        GPL-2.0
  */
 
 /*
  *                     - own IP address
  *     We want:        - network time
  *     Next step:      none
+ *
+ * WOL:
+ *
+ *     Prerequisites:  - own ethernet address
+ *     We want:        - magic packet or timeout
+ *     Next step:      none
  */
 
 
@@ -87,6 +93,7 @@
 #include <environment.h>
 #include <errno.h>
 #include <net.h>
+#include <net/fastboot.h>
 #include <net/tftp.h>
 #if defined(CONFIG_LED_STATUS)
 #include <miiphy.h>
 #if defined(CONFIG_CMD_SNTP)
 #include "sntp.h"
 #endif
-
-DECLARE_GLOBAL_DATA_PTR;
+#if defined(CONFIG_CMD_WOL)
+#include "wol.h"
+#endif
 
 /** BOOTP EXTENTIONS **/
 
@@ -166,6 +174,8 @@ ushort              net_native_vlan = 0xFFFF;
 
 /* Boot File name */
 char net_boot_file_name[1024];
+/* Indicates whether the file name was specified on the command line */
+bool net_boot_file_name_explicit;
 /* The actual transferred size of the bootfile (in bytes) */
 u32 net_boot_file_size;
 /* Boot file size in blocks as reported by the DHCP server */
@@ -394,6 +404,7 @@ void net_init(void)
 int net_loop(enum proto_t protocol)
 {
        int ret = -EINVAL;
+       enum net_loop_state prev_net_state = net_state;
 
        net_restarted = 0;
        net_dev_exists = 0;
@@ -431,6 +442,7 @@ restart:
        case 1:
                /* network not configured */
                eth_halt();
+               net_set_state(prev_net_state);
                return -ENODEV;
 
        case 2:
@@ -453,6 +465,11 @@ restart:
                        tftp_start_server();
                        break;
 #endif
+#ifdef CONFIG_UDP_FUNCTION_FASTBOOT
+               case FASTBOOT:
+                       fastboot_start_server();
+                       break;
+#endif
 #if defined(CONFIG_CMD_DHCP)
                case DHCP:
                        bootp_reset();
@@ -508,6 +525,11 @@ restart:
                case LINKLOCAL:
                        link_local_start();
                        break;
+#endif
+#if defined(CONFIG_CMD_WOL)
+               case WOL:
+                       wol_start();
+                       break;
 #endif
                default:
                        break;
@@ -651,6 +673,7 @@ done:
        net_set_udp_handler(NULL);
        net_set_icmp_handler(NULL);
 #endif
+       net_set_state(prev_net_state);
        return ret;
 }
 
@@ -683,7 +706,7 @@ int net_start_again(void)
                retry_forever = 0;
        }
 
-       if ((!retry_forever) && (net_try_count >= retrycnt)) {
+       if ((!retry_forever) && (net_try_count > retrycnt)) {
                eth_halt();
                net_set_state(NETLOOP_FAIL);
                /*
@@ -1274,6 +1297,11 @@ void net_process_received_packet(uchar *in_packet, int len)
                                      ntohs(ip->udp_src),
                                      ntohs(ip->udp_len) - UDP_HDR_SIZE);
                break;
+#ifdef CONFIG_CMD_WOL
+       case PROT_WOL:
+               wol_receive(ip, len);
+               break;
+#endif
        }
 }
 
@@ -1324,6 +1352,7 @@ common:
                /* Fall through */
 
        case NETCONS:
+       case FASTBOOT:
        case TFTPSRV:
                if (net_ip.s_addr == 0) {
                        puts("*** ERROR: `ipaddr' not set\n");