DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com, Mike Baucom <michael.baucom@broadcom.com>,
	Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Subject: [dpdk-dev] [PATCH v1 9/9] net/bnxt: fix to allocate bnxt ulp context
Date: Fri, 15 May 2020 11:45:42 -0700
Message-ID: <20200515184542.89318-10-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <20200515184542.89318-1-ajit.khaparde@broadcom.com>

From: Mike Baucom <michael.baucom@broadcom.com>

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>
---
 drivers/net/bnxt/bnxt.h            |  5 ++-
 drivers/net/bnxt/bnxt_ethdev.c     | 12 +++---
 drivers/net/bnxt/bnxt_rxr.c        |  4 +-
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 64 ++++++++++++++++++++----------
 4 files changed, 53 insertions(+), 32 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 403b23f35..446764c57 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -561,6 +561,7 @@ struct bnxt {
 #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)
@@ -575,6 +576,7 @@ struct bnxt {
 #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)
@@ -720,8 +722,7 @@ struct bnxt {
 	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;
 };
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 77492f89c..ae495da34 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1095,7 +1095,7 @@ bnxt_receive_function(struct rte_eth_dev *eth_dev)
 		DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM |
 		DEV_RX_OFFLOAD_RSS_HASH |
 		DEV_RX_OFFLOAD_VLAN_FILTER)) &&
-	    !bp->truflow) {
+	    !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;
@@ -1221,7 +1221,7 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
 	bnxt_schedule_fw_health_check(bp);
 	pthread_mutex_unlock(&bp->def_cp_lock);
 
-	if (bp->truflow)
+	if (BNXT_TRUFLOW_EN(bp))
 		bnxt_ulp_init(bp);
 
 	return 0;
@@ -1267,7 +1267,7 @@ static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
 	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
 
-	if (bp->truflow)
+	if (BNXT_TRUFLOW_EN(bp))
 		bnxt_ulp_deinit(bp);
 
 	eth_dev->data->dev_started = 0;
@@ -3647,7 +3647,7 @@ bnxt_filter_ctrl_op(struct rte_eth_dev *dev,
 	case RTE_ETH_FILTER_GENERIC:
 		if (filter_op != RTE_ETH_FILTER_GET)
 			return -EINVAL;
-		if (bp->truflow)
+		if (BNXT_TRUFLOW_EN(bp))
 			*(const void **)arg = &bnxt_ulp_rte_flow_ops;
 		else
 			*(const void **)arg = &bnxt_flow_ops;
@@ -5350,8 +5350,8 @@ bnxt_parse_devarg_truflow(__rte_unused const char *key,
 		return -EINVAL;
 	}
 
-	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;
diff --git a/drivers/net/bnxt/bnxt_rxr.c b/drivers/net/bnxt/bnxt_rxr.c
index 9ecdf5e65..d2955bae3 100644
--- a/drivers/net/bnxt/bnxt_rxr.c
+++ b/drivers/net/bnxt/bnxt_rxr.c
@@ -466,7 +466,7 @@ bnxt_ulp_set_mark_in_mbuf(struct bnxt *bp, struct rx_pkt_cmpl_hi *rxcmp1,
 	}
 
 	if (cfa_code) {
-		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 */
@@ -614,7 +614,7 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
 		mbuf->ol_flags |= PKT_RX_RSS_HASH;
 	}
 
-	if (bp->truflow)
+	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);
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
index a9cc92d34..872c1aba4 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
@@ -44,7 +44,7 @@ ulp_ctx_deinit_allowed(void *ptr)
 	if (!bp)
 		return 0;
 
-	if (&bp->tfp == bp->ulp_ctx.g_tfp)
+	if (&bp->tfp == bp->ulp_ctx->g_tfp)
 		return 1;
 
 	return 0;
@@ -103,7 +103,7 @@ ulp_ctx_session_close(struct bnxt *bp,
 		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;
 }
 
 static void
@@ -114,7 +114,7 @@ bnxt_init_tbl_scope_parms(struct bnxt *bp,
 	uint32_t dev_id;
 	int rc;
 
-	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;
@@ -174,7 +174,7 @@ ulp_eem_tbl_scope_init(struct bnxt *bp)
 		return rc;
 	}
 
-	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;
@@ -234,7 +234,7 @@ ulp_ctx_deinit(struct bnxt *bp,
 	/* 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;
@@ -262,7 +262,7 @@ ulp_ctx_init(struct bnxt *bp,
 	}
 
 	/* 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++;
 
@@ -272,7 +272,7 @@ ulp_ctx_init(struct bnxt *bp,
 		(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);
 	return rc;
 }
 
@@ -304,7 +304,7 @@ ulp_ctx_detach(struct bnxt *bp,
 		BNXT_TF_DBG(ERR, "Invalid Arguments\n");
 		return -EINVAL;
 	}
-	ulp_ctx = &bp->ulp_ctx;
+	ulp_ctx = bp->ulp_ctx;
 
 	if (!ulp_ctx->cfg_data)
 		return 0;
@@ -441,6 +441,11 @@ bnxt_ulp_init(struct bnxt *bp)
 	bool init;
 	int rc;
 
+	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
@@ -452,22 +457,35 @@ bnxt_ulp_init(struct bnxt *bp)
 		return -EINVAL;
 	}
 
+	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) {
-		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");
+			ulp_session_deinit(session);
+			rte_free(bp->ulp_ctx);
 			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");
+			ulp_ctx_detach(bp, session);
+			ulp_session_deinit(session);
+			rte_free(bp->ulp_ctx);
 		}
 		return rc;
 	}
@@ -480,28 +498,28 @@ bnxt_ulp_init(struct bnxt *bp)
 	}
 
 	/* 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 */
-	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. */
-	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. */
-	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;
@@ -514,7 +532,7 @@ bnxt_ulp_init(struct bnxt *bp)
 		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;
@@ -553,28 +571,30 @@ bnxt_ulp_deinit(struct bnxt *bp)
 		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 */
-	ulp_eem_tbl_scope_deinit(bp, &bp->ulp_ctx);
+	ulp_eem_tbl_scope_deinit(bp, bp->ulp_ctx);
 
 	/* cleanup the flow database */
-	ulp_flow_db_deinit(&bp->ulp_ctx);
+	ulp_flow_db_deinit(bp->ulp_ctx);
 
 	/* Delete the Mark database */
-	ulp_mark_db_deinit(&bp->ulp_ctx);
+	ulp_mark_db_deinit(bp->ulp_ctx);
 
 	/* cleanup the ulp mapper */
-	ulp_mapper_deinit(&bp->ulp_ctx);
+	ulp_mapper_deinit(bp->ulp_ctx);
 
 	/* 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);
+
+	rte_free(bp->ulp_ctx);
 }
 
 /* Function to set the Mark DB into the context */
@@ -728,7 +748,7 @@ bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev	*dev)
 		BNXT_TF_DBG(ERR, "Bnxt private data is not initialized\n");
 		return NULL;
 	}
