ethdev: initialize more fields on allocation
authorJan Blunck <jblunck@infradead.org>
Thu, 17 Nov 2016 17:16:12 +0000 (18:16 +0100)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Wed, 21 Dec 2016 16:32:17 +0000 (17:32 +0100)
This moves the non-PCI related initialization of the link state interrupt
callback list and the setting of the default MTU to rte_eth_dev_allocate()
so that drivers only need to set non-default values.

Signed-off-by: Jan Blunck <jblunck@infradead.org>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
app/test/virtual_pmd.c
drivers/net/bonding/rte_eth_bond_api.c
drivers/net/cxgbe/cxgbe_main.c
drivers/net/mlx4/mlx4.c
drivers/net/mlx5/mlx5.c
drivers/net/null/rte_eth_null.c
drivers/net/ring/rte_eth_ring.c
drivers/net/vhost/rte_eth_vhost.c
lib/librte_ether/rte_ethdev.c

index 65b44c6..bd969f9 100644 (file)
@@ -601,8 +601,6 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
        eth_dev->data->nb_rx_queues = (uint16_t)1;
        eth_dev->data->nb_tx_queues = (uint16_t)1;
 
-       TAILQ_INIT(&(eth_dev->link_intr_cbs));
-
        eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
        eth_dev->data->dev_link.link_speed = ETH_SPEED_NUM_10G;
        eth_dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
index ed75c28..19347d8 100644 (file)
@@ -200,8 +200,6 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
        eth_dev->data->nb_rx_queues = (uint16_t)1;
        eth_dev->data->nb_tx_queues = (uint16_t)1;
 
-       TAILQ_INIT(&(eth_dev->link_intr_cbs));
-
        eth_dev->data->mac_addrs = rte_zmalloc_socket(name, ETHER_ADDR_LEN, 0,
                        socket_id);
        if (eth_dev->data->mac_addrs == NULL) {
index 922155b..9e8402b 100644 (file)
@@ -1172,8 +1172,6 @@ allocate_mac:
 
                rte_eth_copy_pci_info(pi->eth_dev, pi->eth_dev->pci_dev);
 
-               TAILQ_INIT(&pi->eth_dev->link_intr_cbs);
-
                pi->eth_dev->data->mac_addrs = rte_zmalloc(name,
                                                           ETHER_ADDR_LEN, 0);
                if (!pi->eth_dev->data->mac_addrs) {
index d967565..82b51a7 100644 (file)
@@ -5834,7 +5834,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                        eth_dev->rx_pkt_burst = mlx4_rx_burst_secondary_setup;
                } else {
                        eth_dev->data->dev_private = priv;
-                       eth_dev->data->mtu = ETHER_MTU;
                        eth_dev->data->mac_addrs = priv->mac;
                }
                eth_dev->pci_dev = pci_dev;
@@ -5845,7 +5844,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 
                priv->dev = eth_dev;
                eth_dev->dev_ops = &mlx4_dev_ops;
-               TAILQ_INIT(&eth_dev->link_intr_cbs);
 
                /* Bring Ethernet device up. */
                DEBUG("forcing Ethernet interface up");
index 128a761..ca123e4 100644 (file)
@@ -652,7 +652,6 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                        eth_dev->rx_pkt_burst = mlx5_rx_burst_secondary_setup;
                } else {
                        eth_dev->data->dev_private = priv;
-                       eth_dev->data->mtu = ETHER_MTU;
                        eth_dev->data->mac_addrs = priv->mac;
                }
 
@@ -662,8 +661,6 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                priv->dev = eth_dev;
                eth_dev->dev_ops = &mlx5_dev_ops;
 
-               TAILQ_INIT(&eth_dev->link_intr_cbs);
-
                /* Bring Ethernet device up. */
                DEBUG("forcing Ethernet interface up");
                priv_set_flags(priv, ~IFF_UP, IFF_UP);
index 836d982..f09caf1 100644 (file)
@@ -550,8 +550,6 @@ eth_dev_null_create(const char *name,
        eth_dev->data = data;
        eth_dev->dev_ops = &ops;
 
-       TAILQ_INIT(&eth_dev->link_intr_cbs);
-
        eth_dev->driver = NULL;
        data->dev_flags = RTE_ETH_DEV_DETACHABLE;
        data->kdrv = RTE_KDRV_NONE;
index c1767c4..c7726f4 100644 (file)
@@ -346,8 +346,6 @@ do_eth_dev_ring_create(const char *name,
        data->drv_name = drivername;
        data->numa_node = numa_node;
 
-       TAILQ_INIT(&(eth_dev->link_intr_cbs));
-
        /* finally assign rx and tx ops */
        eth_dev->rx_pkt_burst = eth_ring_rx;
        eth_dev->tx_pkt_burst = eth_ring_tx;
index 766d4ef..1912346 100644 (file)
@@ -1032,8 +1032,6 @@ eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues,
        if (vring_state == NULL)
                goto error;
 
-       TAILQ_INIT(&eth_dev->link_intr_cbs);
-
        /* now put it all together
         * - store queue data in internal,
         * - store numa_node info in ethdev data
index 59038ad..a6d82fa 100644 (file)
@@ -215,6 +215,9 @@ rte_eth_dev_allocate(const char *name)
        memset(eth_dev->data, 0, sizeof(*eth_dev->data));
        snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
        eth_dev->data->port_id = port_id;
+       eth_dev->data->mtu = ETHER_MTU;
+       TAILQ_INIT(&(eth_dev->link_intr_cbs));
+
        eth_dev->attached = DEV_ATTACHED;
        eth_dev_last_created_port = port_id;
        nb_ports++;
@@ -261,14 +264,6 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
        eth_dev->pci_dev = pci_dev;
        eth_dev->driver = eth_drv;
 
-       /* init user callbacks */
-       TAILQ_INIT(&(eth_dev->link_intr_cbs));
-
-       /*
-        * Set the default MTU.
-        */
-       eth_dev->data->mtu = ETHER_MTU;
-
        /* Invoke PMD device initialization function */
        diag = (*eth_drv->eth_dev_init)(eth_dev);
        if (diag == 0)