Parcourir la source

[netdevice] Record whether or not interrupts are currently enabled

Signed-off-by: Michael Brown <mcb30@etherboot.org>
tags/v1.20.1
Michael Brown il y a 14 ans
Parent
révision
4a7648bd3d
2 fichiers modifiés avec 21 ajouts et 0 suppressions
  1. 14
    0
      src/include/gpxe/netdevice.h
  2. 7
    0
      src/net/netdevice.c

+ 14
- 0
src/include/gpxe/netdevice.h Voir le fichier

@@ -329,6 +329,9 @@ struct net_device {
329 329
 /** Network device is open */
330 330
 #define NETDEV_OPEN 0x0001
331 331
 
332
+/** Network device interrupts are enabled */
333
+#define NETDEV_IRQ_ENABLED 0x0002
334
+
332 335
 /** Link-layer protocol table */
333 336
 #define LL_PROTOCOLS __table ( struct ll_protocol, "ll_protocols" )
334 337
 
@@ -491,6 +494,17 @@ netdev_is_open ( struct net_device *netdev ) {
491 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 508
 extern void netdev_link_down ( struct net_device *netdev );
495 509
 extern int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf );
496 510
 extern void netdev_tx_complete_err ( struct net_device *netdev,

+ 7
- 0
src/net/netdevice.c Voir le fichier

@@ -460,7 +460,14 @@ void unregister_netdev ( struct net_device *netdev ) {
460 460
  * @v enable		Interrupts should be enabled
461 461
  */
462 462
 void netdev_irq ( struct net_device *netdev, int enable ) {
463
+
464
+	/* Enable or disable device interrupts */
463 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
 /**

Chargement…
Annuler
Enregistrer