-	return &bp->ulp_ctx;
+	return bp->ulp_ctx;
 }
 
 int32_t
-- 
2.21.1 (Apple Git-122.3)


  parent reply	other threads:[~2020-05-15 18:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-15 18:45 [dpdk-dev] [PATCH v1 0/9] bug fixes for bnxt PMD Ajit Khaparde
2020-05-15 18:45 ` [dpdk-dev] [PATCH v1 1/9] net/bnxt: fix error log for command timeout Ajit Khaparde
2020-05-15 18:45 ` [dpdk-dev] [PATCH v1 2/9] net/bnxt: fix to alloc LED config info Ajit Khaparde
2020-05-15 18:45 ` [dpdk-dev] [PATCH v1 3/9] net/bnxt: fix to alloc COS queue info dynamically Ajit Khaparde
2020-05-15 18:45 ` [dpdk-dev] [PATCH v1 4/9] net/bnxt: fix to allocate flow stat related structs Ajit Khaparde
2020-05-15 18:45 ` [dpdk-dev] [PATCH v1 5/9] net/bnxt: fix to alloc link info struct Ajit Khaparde
2020-05-15 18:45 ` [dpdk-dev] [PATCH v1 6/9] net/bnxt: fix to alloc PF info structure Ajit Khaparde
2020-05-15 18:45 ` [dpdk-dev] [PATCH v1 7/9] net/bnxt: fix to use RSS config from eth dev struct Ajit Khaparde
2020-05-15 18:45 ` [dpdk-dev] [PATCH v1 8/9] net/bnxt: fix to remove unneeded structure variable Ajit Khaparde
2020-05-15 18:45 ` Ajit Khaparde [this message]
2020-05-16 15:12 ` [dpdk-dev] [PATCH v1 0/9] bug fixes for bnxt PMD Ajit Khaparde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200515184542.89318-10-ajit.khaparde@broadcom.com \
    --to=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=michael.baucom@broadcom.com \
    --cc=venkatkumar.duvvuru@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git