diff --git a/src/include/ipxe/netdevice.h b/src/include/ipxe/netdevice.h index caa83b44b..17695d5b6 100644 --- a/src/include/ipxe/netdevice.h +++ b/src/include/ipxe/netdevice.h @@ -457,6 +457,9 @@ struct net_device { /** Network device poll is in progress */ #define NETDEV_POLL_IN_PROGRESS 0x0020 +/** Network device must be polled even when closed */ +#define NETDEV_INSOMNIAC 0x0040 + /** Link-layer protocol table */ #define LL_PROTOCOLS __table ( struct ll_protocol, "ll_protocols" ) @@ -693,6 +696,17 @@ netdev_rx_frozen ( struct net_device *netdev ) { return ( netdev->state & NETDEV_RX_FROZEN ); } +/** + * Check whether or not network device must be polled even while closed + * + * @v netdev Network device + * @ret insomniac Network device must be polled even while closed + */ +static inline __attribute__ (( always_inline )) int +netdev_insomniac ( struct net_device *netdev ) { + return ( netdev->state & NETDEV_INSOMNIAC ); +} + extern void * netdev_priv ( struct net_device *netdev, struct net_driver *driver ); extern void netdev_rx_freeze ( struct net_device *netdev ); diff --git a/src/net/netdevice.c b/src/net/netdevice.c index a9ed18134..c89585708 100644 --- a/src/net/netdevice.c +++ b/src/net/netdevice.c @@ -611,8 +611,8 @@ void netdev_rx_err ( struct net_device *netdev, */ void netdev_poll ( struct net_device *netdev ) { - /* Avoid calling poll() on unopened network devices */ - if ( ! netdev_is_open ( netdev ) ) + /* Call poll() only on open (or insomniac) network devices */ + if ( ! ( netdev->state & ( NETDEV_OPEN | NETDEV_INSOMNIAC ) ) ) return; /* Guard against re-entry */