X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fbnxt%2Ftf_core%2Ftf_em_common.c;h=3bdfc14e0519ad635e33cfb8ff12a740a6ed0452;hb=53a80512644c8a12cb8efc903f77dd7b42263565;hp=4dc3c86b5784ccf0bf78c72c5db8e7b865f2dec4;hpb=08e1af1a7e07a99499deb96bbf12a4e4d663bd51;p=dpdk.git diff --git a/drivers/net/bnxt/tf_core/tf_em_common.c b/drivers/net/bnxt/tf_core/tf_em_common.c index 4dc3c86b57..3bdfc14e05 100644 --- a/drivers/net/bnxt/tf_core/tf_em_common.c +++ b/drivers/net/bnxt/tf_core/tf_em_common.c @@ -23,14 +23,13 @@ #include "bnxt.h" + +/** Invalid table scope id */ +#define TF_TBL_SCOPE_INVALID 0xffffffff + /* Number of pointers per page_size */ #define MAX_PAGE_PTRS(page_size) ((page_size) / sizeof(void *)) -/** - * Init flag, set on bind and cleared on unbind - */ -static uint8_t init; - /** * Host or system */ @@ -306,6 +305,7 @@ tf_em_page_tbl_pgcnt(uint32_t num_pages, { return roundup(num_pages, MAX_PAGE_PTRS(page_size)) / MAX_PAGE_PTRS(page_size); + return 0; } /** @@ -727,10 +727,6 @@ tf_insert_eem_entry(struct tf_dev_info *dev, if (!mask) return -EINVAL; -#ifdef TF_EEM_DEBUG - dump_raw((uint8_t *)parms->key, TF_P4_HW_EM_KEY_MAX_SIZE + 4, "In Key"); -#endif - if (dev->ops->tf_dev_cfa_key_hash == NULL) return -EINVAL; @@ -742,10 +738,6 @@ tf_insert_eem_entry(struct tf_dev_info *dev, key0_index = key0_hash & mask; key1_index = key1_hash & mask; -#ifdef TF_EEM_DEBUG - TFP_DRV_LOG(DEBUG, "Key0 hash:0x%08x\n", key0_hash); - TFP_DRV_LOG(DEBUG, "Key1 hash:0x%08x\n", key1_hash); -#endif /* * Use the "result" arg to populate all of the key entry then * store the byte swapped "raw" entry in a local copy ready @@ -924,18 +916,11 @@ tf_em_ext_common_bind(struct tf *tfp, int rc; int i; struct tf_rm_create_db_parms db_cfg = { 0 }; - uint8_t db_exists = 0; struct em_ext_db *ext_db; struct tfp_calloc_parms cparms; TF_CHECK_PARMS2(tfp, parms); - if (init) { - TFP_DRV_LOG(ERR, - "EM Ext DB already initialized\n"); - return -EINVAL; - } - cparms.nitems = 1; cparms.size = sizeof(struct em_ext_db); cparms.alignment = 0; @@ -974,12 +959,8 @@ tf_em_ext_common_bind(struct tf *tfp, return rc; } - db_exists = 1; } - if (db_exists) - init = 1; - mem_type = parms->mem_type; return 0; @@ -1001,13 +982,6 @@ tf_em_ext_common_unbind(struct tf *tfp) TF_CHECK_PARMS1(tfp); - /* Bail if nothing has been initialized */ - if (!init) { - TFP_DRV_LOG(INFO, - "No EM Ext DBs created\n"); - return 0; - } - rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { TFP_DRV_LOG(ERR, "Failed to get tf_session, rc:%s\n", @@ -1033,39 +1007,43 @@ tf_em_ext_common_unbind(struct tf *tfp) } ext_db = (struct em_ext_db *)ext_ptr; - entry = ext_db->tbl_scope_ll.head; - while (entry != NULL) { - tbl_scope_cb = (struct tf_tbl_scope_cb *)entry; - entry = entry->next; - tparms.tbl_scope_id = tbl_scope_cb->tbl_scope_id; - - if (dev->ops->tf_dev_free_tbl_scope) { - dev->ops->tf_dev_free_tbl_scope(tfp, &tparms); - } else { - /* should not reach here */ - ll_delete(&ext_db->tbl_scope_ll, &tbl_scope_cb->ll_entry); - tfp_free(tbl_scope_cb); + if (ext_db != NULL) { + entry = ext_db->tbl_scope_ll.head; + while (entry != NULL) { + tbl_scope_cb = (struct tf_tbl_scope_cb *)entry; + entry = entry->next; + tparms.tbl_scope_id = + tbl_scope_cb->tbl_scope_id; + + if (dev->ops->tf_dev_free_tbl_scope) { + dev->ops->tf_dev_free_tbl_scope(tfp, + &tparms); + } else { + /* should not reach here */ + ll_delete(&ext_db->tbl_scope_ll, + &tbl_scope_cb->ll_entry); + tfp_free(tbl_scope_cb); + } } - } - for (i = 0; i < TF_DIR_MAX; i++) { - if (ext_db->eem_db[i] == NULL) - continue; + for (i = 0; i < TF_DIR_MAX; i++) { + if (ext_db->eem_db[i] == NULL) + continue; - fparms.dir = i; - fparms.rm_db = ext_db->eem_db[i]; - rc = tf_rm_free_db(tfp, &fparms); - if (rc) - return rc; + fparms.dir = i; + fparms.rm_db = ext_db->eem_db[i]; + rc = tf_rm_free_db(tfp, &fparms); + if (rc) + return rc; - ext_db->eem_db[i] = NULL; + ext_db->eem_db[i] = NULL; + } + + tfp_free(ext_db); } - tfp_free(ext_db); tf_session_set_em_ext_db(tfp, NULL); - init = 0; - return 0; }