DPDK patches and discussions
 help / color / mirror / Atom feed
* [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; 37+ 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] 37+ messages in thread
* [dpdk-dev] [PATCH v4 0/5] Add a PA-VA Translation table for DPAAx
@ 2018-10-15  6:41 Shreyansh Jain
  2018-10-15 12:01 ` [dpdk-dev] [PATCH v5 0/5] Shreyansh Jain
  0 siblings, 1 reply; 37+ messages in thread
From: Shreyansh Jain @ 2018-10-15  6:41 UTC (permalink / raw)
  To: ferruh.yigit, thomas; +Cc: anatoly.burakov, pbhagavatula, dev, Shreyansh Jain

::Background::
After the restructuring of memory in last release(s), one of the
major impact on fslmc/dpaa bus (and its devices) was the performance
drop when using physical addressing.

Previously, it was assumed that physical range was contiguous for
any given request for hugepage memory. That way, whenever a
virtual address was returned, it was easy to fetch physical
equivalent, in almost constant time.
But, with memory hotplug series, that assumption was negated.
Every call that device drivers made for rte_mem_virt2iova or
rte_mem_virt2phy were expensive. (Using IOVA_CONTIG is an app
dependency which is not a practical option).

For fslmc, working on Physical or Virtual (IOMMU supported) address
is an optional thing. For dpaa bus, it is not optional and only
physical addressing is supported. Thus, it impacted dpaa bus
the most.

::DPAAX PA-VA Table::
- A simple table containing entries for all physical memory range
  available on a particular SoC (in this case, NXP's LS104x and
  LS20xx series, which are handled by dpaa and fslmc bus,
  respectively). As of now, this is SoC dependent for fetching
  range.
- We populate the table either through the mempool handler (for
  mempool pinned memory) or through the memory event callbacks
  (for cases where working memory is allocated by application).
- Though aim is only to translate addresses for descriptors
  which are Rx'd from devices, this is a generic layer which
  should work in other cases as well (though, not the target of
  current testing).

::About patches::
Patch 1: There was an issue in existing PA/VA mode reporting being
         done by fslmc bus. This patch fixes it.
Patch 2: Common libraries/commponents can be dependency for the bus
         thus, blocking parallel compilation
Patch 3: Add the library in common/dpaax. This is a single patch
         as functions are mostly inter-linked.
Patch 4~5: Add support in dpaa and fslmc bus, respectively.
         It is not possible to unlink the bus and device drivers,
         thus, these patches have blanket change across all drivers.

::Next Steps::
- Some optimization are required to tune the access pattern of the
  table. These would be posted as additional patches.
- In case there is any possible split of patches, I will post another
  version. But until then, this is the layout.

::Version History::
v3->v4:
 - Fixed missing rework against review comment from Pavan: shift the
   IOVA mode detection code in bus/fslmc
 - Rebased over master (abe92131c92)

v2->v3:
 - Added back del operation (update) for mem-events, which was removed
   in v2
 - Change IOMMU(PA) detection for FSLMC Bus (review comment: Pavan)
 - Rebase on master (6673fe0ce2)

v1->v2:
 - Rework of review comments on v1
 - Removed dpaax_iova_table_del API - that is redundant
 - Changed paax_iova_table_add to paax_iova_table_update to make
   it more relevant
 - Previous patch removed an advertised API (rte_dpaa2_memsegs). This is
   fixed. A deprecation notice would now be sent for removal in next
   release.
 - Rebase on master (5f73c2670f); Also verified on net-next/mater (317f8b01f)

Shreyansh Jain (5):
  bus/fslmc: fix physical addressing check
  drivers: common as dependency for bus
  common/dpaax: add library for PA VA translation table
  dpaa: enable dpaax library
  fslmc: enable dpaax library

 config/common_base                            |   5 +
 config/common_linuxapp                        |   5 +
 drivers/Makefile                              |   1 +
 drivers/bus/dpaa/Makefile                     |   1 +
 drivers/bus/dpaa/dpaa_bus.c                   |   4 +
 drivers/bus/dpaa/meson.build                  |   2 +-
 drivers/bus/dpaa/rte_dpaa_bus.h               |   6 +
 drivers/bus/fslmc/Makefile                    |   1 +
 drivers/bus/fslmc/fslmc_bus.c                 |  24 +
 drivers/bus/fslmc/meson.build                 |   2 +-
 drivers/bus/fslmc/portal/dpaa2_hw_pvt.h       |  21 +-
 drivers/common/Makefile                       |   4 +
 drivers/common/dpaax/Makefile                 |  31 ++
 drivers/common/dpaax/dpaax_iova_table.c       | 461 ++++++++++++++++++
 drivers/common/dpaax/dpaax_iova_table.h       | 103 ++++
 drivers/common/dpaax/dpaax_logs.h             |  39 ++
 drivers/common/dpaax/meson.build              |  12 +
 .../common/dpaax/rte_common_dpaax_version.map |  11 +
 drivers/common/meson.build                    |   2 +-
 drivers/crypto/dpaa2_sec/Makefile             |   1 +
 drivers/crypto/dpaa_sec/Makefile              |   1 +
 drivers/crypto/dpaa_sec/dpaa_sec.c            |   6 +
 drivers/event/dpaa/Makefile                   |   1 +
 drivers/event/dpaa2/Makefile                  |   1 +
 drivers/mempool/dpaa/Makefile                 |   1 +
 drivers/mempool/dpaa/dpaa_mempool.c           |   4 +
 drivers/mempool/dpaa/dpaa_mempool.h           |   4 +-
 drivers/mempool/dpaa2/Makefile                |   1 +
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c      |  29 +-
 drivers/net/dpaa/Makefile                     |   1 +
 drivers/net/dpaa2/Makefile                    |   1 +
 drivers/raw/dpaa2_cmdif/Makefile              |   1 +
 drivers/raw/dpaa2_qdma/Makefile               |   1 +
 mk/rte.app.mk                                 |   2 +
 34 files changed, 748 insertions(+), 42 deletions(-)
 create mode 100644 drivers/common/dpaax/Makefile
 create mode 100644 drivers/common/dpaax/dpaax_iova_table.c
 create mode 100644 drivers/common/dpaax/dpaax_iova_table.h
 create mode 100644 drivers/common/dpaax/dpaax_logs.h
 create mode 100644 drivers/common/dpaax/meson.build
 create mode 100644 drivers/common/dpaax/rte_common_dpaax_version.map

-- 
2.17.1

^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2018-10-16 10:18 UTC | newest]

Thread overview: 37+ 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
2018-10-15  6:41 [dpdk-dev] [PATCH v4 0/5] Add a PA-VA Translation table for DPAAx Shreyansh Jain
2018-10-15 12:01 ` [dpdk-dev] [PATCH v5 0/5] Shreyansh Jain
2018-10-16 10:18   ` Thomas Monjalon

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).