diff mbox series

[v3,1/5] eventdev: support to set queue attributes at runtime

Message ID e1ba4a0a6fadf0a43bd8d59c90f659b8b056f657.1652607951.git.sthotton@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series Extend and set event queue attributes at runtime | expand

Checks

Context Check Description
ci/iol-testing warning apply patch failure
ci/checkpatch success coding style OK

Commit Message

Shijith Thotton May 15, 2022, 9:53 a.m. UTC
Added a new eventdev API rte_event_queue_attr_set(), to set event queue
attributes at runtime from the values set during initialization using
rte_event_queue_setup(). PMD's supporting this feature should expose the
capability RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR.

Signed-off-by: Shijith Thotton <sthotton@marvell.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
---
 doc/guides/eventdevs/features/default.ini |  1 +
 doc/guides/rel_notes/release_22_07.rst    |  5 ++++
 lib/eventdev/eventdev_pmd.h               | 22 +++++++++++++++
 lib/eventdev/rte_eventdev.c               | 26 ++++++++++++++++++
 lib/eventdev/rte_eventdev.h               | 33 ++++++++++++++++++++++-
 lib/eventdev/version.map                  |  3 +++
 6 files changed, 89 insertions(+), 1 deletion(-)

Comments

Mattias Rönnblom May 15, 2022, 1:11 p.m. UTC | #1
On 2022-05-15 11:53, Shijith Thotton wrote:
> Added a new eventdev API rte_event_queue_attr_set(), to set event queue
> attributes at runtime from the values set during initialization using
> rte_event_queue_setup(). PMD's supporting this feature should expose the
> capability RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR.
> 
> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
> Acked-by: Jerin Jacob <jerinj@marvell.com>
> ---
>   doc/guides/eventdevs/features/default.ini |  1 +
>   doc/guides/rel_notes/release_22_07.rst    |  5 ++++
>   lib/eventdev/eventdev_pmd.h               | 22 +++++++++++++++
>   lib/eventdev/rte_eventdev.c               | 26 ++++++++++++++++++
>   lib/eventdev/rte_eventdev.h               | 33 ++++++++++++++++++++++-
>   lib/eventdev/version.map                  |  3 +++
>   6 files changed, 89 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/guides/eventdevs/features/default.ini b/doc/guides/eventdevs/features/default.ini
> index 2ea233463a..00360f60c6 100644
> --- a/doc/guides/eventdevs/features/default.ini
> +++ b/doc/guides/eventdevs/features/default.ini
> @@ -17,6 +17,7 @@ runtime_port_link          =
>   multiple_queue_port        =
>   carry_flow_id              =
>   maintenance_free           =
> +runtime_queue_attr         =
>   
>   ;
>   ; Features of a default Ethernet Rx adapter.
> diff --git a/doc/guides/rel_notes/release_22_07.rst b/doc/guides/rel_notes/release_22_07.rst
> index 88d6e96cc1..a7a912d665 100644
> --- a/doc/guides/rel_notes/release_22_07.rst
> +++ b/doc/guides/rel_notes/release_22_07.rst
> @@ -65,6 +65,11 @@ New Features
>     * Added support for promiscuous mode on Windows.
>     * Added support for MTU on Windows.
>   
> +* **Added support for setting queue attributes at runtime in eventdev.**
> +
> +  Added new API ``rte_event_queue_attr_set()``, to set event queue attributes
> +  at runtime.
> +
>   
>   Removed Items
>   -------------
> diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
> index ce469d47a6..3b85d9f7a5 100644
> --- a/lib/eventdev/eventdev_pmd.h
> +++ b/lib/eventdev/eventdev_pmd.h
> @@ -341,6 +341,26 @@ typedef int (*eventdev_queue_setup_t)(struct rte_eventdev *dev,
>   typedef void (*eventdev_queue_release_t)(struct rte_eventdev *dev,
>   		uint8_t queue_id);
>   
> +/**
> + * Set an event queue attribute at runtime.
> + *
> + * @param dev
> + *   Event device pointer
> + * @param queue_id
> + *   Event queue index
> + * @param attr_id
> + *   Event queue attribute id
> + * @param attr_value
> + *   Event queue attribute value
> + *
> + * @return
> + *  - 0: Success.
> + *  - <0: Error code on failure.
> + */
> +typedef int (*eventdev_queue_attr_set_t)(struct rte_eventdev *dev,
> +					 uint8_t queue_id, uint32_t attr_id,
> +					 uint64_t attr_value);
> +
>   /**
>    * Retrieve the default event port configuration.
>    *
> @@ -1211,6 +1231,8 @@ struct eventdev_ops {
>   	/**< Set up an event queue. */
>   	eventdev_queue_release_t queue_release;
>   	/**< Release an event queue. */
> +	eventdev_queue_attr_set_t queue_attr_set;
> +	/**< Set an event queue attribute. */
>   
>   	eventdev_port_default_conf_get_t port_def_conf;
>   	/**< Get default port configuration. */
> diff --git a/lib/eventdev/rte_eventdev.c b/lib/eventdev/rte_eventdev.c
> index 532a253553..a31e99be02 100644
> --- a/lib/eventdev/rte_eventdev.c
> +++ b/lib/eventdev/rte_eventdev.c
> @@ -844,6 +844,32 @@ rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
>   	return 0;
>   }
>   
> +int
> +rte_event_queue_attr_set(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
> +			 uint64_t attr_value)
> +{
> +	struct rte_eventdev *dev;
> +
> +	RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
> +	dev = &rte_eventdevs[dev_id];
> +	if (!is_valid_queue(dev, queue_id)) {
> +		RTE_EDEV_LOG_ERR("Invalid queue_id=%" PRIu8, queue_id);
> +		return -EINVAL;
> +	}
> +
> +	if (!(dev->data->event_dev_cap &
> +	      RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR)) {
> +		RTE_EDEV_LOG_ERR(
> +			"Device %" PRIu8 "does not support changing queue attributes at runtime",
> +			dev_id);
> +		return -ENOTSUP;
> +	}
> +
> +	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_attr_set, -ENOTSUP);
> +	return (*dev->dev_ops->queue_attr_set)(dev, queue_id, attr_id,
> +					       attr_value);
> +}
> +
>   int
>   rte_event_port_link(uint8_t dev_id, uint8_t port_id,
>   		    const uint8_t queues[], const uint8_t priorities[],
> diff --git a/lib/eventdev/rte_eventdev.h b/lib/eventdev/rte_eventdev.h
> index 42a5660169..c1163ee8ec 100644
> --- a/lib/eventdev/rte_eventdev.h
> +++ b/lib/eventdev/rte_eventdev.h
> @@ -225,7 +225,7 @@ struct rte_event;
>   /**< Event scheduling prioritization is based on the priority associated with
>    *  each event queue.
>    *
> - *  @see rte_event_queue_setup()
> + *  @see rte_event_queue_setup(), rte_event_queue_attr_set()
>    */
>   #define RTE_EVENT_DEV_CAP_EVENT_QOS           (1ULL << 1)
>   /**< Event scheduling prioritization is based on the priority associated with
> @@ -307,6 +307,13 @@ struct rte_event;
>    * global pool, or process signaling related to load balancing.
>    */
>   
> +#define RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR (1ULL << 11)
> +/**< Event device is capable of changing the queue attributes at runtime i.e
> + * after rte_event_queue_setup() or rte_event_start() call sequence. If this
> + * flag is not set, eventdev queue attributes can only be configured during
> + * rte_event_queue_setup().
> + */
> +
>   /* Event device priority levels */
>   #define RTE_EVENT_DEV_PRIORITY_HIGHEST   0
>   /**< Highest priority expressed across eventdev subsystem
> @@ -702,6 +709,30 @@ int
>   rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
>   			uint32_t *attr_value);
>   
> +/**
> + * Set an event queue attribute.
> + *
> + * @param dev_id
> + *   Eventdev id
> + * @param queue_id
> + *   Eventdev queue id
> + * @param attr_id
> + *   The attribute ID to set
> + * @param attr_value
> + *   The attribute value to set
> + *
> + * @return
> + *   - 0: Successfully set attribute.
> + *   - -EINVAL: invalid device, queue or attr_id.
> + *   - -ENOTSUP: device does not support setting event attribute.
> + *   - -EBUSY: device is in running state

I thought the point of this new interface was to allow setting queue 
attributes when the event device was running?

It would be useful for the caller to be able to distinguish between 
"busy, but please try again later", and "busy, forever". Maybe the 
latter is what's meant here? In that case, what is the difference with 
EBUSY and ENOTSUP?

> + *   - <0: failed to set event queue attribute
> + */
> +__rte_experimental
> +int
> +rte_event_queue_attr_set(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
> +			 uint64_t attr_value);
> +
>   /* Event port specific APIs */
>   
>   /* Event port configuration bitmap flags */
> diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
> index cd5dada07f..c581b75c18 100644
> --- a/lib/eventdev/version.map
> +++ b/lib/eventdev/version.map
> @@ -108,6 +108,9 @@ EXPERIMENTAL {
>   
>   	# added in 22.03
>   	rte_event_eth_rx_adapter_event_port_get;
> +
> +	# added in 22.07
> +	rte_event_queue_attr_set;
>   };
>   
>   INTERNAL {
Shijith Thotton May 16, 2022, 3:57 a.m. UTC | #2
>> Added a new eventdev API rte_event_queue_attr_set(), to set event queue
>> attributes at runtime from the values set during initialization using
>> rte_event_queue_setup(). PMD's supporting this feature should expose the
>> capability RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR.
>>
>> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
>> Acked-by: Jerin Jacob <jerinj@marvell.com>
>> ---
>>   doc/guides/eventdevs/features/default.ini |  1 +
>>   doc/guides/rel_notes/release_22_07.rst    |  5 ++++
>>   lib/eventdev/eventdev_pmd.h               | 22 +++++++++++++++
>>   lib/eventdev/rte_eventdev.c               | 26 ++++++++++++++++++
>>   lib/eventdev/rte_eventdev.h               | 33 ++++++++++++++++++++++-
>>   lib/eventdev/version.map                  |  3 +++
>>   6 files changed, 89 insertions(+), 1 deletion(-)
>>
>> diff --git a/doc/guides/eventdevs/features/default.ini
>b/doc/guides/eventdevs/features/default.ini
>> index 2ea233463a..00360f60c6 100644
>> --- a/doc/guides/eventdevs/features/default.ini
>> +++ b/doc/guides/eventdevs/features/default.ini
>> @@ -17,6 +17,7 @@ runtime_port_link          =
>>   multiple_queue_port        =
>>   carry_flow_id              =
>>   maintenance_free           =
>> +runtime_queue_attr         =
>>
>>   ;
>>   ; Features of a default Ethernet Rx adapter.
>> diff --git a/doc/guides/rel_notes/release_22_07.rst
>b/doc/guides/rel_notes/release_22_07.rst
>> index 88d6e96cc1..a7a912d665 100644
>> --- a/doc/guides/rel_notes/release_22_07.rst
>> +++ b/doc/guides/rel_notes/release_22_07.rst
>> @@ -65,6 +65,11 @@ New Features
>>     * Added support for promiscuous mode on Windows.
>>     * Added support for MTU on Windows.
>>
>> +* **Added support for setting queue attributes at runtime in eventdev.**
>> +
>> +  Added new API ``rte_event_queue_attr_set()``, to set event queue
>attributes
>> +  at runtime.
>> +
>>
>>   Removed Items
>>   -------------
>> diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
>> index ce469d47a6..3b85d9f7a5 100644
>> --- a/lib/eventdev/eventdev_pmd.h
>> +++ b/lib/eventdev/eventdev_pmd.h
>> @@ -341,6 +341,26 @@ typedef int (*eventdev_queue_setup_t)(struct
>rte_eventdev *dev,
>>   typedef void (*eventdev_queue_release_t)(struct rte_eventdev *dev,
>>   		uint8_t queue_id);
>>
>> +/**
>> + * Set an event queue attribute at runtime.
>> + *
>> + * @param dev
>> + *   Event device pointer
>> + * @param queue_id
>> + *   Event queue index
>> + * @param attr_id
>> + *   Event queue attribute id
>> + * @param attr_value
>> + *   Event queue attribute value
>> + *
>> + * @return
>> + *  - 0: Success.
>> + *  - <0: Error code on failure.
>> + */
>> +typedef int (*eventdev_queue_attr_set_t)(struct rte_eventdev *dev,
>> +					 uint8_t queue_id, uint32_t attr_id,
>> +					 uint64_t attr_value);
>> +
>>   /**
>>    * Retrieve the default event port configuration.
>>    *
>> @@ -1211,6 +1231,8 @@ struct eventdev_ops {
>>   	/**< Set up an event queue. */
>>   	eventdev_queue_release_t queue_release;
>>   	/**< Release an event queue. */
>> +	eventdev_queue_attr_set_t queue_attr_set;
>> +	/**< Set an event queue attribute. */
>>
>>   	eventdev_port_default_conf_get_t port_def_conf;
>>   	/**< Get default port configuration. */
>> diff --git a/lib/eventdev/rte_eventdev.c b/lib/eventdev/rte_eventdev.c
>> index 532a253553..a31e99be02 100644
>> --- a/lib/eventdev/rte_eventdev.c
>> +++ b/lib/eventdev/rte_eventdev.c
>> @@ -844,6 +844,32 @@ rte_event_queue_attr_get(uint8_t dev_id, uint8_t
>queue_id, uint32_t attr_id,
>>   	return 0;
>>   }
>>
>> +int
>> +rte_event_queue_attr_set(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
>> +			 uint64_t attr_value)
>> +{
>> +	struct rte_eventdev *dev;
>> +
>> +	RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
>> +	dev = &rte_eventdevs[dev_id];
>> +	if (!is_valid_queue(dev, queue_id)) {
>> +		RTE_EDEV_LOG_ERR("Invalid queue_id=%" PRIu8, queue_id);
>> +		return -EINVAL;
>> +	}
>> +
>> +	if (!(dev->data->event_dev_cap &
>> +	      RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR)) {
>> +		RTE_EDEV_LOG_ERR(
>> +			"Device %" PRIu8 "does not support changing queue
>attributes at runtime",
>> +			dev_id);
>> +		return -ENOTSUP;
>> +	}
>> +
>> +	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_attr_set, -
>ENOTSUP);
>> +	return (*dev->dev_ops->queue_attr_set)(dev, queue_id, attr_id,
>> +					       attr_value);
>> +}
>> +
>>   int
>>   rte_event_port_link(uint8_t dev_id, uint8_t port_id,
>>   		    const uint8_t queues[], const uint8_t priorities[],
>> diff --git a/lib/eventdev/rte_eventdev.h b/lib/eventdev/rte_eventdev.h
>> index 42a5660169..c1163ee8ec 100644
>> --- a/lib/eventdev/rte_eventdev.h
>> +++ b/lib/eventdev/rte_eventdev.h
>> @@ -225,7 +225,7 @@ struct rte_event;
>>   /**< Event scheduling prioritization is based on the priority associated with
>>    *  each event queue.
>>    *
>> - *  @see rte_event_queue_setup()
>> + *  @see rte_event_queue_setup(), rte_event_queue_attr_set()
>>    */
>>   #define RTE_EVENT_DEV_CAP_EVENT_QOS           (1ULL << 1)
>>   /**< Event scheduling prioritization is based on the priority associated with
>> @@ -307,6 +307,13 @@ struct rte_event;
>>    * global pool, or process signaling related to load balancing.
>>    */
>>
>> +#define RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR (1ULL << 11)
>> +/**< Event device is capable of changing the queue attributes at runtime i.e
>> + * after rte_event_queue_setup() or rte_event_start() call sequence. If this
>> + * flag is not set, eventdev queue attributes can only be configured during
>> + * rte_event_queue_setup().
>> + */
>> +
>>   /* Event device priority levels */
>>   #define RTE_EVENT_DEV_PRIORITY_HIGHEST   0
>>   /**< Highest priority expressed across eventdev subsystem
>> @@ -702,6 +709,30 @@ int
>>   rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
>>   			uint32_t *attr_value);
>>
>> +/**
>> + * Set an event queue attribute.
>> + *
>> + * @param dev_id
>> + *   Eventdev id
>> + * @param queue_id
>> + *   Eventdev queue id
>> + * @param attr_id
>> + *   The attribute ID to set
>> + * @param attr_value
>> + *   The attribute value to set
>> + *
>> + * @return
>> + *   - 0: Successfully set attribute.
>> + *   - -EINVAL: invalid device, queue or attr_id.
>> + *   - -ENOTSUP: device does not support setting event attribute.
>> + *   - -EBUSY: device is in running state
>
>I thought the point of this new interface was to allow setting queue
>attributes when the event device was running?
>
>It would be useful for the caller to be able to distinguish between
>"busy, but please try again later", and "busy, forever". Maybe the
>latter is what's meant here? In that case, what is the difference with
>EBUSY and ENOTSUP?
>

As there are multiple queue attributes, not all attributes could be supported by
all PMDs. ENOTSUP can be returned for unsupported attributes.

>> + *   - <0: failed to set event queue attribute
>> + */
>> +__rte_experimental
>> +int
>> +rte_event_queue_attr_set(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
>> +			 uint64_t attr_value);
>> +
>>   /* Event port specific APIs */
>>
>>   /* Event port configuration bitmap flags */
>> diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
>> index cd5dada07f..c581b75c18 100644
>> --- a/lib/eventdev/version.map
>> +++ b/lib/eventdev/version.map
>> @@ -108,6 +108,9 @@ EXPERIMENTAL {
>>
>>   	# added in 22.03
>>   	rte_event_eth_rx_adapter_event_port_get;
>> +
>> +	# added in 22.07
>> +	rte_event_queue_attr_set;
>>   };
>>
>>   INTERNAL {
Mattias Rönnblom May 16, 2022, 10:23 a.m. UTC | #3
On 2022-05-16 05:57, Shijith Thotton wrote:
>>> Added a new eventdev API rte_event_queue_attr_set(), to set event queue
>>> attributes at runtime from the values set during initialization using
>>> rte_event_queue_setup(). PMD's supporting this feature should expose the
>>> capability RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR.
>>>
>>> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
>>> Acked-by: Jerin Jacob <jerinj@marvell.com>
>>> ---
>>>    doc/guides/eventdevs/features/default.ini |  1 +
>>>    doc/guides/rel_notes/release_22_07.rst    |  5 ++++
>>>    lib/eventdev/eventdev_pmd.h               | 22 +++++++++++++++
>>>    lib/eventdev/rte_eventdev.c               | 26 ++++++++++++++++++
>>>    lib/eventdev/rte_eventdev.h               | 33 ++++++++++++++++++++++-
>>>    lib/eventdev/version.map                  |  3 +++
>>>    6 files changed, 89 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/doc/guides/eventdevs/features/default.ini
>> b/doc/guides/eventdevs/features/default.ini
>>> index 2ea233463a..00360f60c6 100644
>>> --- a/doc/guides/eventdevs/features/default.ini
>>> +++ b/doc/guides/eventdevs/features/default.ini
>>> @@ -17,6 +17,7 @@ runtime_port_link          =
>>>    multiple_queue_port        =
>>>    carry_flow_id              =
>>>    maintenance_free           =
>>> +runtime_queue_attr         =
>>>
>>>    ;
>>>    ; Features of a default Ethernet Rx adapter.
>>> diff --git a/doc/guides/rel_notes/release_22_07.rst
>> b/doc/guides/rel_notes/release_22_07.rst
>>> index 88d6e96cc1..a7a912d665 100644
>>> --- a/doc/guides/rel_notes/release_22_07.rst
>>> +++ b/doc/guides/rel_notes/release_22_07.rst
>>> @@ -65,6 +65,11 @@ New Features
>>>      * Added support for promiscuous mode on Windows.
>>>      * Added support for MTU on Windows.
>>>
>>> +* **Added support for setting queue attributes at runtime in eventdev.**
>>> +
>>> +  Added new API ``rte_event_queue_attr_set()``, to set event queue
>> attributes
>>> +  at runtime.
>>> +
>>>
>>>    Removed Items
>>>    -------------
>>> diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
>>> index ce469d47a6..3b85d9f7a5 100644
>>> --- a/lib/eventdev/eventdev_pmd.h
>>> +++ b/lib/eventdev/eventdev_pmd.h
>>> @@ -341,6 +341,26 @@ typedef int (*eventdev_queue_setup_t)(struct
>> rte_eventdev *dev,
>>>    typedef void (*eventdev_queue_release_t)(struct rte_eventdev *dev,
>>>    		uint8_t queue_id);
>>>
>>> +/**
>>> + * Set an event queue attribute at runtime.
>>> + *
>>> + * @param dev
>>> + *   Event device pointer
>>> + * @param queue_id
>>> + *   Event queue index
>>> + * @param attr_id
>>> + *   Event queue attribute id
>>> + * @param attr_value
>>> + *   Event queue attribute value
>>> + *
>>> + * @return
>>> + *  - 0: Success.
>>> + *  - <0: Error code on failure.
>>> + */
>>> +typedef int (*eventdev_queue_attr_set_t)(struct rte_eventdev *dev,
>>> +					 uint8_t queue_id, uint32_t attr_id,
>>> +					 uint64_t attr_value);
>>> +
>>>    /**
>>>     * Retrieve the default event port configuration.
>>>     *
>>> @@ -1211,6 +1231,8 @@ struct eventdev_ops {
>>>    	/**< Set up an event queue. */
>>>    	eventdev_queue_release_t queue_release;
>>>    	/**< Release an event queue. */
>>> +	eventdev_queue_attr_set_t queue_attr_set;
>>> +	/**< Set an event queue attribute. */
>>>
>>>    	eventdev_port_default_conf_get_t port_def_conf;
>>>    	/**< Get default port configuration. */
>>> diff --git a/lib/eventdev/rte_eventdev.c b/lib/eventdev/rte_eventdev.c
>>> index 532a253553..a31e99be02 100644
>>> --- a/lib/eventdev/rte_eventdev.c
>>> +++ b/lib/eventdev/rte_eventdev.c
>>> @@ -844,6 +844,32 @@ rte_event_queue_attr_get(uint8_t dev_id, uint8_t
>> queue_id, uint32_t attr_id,
>>>    	return 0;
>>>    }
>>>
>>> +int
>>> +rte_event_queue_attr_set(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
>>> +			 uint64_t attr_value)
>>> +{
>>> +	struct rte_eventdev *dev;
>>> +
>>> +	RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
>>> +	dev = &rte_eventdevs[dev_id];
>>> +	if (!is_valid_queue(dev, queue_id)) {
>>> +		RTE_EDEV_LOG_ERR("Invalid queue_id=%" PRIu8, queue_id);
>>> +		return -EINVAL;
>>> +	}
>>> +
>>> +	if (!(dev->data->event_dev_cap &
>>> +	      RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR)) {
>>> +		RTE_EDEV_LOG_ERR(
>>> +			"Device %" PRIu8 "does not support changing queue
>> attributes at runtime",
>>> +			dev_id);
>>> +		return -ENOTSUP;
>>> +	}
>>> +
>>> +	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_attr_set, -
>> ENOTSUP);
>>> +	return (*dev->dev_ops->queue_attr_set)(dev, queue_id, attr_id,
>>> +					       attr_value);
>>> +}
>>> +
>>>    int
>>>    rte_event_port_link(uint8_t dev_id, uint8_t port_id,
>>>    		    const uint8_t queues[], const uint8_t priorities[],
>>> diff --git a/lib/eventdev/rte_eventdev.h b/lib/eventdev/rte_eventdev.h
>>> index 42a5660169..c1163ee8ec 100644
>>> --- a/lib/eventdev/rte_eventdev.h
>>> +++ b/lib/eventdev/rte_eventdev.h
>>> @@ -225,7 +225,7 @@ struct rte_event;
>>>    /**< Event scheduling prioritization is based on the priority associated with
>>>     *  each event queue.
>>>     *
>>> - *  @see rte_event_queue_setup()
>>> + *  @see rte_event_queue_setup(), rte_event_queue_attr_set()
>>>     */
>>>    #define RTE_EVENT_DEV_CAP_EVENT_QOS           (1ULL << 1)
>>>    /**< Event scheduling prioritization is based on the priority associated with
>>> @@ -307,6 +307,13 @@ struct rte_event;
>>>     * global pool, or process signaling related to load balancing.
>>>     */
>>>
>>> +#define RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR (1ULL << 11)
>>> +/**< Event device is capable of changing the queue attributes at runtime i.e
>>> + * after rte_event_queue_setup() or rte_event_start() call sequence. If this
>>> + * flag is not set, eventdev queue attributes can only be configured during
>>> + * rte_event_queue_setup().
>>> + */
>>> +
>>>    /* Event device priority levels */
>>>    #define RTE_EVENT_DEV_PRIORITY_HIGHEST   0
>>>    /**< Highest priority expressed across eventdev subsystem
>>> @@ -702,6 +709,30 @@ int
>>>    rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
>>>    			uint32_t *attr_value);
>>>
>>> +/**
>>> + * Set an event queue attribute.
>>> + *
>>> + * @param dev_id
>>> + *   Eventdev id
>>> + * @param queue_id
>>> + *   Eventdev queue id
>>> + * @param attr_id
>>> + *   The attribute ID to set
>>> + * @param attr_value
>>> + *   The attribute value to set
>>> + *
>>> + * @return
>>> + *   - 0: Successfully set attribute.
>>> + *   - -EINVAL: invalid device, queue or attr_id.

Can "invalid" here be something else than "non-existent"?

>>> + *   - -ENOTSUP: device does not support setting event attribute.
>>> + *   - -EBUSY: device is in running state
>>
>> I thought the point of this new interface was to allow setting queue
>> attributes when the event device was running?
>>
>> It would be useful for the caller to be able to distinguish between
>> "busy, but please try again later", and "busy, forever". Maybe the
>> latter is what's meant here? In that case, what is the difference with
>> EBUSY and ENOTSUP?
>>
> 
> As there are multiple queue attributes, not all attributes could be supported by
> all PMDs. ENOTSUP can be returned for unsupported attributes.
> 

So ENOTSUP means this particular attribute exists, but can't be change 
in runtime? Is ENOTSUP returned also if no attributes can be modified 
(i.e., the event device does not have the appropriate capability)?

How is the application supposed to behaved in case -EBUSY is returned? 
What does -EBUSY mean? The event device being in a running state doesn't 
sound like an error to me.


>>> + *   - <0: failed to set event queue attribute
>>> + */
>>> +__rte_experimental
>>> +int
>>> +rte_event_queue_attr_set(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
>>> +			 uint64_t attr_value);
>>> +
>>>    /* Event port specific APIs */
>>>
>>>    /* Event port configuration bitmap flags */
>>> diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
>>> index cd5dada07f..c581b75c18 100644
>>> --- a/lib/eventdev/version.map
>>> +++ b/lib/eventdev/version.map
>>> @@ -108,6 +108,9 @@ EXPERIMENTAL {
>>>
>>>    	# added in 22.03
>>>    	rte_event_eth_rx_adapter_event_port_get;
>>> +
>>> +	# added in 22.07
>>> +	rte_event_queue_attr_set;
>>>    };
>>>
>>>    INTERNAL {
>
Shijith Thotton May 16, 2022, 12:12 p.m. UTC | #4
>>>> Added a new eventdev API rte_event_queue_attr_set(), to set event queue
>>>> attributes at runtime from the values set during initialization using
>>>> rte_event_queue_setup(). PMD's supporting this feature should expose the
>>>> capability RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR.
>>>>
>>>> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
>>>> Acked-by: Jerin Jacob <jerinj@marvell.com>
>>>> ---
>>>>    doc/guides/eventdevs/features/default.ini |  1 +
>>>>    doc/guides/rel_notes/release_22_07.rst    |  5 ++++
>>>>    lib/eventdev/eventdev_pmd.h               | 22 +++++++++++++++
>>>>    lib/eventdev/rte_eventdev.c               | 26 ++++++++++++++++++
>>>>    lib/eventdev/rte_eventdev.h               | 33 ++++++++++++++++++++++-
>>>>    lib/eventdev/version.map                  |  3 +++
>>>>    6 files changed, 89 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/doc/guides/eventdevs/features/default.ini
>>> b/doc/guides/eventdevs/features/default.ini
>>>> index 2ea233463a..00360f60c6 100644
>>>> --- a/doc/guides/eventdevs/features/default.ini
>>>> +++ b/doc/guides/eventdevs/features/default.ini
>>>> @@ -17,6 +17,7 @@ runtime_port_link          =
>>>>    multiple_queue_port        =
>>>>    carry_flow_id              =
>>>>    maintenance_free           =
>>>> +runtime_queue_attr         =
>>>>
>>>>    ;
>>>>    ; Features of a default Ethernet Rx adapter.
>>>> diff --git a/doc/guides/rel_notes/release_22_07.rst
>>> b/doc/guides/rel_notes/release_22_07.rst
>>>> index 88d6e96cc1..a7a912d665 100644
>>>> --- a/doc/guides/rel_notes/release_22_07.rst
>>>> +++ b/doc/guides/rel_notes/release_22_07.rst
>>>> @@ -65,6 +65,11 @@ New Features
>>>>      * Added support for promiscuous mode on Windows.
>>>>      * Added support for MTU on Windows.
>>>>
>>>> +* **Added support for setting queue attributes at runtime in eventdev.**
>>>> +
>>>> +  Added new API ``rte_event_queue_attr_set()``, to set event queue
>>> attributes
>>>> +  at runtime.
>>>> +
>>>>
>>>>    Removed Items
>>>>    -------------
>>>> diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
>>>> index ce469d47a6..3b85d9f7a5 100644
>>>> --- a/lib/eventdev/eventdev_pmd.h
>>>> +++ b/lib/eventdev/eventdev_pmd.h
>>>> @@ -341,6 +341,26 @@ typedef int (*eventdev_queue_setup_t)(struct
>>> rte_eventdev *dev,
>>>>    typedef void (*eventdev_queue_release_t)(struct rte_eventdev *dev,
>>>>    		uint8_t queue_id);
>>>>
>>>> +/**
>>>> + * Set an event queue attribute at runtime.
>>>> + *
>>>> + * @param dev
>>>> + *   Event device pointer
>>>> + * @param queue_id
>>>> + *   Event queue index
>>>> + * @param attr_id
>>>> + *   Event queue attribute id
>>>> + * @param attr_value
>>>> + *   Event queue attribute value
>>>> + *
>>>> + * @return
>>>> + *  - 0: Success.
>>>> + *  - <0: Error code on failure.
>>>> + */
>>>> +typedef int (*eventdev_queue_attr_set_t)(struct rte_eventdev *dev,
>>>> +					 uint8_t queue_id, uint32_t attr_id,
>>>> +					 uint64_t attr_value);
>>>> +
>>>>    /**
>>>>     * Retrieve the default event port configuration.
>>>>     *
>>>> @@ -1211,6 +1231,8 @@ struct eventdev_ops {
>>>>    	/**< Set up an event queue. */
>>>>    	eventdev_queue_release_t queue_release;
>>>>    	/**< Release an event queue. */
>>>> +	eventdev_queue_attr_set_t queue_attr_set;
>>>> +	/**< Set an event queue attribute. */
>>>>
>>>>    	eventdev_port_default_conf_get_t port_def_conf;
>>>>    	/**< Get default port configuration. */
>>>> diff --git a/lib/eventdev/rte_eventdev.c b/lib/eventdev/rte_eventdev.c
>>>> index 532a253553..a31e99be02 100644
>>>> --- a/lib/eventdev/rte_eventdev.c
>>>> +++ b/lib/eventdev/rte_eventdev.c
>>>> @@ -844,6 +844,32 @@ rte_event_queue_attr_get(uint8_t dev_id, uint8_t
>>> queue_id, uint32_t attr_id,
>>>>    	return 0;
>>>>    }
>>>>
>>>> +int
>>>> +rte_event_queue_attr_set(uint8_t dev_id, uint8_t queue_id, uint32_t
>attr_id,
>>>> +			 uint64_t attr_value)
>>>> +{
>>>> +	struct rte_eventdev *dev;
>>>> +
>>>> +	RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
>>>> +	dev = &rte_eventdevs[dev_id];
>>>> +	if (!is_valid_queue(dev, queue_id)) {
>>>> +		RTE_EDEV_LOG_ERR("Invalid queue_id=%" PRIu8, queue_id);
>>>> +		return -EINVAL;
>>>> +	}
>>>> +
>>>> +	if (!(dev->data->event_dev_cap &
>>>> +	      RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR)) {
>>>> +		RTE_EDEV_LOG_ERR(
>>>> +			"Device %" PRIu8 "does not support changing queue
>>> attributes at runtime",
>>>> +			dev_id);
>>>> +		return -ENOTSUP;
>>>> +	}
>>>> +
>>>> +	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_attr_set, -
>>> ENOTSUP);
>>>> +	return (*dev->dev_ops->queue_attr_set)(dev, queue_id, attr_id,
>>>> +					       attr_value);
>>>> +}
>>>> +
>>>>    int
>>>>    rte_event_port_link(uint8_t dev_id, uint8_t port_id,
>>>>    		    const uint8_t queues[], const uint8_t priorities[],
>>>> diff --git a/lib/eventdev/rte_eventdev.h b/lib/eventdev/rte_eventdev.h
>>>> index 42a5660169..c1163ee8ec 100644
>>>> --- a/lib/eventdev/rte_eventdev.h
>>>> +++ b/lib/eventdev/rte_eventdev.h
>>>> @@ -225,7 +225,7 @@ struct rte_event;
>>>>    /**< Event scheduling prioritization is based on the priority associated with
>>>>     *  each event queue.
>>>>     *
>>>> - *  @see rte_event_queue_setup()
>>>> + *  @see rte_event_queue_setup(), rte_event_queue_attr_set()
>>>>     */
>>>>    #define RTE_EVENT_DEV_CAP_EVENT_QOS           (1ULL << 1)
>>>>    /**< Event scheduling prioritization is based on the priority associated with
>>>> @@ -307,6 +307,13 @@ struct rte_event;
>>>>     * global pool, or process signaling related to load balancing.
>>>>     */
>>>>
>>>> +#define RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR (1ULL << 11)
>>>> +/**< Event device is capable of changing the queue attributes at runtime i.e
>>>> + * after rte_event_queue_setup() or rte_event_start() call sequence. If this
>>>> + * flag is not set, eventdev queue attributes can only be configured during
>>>> + * rte_event_queue_setup().
>>>> + */
>>>> +
>>>>    /* Event device priority levels */
>>>>    #define RTE_EVENT_DEV_PRIORITY_HIGHEST   0
>>>>    /**< Highest priority expressed across eventdev subsystem
>>>> @@ -702,6 +709,30 @@ int
>>>>    rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t
>attr_id,
>>>>    			uint32_t *attr_value);
>>>>
>>>> +/**
>>>> + * Set an event queue attribute.
>>>> + *
>>>> + * @param dev_id
>>>> + *   Eventdev id
>>>> + * @param queue_id
>>>> + *   Eventdev queue id
>>>> + * @param attr_id
>>>> + *   The attribute ID to set
>>>> + * @param attr_value
>>>> + *   The attribute value to set
>>>> + *
>>>> + * @return
>>>> + *   - 0: Successfully set attribute.
>>>> + *   - -EINVAL: invalid device, queue or attr_id.
>
>Can "invalid" here be something else than "non-existent"?
>

No. 

>>>> + *   - -ENOTSUP: device does not support setting event attribute.
>>>> + *   - -EBUSY: device is in running state
>>>
>>> I thought the point of this new interface was to allow setting queue
>>> attributes when the event device was running?
>>>
>>> It would be useful for the caller to be able to distinguish between
>>> "busy, but please try again later", and "busy, forever". Maybe the
>>> latter is what's meant here? In that case, what is the difference with
>>> EBUSY and ENOTSUP?
>>>
>>
>> As there are multiple queue attributes, not all attributes could be supported by
>> all PMDs. ENOTSUP can be returned for unsupported attributes.
>>
>
>So ENOTSUP means this particular attribute exists, but can't be change
>in runtime?

Yes. If the attribute doesn’t exist, EINVAL is returned.

> Is ENOTSUP returned also if no attributes can be modified
>(i.e., the event device does not have the appropriate capability)?
>

Yes. Application should also be checking the eventdev capability
RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR before calling this API.

>How is the application supposed to behaved in case -EBUSY is returned?
>What does -EBUSY mean? The event device being in a running state doesn't
>sound like an error to me.
>
 
EBUSY was added to indicate the device was busy and was unable to set the
attribute at that time. I think, it can be removed as it is causing confusion.
Please let me know if it make sense, I will send v4.

>
>>>> + *   - <0: failed to set event queue attribute
>>>> + */
>>>> +__rte_experimental
>>>> +int
>>>> +rte_event_queue_attr_set(uint8_t dev_id, uint8_t queue_id, uint32_t
>attr_id,
>>>> +			 uint64_t attr_value);
>>>> +
>>>>    /* Event port specific APIs */
>>>>
>>>>    /* Event port configuration bitmap flags */
>>>> diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
>>>> index cd5dada07f..c581b75c18 100644
>>>> --- a/lib/eventdev/version.map
>>>> +++ b/lib/eventdev/version.map
>>>> @@ -108,6 +108,9 @@ EXPERIMENTAL {
>>>>
>>>>    	# added in 22.03
>>>>    	rte_event_eth_rx_adapter_event_port_get;
>>>> +
>>>> +	# added in 22.07
>>>> +	rte_event_queue_attr_set;
>>>>    };
>>>>
>>>>    INTERNAL {
>>
diff mbox series

Patch

diff --git a/doc/guides/eventdevs/features/default.ini b/doc/guides/eventdevs/features/default.ini
index 2ea233463a..00360f60c6 100644
--- a/doc/guides/eventdevs/features/default.ini
+++ b/doc/guides/eventdevs/features/default.ini
@@ -17,6 +17,7 @@  runtime_port_link          =
 multiple_queue_port        =
 carry_flow_id              =
 maintenance_free           =
+runtime_queue_attr         =
 
 ;
 ; Features of a default Ethernet Rx adapter.
diff --git a/doc/guides/rel_notes/release_22_07.rst b/doc/guides/rel_notes/release_22_07.rst
index 88d6e96cc1..a7a912d665 100644
--- a/doc/guides/rel_notes/release_22_07.rst
+++ b/doc/guides/rel_notes/release_22_07.rst
@@ -65,6 +65,11 @@  New Features
   * Added support for promiscuous mode on Windows.
   * Added support for MTU on Windows.
 
+* **Added support for setting queue attributes at runtime in eventdev.**
+
+  Added new API ``rte_event_queue_attr_set()``, to set event queue attributes
+  at runtime.
+
 
 Removed Items
 -------------
diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
index ce469d47a6..3b85d9f7a5 100644
--- a/lib/eventdev/eventdev_pmd.h
+++ b/lib/eventdev/eventdev_pmd.h
@@ -341,6 +341,26 @@  typedef int (*eventdev_queue_setup_t)(struct rte_eventdev *dev,
 typedef void (*eventdev_queue_release_t)(struct rte_eventdev *dev,
 		uint8_t queue_id);
 
+/**
+ * Set an event queue attribute at runtime.
+ *
+ * @param dev
+ *   Event device pointer
+ * @param queue_id
+ *   Event queue index
+ * @param attr_id
+ *   Event queue attribute id
+ * @param attr_value
+ *   Event queue attribute value
+ *
+ * @return
+ *  - 0: Success.
+ *  - <0: Error code on failure.
+ */
+typedef int (*eventdev_queue_attr_set_t)(struct rte_eventdev *dev,
+					 uint8_t queue_id, uint32_t attr_id,
+					 uint64_t attr_value);
+
 /**
  * Retrieve the default event port configuration.
  *
@@ -1211,6 +1231,8 @@  struct eventdev_ops {
 	/**< Set up an event queue. */
 	eventdev_queue_release_t queue_release;
 	/**< Release an event queue. */
+	eventdev_queue_attr_set_t queue_attr_set;
+	/**< Set an event queue attribute. */
 
 	eventdev_port_default_conf_get_t port_def_conf;
 	/**< Get default port configuration. */
diff --git a/lib/eventdev/rte_eventdev.c b/lib/eventdev/rte_eventdev.c
index 532a253553..a31e99be02 100644
--- a/lib/eventdev/rte_eventdev.c
+++ b/lib/eventdev/rte_eventdev.c
@@ -844,6 +844,32 @@  rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
 	return 0;
 }
 
+int
+rte_event_queue_attr_set(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
+			 uint64_t attr_value)
+{
+	struct rte_eventdev *dev;
+
+	RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
+	dev = &rte_eventdevs[dev_id];
+	if (!is_valid_queue(dev, queue_id)) {
+		RTE_EDEV_LOG_ERR("Invalid queue_id=%" PRIu8, queue_id);
+		return -EINVAL;
+	}
+
+	if (!(dev->data->event_dev_cap &
+	      RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR)) {
+		RTE_EDEV_LOG_ERR(
+			"Device %" PRIu8 "does not support changing queue attributes at runtime",
+			dev_id);
+		return -ENOTSUP;
+	}
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_attr_set, -ENOTSUP);
+	return (*dev->dev_ops->queue_attr_set)(dev, queue_id, attr_id,
+					       attr_value);
+}
+
 int
 rte_event_port_link(uint8_t dev_id, uint8_t port_id,
 		    const uint8_t queues[], const uint8_t priorities[],
diff --git a/lib/eventdev/rte_eventdev.h b/lib/eventdev/rte_eventdev.h
index 42a5660169..c1163ee8ec 100644
--- a/lib/eventdev/rte_eventdev.h
+++ b/lib/eventdev/rte_eventdev.h
@@ -225,7 +225,7 @@  struct rte_event;
 /**< Event scheduling prioritization is based on the priority associated with
  *  each event queue.
  *
- *  @see rte_event_queue_setup()
+ *  @see rte_event_queue_setup(), rte_event_queue_attr_set()
  */
 #define RTE_EVENT_DEV_CAP_EVENT_QOS           (1ULL << 1)
 /**< Event scheduling prioritization is based on the priority associated with
@@ -307,6 +307,13 @@  struct rte_event;
  * global pool, or process signaling related to load balancing.
  */
 
+#define RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR (1ULL << 11)
+/**< Event device is capable of changing the queue attributes at runtime i.e
+ * after rte_event_queue_setup() or rte_event_start() call sequence. If this
+ * flag is not set, eventdev queue attributes can only be configured during
+ * rte_event_queue_setup().
+ */
+
 /* Event device priority levels */
 #define RTE_EVENT_DEV_PRIORITY_HIGHEST   0
 /**< Highest priority expressed across eventdev subsystem
@@ -702,6 +709,30 @@  int
 rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
 			uint32_t *attr_value);
 
+/**
+ * Set an event queue attribute.
+ *
+ * @param dev_id
+ *   Eventdev id
+ * @param queue_id
+ *   Eventdev queue id
+ * @param attr_id
+ *   The attribute ID to set
+ * @param attr_value
+ *   The attribute value to set
+ *
+ * @return
+ *   - 0: Successfully set attribute.
+ *   - -EINVAL: invalid device, queue or attr_id.
+ *   - -ENOTSUP: device does not support setting event attribute.
+ *   - -EBUSY: device is in running state
+ *   - <0: failed to set event queue attribute
+ */
+__rte_experimental
+int
+rte_event_queue_attr_set(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
+			 uint64_t attr_value);
+
 /* Event port specific APIs */
 
 /* Event port configuration bitmap flags */
diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
index cd5dada07f..c581b75c18 100644
--- a/lib/eventdev/version.map
+++ b/lib/eventdev/version.map
@@ -108,6 +108,9 @@  EXPERIMENTAL {
 
 	# added in 22.03
 	rte_event_eth_rx_adapter_event_port_get;
+
+	# added in 22.07
+	rte_event_queue_attr_set;
 };
 
 INTERNAL {