[dpdk-stable] [ PATCH 17.11 1/2] ethdev: clear ethdev data upon detach

Yongseok Koh yskoh at mellanox.com
Tue Mar 12 22:53:44 CET 2019


> On Mar 12, 2019, at 2:31 AM, Pattan, Reshma <reshma.pattan at intel.com> wrote:
> 
> Hi,
> 
>> -----Original Message-----
>> From: Yongseok Koh [mailto:yskoh at mellanox.com]
>> Sent: Monday, March 4, 2019 7:57 PM
>> To: Pattan, Reshma <reshma.pattan at intel.com>
>> Cc: stable at dpdk.org
>> Subject: Re: [dpdk-stable] [ PATCH 17.11 1/2] ethdev: clear ethdev data upon
>> detach
>> 
>> 
>>> On Mar 1, 2019, at 3:53 AM, Reshma Pattan <reshma.pattan at intel.com>
>> wrote:
>>> 
>>> When port is detached its relevant rte_eth_dev_data[port_id] has to be
>>> zeroed, otherwise the next port creations could get wrong port_id.
>>> 
>>> Fixes: 92d94d3744 ("ethdev: attach or detach port")
>>> Signed-off-by: Reshma Pattan <reshma.pattan at intel.com>
>>> ---
>>> lib/librte_ether/rte_ethdev.c | 1 +
>>> 1 file changed, 1 insertion(+)
>>> 
>>> diff --git a/lib/librte_ether/rte_ethdev.c
>>> b/lib/librte_ether/rte_ethdev.c index 096b35faf..7ba9bc564 100644
>>> --- a/lib/librte_ether/rte_ethdev.c
>>> +++ b/lib/librte_ether/rte_ethdev.c
>>> @@ -443,6 +443,7 @@ rte_eth_dev_detach(uint16_t port_id, char *name)
>>> 		goto err;
>>> 
>>> 	rte_eth_devices[port_id].state = RTE_ETH_DEV_UNUSED;
>>> +	memset(&rte_eth_dev_data[port_id], 0, sizeof(struct
>>> +rte_eth_dev_data));
>> 
>> Hi,
>> 
>> I believe such code is good to have. Before I merge it, I have a question.
>> I wonder what the problem of the current code is.
>> If the state turns into RTE_ETH_DEV_UNUSED, then will the eth_dev be re-
>> initialized next time anyway?
>> 
>> 
> 
> Yes to reuse the UNUSED port next time , its relevant rte_eth_dev_data[] also has to be 0 (which is missing in current code), because attach operation not only checks for UNUSED but also for its relevant data to be  0.
> If state UNUSED, but data still not 0, the attach operation will assume port is under use, so it will assign the next new available port id  which is wrong. So we are now fixing this by zeroing dev data upon detach operation.

applied to stable/17.11

Thanks,
Yongseok



More information about the stable mailing list