Skip to content

Commit

Permalink
[netdevice] Record whether or not interrupts are currently enabled
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Brown <mcb30@etherboot.org>
  • Loading branch information
Michael Brown committed Mar 23, 2010
1 parent 88e4363 commit 4a7648b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/include/gpxe/netdevice.h
Expand Up @@ -329,6 +329,9 @@ struct net_device {
/** Network device is open */
#define NETDEV_OPEN 0x0001

/** Network device interrupts are enabled */
#define NETDEV_IRQ_ENABLED 0x0002

/** Link-layer protocol table */
#define LL_PROTOCOLS __table ( struct ll_protocol, "ll_protocols" )

Expand Down Expand Up @@ -491,6 +494,17 @@ netdev_is_open ( struct net_device *netdev ) {
return ( netdev->state & NETDEV_OPEN );
}

/**
* Check whether or not network device interrupts are currently enabled
*
* @v netdev Network device
* @v irq_enabled Network device interrupts are enabled
*/
static inline __attribute__ (( always_inline )) int
netdev_irq_enabled ( struct net_device *netdev ) {
return ( netdev->state & NETDEV_IRQ_ENABLED );
}

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,
Expand Down
7 changes: 7 additions & 0 deletions src/net/netdevice.c
Expand Up @@ -460,7 +460,14 @@ void unregister_netdev ( struct net_device *netdev ) {
* @v enable Interrupts should be enabled
*/
void netdev_irq ( struct net_device *netdev, int enable ) {

/* Enable or disable device interrupts */
netdev->op->irq ( netdev, enable );

/* Record interrupt enabled state */
netdev->state &= ~NETDEV_IRQ_ENABLED;
if ( enable )
netdev->state |= NETDEV_IRQ_ENABLED;
}

/**
Expand Down

0 comments on commit 4a7648b

Please sign in to comment.