From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <aburakov@ecsmtp.ir.intel.com>
Received: from mga01.intel.com (mga01.intel.com [192.55.52.88])
 by dpdk.org (Postfix) with ESMTP id 299DBAFE1
 for <dev@dpdk.org>; Tue, 17 Jun 2014 17:36:07 +0200 (CEST)
Received: from fmsmga002.fm.intel.com ([10.253.24.26])
 by fmsmga101.fm.intel.com with ESMTP; 17 Jun 2014 08:36:09 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.01,494,1400050800"; d="scan'208";a="556851896"
Received: from irvmail001.ir.intel.com ([163.33.26.43])
 by fmsmga002.fm.intel.com with ESMTP; 17 Jun 2014 08:36:08 -0700
Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com
 [10.237.217.45])
 by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id
 s5HFa7rM019315; Tue, 17 Jun 2014 16:36:07 +0100
Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1])
 by sivswdev01.ir.intel.com with ESMTP id s5HFa7pK031832;
 Tue, 17 Jun 2014 16:36:07 +0100
Received: (from aburakov@localhost)
 by sivswdev01.ir.intel.com with  id s5HFa7AR031828;
 Tue, 17 Jun 2014 16:36:07 +0100
From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Date: Tue, 17 Jun 2014 16:36:00 +0100
Message-Id: <d4b40a47d61c37a6390df0173ce35661fdbb0af6.1403018971.git.anatoly.burakov@intel.com>
X-Mailer: git-send-email 1.7.0.7
In-Reply-To: <cover.1402672392.git.anatoly.burakov@intel.com>
References: <cover.1402672392.git.anatoly.burakov@intel.com>
In-Reply-To: <cover.1403018971.git.anatoly.burakov@intel.com>
References: <cover.1403018971.git.anatoly.burakov@intel.com>
Subject: [dpdk-dev] [PATCH 2/9] rte_tailq: change rte_dummy to
	rte_tailq_entry, add data pointer
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Tue, 17 Jun 2014 15:36:09 -0000


Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 app/test/test_tailq.c                     | 33 ++++++++++++++++---------------
 lib/librte_eal/common/eal_common_tailqs.c |  2 +-
 lib/librte_eal/common/include/rte_tailq.h |  9 +++++----
 3 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/app/test/test_tailq.c b/app/test/test_tailq.c
index 67da009..c9b53ee 100644
--- a/app/test/test_tailq.c
+++ b/app/test/test_tailq.c
@@ -52,16 +52,16 @@
 
 #define DEFAULT_TAILQ (RTE_TAILQ_NUM)
 
-static struct rte_dummy d_elem;
+static struct rte_tailq_entry d_elem;
 
 static int
 test_tailq_create(void)
 {
-	struct rte_dummy_head *d_head;
+	struct rte_tailq_entry_head *d_head;
 	unsigned i;
 
 	/* create a first tailq and check its non-null */
-	d_head = RTE_TAILQ_RESERVE_BY_IDX(DEFAULT_TAILQ, rte_dummy_head);
+	d_head = RTE_TAILQ_RESERVE_BY_IDX(DEFAULT_TAILQ, rte_tailq_entry_head);
 	if (d_head == NULL)
 		do_return("Error allocating dummy_q0\n");
 
@@ -70,13 +70,14 @@ 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_dummy_head) == NULL)
+	if (RTE_TAILQ_RESERVE_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, rte_dummy_head)) == NULL)
+		if ((d_head = RTE_TAILQ_RESERVE_BY_IDX(i,
+				rte_tailq_entry_head)) == NULL)
 			break;
 	}
 
@@ -91,10 +92,10 @@ static int
 test_tailq_lookup(void)
 {
 	/* run successful  test - check result is found */
-	struct rte_dummy_head *d_head;
-	struct rte_dummy *d_ptr;
+	struct rte_tailq_entry_head *d_head;
+	struct rte_tailq_entry *d_ptr;
 
-	d_head = RTE_TAILQ_LOOKUP_BY_IDX(DEFAULT_TAILQ, rte_dummy_head);
+	d_head = RTE_TAILQ_LOOKUP_BY_IDX(DEFAULT_TAILQ, rte_tailq_entry_head);
 	if (d_head == NULL)
 		do_return("Error with tailq lookup\n");
 
@@ -104,7 +105,7 @@ test_tailq_lookup(void)
 					"expected element not found\n");
 
 	/* now try a bad/error lookup */
