From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C7C07A0C45; Wed, 1 Sep 2021 16:25:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2D3BF41149; Wed, 1 Sep 2021 16:24:51 +0200 (CEST) Received: from relay.smtp-ext.broadcom.com (lpdvsmtp11.broadcom.com [192.19.166.231]) by mails.dpdk.org (Postfix) with ESMTP id 888B5406A3 for ; Wed, 1 Sep 2021 16:24:49 +0200 (CEST) Received: from S60.dhcp.broadcom.net (unknown [10.123.66.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by relay.smtp-ext.broadcom.com (Postfix) with ESMTPS id 1B2CA2E2D4; Wed, 1 Sep 2021 07:24:47 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 1B2CA2E2D4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1630506288; bh=FCGX1wuFUTHlyGTb4aqFpRXqLcq3w9e6W36qGIZ+WZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j95pE1MPgyqxjEBZ9lIpqw3hI1yW2g2I9D5u4y7PvnfoEyGIQZbULTiEH+zUM+/x0 EbiSQxmAfRo9HH8PgepkNwIiiKeQeH4DY3qNtoy0J+7eZLAZRog/si0oDeAubMV2JM yYEgu7icveeVLrtDkyt6OrZRSUyclMzmQTbiOdVI= From: Venkat Duvvuru To: dev@dpdk.org Cc: Peter Spreadborough Date: Wed, 1 Sep 2021 19:54:21 +0530 Message-Id: <20210901142433.8444-3-venkatkumar.duvvuru@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210901142433.8444-1-venkatkumar.duvvuru@broadcom.com> References: <20210901142433.8444-1-venkatkumar.duvvuru@broadcom.com> Subject: [dpdk-dev] [PATCH 02/14] net/bnxt: enable dpool allocator X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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: Peter Spreadborough Enable dynamic entry allocator for EM SRAM entries. Deprecate static entry allocator code. Signed-off-by: Peter Spreadborough Reviewed-by: Randy Schacher --- drivers/net/bnxt/tf_core/tf_device_p58.c | 4 - drivers/net/bnxt/tf_core/tf_em.h | 10 - .../net/bnxt/tf_core/tf_em_hash_internal.c | 34 ---- drivers/net/bnxt/tf_core/tf_em_internal.c | 180 +----------------- 4 files changed, 1 insertion(+), 227 deletions(-) diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c index ce4d8c661f..808dcb1f77 100644 --- a/drivers/net/bnxt/tf_core/tf_device_p58.c +++ b/drivers/net/bnxt/tf_core/tf_device_p58.c @@ -348,11 +348,7 @@ const struct tf_dev_ops tf_dev_ops_p58 = { .tf_dev_get_tcam_resc_info = tf_tcam_get_resc_info, .tf_dev_insert_int_em_entry = tf_em_hash_insert_int_entry, .tf_dev_delete_int_em_entry = tf_em_hash_delete_int_entry, -#if (TF_EM_ALLOC == 1) .tf_dev_move_int_em_entry = tf_em_move_int_entry, -#else - .tf_dev_move_int_em_entry = NULL, -#endif .tf_dev_insert_ext_em_entry = NULL, .tf_dev_delete_ext_em_entry = NULL, .tf_dev_get_em_resc_info = tf_em_get_resc_info, diff --git a/drivers/net/bnxt/tf_core/tf_em.h b/drivers/net/bnxt/tf_core/tf_em.h index 568071ad8c..074c128651 100644 --- a/drivers/net/bnxt/tf_core/tf_em.h +++ b/drivers/net/bnxt/tf_core/tf_em.h @@ -13,16 +13,6 @@ #include "hcapi_cfa_defs.h" -/** - * TF_EM_ALLOC - * - * 0: Use stack allocator with fixed sized entries - * (default). - * 1: Use dpool allocator with variable size - * entries. - */ -#define TF_EM_ALLOC 0 - #define TF_EM_MIN_ENTRIES (1 << 15) /* 32K */ #define TF_EM_MAX_ENTRIES (1 << 27) /* 128M */ diff --git a/drivers/net/bnxt/tf_core/tf_em_hash_internal.c b/drivers/net/bnxt/tf_core/tf_em_hash_internal.c index 098e8af07e..60273a798c 100644 --- a/drivers/net/bnxt/tf_core/tf_em_hash_internal.c +++ b/drivers/net/bnxt/tf_core/tf_em_hash_internal.c @@ -22,9 +22,7 @@ /** * EM Pool */ -#if (TF_EM_ALLOC == 1) #include "dpool.h" -#endif /** * Insert EM internal entry API @@ -41,11 +39,7 @@ tf_em_hash_insert_int_entry(struct tf *tfp, uint16_t rptr_index = 0; uint8_t rptr_entry = 0; uint8_t num_of_entries = 0; -#if (TF_EM_ALLOC == 1) struct dpool *pool; -#else - struct stack *pool; -#endif uint32_t index; uint32_t key0_hash; uint32_t key1_hash; @@ -62,7 +56,6 @@ tf_em_hash_insert_int_entry(struct tf *tfp, rc = tf_session_get_device(tfs, &dev); if (rc) return rc; -#if (TF_EM_ALLOC == 1) pool = (struct dpool *)tfs->em_pool[parms->dir]; index = dpool_alloc(pool, parms->em_record_sz_in_bits / 128, @@ -74,16 +67,6 @@ tf_em_hash_insert_int_entry(struct tf *tfp, tf_dir_2_str(parms->dir)); return -1; } -#else - pool = (struct stack *)tfs->em_pool[parms->dir]; - rc = stack_pop(pool, &index); - if (rc) { - PMD_DRV_LOG(ERR, - "%s, EM entry index allocation failed\n", - tf_dir_2_str(parms->dir)); - return rc; - } -#endif if (dev->ops->tf_dev_cfa_key_hash == NULL) return -EINVAL; @@ -103,11 +86,7 @@ tf_em_hash_insert_int_entry(struct tf *tfp, &num_of_entries); if (rc) { /* Free the allocated index before returning */ -#if (TF_EM_ALLOC == 1) dpool_free(pool, index); -#else - stack_push(pool, index); -#endif return -1; } @@ -128,9 +107,7 @@ tf_em_hash_insert_int_entry(struct tf *tfp, rptr_index, rptr_entry, 0); -#if (TF_EM_ALLOC == 1) dpool_set_entry_data(pool, index, parms->flow_handle); -#endif return 0; } @@ -146,11 +123,7 @@ tf_em_hash_delete_int_entry(struct tf *tfp, { int rc = 0; struct tf_session *tfs; -#if (TF_EM_ALLOC == 1) struct dpool *pool; -#else - struct stack *pool; -#endif /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { @@ -165,19 +138,13 @@ tf_em_hash_delete_int_entry(struct tf *tfp, /* Return resource to pool */ if (rc == 0) { -#if (TF_EM_ALLOC == 1) pool = (struct dpool *)tfs->em_pool[parms->dir]; dpool_free(pool, parms->index); -#else - pool = (struct stack *)tfs->em_pool[parms->dir]; - stack_push(pool, parms->index); -#endif } return rc; } -#if (TF_EM_ALLOC == 1) /** Move EM internal entry API * * returns: @@ -212,4 +179,3 @@ tf_em_move_int_entry(struct tf *tfp, return rc; } -#endif diff --git a/drivers/net/bnxt/tf_core/tf_em_internal.c b/drivers/net/bnxt/tf_core/tf_em_internal.c index 0720bb905d..2d57595f17 100644 --- a/drivers/net/bnxt/tf_core/tf_em_internal.c +++ b/drivers/net/bnxt/tf_core/tf_em_internal.c @@ -22,145 +22,7 @@ /** * EM Pool */ -#if (TF_EM_ALLOC == 1) #include "dpool.h" -#else - -/** - * Create EM Tbl pool of memory indexes. - * - * [in] dir - * direction - * [in] num_entries - * number of entries to write - * [in] start - * starting offset - * - * Return: - * 0 - Success, entry allocated - no search support - * -ENOMEM -EINVAL -EOPNOTSUPP - * - Failure, entry not allocated, out of resources - */ -static int -tf_create_em_pool(struct tf_session *tfs, - enum tf_dir dir, - uint32_t num_entries, - uint32_t start) -{ - struct tfp_calloc_parms parms; - uint32_t i, j; - int rc = 0; - struct stack *pool; - - /* - * Allocate stack pool - */ - parms.nitems = 1; - parms.size = sizeof(struct stack); - parms.alignment = 0; - - rc = tfp_calloc(&parms); - - if (rc) { - TFP_DRV_LOG(ERR, - "%s, EM stack allocation failure %s\n", - tf_dir_2_str(dir), - strerror(-rc)); - return rc; - } - - pool = (struct stack *)parms.mem_va; - tfs->em_pool[dir] = (void *)pool; - - /* Assumes that num_entries has been checked before we get here */ - parms.nitems = num_entries / TF_SESSION_EM_ENTRY_SIZE; - parms.size = sizeof(uint32_t); - parms.alignment = 0; - - rc = tfp_calloc(&parms); - - if (rc) { - TFP_DRV_LOG(ERR, - "%s, EM pool allocation failure %s\n", - tf_dir_2_str(dir), - strerror(-rc)); - return rc; - } - - /* Create empty stack - */ - rc = stack_init(num_entries / TF_SESSION_EM_ENTRY_SIZE, - (uint32_t *)parms.mem_va, - pool); - - if (rc) { - TFP_DRV_LOG(ERR, - "%s, EM pool stack init failure %s\n", - tf_dir_2_str(dir), - strerror(-rc)); - goto cleanup; - } - - /* Fill pool with indexes - */ - j = start + num_entries - TF_SESSION_EM_ENTRY_SIZE; - - for (i = 0; i < (num_entries / TF_SESSION_EM_ENTRY_SIZE); i++) { - rc = stack_push(pool, j); - if (rc) { - TFP_DRV_LOG(ERR, - "%s, EM pool stack push failure %s\n", - tf_dir_2_str(dir), - strerror(-rc)); - goto cleanup; - } - - j -= TF_SESSION_EM_ENTRY_SIZE; - } - - if (!stack_is_full(pool)) { - rc = -EINVAL; - TFP_DRV_LOG(ERR, - "%s, EM pool stack failure %s\n", - tf_dir_2_str(dir), - strerror(-rc)); - goto cleanup; - } - - return 0; -cleanup: - tfp_free((void *)parms.mem_va); - tfp_free((void *)tfs->em_pool[dir]); - tfs->em_pool[dir] = NULL; - return rc; -} - -/** - * Create EM Tbl pool of memory indexes. - * - * [in] dir - * direction - * - * Return: - */ -static void -tf_free_em_pool(struct tf_session *tfs, - enum tf_dir dir) -{ - struct stack *pool = (struct stack *)tfs->em_pool[dir]; - uint32_t *ptr; - - if (pool != NULL) { - ptr = stack_items(pool); - - if (ptr != NULL) - tfp_free(ptr); - - tfp_free(pool); - tfs->em_pool[dir] = NULL; - } -} -#endif /* TF_EM_ALLOC != 1 */ /** * Insert EM internal entry API @@ -178,11 +40,7 @@ tf_em_insert_int_entry(struct tf *tfp, uint8_t rptr_entry = 0; uint8_t num_of_entries = 0; struct tf_session *tfs; -#if (TF_EM_ALLOC == 1) struct dpool *pool; -#else - struct stack *pool; -#endif uint32_t index; /* Retrieve the session information */ @@ -195,7 +53,6 @@ tf_em_insert_int_entry(struct tf *tfp, return rc; } -#if (TF_EM_ALLOC == 1) pool = (struct dpool *)tfs->em_pool[parms->dir]; index = dpool_alloc(pool, TF_SESSION_EM_ENTRY_SIZE, 0); if (index == DP_INVALID_INDEX) { @@ -204,16 +61,6 @@ tf_em_insert_int_entry(struct tf *tfp, tf_dir_2_str(parms->dir)); return -1; } -#else - pool = (struct stack *)tfs->em_pool[parms->dir]; - rc = stack_pop(pool, &index); - if (rc) { - PMD_DRV_LOG(ERR, - "%s, EM entry index allocation failed\n", - tf_dir_2_str(parms->dir)); - return rc; - } -#endif rptr_index = index; @@ -224,11 +71,7 @@ tf_em_insert_int_entry(struct tf *tfp, &num_of_entries); if (rc) { /* Free the allocated index before returning */ -#if (TF_EM_ALLOC == 1) dpool_free(pool, index); -#else - stack_push(pool, index); -#endif return -1; } TF_SET_GFID(gfid, @@ -264,11 +107,7 @@ tf_em_delete_int_entry(struct tf *tfp, { int rc = 0; struct tf_session *tfs; -#if (TF_EM_ALLOC == 1) struct dpool *pool; -#else - struct stack *pool; -#endif /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { @@ -283,19 +122,13 @@ tf_em_delete_int_entry(struct tf *tfp, /* Return resource to pool */ if (rc == 0) { -#if (TF_EM_ALLOC == 1) pool = (struct dpool *)tfs->em_pool[parms->dir]; dpool_free(pool, parms->index); -#else - pool = (struct stack *)tfs->em_pool[parms->dir]; - stack_push(pool, parms->index); -#endif } return rc; } -#if (TF_EM_ALLOC == 1) static int tf_em_move_callback(void *user_data, uint64_t entry_data, @@ -342,7 +175,6 @@ tf_em_move_callback(void *user_data, return rc; } -#endif int tf_em_int_bind(struct tf *tfp, @@ -434,7 +266,7 @@ tf_em_int_bind(struct tf *tfp, tf_dir_2_str(i)); return rc; } -#if (TF_EM_ALLOC == 1) + /* * Allocate stack pool */ @@ -460,12 +292,6 @@ tf_em_int_bind(struct tf *tfp, 7, (void *)tfp, tf_em_move_callback); -#else - rc = tf_create_em_pool(tfs, - i, - iparms.info->entry.stride, - iparms.info->entry.start); -#endif /* Logging handled in tf_create_em_pool */ if (rc) return rc; @@ -501,11 +327,7 @@ tf_em_int_unbind(struct tf *tfp) if (!tf_session_is_shared_session(tfs)) { for (i = 0; i < TF_DIR_MAX; i++) -#if (TF_EM_ALLOC == 1) dpool_free_all(tfs->em_pool[i]); -#else - tf_free_em_pool(tfs, i); -#endif } rc = tf_session_get_db(tfp, TF_MODULE_TYPE_EM, &em_db_ptr); -- 2.17.1