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 710E9A04B5; Wed, 2 Sep 2020 07:32:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 073961C0D7; Wed, 2 Sep 2020 07:31:57 +0200 (CEST) Received: from mail-ot1-f97.google.com (mail-ot1-f97.google.com [209.85.210.97]) by dpdk.org (Postfix) with ESMTP id 5CC12E07 for ; Wed, 2 Sep 2020 07:31:55 +0200 (CEST) Received: by mail-ot1-f97.google.com with SMTP id e23so3254177otk.7 for ; Tue, 01 Sep 2020 22:31:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9rNUukFseCQRzKl9VMNbvDvDzf2yaLhPgZjDqZpMejs=; b=F64/tnKZQ8mjxGCEp0QwJloqm9EGpvJ8OqRkIQgVchAVQhdjQJyllUfKKfeSK7laLg dOnsC4rYeolreTzlCX2LbMEYgi8NiqfFNIM9bbh8w0lS69B7NFjLLggZRSI+wtjbOkwN EP2sTjq7P+1o56ygtNx3Q1TMV2N1kuLeZ0ogU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9rNUukFseCQRzKl9VMNbvDvDzf2yaLhPgZjDqZpMejs=; b=rVIE96XiImD9AipyI0LcYo+rXoS3RqIMxIK5jCjQ0FT9eFnfmK4KmXEraKmcj8BDvZ RinBWxhItEjn5rWsrltyWVx2sSn8LDxa33e4tngFUlglsEqHaHYVBHHN2FqeQKI60YgG Bveu1wZTt2Od+H5MUxO58WSjc65UBfG+S2dPuQONqaHnB15VbW1iIOT3Pxjmq8hFiW1l MD0uMvTuzErW/aacUSd2drW5FhqJ/jFMXqg/a5uU6adjuMGITDgJBQf+JDmjMaNyyPAq d07ojBidUeEaTRHZ7/Tx2lO2065oziJexFrINUIx664Bgh+peaWt5urJ7s7w+2danRnK ONxA== X-Gm-Message-State: AOAM531QpiyCYJpJ4RKyiwmlMzAtQ2so82ZmsXyE1XZqVEGMYx2x+i9o bZiZAd9nJNQr88B07TIJnMepPpvTsy90OkLizSNKbTPhtdXCdYHlqJ8CZyMwXjT42G8tND2qMhs aAlp1hI0+Dp8T1tEYVhJN9xn44FLVboqB4ISs81cWGS4XCiMx0poscGaO53b60PKvn6IqAvZqeU QV6A== X-Google-Smtp-Source: ABdhPJy08T7Y+3uTY4SL4IcsnW8/J4xl0O5v23jFGbmPMoJfZpM4avUXTXbSwcMbIQFOWj9ZXLW2JaNdIXjr X-Received: by 2002:a9d:1d68:: with SMTP id m95mr4203294otm.110.1599024714542; Tue, 01 Sep 2020 22:31:54 -0700 (PDT) Received: from localhost.localdomain ([192.19.223.252]) by smtp-relay.gmail.com with ESMTPS id h26sm566703oos.1.2020.09.01.22.31.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Sep 2020 22:31:54 -0700 (PDT) X-Relaying-Domain: broadcom.com From: Ajit Khaparde To: dev@dpdk.org Cc: Somnath Kotur , Venkat Duvvuru Date: Tue, 1 Sep 2020 22:31:37 -0700 Message-Id: <20200902053138.39649-4-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200902053138.39649-1-ajit.khaparde@broadcom.com> References: <20200731172302.5292-1-ajit.khaparde@broadcom.com> <20200902053138.39649-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 3/4] net/bnxt: cleanups and checks 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" From: Somnath Kotur 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 Reviewed-by: Venkat Duvvuru Reviewed-by: Ajit Khaparde --- 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)