summaryrefslogtreecommitdiffstats
path: root/src/net/netdevice.c
diff options
context:
space:
mode:
authorMichael Brown2010-11-20 05:56:25 +0100
committerMichael Brown2010-11-20 16:46:00 +0100
commit4576c2da587eeb884fbf848021d06d1a7d280e3f (patch)
tree1316462745251b50f02733d76b3379cdb7b772d5 /src/net/netdevice.c
parent[undi] Support underlying UNDI devices that don't support interrupts (diff)
downloadipxe-4576c2da587eeb884fbf848021d06d1a7d280e3f.tar.gz
ipxe-4576c2da587eeb884fbf848021d06d1a7d280e3f.tar.xz
ipxe-4576c2da587eeb884fbf848021d06d1a7d280e3f.zip
[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/net/netdevice.c')
-rw-r--r--src/net/netdevice.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/net/netdevice.c b/src/net/netdevice.c
index c6c377b5..90dab8fb 100644
--- a/src/net/netdevice.c
+++ b/src/net/netdevice.c
@@ -669,14 +669,12 @@ int net_rx ( struct io_buffer *iobuf, struct net_device *netdev,
}
/**
- * Single-step the network stack
- *
- * @v process Network stack process
+ * Poll the network stack
*
* This polls all interfaces for received packets, and processes
* packets from the RX queue.
*/
-static void net_step ( struct process *process __unused ) {
+void net_poll ( void ) {
struct net_device *netdev;
struct io_buffer *iobuf;
struct ll_protocol *ll_protocol;
@@ -691,6 +689,15 @@ static void net_step ( struct process *process __unused ) {
/* Poll for new packets */
netdev_poll ( netdev );
+ /* Leave received packets on the queue if receive
+ * queue processing is currently frozen. This will
+ * happen when the raw packets are to be manually
+ * dequeued using netdev_rx_dequeue(), rather than
+ * processed via the usual networking stack.
+ */
+ if ( netdev_rx_frozen ( netdev ) )
+ continue;
+
/* Process at most one received packet. Give priority
* to getting packets out of the NIC over processing
* the received packets, because we advertise a window
@@ -723,6 +730,15 @@ static void net_step ( struct process *process __unused ) {
}
}
+/**
+ * Single-step the network stack
+ *
+ * @v process Network stack process
+ */
+static void net_step ( struct process *process __unused ) {
+ net_poll();
+}
+
/** Networking stack process */
struct process net_process __permanent_process = {
.list = LIST_HEAD_INIT ( net_process.list ),