From f3812395a261b80fe77d19ebb9045e790c434773 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 25 Jun 2015 16:41:39 +0100 Subject: [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 --- src/include/ipxe/netdevice.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/include') diff --git a/src/include/ipxe/netdevice.h b/src/include/ipxe/netdevice.h index 8e615c941..f20a81f79 100644 --- a/src/include/ipxe/netdevice.h +++ b/src/include/ipxe/netdevice.h @@ -15,6 +15,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include 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 ); -- cgit v1.2.3-55-g7522