DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [RFC] lib/ethdev: add dev configured flag
@ 2021-05-08  8:00 Huisong Li
  2021-05-31  8:51 ` Huisong Li
                   ` (5 more replies)
  0 siblings, 6 replies; 33+ messages in thread
From: Huisong Li @ 2021-05-08  8:00 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit

Currently, if dev_configure is not invoked or fails to be invoked, users
can still invoke dev_start successfully. This patch adds a "dev_configured"
flag in "rte_eth_dev_data" to control whether dev_start can be invoked.

Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
 lib/ethdev/rte_ethdev.c      | 11 +++++++++++
 lib/ethdev/rte_ethdev_core.h |  6 +++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index a187976..7d74b17 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -1604,6 +1604,8 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	}
 
 	rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q, dev_conf, 0);
+	dev->data->dev_configured = 1;
+
 	return 0;
 reset_queues:
 	eth_dev_rx_queue_config(dev, 0);
@@ -1614,6 +1616,8 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		dev->data->mtu = old_mtu;
 
 	rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q, dev_conf, ret);
+	dev->data->dev_configured = 0;
+
 	return ret;
 }
 
@@ -1749,6 +1753,13 @@ rte_eth_dev_start(uint16_t port_id)
 
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
 
+	if (dev->data->dev_configured == 0) {
+		RTE_ETHDEV_LOG(INFO,
+			"Device with port_id=%"PRIu16" is not configured.\n",
+			port_id);
+		return -EINVAL;
+	}
+
 	if (dev->data->dev_started != 0) {
 		RTE_ETHDEV_LOG(INFO,
 			"Device with port_id=%"PRIu16" already started\n",
diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h
index 4679d94..b508769 100644
--- a/lib/ethdev/rte_ethdev_core.h
+++ b/lib/ethdev/rte_ethdev_core.h
@@ -167,7 +167,11 @@ struct rte_eth_dev_data {
 		scattered_rx : 1,  /**< RX of scattered packets is ON(1) / OFF(0) */
 		all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
 		dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
-		lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
+		lro         : 1,  /**< RX LRO is ON(1) / OFF(0) */
+		dev_configured : 1;
+		/**< Device configuration state:
+		 * CONFIGURED(1) / NOT CONFIGURED(0).
+		 */
 	uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
 		/**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
 	uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
-- 
2.7.4


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC] lib/ethdev: add dev configured flag
  2021-05-08  8:00 [dpdk-dev] [RFC] lib/ethdev: add dev configured flag Huisong Li
@ 2021-05-31  8:51 ` Huisong Li
  2021-06-14 15:37 ` Andrew Rybchenko
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 33+ messages in thread
From: Huisong Li @ 2021-05-31  8:51 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit

Hi, All & Ferruh

What do you think about this patch?


在 2021/5/8 16:00, Huisong Li 写道:
> Currently, if dev_configure is not invoked or fails to be invoked, users
> can still invoke dev_start successfully. This patch adds a "dev_configured"
> flag in "rte_eth_dev_data" to control whether dev_start can be invoked.
>
> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> ---
>   lib/ethdev/rte_ethdev.c      | 11 +++++++++++
>   lib/ethdev/rte_ethdev_core.h |  6 +++++-
>   2 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
> index a187976..7d74b17 100644
> --- a/lib/ethdev/rte_ethdev.c
> +++ b/lib/ethdev/rte_ethdev.c
> @@ -1604,6 +1604,8 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
>   	}
>   
>   	rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q, dev_conf, 0);
> +	dev->data->dev_configured = 1;
> +
>   	return 0;
>   reset_queues:
>   	eth_dev_rx_queue_config(dev, 0);
> @@ -1614,6 +1616,8 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
>   		dev->data->mtu = old_mtu;
>   
>   	rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q, dev_conf, ret);
> +	dev->data->dev_configured = 0;
> +
>   	return ret;
>   }
>   
> @@ -1749,6 +1753,13 @@ rte_eth_dev_start(uint16_t port_id)
>   
>   	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
>   
> +	if (dev->data->dev_configured == 0) {
> +		RTE_ETHDEV_LOG(INFO,
> +			"Device with port_id=%"PRIu16" is not configured.\n",
> +			port_id);
> +		return -EINVAL;
> +	}
> +
>   	if (dev->data->dev_started != 0) {
>   		RTE_ETHDEV_LOG(INFO,
>   			"Device with port_id=%"PRIu16" already started\n",
> diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h
> index 4679d94..b508769 100644
> --- a/lib/ethdev/rte_ethdev_core.h
> +++ b/lib/ethdev/rte_ethdev_core.h
> @@ -167,7 +167,11 @@ struct rte_eth_dev_data {
>   		scattered_rx : 1,  /**< RX of scattered packets is ON(1) / OFF(0) */
>   		all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
>   		dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
> -		lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
> +		lro         : 1,  /**< RX LRO is ON(1) / OFF(0) */
> +		dev_configured : 1;
> +		/**< Device configuration state:
> +		 * CONFIGURED(1) / NOT CONFIGURED(0).
> +		 */
>   	uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
>   		/**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
>   	uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC] lib/ethdev: add dev configured flag
  2021-05-08  8:00 [dpdk-dev] [RFC] lib/ethdev: add dev configured flag Huisong Li
  2021-05-31  8:51 ` Huisong Li
@ 2021-06-14 15:37 ` Andrew Rybchenko
  2021-06-29  2:27   ` Huisong Li
  2021-07-04 20:05 ` Thomas Monjalon
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 33+ messages in thread
From: Andrew Rybchenko @ 2021-06-14 15:37 UTC (permalink / raw)
  To: Huisong Li, dev; +Cc: ferruh.yigit, Thomas Monjalon

Summary should start from "ethdev: "

Don't forget to include all maintainers in Cc the next time.
Just use --cc-cmd or --to-cmd options.

Adding Thomas.

On 5/8/21 11:00 AM, Huisong Li wrote:
> Currently, if dev_configure is not invoked or fails to be invoked, users
> can still invoke dev_start successfully. This patch adds a "dev_configured"
> flag in "rte_eth_dev_data" to control whether dev_start can be invoked.

In theory there is an indirect condition. If number of configured Tx
*and* Rx queues is 0, device is not configured.

I have no strong opinion on the topic. Extra flag requires
extra housekeeping. Indirect conditions are not always good
and could be a subject to change.

> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> ---
>   lib/ethdev/rte_ethdev.c      | 11 +++++++++++
>   lib/ethdev/rte_ethdev_core.h |  6 +++++-
>   2 files changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
> index a187976..7d74b17 100644
> --- a/lib/ethdev/rte_ethdev.c
> +++ b/lib/ethdev/rte_ethdev.c
> @@ -1604,6 +1604,8 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
>   	}
>   
>   	rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q, dev_conf, 0);
> +	dev->data->dev_configured = 1;
> +
>   	return 0;
>   reset_queues:
>   	eth_dev_rx_queue_config(dev, 0);
> @@ -1614,6 +1616,8 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
>   		dev->data->mtu = old_mtu;
>   
>   	rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q, dev_conf, ret);
> +	dev->data->dev_configured = 0;
> +
>   	return ret;
>   }
>   
> @@ -1749,6 +1753,13 @@ rte_eth_dev_start(uint16_t port_id)
>   
>   	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
>   
> +	if (dev->data->dev_configured == 0) {
> +		RTE_ETHDEV_LOG(INFO,
> +			"Device with port_id=%"PRIu16" is not configured.\n",
> +			port_id);
> +		return -EINVAL;
> +	}
> +
>   	if (dev->data->dev_started != 0) {
>   		RTE_ETHDEV_LOG(INFO,
>   			"Device with port_id=%"PRIu16" already started\n",
> diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h
> index 4679d94..b508769 100644
> --- a/lib/ethdev/rte_ethdev_core.h
> +++ b/lib/ethdev/rte_ethdev_core.h
> @@ -167,7 +167,11 @@ struct rte_eth_dev_data {
>   		scattered_rx : 1,  /**< RX of scattered packets is ON(1) / OFF(0) */
>   		all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
>   		dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
> -		lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
> +		lro         : 1,  /**< RX LRO is ON(1) / OFF(0) */
> +		dev_configured : 1;
> +		/**< Device configuration state:
> +		 * CONFIGURED(1) / NOT CONFIGURED(0).
> +		 */
>   	uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
>   		/**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
>   	uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
> 


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC] lib/ethdev: add dev configured flag
  2021-06-14 15:37 ` Andrew Rybchenko
@ 2021-06-29  2:27   ` Huisong Li
  2021-07-02 10:08     ` Andrew Rybchenko
  0 siblings, 1 reply; 33+ messages in thread
From: Huisong Li @ 2021-06-29  2:27 UTC (permalink / raw)
  To: Andrew Rybchenko, dev; +Cc: ferruh.yigit, Thomas Monjalon


在 2021/6/14 23:37, Andrew Rybchenko 写道:
> Summary should start from "ethdev: "
>
> Don't forget to include all maintainers in Cc the next time.
> Just use --cc-cmd or --to-cmd options.
ok, thanks!
>
> Adding Thomas.
>
> On 5/8/21 11:00 AM, Huisong Li wrote:
>> Currently, if dev_configure is not invoked or fails to be invoked, users
>> can still invoke dev_start successfully. This patch adds a 
>> "dev_configured"
>> flag in "rte_eth_dev_data" to control whether dev_start can be invoked.
>
> In theory there is an indirect condition. If number of configured Tx
> *and* Rx queues is 0, device is not configured.

That's true. If the framework doesn't have this check, each driver needs 
to do this.

But it's a common thing, and it's probably more reasonable to put it in 
the ethdev layer.

>
> I have no strong opinion on the topic. Extra flag requires
> extra housekeeping. Indirect conditions are not always good
> and could be a subject to change.
>
>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>> ---
>>   lib/ethdev/rte_ethdev.c      | 11 +++++++++++
>>   lib/ethdev/rte_ethdev_core.h |  6 +++++-
>>   2 files changed, 16 insertions(+), 1 deletion(-)
>>
>> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
>> index a187976..7d74b17 100644
>> --- a/lib/ethdev/rte_ethdev.c
>> +++ b/lib/ethdev/rte_ethdev.c
>> @@ -1604,6 +1604,8 @@ rte_eth_dev_configure(uint16_t port_id, 
>> uint16_t nb_rx_q, uint16_t nb_tx_q,
>>       }
>>         rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q, 
>> dev_conf, 0);
>> +    dev->data->dev_configured = 1;
>> +
>>       return 0;
>>   reset_queues:
>>       eth_dev_rx_queue_config(dev, 0);
>> @@ -1614,6 +1616,8 @@ rte_eth_dev_configure(uint16_t port_id, 
>> uint16_t nb_rx_q, uint16_t nb_tx_q,
>>           dev->data->mtu = old_mtu;
>>         rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q, 
>> dev_conf, ret);
>> +    dev->data->dev_configured = 0;
>> +
>>       return ret;
>>   }
>>   @@ -1749,6 +1753,13 @@ rte_eth_dev_start(uint16_t port_id)
>>         RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
>>   +    if (dev->data->dev_configured == 0) {
>> +        RTE_ETHDEV_LOG(INFO,
>> +            "Device with port_id=%"PRIu16" is not configured.\n",
>> +            port_id);
>> +        return -EINVAL;
>> +    }
>> +
>>       if (dev->data->dev_started != 0) {
>>           RTE_ETHDEV_LOG(INFO,
>>               "Device with port_id=%"PRIu16" already started\n",
>> diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h
>> index 4679d94..b508769 100644
>> --- a/lib/ethdev/rte_ethdev_core.h
>> +++ b/lib/ethdev/rte_ethdev_core.h
>> @@ -167,7 +167,11 @@ struct rte_eth_dev_data {
>>           scattered_rx : 1,  /**< RX of scattered packets is ON(1) / 
>> OFF(0) */
>>           all_multicast : 1, /**< RX all multicast mode ON(1) / 
>> OFF(0). */
>>           dev_started : 1,   /**< Device state: STARTED(1) / 
>> STOPPED(0). */
>> -        lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
>> +        lro         : 1,  /**< RX LRO is ON(1) / OFF(0) */
>> +        dev_configured : 1;
>> +        /**< Device configuration state:
>> +         * CONFIGURED(1) / NOT CONFIGURED(0).
>> +         */
>>       uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
>>           /**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
>>       uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
>>
>
> .

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC] lib/ethdev: add dev configured flag
  2021-06-29  2:27   ` Huisong Li
@ 2021-07-02 10:08     ` Andrew Rybchenko
  2021-07-02 11:57       ` Ferruh Yigit
  0 siblings, 1 reply; 33+ messages in thread
From: Andrew Rybchenko @ 2021-07-02 10:08 UTC (permalink / raw)
  To: Huisong Li, dev; +Cc: ferruh.yigit, Thomas Monjalon

@Thomas, @Ferruh, I tend to accept it (with minor style fixes),
but I need your opinion on it before doing it.

Thanks,
Andrew.

On 6/29/21 5:27 AM, Huisong Li wrote:
> 
> 在 2021/6/14 23:37, Andrew Rybchenko 写道:
>> Summary should start from "ethdev: "
>>
>> Don't forget to include all maintainers in Cc the next time.
>> Just use --cc-cmd or --to-cmd options.
> ok, thanks!
>>
>> Adding Thomas.
>>
>> On 5/8/21 11:00 AM, Huisong Li wrote:
>>> Currently, if dev_configure is not invoked or fails to be invoked, users
>>> can still invoke dev_start successfully. This patch adds a
>>> "dev_configured"
>>> flag in "rte_eth_dev_data" to control whether dev_start can be invoked.
>>
>> In theory there is an indirect condition. If number of configured Tx
>> *and* Rx queues is 0, device is not configured.
> 
> That's true. If the framework doesn't have this check, each driver needs
> to do this.
> 
> But it's a common thing, and it's probably more reasonable to put it in
> the ethdev layer.
> 
>>
>> I have no strong opinion on the topic. Extra flag requires
>> extra housekeeping. Indirect conditions are not always good
>> and could be a subject to change.
>>
>>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>>> ---
>>>   lib/ethdev/rte_ethdev.c      | 11 +++++++++++
>>>   lib/ethdev/rte_ethdev_core.h |  6 +++++-
>>>   2 files changed, 16 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
>>> index a187976..7d74b17 100644
>>> --- a/lib/ethdev/rte_ethdev.c
>>> +++ b/lib/ethdev/rte_ethdev.c
>>> @@ -1604,6 +1604,8 @@ rte_eth_dev_configure(uint16_t port_id,
>>> uint16_t nb_rx_q, uint16_t nb_tx_q,
>>>       }
>>>         rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q,
>>> dev_conf, 0);
>>> +    dev->data->dev_configured = 1;
>>> +
>>>       return 0;
>>>   reset_queues:
>>>       eth_dev_rx_queue_config(dev, 0);
>>> @@ -1614,6 +1616,8 @@ rte_eth_dev_configure(uint16_t port_id,
>>> uint16_t nb_rx_q, uint16_t nb_tx_q,
>>>           dev->data->mtu = old_mtu;
>>>         rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q,
>>> dev_conf, ret);
>>> +    dev->data->dev_configured = 0;
>>> +
>>>       return ret;
>>>   }
>>>   @@ -1749,6 +1753,13 @@ rte_eth_dev_start(uint16_t port_id)
>>>         RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
>>>   +    if (dev->data->dev_configured == 0) {
>>> +        RTE_ETHDEV_LOG(INFO,
>>> +            "Device with port_id=%"PRIu16" is not configured.\n",
>>> +            port_id);
>>> +        return -EINVAL;
>>> +    }
>>> +
>>>       if (dev->data->dev_started != 0) {
>>>           RTE_ETHDEV_LOG(INFO,
>>>               "Device with port_id=%"PRIu16" already started\n",
>>> diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h
>>> index 4679d94..b508769 100644
>>> --- a/lib/ethdev/rte_ethdev_core.h
>>> +++ b/lib/ethdev/rte_ethdev_core.h
>>> @@ -167,7 +167,11 @@ struct rte_eth_dev_data {
>>>           scattered_rx : 1,  /**< RX of scattered packets is ON(1) /
>>> OFF(0) */
>>>           all_multicast : 1, /**< RX all multicast mode ON(1) /
>>> OFF(0). */
>>>           dev_started : 1,   /**< Device state: STARTED(1) /
>>> STOPPED(0). */
>>> -        lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
>>> +        lro         : 1,  /**< RX LRO is ON(1) / OFF(0) */
>>> +        dev_configured : 1;
>>> +        /**< Device configuration state:
>>> +         * CONFIGURED(1) / NOT CONFIGURED(0).
>>> +         */
>>>       uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
>>>           /**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
>>>       uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
>>>
>>
>> .


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC] lib/ethdev: add dev configured flag
  2021-07-02 10:08     ` Andrew Rybchenko
@ 2021-07-02 11:57       ` Ferruh Yigit
  2021-07-02 13:23         ` Ananyev, Konstantin
  0 siblings, 1 reply; 33+ messages in thread
From: Ferruh Yigit @ 2021-07-02 11:57 UTC (permalink / raw)
  To: Andrew Rybchenko, Huisong Li, dev; +Cc: Thomas Monjalon

On 7/2/2021 12:08 PM, Andrew Rybchenko wrote:
> @Thomas, @Ferruh, I tend to accept it (with minor style fixes),
> but I need your opinion on it before doing it.
> 

I guess we were relying on the user/application to have correct order up until
now, it can be good to add this into the API. OK to add it for me.

> Thanks,
> Andrew.
> 
> On 6/29/21 5:27 AM, Huisong Li wrote:
>>
>> 在 2021/6/14 23:37, Andrew Rybchenko 写道:
>>> Summary should start from "ethdev: "
>>>
>>> Don't forget to include all maintainers in Cc the next time.
>>> Just use --cc-cmd or --to-cmd options.
>> ok, thanks!
>>>
>>> Adding Thomas.
>>>
>>> On 5/8/21 11:00 AM, Huisong Li wrote:
>>>> Currently, if dev_configure is not invoked or fails to be invoked, users
>>>> can still invoke dev_start successfully. This patch adds a
>>>> "dev_configured"
>>>> flag in "rte_eth_dev_data" to control whether dev_start can be invoked.
>>>
>>> In theory there is an indirect condition. If number of configured Tx
>>> *and* Rx queues is 0, device is not configured.
>>
>> That's true. If the framework doesn't have this check, each driver needs
>> to do this.
>>
>> But it's a common thing, and it's probably more reasonable to put it in
>> the ethdev layer.
>>
>>>
>>> I have no strong opinion on the topic. Extra flag requires
>>> extra housekeeping. Indirect conditions are not always good
>>> and could be a subject to change.
>>>
>>>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>>>> ---
>>>>   lib/ethdev/rte_ethdev.c      | 11 +++++++++++
>>>>   lib/ethdev/rte_ethdev_core.h |  6 +++++-
>>>>   2 files changed, 16 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
>>>> index a187976..7d74b17 100644
>>>> --- a/lib/ethdev/rte_ethdev.c
>>>> +++ b/lib/ethdev/rte_ethdev.c
>>>> @@ -1604,6 +1604,8 @@ rte_eth_dev_configure(uint16_t port_id,
>>>> uint16_t nb_rx_q, uint16_t nb_tx_q,
>>>>       }
>>>>         rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q,
>>>> dev_conf, 0);
>>>> +    dev->data->dev_configured = 1;
>>>> +
>>>>       return 0;
>>>>   reset_queues:
>>>>       eth_dev_rx_queue_config(dev, 0);
>>>> @@ -1614,6 +1616,8 @@ rte_eth_dev_configure(uint16_t port_id,
>>>> uint16_t nb_rx_q, uint16_t nb_tx_q,
>>>>           dev->data->mtu = old_mtu;
>>>>         rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q,
>>>> dev_conf, ret);
>>>> +    dev->data->dev_configured = 0;
>>>> +

I would move it before trace function.

>>>>       return ret;
>>>>   }
>>>>   @@ -1749,6 +1753,13 @@ rte_eth_dev_start(uint16_t port_id)
>>>>         RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
>>>>   +    if (dev->data->dev_configured == 0) {
>>>> +        RTE_ETHDEV_LOG(INFO,
>>>> +            "Device with port_id=%"PRIu16" is not configured.\n",
>>>> +            port_id);

Should log type be warning/error?

>>>> +        return -EINVAL;
>>>> +    }
>>>> +
>>>>       if (dev->data->dev_started != 0) {
>>>>           RTE_ETHDEV_LOG(INFO,
>>>>               "Device with port_id=%"PRIu16" already started\n",
>>>> diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h
>>>> index 4679d94..b508769 100644
>>>> --- a/lib/ethdev/rte_ethdev_core.h
>>>> +++ b/lib/ethdev/rte_ethdev_core.h
>>>> @@ -167,7 +167,11 @@ struct rte_eth_dev_data {
>>>>           scattered_rx : 1,  /**< RX of scattered packets is ON(1) /
>>>> OFF(0) */
>>>>           all_multicast : 1, /**< RX all multicast mode ON(1) /
>>>> OFF(0). */
>>>>           dev_started : 1,   /**< Device state: STARTED(1) /
>>>> STOPPED(0). */
>>>> -        lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
>>>> +        lro         : 1,  /**< RX LRO is ON(1) / OFF(0) */
>>>> +        dev_configured : 1;
>>>> +        /**< Device configuration state:
>>>> +         * CONFIGURED(1) / NOT CONFIGURED(0).
>>>> +         */
>>>>       uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
>>>>           /**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
>>>>       uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
>>>>
>>>
>>> .
> 


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC] lib/ethdev: add dev configured flag
  2021-07-02 11:57       ` Ferruh Yigit
@ 2021-07-02 13:23         ` Ananyev, Konstantin
  2021-07-03  8:35           ` Huisong Li
  0 siblings, 1 reply; 33+ messages in thread
From: Ananyev, Konstantin @ 2021-07-02 13:23 UTC (permalink / raw)
  To: Yigit, Ferruh, Andrew Rybchenko, Huisong Li, dev; +Cc: Thomas Monjalon



> 
> On 7/2/2021 12:08 PM, Andrew Rybchenko wrote:
> > @Thomas, @Ferruh, I tend to accept it (with minor style fixes),
> > but I need your opinion on it before doing it.
> >
> 
> I guess we were relying on the user/application to have correct order up until
> now, it can be good to add this into the API. OK to add it for me.

I don't know do we really need that flag in dev_data or not,
but if we do - probably better to reset it at dev_confgure() straight before
we start to make any changes in dev_data.
That way SP can also figure out that device is not configured yet, etc.

> 
> > Thanks,
> > Andrew.
> >
> > On 6/29/21 5:27 AM, Huisong Li wrote:
> >>
> >> 在 2021/6/14 23:37, Andrew Rybchenko 写道:
> >>> Summary should start from "ethdev: "
> >>>
> >>> Don't forget to include all maintainers in Cc the next time.
> >>> Just use --cc-cmd or --to-cmd options.
> >> ok, thanks!
> >>>
> >>> Adding Thomas.
> >>>
> >>> On 5/8/21 11:00 AM, Huisong Li wrote:
> >>>> Currently, if dev_configure is not invoked or fails to be invoked, users
> >>>> can still invoke dev_start successfully. This patch adds a
> >>>> "dev_configured"
> >>>> flag in "rte_eth_dev_data" to control whether dev_start can be invoked.
> >>>
> >>> In theory there is an indirect condition. If number of configured Tx
> >>> *and* Rx queues is 0, device is not configured.
> >>
> >> That's true. If the framework doesn't have this check, each driver needs
> >> to do this.
> >>
> >> But it's a common thing, and it's probably more reasonable to put it in
> >> the ethdev layer.
> >>
> >>>
> >>> I have no strong opinion on the topic. Extra flag requires
> >>> extra housekeeping. Indirect conditions are not always good
> >>> and could be a subject to change.
> >>>
> >>>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> >>>> ---
> >>>>   lib/ethdev/rte_ethdev.c      | 11 +++++++++++
> >>>>   lib/ethdev/rte_ethdev_core.h |  6 +++++-
> >>>>   2 files changed, 16 insertions(+), 1 deletion(-)
> >>>>
> >>>> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
> >>>> index a187976..7d74b17 100644
> >>>> --- a/lib/ethdev/rte_ethdev.c
> >>>> +++ b/lib/ethdev/rte_ethdev.c
> >>>> @@ -1604,6 +1604,8 @@ rte_eth_dev_configure(uint16_t port_id,
> >>>> uint16_t nb_rx_q, uint16_t nb_tx_q,
> >>>>       }
> >>>>         rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q,
> >>>> dev_conf, 0);
> >>>> +    dev->data->dev_configured = 1;
> >>>> +
> >>>>       return 0;
> >>>>   reset_queues:
> >>>>       eth_dev_rx_queue_config(dev, 0);
> >>>> @@ -1614,6 +1616,8 @@ rte_eth_dev_configure(uint16_t port_id,
> >>>> uint16_t nb_rx_q, uint16_t nb_tx_q,
> >>>>           dev->data->mtu = old_mtu;
> >>>>         rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q,
> >>>> dev_conf, ret);
> >>>> +    dev->data->dev_configured = 0;
> >>>> +
> 
> I would move it before trace function.
> 
> >>>>       return ret;
> >>>>   }
> >>>>   @@ -1749,6 +1753,13 @@ rte_eth_dev_start(uint16_t port_id)
> >>>>         RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
> >>>>   +    if (dev->data->dev_configured == 0) {
> >>>> +        RTE_ETHDEV_LOG(INFO,
> >>>> +            "Device with port_id=%"PRIu16" is not configured.\n",
> >>>> +            port_id);
> 
> Should log type be warning/error?
> 
> >>>> +        return -EINVAL;
> >>>> +    }
> >>>> +
> >>>>       if (dev->data->dev_started != 0) {
> >>>>           RTE_ETHDEV_LOG(INFO,
> >>>>               "Device with port_id=%"PRIu16" already started\n",
> >>>> diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h
> >>>> index 4679d94..b508769 100644
> >>>> --- a/lib/ethdev/rte_ethdev_core.h
> >>>> +++ b/lib/ethdev/rte_ethdev_core.h
> >>>> @@ -167,7 +167,11 @@ struct rte_eth_dev_data {
> >>>>           scattered_rx : 1,  /**< RX of scattered packets is ON(1) /
> >>>> OFF(0) */
> >>>>           all_multicast : 1, /**< RX all multicast mode ON(1) /
> >>>> OFF(0). */
> >>>>           dev_started : 1,   /**< Device state: STARTED(1) /
> >>>> STOPPED(0). */
> >>>> -        lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
> >>>> +        lro         : 1,  /**< RX LRO is ON(1) / OFF(0) */
> >>>> +        dev_configured : 1;
> >>>> +        /**< Device configuration state:
> >>>> +         * CONFIGURED(1) / NOT CONFIGURED(0).
> >>>> +         */
> >>>>       uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
> >>>>           /**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
> >>>>       uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
> >>>>
> >>>
> >>> .
> >


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC] lib/ethdev: add dev configured flag
  2021-07-02 13:23         ` Ananyev, Konstantin
@ 2021-07-03  8:35           ` Huisong Li
  2021-07-03 11:04             ` Ananyev, Konstantin
  0 siblings, 1 reply; 33+ messages in thread
From: Huisong Li @ 2021-07-03  8:35 UTC (permalink / raw)
  To: Ananyev, Konstantin, Yigit, Ferruh, Andrew Rybchenko, dev; +Cc: Thomas Monjalon


在 2021/7/2 21:23, Ananyev, Konstantin 写道:
>
>> On 7/2/2021 12:08 PM, Andrew Rybchenko wrote:
>>> @Thomas, @Ferruh, I tend to accept it (with minor style fixes),
>>> but I need your opinion on it before doing it.
>>>
>> I guess we were relying on the user/application to have correct order up until
>> now, it can be good to add this into the API. OK to add it for me.
> I don't know do we really need that flag in dev_data or not,
> but if we do - probably better to reset it at dev_confgure() straight before
> we start to make any changes in dev_data.

Sorry, I don't get you. Some fields in rte_eth_dev_data are initialized 
firstly in the probe phase.

Do you mean to add clear this flag at the beginning of dev_configure()?

> That way SP can also figure out that device is not configured yet, etc.
>
>>> Thanks,
>>> Andrew.
>>>
>>> On 6/29/21 5:27 AM, Huisong Li wrote:
>>>> 在 2021/6/14 23:37, Andrew Rybchenko 写道:
>>>>> Summary should start from "ethdev: "
>>>>>
>>>>> Don't forget to include all maintainers in Cc the next time.
>>>>> Just use --cc-cmd or --to-cmd options.
>>>> ok, thanks!
>>>>> Adding Thomas.
>>>>>
>>>>> On 5/8/21 11:00 AM, Huisong Li wrote:
>>>>>> Currently, if dev_configure is not invoked or fails to be invoked, users
>>>>>> can still invoke dev_start successfully. This patch adds a
>>>>>> "dev_configured"
>>>>>> flag in "rte_eth_dev_data" to control whether dev_start can be invoked.
>>>>> In theory there is an indirect condition. If number of configured Tx
>>>>> *and* Rx queues is 0, device is not configured.
>>>> That's true. If the framework doesn't have this check, each driver needs
>>>> to do this.
>>>>
>>>> But it's a common thing, and it's probably more reasonable to put it in
>>>> the ethdev layer.
>>>>
>>>>> I have no strong opinion on the topic. Extra flag requires
>>>>> extra housekeeping. Indirect conditions are not always good
>>>>> and could be a subject to change.
>>>>>
>>>>>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>>>>>> ---
>>>>>>    lib/ethdev/rte_ethdev.c      | 11 +++++++++++
>>>>>>    lib/ethdev/rte_ethdev_core.h |  6 +++++-
>>>>>>    2 files changed, 16 insertions(+), 1 deletion(-)
>>>>>>
>>>>>> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
>>>>>> index a187976..7d74b17 100644
>>>>>> --- a/lib/ethdev/rte_ethdev.c
>>>>>> +++ b/lib/ethdev/rte_ethdev.c
>>>>>> @@ -1604,6 +1604,8 @@ rte_eth_dev_configure(uint16_t port_id,
>>>>>> uint16_t nb_rx_q, uint16_t nb_tx_q,
>>>>>>        }
>>>>>>          rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q,
>>>>>> dev_conf, 0);
>>>>>> +    dev->data->dev_configured = 1;
>>>>>> +
>>>>>>        return 0;
>>>>>>    reset_queues:
>>>>>>        eth_dev_rx_queue_config(dev, 0);
>>>>>> @@ -1614,6 +1616,8 @@ rte_eth_dev_configure(uint16_t port_id,
>>>>>> uint16_t nb_rx_q, uint16_t nb_tx_q,
>>>>>>            dev->data->mtu = old_mtu;
>>>>>>          rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q,
>>>>>> dev_conf, ret);
>>>>>> +    dev->data->dev_configured = 0;
>>>>>> +
>> I would move it before trace function.
>>
>>>>>>        return ret;
>>>>>>    }
>>>>>>    @@ -1749,6 +1753,13 @@ rte_eth_dev_start(uint16_t port_id)
>>>>>>          RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
>>>>>>    +    if (dev->data->dev_configured == 0) {
>>>>>> +        RTE_ETHDEV_LOG(INFO,
>>>>>> +            "Device with port_id=%"PRIu16" is not configured.\n",
>>>>>> +            port_id);
>> Should log type be warning/error?
>>
>>>>>> +        return -EINVAL;
>>>>>> +    }
>>>>>> +
>>>>>>        if (dev->data->dev_started != 0) {
>>>>>>            RTE_ETHDEV_LOG(INFO,
>>>>>>                "Device with port_id=%"PRIu16" already started\n",
>>>>>> diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h
>>>>>> index 4679d94..b508769 100644
>>>>>> --- a/lib/ethdev/rte_ethdev_core.h
>>>>>> +++ b/lib/ethdev/rte_ethdev_core.h
>>>>>> @@ -167,7 +167,11 @@ struct rte_eth_dev_data {
>>>>>>            scattered_rx : 1,  /**< RX of scattered packets is ON(1) /
>>>>>> OFF(0) */
>>>>>>            all_multicast : 1, /**< RX all multicast mode ON(1) /
>>>>>> OFF(0). */
>>>>>>            dev_started : 1,   /**< Device state: STARTED(1) /
>>>>>> STOPPED(0). */
>>>>>> -        lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
>>>>>> +        lro         : 1,  /**< RX LRO is ON(1) / OFF(0) */
>>>>>> +        dev_configured : 1;
>>>>>> +        /**< Device configuration state:
>>>>>> +         * CONFIGURED(1) / NOT CONFIGURED(0).
>>>>>> +         */
>>>>>>        uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
>>>>>>            /**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
>>>>>>        uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
>>>>>>
>>>>> .

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC] lib/ethdev: add dev configured flag
  2021-07-03  8:35           ` Huisong Li
@ 2021-07-03 11:04             ` Ananyev, Konstantin
  2021-07-05  3:03               ` Huisong Li
  0 siblings, 1 reply; 33+ messages in thread
From: Ananyev, Konstantin @ 2021-07-03 11:04 UTC (permalink / raw)
  To: Huisong Li, Yigit, Ferruh, Andrew Rybchenko, dev; +Cc: Thomas Monjalon

> 
> 在 2021/7/2 21:23, Ananyev, Konstantin 写道:
> >
> >> On 7/2/2021 12:08 PM, Andrew Rybchenko wrote:
> >>> @Thomas, @Ferruh, I tend to accept it (with minor style fixes),
> >>> but I need your opinion on it before doing it.
> >>>
> >> I guess we were relying on the user/application to have correct order up until
> >> now, it can be good to add this into the API. OK to add it for me.
> > I don't know do we really need that flag in dev_data or not,
> > but if we do - probably better to reset it at dev_confgure() straight before
> > we start to make any changes in dev_data.
> 
> Sorry, I don't get you. Some fields in rte_eth_dev_data are initialized
> firstly in the probe phase.
> 
> Do you mean to add clear this flag at the beginning of dev_configure()?

Yes, just before we start to modify things.

> 
> > That way SP can also figure out that device is not configured yet, etc.
> >
> >>> Thanks,
> >>> Andrew.
> >>>
> >>> On 6/29/21 5:27 AM, Huisong Li wrote:
> >>>> 在 2021/6/14 23:37, Andrew Rybchenko 写道:
> >>>>> Summary should start from "ethdev: "
> >>>>>
> >>>>> Don't forget to include all maintainers in Cc the next time.
> >>>>> Just use --cc-cmd or --to-cmd options.
> >>>> ok, thanks!
> >>>>> Adding Thomas.
> >>>>>
> >>>>> On 5/8/21 11:00 AM, Huisong Li wrote:
> >>>>>> Currently, if dev_configure is not invoked or fails to be invoked, users
> >>>>>> can still invoke dev_start successfully. This patch adds a
> >>>>>> "dev_configured"
> >>>>>> flag in "rte_eth_dev_data" to control whether dev_start can be invoked.
> >>>>> In theory there is an indirect condition. If number of configured Tx
> >>>>> *and* Rx queues is 0, device is not configured.
> >>>> That's true. If the framework doesn't have this check, each driver needs
> >>>> to do this.
> >>>>
> >>>> But it's a common thing, and it's probably more reasonable to put it in
> >>>> the ethdev layer.
> >>>>
> >>>>> I have no strong opinion on the topic. Extra flag requires
> >>>>> extra housekeeping. Indirect conditions are not always good
> >>>>> and could be a subject to change.
> >>>>>
> >>>>>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> >>>>>> ---
> >>>>>>    lib/ethdev/rte_ethdev.c      | 11 +++++++++++
> >>>>>>    lib/ethdev/rte_ethdev_core.h |  6 +++++-
> >>>>>>    2 files changed, 16 insertions(+), 1 deletion(-)
> >>>>>>
> >>>>>> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
> >>>>>> index a187976..7d74b17 100644
> >>>>>> --- a/lib/ethdev/rte_ethdev.c
> >>>>>> +++ b/lib/ethdev/rte_ethdev.c
> >>>>>> @@ -1604,6 +1604,8 @@ rte_eth_dev_configure(uint16_t port_id,
> >>>>>> uint16_t nb_rx_q, uint16_t nb_tx_q,
> >>>>>>        }
> >>>>>>          rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q,
> >>>>>> dev_conf, 0);
> >>>>>> +    dev->data->dev_configured = 1;
> >>>>>> +
> >>>>>>        return 0;
> >>>>>>    reset_queues:
> >>>>>>        eth_dev_rx_queue_config(dev, 0);
> >>>>>> @@ -1614,6 +1616,8 @@ rte_eth_dev_configure(uint16_t port_id,
> >>>>>> uint16_t nb_rx_q, uint16_t nb_tx_q,
> >>>>>>            dev->data->mtu = old_mtu;
> >>>>>>          rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q,
> >>>>>> dev_conf, ret);
> >>>>>> +    dev->data->dev_configured = 0;
> >>>>>> +
> >> I would move it before trace function.
> >>
> >>>>>>        return ret;
> >>>>>>    }
> >>>>>>    @@ -1749,6 +1753,13 @@ rte_eth_dev_start(uint16_t port_id)
> >>>>>>          RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
> >>>>>>    +    if (dev->data->dev_configured == 0) {
> >>>>>> +        RTE_ETHDEV_LOG(INFO,
> >>>>>> +            "Device with port_id=%"PRIu16" is not configured.\n",
> >>>>>> +            port_id);
> >> Should log type be warning/error?
> >>
> >>>>>> +        return -EINVAL;
> >>>>>> +    }
> >>>>>> +
> >>>>>>        if (dev->data->dev_started != 0) {
> >>>>>>            RTE_ETHDEV_LOG(INFO,
> >>>>>>                "Device with port_id=%"PRIu16" already started\n",
> >>>>>> diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h
> >>>>>> index 4679d94..b508769 100644
> >>>>>> --- a/lib/ethdev/rte_ethdev_core.h
> >>>>>> +++ b/lib/ethdev/rte_ethdev_core.h
> >>>>>> @@ -167,7 +167,11 @@ struct rte_eth_dev_data {
> >>>>>>            scattered_rx : 1,  /**< RX of scattered packets is ON(1) /
> >>>>>> OFF(0) */
> >>>>>>            all_multicast : 1, /**< RX all multicast mode ON(1) /
> >>>>>> OFF(0). */
> >>>>>>            dev_started : 1,   /**< Device state: STARTED(1) /
> >>>>>> STOPPED(0). */
> >>>>>> -        lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
> >>>>>> +        lro         : 1,  /**< RX LRO is ON(1) / OFF(0) */
> >>>>>> +        dev_configured : 1;
> >>>>>> +        /**< Device configuration state:
> >>>>>> +         * CONFIGURED(1) / NOT CONFIGURED(0).
> >>>>>> +         */
> >>>>>>        uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
> >>>>>>            /**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
> >>>>>>        uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
> >>>>>>
> >>>>> .

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC] lib/ethdev: add dev configured flag
  2021-05-08  8:00 [dpdk-dev] [RFC] lib/ethdev: add dev configured flag Huisong Li
  2021-05-31  8:51 ` Huisong Li
  2021-06-14 15:37 ` Andrew Rybchenko
@ 2021-07-04 20:05 ` Thomas Monjalon
  2021-07-05  3:18   ` Huisong Li
  2021-07-06  3:24 ` [dpdk-dev] [PATCH V1] ethdev: " Huisong Li
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 33+ messages in thread
From: Thomas Monjalon @ 2021-07-04 20:05 UTC (permalink / raw)
  To: Huisong Li; +Cc: dev, ferruh.yigit, andrew.rybchenko, konstantin.ananyev

08/05/2021 10:00, Huisong Li:
> Currently, if dev_configure is not invoked or fails to be invoked, users
> can still invoke dev_start successfully. This patch adds a "dev_configured"
> flag in "rte_eth_dev_data" to control whether dev_start can be invoked.
[...]
> --- a/lib/ethdev/rte_ethdev_core.h
> +++ b/lib/ethdev/rte_ethdev_core.h
> @@ -167,7 +167,11 @@ struct rte_eth_dev_data {
>  		scattered_rx : 1,  /**< RX of scattered packets is ON(1) / OFF(0) */
>  		all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
>  		dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
> -		lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
> +		lro         : 1,  /**< RX LRO is ON(1) / OFF(0) */
> +		dev_configured : 1;
> +		/**< Device configuration state:
> +		 * CONFIGURED(1) / NOT CONFIGURED(0).
> +		 */

Why not using "enum rte_eth_dev_state"?
Because rte_eth_dev.state is not shared between processes?




^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC] lib/ethdev: add dev configured flag
  2021-07-03 11:04             ` Ananyev, Konstantin
@ 2021-07-05  3:03               ` Huisong Li
  2021-07-05  9:50                 ` Andrew Rybchenko
  0 siblings, 1 reply; 33+ messages in thread
From: Huisong Li @ 2021-07-05  3:03 UTC (permalink / raw)
  To: Ananyev, Konstantin, Yigit, Ferruh, Andrew Rybchenko, dev; +Cc: Thomas Monjalon


在 2021/7/3 19:04, Ananyev, Konstantin 写道:
>> 在 2021/7/2 21:23, Ananyev, Konstantin 写道:
>>>> On 7/2/2021 12:08 PM, Andrew Rybchenko wrote:
>>>>> @Thomas, @Ferruh, I tend to accept it (with minor style fixes),
>>>>> but I need your opinion on it before doing it.
>>>>>
>>>> I guess we were relying on the user/application to have correct order up until
>>>> now, it can be good to add this into the API. OK to add it for me.
>>> I don't know do we really need that flag in dev_data or not,
>>> but if we do - probably better to reset it at dev_confgure() straight before
>>> we start to make any changes in dev_data.
>> Sorry, I don't get you. Some fields in rte_eth_dev_data are initialized
>> firstly in the probe phase.
>>
>> Do you mean to add clear this flag at the beginning of dev_configure()?
> Yes, just before we start to modify things.

In this patch, this flag has been cleared for all scenarios where the 
rte_eth_dev_data modification fails in the dev_configure().

And it is set to 1 when dev_configure() is configured successfully.

Please check the rollback. Thanks😁


>
>>> That way SP can also figure out that device is not configured yet, etc.
>>>
>>>>> Thanks,
>>>>> Andrew.
>>>>>
>>>>> On 6/29/21 5:27 AM, Huisong Li wrote:
>>>>>> 在 2021/6/14 23:37, Andrew Rybchenko 写道:
>>>>>>> Summary should start from "ethdev: "
>>>>>>>
>>>>>>> Don't forget to include all maintainers in Cc the next time.
>>>>>>> Just use --cc-cmd or --to-cmd options.
>>>>>> ok, thanks!
>>>>>>> Adding Thomas.
>>>>>>>
>>>>>>> On 5/8/21 11:00 AM, Huisong Li wrote:
>>>>>>>> Currently, if dev_configure is not invoked or fails to be invoked, users
>>>>>>>> can still invoke dev_start successfully. This patch adds a
>>>>>>>> "dev_configured"
>>>>>>>> flag in "rte_eth_dev_data" to control whether dev_start can be invoked.
>>>>>>> In theory there is an indirect condition. If number of configured Tx
>>>>>>> *and* Rx queues is 0, device is not configured.
>>>>>> That's true. If the framework doesn't have this check, each driver needs
>>>>>> to do this.
>>>>>>
>>>>>> But it's a common thing, and it's probably more reasonable to put it in
>>>>>> the ethdev layer.
>>>>>>
>>>>>>> I have no strong opinion on the topic. Extra flag requires
>>>>>>> extra housekeeping. Indirect conditions are not always good
>>>>>>> and could be a subject to change.
>>>>>>>
>>>>>>>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>>>>>>>> ---
>>>>>>>>     lib/ethdev/rte_ethdev.c      | 11 +++++++++++
>>>>>>>>     lib/ethdev/rte_ethdev_core.h |  6 +++++-
>>>>>>>>     2 files changed, 16 insertions(+), 1 deletion(-)
>>>>>>>>
>>>>>>>> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
>>>>>>>> index a187976..7d74b17 100644
>>>>>>>> --- a/lib/ethdev/rte_ethdev.c
>>>>>>>> +++ b/lib/ethdev/rte_ethdev.c
>>>>>>>> @@ -1604,6 +1604,8 @@ rte_eth_dev_configure(uint16_t port_id,
>>>>>>>> uint16_t nb_rx_q, uint16_t nb_tx_q,
>>>>>>>>         }
>>>>>>>>           rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q,
>>>>>>>> dev_conf, 0);
>>>>>>>> +    dev->data->dev_configured = 1;
>>>>>>>> +
>>>>>>>>         return 0;
>>>>>>>>     reset_queues:
>>>>>>>>         eth_dev_rx_queue_config(dev, 0);
>>>>>>>> @@ -1614,6 +1616,8 @@ rte_eth_dev_configure(uint16_t port_id,
>>>>>>>> uint16_t nb_rx_q, uint16_t nb_tx_q,
>>>>>>>>             dev->data->mtu = old_mtu;
>>>>>>>>           rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q,
>>>>>>>> dev_conf, ret);
>>>>>>>> +    dev->data->dev_configured = 0;
>>>>>>>> +
>>>> I would move it before trace function.
>>>>
>>>>>>>>         return ret;
>>>>>>>>     }
>>>>>>>>     @@ -1749,6 +1753,13 @@ rte_eth_dev_start(uint16_t port_id)
>>>>>>>>           RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
>>>>>>>>     +    if (dev->data->dev_configured == 0) {
>>>>>>>> +        RTE_ETHDEV_LOG(INFO,
>>>>>>>> +            "Device with port_id=%"PRIu16" is not configured.\n",
>>>>>>>> +            port_id);
>>>> Should log type be warning/error?
>>>>
>>>>>>>> +        return -EINVAL;
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>>         if (dev->data->dev_started != 0) {
>>>>>>>>             RTE_ETHDEV_LOG(INFO,
>>>>>>>>                 "Device with port_id=%"PRIu16" already started\n",
>>>>>>>> diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h
>>>>>>>> index 4679d94..b508769 100644
>>>>>>>> --- a/lib/ethdev/rte_ethdev_core.h
>>>>>>>> +++ b/lib/ethdev/rte_ethdev_core.h
>>>>>>>> @@ -167,7 +167,11 @@ struct rte_eth_dev_data {
>>>>>>>>             scattered_rx : 1,  /**< RX of scattered packets is ON(1) /
>>>>>>>> OFF(0) */
>>>>>>>>             all_multicast : 1, /**< RX all multicast mode ON(1) /
>>>>>>>> OFF(0). */
>>>>>>>>             dev_started : 1,   /**< Device state: STARTED(1) /
>>>>>>>> STOPPED(0). */
>>>>>>>> -        lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
>>>>>>>> +        lro         : 1,  /**< RX LRO is ON(1) / OFF(0) */
>>>>>>>> +        dev_configured : 1;
>>>>>>>> +        /**< Device configuration state:
>>>>>>>> +         * CONFIGURED(1) / NOT CONFIGURED(0).
>>>>>>>> +         */
>>>>>>>>         uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
>>>>>>>>             /**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
>>>>>>>>         uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
>>>>>>>>
>>>>>>> .

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC] lib/ethdev: add dev configured flag
  2021-07-04 20:05 ` Thomas Monjalon
@ 2021-07-05  3:18   ` Huisong Li
  2021-07-05  6:07     ` Thomas Monjalon
  0 siblings, 1 reply; 33+ messages in thread
From: Huisong Li @ 2021-07-05  3:18 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, ferruh.yigit, andrew.rybchenko, konstantin.ananyev


在 2021/7/5 4:05, Thomas Monjalon 写道:
> 08/05/2021 10:00, Huisong Li:
>> Currently, if dev_configure is not invoked or fails to be invoked, users
>> can still invoke dev_start successfully. This patch adds a "dev_configured"
>> flag in "rte_eth_dev_data" to control whether dev_start can be invoked.
> [...]
>> --- a/lib/ethdev/rte_ethdev_core.h
>> +++ b/lib/ethdev/rte_ethdev_core.h
>> @@ -167,7 +167,11 @@ struct rte_eth_dev_data {
>>   		scattered_rx : 1,  /**< RX of scattered packets is ON(1) / OFF(0) */
>>   		all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
>>   		dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
>> -		lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
>> +		lro         : 1,  /**< RX LRO is ON(1) / OFF(0) */
>> +		dev_configured : 1;
>> +		/**< Device configuration state:
>> +		 * CONFIGURED(1) / NOT CONFIGURED(0).
>> +		 */
> Why not using "enum rte_eth_dev_state"?
> Because rte_eth_dev.state is not shared between processes?

It doesn't feel right. "enum rte_eth_dev_state" is private to the 
primary and secondary processes and can be independently controlled.

However, the secondary process does not make resource allocations and 
does not call dev_configure().

These are done by the primary process and  can be obtained or used by 
the secondary process.

Like "dev_started" in struct rte_eth_dev_data.

>
>
>
> .

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC] lib/ethdev: add dev configured flag
  2021-07-05  3:18   ` Huisong Li
@ 2021-07-05  6:07     ` Thomas Monjalon
  2021-07-05  9:50       ` Andrew Rybchenko
  0 siblings, 1 reply; 33+ messages in thread
From: Thomas Monjalon @ 2021-07-05  6:07 UTC (permalink / raw)
  To: Huisong Li; +Cc: dev, ferruh.yigit, andrew.rybchenko, konstantin.ananyev

05/07/2021 05:18, Huisong Li:
> 在 2021/7/5 4:05, Thomas Monjalon 写道:
> > 08/05/2021 10:00, Huisong Li:
> >> Currently, if dev_configure is not invoked or fails to be invoked, users
> >> can still invoke dev_start successfully. This patch adds a "dev_configured"
> >> flag in "rte_eth_dev_data" to control whether dev_start can be invoked.
> > [...]
> >> --- a/lib/ethdev/rte_ethdev_core.h
> >> +++ b/lib/ethdev/rte_ethdev_core.h
> >> @@ -167,7 +167,11 @@ struct rte_eth_dev_data {
> >>   		scattered_rx : 1,  /**< RX of scattered packets is ON(1) / OFF(0) */
> >>   		all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
> >>   		dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
> >> -		lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
> >> +		lro         : 1,  /**< RX LRO is ON(1) / OFF(0) */
> >> +		dev_configured : 1;
> >> +		/**< Device configuration state:
> >> +		 * CONFIGURED(1) / NOT CONFIGURED(0).
> >> +		 */
> > Why not using "enum rte_eth_dev_state"?
> > Because rte_eth_dev.state is not shared between processes?
> 
> It doesn't feel right. "enum rte_eth_dev_state" is private to the 
> primary and secondary processes and can be independently controlled.
> 
> However, the secondary process does not make resource allocations and 
> does not call dev_configure().
> 
> These are done by the primary process and  can be obtained or used by 
> the secondary process.
> 
> Like "dev_started" in struct rte_eth_dev_data.

That's a good reason, thanks.



^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC] lib/ethdev: add dev configured flag
  2021-07-05  3:03               ` Huisong Li
@ 2021-07-05  9:50                 ` Andrew Rybchenko
  2021-07-05 11:22                   ` Ananyev, Konstantin
  0 siblings, 1 reply; 33+ messages in thread
From: Andrew Rybchenko @ 2021-07-05  9:50 UTC (permalink / raw)
  To: Huisong Li, Ananyev, Konstantin, Yigit, Ferruh, dev; +Cc: Thomas Monjalon

On 7/5/21 6:03 AM, Huisong Li wrote:
> 
> 在 2021/7/3 19:04, Ananyev, Konstantin 写道:
>>> 在 2021/7/2 21:23, Ananyev, Konstantin 写道:
>>>>> On 7/2/2021 12:08 PM, Andrew Rybchenko wrote:
>>>>>> @Thomas, @Ferruh, I tend to accept it (with minor style fixes),
>>>>>> but I need your opinion on it before doing it.
>>>>>>
>>>>> I guess we were relying on the user/application to have correct
>>>>> order up until
>>>>> now, it can be good to add this into the API. OK to add it for me.
>>>> I don't know do we really need that flag in dev_data or not,
>>>> but if we do - probably better to reset it at dev_confgure()
>>>> straight before
>>>> we start to make any changes in dev_data.
>>> Sorry, I don't get you. Some fields in rte_eth_dev_data are initialized
>>> firstly in the probe phase.
>>>
>>> Do you mean to add clear this flag at the beginning of dev_configure()?
>> Yes, just before we start to modify things.
> 
> In this patch, this flag has been cleared for all scenarios where the
> rte_eth_dev_data modification fails in the dev_configure().
> 
> And it is set to 1 when dev_configure() is configured successfully.
> 
> Please check the rollback. Thanks😁

I guess Konstantin means the case when user re-configures
the device which has been configured before and the operation
fails. I'm not 100% what should be the state of the flag when
dev_configure callback is executed. I'd say that it should be
0 when the first configure happens and should be 1 in the
case of reconfigure. I'll try to review it carefully when
non-RFC version of the patch is available.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC] lib/ethdev: add dev configured flag
  2021-07-05  6:07     ` Thomas Monjalon
@ 2021-07-05  9:50       ` Andrew Rybchenko
  2021-07-06  1:48         ` Huisong Li
  0 siblings, 1 reply; 33+ messages in thread
From: Andrew Rybchenko @ 2021-07-05  9:50 UTC (permalink / raw)
  To: Thomas Monjalon, Huisong Li; +Cc: dev, ferruh.yigit, konstantin.ananyev

Hi Huisong,

On 7/5/21 9:07 AM, Thomas Monjalon wrote:
> 05/07/2021 05:18, Huisong Li:
>> 在 2021/7/5 4:05, Thomas Monjalon 写道:
>>> 08/05/2021 10:00, Huisong Li:
>>>> Currently, if dev_configure is not invoked or fails to be invoked, users
>>>> can still invoke dev_start successfully. This patch adds a "dev_configured"
>>>> flag in "rte_eth_dev_data" to control whether dev_start can be invoked.
>>> [...]
>>>> --- a/lib/ethdev/rte_ethdev_core.h
>>>> +++ b/lib/ethdev/rte_ethdev_core.h
>>>> @@ -167,7 +167,11 @@ struct rte_eth_dev_data {
>>>>   		scattered_rx : 1,  /**< RX of scattered packets is ON(1) / OFF(0) */
>>>>   		all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
>>>>   		dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
>>>> -		lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
>>>> +		lro         : 1,  /**< RX LRO is ON(1) / OFF(0) */
>>>> +		dev_configured : 1;
>>>> +		/**< Device configuration state:
>>>> +		 * CONFIGURED(1) / NOT CONFIGURED(0).
>>>> +		 */
>>> Why not using "enum rte_eth_dev_state"?
>>> Because rte_eth_dev.state is not shared between processes?
>>
>> It doesn't feel right. "enum rte_eth_dev_state" is private to the 
>> primary and secondary processes and can be independently controlled.
>>
>> However, the secondary process does not make resource allocations and 
>> does not call dev_configure().
>>
>> These are done by the primary process and  can be obtained or used by 
>> the secondary process.
>>
>> Like "dev_started" in struct rte_eth_dev_data.
> 
> That's a good reason, thanks.
> 

Please, send non-RFC version of the patch with fixed summary
(w/o "lib/") and above reason mentioned in the patch
description as well.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC] lib/ethdev: add dev configured flag
  2021-07-05  9:50                 ` Andrew Rybchenko
@ 2021-07-05 11:22                   ` Ananyev, Konstantin
  2021-07-06  1:47                     ` Huisong Li
  0 siblings, 1 reply; 33+ messages in thread
From: Ananyev, Konstantin @ 2021-07-05 11:22 UTC (permalink / raw)
  To: Andrew Rybchenko, Huisong Li, Yigit, Ferruh, dev; +Cc: Thomas Monjalon



> On 7/5/21 6:03 AM, Huisong Li wrote:
> >
> > 在 2021/7/3 19:04, Ananyev, Konstantin 写道:
> >>> 在 2021/7/2 21:23, Ananyev, Konstantin 写道:
> >>>>> On 7/2/2021 12:08 PM, Andrew Rybchenko wrote:
> >>>>>> @Thomas, @Ferruh, I tend to accept it (with minor style fixes),
> >>>>>> but I need your opinion on it before doing it.
> >>>>>>
> >>>>> I guess we were relying on the user/application to have correct
> >>>>> order up until
> >>>>> now, it can be good to add this into the API. OK to add it for me.
> >>>> I don't know do we really need that flag in dev_data or not,
> >>>> but if we do - probably better to reset it at dev_confgure()
> >>>> straight before
> >>>> we start to make any changes in dev_data.
> >>> Sorry, I don't get you. Some fields in rte_eth_dev_data are initialized
> >>> firstly in the probe phase.
> >>>
> >>> Do you mean to add clear this flag at the beginning of dev_configure()?
> >> Yes, just before we start to modify things.
> >
> > In this patch, this flag has been cleared for all scenarios where the
> > rte_eth_dev_data modification fails in the dev_configure().

I understand that.
What I am saying: at first call to dev_confgiure() you execute it with
dev_data->confgiured == 0.
On second and subsequent calls - it could be either 0 or 1,
depending how previous dev_confgiure() had finished.
I think it would be good to keep it always the same,
to avoid any non-anticipated behaviour.

> > And it is set to 1 when dev_configure() is configured successfully.
> >
> > Please check the rollback. Thanks😁



> 
> I guess Konstantin means the case when user re-configures
> the device which has been configured before and the operation
> fails. I'm not 100% what should be the state of the flag when
> dev_configure callback is executed. I'd say that it should be
> 0 when the first configure happens and should be 1 in the
> case of reconfigure. I'll try to review it carefully when
> non-RFC version of the patch is available.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC] lib/ethdev: add dev configured flag
  2021-07-05 11:22                   ` Ananyev, Konstantin
@ 2021-07-06  1:47                     ` Huisong Li
  0 siblings, 0 replies; 33+ messages in thread
