summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJoe Hershberger <joe.hershberger@ni.com>2012-08-03 10:59:08 +0000
committerJoe Hershberger <joe.hershberger@ni.com>2012-09-24 13:55:43 -0500
commitf8be7d659c45720edb91503d2a480fc198e7ee9d (patch)
treec38ce492840a95d7ff7cd8242703096d3c4e488f /include
parent2c8fe5120f8da013cbd789be2f10cce880972836 (diff)
downloadu-boot-imx-f8be7d659c45720edb91503d2a480fc198e7ee9d.zip
u-boot-imx-f8be7d659c45720edb91503d2a480fc198e7ee9d.tar.gz
u-boot-imx-f8be7d659c45720edb91503d2a480fc198e7ee9d.tar.bz2
net: Improve the speed of netconsole
Previously u-boot would initialize the network interface for every network operation and then shut it down again. This makes sense for most operations where the network in not known to be needed soon after the operation is complete. In the case of netconsole, it will use the network for every interaction with the shell or every printf. This means that the network is being reinitialized very often. On many devices, this intialization is very slow. This patch checks for consecutive netconsole actions and leaves the ethernet hardware initialized between them. It will still behave the same old way for all other network operations and any time another network operation happens between netconsole operations. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Cc: Stefano Babic <sbabic@denx.de> Acked-by: Stefano Babic <sbabic@denx.de>
Diffstat (limited to 'include')
-rw-r--r--include/net.h42
1 files changed, 41 insertions, 1 deletions
diff --git a/include/net.h b/include/net.h
index 6d2d6cd..e193b7b 100644
--- a/include/net.h
+++ b/include/net.h
@@ -102,7 +102,14 @@ extern int eth_register(struct eth_device* dev);/* Register network device */
extern int eth_unregister(struct eth_device *dev);/* Remove network device */
extern void eth_try_another(int first_restart); /* Change the device */
extern void eth_set_current(void); /* set nterface to ethcur var */
-extern struct eth_device *eth_get_dev(void); /* get the current device MAC */
+/* get the current device MAC */
+static inline __attribute__((always_inline))
+struct eth_device *eth_get_dev(void)
+{
+ extern struct eth_device *eth_current;
+
+ return eth_current;
+}
extern struct eth_device *eth_get_dev_by_name(const char *devname);
extern struct eth_device *eth_get_dev_by_index(int index); /* get dev @ index */
extern int eth_get_dev_index(void); /* get the device index */
@@ -151,6 +158,19 @@ extern int eth_rx(void); /* Check for received packets */
extern void eth_halt(void); /* stop SCC */
extern char *eth_get_name(void); /* get name of current device */
+/* Set active state */
+static inline __attribute__((always_inline)) int eth_init_state_only(bd_t *bis)
+{
+ eth_get_dev()->state = ETH_STATE_ACTIVE;
+
+ return 0;
+}
+/* Set passive state */
+static inline __attribute__((always_inline)) void eth_halt_state_only(void)
+{
+ eth_get_dev()->state = ETH_STATE_PASSIVE;
+}
+
/*
* Set the hardware address for an ethernet interface based on 'eth%daddr'
* environment variable (or just 'ethaddr' if eth_number is 0).
@@ -532,6 +552,26 @@ void NcStart(void);
int nc_input_packet(uchar *pkt, unsigned dest, unsigned src, unsigned len);
#endif
+static inline __attribute__((always_inline)) int eth_is_on_demand_init(void)
+{
+#ifdef CONFIG_NETCONSOLE
+ extern enum proto_t net_loop_last_protocol;
+
+ return net_loop_last_protocol != NETCONS;
+#else
+ return 1;
+#endif
+}
+
+static inline void eth_set_last_protocol(int protocol)
+{
+#ifdef CONFIG_NETCONSOLE
+ extern enum proto_t net_loop_last_protocol;
+
+ net_loop_last_protocol = protocol;
+#endif
+}
+
/*
* Check if autoload is enabled. If so, use either NFS or TFTP to download
* the boot file.