Extend port and queue attribute get functions
cover Extend port and queue attribute get functions
This patchset makes the full queue and port configuration structures accessible through the attribute get functions, adds tests for the new attributes, and fixes one bug in a port attribute get test.
This patchset is based on patches 29019 through 29023.
Gage Eads (3):
eventdev: extend queue attribute get function
eventdev: extend port attribute get function test/eventdev: fix bug in port enqueue depth test
lib/librte_eventdev/rte_eventdev.c | 125 ++++++++++++-------------- lib/librte_eventdev/rte_eventdev.h | 26 ++++-- test/test/test_eventdev.c | 179 +++++++++++++++++++++++++++++++++++-- 3 files changed, 245 insertions(+), 85 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/3 eventdev: extend queue attribute get function
This commit adds three new queue attributes, so that the entire queue configuration structure passed to rte_event_queue_setup can be queried.
--- lib/librte_eventdev/rte_eventdev.c | 54 +++++++++------ lib/librte_eventdev/rte_eventdev.h | 16 ++++- test/test/test_eventdev.c | 138 ++++++++++++++++++++++++++++++++++++- 3 files changed, 183 insertions(+), 25 deletions(-)
lib/librte_eventdev/rte_eventdev.c +33 -21
@@ -132,51 +132,51 @@ static inline int rte_event_dev_queue_config(struct rte_eventdev *dev, uint8_t nb_queues) { uint8_t old_nb_queues = dev->data->nb_queues; -uint8_t *queues_prio; +struct rte_event_queue_conf *queues_cfg;unsigned int i;RTE_EDEV_LOG_DEBUG ("Setup %d queues on device %u" , nb_queues, dev->data->dev_id);/* First time configuration */ -if (dev->data->queues_prio ==NULL && nb_queues !=0 ) { -/* Allocate memory to store queue priority */ - dev->data->queues_prio =rte_zmalloc_socket ( -"eventdev->data->queues_prio" , -sizeof (dev->data->queues_prio[0 ]) * nb_queues, +if (dev->data->queues_cfg ==NULL && nb_queues !=0 ) { +/* Allocate memory to store queue configuration */ + dev->data->queues_cfg =rte_zmalloc_socket ( +"eventdev->data->queues_cfg" , +sizeof (dev->data->queues_cfg[0 ]) * nb_queues,RTE_CACHE_LINE_SIZE , dev->data->socket_id); -if (dev->data->queues_prio ==NULL ) { +if (dev->data->queues_cfg ==NULL ) { dev->data->nb_queues =0 ; -RTE_EDEV_LOG_ERR ("failed to get mem for queue priority," +RTE_EDEV_LOG_ERR ("failed to get mem for queue cfg," "nb_queues %u" , nb_queues);return -(ENOMEM ); }/* Re-configure */ - }else if (dev->data->queues_prio !=NULL && nb_queues !=0 ) { + }else if (dev->data->queues_cfg !=NULL && nb_queues !=0 ) {RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->queue_release, -ENOTSUP );for (i = nb_queues; i < old_nb_queues; i++) (*dev->dev_ops->queue_release)(dev, i); -/* Re allocate memory to store queue priority */ - queues_prio = dev->data->queues_prio; - queues_prio =rte_realloc (queues_prio, -sizeof (queues_prio[0 ]) * nb_queues, +/* Re allocate memory to store queue configuration */ + queues_cfg = dev->data->queues_cfg; + queues_cfg =rte_realloc (queues_cfg, +sizeof (queues_cfg[0 ]) * nb_queues,RTE_CACHE_LINE_SIZE ); -if (queues_prio ==NULL ) { -RTE_EDEV_LOG_ERR ("failed to realloc queue priority," +if (queues_cfg ==NULL ) { +RTE_EDEV_LOG_ERR ("failed to realloc queue cfg memory," " nb_queues %u" , nb_queues);return -(ENOMEM ); } - dev->data->queues_prio = queues_prio; + dev->data->queues_cfg = queues_cfg;if (nb_queues > old_nb_queues) {uint8_t new_qs = nb_queues - old_nb_queues; -memset (queues_prio + old_nb_queues,0 , -sizeof (queues_prio[0 ]) * new_qs); +memset (queues_cfg + old_nb_queues,0 , +sizeof (queues_cfg[0 ]) * new_qs); } - }else if (dev->data->queues_prio !=NULL && nb_queues ==0 ) { + }else if (dev->data->queues_cfg !=NULL && nb_queues ==0 ) {RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->queue_release, -ENOTSUP );for (i = nb_queues; i < old_nb_queues; i++)
@@ -609,7 +609,7 @@ rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id, queue_conf = &def_conf; } - dev->data->queues_prio[queue_id] = queue_conf->priority; + dev->data->queues_cfg[queue_id] = *queue_conf;return (*dev->dev_ops->queue_setup)(dev, queue_id, queue_conf); }
@@ -787,6 +787,7 @@ int rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id, uint32_t *attr_value) { + struct rte_event_queue_conf *conf;struct rte_eventdev *dev;if (!attr_value)
@@ -799,11 +800,22 @@ rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,return -EINVAL ; } + conf = &dev->data->queues_cfg[queue_id]; +switch (attr_id) {case RTE_EVENT_QUEUE_ATTR_PRIORITY : *attr_value =RTE_EVENT_DEV_PRIORITY_NORMAL ;if (dev->data->event_dev_cap &RTE_EVENT_DEV_CAP_QUEUE_QOS ) - *attr_value = dev->data->queues_prio[queue_id]; + *attr_value = conf->priority; +break ; +case RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_FLOWS : + *attr_value = conf->nb_atomic_flows; +break ; +case RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_ORDER_SEQUENCES : + *attr_value = conf->nb_atomic_order_sequences; +break ; +case RTE_EVENT_QUEUE_ATTR_EVENT_QUEUE_CFG : + *attr_value = conf->event_queue_cfg;break ;default :return -EINVAL ;
lib/librte_eventdev/rte_eventdev.h +14 -2
@@ -640,6 +640,18 @@ rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id,* The priority of the queue. */ #define RTE_EVENT_QUEUE_ATTR_PRIORITY 0 +/** +* The number of atomic flows configured for the queue. +*/ +#define RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_FLOWS 1 +/** +* The number of atomic order sequences configured for the queue. +*/ +#define RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_ORDER_SEQUENCES 2 +/** +* The cfg flags for the queue. +*/ +#define RTE_EVENT_QUEUE_ATTR_EVENT_QUEUE_CFG 3/** * Get an attribute from a queue.
@@ -1051,8 +1063,8 @@ struct rte_eventdev_data {/**< Array of port dequeue depth. */ uint8_t *ports_enqueue_depth;/**< Array of port enqueue depth. */ -uint8_t *queues_prio; -/**< Array of queue priority. */ +struct rte_event_queue_conf *queues_cfg; +/**< Array of queue configuration structures. */ uint16_t *links_map;/**< Memory to store queues to port connections. */ void *dev_private;
test/test/test_eventdev.c +136 -2
156 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH 2/3 eventdev: extend port attribute get function
In reply to Gage EadsThis commit adds the new_event_threshold port attribute, so the entire port configuration structure passed to rte_event_queue_setup can be queried.
--- lib/librte_eventdev/rte_eventdev.c | 71 ++++++++++++-------------------------- lib/librte_eventdev/rte_eventdev.h | 10 +++--- test/test/test_eventdev.c | 39 +++++++++++++++++---- 3 files changed, 61 insertions(+), 59 deletions(-)
lib/librte_eventdev/rte_eventdev.c +22 -49
@@ -195,8 +195,7 @@ rte_event_dev_port_config(struct rte_eventdev *dev, uint8_t nb_ports)uint8_t old_nb_ports = dev->data->nb_ports;void **ports;uint16_t *links_map; -uint8_t *ports_dequeue_depth; -uint8_t *ports_enqueue_depth; +struct rte_event_port_conf *ports_cfg;unsigned int i; RTE_EDEV_LOG_DEBUG("Setup %d ports on device %u", nb_ports,
@@ -214,26 +213,14 @@ rte_event_dev_port_config(struct rte_eventdev *dev, uint8_t nb_ports)return -(ENOMEM ); } -/* Allocate memory to store ports dequeue depth */ - dev->data->ports_dequeue_depth = -rte_zmalloc_socket ("eventdev->ports_dequeue_depth" , -sizeof (dev->data->ports_dequeue_depth[0 ]) * nb_ports, +/* Allocate memory to store port configurations */ + dev->data->ports_cfg = +rte_zmalloc_socket ("eventdev->ports_cfg" , +sizeof (dev->data->ports_cfg[0 ]) * nb_ports,RTE_CACHE_LINE_SIZE , dev->data->socket_id); -if (dev->data->ports_dequeue_depth ==NULL ) { +if (dev->data->ports_cfg ==NULL ) { dev->data->nb_ports =0 ; -RTE_EDEV_LOG_ERR ("failed to get mem for port deq meta," -"nb_ports %u" , nb_ports); -return -(ENOMEM ); - } - -/* Allocate memory to store ports enqueue depth */ - dev->data->ports_enqueue_depth = -rte_zmalloc_socket ("eventdev->ports_enqueue_depth" , -sizeof (dev->data->ports_enqueue_depth[0 ]) * nb_ports, -RTE_CACHE_LINE_SIZE , dev->data->socket_id); -if (dev->data->ports_enqueue_depth ==NULL ) { - dev->data->nb_ports =0 ; -RTE_EDEV_LOG_ERR ("failed to get mem for port enq meta," +RTE_EDEV_LOG_ERR ("failed to get mem for port cfg," "nb_ports %u" , nb_ports);return -(ENOMEM ); }
@@ -257,8 +244,7 @@ rte_event_dev_port_config(struct rte_eventdev *dev, uint8_t nb_ports)RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->port_release, -ENOTSUP ); ports = dev->data->ports; - ports_dequeue_depth = dev->data->ports_dequeue_depth; - ports_enqueue_depth = dev->data->ports_enqueue_depth; + ports_cfg = dev->data->ports_cfg; links_map = dev->data->links_map;for (i = nb_ports; i < old_nb_ports; i++)
@@ -273,22 +259,12 @@ rte_event_dev_port_config(struct rte_eventdev *dev, uint8_t nb_ports)return -(ENOMEM ); } -/* Realloc memory for ports_dequeue_depth */ - ports_dequeue_depth =rte_realloc (ports_dequeue_depth, -sizeof (ports_dequeue_depth[0 ]) * nb_ports, +/* Realloc memory for ports_cfg */ + ports_cfg =rte_realloc (ports_cfg, +sizeof (ports_cfg[0 ]) * nb_ports,RTE_CACHE_LINE_SIZE ); -if (ports_dequeue_depth ==NULL ) { -RTE_EDEV_LOG_ERR ("failed to realloc port dequeue meta," -" nb_ports %u" , nb_ports); -return -(ENOMEM ); - } - -/* Realloc memory for ports_enqueue_depth */ - ports_enqueue_depth =rte_realloc (ports_enqueue_depth, -sizeof (ports_enqueue_depth[0 ]) * nb_ports, -RTE_CACHE_LINE_SIZE ); -if (ports_enqueue_depth ==NULL ) { -RTE_EDEV_LOG_ERR ("failed to realloc port enqueue meta," +if (ports_cfg ==NULL ) { +RTE_EDEV_LOG_ERR ("failed to realloc port cfg mem," " nb_ports %u" , nb_ports);return -(ENOMEM ); }
@@ -314,18 +290,15 @@ rte_event_dev_port_config(struct rte_eventdev *dev, uint8_t nb_ports)memset (ports + old_nb_ports,0 ,sizeof (ports[0 ]) * new_ps); -memset (ports_dequeue_depth + old_nb_ports,0 , -sizeof (ports_dequeue_depth[0 ]) * new_ps); -memset (ports_enqueue_depth + old_nb_ports,0 , -sizeof (ports_enqueue_depth[0 ]) * new_ps); +memset (ports_cfg + old_nb_ports,0 , +sizeof (ports_cfg[0 ]) * new_ps);for (i = old_links_map_end; i < links_map_end; i++) links_map[i] =EVENT_QUEUE_SERVICE_PRIORITY_INVALID ; } dev->data->ports = ports; - dev->data->ports_dequeue_depth = ports_dequeue_depth; - dev->data->ports_enqueue_depth = ports_enqueue_depth; + dev->data->ports_cfg = ports_cfg; dev->data->links_map = links_map; }else if (dev->data->ports !=NULL && nb_ports ==0 ) {RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->port_release, -ENOTSUP );
@@ -709,10 +682,7 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, port_conf = &def_conf; } - dev->data->ports_dequeue_depth[port_id] = - port_conf->dequeue_depth; - dev->data->ports_enqueue_depth[port_id] = - port_conf->enqueue_depth; + dev->data->ports_cfg[port_id] = *port_conf; diag = (*dev->dev_ops->port_setup)(dev, port_id, port_conf);
@@ -772,10 +742,13 @@ rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id,switch (attr_id) {case RTE_EVENT_PORT_ATTR_ENQ_DEPTH : - *attr_value = dev->data->ports_enqueue_depth[port_id]; + *attr_value = dev->data->ports_cfg[port_id].enqueue_depth;break ;case RTE_EVENT_PORT_ATTR_DEQ_DEPTH : - *attr_value = dev->data->ports_dequeue_depth[port_id]; + *attr_value = dev->data->ports_cfg[port_id].dequeue_depth; +break ; +case RTE_EVENT_PORT_ATTR_NEW_EVENT_THRESHOLD : + *attr_value = dev->data->ports_cfg[port_id].new_event_threshold;break ;default :return -EINVAL ;
lib/librte_eventdev/rte_eventdev.h +6 -4
@@ -759,6 +759,10 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id,* The queue depth of the port on the dequeue side */ #define RTE_EVENT_PORT_ATTR_DEQ_DEPTH 1 +/** +* The new event threshold of the port +*/ +#define RTE_EVENT_PORT_ATTR_NEW_EVENT_THRESHOLD 2/** * Get an attribute from a port.
@@ -1059,10 +1063,8 @@ struct rte_eventdev_data {/**< Number of event ports. */ void **ports;/**< Array of pointers to ports. */ -uint8_t *ports_dequeue_depth; -/**< Array of port dequeue depth. */ -uint8_t *ports_enqueue_depth; -/**< Array of port enqueue depth. */ +struct rte_event_port_conf *ports_cfg; +/**< Array of port configuration structures. */ struct rte_event_queue_conf *queues_cfg;/**< Array of queue configuration structures. */ uint16_t *links_map;
test/test/test_eventdev.c +33 -6
@@ -606,7 +606,7 @@ test_eventdev_port_setup(void) }static int -test_eventdev_dequeue_depth (void ) +test_eventdev_port_attr_dequeue_depth (void ) {int ret;struct rte_event_dev_info info;
@@ -623,7 +623,7 @@ test_eventdev_dequeue_depth(void)uint32_t value;TEST_ASSERT_EQUAL (rte_event_port_attr_get (TEST_DEV_ID ,0 ,RTE_EVENT_PORT_ATTR_DEQ_DEPTH , &value), -0 ,"Call to port dequeue depth failed" ); +0 ,"Call to get port dequeue depth failed" );TEST_ASSERT_EQUAL (value, pconf.dequeue_depth,"Wrong port dequeue depth" );
@@ -631,7 +631,7 @@ test_eventdev_dequeue_depth(void) }static int -test_eventdev_enqueue_depth (void ) +test_eventdev_port_attr_enqueue_depth (void ) {int ret;struct rte_event_dev_info info;
@@ -648,7 +648,7 @@ test_eventdev_enqueue_depth(void)uint32_t value;TEST_ASSERT_EQUAL (rte_event_port_attr_get (TEST_DEV_ID ,0 ,RTE_EVENT_PORT_ATTR_ENQ_DEPTH , &value), -0 ,"Call to port enqueue depth failed" ); +0 ,"Call to get port enqueue depth failed" );TEST_ASSERT_EQUAL (value, pconf.dequeue_depth,"Wrong port enqueue depth" );
@@ -656,6 +656,31 @@ test_eventdev_enqueue_depth(void) }static int +test_eventdev_port_attr_new_event_threshold (void ) +{ +int ret; +struct rte_event_dev_info info; +struct rte_event_port_conf pconf; + + ret =rte_event_dev_info_get (TEST_DEV_ID , &info); +TEST_ASSERT_SUCCESS (ret,"Failed to get event dev info" ); + + ret =rte_event_port_default_conf_get (TEST_DEV_ID ,0 , &pconf); +TEST_ASSERT_SUCCESS (ret,"Failed to get port0 info" ); + ret =rte_event_port_setup (TEST_DEV_ID ,0 , &pconf); +TEST_ASSERT_SUCCESS (ret,"Failed to setup port0" ); + +uint32_t value; +TEST_ASSERT_EQUAL (rte_event_port_attr_get (TEST_DEV_ID ,0 , +RTE_EVENT_PORT_ATTR_NEW_EVENT_THRESHOLD , &value), +0 ,"Call to get port new event threshold failed" ); +TEST_ASSERT_EQUAL ((int32_t ) value, pconf.new_event_threshold, +"Wrong port new event threshold" ); + +return TEST_SUCCESS ; +} + +static int test_eventdev_port_count (void ) {int ret;
@@ -953,9 +978,11 @@ static struct unit_test_suite eventdev_common_testsuite = {TEST_CASE_ST (eventdev_configure_setup,NULL , test_eventdev_port_setup),TEST_CASE_ST (eventdev_configure_setup,NULL , - test_eventdev_dequeue_depth), + test_eventdev_port_attr_dequeue_depth), +TEST_CASE_ST (eventdev_configure_setup,NULL , + test_eventdev_port_attr_enqueue_depth),TEST_CASE_ST (eventdev_configure_setup,NULL , - test_eventdev_enqueue_depth), + test_eventdev_port_attr_new_event_threshold),TEST_CASE_ST (eventdev_configure_setup,NULL , test_eventdev_port_count), TEST_CASE_ST(eventdev_configure_setup, NULL,
Signature · 1 line
2.7.4
PATCH 3/3 test/eventdev: fix bug in port enqueue depth test
In reply to Gage EadsThe enqueue depth test was comparing the port's dequeue depth against its enqueue depth.
--- test/test/test_eventdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
test/test/test_eventdev.c +1 -1
@@ -649,7 +649,7 @@ test_eventdev_port_attr_enqueue_depth(void)TEST_ASSERT_EQUAL (rte_event_port_attr_get (TEST_DEV_ID ,0 ,RTE_EVENT_PORT_ATTR_ENQ_DEPTH , &value),0 ,"Call to get port enqueue depth failed" ); -TEST_ASSERT_EQUAL (value, pconf.dequeue_depth, +TEST_ASSERT_EQUAL (value, pconf.enqueue_depth,"Wrong port enqueue depth" );return TEST_SUCCESS ;
Signature · 1 line
2.7.4
Quoted 19 lines
From: Eads, Gage
Sent: Wednesday, September 20, 2017 4:21 PM
To: [email protected]
Cc: [email protected]; Van Haaren, Harry <[email protected]>
Subject: [PATCH 0/3] Extend port and queue attribute get functionsThis patchset makes the full queue and port configuration structures accessible
through the attribute get functions, adds tests for the new attributes, and fixes one bug in a port attribute get test.This patchset is based on patches 29019 through 29023.
Gage Eads (3):
eventdev: extend queue attribute get function
eventdev: extend port attribute get function test/eventdev: fix bug in port enqueue depth test
Quoted 5 lines
lib/librte_eventdev/rte_eventdev.c | 125 ++++++++++++-------------- lib/librte_eventdev/rte_eventdev.h | 26 ++++-- test/test/test_eventdev.c | 179 +++++++++++++++++++++++++++++++++++-- 3 files changed, 245 insertions(+), 85 deletions(-)
Thanks - good to see the attrs API get more value!
-----Original Message-----
Quoted 31 lines
Date: Wed, 4 Oct 2017 14:12:50 +0000
From: "Van Haaren, Harry" <[email protected]>
To: "Eads, Gage" <[email protected]>, "[email protected]" <[email protected]>
CC: "[email protected]" <[email protected]>
Subject: RE: [PATCH 0/3] Extend port and queue attribute get functionsQuoted 19 lines
From: Eads, Gage
Sent: Wednesday, September 20, 2017 4:21 PM
To: [email protected]
Cc: [email protected]; Van Haaren, Harry <[email protected]>
Subject: [PATCH 0/3] Extend port and queue attribute get functionsThis patchset makes the full queue and port configuration structures accessible
through the attribute get functions, adds tests for the new attributes, and fixes one bug in a port attribute get test.This patchset is based on patches 29019 through 29023.
Gage Eads (3):
eventdev: extend queue attribute get function
eventdev: extend port attribute get function test/eventdev: fix bug in port enqueue depth testQuoted 5 lines
lib/librte_eventdev/rte_eventdev.c | 125 ++++++++++++-------------- lib/librte_eventdev/rte_eventdev.h | 26 ++++-- test/test/test_eventdev.c | 179 +++++++++++++++++++++++++++++++++++-- 3 files changed, 245 insertions(+), 85 deletions(-)
Quoted 3 lines
Thanks - good to see the attrs API get more value!
Series-Reviewed-by Harry van Haaren <[email protected]>
Applied after fixing the build issue found in my system(gcc 7.2.0) to dpdk-next-eventdev/master. Thanks.
== Build test/cmdline_test
CC test_eventdev.o
In file included from /export/dpdk-next-eventdev/test/test/test_eventdev.c:41:0:
/export/dpdk-next-eventdev/test/test/test_eventdev.c: In function ‘test_eventdev_queue_attr_event_queue_cfg’:
/export/dpdk-next-eventdev/test/test/test.h:149:4: error: ‘i’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
printf("TestCase %s() line %d failed (err %d): " \
^~~~~~
/export/dpdk-next-eventdev/test/test/test_eventdev.c:494:6: note: ‘i’
was declared here
int i, ret;
^➜ [master][dpdk-next-eventdev] $ git diff
test/test/test_eventdev.c +1 -1
@@ -505,7 +505,7 @@ test_eventdev_queue_attr_event_queue_cfg(void) "Queue count get failed"); ret =rte_event_queue_default_conf_get (TEST_DEV_ID ,0 , &qconf); -TEST_ASSERT_SUCCESS (ret,"Failed to get queue%d def conf" , i); +TEST_ASSERT_SUCCESS (ret,"Failed to get queue0 def conf" ); qconf.event_queue_cfg =RTE_EVENT_QUEUE_CFG_PARALLEL_ONLY ;