From: Huisong Li @ 2021-07-06  1:47 UTC (permalink / raw)
  To: Ananyev, Konstantin, Andrew Rybchenko, Yigit, Ferruh, dev; +Cc: Thomas Monjalon


在 2021/7/5 19:22, Ananyev, Konstantin 写道:
>
>> On 7/5/21 6:03 AM, Huisong Li wrote:
>>> 在 2021/7/3 19:04, Ananyev, Konstantin 写道:
>>>>> 在 2021/7/2 21:23, Ananyev, Konstantin 写道:
>>>>>>> On 7/2/2021 12:08 PM, Andrew Rybchenko wrote:
>>>>>>>> @Thomas, @Ferruh, I tend to accept it (with minor style fixes),
>>>>>>>> but I need your opinion on it before doing it.
>>>>>>>>
>>>>>>> I guess we were relying on the user/application to have correct
>>>>>>> order up until
>>>>>>> now, it can be good to add this into the API. OK to add it for me.
>>>>>> I don't know do we really need that flag in dev_data or not,
>>>>>> but if we do - probably better to reset it at dev_confgure()
>>>>>> straight before
>>>>>> we start to make any changes in dev_data.
>>>>> Sorry, I don't get you. Some fields in rte_eth_dev_data are initialized
>>>>> firstly in the probe phase.
>>>>>
>>>>> Do you mean to add clear this flag at the beginning of dev_configure()?
>>>> Yes, just before we start to modify things.
>>> In this patch, this flag has been cleared for all scenarios where the
>>> rte_eth_dev_data modification fails in the dev_configure().
> I understand that.
> What I am saying: at first call to dev_confgiure() you execute it with
> dev_data->confgiured == 0.
> On second and subsequent calls - it could be either 0 or 1,
> depending how previous dev_confgiure() had finished.
> I think it would be good to keep it always the same,
> to avoid any non-anticipated behaviour.

