[dpdk-dev,v3] net/tap: fix dev name look-up

Message ID ffb56d14c13428a7f89e597fe7d27fe5445ed668.1488812470.git.pascal.mazon@6wind.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Pascal Mazon March 6, 2017, 3:13 p.m. UTC
  Store the device name in dev->data->name, to have symmetrical behavior
between rte_pmd_tap_probe(name) and rte_pmd_tap_remove(name).

The netdevice name (linux interface name) is stored in the name field of
struct pmd_internals.

snprintf(data->name) has been moved closer to the rte_ethdev_allocate()
as it should use the same name.

Signed-off-by: Pascal Mazon <pascal.mazon@6wind.com>
---
 drivers/net/tap/rte_eth_tap.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Comments

Wiles, Keith March 6, 2017, 3:16 p.m. UTC | #1
> On Mar 6, 2017, at 9:13 AM, Pascal Mazon <pascal.mazon@6wind.com> wrote:
> 
> Store the device name in dev->data->name, to have symmetrical behavior
> between rte_pmd_tap_probe(name) and rte_pmd_tap_remove(name).
> 
> The netdevice name (linux interface name) is stored in the name field of
> struct pmd_internals.
> 
> snprintf(data->name) has been moved closer to the rte_ethdev_allocate()
> as it should use the same name.
> 
> Signed-off-by: Pascal Mazon <pascal.mazon@6wind.com>
> ---
> drivers/net/tap/rte_eth_tap.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
> index 47a706070652..ece3a5fcc897 100644
> --- a/drivers/net/tap/rte_eth_tap.c
> +++ b/drivers/net/tap/rte_eth_tap.c
> @@ -663,7 +663,9 @@ eth_dev_tap_create(const char *name, char *tap_name)
> 		goto error_exit;
> 	}
> 
> -	dev = rte_eth_dev_allocate(tap_name);
> +	/* name in allocation and data->name must be consistent */
> +	snprintf(data->name, sizeof(data->name), "%s", name);
> +	dev = rte_eth_dev_allocate(name);
> 	if (!dev) {
> 		RTE_LOG(ERR, PMD, "TAP Unable to allocate device struct\n");
> 		goto error_exit;
> @@ -691,7 +693,6 @@ eth_dev_tap_create(const char *name, char *tap_name)
> 	dev->driver = NULL;
> 	dev->rx_pkt_burst = pmd_rx_burst;
> 	dev->tx_pkt_burst = pmd_tx_burst;
> -	snprintf(dev->data->name, sizeof(dev->data->name), "%s", name);
> 
> 	/* Presetup the fds to -1 as being not valid */
> 	for (i = 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) {
> -- 
> 2.8.0.rc0

Looks good to me, but Ferruh seems to be the expect here :-)
> 

Regards,
Keith
  
Ferruh Yigit March 6, 2017, 3:41 p.m. UTC | #2
On 3/6/2017 3:13 PM, Pascal Mazon wrote:
> Store the device name in dev->data->name, to have symmetrical behavior
> between rte_pmd_tap_probe(name) and rte_pmd_tap_remove(name).
> 
> The netdevice name (linux interface name) is stored in the name field of
> struct pmd_internals.
> 
> snprintf(data->name) has been moved closer to the rte_ethdev_allocate()
> as it should use the same name.
> 
> Signed-off-by: Pascal Mazon <pascal.mazon@6wind.com>
> ---
>  drivers/net/tap/rte_eth_tap.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
> index 47a706070652..ece3a5fcc897 100644
> --- a/drivers/net/tap/rte_eth_tap.c
> +++ b/drivers/net/tap/rte_eth_tap.c
> @@ -663,7 +663,9 @@ eth_dev_tap_create(const char *name, char *tap_name)
>  		goto error_exit;
>  	}
>  
> -	dev = rte_eth_dev_allocate(tap_name);
> +	/* name in allocation and data->name must be consistent */
> +	snprintf(data->name, sizeof(data->name), "%s", name);

When you use correct name (name) for rte_eth_dev_allocate(), snprintf()
no more required. rte_eth_dev_allocate() already does it [1].

