From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v3 9/9] rte_acl: make acl tailq fully local
Date: Wed, 18 Jun 2014 12:27:14 +0100 [thread overview]
Message-ID: <23fe0593993322b8dc0a87cb2fdee1e2591d6df3.1403084449.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <cover.1403018971.git.anatoly.burakov@intel.com>
In-Reply-To: <cover.1403084449.git.anatoly.burakov@intel.com>
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
lib/librte_acl/acl.h | 1 -
lib/librte_acl/rte_acl.c | 74 +++++++++++++++++++++++++++++++++++++++---------
2 files changed, 60 insertions(+), 15 deletions(-)
diff --git a/lib/librte_acl/acl.h b/lib/librte_acl/acl.h
index e6d7985..b9d63fd 100644
--- a/lib/librte_acl/acl.h
+++ b/lib/librte_acl/acl.h
@@ -149,7 +149,6 @@ struct rte_acl_bld_trie {
};
struct rte_acl_ctx {
- TAILQ_ENTRY(rte_acl_ctx) next; /**< Next in list. */
char name[RTE_ACL_NAMESIZE];
/** Name of the ACL context. */
int32_t socket_id;
diff --git a/lib/librte_acl/rte_acl.c b/lib/librte_acl/rte_acl.c
index 129a41f..3b47ab6 100644
--- a/lib/librte_acl/rte_acl.c
+++ b/lib/librte_acl/rte_acl.c
@@ -36,13 +36,14 @@
#define BIT_SIZEOF(x) (sizeof(x) * CHAR_BIT)
-TAILQ_HEAD(rte_acl_list, rte_acl_ctx);
+TAILQ_HEAD(rte_acl_list, rte_tailq_entry);
struct rte_acl_ctx *
rte_acl_find_existing(const char *name)
{
- struct rte_acl_ctx *ctx;
+ struct rte_acl_ctx *ctx = NULL;
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);
@@ -52,27 +53,55 @@ rte_acl_find_existing(const char *name)
}
rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
- TAILQ_FOREACH(ctx, acl_list, next) {
+ TAILQ_FOREACH(te, acl_list, next) {
+ ctx = (struct rte_acl_ctx*) te->data;
if (strncmp(name, ctx->name, sizeof(ctx->name)) == 0)
break;
}
rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
- if (ctx == NULL)
+ if (te == NULL) {
rte_errno = ENOENT;
+ return NULL;
+ }
return ctx;
}
void
rte_acl_free(struct rte_acl_ctx *ctx)
{
+ struct rte_acl_list *acl_list;
+ struct rte_tailq_entry *te;
+
if (ctx == NULL)
return;
- RTE_EAL_TAILQ_REMOVE(RTE_TAILQ_ACL, rte_acl_list, ctx);
+ /* 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;
+ }
+
+ rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+
+ /* find our tailq entry */
+ TAILQ_FOREACH(te, acl_list, next) {
+ if (te->data == (void *) ctx)
+ break;
+ }
+ if (te == NULL) {
+ rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+ return;
+ }
+
+ TAILQ_REMOVE(acl_list, te, next);
+
+ rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
rte_free(ctx->mem);
rte_free(ctx);
+ rte_free(te);
}
struct rte_acl_ctx *
@@ -81,6 +110,7 @@ rte_acl_create(const struct rte_acl_param *param)
size_t sz;
struct rte_acl_ctx *ctx;
struct rte_acl_list *acl_list;
+ struct rte_tailq_entry *te;
char name[sizeof(ctx->name)];
/* check that we have an initialised tail queue */
@@ -105,15 +135,31 @@ rte_acl_create(const struct rte_acl_param *param)
rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
/* if we already have one with that name */
- TAILQ_FOREACH(ctx, acl_list, next) {
+ TAILQ_FOREACH(te, acl_list, next) {
+ ctx = (struct rte_acl_ctx*) te->data;
if (strncmp(param->name, ctx->name, sizeof(ctx->name)) == 0)
break;
}
/* if ACL with such name doesn't exist, then create a new one. */
- if (ctx == NULL && (ctx = rte_zmalloc_socket(name, sz, CACHE_LINE_SIZE,
- param->socket_id)) != NULL) {
+ if (te == NULL) {
+ ctx = NULL;
+ te = rte_zmalloc("ACL_TAILQ_ENTRY", sizeof(*te), 0);
+
+ if (te == NULL) {
+ RTE_LOG(ERR, ACL, "Cannot allocate tailq entry!\n");
+ goto exit;
+ }
+
+ ctx = rte_zmalloc_socket(name, sz, CACHE_LINE_SIZE, param->socket_id);
+ if (ctx == NULL) {
+ RTE_LOG(ERR, ACL,
+ "allocation of %zu bytes on socket %d for %s failed\n",
+ sz, param->socket_id, name);
+ rte_free(te);
+ goto exit;
+ }
/* init new allocated context. */
ctx->rules = ctx + 1;
ctx->max_rules = param->max_rule_num;
@@ -121,14 +167,12 @@ rte_acl_create(const struct rte_acl_param *param)
ctx->socket_id = param->socket_id;
rte_snprintf(ctx->name, sizeof(ctx->name), "%s", param->name);
- TAILQ_INSERT_TAIL(acl_list, ctx, next);
+ te->data = (void *) ctx;
- } else if (ctx == NULL) {
- RTE_LOG(ERR, ACL,
- "allocation of %zu bytes on socket %d for %s failed\n",
- sz, param->socket_id, name);
+ TAILQ_INSERT_TAIL(acl_list, te, next);
}
+exit:
rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
return ctx;
}
@@ -232,6 +276,7 @@ rte_acl_list_dump(void)
{
struct rte_acl_ctx *ctx;
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);
@@ -241,7 +286,8 @@ rte_acl_list_dump(void)
}
rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
- TAILQ_FOREACH(ctx, acl_list, next) {
+ TAILQ_FOREACH(te, acl_list, next) {
+ ctx = (struct rte_acl_ctx *) te->data;
rte_acl_dump(ctx);
}
rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
--
1.8.1.4
next prev parent reply other threads:[~2014-06-18 11:27 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-13 15:29 [dpdk-dev] [PATCH 0/7] Make DPDK tailqs " Anatoly Burakov
2014-06-13 15:29 ` [dpdk-dev] [PATCH 1/7] rte_tailq: change rte_dummy to rte_tailq_entry, add data pointer Anatoly Burakov
2014-06-13 15:29 ` [dpdk-dev] [PATCH 2/7] rte_ring: make ring tailq completely local Anatoly Burakov
2014-06-13 15:29 ` [dpdk-dev] [PATCH 3/7] rte_hash: make rte_hash tailq fully local Anatoly Burakov
2014-06-13 15:29 ` [dpdk-dev] [PATCH 4/7] rte_fbk_hash: make rte_fbk_hash " Anatoly Burakov
2014-06-13 15:29 ` [dpdk-dev] [PATCH 5/7] rte_mempool: make mempool " Anatoly Burakov
2014-06-13 15:29 ` [dpdk-dev] [PATCH 6/7] rte_lpm: make lpm " Anatoly Burakov
2014-06-13 15:29 ` [dpdk-dev] [PATCH 7/7] rte_lpm6: make lpm6 " Anatoly Burakov
2014-06-17 9:57 ` [dpdk-dev] [PATCH 0/7] Make DPDK tailqs " Burakov, Anatoly
2014-06-17 15:35 ` [dpdk-dev] [PATCH 0/9] " Anatoly Burakov
2014-06-17 15:35 ` [dpdk-dev] [PATCH 1/9] eal: map shared config into exact same address as primary process Anatoly Burakov
2014-06-17 16:29 ` Ananyev, Konstantin
2014-06-18 9:25 ` Burakov, Anatoly
2014-06-17 15:36 ` [dpdk-dev] [PATCH 2/9] rte_tailq: change rte_dummy to rte_tailq_entry, add data pointer Anatoly Burakov
2014-06-17 15:36 ` [dpdk-dev] [PATCH 3/9] rte_ring: make ring tailq fully local Anatoly Burakov
2014-06-17 15:36 ` [dpdk-dev] [PATCH 4/9] rte_hash: make rte_hash " Anatoly Burakov
2014-06-17 15:36 ` [dpdk-dev] [PATCH 5/9] rte_fbk_hash: make rte_fbk_hash " Anatoly Burakov
2014-06-17 15:36 ` [dpdk-dev] [PATCH 6/9] rte_mempool: make mempool " Anatoly Burakov
2014-06-17 15:36 ` [dpdk-dev] [PATCH 7/9] rte_lpm: make lpm " Anatoly Burakov
2014-06-17 15:36 ` [dpdk-dev] [PATCH 8/9] rte_lpm6: make lpm6 " Anatoly Burakov
2014-06-17 15:36 ` [dpdk-dev] [PATCH 9/9] rte_acl: make acl " Anatoly Burakov
2014-06-18 11:27 ` [dpdk-dev] [PATCH v3 0/9] Make DPDK tailqs " Anatoly Burakov
2014-06-18 11:27 ` [dpdk-dev] [PATCH v3 1/9] eal: map shared config into exact same address as primary process Anatoly Burakov
2014-06-18 11:27 ` [dpdk-dev] [PATCH v3 2/9] rte_tailq: change rte_dummy to rte_tailq_entry, add data pointer Anatoly Burakov
2014-06-18 11:27 ` [dpdk-dev] [PATCH v3 3/9] rte_ring: make ring tailq fully local Anatoly Burakov
2014-06-18 11:27 ` [dpdk-dev] [PATCH v3 4/9] rte_hash: make rte_hash " Anatoly Burakov
2014-06-18 11:27 ` [dpdk-dev] [PATCH v3 5/9] rte_fbk_hash: make rte_fbk_hash " Anatoly Burakov
2014-06-18 11:27 ` [dpdk-dev] [PATCH v3 6/9] rte_mempool: make mempool " Anatoly Burakov
2014-06-18 11:27 ` [dpdk-dev] [PATCH v3 7/9] rte_lpm: make lpm " Anatoly Burakov
2014-06-18 11:27 ` [dpdk-dev] [PATCH v3 8/9] rte_lpm6: make lpm6 " Anatoly Burakov
2014-06-18 11:27 ` Anatoly Burakov [this message]
2014-06-18 14:21 ` [dpdk-dev] [PATCH v3 0/9] Make DPDK tailqs " Ananyev, Konstantin
2014-06-20 15:42 ` [dpdk-dev] [PATCH 00/10] " Anatoly Burakov
2014-06-20 15:42 ` [dpdk-dev] [PATCH 01/10] eal: map shared config into exact same address as primary process Anatoly Burakov
2014-06-20 15:42 ` [dpdk-dev] [PATCH 02/10] eal: use --base-virtaddr for mapping rte_config as well Anatoly Burakov
2014-06-20 15:42 ` [dpdk-dev] [PATCH 03/10] rte_tailq: change rte_dummy to rte_tailq_entry, add data pointer Anatoly Burakov
2014-06-20 15:42 ` [dpdk-dev] [PATCH 04/10] rte_ring: make ring tailq fully local Anatoly Burakov
2014-06-20 15:42 ` [dpdk-dev] [PATCH 05/10] rte_hash: make rte_hash " Anatoly Burakov
2014-06-20 15:42 ` [dpdk-dev] [PATCH 06/10] rte_fbk_hash: make rte_fbk_hash " Anatoly Burakov
2014-06-20 15:42 ` [dpdk-dev] [PATCH 07/10] rte_mempool: make mempool " Anatoly Burakov
2014-06-20 15:42 ` [dpdk-dev] [PATCH 08/10] rte_lpm: make lpm " Anatoly Burakov
2014-06-20 15:42 ` [dpdk-dev] [PATCH 09/10] rte_lpm6: make lpm6 " Anatoly Burakov
2014-06-20 15:42 ` [dpdk-dev] [PATCH 10/10] rte_acl: make acl " Anatoly Burakov
2014-07-22 22:12 ` [dpdk-dev] [PATCH 00/10] Make DPDK tailqs " Thomas Monjalon
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=23fe0593993322b8dc0a87cb2fdee1e2591d6df3.1403084449.git.anatoly.burakov@intel.com \
--to=anatoly.burakov@intel.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).