From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 04184AF85 for ; Fri, 20 Jun 2014 17:42:11 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 20 Jun 2014 08:37:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,514,1400050800"; d="scan'208";a="560767131" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 20 Jun 2014 08:42:27 -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 s5KFgQj7024701; Fri, 20 Jun 2014 16:42:26 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id s5KFgQT8003208; Fri, 20 Jun 2014 16:42:26 +0100 Received: (from aburakov@localhost) by sivswdev01.ir.intel.com with id s5KFgQLG003204; Fri, 20 Jun 2014 16:42:26 +0100 From: Anatoly Burakov To: dev@dpdk.org Date: Fri, 20 Jun 2014 16:42:18 +0100 Message-Id: <09ca393b5c395ef9db43a8284b6fe9a82eba33e6.1403277437.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH 03/10] 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jun 2014 15:42:12 -0000 Signed-off-by: Anatoly Burakov --- 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 /** 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