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 5479CA00BE; Fri, 12 Jun 2020 15:46:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C69EE1C18E; Fri, 12 Jun 2020 15:34:43 +0200 (CEST) Received: from relay.smtp.broadcom.com (relay.smtp.broadcom.com [192.19.232.149]) by dpdk.org (Postfix) with ESMTP id E7E691C0D9 for ; Fri, 12 Jun 2020 15:34:39 +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 C146D1BD7A4; Fri, 12 Jun 2020 06:34:38 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com C146D1BD7A4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1591968879; bh=lSfASedBGOd0qf92Z7uuBi96ifoHaisvxRwSU8/T9Gc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eITtsCF7e+lAjxhU5h/Q62I6VjjPpY9u3GPd5jJHTCOtDY/RaHdD0kctsonvj0axL zLjsnlAFBnmXTRI99NjF76iBTZl680HvGYNq3Iizp0Z28BLaqeQX39ZQow1q6BYTB2 lqgNenYwHKrm5V3IHpCj13hR3ioBUuxHHeNTxnvA= From: Somnath Kotur To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Fri, 12 Jun 2020 18:59:10 +0530 Message-Id: <20200612132934.16488-27-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 26/50] net/bnxt: add external action alloc and free 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: Jay Ding - Link external action alloc and free to new hcapi interface - Add parameter range checking - Fix issues with index allocation check Signed-off-by: Jay Ding Reviewed-by: Randy Schacher Signed-off-by: Venkat Duvvuru --- drivers/net/bnxt/tf_core/tf_core.c | 163 ++++++++++++++++++++++--------- drivers/net/bnxt/tf_core/tf_core.h | 4 - drivers/net/bnxt/tf_core/tf_device.h | 58 +++++++++++ drivers/net/bnxt/tf_core/tf_device_p4.c | 6 ++ drivers/net/bnxt/tf_core/tf_device_p4.h | 2 - drivers/net/bnxt/tf_core/tf_em.h | 95 ++++++++++++++++++ drivers/net/bnxt/tf_core/tf_em_common.c | 120 ++++++++++++++++++++++- drivers/net/bnxt/tf_core/tf_em_host.c | 80 ++++++++++++++- drivers/net/bnxt/tf_core/tf_em_system.c | 6 ++ drivers/net/bnxt/tf_core/tf_identifier.c | 4 +- drivers/net/bnxt/tf_core/tf_rm.h | 5 + drivers/net/bnxt/tf_core/tf_tbl.c | 10 +- drivers/net/bnxt/tf_core/tf_tbl.h | 12 +++ drivers/net/bnxt/tf_core/tf_tcam.c | 8 +- drivers/net/bnxt/tf_core/tf_util.c | 4 - 15 files changed, 499 insertions(+), 78 deletions(-) diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c index 6410843..45accb0 100644 --- a/drivers/net/bnxt/tf_core/tf_core.c +++ b/drivers/net/bnxt/tf_core/tf_core.c @@ -617,25 +617,48 @@ tf_alloc_tbl_entry(struct tf *tfp, return rc; } - if (dev->ops->tf_dev_alloc_tbl == NULL) { - rc = -EOPNOTSUPP; - TFP_DRV_LOG(ERR, - "%s: Operation not supported, rc:%s\n", - tf_dir_2_str(parms->dir), - strerror(-rc)); - return -EOPNOTSUPP; - } - aparms.dir = parms->dir; aparms.type = parms->type; aparms.idx = &idx; - rc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms); - if (rc) { - TFP_DRV_LOG(ERR, - "%s: Table allocation failed, rc:%s\n", - tf_dir_2_str(parms->dir), - strerror(-rc)); - return rc; + aparms.tbl_scope_id = parms->tbl_scope_id; + + if (parms->type == TF_TBL_TYPE_EXT) { + if (dev->ops->tf_dev_alloc_ext_tbl == NULL) { + rc = -EOPNOTSUPP; + TFP_DRV_LOG(ERR, + "%s: Operation not supported, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return -EOPNOTSUPP; + } + + rc = dev->ops->tf_dev_alloc_ext_tbl(tfp, &aparms); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: External table allocation failed, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } + + } else { + if (dev->ops->tf_dev_alloc_tbl == NULL) { + rc = -EOPNOTSUPP; + TFP_DRV_LOG(ERR, + "%s: Operation not supported, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return -EOPNOTSUPP; + } + + rc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Table allocation failed, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } } parms->idx = idx; @@ -677,25 +700,47 @@ tf_free_tbl_entry(struct tf *tfp, return rc; } - if (dev->ops->tf_dev_free_tbl == NULL) { - rc = -EOPNOTSUPP; - TFP_DRV_LOG(ERR, - "%s: Operation not supported, rc:%s\n", - tf_dir_2_str(parms->dir), - strerror(-rc)); - return -EOPNOTSUPP; - } - fparms.dir = parms->dir; fparms.type = parms->type; fparms.idx = parms->idx; - rc = dev->ops->tf_dev_free_tbl(tfp, &fparms); - if (rc) { - TFP_DRV_LOG(ERR, - "%s: Table free failed, rc:%s\n", - tf_dir_2_str(parms->dir), - strerror(-rc)); - return rc; + fparms.tbl_scope_id = parms->tbl_scope_id; + + if (parms->type == TF_TBL_TYPE_EXT) { + if (dev->ops->tf_dev_free_ext_tbl == NULL) { + rc = -EOPNOTSUPP; + TFP_DRV_LOG(ERR, + "%s: Operation not supported, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return -EOPNOTSUPP; + } + + rc = dev->ops->tf_dev_free_ext_tbl(tfp, &fparms); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Table free failed, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } + } else { + if (dev->ops->tf_dev_free_tbl == NULL) { + rc = -EOPNOTSUPP; + TFP_DRV_LOG(ERR, + "%s: Operation not supported, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return -EOPNOTSUPP; + } + + rc = dev->ops->tf_dev_free_tbl(tfp, &fparms); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Table free failed, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } } return 0; @@ -735,27 +780,49 @@ tf_set_tbl_entry(struct tf *tfp, return rc; } - if (dev->ops->tf_dev_set_tbl == NULL) { - rc = -EOPNOTSUPP; - TFP_DRV_LOG(ERR, - "%s: Operation not supported, rc:%s\n", - tf_dir_2_str(parms->dir), - strerror(-rc)); - return -EOPNOTSUPP; - } - sparms.dir = parms->dir; sparms.type = parms->type; sparms.data = parms->data; sparms.data_sz_in_bytes = parms->data_sz_in_bytes; sparms.idx = parms->idx; - rc = dev->ops->tf_dev_set_tbl(tfp, &sparms); - if (rc) { - TFP_DRV_LOG(ERR, - "%s: Table set failed, rc:%s\n", - tf_dir_2_str(parms->dir), - strerror(-rc)); - return rc; + sparms.tbl_scope_id = parms->tbl_scope_id; + + if (parms->type == TF_TBL_TYPE_EXT) { + if (dev->ops->tf_dev_set_ext_tbl == NULL) { + rc = -EOPNOTSUPP; + TFP_DRV_LOG(ERR, + "%s: Operation not supported, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return -EOPNOTSUPP; + } + + rc = dev->ops->tf_dev_set_ext_tbl(tfp, &sparms); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Table set failed, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } + } else { + if (dev->ops->tf_dev_set_tbl == NULL) { + rc = -EOPNOTSUPP; + TFP_DRV_LOG(ERR, + "%s: Operation not supported, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return -EOPNOTSUPP; + } + + rc = dev->ops->tf_dev_set_tbl(tfp, &sparms); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Table set failed, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } } return rc; diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h index a7a7bd3..e898f19 100644 --- a/drivers/net/bnxt/tf_core/tf_core.h +++ b/drivers/net/bnxt/tf_core/tf_core.h @@ -211,10 +211,6 @@ enum tf_tbl_type { TF_TBL_TYPE_ACT_MODIFY_IPV4_SRC, /** Wh+/SR Action _Modify L4 Dest Port */ TF_TBL_TYPE_ACT_MODIFY_IPV4_DEST, - /** Action Modify IPv6 Source */ - TF_TBL_TYPE_ACT_MODIFY_IPV6_SRC, - /** Action Modify IPv6 Destination */ - TF_TBL_TYPE_ACT_MODIFY_IPV6_DEST, /** Meter Profiles */ TF_TBL_TYPE_METER_PROF, /** Meter Instance */ diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h index 93f3627..58b7a4a 100644 --- a/drivers/net/bnxt/tf_core/tf_device.h +++ b/drivers/net/bnxt/tf_core/tf_device.h @@ -217,6 +217,26 @@ struct tf_dev_ops { struct tf_tbl_alloc_parms *parms); /** + * Allocation of a external table type element. + * + * This API allocates the specified table type element from a + * device specific table type DB. The allocated element is + * returned. + * + * [in] tfp + * Pointer to TF handle + * + * [in] parms + * Pointer to table allocation parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ + int (*tf_dev_alloc_ext_tbl)(struct tf *tfp, + struct tf_tbl_alloc_parms *parms); + + /** * Free of a table type element. * * This API free's a previous allocated table type element from a @@ -236,6 +256,25 @@ struct tf_dev_ops { struct tf_tbl_free_parms *parms); /** + * Free of a external table type element. + * + * This API free's a previous allocated table type element from a + * device specific table type DB. + * + * [in] tfp + * Pointer to TF handle + * + * [in] parms + * Pointer to table free parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ + int (*tf_dev_free_ext_tbl)(struct tf *tfp, + struct tf_tbl_free_parms *parms); + + /** * Searches for the specified table type element in a shadow DB. * * This API searches for the specified table type element in a @@ -277,6 +316,25 @@ struct tf_dev_ops { struct tf_tbl_set_parms *parms); /** + * Sets the specified external table type element. + * + * This API sets the specified element data by invoking the + * firmware. + * + * [in] tfp + * Pointer to TF handle + * + * [in] parms + * Pointer to table set parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ + int (*tf_dev_set_ext_tbl)(struct tf *tfp, + struct tf_tbl_set_parms *parms); + + /** * Retrieves the specified table type element. * * This API retrieves the specified element data by invoking the diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c index 1eaf182..9a32307 100644 --- a/drivers/net/bnxt/tf_core/tf_device_p4.c +++ b/drivers/net/bnxt/tf_core/tf_device_p4.c @@ -85,10 +85,13 @@ const struct tf_dev_ops tf_dev_ops_p4_init = { .tf_dev_get_tcam_slice_info = tf_dev_p4_get_tcam_slice_info, .tf_dev_alloc_ident = NULL, .tf_dev_free_ident = NULL, + .tf_dev_alloc_ext_tbl = NULL, .tf_dev_alloc_tbl = NULL, + .tf_dev_free_ext_tbl = NULL, .tf_dev_free_tbl = NULL, .tf_dev_alloc_search_tbl = NULL, .tf_dev_set_tbl = NULL, + .tf_dev_set_ext_tbl = NULL, .tf_dev_get_tbl = NULL, .tf_dev_get_bulk_tbl = NULL, .tf_dev_alloc_tcam = NULL, @@ -113,9 +116,12 @@ const struct tf_dev_ops tf_dev_ops_p4 = { .tf_dev_alloc_ident = tf_ident_alloc, .tf_dev_free_ident = tf_ident_free, .tf_dev_alloc_tbl = tf_tbl_alloc, + .tf_dev_alloc_ext_tbl = tf_tbl_ext_alloc, .tf_dev_free_tbl = tf_tbl_free, + .tf_dev_free_ext_tbl = tf_tbl_ext_free, .tf_dev_alloc_search_tbl = NULL, .tf_dev_set_tbl = tf_tbl_set, + .tf_dev_set_ext_tbl = tf_tbl_ext_set, .tf_dev_get_tbl = tf_tbl_get, .tf_dev_get_bulk_tbl = tf_tbl_bulk_get, .tf_dev_alloc_tcam = tf_tcam_alloc, diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.h b/drivers/net/bnxt/tf_core/tf_device_p4.h index 8fae180..298e100 100644 --- a/drivers/net/bnxt/tf_core/tf_device_p4.h +++ b/drivers/net/bnxt/tf_core/tf_device_p4.h @@ -47,8 +47,6 @@ struct tf_rm_element_cfg tf_tbl_p4[TF_TBL_TYPE_MAX] = { { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_NAT_DPORT }, { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_NAT_S_IPV4 }, { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_NAT_D_IPV4 }, - { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_NAT_S_IPV6 }, - { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_NAT_D_IPV6 }, { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_METER_PROF }, { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_METER }, { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_MIRROR }, diff --git a/drivers/net/bnxt/tf_core/tf_em.h b/drivers/net/bnxt/tf_core/tf_em.h index c3c712f..1c2369c 100644 --- a/drivers/net/bnxt/tf_core/tf_em.h +++ b/drivers/net/bnxt/tf_core/tf_em.h @@ -456,4 +456,99 @@ int tf_em_ext_common_free(struct tf *tfp, */ int tf_em_ext_common_alloc(struct tf *tfp, struct tf_alloc_tbl_scope_parms *parms); + +/** + * Allocate External Tbl entry from the scope pool. + * + * [in] tfp + * Pointer to Truflow Handle + * [in] parms + * Allocation parameters + * + * Return: + * 0 - Success, entry allocated - no search support + * -ENOMEM -EINVAL -EOPNOTSUPP + * - Failure, entry not allocated, out of resources + */ +int +tf_tbl_ext_alloc(struct tf *tfp, + struct tf_tbl_alloc_parms *parms); + +/** + * Free External Tbl entry to the scope pool. + * + * [in] tfp + * Pointer to Truflow Handle + * [in] parms + * Allocation parameters + * + * Return: + * 0 - Success, entry freed + * + * - Failure, entry not successfully freed for these reasons + * -ENOMEM + * -EOPNOTSUPP + * -EINVAL + */ +int +tf_tbl_ext_free(struct tf *tfp, + struct tf_tbl_free_parms *parms); + +/** + * Sets the specified external table type element. + * + * This API sets the specified element data by invoking the + * firmware. + * + * [in] tfp + * Pointer to TF handle + * + * [in] parms + * Pointer to table set parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_tbl_ext_set(struct tf *tfp, + struct tf_tbl_set_parms *parms); + +/** + * Sets the specified external table type element. + * + * This API sets the specified element data by invoking the + * firmware. + * + * [in] tfp + * Pointer to TF handle + * + * [in] parms + * Pointer to table set parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_tbl_ext_host_set(struct tf *tfp, + struct tf_tbl_set_parms *parms); + +/** + * Sets the specified external table type element. + * + * This API sets the specified element data by invoking the + * firmware. + * + * [in] tfp + * Pointer to TF handle + * + * [in] parms + * Pointer to table set parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_tbl_ext_system_set(struct tf *tfp, + struct tf_tbl_set_parms *parms); + #endif /* _TF_EM_H_ */ diff --git a/drivers/net/bnxt/tf_core/tf_em_common.c b/drivers/net/bnxt/tf_core/tf_em_common.c index e31a63b..39a8412 100644 --- a/drivers/net/bnxt/tf_core/tf_em_common.c +++ b/drivers/net/bnxt/tf_core/tf_em_common.c @@ -29,8 +29,6 @@ */ void *eem_db[TF_DIR_MAX]; -#define TF_EEM_DB_TBL_SCOPE 1 - /** * Init flag, set on bind and cleared on unbind */ @@ -54,13 +52,13 @@ tbl_scope_cb_find(uint32_t tbl_scope_id) /* Check that id is valid */ parms.rm_db = eem_db[TF_DIR_RX]; - parms.db_index = TF_EEM_DB_TBL_SCOPE; + parms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE; parms.index = tbl_scope_id; parms.allocated = &allocated; i = tf_rm_is_allocated(&parms); - if (i < 0 || !allocated) + if (i < 0 || allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) return NULL; for (i = 0; i < TF_NUM_TBL_SCOPE; i++) { @@ -158,6 +156,111 @@ tf_destroy_tbl_pool_external(enum tf_dir dir, tfp_free(ext_act_pool_mem); } +/** + * Allocate External Tbl entry from the scope pool. + * + * [in] tfp + * Pointer to Truflow Handle + * [in] parms + * Allocation parameters + * + * Return: + * 0 - Success, entry allocated - no search support + * -ENOMEM -EINVAL -EOPNOTSUPP + * - Failure, entry not allocated, out of resources + */ +int +tf_tbl_ext_alloc(struct tf *tfp, + struct tf_tbl_alloc_parms *parms) +{ + int rc; + uint32_t index; + struct tf_tbl_scope_cb *tbl_scope_cb; + struct stack *pool; + + TF_CHECK_PARMS2(tfp, parms); + + /* Get the pool info from the table scope + */ + tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id); + + if (tbl_scope_cb == NULL) { + TFP_DRV_LOG(ERR, + "%s, table scope not allocated\n", + tf_dir_2_str(parms->dir)); + return -EINVAL; + } + pool = &tbl_scope_cb->ext_act_pool[parms->dir]; + + /* Allocate an element + */ + rc = stack_pop(pool, &index); + + if (rc != 0) { + TFP_DRV_LOG(ERR, + "%s, Allocation failed, type:%d\n", + tf_dir_2_str(parms->dir), + parms->type); + return rc; + } + + *parms->idx = index; + return rc; +} + +/** + * Free External Tbl entry to the scope pool. + * + * [in] tfp + * Pointer to Truflow Handle + * [in] parms + * Allocation parameters + * + * Return: + * 0 - Success, entry freed + * + * - Failure, entry not successfully freed for these reasons + * -ENOMEM + * -EOPNOTSUPP + * -EINVAL + */ +int +tf_tbl_ext_free(struct tf *tfp, + struct tf_tbl_free_parms *parms) +{ + int rc = 0; + uint32_t index; + struct tf_tbl_scope_cb *tbl_scope_cb; + struct stack *pool; + + TF_CHECK_PARMS2(tfp, parms); + + /* Get the pool info from the table scope + */ + tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id); + + if (tbl_scope_cb == NULL) { + TFP_DRV_LOG(ERR, + "%s, table scope error\n", + tf_dir_2_str(parms->dir)); + return -EINVAL; + } + pool = &tbl_scope_cb->ext_act_pool[parms->dir]; + + index = parms->idx; + + rc = stack_push(pool, index); + + if (rc != 0) { + TFP_DRV_LOG(ERR, + "%s, consistency error, stack full, type:%d, idx:%d\n", + tf_dir_2_str(parms->dir), + parms->type, + index); + } + return rc; +} + uint32_t tf_em_get_key_mask(int num_entries) { @@ -273,6 +376,15 @@ tf_em_ext_common_unbind(struct tf *tfp) return 0; } +int tf_tbl_ext_set(struct tf *tfp, + struct tf_tbl_set_parms *parms) +{ + if (mem_type == TF_EEM_MEM_TYPE_HOST) + return tf_tbl_ext_host_set(tfp, parms); + else + return tf_tbl_ext_system_set(tfp, parms); +} + int tf_em_ext_common_alloc(struct tf *tfp, struct tf_alloc_tbl_scope_parms *parms) diff --git a/drivers/net/bnxt/tf_core/tf_em_host.c b/drivers/net/bnxt/tf_core/tf_em_host.c index f36c9dc..d734f1a 100644 --- a/drivers/net/bnxt/tf_core/tf_em_host.c +++ b/drivers/net/bnxt/tf_core/tf_em_host.c @@ -48,7 +48,6 @@ * EM DBs. */ extern void *eem_db[TF_DIR_MAX]; -#define TF_EEM_DB_TBL_SCOPE 1 extern struct tf_tbl_scope_cb tbl_scopes[TF_NUM_TBL_SCOPE]; @@ -989,7 +988,7 @@ tf_em_ext_host_alloc(struct tf *tfp, /* Get Table Scope control block from the session pool */ aparms.rm_db = eem_db[TF_DIR_RX]; - aparms.db_index = TF_EEM_DB_TBL_SCOPE; + aparms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE; aparms.index = (uint32_t *)&parms->tbl_scope_id; rc = tf_rm_allocate(&aparms); if (rc) { @@ -1090,7 +1089,7 @@ tf_em_ext_host_alloc(struct tf *tfp, cleanup: /* Free Table control block */ fparms.rm_db = eem_db[TF_DIR_RX]; - fparms.db_index = TF_EEM_DB_TBL_SCOPE; + fparms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE; fparms.index = parms->tbl_scope_id; tf_rm_free(&fparms); return -EINVAL; @@ -1114,7 +1113,7 @@ tf_em_ext_host_free(struct tf *tfp, /* Free Table control block */ aparms.rm_db = eem_db[TF_DIR_RX]; - aparms.db_index = TF_EEM_DB_TBL_SCOPE; + aparms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE; aparms.index = parms->tbl_scope_id; rc = tf_rm_free(&aparms); if (rc) { @@ -1136,6 +1135,77 @@ tf_em_ext_host_free(struct tf *tfp, tf_em_ctx_unreg(tfp, tbl_scope_cb, dir); } - tbl_scopes[parms->tbl_scope_id].tbl_scope_id = -1; + tbl_scopes[parms->tbl_scope_id].tbl_scope_id = TF_TBL_SCOPE_INVALID; + return rc; +} + +/** + * Sets the specified external table type element. + * + * This API sets the specified element data + * + * [in] tfp + * Pointer to TF handle + * + * [in] parms + * Pointer to table set parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_tbl_ext_host_set(struct tf *tfp, + struct tf_tbl_set_parms *parms) +{ + int rc = 0; + struct tf_tbl_scope_cb *tbl_scope_cb; + uint32_t tbl_scope_id; + struct hcapi_cfa_hwop op; + struct hcapi_cfa_key_tbl key_tbl; + struct hcapi_cfa_key_data key_obj; + struct hcapi_cfa_key_loc key_loc; + + TF_CHECK_PARMS2(tfp, parms); + + if (parms->data == NULL) { + TFP_DRV_LOG(ERR, + "%s, invalid parms->data\n", + tf_dir_2_str(parms->dir)); + return -EINVAL; + } + + tbl_scope_id = parms->tbl_scope_id; + + if (tbl_scope_id == TF_TBL_SCOPE_INVALID) { + TFP_DRV_LOG(ERR, + "%s, Table scope not allocated\n", + tf_dir_2_str(parms->dir)); + return -EINVAL; + } + + /* Get the table scope control block associated with the + * external pool + */ + tbl_scope_cb = tbl_scope_cb_find(tbl_scope_id); + + if (tbl_scope_cb == NULL) { + TFP_DRV_LOG(ERR, + "%s, table scope error\n", + tf_dir_2_str(parms->dir)); + return -EINVAL; + } + + op.opcode = HCAPI_CFA_HWOPS_PUT; + key_tbl.base0 = + (uint8_t *)&tbl_scope_cb->em_ctx_info[parms->dir].em_tables[TF_RECORD_TABLE]; + key_obj.offset = parms->idx % TF_EM_PAGE_SIZE; + key_obj.data = parms->data; + key_obj.size = parms->data_sz_in_bytes; + + rc = hcapi_cfa_key_hw_op(&op, + &key_tbl, + &key_obj, + &key_loc); + return rc; } diff --git a/drivers/net/bnxt/tf_core/tf_em_system.c b/drivers/net/bnxt/tf_core/tf_em_system.c index 6dd1154..10768df 100644 --- a/drivers/net/bnxt/tf_core/tf_em_system.c +++ b/drivers/net/bnxt/tf_core/tf_em_system.c @@ -112,3 +112,9 @@ tf_em_ext_system_free(struct tf *tfp __rte_unused, { return 0; } + +int tf_tbl_ext_system_set(struct tf *tfp __rte_unused, + struct tf_tbl_set_parms *parms __rte_unused) +{ + return 0; +} diff --git a/drivers/net/bnxt/tf_core/tf_identifier.c b/drivers/net/bnxt/tf_core/tf_identifier.c index 2113710..2198392 100644 --- a/drivers/net/bnxt/tf_core/tf_identifier.c +++ b/drivers/net/bnxt/tf_core/tf_identifier.c @@ -159,13 +159,13 @@ tf_ident_free(struct tf *tfp __rte_unused, if (rc) return rc; - if (!allocated) { + if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) { TFP_DRV_LOG(ERR, "%s: Entry already free, type:%d, index:%d\n", tf_dir_2_str(parms->dir), parms->type, parms->id); - return rc; + return -EINVAL; } /* Free requested element */ diff --git a/drivers/net/bnxt/tf_core/tf_rm.h b/drivers/net/bnxt/tf_core/tf_rm.h index f44fcca..fd04480 100644 --- a/drivers/net/bnxt/tf_core/tf_rm.h +++ b/drivers/net/bnxt/tf_core/tf_rm.h @@ -12,6 +12,11 @@ struct tf; +/** RM return codes */ +#define TF_RM_ALLOCATED_ENTRY_FREE 0 +#define TF_RM_ALLOCATED_ENTRY_IN_USE 1 +#define TF_RM_ALLOCATED_NO_ENTRY_FOUND -1 + /** * The Resource Manager (RM) module provides basic DB handling for * internal resources. These resources exists within the actual device diff --git a/drivers/net/bnxt/tf_core/tf_tbl.c b/drivers/net/bnxt/tf_core/tf_tbl.c index 6303033..9b1b20f 100644 --- a/drivers/net/bnxt/tf_core/tf_tbl.c +++ b/drivers/net/bnxt/tf_core/tf_tbl.c @@ -169,13 +169,13 @@ tf_tbl_free(struct tf *tfp __rte_unused, if (rc) return rc; - if (!allocated) { + if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) { TFP_DRV_LOG(ERR, "%s: Entry already free, type:%d, index:%d\n", tf_dir_2_str(parms->dir), parms->type, parms->idx); - return rc; + return -EINVAL; } /* Free requested element */ @@ -230,7 +230,7 @@ tf_tbl_set(struct tf *tfp, if (rc) return rc; - if (!allocated) { + if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) { TFP_DRV_LOG(ERR, "%s, Invalid or not allocated index, type:%d, idx:%d\n", tf_dir_2_str(parms->dir), @@ -298,7 +298,7 @@ tf_tbl_get(struct tf *tfp, if (rc) return rc; - if (!allocated) { + if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) { TFP_DRV_LOG(ERR, "%s, Invalid or not allocated index, type:%d, idx:%d\n", tf_dir_2_str(parms->dir), @@ -371,7 +371,7 @@ tf_tbl_bulk_get(struct tf *tfp, if (rc) return rc; - if (!allocated) { + if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) { TFP_DRV_LOG(ERR, "%s, Invalid or not allocated index, type:%d, idx:%d\n", tf_dir_2_str(parms->dir), diff --git a/drivers/net/bnxt/tf_core/tf_tbl.h b/drivers/net/bnxt/tf_core/tf_tbl.h index eb560ff..2a10b47 100644 --- a/drivers/net/bnxt/tf_core/tf_tbl.h +++ b/drivers/net/bnxt/tf_core/tf_tbl.h @@ -84,6 +84,10 @@ struct tf_tbl_alloc_parms { */ enum tf_tbl_type type; /** + * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT) + */ + uint32_t tbl_scope_id; + /** * [out] Idx of allocated entry or found entry (if search_enable) */ uint32_t *idx; @@ -102,6 +106,10 @@ struct tf_tbl_free_parms { */ enum tf_tbl_type type; /** + * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT) + */ + uint32_t tbl_scope_id; + /** * [in] Index to free */ uint32_t idx; @@ -169,6 +177,10 @@ struct tf_tbl_set_parms { */ enum tf_tbl_type type; /** + * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT) + */ + uint32_t tbl_scope_id; + /** * [in] Entry data */ uint8_t *data; diff --git a/drivers/net/bnxt/tf_core/tf_tcam.c b/drivers/net/bnxt/tf_core/tf_tcam.c index b67159a..b1092cd 100644 --- a/drivers/net/bnxt/tf_core/tf_tcam.c +++ b/drivers/net/bnxt/tf_core/tf_tcam.c @@ -252,13 +252,13 @@ tf_tcam_free(struct tf *tfp, if (rc) return rc; - if (!allocated) { + if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) { TFP_DRV_LOG(ERR, "%s: Entry already free, type:%d, index:%d\n", tf_dir_2_str(parms->dir), parms->type, parms->idx); - return rc; + return -EINVAL; } /* Free requested element */ @@ -362,13 +362,13 @@ tf_tcam_set(struct tf *tfp __rte_unused, if (rc) return rc; - if (!allocated) { + if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) { TFP_DRV_LOG(ERR, "%s: Entry is not allocated, type:%d, index:%d\n", tf_dir_2_str(parms->dir), parms->type, parms->idx); - return rc; + return -EINVAL; } /* Convert TF type to HCAPI RM type */ diff --git a/drivers/net/bnxt/tf_core/tf_util.c b/drivers/net/bnxt/tf_core/tf_util.c index 5472a9a..85f6e25 100644 --- a/drivers/net/bnxt/tf_core/tf_util.c +++ b/drivers/net/bnxt/tf_core/tf_util.c @@ -92,10 +92,6 @@ tf_tbl_type_2_str(enum tf_tbl_type tbl_type) return "NAT IPv4 Source"; case TF_TBL_TYPE_ACT_MODIFY_IPV4_DEST: return "NAT IPv4 Destination"; - case TF_TBL_TYPE_ACT_MODIFY_IPV6_SRC: - return "NAT IPv6 Source"; - case TF_TBL_TYPE_ACT_MODIFY_IPV6_DEST: - return "NAT IPv6 Destination"; case TF_TBL_TYPE_METER_PROF: return "Meter Profile"; case TF_TBL_TYPE_METER_INST: -- 2.7.4