diff options
Diffstat (limited to 'src/include/gpxe/netdevice.h')
| -rw-r--r-- | src/include/gpxe/netdevice.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/include/gpxe/netdevice.h b/src/include/gpxe/netdevice.h index d8cb84d08..1ef648e11 100644 --- a/src/include/gpxe/netdevice.h +++ b/src/include/gpxe/netdevice.h @@ -254,6 +254,9 @@ struct net_device { /** Network device is open */ #define NETDEV_OPEN 0x0001 +/** Network device has link */ +#define NETDEV_LINK_UP 0x0002 + /** Declare a link-layer protocol */ #define __ll_protocol __table ( struct ll_protocol, ll_protocols, 01 ) @@ -352,6 +355,37 @@ netdev_settings ( struct net_device *netdev ) { return &netdev->settings.settings; } +/** + * Mark network device as having link up + * + * @v netdev Network device + */ +static inline __attribute__ (( always_inline )) void +netdev_link_up ( struct net_device *netdev ) { + netdev->state |= NETDEV_LINK_UP; +} + +/** + * Mark network device as having link down + * + * @v netdev Network device + */ +static inline __attribute__ (( always_inline )) void +netdev_link_down ( struct net_device *netdev ) { + netdev->state &= ~NETDEV_LINK_UP; +} + +/** + * Check link state of network device + * + * @v netdev Network device + * @ret link_up Link is up + */ +static inline __attribute__ (( always_inline )) int +netdev_link_ok ( struct net_device *netdev ) { + return ( netdev->state & NETDEV_LINK_UP ); +} + extern int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf ); extern void netdev_tx_complete_err ( struct net_device *netdev, struct io_buffer *iobuf, int rc ); |