I get it.

The current patch can ensure that this flag is 1 when dev_configure() is 
called successfully,

and is 0 when dev_configure() isn't called or dev_data fails to be 
modified.

But there is a drawback, as you say. I will fix it in non-RFC version.

>>> And it is set to 1 when dev_configure() is configured successfully.
>>>
>>> Please check the rollback. Thanks😁
>
>
>> I guess Konstantin means the case when user re-configures
>> the device which has been configured before and the operation
>> fails. I'm not 100% what should be the state of the flag when
>> dev_configure callback is executed. I'd say that it should be
>> 0 when the first configure happens and should be 1 in the
>> case of reconfigure. I'll try to review it carefully when
>> non-RFC version of the patch is available.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC] lib/ethdev: add dev configured flag
  2021-07-05  9:50       ` Andrew Rybchenko
@ 2021-07-06  1:48         ` Huisong Li
  0 siblings, 0 replies; 33+ messages in thread
From: Huisong Li @ 2021-07-06  1:48 UTC (permalink / raw)
  To: Andrew Rybchenko, Thomas Monjalon; +Cc: dev, ferruh.yigit, konstantin.ananyev


在 2021/7/5 17:50, Andrew Rybchenko 写道:
> Hi Huisong,
>
> On 7/5/21 9:07 AM, Thomas Monjalon wrote:
>> 05/07/2021 05:18, Huisong Li:
>>> 在 2021/7/5 4:05, Thomas Monjalon 写道:
>>>> 08/05/2021 10:00, Huisong Li:
>>>>> Currently, if dev_configure is not invoked or fails to be invoked, users
>>>>> can still invoke dev_start successfully. This patch adds a "dev_configured"
>>>>> flag in "rte_eth_dev_data" to control whether dev_start can be invoked.
>>>> [...]
>>>>> --- a/lib/ethdev/rte_ethdev_core.h
>>>>> +++ b/lib/ethdev/rte_ethdev_core.h
>>>>> @@ -167,7 +167,11 @@ struct rte_eth_dev_data {
>>>>>    		scattered_rx : 1,  /**< RX of scattered packets is ON(1) / OFF(0) */
>>>>>    		all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
>>>>>    		dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
>>>>> -		lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
>>>>> +		lro         : 1,  /**< RX LRO is ON(1) / OFF(0) */
>>>>> +		dev_configured : 1;
>>>>> +		/**< Device configuration state:
>>>>> +		 * CONFIGURED(1) / NOT CONFIGURED(0).
>>>>> +		 */
>>>> Why not using "enum rte_eth_dev_state"?
>>>> Because rte_eth_dev.state is not shared between processes?
>>> It doesn't feel right. "enum rte_eth_dev_state" is private to the
>>> primary and secondary processes and can be independently controlled.
>>>
>>> However, the secondary process does not make resource allocations and
>>> does not call dev_configure().
>>>
>>> These are done by the primary process and  can be obtained or used by
>>> the secondary process.
>>>
>>> Like "dev_started" in struct rte_eth_dev_data.
>> That's a good reason, thanks.
>>
> Please, send non-RFC version of the patch with fixed summary
> (w/o "lib/") and above reason mentioned in the patch
> description as well.
ok
> .

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [dpdk-dev] [PATCH V1] ethdev: add dev configured flag
  2021-05-08  8:00 [dpdk-dev] [RFC] lib/ethdev: add dev configured flag Huisong Li
                   ` (2 preceding siblings ...)
  2021-07-04 20:05 ` Thomas Monjalon
@ 2021-07-06  3:24 ` Huisong Li
  2021-07-06  4:10 ` [dpdk-dev] [PATCH V2] " Huisong Li
  2021-07-07  9:53 ` [dpdk-dev] [PATCH V3] " Huisong Li
  5 siblings, 0 replies; 33+ messages in thread
From: Huisong Li @ 2021-07-06  3:24 UTC (permalink / raw)
  To: dev; +Cc: thomas, ferruh.yigit, konstantin.ananyev, andrew.rybchenko

Currently, if dev_configure is not called or fails to be called, users
can still call dev_start successfully. So it is necessary to have a flag
which indicates whether the device is configured, to control whether
dev_start can be called and eliminate dependency on user invocation order.

The falg stored in "struct rte_eth_dev_data" is more reasonable than
 "enum rte_eth_dev_state". "enum rte_eth_dev_state" is private to the
primary and secondary processes, and can be independently controlled.
However, the secondary process does not make resource allocations and
does not call dev_configure(). These are done by the primary process
and can be obtained or used by the secondary process. So this patch
adds a "dev_configured" flag in "rte_eth_dev_data", like "dev_started".

Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
 lib/ethdev/rte_ethdev.c      | 16 ++++++++++++++++
 lib/ethdev/rte_ethdev_core.h |  6 +++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index c607eab..6540432 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -1356,6 +1356,13 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		return -EBUSY;
 	}
 
+	/*
+	 * Ensure that "dev_configured" is always 0 each time prepare to do
+	 * dev_configure() to avoid any non-anticipated behaviour.
+	 * And set to 1 when dev_configure() is executed successfully.
+	 */
+	dev->data->dev_configured = 0;
+
 	 /* Store original config, as rollback required on failure */
 	memcpy(&orig_conf, &dev->data->dev_conf, sizeof(dev->data->dev_conf));
 
@@ -1606,6 +1613,8 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	}
 
 	rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q, dev_conf, 0);
+	dev->data->dev_configured = 1;
+
 	return 0;
 reset_queues:
 	eth_dev_rx_queue_config(dev, 0);
@@ -1751,6 +1760,13 @@ rte_eth_dev_start(uint16_t port_id)
 
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
 
+	if (dev->data->dev_configured == 0) {
+		RTE_ETHDEV_LOG(INFO,
+			"Device with port_id=%"PRIu16" is not configured.\n",
+			port_id);
+		return -EINVAL;
+	}
+
 	if (dev->data->dev_started != 0) {
 		RTE_ETHDEV_LOG(INFO,
 			"Device with port_id=%"PRIu16" already started\n",
diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h
index 4679d94..edf96de 100644
--- a/lib/ethdev/rte_ethdev_core.h
+++ b/lib/ethdev/rte_ethdev_core.h
@@ -167,7 +167,11 @@ struct rte_eth_dev_data {
 		scattered_rx : 1,  /**< RX of scattered packets is ON(1) / OFF(0) */
 		all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
 		dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
-		lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
+		lro         : 1,   /**< RX LRO is ON(1) / OFF(0) */
+		dev_configured : 1;
+		/**< Indicates whether the device is configured.
+		 *   CONFIGURED(1) / NOT CONFIGURED(0).
+		 */
 	uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
 		/**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
 	uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
-- 
2.7.4


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [dpdk-dev] [PATCH V2] ethdev: add dev configured flag
  2021-05-08  8:00 [dpdk-dev] [RFC] lib/ethdev: add dev configured flag Huisong Li
                   ` (3 preceding siblings ...)
  2021-07-06  3:24 ` [dpdk-dev] [PATCH V1] ethdev: " Huisong Li
@ 2021-07-06  4:10 ` Huisong Li
  2021-07-06  8:36   ` Andrew Rybchenko
  2021-07-06 17:49   ` Ananyev, Konstantin
  2021-07-07  9:53 ` [dpdk-dev] [PATCH V3] " Huisong Li
  5 siblings, 2 replies; 33+ messages in thread
From: Huisong Li @ 2021-07-06  4:10 UTC (permalink / raw)
  To: dev; +Cc: thomas, ferruh.yigit, konstantin.ananyev, andrew.rybchenko

Currently, if dev_configure is not called or fails to be called, users
can still call dev_start successfully. So it is necessary to have a flag
which indicates whether the device is configured, to control whether
dev_start can be called and eliminate dependency on user invocation order.

The flag stored in "struct rte_eth_dev_data" is more reasonable than
 "enum rte_eth_dev_state". "enum rte_eth_dev_state" is private to the
primary and secondary processes, and can be independently controlled.
However, the secondary process does not make resource allocations and
does not call dev_configure(). These are done by the primary process
and can be obtained or used by the secondary process. So this patch
adds a "dev_configured" flag in "rte_eth_dev_data", like "dev_started".

Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
v1 -> v2:
  - adjusting the description of patch.

---
 lib/ethdev/rte_ethdev.c      | 16 ++++++++++++++++
 lib/ethdev/rte_ethdev_core.h |  6 +++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index c607eab..6540432 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -1356,6 +1356,13 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		return -EBUSY;
 	}
 
+	/*
+	 * Ensure that "dev_configured" is always 0 each time prepare to do
+	 * dev_configure() to avoid any non-anticipated behaviour.
+	 * And set to 1 when dev_configure() is executed successfully.
+	 */
+	dev->data->dev_configured = 0;
+
 	 /* Store original config, as rollback required on failure */
 	memcpy(&orig_conf, &dev->data->dev_conf, sizeof(dev->data->dev_conf));
 
@@ -1606,6 +1613,8 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	}
 
 	rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q, dev_conf, 0);
+	dev->data->dev_configured = 1;
+
 	return 0;
 reset_queues:
 	eth_dev_rx_queue_config(dev, 0);
@@ -1751,6 +1760,13 @@ rte_eth_dev_start(uint16_t port_id)
 
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
 
+	if (dev->data->dev_configured == 0) {
+		RTE_ETHDEV_LOG(INFO,
+			"Device with port_id=%"PRIu16" is not configured.\n",
+			port_id);
+		return -EINVAL;
+	}
+
 	if (dev->data->dev_started != 0) {
 		RTE_ETHDEV_LOG(INFO,
 			"Device with port_id=%"PRIu16" already started\n",
diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h
index 4679d94..edf96de 100644
--- a/lib/ethdev/rte_ethdev_core.h
+++ b/lib/ethdev/rte_ethdev_core.h
@@ -167,7 +167,11 @@ struct rte_eth_dev_data {
 		scattered_rx : 1,  /**< RX of scattered packets is ON(1) / OFF(0) */
 		all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
 		dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
-		lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
+		lro         : 1,   /**< RX LRO is ON(1) / OFF(0) */
+		dev_configured : 1;
+		/**< Indicates whether the device is configured.
+		 *   CONFIGURED(1) / NOT CONFIGURED(0).
+		 */
 	uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
 		/**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
 	uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
-- 
2.7.4


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH V2] ethdev: add dev configured flag
  2021-07-06  4:10 ` [dpdk-dev] [PATCH V2] " Huisong Li
@ 2021-07-06  8:36   ` Andrew Rybchenko
  2021-07-07  2:55     ` Huisong Li
  2021-07-07  7:39     ` David Marchand
  2021-07-06 17:49   ` Ananyev, Konstantin
  1 sibling, 2 replies; 33+ messages in thread
From: Andrew Rybchenko @ 2021-07-06  8:36 UTC (permalink / raw)
  To: Huisong Li, dev
  Cc: thomas, ferruh.yigit, konstantin.ananyev, david.marchand, Ray Kinsella

@David, could you take a look at the ABI breakage warnings for
the patch. May we ignore it since ABI looks backward
compatible? Or should be marked as a minor change ABI
which is backward compatible with DPDK_21?

On 7/6/21 7:10 AM, Huisong Li wrote:
> Currently, if dev_configure is not called or fails to be called, users
> can still call dev_start successfully. So it is necessary to have a flag
> which indicates whether the device is configured, to control whether
> dev_start can be called and eliminate dependency on user invocation order.
> 
> The flag stored in "struct rte_eth_dev_data" is more reasonable than
>  "enum rte_eth_dev_state". "enum rte_eth_dev_state" is private to the
> primary and secondary processes, and can be independently controlled.
> However, the secondary process does not make resource allocations and
> does not call dev_configure(). These are done by the primary process
> and can be obtained or used by the secondary process. So this patch
> adds a "dev_configured" flag in "rte_eth_dev_data", like "dev_started".
> 
> Signed-off-by: Huisong Li <lihuisong@huawei.com>

Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>

> ---
> v1 -> v2:
>   - adjusting the description of patch.
> 
> ---
>  lib/ethdev/rte_ethdev.c      | 16 ++++++++++++++++
>  lib/ethdev/rte_ethdev_core.h |  6 +++++-
>  2 files changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
> index c607eab..6540432 100644
> --- a/lib/ethdev/rte_ethdev.c
> +++ b/lib/ethdev/rte_ethdev.c
> @@ -1356,6 +1356,13 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
>  		return -EBUSY;
>  	}
>  
> +	/*
> +	 * Ensure that "dev_configured" is always 0 each time prepare to do
> +	 * dev_configure() to avoid any non-anticipated behaviour.
> +	 * And set to 1 when dev_configure() is executed successfully.
> +	 */
> +	dev->data->dev_configured = 0;
> +
>  	 /* Store original config, as rollback required on failure */
>  	memcpy(&orig_conf, &dev->data->dev_conf, sizeof(dev->data->dev_conf));
>  
> @@ -1606,6 +1613,8 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
>  	}
>  
>  	rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q, dev_conf, 0);
> +	dev->data->dev_configured = 1;
> +

