From patchwork Mon Aug 3 14:12:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Somnath Kotur X-Patchwork-Id: 75145 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 8CB2EA052A; Mon, 3 Aug 2020 16:18:00 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 044C92BE1; Mon, 3 Aug 2020 16:17:59 +0200 (CEST) Received: from relay.smtp.broadcom.com (relay.smtp.broadcom.com [192.19.211.62]) by dpdk.org (Postfix) with ESMTP id E28FDF64 for ; Mon, 3 Aug 2020 16:17:57 +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 5CA1C29A690; Mon, 3 Aug 2020 07:17:56 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com 5CA1C29A690 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1596464276; bh=lLS1fMGpQUR3OmZhKjmWGjkd97SO/2G5Yx1GLc2N/94=; h=From:To:Cc:Subject:Date:From; b=k6oTR+VFZOT8fBHv7Pbg2/xotShwA1dSLHvYnrnYZVjm996nLoZwe5Ht28oQro3v/ UoDUBUYnYHmjb/x2IK5IkOD/xo1wDv8pCv5SI05sAPHZnnZsPEbFRst0Ni3uAWDzg0 uhePhnY4BICvU1BHB42zAN5QBlqwjTsaS0LXGCgg= From: Somnath Kotur To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Mon, 3 Aug 2020 19:42:19 +0530 Message-Id: <20200803141219.5682-1-somnath.kotur@broadcom.com> X-Mailer: git-send-email 2.10.1.613.g2cc2e70 Subject: [dpdk-dev] [PATCH] net/bnxt: fixes in flow counter mgr 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" OVS-DPDK seems to set the reset bit for every flow query. Honor the bit by resetting the SW counter values after assigning them. Also set the 'hit' bit only if the counter value retrieved by HW is non-zero. While querying flow stats, use max possible entries in the fc table scan for valid entries instead of active entries as the active entry can be in any slot in the table. This is a critical fix for OVS-DPDK flow aging. Fixes: 306c2d28e247 ("net/bnxt: support count action in flow query") Reviewed-by: Venkat Duvvuru Signed-off-by: Somnath Kotur --- drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c index febda94..df1921d 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c +++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c @@ -339,7 +339,7 @@ ulp_fc_mgr_alarm_cb(void *arg) struct bnxt_ulp_fc_info *ulp_fc_info; struct bnxt_ulp_device_params *dparms; struct tf *tfp; - uint32_t dev_id, hw_cntr_id = 0; + uint32_t dev_id, hw_cntr_id = 0, num_entries = 0; ulp_fc_info = bnxt_ulp_cntxt_ptr2_fc_info_get(ctxt); if (!ulp_fc_info) @@ -384,8 +384,9 @@ ulp_fc_mgr_alarm_cb(void *arg) break; } */ + num_entries = dparms->flow_count_db_entries / 2; for (i = 0; i < TF_DIR_MAX; i++) { - for (j = 0; j < ulp_fc_info->num_entries; j++) { + for (j = 0; j < num_entries; j++) { if (!ulp_fc_info->sw_acc_tbl[i][j].valid) continue; hw_cntr_id = ulp_fc_info->sw_acc_tbl[i][j].hw_cntr_id; @@ -551,7 +552,7 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context *ctxt, struct ulp_flow_db_res_params params; enum tf_dir dir; uint32_t hw_cntr_id = 0, sw_cntr_idx = 0; - struct sw_acc_counter sw_acc_tbl_entry; + struct sw_acc_counter *sw_acc_tbl_entry; bool found_cntr_resource = false; ulp_fc_info = bnxt_ulp_cntxt_ptr2_fc_info_get(ctxt); @@ -584,13 +585,21 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context *ctxt, 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]; + 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) { - count->hits_set = 1; - count->bytes_set = 1; - count->hits = sw_acc_tbl_entry.pkt_count; - count->bytes = sw_acc_tbl_entry.byte_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;