[U-Boot] [PATCH 4/4] net: NC-SI setup and handling
Samuel Mendoza-Jonas
sam at mendozajonas.com
Thu Jun 6 04:49:50 UTC 2019
Add the handling of NC-SI ethernet frames, and add a check at the start
of net_loop() to configure NC-SI before starting other network commands.
This also adds an "ncsi" command to manually start NC-SI configuration.
Signed-off-by: Samuel Mendoza-Jonas <sam at mendozajonas.com>
---
cmd/Kconfig | 6 ++++++
cmd/net.c | 18 ++++++++++++++++++
include/net.h | 2 +-
net/net.c | 27 ++++++++++++++++++++++++++-
4 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/cmd/Kconfig b/cmd/Kconfig
index ea1a325eb3..0b5df0db90 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1296,6 +1296,12 @@ config CMD_LINK_LOCAL
help
Acquire a network IP address using the link-local protocol
+config CMD_NCSI
+ bool "ncsi"
+ depends on PHY_NCSI
+ help
+ Configure the attached NIC via NC-SI
+
endif
config CMD_ETHSW
diff --git a/cmd/net.c b/cmd/net.c
index 89721b8f8b..7d2c21ba4d 100644
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -457,3 +457,21 @@ U_BOOT_CMD(
);
#endif /* CONFIG_CMD_LINK_LOCAL */
+
+#if defined(CONFIG_CMD_NCSI)
+static int do_ncsi(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
+{
+ if (net_loop(NCSI) < 0)
+ return CMD_RET_FAILURE;
+
+ return CMD_RET_SUCCESS;
+}
+
+U_BOOT_CMD(
+ ncsi, 1, 1, do_ncsi,
+ "Configure attached NIC via NC-SI",
+ ""
+);
+
+#endif /* CONFIG_CMD_NCSI */
diff --git a/include/net.h b/include/net.h
index 4f7ba211b6..82a71c5219 100644
--- a/include/net.h
+++ b/include/net.h
@@ -538,7 +538,7 @@ extern int net_restart_wrap; /* Tried all network devices */
enum proto_t {
BOOTP, RARP, ARP, TFTPGET, DHCP, PING, DNS, NFS, CDP, NETCONS, SNTP,
- TFTPSRV, TFTPPUT, LINKLOCAL, FASTBOOT, WOL
+ TFTPSRV, TFTPPUT, LINKLOCAL, FASTBOOT, WOL, NCSI
};
extern char net_boot_file_name[1024];/* Boot File name */
diff --git a/net/net.c b/net/net.c
index a5a216c3ee..16ca2b0e18 100644
--- a/net/net.c
+++ b/net/net.c
@@ -95,6 +95,7 @@
#include <net.h>
#include <net/fastboot.h>
#include <net/tftp.h>
+#include <net/ncsi.h>
#if defined(CONFIG_LED_STATUS)
#include <miiphy.h>
#include <status_led.h>
@@ -411,6 +412,16 @@ int net_loop(enum proto_t protocol)
net_try_count = 1;
debug_cond(DEBUG_INT_STATE, "--- net_loop Entry\n");
+#ifdef CONFIG_PHY_NCSI
+ if (protocol != NCSI && !ncsi_active()) {
+ printf("%s: configuring NCSI first\n", __func__);
+ if (net_loop(NCSI) < 0)
+ return ret;
+ eth_init_state_only();
+ goto restart;
+ }
+#endif
+
bootstage_mark_name(BOOTSTAGE_ID_ETH_START, "eth_start");
net_init();
if (eth_is_on_demand_init() || protocol != NETCONS) {
@@ -424,6 +435,7 @@ int net_loop(enum proto_t protocol)
} else {
eth_init_state_only();
}
+
restart:
#ifdef CONFIG_USB_KEYBOARD
net_busy_flag = 0;
@@ -530,6 +542,11 @@ restart:
case WOL:
wol_start();
break;
+#endif
+#if defined(CONFIG_CMD_NCSI)
+ case NCSI:
+ ncsi_probe_packages();
+ break;
#endif
default:
break;
@@ -641,7 +658,7 @@ restart:
env_set_hex("filesize", net_boot_file_size);
env_set_hex("fileaddr", load_addr);
}
- if (protocol != NETCONS)
+ if (protocol != NETCONS && protocol != NCSI)
eth_halt();
else
eth_halt_state_only();
@@ -1324,6 +1341,11 @@ void net_process_received_packet(uchar *in_packet, int len)
case PROT_WOL:
wol_receive(ip, len);
break;
+#endif
+#ifdef CONFIG_PHY_NCSI
+ case PROT_NCSI:
+ ncsi_receive(et, ip, len);
+ break;
#endif
}
}
@@ -1385,6 +1407,9 @@ common:
#ifdef CONFIG_CMD_RARP
case RARP:
+#endif
+#ifdef CONFIG_CMD_NCSI
+ case NCSI:
#endif
case BOOTP:
case CDP:
--
2.21.0
More information about the U-Boot
mailing list