X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fbnxt%2Ftf_core%2Ftf_device.c;h=f68eb723fe53446fd67847549cbabbb35b5777f0;hb=7100b0e5511e58269498900aea30bc03e15ba2fd;hp=b474e8c257157112c980a5b58096342cd0f6071f;hpb=48d3dff2b98680c6315593e8b6495b64e678b004;p=dpdk.git diff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c index b474e8c257..f68eb723fe 100644 --- a/drivers/net/bnxt/tf_core/tf_device.c +++ b/drivers/net/bnxt/tf_core/tf_device.c @@ -1,16 +1,17 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2019-2020 Broadcom + * Copyright(c) 2019-2021 Broadcom * All rights reserved. */ #include "tf_device.h" #include "tf_device_p4.h" #include "tfp.h" +#include "tf_em.h" struct tf; /* Forward declarations */ -static int dev_unbind_p4(struct tf *tfp); +static int tf_dev_unbind_p4(struct tf *tfp); /** * Device specific bind function, WH+ @@ -32,22 +33,20 @@ static int dev_unbind_p4(struct tf *tfp); * - (-EINVAL) on parameter or internal failure. */ static int -dev_bind_p4(struct tf *tfp, - bool shadow_copy, - struct tf_session_resources *resources, - struct tf_dev_info *dev_handle) +tf_dev_bind_p4(struct tf *tfp, + bool shadow_copy, + struct tf_session_resources *resources, + struct tf_dev_info *dev_handle) { int rc; int frc; struct tf_ident_cfg_parms ident_cfg; struct tf_tbl_cfg_parms tbl_cfg; struct tf_tcam_cfg_parms tcam_cfg; + struct tf_em_cfg_parms em_cfg; + struct tf_if_tbl_cfg_parms if_tbl_cfg; + struct tf_global_cfg_cfg_parms global_cfg; - dev_handle->type = TF_DEVICE_TYPE_WH; - /* Initial function initialization */ - dev_handle->ops = &tf_dev_ops_p4_init; - - dev_handle->type = TF_DEVICE_TYPE_WH; /* Initial function initialization */ dev_handle->ops = &tf_dev_ops_p4_init; @@ -86,6 +85,63 @@ dev_bind_p4(struct tf *tfp, goto fail; } + /* + * EEM + */ + em_cfg.num_elements = TF_EM_TBL_TYPE_MAX; + if (dev_handle->type == TF_DEVICE_TYPE_WH) + em_cfg.cfg = tf_em_ext_p4; + else + em_cfg.cfg = tf_em_ext_p45; + em_cfg.resources = resources; + em_cfg.mem_type = TF_EEM_MEM_TYPE_HOST; + rc = tf_em_ext_common_bind(tfp, &em_cfg); + if (rc) { + TFP_DRV_LOG(ERR, + "EEM initialization failure\n"); + goto fail; + } + + /* + * EM + */ + em_cfg.num_elements = TF_EM_TBL_TYPE_MAX; + em_cfg.cfg = tf_em_int_p4; + em_cfg.resources = resources; + em_cfg.mem_type = 0; /* Not used by EM */ + + rc = tf_em_int_bind(tfp, &em_cfg); + if (rc) { + TFP_DRV_LOG(ERR, + "EM initialization failure\n"); + goto fail; + } + + /* + * IF_TBL + */ + if_tbl_cfg.num_elements = TF_IF_TBL_TYPE_MAX; + if_tbl_cfg.cfg = tf_if_tbl_p4; + if_tbl_cfg.shadow_copy = shadow_copy; + rc = tf_if_tbl_bind(tfp, &if_tbl_cfg); + if (rc) { + TFP_DRV_LOG(ERR, + "IF Table initialization failure\n"); + goto fail; + } + + /* + * GLOBAL_CFG + */ + global_cfg.num_elements = TF_GLOBAL_CFG_TYPE_MAX; + global_cfg.cfg = tf_global_cfg_p4; + rc = tf_global_cfg_bind(tfp, &global_cfg); + if (rc) { + TFP_DRV_LOG(ERR, + "Global Cfg initialization failure\n"); + goto fail; + } + /* Final function initialization */ dev_handle->ops = &tf_dev_ops_p4; @@ -93,7 +149,7 @@ dev_bind_p4(struct tf *tfp, fail: /* Cleanup of already created modules */ - frc = dev_unbind_p4(tfp); + frc = tf_dev_unbind_p4(tfp); if (frc) return frc; @@ -111,7 +167,7 @@ dev_bind_p4(struct tf *tfp, * - (-EINVAL) on failure. */ static int -dev_unbind_p4(struct tf *tfp) +tf_dev_unbind_p4(struct tf *tfp) { int rc = 0; bool fail = false; @@ -119,7 +175,17 @@ dev_unbind_p4(struct tf *tfp) /* Unbind all the support modules. As this is only done on * close we only report errors as everything has to be cleaned * up regardless. + * + * In case of residuals TCAMs are cleaned up first as to + * invalidate the pipeline in a clean manner. */ + rc = tf_tcam_unbind(tfp); + if (rc) { + TFP_DRV_LOG(ERR, + "Device unbind failed, TCAM\n"); + fail = true; + } + rc = tf_ident_unbind(tfp); if (rc) { TFP_DRV_LOG(ERR, @@ -134,10 +200,31 @@ dev_unbind_p4(struct tf *tfp) fail = true; } - rc = tf_tcam_unbind(tfp); + rc = tf_em_ext_common_unbind(tfp); if (rc) { TFP_DRV_LOG(ERR, - "Device unbind failed, TCAM\n"); + "Device unbind failed, EEM\n"); + fail = true; + } + + rc = tf_em_int_unbind(tfp); + if (rc) { + TFP_DRV_LOG(ERR, + "Device unbind failed, EM\n"); + fail = true; + } + + rc = tf_if_tbl_unbind(tfp); + if (rc) { + TFP_DRV_LOG(ERR, + "Device unbind failed, IF Table Type\n"); + fail = true; + } + + rc = tf_global_cfg_unbind(tfp); + if (rc) { + TFP_DRV_LOG(ERR, + "Device unbind failed, Global Cfg Type\n"); fail = true; } @@ -148,18 +235,20 @@ dev_unbind_p4(struct tf *tfp) } int -dev_bind(struct tf *tfp __rte_unused, - enum tf_device_type type, - bool shadow_copy, - struct tf_session_resources *resources, - struct tf_dev_info *dev_handle) +tf_dev_bind(struct tf *tfp __rte_unused, + enum tf_device_type type, + bool shadow_copy, + struct tf_session_resources *resources, + struct tf_dev_info *dev_handle) { switch (type) { case TF_DEVICE_TYPE_WH: - return dev_bind_p4(tfp, - shadow_copy, - resources, - dev_handle); + case TF_DEVICE_TYPE_SR: + dev_handle->type = type; + return tf_dev_bind_p4(tfp, + shadow_copy, + resources, + dev_handle); default: TFP_DRV_LOG(ERR, "No such device\n"); @@ -168,12 +257,13 @@ dev_bind(struct tf *tfp __rte_unused, } int -dev_unbind(struct tf *tfp, - struct tf_dev_info *dev_handle) +tf_dev_unbind(struct tf *tfp, + struct tf_dev_info *dev_handle) { switch (dev_handle->type) { case TF_DEVICE_TYPE_WH: - return dev_unbind_p4(tfp); + case TF_DEVICE_TYPE_SR: + return tf_dev_unbind_p4(tfp); default: TFP_DRV_LOG(ERR, "No such device\n");