tailq: change rte_dummy to rte_tailq_entry
authorAnatoly Burakov <anatoly.burakov@intel.com>
Fri, 20 Jun 2014 15:42:18 +0000 (16:42 +0100)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 22 Jul 2014 17:15:01 +0000 (19:15 +0200)
Rename structure and add a data pointer.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
app/test/test_tailq.c
lib/librte_eal/common/eal_common_tailqs.c
lib/librte_eal/common/include/rte_tailq.h

index 67da009..c9b53ee 100644 (file)
 
 #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");
 
index f294a58..db9a185 100644 (file)
@@ -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"),
index d084d9a..b34e5ed 100644 (file)
@@ -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 */
 };
 
 /**