From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 62726A052B; Wed, 29 Jul 2020 16:11:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 531731C038; Wed, 29 Jul 2020 16:10:42 +0200 (CEST) Received: from relay.smtp.broadcom.com (unknown [192.19.232.149]) by dpdk.org (Postfix) with ESMTP id C53E41C023 for ; Wed, 29 Jul 2020 16:10:36 +0200 (CEST) Received: from dhcp-10-123-153-55.dhcp.broadcom.net (bgccx-dev-host-lnx35.bec.broadcom.net [10.123.153.55]) by relay.smtp.broadcom.com (Postfix) with ESMTP id 4AAA31BDB0A; Wed, 29 Jul 2020 07:10:35 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com 4AAA31BDB0A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1596031836; bh=t0H1+xtEmnYsj0XTbjLVNpYU2AwXyZEcpiwOWHPQHKw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hDto5oSKwEWiuCChKQ+PJek6EZNEM2HE62yYnSu9+JULTSvEz/Ol1VEhMeMasNqye faFhMJy5pqUuY2yRW2Ou4IgY21Ja0+Nnm3VAq62+cZPSCUif4ptqjoTSWxRLBFCNZa 43yVlRWoLtdO5sq2D/FfHjAc9jrdrkjEwpQvmzYo= From: Somnath Kotur To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Wed, 29 Jul 2020 19:34:58 +0530 Message-Id: <20200729140459.5227-4-somnath.kotur@broadcom.com> X-Mailer: git-send-email 2.10.1.613.g2cc2e70 In-Reply-To: <20200729140459.5227-1-somnath.kotur@broadcom.com> References: <20200729140459.5227-1-somnath.kotur@broadcom.com> Subject: [dpdk-dev] [PATCH 3/4] net/bnxt: cleanups and checks for ulp context allocation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 in VF rep dev ops for proper parent dev initialization Fixes: 322bd6e70272 ("net/bnxt: add port representor infrastructure") Fixes: 313ac35ac701 ("net/bnxt: support ULP session manager init") Reviewed-by: Venkat Duvvuru Signed-off-by: Somnath Kotur --- 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 6fa9a30..2941aff 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 077527f..c19cd1d 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 9fb1a02..46acc1d 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.7.4