I think it should be inserted before the trace, since tracing
is intentionally put close to return without any empty lines
in between.

>  	return 0;
>  reset_queues:
>  	eth_dev_rx_queue_config(dev, 0);
> @@ -1751,6 +1760,13 @@ rte_eth_dev_start(uint16_t port_id)
>  
>  	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
>  
> +	if (dev->data->dev_configured == 0) {
> +		RTE_ETHDEV_LOG(INFO,
> +			"Device with port_id=%"PRIu16" is not configured.\n",
> +			port_id);
> +		return -EINVAL;
> +	}
> +
>  	if (dev->data->dev_started != 0) {
>  		RTE_ETHDEV_LOG(INFO,
>  			"Device with port_id=%"PRIu16" already started\n",
> diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h
> index 4679d94..edf96de 100644
> --- a/lib/ethdev/rte_ethdev_core.h
> +++ b/lib/ethdev/rte_ethdev_core.h
> @@ -167,7 +167,11 @@ struct rte_eth_dev_data {
>  		scattered_rx : 1,  /**< RX of scattered packets is ON(1) / OFF(0) */
>  		all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
>  		dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
> -		lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
> +		lro         : 1,   /**< RX LRO is ON(1) / OFF(0) */
> +		dev_configured : 1;
> +		/**< Indicates whether the device is configured.
> +		 *   CONFIGURED(1) / NOT CONFIGURED(0).
> +		 */
>  	uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
>  		/**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
>  	uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
> 


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH V2] ethdev: add dev configured flag
  2021-07-06  4:10 ` [dpdk-dev] [PATCH V2] " Huisong Li
  2021-07-06  8:36   ` Andrew Rybchenko
@ 2021-07-06 17:49   ` Ananyev, Konstantin
  1 sibling, 0 replies; 33+ messages in thread
From: Ananyev, Konstantin @ 2021-07-06 17:49 UTC (permalink / raw)
  To: Huisong Li, dev; +Cc: thomas, Yigit, Ferruh, andrew.rybchenko


> Currently, if dev_configure is not called or fails to be called, users
> can still call dev_start successfully. So it is necessary to have a flag
> which indicates whether the device is configured, to control whether
> dev_start can be called and eliminate dependency on user invocation order.
> 
> The flag stored in "struct rte_eth_dev_data" is more reasonable than
>  "enum rte_eth_dev_state". "enum rte_eth_dev_state" is private to the
> primary and secondary processes, and can be independently controlled.
> However, the secondary process does not make resource allocations and
> does not call dev_configure(). These are done by the primary process
> and can be obtained or used by the secondary process. So this patch
> adds a "dev_configured" flag in "rte_eth_dev_data", like "dev_started".
> 
> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> ---
> v1 -> v2:
>   - adjusting the description of patch.
> 
> ---
>  lib/ethdev/rte_ethdev.c      | 16 ++++++++++++++++
>  lib/ethdev/rte_ethdev_core.h |  6 +++++-
>  2 files changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
> index c607eab..6540432 100644
> --- a/lib/ethdev/rte_ethdev.c
> +++ b/lib/ethdev/rte_ethdev.c
> @@ -1356,6 +1356,13 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
>  		return -EBUSY;
>  	}
> 
> +	/*
> +	 * Ensure that "dev_configured" is always 0 each time prepare to do
> +	 * dev_configure() to avoid any non-anticipated behaviour.
> +	 * And set to 1 when dev_configure() is executed successfully.
> +	 */
> +	dev->data->dev_configured = 0;
> +
>  	 /* Store original config, as rollback required on failure */
>  	memcpy(&orig_conf, &dev->data->dev_conf, sizeof(dev->data->dev_conf));
> 
> @@ -1606,6 +1613,8 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
>  	}
> 
>  	rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q, dev_conf, 0);
> +	dev->data->dev_configured = 1;
> +
>  	return 0;
>  reset_queues:
>  	eth_dev_rx_queue_config(dev, 0);
> @@ -1751,6 +1760,13 @@ rte_eth_dev_start(uint16_t port_id)
> 
>  	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
> 
> +	if (dev->data->dev_configured == 0) {
> +		RTE_ETHDEV_LOG(INFO,
> +			"Device with port_id=%"PRIu16" is not configured.\n",
> +			port_id);
> +		return -EINVAL;
> +	}
> +
>  	if (dev->data->dev_started != 0) {
>  		RTE_ETHDEV_LOG(INFO,
>  			"Device with port_id=%"PRIu16" already started\n",
> diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h
> index 4679d94..edf96de 100644
> --- a/lib/ethdev/rte_ethdev_core.h
> +++ b/lib/ethdev/rte_ethdev_core.h
> @@ -167,7 +167,11 @@ struct rte_eth_dev_data {
>  		scattered_rx : 1,  /**< RX of scattered packets is ON(1) / OFF(0) */
>  		all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
>  		dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
> -		lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
> +		lro         : 1,   /**< RX LRO is ON(1) / OFF(0) */
> +		dev_configured : 1;
> +		/**< Indicates whether the device is configured.
> +		 *   CONFIGURED(1) / NOT CONFIGURED(0).
> +		 */
>  	uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
>  		/**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
>  	uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
> --

Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

> 2.7.4


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH V2] ethdev: add dev configured flag
  2021-07-06  8:36   ` Andrew Rybchenko
@ 2021-07-07  2:55     ` Huisong Li
  2021-07-07  8:25       ` Andrew Rybchenko
  2021-07-07  7:39     ` David Marchand
  1 sibling, 1 reply; 33+ messages in thread
From: Huisong Li @ 2021-07-07  2:55 UTC (permalink / raw)
  To: Andrew Rybchenko, dev
  Cc: thomas, ferruh.yigit, konstantin.ananyev, david.marchand, Ray Kinsella


在 2021/7/6 16:36, Andrew Rybchenko 写道:
> @David, could you take a look at the ABI breakage warnings for
> the patch. May we ignore it since ABI looks backward
> compatible? Or should be marked as a minor change ABI
> which is backward compatible with DPDK_21?
>
> On 7/6/21 7:10 AM, Huisong Li wrote:
>> Currently, if dev_configure is not called or fails to be called, users
>> can still call dev_start successfully. So it is necessary to have a flag
>> which indicates whether the device is configured, to control whether
>> dev_start can be called and eliminate dependency on user invocation order.
>>
>> The flag stored in "struct rte_eth_dev_data" is more reasonable than
>>   "enum rte_eth_dev_state". "enum rte_eth_dev_state" is private to the
>> primary and secondary processes, and can be independently controlled.
>> However, the secondary process does not make resource allocations and
>> does not call dev_configure(). These are done by the primary process
>> and can be obtained or used by the secondary process. So this patch
>> adds a "dev_configured" flag in "rte_eth_dev_data", like "dev_started".
>>
>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
>
>> ---
>> v1 -> v2:
>>    - adjusting the description of patch.
>>
>> ---
>>   lib/ethdev/rte_ethdev.c      | 16 ++++++++++++++++
>>   lib/ethdev/rte_ethdev_core.h |  6 +++++-
>>   2 files changed, 21 insertions(+), 1 deletion(-)
>>
>> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
>> index c607eab..6540432 100644
>> --- a/lib/ethdev/rte_ethdev.c
>> +++ b/lib/ethdev/rte_ethdev.c
>> @@ -1356,6 +1356,13 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
>>   		return -EBUSY;
>>   	}
>>   
>> +	/*
>> +	 * Ensure that "dev_configured" is always 0 each time prepare to do
>> +	 * dev_configure() to avoid any non-anticipated behaviour.
>> +	 * And set to 1 when dev_configure() is executed successfully.
>> +	 */
>> +	dev->data->dev_configured = 0;
>> +
>>   	 /* Store original config, as rollback required on failure */
>>   	memcpy(&orig_conf, &dev->data->dev_conf, sizeof(dev->data->dev_conf));
>>   
>> @@ -1606,6 +1613,8 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
>>   	}
>>   
>>   	rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q, dev_conf, 0);
>> +	dev->data->dev_configured = 1;
>> +
> I think it should be inserted before the trace, since tracing
> is intentionally put close to return without any empty lines
> in between.
All right. Do I need to send a patch V3?
>>   	return 0;
>>   reset_queues:
>>   	eth_dev_rx_queue_config(dev, 0);
>> @@ -1751,6 +1760,13 @@ rte_eth_dev_start(uint16_t port_id)
>>   
>>   	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
>>   
>> +	if (dev->data->dev_configured == 0) {
>> +		RTE_ETHDEV_LOG(INFO,
>> +			"Device with port_id=%"PRIu16" is not configured.\n",
>> +			port_id);
>> +		return -EINVAL;
>> +	}
>> +
>>   	if (dev->data->dev_started != 0) {
>>   		RTE_ETHDEV_LOG(INFO,
>>   			"Device with port_id=%"PRIu16" already started\n",
>> diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h
>> index 4679d94..edf96de 100644
>> --- a/lib/ethdev/rte_ethdev_core.h
>> +++ b/lib/ethdev/rte_ethdev_core.h
>> @@ -167,7 +167,11 @@ struct rte_eth_dev_data {
>>   		scattered_rx : 1,  /**< RX of scattered packets is ON(1) / OFF(0) */
>>   		all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
>>   		dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
>> -		lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
>> +		lro         : 1,   /**< RX LRO is ON(1) / OFF(0) */
>> +		dev_configured : 1;
>> +		/**< Indicates whether the device is configured.
>> +		 *   CONFIGURED(1) / NOT CONFIGURED(0).
>> +		 */
>>   	uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
>>   		/**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
>>   	uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
>>
> .

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH V2] ethdev: add dev configured flag
  2021-07-06  8:36   ` Andrew Rybchenko
  2021-07-07  2:55     ` Huisong Li
@ 2021-07-07  7:39     ` David Marchand
  2021-07-07  8:23       ` Andrew Rybchenko
  1 sibling, 1 reply; 33+ messages in thread
From: David Marchand @ 2021-07-07  7:39 UTC (permalink / raw)
  To: Andrew Rybchenko, Dodji Seketeli
  Cc: Huisong Li, dev, Thomas Monjalon, Yigit, Ferruh, Ananyev,
	Konstantin, Ray Kinsella

On Tue, Jul 6, 2021 at 10:36 AM Andrew Rybchenko
<andrew.rybchenko@oktetlabs.ru> wrote:
>
> @David, could you take a look at the ABI breakage warnings for
> the patch. May we ignore it since ABI looks backward
> compatible? Or should be marked as a minor change ABI
> which is backward compatible with DPDK_21?

The whole eth_dev_shared_data area has always been reset to 0 at the
first port allocation in a dpdk application life.
Subsequent calls to rte_eth_dev_release_port() reset every port
eth_dev->data to 0.

This bit flag is added in a hole of the structure, and it is
set/manipulated internally of ethdev.

So unless the application was doing something nasty like highjacking
this empty hole in the structure, I see no problem with the change wrt
ABI.


I wonder if libabigail is too strict on this report.
Or maybe there is some extreme consideration on what a compiler could
do about this hole...
Dodji?


For now, we can waive the warning.
I'll look into the exception rule to add.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH V2] ethdev: add dev configured flag
  2021-07-07  7:39     ` David Marchand
@ 2021-07-07  8:23       ` Andrew Rybchenko
  2021-07-07  9:36         ` David Marchand
  0 siblings, 1 reply; 33+ messages in thread
From: Andrew Rybchenko @ 2021-07-07  8:23 UTC (permalink / raw)
  To: David Marchand, Dodji Seketeli
  Cc: Huisong Li, dev, Thomas Monjalon, Yigit, Ferruh, Ananyev,
	Konstantin, Ray Kinsella

On 7/7/21 10:39 AM, David Marchand wrote:
> On Tue, Jul 6, 2021 at 10:36 AM Andrew Rybchenko
> <andrew.rybchenko@oktetlabs.ru> wrote:
>>
>> @David, could you take a look at the ABI breakage warnings for
>> the patch. May we ignore it since ABI looks backward
>> compatible? Or should be marked as a minor change ABI
>> which is backward compatible with DPDK_21?
> 
> The whole eth_dev_shared_data area has always been reset to 0 at the
> first port allocation in a dpdk application life.
> Subsequent calls to rte_eth_dev_release_port() reset every port
> eth_dev->data to 0.
> 
> This bit flag is added in a hole of the structure, and it is
> set/manipulated internally of ethdev.
> 
> So unless the application was doing something nasty like highjacking
> this empty hole in the structure, I see no problem with the change wrt
> ABI.
> 
> 
> I wonder if libabigail is too strict on this report.
> Or maybe there is some extreme consideration on what a compiler could
> do about this hole...

I was wondering if it could be any specifics related to big-
little endian vs bit fields placement, but throw the idea
away...

> Dodji?
> 
> 
> For now, we can waive the warning.
> I'll look into the exception rule to add.

Thanks a lot. I'll hold on the patch for now.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH V2] ethdev: add dev configured flag
  2021-07-07  2:55     ` Huisong Li
@ 2021-07-07  8:25       ` Andrew Rybchenko
  2021-07-07  9:26         ` Huisong Li
  0 siblings, 1 reply; 33+ messages in thread
From: Andrew Rybchenko @ 2021-07-07  8:25 UTC (permalink / raw)
  To: Huisong Li, dev
  Cc: thomas, ferruh.yigit, konstantin.ananyev, david.marchand, Ray Kinsella

On 7/7/21 5:55 AM, Huisong Li wrote:
> 
> 在 2021/7/6 16:36, Andrew Rybchenko 写道:
>> @David, could you take a look at the ABI breakage warnings for
>> the patch. May we ignore it since ABI looks backward
>> compatible? Or should be marked as a minor change ABI
>> which is backward compatible with DPDK_21?
>>
>> On 7/6/21 7:10 AM, Huisong Li wrote:
>>> Currently, if dev_configure is not called or fails to be called, users
>>> can still call dev_start successfully. So it is necessary to have a flag
>>> which indicates whether the device is configured, to control whether
>>> dev_start can be called and eliminate dependency on user invocation
>>> order.
>>>
>>> The flag stored in "struct rte_eth_dev_data" is more reasonable than
>>>   "enum rte_eth_dev_state". "enum rte_eth_dev_state" is private to the
>>> primary and secondary processes, and can be independently controlled.
>>> However, the secondary process does not make resource allocations and
>>> does not call dev_configure(). These are done by the primary process
>>> and can be obtained or used by the secondary process. So this patch
>>> adds a "dev_configured" flag in "rte_eth_dev_data", like "dev_started".
>>>
>>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>> Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
>>
>>> ---
>>> v1 -> v2:
>>>    - adjusting the description of patch.
>>>
>>> ---
>>>   lib/ethdev/rte_ethdev.c      | 16 ++++++++++++++++
>>>   lib/ethdev/rte_ethdev_core.h |  6 +++++-
>>>   2 files changed, 21 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
>>> index c607eab..6540432 100644
>>> --- a/lib/ethdev/rte_ethdev.c
>>> +++ b/lib/ethdev/rte_ethdev.c
>>> @@ -1356,6 +1356,13 @@ rte_eth_dev_configure(uint16_t port_id,
>>> uint16_t nb_rx_q, uint16_t nb_tx_q,
>>>           return -EBUSY;
>>>       }
>>>   +    /*
>>> +     * Ensure that "dev_configured" is always 0 each time prepare to do
>>> +     * dev_configure() to avoid any non-anticipated behaviour.
>>> +     * And set to 1 when dev_configure() is executed successfully.
>>> +     */
>>> +    dev->data->dev_configured = 0;
>>> +
>>>        /* Store original config, as rollback required on failure */
>>>       memcpy(&orig_conf, &dev->data->dev_conf,
>>> sizeof(dev->data->dev_conf));
>>>   @@ -1606,6 +1613,8 @@ rte_eth_dev_configure(uint16_t port_id,
>>> uint16_t nb_rx_q, uint16_t nb_tx_q,
>>>       }
>>>         rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q,
>>> dev_conf, 0);
>>> +    dev->data->dev_configured = 1;
>>> +
>> I think it should be inserted before the trace, since tracing
>> is intentionally put close to return without any empty lines
>> in between.
> All right. Do I need to send a patch V3?

Since the patch is waiting for resolution for ABI warning,
please, send v3 with my Reviewed-by and ack from Konstantin.
It will be a bit easier to apply when it is OK to do it.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH V2] ethdev: add dev configured flag
  2021-07-07  8:25       ` Andrew Rybchenko
@ 2021-07-07  9:26         ` Huisong Li
  0 siblings, 0 replies; 33+ messages in thread
From: Huisong Li @ 2021-07-07  9:26 UTC (permalink / raw)
  To: Andrew Rybchenko, dev
  Cc: thomas, ferruh.yigit, konstantin.ananyev, david.marchand, Ray Kinsella


在 2021/7/7 16:25, Andrew Rybchenko 写道:
> On 7/7/21 5:55 AM, Huisong Li wrote:
>> 在 2021/7/6 16:36, Andrew Rybchenko 写道:
>>> @David, could you take a look at the ABI breakage warnings for
>>> the patch. May we ignore it since ABI looks backward
>>> compatible? Or should be marked as a minor change ABI
>>> which is backward compatible with DPDK_21?
>>>
>>> On 7/6/21 7:10 AM, Huisong Li wrote:
>>>> Currently, if dev_configure is not called or fails to be called, users
>>>> can still call dev_start successfully. So it is necessary to have a flag
>>>> which indicates whether the device is configured, to control whether
>>>> dev_start can be called and eliminate dependency on user invocation
>>>> order.
>>>>
>>>> The flag stored in "struct rte_eth_dev_data" is more reasonable than
>>>>    "enum rte_eth_dev_state". "enum rte_eth_dev_state" is private to the
>>>> primary and secondary processes, and can be independently controlled.
>>>> However, the secondary process does not make resource allocations and
>>>> does not call dev_configure(). These are done by the primary process
>>>> and can be obtained or used by the secondary process. So this patch
>>>> adds a "dev_configured" flag in "rte_eth_dev_data", like "dev_started".
>>>>
>>>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>>> Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
>>>
>>>> ---
>>>> v1 -> v2:
>>>>     - adjusting the description of patch.
>>>>
>>>> ---
>>>>    lib/ethdev/rte_ethdev.c      | 16 ++++++++++++++++
>>>>    lib/ethdev/rte_ethdev_core.h |  6 +++++-
>>>>    2 files changed, 21 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
>>>> index c607eab..6540432 100644
>>>> --- a/lib/ethdev/rte_ethdev.c
>>>> +++ b/lib/ethdev/rte_ethdev.c
>>>> @@ -1356,6 +1356,13 @@ rte_eth_dev_configure(uint16_t port_id,
>>>> uint16_t nb_rx_q, uint16_t nb_tx_q,
>>>>            return -EBUSY;
>>>>        }
>>>>    +    /*
>>>> +     * Ensure that "dev_configured" is always 0 each time prepare to do
>>>> +     * dev_configure() to avoid any non-anticipated behaviour.
>>>> +     * And set to 1 when dev_configure() is executed successfully.
>>>> +     */
>>>> +    dev->data->dev_configured = 0;
>>>> +
>>>>         /* Store original config, as rollback required on failure */
>>>>        memcpy(&orig_conf, &dev->data->dev_conf,
>>>> sizeof(dev->data->dev_conf));
>>>>    @@ -1606,6 +1613,8 @@ rte_eth_dev_configure(uint16_t port_id,
>>>> uint16_t nb_rx_q, uint16_t nb_tx_q,
>>>>        }
>>>>          rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q,
>>>> dev_conf, 0);
>>>> +    dev->data->dev_configured = 1;
>>>> +
>>> I think it should be inserted before the trace, since tracing
>>> is intentionally put close to return without any empty lines
>>> in between.
>> All right. Do I need to send a patch V3?
> Since the patch is waiting for resolution for ABI warning,
> please, send v3 with my Reviewed-by and ack from Konstantin.
> It will be a bit easier to apply when it is OK to do it.
> .
ok. I will send patch V3.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH V2] ethdev: add dev configured flag
  2021-07-07  8:23       ` Andrew Rybchenko
@ 2021-07-07  9:36         ` David Marchand
  2021-07-07  9:59           ` Thomas Monjalon
  0 siblings, 1 reply; 33+ messages in thread
From: David Marchand @ 2021-07-07  9:36 UTC (permalink / raw)
  To: Andrew Rybchenko
  Cc: Dodji Seketeli, Huisong Li, dev, Thomas Monjalon, Yigit, Ferruh,
	Ananyev, Konstantin, Ray Kinsella

On Wed, Jul 7, 2021 at 10:23 AM Andrew Rybchenko
<andrew.rybchenko@oktetlabs.ru> wrote:
>
> On 7/7/21 10:39 AM, David Marchand wrote:
> > On Tue, Jul 6, 2021 at 10:36 AM Andrew Rybchenko
> > <andrew.rybchenko@oktetlabs.ru> wrote:
> >>
> >> @David, could you take a look at the ABI breakage warnings for
> >> the patch. May we ignore it since ABI looks backward
> >> compatible? Or should be marked as a minor change ABI
> >> which is backward compatible with DPDK_21?
> >
> > The whole eth_dev_shared_data area has always been reset to 0 at the
> > first port allocation in a dpdk application life.
> > Subsequent calls to rte_eth_dev_release_port() reset every port
> > eth_dev->data to 0.
> >
> > This bit flag is added in a hole of the structure, and it is
> > set/manipulated internally of ethdev.
> >
> > So unless the application was doing something nasty like highjacking
> > this empty hole in the structure, I see no problem with the change wrt
> > ABI.
> >
> >
> > I wonder if libabigail is too strict on this report.
> > Or maybe there is some extreme consideration on what a compiler could
> > do about this hole...
>
> I was wondering if it could be any specifics related to big-
> little endian vs bit fields placement, but throw the idea
> away...

After some discussion offlist with (fairly busy ;-)) Dodji, the report
here is a good warning.

But it looks we have an issue with libabigail not properly computing
bitfields offsets.
I just opened a bz for tracking
https://sourceware.org/bugzilla/show_bug.cgi?id=28060

This is problematic, as the following rule does not work:

+; Ignore bitfields added in rte_eth_dev_data hole
+[suppress_type]
+        name = rte_eth_dev_data
+        has_data_member_inserted_between = {offset_after(lro),
offset_of(rx_queue_state)}

On the other hand, a (wrong) rule with "has_data_member_inserted_at =
2" (2 being the wrong offset you can read in abidiff output) works.

This might force us to waive all changes to rte_eth_dev_data... not
that I am happy about it.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [dpdk-dev] [PATCH V3] ethdev: add dev configured flag
  2021-05-08  8:00 [dpdk-dev] [RFC] lib/ethdev: add dev configured flag Huisong Li
                   ` (4 preceding siblings ...)
  2021-07-06  4:10 ` [dpdk-dev] [PATCH V2] " Huisong Li
@ 2021-07-07  9:53 ` Huisong Li
  2021-07-08  9:56   ` David Marchand
  5 siblings, 1 reply; 33+ messages in thread
From: Huisong Li @ 2021-07-07  9:53 UTC (permalink / raw)
  To: dev; +Cc: thomas, ferruh.yigit, konstantin.ananyev, andrew.rybchenko

Currently, if dev_configure is not called or fails to be called, users
can still call dev_start successfully. So it is necessary to have a flag
which indicates whether the device is configured, to control whether
dev_start can be called and eliminate dependency on user invocation order.

The flag stored in "struct rte_eth_dev_data" is more reasonable than
 "enum rte_eth_dev_state". "enum rte_eth_dev_state" is private to the
primary and secondary processes, and can be independently controlled.
However, the secondary process does not make resource allocations and
does not call dev_configure(). These are done by the primary process
and can be obtained or used by the secondary process. So this patch
adds a "dev_configured" flag in "rte_eth_dev_data", like "dev_started".

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
v2 -> v3:
 - move "dev->data->dev_configured = 1" to the front of the trace.
v1 -> v2:                                                                  
 - adjusting the description of patch.
---
 lib/ethdev/rte_ethdev.c      | 15 +++++++++++++++
 lib/ethdev/rte_ethdev_core.h |  6 +++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index c607eab..6ebf52b 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -1356,6 +1356,13 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		return -EBUSY;
 	}
 
+	/*
+	 * Ensure that "dev_configured" is always 0 each time prepare to do
+	 * dev_configure() to avoid any non-anticipated behaviour.
+	 * And set to 1 when dev_configure() is executed successfully.
+	 */
+	dev->data->dev_configured = 0;
+
 	 /* Store original config, as rollback required on failure */
 	memcpy(&orig_conf, &dev->data->dev_conf, sizeof(dev->data->dev_conf));
 
@@ -1605,6 +1612,7 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		goto reset_queues;
 	}
 
+	dev->data->dev_configured = 1;
 	rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q, dev_conf, 0);
 	return 0;
 reset_queues:
@@ -1751,6 +1759,13 @@ rte_eth_dev_start(uint16_t port_id)
 
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
 
+	if (dev->data->dev_configured == 0) {
+		RTE_ETHDEV_LOG(INFO,
+			"Device with port_id=%"PRIu16" is not configured.\n",
+			port_id);
+		return -EINVAL;
+	}
+
 	if (dev->data->dev_started != 0) {
 		RTE_ETHDEV_LOG(INFO,
 			"Device with port_id=%"PRIu16" already started\n",
diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h
index 4679d94..edf96de 100644
--- a/lib/ethdev/rte_ethdev_core.h
+++ b/lib/ethdev/rte_ethdev_core.h
@@ -167,7 +167,11 @@ struct rte_eth_dev_data {
 		scattered_rx : 1,  /**< RX of scattered packets is ON(1) / OFF(0) */
 		all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
 		dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
-		lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
+		lro         : 1,   /**< RX LRO is ON(1) / OFF(0) */
+		dev_configured : 1;
+		/**< Indicates whether the device is configured.
+		 *   CONFIGURED(1) / NOT CONFIGURED(0).
+		 */
 	uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
 		/**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
 	uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
-- 
2.7.4


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH V2] ethdev: add dev configured flag
  2021-07-07  9:36         ` David Marchand
@ 2021-07-07  9:59           ` Thomas Monjalon
  2021-07-07 10:40             ` David Marchand
  0 siblings, 1 reply; 33+ messages in thread
From: Thomas Monjalon @ 2021-07-07  9:59 UTC (permalink / raw)
  To: Andrew Rybchenko, David Marchand
  Cc: Dodji Seketeli, Huisong Li, dev, Yigit, Ferruh, Ananyev,
	Konstantin, Ray Kinsella

07/07/2021 11:36, David Marchand:
> On Wed, Jul 7, 2021 at 10:23 AM Andrew Rybchenko
> <andrew.rybchenko@oktetlabs.ru> wrote:
> >
> > On 7/7/21 10:39 AM, David Marchand wrote:
> > > On Tue, Jul 6, 2021 at 10:36 AM Andrew Rybchenko
> > > <andrew.rybchenko@oktetlabs.ru> wrote:
> > >>
> > >> @David, could you take a look at the ABI breakage warnings for
> > >> the patch. May we ignore it since ABI looks backward
> > >> compatible? Or should be marked as a minor change ABI
> > >> which is backward compatible with DPDK_21?
> > >
> > > The whole eth_dev_shared_data area has always been reset to 0 at the
> > > first port allocation in a dpdk application life.
> > > Subsequent calls to rte_eth_dev_release_port() reset every port
> > > eth_dev->data to 0.
> > >
> > > This bit flag is added in a hole of the structure, and it is
> > > set/manipulated internally of ethdev.
> > >
> > > So unless the application was doing something nasty like highjacking
> > > this empty hole in the structure, I see no problem with the change wrt
> > > ABI.
> > >
> > >
> > > I wonder if libabigail is too strict on this report.
> > > Or maybe there is some extreme consideration on what a compiler could
> > > do about this hole...
> >
> > I was wondering if it could be any specifics related to big-
> > little endian vs bit fields placement, but throw the idea
> > away...
> 
> After some discussion offlist with (fairly busy ;-)) Dodji, the report
> here is a good warning.
> 
> But it looks we have an issue with libabigail not properly computing
> bitfields offsets.
> I just opened a bz for tracking
> https://sourceware.org/bugzilla/show_bug.cgi?id=28060
> 
> This is problematic, as the following rule does not work:
> 
> +; Ignore bitfields added in rte_eth_dev_data hole
> +[suppress_type]
> +        name = rte_eth_dev_data
> +        has_data_member_inserted_between = {offset_after(lro),
> offset_of(rx_queue_state)}
> 
> On the other hand, a (wrong) rule with "has_data_member_inserted_at =
> 2" (2 being the wrong offset you can read in abidiff output) works.
> 
> This might force us to waive all changes to rte_eth_dev_data... not
> that I am happy about it.

