+ 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(INFO,
+ "Device unbind failed, Global Cfg Type\n");
+ fail = true;
+ }
+ }
+
+ if (fail)
+ return -1;
+
+ return rc;
+}
+
+/**
+ * Device specific bind function, THOR
+ *
+ * [in] tfp
+ * Pointer to TF handle
+ *
+ * [in] shadow_copy
+ * Flag controlling shadow copy DB creation
+ *
+ * [in] resources
+ * Pointer to resource allocation information
+ *
+ * [out] dev_handle
+ * Device handle
+ *
+ * Returns
+ * - (0) if successful.
+ * - (-EINVAL) on parameter or internal failure.
+ */
+static int
+tf_dev_bind_p58(struct tf *tfp,
+ bool shadow_copy,
+ struct tf_session_resources *resources,
+ struct tf_dev_info *dev_handle)
+{
+ int rc;
+ int frc;
+ int rsv_cnt;
+ bool no_rsv_flag = true;
+ 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;
+ 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);
+ if (rsv_cnt) {
+ ident_cfg.num_elements = TF_IDENT_TYPE_MAX;
+ ident_cfg.cfg = tf_ident_p58;
+ ident_cfg.shadow_copy = shadow_copy;
+ ident_cfg.resources = resources;
+ rc = tf_ident_bind(tfp, &ident_cfg);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Identifier initialization failure\n");
+ goto fail;
+ }
+ no_rsv_flag = false;
+ }
+
+ rsv_cnt = tf_dev_reservation_check(TF_TBL_TYPE_MAX,
+ tf_tbl_p58,
+ (uint16_t *)resources->tbl_cnt);
+ 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) {
+ TFP_DRV_LOG(ERR,
+ "Table initialization failure\n");
+ goto fail;
+ }
+ no_rsv_flag = false;
+ }
+
+ rsv_cnt = tf_dev_reservation_check(TF_TCAM_TBL_TYPE_MAX,
+ tf_tcam_p58,
+ (uint16_t *)resources->tcam_cnt);
+ if (rsv_cnt) {
+ tcam_cfg.num_elements = TF_TCAM_TBL_TYPE_MAX;
+ tcam_cfg.cfg = tf_tcam_p58;
+ tcam_cfg.shadow_copy = shadow_copy;
+ tcam_cfg.resources = resources;
+#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");
+ goto fail;
+ }
+ no_rsv_flag = false;
+ }
+
+ /*
+ * EM
+ */
+ rsv_cnt = tf_dev_reservation_check(TF_EM_TBL_TYPE_MAX,
+ tf_em_int_p58,
+ (uint16_t *)resources->em_cnt);
+ if (rsv_cnt) {
+ em_cfg.num_elements = TF_EM_TBL_TYPE_MAX;
+ em_cfg.cfg = tf_em_int_p58;
+ 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;
+ }
+ no_rsv_flag = false;
+ }
+
+ /*
+ * There is no rm reserved for any tables
+ *
+ */
+ if (no_rsv_flag) {
+ TFP_DRV_LOG(ERR,
+ "No rm reserved for any tables\n");
+ return -ENOMEM;
+ }
+
+ /*
+ * IF_TBL
+ */
+ if_tbl_cfg.num_elements = TF_IF_TBL_TYPE_MAX;
+ if_tbl_cfg.cfg = tf_if_tbl_p58;
+ if_tbl_cfg.shadow_copy = shadow_copy;
+ rc = tf_if_tbl_bind(tfp, &if_tbl_cfg);