From: Gage Eads Date: Wed, 20 Sep 2017 15:21:02 +0000 (-0500) Subject: eventdev: extend port attribute get function X-Git-Tag: spdx-start~1622 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=be1bf6077ec9580e460d5558b56008845f1195b2;p=dpdk.git eventdev: extend port attribute get function 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 --- diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c index 06c184c09b..e6ed0a32df 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 8ad06dd674..ca858cce32 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 1a6d6a5e00..d6ade78efb 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,13 +648,38 @@ 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.enqueue_depth, "Wrong port enqueue depth"); return TEST_SUCCESS; } +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) { @@ -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,