]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cmd: Add ncsi command
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>
Mon, 8 Aug 2022 12:16:04 +0000 (21:46 +0930)
committerTom Rini <trini@konsulko.com>
Fri, 21 Oct 2022 20:04:39 +0000 (16:04 -0400)
Adds an "ncsi" command to manually start NC-SI configuration.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
cmd/Kconfig
cmd/net.c
net/net.c

index 16030e34a12e388e4c3f7c27bf5718bb5f6855a1..41cf1d46fb17601896d049f94915c2c82f3e5d95 100644 (file)
@@ -1842,6 +1842,14 @@ 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
+         Manually configure the attached NIC via NC-SI.
+         Normally this happens automatically before other network
+         operations.
+
 endif
 
 config CMD_ETHSW
index 46f8c87b69201bb9085c29b9f214b7e9373e4d87..addcad3ac14080157f6a7fdc6c32005c46571c0b 100644 (file)
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -16,6 +16,7 @@
 #include <net.h>
 #include <net/udp.h>
 #include <net/sntp.h>
+#include <net/ncsi.h>
 
 static int netboot_common(enum proto_t, struct cmd_tbl *, int, char * const []);
 
@@ -566,3 +567,24 @@ U_BOOT_CMD(
        "list - list available devices\n"
 );
 #endif // CONFIG_DM_ETH
+
+#if defined(CONFIG_CMD_NCSI)
+static int do_ncsi(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
+{
+       if (!phy_interface_is_ncsi() || !ncsi_active()) {
+               printf("Device not configured for NC-SI\n");
+               return CMD_RET_FAILURE;
+       }
+
+       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 */
index 6987a3817b9f24b84344e689939f18577201d795..b27b021d0711f87c69d967a0450074464ad42991 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -434,6 +434,7 @@ int net_loop(enum proto_t protocol)
        } else {
                eth_init_state_only();
        }
+
 restart:
 #ifdef CONFIG_USB_KEYBOARD
        net_busy_flag = 0;