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 0FB72A04DD; Tue, 20 Oct 2020 23:57:06 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0DECAACB3; Tue, 20 Oct 2020 23:55:59 +0200 (CEST) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by dpdk.org (Postfix) with ESMTP id 178C5AC99 for ; Tue, 20 Oct 2020 23:55:51 +0200 (CEST) Received: by mail-pf1-f196.google.com with SMTP id y14so194906pfp.13 for ; Tue, 20 Oct 2020 14:55:50 -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=HGS6cSXcgx+V5pR7O2CipxpXsnZNFCQtRQx9oM6HtOc=; b=OvwGn/gOom+825WOz1wX8pvB0T24GYqhb5aYnKsJyMvavWWRvL11GkyJQokUahCv1M iP5VLRig4azGjXoJGqckudGdAfS/WeE9t+8fdOolrKQ2dc7JptOn4SZ8pl+sgDXrrka8 MBzVTpcVfpBLkpiuBH2AmqkEA3CutpoQ1lTls= 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=HGS6cSXcgx+V5pR7O2CipxpXsnZNFCQtRQx9oM6HtOc=; b=frVxzAxKgjXSwCK/cPUTeOIPpRSYosTFH/bCCOzUlgotWV58Zl15w9ltvoaG78keQb 44Gvf+/s/G4Fh743IwyVouEWD2tTdep8QqqyTBcsC5hVsCj+/RUVAiSjY6wrBqTHKiSP Oj4r7hGuMx4vXfnpA290JuRAA5hbqNeIYVzhcXW9BjghPIhNFl7la1B8bkxRGsL/c9qE SLg4xOgGM+7srbEg8ljGDguzKwCLC+UQjWTkwN1CgDYfcA2VLvkwk4Wz57NLcf+gDGZu tvTjcQtpeu055Sx8hPMv2FTlvF7wzA1lJ2xnMdrG1O2659hYBDx7/Nulwh+IZRI2xCni lxRg== X-Gm-Message-State: AOAM5300wZph6VbFOuc9JEIBR5iLXlvzYHmK/5uG5KPemD7CdINvEz+0 hCIinIlkl0OrWHFzSSm8bmHKg4bcoqmEXNy+/DSp9XDxoHMSRCBWXzWAQCfse8dWiEEhRey3RBQ BIEDCyN8YvxVcgtbdZHffCCsTmavlVUiHmC8i9V8HRqGuB118K5Mn3DoxHuRzA1TZVA== X-Google-Smtp-Source: ABdhPJxKHPYOZVCVXebuGgKkoUo6JFX1KATe+MQl+vBpiQU5gdDw4KYltQ3dQsaY+ynjzXvKS4MuWg== X-Received: by 2002:a63:e57:: with SMTP id 23mr308895pgo.278.1603230948681; Tue, 20 Oct 2020 14:55:48 -0700 (PDT) Received: from localhost.localdomain ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id e6sm24113pfn.190.2020.10.20.14.55.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Oct 2020 14:55:48 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: Somnath Kotur , Venkat Duvvuru Date: Tue, 20 Oct 2020 14:55:32 -0700 Message-Id: <20201020215538.59242-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: <1602916089-18576-1-git-send-email-venkatkumar.duvvuru@broadcom.com> <20201020215538.59242-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [dpdk-dev] [PATCH v2 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 051ebac04..41736a80d 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; -- 2.21.1 (Apple Git-122.3)