bus/pci: use SPDX tags in 6WIND copyrighted files
[dpdk.git] / lib / librte_member / rte_member.c
index 7e74e18..e147dd1 100644 (file)
@@ -1,34 +1,5 @@
-/*-
- *   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 <string.h>
 #include <rte_eal.h>
 #include <rte_eal_memconfig.h>
 #include <rte_memory.h>
-#include <rte_memzone.h>
 #include <rte_malloc.h>
 #include <rte_errno.h>
 
 #include "rte_member.h"
 #include "rte_member_ht.h"
+#include "rte_member_vbf.h"
 
 int librte_member_logtype;
 
@@ -100,6 +71,9 @@ rte_member_free(struct rte_member_setsum *setsum)
        case RTE_MEMBER_TYPE_HT:
                rte_member_free_ht(setsum);
                break;
+       case RTE_MEMBER_TYPE_VBF:
+               rte_member_free_vbf(setsum);
+               break;
        default:
                break;
        }
@@ -133,7 +107,7 @@ rte_member_create(const struct rte_member_parameters *params)
        rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
 
        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;
@@ -151,7 +125,7 @@ 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) {
@@ -170,6 +144,9 @@ rte_member_create(const struct rte_member_parameters *params)
        case RTE_MEMBER_TYPE_HT:
                ret = rte_member_create_ht(setsum, params);
                break;
+       case RTE_MEMBER_TYPE_VBF:
+               ret = rte_member_create_vbf(setsum, params);
+               break;
        default:
                goto error_unlock_exit;
        }
@@ -185,8 +162,9 @@ rte_member_create(const struct rte_member_parameters *params)
        return setsum;
 
 error_unlock_exit:
+       rte_free(te);
+       rte_free(setsum);
        rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
-       rte_member_free(setsum);
        return NULL;
 }
 
@@ -200,6 +178,8 @@ rte_member_add(const struct rte_member_setsum *setsum, const void *key,
        switch (setsum->type) {
        case RTE_MEMBER_TYPE_HT:
                return rte_member_add_ht(setsum, key, set_id);
+       case RTE_MEMBER_TYPE_VBF:
+               return rte_member_add_vbf(setsum, key, set_id);
        default:
                return -EINVAL;
        }
@@ -215,6 +195,8 @@ rte_member_lookup(const struct rte_member_setsum *setsum, const void *key,
        switch (setsum->type) {
        case RTE_MEMBER_TYPE_HT:
                return rte_member_lookup_ht(setsum, key, set_id);
+       case RTE_MEMBER_TYPE_VBF:
+               return rte_member_lookup_vbf(setsum, key, set_id);
        default:
                return -EINVAL;
        }
@@ -232,6 +214,9 @@ rte_member_lookup_bulk(const struct rte_member_setsum *setsum,
        case RTE_MEMBER_TYPE_HT:
                return rte_member_lookup_bulk_ht(setsum, keys, num_keys,
                                set_ids);
+       case RTE_MEMBER_TYPE_VBF:
+               return rte_member_lookup_bulk_vbf(setsum, keys, num_keys,
+                               set_ids);
        default:
                return -EINVAL;
        }
@@ -248,6 +233,9 @@ rte_member_lookup_multi(const struct rte_member_setsum *setsum, const void *key,
        case RTE_MEMBER_TYPE_HT:
                return rte_member_lookup_multi_ht(setsum, key, match_per_key,
                                set_id);
+       case RTE_MEMBER_TYPE_VBF:
+               return rte_member_lookup_multi_vbf(setsum, key, match_per_key,
+                               set_id);
        default:
                return -EINVAL;
        }
@@ -267,6 +255,9 @@ rte_member_lookup_multi_bulk(const struct rte_member_setsum *setsum,
        case RTE_MEMBER_TYPE_HT:
                return rte_member_lookup_multi_bulk_ht(setsum, keys, num_keys,
                                max_match_per_key, match_count, set_ids);
+       case RTE_MEMBER_TYPE_VBF:
+               return rte_member_lookup_multi_bulk_vbf(setsum, keys, num_keys,
+                               max_match_per_key, match_count, set_ids);
        default:
                return -EINVAL;
        }
@@ -282,6 +273,8 @@ rte_member_delete(const struct rte_member_setsum *setsum, const void *key,
        switch (setsum->type) {
        case RTE_MEMBER_TYPE_HT:
                return rte_member_delete_ht(setsum, key, set_id);
+       /* current vBF implementation does not support delete function */
+       case RTE_MEMBER_TYPE_VBF:
        default:
                return -EINVAL;
        }
@@ -296,6 +289,9 @@ rte_member_reset(const struct rte_member_setsum *setsum)
        case RTE_MEMBER_TYPE_HT:
                rte_member_reset_ht(setsum);
                return;
+       case RTE_MEMBER_TYPE_VBF:
+               rte_member_reset_vbf(setsum);
+               return;
        default:
                return;
        }
@@ -306,7 +302,7 @@ RTE_INIT(librte_member_init_log);
 static void
 librte_member_init_log(void)
 {
-       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);
 }