From patchwork Mon Oct 26 03:56:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Khaparde X-Patchwork-Id: 82134 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 C9B7DA04B5; Mon, 26 Oct 2020 04:58:09 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9210D2C2A; Mon, 26 Oct 2020 04:56:40 +0100 (CET) Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by dpdk.org (Postfix) with ESMTP id DB4F72BAA for ; Mon, 26 Oct 2020 04:56:29 +0100 (CET) Received: by mail-pj1-f66.google.com with SMTP id lt2so2368669pjb.2 for ; Sun, 25 Oct 2020 20:56:29 -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=8aFN0LVp4+IXgxPELokqteFaquFhETvGtH6yo/Bod64=; b=RWKe0sv8fy4yyqicDl+Xl+1JL5/lrGULfNIz8sGEsLGtEj6kQlkZ93k1sRyAvbnvUs vgdks0U/mES6UCFvvxvUsy0JPNlGgGwFveTUB6kyR2Agdqt25AhYaCidPDkBbNeqORNO PVLhIPmVxRzbxGejNkw84tTIaPVVSWelNzUIQ= 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=8aFN0LVp4+IXgxPELokqteFaquFhETvGtH6yo/Bod64=; b=MojWlh7tqIj3um5ZsSDAL59PzpBKFKmq0+odLi2IOw+oupG3n4aEq7dmaFw1KpidSo /xkqnZhclp9e1u1wDVgY4Eq0EQCQhkFR23bLmIL1bamOpPw5N3I4uIE8nzGKLlYHDzcA PvO8Kf4+VDgnTXr2GmlpEtzC2C14MRvH4IBeGquL+WEoqMOlbxSY8XIh/2HHqtCuFb9M OFYBrUgXlKn8FaOubzGISVk0JrHJTTqBdr/sN+A8wzxdVhBXH6PW3VIZnv3WfvSa97BF PDKdHHUE/a8DDD2Kp846SznGUQuhAOt4ewmZiL35PGuhcvsjhT/NfSbB/QTRz0yHFcGL tucg== X-Gm-Message-State: AOAM5333jZNY26pi52Dbp4xY0+5KuyQ/7em+8cVybi8MhzilvthoifkW 9yxAgvYMyHW40WzMJKZJAB9wSaRF5EaNJk0jebVyT9N9Cd8NclsZMhoOgztZESyqZ366Mr05ovP 5p+Gvf+7VUfO3jwexm4vNXO/PWtj7o1oaATRE6djNRB71Iz72zeXXSOFkQCTK+K/9qA== X-Google-Smtp-Source: ABdhPJyAzwrHTwnsMnWsSppVD5ubceU5Eqdn4f6JgSjEH9I9KVR+Z04SAuzvfkPYdNvlUVRKiDQc9A== X-Received: by 2002:a17:902:b18f:b029:d2:1ec0:4161 with SMTP id s15-20020a170902b18fb02900d21ec04161mr6591818plr.58.1603684588664; Sun, 25 Oct 2020 20:56:28 -0700 (PDT) Received: from localhost.localdomain ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id z185sm10207463pfz.32.2020.10.25.20.56.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Oct 2020 20:56:27 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: Somnath Kotur , Venkat Duvvuru Date: Sun, 25 Oct 2020 20:56:06 -0700 Message-Id: <20201026035616.19264-6-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20201026035616.19264-1-ajit.khaparde@broadcom.com> References: <20201026035616.19264-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [dpdk-dev] [PATCH v4 05/15] net/bnxt: fix 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 Fix infinite loop in flow query count. `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;