int rc;
unsigned int domain, bus, slot, device;
struct tf_session_open_session_parms oparms;
- int name_len;
- char *name;
TF_CHECK_PARMS2(tfp, parms);
}
}
- name_len = strlen(parms->ctrl_chan_name);
- name = &parms->ctrl_chan_name[name_len - strlen("tf_shared")];
- if (!strncmp(name, "tf_shared", strlen("tf_shared"))) {
- memset(parms->ctrl_chan_name, 0, strlen(parms->ctrl_chan_name));
- strcpy(parms->ctrl_chan_name, "tf_share");
- }
-
parms->session_id.internal.domain = domain;
parms->session_id.internal.bus = bus;
parms->session_id.internal.device = device;
*/
struct tf {
struct tf_session_info *session;
+ /**
+ * the pointer to the parent bp struct
+ */
+ void *bp;
};
/**
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++;
}
*/
rc = tf_tcam_unbind(tfp);
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,
+ 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,
+ TFP_DRV_LOG(INFO,
"Device unbind failed, Global Cfg Type\n");
fail = true;
}
*/
rc = tf_tcam_unbind(tfp);
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_int_unbind(tfp);
if (rc) {
- TFP_DRV_LOG(ERR,
+ TFP_DRV_LOG(INFO,
"Device unbind failed, EM\n");
fail = true;
}
parms.hcapi_type = &hcapi_type;
rc = tf_rm_get_hcapi_type(&parms);
- if (rc)
- return rc;
+ if (rc) {
+ *base = 0;
+ *shift = 0;
+ return 0;
+ }
switch (hcapi_type) {
case CFA_RESOURCE_TYPE_P58_SRAM_BANK_0:
rc = tf_session_get_db(tfp, TF_MODULE_TYPE_EM, &em_db_ptr);
if (rc) {
- TFP_DRV_LOG(ERR,
- "Failed to get em_ext_db from session, rc:%s\n",
+ TFP_DRV_LOG(INFO,
+ "Em_db is not initialized, rc:%s\n",
strerror(-rc));
- return rc;
+ return 0;
}
em_db = (struct em_rm_db *)em_db_ptr;
for (i = 0; i < TF_DIR_MAX; i++) {
+ if (em_db->em_db[i] == NULL)
+ continue;
fparms.dir = i;
fparms.rm_db = em_db->em_db[i];
- if (em_db->em_db[i] != NULL) {
- rc = tf_rm_free_db(tfp, &fparms);
- if (rc)
- return rc;
- }
+ rc = tf_rm_free_db(tfp, &fparms);
+ if (rc)
+ return rc;
em_db->em_db[i] = NULL;
}
rc = tf_session_get_db(tfp, TF_MODULE_TYPE_EM, &em_db_ptr);
if (rc) {
- TFP_DRV_LOG(ERR,
- "Failed to get em_ext_db from session, rc:%s\n",
- strerror(-rc));
- return rc;
+ TFP_DRV_LOG(INFO,
+ "No resource allocated for em from session\n");
+ return 0;
}
em_db = (struct em_rm_db *)em_db_ptr;
rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr);
if (rc) {
- TFP_DRV_LOG(ERR,
- "Failed to get ident_db from session, rc:%s\n",
+ TFP_DRV_LOG(INFO,
+ "Ident_db is not initialized, rc:%s\n",
strerror(-rc));
- return rc;
+ return 0;
}
ident_db = (struct ident_rm_db *)ident_db_ptr;
for (i = 0; i < TF_DIR_MAX; i++) {
+ if (ident_db->ident_db[i] == NULL)
+ continue;
fparms.rm_db = ident_db->ident_db[i];
fparms.dir = i;
rc = tf_rm_free_db(tfp, &fparms);
rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr);
if (rc) {
- TFP_DRV_LOG(ERR,
- "Failed to get ident_db from session, rc:%s\n",
- strerror(-rc));
- return rc;
+ TFP_DRV_LOG(INFO,
+ "No resource allocated for ident from session\n");
+ return 0;
}
ident_db = (struct ident_rm_db *)ident_db_ptr;
struct hwrm_tf_session_open_input req = { 0 };
struct hwrm_tf_session_open_output resp = { 0 };
struct tfp_send_msg_parms parms = { 0 };
+ int name_len;
+ char *name;
/* Populate the request */
- tfp_memcpy(&req.session_name, ctrl_chan_name, TF_SESSION_NAME_MAX);
+ name_len = strnlen(ctrl_chan_name, TF_SESSION_NAME_MAX);
+ name = &ctrl_chan_name[name_len - strlen("tf_shared")];
+ if (!strncmp(name, "tf_shared", strlen("tf_shared")))
+ tfp_memcpy(&req.session_name, name, strlen("tf_share"));
+ else
+ tfp_memcpy(&req.session_name, ctrl_chan_name, TF_SESSION_NAME_MAX);
parms.tf_type = HWRM_TF_SESSION_OPEN;
parms.req_data = (uint32_t *)&req;
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
&parms);
if (rc)
return rc;
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
&parms);
return rc;
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
&parms);
return rc;
}
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
&parms);
return rc;
}
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp), &parms);
if (rc)
goto cleanup;
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp), &parms);
if (rc)
goto cleanup;
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp), &parms);
if (rc)
goto cleanup;
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp), &parms);
tf_msg_free_dma_buf(&resv_buf);
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
&parms);
if (rc)
return rc;
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
&parms);
if (rc)
return rc;
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
&parms);
if (rc)
return rc;
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
&parms);
if (rc)
return rc;
parms.resp_data = (uint32_t *)&resp;
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp), &parms);
if (rc) {
TFP_DRV_LOG(ERR, "Failed ext_em_alloc error rc:%s\n",
strerror(-rc));
parms.resp_data = (uint32_t *)&resp;
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp), &parms);
return rc;
}
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
&parms);
if (rc)
return rc;
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
&parms);
return rc;
}
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
&parms);
if (rc)
return rc;
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
&parms);
return rc;
}
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
&parms);
return rc;
}
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
&parms);
return rc;
}
mparms.resp_size = sizeof(resp);
mparms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
&mparms);
cleanup:
mparms.resp_size = sizeof(resp);
mparms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
&mparms);
if (rc != 0)
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
&parms);
return rc;
}
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
&parms);
if (rc)
return rc;
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
&parms);
if (rc)
return rc;
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp), &parms);
if (rc != 0)
return rc;
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp), &parms);
if (rc != 0)
return rc;
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs),
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
&parms);
if (rc)
return rc;
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp), &parms);
if (rc != 0)
return rc;
parms.resp_size = sizeof(resp);
parms.mailbox = dev->ops->tf_dev_get_mailbox();
- rc = tfp_send_msg_direct(tf_session_get_bp(tfs), &parms);
+ rc = tfp_send_msg_direct(tf_session_get_bp(tfp), &parms);
if (rc != 0)
return rc;
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;
if (session->shared_session && shared_session_creator) {
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);
*/
void *em_db_handle;
- /**
- * the pointer to the parent bp struct
- */
- void *bp;
-
/**
* EM allocator for session
*/
* - the pointer to the parent bnxt struct
*/
static inline struct bnxt*
-tf_session_get_bp(struct tf_session *tfs)
+tf_session_get_bp(struct tf *tfp)
{
- return tfs->bp;
+ return tfp->bp;
}
#endif /* _TF_SESSION_H_ */
rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
if (rc) {
- TFP_DRV_LOG(ERR,
- "Failed to get em_ext_db from session, rc:%s\n",
+ TFP_DRV_LOG(INFO,
+ "Tbl_db is not initialized, rc:%s\n",
strerror(-rc));
- return rc;
+ return 0;
}
tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
for (i = 0; i < TF_DIR_MAX; i++) {
+ if (tbl_db->tbl_db[i] == NULL)
+ continue;
fparms.dir = i;
fparms.rm_db = tbl_db->tbl_db[i];
rc = tf_rm_free_db(tfp, &fparms);
struct tf_tbl_resource_info *tbl)
{
int rc;
- int d;
+ int d, i;
struct tf_resource_info *dinfo;
struct tf_rm_get_alloc_info_parms ainfo;
void *tbl_db_ptr = NULL;
struct tbl_rm_db *tbl_db;
+ uint16_t base = 0, shift = 0;
+ struct tf_dev_info *dev;
+ struct tf_session *tfs;
TF_CHECK_PARMS2(tfp, tbl);
+ /* Retrieve the session information */
+ rc = tf_session_get_session_internal(tfp, &tfs);
+ if (rc)
+ return rc;
+
+ /* Retrieve the device information */
+ rc = tf_session_get_device(tfs, &dev);
+ if (rc)
+ return rc;
+
rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
if (rc) {
- TFP_DRV_LOG(ERR,
- "Failed to get em_ext_db from session, rc:%s\n",
- strerror(-rc));
- return rc;
+ TFP_DRV_LOG(INFO,
+ "No resource allocated for table from session\n");
+ return 0;
}
tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
+
/* check if reserved resource for WC is multiple of num_slices */
for (d = 0; d < TF_DIR_MAX; d++) {
ainfo.rm_db = tbl_db->tbl_db[d];
rc = tf_rm_get_all_info(&ainfo, TF_TBL_TYPE_MAX);
if (rc)
return rc;
+
+ if (dev->ops->tf_dev_get_tbl_info) {
+ /* Adjust all */
+ for (i = 0; i < TF_TBL_TYPE_MAX; i++) {
+ /* Only get table info if required for the device */
+ rc = dev->ops->tf_dev_get_tbl_info(tfp,
+ tbl_db->tbl_db[d],
+ i,
+ &base,
+ &shift);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s: Failed to get table info:%d\n",
+ tf_dir_2_str(d),
+ i);
+ return rc;
+ }
+ if (dinfo[i].stride)
+ TF_TBL_RM_TO_PTR(&dinfo[i].start,
+ dinfo[i].start,
+ base,
+ shift);
+ }
+ }
}
+
+
return 0;
}
rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
if (rc) {
- TFP_DRV_LOG(ERR,
- "Failed to get em_ext_db from session, rc:%s\n",
+ TFP_DRV_LOG(INFO,
+ "Tcam_db is not initialized, rc:%s\n",
strerror(-rc));
- return rc;
+ return 0;
}
tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
for (i = 0; i < TF_DIR_MAX; i++) {
+ if (tcam_db->tcam_db[i] == NULL)
+ continue;
memset(&fparms, 0, sizeof(fparms));
fparms.dir = i;
fparms.rm_db = tcam_db->tcam_db[i];
rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
if (rc) {
- TFP_DRV_LOG(ERR,
- "Failed to get em_ext_db from session, rc:%s\n",
- strerror(-rc));
- return rc;
+ TFP_DRV_LOG(INFO,
+ "No resource allocated for tcam from session\n");
+ return 0;
}
tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
if (tfp == NULL || fw_fid == NULL)
return -EINVAL;
- bp = container_of(tfp, struct bnxt, tfp);
+ bp = (struct bnxt *)tfp->bp;
if (bp == NULL)
return -EINVAL;
if (tfp == NULL || pf == NULL)
return -EINVAL;
- bp = container_of(tfp, struct bnxt, tfp);
+ bp = (struct bnxt *)tfp->bp;
if (BNXT_VF(bp) && bp->parent) {
*pf = bp->parent->fid - 1;
return 0;