瀏覽代碼

[netdevice] Record whether or not interrupts are currently enabled

Signed-off-by: Michael Brown <mcb30@etherboot.org>
tags/v1.20.1
Michael Brown 14 年之前
父節點
當前提交
4a7648bd3d
共有 2 個檔案被更改,包括 21 行新增0 行删除
  1. 14
    0
      src/include/gpxe/netdevice.h
  2. 7
    0
      src/net/netdevice.c

+ 14
- 0
src/include/gpxe/netdevice.h 查看文件

@@ -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 查看文件

@@ -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
 /**

Loading…
取消
儲存