From patchwork Thu Oct 22 22:05:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Khaparde X-Patchwork-Id: 81841 X-Patchwork-Delegate: ajit.khaparde@broadcom.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 56094A04DD; Fri, 23 Oct 2020 00:09:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8162CA8F5; Fri, 23 Oct 2020 00:06:41 +0200 (CEST) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by dpdk.org (Postfix) with ESMTP id 856E0A8FA for ; Fri, 23 Oct 2020 00:06:35 +0200 (CEST) Received: by mail-pl1-f196.google.com with SMTP id r10so1704287plx.3 for ; Thu, 22 Oct 2020 15:06:35 -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; bh=2Evt+PTGz0JQqkLAJfCq/bNF4wEBDACFvZra8P6CqnI=; b=Jhgix11hvSIlQs4+XO3fVC0hTR+mwPb/EakNKrrcuPFr34fkqNvG1DaQSPKFybwK0l Os0ELTykuRDOtL/P/9XX538h0gFyatVwvM8BpFWIdp51Pjrh1Igwr2WiW8t8Jywyfs3W m1pFpvTrnp9+AlfgL6e3bvgGd8Q3bl0SrluyY= 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; bh=2Evt+PTGz0JQqkLAJfCq/bNF4wEBDACFvZra8P6CqnI=; b=najJXfI9yAxAkUD6kWeLjVP0F/MfOqrE5skVHzT8awKKdr77iN2vIX28q3rrtwfDov D8pqETN5rUz8l9lQdBLQw0tzQzC0lXLmQGptgL5FBhL1SxhQyPSWlBQEb19QU6L89OH3 wTB61v4Y+Mqrq/WkPRDNDLi0tk/JJBciqpvokGOcbjf3vj+2BCcQjC7u8suTNrGbZMYP QUrLIDSdXDXaMooRoj+tjnUMnM17MqIIA16e2NqpEu+MV3ck6Dfh0CCrlpnR4olxc4mz 3iTOrCQwNAed5ca2bZ+hhg5DDiAIN9B7s+7Nf4SMc0T9Ozu0RDb3qBudiIn/NKU1swJq Wrcw== X-Gm-Message-State: AOAM532FRFrt0d1tZhRnacNbuqrkmzRc7Lwb9in3qlI1jLXkXEUOz3RV 75CQULk68ipW6HsBtGGK+22RrrqMBbBwFHBGmIlhFQ1obIUUnIkmBAh+ibQ6l5GZFoEpfv/LzTZ /O3EGLeTeksKx9SdPHQ9z4bHnwr33jXNoXb3NZrDXnRMRj9usJHhZlZJuK7UDRYNXPg== X-Google-Smtp-Source: ABdhPJzgrThZYe97pGvjimvAm1QokyGMZhdauzFnMH5YZgedyH1NVU8BZiK1DtLN1oWcQ/Ywzqn/aA== X-Received: by 2002:a17:902:d90d:b029:d5:ee36:3438 with SMTP id c13-20020a170902d90db02900d5ee363438mr4552900plz.77.1603404394364; Thu, 22 Oct 2020 15:06:34 -0700 (PDT) Received: from localhost.localdomain ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id q14sm3214059pjp.43.2020.10.22.15.06.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Oct 2020 15:06:33 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: Somnath Kotur , Venkat Duvvuru Date: Thu, 22 Oct 2020 15:05:37 -0700 Message-Id: <20201022220542.84166-6-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20201020215538.59242-1-ajit.khaparde@broadcom.com> References: <20201020215538.59242-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [dpdk-dev] [PATCH v3 05/11] net/bnxt: fix infinite loop in flow query count 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 `nxt_resource_idx` could be zero in some cases which is invalid and should be part of the while loop condition. Also synchronize access to the flow db using the fdb_lock Fixes: 306c2d28e247 ("net/bnxt: support count action in flow query") Signed-off-by: Somnath Kotur Reviewed-by: Venkat Duvvuru Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c | 51 +++++++++++++++------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c index 051ebac049..41736a80df 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c +++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c @@ -559,6 +559,9 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context *ctxt, if (!ulp_fc_info) return -ENODEV; + if (bnxt_ulp_cntxt_acquire_fdb_lock(ctxt)) + return -EIO; + do { rc = ulp_flow_db_resource_get(ctxt, BNXT_ULP_FDB_TYPE_REGULAR, @@ -575,35 +578,35 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context *ctxt, break; } - } while (!rc); + } while (!rc && nxt_resource_index); + + bnxt_ulp_cntxt_release_fdb_lock(ctxt); - if (rc) + if (rc || !found_cntr_resource) return rc; - if (found_cntr_resource) { - dir = params.direction; - hw_cntr_id = params.resource_hndl; - sw_cntr_idx = hw_cntr_id - - ulp_fc_info->shadow_hw_tbl[dir].start_idx; - sw_acc_tbl_entry = &ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx]; - if (params.resource_sub_type == + dir = params.direction; + hw_cntr_id = params.resource_hndl; + sw_cntr_idx = hw_cntr_id - + ulp_fc_info->shadow_hw_tbl[dir].start_idx; + sw_acc_tbl_entry = &ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx]; + if (params.resource_sub_type == BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_INT_COUNT) { - pthread_mutex_lock(&ulp_fc_info->fc_lock); - if (sw_acc_tbl_entry->pkt_count) { - count->hits_set = 1; - count->bytes_set = 1; - count->hits = sw_acc_tbl_entry->pkt_count; - count->bytes = sw_acc_tbl_entry->byte_count; - } - if (count->reset) { - sw_acc_tbl_entry->pkt_count = 0; - sw_acc_tbl_entry->byte_count = 0; - } - pthread_mutex_unlock(&ulp_fc_info->fc_lock); - } else { - /* TBD: Handle External counters */ - rc = -EINVAL; + pthread_mutex_lock(&ulp_fc_info->fc_lock); + if (sw_acc_tbl_entry->pkt_count) { + count->hits_set = 1; + count->bytes_set = 1; + count->hits = sw_acc_tbl_entry->pkt_count; + count->bytes = sw_acc_tbl_entry->byte_count; } + if (count->reset) { + sw_acc_tbl_entry->pkt_count = 0; + sw_acc_tbl_entry->byte_count = 0; + } + pthread_mutex_unlock(&ulp_fc_info->fc_lock); + } else { + /* TBD: Handle External counters */ + rc = -EINVAL; } return rc;