@@ -1800,6 +1800,21 @@ int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
/* Initialize bnxt ULP port details */
if (bnxt_enable_ulp(bp)) {
+ if (BNXT_CHIP_P7(bp)) {
+ /* Need to release the Fid from AFM control */
+ rc = bnxt_hwrm_release_afm_func(bp, bp->fw_fid,
+ bp->fw_fid,
+ HWRM_CFA_RELEASE_AFM_FUNC_INPUT_TYPE_RFID,
+ 0);
+ if (rc) {
+ PMD_DRV_LOG(ERR,
+ "Failed in hwrm release afm func:%u rc=%d\n",
+ bp->fw_fid, rc);
+ goto error;
+ }
+ PMD_DRV_LOG(DEBUG, "Released RFID:%d\n", bp->fw_fid);
+ }
+
rc = bnxt_ulp_port_init(bp);
if (rc)
goto error;
@@ -34,7 +34,7 @@ static const struct eth_dev_ops bnxt_rep_dev_ops = {
static bool bnxt_rep_check_parent(struct bnxt_representor *rep)
{
- if (!rep->parent_dev->data->dev_private)
+ if (!rep->parent_dev->data || !rep->parent_dev->data->dev_private)
return false;
return true;
@@ -357,28 +357,41 @@ static int bnxt_tf_vfr_alloc(struct rte_eth_dev *vfr_ethdev)
rc = bnxt_hwrm_release_afm_func(parent_bp,
vfr->fw_fid,
parent_bp->fw_fid,
- HWRM_CFA_RELEASE_AFM_FUNC_INPUT_TYPE_RFID,
+ HWRM_CFA_RELEASE_AFM_FUNC_INPUT_TYPE_EFID,
0);
- if (rc)
+ if (rc) {
PMD_DRV_LOG(ERR,
- "Failed in hwrm release afm func:%u rc=%d\n",
- vfr->vf_id, rc);
+ "Failed to release EFID:%d from RFID:%d rc=%d\n",
+ vfr->vf_id, parent_bp->fw_fid, rc);
+ goto error_del_rules;
+ }
+ PMD_DRV_LOG(DEBUG, "Released EFID:%d from RFID:%d\n",
+ vfr->fw_fid, parent_bp->fw_fid);
+
} else {
rc = bnxt_hwrm_cfa_pair_alloc(parent_bp, vfr);
- if (rc)
+ if (rc) {
PMD_DRV_LOG(ERR,
"Failed in hwrm vfr alloc vfr:%u rc=%d\n",
vfr->vf_id, rc);
+ goto error_del_rules;
+ }
}
+ /* if supported, it will add the vfr endpoint to the session, otherwise
+ * it returns success
+ */
+ rc = bnxt_ulp_vfr_session_fid_add(parent_bp->ulp_ctx, vfr->fw_fid);
if (rc)
- (void)bnxt_ulp_delete_vfr_default_rules(vfr);
+ goto error_del_rules;
else
PMD_DRV_LOG(DEBUG,
"BNXT Port:%d VFR created and initialized\n",
vfr->dpdk_port_id);
-
+ return rc;
+error_del_rules:
+ (void)bnxt_ulp_delete_vfr_default_rules(vfr);
return rc;
}
@@ -489,8 +502,29 @@ int bnxt_rep_dev_start_op(struct rte_eth_dev *eth_dev)
static int bnxt_tf_vfr_free(struct bnxt_representor *vfr)
{
+ struct bnxt *parent_bp;
+ int32_t rc;
+
PMD_DRV_LOG(DEBUG, "BNXT Port:%d VFR ulp free\n", vfr->dpdk_port_id);
- return bnxt_ulp_delete_vfr_default_rules(vfr);
+ rc = bnxt_ulp_delete_vfr_default_rules(vfr);
+ if (rc)
+ PMD_DRV_LOG(ERR,
+ "Failed to delete dflt rules from Port:%d VFR\n",
+ vfr->dpdk_port_id);
+
+ /* Need to remove the vfr fid from the session regardless */
+ parent_bp = vfr->parent_dev->data->dev_private;
+ if (!parent_bp) {
+ PMD_DRV_LOG(DEBUG, "BNXT Port:%d VFR already freed\n",
+ vfr->dpdk_port_id);
+ return 0;
+ }
+ rc = bnxt_ulp_vfr_session_fid_rem(parent_bp->ulp_ctx, vfr->fw_fid);
+ if (rc)
+ PMD_DRV_LOG(ERR,
+ "Failed to remove BNXT Port:%d VFR from session\n",
+ vfr->dpdk_port_id);
+ return rc;
}
static int bnxt_vfr_free(struct bnxt_representor *vfr)
@@ -564,13 +598,15 @@ int bnxt_rep_dev_info_get_op(struct rte_eth_dev *eth_dev,
struct bnxt_representor *rep_bp = eth_dev->data->dev_private;
struct bnxt *parent_bp;
unsigned int max_rx_rings;
- int rc = 0;
/* MAC Specifics */
if (!bnxt_rep_check_parent(rep_bp)) {
- /* Need not be an error scenario, if parent is closed first */
PMD_DRV_LOG(INFO, "Rep parent port does not exist.\n");
- return rc;
+ /* Need be an error scenario, if parent is removed first */
+ if (eth_dev->device->driver == NULL)
+ return -ENODEV;
+ /* Need not be an error scenario, if parent is closed first */
+ return 0;
}
parent_bp = rep_bp->parent_dev->data->dev_private;
PMD_DRV_LOG(DEBUG, "Representor dev_info_get_op\n");
@@ -1567,3 +1567,31 @@ bnxt_ulp_feature_bits_get(struct bnxt_ulp_context *ulp_ctx)
return ulp_ctx->cfg_data->feature_bits;
}
+/* Add the VF Rep endpoint to the session */
+int32_t
+bnxt_ulp_vfr_session_fid_add(struct bnxt_ulp_context *ulp_ctx,
+ uint16_t vfr_fid)
+{
+ int32_t rc = 0;
+
+ if (ulp_ctx == NULL || ulp_ctx->ops == NULL)
+ return -EINVAL;
+ if (ulp_ctx->ops->ulp_vfr_session_fid_add)
+ rc = ulp_ctx->ops->ulp_vfr_session_fid_add(ulp_ctx, vfr_fid);
+
+ return rc;
+}
+
+/* Remove the VF Rep endpoint from the session */
+int32_t
+bnxt_ulp_vfr_session_fid_rem(struct bnxt_ulp_context *ulp_ctx,
+ uint16_t vfr_fid)
+{
+ int32_t rc = 0;
+
+ if (ulp_ctx == NULL || ulp_ctx->ops == NULL)
+ return -EINVAL;
+ if (ulp_ctx->ops->ulp_vfr_session_fid_rem)
+ rc = ulp_ctx->ops->ulp_vfr_session_fid_rem(ulp_ctx, vfr_fid);
+ return rc;
+}
@@ -220,6 +220,12 @@ struct bnxt_ulp_core_ops {
void
(*ulp_ctx_detach)(struct bnxt *bp,
struct bnxt_ulp_session_state *session);
+ int32_t
+ (*ulp_vfr_session_fid_add)(struct bnxt_ulp_context *ulp_ctx,
+ uint16_t rep_fid);
+ int32_t
+ (*ulp_vfr_session_fid_rem)(struct bnxt_ulp_context *ulp_ctx,
+ uint16_t rep_fid);
};
extern const struct bnxt_ulp_core_ops bnxt_ulp_tf_core_ops;
@@ -581,4 +587,10 @@ int32_t bnxt_ulp_num_key_recipes_get(struct bnxt_ulp_context *ulp_ctx);
uint64_t
bnxt_ulp_feature_bits_get(struct bnxt_ulp_context *ulp_ctx);
+int32_t
+bnxt_ulp_vfr_session_fid_add(struct bnxt_ulp_context *ulp_ctx,
+ uint16_t vfr_fid);
+int32_t
+bnxt_ulp_vfr_session_fid_rem(struct bnxt_ulp_context *ulp_ctx,
+ uint16_t vfr_fid);
#endif /* _BNXT_ULP_H_ */
@@ -1511,4 +1511,6 @@ const struct bnxt_ulp_core_ops bnxt_ulp_tf_core_ops = {
.ulp_ctx_detach = ulp_tf_ctx_detach,
.ulp_deinit = ulp_tf_deinit,
.ulp_init = ulp_tf_init,
+ .ulp_vfr_session_fid_add = NULL,
+ .ulp_vfr_session_fid_rem = NULL
};
@@ -336,7 +336,7 @@ ulp_tfc_tbl_scope_init(struct bnxt *bp)
{
struct tfc_tbl_scope_mem_alloc_parms mem_parms;
struct tfc_tbl_scope_size_query_parms qparms = { 0 };
- uint8_t max_lkup_sz[CFA_DIR_MAX], max_act_sz[CFA_DIR_MAX];
+ uint16_t max_lkup_sz[CFA_DIR_MAX], max_act_sz[CFA_DIR_MAX];
struct tfc_tbl_scope_cpm_alloc_parms cparms;
uint16_t fid, max_pools;
bool first = true, shared = false;
@@ -681,6 +681,70 @@ ulp_tfc_ctx_init(struct bnxt *bp,
return rc;
}
+static int32_t
+ulp_tfc_vfr_session_fid_add(struct bnxt_ulp_context *ulp_ctx, uint16_t rep_fid)
+{
+ uint16_t fid_cnt = 0, sid = 0;
+ struct tfc *tfcp = NULL;
+ int rc;
+
+ tfcp = bnxt_ulp_cntxt_tfcp_get(ulp_ctx);
+ if (!tfcp) {
+ PMD_DRV_LOG(ERR, "Unable to get tfcp from ulp_ctx\n");
+ return -EINVAL;
+ }
+
+ /* Get the session id */
+ rc = bnxt_ulp_cntxt_sid_get(ulp_ctx, &sid);
+ if (rc) {
+ PMD_DRV_LOG(ERR, "Unable to get SID for VFR FID=%d\n", rep_fid);
+ return rc;
+ }
+
+ rc = tfc_session_fid_add(tfcp, rep_fid, sid, &fid_cnt);
+ if (!rc)
+ PMD_DRV_LOG(DEBUG,
+ "EFID=%d added to SID=%d, %d total.\n",
+ rep_fid, sid, fid_cnt);
+ else
+ PMD_DRV_LOG(ERR,
+ "Failed to add EFID=%d to SID=%d\n",
+ rep_fid, sid);
+ return rc;
+}
+
+static int32_t
+ulp_tfc_vfr_session_fid_rem(struct bnxt_ulp_context *ulp_ctx, uint16_t rep_fid)
+{
+ uint16_t fid_cnt = 0, sid = 0;
+ struct tfc *tfcp = NULL;
+ int rc;
+
+ tfcp = bnxt_ulp_cntxt_tfcp_get(ulp_ctx);
+ if (!tfcp) {
+ PMD_DRV_LOG(ERR, "Unable tfcp from ulp_ctx\n");
+ return -EINVAL;
+ }
+
+ /* Get the session id */
+ rc = bnxt_ulp_cntxt_sid_get(ulp_ctx, &sid);
+ if (rc) {
+ PMD_DRV_LOG(ERR, "Unable to get SID for VFR FID=%d\n", rep_fid);
+ return rc;
+ }
+
+ rc = tfc_session_fid_rem(tfcp, rep_fid, &fid_cnt);
+ if (!rc)
+ PMD_DRV_LOG(DEBUG,
+ "Removed EFID=%d from SID=%d, %d remain.\n",
+ rep_fid, sid, fid_cnt);
+ else
+ PMD_DRV_LOG(ERR, "Failed to remove EFID=%d from SID=%d\n",
+ rep_fid, sid);
+
+ return rc;
+}
+
static int32_t
ulp_tfc_ctx_attach(struct bnxt *bp,
struct bnxt_ulp_session_state *session)
@@ -703,6 +767,12 @@ ulp_tfc_ctx_attach(struct bnxt *bp,
return rc;
}
+ rc = bnxt_ulp_devid_get(bp, &dev_id);
+ if (rc) {
+ BNXT_DRV_DBG(ERR, "Unable to get device id from ulp.\n");
+ return rc;
+ }
+
/* Increment the ulp context data reference count usage. */
bp->ulp_ctx->cfg_data = session->cfg_data;
bp->ulp_ctx->cfg_data->ref_cnt++;
@@ -710,12 +780,12 @@ ulp_tfc_ctx_attach(struct bnxt *bp,
rc = tfc_session_fid_add(&bp->tfcp, bp->fw_fid,
session->session_id, &fid_cnt);
if (rc) {
- BNXT_DRV_DBG(ERR, "Failed to add FID:%d to SID:%d.\n",
+ BNXT_DRV_DBG(ERR, "Failed to add RFID:%d to SID:%d.\n",
bp->fw_fid, session->session_id);
return rc;
}
- BNXT_DRV_DBG(DEBUG, "SID:%d added FID:%d\n",
- session->session_id, bp->fw_fid);
+ BNXT_DRV_DBG(DEBUG, "RFID:%d added to SID:%d\n",
+ bp->fw_fid, session->session_id);
rc = bnxt_ulp_cntxt_sid_set(bp->ulp_ctx, session->session_id);
if (rc) {
@@ -739,13 +809,6 @@ ulp_tfc_ctx_attach(struct bnxt *bp,
BNXT_DRV_DBG(ERR, "Unable to get the app id from ulp.\n");
return -EINVAL;
}
-
- rc = bnxt_ulp_cntxt_dev_id_get(bp->ulp_ctx, &dev_id);
- if (rc) {
- BNXT_DRV_DBG(ERR, "Unable do get the dev_id.\n");
- return -EINVAL;
- }
-
flags = bp->ulp_ctx->cfg_data->ulp_flags;
if (ULP_APP_DEV_UNSUPPORTED_ENABLED(flags)) {
BNXT_DRV_DBG(ERR, "APP ID %d, Device ID: 0x%x not supported.\n",
@@ -769,11 +832,11 @@ ulp_tfc_ctx_detach(struct bnxt *bp,
rc = tfc_session_fid_rem(&bp->tfcp, bp->fw_fid, &fid_cnt);
if (rc)
- BNXT_DRV_DBG(ERR, "Failed to remove FID:%d from SID:%d\n",
+ BNXT_DRV_DBG(ERR, "Failed to remove RFID:%d from SID:%d\n",
bp->fw_fid, session->session_id);
else
- BNXT_DRV_DBG(DEBUG, "SID:%d removed FID:%d CNT:%d\n",
- session->session_id, bp->fw_fid, fid_cnt);
+ BNXT_DRV_DBG(DEBUG, "Removed RFID:%d from SID:%d CNT:%d\n",
+ bp->fw_fid, session->session_id, fid_cnt);
bnxt_ulp_cntxt_sid_reset(bp->ulp_ctx);
(void)tfc_close(&bp->tfcp);
}
@@ -826,11 +889,11 @@ ulp_tfc_deinit(struct bnxt *bp,
rc = tfc_session_fid_rem(&bp->tfcp, bp->fw_fid, &fid_cnt);
if (rc)
- BNXT_DRV_DBG(ERR, "Failed to remove FID:%d from SID:%d\n",
+ BNXT_DRV_DBG(ERR, "Failed to remove RFID:%d from SID:%d\n",
bp->fw_fid, session->session_id);
else
- BNXT_DRV_DBG(DEBUG, "SID:%d removed FID:%d CNT:%d\n",
- session->session_id, bp->fw_fid, fid_cnt);
+ BNXT_DRV_DBG(DEBUG, "Removed RFID:%d from SID:%d CNT:%d\n",
+ bp->fw_fid, session->session_id, fid_cnt);
bnxt_ulp_cntxt_sid_reset(bp->ulp_ctx);
(void)tfc_close(&bp->tfcp);
@@ -853,6 +916,12 @@ ulp_tfc_init(struct bnxt *bp,
uint16_t sid;
int rc;
+ rc = bnxt_ulp_devid_get(bp, &ulp_dev_id);
+ if (rc) {
+ BNXT_DRV_DBG(ERR, "Unable to get device id from ulp.\n");
+ return rc;
+ }
+
bp->tfcp.bp = bp;
rc = tfc_open(&bp->tfcp);
if (rc) {
@@ -872,7 +941,7 @@ ulp_tfc_init(struct bnxt *bp,
BNXT_DRV_DBG(ERR, "Failed to allocate a session id\n");
return rc;
}
- BNXT_DRV_DBG(DEBUG, "SID:%d allocated with FID:%d\n", sid, bp->fw_fid);
+ BNXT_DRV_DBG(DEBUG, "SID:%d allocated with RFID:%d\n", sid, bp->fw_fid);
session->session_id = sid;
rc = bnxt_ulp_cntxt_sid_set(bp->ulp_ctx, sid);
if (rc) {
@@ -899,13 +968,6 @@ ulp_tfc_init(struct bnxt *bp,
goto jump_to_error;
}
- /* Initialize ulp dparms with values devargs passed */
- rc = bnxt_ulp_cntxt_dev_id_get(bp->ulp_ctx, &ulp_dev_id);
- if (rc) {
- BNXT_DRV_DBG(ERR, "Unable to get device id from ulp.\n");
- return rc;
- }
-
rc = ulp_tfc_dparms_init(bp, bp->ulp_ctx, ulp_dev_id);
if (rc) {
BNXT_DRV_DBG(ERR, "Failed to initialize the dparms\n");
@@ -968,4 +1030,6 @@ const struct bnxt_ulp_core_ops bnxt_ulp_tfc_core_ops = {
.ulp_ctx_detach = ulp_tfc_ctx_detach,
.ulp_deinit = ulp_tfc_deinit,
.ulp_init = ulp_tfc_init,
+ .ulp_vfr_session_fid_add = ulp_tfc_vfr_session_fid_add,
+ .ulp_vfr_session_fid_rem = ulp_tfc_vfr_session_fid_rem
};
@@ -83,10 +83,13 @@ ulp_fc_tfc_flow_stat_get(struct bnxt_ulp_context *ctxt,
cmm_info.rsubtype = CFA_RSUBTYPE_CMM_ACT;
cmm_info.act_handle = handle;
cmm_info.dir = (enum cfa_dir)direction;
- cmm_clr.clr = true;
- cmm_clr.offset_in_byte = 0;
- cmm_clr.sz_in_byte = sizeof(data64[ULP_FC_TFC_PKT_CNT_OFFS]) +
- sizeof(data64[ULP_FC_TFC_BYTE_CNT_OFFS]);
+ /* Read and Clear the hw stat if requested */
+ if (count->reset) {
+ cmm_clr.clr = true;
+ cmm_clr.offset_in_byte = 0;
+ cmm_clr.sz_in_byte = sizeof(data64[ULP_FC_TFC_PKT_CNT_OFFS]) +
+ sizeof(data64[ULP_FC_TFC_BYTE_CNT_OFFS]);
+ }
rc = tfc_act_get(tfcp, NULL, &cmm_info, &cmm_clr, data, &word_size);
if (rc) {
BNXT_DRV_DBG(ERR,
@@ -608,8 +608,12 @@ ulp_mapper_tfc_em_tbl_process(struct bnxt_ulp_mapper_parms *parms,
if (tbl->tbl_opcode == BNXT_ULP_EM_TBL_OPC_WR_REGFILE) {
uint64_t val = 0;
- /* over max flows or hash collision */
- if (rc == -E2BIG || rc == -ENOMEM) {
+ /* hash collision */
+ if (rc == -E2BIG)
+ BNXT_DRV_DBG(DEBUG, "Dulicate EM entry\n");
+
+ /* over max flows */
+ if (rc == -ENOMEM) {
val = 1;
rc = 0;
BNXT_DRV_DBG(DEBUG,
@@ -618,9 +622,11 @@ ulp_mapper_tfc_em_tbl_process(struct bnxt_ulp_mapper_parms *parms,
ulp_regfile_write(parms->regfile, tbl->tbl_operand,
rte_cpu_to_be_64(val));
}
- if (rc)
+
+ if (rc && rc != -E2BIG)
BNXT_DRV_DBG(ERR,
"Failed to insert em entry rc=%d.\n", rc);
+
if (rc && error != NULL && tfc_is_mpc_error(rc))
rte_flow_error_set((struct rte_flow_error *)error, EIO,
RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
@@ -1021,6 +1027,7 @@ ulp_mapper_tfc_index_entry_free(struct bnxt_ulp_context *ulp_ctx,
struct tfc *tfcp = NULL;
struct tfc_idx_tbl_info tbl_info = { 0 };
uint16_t fw_fid = 0;
+ int32_t rc;
if (bnxt_ulp_cntxt_fid_get(ulp_ctx, &fw_fid)) {
BNXT_DRV_DBG(ERR, "Failed to get func_id\n");
@@ -1039,7 +1046,16 @@ ulp_mapper_tfc_index_entry_free(struct bnxt_ulp_context *ulp_ctx,
tbl_info.id = (uint16_t)res->resource_hndl;
/* TBD: check to see if the memory needs to be cleaned as well*/
- return tfc_idx_tbl_free(tfcp, fw_fid, &tbl_info);
+ rc = tfc_idx_tbl_free(tfcp, fw_fid, &tbl_info);
+#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
+#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG_MAPPER
+ if (!rc)
+ BNXT_DRV_DBG(DEBUG, "Freed Index [%s]:[%s] = 0x%X\n",
+ tfc_dir_2_str(tbl_info.dir),
+ tfc_idx_tbl_2_str(tbl_info.rsubtype), tbl_info.id);
+#endif
+#endif
+ return rc;
}
static int32_t
@@ -1568,7 +1584,7 @@ ulp_mapper_tfc_ident_free(struct bnxt_ulp_context *ulp_ctx,
}
#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG_MAPPER
- BNXT_DRV_INF("Freed Identifier [%s]:[%s] = 0x%X\n",
+ BNXT_DRV_DBG(DEBUG, "Freed Identifier [%s]:[%s] = 0x%X\n",
tfc_dir_2_str(ident_info.dir),
tfc_ident_2_str(ident_info.rsubtype), ident_info.id);
#endif
@@ -1604,6 +1620,13 @@ ulp_mapper_tfc_tcam_entry_free(struct bnxt_ulp_context *ulp,
tcam_info.id);
return -EINVAL;
}
+#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
+#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG_MAPPER
+ BNXT_DRV_DBG(DEBUG, "Freed TCAM [%s]:[%s] = 0x%X\n",
+ tfc_dir_2_str(tcam_info.dir),
+ tfc_tcam_2_str(tcam_info.rsubtype), tcam_info.id);
+#endif
+#endif
return 0;
}