X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fbnxt%2Ftf_core%2Ftf_device.c;h=25a7166bbba45289883bfd4c226319742d38bec3;hb=f1f6ebc0eaf68a825c6175f5e6a436f7d91660c3;hp=9e71c04bf24d6cb15953c0e39d041bcfd048edab;hpb=08e1af1a7e07a99499deb96bbf12a4e4d663bd51;p=dpdk.git diff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c index 9e71c04bf2..25a7166bbb 100644 --- a/drivers/net/bnxt/tf_core/tf_device.c +++ b/drivers/net/bnxt/tf_core/tf_device.c @@ -9,9 +9,16 @@ #include "tfp.h" #include "tf_em.h" #include "tf_rm.h" +#ifdef TF_TCAM_SHARED +#include "tf_tcam_shared.h" +#include "tf_tbl_sram.h" +#endif /* TF_TCAM_SHARED */ struct tf; +/* Number of slices per row for WC TCAM */ +uint16_t g_wc_num_slices_per_row = TF_WC_TCAM_1_SLICE_PER_ROW; + /* Forward declarations */ static int tf_dev_unbind_p4(struct tf *tfp); static int tf_dev_unbind_p58(struct tf *tfp); @@ -44,7 +51,11 @@ tf_dev_reservation_check(uint16_t count, rm_num = (uint16_t *)reservations + i * count; for (j = 0; j < count; j++) { if ((cfg[j].cfg_type == TF_RM_ELEM_CFG_HCAPI || - cfg[j].cfg_type == TF_RM_ELEM_CFG_HCAPI_BA) && + cfg[j].cfg_type == TF_RM_ELEM_CFG_HCAPI_BA || + cfg[j].cfg_type == + TF_RM_ELEM_CFG_HCAPI_BA_PARENT || + cfg[j].cfg_type == + TF_RM_ELEM_CFG_HCAPI_BA_CHILD) && rm_num[j] > 0) cnt++; } @@ -76,7 +87,8 @@ static int tf_dev_bind_p4(struct tf *tfp, bool shadow_copy, struct tf_session_resources *resources, - struct tf_dev_info *dev_handle) + struct tf_dev_info *dev_handle, + enum tf_wc_num_slice wc_num_slices) { int rc; int frc; @@ -88,6 +100,12 @@ tf_dev_bind_p4(struct tf *tfp, struct tf_em_cfg_parms em_cfg; struct tf_if_tbl_cfg_parms if_tbl_cfg; struct tf_global_cfg_cfg_parms global_cfg; + struct tf_session *tfs; + + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) + return rc; /* Initial function initialization */ dev_handle->ops = &tf_dev_ops_p4_init; @@ -118,7 +136,6 @@ tf_dev_bind_p4(struct tf *tfp, if (rsv_cnt) { tbl_cfg.num_elements = TF_TBL_TYPE_MAX; tbl_cfg.cfg = tf_tbl_p4; - tbl_cfg.shadow_copy = shadow_copy; tbl_cfg.resources = resources; rc = tf_tbl_bind(tfp, &tbl_cfg); if (rc) { @@ -138,7 +155,12 @@ tf_dev_bind_p4(struct tf *tfp, tcam_cfg.cfg = tf_tcam_p4; tcam_cfg.shadow_copy = shadow_copy; tcam_cfg.resources = resources; + tcam_cfg.wc_num_slices = wc_num_slices; +#ifdef TF_TCAM_SHARED + rc = tf_tcam_shared_bind(tfp, &tcam_cfg); +#else /* !TF_TCAM_SHARED */ rc = tf_tcam_bind(tfp, &tcam_cfg); +#endif if (rc) { TFP_DRV_LOG(ERR, "TCAM initialization failure\n"); @@ -212,18 +234,19 @@ tf_dev_bind_p4(struct tf *tfp, 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; + if (!tf_session_is_shared_session(tfs)) { + /* + * 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; @@ -253,6 +276,12 @@ tf_dev_unbind_p4(struct tf *tfp) { int rc = 0; bool fail = false; + struct tf_session *tfs; + + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) + return rc; /* Unbind all the support modules. As this is only done on * close we only report errors as everything has to be cleaned @@ -261,53 +290,59 @@ tf_dev_unbind_p4(struct tf *tfp) * In case of residuals TCAMs are cleaned up first as to * invalidate the pipeline in a clean manner. */ +#ifdef TF_TCAM_SHARED + rc = tf_tcam_shared_unbind(tfp); +#else /* !TF_TCAM_SHARED */ rc = tf_tcam_unbind(tfp); +#endif /* TF_TCAM_SHARED */ if (rc) { - TFP_DRV_LOG(ERR, + TFP_DRV_LOG(INFO, "Device unbind failed, TCAM\n"); fail = true; } rc = tf_ident_unbind(tfp); if (rc) { - TFP_DRV_LOG(ERR, + TFP_DRV_LOG(INFO, "Device unbind failed, Identifier\n"); fail = true; } rc = tf_tbl_unbind(tfp); if (rc) { - TFP_DRV_LOG(ERR, + TFP_DRV_LOG(INFO, "Device unbind failed, Table Type\n"); fail = true; } rc = tf_em_ext_common_unbind(tfp); if (rc) { - TFP_DRV_LOG(ERR, + TFP_DRV_LOG(INFO, "Device unbind failed, EEM\n"); fail = true; } rc = tf_em_int_unbind(tfp); if (rc) { - TFP_DRV_LOG(ERR, + TFP_DRV_LOG(INFO, "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; - } + if (!tf_session_is_shared_session(tfs)) { + rc = tf_if_tbl_unbind(tfp); + if (rc) { + TFP_DRV_LOG(INFO, + "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; + rc = tf_global_cfg_unbind(tfp); + if (rc) { + TFP_DRV_LOG(INFO, + "Device unbind failed, Global Cfg Type\n"); + fail = true; + } } if (fail) @@ -339,7 +374,8 @@ static int tf_dev_bind_p58(struct tf *tfp, bool shadow_copy, struct tf_session_resources *resources, - struct tf_dev_info *dev_handle) + struct tf_dev_info *dev_handle, + enum tf_wc_num_slice wc_num_slices) { int rc; int frc; @@ -351,10 +387,16 @@ tf_dev_bind_p58(struct tf *tfp, struct tf_em_cfg_parms em_cfg; struct tf_if_tbl_cfg_parms if_tbl_cfg; struct tf_global_cfg_cfg_parms global_cfg; + struct tf_session *tfs; /* Initial function initialization */ dev_handle->ops = &tf_dev_ops_p58_init; + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) + return rc; + rsv_cnt = tf_dev_reservation_check(TF_IDENT_TYPE_MAX, tf_ident_p58, (uint16_t *)resources->ident_cnt); @@ -378,7 +420,6 @@ tf_dev_bind_p58(struct tf *tfp, if (rsv_cnt) { tbl_cfg.num_elements = TF_TBL_TYPE_MAX; tbl_cfg.cfg = tf_tbl_p58; - tbl_cfg.shadow_copy = shadow_copy; tbl_cfg.resources = resources; rc = tf_tbl_bind(tfp, &tbl_cfg); if (rc) { @@ -387,6 +428,13 @@ tf_dev_bind_p58(struct tf *tfp, goto fail; } no_rsv_flag = false; + + rc = tf_tbl_sram_bind(tfp); + if (rc) { + TFP_DRV_LOG(ERR, + "SRAM table initialization failure\n"); + goto fail; + } } rsv_cnt = tf_dev_reservation_check(TF_TCAM_TBL_TYPE_MAX, @@ -397,7 +445,12 @@ tf_dev_bind_p58(struct tf *tfp, tcam_cfg.cfg = tf_tcam_p58; tcam_cfg.shadow_copy = shadow_copy; tcam_cfg.resources = resources; + tcam_cfg.wc_num_slices = wc_num_slices; +#ifdef TF_TCAM_SHARED + rc = tf_tcam_shared_bind(tfp, &tcam_cfg); +#else /* !TF_TCAM_SHARED */ rc = tf_tcam_bind(tfp, &tcam_cfg); +#endif if (rc) { TFP_DRV_LOG(ERR, "TCAM initialization failure\n"); @@ -450,16 +503,18 @@ tf_dev_bind_p58(struct tf *tfp, goto fail; } - /* - * GLOBAL_CFG - */ - global_cfg.num_elements = TF_GLOBAL_CFG_TYPE_MAX; - global_cfg.cfg = tf_global_cfg_p58; - rc = tf_global_cfg_bind(tfp, &global_cfg); - if (rc) { - TFP_DRV_LOG(ERR, - "Global Cfg initialization failure\n"); - goto fail; + if (!tf_session_is_shared_session(tfs)) { + /* + * GLOBAL_CFG + */ + global_cfg.num_elements = TF_GLOBAL_CFG_TYPE_MAX; + global_cfg.cfg = tf_global_cfg_p58; + rc = tf_global_cfg_bind(tfp, &global_cfg); + if (rc) { + TFP_DRV_LOG(ERR, + "Global Cfg initialization failure\n"); + goto fail; + } } /* Final function initialization */ @@ -491,6 +546,12 @@ tf_dev_unbind_p58(struct tf *tfp) { int rc = 0; bool fail = false; + struct tf_session *tfs; + + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) + return rc; /* Unbind all the support modules. As this is only done on * close we only report errors as everything has to be cleaned @@ -499,30 +560,46 @@ tf_dev_unbind_p58(struct tf *tfp) * In case of residuals TCAMs are cleaned up first as to * invalidate the pipeline in a clean manner. */ +#ifdef TF_TCAM_SHARED + rc = tf_tcam_shared_unbind(tfp); +#else /* !TF_TCAM_SHARED */ rc = tf_tcam_unbind(tfp); +#endif /* TF_TCAM_SHARED */ if (rc) { - TFP_DRV_LOG(ERR, + TFP_DRV_LOG(INFO, "Device unbind failed, TCAM\n"); fail = true; } rc = tf_ident_unbind(tfp); if (rc) { - TFP_DRV_LOG(ERR, + TFP_DRV_LOG(INFO, "Device unbind failed, Identifier\n"); fail = true; } - rc = tf_tbl_unbind(tfp); + /* Unbind the SRAM table prior to table as the table manager + * owns and frees the table DB while the SRAM table manager owns + * and manages it's internal data structures. SRAM table manager + * relies on the table rm_db to exist. + */ + rc = tf_tbl_sram_unbind(tfp); if (rc) { TFP_DRV_LOG(ERR, + "Device unbind failed, SRAM table\n"); + fail = true; + } + + rc = tf_tbl_unbind(tfp); + if (rc) { + TFP_DRV_LOG(INFO, "Device unbind failed, Table Type\n"); fail = true; } rc = tf_em_int_unbind(tfp); if (rc) { - TFP_DRV_LOG(ERR, + TFP_DRV_LOG(INFO, "Device unbind failed, EM\n"); fail = true; } @@ -534,11 +611,13 @@ tf_dev_unbind_p58(struct tf *tfp) fail = true; } - rc = tf_global_cfg_unbind(tfp); - if (rc) { - TFP_DRV_LOG(ERR, - "Device unbind failed, Global Cfg Type\n"); - fail = true; + if (!tf_session_is_shared_session(tfs)) { + rc = tf_global_cfg_unbind(tfp); + if (rc) { + TFP_DRV_LOG(ERR, + "Device unbind failed, Global Cfg Type\n"); + fail = true; + } } if (fail) @@ -552,6 +631,7 @@ tf_dev_bind(struct tf *tfp __rte_unused, enum tf_device_type type, bool shadow_copy, struct tf_session_resources *resources, + uint16_t wc_num_slices, struct tf_dev_info *dev_handle) { switch (type) { @@ -561,13 +641,15 @@ tf_dev_bind(struct tf *tfp __rte_unused, return tf_dev_bind_p4(tfp, shadow_copy, resources, - dev_handle); + dev_handle, + wc_num_slices); case TF_DEVICE_TYPE_THOR: dev_handle->type = type; return tf_dev_bind_p58(tfp, shadow_copy, resources, - dev_handle); + dev_handle, + wc_num_slices); default: TFP_DRV_LOG(ERR, "No such device\n");