1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2021 Broadcom
7 #include <rte_common.h>
13 #include "tf_common.h"
17 #include "tf_ext_flow_handle.h"
18 #include "tf_device.h"
28 * Insert EM internal entry API
34 tf_em_hash_insert_int_entry(struct tf *tfp,
35 struct tf_insert_em_entry_parms *parms)
39 uint16_t rptr_index = 0;
40 uint8_t rptr_entry = 0;
41 uint8_t num_of_entries = 0;
47 struct tf_dev_info *dev;
48 struct tf_session *tfs;
50 /* Retrieve the session information */
51 rc = tf_session_get_session_internal(tfp, &tfs);
55 /* Retrieve the device information */
56 rc = tf_session_get_device(tfs, &dev);
59 pool = (struct dpool *)tfs->em_pool[parms->dir];
60 index = dpool_alloc(pool,
61 parms->em_record_sz_in_bits / 128,
64 if (index == DP_INVALID_INDEX) {
66 "%s, EM entry index allocation failed\n",
67 tf_dir_2_str(parms->dir));
71 if (dev->ops->tf_dev_cfa_key_hash == NULL)
74 big_hash = dev->ops->tf_dev_cfa_key_hash((uint64_t *)parms->key,
75 TF_P58_HW_EM_KEY_MAX_SIZE * 8);
76 key0_hash = (uint32_t)(big_hash >> 32);
77 key1_hash = (uint32_t)(big_hash & 0xFFFFFFFF);
80 rc = tf_msg_hash_insert_em_internal_entry(tfp,
88 /* Free the allocated index before returning */
89 dpool_free(pool, index);
94 ((rptr_index << TF_EM_INTERNAL_INDEX_SHIFT) |
96 0); /* N/A for internal table */
98 TF_SET_FLOW_ID(parms->flow_id,
100 TF_GFID_TABLE_INTERNAL,
103 TF_SET_FIELDS_IN_FLOW_HANDLE(parms->flow_handle,
104 (uint32_t)num_of_entries,
106 TF_FLAGS_FLOW_HANDLE_INTERNAL,
110 dpool_set_entry_data(pool, index, parms->flow_handle);
114 /** Delete EM internal entry API
121 tf_em_hash_delete_int_entry(struct tf *tfp,
122 struct tf_delete_em_entry_parms *parms)
125 struct tf_session *tfs;
127 /* Retrieve the session information */
128 rc = tf_session_get_session(tfp, &tfs);
131 "%s: Failed to lookup session, rc:%s\n",
132 tf_dir_2_str(parms->dir),
137 rc = tf_msg_delete_em_entry(tfp, parms);
139 /* Return resource to pool */
141 pool = (struct dpool *)tfs->em_pool[parms->dir];
142 dpool_free(pool, parms->index);
148 /** Move EM internal entry API
155 tf_em_move_int_entry(struct tf *tfp,
156 struct tf_move_em_entry_parms *parms)
160 struct tf_session *tfs;
162 /* Retrieve the session information */
163 rc = tf_session_get_session(tfp, &tfs);
166 "%s: Failed to lookup session, rc:%s\n",
167 tf_dir_2_str(parms->dir),
172 rc = tf_msg_move_em_entry(tfp, parms);
174 /* Return resource to pool */
176 pool = (struct dpool *)tfs->em_pool[parms->dir];
177 dpool_free(pool, parms->index);