net/tap: skip overwritten file descriptor assignment
[dpdk.git] / drivers / net / tap / rte_eth_tap.c
index 91f63f5..8811716 100644 (file)
@@ -410,6 +410,7 @@ tap_setup_queue(struct rte_eth_dev *dev,
                struct pmd_internals *internals,
                uint16_t qid)
 {
+       struct pmd_internals *pmd = dev->data->dev_private;
        struct rx_queue *rx = &internals->rxq[qid];
        struct tx_queue *tx = &internals->txq[qid];
        int fd;
@@ -419,11 +420,11 @@ tap_setup_queue(struct rte_eth_dev *dev,
                fd = tx->fd;
                if (fd < 0) {
                        RTE_LOG(INFO, PMD, "Add queue to TAP %s for qid %d\n",
-                               dev->data->name, qid);
-                       fd = tun_alloc(dev->data->name);
+                               pmd->name, qid);
+                       fd = tun_alloc(pmd->name);
                        if (fd < 0) {
                                RTE_LOG(ERR, PMD, "tun_alloc(%s) failed\n",
-                                       dev->data->name);
+                                       pmd->name);
                                return -1;
                        }
                }
@@ -493,7 +494,7 @@ tap_rx_queue_setup(struct rte_eth_dev *dev,
 
        internals->fds[rx_queue_id] = fd;
        RTE_LOG(INFO, PMD, "RX TAP device name %s, qid %d on fd %d\n",
-               dev->data->name, rx_queue_id, internals->rxq[rx_queue_id].fd);
+               internals->name, rx_queue_id, internals->rxq[rx_queue_id].fd);
 
        return 0;
 }
@@ -516,7 +517,7 @@ tap_tx_queue_setup(struct rte_eth_dev *dev,
                return -1;
 
        RTE_LOG(INFO, PMD, "TX TAP device name %s, qid %d on fd %d\n",
-               dev->data->name, tx_queue_id, internals->txq[tx_queue_id].fd);
+               internals->name, tx_queue_id, internals->txq[tx_queue_id].fd);
 
        return 0;
 }
@@ -594,20 +595,20 @@ eth_dev_tap_create(const char *name, char *tap_name)
 
        data = rte_zmalloc_socket(tap_name, sizeof(*data), 0, numa_node);
        if (!data) {
-               RTE_LOG(INFO, PMD, "Failed to allocate data\n");
+               RTE_LOG(ERR, PMD, "Failed to allocate data\n");
                goto error_exit;
        }
 
        pmd = rte_zmalloc_socket(tap_name, sizeof(*pmd), 0, numa_node);
        if (!pmd) {
-               RTE_LOG(INFO, PMD, "Unable to allocate internal struct\n");
+               RTE_LOG(ERR, PMD, "Unable to allocate internal struct\n");
                goto error_exit;
        }
 
        /* Use the name and not the tap_name */
        dev = rte_eth_dev_allocate(tap_name);
        if (!dev) {
-               RTE_LOG(INFO, PMD, "Unable to allocate device struct\n");
+               RTE_LOG(ERR, PMD, "Unable to allocate device struct\n");
                goto error_exit;
        }
 
@@ -638,12 +639,12 @@ eth_dev_tap_create(const char *name, char *tap_name)
        /* Create the first Tap device */
        fd = tun_alloc(tap_name);
        if (fd < 0) {
-               RTE_LOG(INFO, PMD, "tun_alloc() failed\n");
+               RTE_LOG(ERR, PMD, "tun_alloc() failed\n");
                goto error_exit;
        }
 
        /* Presetup the fds to -1 as being not working */
-       for (i = 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) {
+       for (i = 1; i < RTE_PMD_TAP_MAX_QUEUES; i++) {
                pmd->fds[i] = -1;
                pmd->rxq[i].fd = -1;
                pmd->txq[i].fd = -1;
@@ -655,7 +656,7 @@ eth_dev_tap_create(const char *name, char *tap_name)
        pmd->fds[0] = fd;
 
        if (pmd_mac_address(fd, dev, &pmd->eth_addr) < 0) {
-               RTE_LOG(INFO, PMD, "Unable to get MAC address\n");
+               RTE_LOG(ERR, PMD, "Unable to get MAC address\n");
                goto error_exit;
        }