]> git.droids-corp.org - dpdk.git/commitdiff
drivers/net: use device name from device structure
authorFerruh Yigit <ferruh.yigit@intel.com>
Fri, 9 Jun 2017 18:36:05 +0000 (19:36 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 5 Jul 2017 22:17:02 +0000 (00:17 +0200)
Device name resides in two different locations, in rte_device->name and
in ethernet device private data.

For now, the copy in the ethernet device private data is required for
multi process support, the name is the how secondary process finds about
primary process device.

But for drivers there is no reason to use the copy in the ethernet
device private data.

This patch updates PMDs to use only rte_device->name.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
drivers/net/af_packet/rte_eth_af_packet.c
drivers/net/bnxt/bnxt_irq.c
drivers/net/bonding/rte_eth_bond_alb.c
drivers/net/bonding/rte_eth_bond_args.c
drivers/net/bonding/rte_eth_bond_pmd.c
drivers/net/i40e/i40e_ethdev.c
drivers/net/ixgbe/ixgbe_ethdev.c
drivers/net/kni/rte_eth_kni.c
drivers/net/ring/rte_eth_ring.c
drivers/net/tap/rte_eth_tap.c

index 5620acdf870c1fb332fa10125999e41a6753201a..9a47852ca018692368bfbc878edb643e2c2d6788 100644 (file)
@@ -413,7 +413,7 @@ eth_rx_queue_setup(struct rte_eth_dev *dev,
        if (data_size > buf_size) {
                RTE_LOG(ERR, PMD,
                        "%s: %d bytes will not fit in mbuf (%d bytes)\n",
-                       dev->data->name, data_size, buf_size);
+                       dev->device->name, data_size, buf_size);
                return -ENOMEM;
        }
 
index a3d235daf3cd6d8c845b4e145ef3cb11d4b8149e..47cda7e521ed6ce5a1c87e35093c26ea93bef6a5 100644 (file)
@@ -137,7 +137,7 @@ int bnxt_setup_int(struct bnxt *bp)
                for (i = 0; i < total_vecs; i++) {
                        bp->irq_tbl[i].vector = i;
                        snprintf(bp->irq_tbl[i].name, len,
-                                "%s-%d", bp->eth_dev->data->name, i);
+                                "%s-%d", bp->eth_dev->device->name, i);
                        bp->irq_tbl[i].handler = bnxt_int_handler;
                }
        } else {
index 38f5c4d4d85837dd1a784694954aeb2a53316653..7f6884d2f179c1a84ca99398de690fc831106d7e 100644 (file)
@@ -80,7 +80,8 @@ bond_mode_alb_enable(struct rte_eth_dev *bond_dev)
                 * The value is chosen to be cache aligned.
                 */
                data_size = 256 + RTE_PKTMBUF_HEADROOM;
-               snprintf(mem_name, sizeof(mem_name), "%s_MODE6", bond_dev->data->name);
+               snprintf(mem_name, sizeof(mem_name), "%s_MODE6",
+                               bond_dev->device->name);
                internals->mode6.mempool = rte_pktmbuf_pool_create(mem_name,
                        512 * RTE_MAX_ETHPORTS,
                        RTE_MEMPOOL_CACHE_MAX_SIZE >= 32 ?
@@ -89,7 +90,7 @@ bond_mode_alb_enable(struct rte_eth_dev *bond_dev)
 
                if (internals->mode6.mempool == NULL) {
                        RTE_LOG(ERR, PMD, "%s: Failed to initialize ALB mempool.\n",
-                                       bond_dev->data->name);
+                                       bond_dev->device->name);
                        goto mempool_alloc_error;
                }
        }
index c718e6145f129ab216ab641c76e4606877ff40b4..a422eb89c75c8fc6015662fd66a5d385cba4bd6b 100644 (file)
@@ -90,7 +90,7 @@ find_port_id_by_dev_name(const char *name)
                if (rte_eth_devices[i].data == NULL)
                        continue;
 
-               if (strcmp(rte_eth_devices[i].data->name, name) == 0)
+               if (strcmp(rte_eth_devices[i].device->name, name) == 0)
                        return i;
        }
        return -1;
index 35fe90673fea6a4ee22fc3abadb5cdddd29880ce..e0e73b25845f74af2d41f73b2cbf2c74db1e2141 100644 (file)
@@ -1667,7 +1667,7 @@ bond_ethdev_close(struct rte_eth_dev *dev)
        uint8_t bond_port_id = internals->port_id;
        int skipped = 0;
 
-       RTE_LOG(INFO, EAL, "Closing bonded device %s\n", dev->data->name);
+       RTE_LOG(INFO, EAL, "Closing bonded device %s\n", dev->device->name);
        while (internals->slave_count != skipped) {
                uint8_t port_id = internals->slaves[skipped].port_id;
 
@@ -1676,7 +1676,7 @@ bond_ethdev_close(struct rte_eth_dev *dev)
                if (rte_eth_bond_slave_remove(bond_port_id, port_id) != 0) {
                        RTE_LOG(ERR, EAL,
                                "Failed to remove port %d from bonded device "
-                               "%s\n", port_id, dev->data->name);
+                               "%s\n", port_id, dev->device->name);
                        skipped++;
                }
        }
