X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fbnxt%2Ftf_core%2Ftf_identifier.c;h=9f27a41fcff369dde99f21c7ecc4100199f29fb8;hb=c87bd543a8d42ba820870ececa76f1d98057d3ad;hp=ee68b6ca58c1d4914d0d7b55610163777d34fdc0;hpb=38dc96f919318d3580fdb37142dbcfb879de1d79;p=dpdk.git diff --git a/drivers/net/bnxt/tf_core/tf_identifier.c b/drivers/net/bnxt/tf_core/tf_identifier.c index ee68b6ca58..9f27a41fcf 100644 --- a/drivers/net/bnxt/tf_core/tf_identifier.c +++ b/drivers/net/bnxt/tf_core/tf_identifier.c @@ -15,11 +15,6 @@ struct tf; -/** - * Init flag, set on bind and cleared on unbind - */ -static uint8_t init; - /** * Identifier shadow DBs. */ @@ -35,20 +30,21 @@ tf_ident_bind(struct tf *tfp, struct tf_ident_cfg_parms *parms) { int rc; + int db_rc[TF_DIR_MAX] = { 0 }; int i; struct tf_rm_create_db_parms db_cfg = { 0 }; struct tf_shadow_ident_cfg_parms shadow_cfg = { 0 }; struct tf_shadow_ident_create_db_parms shadow_cdb = { 0 }; struct ident_rm_db *ident_db; struct tfp_calloc_parms cparms; + struct tf_session *tfs; TF_CHECK_PARMS2(tfp, parms); - if (init) { - TFP_DRV_LOG(ERR, - "Identifier DB already initialized\n"); - return -EINVAL; - } + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) + return rc; memset(&db_cfg, 0, sizeof(db_cfg)); cparms.nitems = 1; @@ -73,14 +69,11 @@ tf_ident_bind(struct tf *tfp, db_cfg.rm_db = (void *)&ident_db->ident_db[i]; db_cfg.dir = i; db_cfg.alloc_cnt = parms->resources->ident_cnt[i].cnt; - rc = tf_rm_create_db(tfp, &db_cfg); - if (rc) { - TFP_DRV_LOG(ERR, - "%s: Identifier DB creation failed\n", - tf_dir_2_str(i)); - - return rc; - } + if (tf_session_is_shared_session(tfs) && + (!tf_session_is_shared_session_creator(tfs))) + db_rc[i] = tf_rm_create_db_no_reservation(tfp, &db_cfg); + else + db_rc[i] = tf_rm_create_db(tfp, &db_cfg); if (parms->shadow_copy) { shadow_cfg.alloc_cnt = @@ -100,7 +93,11 @@ tf_ident_bind(struct tf *tfp, } } - init = 1; + /* No db created */ + if (db_rc[TF_DIR_RX] && db_rc[TF_DIR_TX]) { + TFP_DRV_LOG(ERR, "No Identifier DB created\n"); + return db_rc[TF_DIR_RX]; + } TFP_DRV_LOG(INFO, "Identifier - initialized\n"); @@ -120,23 +117,14 @@ tf_ident_unbind(struct tf *tfp) TF_CHECK_PARMS1(tfp); - /* Bail if nothing has been initialized */ - if (!init) { - TFP_DRV_LOG(INFO, - "No Identifier DBs created\n"); - return 0; - } - rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr); - if (rc) { - TFP_DRV_LOG(ERR, - "Failed to get ident_db from session, rc:%s\n", - strerror(-rc)); - return rc; - } + if (rc) + return 0; ident_db = (struct ident_rm_db *)ident_db_ptr; for (i = 0; i < TF_DIR_MAX; i++) { + if (ident_db->ident_db[i] == NULL) + continue; fparms.rm_db = ident_db->ident_db[i]; fparms.dir = i; rc = tf_rm_free_db(tfp, &fparms); @@ -158,7 +146,6 @@ tf_ident_unbind(struct tf *tfp) ident_db->ident_db[i] = NULL; } - init = 0; shadow_init = 0; return 0; @@ -178,13 +165,6 @@ tf_ident_alloc(struct tf *tfp __rte_unused, TF_CHECK_PARMS2(tfp, parms); - if (!init) { - TFP_DRV_LOG(ERR, - "%s: No Identifier DBs created\n", - tf_dir_2_str(parms->dir)); - return -EINVAL; - } - rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr); if (rc) { TFP_DRV_LOG(ERR, @@ -242,13 +222,6 @@ tf_ident_free(struct tf *tfp __rte_unused, TF_CHECK_PARMS2(tfp, parms); - if (!init) { - TFP_DRV_LOG(ERR, - "%s: No Identifier DBs created\n", - tf_dir_2_str(parms->dir)); - return -EINVAL; - } - rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr); if (rc) { TFP_DRV_LOG(ERR, @@ -329,13 +302,6 @@ tf_ident_search(struct tf *tfp __rte_unused, TF_CHECK_PARMS2(tfp, parms); - if (!init) { - TFP_DRV_LOG(ERR, - "%s: No Identifier DBs created\n", - tf_dir_2_str(parms->dir)); - return -EINVAL; - } - if (!shadow_init) { TFP_DRV_LOG(ERR, "%s: Identifier Shadow copy is not enabled\n", @@ -388,3 +354,39 @@ tf_ident_search(struct tf *tfp __rte_unused, return 0; } + +int +tf_ident_get_resc_info(struct tf *tfp, + struct tf_identifier_resource_info *ident) +{ + int rc; + int d; + struct tf_resource_info *dinfo; + struct tf_rm_get_alloc_info_parms ainfo; + void *ident_db_ptr = NULL; + struct ident_rm_db *ident_db; + + TF_CHECK_PARMS2(tfp, ident); + + rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr); + if (rc) { + TFP_DRV_LOG(INFO, + "No resource allocated for ident from session\n"); + return 0; + } + ident_db = (struct ident_rm_db *)ident_db_ptr; + + /* check if reserved resource for WC is multiple of num_slices */ + for (d = 0; d < TF_DIR_MAX; d++) { + ainfo.rm_db = ident_db->ident_db[d]; + dinfo = ident[d].info; + + ainfo.info = (struct tf_rm_alloc_info *)dinfo; + ainfo.subtype = 0; + rc = tf_rm_get_all_info(&ainfo, TF_IDENT_TYPE_MAX); + if (rc) + return rc; + } + + return 0; +}