aboutsummaryrefslogtreecommitdiffstats
path: root/gpxe/src/usr/ifmgmt.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-06-04 18:52:18 -0700
committerH. Peter Anvin <hpa@zytor.com>2008-06-04 18:52:18 -0700
commite63132bf03140d91ec74eca663f7bc2f16429fb0 (patch)
treeea5af9895146e85d3912584e699799863e0f8a29 /gpxe/src/usr/ifmgmt.c
parentbce8e1595ab30c828254038523e1e25c9fd9445f (diff)
downloadsyslinux.git-e63132bf03140d91ec74eca663f7bc2f16429fb0.tar.gz
syslinux.git-e63132bf03140d91ec74eca663f7bc2f16429fb0.tar.xz
syslinux.git-e63132bf03140d91ec74eca663f7bc2f16429fb0.zip
Update gPXE from gPXE git
Diffstat (limited to 'gpxe/src/usr/ifmgmt.c')
-rw-r--r--gpxe/src/usr/ifmgmt.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/gpxe/src/usr/ifmgmt.c b/gpxe/src/usr/ifmgmt.c
index 5f4323de..9c88ab53 100644
--- a/gpxe/src/usr/ifmgmt.c
+++ b/gpxe/src/usr/ifmgmt.c
@@ -18,8 +18,11 @@
#include <string.h>
#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
#include <gpxe/netdevice.h>
#include <gpxe/device.h>
+#include <gpxe/process.h>
#include <usr/ifmgmt.h>
/** @file
@@ -61,9 +64,28 @@ void ifclose ( struct net_device *netdev ) {
* @v netdev Network device
*/
void ifstat ( struct net_device *netdev ) {
- printf ( "%s: %s on %s (%s) TX:%d TXE:%d RX:%d RXE:%d\n",
+ printf ( "%s: %s on %s (%s)\n"
+ " [Link:%s, TX:%d TXE:%d RX:%d RXE:%d]\n",
netdev->name, netdev_hwaddr ( netdev ), netdev->dev->name,
( ( netdev->state & NETDEV_OPEN ) ? "open" : "closed" ),
+ ( netdev_link_ok ( netdev ) ? "up" : "down" ),
netdev->stats.tx_ok, netdev->stats.tx_err,
netdev->stats.rx_ok, netdev->stats.rx_err );
}
+
+/**
+ * Wait for link-up
+ *
+ * @v netdev Network device
+ * @v max_wait_ms Maximum time to wait, in ms
+ */
+int iflinkwait ( struct net_device *netdev, unsigned int max_wait_ms ) {
+ while ( 1 ) {
+ if ( netdev_link_ok ( netdev ) )
+ return 0;
+ if ( max_wait_ms-- == 0 )
+ return -ETIMEDOUT;
+ step();
+ mdelay ( 1 );
+ }
+}