DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@6wind.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 05/10] tailq: get rid of broken "reserve" api
Date: Wed,  4 Mar 2015 22:50:05 +0100	[thread overview]
Message-ID: <1425505810-9269-6-git-send-email-david.marchand@6wind.com> (raw)
In-Reply-To: <1425505810-9269-1-git-send-email-david.marchand@6wind.com>

The "reserve" macros and functions do not check if the requested entry is free.
They do nothing more than the lookup function (which itself "creates" entries
...).
The rte_tailq api is marked as "internal use" in documentation and these macros
are only used in test application, so just get rid of them.

Signed-off-by: David Marchand <david.marchand@6wind.com>
---
 app/test/test_tailq.c                           |   48 +--------------
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |    2 -
 lib/librte_eal/common/eal_common_tailqs.c       |   12 ----
 lib/librte_eal/common/include/rte_tailq.h       |   75 ++---------------------
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |    2 -
 5 files changed, 9 insertions(+), 130 deletions(-)

diff --git a/app/test/test_tailq.c b/app/test/test_tailq.c
index b0f9a78..56656f0 100644
--- a/app/test/test_tailq.c
+++ b/app/test/test_tailq.c
@@ -60,7 +60,7 @@ test_tailq_create(void)
 	unsigned i;
 
 	/* create a first tailq and check its non-null */
-	d_head = RTE_TAILQ_RESERVE_BY_IDX(DEFAULT_TAILQ, rte_tailq_entry_head);
+	d_head = RTE_TAILQ_LOOKUP_BY_IDX(DEFAULT_TAILQ, rte_tailq_entry_head);
 	if (d_head == NULL)
 		do_return("Error allocating dummy_q0\n");
 
@@ -69,13 +69,13 @@ test_tailq_create(void)
 	TAILQ_INSERT_TAIL(d_head, &d_elem, next);
 
 	/* try allocating dummy_q0 again, and check for failure */
