[netdevice] Add a generic concept of a "blocked link"

When Spanning Tree Protocol (STP) is used, there may be a substantial
delay (tens of seconds) from the time that the link goes up to the
time that the port starts forwarding packets.

Add a generic concept of a "blocked link" (i.e. a link which is up but
which is not expected to communicate successfully), and allow "ifstat"
to indicate when a link is blocked.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2015-06-25 16:41:39 +01:00
parent 7e7870984b
commit f3812395a2
3 changed files with 70 additions and 2 deletions

View File

@@ -15,6 +15,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/refcnt.h>
#include <ipxe/settings.h>
#include <ipxe/interface.h>
#include <ipxe/retry.h>
struct io_buffer;
struct net_device;
@@ -392,6 +393,8 @@ struct net_device {
* indicates the error preventing link-up.
*/
int link_rc;
/** Link block timer */
struct retry_timer link_block;
/** Maximum packet length
*
* This length includes any link-layer headers.
@@ -613,6 +616,17 @@ netdev_link_ok ( struct net_device *netdev ) {
return ( netdev->link_rc == 0 );
}
/**
* Check link block state of network device
*
* @v netdev Network device
* @ret link_blocked Link is blocked
*/
static inline __attribute__ (( always_inline )) int
netdev_link_blocked ( struct net_device *netdev ) {
return ( timer_running ( &netdev->link_block ) );
}
/**
* Check whether or not network device is open
*
@@ -661,6 +675,9 @@ extern void netdev_rx_freeze ( struct net_device *netdev );
extern void netdev_rx_unfreeze ( struct net_device *netdev );
extern void netdev_link_err ( struct net_device *netdev, int rc );
extern void netdev_link_down ( struct net_device *netdev );
extern void netdev_link_block ( struct net_device *netdev,
unsigned long timeout );
extern void netdev_link_unblock ( struct net_device *netdev );
extern int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf );
extern void netdev_tx_defer ( struct net_device *netdev,
struct io_buffer *iobuf );