From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 48755101B for ; Wed, 20 Sep 2017 15:35:47 +0200 (CEST) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Sep 2017 06:35:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,421,1500966000"; d="scan'208";a="153521567" Received: from silpixa00398672.ir.intel.com ([10.237.223.128]) by fmsmga005.fm.intel.com with ESMTP; 20 Sep 2017 06:35:45 -0700 From: Harry van Haaren To: dev@dpdk.org Cc: jerin.jacob@caviumnetworks.com, Harry van Haaren Date: Wed, 20 Sep 2017 14:35:59 +0100 Message-Id: <1505914563-182552-2-git-send-email-harry.van.haaren@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505914563-182552-1-git-send-email-harry.van.haaren@intel.com> References: <1505405343-18234-1-git-send-email-harry.van.haaren@intel.com> <1505914563-182552-1-git-send-email-harry.van.haaren@intel.com> Subject: [dpdk-dev] [PATCH v5 1/5] eventdev: add port attribute 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: Wed, 20 Sep 2017 13:35:47 -0000 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 --- 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