- Close FW session if session open fails after Fw session open.
- Additional WC TCAM debug info to help in future debug
- Reduce key/mask buffer sizes for performance
- When a 64b counter is freed, clear the entry
Signed-off-by: Jay Ding <jay.ding@broadcom.com>
Signed-off-by: Farah Smith <farah.smith@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
TF_CHECK_PARMS2(tfp, em);
rc = tf_session_get_db(tfp, TF_MODULE_TYPE_EM, &em_db_ptr);
- if (rc) {
- TFP_DRV_LOG(INFO,
- "No resource allocated for em from session\n");
- return 0;
- }
+ if (rc == -ENOMEM)
+ return 0; /* db does not exist */
+ else if (rc)
+ return rc; /* db error */
+
em_db = (struct em_rm_db *)em_db_ptr;
- /* check if reserved resource for WC is multiple of num_slices */
+ /* check if reserved resource for EM is multiple of num_slices */
for (d = 0; d < TF_DIR_MAX; d++) {
ainfo.rm_db = em_db->em_db[d];
dinfo = em[d].info;
+ if (!ainfo.rm_db)
+ continue;
+
ainfo.info = (struct tf_rm_alloc_info *)dinfo;
ainfo.subtype = 0;
rc = tf_rm_get_all_info(&ainfo, TF_EM_TBL_TYPE_MAX);
TF_CHECK_PARMS2(tfp, ident);
rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr);
- if (rc) {
- TFP_DRV_LOG(INFO,
- "No resource allocated for ident from session\n");
- return 0;
- }
+ if (rc == -ENOMEM)
+ return 0; /* db doesn't exist */
+ else if (rc)
+ return rc; /* error getting db */
+
ident_db = (struct ident_rm_db *)ident_db_ptr;
/* check if reserved resource for WC is multiple of num_slices */
for (d = 0; d < TF_DIR_MAX; d++) {
ainfo.rm_db = ident_db->ident_db[d];
+
+ if (!ainfo.rm_db)
+ continue;
+
dinfo = ident[d].info;
ainfo.info = (struct tf_rm_alloc_info *)dinfo;
int
tf_msg_session_close(struct tf *tfp,
- struct tf_session *tfs)
+ uint8_t fw_session_id,
+ int mailbox)
{
int rc;
struct hwrm_tf_session_close_input req = { 0 };
struct hwrm_tf_session_close_output resp = { 0 };
struct tfp_send_msg_parms parms = { 0 };
- uint8_t fw_session_id;
- struct tf_dev_info *dev;
-
- /* Retrieve the device information */
- rc = tf_session_get_device(tfs, &dev);
- if (rc) {
- TFP_DRV_LOG(ERR,
- "Failed to lookup device, rc:%s\n",
- strerror(-rc));
- return rc;
- }
-
- 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;
- }
/* Populate the request */
req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
parms.req_size = sizeof(req);
parms.resp_data = (uint32_t *)&resp;
parms.resp_size = sizeof(resp);
- parms.mailbox = dev->ops->tf_dev_get_mailbox();
+ parms.mailbox = mailbox;
rc = tfp_send_msg_direct(tf_session_get_bp(tfp),
&parms);
* [in] session
* Pointer to session handle
*
+ * [in] fw_session_id
+ * fw session id
+ *
+ * [in] mailbox
+ * mailbox
+ *
* Returns:
* 0 on Success else internal Truflow error
*/
int tf_msg_session_close(struct tf *tfp,
- struct tf_session *tfs);
+ uint8_t fw_session_id,
+ int mailbox);
/**
* Sends session query config request to TF Firmware
#include "tfp.h"
#include "tf_msg.h"
-/* Logging defines */
-#define TF_RM_DEBUG 0
-
/**
* Generic RM Element data type that an RM DB is build upon.
*/
return rc;
}
-/**
- * Logs an array of found residual entries to the console.
- *
- * [in] dir
- * Receive or transmit direction
- *
- * [in] module
- * Type of Device Module
- *
- * [in] count
- * Number of entries in the residual array
- *
- * [in] residuals
- * Pointer to an array of residual entries. Array is index same as
- * the DB in which this function is used. Each entry holds residual
- * value for that entry.
- */
-static void
-tf_rm_log_residuals(enum tf_dir dir,
- enum tf_module_type module,
- uint16_t count,
- uint16_t *residuals)
-{
- int i;
-
- /* Walk the residual array and log the types that wasn't
- * cleaned up to the console.
- */
- for (i = 0; i < count; i++) {
- if (residuals[i] != 0)
- TFP_DRV_LOG(ERR,
- "%s, %s was not cleaned up, %d outstanding\n",
- tf_dir_2_str(dir),
- tf_module_subtype_2_str(module, i),
- residuals[i]);
- }
-}
-
/**
* Performs a check of the passed in DB for any lingering elements. If
* a resource type was found to not have been cleaned up by the caller
*resv_size = found;
}
- tf_rm_log_residuals(rm_db->dir,
- rm_db->module,
- rm_db->num_entries,
- residuals);
-
tfp_free((void *)residuals);
*resv = local_resv;
&hcapi_items);
if (hcapi_items == 0) {
- TFP_DRV_LOG(ERR,
- "%s: module:%s Empty RM DB create request\n",
- tf_dir_2_str(parms->dir),
- tf_module_2_str(parms->module));
-
parms->rm_db = NULL;
return -ENOMEM;
}
struct tf_rm_alloc_info *info = parms->info;
int i;
- TF_CHECK_PARMS2(parms, parms->rm_db);
+ TF_CHECK_PARMS1(parms);
+
+ /* No rm info available for this module type
+ */
+ if (!parms->rm_db)
+ return -ENOMEM;
+
rm_db = (struct tf_rm_new_db *)parms->rm_db;
TF_CHECK_PARMS1(rm_db->db);
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;
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);
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,
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;
parms->idx);
return -EINVAL;
}
+
+ /* If this is counter table, clear the entry on free */
+ if (parms->type == TF_TBL_TYPE_ACT_STATS_64) {
+ uint8_t data[8] = { 0 };
+ uint16_t hcapi_type = 0;
+ struct tf_rm_get_hcapi_parms hparms = { 0 };
+
+ /* Get the hcapi type */
+ hparms.rm_db = tbl_db->tbl_db[parms->dir];
+ hparms.subtype = parms->type;
+ hparms.hcapi_type = &hcapi_type;
+ rc = tf_rm_get_hcapi_type(&hparms);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s, Failed type lookup, type:%d, rc:%s\n",
+ tf_dir_2_str(parms->dir),
+ parms->type,
+ strerror(-rc));
+ return rc;
+ }
+ /* Clear the counter
+ */
+ rc = tf_msg_set_tbl_entry(tfp,
+ parms->dir,
+ hcapi_type,
+ sizeof(data),
+ data,
+ parms->idx);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s, Set failed, type:%d, rc:%s\n",
+ tf_dir_2_str(parms->dir),
+ parms->type,
+ strerror(-rc));
+ return rc;
+ }
+ }
+
/* Free requested element */
fparms.rm_db = tbl_db->tbl_db[parms->dir];
fparms.subtype = parms->type;
return rc;
rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
- if (rc) {
- TFP_DRV_LOG(INFO,
- "No resource allocated for table from session\n");
- return 0;
- }
+ if (rc == -ENOMEM)
+ return 0; /* db doesn't exist */
+ else if (rc)
+ return rc; /* error getting db */
+
tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
/* check if reserved resource for WC is multiple of num_slices */
ainfo.rm_db = tbl_db->tbl_db[d];
dinfo = tbl[d].info;
+ if (!ainfo.rm_db)
+ continue;
+
ainfo.info = (struct tf_rm_alloc_info *)dinfo;
ainfo.subtype = 0;
rc = tf_rm_get_all_info(&ainfo, TF_TBL_TYPE_MAX);
TF_CHECK_PARMS2(tfp, tcam);
rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
- if (rc) {
- TFP_DRV_LOG(INFO,
- "No resource allocated for tcam from session\n");
- return 0;
- }
+ if (rc == -ENOMEM)
+ return 0; /* db doesn't exist */
+ else if (rc)
+ return rc; /* error getting db */
+
tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
/* check if reserved resource for WC is multiple of num_slices */
for (d = 0; d < TF_DIR_MAX; d++) {
ainfo.rm_db = tcam_db->tcam_db[d];
+
+ if (!ainfo.rm_db)
+ continue;
+
dinfo = tcam[d].info;
ainfo.info = (struct tf_rm_alloc_info *)dinfo;
return 0;
}
-/* Temporary builder defines pulled in here and renamed
+/* Normally, device specific code wouldn't reside here, it belongs
+ * in a separate device specific function in tf_device_pxx.c.
+ * But this code is placed here as it is not a long term solution
+ * and we would like to have this code centrally located for easy
+ * removal
*/
-#define TF_TMP_MAX_FIELD_BITLEN 512
+#define TF_TCAM_SHARED_KEY_SLICE_SZ_BYTES_P4 12
+#define TF_TCAM_SHARED_REMAP_SZ_BYTES_P4 4
+#define TF_TCAM_SHARED_KEY_SLICE_SZ_BYTES_P58 24
+#define TF_TCAM_SHARED_REMAP_SZ_BYTES_P58 8
+/* Temporary builder defines pulled in here and adjusted
+ * for max WC TCAM values
+ */
union tf_tmp_field_obj {
- uint8_t bytes[(TF_TMP_MAX_FIELD_BITLEN + 7) / 8];
+ uint32_t words[(TF_TCAM_SHARED_REMAP_SZ_BYTES_P58 + 3) / 4];
+ uint8_t bytes[TF_TCAM_SHARED_REMAP_SZ_BYTES_P58];
};
-#define TF_TMP_MAX_KEY_BITLEN 768
-#define TF_TMP_MAX_KEY_WORDLEN ((TF_TMP_MAX_KEY_BITLEN + 63) / 64)
-
union tf_tmp_key {
- uint32_t words[(TF_TMP_MAX_KEY_BITLEN + 31) / 32];
- uint8_t bytes[(TF_TMP_MAX_KEY_BITLEN + 7) / 8];
+ uint32_t words[(TF_TCAM_SHARED_KEY_SLICE_SZ_BYTES_P58 + 3) / 4];
+ uint8_t bytes[TF_TCAM_SHARED_KEY_SLICE_SZ_BYTES_P58];
};
/** p58 has an enable bit, p4 does not
if (rc) {
/* Log error */
TFP_DRV_LOG(ERR,
- "%s: WC_TCAM_LOW phyid(%d) set failed, rc:%s",
+ "%s: WC_TCAM_LOW phyid(%d/0x%x) set failed, rc:%s",
tf_dir_2_str(dir),
sparms.idx,
+ sparms.idx,
strerror(-rc));
return rc;
}
if (rc) {
/* Log error */
TFP_DRV_LOG(ERR,
- "%s: %s: phyid(%d) free failed, rc:%s\n",
+ "%s: %s: phyid(%d/0x%x) free failed, rc:%s\n",
tf_dir_2_str(dir),
tf_tcam_tbl_2_str(fparms.type),
sphy_idx,
+ sphy_idx,
strerror(-rc));
return rc;
}
return rc;
}
-/* Normally, device specific code wouldn't reside here, it belongs
- * in a separate device specific function in tf_device_pxx.c.
- * But this code is placed here as it is not a long term solution
- * and we would like to have this code centrally located for easy
- * removal
- */
-#define TF_TCAM_SHARED_KEY_SLICE_SZ_BYTES_P4 12
-#define TF_TCAM_SHARED_REMAP_SZ_BYTES_P4 4
-
int tf_tcam_shared_move_p4(struct tf *tfp,
struct tf_move_tcam_shared_entries_parms *parms)
{
return rc;
}
-#define TF_TCAM_SHARED_KEY_SLICE_SZ_BYTES_P58 24
-#define TF_TCAM_SHARED_REMAP_SZ_BYTES_P58 8
int tf_tcam_shared_move_p58(struct tf *tfp,
struct tf_move_tcam_shared_entries_parms *parms)