-	d_head = RTE_TAILQ_LOOKUP_BY_IDX(RTE_MAX_TAILQ, rte_dummy_head);
+	d_head = RTE_TAILQ_LOOKUP_BY_IDX(RTE_MAX_TAILQ, rte_tailq_entry_head);
 	if (d_head != NULL)
 		do_return("Error, lookup does not return NULL for bad tailq name\n");
 
@@ -115,7 +116,7 @@ test_tailq_lookup(void)
 static int
 test_tailq_deprecated(void)
 {
-	struct rte_dummy_head *d_head;
+	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
@@ -123,29 +124,29 @@ test_tailq_deprecated(void)
 	 *
 	 * PCI_RESOURCE_LIST tailq is guaranteed to
 	 * be present in any DPDK app. */
-	d_head = RTE_TAILQ_RESERVE("PCI_RESOURCE_LIST", rte_dummy_head);
+	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_dummy_head);
+	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_dummy_head);
+	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_dummy_head);
+	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_dummy_head);
+	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_dummy_head);
+	d_head = RTE_TAILQ_LOOKUP(NULL, rte_tailq_entry_head);
 	if (d_head != NULL)
 		do_return("NULL tailq found!\n");
 
diff --git a/lib/librte_eal/common/eal_common_tailqs.c b/lib/librte_eal/common/eal_common_tailqs.c
index f294a58..db9a185 100644
--- a/lib/librte_eal/common/eal_common_tailqs.c
+++ b/lib/librte_eal/common/eal_common_tailqs.c
@@ -118,7 +118,7 @@ rte_dump_tailq(FILE *f)
 	rte_rwlock_read_lock(&mcfg->qlock);
 	for (i=0; i < RTE_MAX_TAILQ; i++) {
 		const struct rte_tailq_head *tailq = &mcfg->tailq_head[i];
-		const struct rte_dummy_head *head = &tailq->tailq_head;
+		const struct rte_tailq_entry_head *head = &tailq->tailq_head;
 
 		fprintf(f, "Tailq %u: qname:<%s>, tqh_first:%p, tqh_last:%p\n", i,
 		       (rte_tailq_names[i] != NULL ? rte_tailq_names[i]:"nil"),
diff --git a/lib/librte_eal/common/include/rte_tailq.h b/lib/librte_eal/common/include/rte_tailq.h
index d084d9a..b34e5ed 100644
--- a/lib/librte_eal/common/include/rte_tailq.h
+++ b/lib/librte_eal/common/include/rte_tailq.h
@@ -48,11 +48,12 @@ extern "C" {
 #include <stdio.h>
 
 /** dummy structure type used by the rte_tailq APIs */
-struct rte_dummy {
-	TAILQ_ENTRY(rte_dummy) next; /**< Pointer entries for a tailq list */
+struct rte_tailq_entry {
+	TAILQ_ENTRY(rte_tailq_entry) next; /**< Pointer entries for a tailq list */
+	void *data; /**< Pointer to the data referenced by this tailq entry */
 };
 /** dummy */
-TAILQ_HEAD(rte_dummy_head, rte_dummy);
+TAILQ_HEAD(rte_tailq_entry_head, rte_tailq_entry);
 
 #define RTE_TAILQ_NAMESIZE 32
 
@@ -65,7 +66,7 @@ TAILQ_HEAD(rte_dummy_head, rte_dummy);
  * a multi-process app to find already-created elements in shared memory.
  */
 struct rte_tailq_head {
-	struct rte_dummy_head tailq_head; /**< NOTE: must be first element */
+	struct rte_tailq_entry_head tailq_head; /**< NOTE: must be first element */
 };
 
 /**
-- 
1.8.1.4