DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dev@dpdk.org
Cc: Somnath Kotur <somnath.kotur@broadcom.com>,
	Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Subject: [dpdk-dev] [PATCH v3 3/4] net/bnxt: cleanups and checks ULP context allocation
Date: Tue,  1 Sep 2020 22:31:37 -0700
Message-ID: <20200902053138.39649-4-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <20200902053138.39649-1-ajit.khaparde@broadcom.com>

From: Somnath Kotur <somnath.kotur@broadcom.com>

Set ulp_ctx explicitly to NULL in ulp_ctx_deinit() so that representor
init is aborted if parent ulp context is not initialized.
Also check for the same before creation of port default rules.
Additional checks added in VF rep dev ops for proper parent dev
initialization, to avoid null pointer dereference.

Fixes: 322bd6e70272 ("net/bnxt: add port representor infrastructure")
Fixes: 313ac35ac701 ("net/bnxt: support ULP session manager init")

Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_reps.c            | 18 ++++++++++++++++++
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c      |  2 ++
 drivers/net/bnxt/tf_ulp/ulp_def_rules.c |  2 +-
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bnxt/bnxt_reps.c b/drivers/net/bnxt/bnxt_reps.c
index 6fa9a30d2..2941aff7b 100644
--- a/drivers/net/bnxt/bnxt_reps.c
+++ b/drivers/net/bnxt/bnxt_reps.c
@@ -319,6 +319,7 @@ static int bnxt_vfr_alloc(struct rte_eth_dev *vfr_ethdev)
 {
 	int rc = 0;
 	struct bnxt_vf_representor *vfr = vfr_ethdev->data->dev_private;
+	struct bnxt *parent_bp;
 
 	if (!vfr || !vfr->parent_dev) {
 		PMD_DRV_LOG(ERR,
@@ -326,6 +327,13 @@ static int bnxt_vfr_alloc(struct rte_eth_dev *vfr_ethdev)
 		return -ENOMEM;
 	}
 
+	parent_bp = vfr->parent_dev->data->dev_private;
+	if (parent_bp && !parent_bp->ulp_ctx) {
+		PMD_DRV_LOG(ERR,
+			    "ulp context not allocated for parent\n");
+		return -EIO;
+	}
+
 	/* Check if representor has been already allocated in FW */
 	if (vfr->vfr_tx_cfa_action)
 		return 0;
@@ -534,6 +542,11 @@ int bnxt_vf_rep_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
 		return -EINVAL;
 	}
 
+	if (!parent_bp->rx_queues) {
+		PMD_DRV_LOG(ERR, "Parent Rx qs not configured yet\n");
+		return -EINVAL;
+	}
+
 	parent_rxq = parent_bp->rx_queues[queue_idx];
 	if (!parent_rxq) {
 		PMD_DRV_LOG(ERR, "Parent RxQ has not been configured yet\n");
@@ -628,6 +641,11 @@ int bnxt_vf_rep_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
 		return -EINVAL;
 	}
 
+	if (!parent_bp->tx_queues) {
+		PMD_DRV_LOG(ERR, "Parent Tx qs not configured yet\n");
+		return -EINVAL;
+	}
+
 	parent_txq = parent_bp->tx_queues[queue_idx];
 	if (!parent_txq) {
 		PMD_DRV_LOG(ERR, "Parent TxQ has not been configured yet\n");
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
index 263040ee4..0d4a45513 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
@@ -884,6 +884,8 @@ bnxt_ulp_deinit(struct bnxt *bp)
 	ulp_session_deinit(session);
 
 	rte_free(bp->ulp_ctx);
+
+	bp->ulp_ctx = NULL;
 }
 
 /* Function to set the Mark DB into the context */
diff --git a/drivers/net/bnxt/tf_ulp/ulp_def_rules.c b/drivers/net/bnxt/tf_ulp/ulp_def_rules.c
index 9fb1a028f..46acc1d65 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_def_rules.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_def_rules.c
@@ -465,7 +465,7 @@ bnxt_ulp_create_df_rules(struct bnxt *bp)
 	int rc;
 
 	if (!BNXT_TRUFLOW_EN(bp) ||
-	    BNXT_ETH_DEV_IS_REPRESENTOR(bp->eth_dev))
+	    BNXT_ETH_DEV_IS_REPRESENTOR(bp->eth_dev) || !bp->ulp_ctx)
 		return 0;
 
 	port_id = bp->eth_dev->data->port_id;
-- 
2.21.1 (Apple Git-122.3)


  parent reply	other threads:[~2020-09-02  5:32 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-29 14:03 [dpdk-dev] [PATCH 0/4] bnxt patches Somnath Kotur
2020-07-29 14:03 ` [dpdk-dev] [PATCH 1/4] net/bnxt: configure loopback parif for full offload egress flows Somnath Kotur
2020-07-29 21:23 ` [dpdk-dev] [PATCH 0/4] bnxt patches Ajit Khaparde
2020-07-31 17:22   ` [dpdk-dev] [PATCH v2 " Ajit Khaparde
2020-07-31 17:22     ` [dpdk-dev] [PATCH v2 1/4] net/bnxt: fix loopback parif for egress flows Ajit Khaparde
2020-08-05 20:29       ` Thomas Monjalon
2020-07-31 17:23     ` [dpdk-dev] [PATCH v2 2/4] net/bnxt: fix lookup for default parif action record Ajit Khaparde
2020-08-05 20:28       ` Thomas Monjalon
2020-08-06  1:27         ` Kishore Padmanabha
2020-07-31 17:23     ` [dpdk-dev] [PATCH v2 3/4] net/bnxt: fix cleanup and check for ulp context alloc Ajit Khaparde
2020-08-05 20:27       ` Thomas Monjalon
2020-07-31 17:23     ` [dpdk-dev] [PATCH v2 4/4] net/bnxt: fix vfrep add when VF interface is down Ajit Khaparde
2020-08-05 20:37       ` Thomas Monjalon
2020-09-02  5:31     ` [dpdk-dev] [PATCH v3 0/4] bnxt patches Ajit Khaparde
2020-09-02  5:31       ` [dpdk-dev] [PATCH v3 1/4] net/bnxt: configure loopback parif for egress flows Ajit Khaparde
2020-09-02  5:31       ` [dpdk-dev] [PATCH v3 2/4] net/bnxt: lookup default action record parif Ajit Khaparde
2020-09-02  5:31       ` Ajit Khaparde [this message]
2020-09-02  5:31       ` [dpdk-dev] [PATCH v3 4/4] net/bnxt: fix VF representor port add Ajit Khaparde
2020-09-02 19:16       ` [dpdk-dev] [PATCH v3 0/4] bnxt patches 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=20200902053138.39649-4-ajit.khaparde@broadcom.com \
    --to=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=somnath.kotur@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