[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH v4 3/4] drivers/virtio: virtio_netdev_recv(): Remove disabling interrupts



Disabling interrupts by virtio_netdev_recv() is not needed because in
normal cases they are already disabled by the internal receive
interrupt handler, right before a uknetdev API program can call the
receive function. When the device is used in pure polling mode, queue
interrutps are never enabled.
We remove this step because of performance reasons. An assertion is
making sure that the API is used as intended.

Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
Reviewed-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx>
---
 lib/uknetdev/include/uk/netdev.h | 8 +++++++-
 plat/drivers/virtio/virtio_net.c | 6 ++----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/lib/uknetdev/include/uk/netdev.h b/lib/uknetdev/include/uk/netdev.h
index 919edea3..2563647c 100644
--- a/lib/uknetdev/include/uk/netdev.h
+++ b/lib/uknetdev/include/uk/netdev.h
@@ -422,7 +422,13 @@ static inline int uk_netdev_rxq_intr_disable(struct 
uk_netdev *dev,
 }
 
 /**
- * Receive one packet and re-program used receive descriptors
+ * Receive one packet and re-program used receive descriptors. In order to 
avoid
+ * race conditions, queue interrupts have to be off while executing this
+ * function. When operating the queue in interrupt mode, this is automatically
+ * the case as soon as an interrupt arrived or the return code of
+ * uk_netdev_rxq_intr_enable() indicated that packets are left on the queue.
+ * In both cases, uk_netdev_rx_one() is going to enable interrupts again as 
soon
+ * as the last packet was received from the queue.
  * If this function is called from interrupt context (e.g., within receive 
event
  * handler when no dispatcher threads are configured) make sure that the
  * provided receive buffer allocator function is interrupt-context-safe
diff --git a/plat/drivers/virtio/virtio_net.c b/plat/drivers/virtio/virtio_net.c
index d76f44a8..3025ed3f 100644
--- a/plat/drivers/virtio/virtio_net.c
+++ b/plat/drivers/virtio/virtio_net.c
@@ -544,10 +544,8 @@ static int virtio_netdev_recv(struct uk_netdev *dev,
        UK_ASSERT(dev && queue);
        UK_ASSERT(pkt);
 
-       if (queue->intr_enabled & VTNET_INTR_USR_EN_MASK) {
-               virtqueue_intr_disable(queue->vq);
-               queue->intr_enabled &= ~(VTNET_INTR_EN);
-       }
+       /* Queue interrupts have to be off when calling receive */
+       UK_ASSERT(!(queue->intr_enabled & VTNET_INTR_EN));
 
        rc = virtio_netdev_rxq_dequeue(queue, pkt);
        if (unlikely(rc < 0)) {
-- 
2.17.1


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.