We are not going to do other changes until 21.11, so it could be fine.



^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH V2] ethdev: add dev configured flag
  2021-07-07  9:59           ` Thomas Monjalon
@ 2021-07-07 10:40             ` David Marchand
  2021-07-07 10:57               ` Thomas Monjalon
  0 siblings, 1 reply; 33+ messages in thread
From: David Marchand @ 2021-07-07 10:40 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: Andrew Rybchenko, Dodji Seketeli, Huisong Li, dev, Yigit, Ferruh,
	Ananyev, Konstantin, Ray Kinsella

On Wed, Jul 7, 2021 at 11:59 AM Thomas Monjalon <thomas@monjalon.net> wrote:
> > This is problematic, as the following rule does not work:
> >
> > +; Ignore bitfields added in rte_eth_dev_data hole
> > +[suppress_type]
> > +        name = rte_eth_dev_data
> > +        has_data_member_inserted_between = {offset_after(lro),
> > offset_of(rx_queue_state)}
> >
> > On the other hand, a (wrong) rule with "has_data_member_inserted_at =
> > 2" (2 being the wrong offset you can read in abidiff output) works.
> >
> > This might force us to waive all changes to rte_eth_dev_data... not
> > that I am happy about it.
>
> We are not going to do other changes until 21.11, so it could be fine.

Ok, example of a global exception for the structure:

+; Ignore all changes to rte_eth_dev_data
+; Note: we only cared about dev_configured bit addition, but libabigail
+; seems to wrongly compute bitfields offset.
+; https://sourceware.org/bugzilla/show_bug.cgi?id=28060
+[suppress_type]
+        name = rte_eth_dev_data


-- 
David Marchand


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH V2] ethdev: add dev configured flag
  2021-07-07 10:40             ` David Marchand
