From: Farah Smith Date: Wed, 15 Apr 2020 08:18:46 +0000 (+0530) Subject: net/bnxt: add TruFlow core identifier X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=6cf2f95d4dfbae8c8b4ea31ec899e750dcbc62bb;p=dpdk.git net/bnxt: add TruFlow core identifier - Add TruFlow Identifier resource support - Add TruFlow public API for Identifier resources. - Add support code and stack for Identifier resource allocation control. Signed-off-by: Farah Smith 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 bb6d38b452..7b027f7bf8 100644 --- a/drivers/net/bnxt/tf_core/tf_core.c +++ b/drivers/net/bnxt/tf_core/tf_core.c @@ -284,3 +284,159 @@ tf_close_session(struct tf *tfp) return rc_close; } + +/** allocate identifier resource + * + * Returns success or failure code. + */ +int tf_alloc_identifier(struct tf *tfp, + struct tf_alloc_identifier_parms *parms) +{ + struct bitalloc *session_pool; + struct tf_session *tfs; + int id; + int rc; + + if (parms == NULL || tfp == NULL) + return -EINVAL; + + if (tfp->session == NULL || tfp->session->core_data == NULL) { + PMD_DRV_LOG(ERR, "%s: session error\n", + tf_dir_2_str(parms->dir)); + return -EINVAL; + } + + tfs = (struct tf_session *)(tfp->session->core_data); + + switch (parms->ident_type) { + case TF_IDENT_TYPE_L2_CTXT: + TF_RM_GET_POOLS(tfs, parms->dir, &session_pool, + TF_L2_CTXT_REMAP_POOL_NAME, + rc); + break; + case TF_IDENT_TYPE_PROF_FUNC: + TF_RM_GET_POOLS(tfs, parms->dir, &session_pool, + TF_PROF_FUNC_POOL_NAME, + rc); + break; + case TF_IDENT_TYPE_EM_PROF: + TF_RM_GET_POOLS(tfs, parms->dir, &session_pool, + TF_EM_PROF_ID_POOL_NAME, + rc); + break; + case TF_IDENT_TYPE_WC_PROF: + TF_RM_GET_POOLS(tfs, parms->dir, &session_pool, + TF_WC_TCAM_PROF_ID_POOL_NAME, + rc); + break; + case TF_IDENT_TYPE_L2_FUNC: + PMD_DRV_LOG(ERR, "%s: unsupported %s\n", + tf_dir_2_str(parms->dir), + tf_ident_2_str(parms->ident_type)); + rc = -EOPNOTSUPP; + break; + default: + PMD_DRV_LOG(ERR, "%s: %s\n", + tf_dir_2_str(parms->dir), + tf_ident_2_str(parms->ident_type)); + rc = -EINVAL; + break; + } + + if (rc) { + PMD_DRV_LOG(ERR, "%s: identifier pool %s failure\n", + tf_dir_2_str(parms->dir), + tf_ident_2_str(parms->ident_type)); + return rc; + } + + id = ba_alloc(session_pool); + + if (id == BA_FAIL) { + PMD_DRV_LOG(ERR, "%s: %s: No resource available\n", + tf_dir_2_str(parms->dir), + tf_ident_2_str(parms->ident_type)); + return -ENOMEM; + } + parms->id = id; + return 0; +} + +/** free identifier resource + * + * Returns success or failure code. + */ +int tf_free_identifier(struct tf *tfp, + struct tf_free_identifier_parms *parms) +{ + struct bitalloc *session_pool; + int rc; + int ba_rc; + struct tf_session *tfs; + + if (parms == NULL || tfp == NULL) + return -EINVAL; + + if (tfp->session == NULL || tfp->session->core_data == NULL) { + PMD_DRV_LOG(ERR, "%s: Session error\n", + tf_dir_2_str(parms->dir)); + return -EINVAL; + } + + tfs = (struct tf_session *)(tfp->session->core_data); + + switch (parms->ident_type) { + case TF_IDENT_TYPE_L2_CTXT: + TF_RM_GET_POOLS(tfs, parms->dir, &session_pool, + TF_L2_CTXT_REMAP_POOL_NAME, + rc); + break; + case TF_IDENT_TYPE_PROF_FUNC: + TF_RM_GET_POOLS(tfs, parms->dir, &session_pool, + TF_PROF_FUNC_POOL_NAME, + rc); + break; + case TF_IDENT_TYPE_EM_PROF: + TF_RM_GET_POOLS(tfs, parms->dir, &session_pool, + TF_EM_PROF_ID_POOL_NAME, + rc); + break; + case TF_IDENT_TYPE_WC_PROF: + TF_RM_GET_POOLS(tfs, parms->dir, &session_pool, + TF_WC_TCAM_PROF_ID_POOL_NAME, + rc); + break; + case TF_IDENT_TYPE_L2_FUNC: + PMD_DRV_LOG(ERR, "%s: unsupported %s\n", + tf_dir_2_str(parms->dir), + tf_ident_2_str(parms->ident_type)); + rc = -EOPNOTSUPP; + break; + default: + PMD_DRV_LOG(ERR, "%s: invalid %s\n", + tf_dir_2_str(parms->dir), + tf_ident_2_str(parms->ident_type)); + rc = -EINVAL; + break; + } + if (rc) { + PMD_DRV_LOG(ERR, "%s: %s Identifier pool access failed\n", + tf_dir_2_str(parms->dir), + tf_ident_2_str(parms->ident_type)); + return rc; + } + + ba_rc = ba_inuse(session_pool, (int)parms->id); + + if (ba_rc == BA_FAIL || ba_rc == BA_ENTRY_FREE) { + PMD_DRV_LOG(ERR, "%s: %s: Entry %d already free", + tf_dir_2_str(parms->dir), + tf_ident_2_str(parms->ident_type), + parms->id); + return -EINVAL; + } + + ba_free(session_pool, (int)parms->id); + + return 0; +} diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h index c225202a71..2f5bee27c3 100644 --- a/drivers/net/bnxt/tf_core/tf_core.h +++ b/drivers/net/bnxt/tf_core/tf_core.h @@ -402,6 +402,61 @@ enum tf_identifier_type { TF_IDENT_TYPE_L2_FUNC }; +/** tf_alloc_identifier parameter definition + */ +struct tf_alloc_identifier_parms { + /** + * [in] receive or transmit direction + */ + enum tf_dir dir; + /** + * [in] Identifier type + */ + enum tf_identifier_type ident_type; + /** + * [out] Identifier allocated + */ + uint16_t id; +}; + +/** tf_free_identifier parameter definition + */ +struct tf_free_identifier_parms { + /** + * [in] receive or transmit direction + */ + enum tf_dir dir; + /** + * [in] Identifier type + */ + enum tf_identifier_type ident_type; + /** + * [in] ID to free + */ + uint16_t id; +}; + +/** allocate identifier resource + * + * TruFlow core will allocate a free id from the per identifier resource type + * pool reserved for the session during tf_open(). No firmware is involved. + * + * Returns success or failure code. + */ +int tf_alloc_identifier(struct tf *tfp, + struct tf_alloc_identifier_parms *parms); + +/** free identifier resource + * + * TruFlow core will return an id back to the per identifier resource type pool + * reserved for the session. No firmware is involved. During tf_close, the + * complete pool is returned to the firmware. + * + * Returns success or failure code. + */ +int tf_free_identifier(struct tf *tfp, + struct tf_free_identifier_parms *parms); + /** * TCAM table type */ diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c index 4ce2bc53d0..c44f96feed 100644 --- a/drivers/net/bnxt/tf_core/tf_msg.c +++ b/drivers/net/bnxt/tf_core/tf_msg.c @@ -93,6 +93,19 @@ tfp_le_to_cpu_16(response.element ## _stride); \ } while (0) +/** + * This is the MAX data we can transport across regular HWRM + */ +#define TF_PCI_BUF_SIZE_MAX 88 + +/** + * If data bigger than TF_PCI_BUF_SIZE_MAX then use DMA method + */ +struct tf_msg_dma_buf { + void *va_addr; + uint64_t pa_addr; +}; + /** * Sends session open request to TF Firmware */