aboutsummaryrefslogtreecommitdiff
path: root/src/include/ipxe/netdevice.h
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2010-11-20 04:56:25 +0000
committerMichael Brown <mcb30@ipxe.org>2010-11-20 15:46:00 +0000
commit4576c2da587eeb884fbf848021d06d1a7d280e3f (patch)
tree1316462745251b50f02733d76b3379cdb7b772d5 /src/include/ipxe/netdevice.h
parent006d9f1f60594d6ffd147bea1f08bc753051a50d (diff)
downloadipxe-4576c2da587eeb884fbf848021d06d1a7d280e3f.zip
ipxe-4576c2da587eeb884fbf848021d06d1a7d280e3f.tar.gz
ipxe-4576c2da587eeb884fbf848021d06d1a7d280e3f.tar.bz2
[netdevice] Allow per-device receive queue processing to be frozen
Several use cases (e.g. the UNDI API and the EFI SNP API) require access to the raw network device receive queue, and so currently use manual calls to netdev_poll() on a specific network device in order to prevent received packets from being processed by the network stack. As an alternative, provide a flag that allows receive queue processing to be frozen on a per-device basis. When receive queue processing is frozen, packets will be enqueued as normal, but will not be automatically dequeued and passed up the network stack. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe/netdevice.h')
-rw-r--r--src/include/ipxe/netdevice.h39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/include/ipxe/netdevice.h b/src/include/ipxe/netdevice.h
index 4649377..26e2ab8 100644
--- a/src/include/ipxe/netdevice.h
+++ b/src/include/ipxe/netdevice.h
@@ -343,6 +343,9 @@ struct net_device {
/** Network device interrupts are enabled */
#define NETDEV_IRQ_ENABLED 0x0002
+/** Network device receive queue processing is frozen */
+#define NETDEV_RX_FROZEN 0x0004
+
/** Link-layer protocol table */
#define LL_PROTOCOLS __table ( struct ll_protocol, "ll_protocols" )
@@ -505,7 +508,7 @@ netdev_link_ok ( struct net_device *netdev ) {
* Check whether or not network device is open
*
* @v netdev Network device
- * @v is_open Network device is open
+ * @ret is_open Network device is open
*/
static inline __attribute__ (( always_inline )) int
netdev_is_open ( struct net_device *netdev ) {
@@ -516,13 +519,24 @@ netdev_is_open ( struct net_device *netdev ) {
* Check whether or not network device interrupts are currently enabled
*
* @v netdev Network device
- * @v irq_enabled Network device interrupts are enabled
+ * @ret 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 );
}
+/**
+ * Check whether or not network device receive queue processing is frozen
+ *
+ * @v netdev Network device
+ * @ret rx_frozen Network device receive queue processing is frozen
+ */
+static inline __attribute__ (( always_inline )) int
+netdev_rx_frozen ( struct net_device *netdev ) {
+ return ( netdev->state & NETDEV_RX_FROZEN );
+}
+
extern void netdev_link_err ( struct net_device *netdev, int rc );
extern void netdev_link_down ( struct net_device *netdev );
extern int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf );
@@ -550,6 +564,7 @@ extern int net_tx ( struct io_buffer *iobuf, struct net_device *netdev,
extern int net_rx ( struct io_buffer *iobuf, struct net_device *netdev,
uint16_t net_proto, const void *ll_dest,
const void *ll_source );
+extern void net_poll ( void );
/**
* Complete network transmission
@@ -585,4 +600,24 @@ netdev_link_up ( struct net_device *netdev ) {
netdev_link_err ( netdev, 0 );
}
+/**
+ * Freeze network device receive queue processing
+ *
+ * @v netdev Network device
+ */
+static inline __attribute__ (( always_inline )) void
+netdev_rx_freeze ( struct net_device *netdev ) {
+ netdev->state |= NETDEV_RX_FROZEN;
+}
+
+/**
+ * Unfreeze network device receive queue processing
+ *
+ * @v netdev Network device
+ */
+static inline __attribute__ (( always_inline )) void
+netdev_rx_unfreeze ( struct net_device *netdev ) {
+ netdev->state &= ~NETDEV_RX_FROZEN;
+}
+
#endif /* _IPXE_NETDEVICE_H */