union tf_session_id *session_id;
struct tf_dev_info dev;
bool shared_session_creator;
+ int name_len;
+ char *name;
TF_CHECK_PARMS2(tfp, parms);
session_id->id = session->session_id.id;
session->shadow_copy = parms->open_cfg->shadow_copy;
- session->bp = parms->open_cfg->bp;
/* Init session client list */
ll_init(&session->client_ll);
/* Init session em_ext_db */
session->em_ext_db_handle = NULL;
- if (!strcmp(parms->open_cfg->ctrl_chan_name, "tf_share"))
+
+ /* Populate the request */
+ name_len = strnlen(parms->open_cfg->ctrl_chan_name,
+ TF_SESSION_NAME_MAX);
+ name = &parms->open_cfg->ctrl_chan_name[name_len - strlen("tf_shared")];
+ if (!strncmp(name, "tf_shared", strlen("tf_shared")))
+ session->shared_session = true;
+
+ name = &parms->open_cfg->ctrl_chan_name[name_len -
+ strlen("tf_shared-wc_tcam")];
+ if (!strncmp(name, "tf_shared-wc_tcam", strlen("tf_shared-wc_tcam")))
session->shared_session = true;
if (session->shared_session && shared_session_creator) {
return 0;
cleanup:
+ rc = tf_msg_session_close(tfp,
+ fw_session_id,
+ dev.ops->tf_dev_get_mailbox());
+ if (rc) {
+ /* Log error */
+ TFP_DRV_LOG(ERR,
+ "FW Session close failed, rc:%s\n",
+ strerror(-rc));
+ }
+
tfp_free(tfp->session->core_data);
tfp_free(tfp->session);
tfp->session = NULL;
int rc;
struct tf_session_client_create_parms scparms;
- TF_CHECK_PARMS2(tfp, parms);
+ TF_CHECK_PARMS3(tfp, parms, parms->open_cfg->bp);
+ tfp->bp = parms->open_cfg->bp;
/* Decide if we're creating a new session or session client */
if (tfp->session == NULL) {
rc = tf_session_create(tfp, parms);
}
TFP_DRV_LOG(INFO,
- "Session created, session_client_id:%d, session_id:%d\n",
+ "Session created, session_client_id:%d,"
+ "session_id:0x%08x, fw_session_id:%d\n",
parms->open_cfg->session_client_id.id,
- parms->open_cfg->session_id.id);
+ parms->open_cfg->session_id.id,
+ parms->open_cfg->session_id.internal.fw_session_id);
} else {
scparms.ctrl_chan_name = parms->open_cfg->ctrl_chan_name;
scparms.session_client_id = &parms->open_cfg->session_client_id;
rc = tf_session_client_create(tfp, &scparms);
if (rc) {
TFP_DRV_LOG(ERR,
- "Failed to create client on session %d, rc:%s\n",
+ "Failed to create client on session 0x%x, rc:%s\n",
parms->open_cfg->session_id.id,
strerror(-rc));
return rc;
}
TFP_DRV_LOG(INFO,
- "Session Client:%d created on session:%d\n",
- parms->open_cfg->session_client_id.id,
- parms->open_cfg->session_id.id);
+ "Session Client:%d registered on session:0x%8x\n",
+ scparms.session_client_id->internal.fw_session_client_id,
+ tfp->session->session_id.id);
}
return 0;
struct tf_dev_info *tfd = NULL;
struct tf_session_client_destroy_parms scdparms;
uint16_t fid;
+ uint8_t fw_session_id = 1;
+ int mailbox = 0;
TF_CHECK_PARMS2(tfp, parms);
client->session_client_id.id);
TFP_DRV_LOG(INFO,
- "session_id:%d, ref_count:%d\n",
+ "session_id:0x%08x, ref_count:%d\n",
tfs->session_id.id,
tfs->ref_count);
return rc;
}
+ mailbox = tfd->ops->tf_dev_get_mailbox();
+
+ rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Unable to lookup FW id, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+
/* Unbind the device */
rc = tf_dev_unbind(tfp, tfd);
if (rc) {
strerror(-rc));
}
- rc = tf_msg_session_close(tfp, tfs);
+ rc = tf_msg_session_close(tfp, fw_session_id, mailbox);
if (rc) {
/* Log error */
TFP_DRV_LOG(ERR,
tfs->ref_count--;
TFP_DRV_LOG(INFO,
- "Closed session, session_id:%d, ref_count:%d\n",
+ "Closed session, session_id:0x%08x, ref_count:%d\n",
tfs->session_id.id,
tfs->ref_count);
if (tfs->id_db_handle)
*db_handle = tfs->id_db_handle;
else
- rc = -EINVAL;
+ rc = -ENOMEM;
break;
case TF_MODULE_TYPE_TABLE:
if (tfs->tbl_db_handle)
*db_handle = tfs->tbl_db_handle;
else
- rc = -EINVAL;
+ rc = -ENOMEM;
break;
case TF_MODULE_TYPE_TCAM:
if (tfs->tcam_db_handle)
*db_handle = tfs->tcam_db_handle;
else
- rc = -EINVAL;
+ rc = -ENOMEM;
break;
case TF_MODULE_TYPE_EM:
if (tfs->em_db_handle)
*db_handle = tfs->em_db_handle;
else
- rc = -EINVAL;
+ rc = -ENOMEM;
break;
default:
rc = -EINVAL;
return rc;
}
+
+#ifdef TF_TCAM_SHARED
+
+int
+tf_session_get_tcam_shared_db(struct tf *tfp,
+ void **tcam_shared_db_handle)
+{
+ struct tf_session *tfs = NULL;
+ int rc = 0;
+
+ *tcam_shared_db_handle = NULL;
+
+ if (tfp == NULL)
+ return (-EINVAL);
+
+ rc = tf_session_get_session_internal(tfp, &tfs);
+ if (rc)
+ return rc;
+
+ *tcam_shared_db_handle = tfs->tcam_shared_db_handle;
+ return rc;
+}
+
+int
+tf_session_set_tcam_shared_db(struct tf *tfp,
+ void *tcam_shared_db_handle)
+{
+ struct tf_session *tfs = NULL;
+ int rc = 0;
+
+ if (tfp == NULL)
+ return (-EINVAL);
+
+ rc = tf_session_get_session_internal(tfp, &tfs);
+ if (rc)
+ return rc;
+
+ tfs->tcam_shared_db_handle = tcam_shared_db_handle;
+ return rc;
+}
+#endif /* TF_TCAM_SHARED */