Browse Source

[netdevice] Record whether or not interrupts are currently enabled

Signed-off-by: Michael Brown <mcb30@etherboot.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
4a7648bd3d
2 changed files with 21 additions and 0 deletions
  1. 14
    0
      src/include/gpxe/netdevice.h
  2. 7
    0
      src/net/netdevice.c

+ 14
- 0
src/include/gpxe/netdevice.h View File

329
 /** Network device is open */
329
 /** Network device is open */
330
 #define NETDEV_OPEN 0x0001
330
 #define NETDEV_OPEN 0x0001
331
 
331
 
332
+/** Network device interrupts are enabled */
333
+#define NETDEV_IRQ_ENABLED 0x0002
334
+
332
 /** Link-layer protocol table */
335
 /** Link-layer protocol table */
333
 #define LL_PROTOCOLS __table ( struct ll_protocol, "ll_protocols" )
336
 #define LL_PROTOCOLS __table ( struct ll_protocol, "ll_protocols" )
334
 
337
 
491
 	return ( netdev->state & NETDEV_OPEN );
494
 	return ( netdev->state & NETDEV_OPEN );
492
 }
495
 }
493
 
496
 
497
+/**
498
+ * Check whether or not network device interrupts are currently enabled
499
+ *
500
+ * @v netdev		Network device
501
+ * @v irq_enabled	Network device interrupts are enabled
502
+ */
503
+static inline __attribute__ (( always_inline )) int
504
+netdev_irq_enabled ( struct net_device *netdev ) {
505
+	return ( netdev->state & NETDEV_IRQ_ENABLED );
506
+}
507
+
494
 extern void netdev_link_down ( struct net_device *netdev );
508
 extern void netdev_link_down ( struct net_device *netdev );
495
 extern int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf );
509
 extern int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf );
496
 extern void netdev_tx_complete_err ( struct net_device *netdev,
510
 extern void netdev_tx_complete_err ( struct net_device *netdev,

+ 7
- 0
src/net/netdevice.c View File

460
  * @v enable		Interrupts should be enabled
460
  * @v enable		Interrupts should be enabled
461
  */
461
  */
462
 void netdev_irq ( struct net_device *netdev, int enable ) {
462
 void netdev_irq ( struct net_device *netdev, int enable ) {
463
+
464
+	/* Enable or disable device interrupts */
463
 	netdev->op->irq ( netdev, enable );
465
 	netdev->op->irq ( netdev, enable );
466
+
467
+	/* Record interrupt enabled state */
468
+	netdev->state &= ~NETDEV_IRQ_ENABLED;
469
+	if ( enable )
470
+		netdev->state |= NETDEV_IRQ_ENABLED;
464
 }
471
 }
465
 
472
 
466
 /**
473
 /**

Loading…
Cancel
Save