From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 9F41927D for ; Fri, 8 Sep 2017 17:18:09 +0200 (CEST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Sep 2017 08:18:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,362,1500966000"; d="scan'208";a="147035363" Received: from silpixa00398672.ir.intel.com ([10.237.223.128]) by orsmga005.jf.intel.com with ESMTP; 08 Sep 2017 08:18:08 -0700 From: Harry van Haaren To: dev@dpdk.org Cc: jerin.jacob@caviumnetworks.com, Harry van Haaren Date: Fri, 8 Sep 2017 16:18:12 +0100 Message-Id: <1504883894-43451-3-git-send-email-harry.van.haaren@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504883894-43451-1-git-send-email-harry.van.haaren@intel.com> References: <1500900500-144237-1-git-send-email-harry.van.haaren@intel.com> <1504883894-43451-1-git-send-email-harry.van.haaren@intel.com> Subject: [dpdk-dev] [PATCH v2 2/4] eventdev: add dev attribute get function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Sep 2017 15:18:10 -0000 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 --- 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