[dpdk-dev,2/2] Move non-PCI related eth_dev initialization to rte_eth_dev_allocate()
Checks
Commit Message
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>
---
drivers/net/bonding/rte_eth_bond_api.c | 2 --
drivers/net/cxgbe/cxgbe_main.c | 2 --
drivers/net/mlx4/mlx4.c | 2 --
drivers/net/mlx5/mlx5.c | 3 ---
drivers/net/null/rte_eth_null.c | 2 --
drivers/net/ring/rte_eth_ring.c | 2 --
drivers/net/vhost/rte_eth_vhost.c | 2 --
lib/librte_ether/rte_ethdev.c | 12 ++++--------
8 files changed, 4 insertions(+), 23 deletions(-)
Comments
On 11/17/2016 2:24 PM, Jan Blunck wrote:
> 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>
> ---
> drivers/net/bonding/rte_eth_bond_api.c | 2 --
> drivers/net/cxgbe/cxgbe_main.c | 2 --
> drivers/net/mlx4/mlx4.c | 2 --
> drivers/net/mlx5/mlx5.c | 3 ---
> drivers/net/null/rte_eth_null.c | 2 --
> drivers/net/ring/rte_eth_ring.c | 2 --
> drivers/net/vhost/rte_eth_vhost.c | 2 --
> lib/librte_ether/rte_ethdev.c | 12 ++++--------
> 8 files changed, 4 insertions(+), 23 deletions(-)
I think following also redundant and can be removed:
app/test/virtual_pmd.c:
604: TAILQ_INIT(&(eth_dev->link_intr_cbs));
<...>
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index 12af4b1..f58a995 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
What do you think doing same thing for rte_cryptodev.c J
> @@ -215,6 +215,10 @@ 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->rx_mbuf_alloc_failed = 0;
This is no more required, because of memset
> + 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 +265,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)
>
On Thu, Nov 17, 2016 at 4:46 PM, Ferruh Yigit <ferruh.yigit@intel.com> wrote:
> On 11/17/2016 2:24 PM, Jan Blunck wrote:
>> 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>
>> ---
>> drivers/net/bonding/rte_eth_bond_api.c | 2 --
>> drivers/net/cxgbe/cxgbe_main.c | 2 --
>> drivers/net/mlx4/mlx4.c | 2 --
>> drivers/net/mlx5/mlx5.c | 3 ---
>> drivers/net/null/rte_eth_null.c | 2 --
>> drivers/net/ring/rte_eth_ring.c | 2 --
>> drivers/net/vhost/rte_eth_vhost.c | 2 --
>> lib/librte_ether/rte_ethdev.c | 12 ++++--------
>> 8 files changed, 4 insertions(+), 23 deletions(-)
>
> I think following also redundant and can be removed:
> app/test/virtual_pmd.c:
> 604: TAILQ_INIT(&(eth_dev->link_intr_cbs));
>
> <...>
>
>> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
>> index 12af4b1..f58a995 100644
>> --- a/lib/librte_ether/rte_ethdev.c
>> +++ b/lib/librte_ether/rte_ethdev.c
>
> What do you think doing same thing for rte_cryptodev.c J
>
Thanks for the review Ferruh. I'll fixup the patches and resend. I'm
currently looking in the rte_bus and rte_eth_dev stuff. If nobody
volunteers to do the changes for cryptodev I can take a look at some
later point.
Thanks,
Jan
>> @@ -215,6 +215,10 @@ 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->rx_mbuf_alloc_failed = 0;
>
> This is no more required, because of memset
>
>> + 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 +265,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)
>>
>
@@ -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->dev_link.link_status = ETH_LINK_DOWN;
eth_dev->data->mac_addrs = rte_zmalloc_socket(name, ETHER_ADDR_LEN, 0,
@@ -1172,8 +1172,6 @@ int cxgbe_probe(struct adapter *adapter)
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) {
@@ -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(ð_dev->link_intr_cbs);
/* Bring Ethernet device up. */
DEBUG("forcing Ethernet interface up");
@@ -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(ð_dev->link_intr_cbs);
-
/* Bring Ethernet device up. */
DEBUG("forcing Ethernet interface up");
priv_set_flags(priv, ~IFF_UP, IFF_UP);
@@ -550,8 +550,6 @@ eth_dev_null_create(const char *name,
eth_dev->data = data;
eth_dev->dev_ops = &ops;
- TAILQ_INIT(ð_dev->link_intr_cbs);
-
eth_dev->driver = NULL;
data->dev_flags = RTE_ETH_DEV_DETACHABLE;
data->kdrv = RTE_KDRV_NONE;
@@ -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;
@@ -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(ð_dev->link_intr_cbs);
-
/* now put it all together
* - store queue data in internal,
* - store numa_node info in ethdev data
@@ -215,6 +215,10 @@ 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->rx_mbuf_alloc_failed = 0;
+ 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 +265,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)