From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 47EDCA00BE; Fri, 12 Jun 2020 15:41:24 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7B01E1BFD4; Fri, 12 Jun 2020 15:34:27 +0200 (CEST) Received: from relay.smtp.broadcom.com (relay.smtp.broadcom.com [192.19.232.149]) by dpdk.org (Postfix) with ESMTP id D80D91BFA9 for ; Fri, 12 Jun 2020 15:34:23 +0200 (CEST) Received: from dhcp-10-123-153-55.dhcp.broadcom.net (dhcp-10-123-153-55.dhcp.broadcom.net [10.123.153.55]) by relay.smtp.broadcom.com (Postfix) with ESMTP id AFD601BD7AB; Fri, 12 Jun 2020 06:34:22 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com AFD601BD7AB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1591968863; bh=S2RxGM1BGFDAx44SCSD3HB7MjkkRGiL3Vz/jAGw0kzs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gobzgvHejoWW5UIscyYJlAAJOP5Tk/vrb9tNsXP/srEh3yEfXZxG8CACz/AQcPWiZ 19TQjv3OTJGQRb3BQDR4kO/iSyCqsFsfl4Aq0yk/6ZMkTtzt2EykwZY7oZQ/LZTIXb j3mAw9Ujn92SXO3DiiEkUucOpf9oWQhyV/V8UMRM= From: Somnath Kotur To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Fri, 12 Jun 2020 18:58:58 +0530 Message-Id: <20200612132934.16488-15-somnath.kotur@broadcom.com> X-Mailer: git-send-email 2.10.1.613.g2cc2e70 In-Reply-To: <20200612132934.16488-1-somnath.kotur@broadcom.com> References: <20200612132934.16488-1-somnath.kotur@broadcom.com> Subject: [dpdk-dev] [PATCH 14/50] net/bnxt: support two-level priority for TCAMs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Shahaji Bhosle 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 Reviewed-by: Randy Schacher Reviewed-by: Ajit Kumar Khaparde Signed-off-by: Venkat Duvvuru --- drivers/net/bnxt/tf_core/tf_core.c | 36 +++++++++++++++++++++++++++++------- drivers/net/bnxt/tf_core/tf_core.h | 4 +++- drivers/net/bnxt/tf_core/tf_em.c | 6 ++---- drivers/net/bnxt/tf_core/tf_tbl.c | 2 +- 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c index 28a6bbd..7d9bca8 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 74ed24e..f1ef00b 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 fd1797e..91cbc62 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 0f2979e..f9bfae7 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")); -- 2.7.4