/**
* EM Pool
*/
-extern struct stack em_pool[TF_DIR_MAX];
+#include "dpool.h"
/**
* Insert EM internal entry API
uint16_t rptr_index = 0;
uint8_t rptr_entry = 0;
uint8_t num_of_entries = 0;
- struct stack *pool = &em_pool[parms->dir];
+ struct dpool *pool;
uint32_t index;
uint32_t key0_hash;
uint32_t key1_hash;
rc = tf_session_get_device(tfs, &dev);
if (rc)
return rc;
+ pool = (struct dpool *)tfs->em_pool[parms->dir];
+ index = dpool_alloc(pool,
+ parms->em_record_sz_in_bits / 128,
+ DP_DEFRAG_TO_FIT);
- rc = stack_pop(pool, &index);
- if (rc) {
+ if (index == DP_INVALID_INDEX) {
PMD_DRV_LOG(ERR,
"%s, EM entry index allocation failed\n",
tf_dir_2_str(parms->dir));
- return rc;
+ return -1;
}
if (dev->ops->tf_dev_cfa_key_hash == NULL)
&num_of_entries);
if (rc) {
/* Free the allocated index before returning */
- stack_push(pool, index);
+ dpool_free(pool, index);
return -1;
}
- PMD_DRV_LOG
- (DEBUG,
- "%s, Internal entry @ Index:%d rptr_index:0x%x rptr_entry:0x%x num_of_entries:%d\n",
- tf_dir_2_str(parms->dir),
- index,
- rptr_index,
- rptr_entry,
- num_of_entries);
-
TF_SET_GFID(gfid,
((rptr_index << TF_EM_INTERNAL_INDEX_SHIFT) |
rptr_entry),
rptr_index,
rptr_entry,
0);
+ dpool_set_entry_data(pool, index, parms->flow_handle);
return 0;
}
struct tf_delete_em_entry_parms *parms)
{
int rc = 0;
- struct stack *pool = &em_pool[parms->dir];
+ struct tf_session *tfs;
+ struct dpool *pool;
+ /* Retrieve the session information */
+ rc = tf_session_get_session(tfp, &tfs);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s: Failed to lookup session, rc:%s\n",
+ tf_dir_2_str(parms->dir),
+ strerror(-rc));
+ return rc;
+ }
rc = tf_msg_delete_em_entry(tfp, parms);
/* Return resource to pool */
- if (rc == 0)
- stack_push(pool, parms->index);
+ if (rc == 0) {
+ pool = (struct dpool *)tfs->em_pool[parms->dir];
+ dpool_free(pool, parms->index);
+ }
+
+ return rc;
+}
+
+/** Move EM internal entry API
+ *
+ * returns:
+ * 0
+ * -EINVAL
+ */
+int
+tf_em_move_int_entry(struct tf *tfp,
+ struct tf_move_em_entry_parms *parms)
+{
+ int rc = 0;
+ struct dpool *pool;
+ struct tf_session *tfs;
+
+ /* Retrieve the session information */
+ rc = tf_session_get_session(tfp, &tfs);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s: Failed to lookup session, rc:%s\n",
+ tf_dir_2_str(parms->dir),
+ strerror(-rc));
+ return rc;
+ }
+
+ rc = tf_msg_move_em_entry(tfp, parms);
+
+ /* Return resource to pool */
+ if (rc == 0) {
+ pool = (struct dpool *)tfs->em_pool[parms->dir];
+ dpool_free(pool, parms->index);
+ }
return rc;
}