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

[UNIKRAFT PATCH v2 10/15] plat/tap: Setup txq



Tap driver implements the function to setup the txq.

Signed-off-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx>
---
 plat/drivers/tap/tap.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/plat/drivers/tap/tap.c b/plat/drivers/tap/tap.c
index 819d2be..aa8ab5e 100644
--- a/plat/drivers/tap/tap.c
+++ b/plat/drivers/tap/tap.c
@@ -70,6 +70,12 @@
 struct uk_netdev_tx_queue {
        /* tx queue identifier */
        int queue_id;
+       /* List of tx queue */
+       UK_TAILQ_ENTRY(struct uk_netdev_tx_queue) next;
+       /* Allocator for the txq */
+       struct uk_alloc *a;
+       /* Set the file descriptor for the tap device */
+       int fd;
 };
 
 struct uk_netdev_rx_queue {
@@ -299,17 +305,34 @@ static struct uk_netdev_rx_queue 
*tap_netdev_rxq_setup(struct uk_netdev *dev,
 }
 
 static struct uk_netdev_tx_queue *tap_netdev_txq_setup(struct uk_netdev *dev,
-                                                      __u16 queue_id __unused,
+                                                      __u16 queue_id,
                                                       __u16 nb_desc __unused,
                                        struct uk_netdev_txqueue_conf *conf)
 {
-       int rc = -EINVAL;
+       int rc = 0;
        struct uk_netdev_tx_queue *txq = NULL;
+       struct tap_net_dev *tdev = NULL;
 
        UK_ASSERT(dev && conf);
 
-       txq = ERR2PTR(rc);
+       tdev = to_tapnetdev(dev);
+       txq = uk_zalloc(conf->a, sizeof(*txq));
+       if (!txq) {
+               uk_pr_err(DRIVER_NAME": Failed to allocate the tx queue\n");
+               rc = -ENOMEM;
+               goto err_exit;
+       }
+
+       txq->queue_id = queue_id;
+       txq->fd = tdev->tap_fd;
+       txq->a = conf->a;
+       UK_TAILQ_INSERT_TAIL(&tdev->txqs, txq, next);
+       tdev->txq_cnt++;
+exit:
        return txq;
+err_exit:
+       txq = ERR2PTR(rc);
+       goto exit;
 }
 
 static int tap_netdev_start(struct uk_netdev *n)
-- 
2.7.4




 


Rackspace

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