2017-12-19 15:49:03 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
* Copyright(c) 2017 Intel Corporation
|
2017-10-04 03:12:19 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2019-04-03 14:45:05 +00:00
|
|
|
#include <rte_string_fns.h>
|
2017-10-04 03:12:19 +00:00
|
|
|
#include <rte_eal.h>
|
|
|
|
#include <rte_eal_memconfig.h>
|
|
|
|
#include <rte_memory.h>
|
|
|
|
#include <rte_malloc.h>
|
|
|
|
#include <rte_errno.h>
|
2019-07-05 13:10:30 +00:00
|
|
|
#include <rte_tailq.h>
|
2017-10-04 03:12:19 +00:00
|
|
|
|
|
|
|
#include "rte_member.h"
|
member: implement HT mode
One of the set-summary structures is hash-table based
set-summary (HTSS). One example is cuckoo filter [1].
Comparing to a traditional hash table, HTSS has a much more
compact structure. For each element, only one signature and
its corresponding set ID is stored. No key comparison is required
during lookup. For the table structure, there are multiple entries
in each bucket, and the table is composed of many buckets.
Two modes are supported for HTSS, "cache" and "none-cache" modes.
The non-cache mode is similar to the cuckoo filter [1].
When a bucket is full, one entry will be evicted to its
alternative bucket to make space for the new key. The table could
be full and then no more keys could be inserted. This mode has
false-positive rate but no false-negative. Multiple entries
with same signature could stay in the same bucket.
The "cache" mode does not evict key to its alternative bucket
when a bucket is full, an existing key will be evicted out of
the table like a cache. Thus, the table will never reject keys when
it is full. Another property is in each bucket, there cannot be
multiple entries with same signature. The mode could have both
false-positive and false-negative probability.
This patch adds the implementation of HTSS.
[1] B Fan, D G Andersen and M Kaminsky, “Cuckoo Filter: Practically
Better Than Bloom,” in Conference on emerging Networking
Experiments and Technologies, 2014.
Signed-off-by: Yipeng Wang <yipeng1.wang@intel.com>
Reviewed-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
2017-10-04 03:12:20 +00:00
|
|
|
#include "rte_member_ht.h"
|
2017-10-04 03:12:21 +00:00
|
|
|
#include "rte_member_vbf.h"
|
2017-10-04 03:12:19 +00:00
|
|
|
|
|
|
|
TAILQ_HEAD(rte_member_list, rte_tailq_entry);
|
|
|
|
static struct rte_tailq_elem rte_member_tailq = {
|
|
|
|
.name = "RTE_MEMBER",
|
|
|
|
};
|
|
|
|
EAL_REGISTER_TAILQ(rte_member_tailq)
|
|
|
|
|
|
|
|
struct rte_member_setsum *
|
|
|
|
rte_member_find_existing(const char *name)
|
|
|
|
{
|
|
|
|
struct rte_member_setsum *setsum = NULL;
|
|
|
|
struct rte_tailq_entry *te;
|
|
|
|
struct rte_member_list *member_list;
|
|
|
|
|
|
|
|
member_list = RTE_TAILQ_CAST(rte_member_tailq.head, rte_member_list);
|
|
|
|
|
2019-07-05 13:10:28 +00:00
|
|
|
rte_mcfg_tailq_read_lock();
|
2017-10-04 03:12:19 +00:00
|
|
|
TAILQ_FOREACH(te, member_list, next) {
|
|
|
|
setsum = (struct rte_member_setsum *) te->data;
|
|
|
|
if (strncmp(name, setsum->name, RTE_MEMBER_NAMESIZE) == 0)
|
|
|
|
break;
|
|
|
|
}
|
2019-07-05 13:10:28 +00:00
|
|
|
rte_mcfg_tailq_read_unlock();
|
2017-10-04 03:12:19 +00:00
|
|
|
|
|
|
|
if (te == NULL) {
|
|
|
|
rte_errno = ENOENT;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return setsum;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
rte_member_free(struct rte_member_setsum *setsum)
|
|
|
|
{
|
|
|
|
struct rte_member_list *member_list;
|
|
|
|
struct rte_tailq_entry *te;
|
|
|
|
|
|
|
|
if (setsum == NULL)
|
|
|
|
return;
|
|
|
|
member_list = RTE_TAILQ_CAST(rte_member_tailq.head, rte_member_list);
|
2019-07-05 13:10:28 +00:00
|
|
|
rte_mcfg_tailq_write_lock();
|
2017-10-04 03:12:19 +00:00
|
|
|
TAILQ_FOREACH(te, member_list, next) {
|
|
|
|
if (te->data == (void *)setsum)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (te == NULL) {
|
2019-07-05 13:10:28 +00:00
|
|
|
rte_mcfg_tailq_write_unlock();
|
2017-10-04 03:12:19 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
TAILQ_REMOVE(member_list, te, next);
|
2019-07-05 13:10:28 +00:00
|
|
|
rte_mcfg_tailq_write_unlock();
|
2017-10-04 03:12:19 +00:00
|
|
|
|
|
|
|
switch (setsum->type) {
|
member: implement HT mode
One of the set-summary structures is hash-table based
set-summary (HTSS). One example is cuckoo filter [1].
Comparing to a traditional hash table, HTSS has a much more
compact structure. For each element, only one signature and
its corresponding set ID is stored. No key comparison is required
during lookup. For the table structure, there are multiple entries
in each bucket, and the table is composed of many buckets.
Two modes are supported for HTSS, "cache" and "none-cache" modes.
The non-cache mode is similar to the cuckoo filter [1].
When a bucket is full, one entry will be evicted to its
alternative bucket to make space for the new key. The table could
be full and then no more keys could be inserted. This mode has
false-positive rate but no false-negative. Multiple entries
with same signature could stay in the same bucket.
The "cache" mode does not evict key to its alternative bucket
when a bucket is full, an existing key will be evicted out of
the table like a cache. Thus, the table will never reject keys when
it is full. Another property is in each bucket, there cannot be
multiple entries with same signature. The mode could have both
false-positive and false-negative probability.
This patch adds the implementation of HTSS.
[1] B Fan, D G Andersen and M Kaminsky, “Cuckoo Filter: Practically
Better Than Bloom,” in Conference on emerging Networking
Experiments and Technologies, 2014.
Signed-off-by: Yipeng Wang <yipeng1.wang@intel.com>
Reviewed-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
2017-10-04 03:12:20 +00:00
|
|
|
case RTE_MEMBER_TYPE_HT:
|
|
|
|
rte_member_free_ht(setsum);
|
|
|
|
break;
|
2017-10-04 03:12:21 +00:00
|
|
|
case RTE_MEMBER_TYPE_VBF:
|
|
|
|
rte_member_free_vbf(setsum);
|
|
|
|
break;
|
2017-10-04 03:12:19 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
rte_free(setsum);
|
|
|
|
rte_free(te);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct rte_member_setsum *
|
|
|
|
rte_member_create(const struct rte_member_parameters *params)
|
|
|
|
{
|
|
|
|
struct rte_tailq_entry *te;
|
|
|
|
struct rte_member_list *member_list;
|
|
|
|
struct rte_member_setsum *setsum;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (params == NULL) {
|
|
|
|
rte_errno = EINVAL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (params->key_len == 0 ||
|
|
|
|
params->prim_hash_seed == params->sec_hash_seed) {
|
|
|
|
rte_errno = EINVAL;
|
|
|
|
RTE_MEMBER_LOG(ERR, "Create setsummary with "
|
|
|
|
"invalid parameters\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
member_list = RTE_TAILQ_CAST(rte_member_tailq.head, rte_member_list);
|
|
|
|
|
2019-07-05 13:10:28 +00:00
|
|
|
rte_mcfg_tailq_write_lock();
|
2017-10-04 03:12:19 +00:00
|
|
|
|
|
|
|
TAILQ_FOREACH(te, member_list, next) {
|
2018-01-15 07:55:06 +00:00
|
|
|
setsum = te->data;
|
2017-10-04 03:12:19 +00:00
|
|
|
if (strncmp(params->name, setsum->name,
|
|
|
|
RTE_MEMBER_NAMESIZE) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
setsum = NULL;
|
|
|
|
if (te != NULL) {
|
|
|
|
rte_errno = EEXIST;
|
|
|
|
te = NULL;
|
|
|
|
goto error_unlock_exit;
|
|
|
|
}
|
|
|
|
te = rte_zmalloc("MEMBER_TAILQ_ENTRY", sizeof(*te), 0);
|
|
|
|
if (te == NULL) {
|
|
|
|
RTE_MEMBER_LOG(ERR, "tailq entry allocation failed\n");
|
|
|
|
goto error_unlock_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create a new setsum structure */
|
2018-01-15 07:55:06 +00:00
|
|
|
setsum = rte_zmalloc_socket(params->name,
|
2017-10-04 03:12:19 +00:00
|
|
|
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;
|
|
|
|
}
|
2019-04-03 14:45:05 +00:00
|
|
|
strlcpy(setsum->name, params->name, sizeof(setsum->name));
|
2017-10-04 03:12:19 +00:00
|
|
|
setsum->type = params->type;
|
|
|
|
setsum->socket_id = params->socket_id;
|
|
|
|
setsum->key_len = params->key_len;
|
|
|
|
setsum->num_set = params->num_set;
|
|
|
|
setsum->prim_hash_seed = params->prim_hash_seed;
|
|
|
|
setsum->sec_hash_seed = params->sec_hash_seed;
|
|
|
|
|
|
|
|
switch (setsum->type) {
|
member: implement HT mode
One of the set-summary structures is hash-table based
set-summary (HTSS). One example is cuckoo filter [1].
Comparing to a traditional hash table, HTSS has a much more
compact structure. For each element, only one signature and
its corresponding set ID is stored. No key comparison is required
during lookup. For the table structure, there are multiple entries
in each bucket, and the table is composed of many buckets.
Two modes are supported for HTSS, "cache" and "none-cache" modes.
The non-cache mode is similar to the cuckoo filter [1].
When a bucket is full, one entry will be evicted to its
alternative bucket to make space for the new key. The table could
be full and then no more keys could be inserted. This mode has
false-positive rate but no false-negative. Multiple entries
with same signature could stay in the same bucket.
The "cache" mode does not evict key to its alternative bucket
when a bucket is full, an existing key will be evicted out of
the table like a cache. Thus, the table will never reject keys when
it is full. Another property is in each bucket, there cannot be
multiple entries with same signature. The mode could have both
false-positive and false-negative probability.
This patch adds the implementation of HTSS.
[1] B Fan, D G Andersen and M Kaminsky, “Cuckoo Filter: Practically
Better Than Bloom,” in Conference on emerging Networking
Experiments and Technologies, 2014.
Signed-off-by: Yipeng Wang <yipeng1.wang@intel.com>
Reviewed-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
2017-10-04 03:12:20 +00:00
|
|
|
case RTE_MEMBER_TYPE_HT:
|
|
|
|
ret = rte_member_create_ht(setsum, params);
|
|
|
|
break;
|
2017-10-04 03:12:21 +00:00
|
|
|
case RTE_MEMBER_TYPE_VBF:
|
|
|
|
ret = rte_member_create_vbf(setsum, params);
|
|
|
|
break;
|
2017-10-04 03:12:19 +00:00
|
|
|
default:
|
|
|
|
goto error_unlock_exit;
|
|
|
|
}
|
|
|
|
if (ret < 0)
|
|
|
|
goto error_unlock_exit;
|
|
|
|
|
|
|
|
RTE_MEMBER_LOG(DEBUG, "Creating a setsummary table with "
|
|
|
|
"mode %u\n", setsum->type);
|
|
|
|
|
|
|
|
te->data = (void *)setsum;
|
|
|
|
TAILQ_INSERT_TAIL(member_list, te, next);
|
2019-07-05 13:10:28 +00:00
|
|
|
rte_mcfg_tailq_write_unlock();
|
2017-10-04 03:12:19 +00:00
|
|
|
return setsum;
|
|
|
|
|
|
|
|
error_unlock_exit:
|
2018-01-12 17:23:16 +00:00
|
|
|
rte_free(te);
|
|
|
|
rte_free(setsum);
|
2019-07-05 13:10:28 +00:00
|
|
|
rte_mcfg_tailq_write_unlock();
|
2017-10-04 03:12:19 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
rte_member_add(const struct rte_member_setsum *setsum, const void *key,
|
|
|
|
member_set_t set_id)
|
|
|
|
{
|
|
|
|
if (setsum == NULL || key == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
switch (setsum->type) {
|
member: implement HT mode
One of the set-summary structures is hash-table based
set-summary (HTSS). One example is cuckoo filter [1].
Comparing to a traditional hash table, HTSS has a much more
compact structure. For each element, only one signature and
its corresponding set ID is stored. No key comparison is required
during lookup. For the table structure, there are multiple entries
in each bucket, and the table is composed of many buckets.
Two modes are supported for HTSS, "cache" and "none-cache" modes.
The non-cache mode is similar to the cuckoo filter [1].
When a bucket is full, one entry will be evicted to its
alternative bucket to make space for the new key. The table could
be full and then no more keys could be inserted. This mode has
false-positive rate but no false-negative. Multiple entries
with same signature could stay in the same bucket.
The "cache" mode does not evict key to its alternative bucket
when a bucket is full, an existing key will be evicted out of
the table like a cache. Thus, the table will never reject keys when
it is full. Another property is in each bucket, there cannot be
multiple entries with same signature. The mode could have both
false-positive and false-negative probability.
This patch adds the implementation of HTSS.
[1] B Fan, D G Andersen and M Kaminsky, “Cuckoo Filter: Practically
Better Than Bloom,” in Conference on emerging Networking
Experiments and Technologies, 2014.
Signed-off-by: Yipeng Wang <yipeng1.wang@intel.com>
Reviewed-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
2017-10-04 03:12:20 +00:00
|
|
|
case RTE_MEMBER_TYPE_HT:
|
|
|
|
return rte_member_add_ht(setsum, key, set_id);
|
2017-10-04 03:12:21 +00:00
|
|
|
case RTE_MEMBER_TYPE_VBF:
|
|
|
|
return rte_member_add_vbf(setsum, key, set_id);
|
2017-10-04 03:12:19 +00:00
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
rte_member_lookup(const struct rte_member_setsum *setsum, const void *key,
|
|
|
|
member_set_t *set_id)
|
|
|
|
{
|
|
|
|
if (setsum == NULL || key == NULL || set_id == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
switch (setsum->type) {
|
member: implement HT mode
One of the set-summary structures is hash-table based
set-summary (HTSS). One example is cuckoo filter [1].
Comparing to a traditional hash table, HTSS has a much more
compact structure. For each element, only one signature and
its corresponding set ID is stored. No key comparison is required
during lookup. For the table structure, there are multiple entries
in each bucket, and the table is composed of many buckets.
Two modes are supported for HTSS, "cache" and "none-cache" modes.
The non-cache mode is similar to the cuckoo filter [1].
When a bucket is full, one entry will be evicted to its
alternative bucket to make space for the new key. The table could
be full and then no more keys could be inserted. This mode has
false-positive rate but no false-negative. Multiple entries
with same signature could stay in the same bucket.
The "cache" mode does not evict key to its alternative bucket
when a bucket is full, an existing key will be evicted out of
the table like a cache. Thus, the table will never reject keys when
it is full. Another property is in each bucket, there cannot be
multiple entries with same signature. The mode could have both
false-positive and false-negative probability.
This patch adds the implementation of HTSS.
[1] B Fan, D G Andersen and M Kaminsky, “Cuckoo Filter: Practically
Better Than Bloom,” in Conference on emerging Networking
Experiments and Technologies, 2014.
Signed-off-by: Yipeng Wang <yipeng1.wang@intel.com>
Reviewed-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
2017-10-04 03:12:20 +00:00
|
|
|
case RTE_MEMBER_TYPE_HT:
|
|
|
|
return rte_member_lookup_ht(setsum, key, set_id);
|
2017-10-04 03:12:21 +00:00
|
|
|
case RTE_MEMBER_TYPE_VBF:
|
|
|
|
return rte_member_lookup_vbf(setsum, key, set_id);
|
2017-10-04 03:12:19 +00:00
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
rte_member_lookup_bulk(const struct rte_member_setsum *setsum,
|
|
|
|
const void **keys, uint32_t num_keys,
|
|
|
|
member_set_t *set_ids)
|
|
|
|
{
|
|
|
|
if (setsum == NULL || keys == NULL || set_ids == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
switch (setsum->type) {
|
member: implement HT mode
One of the set-summary structures is hash-table based
set-summary (HTSS). One example is cuckoo filter [1].
Comparing to a traditional hash table, HTSS has a much more
compact structure. For each element, only one signature and
its corresponding set ID is stored. No key comparison is required
during lookup. For the table structure, there are multiple entries
in each bucket, and the table is composed of many buckets.
Two modes are supported for HTSS, "cache" and "none-cache" modes.
The non-cache mode is similar to the cuckoo filter [1].
When a bucket is full, one entry will be evicted to its
alternative bucket to make space for the new key. The table could
be full and then no more keys could be inserted. This mode has
false-positive rate but no false-negative. Multiple entries
with same signature could stay in the same bucket.
The "cache" mode does not evict key to its alternative bucket
when a bucket is full, an existing key will be evicted out of
the table like a cache. Thus, the table will never reject keys when
it is full. Another property is in each bucket, there cannot be
multiple entries with same signature. The mode could have both
false-positive and false-negative probability.
This patch adds the implementation of HTSS.
[1] B Fan, D G Andersen and M Kaminsky, “Cuckoo Filter: Practically
Better Than Bloom,” in Conference on emerging Networking
Experiments and Technologies, 2014.
Signed-off-by: Yipeng Wang <yipeng1.wang@intel.com>
Reviewed-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
2017-10-04 03:12:20 +00:00
|
|
|
case RTE_MEMBER_TYPE_HT:
|
|
|
|
return rte_member_lookup_bulk_ht(setsum, keys, num_keys,
|
|
|
|
set_ids);
|
2017-10-04 03:12:21 +00:00
|
|
|
case RTE_MEMBER_TYPE_VBF:
|
|
|
|
return rte_member_lookup_bulk_vbf(setsum, keys, num_keys,
|
|
|
|
set_ids);
|
2017-10-04 03:12:19 +00:00
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
rte_member_lookup_multi(const struct rte_member_setsum *setsum, const void *key,
|
|
|
|
uint32_t match_per_key, member_set_t *set_id)
|
|
|
|
{
|
|
|
|
if (setsum == NULL || key == NULL || set_id == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
switch (setsum->type) {
|
member: implement HT mode
One of the set-summary structures is hash-table based
set-summary (HTSS). One example is cuckoo filter [1].
Comparing to a traditional hash table, HTSS has a much more
compact structure. For each element, only one signature and
its corresponding set ID is stored. No key comparison is required
during lookup. For the table structure, there are multiple entries
in each bucket, and the table is composed of many buckets.
Two modes are supported for HTSS, "cache" and "none-cache" modes.
The non-cache mode is similar to the cuckoo filter [1].
When a bucket is full, one entry will be evicted to its
alternative bucket to make space for the new key. The table could
be full and then no more keys could be inserted. This mode has
false-positive rate but no false-negative. Multiple entries
with same signature could stay in the same bucket.
The "cache" mode does not evict key to its alternative bucket
when a bucket is full, an existing key will be evicted out of
the table like a cache. Thus, the table will never reject keys when
it is full. Another property is in each bucket, there cannot be
multiple entries with same signature. The mode could have both
false-positive and false-negative probability.
This patch adds the implementation of HTSS.
[1] B Fan, D G Andersen and M Kaminsky, “Cuckoo Filter: Practically
Better Than Bloom,” in Conference on emerging Networking
Experiments and Technologies, 2014.
Signed-off-by: Yipeng Wang <yipeng1.wang@intel.com>
Reviewed-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
2017-10-04 03:12:20 +00:00
|
|
|
case RTE_MEMBER_TYPE_HT:
|
|
|
|
return rte_member_lookup_multi_ht(setsum, key, match_per_key,
|
|
|
|
set_id);
|
2017-10-04 03:12:21 +00:00
|
|
|
case RTE_MEMBER_TYPE_VBF:
|
|
|
|
return rte_member_lookup_multi_vbf(setsum, key, match_per_key,
|
|
|
|
set_id);
|
2017-10-04 03:12:19 +00:00
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
rte_member_lookup_multi_bulk(const struct rte_member_setsum *setsum,
|
|
|
|
const void **keys, uint32_t num_keys,
|
|
|
|
uint32_t max_match_per_key, uint32_t *match_count,
|
|
|
|
member_set_t *set_ids)
|
|
|
|
{
|
|
|
|
if (setsum == NULL || keys == NULL || set_ids == NULL ||
|
|
|
|
match_count == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
switch (setsum->type) {
|
member: implement HT mode
One of the set-summary structures is hash-table based
set-summary (HTSS). One example is cuckoo filter [1].
Comparing to a traditional hash table, HTSS has a much more
compact structure. For each element, only one signature and
its corresponding set ID is stored. No key comparison is required
during lookup. For the table structure, there are multiple entries
in each bucket, and the table is composed of many buckets.
Two modes are supported for HTSS, "cache" and "none-cache" modes.
The non-cache mode is similar to the cuckoo filter [1].
When a bucket is full, one entry will be evicted to its
alternative bucket to make space for the new key. The table could
be full and then no more keys could be inserted. This mode has
false-positive rate but no false-negative. Multiple entries
with same signature could stay in the same bucket.
The "cache" mode does not evict key to its alternative bucket
when a bucket is full, an existing key will be evicted out of
the table like a cache. Thus, the table will never reject keys when
it is full. Another property is in each bucket, there cannot be
multiple entries with same signature. The mode could have both
false-positive and false-negative probability.
This patch adds the implementation of HTSS.
[1] B Fan, D G Andersen and M Kaminsky, “Cuckoo Filter: Practically
Better Than Bloom,” in Conference on emerging Networking
Experiments and Technologies, 2014.
Signed-off-by: Yipeng Wang <yipeng1.wang@intel.com>
Reviewed-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
2017-10-04 03:12:20 +00:00
|
|
|
case RTE_MEMBER_TYPE_HT:
|
|
|
|
return rte_member_lookup_multi_bulk_ht(setsum, keys, num_keys,
|
|
|
|
max_match_per_key, match_count, set_ids);
|
2017-10-04 03:12:21 +00:00
|
|
|
case RTE_MEMBER_TYPE_VBF:
|
|
|
|
return rte_member_lookup_multi_bulk_vbf(setsum, keys, num_keys,
|
|
|
|
max_match_per_key, match_count, set_ids);
|
2017-10-04 03:12:19 +00:00
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
rte_member_delete(const struct rte_member_setsum *setsum, const void *key,
|
|
|
|
member_set_t set_id)
|
|
|
|
{
|
|
|
|
if (setsum == NULL || key == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
switch (setsum->type) {
|
member: implement HT mode
One of the set-summary structures is hash-table based
set-summary (HTSS). One example is cuckoo filter [1].
Comparing to a traditional hash table, HTSS has a much more
compact structure. For each element, only one signature and
its corresponding set ID is stored. No key comparison is required
during lookup. For the table structure, there are multiple entries
in each bucket, and the table is composed of many buckets.
Two modes are supported for HTSS, "cache" and "none-cache" modes.
The non-cache mode is similar to the cuckoo filter [1].
When a bucket is full, one entry will be evicted to its
alternative bucket to make space for the new key. The table could
be full and then no more keys could be inserted. This mode has
false-positive rate but no false-negative. Multiple entries
with same signature could stay in the same bucket.
The "cache" mode does not evict key to its alternative bucket
when a bucket is full, an existing key will be evicted out of
the table like a cache. Thus, the table will never reject keys when
it is full. Another property is in each bucket, there cannot be
multiple entries with same signature. The mode could have both
false-positive and false-negative probability.
This patch adds the implementation of HTSS.
[1] B Fan, D G Andersen and M Kaminsky, “Cuckoo Filter: Practically
Better Than Bloom,” in Conference on emerging Networking
Experiments and Technologies, 2014.
Signed-off-by: Yipeng Wang <yipeng1.wang@intel.com>
Reviewed-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
2017-10-04 03:12:20 +00:00
|
|
|
case RTE_MEMBER_TYPE_HT:
|
|
|
|
return rte_member_delete_ht(setsum, key, set_id);
|
2017-10-04 03:12:21 +00:00
|
|
|
/* current vBF implementation does not support delete function */
|
|
|
|
case RTE_MEMBER_TYPE_VBF:
|
2017-10-04 03:12:19 +00:00
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
rte_member_reset(const struct rte_member_setsum *setsum)
|
|
|
|
{
|
|
|
|
if (setsum == NULL)
|
|
|
|
return;
|
|
|
|
switch (setsum->type) {
|
member: implement HT mode
One of the set-summary structures is hash-table based
set-summary (HTSS). One example is cuckoo filter [1].
Comparing to a traditional hash table, HTSS has a much more
compact structure. For each element, only one signature and
its corresponding set ID is stored. No key comparison is required
during lookup. For the table structure, there are multiple entries
in each bucket, and the table is composed of many buckets.
Two modes are supported for HTSS, "cache" and "none-cache" modes.
The non-cache mode is similar to the cuckoo filter [1].
When a bucket is full, one entry will be evicted to its
alternative bucket to make space for the new key. The table could
be full and then no more keys could be inserted. This mode has
false-positive rate but no false-negative. Multiple entries
with same signature could stay in the same bucket.
The "cache" mode does not evict key to its alternative bucket
when a bucket is full, an existing key will be evicted out of
the table like a cache. Thus, the table will never reject keys when
it is full. Another property is in each bucket, there cannot be
multiple entries with same signature. The mode could have both
false-positive and false-negative probability.
This patch adds the implementation of HTSS.
[1] B Fan, D G Andersen and M Kaminsky, “Cuckoo Filter: Practically
Better Than Bloom,” in Conference on emerging Networking
Experiments and Technologies, 2014.
Signed-off-by: Yipeng Wang <yipeng1.wang@intel.com>
Reviewed-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
2017-10-04 03:12:20 +00:00
|
|
|
case RTE_MEMBER_TYPE_HT:
|
|
|
|
rte_member_reset_ht(setsum);
|
|
|
|
return;
|
2017-10-04 03:12:21 +00:00
|
|
|
case RTE_MEMBER_TYPE_VBF:
|
|
|
|
rte_member_reset_vbf(setsum);
|
|
|
|
return;
|
2017-10-04 03:12:19 +00:00
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-01 12:33:35 +00:00
|
|
|
RTE_LOG_REGISTER(librte_member_logtype, lib.member, DEBUG);
|