X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fbnxt%2Ftf_core%2Ftf_if_tbl.c;h=e667d6fa6df0e75d7b72a0b0a4aa6850695417de;hb=e90df01c7aba0738a73505942939d2f9e94e1adc;hp=762dac0473b91694aadb618beaba4910c3bb2c85;hpb=e0699d649679b1b9b5e6779b35f575519ec4c8a6;p=dpdk.git diff --git a/drivers/net/bnxt/tf_core/tf_if_tbl.c b/drivers/net/bnxt/tf_core/tf_if_tbl.c index 762dac0473..e667d6fa6d 100644 --- a/drivers/net/bnxt/tf_core/tf_if_tbl.c +++ b/drivers/net/bnxt/tf_core/tf_if_tbl.c @@ -15,10 +15,11 @@ struct tf; /** - * IF Table DBs. - * TODO: Store this data in session db + * IF Table database */ -static void *if_tbl_db[TF_DIR_MAX]; +struct tf_if_tbl_db { + struct tf_if_tbl_cfg *if_tbl_cfg_db[TF_DIR_MAX]; +}; /** * Init flag, set on bind and cleared on unbind @@ -57,13 +58,27 @@ tf_if_tbl_get_hcapi_type(struct tf_if_tbl_get_hcapi_parms *parms) } int -tf_if_tbl_bind(struct tf *tfp __rte_unused, +tf_if_tbl_bind(struct tf *tfp, struct tf_if_tbl_cfg_parms *parms) { + struct tfp_calloc_parms cparms; + struct tf_if_tbl_db *if_tbl_db; + TF_CHECK_PARMS2(tfp, parms); - if_tbl_db[TF_DIR_RX] = parms->cfg; - if_tbl_db[TF_DIR_TX] = parms->cfg; + cparms.nitems = 1; + cparms.size = sizeof(struct tf_if_tbl_db); + cparms.alignment = 0; + if (tfp_calloc(&cparms) != 0) { + TFP_DRV_LOG(ERR, "if_tbl_rm_db alloc error %s\n", + strerror(ENOMEM)); + return -ENOMEM; + } + + if_tbl_db = cparms.mem_va; + if_tbl_db->if_tbl_cfg_db[TF_DIR_RX] = parms->cfg; + if_tbl_db->if_tbl_cfg_db[TF_DIR_TX] = parms->cfg; + tf_session_set_if_tbl_db(tfp, (void *)if_tbl_db); init = 1; @@ -74,8 +89,11 @@ tf_if_tbl_bind(struct tf *tfp __rte_unused, } int -tf_if_tbl_unbind(struct tf *tfp __rte_unused) +tf_if_tbl_unbind(struct tf *tfp) { + int rc; + struct tf_if_tbl_db *if_tbl_db_ptr; + /* Bail if nothing has been initialized */ if (!init) { TFP_DRV_LOG(INFO, @@ -83,8 +101,15 @@ tf_if_tbl_unbind(struct tf *tfp __rte_unused) return 0; } - if_tbl_db[TF_DIR_RX] = NULL; - if_tbl_db[TF_DIR_TX] = NULL; + TF_CHECK_PARMS1(tfp); + + rc = tf_session_get_if_tbl_db(tfp, (void **)&if_tbl_db_ptr); + if (rc) { + TFP_DRV_LOG(INFO, "No IF Table DBs initialized\n"); + return 0; + } + + tfp_free((void *)if_tbl_db_ptr); init = 0; return 0; @@ -95,6 +120,7 @@ tf_if_tbl_set(struct tf *tfp, struct tf_if_tbl_set_parms *parms) { int rc; + struct tf_if_tbl_db *if_tbl_db_ptr; struct tf_if_tbl_get_hcapi_parms hparms; TF_CHECK_PARMS3(tfp, parms, parms->data); @@ -106,8 +132,14 @@ tf_if_tbl_set(struct tf *tfp, return -EINVAL; } + rc = tf_session_get_if_tbl_db(tfp, (void **)&if_tbl_db_ptr); + if (rc) { + TFP_DRV_LOG(INFO, "No IF Table DBs initialized\n"); + return 0; + } + /* Convert TF type to HCAPI type */ - hparms.tbl_db = if_tbl_db[parms->dir]; + hparms.tbl_db = if_tbl_db_ptr->if_tbl_cfg_db[parms->dir]; hparms.db_index = parms->type; hparms.hcapi_type = &parms->hcapi_type; rc = tf_if_tbl_get_hcapi_type(&hparms); @@ -131,6 +163,7 @@ tf_if_tbl_get(struct tf *tfp, struct tf_if_tbl_get_parms *parms) { int rc = 0; + struct tf_if_tbl_db *if_tbl_db_ptr; struct tf_if_tbl_get_hcapi_parms hparms; TF_CHECK_PARMS3(tfp, parms, parms->data); @@ -142,8 +175,14 @@ tf_if_tbl_get(struct tf *tfp, return -EINVAL; } + rc = tf_session_get_if_tbl_db(tfp, (void **)&if_tbl_db_ptr); + if (rc) { + TFP_DRV_LOG(INFO, "No IF Table DBs initialized\n"); + return 0; + } + /* Convert TF type to HCAPI type */ - hparms.tbl_db = if_tbl_db[parms->dir]; + hparms.tbl_db = if_tbl_db_ptr->if_tbl_cfg_db[parms->dir]; hparms.db_index = parms->type; hparms.hcapi_type = &parms->hcapi_type; rc = tf_if_tbl_get_hcapi_type(&hparms);