From: David Marchand <david.marchand@6wind.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 08/10] tailq: move to dynamic tailq
Date: Wed, 4 Mar 2015 22:50:08 +0100 [thread overview]
Message-ID: <1425505810-9269-9-git-send-email-david.marchand@6wind.com> (raw)
In-Reply-To: <1425505810-9269-1-git-send-email-david.marchand@6wind.com>
Use dynamic tailq rather than static entries.
Signed-off-by: David Marchand <david.marchand@6wind.com>
---
lib/librte_acl/rte_acl.c | 33 +++++++----------------
lib/librte_acl/rte_acl.h | 1 -
lib/librte_distributor/rte_distributor.c | 16 +++++------
lib/librte_eal/bsdapp/eal/eal_pci.c | 7 ++++-
lib/librte_eal/common/include/rte_tailq_elem.h | 20 --------------
lib/librte_eal/linuxapp/eal/eal_ivshmem.c | 5 ++--
lib/librte_eal/linuxapp/eal/eal_pci.c | 8 ++++--
lib/librte_hash/rte_fbk_hash.c | 32 ++++++++--------------
lib/librte_hash/rte_fbk_hash.h | 1 -
lib/librte_hash/rte_hash.c | 27 ++++++-------------
lib/librte_hash/rte_hash.h | 1 -
lib/librte_lpm/rte_lpm.c | 34 +++++++++---------------
lib/librte_lpm/rte_lpm.h | 1 -
lib/librte_lpm/rte_lpm6.c | 26 ++++++------------
lib/librte_lpm/rte_lpm6.h | 1 -
lib/librte_mempool/rte_mempool.c | 32 +++++++---------------
lib/librte_mempool/rte_mempool.h | 3 ---
lib/librte_reorder/rte_reorder.c | 26 ++++++------------
lib/librte_reorder/rte_reorder.h | 1 -
lib/librte_ring/rte_ring.c | 27 +++++++------------
lib/librte_ring/rte_ring.h | 3 ++-
21 files changed, 99 insertions(+), 206 deletions(-)
diff --git a/lib/librte_acl/rte_acl.c b/lib/librte_acl/rte_acl.c
index 7d10301..b6ddeeb 100644
--- a/lib/librte_acl/rte_acl.c
+++ b/lib/librte_acl/rte_acl.c
@@ -38,6 +38,11 @@
TAILQ_HEAD(rte_acl_list, rte_tailq_entry);
+static struct rte_tailq_elem rte_acl_tailq = {
+ .name = "RTE_ACL",
+};
+EAL_REGISTER_TAILQ(rte_acl_tailq)
+
/*
* If the compiler doesn't support AVX2 instructions,
* then the dummy one would be used instead for AVX2 classify method.
@@ -129,12 +134,7 @@ rte_acl_find_existing(const char *name)
struct rte_acl_list *acl_list;
struct rte_tailq_entry *te;
- /* check that we have an initialised tail queue */
- acl_list = RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_ACL, rte_acl_list);
- if (acl_list == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return NULL;
- }
+ acl_list = RTE_TAILQ_CAST(rte_acl_tailq.head, rte_acl_list);
rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
TAILQ_FOREACH(te, acl_list, next) {
@@ -160,12 +160,7 @@ rte_acl_free(struct rte_acl_ctx *ctx)
if (ctx == NULL)
return;
- /* check that we have an initialised tail queue */
- acl_list = RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_ACL, rte_acl_list);
- if (acl_list == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return;
- }
+ acl_list = RTE_TAILQ_CAST(rte_acl_tailq.head, rte_acl_list);
rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
@@ -197,12 +192,7 @@ rte_acl_create(const struct rte_acl_param *param)
struct rte_tailq_entry *te;
char name[sizeof(ctx->name)];
- /* check that we have an initialised tail queue */
- acl_list = RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_ACL, rte_acl_list);
- if (acl_list == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return NULL;
- }
+ acl_list = RTE_TAILQ_CAST(rte_acl_tailq.head, rte_acl_list);
/* check that input parameters are valid. */
if (param == NULL || param->name == NULL) {
@@ -365,12 +355,7 @@ rte_acl_list_dump(void)
struct rte_acl_list *acl_list;
struct rte_tailq_entry *te;
- /* check that we have an initialised tail queue */
- acl_list = RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_ACL, rte_acl_list);
- if (acl_list == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return;
- }
+ acl_list = RTE_TAILQ_CAST(rte_acl_tailq.head, rte_acl_list);
rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
TAILQ_FOREACH(te, acl_list, next) {
diff --git a/lib/librte_acl/rte_acl.h b/lib/librte_acl/rte_acl.h
index 30aea03..3a93730 100644
--- a/lib/librte_acl/rte_acl.h
+++ b/lib/librte_acl/rte_acl.h
@@ -170,7 +170,6 @@ struct rte_acl_param {
* Pointer to ACL context structure that is used in future ACL
* operations, or NULL on error, with error code set in rte_errno.
* Possible rte_errno errors include:
- * - E_RTE_NO_TAILQ - no tailq list could be got for the ACL context list
* - EINVAL - invalid parameter passed to function
*/
struct rte_acl_ctx *
diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c
index 84e78bb..f3f778c 100644
--- a/lib/librte_distributor/rte_distributor.c
+++ b/lib/librte_distributor/rte_distributor.c
@@ -115,6 +115,11 @@ struct rte_distributor {
TAILQ_HEAD(rte_distributor_list, rte_distributor);
+static struct rte_tailq_elem rte_distributor_tailq = {
+ .name = "RTE_DISTRIBUTOR",
+};
+EAL_REGISTER_TAILQ(rte_distributor_tailq)
+
/**** APIs called by workers ****/
void
@@ -460,14 +465,6 @@ rte_distributor_create(const char *name,
return NULL;
}
- /* check that we have an initialised tail queue */
- distributor_list = RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_DISTRIBUTOR,
- rte_distributor_list);
- if (distributor_list == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return NULL;
- }
-
snprintf(mz_name, sizeof(mz_name), RTE_DISTRIB_PREFIX"%s", name);
mz = rte_memzone_reserve(mz_name, sizeof(*d), socket_id, NO_FLAGS);
if (mz == NULL) {
@@ -479,6 +476,9 @@ rte_distributor_create(const char *name,
snprintf(d->name, sizeof(d->name), "%s", name);
d->num_workers = num_workers;
+ distributor_list = RTE_TAILQ_CAST(rte_distributor_tailq.head,
+ rte_distributor_list);
+
rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
TAILQ_INSERT_TAIL(distributor_list, d, next);
rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 5457a21..3a0fda5 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -107,6 +107,11 @@ TAILQ_HEAD(uio_res_list, uio_resource);
static struct uio_res_list *uio_res_list = NULL;
+static struct rte_tailq_elem rte_pci_tailq = {
+ .name = "PCI_RESOURCE_LIST",
+};
+EAL_REGISTER_TAILQ(rte_pci_tailq)
+
/* unbind kernel driver for this device */
static int
pci_unbind_kernel_driver(struct rte_pci_device *dev __rte_unused)
@@ -492,7 +497,7 @@ rte_eal_pci_init(void)
{
TAILQ_INIT(&pci_driver_list);
TAILQ_INIT(&pci_device_list);
- uio_res_list = RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_PCI, uio_res_list);
+ uio_res_list = RTE_TAILQ_CAST(rte_pci_tailq.head, uio_res_list);
/* for debug purposes, PCI can be disabled */
if (internal_config.no_pci)
diff --git a/lib/librte_eal/common/include/rte_tailq_elem.h b/lib/librte_eal/common/include/rte_tailq_elem.h
index 01fc769..e88211c 100644
--- a/lib/librte_eal/common/include/rte_tailq_elem.h
+++ b/lib/librte_eal/common/include/rte_tailq_elem.h
@@ -64,26 +64,6 @@
#define rte_tailq_end(idx)
#endif /* rte_tailq_end */
-rte_tailq_elem(RTE_TAILQ_PCI, "PCI_RESOURCE_LIST")
-
-rte_tailq_elem(RTE_TAILQ_MEMPOOL, "RTE_MEMPOOL")
-
-rte_tailq_elem(RTE_TAILQ_RING, "RTE_RING")
-
-rte_tailq_elem(RTE_TAILQ_HASH, "RTE_HASH")
-
-rte_tailq_elem(RTE_TAILQ_FBK_HASH, "RTE_FBK_HASH")
-
-rte_tailq_elem(RTE_TAILQ_LPM, "RTE_LPM")
-
-rte_tailq_elem(RTE_TAILQ_LPM6, "RTE_LPM6")
-
-rte_tailq_elem(RTE_TAILQ_ACL, "RTE_ACL")
-
-rte_tailq_elem(RTE_TAILQ_DISTRIBUTOR, "RTE_DISTRIBUTOR")
-
-rte_tailq_elem(RTE_TAILQ_REORDER, "RTE_REORDER")
-
rte_tailq_end(RTE_TAILQ_NUM)
#undef rte_tailq_elem
diff --git a/lib/librte_eal/linuxapp/eal/eal_ivshmem.c b/lib/librte_eal/linuxapp/eal/eal_ivshmem.c
index 413a9ba..2deaeb7 100644
--- a/lib/librte_eal/linuxapp/eal/eal_ivshmem.c
+++ b/lib/librte_eal/linuxapp/eal/eal_ivshmem.c
@@ -53,7 +53,6 @@
#include <rte_malloc.h>
#include <rte_common.h>
#include <rte_ivshmem.h>
-#include <rte_tailq_elem.h>
#include "eal_internal_cfg.h"
#include "eal_private.h"
@@ -764,8 +763,8 @@ rte_eal_ivshmem_obj_init(void)
return 0;
/* check that we have an initialised ring tail queue */
- if ((ring_list =
- RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_RING, rte_ring_list)) == NULL) {
+ ring_list = RTE_TAILQ_LOOKUP(RTE_TAILQ_RING_NAME, rte_ring_list);
+ if (ring_list == NULL) {
RTE_LOG(ERR, EAL, "No rte_ring tailq found!\n");
return -1;
}
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c
index 595f17b..c42e843 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -58,6 +58,11 @@
struct mapped_pci_res_list *pci_res_list = NULL;
+static struct rte_tailq_elem rte_pci_tailq = {
+ .name = "PCI_RESOURCE_LIST",
+};
+EAL_REGISTER_TAILQ(rte_pci_tailq)
+
/* unbind kernel driver for this device */
static int
pci_unbind_kernel_driver(struct rte_pci_device *dev)
@@ -765,8 +770,7 @@ rte_eal_pci_init(void)
{
TAILQ_INIT(&pci_driver_list);
TAILQ_INIT(&pci_device_list);
- pci_res_list = RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_PCI,
- mapped_pci_res_list);
+ pci_res_list = RTE_TAILQ_CAST(rte_pci_tailq.head, mapped_pci_res_list);
/* for debug purposes, PCI can be disabled */
if (internal_config.no_pci)
diff --git a/lib/librte_hash/rte_fbk_hash.c b/lib/librte_hash/rte_fbk_hash.c
index c342c0d..356ddfe 100644
--- a/lib/librte_hash/rte_fbk_hash.c
+++ b/lib/librte_hash/rte_fbk_hash.c
@@ -55,6 +55,11 @@
TAILQ_HEAD(rte_fbk_hash_list, rte_tailq_entry);
+static struct rte_tailq_elem rte_fbk_hash_tailq = {
+ .name = "RTE_FBK_HASH",
+};
+EAL_REGISTER_TAILQ(rte_fbk_hash_tailq)
+
/**
* Performs a lookup for an existing hash table, and returns a pointer to
* the table if found.
@@ -72,13 +77,8 @@ rte_fbk_hash_find_existing(const char *name)
struct rte_tailq_entry *te;
struct rte_fbk_hash_list *fbk_hash_list;
- /* check that we have an initialised tail queue */
- if ((fbk_hash_list =
- RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_FBK_HASH,
- rte_fbk_hash_list)) == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return NULL;
- }
+ fbk_hash_list = RTE_TAILQ_CAST(rte_fbk_hash_tailq.head,
+ rte_fbk_hash_list);
rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
TAILQ_FOREACH(te, fbk_hash_list, next) {
@@ -115,13 +115,8 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
uint32_t i;
struct rte_fbk_hash_list *fbk_hash_list;
- /* check that we have an initialised tail queue */
- if ((fbk_hash_list =
- RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_FBK_HASH,
- rte_fbk_hash_list)) == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return NULL;
- }
+ fbk_hash_list = RTE_TAILQ_CAST(rte_fbk_hash_tailq.head,
+ rte_fbk_hash_list);
/* Error checking of parameters. */
if ((!rte_is_power_of_2(params->entries)) ||
@@ -208,13 +203,8 @@ rte_fbk_hash_free(struct rte_fbk_hash_table *ht)
if (ht == NULL)
return;
- /* check that we have an initialised tail queue */
- if ((fbk_hash_list =
- RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_FBK_HASH,
- rte_fbk_hash_list)) == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return;
- }
+ fbk_hash_list = RTE_TAILQ_CAST(rte_fbk_hash_tailq.head,
+ rte_fbk_hash_list);
rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
diff --git a/lib/librte_hash/rte_fbk_hash.h b/lib/librte_hash/rte_fbk_hash.h
index 3d229bf..c9b5a6a 100644
--- a/lib/librte_hash/rte_fbk_hash.h
+++ b/lib/librte_hash/rte_fbk_hash.h
@@ -372,7 +372,6 @@ struct rte_fbk_hash_table *rte_fbk_hash_find_existing(const char *name);
* Possible rte_errno error values include:
* - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
* - E_RTE_SECONDARY - function was called from a secondary process instance
- * - E_RTE_NO_TAILQ - no tailq list could be got for the fbk hash table list
* - EINVAL - invalid parameter value passed to function
* - ENOSPC - the maximum number of memzones has already been allocated
* - EEXIST - a memzone with the same name already exists
diff --git a/lib/librte_hash/rte_hash.c b/lib/librte_hash/rte_hash.c
index b6a2b2f..9245716 100644
--- a/lib/librte_hash/rte_hash.c
+++ b/lib/librte_hash/rte_hash.c
@@ -58,9 +58,13 @@
#include "rte_hash.h"
-
TAILQ_HEAD(rte_hash_list, rte_tailq_entry);
+static struct rte_tailq_elem rte_hash_tailq = {
+ .name = "RTE_HASH",
+};
+EAL_REGISTER_TAILQ(rte_hash_tailq)
+
/* Macro to enable/disable run-time checking of function parameters */
#if defined(RTE_LIBRTE_HASH_DEBUG)
#define RETURN_IF_TRUE(cond, retval) do { \
@@ -144,12 +148,7 @@ rte_hash_find_existing(const char *name)
struct rte_tailq_entry *te;
struct rte_hash_list *hash_list;
- /* check that we have an initialised tail queue */
- if ((hash_list =
- RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_HASH, rte_hash_list)) == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return NULL;
- }
+ hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list);
rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
TAILQ_FOREACH(te, hash_list, next) {
@@ -176,12 +175,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
char hash_name[RTE_HASH_NAMESIZE];
struct rte_hash_list *hash_list;
- /* check that we have an initialised tail queue */
- if ((hash_list =
- RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_HASH, rte_hash_list)) == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return NULL;
- }
+ hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list);
/* Check for valid parameters */
if ((params == NULL) ||
@@ -274,12 +268,7 @@ rte_hash_free(struct rte_hash *h)
if (h == NULL)
return;
- /* check that we have an initialised tail queue */
- if ((hash_list =
- RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_HASH, rte_hash_list)) == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return;
- }
+ hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list);
rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
diff --git a/lib/librte_hash/rte_hash.h b/lib/librte_hash/rte_hash.h
index 2ecaf1a..821a9d4 100644
--- a/lib/librte_hash/rte_hash.h
+++ b/lib/librte_hash/rte_hash.h
@@ -117,7 +117,6 @@ struct rte_hash {
* Possible rte_errno errors include:
* - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
* - E_RTE_SECONDARY - function was called from a secondary process instance
- * - E_RTE_NO_TAILQ - no tailq list could be got for the hash table list
* - ENOENT - missing entry
* - EINVAL - invalid parameter passed to function
* - ENOSPC - the maximum number of memzones has already been allocated
diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c
index 264cde8..0945b81 100644
--- a/lib/librte_lpm/rte_lpm.c
+++ b/lib/librte_lpm/rte_lpm.c
@@ -57,6 +57,11 @@
TAILQ_HEAD(rte_lpm_list, rte_tailq_entry);
+static struct rte_tailq_elem rte_lpm_tailq = {
+ .name = "RTE_LPM",
+};
+EAL_REGISTER_TAILQ(rte_lpm_tailq)
+
#define MAX_DEPTH_TBL24 24
enum valid_flag {
@@ -121,12 +126,7 @@ rte_lpm_find_existing(const char *name)
struct rte_tailq_entry *te;
struct rte_lpm_list *lpm_list;
- /* check that we have an initialised tail queue */
- if ((lpm_list = RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_LPM,
- rte_lpm_list)) == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return NULL;
- }
+ lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
TAILQ_FOREACH(te, lpm_list, next) {
@@ -157,12 +157,7 @@ rte_lpm_create(const char *name, int socket_id, int max_rules,
uint32_t mem_size;
struct rte_lpm_list *lpm_list;
- /* check that we have an initialised tail queue */
- if ((lpm_list = RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_LPM,
- rte_lpm_list)) == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return NULL;
- }
+ lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
RTE_BUILD_BUG_ON(sizeof(struct rte_lpm_tbl24_entry) != 2);
RTE_BUILD_BUG_ON(sizeof(struct rte_lpm_tbl8_entry) != 2);
@@ -232,12 +227,7 @@ rte_lpm_free(struct rte_lpm *lpm)
if (lpm == NULL)
return;
- /* check that we have an initialised tail queue */
- if ((lpm_list =
- RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_LPM, rte_lpm_list)) == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return;
- }
+ lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
@@ -384,8 +374,8 @@ rule_find(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth)
return (rule_index);
}
- /* If rule is not found return -E_RTE_NO_TAILQ. */
- return -E_RTE_NO_TAILQ;
+ /* If rule is not found return -EINVAL. */
+ return -EINVAL;
}
/*
@@ -969,10 +959,10 @@ rte_lpm_delete(struct rte_lpm *lpm, uint32_t ip, uint8_t depth)
/*
* Check if rule_to_delete_index was found. If no rule was found the
- * function rule_find returns -E_RTE_NO_TAILQ.
+ * function rule_find returns -EINVAL.
*/
if (rule_to_delete_index < 0)
- return -E_RTE_NO_TAILQ;
+ return -EINVAL;
/* Delete the rule from the rule table. */
rule_delete(lpm, rule_to_delete_index, depth);
diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h
index 586300b..e6c25b6 100644
--- a/lib/librte_lpm/rte_lpm.h
+++ b/lib/librte_lpm/rte_lpm.h
@@ -163,7 +163,6 @@ struct rte_lpm {
* to an appropriate values. Possible rte_errno values include:
* - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
* - E_RTE_SECONDARY - function was called from a secondary process instance
- * - E_RTE_NO_TAILQ - no tailq list could be got for the lpm object list
* - EINVAL - invalid parameter passed to function
* - ENOSPC - the maximum number of memzones has already been allocated
* - EEXIST - a memzone with the same name already exists
diff --git a/lib/librte_lpm/rte_lpm6.c b/lib/librte_lpm/rte_lpm6.c
index d72f9b3..6c2b293 100644
--- a/lib/librte_lpm/rte_lpm6.c
+++ b/lib/librte_lpm/rte_lpm6.c
@@ -78,6 +78,11 @@ enum valid_flag {
TAILQ_HEAD(rte_lpm6_list, rte_tailq_entry);
+static struct rte_tailq_elem rte_lpm6_tailq = {
+ .name = "RTE_LPM6",
+};
+EAL_REGISTER_TAILQ(rte_lpm6_tailq)
+
/** Tbl entry structure. It is the same for both tbl24 and tbl8 */
struct rte_lpm6_tbl_entry {
uint32_t next_hop: 21; /**< Next hop / next table to be checked. */
@@ -150,12 +155,7 @@ rte_lpm6_create(const char *name, int socket_id,
uint64_t mem_size, rules_size;
struct rte_lpm6_list *lpm_list;
- /* Check that we have an initialised tail queue */
- if ((lpm_list =
- RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_LPM6, rte_lpm6_list)) == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return NULL;
- }
+ lpm_list = RTE_TAILQ_CAST(rte_lpm6_tailq.head, rte_lpm6_list);
RTE_BUILD_BUG_ON(sizeof(struct rte_lpm6_tbl_entry) != sizeof(uint32_t));
@@ -237,12 +237,7 @@ rte_lpm6_find_existing(const char *name)
struct rte_tailq_entry *te;
struct rte_lpm6_list *lpm_list;
- /* Check that we have an initialised tail queue */
- if ((lpm_list = RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_LPM6,
- rte_lpm6_list)) == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return NULL;
- }
+ lpm_list = RTE_TAILQ_CAST(rte_lpm6_tailq.head, rte_lpm6_list);
rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
TAILQ_FOREACH(te, lpm_list, next) {
@@ -273,12 +268,7 @@ rte_lpm6_free(struct rte_lpm6 *lpm)
if (lpm == NULL)
return;
- /* check that we have an initialised tail queue */
- if ((lpm_list =
- RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_LPM, rte_lpm6_list)) == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return;
- }
+ lpm_list = RTE_TAILQ_CAST(rte_lpm6_tailq.head, rte_lpm6_list);
rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
diff --git a/lib/librte_lpm/rte_lpm6.h b/lib/librte_lpm/rte_lpm6.h
index 4db810f..cedcea8 100644
--- a/lib/librte_lpm/rte_lpm6.h
+++ b/lib/librte_lpm/rte_lpm6.h
@@ -72,7 +72,6 @@ struct rte_lpm6_config {
* to an appropriate values. Possible rte_errno values include:
* - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
* - E_RTE_SECONDARY - function was called from a secondary process instance
- * - E_RTE_NO_TAILQ - no tailq list could be got for the lpm object list
* - EINVAL - invalid parameter passed to function
* - ENOSPC - the maximum number of memzones has already been allocated
* - EEXIST - a memzone with the same name already exists
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 3301e97..9405b92 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -62,6 +62,12 @@
TAILQ_HEAD(rte_mempool_list, rte_tailq_entry);
+static struct rte_tailq_elem rte_mempool_tailq =
+{
+ .name = "RTE_MEMPOOL",
+};
+EAL_REGISTER_TAILQ(rte_mempool_tailq)
+
#define CACHE_FLUSHTHRESH_MULTIPLIER 1.5
/*
@@ -432,13 +438,7 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,
RTE_CACHE_LINE_MASK) != 0);
#endif
- /* check that we have an initialised tail queue */
- mempool_list = RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_MEMPOOL,
- rte_mempool_list);
- if (mempool_list == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return NULL;
- }
+ mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
/* asked cache too big */
if (cache_size > RTE_MEMPOOL_CACHE_MAX_SIZE) {
@@ -834,11 +834,7 @@ rte_mempool_list_dump(FILE *f)
struct rte_tailq_entry *te;
struct rte_mempool_list *mempool_list;
- if ((mempool_list =
- RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_MEMPOOL, rte_mempool_list)) == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return;
- }
+ mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
rte_rwlock_read_lock(RTE_EAL_MEMPOOL_RWLOCK);
@@ -858,11 +854,7 @@ rte_mempool_lookup(const char *name)
struct rte_tailq_entry *te;
struct rte_mempool_list *mempool_list;
- if ((mempool_list =
- RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_MEMPOOL, rte_mempool_list)) == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return NULL;
- }
+ mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
rte_rwlock_read_lock(RTE_EAL_MEMPOOL_RWLOCK);
@@ -888,11 +880,7 @@ void rte_mempool_walk(void (*func)(const struct rte_mempool *, void *),
struct rte_tailq_entry *te = NULL;
struct rte_mempool_list *mempool_list;
- if ((mempool_list =
- RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_MEMPOOL, rte_mempool_list)) == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return;
- }
+ mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
rte_rwlock_read_lock(RTE_EAL_MEMPOOL_RWLOCK);
diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index 39f7233..9001312 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -524,7 +524,6 @@ typedef void (rte_mempool_ctor_t)(struct rte_mempool *, void *);
* with rte_errno set appropriately. Possible rte_errno values include:
* - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
* - E_RTE_SECONDARY - function was called from a secondary process instance
- * - E_RTE_NO_TAILQ - no tailq list could be got for the ring or mempool list
* - EINVAL - cache size provided is too large
* - ENOSPC - the maximum number of memzones has already been allocated
* - EEXIST - a memzone with the same name already exists
@@ -625,7 +624,6 @@ rte_mempool_create(const char *name, unsigned n, unsigned elt_size,
* with rte_errno set appropriately. Possible rte_errno values include:
* - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
* - E_RTE_SECONDARY - function was called from a secondary process instance
- * - E_RTE_NO_TAILQ - no tailq list could be got for the ring or mempool list
* - EINVAL - cache size provided is too large
* - ENOSPC - the maximum number of memzones has already been allocated
* - EEXIST - a memzone with the same name already exists
@@ -716,7 +714,6 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,
* with rte_errno set appropriately. Possible rte_errno values include:
* - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
* - E_RTE_SECONDARY - function was called from a secondary process instance
- * - E_RTE_NO_TAILQ - no tailq list could be got for the ring or mempool list
* - EINVAL - cache size provided is too large
* - ENOSPC - the maximum number of memzones has already been allocated
* - EEXIST - a memzone with the same name already exists
diff --git a/lib/librte_reorder/rte_reorder.c b/lib/librte_reorder/rte_reorder.c
index c5ce794..88f1baf 100644
--- a/lib/librte_reorder/rte_reorder.c
+++ b/lib/librte_reorder/rte_reorder.c
@@ -45,6 +45,11 @@
TAILQ_HEAD(rte_reorder_list, rte_tailq_entry);
+static struct rte_tailq_elem rte_reorder_tailq = {
+ .name = "RTE_REORDER",
+};
+EAL_REGISTER_TAILQ(rte_reorder_tailq)
+
#define NO_FLAGS 0
#define RTE_REORDER_PREFIX "RO_"
#define RTE_REORDER_NAMESIZE 32
@@ -126,12 +131,7 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size)
const unsigned int bufsize = sizeof(struct rte_reorder_buffer) +
(2 * size * sizeof(struct rte_mbuf *));
- /* check that we have an initialised tail queue */
- reorder_list = RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_REORDER, rte_reorder_list);
- if (!reorder_list) {
- rte_errno = E_RTE_NO_TAILQ;
- return NULL;
- }
+ reorder_list = RTE_TAILQ_CAST(rte_reorder_tailq.head, rte_reorder_list);
/* Check user arguments. */
if (!rte_is_power_of_2(size)) {
@@ -219,12 +219,7 @@ rte_reorder_free(struct rte_reorder_buffer *b)
if (b == NULL)
return;
- /* check that we have an initialised tail queue */
- reorder_list = RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_REORDER, rte_reorder_list);
- if (!reorder_list) {
- rte_errno = E_RTE_NO_TAILQ;
- return;
- }
+ reorder_list = RTE_TAILQ_CAST(rte_reorder_tailq.head, rte_reorder_list);
rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
@@ -255,12 +250,7 @@ rte_reorder_find_existing(const char *name)
struct rte_tailq_entry *te;
struct rte_reorder_list *reorder_list;
- /* check that we have an initialised tail queue */
- reorder_list = RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_REORDER, rte_reorder_list);
- if (!reorder_list) {
- rte_errno = E_RTE_NO_TAILQ;
- return NULL;
- }
+ reorder_list = RTE_TAILQ_CAST(rte_reorder_tailq.head, rte_reorder_list);
rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
TAILQ_FOREACH(te, reorder_list, next) {
diff --git a/lib/librte_reorder/rte_reorder.h b/lib/librte_reorder/rte_reorder.h
index 8300bf0..c7a2934 100644
--- a/lib/librte_reorder/rte_reorder.h
+++ b/lib/librte_reorder/rte_reorder.h
@@ -102,7 +102,6 @@ rte_reorder_init(struct rte_reorder_buffer *b, unsigned int bufsize,
* Pointer to reorder buffer instance or NULL if object not found with rte_errno
* set appropriately. Possible rte_errno values include:
* - ENOENT - required entry not available to return.
- * - E_RTE_NO_TAILQ - no tailq list could be got for the
* reorder instance list
*/
struct rte_reorder_buffer *
diff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c
index 92ecf04..1b4361d 100644
--- a/lib/librte_ring/rte_ring.c
+++ b/lib/librte_ring/rte_ring.c
@@ -91,6 +91,12 @@
TAILQ_HEAD(rte_ring_list, rte_tailq_entry);
+static struct rte_tailq_elem rte_ring_tailq =
+{
+ .name = RTE_TAILQ_RING_NAME,
+};
+EAL_REGISTER_TAILQ(rte_ring_tailq)
+
/* true if x is a power of 2 */
#define POWEROF2(x) ((((x)-1) & (x)) == 0)
@@ -161,12 +167,7 @@ rte_ring_create(const char *name, unsigned count, int socket_id,
int mz_flags = 0;
struct rte_ring_list* ring_list = NULL;
- /* check that we have an initialised tail queue */
- if ((ring_list =
- RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_RING, rte_ring_list)) == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return NULL;
- }
+ ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
ring_size = rte_ring_get_memsize(count);
if (ring_size < 0) {
@@ -287,12 +288,7 @@ rte_ring_list_dump(FILE *f)
const struct rte_tailq_entry *te;
struct rte_ring_list *ring_list;
- /* check that we have an initialised tail queue */
- if ((ring_list =
- RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_RING, rte_ring_list)) == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return;
- }
+ ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
@@ -311,12 +307,7 @@ rte_ring_lookup(const char *name)
struct rte_ring *r = NULL;
struct rte_ring_list *ring_list;
- /* check that we have an initialized tail queue */
- if ((ring_list =
- RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_RING, rte_ring_list)) == NULL) {
- rte_errno = E_RTE_NO_TAILQ;
- return NULL;
- }
+ ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
index bdf69b7..af68888 100644
--- a/lib/librte_ring/rte_ring.h
+++ b/lib/librte_ring/rte_ring.h
@@ -101,6 +101,8 @@ extern "C" {
#include <rte_atomic.h>
#include <rte_branch_prediction.h>
+#define RTE_TAILQ_RING_NAME "RTE_RING"
+
enum rte_ring_queue_behavior {
RTE_RING_QUEUE_FIXED = 0, /* Enq/Deq a fixed number of items from a ring */
RTE_RING_QUEUE_VARIABLE /* Enq/Deq as many items a possible from ring */
@@ -291,7 +293,6 @@ int rte_ring_init(struct rte_ring *r, const char *name, unsigned count,
* rte_errno set appropriately. Possible errno values include:
* - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
* - E_RTE_SECONDARY - function was called from a secondary process instance
- * - E_RTE_NO_TAILQ - no tailq list could be got for the ring list
* - EINVAL - count provided is not a power of 2
* - ENOSPC - the maximum number of memzones has already been allocated
* - EEXIST - a memzone with the same name already exists
--
1.7.10.4
next prev 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 ` [dpdk-dev] [PATCH 05/10] tailq: get rid of broken "reserve" api David Marchand
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 ` David Marchand [this message]
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-9-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).