aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2024-03-18 13:10:23 +0200
committerMatias Elo <matias.elo@nokia.com>2024-04-26 18:24:19 +0300
commit4f26ee8d8d753e368edb683a912a2b08f80430a4 (patch)
treedea4f6d4543c1598a8734822a4e33342e9fc1e89
parentc630889a9c367527259d49839599a74156a22dc4 (diff)
helper: remove linear table API
Remove unused linear table helper API. Signed-off-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Jere Leppänen <jere.leppanen@nokia.com>
-rw-r--r--helper/Makefile.am2
-rw-r--r--helper/include/odp/helper/odph_api.h1
-rw-r--r--helper/include/odp/helper/odph_lineartable.h101
-rw-r--r--helper/lineartable.c217
4 files changed, 0 insertions, 321 deletions
diff --git a/helper/Makefile.am b/helper/Makefile.am
index 4d24a58ed..ed5c9089a 100644
--- a/helper/Makefile.am
+++ b/helper/Makefile.am
@@ -26,7 +26,6 @@ helperinclude_HEADERS = \
include/odp/helper/macros.h\
include/odp/helper/odph_api.h\
include/odp/helper/odph_iplookuptable.h\
- include/odp/helper/odph_lineartable.h\
include/odp/helper/sctp.h \
include/odp/helper/stress.h\
include/odp/helper/string.h\
@@ -59,7 +58,6 @@ __LIB__libodphelper_la_SOURCES = \
eth.c \
ip.c \
chksum.c \
- lineartable.c \
iplookuptable.c \
ipsec.c \
threads.c \
diff --git a/helper/include/odp/helper/odph_api.h b/helper/include/odp/helper/odph_api.h
index 1e85557d7..6481f138d 100644
--- a/helper/include/odp/helper/odph_api.h
+++ b/helper/include/odp/helper/odph_api.h
@@ -28,7 +28,6 @@ extern "C" {
#include <odp/helper/ipsec.h>
#include <odp/helper/macros.h>
#include <odp/helper/stress.h>
-#include <odp/helper/odph_lineartable.h>
#include <odp/helper/odph_iplookuptable.h>
#include <odp/helper/sctp.h>
#include <odp/helper/string.h>
diff --git a/helper/include/odp/helper/odph_lineartable.h b/helper/include/odp/helper/odph_lineartable.h
deleted file mode 100644
index dc61113a5..000000000
--- a/helper/include/odp/helper/odph_lineartable.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2015-2018 Linaro Limited
- */
-
-/**
- * @file
- *
- * ODP Linear Table
- */
-
-#ifndef ODPH_LINEAR_TABLE_H_
-#define ODPH_LINEAR_TABLE_H_
-
-#include <stdint.h>
-#include <odp/helper/table.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @defgroup odph_lineartable ODPH LINEAR TABLE
- * Linear table
- *
- * @{
- */
-
-/**
- * Create a linear table
- *
- * @param name Name of the linear table to be created
- * @param capacity Number of elements table may store
- * @param ODP_IGNORED Ignored parameter
- * @param value_size Size of the value stored for each element
- *
- * @return Handle of created linear table
- * @return NULL Create failed
- */
-odph_table_t odph_linear_table_create(const char *name,
- uint32_t capacity,
- uint32_t ODP_IGNORED,
- uint32_t value_size);
-
-/**
- * Lookup a linear table
- *
- * @param name Name of the table to be located
- *
- * @return Handle of the located linear table
- * @retval NULL No table matching supplied name found
- */
-odph_table_t odph_linear_table_lookup(const char *name);
-
-/**
- * Destroy a linear table
- *
- * @param table Handle of linear table to be destroyed
- *
- * @retval 0 Success
- * @retval < 0 Failure
- */
-int odph_linear_table_destroy(odph_table_t table);
-
-/**
- * Insert a value into a linear table
- *
- * @param table Table into which value is to be stored
- * @param key Index value used as key
- * @param value Value to be assoceiated with specified key index
- *
- * @retval >= 0 Success
- * @retval < 0 Failure
- */
-int odph_linear_put_value(odph_table_t table, void *key, void *value);
-
-/**
- * Retrieve a value from a linear table
- *
- * @param table Table from which value is to be retrieved
- * @param key Index value used as key
- * @param[out] buffer Address of buffer to receive resulting value
- * @param buffer_size Size of supplied buffer
- *
- * @retval 0 Success
- * @retval 1 Success
- * @retval < 0 Failure
- */
-int odph_linear_get_value(odph_table_t table, void *key, void *buffer,
- uint32_t buffer_size);
-
-extern odph_table_ops_t odph_linear_table_ops; /**< @internal */
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/helper/lineartable.c b/helper/lineartable.c
deleted file mode 100644
index 32242a12a..000000000
--- a/helper/lineartable.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2015-2018 Linaro Limited
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <malloc.h>
-
-#include <odp/helper/odph_lineartable.h>
-#include <odp/helper/odph_debug.h>
-#include <odp/helper/string.h>
-#include <odp_api.h>
-
-#define ODPH_SUCCESS 0
-#define ODPH_FAIL -1
-
-/** @magic word, write to the first byte of the memory block
- * to indicate this block is used by a linear table structure
- */
-#define ODPH_LINEAR_TABLE_MAGIC_WORD 0xEFEFFEFE
-
-/** @internal table struct
- * For linear table, value is orgnized as a big array,
- * and key is the index of this array, so we just need to record the
- * content of value, and make sure the key won't overflow
- */
-typedef struct {
- uint32_t magicword; /**< for check */
- uint32_t init_cap; /**< input param of capacity */
- /** given the capacity, calculate out the max supported nodes number */
- uint32_t node_sum;
- /** size of a lineartable element,including the rwlock in the head */
- uint32_t value_size;
- void *value_array; /**< value pool in array format */
- char name[ODPH_TABLE_NAME_LEN]; /**< name of the table */
-} odph_linear_table_imp;
-
-/** Note: for linear table, key must be an number, its size is fixed 4.
- * So, we ignore the input key_size here
- */
-
-odph_table_t odph_linear_table_create(const char *name, uint32_t capacity,
- uint32_t un ODP_UNUSED,
- uint32_t value_size)
-{
- uint32_t idx;
- uint32_t node_num;
- odp_shm_t shmem;
- odph_linear_table_imp *tbl;
-
- if (strlen(name) >= ODPH_TABLE_NAME_LEN || capacity < 1 ||
- capacity >= 0x1000 || value_size == 0) {
- printf("create para input error or less than !");
- return NULL;
- }
- /* check name conflict in shm*/
- if (odp_shm_lookup(name) != ODP_SHM_INVALID) {
- ODPH_DBG("name already exist\n");
- return NULL;
- }
-
- /* alloc memory from shm */
- shmem = odp_shm_reserve(name, capacity << 20, 64, 0);
- if (shmem == ODP_SHM_INVALID) {
- ODPH_DBG("shm reserve fail\n");
- return NULL;
- }
- tbl = (odph_linear_table_imp *)odp_shm_addr(shmem);
-
- /* clean this block of memory */
- memset(tbl, 0, capacity << 20);
-
- tbl->init_cap = capacity < 20;
-
- odph_strcpy(tbl->name, name, ODPH_TABLE_NAME_LEN);
-
- /* for linear table, the key is just the index, without conflict
- * so we just need to record the value content
- * there is a rwlock in the head of every node
- */
-
- tbl->value_size = value_size + sizeof(odp_rwlock_t);
-
- node_num = tbl->init_cap / tbl->value_size;
- tbl->node_sum = node_num;
-
- tbl->value_array = (void *)((char *)tbl
- + sizeof(odph_linear_table_imp));
-
- /* initialize rwlock*/
- for (idx = 0; idx < tbl->node_sum; idx++) {
- odp_rwlock_t *lock;
-
- lock = (odp_rwlock_t *)(void *)((char *)tbl->value_array
- + idx * tbl->value_size);
- odp_rwlock_init(lock);
- }
-
- tbl->magicword = ODPH_LINEAR_TABLE_MAGIC_WORD;
-
- return (odph_table_t)(tbl);
-}
-
-int odph_linear_table_destroy(odph_table_t table)
-{
- int ret;
- odph_linear_table_imp *linear_tbl = NULL;
-
- if (table != NULL) {
- linear_tbl = (odph_linear_table_imp *)(void *)table;
-
- /* check magicword, make sure the memory is used by a table */
- if (linear_tbl->magicword != ODPH_LINEAR_TABLE_MAGIC_WORD)
- return ODPH_FAIL;
-
- ret = odp_shm_free(odp_shm_lookup(linear_tbl->name));
- if (ret != 0) {
- ODPH_DBG("free fail\n");
- return ret;
- }
-
- return ODPH_SUCCESS;
- }
- return ODPH_FAIL;
-}
-
-odph_table_t odph_linear_table_lookup(const char *name)
-{
- odph_linear_table_imp *tbl = NULL;
- odp_shm_t shm;
-
- if (name == NULL || strlen(name) >= ODPH_TABLE_NAME_LEN)
- return NULL;
-
- shm = odp_shm_lookup(name);
- if (shm != ODP_SHM_INVALID)
- tbl = (odph_linear_table_imp *)odp_shm_addr(shm);
-
- /* check magicword to make sure the memory block is used by a table */
- if (tbl != NULL &&
- tbl->magicword == ODPH_LINEAR_TABLE_MAGIC_WORD &&
- strcmp(tbl->name, name) == 0)
- return (odph_table_t)tbl;
-
- return NULL;
-}
-
-/* should make sure the input table exists and is available */
-static int odph_lineartable_put_value(odph_table_t table,
- void *key, void *value)
-{
- odph_linear_table_imp *tbl;
- uint32_t ikey = 0;
- void *entry = NULL;
- odp_rwlock_t *lock = NULL;
-
- if (table == NULL || key == NULL || value == NULL)
- return ODPH_FAIL;
-
- tbl = (odph_linear_table_imp *)(void *)table;
- ikey = *(uint32_t *)key;
- if (ikey >= tbl->node_sum)
- return ODPH_FAIL;
-
- entry = (void *)((char *)tbl->value_array + ikey * tbl->value_size);
- lock = (odp_rwlock_t *)entry;
- entry = (char *)entry + sizeof(odp_rwlock_t);
-
- odp_rwlock_write_lock(lock);
-
- memcpy(entry, value, tbl->value_size - sizeof(odp_rwlock_t));
-
- odp_rwlock_write_unlock(lock);
-
- return ODPH_SUCCESS;
-}
-
-/* should make sure the input table exists and is available */
-static int odph_lineartable_get_value(odph_table_t table,
- void *key, void *buffer,
- uint32_t buffer_size ODP_UNUSED)
-{
- odph_linear_table_imp *tbl;
- uint32_t ikey = 0;
- void *entry = NULL;
- odp_rwlock_t *lock = NULL;
-
- if (table == NULL || key == NULL || buffer == NULL)
- return ODPH_FAIL;
-
- tbl = (odph_linear_table_imp *)(void *)table;
- ikey = *(uint32_t *)key;
- if (ikey >= tbl->node_sum)
- return ODPH_FAIL;
-
- entry = (void *)((char *)tbl->value_array + ikey * tbl->value_size);
- lock = (odp_rwlock_t *)entry;
- entry = (char *)entry + sizeof(odp_rwlock_t);
-
- odp_rwlock_read_lock(lock);
-
- memcpy(buffer, entry, tbl->value_size - sizeof(odp_rwlock_t));
-
- odp_rwlock_read_unlock(lock);
-
- return ODPH_SUCCESS;
-}
-
-odph_table_ops_t odph_linear_table_ops = {
- odph_linear_table_create,
- odph_linear_table_lookup,
- odph_linear_table_destroy,
- odph_lineartable_put_value,
- odph_lineartable_get_value,
- NULL,
- };
-