Fix to allocate bnxt ulp context when TRUFLOW is enabled.
This patch reduces the size of struct bnxt.
Fixes:
313ac35ac701 ("net/bnxt: support ULP session manager init")
Signed-off-by: Mike Baucom <michael.baucom@broadcom.com>
Reviewed-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
#define BNXT_FLAG_RX_VECTOR_PKT_MODE BIT(24)
#define BNXT_FLAG_FLOW_XSTATS_EN BIT(25)
#define BNXT_FLAG_DFLT_MAC_SET BIT(26)
#define BNXT_FLAG_RX_VECTOR_PKT_MODE BIT(24)
#define BNXT_FLAG_FLOW_XSTATS_EN BIT(25)
#define BNXT_FLAG_DFLT_MAC_SET BIT(26)
+#define BNXT_FLAG_TRUFLOW_EN BIT(27)
#define BNXT_PF(bp) (!((bp)->flags & BNXT_FLAG_VF))
#define BNXT_VF(bp) ((bp)->flags & BNXT_FLAG_VF)
#define BNXT_NPAR(bp) ((bp)->flags & BNXT_FLAG_NPAR_PF)
#define BNXT_PF(bp) (!((bp)->flags & BNXT_FLAG_VF))
#define BNXT_VF(bp) ((bp)->flags & BNXT_FLAG_VF)
#define BNXT_NPAR(bp) ((bp)->flags & BNXT_FLAG_NPAR_PF)
#define BNXT_HAS_RING_GRPS(bp) (!BNXT_CHIP_THOR(bp))
#define BNXT_FLOW_XSTATS_EN(bp) ((bp)->flags & BNXT_FLAG_FLOW_XSTATS_EN)
#define BNXT_HAS_DFLT_MAC_SET(bp) ((bp)->flags & BNXT_FLAG_DFLT_MAC_SET)
#define BNXT_HAS_RING_GRPS(bp) (!BNXT_CHIP_THOR(bp))
#define BNXT_FLOW_XSTATS_EN(bp) ((bp)->flags & BNXT_FLAG_FLOW_XSTATS_EN)
#define BNXT_HAS_DFLT_MAC_SET(bp) ((bp)->flags & BNXT_FLAG_DFLT_MAC_SET)
+#define BNXT_TRUFLOW_EN(bp) ((bp)->flags & BNXT_FLAG_TRUFLOW_EN)
uint32_t fw_cap;
#define BNXT_FW_CAP_HOT_RESET BIT(0)
uint32_t fw_cap;
#define BNXT_FW_CAP_HOT_RESET BIT(0)
uint16_t port_svif;
struct tf tfp;
uint16_t port_svif;
struct tf tfp;
- struct bnxt_ulp_context ulp_ctx;
- uint8_t truflow;
+ struct bnxt_ulp_context *ulp_ctx;
struct bnxt_flow_stat_info *flow_stat;
uint8_t flow_xstat;
};
struct bnxt_flow_stat_info *flow_stat;
uint8_t flow_xstat;
};
DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM |
DEV_RX_OFFLOAD_RSS_HASH |
DEV_RX_OFFLOAD_VLAN_FILTER)) &&
DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM |
DEV_RX_OFFLOAD_RSS_HASH |
DEV_RX_OFFLOAD_VLAN_FILTER)) &&
+ !BNXT_TRUFLOW_EN(bp)) {
PMD_DRV_LOG(INFO, "Using vector mode receive for port %d\n",
eth_dev->data->port_id);
bp->flags |= BNXT_FLAG_RX_VECTOR_PKT_MODE;
PMD_DRV_LOG(INFO, "Using vector mode receive for port %d\n",
eth_dev->data->port_id);
bp->flags |= BNXT_FLAG_RX_VECTOR_PKT_MODE;
bnxt_schedule_fw_health_check(bp);
pthread_mutex_unlock(&bp->def_cp_lock);
bnxt_schedule_fw_health_check(bp);
pthread_mutex_unlock(&bp->def_cp_lock);
+ if (BNXT_TRUFLOW_EN(bp))
bnxt_ulp_init(bp);
return 0;
bnxt_ulp_init(bp);
return 0;
struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
+ if (BNXT_TRUFLOW_EN(bp))
bnxt_ulp_deinit(bp);
eth_dev->data->dev_started = 0;
bnxt_ulp_deinit(bp);
eth_dev->data->dev_started = 0;
case RTE_ETH_FILTER_GENERIC:
if (filter_op != RTE_ETH_FILTER_GET)
return -EINVAL;
case RTE_ETH_FILTER_GENERIC:
if (filter_op != RTE_ETH_FILTER_GET)
return -EINVAL;
+ if (BNXT_TRUFLOW_EN(bp))
*(const void **)arg = &bnxt_ulp_rte_flow_ops;
else
*(const void **)arg = &bnxt_flow_ops;
*(const void **)arg = &bnxt_ulp_rte_flow_ops;
else
*(const void **)arg = &bnxt_flow_ops;
- bp->truflow = truflow;
- if (bp->truflow)
+ bp->flags |= BNXT_FLAG_TRUFLOW_EN;
+ if (BNXT_TRUFLOW_EN(bp))
PMD_DRV_LOG(INFO, "Host-based truflow feature enabled.\n");
return 0;
PMD_DRV_LOG(INFO, "Host-based truflow feature enabled.\n");
return 0;
- rc = ulp_mark_db_mark_get(&bp->ulp_ctx, gfid,
+ rc = ulp_mark_db_mark_get(bp->ulp_ctx, gfid,
cfa_code, &mark_id);
if (!rc) {
/* Got the mark, write it to the mbuf and return */
cfa_code, &mark_id);
if (!rc) {
/* Got the mark, write it to the mbuf and return */
mbuf->ol_flags |= PKT_RX_RSS_HASH;
}
mbuf->ol_flags |= PKT_RX_RSS_HASH;
}
+ if (BNXT_TRUFLOW_EN(bp))
bnxt_ulp_set_mark_in_mbuf(rxq->bp, rxcmp1, mbuf);
else
bnxt_set_mark_in_mbuf(rxq->bp, rxcmp1, mbuf);
bnxt_ulp_set_mark_in_mbuf(rxq->bp, rxcmp1, mbuf);
else
bnxt_set_mark_in_mbuf(rxq->bp, rxcmp1, mbuf);
- if (&bp->tfp == bp->ulp_ctx.g_tfp)
+ if (&bp->tfp == bp->ulp_ctx->g_tfp)
tf_close_session(&bp->tfp);
session->session_opened = 0;
session->g_tfp = NULL;
tf_close_session(&bp->tfp);
session->session_opened = 0;
session->g_tfp = NULL;
- bp->ulp_ctx.g_tfp = NULL;
+ bp->ulp_ctx->g_tfp = NULL;
- rc = bnxt_ulp_cntxt_dev_id_get(&bp->ulp_ctx, &dev_id);
+ rc = bnxt_ulp_cntxt_dev_id_get(bp->ulp_ctx, &dev_id);
if (rc)
/* TBD: For now, just use default. */
dparms = 0;
if (rc)
/* TBD: For now, just use default. */
dparms = 0;
- rc = bnxt_ulp_cntxt_tbl_scope_id_set(&bp->ulp_ctx, params.tbl_scope_id);
+ rc = bnxt_ulp_cntxt_tbl_scope_id_set(bp->ulp_ctx, params.tbl_scope_id);
if (rc) {
BNXT_TF_DBG(ERR, "Unable to set table scope id\n");
return rc;
if (rc) {
BNXT_TF_DBG(ERR, "Unable to set table scope id\n");
return rc;
/* Free the contents */
if (session->cfg_data) {
rte_free(session->cfg_data);
/* Free the contents */
if (session->cfg_data) {
rte_free(session->cfg_data);
- bp->ulp_ctx.cfg_data = NULL;
+ bp->ulp_ctx->cfg_data = NULL;
session->cfg_data = NULL;
}
return 0;
session->cfg_data = NULL;
}
return 0;
}
/* Increment the ulp context data reference count usage. */
}
/* Increment the ulp context data reference count usage. */
- bp->ulp_ctx.cfg_data = ulp_data;
+ bp->ulp_ctx->cfg_data = ulp_data;
session->cfg_data = ulp_data;
ulp_data->ref_cnt++;
session->cfg_data = ulp_data;
ulp_data->ref_cnt++;
(void)ulp_ctx_deinit(bp, session);
return rc;
}
(void)ulp_ctx_deinit(bp, session);
return rc;
}
- bnxt_ulp_cntxt_tfp_set(&bp->ulp_ctx, session->g_tfp);
+ bnxt_ulp_cntxt_tfp_set(bp->ulp_ctx, session->g_tfp);
BNXT_TF_DBG(ERR, "Invalid Arguments\n");
return -EINVAL;
}
BNXT_TF_DBG(ERR, "Invalid Arguments\n");
return -EINVAL;
}
- ulp_ctx = &bp->ulp_ctx;
if (!ulp_ctx->cfg_data)
return 0;
if (!ulp_ctx->cfg_data)
return 0;
+ if (bp->ulp_ctx) {
+ BNXT_TF_DBG(ERR, "ulp ctx already allocated\n");
+ return -EINVAL;
+ }
+
/*
* Multiple uplink ports can be associated with a single vswitch.
* Make sure only the port that is started first will initialize
/*
* Multiple uplink ports can be associated with a single vswitch.
* Make sure only the port that is started first will initialize
+ bp->ulp_ctx = rte_zmalloc("bnxt_ulp_ctx",
+ sizeof(struct bnxt_ulp_context), 0);
+ if (!bp->ulp_ctx) {
+ BNXT_TF_DBG(ERR, "Failed to allocate ulp ctx\n");
+ ulp_session_deinit(session);
+ return -ENOMEM;
+ }
+
/*
* If ULP is already initialized for a specific domain then simply
* assign the ulp context to this rte_eth_dev.
*/
if (init) {
/*
* If ULP is already initialized for a specific domain then simply
* assign the ulp context to this rte_eth_dev.
*/
if (init) {
- rc = ulp_ctx_attach(&bp->ulp_ctx, session);
+ rc = ulp_ctx_attach(bp->ulp_ctx, session);
if (rc) {
BNXT_TF_DBG(ERR,
"Failed to attach the ulp context\n");
if (rc) {
BNXT_TF_DBG(ERR,
"Failed to attach the ulp context\n");
+ ulp_session_deinit(session);
+ rte_free(bp->ulp_ctx);
return rc;
}
/* update the port database */
return rc;
}
/* update the port database */
- rc = ulp_port_db_dev_port_intf_update(&bp->ulp_ctx, bp);
+ rc = ulp_port_db_dev_port_intf_update(bp->ulp_ctx, bp);
if (rc) {
BNXT_TF_DBG(ERR,
"Failed to update port database\n");
if (rc) {
BNXT_TF_DBG(ERR,
"Failed to update port database\n");
+ ulp_ctx_detach(bp, session);
+ ulp_session_deinit(session);
+ rte_free(bp->ulp_ctx);
}
/* create the port database */
}
/* create the port database */
- rc = ulp_port_db_init(&bp->ulp_ctx);
+ rc = ulp_port_db_init(bp->ulp_ctx);
if (rc) {
BNXT_TF_DBG(ERR, "Failed to create the port database\n");
goto jump_to_error;
}
/* update the port database */
if (rc) {
BNXT_TF_DBG(ERR, "Failed to create the port database\n");
goto jump_to_error;
}
/* update the port database */
- rc = ulp_port_db_dev_port_intf_update(&bp->ulp_ctx, bp);
+ rc = ulp_port_db_dev_port_intf_update(bp->ulp_ctx, bp);
if (rc) {
BNXT_TF_DBG(ERR, "Failed to update port database\n");
goto jump_to_error;
}
/* Create the Mark database. */
if (rc) {
BNXT_TF_DBG(ERR, "Failed to update port database\n");
goto jump_to_error;
}
/* Create the Mark database. */
- rc = ulp_mark_db_init(&bp->ulp_ctx);
+ rc = ulp_mark_db_init(bp->ulp_ctx);
if (rc) {
BNXT_TF_DBG(ERR, "Failed to create the mark database\n");
goto jump_to_error;
}
/* Create the flow database. */
if (rc) {
BNXT_TF_DBG(ERR, "Failed to create the mark database\n");
goto jump_to_error;
}
/* Create the flow database. */
- rc = ulp_flow_db_init(&bp->ulp_ctx);
+ rc = ulp_flow_db_init(bp->ulp_ctx);
if (rc) {
BNXT_TF_DBG(ERR, "Failed to create the flow database\n");
goto jump_to_error;
if (rc) {
BNXT_TF_DBG(ERR, "Failed to create the flow database\n");
goto jump_to_error;
- rc = ulp_mapper_init(&bp->ulp_ctx);
+ rc = ulp_mapper_init(bp->ulp_ctx);
if (rc) {
BNXT_TF_DBG(ERR, "Failed to initialize ulp mapper\n");
goto jump_to_error;
if (rc) {
BNXT_TF_DBG(ERR, "Failed to initialize ulp mapper\n");
goto jump_to_error;
return;
/* clean up regular flows */
return;
/* clean up regular flows */
- ulp_flow_db_flush_flows(&bp->ulp_ctx, BNXT_ULP_REGULAR_FLOW_TABLE);
+ ulp_flow_db_flush_flows(bp->ulp_ctx, BNXT_ULP_REGULAR_FLOW_TABLE);
/* cleanup the eem table scope */
/* cleanup the eem table scope */
- ulp_eem_tbl_scope_deinit(bp, &bp->ulp_ctx);
+ ulp_eem_tbl_scope_deinit(bp, bp->ulp_ctx);
/* cleanup the flow database */
/* cleanup the flow database */
- ulp_flow_db_deinit(&bp->ulp_ctx);
+ ulp_flow_db_deinit(bp->ulp_ctx);
/* Delete the Mark database */
/* Delete the Mark database */
- ulp_mark_db_deinit(&bp->ulp_ctx);
+ ulp_mark_db_deinit(bp->ulp_ctx);
/* cleanup the ulp mapper */
/* cleanup the ulp mapper */
- ulp_mapper_deinit(&bp->ulp_ctx);
+ ulp_mapper_deinit(bp->ulp_ctx);
/* Delete the Port database */
/* Delete the Port database */
- ulp_port_db_deinit(&bp->ulp_ctx);
+ ulp_port_db_deinit(bp->ulp_ctx);
/* Delete the ulp context and tf session */
ulp_ctx_detach(bp, session);
/* Finally delete the bnxt session*/
ulp_session_deinit(session);
/* Delete the ulp context and tf session */
ulp_ctx_detach(bp, session);
/* Finally delete the bnxt session*/
ulp_session_deinit(session);
+
+ rte_free(bp->ulp_ctx);
}
/* Function to set the Mark DB into the context */
}
/* Function to set the Mark DB into the context */
BNXT_TF_DBG(ERR, "Bnxt private data is not initialized\n");
return NULL;
}
BNXT_TF_DBG(ERR, "Bnxt private data is not initialized\n");
return NULL;
}