[1]
http://dpdk.org/browse/dpdk/tree/lib/librte_ether/rte_ethdev.c#n230

> +	dev = rte_eth_dev_allocate(name);
>  	if (!dev) {
>  		RTE_LOG(ERR, PMD, "TAP Unable to allocate device struct\n");
>  		goto error_exit;
> @@ -691,7 +693,6 @@ eth_dev_tap_create(const char *name, char *tap_name)
>  	dev->driver = NULL;
>  	dev->rx_pkt_burst = pmd_rx_burst;
>  	dev->tx_pkt_burst = pmd_tx_burst;
> -	snprintf(dev->data->name, sizeof(dev->data->name), "%s", name);
>  
>  	/* Presetup the fds to -1 as being not valid */
>  	for (i = 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) {
>
  
Ferruh Yigit March 6, 2017, 3:42 p.m. UTC | #3
On 3/6/2017 3:16 PM, Wiles, Keith wrote:
> 
>> On Mar 6, 2017, at 9:13 AM, Pascal Mazon <pascal.mazon@6wind.com> wrote:
>>
>> Store the device name in dev->data->name, to have symmetrical behavior
>> between rte_pmd_tap_probe(name) and rte_pmd_tap_remove(name).
>>
>> The netdevice name (linux interface name) is stored in the name field of
>> struct pmd_internals.
>>
>> snprintf(data->name) has been moved closer to the rte_ethdev_allocate()
>> as it should use the same name.
>>
>> Signed-off-by: Pascal Mazon <pascal.mazon@6wind.com>
>> ---
>> drivers/net/tap/rte_eth_tap.c | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
>> index 47a706070652..ece3a5fcc897 100644
>> --- a/drivers/net/tap/rte_eth_tap.c
>> +++ b/drivers/net/tap/rte_eth_tap.c
>> @@ -663,7 +663,9 @@ eth_dev_tap_create(const char *name, char *tap_name)
>> 		goto error_exit;
>> 	}
>>
>> -	dev = rte_eth_dev_allocate(tap_name);
>> +	/* name in allocation and data->name must be consistent */
>> +	snprintf(data->name, sizeof(data->name), "%s", name);
>> +	dev = rte_eth_dev_allocate(name);
>> 	if (!dev) {
>> 		RTE_LOG(ERR, PMD, "TAP Unable to allocate device struct\n");
>> 		goto error_exit;
>> @@ -691,7 +693,6 @@ eth_dev_tap_create(const char *name, char *tap_name)
>> 	dev->driver = NULL;
>> 	dev->rx_pkt_burst = pmd_rx_burst;
>> 	dev->tx_pkt_burst = pmd_tx_burst;
>> -	snprintf(dev->data->name, sizeof(dev->data->name), "%s", name);
>>
>> 	/* Presetup the fds to -1 as being not valid */
>> 	for (i = 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) {
>> -- 
>> 2.8.0.rc0
> 
> Looks good to me, but Ferruh seems to be the expect here :-)

One more minor update, and will be fine I guess J

>>
> 
> Regards,
> Keith
>
  
Pascal Mazon March 6, 2017, 3:55 p.m. UTC | #4
On Mon, 6 Mar 2017 15:41:14 +0000
Ferruh Yigit <ferruh.yigit@intel.com> wrote:

> On 3/6/2017 3:13 PM, Pascal Mazon wrote:
> > Store the device name in dev->data->name, to have symmetrical
> > behavior between rte_pmd_tap_probe(name) and
> > rte_pmd_tap_remove(name).
> > 
> > The netdevice name (linux interface name) is stored in the name
> > field of struct pmd_internals.
> > 
> > snprintf(data->name) has been moved closer to the
> > rte_ethdev_allocate() as it should use the same name.
> > 
> > Signed-off-by: Pascal Mazon <pascal.mazon@6wind.com>
> > ---
> >  drivers/net/tap/rte_eth_tap.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/net/tap/rte_eth_tap.c
> > b/drivers/net/tap/rte_eth_tap.c index 47a706070652..ece3a5fcc897
> > 100644 --- a/drivers/net/tap/rte_eth_tap.c
> > +++ b/drivers/net/tap/rte_eth_tap.c
> > @@ -663,7 +663,9 @@ eth_dev_tap_create(const char *name, char
> > *tap_name) goto error_exit;
> >  	}
> >  
> > -	dev = rte_eth_dev_allocate(tap_name);
> > +	/* name in allocation and data->name must be consistent */
> > +	snprintf(data->name, sizeof(data->name), "%s", name);
> 
> When you use correct name (name) for rte_eth_dev_allocate(),
> snprintf() no more required. rte_eth_dev_allocate() already does it
> [1].
> 
> [1]
> http://dpdk.org/browse/dpdk/tree/lib/librte_ether/rte_ethdev.c#n230
> 

I disagree here. What rte_eth_dev_allocate() changes, is the shared
automatically-allocated data part, as mentioned in your earlier mail.
We didn't yet pass our own manually allocated data to dev.

Do you see what I mean?

Best regards,
Pascal

> > +	dev = rte_eth_dev_allocate(name);
> >  	if (!dev) {
> >  		RTE_LOG(ERR, PMD, "TAP Unable to allocate device
> > struct\n"); goto error_exit;
> > @@ -691,7 +693,6 @@ eth_dev_tap_create(const char *name, char
> > *tap_name) dev->driver = NULL;
> >  	dev->rx_pkt_burst = pmd_rx_burst;
> >  	dev->tx_pkt_burst = pmd_tx_burst;
> > -	snprintf(dev->data->name, sizeof(dev->data->name), "%s",
> > name); 
> >  	/* Presetup the fds to -1 as being not valid */
> >  	for (i = 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) {
> > 
>
  
Ferruh Yigit March 6, 2017, 4:02 p.m. UTC | #5
On 3/6/2017 3:55 PM, Pascal Mazon wrote:
> On Mon, 6 Mar 2017 15:41:14 +0000
> Ferruh Yigit <ferruh.yigit@intel.com> wrote:
> 
>> On 3/6/2017 3:13 PM, Pascal Mazon wrote:
>>> Store the device name in dev->data->name, to have symmetrical
>>> behavior between rte_pmd_tap_probe(name) and
>>> rte_pmd_tap_remove(name).
>>>
>>> The netdevice name (linux interface name) is stored in the name
>>> field of struct pmd_internals.
>>>
>>> snprintf(data->name) has been moved closer to the
>>> rte_ethdev_allocate() as it should use the same name.
>>>
>>> Signed-off-by: Pascal Mazon <pascal.mazon@6wind.com>
>>> ---
>>>  drivers/net/tap/rte_eth_tap.c | 5 +++--
>>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/net/tap/rte_eth_tap.c
>>> b/drivers/net/tap/rte_eth_tap.c index 47a706070652..ece3a5fcc897
>>> 100644 --- a/drivers/net/tap/rte_eth_tap.c
>>> +++ b/drivers/net/tap/rte_eth_tap.c
>>> @@ -663,7 +663,9 @@ eth_dev_tap_create(const char *name, char
>>> *tap_name) goto error_exit;
>>>  	}
>>>  
>>> -	dev = rte_eth_dev_allocate(tap_name);
>>> +	/* name in allocation and data->name must be consistent */
>>> +	snprintf(data->name, sizeof(data->name), "%s", name);
>>
>> When you use correct name (name) for rte_eth_dev_allocate(),
>> snprintf() no more required. rte_eth_dev_allocate() already does it
>> [1].
>>
>> [1]
>> http://dpdk.org/browse/dpdk/tree/lib/librte_ether/rte_ethdev.c#n230
>>
> 
> I disagree here. What rte_eth_dev_allocate() changes, is the shared
> automatically-allocated data part, as mentioned in your earlier mail.
> We didn't yet pass our own manually allocated data to dev.
> 
> Do you see what I mean?

Yes I do, you are right, so this looks good.

> 
> Best regards,
> Pascal
> 
>>> +	dev = rte_eth_dev_allocate(name);
>>>  	if (!dev) {
>>>  		RTE_LOG(ERR, PMD, "TAP Unable to allocate device
>>> struct\n"); goto error_exit;
>>> @@ -691,7 +693,6 @@ eth_dev_tap_create(const char *name, char
>>> *tap_name) dev->driver = NULL;
>>>  	dev->rx_pkt_burst = pmd_rx_burst;
>>>  	dev->tx_pkt_burst = pmd_tx_burst;
>>> -	snprintf(dev->data->name, sizeof(dev->data->name), "%s",
>>> name); 
>>>  	/* Presetup the fds to -1 as being not valid */
>>>  	for (i = 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) {
>>>
>>
>
  
Ferruh Yigit March 6, 2017, 4:03 p.m. UTC | #6
On 3/6/2017 3:42 PM, Ferruh Yigit wrote:
> On 3/6/2017 3:16 PM, Wiles, Keith wrote:
>>
>>> On Mar 6, 2017, at 9:13 AM, Pascal Mazon <pascal.mazon@6wind.com> wrote:
>>>
>>> Store the device name in dev->data->name, to have symmetrical behavior
>>> between rte_pmd_tap_probe(name) and rte_pmd_tap_remove(name).
>>>
>>> The netdevice name (linux interface name) is stored in the name field of
>>> struct pmd_internals.
>>>
>>> snprintf(data->name) has been moved closer to the rte_ethdev_allocate()
>>> as it should use the same name.
>>>
>>> Signed-off-by: Pascal Mazon <pascal.mazon@6wind.com>
>>> ---
>>> drivers/net/tap/rte_eth_tap.c | 5 +++--
>>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
>>> index 47a706070652..ece3a5fcc897 100644
>>> --- a/drivers/net/tap/rte_eth_tap.c
>>> +++ b/drivers/net/tap/rte_eth_tap.c
>>> @@ -663,7 +663,9 @@ eth_dev_tap_create(const char *name, char *tap_name)
>>> 		goto error_exit;
>>> 	}
>>>
>>> -	dev = rte_eth_dev_allocate(tap_name);
>>> +	/* name in allocation and data->name must be consistent */
>>> +	snprintf(data->name, sizeof(data->name), "%s", name);
>>> +	dev = rte_eth_dev_allocate(name);
>>> 	if (!dev) {
>>> 		RTE_LOG(ERR, PMD, "TAP Unable to allocate device struct\n");
>>> 		goto error_exit;
>>> @@ -691,7 +693,6 @@ eth_dev_tap_create(const char *name, char *tap_name)
>>> 	dev->driver = NULL;
>>> 	dev->rx_pkt_burst = pmd_rx_burst;
>>> 	dev->tx_pkt_burst = pmd_tx_burst;
>>> -	snprintf(dev->data->name, sizeof(dev->data->name), "%s", name);
>>>
>>> 	/* Presetup the fds to -1 as being not valid */
>>> 	for (i = 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) {
>>> -- 
>>> 2.8.0.rc0
>>
>> Looks good to me, but Ferruh seems to be the expect here :-)
> 
> One more minor update, and will be fine I guess J

Since no more update required, I am using above as your "Acked-by".

> 
>>>
>>
>> Regards,
>> Keith
>>
>
  
Wiles, Keith March 6, 2017, 4:14 p.m. UTC | #7
> On Mar 6, 2017, at 10:03 AM, Yigit, Ferruh <ferruh.yigit@intel.com> wrote:

> 

> On 3/6/2017 3:42 PM, Ferruh Yigit wrote:

>> On 3/6/2017 3:16 PM, Wiles, Keith wrote:

>>> 

>>>> On Mar 6, 2017, at 9:13 AM, Pascal Mazon <pascal.mazon@6wind.com> wrote:

>>>> 

>>>> Store the device name in dev->data->name, to have symmetrical behavior

>>>> between rte_pmd_tap_probe(name) and rte_pmd_tap_remove(name).

>>>> 

>>>> The netdevice name (linux interface name) is stored in the name field of

>>>> struct pmd_internals.

>>>> 

>>>> snprintf(data->name) has been moved closer to the rte_ethdev_allocate()

>>>> as it should use the same name.

>>>> 

>>>> Signed-off-by: Pascal Mazon <pascal.mazon@6wind.com>

>>>> ---

>>>> drivers/net/tap/rte_eth_tap.c | 5 +++--

>>>> 1 file changed, 3 insertions(+), 2 deletions(-)

>>>> 

>>>> diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c

>>>> index 47a706070652..ece3a5fcc897 100644

>>>> --- a/drivers/net/tap/rte_eth_tap.c

>>>> +++ b/drivers/net/tap/rte_eth_tap.c

>>>> @@ -663,7 +663,9 @@ eth_dev_tap_create(const char *name, char *tap_name)

>>>> 		goto error_exit;

>>>> 	}

>>>> 

>>>> -	dev = rte_eth_dev_allocate(tap_name);

>>>> +	/* name in allocation and data->name must be consistent */

>>>> +	snprintf(data->name, sizeof(data->name), "%s", name);

>>>> +	dev = rte_eth_dev_allocate(name);

>>>> 	if (!dev) {

>>>> 		RTE_LOG(ERR, PMD, "TAP Unable to allocate device struct\n");

>>>> 		goto error_exit;

>>>> @@ -691,7 +693,6 @@ eth_dev_tap_create(const char *name, char *tap_name)

>>>> 	dev->driver = NULL;

>>>> 	dev->rx_pkt_burst = pmd_rx_burst;

>>>> 	dev->tx_pkt_burst = pmd_tx_burst;

>>>> -	snprintf(dev->data->name, sizeof(dev->data->name), "%s", name);

>>>> 

>>>> 	/* Presetup the fds to -1 as being not valid */

>>>> 	for (i = 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) {

>>>> -- 

>>>> 2.8.0.rc0

>>> 

>>> Looks good to me, but Ferruh seems to be the expect here :-)

>> 

>> One more minor update, and will be fine I guess J

> 

> Since no more update required, I am using above as your "Acked-by”.


Acked-by: Keith Wiles <keith.wiles@intel.com>


> 

>> 

>>>> 

>>> 

>>> Regards,

>>> Keith


Regards,
Keith
  
Ferruh Yigit March 8, 2017, 5:44 p.m. UTC | #8
On 3/6/2017 4:14 PM, Wiles, Keith wrote:
> 
>> On Mar 6, 2017, at 10:03 AM, Yigit, Ferruh <ferruh.yigit@intel.com> wrote:
>>
>> On 3/6/2017 3:42 PM, Ferruh Yigit wrote:
>>> On 3/6/2017 3:16 PM, Wiles, Keith wrote:
>>>>
>>>>> On Mar 6, 2017, at 9:13 AM, Pascal Mazon <pascal.mazon@6wind.com> wrote:
>>>>>
>>>>> Store the device name in dev->data->name, to have symmetrical behavior
>>>>> between rte_pmd_tap_probe(name) and rte_pmd_tap_remove(name).
>>>>>
>>>>> The netdevice name (linux interface name) is stored in the name field of
>>>>> struct pmd_internals.
>>>>>
>>>>> snprintf(data->name) has been moved closer to the rte_ethdev_allocate()
>>>>> as it should use the same name.
>>>>>
>>>>> Signed-off-by: Pascal Mazon <pascal.mazon@6wind.com>

> Acked-by: Keith Wiles <keith.wiles@intel.com>

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 47a706070652..ece3a5fcc897 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -663,7 +663,9 @@  eth_dev_tap_create(const char *name, char *tap_name)
 		goto error_exit;
 	}
 
-	dev = rte_eth_dev_allocate(tap_name);
+	/* name in allocation and data->name must be consistent */
+	snprintf(data->name, sizeof(data->name), "%s", name);
+	dev = rte_eth_dev_allocate(name);
 	if (!dev) {
 		RTE_LOG(ERR, PMD, "TAP Unable to allocate device struct\n");
 		goto error_exit;
@@ -691,7 +693,6 @@  eth_dev_tap_create(const char *name, char *tap_name)
 	dev->driver = NULL;
 	dev->rx_pkt_burst = pmd_rx_burst;
 	dev->tx_pkt_burst = pmd_tx_burst;
-	snprintf(dev->data->name, sizeof(dev->data->name), "%s", name);
 
 	/* Presetup the fds to -1 as being not valid */
 	for (i = 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) {