@@ -2498,7 +2498,7 @@ bond_remove(struct rte_vdev_device *dev)
 static int
 bond_ethdev_configure(struct rte_eth_dev *dev)
 {
-       char *name = dev->data->name;
+       const char *name = dev->device->name;
        struct bond_dev_private *internals = dev->data->dev_private;
        struct rte_kvargs *kvlist = internals->kvlist;
        int arg_count;
index e02fbb17eec50ecec0d063c163d9a7f09ce20002..d8b8dabf4e364989d5fdbbcc566068af662cbd19 100644 (file)
@@ -919,7 +919,7 @@ i40e_init_ethtype_filter_list(struct rte_eth_dev *dev)
        /* Initialize ethertype filter rule list and hash */
        TAILQ_INIT(&ethertype_rule->ethertype_list);
        snprintf(ethertype_hash_name, RTE_HASH_NAMESIZE,
-                "ethertype_%s", dev->data->name);
+                "ethertype_%s", dev->device->name);
        ethertype_rule->hash_table = rte_hash_create(&ethertype_hash_params);
        if (!ethertype_rule->hash_table) {
                PMD_INIT_LOG(ERR, "Failed to create ethertype hash table!");
@@ -964,7 +964,7 @@ i40e_init_tunnel_filter_list(struct rte_eth_dev *dev)
        /* Initialize tunnel filter rule list and hash */
        TAILQ_INIT(&tunnel_rule->tunnel_list);
        snprintf(tunnel_hash_name, RTE_HASH_NAMESIZE,
-                "tunnel_%s", dev->data->name);
+                "tunnel_%s", dev->device->name);
        tunnel_rule->hash_table = rte_hash_create(&tunnel_hash_params);
        if (!tunnel_rule->hash_table) {
                PMD_INIT_LOG(ERR, "Failed to create tunnel hash table!");
@@ -1009,7 +1009,7 @@ i40e_init_fdir_filter_list(struct rte_eth_dev *dev)
        /* Initialize flow director filter rule list and hash */
        TAILQ_INIT(&fdir_info->fdir_list);
        snprintf(fdir_hash_name, RTE_HASH_NAMESIZE,
-                "fdir_%s", dev->data->name);
+                "fdir_%s", dev->device->name);
        fdir_info->hash_table = rte_hash_create(&fdir_hash_params);
        if (!fdir_info->hash_table) {
                PMD_INIT_LOG(ERR, "Failed to create fdir hash table!");
index 39c744038b804d0372961060a628ad121de04027..41c7d25f8c20258db57e76a3df435b81b3a95d94 100644 (file)
@@ -1480,7 +1480,7 @@ static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev)
 
        TAILQ_INIT(&fdir_info->fdir_list);
        snprintf(fdir_hash_name, RTE_HASH_NAMESIZE,
-                "fdir_%s", eth_dev->data->name);
+                "fdir_%s", eth_dev->device->name);
        fdir_info->hash_handle = rte_hash_create(&fdir_hash_params);
        if (!fdir_info->hash_handle) {
                PMD_INIT_LOG(ERR, "Failed to create fdir hash table!");
@@ -1516,7 +1516,7 @@ static int ixgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev)
 
        TAILQ_INIT(&l2_tn_info->l2_tn_list);
        snprintf(l2_tn_hash_name, RTE_HASH_NAMESIZE,
-                "l2_tn_%s", eth_dev->data->name);
+                "l2_tn_%s", eth_dev->device->name);
        l2_tn_info->hash_handle = rte_hash_create(&l2_tn_hash_params);
        if (!l2_tn_info->hash_handle) {
                PMD_INIT_LOG(ERR, "Failed to create L2 TN hash table!");
index f688d91928a5b6345728fbe39d14806b0fa8aca5..72a2733ba59c52b4fc9f522871987d5b05790f0d 100644 (file)
@@ -145,7 +145,7 @@ eth_kni_start(struct rte_eth_dev *dev)
        uint16_t port_id = dev->data->port_id;
        struct rte_mempool *mb_pool;
        struct rte_kni_conf conf;
-       const char *name = dev->data->name + 4; /* remove net_ */
+       const char *name = dev->device->name + 4; /* remove net_ */
 
        snprintf(conf.name, RTE_KNI_NAMESIZE, "%s", name);
        conf.force_bind = 0;
index 8622d99e343fac5750c8d518335bdabaa24033ec..820a41104a9e6a5143df319013fe5a1269c87116 100644 (file)
@@ -280,6 +280,8 @@ do_eth_dev_ring_create(const char *name,
        struct rte_eth_dev_data *data = NULL;
        struct pmd_internals *internals = NULL;
        struct rte_eth_dev *eth_dev = NULL;
+       void **rx_queues_local = NULL;
+       void **tx_queues_local = NULL;
        unsigned i;
 
        RTE_LOG(INFO, PMD, "Creating rings-backed ethdev on numa socket %u\n",
@@ -294,16 +296,16 @@ do_eth_dev_ring_create(const char *name,
                goto error;
        }
 
-       data->rx_queues = rte_zmalloc_socket(name,
+       rx_queues_local = rte_zmalloc_socket(name,
                        sizeof(void *) * nb_rx_queues, 0, numa_node);
-       if (data->rx_queues == NULL) {
+       if (rx_queues_local == NULL) {
                rte_errno = ENOMEM;
                goto error;
        }
 
-       data->tx_queues = rte_zmalloc_socket(name,
+       tx_queues_local = rte_zmalloc_socket(name,
                        sizeof(void *) * nb_tx_queues, 0, numa_node);
-       if (data->tx_queues == NULL) {
+       if (tx_queues_local == NULL) {
                rte_errno = ENOMEM;
                goto error;
        }
@@ -330,6 +332,10 @@ do_eth_dev_ring_create(const char *name,
        /* NOTE: we'll replace the data element, of originally allocated eth_dev
         * so the rings are local per-process */
 
+       rte_memcpy(data, eth_dev->data, sizeof(*data));
+       data->rx_queues = rx_queues_local;
+       data->tx_queues = tx_queues_local;
+
        internals->action = action;
        internals->max_rx_queues = nb_rx_queues;
        internals->max_tx_queues = nb_tx_queues;
@@ -343,8 +349,6 @@ do_eth_dev_ring_create(const char *name,
        }
 
        data->dev_private = internals;
-       data->port_id = eth_dev->data->port_id;
-       memmove(data->name, eth_dev->data->name, sizeof(data->name));
        data->nb_rx_queues = (uint16_t)nb_rx_queues;
        data->nb_tx_queues = (uint16_t)nb_tx_queues;
        data->dev_link = pmd_link;
@@ -365,10 +369,8 @@ do_eth_dev_ring_create(const char *name,
        return data->port_id;
 
 error:
-       if (data) {
-               rte_free(data->rx_queues);
-               rte_free(data->tx_queues);
-       }
+       rte_free(rx_queues_local);
+       rte_free(tx_queues_local);
        rte_free(data);
        rte_free(internals);
 
index 7cfa0a85d375b19a140074bda12d30e1924b0e90..f82f08802fb1e21bb2160de6dc5514ba861eed16 100644 (file)
@@ -843,7 +843,7 @@ tap_mac_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
 
        if (is_zero_ether_addr(mac_addr)) {
                RTE_LOG(ERR, PMD, "%s: can't set an empty MAC address\n",
-                       dev->data->name);
+                       dev->device->name);
                return;
        }
        /* Check the actual current MAC address on the tap netdevice */
@@ -868,13 +868,13 @@ tap_mac_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
                if (tap_flow_implicit_destroy(pmd, TAP_REMOTE_LOCAL_MAC) < 0) {
                        RTE_LOG(ERR, PMD,
                                "%s: Couldn't delete MAC redirection rule\n",
-                               dev->data->name);
+                               dev->device->name);
                        return;
                }
                if (tap_flow_implicit_create(pmd, TAP_REMOTE_LOCAL_MAC) < 0)
                        RTE_LOG(ERR, PMD,
                                "%s: Couldn't add MAC redirection rule\n",
-                               dev->data->name);
+                               dev->device->name);
        }
 }
 
@@ -937,12 +937,12 @@ tap_rx_queue_setup(struct rte_eth_dev *dev,
        rxq->trigger_seen = 1; /* force initial burst */
        rxq->in_port = dev->data->port_id;
        rxq->nb_rx_desc = nb_desc;
-       iovecs = rte_zmalloc_socket(dev->data->name, sizeof(*iovecs), 0,
+       iovecs = rte_zmalloc_socket(dev->device->name, sizeof(*iovecs), 0,
                                    socket_id);
        if (!iovecs) {
                RTE_LOG(WARNING, PMD,
                        "%s: Couldn't allocate %d RX descriptors\n",
-                       dev->data->name, nb_desc);
+                       dev->device->name, nb_desc);
                return -ENOMEM;
        }
        rxq->iovecs = iovecs;
@@ -962,7 +962,7 @@ tap_rx_queue_setup(struct rte_eth_dev *dev,
                if (!*tmp) {
                        RTE_LOG(WARNING, PMD,
                                "%s: couldn't allocate memory for queue %d\n",
-                               dev->data->name, rx_queue_id);
+                               dev->device->name, rx_queue_id);
                        ret = -ENOMEM;
                        goto error;
                }