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

[Minios-devel] [UNIKRAFT PATCH v2 09/12] plat/xen/drivers/net: Add support for enabling/disabling interrupts for rx queues


  • To: minios-devel@xxxxxxxxxxxxx
  • From: Costin Lupu <costin.lupu@xxxxxxxxx>
  • Date: Mon, 1 Apr 2019 16:42:49 +0300
  • Cc: felipe.huici@xxxxxxxxx, Razvan Cojocaru <razvan.cojocaru93@xxxxxxxxx>, Florian.Schmidt@xxxxxxxxx, sharan.santhanam@xxxxxxxxx, simon.kuenzer@xxxxxxxxx, yuri.volchkov@xxxxxxxxx
  • Delivery-date: Mon, 01 Apr 2019 13:43:06 +0000
  • Ironport-phdr: 9a23:cXoWRhD84PGVBXDGlG4WUyQJP3N1i/DPJgcQr6AfoPdwSP36r86wAkXT6L1XgUPTWs2DsrQY0rKQ4vyrBzBIyK3CmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TW94jEIBxrwKxd+KPjrFY7OlcS30P2594HObwlSizexfK9+IA+yoAjeucUbgIRvIbstxxXUpXdFZ/5Yzn5yK1KJmBb86Maw/Jp9/ClVpvks6c1OX7jkcqohVbBXAygoPG4z5M3wqBnMVhCP6WcGUmUXiRVHHQ7I5wznU5jrsyv6su192DSGPcDzULs5Vyiu47ttRRT1kyoMKSI3/3/LhcxxlKJboQyupxpjw47PfYqZMONycr7Bcd8GQGZMWNtaWS5cDYOmd4YBD/QPM/tWoYf+oFUBrxW+CBKwCO/z0DJEmmX70bEm3+knDArI3BYgH9ULsHnMstj1M7wSUfy0zKnO0D7Nae5W2S/g6IPVdR0uvfaMXalsccrQz0kjDQfFjkiIqYz4JD6ayv8Nv3KD7+p9Tu2jkXQnqwZorzWp28wiiZHJi5oIxl3L6Cl12oU4KN2iREJlf9KpEoFcui+CO4drTc4uXntktSU6x7Ecp5K2ciYHxI46yxPQdfCKdZWD7Aj5W+aLOzh4gWpoeLe4hxmv70et0vb8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ists.xenproject.org>

The current patch introduces support for the user to enable/disable
interrupts on rx queues.

Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@xxxxxxxxx>
---
 plat/xen/drivers/net/netfront.c | 67 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/plat/xen/drivers/net/netfront.c b/plat/xen/drivers/net/netfront.c
index 586c0e6a..fc256501 100644
--- a/plat/xen/drivers/net/netfront.c
+++ b/plat/xen/drivers/net/netfront.c
@@ -46,6 +46,12 @@
 
 #define DRIVER_NAME  "xen-netfront"
 
+/* TODO Same interrupt macros we use in virtio-net */
+#define NETFRONT_INTR_EN             (1 << 0)
+#define NETFRONT_INTR_EN_MASK        (1)
+#define NETFRONT_INTR_USR_EN         (1 << 1)
+#define NETFRONT_INTR_USR_EN_MASK    (2)
+
 #define to_netfront_dev(dev) \
        __containerof(dev, struct netfront_dev, netdev)
 
@@ -148,6 +154,22 @@ out:
        return status;
 }
 
+/* Returns 1 if more packets available */
+static int netfront_rxq_intr_enable(struct uk_netdev_rx_queue *rxq)
+{
+       int more;
+
+       /* Check if there are no more packets enabled */
+       RING_FINAL_CHECK_FOR_RESPONSES(&rxq->ring, more);
+       if (!more) {
+               /* No more packets, we can enable interrupts */
+               rxq->intr_enabled |= NETFRONT_INTR_EN;
+               unmask_evtchn(rxq->evtchn);
+       }
+
+       return (more > 0);
+}
+
 static struct uk_netdev_tx_queue *netfront_txq_setup(struct uk_netdev *n,
                uint16_t queue_id,
                uint16_t nb_desc __unused,
@@ -218,6 +240,10 @@ static void netfront_handler(evtchn_port_t port __unused,
 {
        struct uk_netdev_rx_queue *rxq = arg;
 
+       /* Disable the interrupt for the ring */
+       rxq->intr_enabled &= ~(NETFRONT_INTR_EN);
+       mask_evtchn(rxq->evtchn);
+
        /* Indicate to the network stack about an event */
        uk_netdev_drv_rx_event(&rxq->netfront_dev->netdev, rxq->lqueue_id);
 }
@@ -334,6 +360,45 @@ err_free_txrx:
        return rc;
 }
 
+static int netfront_rx_intr_enable(struct uk_netdev *n,
+               struct uk_netdev_rx_queue *rxq)
+{
+       int rc;
+
+       UK_ASSERT(n != NULL);
+       UK_ASSERT(rxq != NULL);
+       UK_ASSERT(&rxq->netfront_dev->netdev == n);
+
+       /* If the interrupt is enabled */
+       if (rxq->intr_enabled & NETFRONT_INTR_EN)
+               return 0;
+
+       /**
+        * Enable the user configuration bit. This would cause the interrupt to
+        * be enabled automatically if the interrupt could not be enabled now
+        * due to data in the queue.
+        */
+       rxq->intr_enabled = NETFRONT_INTR_USR_EN;
+       rc = netfront_rxq_intr_enable(rxq);
+       if (!rc)
+               rxq->intr_enabled |= NETFRONT_INTR_EN;
+
+       return rc;
+}
+
+static int netfront_rx_intr_disable(struct uk_netdev *n,
+               struct uk_netdev_rx_queue *rxq)
+{
+       UK_ASSERT(n != NULL);
+       UK_ASSERT(rxq != NULL);
+       UK_ASSERT(&rxq->netfront_dev->netdev == n);
+
+       rxq->intr_enabled &= ~(NETFRONT_INTR_USR_EN | NETFRONT_INTR_EN);
+       mask_evtchn(rxq->evtchn);
+
+       return 0;
+}
+
 static int netfront_txq_info_get(struct uk_netdev *n,
                uint16_t queue_id,
                struct uk_netdev_queue_info *qinfo)
@@ -478,6 +543,8 @@ static const struct uk_netdev_ops netfront_ops = {
        .configure = netfront_configure,
        .txq_configure = netfront_txq_setup,
        .rxq_configure = netfront_rxq_setup,
+       .rxq_intr_enable = netfront_rx_intr_enable,
+       .rxq_intr_disable = netfront_rx_intr_disable,
        .txq_info_get = netfront_txq_info_get,
        .rxq_info_get = netfront_rxq_info_get,
        .info_get = netfront_info_get,
-- 
2.11.0


_______________________________________________
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®.