* [dpdk-dev] [PATCH] eventdev: add dev id checks to config functions @ 2017-07-24 12:48 Harry van Haaren 2017-09-04 5:20 ` Jerin Jacob 2017-09-08 15:18 ` [dpdk-dev] [PATCH v2 0/3] eventdev: add attribute based get APIs Harry van Haaren 0 siblings, 2 replies; 35+ messages in thread From: Harry van Haaren @ 2017-07-24 12:48 UTC (permalink / raw) To: dev; +Cc: jerin.jacob, Harry van Haaren This commit adds checks to verify the device ID is valid to the following functions. Given that they are non-datapath, these checks are always performed. This commit also updates the event/octeontx test-cases to have the correct signed-ness, as the API has changes this change is required in order to compile. Suggested-by: Jesse Bruni <jesse.bruni@intel.com> Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> --- lib/librte_eventdev/rte_eventdev.c | 36 +++++++++++++++++++++++++----------- lib/librte_eventdev/rte_eventdev.h | 36 ++++++++++++++++++------------------ test/test/test_eventdev_octeontx.c | 32 +++++++++++++++++++------------- 3 files changed, 62 insertions(+), 42 deletions(-) diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c index bbb3805..e71f20c 100644 --- a/lib/librte_eventdev/rte_eventdev.c +++ b/lib/librte_eventdev/rte_eventdev.c @@ -609,21 +609,26 @@ rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id, return (*dev->dev_ops->queue_setup)(dev, queue_id, queue_conf); } -uint8_t +int16_t rte_event_queue_count(uint8_t dev_id) { struct rte_eventdev *dev; + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); dev = &rte_eventdevs[dev_id]; return dev->data->nb_queues; } -uint8_t +int16_t rte_event_queue_priority(uint8_t dev_id, uint8_t queue_id) { - struct rte_eventdev *dev; + struct rte_eventdev *dev = &rte_eventdevs[dev_id]; + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); + if (!is_valid_queue(dev, queue_id)) { + RTE_EDEV_LOG_ERR("Invalid queue_id=%" PRIu8, queue_id); + return -EINVAL; + } - dev = &rte_eventdevs[dev_id]; if (dev->data->event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_QOS) return dev->data->queues_prio[queue_id]; else @@ -743,28 +748,37 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, return 0; } -uint8_t +int16_t rte_event_port_dequeue_depth(uint8_t dev_id, uint8_t port_id) { - struct rte_eventdev *dev; + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); + struct rte_eventdev *dev = &rte_eventdevs[dev_id]; + if (!is_valid_port(dev, port_id)) { + RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id); + return -EINVAL; + } - dev = &rte_eventdevs[dev_id]; return dev->data->ports_dequeue_depth[port_id]; } -uint8_t +int16_t rte_event_port_enqueue_depth(uint8_t dev_id, uint8_t port_id) { - struct rte_eventdev *dev; + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); + struct rte_eventdev *dev = &rte_eventdevs[dev_id]; + if (!is_valid_port(dev, port_id)) { + RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id); + return -EINVAL; + } - dev = &rte_eventdevs[dev_id]; return dev->data->ports_enqueue_depth[port_id]; } -uint8_t +int16_t rte_event_port_count(uint8_t dev_id) { struct rte_eventdev *dev; + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); dev = &rte_eventdevs[dev_id]; return dev->data->nb_ports; diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h index 128bc52..204ff82 100644 --- a/lib/librte_eventdev/rte_eventdev.h +++ b/lib/librte_eventdev/rte_eventdev.h @@ -611,10 +611,10 @@ rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id, * * @param dev_id * Event device identifier. - * @return - * - The number of configured event queues + * @retval Positive The number of configured event queues + * @retval -EINVAL Invalid device id */ -uint8_t +int16_t rte_event_queue_count(uint8_t dev_id); /** @@ -624,13 +624,13 @@ rte_event_queue_count(uint8_t dev_id); * Event device identifier. * @param queue_id * Event queue identifier. - * @return - * - If the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability then the - * configured priority of the event queue in - * [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST] range - * else the value RTE_EVENT_DEV_PRIORITY_NORMAL + * @retval Positive If the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability + * then the configured priority of the event queue in + * [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST] + * range else the value RTE_EVENT_DEV_PRIORITY_NORMAL + * @retval -EINVAL Invalid device id or queue id */ -uint8_t +int16_t rte_event_queue_priority(uint8_t dev_id, uint8_t queue_id); /* Event port specific APIs */ @@ -722,12 +722,12 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, * Event device identifier. * @param port_id * Event port identifier. - * @return - * - The number of configured dequeue queue depth + * @retval Positive The dequeue queue depth + * @retval -EINVAL Invalid device ID or port ID * * @see rte_event_dequeue_burst() */ -uint8_t +int16_t rte_event_port_dequeue_depth(uint8_t dev_id, uint8_t port_id); /** @@ -738,12 +738,12 @@ rte_event_port_dequeue_depth(uint8_t dev_id, uint8_t port_id); * Event device identifier. * @param port_id * Event port identifier. - * @return - * - The number of configured enqueue queue depth + * @retval Positive The enqueue queue depth + * @retval -EINVAL Invalid device ID or port ID * * @see rte_event_enqueue_burst() */ -uint8_t +int16_t rte_event_port_enqueue_depth(uint8_t dev_id, uint8_t port_id); /** @@ -751,10 +751,10 @@ rte_event_port_enqueue_depth(uint8_t dev_id, uint8_t port_id); * * @param dev_id * Event device identifier. - * @return - * - The number of configured ports + * @retval Positive The number of configured ports + * @retval -EINVAL Invalid device id */ -uint8_t +int16_t rte_event_port_count(uint8_t dev_id); /** diff --git a/test/test/test_eventdev_octeontx.c b/test/test/test_eventdev_octeontx.c index 774d030..6794f1f 100644 --- a/test/test/test_eventdev_octeontx.c +++ b/test/test/test_eventdev_octeontx.c @@ -591,7 +591,7 @@ wait_workers_to_join(int lcore, const rte_atomic32_t *count) static inline int launch_workers_and_wait(int (*master_worker)(void *), int (*slave_workers)(void *), uint32_t total_events, - uint8_t nb_workers, uint8_t sched_type) + int16_t nb_workers, uint8_t sched_type) { uint8_t port = 0; int w_lcore; @@ -651,14 +651,15 @@ static int test_multi_queue_enq_multi_port_deq(void) { const unsigned int total_events = MAX_EVENTS; - uint8_t nr_ports; + int16_t nr_ports; int ret; ret = generate_random_events(total_events); if (ret) return TEST_FAILED; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + nr_ports = RTE_MIN(rte_event_port_count(evdev), + (int)rte_lcore_count() - 1); if (!nr_ports) { printf("%s: Not enough ports=%d or workers=%d\n", __func__, @@ -698,7 +699,7 @@ test_queue_to_port_single_link(void) } nr_links = RTE_MIN(rte_event_port_count(evdev), - rte_event_queue_count(evdev)); + (int)rte_event_queue_count(evdev)); const unsigned int total_events = MAX_EVENTS / nr_links; /* Link queue x to port x and inject events to queue x through port x */ @@ -750,7 +751,8 @@ static int test_queue_to_port_multi_link(void) { int ret, port0_events = 0, port1_events = 0; - uint8_t nr_queues, nr_ports, queue, port; + int16_t nr_queues, nr_ports, port; + uint8_t queue; nr_queues = rte_event_queue_count(evdev); nr_ports = rte_event_port_count(evdev); @@ -854,10 +856,11 @@ test_multiport_flow_sched_type_test(uint8_t in_sched_type, uint8_t out_sched_type) { const unsigned int total_events = MAX_EVENTS; - uint8_t nr_ports; + int16_t nr_ports; int ret; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + nr_ports = RTE_MIN(rte_event_port_count(evdev), + (int)rte_lcore_count() - 1); if (!nr_ports) { printf("%s: Not enough ports=%d or workers=%d\n", __func__, @@ -1007,10 +1010,11 @@ test_multiport_queue_sched_type_test(uint8_t in_sched_type, uint8_t out_sched_type) { const unsigned int total_events = MAX_EVENTS; - uint8_t nr_ports; + int16_t nr_ports; int ret; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + nr_ports = RTE_MIN(rte_event_port_count(evdev), + (int)rte_lcore_count() - 1); if (rte_event_queue_count(evdev) < 2 || !nr_ports) { printf("%s: Not enough queues=%d ports=%d or workers=%d\n", @@ -1142,10 +1146,11 @@ worker_flow_based_pipeline_max_stages_rand_sched_type(void *arg) static int launch_multi_port_max_stages_random_sched_type(int (*fn)(void *)) { - uint8_t nr_ports; + int16_t nr_ports; int ret; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + nr_ports = RTE_MIN(rte_event_port_count(evdev), + (int)rte_lcore_count() - 1); if (!nr_ports) { printf("%s: Not enough ports=%d or workers=%d\n", __func__, @@ -1288,9 +1293,10 @@ worker_ordered_flow_producer(void *arg) static inline int test_producer_consumer_ingress_order_test(int (*fn)(void *)) { - uint8_t nr_ports; + int16_t nr_ports; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + nr_ports = RTE_MIN(rte_event_port_count(evdev), + (int)rte_lcore_count() - 1); if (rte_lcore_count() < 3 || nr_ports < 2) { printf("### Not enough cores for %s test.\n", __func__); -- 2.7.4 ^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [dpdk-dev] [PATCH] eventdev: add dev id checks to config functions 2017-07-24 12:48 [dpdk-dev] [PATCH] eventdev: add dev id checks to config functions Harry van Haaren @ 2017-09-04 5:20 ` Jerin Jacob 2017-09-06 14:45 ` Van Haaren, Harry 2017-09-08 15:18 ` [dpdk-dev] [PATCH v2 0/3] eventdev: add attribute based get APIs Harry van Haaren 1 sibling, 1 reply; 35+ messages in thread From: Jerin Jacob @ 2017-09-04 5:20 UTC (permalink / raw) To: Harry van Haaren; +Cc: dev -----Original Message----- > Date: Mon, 24 Jul 2017 13:48:20 +0100 > From: Harry van Haaren <harry.van.haaren@intel.com> > To: dev@dpdk.org > CC: jerin.jacob@caviumnetworks.com, Harry van Haaren > <harry.van.haaren@intel.com> > Subject: [PATCH] eventdev: add dev id checks to config functions > X-Mailer: git-send-email 2.7.4 > > This commit adds checks to verify the device ID is valid > to the following functions. Given that they are non-datapath, > these checks are always performed. Makes sense. > > This commit also updates the event/octeontx test-cases to > have the correct signed-ness, as the API has changes this > change is required in order to compile. > > Suggested-by: Jesse Bruni <jesse.bruni@intel.com> > Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> > > --- > @@ -1288,9 +1293,10 @@ worker_ordered_flow_producer(void *arg) > static inline int > test_producer_consumer_ingress_order_test(int (*fn)(void *)) > { > - uint8_t nr_ports; > + int16_t nr_ports; > > - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); > + nr_ports = RTE_MIN(rte_event_port_count(evdev), > + (int)rte_lcore_count() - 1); While I agree on the problem statement, I am trying to see 1/ an API symmetrical to ethdev APIs. Similar problem solved in a differently in ethdev. see rte_eth_dev_adjust_nb_rx_tx_desc(). Just want to make sure, all the APIs across ethdev, eventdev looks same 2/ How to get rid of above typecasting Considering above two points and following the rte_eth_dev_adjust_nb_rx_tx_desc() pattern. How about, Removing, rte_event_port_dequeue_depth() rte_event_port_enqueue_depth() rte_event_port_count() rte_event_queue_count() rte_event_queue_priority() and change to, int rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint8_t *enqueue_depth /*out */, uint8_t *dequeue_depth /* out*/, uin8_t *count /*out*/); int rte_event_queue_attr_get(uint8_t dev_id, uint8_t port_id, uin8_t *prio /* out */, uint8_t *count /*out */); or something similar. ^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [dpdk-dev] [PATCH] eventdev: add dev id checks to config functions 2017-09-04 5:20 ` Jerin Jacob @ 2017-09-06 14:45 ` Van Haaren, Harry 2017-09-06 14:57 ` Jerin Jacob 0 siblings, 1 reply; 35+ messages in thread From: Van Haaren, Harry @ 2017-09-06 14:45 UTC (permalink / raw) To: Jerin Jacob; +Cc: dev > From: Jerin Jacob [mailto:jerin.jacob@caviumnetworks.com] > Sent: Monday, September 4, 2017 6:21 AM > To: Van Haaren, Harry <harry.van.haaren@intel.com> > Cc: dev@dpdk.org > Subject: Re: [PATCH] eventdev: add dev id checks to config functions > > -----Original Message----- > > Date: Mon, 24 Jul 2017 13:48:20 +0100 > > From: Harry van Haaren <harry.van.haaren@intel.com> > > To: dev@dpdk.org > > CC: jerin.jacob@caviumnetworks.com, Harry van Haaren > > <harry.van.haaren@intel.com> > > Subject: [PATCH] eventdev: add dev id checks to config functions > > X-Mailer: git-send-email 2.7.4 > > > > This commit adds checks to verify the device ID is valid > > to the following functions. Given that they are non-datapath, > > these checks are always performed. > > Makes sense. Great - lets discuss implementation ;) > > This commit also updates the event/octeontx test-cases to > > have the correct signed-ness, as the API has changes this > > change is required in order to compile. > > > > Suggested-by: Jesse Bruni <jesse.bruni@intel.com> > > Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> > > > > --- > > @@ -1288,9 +1293,10 @@ worker_ordered_flow_producer(void *arg) > > static inline int > > test_producer_consumer_ingress_order_test(int (*fn)(void *)) > > { > > - uint8_t nr_ports; > > + int16_t nr_ports; > > > > - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); > > + nr_ports = RTE_MIN(rte_event_port_count(evdev), > > + (int)rte_lcore_count() - 1); > > While I agree on the problem statement, I am trying to see > 1/ an API symmetrical to ethdev APIs. Similar problem solved in a differently in > ethdev. see rte_eth_dev_adjust_nb_rx_tx_desc(). > Just want to make sure, all the APIs across ethdev, eventdev looks same > > 2/ How to get rid of above typecasting > > Considering above two points and following the > rte_eth_dev_adjust_nb_rx_tx_desc() pattern. How about, > > Removing, > rte_event_port_dequeue_depth() > rte_event_port_enqueue_depth() > rte_event_port_count() > > rte_event_queue_count() > rte_event_queue_priority() > > and change to, > > int rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, > uint8_t *enqueue_depth /*out */, uint8_t *dequeue_depth /* out*/, uin8_t *count /*out*/); > > int rte_event_queue_attr_get(uint8_t dev_id, uint8_t port_id, > uin8_t *prio /* out */, uint8_t *count /*out */); > > or something similar. Hmm, I don't like that we'd have to break ABI every time we want to add an item to attr_get().. so adding a parameter "attr_id" would allow adding events in future. This solution feels a bit like a re-implementation of the xstats API.. Thoughts? -H enum { PORT_COUNT, PORT_DEQUEUE_DEPTH, PORT_ENQUEUE_DEPTH, } /* retrieve value of port int rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, uint32_t *attr_value /* out */); ^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [dpdk-dev] [PATCH] eventdev: add dev id checks to config functions 2017-09-06 14:45 ` Van Haaren, Harry @ 2017-09-06 14:57 ` Jerin Jacob 0 siblings, 0 replies; 35+ messages in thread From: Jerin Jacob @ 2017-09-06 14:57 UTC (permalink / raw) To: Van Haaren, Harry; +Cc: dev -----Original Message----- > Date: Wed, 6 Sep 2017 14:45:29 +0000 > From: "Van Haaren, Harry" <harry.van.haaren@intel.com> > To: Jerin Jacob <jerin.jacob@caviumnetworks.com> > CC: "dev@dpdk.org" <dev@dpdk.org> > Subject: RE: [PATCH] eventdev: add dev id checks to config functions > > > From: Jerin Jacob [mailto:jerin.jacob@caviumnetworks.com] > > Sent: Monday, September 4, 2017 6:21 AM > > To: Van Haaren, Harry <harry.van.haaren@intel.com> > > Cc: dev@dpdk.org > > Subject: Re: [PATCH] eventdev: add dev id checks to config functions > > > > -----Original Message----- > > > Date: Mon, 24 Jul 2017 13:48:20 +0100 > > > From: Harry van Haaren <harry.van.haaren@intel.com> > > > To: dev@dpdk.org > > > CC: jerin.jacob@caviumnetworks.com, Harry van Haaren > > > <harry.van.haaren@intel.com> > > > Subject: [PATCH] eventdev: add dev id checks to config functions > > > X-Mailer: git-send-email 2.7.4 > > > > > > This commit adds checks to verify the device ID is valid > > > to the following functions. Given that they are non-datapath, > > > these checks are always performed. > > > > Makes sense. > > Great - lets discuss implementation ;) > > > > > This commit also updates the event/octeontx test-cases to > > > have the correct signed-ness, as the API has changes this > > > change is required in order to compile. > > > > > > Suggested-by: Jesse Bruni <jesse.bruni@intel.com> > > > Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> > > > > > > --- > > > @@ -1288,9 +1293,10 @@ worker_ordered_flow_producer(void *arg) > > > static inline int > > > test_producer_consumer_ingress_order_test(int (*fn)(void *)) > > > { > > > - uint8_t nr_ports; > > > + int16_t nr_ports; > > > > > > - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); > > > + nr_ports = RTE_MIN(rte_event_port_count(evdev), > > > + (int)rte_lcore_count() - 1); > > > > While I agree on the problem statement, I am trying to see > > 1/ an API symmetrical to ethdev APIs. Similar problem solved in a differently in > > ethdev. see rte_eth_dev_adjust_nb_rx_tx_desc(). > > Just want to make sure, all the APIs across ethdev, eventdev looks same > > > > 2/ How to get rid of above typecasting > > > > Considering above two points and following the > > rte_eth_dev_adjust_nb_rx_tx_desc() pattern. How about, > > > > Removing, > > rte_event_port_dequeue_depth() > > rte_event_port_enqueue_depth() > > rte_event_port_count() > > > > rte_event_queue_count() > > rte_event_queue_priority() > > > > and change to, > > > > int rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, > > uint8_t *enqueue_depth /*out */, uint8_t *dequeue_depth /* out*/, uin8_t *count /*out*/); > > > > int rte_event_queue_attr_get(uint8_t dev_id, uint8_t port_id, > > uin8_t *prio /* out */, uint8_t *count /*out */); > > > > or something similar. > > Hmm, I don't like that we'd have to break ABI every time we want to add an item to attr_get().. so adding a parameter "attr_id" would allow adding events in future. This solution feels a bit like a re-implementation of the xstats API.. > > Thoughts? -H > > > enum { > PORT_COUNT, > PORT_DEQUEUE_DEPTH, > PORT_ENQUEUE_DEPTH, > } > > /* retrieve value of port > int rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, uint32_t *attr_value /* out */); Looks good to me. > > ^ permalink raw reply [flat|nested] 35+ messages in thread
* [dpdk-dev] [PATCH v2 0/3] eventdev: add attribute based get APIs 2017-07-24 12:48 [dpdk-dev] [PATCH] eventdev: add dev id checks to config functions Harry van Haaren 2017-09-04 5:20 ` Jerin Jacob @ 2017-09-08 15:18 ` Harry van Haaren 2017-09-08 15:18 ` [dpdk-dev] [PATCH v2 1/4] eventdev: add port attribute function Harry van Haaren ` (4 more replies) 1 sibling, 5 replies; 35+ messages in thread From: Harry van Haaren @ 2017-09-08 15:18 UTC (permalink / raw) To: dev; +Cc: jerin.jacob, Harry van Haaren This patchset refactors the eventdev API to be more flexible and capable. In particular, the API is capable of returning an error value if an invalid device, port or attribute ID is passed in, which was not possible with the previous APIs. The implementation of this patchset is based on a v1 patch[1], and after some discussion this API was seen as the best solution. In terms of flexibility, the attribute id allows addition of new common eventdev layer attributes without breaking ABI or adding new functions. Note that these attributes are not data-path, and that PMDs should continue to use the xstats API for reporting any unique PMD statistics that are available. Regarding API/ABI compatibility, I have removed the functions from the .map files - please review the .map file changes for ABI issues carefully. The last patch of this series adds a started attribute to the device, allowing the application to query if a device is currently running. -Harry [1] http://dpdk.org/dev/patchwork/patch/27152/ Harry van Haaren (3): eventdev: add port attribute function eventdev: add dev attribute get function eventdev: add queue attribute function lib/librte_eventdev/rte_eventdev.c | 88 +++++++++++------ lib/librte_eventdev/rte_eventdev.h | 115 ++++++++++----------- lib/librte_eventdev/rte_eventdev_version.map | 12 ++- test/test/test_eventdev.c | 132 +++++++++++++++++++------ test/test/test_eventdev_octeontx.c | 143 ++++++++++++++++++++------- 5 files changed, 334 insertions(+), 156 deletions(-) -- 2.7.4 ^ permalink raw reply [flat|nested] 35+ messages in thread
* [dpdk-dev] [PATCH v2 1/4] eventdev: add port attribute function 2017-09-08 15:18 ` [dpdk-dev] [PATCH v2 0/3] eventdev: add attribute based get APIs Harry van Haaren @ 2017-09-08 15:18 ` Harry van Haaren 2017-09-08 15:18 ` [dpdk-dev] [PATCH v2 2/4] eventdev: add dev attribute get function Harry van Haaren ` (3 subsequent siblings) 4 siblings, 0 replies; 35+ messages in thread From: Harry van Haaren @ 2017-09-08 15:18 UTC (permalink / raw) To: dev; +Cc: jerin.jacob, Harry van Haaren This commit reworks the port functions to retrieve information about the port, like the enq or deq depths. Note that "port count" is a device attribute, and is added in a later patch for dev attributes. Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> --- lib/librte_eventdev/rte_eventdev.c | 33 +++++++++++-------- lib/librte_eventdev/rte_eventdev.h | 49 ++++++++++++---------------- lib/librte_eventdev/rte_eventdev_version.map | 7 ++++ test/test/test_eventdev.c | 16 ++++++--- 4 files changed, 59 insertions(+), 46 deletions(-) diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c index bbb3805..6b867b3 100644 --- a/lib/librte_eventdev/rte_eventdev.c +++ b/lib/librte_eventdev/rte_eventdev.c @@ -744,30 +744,35 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, } uint8_t -rte_event_port_dequeue_depth(uint8_t dev_id, uint8_t port_id) +rte_event_port_count(uint8_t dev_id) { struct rte_eventdev *dev; dev = &rte_eventdevs[dev_id]; - return dev->data->ports_dequeue_depth[port_id]; + return dev->data->nb_ports; } -uint8_t -rte_event_port_enqueue_depth(uint8_t dev_id, uint8_t port_id) +int +rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, + uint32_t *attr_value /*out */) { struct rte_eventdev *dev; - + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); dev = &rte_eventdevs[dev_id]; - return dev->data->ports_enqueue_depth[port_id]; -} - -uint8_t -rte_event_port_count(uint8_t dev_id) -{ - struct rte_eventdev *dev; + if (!is_valid_port(dev, port_id)) { + RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id); + return -EINVAL; + } - dev = &rte_eventdevs[dev_id]; - return dev->data->nb_ports; + switch(attr_id) { + case RTE_EVENT_PORT_ATTR_ENQ_DEPTH: + *attr_value = dev->data->ports_enqueue_depth[port_id]; + break; + case RTE_EVENT_PORT_ATTR_DEQ_DEPTH: + *attr_value = dev->data->ports_dequeue_depth[port_id]; + break; + }; + return 0; } int diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h index 128bc52..fadc209 100644 --- a/lib/librte_eventdev/rte_eventdev.h +++ b/lib/librte_eventdev/rte_eventdev.h @@ -715,47 +715,40 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, const struct rte_event_port_conf *port_conf); /** - * Get the number of dequeue queue depth configured for event port designated - * by its *port_id* on a specific event device + * Get the number of ports on a specific event device * * @param dev_id * Event device identifier. - * @param port_id - * Event port identifier. * @return - * - The number of configured dequeue queue depth - * - * @see rte_event_dequeue_burst() + * - The number of configured ports */ uint8_t -rte_event_port_dequeue_depth(uint8_t dev_id, uint8_t port_id); +rte_event_port_count(uint8_t dev_id); /** - * Get the number of enqueue queue depth configured for event port designated - * by its *port_id* on a specific event device - * - * @param dev_id - * Event device identifier. - * @param port_id - * Event port identifier. - * @return - * - The number of configured enqueue queue depth - * - * @see rte_event_enqueue_burst() + * The queue depth of the port on the enqueue side */ -uint8_t -rte_event_port_enqueue_depth(uint8_t dev_id, uint8_t port_id); +#define RTE_EVENT_PORT_ATTR_ENQ_DEPTH 0 +/** + * The queue depth of the port on the dequeue side + */ +#define RTE_EVENT_PORT_ATTR_DEQ_DEPTH 1 /** - * Get the number of ports on a specific event device + * Get an attribute from a port. * - * @param dev_id - * Event device identifier. - * @return - * - The number of configured ports + * @param dev_id Eventdev id + * @param port_id Eventdev port id + * @param attr_id The attribute ID to retrieve + * @param[out] attr_value A pointer that will be filled in with the attribute + * value if successful + * + * @retval 0 Successfully returned value + * -EINVAL Invalid device, port or attr_id, or attr_value was NULL */ -uint8_t -rte_event_port_count(uint8_t dev_id); +int +rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, + uint32_t *attr_value /*out */); /** * Start an event device. diff --git a/lib/librte_eventdev/rte_eventdev_version.map b/lib/librte_eventdev/rte_eventdev_version.map index 4c48e5f..a0adde3 100644 --- a/lib/librte_eventdev/rte_eventdev_version.map +++ b/lib/librte_eventdev/rte_eventdev_version.map @@ -51,3 +51,10 @@ DPDK_17.08 { rte_event_ring_init; rte_event_ring_lookup; } DPDK_17.05; + +EXPERIMENTAL { + global: + + rte_event_port_attr_get; + +} DPDK_17.08; diff --git a/test/test/test_eventdev.c b/test/test/test_eventdev.c index f766191..f3ec470 100644 --- a/test/test/test_eventdev.c +++ b/test/test/test_eventdev.c @@ -460,8 +460,12 @@ test_eventdev_dequeue_depth(void) ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf); TEST_ASSERT_SUCCESS(ret, "Failed to setup port0"); - TEST_ASSERT_EQUAL(rte_event_port_dequeue_depth(TEST_DEV_ID, 0), - pconf.dequeue_depth, "Wrong port dequeue depth"); + 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"); + TEST_ASSERT_EQUAL(value, pconf.dequeue_depth, + "Wrong port dequeue depth"); return TEST_SUCCESS; } @@ -481,8 +485,12 @@ test_eventdev_enqueue_depth(void) ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf); TEST_ASSERT_SUCCESS(ret, "Failed to setup port0"); - TEST_ASSERT_EQUAL(rte_event_port_enqueue_depth(TEST_DEV_ID, 0), - pconf.enqueue_depth, "Wrong port enqueue depth"); + 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"); + TEST_ASSERT_EQUAL(value, pconf.dequeue_depth, + "Wrong port enqueue depth"); return TEST_SUCCESS; } -- 2.7.4 ^ permalink raw reply [flat|nested] 35+ messages in thread
* [dpdk-dev] [PATCH v2 2/4] eventdev: add dev attribute get function 2017-09-08 15:18 ` [dpdk-dev] [PATCH v2 0/3] eventdev: add attribute based get APIs Harry van Haaren 2017-09-08 15:18 ` [dpdk-dev] [PATCH v2 1/4] eventdev: add port attribute function Harry van Haaren @ 2017-09-08 15:18 ` Harry van Haaren 2017-09-08 15:18 ` [dpdk-dev] [PATCH v2 3/4] eventdev: add queue attribute function Harry van Haaren ` (2 subsequent siblings) 4 siblings, 0 replies; 35+ messages in thread From: Harry van Haaren @ 2017-09-08 15:18 UTC (permalink / raw) To: dev; +Cc: jerin.jacob, Harry van Haaren This commit adds a device attribute function, allowing flexible fetching of device attributes, like port count or queue count. The unit tests and .map file are updated to the new function. Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> --- lib/librte_eventdev/rte_eventdev.c | 24 ++++++++-- lib/librte_eventdev/rte_eventdev.h | 28 ++++++++--- lib/librte_eventdev/rte_eventdev_version.map | 2 +- test/test/test_eventdev.c | 36 +++++++++++--- test/test/test_eventdev_octeontx.c | 72 ++++++++++++++++++++-------- 5 files changed, 124 insertions(+), 38 deletions(-) diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c index 6b867b3..177dc6b 100644 --- a/lib/librte_eventdev/rte_eventdev.c +++ b/lib/librte_eventdev/rte_eventdev.c @@ -743,13 +743,27 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, return 0; } -uint8_t -rte_event_port_count(uint8_t dev_id) +int +rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id, + uint32_t *attr_value /*out */) { struct rte_eventdev *dev; + if(!attr_value) + return -EINVAL; + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); dev = &rte_eventdevs[dev_id]; - return dev->data->nb_ports; + + switch(attr_id) { + case RTE_EVENT_DEV_ATTR_PORT_COUNT: + *attr_value = dev->data->nb_ports; + break; + case RTE_EVENT_DEV_ATTR_QUEUE_COUNT: + *attr_value = dev->data->nb_queues; + break; + } + + return 0; } int @@ -757,6 +771,10 @@ rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, uint32_t *attr_value /*out */) { struct rte_eventdev *dev; + + if(!attr_value) + return -EINVAL; + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); dev = &rte_eventdevs[dev_id]; if (!is_valid_port(dev, port_id)) { diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h index fadc209..e931eb2 100644 --- a/lib/librte_eventdev/rte_eventdev.h +++ b/lib/librte_eventdev/rte_eventdev.h @@ -715,15 +715,29 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, const struct rte_event_port_conf *port_conf); /** - * Get the number of ports on a specific event device + * The count of ports. + */ +#define RTE_EVENT_DEV_ATTR_PORT_COUNT 0 +/** + * The count of queues. + */ +#define RTE_EVENT_DEV_ATTR_QUEUE_COUNT 1 + +/** + * Get an attribute from a device. * - * @param dev_id - * Event device identifier. - * @return - * - The number of configured ports + * @param dev_id Eventdev id + * @param attr_id The attribute ID to retrieve + * @param[out] attr_value A pointer that will be filled in with the attribute + * value if successful. + * + * @retval 0 Successfully retrieved attribute value + * -EINVAL Invalid device or *attr_id* provided, or *attr_value* + * is NULL */ -uint8_t -rte_event_port_count(uint8_t dev_id); +int +rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id, + uint32_t *attr_value /*out */); /** * The queue depth of the port on the enqueue side diff --git a/lib/librte_eventdev/rte_eventdev_version.map b/lib/librte_eventdev/rte_eventdev_version.map index a0adde3..484a071 100644 --- a/lib/librte_eventdev/rte_eventdev_version.map +++ b/lib/librte_eventdev/rte_eventdev_version.map @@ -21,7 +21,6 @@ DPDK_17.05 { rte_event_port_setup; rte_event_port_dequeue_depth; rte_event_port_enqueue_depth; - rte_event_port_count; rte_event_port_link; rte_event_port_unlink; rte_event_port_links_get; @@ -55,6 +54,7 @@ DPDK_17.08 { EXPERIMENTAL { global: + rte_event_dev_attr_get; rte_event_port_attr_get; } DPDK_17.08; diff --git a/test/test/test_eventdev.c b/test/test/test_eventdev.c index f3ec470..a87b113 100644 --- a/test/test/test_eventdev.c +++ b/test/test/test_eventdev.c @@ -386,11 +386,16 @@ test_eventdev_port_default_conf_get(void) ret = rte_event_port_default_conf_get(TEST_DEV_ID, 0, NULL); TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + ret = rte_event_port_default_conf_get(TEST_DEV_ID, - rte_event_port_count(TEST_DEV_ID) + 1, NULL); + port_count + 1, NULL); TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); - for (i = 0; i < rte_event_port_count(TEST_DEV_ID); i++) { + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_default_conf_get(TEST_DEV_ID, i, &pconf); TEST_ASSERT_SUCCESS(ret, "Failed to get port%d info", i); @@ -436,8 +441,12 @@ test_eventdev_port_setup(void) ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf); TEST_ASSERT_SUCCESS(ret, "Failed to setup port0"); + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); - for (i = 0; i < rte_event_port_count(TEST_DEV_ID); i++) { + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup port%d", i); } @@ -504,8 +513,11 @@ test_eventdev_port_count(void) ret = rte_event_dev_info_get(TEST_DEV_ID, &info); TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info"); - TEST_ASSERT_EQUAL(rte_event_port_count(TEST_DEV_ID), - info.max_event_ports, "Wrong port count"); + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + TEST_ASSERT_EQUAL(port_count, info.max_event_ports, "Wrong port count"); return TEST_SUCCESS; } @@ -537,7 +549,12 @@ test_eventdev_start_stop(void) TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i); } - for (i = 0; i < rte_event_port_count(TEST_DEV_ID); i++) { + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup port%d", i); } @@ -567,7 +584,12 @@ eventdev_setup_device(void) TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i); } - for (i = 0; i < rte_event_port_count(TEST_DEV_ID); i++) { + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup port%d", i); } diff --git a/test/test/test_eventdev_octeontx.c b/test/test/test_eventdev_octeontx.c index 774d030..dfe8611 100644 --- a/test/test/test_eventdev_octeontx.c +++ b/test/test/test_eventdev_octeontx.c @@ -224,7 +224,11 @@ _eventdev_setup(int mode) } } /* Configure event ports */ - for (i = 0; i < rte_event_port_count(evdev); i++) { + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_setup(evdev, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup port=%d", i); ret = rte_event_port_link(evdev, i, NULL, NULL, 0); @@ -651,18 +655,21 @@ static int test_multi_queue_enq_multi_port_deq(void) { const unsigned int total_events = MAX_EVENTS; - uint8_t nr_ports; + uint32_t nr_ports; int ret; ret = generate_random_events(total_events); if (ret) return TEST_FAILED; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); + nr_ports = RTE_MIN(nr_ports, rte_lcore_count() - 1); if (!nr_ports) { printf("%s: Not enough ports=%d or workers=%d\n", __func__, - rte_event_port_count(evdev), rte_lcore_count() - 1); + nr_ports, rte_lcore_count() - 1); return TEST_SUCCESS; } @@ -691,14 +698,18 @@ test_queue_to_port_single_link(void) { int i, nr_links, ret; + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + /* Unlink all connections that created in eventdev_setup */ - for (i = 0; i < rte_event_port_count(evdev); i++) { + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_unlink(evdev, i, NULL, 0); TEST_ASSERT(ret >= 0, "Failed to unlink all queues port=%d", i); } - nr_links = RTE_MIN(rte_event_port_count(evdev), - rte_event_queue_count(evdev)); + nr_links = RTE_MIN(port_count, rte_event_queue_count(evdev)); const unsigned int total_events = MAX_EVENTS / nr_links; /* Link queue x to port x and inject events to queue x through port x */ @@ -750,10 +761,18 @@ static int test_queue_to_port_multi_link(void) { int ret, port0_events = 0, port1_events = 0; - uint8_t nr_queues, nr_ports, queue, port; + uint8_t queue, port; + uint32_t nr_queues = 0; + uint32_t nr_ports = 0; nr_queues = rte_event_queue_count(evdev); - nr_ports = rte_event_port_count(evdev); + + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &nr_queues), "Queue count get failed"); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); if (nr_ports < 2) { printf("%s: Not enough ports to test ports=%d\n", @@ -854,14 +873,17 @@ test_multiport_flow_sched_type_test(uint8_t in_sched_type, uint8_t out_sched_type) { const unsigned int total_events = MAX_EVENTS; - uint8_t nr_ports; + uint32_t nr_ports; int ret; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); + nr_ports = RTE_MIN(nr_ports, rte_lcore_count() - 1); if (!nr_ports) { printf("%s: Not enough ports=%d or workers=%d\n", __func__, - rte_event_port_count(evdev), rte_lcore_count() - 1); + nr_ports, rte_lcore_count() - 1); return TEST_SUCCESS; } @@ -1007,15 +1029,19 @@ test_multiport_queue_sched_type_test(uint8_t in_sched_type, uint8_t out_sched_type) { const unsigned int total_events = MAX_EVENTS; - uint8_t nr_ports; + uint32_t nr_ports; int ret; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); + + nr_ports = RTE_MIN(nr_ports, rte_lcore_count() - 1); if (rte_event_queue_count(evdev) < 2 || !nr_ports) { printf("%s: Not enough queues=%d ports=%d or workers=%d\n", __func__, rte_event_queue_count(evdev), - rte_event_port_count(evdev), rte_lcore_count() - 1); + nr_ports, rte_lcore_count() - 1); return TEST_SUCCESS; } @@ -1142,14 +1168,17 @@ worker_flow_based_pipeline_max_stages_rand_sched_type(void *arg) static int launch_multi_port_max_stages_random_sched_type(int (*fn)(void *)) { - uint8_t nr_ports; + uint32_t nr_ports; int ret; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); + nr_ports = RTE_MIN(nr_ports, rte_lcore_count() - 1); if (!nr_ports) { printf("%s: Not enough ports=%d or workers=%d\n", __func__, - rte_event_port_count(evdev), rte_lcore_count() - 1); + nr_ports, rte_lcore_count() - 1); return TEST_SUCCESS; } @@ -1288,9 +1317,12 @@ worker_ordered_flow_producer(void *arg) static inline int test_producer_consumer_ingress_order_test(int (*fn)(void *)) { - uint8_t nr_ports; + uint32_t nr_ports; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); + nr_ports = RTE_MIN(nr_ports, rte_lcore_count() - 1); if (rte_lcore_count() < 3 || nr_ports < 2) { printf("### Not enough cores for %s test.\n", __func__); -- 2.7.4 ^ permalink raw reply [flat|nested] 35+ messages in thread
* [dpdk-dev] [PATCH v2 3/4] eventdev: add queue attribute function 2017-09-08 15:18 ` [dpdk-dev] [PATCH v2 0/3] eventdev: add attribute based get APIs Harry van Haaren 2017-09-08 15:18 ` [dpdk-dev] [PATCH v2 1/4] eventdev: add port attribute function Harry van Haaren 2017-09-08 15:18 ` [dpdk-dev] [PATCH v2 2/4] eventdev: add dev attribute get function Harry van Haaren @ 2017-09-08 15:18 ` Harry van Haaren 2017-09-08 15:18 ` [dpdk-dev] [PATCH v2 4/4] eventdev: add device started attribute Harry van Haaren 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 0/4] eventdev: add attribute based get APIs Harry van Haaren 4 siblings, 0 replies; 35+ messages in thread From: Harry van Haaren @ 2017-09-08 15:18 UTC (permalink / raw) To: dev; +Cc: jerin.jacob, Harry van Haaren This commit adds a generic queue attribute function. It also removes the previous rte_event_queue_priority() and priority() functions, and updates the map files and unit tests to use the new attr functions. Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> --- lib/librte_eventdev/rte_eventdev.c | 47 ++++++++-------- lib/librte_eventdev/rte_eventdev.h | 49 ++++++++--------- lib/librte_eventdev/rte_eventdev_version.map | 3 +- test/test/test_eventdev.c | 80 +++++++++++++++++++++------- test/test/test_eventdev_octeontx.c | 75 +++++++++++++++++++------- 5 files changed, 166 insertions(+), 88 deletions(-) diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c index 177dc6b..85c0960 100644 --- a/lib/librte_eventdev/rte_eventdev.c +++ b/lib/librte_eventdev/rte_eventdev.c @@ -609,27 +609,6 @@ rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id, return (*dev->dev_ops->queue_setup)(dev, queue_id, queue_conf); } -uint8_t -rte_event_queue_count(uint8_t dev_id) -{ - struct rte_eventdev *dev; - - dev = &rte_eventdevs[dev_id]; - return dev->data->nb_queues; -} - -uint8_t -rte_event_queue_priority(uint8_t dev_id, uint8_t queue_id) -{ - struct rte_eventdev *dev; - - dev = &rte_eventdevs[dev_id]; - if (dev->data->event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_QOS) - return dev->data->queues_prio[queue_id]; - else - return RTE_EVENT_DEV_PRIORITY_NORMAL; -} - static inline int is_valid_port(struct rte_eventdev *dev, uint8_t port_id) { @@ -794,6 +773,32 @@ rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, } int +rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id, + uint32_t *attr_value /*out */) +{ + struct rte_eventdev *dev; + + if(!attr_value) + return -EINVAL; + + 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; + } + + 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]; + break; + }; + return 0; +} + +int rte_event_port_link(uint8_t dev_id, uint8_t port_id, const uint8_t queues[], const uint8_t priorities[], uint16_t nb_links) diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h index e931eb2..cd3026d 100644 --- a/lib/librte_eventdev/rte_eventdev.h +++ b/lib/librte_eventdev/rte_eventdev.h @@ -606,33 +606,6 @@ int rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id, const struct rte_event_queue_conf *queue_conf); -/** - * Get the number of event queues on a specific event device - * - * @param dev_id - * Event device identifier. - * @return - * - The number of configured event queues - */ -uint8_t -rte_event_queue_count(uint8_t dev_id); - -/** - * Get the priority of the event queue on a specific event device - * - * @param dev_id - * Event device identifier. - * @param queue_id - * Event queue identifier. - * @return - * - If the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability then the - * configured priority of the event queue in - * [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST] range - * else the value RTE_EVENT_DEV_PRIORITY_NORMAL - */ -uint8_t -rte_event_queue_priority(uint8_t dev_id, uint8_t queue_id); - /* Event port specific APIs */ /** Event port configuration structure */ @@ -765,6 +738,28 @@ rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, uint32_t *attr_value /*out */); /** + * The priority of the queue. + */ +#define RTE_EVENT_QUEUE_ATTR_PRIORITY 0 + +/** + * Get an attribute from a queue. + * + * @param dev_id Eventdev id + * @param queue_id Eventdev queue id + * @param attr_id The attribute ID to retrieve + * @param[out] attr_value A pointer that will be filled in with the attribute + * value if successful + * + * @retval 0 Successfully returned value + * -EINVAL invalid device, queue or attr_id provided, or attr_value + * was NULL + */ +int +rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id, + uint32_t *attr_value /*out */); + +/** * Start an event device. * * The device start step is the last one and consists of setting the event diff --git a/lib/librte_eventdev/rte_eventdev_version.map b/lib/librte_eventdev/rte_eventdev_version.map index 484a071..c3854f4 100644 --- a/lib/librte_eventdev/rte_eventdev_version.map +++ b/lib/librte_eventdev/rte_eventdev_version.map @@ -27,8 +27,6 @@ DPDK_17.05 { rte_event_queue_default_conf_get; rte_event_queue_setup; - rte_event_queue_count; - rte_event_queue_priority; rte_event_dequeue_timeout_ticks; @@ -56,5 +54,6 @@ EXPERIMENTAL { rte_event_dev_attr_get; rte_event_port_attr_get; + rte_event_queue_attr_get; } DPDK_17.08; diff --git a/test/test/test_eventdev.c b/test/test/test_eventdev.c index a87b113..9b738e0 100644 --- a/test/test/test_eventdev.c +++ b/test/test/test_eventdev.c @@ -273,7 +273,12 @@ test_eventdev_queue_default_conf_get(void) ret = rte_event_queue_default_conf_get(TEST_DEV_ID, 0, NULL); TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_default_conf_get(TEST_DEV_ID, i, &qconf); TEST_ASSERT_SUCCESS(ret, "Failed to get queue%d info", i); @@ -318,8 +323,12 @@ test_eventdev_queue_setup(void) ret = rte_event_queue_setup(TEST_DEV_ID, 0, &qconf); TEST_ASSERT_SUCCESS(ret, "Failed to setup queue0"); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i); } @@ -336,8 +345,12 @@ test_eventdev_queue_count(void) ret = rte_event_dev_info_get(TEST_DEV_ID, &info); TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info"); - TEST_ASSERT_EQUAL(rte_event_queue_count(TEST_DEV_ID), - info.max_event_queues, "Wrong queue count"); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + TEST_ASSERT_EQUAL(queue_count, info.max_event_queues, + "Wrong queue count"); return TEST_SUCCESS; } @@ -353,7 +366,12 @@ test_eventdev_queue_priority(void) ret = rte_event_dev_info_get(TEST_DEV_ID, &info); TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info"); - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_default_conf_get(TEST_DEV_ID, i, &qconf); TEST_ASSERT_SUCCESS(ret, "Failed to get queue%d def conf", i); @@ -362,8 +380,13 @@ test_eventdev_queue_priority(void) TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i); } - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { - priority = rte_event_queue_priority(TEST_DEV_ID, i); + for (i = 0; i < (int)queue_count; i++) { + uint32_t tmp; + TEST_ASSERT_SUCCESS(rte_event_queue_attr_get(TEST_DEV_ID, i, + RTE_EVENT_QUEUE_ATTR_PRIORITY, &tmp), + "Queue count get failed"); + priority = tmp; + if (info.event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_QOS) TEST_ASSERT_EQUAL(priority, i % RTE_EVENT_DEV_PRIORITY_LOWEST, @@ -544,7 +567,11 @@ test_eventdev_start_stop(void) ret = eventdev_configure_setup(); TEST_ASSERT_SUCCESS(ret, "Failed to configure eventdev"); - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i); } @@ -560,8 +587,8 @@ test_eventdev_start_stop(void) } ret = rte_event_port_link(TEST_DEV_ID, 0, NULL, NULL, 0); - TEST_ASSERT(ret == rte_event_queue_count(TEST_DEV_ID), - "Failed to link port, device %d", TEST_DEV_ID); + TEST_ASSERT(ret == (int)queue_count, "Failed to link port, device %d", + TEST_DEV_ID); ret = rte_event_dev_start(TEST_DEV_ID); TEST_ASSERT_SUCCESS(ret, "Failed to start device%d", TEST_DEV_ID); @@ -579,7 +606,11 @@ eventdev_setup_device(void) ret = eventdev_configure_setup(); TEST_ASSERT_SUCCESS(ret, "Failed to configure eventdev"); - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i); } @@ -595,8 +626,8 @@ eventdev_setup_device(void) } ret = rte_event_port_link(TEST_DEV_ID, 0, NULL, NULL, 0); - TEST_ASSERT(ret == rte_event_queue_count(TEST_DEV_ID), - "Failed to link port, device %d", TEST_DEV_ID); + TEST_ASSERT(ret == (int)queue_count, "Failed to link port, device %d", + TEST_DEV_ID); ret = rte_event_dev_start(TEST_DEV_ID); TEST_ASSERT_SUCCESS(ret, "Failed to start device%d", TEST_DEV_ID); @@ -621,7 +652,11 @@ test_eventdev_link(void) TEST_ASSERT(ret >= 0, "Failed to link with NULL device%d", TEST_DEV_ID); - nb_queues = rte_event_queue_count(TEST_DEV_ID); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + nb_queues = queue_count; for (i = 0; i < nb_queues; i++) { queues[i] = i; priorities[i] = RTE_EVENT_DEV_PRIORITY_NORMAL; @@ -644,7 +679,11 @@ test_eventdev_unlink(void) TEST_ASSERT(ret >= 0, "Failed to unlink with NULL device%d", TEST_DEV_ID); - nb_queues = rte_event_queue_count(TEST_DEV_ID); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + nb_queues = queue_count; for (i = 0; i < nb_queues; i++) queues[i] = i; @@ -658,7 +697,7 @@ test_eventdev_unlink(void) static int test_eventdev_link_get(void) { - int ret, nb_queues, i; + int ret, i; uint8_t queues[RTE_EVENT_MAX_QUEUES_PER_DEV]; uint8_t priorities[RTE_EVENT_MAX_QUEUES_PER_DEV]; @@ -667,7 +706,11 @@ test_eventdev_link_get(void) TEST_ASSERT(ret >= 0, "Failed to link with NULL device%d", TEST_DEV_ID); - nb_queues = rte_event_queue_count(TEST_DEV_ID); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + const int nb_queues = queue_count; for (i = 0; i < nb_queues; i++) queues[i] = i; @@ -679,7 +722,6 @@ test_eventdev_link_get(void) TEST_ASSERT(ret == 0, "(%d)Wrong link get=%d", TEST_DEV_ID, ret); /* link all queues and get the links */ - nb_queues = rte_event_queue_count(TEST_DEV_ID); for (i = 0; i < nb_queues; i++) { queues[i] = i; priorities[i] = RTE_EVENT_DEV_PRIORITY_NORMAL; @@ -709,8 +751,8 @@ test_eventdev_link_get(void) ret = rte_event_port_unlink(TEST_DEV_ID, 0, NULL, 0); TEST_ASSERT(ret == nb_queues, "Failed to unlink(device%d) ret=%d", TEST_DEV_ID, ret); + /* 4links and 2 unlinks */ - nb_queues = rte_event_queue_count(TEST_DEV_ID); if (nb_queues >= 4) { for (i = 0; i < 4; i++) { queues[i] = i; diff --git a/test/test/test_eventdev_octeontx.c b/test/test/test_eventdev_octeontx.c index dfe8611..b88b0d2 100644 --- a/test/test/test_eventdev_octeontx.c +++ b/test/test/test_eventdev_octeontx.c @@ -193,8 +193,13 @@ _eventdev_setup(int mode) ret = rte_event_dev_configure(evdev, &dev_conf); TEST_ASSERT_SUCCESS(ret, "Failed to configure eventdev"); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + if (mode == TEST_EVENTDEV_SETUP_PRIORITY) { - if (rte_event_queue_count(evdev) > 8) { + if (queue_count > 8) { printf("test expects the unique priority per queue\n"); return -ENOTSUP; } @@ -204,8 +209,8 @@ _eventdev_setup(int mode) * RTE_EVENT_DEV_PRIORITY_LOWEST */ uint8_t step = (RTE_EVENT_DEV_PRIORITY_LOWEST + 1) / - rte_event_queue_count(evdev); - for (i = 0; i < rte_event_queue_count(evdev); i++) { + queue_count; + for (i = 0; i < (int)queue_count; i++) { struct rte_event_queue_conf queue_conf; ret = rte_event_queue_default_conf_get(evdev, i, @@ -218,7 +223,7 @@ _eventdev_setup(int mode) } else { /* Configure event queues with default priority */ - for (i = 0; i < rte_event_queue_count(evdev); i++) { + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_setup(evdev, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup queue=%d", i); } @@ -339,6 +344,11 @@ generate_random_events(const unsigned int total_events) unsigned int i; int ret; + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + ret = rte_event_dev_info_get(evdev, &info); TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info"); for (i = 0; i < total_events; i++) { @@ -347,7 +357,7 @@ generate_random_events(const unsigned int total_events) rte_rand() % (RTE_EVENT_TYPE_CPU + 1) /* event_type */, rte_rand() % 256 /* sub_event_type */, rte_rand() % (RTE_SCHED_TYPE_PARALLEL + 1), - rte_rand() % rte_event_queue_count(evdev) /* queue */, + rte_rand() % queue_count /* queue */, 0 /* port */, 1 /* events */); if (ret) @@ -486,7 +496,7 @@ test_multi_queue_enq_single_port_deq(void) } /* - * Inject 0..MAX_EVENTS events over 0..rte_event_queue_count() with modulus + * Inject 0..MAX_EVENTS events over 0..queue_count with modulus * operation * * For example, Inject 32 events over 0..7 queues @@ -502,15 +512,19 @@ test_multi_queue_enq_single_port_deq(void) static int validate_queue_priority(uint32_t index, uint8_t port, struct rte_event *ev) { - uint32_t range = MAX_EVENTS / rte_event_queue_count(evdev); - uint32_t expected_val = (index % range) * rte_event_queue_count(evdev); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + uint32_t range = MAX_EVENTS / queue_count; + uint32_t expected_val = (index % range) * queue_count; expected_val += ev->queue_id; RTE_SET_USED(port); TEST_ASSERT_EQUAL(ev->mbuf->seqn, expected_val, "seqn=%d index=%d expected=%d range=%d nb_queues=%d max_event=%d", ev->mbuf->seqn, index, expected_val, range, - rte_event_queue_count(evdev), MAX_EVENTS); + queue_count, MAX_EVENTS); return 0; } @@ -522,8 +536,12 @@ test_multi_queue_priority(void) int i, max_evts_roundoff; /* See validate_queue_priority() comments for priority validate logic */ - max_evts_roundoff = MAX_EVENTS / rte_event_queue_count(evdev); - max_evts_roundoff *= rte_event_queue_count(evdev); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + max_evts_roundoff = MAX_EVENTS / queue_count; + max_evts_roundoff *= queue_count; for (i = 0; i < max_evts_roundoff; i++) { struct rte_event ev = {.event = 0, .u64 = 0}; @@ -532,7 +550,7 @@ test_multi_queue_priority(void) TEST_ASSERT_NOT_NULL(m, "mempool alloc failed"); m->seqn = i; - queue = i % rte_event_queue_count(evdev); + queue = i % queue_count; update_event_and_validation_attr(m, &ev, 0, RTE_EVENT_TYPE_CPU, 0, RTE_SCHED_TYPE_PARALLEL, queue, 0); rte_event_enqueue_burst(evdev, 0, &ev, 1); @@ -709,7 +727,12 @@ test_queue_to_port_single_link(void) TEST_ASSERT(ret >= 0, "Failed to unlink all queues port=%d", i); } - nr_links = RTE_MIN(port_count, rte_event_queue_count(evdev)); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + + nr_links = RTE_MIN(port_count, queue_count); const unsigned int total_events = MAX_EVENTS / nr_links; /* Link queue x to port x and inject events to queue x through port x */ @@ -765,7 +788,9 @@ test_queue_to_port_multi_link(void) uint32_t nr_queues = 0; uint32_t nr_ports = 0; - nr_queues = rte_event_queue_count(evdev); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &nr_queues), "Queue count get failed"); TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, RTE_EVENT_DEV_ATTR_QUEUE_COUNT, @@ -1038,10 +1063,14 @@ test_multiport_queue_sched_type_test(uint8_t in_sched_type, nr_ports = RTE_MIN(nr_ports, rte_lcore_count() - 1); - if (rte_event_queue_count(evdev) < 2 || !nr_ports) { + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + if (queue_count < 2 || !nr_ports) { printf("%s: Not enough queues=%d ports=%d or workers=%d\n", - __func__, rte_event_queue_count(evdev), - nr_ports, rte_lcore_count() - 1); + __func__, queue_count, nr_ports, + rte_lcore_count() - 1); return TEST_SUCCESS; } @@ -1213,7 +1242,11 @@ worker_queue_based_pipeline_max_stages_rand_sched_type(void *arg) struct rte_event ev; uint16_t valid_event; uint8_t port = param->port; - uint8_t nr_queues = rte_event_queue_count(evdev); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + uint8_t nr_queues = queue_count; rte_atomic32_t *total_events = param->total_events; while (rte_atomic32_read(total_events) > 0) { @@ -1251,7 +1284,11 @@ worker_mixed_pipeline_max_stages_rand_sched_type(void *arg) struct rte_event ev; uint16_t valid_event; uint8_t port = param->port; - uint8_t nr_queues = rte_event_queue_count(evdev); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + uint8_t nr_queues = queue_count; rte_atomic32_t *total_events = param->total_events; while (rte_atomic32_read(total_events) > 0) { -- 2.7.4 ^ permalink raw reply [flat|nested] 35+ messages in thread
* [dpdk-dev] [PATCH v2 4/4] eventdev: add device started attribute 2017-09-08 15:18 ` [dpdk-dev] [PATCH v2 0/3] eventdev: add attribute based get APIs Harry van Haaren ` (2 preceding siblings ...) 2017-09-08 15:18 ` [dpdk-dev] [PATCH v2 3/4] eventdev: add queue attribute function Harry van Haaren @ 2017-09-08 15:18 ` Harry van Haaren 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 0/4] eventdev: add attribute based get APIs Harry van Haaren 4 siblings, 0 replies; 35+ messages in thread From: Harry van Haaren @ 2017-09-08 15:18 UTC (permalink / raw) To: dev; +Cc: jerin.jacob, Harry van Haaren This commit adds an attribute to the eventdev, allowing applications to retrieve if the eventdev is running or stopped. Note that no API or ABI changes were required in adding the statistic, and code changes are minimal. Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> --- lib/librte_eventdev/rte_eventdev.c | 3 +++ lib/librte_eventdev/rte_eventdev.h | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c index 85c0960..9ec5d42 100644 --- a/lib/librte_eventdev/rte_eventdev.c +++ b/lib/librte_eventdev/rte_eventdev.c @@ -740,6 +740,9 @@ rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id, case RTE_EVENT_DEV_ATTR_QUEUE_COUNT: *attr_value = dev->data->nb_queues; break; + case RTE_EVENT_DEV_ATTR_STARTED: + *attr_value = dev->data->dev_started; + break; } return 0; diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h index cd3026d..f76d9f9 100644 --- a/lib/librte_eventdev/rte_eventdev.h +++ b/lib/librte_eventdev/rte_eventdev.h @@ -695,6 +695,10 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, * The count of queues. */ #define RTE_EVENT_DEV_ATTR_QUEUE_COUNT 1 +/** + * The state of the device, returns zero if stopped, non-zero when running. + */ +#define RTE_EVENT_DEV_ATTR_STARTED 2 /** * Get an attribute from a device. -- 2.7.4 ^ permalink raw reply [flat|nested] 35+ messages in thread
* [dpdk-dev] [PATCH v3 0/4] eventdev: add attribute based get APIs 2017-09-08 15:18 ` [dpdk-dev] [PATCH v2 0/3] eventdev: add attribute based get APIs Harry van Haaren ` (3 preceding siblings ...) 2017-09-08 15:18 ` [dpdk-dev] [PATCH v2 4/4] eventdev: add device started attribute Harry van Haaren @ 2017-09-08 15:36 ` Harry van Haaren 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 1/4] eventdev: add port attribute function Harry van Haaren ` (5 more replies) 4 siblings, 6 replies; 35+ messages in thread From: Harry van Haaren @ 2017-09-08 15:36 UTC (permalink / raw) To: dev; +Cc: jerin.jacob, Harry van Haaren This patchset refactors the eventdev API to be more flexible and capable. In particular, the API is capable of returning an error value if an invalid device, port or attribute ID is passed in, which was not possible with the previous APIs. The implementation of this patchset is based on a v1 patch[1], and after some discussion this API was seen as the best solution. In terms of flexibility, the attribute id allows addition of new common eventdev layer attributes without breaking ABI or adding new functions. Note that these attributes are not data-path, and that PMDs should continue to use the xstats API for reporting any unique PMD statistics that are available. Regarding API/ABI compatibility, I have removed the functions from the .map files - please review the .map file changes for ABI issues carefully. The last patch of this series adds a started attribute to the device, allowing the application to query if a device is currently running. -Harry [1] http://dpdk.org/dev/patchwork/patch/27152/ --- v3: - Fix checkpatch issues... somehow I broke my checkpatch script :/ v2: - New APIs design based on discussion of initial patch. Harry van Haaren (4): eventdev: add port attribute function eventdev: add dev attribute get function eventdev: add queue attribute function eventdev: add device started attribute lib/librte_eventdev/rte_eventdev.c | 91 +++++++++++------ lib/librte_eventdev/rte_eventdev.h | 118 +++++++++++----------- lib/librte_eventdev/rte_eventdev_version.map | 12 ++- test/test/test_eventdev.c | 132 +++++++++++++++++++------ test/test/test_eventdev_octeontx.c | 143 ++++++++++++++++++++------- 5 files changed, 340 insertions(+), 156 deletions(-) -- 2.7.4 ^ permalink raw reply [flat|nested] 35+ messages in thread
* [dpdk-dev] [PATCH v3 1/4] eventdev: add port attribute function 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 0/4] eventdev: add attribute based get APIs Harry van Haaren @ 2017-09-08 15:36 ` Harry van Haaren 2017-09-11 16:35 ` Jerin Jacob 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 2/4] eventdev: add dev attribute get function Harry van Haaren ` (4 subsequent siblings) 5 siblings, 1 reply; 35+ messages in thread From: Harry van Haaren @ 2017-09-08 15:36 UTC (permalink / raw) To: dev; +Cc: jerin.jacob, Harry van Haaren This commit reworks the port functions to retrieve information about the port, like the enq or deq depths. Note that "port count" is a device attribute, and is added in a later patch for dev attributes. Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> --- lib/librte_eventdev/rte_eventdev.c | 33 +++++++++++-------- lib/librte_eventdev/rte_eventdev.h | 49 ++++++++++++---------------- lib/librte_eventdev/rte_eventdev_version.map | 7 ++++ test/test/test_eventdev.c | 16 ++++++--- 4 files changed, 59 insertions(+), 46 deletions(-) diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c index bbb3805..a02ff0a 100644 --- a/lib/librte_eventdev/rte_eventdev.c +++ b/lib/librte_eventdev/rte_eventdev.c @@ -744,30 +744,35 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, } uint8_t -rte_event_port_dequeue_depth(uint8_t dev_id, uint8_t port_id) +rte_event_port_count(uint8_t dev_id) { struct rte_eventdev *dev; dev = &rte_eventdevs[dev_id]; - return dev->data->ports_dequeue_depth[port_id]; + return dev->data->nb_ports; } -uint8_t -rte_event_port_enqueue_depth(uint8_t dev_id, uint8_t port_id) +int +rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, + uint32_t *attr_value /*out */) { struct rte_eventdev *dev; - + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); dev = &rte_eventdevs[dev_id]; - return dev->data->ports_enqueue_depth[port_id]; -} - -uint8_t -rte_event_port_count(uint8_t dev_id) -{ - struct rte_eventdev *dev; + if (!is_valid_port(dev, port_id)) { + RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id); + return -EINVAL; + } - dev = &rte_eventdevs[dev_id]; - return dev->data->nb_ports; + switch (attr_id) { + case RTE_EVENT_PORT_ATTR_ENQ_DEPTH: + *attr_value = dev->data->ports_enqueue_depth[port_id]; + break; + case RTE_EVENT_PORT_ATTR_DEQ_DEPTH: + *attr_value = dev->data->ports_dequeue_depth[port_id]; + break; + }; + return 0; } int diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h index 128bc52..fadc209 100644 --- a/lib/librte_eventdev/rte_eventdev.h +++ b/lib/librte_eventdev/rte_eventdev.h @@ -715,47 +715,40 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, const struct rte_event_port_conf *port_conf); /** - * Get the number of dequeue queue depth configured for event port designated - * by its *port_id* on a specific event device + * Get the number of ports on a specific event device * * @param dev_id * Event device identifier. - * @param port_id - * Event port identifier. * @return - * - The number of configured dequeue queue depth - * - * @see rte_event_dequeue_burst() + * - The number of configured ports */ uint8_t -rte_event_port_dequeue_depth(uint8_t dev_id, uint8_t port_id); +rte_event_port_count(uint8_t dev_id); /** - * Get the number of enqueue queue depth configured for event port designated - * by its *port_id* on a specific event device - * - * @param dev_id - * Event device identifier. - * @param port_id - * Event port identifier. - * @return - * - The number of configured enqueue queue depth - * - * @see rte_event_enqueue_burst() + * The queue depth of the port on the enqueue side */ -uint8_t -rte_event_port_enqueue_depth(uint8_t dev_id, uint8_t port_id); +#define RTE_EVENT_PORT_ATTR_ENQ_DEPTH 0 +/** + * The queue depth of the port on the dequeue side + */ +#define RTE_EVENT_PORT_ATTR_DEQ_DEPTH 1 /** - * Get the number of ports on a specific event device + * Get an attribute from a port. * - * @param dev_id - * Event device identifier. - * @return - * - The number of configured ports + * @param dev_id Eventdev id + * @param port_id Eventdev port id + * @param attr_id The attribute ID to retrieve + * @param[out] attr_value A pointer that will be filled in with the attribute + * value if successful + * + * @retval 0 Successfully returned value + * -EINVAL Invalid device, port or attr_id, or attr_value was NULL */ -uint8_t -rte_event_port_count(uint8_t dev_id); +int +rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, + uint32_t *attr_value /*out */); /** * Start an event device. diff --git a/lib/librte_eventdev/rte_eventdev_version.map b/lib/librte_eventdev/rte_eventdev_version.map index 4c48e5f..a0adde3 100644 --- a/lib/librte_eventdev/rte_eventdev_version.map +++ b/lib/librte_eventdev/rte_eventdev_version.map @@ -51,3 +51,10 @@ DPDK_17.08 { rte_event_ring_init; rte_event_ring_lookup; } DPDK_17.05; + +EXPERIMENTAL { + global: + + rte_event_port_attr_get; + +} DPDK_17.08; diff --git a/test/test/test_eventdev.c b/test/test/test_eventdev.c index f766191..f3ec470 100644 --- a/test/test/test_eventdev.c +++ b/test/test/test_eventdev.c @@ -460,8 +460,12 @@ test_eventdev_dequeue_depth(void) ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf); TEST_ASSERT_SUCCESS(ret, "Failed to setup port0"); - TEST_ASSERT_EQUAL(rte_event_port_dequeue_depth(TEST_DEV_ID, 0), - pconf.dequeue_depth, "Wrong port dequeue depth"); + 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"); + TEST_ASSERT_EQUAL(value, pconf.dequeue_depth, + "Wrong port dequeue depth"); return TEST_SUCCESS; } @@ -481,8 +485,12 @@ test_eventdev_enqueue_depth(void) ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf); TEST_ASSERT_SUCCESS(ret, "Failed to setup port0"); - TEST_ASSERT_EQUAL(rte_event_port_enqueue_depth(TEST_DEV_ID, 0), - pconf.enqueue_depth, "Wrong port enqueue depth"); + 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"); + TEST_ASSERT_EQUAL(value, pconf.dequeue_depth, + "Wrong port enqueue depth"); return TEST_SUCCESS; } -- 2.7.4 ^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [dpdk-dev] [PATCH v3 1/4] eventdev: add port attribute function 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 1/4] eventdev: add port attribute function Harry van Haaren @ 2017-09-11 16:35 ` Jerin Jacob 0 siblings, 0 replies; 35+ messages in thread From: Jerin Jacob @ 2017-09-11 16:35 UTC (permalink / raw) To: Harry van Haaren; +Cc: dev -----Original Message----- > Date: Fri, 8 Sep 2017 16:36:52 +0100 > From: Harry van Haaren <harry.van.haaren@intel.com> > To: dev@dpdk.org > CC: jerin.jacob@caviumnetworks.com, Harry van Haaren > <harry.van.haaren@intel.com> > Subject: [PATCH v3 1/4] eventdev: add port attribute function > X-Mailer: git-send-email 2.7.4 > > This commit reworks the port functions to retrieve information > about the port, like the enq or deq depths. Note that "port count" > is a device attribute, and is added in a later patch for dev attributes. > > Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> > --- > lib/librte_eventdev/rte_eventdev.c | 33 +++++++++++-------- > lib/librte_eventdev/rte_eventdev.h | 49 ++++++++++++---------------- > lib/librte_eventdev/rte_eventdev_version.map | 7 ++++ > test/test/test_eventdev.c | 16 ++++++--- > 4 files changed, 59 insertions(+), 46 deletions(-) > > - > -uint8_t > -rte_event_port_count(uint8_t dev_id) > -{ > - struct rte_eventdev *dev; > + if (!is_valid_port(dev, port_id)) { > + RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id); > + return -EINVAL; > + } > > - dev = &rte_eventdevs[dev_id]; > - return dev->data->nb_ports; > + switch (attr_id) { > + case RTE_EVENT_PORT_ATTR_ENQ_DEPTH: > + *attr_value = dev->data->ports_enqueue_depth[port_id]; > + break; > + case RTE_EVENT_PORT_ATTR_DEQ_DEPTH: > + *attr_value = dev->data->ports_dequeue_depth[port_id]; > + break; IMO, We should have "default:" case here to detect invalid attr_id here and return the error code accordingly in the header file as well. > + }; > + return 0; > } > /** > * Start an event device. > diff --git a/lib/librte_eventdev/rte_eventdev_version.map b/lib/librte_eventdev/rte_eventdev_version.map > index 4c48e5f..a0adde3 100644 > --- a/lib/librte_eventdev/rte_eventdev_version.map > +++ b/lib/librte_eventdev/rte_eventdev_version.map > @@ -51,3 +51,10 @@ DPDK_17.08 { > rte_event_ring_init; > rte_event_ring_lookup; We should delete the remove functions from here. like rte_event_port_dequeue_depth() and rte_event_port_enqueue_depth; > } DPDK_17.05; > + > +EXPERIMENTAL { Note sure we need to add EXPERIMENTAL here.(i.e other section don't have this) > + global: > + > + rte_event_port_attr_get; > + > +} DPDK_17.08; ^ permalink raw reply [flat|nested] 35+ messages in thread
* [dpdk-dev] [PATCH v3 2/4] eventdev: add dev attribute get function 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 0/4] eventdev: add attribute based get APIs Harry van Haaren 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 1/4] eventdev: add port attribute function Harry van Haaren @ 2017-09-08 15:36 ` Harry van Haaren 2017-09-11 16:51 ` Jerin Jacob 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 3/4] eventdev: add queue attribute function Harry van Haaren ` (3 subsequent siblings) 5 siblings, 1 reply; 35+ messages in thread From: Harry van Haaren @ 2017-09-08 15:36 UTC (permalink / raw) To: dev; +Cc: jerin.jacob, Harry van Haaren This commit adds a device attribute function, allowing flexible fetching of device attributes, like port count or queue count. The unit tests and .map file are updated to the new function. Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> --- lib/librte_eventdev/rte_eventdev.c | 24 ++++++++-- lib/librte_eventdev/rte_eventdev.h | 28 ++++++++--- lib/librte_eventdev/rte_eventdev_version.map | 2 +- test/test/test_eventdev.c | 36 +++++++++++--- test/test/test_eventdev_octeontx.c | 72 ++++++++++++++++++++-------- 5 files changed, 124 insertions(+), 38 deletions(-) diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c index a02ff0a..4b1c0be 100644 --- a/lib/librte_eventdev/rte_eventdev.c +++ b/lib/librte_eventdev/rte_eventdev.c @@ -743,13 +743,27 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, return 0; } -uint8_t -rte_event_port_count(uint8_t dev_id) +int +rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id, + uint32_t *attr_value /*out */) { struct rte_eventdev *dev; + if (!attr_value) + return -EINVAL; + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); dev = &rte_eventdevs[dev_id]; - return dev->data->nb_ports; + + switch (attr_id) { + case RTE_EVENT_DEV_ATTR_PORT_COUNT: + *attr_value = dev->data->nb_ports; + break; + case RTE_EVENT_DEV_ATTR_QUEUE_COUNT: + *attr_value = dev->data->nb_queues; + break; + } + + return 0; } int @@ -757,6 +771,10 @@ rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, uint32_t *attr_value /*out */) { struct rte_eventdev *dev; + + if (!attr_value) + return -EINVAL; + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); dev = &rte_eventdevs[dev_id]; if (!is_valid_port(dev, port_id)) { diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h index fadc209..e931eb2 100644 --- a/lib/librte_eventdev/rte_eventdev.h +++ b/lib/librte_eventdev/rte_eventdev.h @@ -715,15 +715,29 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, const struct rte_event_port_conf *port_conf); /** - * Get the number of ports on a specific event device + * The count of ports. + */ +#define RTE_EVENT_DEV_ATTR_PORT_COUNT 0 +/** + * The count of queues. + */ +#define RTE_EVENT_DEV_ATTR_QUEUE_COUNT 1 + +/** + * Get an attribute from a device. * - * @param dev_id - * Event device identifier. - * @return - * - The number of configured ports + * @param dev_id Eventdev id + * @param attr_id The attribute ID to retrieve + * @param[out] attr_value A pointer that will be filled in with the attribute + * value if successful. + * + * @retval 0 Successfully retrieved attribute value + * -EINVAL Invalid device or *attr_id* provided, or *attr_value* + * is NULL */ -uint8_t -rte_event_port_count(uint8_t dev_id); +int +rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id, + uint32_t *attr_value /*out */); /** * The queue depth of the port on the enqueue side diff --git a/lib/librte_eventdev/rte_eventdev_version.map b/lib/librte_eventdev/rte_eventdev_version.map index a0adde3..484a071 100644 --- a/lib/librte_eventdev/rte_eventdev_version.map +++ b/lib/librte_eventdev/rte_eventdev_version.map @@ -21,7 +21,6 @@ DPDK_17.05 { rte_event_port_setup; rte_event_port_dequeue_depth; rte_event_port_enqueue_depth; - rte_event_port_count; rte_event_port_link; rte_event_port_unlink; rte_event_port_links_get; @@ -55,6 +54,7 @@ DPDK_17.08 { EXPERIMENTAL { global: + rte_event_dev_attr_get; rte_event_port_attr_get; } DPDK_17.08; diff --git a/test/test/test_eventdev.c b/test/test/test_eventdev.c index f3ec470..a87b113 100644 --- a/test/test/test_eventdev.c +++ b/test/test/test_eventdev.c @@ -386,11 +386,16 @@ test_eventdev_port_default_conf_get(void) ret = rte_event_port_default_conf_get(TEST_DEV_ID, 0, NULL); TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + ret = rte_event_port_default_conf_get(TEST_DEV_ID, - rte_event_port_count(TEST_DEV_ID) + 1, NULL); + port_count + 1, NULL); TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); - for (i = 0; i < rte_event_port_count(TEST_DEV_ID); i++) { + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_default_conf_get(TEST_DEV_ID, i, &pconf); TEST_ASSERT_SUCCESS(ret, "Failed to get port%d info", i); @@ -436,8 +441,12 @@ test_eventdev_port_setup(void) ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf); TEST_ASSERT_SUCCESS(ret, "Failed to setup port0"); + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); - for (i = 0; i < rte_event_port_count(TEST_DEV_ID); i++) { + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup port%d", i); } @@ -504,8 +513,11 @@ test_eventdev_port_count(void) ret = rte_event_dev_info_get(TEST_DEV_ID, &info); TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info"); - TEST_ASSERT_EQUAL(rte_event_port_count(TEST_DEV_ID), - info.max_event_ports, "Wrong port count"); + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + TEST_ASSERT_EQUAL(port_count, info.max_event_ports, "Wrong port count"); return TEST_SUCCESS; } @@ -537,7 +549,12 @@ test_eventdev_start_stop(void) TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i); } - for (i = 0; i < rte_event_port_count(TEST_DEV_ID); i++) { + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup port%d", i); } @@ -567,7 +584,12 @@ eventdev_setup_device(void) TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i); } - for (i = 0; i < rte_event_port_count(TEST_DEV_ID); i++) { + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup port%d", i); } diff --git a/test/test/test_eventdev_octeontx.c b/test/test/test_eventdev_octeontx.c index 774d030..dfe8611 100644 --- a/test/test/test_eventdev_octeontx.c +++ b/test/test/test_eventdev_octeontx.c @@ -224,7 +224,11 @@ _eventdev_setup(int mode) } } /* Configure event ports */ - for (i = 0; i < rte_event_port_count(evdev); i++) { + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_setup(evdev, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup port=%d", i); ret = rte_event_port_link(evdev, i, NULL, NULL, 0); @@ -651,18 +655,21 @@ static int test_multi_queue_enq_multi_port_deq(void) { const unsigned int total_events = MAX_EVENTS; - uint8_t nr_ports; + uint32_t nr_ports; int ret; ret = generate_random_events(total_events); if (ret) return TEST_FAILED; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); + nr_ports = RTE_MIN(nr_ports, rte_lcore_count() - 1); if (!nr_ports) { printf("%s: Not enough ports=%d or workers=%d\n", __func__, - rte_event_port_count(evdev), rte_lcore_count() - 1); + nr_ports, rte_lcore_count() - 1); return TEST_SUCCESS; } @@ -691,14 +698,18 @@ test_queue_to_port_single_link(void) { int i, nr_links, ret; + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + /* Unlink all connections that created in eventdev_setup */ - for (i = 0; i < rte_event_port_count(evdev); i++) { + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_unlink(evdev, i, NULL, 0); TEST_ASSERT(ret >= 0, "Failed to unlink all queues port=%d", i); } - nr_links = RTE_MIN(rte_event_port_count(evdev), - rte_event_queue_count(evdev)); + nr_links = RTE_MIN(port_count, rte_event_queue_count(evdev)); const unsigned int total_events = MAX_EVENTS / nr_links; /* Link queue x to port x and inject events to queue x through port x */ @@ -750,10 +761,18 @@ static int test_queue_to_port_multi_link(void) { int ret, port0_events = 0, port1_events = 0; - uint8_t nr_queues, nr_ports, queue, port; + uint8_t queue, port; + uint32_t nr_queues = 0; + uint32_t nr_ports = 0; nr_queues = rte_event_queue_count(evdev); - nr_ports = rte_event_port_count(evdev); + + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &nr_queues), "Queue count get failed"); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); if (nr_ports < 2) { printf("%s: Not enough ports to test ports=%d\n", @@ -854,14 +873,17 @@ test_multiport_flow_sched_type_test(uint8_t in_sched_type, uint8_t out_sched_type) { const unsigned int total_events = MAX_EVENTS; - uint8_t nr_ports; + uint32_t nr_ports; int ret; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); + nr_ports = RTE_MIN(nr_ports, rte_lcore_count() - 1); if (!nr_ports) { printf("%s: Not enough ports=%d or workers=%d\n", __func__, - rte_event_port_count(evdev), rte_lcore_count() - 1); + nr_ports, rte_lcore_count() - 1); return TEST_SUCCESS; } @@ -1007,15 +1029,19 @@ test_multiport_queue_sched_type_test(uint8_t in_sched_type, uint8_t out_sched_type) { const unsigned int total_events = MAX_EVENTS; - uint8_t nr_ports; + uint32_t nr_ports; int ret; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); + + nr_ports = RTE_MIN(nr_ports, rte_lcore_count() - 1); if (rte_event_queue_count(evdev) < 2 || !nr_ports) { printf("%s: Not enough queues=%d ports=%d or workers=%d\n", __func__, rte_event_queue_count(evdev), - rte_event_port_count(evdev), rte_lcore_count() - 1); + nr_ports, rte_lcore_count() - 1); return TEST_SUCCESS; } @@ -1142,14 +1168,17 @@ worker_flow_based_pipeline_max_stages_rand_sched_type(void *arg) static int launch_multi_port_max_stages_random_sched_type(int (*fn)(void *)) { - uint8_t nr_ports; + uint32_t nr_ports; int ret; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); + nr_ports = RTE_MIN(nr_ports, rte_lcore_count() - 1); if (!nr_ports) { printf("%s: Not enough ports=%d or workers=%d\n", __func__, - rte_event_port_count(evdev), rte_lcore_count() - 1); + nr_ports, rte_lcore_count() - 1); return TEST_SUCCESS; } @@ -1288,9 +1317,12 @@ worker_ordered_flow_producer(void *arg) static inline int test_producer_consumer_ingress_order_test(int (*fn)(void *)) { - uint8_t nr_ports; + uint32_t nr_ports; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); + nr_ports = RTE_MIN(nr_ports, rte_lcore_count() - 1); if (rte_lcore_count() < 3 || nr_ports < 2) { printf("### Not enough cores for %s test.\n", __func__); -- 2.7.4 ^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [dpdk-dev] [PATCH v3 2/4] eventdev: add dev attribute get function 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 2/4] eventdev: add dev attribute get function Harry van Haaren @ 2017-09-11 16:51 ` Jerin Jacob 0 siblings, 0 replies; 35+ messages in thread From: Jerin Jacob @ 2017-09-11 16:51 UTC (permalink / raw) To: Harry van Haaren; +Cc: dev -----Original Message----- > Date: Fri, 8 Sep 2017 16:36:53 +0100 > From: Harry van Haaren <harry.van.haaren@intel.com> > To: dev@dpdk.org > CC: jerin.jacob@caviumnetworks.com, Harry van Haaren > <harry.van.haaren@intel.com> > Subject: [PATCH v3 2/4] eventdev: add dev attribute get function > X-Mailer: git-send-email 2.7.4 > > This commit adds a device attribute function, allowing flexible > fetching of device attributes, like port count or queue count. > The unit tests and .map file are updated to the new function. > > Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> > --- > lib/librte_eventdev/rte_eventdev.c | 24 ++++++++-- > lib/librte_eventdev/rte_eventdev.h | 28 ++++++++--- > lib/librte_eventdev/rte_eventdev_version.map | 2 +- > test/test/test_eventdev.c | 36 +++++++++++--- > test/test/test_eventdev_octeontx.c | 72 ++++++++++++++++++++-------- > 5 files changed, 124 insertions(+), 38 deletions(-) > > diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c > index a02ff0a..4b1c0be 100644 > --- a/lib/librte_eventdev/rte_eventdev.c > +++ b/lib/librte_eventdev/rte_eventdev.c > @@ -743,13 +743,27 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, > return 0; > } > > -uint8_t > -rte_event_port_count(uint8_t dev_id) > +int > +rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id, > + uint32_t *attr_value /*out */) > { > struct rte_eventdev *dev; > > + if (!attr_value) > + return -EINVAL; > + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); > dev = &rte_eventdevs[dev_id]; > - return dev->data->nb_ports; > + > + switch (attr_id) { > + case RTE_EVENT_DEV_ATTR_PORT_COUNT: > + *attr_value = dev->data->nb_ports; > + break; > + case RTE_EVENT_DEV_ATTR_QUEUE_COUNT: > + *attr_value = dev->data->nb_queues; > + break; Same as previous "default case" comment. > + } > + > + return 0; With above change: Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com> ^ permalink raw reply [flat|nested] 35+ messages in thread
* [dpdk-dev] [PATCH v3 3/4] eventdev: add queue attribute function 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 0/4] eventdev: add attribute based get APIs Harry van Haaren 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 1/4] eventdev: add port attribute function Harry van Haaren 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 2/4] eventdev: add dev attribute get function Harry van Haaren @ 2017-09-08 15:36 ` Harry van Haaren 2017-09-11 17:36 ` Jerin Jacob 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 4/4] eventdev: add device started attribute Harry van Haaren ` (2 subsequent siblings) 5 siblings, 1 reply; 35+ messages in thread From: Harry van Haaren @ 2017-09-08 15:36 UTC (permalink / raw) To: dev; +Cc: jerin.jacob, Harry van Haaren This commit adds a generic queue attribute function. It also removes the previous rte_event_queue_priority() and priority() functions, and updates the map files and unit tests to use the new attr functions. Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> --- lib/librte_eventdev/rte_eventdev.c | 47 ++++++++-------- lib/librte_eventdev/rte_eventdev.h | 49 ++++++++--------- lib/librte_eventdev/rte_eventdev_version.map | 3 +- test/test/test_eventdev.c | 80 +++++++++++++++++++++------- test/test/test_eventdev_octeontx.c | 75 +++++++++++++++++++------- 5 files changed, 166 insertions(+), 88 deletions(-) diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c index 4b1c0be..3756ec7 100644 --- a/lib/librte_eventdev/rte_eventdev.c +++ b/lib/librte_eventdev/rte_eventdev.c @@ -609,27 +609,6 @@ rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id, return (*dev->dev_ops->queue_setup)(dev, queue_id, queue_conf); } -uint8_t -rte_event_queue_count(uint8_t dev_id) -{ - struct rte_eventdev *dev; - - dev = &rte_eventdevs[dev_id]; - return dev->data->nb_queues; -} - -uint8_t -rte_event_queue_priority(uint8_t dev_id, uint8_t queue_id) -{ - struct rte_eventdev *dev; - - dev = &rte_eventdevs[dev_id]; - if (dev->data->event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_QOS) - return dev->data->queues_prio[queue_id]; - else - return RTE_EVENT_DEV_PRIORITY_NORMAL; -} - static inline int is_valid_port(struct rte_eventdev *dev, uint8_t port_id) { @@ -794,6 +773,32 @@ rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, } int +rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id, + uint32_t *attr_value /*out */) +{ + struct rte_eventdev *dev; + + if (!attr_value) + return -EINVAL; + + 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; + } + + 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]; + break; + }; + return 0; +} + +int rte_event_port_link(uint8_t dev_id, uint8_t port_id, const uint8_t queues[], const uint8_t priorities[], uint16_t nb_links) diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h index e931eb2..cd3026d 100644 --- a/lib/librte_eventdev/rte_eventdev.h +++ b/lib/librte_eventdev/rte_eventdev.h @@ -606,33 +606,6 @@ int rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id, const struct rte_event_queue_conf *queue_conf); -/** - * Get the number of event queues on a specific event device - * - * @param dev_id - * Event device identifier. - * @return - * - The number of configured event queues - */ -uint8_t -rte_event_queue_count(uint8_t dev_id); - -/** - * Get the priority of the event queue on a specific event device - * - * @param dev_id - * Event device identifier. - * @param queue_id - * Event queue identifier. - * @return - * - If the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability then the - * configured priority of the event queue in - * [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST] range - * else the value RTE_EVENT_DEV_PRIORITY_NORMAL - */ -uint8_t -rte_event_queue_priority(uint8_t dev_id, uint8_t queue_id); - /* Event port specific APIs */ /** Event port configuration structure */ @@ -765,6 +738,28 @@ rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, uint32_t *attr_value /*out */); /** + * The priority of the queue. + */ +#define RTE_EVENT_QUEUE_ATTR_PRIORITY 0 + +/** + * Get an attribute from a queue. + * + * @param dev_id Eventdev id + * @param queue_id Eventdev queue id + * @param attr_id The attribute ID to retrieve + * @param[out] attr_value A pointer that will be filled in with the attribute + * value if successful + * + * @retval 0 Successfully returned value + * -EINVAL invalid device, queue or attr_id provided, or attr_value + * was NULL + */ +int +rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id, + uint32_t *attr_value /*out */); + +/** * Start an event device. * * The device start step is the last one and consists of setting the event diff --git a/lib/librte_eventdev/rte_eventdev_version.map b/lib/librte_eventdev/rte_eventdev_version.map index 484a071..c3854f4 100644 --- a/lib/librte_eventdev/rte_eventdev_version.map +++ b/lib/librte_eventdev/rte_eventdev_version.map @@ -27,8 +27,6 @@ DPDK_17.05 { rte_event_queue_default_conf_get; rte_event_queue_setup; - rte_event_queue_count; - rte_event_queue_priority; rte_event_dequeue_timeout_ticks; @@ -56,5 +54,6 @@ EXPERIMENTAL { rte_event_dev_attr_get; rte_event_port_attr_get; + rte_event_queue_attr_get; } DPDK_17.08; diff --git a/test/test/test_eventdev.c b/test/test/test_eventdev.c index a87b113..9b738e0 100644 --- a/test/test/test_eventdev.c +++ b/test/test/test_eventdev.c @@ -273,7 +273,12 @@ test_eventdev_queue_default_conf_get(void) ret = rte_event_queue_default_conf_get(TEST_DEV_ID, 0, NULL); TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_default_conf_get(TEST_DEV_ID, i, &qconf); TEST_ASSERT_SUCCESS(ret, "Failed to get queue%d info", i); @@ -318,8 +323,12 @@ test_eventdev_queue_setup(void) ret = rte_event_queue_setup(TEST_DEV_ID, 0, &qconf); TEST_ASSERT_SUCCESS(ret, "Failed to setup queue0"); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i); } @@ -336,8 +345,12 @@ test_eventdev_queue_count(void) ret = rte_event_dev_info_get(TEST_DEV_ID, &info); TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info"); - TEST_ASSERT_EQUAL(rte_event_queue_count(TEST_DEV_ID), - info.max_event_queues, "Wrong queue count"); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + TEST_ASSERT_EQUAL(queue_count, info.max_event_queues, + "Wrong queue count"); return TEST_SUCCESS; } @@ -353,7 +366,12 @@ test_eventdev_queue_priority(void) ret = rte_event_dev_info_get(TEST_DEV_ID, &info); TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info"); - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_default_conf_get(TEST_DEV_ID, i, &qconf); TEST_ASSERT_SUCCESS(ret, "Failed to get queue%d def conf", i); @@ -362,8 +380,13 @@ test_eventdev_queue_priority(void) TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i); } - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { - priority = rte_event_queue_priority(TEST_DEV_ID, i); + for (i = 0; i < (int)queue_count; i++) { + uint32_t tmp; + TEST_ASSERT_SUCCESS(rte_event_queue_attr_get(TEST_DEV_ID, i, + RTE_EVENT_QUEUE_ATTR_PRIORITY, &tmp), + "Queue count get failed"); + priority = tmp; + if (info.event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_QOS) TEST_ASSERT_EQUAL(priority, i % RTE_EVENT_DEV_PRIORITY_LOWEST, @@ -544,7 +567,11 @@ test_eventdev_start_stop(void) ret = eventdev_configure_setup(); TEST_ASSERT_SUCCESS(ret, "Failed to configure eventdev"); - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i); } @@ -560,8 +587,8 @@ test_eventdev_start_stop(void) } ret = rte_event_port_link(TEST_DEV_ID, 0, NULL, NULL, 0); - TEST_ASSERT(ret == rte_event_queue_count(TEST_DEV_ID), - "Failed to link port, device %d", TEST_DEV_ID); + TEST_ASSERT(ret == (int)queue_count, "Failed to link port, device %d", + TEST_DEV_ID); ret = rte_event_dev_start(TEST_DEV_ID); TEST_ASSERT_SUCCESS(ret, "Failed to start device%d", TEST_DEV_ID); @@ -579,7 +606,11 @@ eventdev_setup_device(void) ret = eventdev_configure_setup(); TEST_ASSERT_SUCCESS(ret, "Failed to configure eventdev"); - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i); } @@ -595,8 +626,8 @@ eventdev_setup_device(void) } ret = rte_event_port_link(TEST_DEV_ID, 0, NULL, NULL, 0); - TEST_ASSERT(ret == rte_event_queue_count(TEST_DEV_ID), - "Failed to link port, device %d", TEST_DEV_ID); + TEST_ASSERT(ret == (int)queue_count, "Failed to link port, device %d", + TEST_DEV_ID); ret = rte_event_dev_start(TEST_DEV_ID); TEST_ASSERT_SUCCESS(ret, "Failed to start device%d", TEST_DEV_ID); @@ -621,7 +652,11 @@ test_eventdev_link(void) TEST_ASSERT(ret >= 0, "Failed to link with NULL device%d", TEST_DEV_ID); - nb_queues = rte_event_queue_count(TEST_DEV_ID); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + nb_queues = queue_count; for (i = 0; i < nb_queues; i++) { queues[i] = i; priorities[i] = RTE_EVENT_DEV_PRIORITY_NORMAL; @@ -644,7 +679,11 @@ test_eventdev_unlink(void) TEST_ASSERT(ret >= 0, "Failed to unlink with NULL device%d", TEST_DEV_ID); - nb_queues = rte_event_queue_count(TEST_DEV_ID); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + nb_queues = queue_count; for (i = 0; i < nb_queues; i++) queues[i] = i; @@ -658,7 +697,7 @@ test_eventdev_unlink(void) static int test_eventdev_link_get(void) { - int ret, nb_queues, i; + int ret, i; uint8_t queues[RTE_EVENT_MAX_QUEUES_PER_DEV]; uint8_t priorities[RTE_EVENT_MAX_QUEUES_PER_DEV]; @@ -667,7 +706,11 @@ test_eventdev_link_get(void) TEST_ASSERT(ret >= 0, "Failed to link with NULL device%d", TEST_DEV_ID); - nb_queues = rte_event_queue_count(TEST_DEV_ID); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + const int nb_queues = queue_count; for (i = 0; i < nb_queues; i++) queues[i] = i; @@ -679,7 +722,6 @@ test_eventdev_link_get(void) TEST_ASSERT(ret == 0, "(%d)Wrong link get=%d", TEST_DEV_ID, ret); /* link all queues and get the links */ - nb_queues = rte_event_queue_count(TEST_DEV_ID); for (i = 0; i < nb_queues; i++) { queues[i] = i; priorities[i] = RTE_EVENT_DEV_PRIORITY_NORMAL; @@ -709,8 +751,8 @@ test_eventdev_link_get(void) ret = rte_event_port_unlink(TEST_DEV_ID, 0, NULL, 0); TEST_ASSERT(ret == nb_queues, "Failed to unlink(device%d) ret=%d", TEST_DEV_ID, ret); + /* 4links and 2 unlinks */ - nb_queues = rte_event_queue_count(TEST_DEV_ID); if (nb_queues >= 4) { for (i = 0; i < 4; i++) { queues[i] = i; diff --git a/test/test/test_eventdev_octeontx.c b/test/test/test_eventdev_octeontx.c index dfe8611..b88b0d2 100644 --- a/test/test/test_eventdev_octeontx.c +++ b/test/test/test_eventdev_octeontx.c @@ -193,8 +193,13 @@ _eventdev_setup(int mode) ret = rte_event_dev_configure(evdev, &dev_conf); TEST_ASSERT_SUCCESS(ret, "Failed to configure eventdev"); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + if (mode == TEST_EVENTDEV_SETUP_PRIORITY) { - if (rte_event_queue_count(evdev) > 8) { + if (queue_count > 8) { printf("test expects the unique priority per queue\n"); return -ENOTSUP; } @@ -204,8 +209,8 @@ _eventdev_setup(int mode) * RTE_EVENT_DEV_PRIORITY_LOWEST */ uint8_t step = (RTE_EVENT_DEV_PRIORITY_LOWEST + 1) / - rte_event_queue_count(evdev); - for (i = 0; i < rte_event_queue_count(evdev); i++) { + queue_count; + for (i = 0; i < (int)queue_count; i++) { struct rte_event_queue_conf queue_conf; ret = rte_event_queue_default_conf_get(evdev, i, @@ -218,7 +223,7 @@ _eventdev_setup(int mode) } else { /* Configure event queues with default priority */ - for (i = 0; i < rte_event_queue_count(evdev); i++) { + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_setup(evdev, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup queue=%d", i); } @@ -339,6 +344,11 @@ generate_random_events(const unsigned int total_events) unsigned int i; int ret; + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + ret = rte_event_dev_info_get(evdev, &info); TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info"); for (i = 0; i < total_events; i++) { @@ -347,7 +357,7 @@ generate_random_events(const unsigned int total_events) rte_rand() % (RTE_EVENT_TYPE_CPU + 1) /* event_type */, rte_rand() % 256 /* sub_event_type */, rte_rand() % (RTE_SCHED_TYPE_PARALLEL + 1), - rte_rand() % rte_event_queue_count(evdev) /* queue */, + rte_rand() % queue_count /* queue */, 0 /* port */, 1 /* events */); if (ret) @@ -486,7 +496,7 @@ test_multi_queue_enq_single_port_deq(void) } /* - * Inject 0..MAX_EVENTS events over 0..rte_event_queue_count() with modulus + * Inject 0..MAX_EVENTS events over 0..queue_count with modulus * operation * * For example, Inject 32 events over 0..7 queues @@ -502,15 +512,19 @@ test_multi_queue_enq_single_port_deq(void) static int validate_queue_priority(uint32_t index, uint8_t port, struct rte_event *ev) { - uint32_t range = MAX_EVENTS / rte_event_queue_count(evdev); - uint32_t expected_val = (index % range) * rte_event_queue_count(evdev); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + uint32_t range = MAX_EVENTS / queue_count; + uint32_t expected_val = (index % range) * queue_count; expected_val += ev->queue_id; RTE_SET_USED(port); TEST_ASSERT_EQUAL(ev->mbuf->seqn, expected_val, "seqn=%d index=%d expected=%d range=%d nb_queues=%d max_event=%d", ev->mbuf->seqn, index, expected_val, range, - rte_event_queue_count(evdev), MAX_EVENTS); + queue_count, MAX_EVENTS); return 0; } @@ -522,8 +536,12 @@ test_multi_queue_priority(void) int i, max_evts_roundoff; /* See validate_queue_priority() comments for priority validate logic */ - max_evts_roundoff = MAX_EVENTS / rte_event_queue_count(evdev); - max_evts_roundoff *= rte_event_queue_count(evdev); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + max_evts_roundoff = MAX_EVENTS / queue_count; + max_evts_roundoff *= queue_count; for (i = 0; i < max_evts_roundoff; i++) { struct rte_event ev = {.event = 0, .u64 = 0}; @@ -532,7 +550,7 @@ test_multi_queue_priority(void) TEST_ASSERT_NOT_NULL(m, "mempool alloc failed"); m->seqn = i; - queue = i % rte_event_queue_count(evdev); + queue = i % queue_count; update_event_and_validation_attr(m, &ev, 0, RTE_EVENT_TYPE_CPU, 0, RTE_SCHED_TYPE_PARALLEL, queue, 0); rte_event_enqueue_burst(evdev, 0, &ev, 1); @@ -709,7 +727,12 @@ test_queue_to_port_single_link(void) TEST_ASSERT(ret >= 0, "Failed to unlink all queues port=%d", i); } - nr_links = RTE_MIN(port_count, rte_event_queue_count(evdev)); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + + nr_links = RTE_MIN(port_count, queue_count); const unsigned int total_events = MAX_EVENTS / nr_links; /* Link queue x to port x and inject events to queue x through port x */ @@ -765,7 +788,9 @@ test_queue_to_port_multi_link(void) uint32_t nr_queues = 0; uint32_t nr_ports = 0; - nr_queues = rte_event_queue_count(evdev); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &nr_queues), "Queue count get failed"); TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, RTE_EVENT_DEV_ATTR_QUEUE_COUNT, @@ -1038,10 +1063,14 @@ test_multiport_queue_sched_type_test(uint8_t in_sched_type, nr_ports = RTE_MIN(nr_ports, rte_lcore_count() - 1); - if (rte_event_queue_count(evdev) < 2 || !nr_ports) { + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + if (queue_count < 2 || !nr_ports) { printf("%s: Not enough queues=%d ports=%d or workers=%d\n", - __func__, rte_event_queue_count(evdev), - nr_ports, rte_lcore_count() - 1); + __func__, queue_count, nr_ports, + rte_lcore_count() - 1); return TEST_SUCCESS; } @@ -1213,7 +1242,11 @@ worker_queue_based_pipeline_max_stages_rand_sched_type(void *arg) struct rte_event ev; uint16_t valid_event; uint8_t port = param->port; - uint8_t nr_queues = rte_event_queue_count(evdev); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + uint8_t nr_queues = queue_count; rte_atomic32_t *total_events = param->total_events; while (rte_atomic32_read(total_events) > 0) { @@ -1251,7 +1284,11 @@ worker_mixed_pipeline_max_stages_rand_sched_type(void *arg) struct rte_event ev; uint16_t valid_event; uint8_t port = param->port; - uint8_t nr_queues = rte_event_queue_count(evdev); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + uint8_t nr_queues = queue_count; rte_atomic32_t *total_events = param->total_events; while (rte_atomic32_read(total_events) > 0) { -- 2.7.4 ^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [dpdk-dev] [PATCH v3 3/4] eventdev: add queue attribute function 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 3/4] eventdev: add queue attribute function Harry van Haaren @ 2017-09-11 17:36 ` Jerin Jacob 0 siblings, 0 replies; 35+ messages in thread From: Jerin Jacob @ 2017-09-11 17:36 UTC (permalink / raw) To: Harry van Haaren; +Cc: dev -----Original Message----- > Date: Fri, 8 Sep 2017 16:36:54 +0100 > From: Harry van Haaren <harry.van.haaren@intel.com> > To: dev@dpdk.org > CC: jerin.jacob@caviumnetworks.com, Harry van Haaren > <harry.van.haaren@intel.com> > Subject: [PATCH v3 3/4] eventdev: add queue attribute function > X-Mailer: git-send-email 2.7.4 > > This commit adds a generic queue attribute function. It also removes > the previous rte_event_queue_priority() and priority() functions, and > updates the map files and unit tests to use the new attr functions. > > Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> > --- > lib/librte_eventdev/rte_eventdev.c | 47 ++++++++-------- > lib/librte_eventdev/rte_eventdev.h | 49 ++++++++--------- > lib/librte_eventdev/rte_eventdev_version.map | 3 +- > test/test/test_eventdev.c | 80 +++++++++++++++++++++------- > test/test/test_eventdev_octeontx.c | 75 +++++++++++++++++++------- > 5 files changed, 166 insertions(+), 88 deletions(-) > > diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c > index 4b1c0be..3756ec7 100644 > --- a/lib/librte_eventdev/rte_eventdev.c > +++ b/lib/librte_eventdev/rte_eventdev.c > @@ -609,27 +609,6 @@ rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id, > return (*dev->dev_ops->queue_setup)(dev, queue_id, queue_conf); > } > > static inline int > is_valid_port(struct rte_eventdev *dev, uint8_t port_id) > { > @@ -794,6 +773,32 @@ rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, > } > > int > +rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id, > + uint32_t *attr_value /*out */) > +{ > + struct rte_eventdev *dev; > + > + if (!attr_value) > + return -EINVAL; > + > + 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; > + } > + > + 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]; > + break; The same switch case comment. > + }; > + return 0; > +} > + > +int > rte_event_port_link(uint8_t dev_id, uint8_t port_id, > const uint8_t queues[], const uint8_t priorities[], > uint16_t nb_links) > diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h > index e931eb2..cd3026d 100644 > --- a/lib/librte_eventdev/rte_eventdev.h > +++ b/lib/librte_eventdev/rte_eventdev.h > @@ -606,33 +606,6 @@ int > rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id, > const struct rte_event_queue_conf *queue_conf); > > -/** > - * Get the number of event queues on a specific event device > - * > - * @param dev_id > - * Event device identifier. > - * @return > - * - The number of configured event queues > - */ > -uint8_t > -rte_event_queue_count(uint8_t dev_id); > - > -/** > - * Get the priority of the event queue on a specific event device > - * > - * @param dev_id > - * Event device identifier. > - * @param queue_id > - * Event queue identifier. > - * @return > - * - If the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability then the > - * configured priority of the event queue in > - * [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST] range > - * else the value RTE_EVENT_DEV_PRIORITY_NORMAL > - */ > -uint8_t > -rte_event_queue_priority(uint8_t dev_id, uint8_t queue_id); > - > /* Event port specific APIs */ > > /** Event port configuration structure */ > @@ -765,6 +738,28 @@ rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, > uint32_t *attr_value /*out */); We can remove explicit /* out */. > > /** > + * The priority of the queue. > + */ > +#define RTE_EVENT_QUEUE_ATTR_PRIORITY 0 > + > +/** > + * Get an attribute from a queue. > + * > + * @param dev_id Eventdev id > + * @param queue_id Eventdev queue id > + * @param attr_id The attribute ID to retrieve > + * @param[out] attr_value A pointer that will be filled in with the attribute > + * value if successful > + * > + * @retval 0 Successfully returned value > + * -EINVAL invalid device, queue or attr_id provided, or attr_value > + * was NULL > + */ > +int > +rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id, > + uint32_t *attr_value /*out */); > + We can remove explicit /* out */. ^ permalink raw reply [flat|nested] 35+ messages in thread
* [dpdk-dev] [PATCH v3 4/4] eventdev: add device started attribute 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 0/4] eventdev: add attribute based get APIs Harry van Haaren ` (2 preceding siblings ...) 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 3/4] eventdev: add queue attribute function Harry van Haaren @ 2017-09-08 15:36 ` Harry van Haaren 2017-09-11 17:52 ` Jerin Jacob 2017-09-11 16:16 ` [dpdk-dev] [PATCH v3 0/4] eventdev: add attribute based get APIs Jerin Jacob 2017-09-14 16:08 ` [dpdk-dev] [PATCH v4 " Harry van Haaren 5 siblings, 1 reply; 35+ messages in thread From: Harry van Haaren @ 2017-09-08 15:36 UTC (permalink / raw) To: dev; +Cc: jerin.jacob, Harry van Haaren This commit adds an attribute to the eventdev, allowing applications to retrieve if the eventdev is running or stopped. Note that no API or ABI changes were required in adding the statistic, and code changes are minimal. Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> --- lib/librte_eventdev/rte_eventdev.c | 3 +++ lib/librte_eventdev/rte_eventdev.h | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c index 3756ec7..87a1e19 100644 --- a/lib/librte_eventdev/rte_eventdev.c +++ b/lib/librte_eventdev/rte_eventdev.c @@ -740,6 +740,9 @@ rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id, case RTE_EVENT_DEV_ATTR_QUEUE_COUNT: *attr_value = dev->data->nb_queues; break; + case RTE_EVENT_DEV_ATTR_STARTED: + *attr_value = dev->data->dev_started; + break; } return 0; diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h index cd3026d..f76d9f9 100644 --- a/lib/librte_eventdev/rte_eventdev.h +++ b/lib/librte_eventdev/rte_eventdev.h @@ -695,6 +695,10 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, * The count of queues. */ #define RTE_EVENT_DEV_ATTR_QUEUE_COUNT 1 +/** + * The state of the device, returns zero if stopped, non-zero when running. + */ +#define RTE_EVENT_DEV_ATTR_STARTED 2 /** * Get an attribute from a device. -- 2.7.4 ^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [dpdk-dev] [PATCH v3 4/4] eventdev: add device started attribute 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 4/4] eventdev: add device started attribute Harry van Haaren @ 2017-09-11 17:52 ` Jerin Jacob 2017-09-12 8:07 ` Van Haaren, Harry 0 siblings, 1 reply; 35+ messages in thread From: Jerin Jacob @ 2017-09-11 17:52 UTC (permalink / raw) To: Harry van Haaren; +Cc: dev -----Original Message----- > Date: Fri, 8 Sep 2017 16:36:55 +0100 > From: Harry van Haaren <harry.van.haaren@intel.com> > To: dev@dpdk.org > CC: jerin.jacob@caviumnetworks.com, Harry van Haaren > <harry.van.haaren@intel.com> > Subject: [PATCH v3 4/4] eventdev: add device started attribute > X-Mailer: git-send-email 2.7.4 > > This commit adds an attribute to the eventdev, allowing applications > to retrieve if the eventdev is running or stopped. Note that no API > or ABI changes were required in adding the statistic, and code changes > are minimal. > > Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> > --- > lib/librte_eventdev/rte_eventdev.c | 3 +++ > lib/librte_eventdev/rte_eventdev.h | 4 ++++ > 2 files changed, 7 insertions(+) > > diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c > index 3756ec7..87a1e19 100644 > --- a/lib/librte_eventdev/rte_eventdev.c > +++ b/lib/librte_eventdev/rte_eventdev.c > @@ -740,6 +740,9 @@ rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id, I think, the new rte_event_dev_attr_get function, we can move up so that all device specific functions comes back to back in API documentation. Check the output of "make doc-api-html" Other than that, it looks good. Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com> ^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [dpdk-dev] [PATCH v3 4/4] eventdev: add device started attribute 2017-09-11 17:52 ` Jerin Jacob @ 2017-09-12 8:07 ` Van Haaren, Harry 0 siblings, 0 replies; 35+ messages in thread From: Van Haaren, Harry @ 2017-09-12 8:07 UTC (permalink / raw) To: Jerin Jacob; +Cc: dev > From: Jerin Jacob [mailto:jerin.jacob@caviumnetworks.com] > Sent: Monday, September 11, 2017 6:53 PM > To: Van Haaren, Harry <harry.van.haaren@intel.com> > Cc: dev@dpdk.org > Subject: Re: [PATCH v3 4/4] eventdev: add device started attribute > > -----Original Message----- > > Date: Fri, 8 Sep 2017 16:36:55 +0100 > > From: Harry van Haaren <harry.van.haaren@intel.com> > > To: dev@dpdk.org > > CC: jerin.jacob@caviumnetworks.com, Harry van Haaren > > <harry.van.haaren@intel.com> > > Subject: [PATCH v3 4/4] eventdev: add device started attribute > > X-Mailer: git-send-email 2.7.4 > > > > This commit adds an attribute to the eventdev, allowing applications > > to retrieve if the eventdev is running or stopped. Note that no API > > or ABI changes were required in adding the statistic, and code changes > > are minimal. > > > > Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> > > --- > > lib/librte_eventdev/rte_eventdev.c | 3 +++ > > lib/librte_eventdev/rte_eventdev.h | 4 ++++ > > 2 files changed, 7 insertions(+) > > > > diff --git a/lib/librte_eventdev/rte_eventdev.c > b/lib/librte_eventdev/rte_eventdev.c > > index 3756ec7..87a1e19 100644 > > --- a/lib/librte_eventdev/rte_eventdev.c > > +++ b/lib/librte_eventdev/rte_eventdev.c > > @@ -740,6 +740,9 @@ rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id, > > I think, the new rte_event_dev_attr_get function, we can move up so that > all device specific functions comes back to back in API documentation. > > Check the output of "make doc-api-html" > > Other than that, it looks good. > > Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com> Thanks for the review - all comments make sense. Will respin with comments addressed, and include Acks. ^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [dpdk-dev] [PATCH v3 0/4] eventdev: add attribute based get APIs 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 0/4] eventdev: add attribute based get APIs Harry van Haaren ` (3 preceding siblings ...) 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 4/4] eventdev: add device started attribute Harry van Haaren @ 2017-09-11 16:16 ` Jerin Jacob 2017-09-14 16:08 ` [dpdk-dev] [PATCH v4 " Harry van Haaren 5 siblings, 0 replies; 35+ messages in thread From: Jerin Jacob @ 2017-09-11 16:16 UTC (permalink / raw) To: Harry van Haaren; +Cc: dev -----Original Message----- > Date: Fri, 8 Sep 2017 16:36:51 +0100 > From: Harry van Haaren <harry.van.haaren@intel.com> > To: dev@dpdk.org > CC: jerin.jacob@caviumnetworks.com, Harry van Haaren > <harry.van.haaren@intel.com> > Subject: [PATCH v3 0/4] eventdev: add attribute based get APIs > X-Mailer: git-send-email 2.7.4 > > This patchset refactors the eventdev API to be more flexible > and capable. In particular, the API is capable of returning an > error value if an invalid device, port or attribute ID is passed > in, which was not possible with the previous APIs. > > The implementation of this patchset is based on a v1 patch[1], > and after some discussion this API was seen as the best solution. > > In terms of flexibility, the attribute id allows addition of new > common eventdev layer attributes without breaking ABI or adding > new functions. Note that these attributes are not data-path, and > that PMDs should continue to use the xstats API for reporting any > unique PMD statistics that are available. > > Regarding API/ABI compatibility, I have removed the functions from > the .map files - please review the .map file changes for ABI issues > carefully. Please update the LIBABIVER in the Makefile. Reference: http://dpdk.org/browse/dpdk/commit/?id=945081a76ab0bb481f1d62125aa5b547fcc000bd ^ permalink raw reply [flat|nested] 35+ messages in thread
* [dpdk-dev] [PATCH v4 0/4] eventdev: add attribute based get APIs 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 0/4] eventdev: add attribute based get APIs Harry van Haaren ` (4 preceding siblings ...) 2017-09-11 16:16 ` [dpdk-dev] [PATCH v3 0/4] eventdev: add attribute based get APIs Jerin Jacob @ 2017-09-14 16:08 ` Harry van Haaren 2017-09-14 16:09 ` [dpdk-dev] [PATCH v4 1/4] eventdev: add port attribute function Harry van Haaren ` (6 more replies) 5 siblings, 7 replies; 35+ messages in thread From: Harry van Haaren @ 2017-09-14 16:08 UTC (permalink / raw) To: dev; +Cc: jerin.jacob, Harry van Haaren This patchset refactors the eventdev API to be more flexible and capable. In particular, the API is capable of returning an error value if an invalid device, port or attribute ID is passed in, which was not possible with the previous APIs. The implementation of this patchset is based on a v1 patch[1], and after some discussion this API was seen as the best solution. In terms of flexibility, the attribute id allows addition of new common eventdev layer attributes without breaking ABI or adding new functions. Note that these attributes are not data-path, and that PMDs should continue to use the xstats API for reporting any unique PMD statistics that are available. Regarding API/ABI compatibility, I have removed the functions from the .map files - please review the .map file changes for ABI issues carefully. The last patch of this series adds a started attribute to the device, allowing the application to query if a device is currently running. -Harry [1] http://dpdk.org/dev/patchwork/patch/27152/ --- v4: - Rework based on review by Jerin - default: cases into switches - Remove old functions from .map file - Remove /* out */ parameters - Rework header file definitions to match logical order - Rework patch split - Cleaner removal of queue_count() function v3: - Fix checkpatch issues... somehow I broke my checkpatch script :/ v2: - New APIs design based on discussion of initial patch. Harry van Haaren (4): eventdev: add port attribute function eventdev: add dev attribute get function eventdev: add queue attribute function eventdev: add device started attribute lib/librte_eventdev/rte_eventdev.c | 97 ++++++++++++------ lib/librte_eventdev/rte_eventdev.h | 115 +++++++++++---------- lib/librte_eventdev/rte_eventdev_version.map | 14 ++- test/test/test_eventdev.c | 132 +++++++++++++++++++------ test/test/test_eventdev_octeontx.c | 143 ++++++++++++++++++++------- 5 files changed, 345 insertions(+), 156 deletions(-) -- 2.7.4 ^ permalink raw reply [flat|nested] 35+ messages in thread
* [dpdk-dev] [PATCH v4 1/4] eventdev: add port attribute function 2017-09-14 16:08 ` [dpdk-dev] [PATCH v4 " Harry van Haaren @ 2017-09-14 16:09 ` Harry van Haaren 2017-09-14 16:19 ` Van Haaren, Harry 2017-09-14 16:09 ` [dpdk-dev] [PATCH v4 2/4] eventdev: add dev attribute get function Harry van Haaren ` (5 subsequent siblings) 6 siblings, 1 reply; 35+ messages in thread From: Harry van Haaren @ 2017-09-14 16:09 UTC (permalink / raw) To: dev; +Cc: jerin.jacob, Harry van Haaren This commit reworks the port functions to retrieve information about the port, like the enq or deq depths. Note that "port count" is a device attribute, and is added in a later patch for dev attributes. Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> --- v4: feedback from http://dpdk.org/dev/patchwork/patch/28520/ - Added default: case into switch, returns -EINVAL as per header file (Jerin) - Reworked .map file, removed old functions (Jerin) - Renamed EXPERIMENTAL section of map file to 17.11 (Jerin) - Removed /* out */ comments in .h and .c (Jerin) --- lib/librte_eventdev/rte_eventdev.c | 35 ++++++++++++-------- lib/librte_eventdev/rte_eventdev.h | 49 ++++++++++++---------------- lib/librte_eventdev/rte_eventdev_version.map | 9 +++-- test/test/test_eventdev.c | 16 ++++++--- 4 files changed, 61 insertions(+), 48 deletions(-) diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c index bbb3805..9eacc73 100644 --- a/lib/librte_eventdev/rte_eventdev.c +++ b/lib/librte_eventdev/rte_eventdev.c @@ -744,30 +744,37 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, } uint8_t -rte_event_port_dequeue_depth(uint8_t dev_id, uint8_t port_id) +rte_event_port_count(uint8_t dev_id) { struct rte_eventdev *dev; dev = &rte_eventdevs[dev_id]; - return dev->data->ports_dequeue_depth[port_id]; + return dev->data->nb_ports; } -uint8_t -rte_event_port_enqueue_depth(uint8_t dev_id, uint8_t port_id) +int +rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, + uint32_t *attr_value) { struct rte_eventdev *dev; - + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); dev = &rte_eventdevs[dev_id]; - return dev->data->ports_enqueue_depth[port_id]; -} - -uint8_t -rte_event_port_count(uint8_t dev_id) -{ - struct rte_eventdev *dev; + if (!is_valid_port(dev, port_id)) { + RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id); + return -EINVAL; + } - dev = &rte_eventdevs[dev_id]; - return dev->data->nb_ports; + switch (attr_id) { + case RTE_EVENT_PORT_ATTR_ENQ_DEPTH: + *attr_value = dev->data->ports_enqueue_depth[port_id]; + break; + case RTE_EVENT_PORT_ATTR_DEQ_DEPTH: + *attr_value = dev->data->ports_dequeue_depth[port_id]; + break; + default: + return -EINVAL; + }; + return 0; } int diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h index 128bc52..e1febfa 100644 --- a/lib/librte_eventdev/rte_eventdev.h +++ b/lib/librte_eventdev/rte_eventdev.h @@ -715,47 +715,40 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, const struct rte_event_port_conf *port_conf); /** - * Get the number of dequeue queue depth configured for event port designated - * by its *port_id* on a specific event device + * Get the number of ports on a specific event device * * @param dev_id * Event device identifier. - * @param port_id - * Event port identifier. * @return - * - The number of configured dequeue queue depth - * - * @see rte_event_dequeue_burst() + * - The number of configured ports */ uint8_t -rte_event_port_dequeue_depth(uint8_t dev_id, uint8_t port_id); +rte_event_port_count(uint8_t dev_id); /** - * Get the number of enqueue queue depth configured for event port designated - * by its *port_id* on a specific event device - * - * @param dev_id - * Event device identifier. - * @param port_id - * Event port identifier. - * @return - * - The number of configured enqueue queue depth - * - * @see rte_event_enqueue_burst() + * The queue depth of the port on the enqueue side */ -uint8_t -rte_event_port_enqueue_depth(uint8_t dev_id, uint8_t port_id); +#define RTE_EVENT_PORT_ATTR_ENQ_DEPTH 0 +/** + * The queue depth of the port on the dequeue side + */ +#define RTE_EVENT_PORT_ATTR_DEQ_DEPTH 1 /** - * Get the number of ports on a specific event device + * Get an attribute from a port. * - * @param dev_id - * Event device identifier. - * @return - * - The number of configured ports + * @param dev_id Eventdev id + * @param port_id Eventdev port id + * @param attr_id The attribute ID to retrieve + * @param[out] attr_value A pointer that will be filled in with the attribute + * value if successful + * + * @retval 0 Successfully returned value + * -EINVAL Invalid device, port or attr_id, or attr_value was NULL */ -uint8_t -rte_event_port_count(uint8_t dev_id); +int +rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, + uint32_t *attr_value); /** * Start an event device. diff --git a/lib/librte_eventdev/rte_eventdev_version.map b/lib/librte_eventdev/rte_eventdev_version.map index 4c48e5f..57d0b72 100644 --- a/lib/librte_eventdev/rte_eventdev_version.map +++ b/lib/librte_eventdev/rte_eventdev_version.map @@ -19,8 +19,6 @@ DPDK_17.05 { rte_event_port_default_conf_get; rte_event_port_setup; - rte_event_port_dequeue_depth; - rte_event_port_enqueue_depth; rte_event_port_count; rte_event_port_link; rte_event_port_unlink; @@ -51,3 +49,10 @@ DPDK_17.08 { rte_event_ring_init; rte_event_ring_lookup; } DPDK_17.05; + +DPDK_17.11 { + global: + + rte_event_port_attr_get; + +} DPDK_17.08; diff --git a/test/test/test_eventdev.c b/test/test/test_eventdev.c index f766191..f3ec470 100644 --- a/test/test/test_eventdev.c +++ b/test/test/test_eventdev.c @@ -460,8 +460,12 @@ test_eventdev_dequeue_depth(void) ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf); TEST_ASSERT_SUCCESS(ret, "Failed to setup port0"); - TEST_ASSERT_EQUAL(rte_event_port_dequeue_depth(TEST_DEV_ID, 0), - pconf.dequeue_depth, "Wrong port dequeue depth"); + 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"); + TEST_ASSERT_EQUAL(value, pconf.dequeue_depth, + "Wrong port dequeue depth"); return TEST_SUCCESS; } @@ -481,8 +485,12 @@ test_eventdev_enqueue_depth(void) ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf); TEST_ASSERT_SUCCESS(ret, "Failed to setup port0"); - TEST_ASSERT_EQUAL(rte_event_port_enqueue_depth(TEST_DEV_ID, 0), - pconf.enqueue_depth, "Wrong port enqueue depth"); + 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"); + TEST_ASSERT_EQUAL(value, pconf.dequeue_depth, + "Wrong port enqueue depth"); return TEST_SUCCESS; } -- 2.7.4 ^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [dpdk-dev] [PATCH v4 1/4] eventdev: add port attribute function 2017-09-14 16:09 ` [dpdk-dev] [PATCH v4 1/4] eventdev: add port attribute function Harry van Haaren @ 2017-09-14 16:19 ` Van Haaren, Harry 0 siblings, 0 replies; 35+ messages in thread From: Van Haaren, Harry @ 2017-09-14 16:19 UTC (permalink / raw) To: dev; +Cc: jerin.jacob > From: Van Haaren, Harry > Sent: Thursday, September 14, 2017 5:09 PM > To: dev@dpdk.org > Cc: jerin.jacob@caviumnetworks.com; Van Haaren, Harry > <harry.van.haaren@intel.com> > Subject: [PATCH v4 1/4] eventdev: add port attribute function > > This commit reworks the port functions to retrieve information > about the port, like the enq or deq depths. Note that "port count" > is a device attribute, and is added in a later patch for dev attributes. Just to clarify the "Note", the rte_event_port_count() function exists before this patchset. This patch itself doesn't change/update it to the new style attr API yet, the 2/4 patch does. Based on how git made the diff, it *looks* like the port_count() function is changed. See patch 2/4 where the function is *actually* updated to dev_attr() API :) ^ permalink raw reply [flat|nested] 35+ messages in thread
* [dpdk-dev] [PATCH v4 2/4] eventdev: add dev attribute get function 2017-09-14 16:08 ` [dpdk-dev] [PATCH v4 " Harry van Haaren 2017-09-14 16:09 ` [dpdk-dev] [PATCH v4 1/4] eventdev: add port attribute function Harry van Haaren @ 2017-09-14 16:09 ` Harry van Haaren 2017-09-14 16:09 ` [dpdk-dev] [PATCH v4 3/4] eventdev: add queue attribute function Harry van Haaren ` (4 subsequent siblings) 6 siblings, 0 replies; 35+ messages in thread From: Harry van Haaren @ 2017-09-14 16:09 UTC (permalink / raw) To: dev; +Cc: jerin.jacob, Harry van Haaren This commit adds a device attribute function, allowing flexible fetching of device attributes, like port count or queue count. The unit tests and .map file are updated to the new function. Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com> --- v4: [feedback http://dpdk.org/dev/patchwork/patch/28521/ ] - Fixed default case comment (Jerin) - Removed /* out */ comment in .h and .c (Jerin) - Move function declaration in .h file to dev area (Jerin) - Fix inconsistent removal of queue_count() function (Harry) --- lib/librte_eventdev/rte_eventdev.c | 35 ++++--- lib/librte_eventdev/rte_eventdev.h | 37 ++++--- lib/librte_eventdev/rte_eventdev_version.map | 3 +- test/test/test_eventdev.c | 110 ++++++++++++++++----- test/test/test_eventdev_octeontx.c | 143 ++++++++++++++++++++------- 5 files changed, 241 insertions(+), 87 deletions(-) diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c index 9eacc73..ea76444 100644 --- a/lib/librte_eventdev/rte_eventdev.c +++ b/lib/librte_eventdev/rte_eventdev.c @@ -610,15 +610,6 @@ rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id, } uint8_t -rte_event_queue_count(uint8_t dev_id) -{ - struct rte_eventdev *dev; - - dev = &rte_eventdevs[dev_id]; - return dev->data->nb_queues; -} - -uint8_t rte_event_queue_priority(uint8_t dev_id, uint8_t queue_id) { struct rte_eventdev *dev; @@ -743,13 +734,29 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, return 0; } -uint8_t -rte_event_port_count(uint8_t dev_id) +int +rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id, + uint32_t *attr_value) { struct rte_eventdev *dev; + if (!attr_value) + return -EINVAL; + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); dev = &rte_eventdevs[dev_id]; - return dev->data->nb_ports; + + switch (attr_id) { + case RTE_EVENT_DEV_ATTR_PORT_COUNT: + *attr_value = dev->data->nb_ports; + break; + case RTE_EVENT_DEV_ATTR_QUEUE_COUNT: + *attr_value = dev->data->nb_queues; + break; + default: + return -EINVAL; + } + + return 0; } int @@ -757,6 +764,10 @@ rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, uint32_t *attr_value) { struct rte_eventdev *dev; + + if (!attr_value) + return -EINVAL; + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); dev = &rte_eventdevs[dev_id]; if (!is_valid_port(dev, port_id)) { diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h index e1febfa..0f7f10a 100644 --- a/lib/librte_eventdev/rte_eventdev.h +++ b/lib/librte_eventdev/rte_eventdev.h @@ -399,6 +399,32 @@ struct rte_event_dev_info { int rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info); +/** + * The count of ports. + */ +#define RTE_EVENT_DEV_ATTR_PORT_COUNT 0 +/** + * The count of queues. + */ +#define RTE_EVENT_DEV_ATTR_QUEUE_COUNT 1 + +/** + * Get an attribute from a device. + * + * @param dev_id Eventdev id + * @param attr_id The attribute ID to retrieve + * @param[out] attr_value A pointer that will be filled in with the attribute + * value if successful. + * + * @retval 0 Successfully retrieved attribute value + * -EINVAL Invalid device or *attr_id* provided, or *attr_value* + * is NULL + */ +int +rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id, + uint32_t *attr_value); + + /* Event device configuration bitmap flags */ #define RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT (1ULL << 0) /**< Override the global *dequeue_timeout_ns* and use per dequeue timeout in ns. @@ -715,17 +741,6 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, const struct rte_event_port_conf *port_conf); /** - * Get the number of ports on a specific event device - * - * @param dev_id - * Event device identifier. - * @return - * - The number of configured ports - */ -uint8_t -rte_event_port_count(uint8_t dev_id); - -/** * The queue depth of the port on the enqueue side */ #define RTE_EVENT_PORT_ATTR_ENQ_DEPTH 0 diff --git a/lib/librte_eventdev/rte_eventdev_version.map b/lib/librte_eventdev/rte_eventdev_version.map index 57d0b72..1353a6d 100644 --- a/lib/librte_eventdev/rte_eventdev_version.map +++ b/lib/librte_eventdev/rte_eventdev_version.map @@ -19,14 +19,12 @@ DPDK_17.05 { rte_event_port_default_conf_get; rte_event_port_setup; - rte_event_port_count; rte_event_port_link; rte_event_port_unlink; rte_event_port_links_get; rte_event_queue_default_conf_get; rte_event_queue_setup; - rte_event_queue_count; rte_event_queue_priority; rte_event_dequeue_timeout_ticks; @@ -53,6 +51,7 @@ DPDK_17.08 { DPDK_17.11 { global: + rte_event_dev_attr_get; rte_event_port_attr_get; } DPDK_17.08; diff --git a/test/test/test_eventdev.c b/test/test/test_eventdev.c index f3ec470..0c612be 100644 --- a/test/test/test_eventdev.c +++ b/test/test/test_eventdev.c @@ -273,7 +273,12 @@ test_eventdev_queue_default_conf_get(void) ret = rte_event_queue_default_conf_get(TEST_DEV_ID, 0, NULL); TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_default_conf_get(TEST_DEV_ID, i, &qconf); TEST_ASSERT_SUCCESS(ret, "Failed to get queue%d info", i); @@ -318,8 +323,12 @@ test_eventdev_queue_setup(void) ret = rte_event_queue_setup(TEST_DEV_ID, 0, &qconf); TEST_ASSERT_SUCCESS(ret, "Failed to setup queue0"); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i); } @@ -336,8 +345,12 @@ test_eventdev_queue_count(void) ret = rte_event_dev_info_get(TEST_DEV_ID, &info); TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info"); - TEST_ASSERT_EQUAL(rte_event_queue_count(TEST_DEV_ID), - info.max_event_queues, "Wrong queue count"); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + TEST_ASSERT_EQUAL(queue_count, info.max_event_queues, + "Wrong queue count"); return TEST_SUCCESS; } @@ -353,7 +366,12 @@ test_eventdev_queue_priority(void) ret = rte_event_dev_info_get(TEST_DEV_ID, &info); TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info"); - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_default_conf_get(TEST_DEV_ID, i, &qconf); TEST_ASSERT_SUCCESS(ret, "Failed to get queue%d def conf", i); @@ -362,8 +380,9 @@ test_eventdev_queue_priority(void) TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i); } - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { + for (i = 0; i < (int)queue_count; i++) { priority = rte_event_queue_priority(TEST_DEV_ID, i); + if (info.event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_QOS) TEST_ASSERT_EQUAL(priority, i % RTE_EVENT_DEV_PRIORITY_LOWEST, @@ -386,11 +405,16 @@ test_eventdev_port_default_conf_get(void) ret = rte_event_port_default_conf_get(TEST_DEV_ID, 0, NULL); TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + ret = rte_event_port_default_conf_get(TEST_DEV_ID, - rte_event_port_count(TEST_DEV_ID) + 1, NULL); + port_count + 1, NULL); TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); - for (i = 0; i < rte_event_port_count(TEST_DEV_ID); i++) { + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_default_conf_get(TEST_DEV_ID, i, &pconf); TEST_ASSERT_SUCCESS(ret, "Failed to get port%d info", i); @@ -436,8 +460,12 @@ test_eventdev_port_setup(void) ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf); TEST_ASSERT_SUCCESS(ret, "Failed to setup port0"); + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); - for (i = 0; i < rte_event_port_count(TEST_DEV_ID); i++) { + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup port%d", i); } @@ -504,8 +532,11 @@ test_eventdev_port_count(void) ret = rte_event_dev_info_get(TEST_DEV_ID, &info); TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info"); - TEST_ASSERT_EQUAL(rte_event_port_count(TEST_DEV_ID), - info.max_event_ports, "Wrong port count"); + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + TEST_ASSERT_EQUAL(port_count, info.max_event_ports, "Wrong port count"); return TEST_SUCCESS; } @@ -532,19 +563,28 @@ test_eventdev_start_stop(void) ret = eventdev_configure_setup(); TEST_ASSERT_SUCCESS(ret, "Failed to configure eventdev"); - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i); } - for (i = 0; i < rte_event_port_count(TEST_DEV_ID); i++) { + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup port%d", i); } ret = rte_event_port_link(TEST_DEV_ID, 0, NULL, NULL, 0); - TEST_ASSERT(ret == rte_event_queue_count(TEST_DEV_ID), - "Failed to link port, device %d", TEST_DEV_ID); + TEST_ASSERT(ret == (int)queue_count, "Failed to link port, device %d", + TEST_DEV_ID); ret = rte_event_dev_start(TEST_DEV_ID); TEST_ASSERT_SUCCESS(ret, "Failed to start device%d", TEST_DEV_ID); @@ -562,19 +602,28 @@ eventdev_setup_device(void) ret = eventdev_configure_setup(); TEST_ASSERT_SUCCESS(ret, "Failed to configure eventdev"); - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i); } - for (i = 0; i < rte_event_port_count(TEST_DEV_ID); i++) { + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup port%d", i); } ret = rte_event_port_link(TEST_DEV_ID, 0, NULL, NULL, 0); - TEST_ASSERT(ret == rte_event_queue_count(TEST_DEV_ID), - "Failed to link port, device %d", TEST_DEV_ID); + TEST_ASSERT(ret == (int)queue_count, "Failed to link port, device %d", + TEST_DEV_ID); ret = rte_event_dev_start(TEST_DEV_ID); TEST_ASSERT_SUCCESS(ret, "Failed to start device%d", TEST_DEV_ID); @@ -599,7 +648,11 @@ test_eventdev_link(void) TEST_ASSERT(ret >= 0, "Failed to link with NULL device%d", TEST_DEV_ID); - nb_queues = rte_event_queue_count(TEST_DEV_ID); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + nb_queues = queue_count; for (i = 0; i < nb_queues; i++) { queues[i] = i; priorities[i] = RTE_EVENT_DEV_PRIORITY_NORMAL; @@ -622,7 +675,11 @@ test_eventdev_unlink(void) TEST_ASSERT(ret >= 0, "Failed to unlink with NULL device%d", TEST_DEV_ID); - nb_queues = rte_event_queue_count(TEST_DEV_ID); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + nb_queues = queue_count; for (i = 0; i < nb_queues; i++) queues[i] = i; @@ -636,7 +693,7 @@ test_eventdev_unlink(void) static int test_eventdev_link_get(void) { - int ret, nb_queues, i; + int ret, i; uint8_t queues[RTE_EVENT_MAX_QUEUES_PER_DEV]; uint8_t priorities[RTE_EVENT_MAX_QUEUES_PER_DEV]; @@ -645,7 +702,11 @@ test_eventdev_link_get(void) TEST_ASSERT(ret >= 0, "Failed to link with NULL device%d", TEST_DEV_ID); - nb_queues = rte_event_queue_count(TEST_DEV_ID); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + const int nb_queues = queue_count; for (i = 0; i < nb_queues; i++) queues[i] = i; @@ -657,7 +718,6 @@ test_eventdev_link_get(void) TEST_ASSERT(ret == 0, "(%d)Wrong link get=%d", TEST_DEV_ID, ret); /* link all queues and get the links */ - nb_queues = rte_event_queue_count(TEST_DEV_ID); for (i = 0; i < nb_queues; i++) { queues[i] = i; priorities[i] = RTE_EVENT_DEV_PRIORITY_NORMAL; @@ -687,8 +747,8 @@ test_eventdev_link_get(void) ret = rte_event_port_unlink(TEST_DEV_ID, 0, NULL, 0); TEST_ASSERT(ret == nb_queues, "Failed to unlink(device%d) ret=%d", TEST_DEV_ID, ret); + /* 4links and 2 unlinks */ - nb_queues = rte_event_queue_count(TEST_DEV_ID); if (nb_queues >= 4) { for (i = 0; i < 4; i++) { queues[i] = i; diff --git a/test/test/test_eventdev_octeontx.c b/test/test/test_eventdev_octeontx.c index 774d030..b88b0d2 100644 --- a/test/test/test_eventdev_octeontx.c +++ b/test/test/test_eventdev_octeontx.c @@ -193,8 +193,13 @@ _eventdev_setup(int mode) ret = rte_event_dev_configure(evdev, &dev_conf); TEST_ASSERT_SUCCESS(ret, "Failed to configure eventdev"); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + if (mode == TEST_EVENTDEV_SETUP_PRIORITY) { - if (rte_event_queue_count(evdev) > 8) { + if (queue_count > 8) { printf("test expects the unique priority per queue\n"); return -ENOTSUP; } @@ -204,8 +209,8 @@ _eventdev_setup(int mode) * RTE_EVENT_DEV_PRIORITY_LOWEST */ uint8_t step = (RTE_EVENT_DEV_PRIORITY_LOWEST + 1) / - rte_event_queue_count(evdev); - for (i = 0; i < rte_event_queue_count(evdev); i++) { + queue_count; + for (i = 0; i < (int)queue_count; i++) { struct rte_event_queue_conf queue_conf; ret = rte_event_queue_default_conf_get(evdev, i, @@ -218,13 +223,17 @@ _eventdev_setup(int mode) } else { /* Configure event queues with default priority */ - for (i = 0; i < rte_event_queue_count(evdev); i++) { + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_setup(evdev, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup queue=%d", i); } } /* Configure event ports */ - for (i = 0; i < rte_event_port_count(evdev); i++) { + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_setup(evdev, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup port=%d", i); ret = rte_event_port_link(evdev, i, NULL, NULL, 0); @@ -335,6 +344,11 @@ generate_random_events(const unsigned int total_events) unsigned int i; int ret; + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + ret = rte_event_dev_info_get(evdev, &info); TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info"); for (i = 0; i < total_events; i++) { @@ -343,7 +357,7 @@ generate_random_events(const unsigned int total_events) rte_rand() % (RTE_EVENT_TYPE_CPU + 1) /* event_type */, rte_rand() % 256 /* sub_event_type */, rte_rand() % (RTE_SCHED_TYPE_PARALLEL + 1), - rte_rand() % rte_event_queue_count(evdev) /* queue */, + rte_rand() % queue_count /* queue */, 0 /* port */, 1 /* events */); if (ret) @@ -482,7 +496,7 @@ test_multi_queue_enq_single_port_deq(void) } /* - * Inject 0..MAX_EVENTS events over 0..rte_event_queue_count() with modulus + * Inject 0..MAX_EVENTS events over 0..queue_count with modulus * operation * * For example, Inject 32 events over 0..7 queues @@ -498,15 +512,19 @@ test_multi_queue_enq_single_port_deq(void) static int validate_queue_priority(uint32_t index, uint8_t port, struct rte_event *ev) { - uint32_t range = MAX_EVENTS / rte_event_queue_count(evdev); - uint32_t expected_val = (index % range) * rte_event_queue_count(evdev); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + uint32_t range = MAX_EVENTS / queue_count; + uint32_t expected_val = (index % range) * queue_count; expected_val += ev->queue_id; RTE_SET_USED(port); TEST_ASSERT_EQUAL(ev->mbuf->seqn, expected_val, "seqn=%d index=%d expected=%d range=%d nb_queues=%d max_event=%d", ev->mbuf->seqn, index, expected_val, range, - rte_event_queue_count(evdev), MAX_EVENTS); + queue_count, MAX_EVENTS); return 0; } @@ -518,8 +536,12 @@ test_multi_queue_priority(void) int i, max_evts_roundoff; /* See validate_queue_priority() comments for priority validate logic */ - max_evts_roundoff = MAX_EVENTS / rte_event_queue_count(evdev); - max_evts_roundoff *= rte_event_queue_count(evdev); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + max_evts_roundoff = MAX_EVENTS / queue_count; + max_evts_roundoff *= queue_count; for (i = 0; i < max_evts_roundoff; i++) { struct rte_event ev = {.event = 0, .u64 = 0}; @@ -528,7 +550,7 @@ test_multi_queue_priority(void) TEST_ASSERT_NOT_NULL(m, "mempool alloc failed"); m->seqn = i; - queue = i % rte_event_queue_count(evdev); + queue = i % queue_count; update_event_and_validation_attr(m, &ev, 0, RTE_EVENT_TYPE_CPU, 0, RTE_SCHED_TYPE_PARALLEL, queue, 0); rte_event_enqueue_burst(evdev, 0, &ev, 1); @@ -651,18 +673,21 @@ static int test_multi_queue_enq_multi_port_deq(void) { const unsigned int total_events = MAX_EVENTS; - uint8_t nr_ports; + uint32_t nr_ports; int ret; ret = generate_random_events(total_events); if (ret) return TEST_FAILED; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); + nr_ports = RTE_MIN(nr_ports, rte_lcore_count() - 1); if (!nr_ports) { printf("%s: Not enough ports=%d or workers=%d\n", __func__, - rte_event_port_count(evdev), rte_lcore_count() - 1); + nr_ports, rte_lcore_count() - 1); return TEST_SUCCESS; } @@ -691,14 +716,23 @@ test_queue_to_port_single_link(void) { int i, nr_links, ret; + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + /* Unlink all connections that created in eventdev_setup */ - for (i = 0; i < rte_event_port_count(evdev); i++) { + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_unlink(evdev, i, NULL, 0); TEST_ASSERT(ret >= 0, "Failed to unlink all queues port=%d", i); } - nr_links = RTE_MIN(rte_event_port_count(evdev), - rte_event_queue_count(evdev)); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + + nr_links = RTE_MIN(port_count, queue_count); const unsigned int total_events = MAX_EVENTS / nr_links; /* Link queue x to port x and inject events to queue x through port x */ @@ -750,10 +784,20 @@ static int test_queue_to_port_multi_link(void) { int ret, port0_events = 0, port1_events = 0; - uint8_t nr_queues, nr_ports, queue, port; + uint8_t queue, port; + uint32_t nr_queues = 0; + uint32_t nr_ports = 0; + + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &nr_queues), "Queue count get failed"); - nr_queues = rte_event_queue_count(evdev); - nr_ports = rte_event_port_count(evdev); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &nr_queues), "Queue count get failed"); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); if (nr_ports < 2) { printf("%s: Not enough ports to test ports=%d\n", @@ -854,14 +898,17 @@ test_multiport_flow_sched_type_test(uint8_t in_sched_type, uint8_t out_sched_type) { const unsigned int total_events = MAX_EVENTS; - uint8_t nr_ports; + uint32_t nr_ports; int ret; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); + nr_ports = RTE_MIN(nr_ports, rte_lcore_count() - 1); if (!nr_ports) { printf("%s: Not enough ports=%d or workers=%d\n", __func__, - rte_event_port_count(evdev), rte_lcore_count() - 1); + nr_ports, rte_lcore_count() - 1); return TEST_SUCCESS; } @@ -1007,15 +1054,23 @@ test_multiport_queue_sched_type_test(uint8_t in_sched_type, uint8_t out_sched_type) { const unsigned int total_events = MAX_EVENTS; - uint8_t nr_ports; + uint32_t nr_ports; int ret; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); + + nr_ports = RTE_MIN(nr_ports, rte_lcore_count() - 1); - if (rte_event_queue_count(evdev) < 2 || !nr_ports) { + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + if (queue_count < 2 || !nr_ports) { printf("%s: Not enough queues=%d ports=%d or workers=%d\n", - __func__, rte_event_queue_count(evdev), - rte_event_port_count(evdev), rte_lcore_count() - 1); + __func__, queue_count, nr_ports, + rte_lcore_count() - 1); return TEST_SUCCESS; } @@ -1142,14 +1197,17 @@ worker_flow_based_pipeline_max_stages_rand_sched_type(void *arg) static int launch_multi_port_max_stages_random_sched_type(int (*fn)(void *)) { - uint8_t nr_ports; + uint32_t nr_ports; int ret; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); + nr_ports = RTE_MIN(nr_ports, rte_lcore_count() - 1); if (!nr_ports) { printf("%s: Not enough ports=%d or workers=%d\n", __func__, - rte_event_port_count(evdev), rte_lcore_count() - 1); + nr_ports, rte_lcore_count() - 1); return TEST_SUCCESS; } @@ -1184,7 +1242,11 @@ worker_queue_based_pipeline_max_stages_rand_sched_type(void *arg) struct rte_event ev; uint16_t valid_event; uint8_t port = param->port; - uint8_t nr_queues = rte_event_queue_count(evdev); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + uint8_t nr_queues = queue_count; rte_atomic32_t *total_events = param->total_events; while (rte_atomic32_read(total_events) > 0) { @@ -1222,7 +1284,11 @@ worker_mixed_pipeline_max_stages_rand_sched_type(void *arg) struct rte_event ev; uint16_t valid_event; uint8_t port = param->port; - uint8_t nr_queues = rte_event_queue_count(evdev); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + uint8_t nr_queues = queue_count; rte_atomic32_t *total_events = param->total_events; while (rte_atomic32_read(total_events) > 0) { @@ -1288,9 +1354,12 @@ worker_ordered_flow_producer(void *arg) static inline int test_producer_consumer_ingress_order_test(int (*fn)(void *)) { - uint8_t nr_ports; + uint32_t nr_ports; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); + nr_ports = RTE_MIN(nr_ports, rte_lcore_count() - 1); if (rte_lcore_count() < 3 || nr_ports < 2) { printf("### Not enough cores for %s test.\n", __func__); -- 2.7.4 ^ permalink raw reply [flat|nested] 35+ messages in thread
* [dpdk-dev] [PATCH v4 3/4] eventdev: add queue attribute function 2017-09-14 16:08 ` [dpdk-dev] [PATCH v4 " Harry van Haaren 2017-09-14 16:09 ` [dpdk-dev] [PATCH v4 1/4] eventdev: add port attribute function Harry van Haaren 2017-09-14 16:09 ` [dpdk-dev] [PATCH v4 2/4] eventdev: add dev attribute get function Harry van Haaren @ 2017-09-14 16:09 ` Harry van Haaren 2017-09-14 16:09 ` [dpdk-dev] [PATCH v4 4/4] eventdev: add device started attribute Harry van Haaren ` (3 subsequent siblings) 6 siblings, 0 replies; 35+ messages in thread From: Harry van Haaren @ 2017-09-14 16:09 UTC (permalink / raw) To: dev; +Cc: jerin.jacob, Harry van Haaren This commit adds a generic queue attribute function. It also removes the previous rte_event_queue_priority() and priority() functions, and updates the map files and unit tests to use the new attr functions. Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> --- v4: [feedback http://dpdk.org/dev/patchwork/patch/28522/ ] - Add default case with -EINVAL (Jerin) - Remove explicity /* out */ comments on parameters (Jerin) - Move queue_attr function in header to queue area (Jerin) - Remove queue_count() fixes, should be in 2/4 patch (Harry) --- lib/librte_eventdev/rte_eventdev.c | 40 +++++++++++++++++++--------- lib/librte_eventdev/rte_eventdev.h | 35 +++++++++++------------- lib/librte_eventdev/rte_eventdev_version.map | 2 +- test/test/test_eventdev.c | 6 ++++- 4 files changed, 49 insertions(+), 34 deletions(-) diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c index ea76444..73e1df0 100644 --- a/lib/librte_eventdev/rte_eventdev.c +++ b/lib/librte_eventdev/rte_eventdev.c @@ -609,18 +609,6 @@ rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id, return (*dev->dev_ops->queue_setup)(dev, queue_id, queue_conf); } -uint8_t -rte_event_queue_priority(uint8_t dev_id, uint8_t queue_id) -{ - struct rte_eventdev *dev; - - dev = &rte_eventdevs[dev_id]; - if (dev->data->event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_QOS) - return dev->data->queues_prio[queue_id]; - else - return RTE_EVENT_DEV_PRIORITY_NORMAL; -} - static inline int is_valid_port(struct rte_eventdev *dev, uint8_t port_id) { @@ -789,6 +777,34 @@ rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, } int +rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id, + uint32_t *attr_value) +{ + struct rte_eventdev *dev; + + if (!attr_value) + return -EINVAL; + + 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; + } + + 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]; + break; + default: + return -EINVAL; + }; + return 0; +} + +int rte_event_port_link(uint8_t dev_id, uint8_t port_id, const uint8_t queues[], const uint8_t priorities[], uint16_t nb_links) diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h index 0f7f10a..3fd447a 100644 --- a/lib/librte_eventdev/rte_eventdev.h +++ b/lib/librte_eventdev/rte_eventdev.h @@ -633,31 +633,26 @@ rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id, const struct rte_event_queue_conf *queue_conf); /** - * Get the number of event queues on a specific event device - * - * @param dev_id - * Event device identifier. - * @return - * - The number of configured event queues + * The priority of the queue. */ -uint8_t -rte_event_queue_count(uint8_t dev_id); +#define RTE_EVENT_QUEUE_ATTR_PRIORITY 0 /** - * Get the priority of the event queue on a specific event device + * Get an attribute from a queue. * - * @param dev_id - * Event device identifier. - * @param queue_id - * Event queue identifier. - * @return - * - If the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability then the - * configured priority of the event queue in - * [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST] range - * else the value RTE_EVENT_DEV_PRIORITY_NORMAL + * @param dev_id Eventdev id + * @param queue_id Eventdev queue id + * @param attr_id The attribute ID to retrieve + * @param[out] attr_value A pointer that will be filled in with the attribute + * value if successful + * + * @retval 0 Successfully returned value + * -EINVAL invalid device, queue or attr_id provided, or attr_value + * was NULL */ -uint8_t -rte_event_queue_priority(uint8_t dev_id, uint8_t queue_id); +int +rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id, + uint32_t *attr_value); /* Event port specific APIs */ diff --git a/lib/librte_eventdev/rte_eventdev_version.map b/lib/librte_eventdev/rte_eventdev_version.map index 1353a6d..90266a8 100644 --- a/lib/librte_eventdev/rte_eventdev_version.map +++ b/lib/librte_eventdev/rte_eventdev_version.map @@ -25,7 +25,6 @@ DPDK_17.05 { rte_event_queue_default_conf_get; rte_event_queue_setup; - rte_event_queue_priority; rte_event_dequeue_timeout_ticks; @@ -53,5 +52,6 @@ DPDK_17.11 { rte_event_dev_attr_get; rte_event_port_attr_get; + rte_event_queue_attr_get; } DPDK_17.08; diff --git a/test/test/test_eventdev.c b/test/test/test_eventdev.c index 0c612be..2d34435 100644 --- a/test/test/test_eventdev.c +++ b/test/test/test_eventdev.c @@ -381,7 +381,11 @@ test_eventdev_queue_priority(void) } for (i = 0; i < (int)queue_count; i++) { - priority = rte_event_queue_priority(TEST_DEV_ID, i); + uint32_t tmp; + TEST_ASSERT_SUCCESS(rte_event_queue_attr_get(TEST_DEV_ID, i, + RTE_EVENT_QUEUE_ATTR_PRIORITY, &tmp), + "Queue priority get failed"); + priority = tmp; if (info.event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_QOS) TEST_ASSERT_EQUAL(priority, -- 2.7.4 ^ permalink raw reply [flat|nested] 35+ messages in thread
* [dpdk-dev] [PATCH v4 4/4] eventdev: add device started attribute 2017-09-14 16:08 ` [dpdk-dev] [PATCH v4 " Harry van Haaren ` (2 preceding siblings ...) 2017-09-14 16:09 ` [dpdk-dev] [PATCH v4 3/4] eventdev: add queue attribute function Harry van Haaren @ 2017-09-14 16:09 ` Harry van Haaren 2017-09-15 6:14 ` [dpdk-dev] [PATCH v4 0/4] eventdev: add attribute based get APIs Nipun Gupta ` (2 subsequent siblings) 6 siblings, 0 replies; 35+ messages in thread From: Harry van Haaren @ 2017-09-14 16:09 UTC (permalink / raw) To: dev; +Cc: jerin.jacob, Harry van Haaren This commit adds an attribute to the eventdev, allowing applications to retrieve if the eventdev is running or stopped. Note that no API or ABI changes were required in adding the statistic, and code changes are minimal. Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com> --- lib/librte_eventdev/rte_eventdev.c | 3 +++ lib/librte_eventdev/rte_eventdev.h | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c index 73e1df0..480b26e 100644 --- a/lib/librte_eventdev/rte_eventdev.c +++ b/lib/librte_eventdev/rte_eventdev.c @@ -740,6 +740,9 @@ rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id, case RTE_EVENT_DEV_ATTR_QUEUE_COUNT: *attr_value = dev->data->nb_queues; break; + case RTE_EVENT_DEV_ATTR_STARTED: + *attr_value = dev->data->dev_started; + break; default: return -EINVAL; } diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h index 3fd447a..1b629fc 100644 --- a/lib/librte_eventdev/rte_eventdev.h +++ b/lib/librte_eventdev/rte_eventdev.h @@ -407,6 +407,10 @@ rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info); * The count of queues. */ #define RTE_EVENT_DEV_ATTR_QUEUE_COUNT 1 +/** + * The status of the device, zero for stopped, non-zero for started. + */ +#define RTE_EVENT_DEV_ATTR_STARTED 2 /** * Get an attribute from a device. -- 2.7.4 ^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [dpdk-dev] [PATCH v4 0/4] eventdev: add attribute based get APIs 2017-09-14 16:08 ` [dpdk-dev] [PATCH v4 " Harry van Haaren ` (3 preceding siblings ...) 2017-09-14 16:09 ` [dpdk-dev] [PATCH v4 4/4] eventdev: add device started attribute Harry van Haaren @ 2017-09-15 6:14 ` Nipun Gupta 2017-09-21 9:57 ` Jerin Jacob 2017-09-15 12:33 ` Jerin Jacob 2017-09-20 13:35 ` [dpdk-dev] [PATCH v5 0/5] Harry van Haaren 6 siblings, 1 reply; 35+ messages in thread From: Nipun Gupta @ 2017-09-15 6:14 UTC (permalink / raw) To: Harry van Haaren, dev; +Cc: jerin.jacob > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Harry van Haaren > Sent: Thursday, September 14, 2017 21:39 > To: dev@dpdk.org > Cc: jerin.jacob@caviumnetworks.com; Harry van Haaren > <harry.van.haaren@intel.com> > Subject: [dpdk-dev] [PATCH v4 0/4] eventdev: add attribute based get APIs > > This patchset refactors the eventdev API to be more flexible > and capable. In particular, the API is capable of returning an > error value if an invalid device, port or attribute ID is passed > in, which was not possible with the previous APIs. > > The implementation of this patchset is based on a v1 patch[1], > and after some discussion this API was seen as the best solution. > > In terms of flexibility, the attribute id allows addition of new > common eventdev layer attributes without breaking ABI or adding > new functions. Note that these attributes are not data-path, and > that PMDs should continue to use the xstats API for reporting any > unique PMD statistics that are available. > > Regarding API/ABI compatibility, I have removed the functions from > the .map files - please review the .map file changes for ABI issues > carefully. > > The last patch of this series adds a started attribute to the device, > allowing the application to query if a device is currently running. > > -Harry > > [1] http://dpdk.org/dev/patchwork/patch/27152/ > > --- > > v4: > - Rework based on review by Jerin > - default: cases into switches > - Remove old functions from .map file > - Remove /* out */ parameters > - Rework header file definitions to match logical order > - Rework patch split > - Cleaner removal of queue_count() function > > v3: > - Fix checkpatch issues... somehow I broke my checkpatch script :/ > > v2: > - New APIs design based on discussion of initial patch. > > > > Harry van Haaren (4): > eventdev: add port attribute function > eventdev: add dev attribute get function > eventdev: add queue attribute function > eventdev: add device started attribute > > lib/librte_eventdev/rte_eventdev.c | 97 ++++++++++++------ > lib/librte_eventdev/rte_eventdev.h | 115 +++++++++++---------- > lib/librte_eventdev/rte_eventdev_version.map | 14 ++- > test/test/test_eventdev.c | 132 +++++++++++++++++++------ > test/test/test_eventdev_octeontx.c | 143 ++++++++++++++++++++------- > 5 files changed, 345 insertions(+), 156 deletions(-) > > -- > 2.7.4 Changes look good. Series Acked-by: Nipun Gupta <Nipun.gupta@nxp.com> ^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [dpdk-dev] [PATCH v4 0/4] eventdev: add attribute based get APIs 2017-09-15 6:14 ` [dpdk-dev] [PATCH v4 0/4] eventdev: add attribute based get APIs Nipun Gupta @ 2017-09-21 9:57 ` Jerin Jacob 0 siblings, 0 replies; 35+ messages in thread From: Jerin Jacob @ 2017-09-21 9:57 UTC (permalink / raw) To: Nipun Gupta; +Cc: Harry van Haaren, dev -----Original Message----- > Date: Fri, 15 Sep 2017 06:14:26 +0000 > From: Nipun Gupta <nipun.gupta@nxp.com> > To: Harry van Haaren <harry.van.haaren@intel.com>, "dev@dpdk.org" > <dev@dpdk.org> > CC: "jerin.jacob@caviumnetworks.com" <jerin.jacob@caviumnetworks.com> > Subject: RE: [dpdk-dev] [PATCH v4 0/4] eventdev: add attribute based get > APIs > > > > > -- > > 2.7.4 > > Changes look good. > Series Acked-by: Nipun Gupta <Nipun.gupta@nxp.com> Applied the v5 series to dpdk-next-eventdev/master. Thanks. > ^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [dpdk-dev] [PATCH v4 0/4] eventdev: add attribute based get APIs 2017-09-14 16:08 ` [dpdk-dev] [PATCH v4 " Harry van Haaren ` (4 preceding siblings ...) 2017-09-15 6:14 ` [dpdk-dev] [PATCH v4 0/4] eventdev: add attribute based get APIs Nipun Gupta @ 2017-09-15 12:33 ` Jerin Jacob 2017-09-20 13:35 ` [dpdk-dev] [PATCH v5 0/5] Harry van Haaren 6 siblings, 0 replies; 35+ messages in thread From: Jerin Jacob @ 2017-09-15 12:33 UTC (permalink / raw) To: Harry van Haaren; +Cc: dev -----Original Message----- > Date: Thu, 14 Sep 2017 17:08:59 +0100 > From: Harry van Haaren <harry.van.haaren@intel.com> > To: dev@dpdk.org > CC: jerin.jacob@caviumnetworks.com, Harry van Haaren > <harry.van.haaren@intel.com> > Subject: [PATCH v4 0/4] eventdev: add attribute based get APIs > X-Mailer: git-send-email 2.7.4 > > This patchset refactors the eventdev API to be more flexible > and capable. In particular, the API is capable of returning an > error value if an invalid device, port or attribute ID is passed > in, which was not possible with the previous APIs. > > The implementation of this patchset is based on a v1 patch[1], > and after some discussion this API was seen as the best solution. > > In terms of flexibility, the attribute id allows addition of new > common eventdev layer attributes without breaking ABI or adding > new functions. Note that these attributes are not data-path, and > that PMDs should continue to use the xstats API for reporting any > unique PMD statistics that are available. > > Regarding API/ABI compatibility, I have removed the functions from > the .map files - please review the .map file changes for ABI issues > carefully. > > The last patch of this series adds a started attribute to the device, > allowing the application to query if a device is currently running. > > -Harry > > [1] http://dpdk.org/dev/patchwork/patch/27152/ > > --- > > v4: > - Rework based on review by Jerin > - default: cases into switches > - Remove old functions from .map file > - Remove /* out */ parameters > - Rework header file definitions to match logical order > - Rework patch split > - Cleaner removal of queue_count() function The changes looks good. Since the functions are removed, we need to update .so version. Please update LIBABIVER(file: lib/librte_eventdev/Makefile) and update the release notes reference to the similar change: http://dpdk.org/browse/dpdk/commit/?id=945081a76ab0bb481f1d62125aa5b547fcc000bd ^ permalink raw reply [flat|nested] 35+ messages in thread
* [dpdk-dev] [PATCH v5 0/5] 2017-09-14 16:08 ` [dpdk-dev] [PATCH v4 " Harry van Haaren ` (5 preceding siblings ...) 2017-09-15 12:33 ` Jerin Jacob @ 2017-09-20 13:35 ` Harry van Haaren 2017-09-20 13:35 ` [dpdk-dev] [PATCH v5 1/5] eventdev: add port attribute function Harry van Haaren ` (4 more replies) 6 siblings, 5 replies; 35+ messages in thread From: Harry van Haaren @ 2017-09-20 13:35 UTC (permalink / raw) To: dev; +Cc: jerin.jacob, Harry van Haaren This patchset refactors the eventdev API to be more flexible and capable. In particular, the API is capable of returning an error value if an invalid device, port or attribute ID is passed in, which was not possible with the previous APIs. The implementation of this patchset is based on a v1 patch[1], and after some discussion this API was seen as the best solution. In terms of flexibility, the attribute id allows addition of new common eventdev layer attributes without breaking ABI or adding new functions. Note that these attributes are not data-path, and that PMDs should continue to use the xstats API for reporting any unique PMD statistics that are available. Regarding API/ABI compatibility, I have removed the functions from the .map files - please review the .map file changes for ABI issues carefully. The last patch of this series adds a started attribute to the device, allowing the application to query if a device is currently running. -Harry [1] http://dpdk.org/dev/patchwork/patch/27152/ --- v5: - Bump library version of Eventdev (Jerin) - http://dpdk.org/ml/archives/dev/2017-September/075551.html v4: - Rework based on review by Jerin - default: cases into switches - Remove old functions from .map file - Remove /* out */ parameters - Rework header file definitions to match logical order - Rework patch split - Cleaner removal of queue_count() function v3: - Fix checkpatch issues... somehow I broke my checkpatch script :/ v2: - New APIs design based on discussion of initial patch. Harry van Haaren (5): eventdev: add port attribute function eventdev: add dev attribute get function eventdev: add queue attribute function eventdev: add device started attribute eventdev: bump library version doc/guides/rel_notes/release_17_11.rst | 2 +- lib/librte_eventdev/Makefile | 2 +- lib/librte_eventdev/rte_eventdev.c | 97 ++++++++++++------ lib/librte_eventdev/rte_eventdev.h | 115 +++++++++++---------- lib/librte_eventdev/rte_eventdev_version.map | 14 ++- test/test/test_eventdev.c | 132 +++++++++++++++++++------ test/test/test_eventdev_octeontx.c | 143 ++++++++++++++++++++------- 7 files changed, 347 insertions(+), 158 deletions(-) -- 2.7.4 ^ permalink raw reply [flat|nested] 35+ messages in thread
* [dpdk-dev] [PATCH v5 1/5] eventdev: add port attribute function 2017-09-20 13:35 ` [dpdk-dev] [PATCH v5 0/5] Harry van Haaren @ 2017-09-20 13:35 ` Harry van Haaren 2017-09-20 13:36 ` [dpdk-dev] [PATCH v5 2/5] eventdev: add dev attribute get function Harry van Haaren ` (3 subsequent siblings) 4 siblings, 0 replies; 35+ messages in thread From: Harry van Haaren @ 2017-09-20 13:35 UTC (permalink / raw) To: dev; +Cc: jerin.jacob, Harry van Haaren This commit reworks the port functions to retrieve information about the port, like the enq or deq depths. Note that "port count" is a device attribute, and is added in a later patch for dev attributes. Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> --- v4: feedback from http://dpdk.org/dev/patchwork/patch/28520/ - Added default: case into switch, returns -EINVAL as per header file (Jerin) - Reworked .map file, removed old functions (Jerin) - Renamed EXPERIMENTAL section of map file to 17.11 (Jerin) - Removed /* out */ comments in .h and .c (Jerin) --- lib/librte_eventdev/rte_eventdev.c | 35 ++++++++++++-------- lib/librte_eventdev/rte_eventdev.h | 49 ++++++++++++---------------- lib/librte_eventdev/rte_eventdev_version.map | 9 +++-- test/test/test_eventdev.c | 16 ++++++--- 4 files changed, 61 insertions(+), 48 deletions(-) diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c index bbb3805..9eacc73 100644 --- a/lib/librte_eventdev/rte_eventdev.c +++ b/lib/librte_eventdev/rte_eventdev.c @@ -744,30 +744,37 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, } uint8_t -rte_event_port_dequeue_depth(uint8_t dev_id, uint8_t port_id) +rte_event_port_count(uint8_t dev_id) { struct rte_eventdev *dev; dev = &rte_eventdevs[dev_id]; - return dev->data->ports_dequeue_depth[port_id]; + return dev->data->nb_ports; } -uint8_t -rte_event_port_enqueue_depth(uint8_t dev_id, uint8_t port_id) +int +rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, + uint32_t *attr_value) { struct rte_eventdev *dev; - + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); dev = &rte_eventdevs[dev_id]; - return dev->data->ports_enqueue_depth[port_id]; -} - -uint8_t -rte_event_port_count(uint8_t dev_id) -{ - struct rte_eventdev *dev; + if (!is_valid_port(dev, port_id)) { + RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id); + return -EINVAL; + } - dev = &rte_eventdevs[dev_id]; - return dev->data->nb_ports; + switch (attr_id) { + case RTE_EVENT_PORT_ATTR_ENQ_DEPTH: + *attr_value = dev->data->ports_enqueue_depth[port_id]; + break; + case RTE_EVENT_PORT_ATTR_DEQ_DEPTH: + *attr_value = dev->data->ports_dequeue_depth[port_id]; + break; + default: + return -EINVAL; + }; + return 0; } int diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h index 128bc52..e1febfa 100644 --- a/lib/librte_eventdev/rte_eventdev.h +++ b/lib/librte_eventdev/rte_eventdev.h @@ -715,47 +715,40 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, const struct rte_event_port_conf *port_conf); /** - * Get the number of dequeue queue depth configured for event port designated - * by its *port_id* on a specific event device + * Get the number of ports on a specific event device * * @param dev_id * Event device identifier. - * @param port_id - * Event port identifier. * @return - * - The number of configured dequeue queue depth - * - * @see rte_event_dequeue_burst() + * - The number of configured ports */ uint8_t -rte_event_port_dequeue_depth(uint8_t dev_id, uint8_t port_id); +rte_event_port_count(uint8_t dev_id); /** - * Get the number of enqueue queue depth configured for event port designated - * by its *port_id* on a specific event device - * - * @param dev_id - * Event device identifier. - * @param port_id - * Event port identifier. - * @return - * - The number of configured enqueue queue depth - * - * @see rte_event_enqueue_burst() + * The queue depth of the port on the enqueue side */ -uint8_t -rte_event_port_enqueue_depth(uint8_t dev_id, uint8_t port_id); +#define RTE_EVENT_PORT_ATTR_ENQ_DEPTH 0 +/** + * The queue depth of the port on the dequeue side + */ +#define RTE_EVENT_PORT_ATTR_DEQ_DEPTH 1 /** - * Get the number of ports on a specific event device + * Get an attribute from a port. * - * @param dev_id - * Event device identifier. - * @return - * - The number of configured ports + * @param dev_id Eventdev id + * @param port_id Eventdev port id + * @param attr_id The attribute ID to retrieve + * @param[out] attr_value A pointer that will be filled in with the attribute + * value if successful + * + * @retval 0 Successfully returned value + * -EINVAL Invalid device, port or attr_id, or attr_value was NULL */ -uint8_t -rte_event_port_count(uint8_t dev_id); +int +rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, + uint32_t *attr_value); /** * Start an event device. diff --git a/lib/librte_eventdev/rte_eventdev_version.map b/lib/librte_eventdev/rte_eventdev_version.map index 4c48e5f..57d0b72 100644 --- a/lib/librte_eventdev/rte_eventdev_version.map +++ b/lib/librte_eventdev/rte_eventdev_version.map @@ -19,8 +19,6 @@ DPDK_17.05 { rte_event_port_default_conf_get; rte_event_port_setup; - rte_event_port_dequeue_depth; - rte_event_port_enqueue_depth; rte_event_port_count; rte_event_port_link; rte_event_port_unlink; @@ -51,3 +49,10 @@ DPDK_17.08 { rte_event_ring_init; rte_event_ring_lookup; } DPDK_17.05; + +DPDK_17.11 { + global: + + rte_event_port_attr_get; + +} DPDK_17.08; diff --git a/test/test/test_eventdev.c b/test/test/test_eventdev.c index f766191..f3ec470 100644 --- a/test/test/test_eventdev.c +++ b/test/test/test_eventdev.c @@ -460,8 +460,12 @@ test_eventdev_dequeue_depth(void) ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf); TEST_ASSERT_SUCCESS(ret, "Failed to setup port0"); - TEST_ASSERT_EQUAL(rte_event_port_dequeue_depth(TEST_DEV_ID, 0), - pconf.dequeue_depth, "Wrong port dequeue depth"); + 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"); + TEST_ASSERT_EQUAL(value, pconf.dequeue_depth, + "Wrong port dequeue depth"); return TEST_SUCCESS; } @@ -481,8 +485,12 @@ test_eventdev_enqueue_depth(void) ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf); TEST_ASSERT_SUCCESS(ret, "Failed to setup port0"); - TEST_ASSERT_EQUAL(rte_event_port_enqueue_depth(TEST_DEV_ID, 0), - pconf.enqueue_depth, "Wrong port enqueue depth"); + 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"); + TEST_ASSERT_EQUAL(value, pconf.dequeue_depth, + "Wrong port enqueue depth"); return TEST_SUCCESS; } -- 2.7.4 ^ permalink raw reply [flat|nested] 35+ messages in thread
* [dpdk-dev] [PATCH v5 2/5] eventdev: add dev attribute get function 2017-09-20 13:35 ` [dpdk-dev] [PATCH v5 0/5] Harry van Haaren 2017-09-20 13:35 ` [dpdk-dev] [PATCH v5 1/5] eventdev: add port attribute function Harry van Haaren @ 2017-09-20 13:36 ` Harry van Haaren 2017-09-20 13:36 ` [dpdk-dev] [PATCH v5 3/5] eventdev: add queue attribute function Harry van Haaren ` (2 subsequent siblings) 4 siblings, 0 replies; 35+ messages in thread From: Harry van Haaren @ 2017-09-20 13:36 UTC (permalink / raw) To: dev; +Cc: jerin.jacob, Harry van Haaren This commit adds a device attribute function, allowing flexible fetching of device attributes, like port count or queue count. The unit tests and .map file are updated to the new function. Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com> --- v4: [feedback http://dpdk.org/dev/patchwork/patch/28521/ ] - Fixed default case comment (Jerin) - Removed /* out */ comment in .h and .c (Jerin) - Move function declaration in .h file to dev area (Jerin) - Fix inconsistent removal of queue_count() function (Harry) --- lib/librte_eventdev/rte_eventdev.c | 35 ++++--- lib/librte_eventdev/rte_eventdev.h | 37 ++++--- lib/librte_eventdev/rte_eventdev_version.map | 3 +- test/test/test_eventdev.c | 110 ++++++++++++++++----- test/test/test_eventdev_octeontx.c | 143 ++++++++++++++++++++------- 5 files changed, 241 insertions(+), 87 deletions(-) diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c index 9eacc73..ea76444 100644 --- a/lib/librte_eventdev/rte_eventdev.c +++ b/lib/librte_eventdev/rte_eventdev.c @@ -610,15 +610,6 @@ rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id, } uint8_t -rte_event_queue_count(uint8_t dev_id) -{ - struct rte_eventdev *dev; - - dev = &rte_eventdevs[dev_id]; - return dev->data->nb_queues; -} - -uint8_t rte_event_queue_priority(uint8_t dev_id, uint8_t queue_id) { struct rte_eventdev *dev; @@ -743,13 +734,29 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, return 0; } -uint8_t -rte_event_port_count(uint8_t dev_id) +int +rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id, + uint32_t *attr_value) { struct rte_eventdev *dev; + if (!attr_value) + return -EINVAL; + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); dev = &rte_eventdevs[dev_id]; - return dev->data->nb_ports; + + switch (attr_id) { + case RTE_EVENT_DEV_ATTR_PORT_COUNT: + *attr_value = dev->data->nb_ports; + break; + case RTE_EVENT_DEV_ATTR_QUEUE_COUNT: + *attr_value = dev->data->nb_queues; + break; + default: + return -EINVAL; + } + + return 0; } int @@ -757,6 +764,10 @@ rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, uint32_t *attr_value) { struct rte_eventdev *dev; + + if (!attr_value) + return -EINVAL; + RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); dev = &rte_eventdevs[dev_id]; if (!is_valid_port(dev, port_id)) { diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h index e1febfa..0f7f10a 100644 --- a/lib/librte_eventdev/rte_eventdev.h +++ b/lib/librte_eventdev/rte_eventdev.h @@ -399,6 +399,32 @@ struct rte_event_dev_info { int rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info); +/** + * The count of ports. + */ +#define RTE_EVENT_DEV_ATTR_PORT_COUNT 0 +/** + * The count of queues. + */ +#define RTE_EVENT_DEV_ATTR_QUEUE_COUNT 1 + +/** + * Get an attribute from a device. + * + * @param dev_id Eventdev id + * @param attr_id The attribute ID to retrieve + * @param[out] attr_value A pointer that will be filled in with the attribute + * value if successful. + * + * @retval 0 Successfully retrieved attribute value + * -EINVAL Invalid device or *attr_id* provided, or *attr_value* + * is NULL + */ +int +rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id, + uint32_t *attr_value); + + /* Event device configuration bitmap flags */ #define RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT (1ULL << 0) /**< Override the global *dequeue_timeout_ns* and use per dequeue timeout in ns. @@ -715,17 +741,6 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, const struct rte_event_port_conf *port_conf); /** - * Get the number of ports on a specific event device - * - * @param dev_id - * Event device identifier. - * @return - * - The number of configured ports - */ -uint8_t -rte_event_port_count(uint8_t dev_id); - -/** * The queue depth of the port on the enqueue side */ #define RTE_EVENT_PORT_ATTR_ENQ_DEPTH 0 diff --git a/lib/librte_eventdev/rte_eventdev_version.map b/lib/librte_eventdev/rte_eventdev_version.map index 57d0b72..1353a6d 100644 --- a/lib/librte_eventdev/rte_eventdev_version.map +++ b/lib/librte_eventdev/rte_eventdev_version.map @@ -19,14 +19,12 @@ DPDK_17.05 { rte_event_port_default_conf_get; rte_event_port_setup; - rte_event_port_count; rte_event_port_link; rte_event_port_unlink; rte_event_port_links_get; rte_event_queue_default_conf_get; rte_event_queue_setup; - rte_event_queue_count; rte_event_queue_priority; rte_event_dequeue_timeout_ticks; @@ -53,6 +51,7 @@ DPDK_17.08 { DPDK_17.11 { global: + rte_event_dev_attr_get; rte_event_port_attr_get; } DPDK_17.08; diff --git a/test/test/test_eventdev.c b/test/test/test_eventdev.c index f3ec470..0c612be 100644 --- a/test/test/test_eventdev.c +++ b/test/test/test_eventdev.c @@ -273,7 +273,12 @@ test_eventdev_queue_default_conf_get(void) ret = rte_event_queue_default_conf_get(TEST_DEV_ID, 0, NULL); TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_default_conf_get(TEST_DEV_ID, i, &qconf); TEST_ASSERT_SUCCESS(ret, "Failed to get queue%d info", i); @@ -318,8 +323,12 @@ test_eventdev_queue_setup(void) ret = rte_event_queue_setup(TEST_DEV_ID, 0, &qconf); TEST_ASSERT_SUCCESS(ret, "Failed to setup queue0"); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i); } @@ -336,8 +345,12 @@ test_eventdev_queue_count(void) ret = rte_event_dev_info_get(TEST_DEV_ID, &info); TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info"); - TEST_ASSERT_EQUAL(rte_event_queue_count(TEST_DEV_ID), - info.max_event_queues, "Wrong queue count"); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + TEST_ASSERT_EQUAL(queue_count, info.max_event_queues, + "Wrong queue count"); return TEST_SUCCESS; } @@ -353,7 +366,12 @@ test_eventdev_queue_priority(void) ret = rte_event_dev_info_get(TEST_DEV_ID, &info); TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info"); - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_default_conf_get(TEST_DEV_ID, i, &qconf); TEST_ASSERT_SUCCESS(ret, "Failed to get queue%d def conf", i); @@ -362,8 +380,9 @@ test_eventdev_queue_priority(void) TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i); } - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { + for (i = 0; i < (int)queue_count; i++) { priority = rte_event_queue_priority(TEST_DEV_ID, i); + if (info.event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_QOS) TEST_ASSERT_EQUAL(priority, i % RTE_EVENT_DEV_PRIORITY_LOWEST, @@ -386,11 +405,16 @@ test_eventdev_port_default_conf_get(void) ret = rte_event_port_default_conf_get(TEST_DEV_ID, 0, NULL); TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + ret = rte_event_port_default_conf_get(TEST_DEV_ID, - rte_event_port_count(TEST_DEV_ID) + 1, NULL); + port_count + 1, NULL); TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); - for (i = 0; i < rte_event_port_count(TEST_DEV_ID); i++) { + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_default_conf_get(TEST_DEV_ID, i, &pconf); TEST_ASSERT_SUCCESS(ret, "Failed to get port%d info", i); @@ -436,8 +460,12 @@ test_eventdev_port_setup(void) ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf); TEST_ASSERT_SUCCESS(ret, "Failed to setup port0"); + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); - for (i = 0; i < rte_event_port_count(TEST_DEV_ID); i++) { + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup port%d", i); } @@ -504,8 +532,11 @@ test_eventdev_port_count(void) ret = rte_event_dev_info_get(TEST_DEV_ID, &info); TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info"); - TEST_ASSERT_EQUAL(rte_event_port_count(TEST_DEV_ID), - info.max_event_ports, "Wrong port count"); + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + TEST_ASSERT_EQUAL(port_count, info.max_event_ports, "Wrong port count"); return TEST_SUCCESS; } @@ -532,19 +563,28 @@ test_eventdev_start_stop(void) ret = eventdev_configure_setup(); TEST_ASSERT_SUCCESS(ret, "Failed to configure eventdev"); - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i); } - for (i = 0; i < rte_event_port_count(TEST_DEV_ID); i++) { + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup port%d", i); } ret = rte_event_port_link(TEST_DEV_ID, 0, NULL, NULL, 0); - TEST_ASSERT(ret == rte_event_queue_count(TEST_DEV_ID), - "Failed to link port, device %d", TEST_DEV_ID); + TEST_ASSERT(ret == (int)queue_count, "Failed to link port, device %d", + TEST_DEV_ID); ret = rte_event_dev_start(TEST_DEV_ID); TEST_ASSERT_SUCCESS(ret, "Failed to start device%d", TEST_DEV_ID); @@ -562,19 +602,28 @@ eventdev_setup_device(void) ret = eventdev_configure_setup(); TEST_ASSERT_SUCCESS(ret, "Failed to configure eventdev"); - for (i = 0; i < rte_event_queue_count(TEST_DEV_ID); i++) { + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i); } - for (i = 0; i < rte_event_port_count(TEST_DEV_ID); i++) { + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_setup(TEST_DEV_ID, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup port%d", i); } ret = rte_event_port_link(TEST_DEV_ID, 0, NULL, NULL, 0); - TEST_ASSERT(ret == rte_event_queue_count(TEST_DEV_ID), - "Failed to link port, device %d", TEST_DEV_ID); + TEST_ASSERT(ret == (int)queue_count, "Failed to link port, device %d", + TEST_DEV_ID); ret = rte_event_dev_start(TEST_DEV_ID); TEST_ASSERT_SUCCESS(ret, "Failed to start device%d", TEST_DEV_ID); @@ -599,7 +648,11 @@ test_eventdev_link(void) TEST_ASSERT(ret >= 0, "Failed to link with NULL device%d", TEST_DEV_ID); - nb_queues = rte_event_queue_count(TEST_DEV_ID); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + nb_queues = queue_count; for (i = 0; i < nb_queues; i++) { queues[i] = i; priorities[i] = RTE_EVENT_DEV_PRIORITY_NORMAL; @@ -622,7 +675,11 @@ test_eventdev_unlink(void) TEST_ASSERT(ret >= 0, "Failed to unlink with NULL device%d", TEST_DEV_ID); - nb_queues = rte_event_queue_count(TEST_DEV_ID); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + nb_queues = queue_count; for (i = 0; i < nb_queues; i++) queues[i] = i; @@ -636,7 +693,7 @@ test_eventdev_unlink(void) static int test_eventdev_link_get(void) { - int ret, nb_queues, i; + int ret, i; uint8_t queues[RTE_EVENT_MAX_QUEUES_PER_DEV]; uint8_t priorities[RTE_EVENT_MAX_QUEUES_PER_DEV]; @@ -645,7 +702,11 @@ test_eventdev_link_get(void) TEST_ASSERT(ret >= 0, "Failed to link with NULL device%d", TEST_DEV_ID); - nb_queues = rte_event_queue_count(TEST_DEV_ID); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count), + "Queue count get failed"); + const int nb_queues = queue_count; for (i = 0; i < nb_queues; i++) queues[i] = i; @@ -657,7 +718,6 @@ test_eventdev_link_get(void) TEST_ASSERT(ret == 0, "(%d)Wrong link get=%d", TEST_DEV_ID, ret); /* link all queues and get the links */ - nb_queues = rte_event_queue_count(TEST_DEV_ID); for (i = 0; i < nb_queues; i++) { queues[i] = i; priorities[i] = RTE_EVENT_DEV_PRIORITY_NORMAL; @@ -687,8 +747,8 @@ test_eventdev_link_get(void) ret = rte_event_port_unlink(TEST_DEV_ID, 0, NULL, 0); TEST_ASSERT(ret == nb_queues, "Failed to unlink(device%d) ret=%d", TEST_DEV_ID, ret); + /* 4links and 2 unlinks */ - nb_queues = rte_event_queue_count(TEST_DEV_ID); if (nb_queues >= 4) { for (i = 0; i < 4; i++) { queues[i] = i; diff --git a/test/test/test_eventdev_octeontx.c b/test/test/test_eventdev_octeontx.c index 774d030..b88b0d2 100644 --- a/test/test/test_eventdev_octeontx.c +++ b/test/test/test_eventdev_octeontx.c @@ -193,8 +193,13 @@ _eventdev_setup(int mode) ret = rte_event_dev_configure(evdev, &dev_conf); TEST_ASSERT_SUCCESS(ret, "Failed to configure eventdev"); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + if (mode == TEST_EVENTDEV_SETUP_PRIORITY) { - if (rte_event_queue_count(evdev) > 8) { + if (queue_count > 8) { printf("test expects the unique priority per queue\n"); return -ENOTSUP; } @@ -204,8 +209,8 @@ _eventdev_setup(int mode) * RTE_EVENT_DEV_PRIORITY_LOWEST */ uint8_t step = (RTE_EVENT_DEV_PRIORITY_LOWEST + 1) / - rte_event_queue_count(evdev); - for (i = 0; i < rte_event_queue_count(evdev); i++) { + queue_count; + for (i = 0; i < (int)queue_count; i++) { struct rte_event_queue_conf queue_conf; ret = rte_event_queue_default_conf_get(evdev, i, @@ -218,13 +223,17 @@ _eventdev_setup(int mode) } else { /* Configure event queues with default priority */ - for (i = 0; i < rte_event_queue_count(evdev); i++) { + for (i = 0; i < (int)queue_count; i++) { ret = rte_event_queue_setup(evdev, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup queue=%d", i); } } /* Configure event ports */ - for (i = 0; i < rte_event_port_count(evdev); i++) { + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_setup(evdev, i, NULL); TEST_ASSERT_SUCCESS(ret, "Failed to setup port=%d", i); ret = rte_event_port_link(evdev, i, NULL, NULL, 0); @@ -335,6 +344,11 @@ generate_random_events(const unsigned int total_events) unsigned int i; int ret; + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + ret = rte_event_dev_info_get(evdev, &info); TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info"); for (i = 0; i < total_events; i++) { @@ -343,7 +357,7 @@ generate_random_events(const unsigned int total_events) rte_rand() % (RTE_EVENT_TYPE_CPU + 1) /* event_type */, rte_rand() % 256 /* sub_event_type */, rte_rand() % (RTE_SCHED_TYPE_PARALLEL + 1), - rte_rand() % rte_event_queue_count(evdev) /* queue */, + rte_rand() % queue_count /* queue */, 0 /* port */, 1 /* events */); if (ret) @@ -482,7 +496,7 @@ test_multi_queue_enq_single_port_deq(void) } /* - * Inject 0..MAX_EVENTS events over 0..rte_event_queue_count() with modulus + * Inject 0..MAX_EVENTS events over 0..queue_count with modulus * operation * * For example, Inject 32 events over 0..7 queues @@ -498,15 +512,19 @@ test_multi_queue_enq_single_port_deq(void) static int validate_queue_priority(uint32_t index, uint8_t port, struct rte_event *ev) { - uint32_t range = MAX_EVENTS / rte_event_queue_count(evdev); - uint32_t expected_val = (index % range) * rte_event_queue_count(evdev); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + uint32_t range = MAX_EVENTS / queue_count; + uint32_t expected_val = (index % range) * queue_count; expected_val += ev->queue_id; RTE_SET_USED(port); TEST_ASSERT_EQUAL(ev->mbuf->seqn, expected_val, "seqn=%d index=%d expected=%d range=%d nb_queues=%d max_event=%d", ev->mbuf->seqn, index, expected_val, range, - rte_event_queue_count(evdev), MAX_EVENTS); + queue_count, MAX_EVENTS); return 0; } @@ -518,8 +536,12 @@ test_multi_queue_priority(void) int i, max_evts_roundoff; /* See validate_queue_priority() comments for priority validate logic */ - max_evts_roundoff = MAX_EVENTS / rte_event_queue_count(evdev); - max_evts_roundoff *= rte_event_queue_count(evdev); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + max_evts_roundoff = MAX_EVENTS / queue_count; + max_evts_roundoff *= queue_count; for (i = 0; i < max_evts_roundoff; i++) { struct rte_event ev = {.event = 0, .u64 = 0}; @@ -528,7 +550,7 @@ test_multi_queue_priority(void) TEST_ASSERT_NOT_NULL(m, "mempool alloc failed"); m->seqn = i; - queue = i % rte_event_queue_count(evdev); + queue = i % queue_count; update_event_and_validation_attr(m, &ev, 0, RTE_EVENT_TYPE_CPU, 0, RTE_SCHED_TYPE_PARALLEL, queue, 0); rte_event_enqueue_burst(evdev, 0, &ev, 1); @@ -651,18 +673,21 @@ static int test_multi_queue_enq_multi_port_deq(void) { const unsigned int total_events = MAX_EVENTS; - uint8_t nr_ports; + uint32_t nr_ports; int ret; ret = generate_random_events(total_events); if (ret) return TEST_FAILED; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); + nr_ports = RTE_MIN(nr_ports, rte_lcore_count() - 1); if (!nr_ports) { printf("%s: Not enough ports=%d or workers=%d\n", __func__, - rte_event_port_count(evdev), rte_lcore_count() - 1); + nr_ports, rte_lcore_count() - 1); return TEST_SUCCESS; } @@ -691,14 +716,23 @@ test_queue_to_port_single_link(void) { int i, nr_links, ret; + uint32_t port_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &port_count), "Port count get failed"); + /* Unlink all connections that created in eventdev_setup */ - for (i = 0; i < rte_event_port_count(evdev); i++) { + for (i = 0; i < (int)port_count; i++) { ret = rte_event_port_unlink(evdev, i, NULL, 0); TEST_ASSERT(ret >= 0, "Failed to unlink all queues port=%d", i); } - nr_links = RTE_MIN(rte_event_port_count(evdev), - rte_event_queue_count(evdev)); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + + nr_links = RTE_MIN(port_count, queue_count); const unsigned int total_events = MAX_EVENTS / nr_links; /* Link queue x to port x and inject events to queue x through port x */ @@ -750,10 +784,20 @@ static int test_queue_to_port_multi_link(void) { int ret, port0_events = 0, port1_events = 0; - uint8_t nr_queues, nr_ports, queue, port; + uint8_t queue, port; + uint32_t nr_queues = 0; + uint32_t nr_ports = 0; + + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &nr_queues), "Queue count get failed"); - nr_queues = rte_event_queue_count(evdev); - nr_ports = rte_event_port_count(evdev); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &nr_queues), "Queue count get failed"); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); if (nr_ports < 2) { printf("%s: Not enough ports to test ports=%d\n", @@ -854,14 +898,17 @@ test_multiport_flow_sched_type_test(uint8_t in_sched_type, uint8_t out_sched_type) { const unsigned int total_events = MAX_EVENTS; - uint8_t nr_ports; + uint32_t nr_ports; int ret; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); + nr_ports = RTE_MIN(nr_ports, rte_lcore_count() - 1); if (!nr_ports) { printf("%s: Not enough ports=%d or workers=%d\n", __func__, - rte_event_port_count(evdev), rte_lcore_count() - 1); + nr_ports, rte_lcore_count() - 1); return TEST_SUCCESS; } @@ -1007,15 +1054,23 @@ test_multiport_queue_sched_type_test(uint8_t in_sched_type, uint8_t out_sched_type) { const unsigned int total_events = MAX_EVENTS; - uint8_t nr_ports; + uint32_t nr_ports; int ret; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); + + nr_ports = RTE_MIN(nr_ports, rte_lcore_count() - 1); - if (rte_event_queue_count(evdev) < 2 || !nr_ports) { + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + if (queue_count < 2 || !nr_ports) { printf("%s: Not enough queues=%d ports=%d or workers=%d\n", - __func__, rte_event_queue_count(evdev), - rte_event_port_count(evdev), rte_lcore_count() - 1); + __func__, queue_count, nr_ports, + rte_lcore_count() - 1); return TEST_SUCCESS; } @@ -1142,14 +1197,17 @@ worker_flow_based_pipeline_max_stages_rand_sched_type(void *arg) static int launch_multi_port_max_stages_random_sched_type(int (*fn)(void *)) { - uint8_t nr_ports; + uint32_t nr_ports; int ret; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); + nr_ports = RTE_MIN(nr_ports, rte_lcore_count() - 1); if (!nr_ports) { printf("%s: Not enough ports=%d or workers=%d\n", __func__, - rte_event_port_count(evdev), rte_lcore_count() - 1); + nr_ports, rte_lcore_count() - 1); return TEST_SUCCESS; } @@ -1184,7 +1242,11 @@ worker_queue_based_pipeline_max_stages_rand_sched_type(void *arg) struct rte_event ev; uint16_t valid_event; uint8_t port = param->port; - uint8_t nr_queues = rte_event_queue_count(evdev); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + uint8_t nr_queues = queue_count; rte_atomic32_t *total_events = param->total_events; while (rte_atomic32_read(total_events) > 0) { @@ -1222,7 +1284,11 @@ worker_mixed_pipeline_max_stages_rand_sched_type(void *arg) struct rte_event ev; uint16_t valid_event; uint8_t port = param->port; - uint8_t nr_queues = rte_event_queue_count(evdev); + uint32_t queue_count; + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_QUEUE_COUNT, + &queue_count), "Queue count get failed"); + uint8_t nr_queues = queue_count; rte_atomic32_t *total_events = param->total_events; while (rte_atomic32_read(total_events) > 0) { @@ -1288,9 +1354,12 @@ worker_ordered_flow_producer(void *arg) static inline int test_producer_consumer_ingress_order_test(int (*fn)(void *)) { - uint8_t nr_ports; + uint32_t nr_ports; - nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1); + TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(evdev, + RTE_EVENT_DEV_ATTR_PORT_COUNT, + &nr_ports), "Port count get failed"); + nr_ports = RTE_MIN(nr_ports, rte_lcore_count() - 1); if (rte_lcore_count() < 3 || nr_ports < 2) { printf("### Not enough cores for %s test.\n", __func__); -- 2.7.4 ^ permalink raw reply [flat|nested] 35+ messages in thread
* [dpdk-dev] [PATCH v5 3/5] eventdev: add queue attribute function 2017-09-20 13:35 ` [dpdk-dev] [PATCH v5 0/5] Harry van Haaren 2017-09-20 13:35 ` [dpdk-dev] [PATCH v5 1/5] eventdev: add port attribute function Harry van Haaren 2017-09-20 13:36 ` [dpdk-dev] [PATCH v5 2/5] eventdev: add dev attribute get function Harry van Haaren @ 2017-09-20 13:36 ` Harry van Haaren 2017-09-20 13:36 ` [dpdk-dev] [PATCH v5 4/5] eventdev: add device started attribute Harry van Haaren 2017-09-20 13:36 ` [dpdk-dev] [PATCH v5 5/5] eventdev: bump library version Harry van Haaren 4 siblings, 0 replies; 35+ messages in thread From: Harry van Haaren @ 2017-09-20 13:36 UTC (permalink / raw) To: dev; +Cc: jerin.jacob, Harry van Haaren This commit adds a generic queue attribute function. It also removes the previous rte_event_queue_priority() and priority() functions, and updates the map files and unit tests to use the new attr functions. Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> --- v4: [feedback http://dpdk.org/dev/patchwork/patch/28522/ ] - Add default case with -EINVAL (Jerin) - Remove explicity /* out */ comments on parameters (Jerin) - Move queue_attr function in header to queue area (Jerin) - Remove queue_count() fixes, should be in 2/4 patch (Harry) --- lib/librte_eventdev/rte_eventdev.c | 40 +++++++++++++++++++--------- lib/librte_eventdev/rte_eventdev.h | 35 +++++++++++------------- lib/librte_eventdev/rte_eventdev_version.map | 2 +- test/test/test_eventdev.c | 6 ++++- 4 files changed, 49 insertions(+), 34 deletions(-) diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c index ea76444..73e1df0 100644 --- a/lib/librte_eventdev/rte_eventdev.c +++ b/lib/librte_eventdev/rte_eventdev.c @@ -609,18 +609,6 @@ rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id, return (*dev->dev_ops->queue_setup)(dev, queue_id, queue_conf); } -uint8_t -rte_event_queue_priority(uint8_t dev_id, uint8_t queue_id) -{ - struct rte_eventdev *dev; - - dev = &rte_eventdevs[dev_id]; - if (dev->data->event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_QOS) - return dev->data->queues_prio[queue_id]; - else - return RTE_EVENT_DEV_PRIORITY_NORMAL; -} - static inline int is_valid_port(struct rte_eventdev *dev, uint8_t port_id) { @@ -789,6 +777,34 @@ rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, } int +rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id, + uint32_t *attr_value) +{ + struct rte_eventdev *dev; + + if (!attr_value) + return -EINVAL; + + 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; + } + + 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]; + break; + default: + return -EINVAL; + }; + return 0; +} + +int rte_event_port_link(uint8_t dev_id, uint8_t port_id, const uint8_t queues[], const uint8_t priorities[], uint16_t nb_links) diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h index 0f7f10a..3fd447a 100644 --- a/lib/librte_eventdev/rte_eventdev.h +++ b/lib/librte_eventdev/rte_eventdev.h @@ -633,31 +633,26 @@ rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id, const struct rte_event_queue_conf *queue_conf); /** - * Get the number of event queues on a specific event device - * - * @param dev_id - * Event device identifier. - * @return - * - The number of configured event queues + * The priority of the queue. */ -uint8_t -rte_event_queue_count(uint8_t dev_id); +#define RTE_EVENT_QUEUE_ATTR_PRIORITY 0 /** - * Get the priority of the event queue on a specific event device + * Get an attribute from a queue. * - * @param dev_id - * Event device identifier. - * @param queue_id - * Event queue identifier. - * @return - * - If the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability then the - * configured priority of the event queue in - * [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST] range - * else the value RTE_EVENT_DEV_PRIORITY_NORMAL + * @param dev_id Eventdev id + * @param queue_id Eventdev queue id + * @param attr_id The attribute ID to retrieve + * @param[out] attr_value A pointer that will be filled in with the attribute + * value if successful + * + * @retval 0 Successfully returned value + * -EINVAL invalid device, queue or attr_id provided, or attr_value + * was NULL */ -uint8_t -rte_event_queue_priority(uint8_t dev_id, uint8_t queue_id); +int +rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id, + uint32_t *attr_value); /* Event port specific APIs */ diff --git a/lib/librte_eventdev/rte_eventdev_version.map b/lib/librte_eventdev/rte_eventdev_version.map index 1353a6d..90266a8 100644 --- a/lib/librte_eventdev/rte_eventdev_version.map +++ b/lib/librte_eventdev/rte_eventdev_version.map @@ -25,7 +25,6 @@ DPDK_17.05 { rte_event_queue_default_conf_get; rte_event_queue_setup; - rte_event_queue_priority; rte_event_dequeue_timeout_ticks; @@ -53,5 +52,6 @@ DPDK_17.11 { rte_event_dev_attr_get; rte_event_port_attr_get; + rte_event_queue_attr_get; } DPDK_17.08; diff --git a/test/test/test_eventdev.c b/test/test/test_eventdev.c index 0c612be..2d34435 100644 --- a/test/test/test_eventdev.c +++ b/test/test/test_eventdev.c @@ -381,7 +381,11 @@ test_eventdev_queue_priority(void) } for (i = 0; i < (int)queue_count; i++) { - priority = rte_event_queue_priority(TEST_DEV_ID, i); + uint32_t tmp; + TEST_ASSERT_SUCCESS(rte_event_queue_attr_get(TEST_DEV_ID, i, + RTE_EVENT_QUEUE_ATTR_PRIORITY, &tmp), + "Queue priority get failed"); + priority = tmp; if (info.event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_QOS) TEST_ASSERT_EQUAL(priority, -- 2.7.4 ^ permalink raw reply [flat|nested] 35+ messages in thread
* [dpdk-dev] [PATCH v5 4/5] eventdev: add device started attribute 2017-09-20 13:35 ` [dpdk-dev] [PATCH v5 0/5] Harry van Haaren ` (2 preceding siblings ...) 2017-09-20 13:36 ` [dpdk-dev] [PATCH v5 3/5] eventdev: add queue attribute function Harry van Haaren @ 2017-09-20 13:36 ` Harry van Haaren 2017-09-20 13:36 ` [dpdk-dev] [PATCH v5 5/5] eventdev: bump library version Harry van Haaren 4 siblings, 0 replies; 35+ messages in thread From: Harry van Haaren @ 2017-09-20 13:36 UTC (permalink / raw) To: dev; +Cc: jerin.jacob, Harry van Haaren This commit adds an attribute to the eventdev, allowing applications to retrieve if the eventdev is running or stopped. Note that no API or ABI changes were required in adding the statistic, and code changes are minimal. Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com> --- lib/librte_eventdev/rte_eventdev.c | 3 +++ lib/librte_eventdev/rte_eventdev.h | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c index 73e1df0..480b26e 100644 --- a/lib/librte_eventdev/rte_eventdev.c +++ b/lib/librte_eventdev/rte_eventdev.c @@ -740,6 +740,9 @@ rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id, case RTE_EVENT_DEV_ATTR_QUEUE_COUNT: *attr_value = dev->data->nb_queues; break; + case RTE_EVENT_DEV_ATTR_STARTED: + *attr_value = dev->data->dev_started; + break; default: return -EINVAL; } diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h index 3fd447a..1b629fc 100644 --- a/lib/librte_eventdev/rte_eventdev.h +++ b/lib/librte_eventdev/rte_eventdev.h @@ -407,6 +407,10 @@ rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info); * The count of queues. */ #define RTE_EVENT_DEV_ATTR_QUEUE_COUNT 1 +/** + * The status of the device, zero for stopped, non-zero for started. + */ +#define RTE_EVENT_DEV_ATTR_STARTED 2 /** * Get an attribute from a device. -- 2.7.4 ^ permalink raw reply [flat|nested] 35+ messages in thread
* [dpdk-dev] [PATCH v5 5/5] eventdev: bump library version 2017-09-20 13:35 ` [dpdk-dev] [PATCH v5 0/5] Harry van Haaren ` (3 preceding siblings ...) 2017-09-20 13:36 ` [dpdk-dev] [PATCH v5 4/5] eventdev: add device started attribute Harry van Haaren @ 2017-09-20 13:36 ` Harry van Haaren 4 siblings, 0 replies; 35+ messages in thread From: Harry van Haaren @ 2017-09-20 13:36 UTC (permalink / raw) To: dev; +Cc: jerin.jacob, Harry van Haaren This commit bumps the library version to refect the ABI change caused by removing the individual rte_event_port_count, queue_count, and other get functions. These functions are superseded by the get-attribute style API, which allows fetching values without API/ABI changes. Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> --- doc/guides/rel_notes/release_17_11.rst | 2 +- lib/librte_eventdev/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/guides/rel_notes/release_17_11.rst b/doc/guides/rel_notes/release_17_11.rst index 170f4f9..c09b1a1 100644 --- a/doc/guides/rel_notes/release_17_11.rst +++ b/doc/guides/rel_notes/release_17_11.rst @@ -152,7 +152,7 @@ The libraries prepended with a plus sign were incremented in this version. librte_distributor.so.1 librte_eal.so.5 librte_ethdev.so.7 - librte_eventdev.so.2 + + librte_eventdev.so.3 librte_gro.so.1 librte_hash.so.2 librte_ip_frag.so.1 diff --git a/lib/librte_eventdev/Makefile b/lib/librte_eventdev/Makefile index 410578a..7d73ca9 100644 --- a/lib/librte_eventdev/Makefile +++ b/lib/librte_eventdev/Makefile @@ -34,7 +34,7 @@ include $(RTE_SDK)/mk/rte.vars.mk LIB = librte_eventdev.a # library version -LIBABIVER := 2 +LIBABIVER := 3 # build flags CFLAGS += -O3 -- 2.7.4 ^ permalink raw reply [flat|nested] 35+ messages in thread
end of thread, other threads:[~2017-09-21 9:57 UTC | newest] Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-07-24 12:48 [dpdk-dev] [PATCH] eventdev: add dev id checks to config functions Harry van Haaren 2017-09-04 5:20 ` Jerin Jacob 2017-09-06 14:45 ` Van Haaren, Harry 2017-09-06 14:57 ` Jerin Jacob 2017-09-08 15:18 ` [dpdk-dev] [PATCH v2 0/3] eventdev: add attribute based get APIs Harry van Haaren 2017-09-08 15:18 ` [dpdk-dev] [PATCH v2 1/4] eventdev: add port attribute function Harry van Haaren 2017-09-08 15:18 ` [dpdk-dev] [PATCH v2 2/4] eventdev: add dev attribute get function Harry van Haaren 2017-09-08 15:18 ` [dpdk-dev] [PATCH v2 3/4] eventdev: add queue attribute function Harry van Haaren 2017-09-08 15:18 ` [dpdk-dev] [PATCH v2 4/4] eventdev: add device started attribute Harry van Haaren 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 0/4] eventdev: add attribute based get APIs Harry van Haaren 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 1/4] eventdev: add port attribute function Harry van Haaren 2017-09-11 16:35 ` Jerin Jacob 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 2/4] eventdev: add dev attribute get function Harry van Haaren 2017-09-11 16:51 ` Jerin Jacob 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 3/4] eventdev: add queue attribute function Harry van Haaren 2017-09-11 17:36 ` Jerin Jacob 2017-09-08 15:36 ` [dpdk-dev] [PATCH v3 4/4] eventdev: add device started attribute Harry van Haaren 2017-09-11 17:52 ` Jerin Jacob 2017-09-12 8:07 ` Van Haaren, Harry 2017-09-11 16:16 ` [dpdk-dev] [PATCH v3 0/4] eventdev: add attribute based get APIs Jerin Jacob 2017-09-14 16:08 ` [dpdk-dev] [PATCH v4 " Harry van Haaren 2017-09-14 16:09 ` [dpdk-dev] [PATCH v4 1/4] eventdev: add port attribute function Harry van Haaren 2017-09-14 16:19 ` Van Haaren, Harry 2017-09-14 16:09 ` [dpdk-dev] [PATCH v4 2/4] eventdev: add dev attribute get function Harry van Haaren 2017-09-14 16:09 ` [dpdk-dev] [PATCH v4 3/4] eventdev: add queue attribute function Harry van Haaren 2017-09-14 16:09 ` [dpdk-dev] [PATCH v4 4/4] eventdev: add device started attribute Harry van Haaren 2017-09-15 6:14 ` [dpdk-dev] [PATCH v4 0/4] eventdev: add attribute based get APIs Nipun Gupta 2017-09-21 9:57 ` Jerin Jacob 2017-09-15 12:33 ` Jerin Jacob 2017-09-20 13:35 ` [dpdk-dev] [PATCH v5 0/5] Harry van Haaren 2017-09-20 13:35 ` [dpdk-dev] [PATCH v5 1/5] eventdev: add port attribute function Harry van Haaren 2017-09-20 13:36 ` [dpdk-dev] [PATCH v5 2/5] eventdev: add dev attribute get function Harry van Haaren 2017-09-20 13:36 ` [dpdk-dev] [PATCH v5 3/5] eventdev: add queue attribute function Harry van Haaren 2017-09-20 13:36 ` [dpdk-dev] [PATCH v5 4/5] eventdev: add device started attribute Harry van Haaren 2017-09-20 13:36 ` [dpdk-dev] [PATCH v5 5/5] eventdev: bump library version Harry van Haaren
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).