@ 2021-07-07 10:57               ` Thomas Monjalon
  0 siblings, 0 replies; 33+ messages in thread
From: Thomas Monjalon @ 2021-07-07 10:57 UTC (permalink / raw)
  To: David Marchand
  Cc: Andrew Rybchenko, Dodji Seketeli, Huisong Li, dev, Yigit, Ferruh,
	Ananyev, Konstantin, Ray Kinsella

07/07/2021 12:40, David Marchand:
> On Wed, Jul 7, 2021 at 11:59 AM Thomas Monjalon <thomas@monjalon.net> wrote:
> > > This is problematic, as the following rule does not work:
> > >
> > > +; Ignore bitfields added in rte_eth_dev_data hole
> > > +[suppress_type]
> > > +        name = rte_eth_dev_data
> > > +        has_data_member_inserted_between = {offset_after(lro),
> > > offset_of(rx_queue_state)}
> > >
> > > On the other hand, a (wrong) rule with "has_data_member_inserted_at =
> > > 2" (2 being the wrong offset you can read in abidiff output) works.
> > >
> > > This might force us to waive all changes to rte_eth_dev_data... not
> > > that I am happy about it.
> >
> > We are not going to do other changes until 21.11, so it could be fine.
> 
> Ok, example of a global exception for the structure:
> 
> +; Ignore all changes to rte_eth_dev_data
> +; Note: we only cared about dev_configured bit addition, but libabigail
> +; seems to wrongly compute bitfields offset.
> +; https://sourceware.org/bugzilla/show_bug.cgi?id=28060
> +[suppress_type]
> +        name = rte_eth_dev_data

OK for me. Thanks for managing this issue.



^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH V3] ethdev: add dev configured flag
  2021-07-07  9:53 ` [dpdk-dev] [PATCH V3] " Huisong Li
