1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
6 /* Truflow Table APIs and supporting code */
12 #include <sys/param.h>
13 #include <rte_common.h>
14 #include <rte_errno.h>
15 #include "hsi_struct_def_dpdk.h"
24 #include "tf_resources.h"
27 #include "tf_common.h"
30 * Internal function to get a Table Entry. Supports all Table Types
31 * except the TF_TBL_TYPE_EXT as that is handled as a table scope.
34 * Pointer to TruFlow handle
37 * Pointer to input parameters
41 * -EINVAL - Parameter error
44 tf_bulk_get_tbl_entry_internal(struct tf *tfp,
45 struct tf_bulk_get_tbl_entry_parms *parms)
50 struct bitalloc *session_pool;
51 struct tf_session *tfs = (struct tf_session *)(tfp->session->core_data);
53 /* Lookup the pool using the table type of the element */
54 rc = tf_rm_lookup_tbl_type_pool(tfs,
58 /* Error logging handled by tf_rm_lookup_tbl_type_pool */
62 index = parms->starting_idx;
65 * Adjust the returned index/offset as there is no guarantee
66 * that the start is 0 at time of RM allocation
68 tf_rm_convert_index(tfs,
71 TF_RM_CONVERT_RM_BASE,
75 /* Verify that the entry has been previously allocated */
76 id = ba_inuse(session_pool, index);
79 "%s, Invalid or not allocated index, type:%d, starting_idx:%d\n",
80 tf_dir_2_str(parms->dir),
87 rc = tf_msg_bulk_get_tbl_entry(tfp, parms);
90 "%s, Bulk get failed, type:%d, rc:%s\n",
91 tf_dir_2_str(parms->dir),
101 * Allocate Tbl entry from the Shadow DB. Shadow DB is searched for
102 * the requested entry. If found the ref count is incremente and
108 * Allocation parameters
111 * 0 - Success, entry found and ref count incremented
112 * -ENOENT - Failure, entry not found
115 tf_alloc_tbl_entry_shadow(struct tf_session *tfs __rte_unused,
116 struct tf_alloc_tbl_entry_parms *parms __rte_unused)
119 "%s, Entry Alloc with search not supported\n",
120 tf_dir_2_str(parms->dir));
126 * Free Tbl entry from the Shadow DB. Shadow DB is searched for
127 * the requested entry. If found the ref count is decremente and
128 * new ref_count returned.
133 * Allocation parameters
136 * 0 - Success, entry found and ref count decremented
137 * -ENOENT - Failure, entry not found
140 tf_free_tbl_entry_shadow(struct tf_session *tfs,
141 struct tf_free_tbl_entry_parms *parms)
144 "%s, Entry Free with search not supported\n",
145 tf_dir_2_str(parms->dir));
149 #endif /* TF_SHADOW */
152 /* API defined in tf_core.h */
154 tf_bulk_get_tbl_entry(struct tf *tfp,
155 struct tf_bulk_get_tbl_entry_parms *parms)
159 TF_CHECK_PARMS_SESSION(tfp, parms);
161 if (parms->type == TF_TBL_TYPE_EXT) {
162 /* Not supported, yet */
164 "%s, External table type not supported\n",
165 tf_dir_2_str(parms->dir));
169 /* Internal table type processing */
170 rc = tf_bulk_get_tbl_entry_internal(tfp, parms);
173 "%s, Bulk get failed, type:%d, rc:%s\n",
174 tf_dir_2_str(parms->dir),