From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 3253D199B6 for ; Wed, 20 Sep 2017 17:22:19 +0200 (CEST) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP; 20 Sep 2017 08:22:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,421,1500966000"; d="scan'208";a="153561606" Received: from txasoft-yocto.an.intel.com (HELO txasoft-yocto.an.intel.com.) ([10.123.72.111]) by fmsmga005.fm.intel.com with ESMTP; 20 Sep 2017 08:22:18 -0700 From: Gage Eads To: dev@dpdk.org Cc: jerin.jacob@caviumnetworks.com, harry.van.haaren@intel.com Date: Wed, 20 Sep 2017 10:21:02 -0500 Message-Id: <1505920863-14826-3-git-send-email-gage.eads@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505920863-14826-1-git-send-email-gage.eads@intel.com> References: <1505920863-14826-1-git-send-email-gage.eads@intel.com> Subject: [dpdk-dev] [PATCH 2/3] eventdev: extend port 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: Wed, 20 Sep 2017 15:22:20 -0000 This commit adds the new_event_threshold port attribute, so the entire port configuration structure passed to rte_event_queue_setup can be queried. Signed-off-by: Gage Eads --- lib/librte_eventdev/rte_eventdev.c | 71 ++++++++++++-------------------------- lib/librte_eventdev/rte_eventdev.h | 10 +++--- test/test/test_eventdev.c | 39 +++++++++++++++++---- 3 files changed, 61 insertions(+), 59 deletions(-) diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c index 06c184c..e6ed0a3 100644 --- a/lib/librte_eventdev/rte_eventdev.c +++ b/lib/librte_eventdev/rte_eventdev.c @@ -195,8 +195,7 @@ rte_event_dev_port_config(struct rte_eventdev *dev, uint8_t nb_ports) uint8_t old_nb_ports = dev->data->nb_ports; void **ports; uint16_t *links_map; - uint8_t *ports_dequeue_depth; - uint8_t *ports_enqueue_depth; + struct rte_event_port_conf *ports_cfg; unsigned int i; RTE_EDEV_LOG_DEBUG("Setup %d ports on device %u", nb_ports, @@ -214,26 +213,14 @@ rte_event_dev_port_config(struct rte_eventdev *dev, uint8_t nb_ports) return -(ENOMEM); } - /* Allocate memory to store ports dequeue depth */ - dev->data->ports_dequeue_depth = - rte_zmalloc_socket("eventdev->ports_dequeue_depth", - sizeof(dev->data->ports_dequeue_depth[0]) * nb_ports, + /* Allocate memory to store port configurations */ + dev->data->ports_cfg = + rte_zmalloc_socket("eventdev->ports_cfg", + sizeof(dev->data->ports_cfg[0]) * nb_ports, RTE_CACHE_LINE_SIZE, dev->data->socket_id); - if (dev->data->ports_dequeue_depth == NULL) { + if (dev->data->ports_cfg == NULL) { dev->data->nb_ports = 0; - RTE_EDEV_LOG_ERR("failed to get mem for port deq meta," - "nb_ports %u", nb_ports); - return -(ENOMEM); - } - - /* Allocate memory to store ports enqueue depth */ - dev->data->ports_enqueue_depth = - rte_zmalloc_socket("eventdev->ports_enqueue_depth", - sizeof(dev->data->ports_enqueue_depth[0]) * nb_ports, - RTE_CACHE_LINE_SIZE, dev->data->socket_id); - if (dev->data->ports_enqueue_depth == NULL) { - dev->data->nb_ports = 0; - RTE_EDEV_LOG_ERR("failed to get mem for port enq meta," + RTE_EDEV_LOG_ERR("failed to get mem for port cfg," "nb_ports %u", nb_ports); return -(ENOMEM); } @@ -257,8 +244,7 @@ rte_event_dev_port_config(struct rte_eventdev *dev, uint8_t nb_ports) RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->port_release, -ENOTSUP); ports = dev->data->ports; - ports_dequeue_depth = dev->data->ports_dequeue_depth; - ports_enqueue_depth = dev->data->ports_enqueue_depth; + ports_cfg = dev->data->ports_cfg; links_map = dev->data->links_map; for (i = nb_ports; i < old_nb_ports; i++) @@ -273,22 +259,12 @@ rte_event_dev_port_config(struct rte_eventdev *dev, uint8_t nb_ports) return -(ENOMEM); } - /* Realloc memory for ports_dequeue_depth */ - ports_dequeue_depth = rte_realloc(ports_dequeue_depth, - sizeof(ports_dequeue_depth[0]) * nb_ports, + /* Realloc memory for ports_cfg */ + ports_cfg = rte_realloc(ports_cfg, + sizeof(ports_cfg[0]) * nb_ports, RTE_CACHE_LINE_SIZE); - if (ports_dequeue_depth == NULL) { - RTE_EDEV_LOG_ERR("failed to realloc port dequeue meta," - " nb_ports %u", nb_ports); - return -(ENOMEM); - } - - /* Realloc memory for ports_enqueue_depth */ - ports_enqueue_depth = rte_realloc(ports_enqueue_depth, - sizeof(ports_enqueue_depth[0]) * nb_ports, - RTE_CACHE_LINE_SIZE); - if (ports_enqueue_depth == NULL) { - RTE_EDEV_LOG_ERR("failed to realloc port enqueue meta," + if (ports_cfg == NULL) { + RTE_EDEV_LOG_ERR("failed to realloc port cfg mem," " nb_ports %u", nb_ports); return -(ENOMEM); } @@ -314,18 +290,15 @@ rte_event_dev_port_config(struct rte_eventdev *dev, uint8_t nb_ports) memset(ports + old_nb_ports, 0, sizeof(ports[0]) * new_ps); - memset(ports_dequeue_depth + old_nb_ports, 0, - sizeof(ports_dequeue_depth[0]) * new_ps); - memset(ports_enqueue_depth + old_nb_ports, 0, - sizeof(ports_enqueue_depth[0]) * new_ps); + memset(ports_cfg + old_nb_ports, 0, + sizeof(ports_cfg[0]) * new_ps); for (i = old_links_map_end; i < links_map_end; i++) links_map[i] = EVENT_QUEUE_SERVICE_PRIORITY_INVALID; } dev->data->ports = ports; - dev->data->ports_dequeue_depth = ports_dequeue_depth; - dev->data->ports_enqueue_depth = ports_enqueue_depth; + dev->data->ports_cfg = ports_cfg; dev->data->links_map = links_map; } else if (dev->data->ports != NULL && nb_ports == 0) { RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->port_release, -ENOTSUP); @@ -709,10 +682,7 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, port_conf = &def_conf; } - dev->data->ports_dequeue_depth[port_id] = - port_conf->dequeue_depth; - dev->data->ports_enqueue_depth[port_id] = - port_conf->enqueue_depth; + dev->data->ports_cfg[port_id] = *port_conf; diag = (*dev->dev_ops->port_setup)(dev, port_id, port_conf); @@ -772,10 +742,13 @@ rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, switch (attr_id) { case RTE_EVENT_PORT_ATTR_ENQ_DEPTH: - *attr_value = dev->data->ports_enqueue_depth[port_id]; + *attr_value = dev->data->ports_cfg[port_id].enqueue_depth; break; case RTE_EVENT_PORT_ATTR_DEQ_DEPTH: - *attr_value = dev->data->ports_dequeue_depth[port_id]; + *attr_value = dev->data->ports_cfg[port_id].dequeue_depth; + break; + case RTE_EVENT_PORT_ATTR_NEW_EVENT_THRESHOLD: + *attr_value = dev->data->ports_cfg[port_id].new_event_threshold; break; default: return -EINVAL; diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h index 8ad06dd..ca858cc 100644 --- a/lib/librte_eventdev/rte_eventdev.h +++ b/lib/librte_eventdev/rte_eventdev.h @@ -759,6 +759,10 @@ rte_event_port_setup(uint8_t dev_id, uint8_t port_id, * The queue depth of the port on the dequeue side */ #define RTE_EVENT_PORT_ATTR_DEQ_DEPTH 1 +/** + * The new event threshold of the port + */ +#define RTE_EVENT_PORT_ATTR_NEW_EVENT_THRESHOLD 2 /** * Get an attribute from a port. @@ -1059,10 +1063,8 @@ struct rte_eventdev_data { /**< Number of event ports. */ void **ports; /**< Array of pointers to ports. */ - uint8_t *ports_dequeue_depth; - /**< Array of port dequeue depth. */ - uint8_t *ports_enqueue_depth; - /**< Array of port enqueue depth. */ + struct rte_event_port_conf *ports_cfg; + /**< Array of port configuration structures. */ struct rte_event_queue_conf *queues_cfg; /**< Array of queue configuration structures. */ uint16_t *links_map; diff --git a/test/test/test_eventdev.c b/test/test/test_eventdev.c index 1d9e9fe..5fd0357 100644 --- a/test/test/test_eventdev.c +++ b/test/test/test_eventdev.c @@ -606,7 +606,7 @@ test_eventdev_port_setup(void) } static int -test_eventdev_dequeue_depth(void) +test_eventdev_port_attr_dequeue_depth(void) { int ret; struct rte_event_dev_info info; @@ -623,7 +623,7 @@ test_eventdev_dequeue_depth(void) uint32_t value; TEST_ASSERT_EQUAL(rte_event_port_attr_get(TEST_DEV_ID, 0, RTE_EVENT_PORT_ATTR_DEQ_DEPTH, &value), - 0, "Call to port dequeue depth failed"); + 0, "Call to get port dequeue depth failed"); TEST_ASSERT_EQUAL(value, pconf.dequeue_depth, "Wrong port dequeue depth"); @@ -631,7 +631,7 @@ test_eventdev_dequeue_depth(void) } static int -test_eventdev_enqueue_depth(void) +test_eventdev_port_attr_enqueue_depth(void) { int ret; struct rte_event_dev_info info; @@ -648,7 +648,7 @@ test_eventdev_enqueue_depth(void) uint32_t value; TEST_ASSERT_EQUAL(rte_event_port_attr_get(TEST_DEV_ID, 0, RTE_EVENT_PORT_ATTR_ENQ_DEPTH, &value), - 0, "Call to port enqueue depth failed"); + 0, "Call to get port enqueue depth failed"); TEST_ASSERT_EQUAL(value, pconf.dequeue_depth, "Wrong port enqueue depth"); @@ -656,6 +656,31 @@ test_eventdev_enqueue_depth(void) } static int +test_eventdev_port_attr_new_event_threshold(void) +{ + int ret; + struct rte_event_dev_info info; + struct rte_event_port_conf pconf; + + ret = rte_event_dev_info_get(TEST_DEV_ID, &info); + TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info"); + + ret = rte_event_port_default_conf_get(TEST_DEV_ID, 0, &pconf); + TEST_ASSERT_SUCCESS(ret, "Failed to get port0 info"); + ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf); + TEST_ASSERT_SUCCESS(ret, "Failed to setup port0"); + + uint32_t value; + TEST_ASSERT_EQUAL(rte_event_port_attr_get(TEST_DEV_ID, 0, + RTE_EVENT_PORT_ATTR_NEW_EVENT_THRESHOLD, &value), + 0, "Call to get port new event threshold failed"); + TEST_ASSERT_EQUAL((int32_t) value, pconf.new_event_threshold, + "Wrong port new event threshold"); + + return TEST_SUCCESS; +} + +static int test_eventdev_port_count(void) { int ret; @@ -953,9 +978,11 @@ static struct unit_test_suite eventdev_common_testsuite = { TEST_CASE_ST(eventdev_configure_setup, NULL, test_eventdev_port_setup), TEST_CASE_ST(eventdev_configure_setup, NULL, - test_eventdev_dequeue_depth), + test_eventdev_port_attr_dequeue_depth), + TEST_CASE_ST(eventdev_configure_setup, NULL, + test_eventdev_port_attr_enqueue_depth), TEST_CASE_ST(eventdev_configure_setup, NULL, - test_eventdev_enqueue_depth), + test_eventdev_port_attr_new_event_threshold), TEST_CASE_ST(eventdev_configure_setup, NULL, test_eventdev_port_count), TEST_CASE_ST(eventdev_configure_setup, NULL, -- 2.7.4