@ 2021-07-08  9:56   ` David Marchand
  0 siblings, 0 replies; 33+ messages in thread
From: David Marchand @ 2021-07-08  9:56 UTC (permalink / raw)
  To: Huisong Li, Thomas Monjalon, Andrew Rybchenko, Yigit, Ferruh
  Cc: dev, Ananyev, Konstantin, Mcnamara, John, Ray Kinsella, Dodji Seketeli

On Wed, Jul 7, 2021 at 11:54 AM Huisong Li <lihuisong@huawei.com> wrote:
>
> Currently, if dev_configure is not called or fails to be called, users
> can still call dev_start successfully. So it is necessary to have a flag
> which indicates whether the device is configured, to control whether
> dev_start can be called and eliminate dependency on user invocation order.
>
> The flag stored in "struct rte_eth_dev_data" is more reasonable than
>  "enum rte_eth_dev_state". "enum rte_eth_dev_state" is private to the
> primary and secondary processes, and can be independently controlled.
> However, the secondary process does not make resource allocations and
> does not call dev_configure(). These are done by the primary process
> and can be obtained or used by the secondary process. So this patch
> adds a "dev_configured" flag in "rte_eth_dev_data", like "dev_started".
>
> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

As explained in the thread, I added a rather "large" ABI exception
rule so that we can merge this patch.

+; Ignore all changes to rte_eth_dev_data
+; Note: we only cared about dev_configured bit addition, but libabigail
+; seems to wrongly compute bitfields offset.
+; https://sourceware.org/bugzilla/show_bug.cgi?id=28060
+[suppress_type]
+        name = rte_eth_dev_data


*Reminder to ethdev maintainers*: with this exception, we have no
check on rte_eth_dev_data struct changes until 21.11.


Applied, thanks.

-- 
David Marchand


^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2021-07-08  9:57 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-08  8:00 [dpdk-dev] [RFC] lib/ethdev: add dev configured flag Huisong Li
2021-05-31  8:51 ` Huisong Li
2021-06-14 15:37 ` Andrew Rybchenko
2021-06-29  2:27   ` Huisong Li
2021-07-02 10:08     ` Andrew Rybchenko
2021-07-02 11:57       ` Ferruh Yigit
2021-07-02 13:23         ` Ananyev, Konstantin
2021-07-03  8:35           ` Huisong Li
2021-07-03 11:04             ` Ananyev, Konstantin
2021-07-05  3:03               ` Huisong Li
2021-07-05  9:50                 ` Andrew Rybchenko
2021-07-05 11:22                   ` Ananyev, Konstantin
2021-07-06  1:47                     ` Huisong Li
2021-07-04 20:05 ` Thomas Monjalon
2021-07-05  3:18   ` Huisong Li
2021-07-05  6:07     ` Thomas Monjalon
2021-07-05  9:50       ` Andrew Rybchenko
2021-07-06  1:48         ` Huisong Li
2021-07-06  3:24 ` [dpdk-dev] [PATCH V1] ethdev: " Huisong Li
2021-07-06  4:10 ` [dpdk-dev] [PATCH V2] " Huisong Li
2021-07-06  8:36   ` Andrew Rybchenko
2021-07-07  2:55     ` Huisong Li
2021-07-07  8:25       ` Andrew Rybchenko
2021-07-07  9:26         ` Huisong Li
2021-07-07  7:39     ` David Marchand
2021-07-07  8:23       ` Andrew Rybchenko
2021-07-07  9:36         ` David Marchand
2021-07-07  9:59           ` Thomas Monjalon
2021-07-07 10:40             ` David Marchand
2021-07-07 10:57               ` Thomas Monjalon
2021-07-06 17:49   ` Ananyev, Konstantin
2021-07-07  9:53 ` [dpdk-dev] [PATCH V3] " Huisong Li
2021-07-08  9:56   ` David Marchand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).