diff options
| author | Michael Brown | 2009-06-24 13:52:38 +0200 |
|---|---|---|
| committer | Michael Brown | 2009-06-24 14:04:36 +0200 |
| commit | a310d00d37f8362b48913972927bfb78e7d7586d (patch) | |
| tree | 8cd343a5de2c6ab1c3f4b825daba09f5a631d101 /src/include | |
| parent | [comboot] Implement INT 22h AX=000Bh (Get Serial Console Configuration) (diff) | |
| download | ipxe-a310d00d37f8362b48913972927bfb78e7d7586d.tar.gz ipxe-a310d00d37f8362b48913972927bfb78e7d7586d.tar.xz ipxe-a310d00d37f8362b48913972927bfb78e7d7586d.zip | |
[netdevice] Add mechanism for reporting detailed link status codes
Expand the NETDEV_LINK_UP bit into a link_rc status code field,
allowing specific reasons for link failure to be reported via
"ifstat".
Originally-authored-by: Joshua Oreman <oremanj@rwcr.net>
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/gpxe/netdevice.h | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/include/gpxe/netdevice.h b/src/include/gpxe/netdevice.h index 43c5aa317..70644af1e 100644 --- a/src/include/gpxe/netdevice.h +++ b/src/include/gpxe/netdevice.h @@ -267,6 +267,12 @@ struct net_device { * This is the bitwise-OR of zero or more NETDEV_XXX constants. */ unsigned int state; + /** Link status code + * + * Zero indicates that the link is up; any other value + * indicates the error preventing link-up. + */ + int link_rc; /** Maximum packet length * * This length includes any link-layer headers. @@ -291,9 +297,6 @@ struct net_device { /** Network device is open */ #define NETDEV_OPEN 0x0001 -/** Network device has link */ -#define NETDEV_LINK_UP 0x0002 - /** Link-layer protocol table */ #define LL_PROTOCOLS __table ( struct ll_protocol, "ll_protocols" ) @@ -420,17 +423,18 @@ netdev_settings_init ( struct net_device *netdev ) { */ static inline __attribute__ (( always_inline )) void netdev_link_up ( struct net_device *netdev ) { - netdev->state |= NETDEV_LINK_UP; + netdev->link_rc = 0; } /** - * Mark network device as having link down + * Mark network device as having link down due to a specific error * * @v netdev Network device + * @v rc Link status code */ static inline __attribute__ (( always_inline )) void -netdev_link_down ( struct net_device *netdev ) { - netdev->state &= ~NETDEV_LINK_UP; +netdev_link_err ( struct net_device *netdev, int rc ) { + netdev->link_rc = rc; } /** @@ -441,9 +445,10 @@ netdev_link_down ( struct net_device *netdev ) { */ static inline __attribute__ (( always_inline )) int netdev_link_ok ( struct net_device *netdev ) { - return ( netdev->state & NETDEV_LINK_UP ); + return ( netdev->link_rc == 0 ); } +extern void netdev_link_down ( struct net_device *netdev ); 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 ); |
