From: Anatoly Burakov Date: Fri, 20 Jun 2014 15:42:18 +0000 (+0100) Subject: tailq: change rte_dummy to rte_tailq_entry X-Git-Tag: spdx-start~10488 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=2db1d35feaf0a2829709a3d57b9204880dedf357;p=dpdk.git tailq: change rte_dummy to rte_tailq_entry Rename structure and add a data pointer. Signed-off-by: Anatoly Burakov Acked-by: Konstantin Ananyev --- diff --git a/app/test/test_tailq.c b/app/test/test_tailq.c index 67da009d5e..c9b53eee27 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 f294a58358..db9a185098 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 d084d9a02d..b34e5ede95 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 */ }; /**