On 10/16/2015 12:35, huanggaoyang wrote:
Signed-off-by: huanggaoyang <[email protected]>
---
  helper/include/odp/helper/table.h | 199 ++++++++++++++++++++++++++++++++++++++
  1 file changed, 199 insertions(+)
  create mode 100644 helper/include/odp/helper/table.h

diff --git a/helper/include/odp/helper/table.h 
b/helper/include/odp/helper/table.h
new file mode 100644
index 0000000..891b115
--- /dev/null
+++ b/helper/include/odp/helper/table.h
@@ -0,0 +1,199 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2013 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.
+ */

This file provides ODP api. How is above Intel copyright related to it?

Maxim.

+
+/**
+ * @file
+ *
+ * ODP table
+ *
+ * Table designed to provide a standard interface to implement different
+ * types of tables for data processing.
+ * Use case:
+ * Table is publicly used in the following scenarios in data plane:
+ * ARP Table, IP Routing Table, MAC address filtering, ACL, interworking etc.
+ * The features of the "table":
+ * 1) All these different types of "table" have the common operations:
+ *    Create a table, destroy a table, add an entry (key/value pairs),
+ *    delete an entry, and lookup the value via the key.
+ *    Usually these operations are software based, but also can be
+ *    hardware accelerated if cost, power consumption are not the concern
+ *    in your platform.
+ * 2) Different types of "table" can use different algorithms to
+ *    add/delete/lookup the entry.
+ *
+ */
+
+#ifndef ODPH_TABLE_H_
+#define ODPH_TABLE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define ODPH_TABLE_NAME_LEN      32
+
+typedef ODP_HANDLE_T(odph_table_t);
+
+/**
+* create a table
+* Generally, tables only support key-value pair both with fixed size
+*
+* @param name
+*    name of this table, max ODPH_TABLE_NAME_LEN - 1
+*    May be specified as NULL for anonymous table
+* @param capacity
+*    Max memory usage this table use, in MBytes
+* @param key_size
+*    fixed size of the 'key' in bytes.
+* @param value_size
+*    fixed size of the 'value' in bytes.
+* @return
+*   Handle to table instance or NULL if failed
+* @note
+*/
+typedef odph_table_t (*odph_table_create)(const char *name,
+                                               uint32_t capacity,
+                                               uint32_t key_size,
+                                               uint32_t value_size);
+
+/**
+ * Find a table by name
+ *
+ * @param name:      Name of the table
+ *
+ * @return Handle of found table
+ * @retval NULL  table could not be found
+ *
+ * @note
+ *     This routine cannot be used to look up an anonymous
+ *     table (one created with no name).
+ *     This API supports Multiprocess
+ */
+typedef odph_table_t (*odph_table_lookup)(const char *name);
+
+/**
+ * Destroy a table previously created by odph_table_create()
+ *
+ * @param table: Handle of the table to be destroyed
+ *
+ * @retval 0 Success
+ * @retval -1 Failure
+ *
+ * @note
+ *       This routine destroys a previously created pool
+ *       also should free any memory allocated at creation
+ *
+ */
+typedef int (*odph_table_destroy)(odph_table_t table);
+
+/**
+ * table element add
+ *
+ * @param table:    Handle of the table that the element be added
+ *
+ * @param key : address of 'key' in key-value pair.
+ *              User should make sure the address and 'key_size' bytes after
+ *              are accessible
+ * @param value : address of 'value' in key-value pair
+ *              User should make sure the address and 'value_size' bytes after
+ *              are accessible
+ * @retval 0 Success
+ * @retval -1 Failure
+ *
+ * @note: Add a same key again with a new value, the older one will be covered.
+ *        This API supports Multiprocess
+ */
+typedef int (*odph_table_put_value)(odph_table_t table, void *key,
+                                                       void *value);
+
+/**
+ * table element lookup
+ *
+ * @param table: Handle of the table that the element be added
+ *
+ * @param key : address of 'key' in key-value pair
+ *              User should make sure the address and key_size bytes after
+ *              are accessible
+ *
+ * @param buffer : output The buffer address to the 'value'
+ *                 After successfully found, the content of 'value' will be
+ *                 copied to this address
+ *                 User should make sure the address and value_size bytes after
+ *                 are accessible
+ * @param buffer_size: size of the buffer
+ *                     should be equal or bigger than value_size
+ * @retval 0 Success
+ * @retval -1 Failure
+ *
+ * @note: This API supports Multiprocess
+ */
+typedef int (*odph_table_get_value)(odph_table_t table, void *key,
+                                               void *buffer,
+                                               uint32_t buffer_size);
+/**
+ * table element remove
+ *
+ * @param table: Handle of the table that the element will be removed from
+ *
+ * @param key : address of 'key' in key-value pair
+ *              User should make sure the address and key_size bytes after
+ *              are accessible
+ *
+ * @retval 0 Success
+ * @retval -1 Failure
+ *
+ * @note: This API supports Multiprocess
+ */
+typedef int (*odph_table_remove_value)(odph_table_t table, void *key);
+
+typedef struct odp_table_ops {
+       odph_table_create        f_create;       /**< Table Create */
+       odph_table_lookup        f_lookup;       /**< Table Lookup */
+       odph_table_destroy       f_des;          /**< Table Destroy */
+       odph_table_put_value     f_put;          /**< Value Put */
+       odph_table_get_value     f_get;          /**< Value Get */
+       odph_table_remove_value  f_remove;       /**< Value Remove */
+} odph_table_ops_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+

_______________________________________________
lng-odp mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to