From: Shahaji Bhosle Date: Thu, 2 Jul 2020 23:28:01 +0000 (-0700) Subject: net/bnxt: support two-level priority for TCAMs X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=2f1b44456cbc0b59173802e429e176aca722e528;p=dpdk.git net/bnxt: support two-level priority for TCAMs Allow TCAM indexes to be allocated from top or bottom. If the priority is set to 0, allocate from the lowest tcam indexes i.e. from top. Any other value, allocate it from the highest tcam indexes i.e. from bottom. Signed-off-by: Shahaji Bhosle Signed-off-by: Venkat Duvvuru Reviewed-by: Randy Schacher Reviewed-by: Ajit Khaparde --- diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c index 81a88e2113..eac57e7bda 100644 --- a/drivers/net/bnxt/tf_core/tf_core.c +++ b/drivers/net/bnxt/tf_core/tf_core.c @@ -893,7 +893,7 @@ tf_alloc_tcam_entry(struct tf *tfp, struct tf_alloc_tcam_entry_parms *parms) { int rc; - int index; + int index = 0; struct tf_session *tfs; struct bitalloc *session_pool; @@ -916,12 +916,34 @@ tf_alloc_tcam_entry(struct tf *tfp, if (rc) return rc; - index = ba_alloc(session_pool); - if (index == BA_FAIL) { - PMD_DRV_LOG(ERR, "%s: %s: No resource available\n", - tf_dir_2_str(parms->dir), - tf_tcam_tbl_2_str(parms->tcam_tbl_type)); - return -ENOMEM; + /* + * priority 0: allocate from top of the tcam i.e. high + * priority !0: allocate index from bottom i.e lowest + */ + if (parms->priority) { + for (index = session_pool->size - 1; index >= 0; index--) { + if (ba_inuse(session_pool, + index) == BA_ENTRY_FREE) { + break; + } + } + if (ba_alloc_index(session_pool, + index) == BA_FAIL) { + TFP_DRV_LOG(ERR, + "%s: %s: ba_alloc index %d failed\n", + tf_dir_2_str(parms->dir), + tf_tcam_tbl_2_str(parms->tcam_tbl_type), + index); + return -ENOMEM; + } + } else { + index = ba_alloc(session_pool); + if (index == BA_FAIL) { + TFP_DRV_LOG(ERR, "%s: %s: Out of resource\n", + tf_dir_2_str(parms->dir), + tf_tcam_tbl_2_str(parms->tcam_tbl_type)); + return -ENOMEM; + } } parms->idx = index; diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h index 74ed24e5ad..f1ef00b304 100644 --- a/drivers/net/bnxt/tf_core/tf_core.h +++ b/drivers/net/bnxt/tf_core/tf_core.h @@ -799,7 +799,9 @@ struct tf_alloc_tcam_entry_parms { */ uint8_t *mask; /** - * [in] Priority of entry requested (definition TBD) + * [in] Priority of entry requested + * 0: index from top i.e. highest priority first + * !0: index from bottom i.e lowest priority first */ uint32_t priority; /** diff --git a/drivers/net/bnxt/tf_core/tf_em.c b/drivers/net/bnxt/tf_core/tf_em.c index fd1797e390..91cbc62997 100644 --- a/drivers/net/bnxt/tf_core/tf_em.c +++ b/drivers/net/bnxt/tf_core/tf_em.c @@ -479,8 +479,7 @@ int tf_insert_em_internal_entry(struct tf *tfp, rc = stack_pop(pool, &index); if (rc != 0) { - PMD_DRV_LOG - (ERR, + TFP_DRV_LOG(ERR, "dir:%d, EM entry index allocation failed\n", parms->dir); return rc; @@ -495,8 +494,7 @@ int tf_insert_em_internal_entry(struct tf *tfp, if (rc != 0) return -1; - PMD_DRV_LOG - (ERR, + TFP_DRV_LOG(INFO, "Internal entry @ Index:%d rptr_index:0x%x rptr_entry:0x%x num_of_entries:%d\n", index * TF_SESSION_EM_ENTRY_SIZE, rptr_index, diff --git a/drivers/net/bnxt/tf_core/tf_tbl.c b/drivers/net/bnxt/tf_core/tf_tbl.c index 26313ed3c2..4e236d56c0 100644 --- a/drivers/net/bnxt/tf_core/tf_tbl.c +++ b/drivers/net/bnxt/tf_core/tf_tbl.c @@ -1967,7 +1967,7 @@ void tf_dump_dma(struct tf *tfp, uint32_t tbl_scope_id) tbl_scope_cb = tbl_scope_cb_find(session, tbl_scope_id); if (tbl_scope_cb == NULL) - PMD_DRV_LOG(ERR, "No table scope\n"); + TFP_DRV_LOG(ERR, "No table scope\n"); for (dir = 0; dir < TF_DIR_MAX; dir++) { printf("Direction %s:\n", (dir == TF_DIR_RX ? "Rx" : "Tx"));