X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_member%2Frte_member.c;h=e0e7f127e36e9d12e177d228297da3b5e97554ef;hb=028669bc9f0d;hp=cc9ea84ae4493dd1791edfce8387074882528b2a;hpb=4c00cfdc0ea225f2518a35db928ad1ab02b2a724;p=dpdk.git diff --git a/lib/librte_member/rte_member.c b/lib/librte_member/rte_member.c index cc9ea84ae4..e0e7f127e3 100644 --- a/lib/librte_member/rte_member.c +++ b/lib/librte_member/rte_member.c @@ -1,43 +1,16 @@ -/*- - * BSD LICENSE - * - * Copyright(c) 2017 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2017 Intel Corporation */ #include +#include #include #include #include #include #include +#include #include "rte_member.h" #include "rte_member_ht.h" @@ -60,13 +33,13 @@ rte_member_find_existing(const char *name) member_list = RTE_TAILQ_CAST(rte_member_tailq.head, rte_member_list); - rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK); + rte_mcfg_tailq_read_lock(); TAILQ_FOREACH(te, member_list, next) { setsum = (struct rte_member_setsum *) te->data; if (strncmp(name, setsum->name, RTE_MEMBER_NAMESIZE) == 0) break; } - rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK); + rte_mcfg_tailq_read_unlock(); if (te == NULL) { rte_errno = ENOENT; @@ -84,17 +57,17 @@ rte_member_free(struct rte_member_setsum *setsum) if (setsum == NULL) return; member_list = RTE_TAILQ_CAST(rte_member_tailq.head, rte_member_list); - rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK); + rte_mcfg_tailq_write_lock(); TAILQ_FOREACH(te, member_list, next) { if (te->data == (void *)setsum) break; } if (te == NULL) { - rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK); + rte_mcfg_tailq_write_unlock(); return; } TAILQ_REMOVE(member_list, te, next); - rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK); + rte_mcfg_tailq_write_unlock(); switch (setsum->type) { case RTE_MEMBER_TYPE_HT: @@ -133,10 +106,10 @@ rte_member_create(const struct rte_member_parameters *params) member_list = RTE_TAILQ_CAST(rte_member_tailq.head, rte_member_list); - rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK); + rte_mcfg_tailq_write_lock(); TAILQ_FOREACH(te, member_list, next) { - setsum = (struct rte_member_setsum *) te->data; + setsum = te->data; if (strncmp(params->name, setsum->name, RTE_MEMBER_NAMESIZE) == 0) break; @@ -154,14 +127,14 @@ rte_member_create(const struct rte_member_parameters *params) } /* Create a new setsum structure */ - setsum = (struct rte_member_setsum *) rte_zmalloc_socket(params->name, + setsum = rte_zmalloc_socket(params->name, sizeof(struct rte_member_setsum), RTE_CACHE_LINE_SIZE, params->socket_id); if (setsum == NULL) { RTE_MEMBER_LOG(ERR, "Create setsummary failed\n"); goto error_unlock_exit; } - snprintf(setsum->name, sizeof(setsum->name), "%s", params->name); + strlcpy(setsum->name, params->name, sizeof(setsum->name)); setsum->type = params->type; setsum->socket_id = params->socket_id; setsum->key_len = params->key_len; @@ -187,12 +160,13 @@ rte_member_create(const struct rte_member_parameters *params) te->data = (void *)setsum; TAILQ_INSERT_TAIL(member_list, te, next); - rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK); + rte_mcfg_tailq_write_unlock(); return setsum; error_unlock_exit: - rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK); - rte_member_free(setsum); + rte_free(te); + rte_free(setsum); + rte_mcfg_tailq_write_unlock(); return NULL; } @@ -325,12 +299,9 @@ rte_member_reset(const struct rte_member_setsum *setsum) } } -RTE_INIT(librte_member_init_log); - -static void -librte_member_init_log(void) +RTE_INIT(librte_member_init_log) { - librte_member_logtype = rte_log_register("librte.member"); + librte_member_logtype = rte_log_register("lib.member"); if (librte_member_logtype >= 0) rte_log_set_level(librte_member_logtype, RTE_LOG_DEBUG); }