-	if (RTE_TAILQ_RESERVE_BY_IDX(DEFAULT_TAILQ, rte_tailq_entry_head) == NULL)
+	if (RTE_TAILQ_LOOKUP_BY_IDX(DEFAULT_TAILQ, rte_tailq_entry_head) == NULL)
 		do_return("Error, non-null result returned when attemption to "
 				"re-allocate a tailq\n");
 
 	/* now fill up the tailq slots available and check we get an error */
 	for (i = RTE_TAILQ_NUM; i < RTE_MAX_TAILQ; i++){
-		if ((d_head = RTE_TAILQ_RESERVE_BY_IDX(i,
+		if ((d_head = RTE_TAILQ_LOOKUP_BY_IDX(i,
 				rte_tailq_entry_head)) == NULL)
 			break;
 	}
@@ -111,54 +111,12 @@ test_tailq_lookup(void)
 	return 0;
 }
 
-/* test for deprecated functions - mainly for coverage */
-static int
-test_tailq_deprecated(void)
-{
-	struct rte_tailq_entry_head *d_head;
-
-	/* since TAILQ_RESERVE is not able to create new tailqs,
-	 * we should find an existing one (IOW, RTE_TAILQ_RESERVE behaves identical
-	 * to RTE_TAILQ_LOOKUP).
-	 *
-	 * PCI_RESOURCE_LIST tailq is guaranteed to
-	 * be present in any DPDK app. */
-	d_head = RTE_TAILQ_RESERVE("PCI_RESOURCE_LIST", rte_tailq_entry_head);
-	if (d_head == NULL)
-		do_return("Error finding PCI_RESOURCE_LIST\n");
-
-	d_head = RTE_TAILQ_LOOKUP("PCI_RESOURCE_LIST", rte_tailq_entry_head);
-	if (d_head == NULL)
-		do_return("Error finding PCI_RESOURCE_LIST\n");
-
-	/* try doing that with non-existent names */
-	d_head = RTE_TAILQ_RESERVE("random name", rte_tailq_entry_head);
-	if (d_head != NULL)
-		do_return("Non-existent tailq found!\n");
-
-	d_head = RTE_TAILQ_LOOKUP("random name", rte_tailq_entry_head);
-	if (d_head != NULL)
-		do_return("Non-existent tailq found!\n");
-
-	/* try doing the same with NULL names */
-	d_head = RTE_TAILQ_RESERVE(NULL, rte_tailq_entry_head);
-	if (d_head != NULL)
-		do_return("NULL tailq found!\n");
-
-	d_head = RTE_TAILQ_LOOKUP(NULL, rte_tailq_entry_head);
-	if (d_head != NULL)
-		do_return("NULL tailq found!\n");
-
-	return 0;
-}
-
 static int
 test_tailq(void)
 {
 	int ret = 0;
 	ret |= test_tailq_create();
 	ret |= test_tailq_lookup();
-	ret |= test_tailq_deprecated();
 	return ret;
 }
 
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index d83524d..c94fe8e 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -45,8 +45,6 @@ DPDK_2.0 {
 	rte_eal_remote_launch;
 	rte_eal_tailq_lookup;
 	rte_eal_tailq_lookup_by_idx;
-	rte_eal_tailq_reserve;
-	rte_eal_tailq_reserve_by_idx;
 	rte_eal_wait_lcore;
 	rte_exit;
 	rte_get_hpet_cycles;
diff --git a/lib/librte_eal/common/eal_common_tailqs.c b/lib/librte_eal/common/eal_common_tailqs.c
index a61e3f3..975ee74 100644
--- a/lib/librte_eal/common/eal_common_tailqs.c
+++ b/lib/librte_eal/common/eal_common_tailqs.c
@@ -94,18 +94,6 @@ rte_eal_tailq_lookup_by_idx(const unsigned tailq_idx)
 	return &mcfg->tailq_head[tailq_idx];
 }
 
-struct rte_tailq_head *
-rte_eal_tailq_reserve(const char *name)
-{
-	return rte_eal_tailq_lookup(name);
-}
-
-inline struct rte_tailq_head *
-rte_eal_tailq_reserve_by_idx(const unsigned tailq_idx)
-{
-	return rte_eal_tailq_lookup_by_idx(tailq_idx);
-}
-
 void
 rte_dump_tailq(FILE *f)
 {
diff --git a/lib/librte_eal/common/include/rte_tailq.h b/lib/librte_eal/common/include/rte_tailq.h
index 6ac4b9b..6b7278c 100644
--- a/lib/librte_eal/common/include/rte_tailq.h
+++ b/lib/librte_eal/common/include/rte_tailq.h
@@ -76,45 +76,6 @@ struct rte_tailq_head {
 	(struct struct_name *)&(tailq_entry)->tailq_head
 
 /**
- * Utility macro to make reserving a tailqueue for a particular struct easier.
- *
- * @param name
- *   The name to be given to the tailq - used by lookup to find it later
- *
- * @param struct_name
- *   The name of the list type we are using. (Generally this is the same as the
- *   first parameter passed to TAILQ_HEAD macro)
- *
- * @return
- *   The return value from rte_eal_tailq_reserve, typecast to the appropriate
- *   structure pointer type.
- *   NULL on error, since the tailq_head is the first
- *   element in the rte_tailq_head structure.
- */
-#define RTE_TAILQ_RESERVE(name, struct_name) \
-	RTE_TAILQ_CAST(rte_eal_tailq_reserve(name), struct_name)
-
-/**
- * Utility macro to make reserving a tailqueue for a particular struct easier.
- *
- * @param idx
- *   The tailq idx defined in rte_tail_t to be given to the tail queue.
- *       - used by lookup to find it later
- *
- * @param struct_name
- *   The name of the list type we are using. (Generally this is the same as the
- *   first parameter passed to TAILQ_HEAD macro)
- *
- * @return
- *   The return value from rte_eal_tailq_reserve, typecast to the appropriate
- *   structure pointer type.
- *   NULL on error, since the tailq_head is the first
- *   element in the rte_tailq_head structure.
- */
-#define RTE_TAILQ_RESERVE_BY_IDX(idx, struct_name) \
-	RTE_TAILQ_CAST(rte_eal_tailq_reserve_by_idx(idx), struct_name)
-
-/**
  * Utility macro to make looking up a tailqueue for a particular struct easier.
  *
  * @param name
@@ -153,30 +114,6 @@ struct rte_tailq_head {
 	RTE_TAILQ_CAST(rte_eal_tailq_lookup_by_idx(idx), struct_name)
 
 /**
- * Reserve a slot in the tailq list for a particular tailq header
- * Note: this function, along with rte_tailq_lookup, is not multi-thread safe,
- * and both these functions should only be called from a single thread at a time
- *
- * @param name
- *   The name to be given to the tail queue.
- * @return
- *   A pointer to the newly reserved tailq entry
- */
-struct rte_tailq_head *rte_eal_tailq_reserve(const char *name);
-
-/**
- * Reserve a slot in the tailq list for a particular tailq header
- * Note: this function, along with rte_tailq_lookup, is not multi-thread safe,
- * and both these functions should only be called from a single thread at a time
- *
- * @param idx
- *   The tailq idx defined in rte_tail_t to be given to the tail queue.
- * @return
- *   A pointer to the newly reserved tailq entry
- */
-struct rte_tailq_head *rte_eal_tailq_reserve_by_idx(const unsigned idx);
-
-/**
  * Dump tail queues to the console.
  *
  * @param f
@@ -187,10 +124,10 @@ void rte_dump_tailq(FILE *f);
 /**
  * Lookup for a tail queue.
  *
- * Get a pointer to a tail queue header of an already reserved tail
+ * Get a pointer to a tail queue header of a tail
  * queue identified by the name given as an argument.
- * Note: this function, along with rte_tailq_reserve, is not multi-thread safe,
- * and both these functions should only be called from a single thread at a time
+ * Note: this function is not multi-thread safe, and should only be called from
+ * a single thread at a time
  *
  * @param name
  *   The name of the queue.
@@ -202,10 +139,10 @@ struct rte_tailq_head *rte_eal_tailq_lookup(const char *name);
 /**
  * Lookup for a tail queue.
  *
- * Get a pointer to a tail queue header of an already reserved tail
+ * Get a pointer to a tail queue header of a tail
  * queue identified by the name given as an argument.
- * Note: this function, along with rte_tailq_reserve, is not multi-thread safe,
- * and both these functions should only be called from a single thread at a time
+ * Note: this function is not multi-thread safe, and should only be called from
+ * a single thread at a time
  *
  * @param idx
  *   The tailq idx defined in rte_tail_t to be given to the tail queue.
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index 54f5ff1..a1ba203 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -49,8 +49,6 @@ DPDK_2.0 {
 	rte_eal_remote_launch;
 	rte_eal_tailq_lookup;
 	rte_eal_tailq_lookup_by_idx;
-	rte_eal_tailq_reserve;
-	rte_eal_tailq_reserve_by_idx;
 	rte_eal_vdev_init;
 	rte_eal_vdev_uninit;
 	rte_eal_wait_lcore;
-- 
1.7.10.4

  parent reply	other threads:[~2015-03-04 21:50 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-04 21:50 [dpdk-dev] [PATCH 00/10] eal: rte_tailq api cleanup David Marchand
2015-03-04 21:50 ` [dpdk-dev] [PATCH 01/10] eal: remove yet another remaining reference to pm David Marchand
2015-03-04 21:50 ` [dpdk-dev] [PATCH 02/10] pci: use lookup tailq api David Marchand
2015-03-04 21:50 ` [dpdk-dev] [PATCH 03/10] tailq: remove unneeded inclusion of rte_tailq.h David Marchand
2015-03-04 21:50 ` [dpdk-dev] [PATCH 04/10] tailq: use a single cast macro David Marchand
2015-03-04 21:50 ` David Marchand [this message]
2015-03-04 21:50 ` [dpdk-dev] [PATCH 06/10] tailq: remove unused RTE_EAL_TAILQ_* macros David Marchand
2015-03-04 21:50 ` [dpdk-dev] [PATCH 07/10] tailq: introduce dynamic register system David Marchand
2015-03-04 21:50 ` [dpdk-dev] [PATCH 08/10] tailq: move to dynamic tailq David Marchand
2015-03-04 21:50 ` [dpdk-dev] [PATCH 09/10] tailq: remove static slots David Marchand
2015-03-04 21:50 ` [dpdk-dev] [PATCH 10/10] eal: no need for E_RTE_NO_TAILQ anymore David Marchand
2015-03-04 22:55 ` [dpdk-dev] [PATCH 00/10] eal: rte_tailq api cleanup Thomas Monjalon
2015-03-06  0:26 ` Neil Horman
2015-03-10 11:20   ` Thomas Monjalon
2015-03-11  7:44     ` Tetsuya Mukawa
2015-03-11  8:47       ` David Marchand
2015-03-11 17:28         ` David Marchand
2015-03-11 20:24           ` Mcnamara, John
2015-03-11 21:29             ` David Marchand
2015-03-11 22:25               ` Mcnamara, John
2015-03-12  2:05                 ` Tetsuya Mukawa
2015-03-12  2:12                   ` Tetsuya Mukawa
2015-03-12  5:44                   ` David Marchand
2015-03-12  8:38                     ` Liu, Yong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1425505810-9269-6-git-send-email-david.marchand@6wind.com \
    --to=david.marchand@6wind.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).