From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 63C76459FD; Fri, 27 Sep 2024 20:03:06 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6225E40A6D; Fri, 27 Sep 2024 20:02:07 +0200 (CEST) Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by mails.dpdk.org (Postfix) with ESMTP id EAF5140A67 for ; Fri, 27 Sep 2024 20:01:53 +0200 (CEST) Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2068a7c9286so26137745ad.1 for ; Fri, 27 Sep 2024 11:01:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1727460113; x=1728064913; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pWY1L+fadk+rSn0Ex25wQt1UoOd3J75qLAwcNHNcY9U=; b=TXKCA5QX5CI2Oc9SOFAr5m0ZeLunw7mmxZr2uK6sJUreviv6nb0XvF3AvDCxQF7wWS yEHRcHHDLpANWnrf1DYykCT+ZjDOsXVWlhxP0h3I6BOQF/+DS5kAcwgFNIq9pAgqQO4Z 561zb5OTkoMXfYlI2Dt0Qpv0WN4R3zto2yp1w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727460113; x=1728064913; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pWY1L+fadk+rSn0Ex25wQt1UoOd3J75qLAwcNHNcY9U=; b=gp8lHit+giO7IJD4xSfXsalNV41/sw08QiSSfqwZT4zV+TJ4FS70TLoGtiwp/aqHuk zk4OyeAmPgoInPICOTOvL4BAiPnCWGdsmnTR35SwVPYS8IGFTlJcmhxxv1y61Bh32ikl JFU1K/blM144VZeEKK4jkKvDr13vrqHtJRuB9Lbwnd78rX8FFrRjFqCgKd3Ifv/YQkfj mG2DLEetxAVcjMlgnlxrQJDFzyXI2NdRcja+a8pa6VsLuqDES8a+dmjwmb1rpWR/A9q5 UoQyLVHfcGrY3Qk2B5qYcxrap5PVM00s9QZhyjbgg/SuY9ajHFKC+9o4LSnhcG+0O7hR 3EfQ== X-Gm-Message-State: AOJu0YwxAk5ThGcoikRyLtsJblwK4q7K1JF0xMcgSxWvYhDlepXO9w2z +HVLMg+1fmMwKlyVH2CHycC8CzgW4ZSVtErxdeMiIZhju6zq8Sm2IvOBSarT1waor2oHNl6iBbZ 3qz+9zEOwvBPOYlwnxqHIZKf1PWuwJ/97PfGtzQRfv6RZzEQxLNk0m3YaxRqAtsR0IXnXGrZ9NF DH20BRqh85CHbk1NB21I8ilMZN+VvQCzxnm9Jw2MAXlw== X-Google-Smtp-Source: AGHT+IHJO/fb5jqV8jjx055ZN6JhOtD6g83qBjm9oBi44u4yb8AapJMHtVSs31ZwYWKyfTBbFIsZcw== X-Received: by 2002:a17:902:fb47:b0:202:4666:f018 with SMTP id d9443c01a7336-20b3767449dmr53869155ad.15.1727460112554; Fri, 27 Sep 2024 11:01:52 -0700 (PDT) Received: from dhcp-10-123-154-23.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b37e4e4desm16198945ad.251.2024.09.27.11.01.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 11:01:52 -0700 (PDT) From: Sriharsha Basavapatna To: dev@dpdk.org Cc: Kishore Padmanabha , Shuanglin Wang , Sriharsha Basavapatna , Michael Baucom , Ajit Khaparde Subject: [PATCH v2 27/47] net/bnxt: tf_ulp: fixed parent child db counters Date: Fri, 27 Sep 2024 23:38:09 +0530 Message-Id: <20240927180829.525350-28-sriharsha.basavapatna@broadcom.com> X-Mailer: git-send-email 2.39.0.189.g4dbebc36b0 In-Reply-To: <20240927180829.525350-1-sriharsha.basavapatna@broadcom.com> References: <20240927180829.525350-1-sriharsha.basavapatna@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Kishore Padmanabha The locking for the parent child counters need to be done till the stats are retrieved. Also the OVS is creating multiple F1 flows for same tunnel hence reference count needs to be maintined for the F1 flows. Fix name conflicts for class and action tables. Matcher allocates hash tables for class and action entries. These tables should have different names for each port. Signed-off-by: Kishore Padmanabha Signed-off-by: Shuanglin Wang Signed-off-by: Sriharsha Basavapatna Reviewed-by: Michael Baucom Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c | 37 +++++++++++++++++---------- drivers/net/bnxt/tf_ulp/ulp_flow_db.c | 22 ++++++++++------ drivers/net/bnxt/tf_ulp/ulp_flow_db.h | 2 ++ drivers/net/bnxt/tf_ulp/ulp_matcher.c | 12 +++++++-- 4 files changed, 50 insertions(+), 23 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c index b880b545da..0c46c7d4c9 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c +++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c @@ -563,23 +563,29 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context *ctxt, } while (!rc && nxt_resource_index); - bnxt_ulp_cntxt_release_fdb_lock(ctxt); - - if (rc || !found_cntr_resource) + if (rc || !found_cntr_resource) { + bnxt_ulp_cntxt_release_fdb_lock(ctxt); return rc; + } dir = params.direction; - if (!(ulp_fc_info->flags & ULP_FLAG_FC_SW_AGG_EN)) - return fc_ops->ulp_flow_stat_get(ctxt, dir, - params.resource_hndl, count); + if (!(ulp_fc_info->flags & ULP_FLAG_FC_SW_AGG_EN)) { + rc = fc_ops->ulp_flow_stat_get(ctxt, dir, + params.resource_hndl, count); + bnxt_ulp_cntxt_release_fdb_lock(ctxt); + return rc; + } if (!found_parent_flow && params.resource_sub_type == BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TABLE_INT_COUNT) { hw_cntr_id = params.resource_hndl; - if (!ulp_fc_info->num_counters) - return fc_ops->ulp_flow_stat_get(ctxt, dir, - hw_cntr_id, count); + if (!ulp_fc_info->num_counters) { + rc = fc_ops->ulp_flow_stat_get(ctxt, dir, + hw_cntr_id, count); + bnxt_ulp_cntxt_release_fdb_lock(ctxt); + return rc; + } /* TODO: * Think about optimizing with try_lock later @@ -603,9 +609,14 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context *ctxt, params.resource_sub_type == BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TABLE_INT_COUNT) { /* Get stats from the parent child table */ - ulp_flow_db_parent_flow_count_get(ctxt, pc_idx, - &count->hits, &count->bytes, - count->reset); + if (ulp_flow_db_parent_flow_count_get(ctxt, flow_id, + pc_idx, + &count->hits, + &count->bytes, + count->reset)) { + bnxt_ulp_cntxt_release_fdb_lock(ctxt); + return -EIO; + } if (count->hits) count->hits_set = 1; if (count->bytes) @@ -613,7 +624,7 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context *ctxt, } else { rc = -EINVAL; } - + bnxt_ulp_cntxt_release_fdb_lock(ctxt); return rc; } diff --git a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c index 099ae7adc8..679dab0f17 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c +++ b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c @@ -836,7 +836,6 @@ ulp_flow_db_fid_free(struct bnxt_ulp_context *ulp_ctxt, #ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG BNXT_DRV_DBG(DEBUG, "flow_id = %u:%u freed\n", flow_type, fid); #endif - /* all good, return success */ return 0; } @@ -1383,13 +1382,12 @@ ulp_flow_db_pc_db_parent_flow_set(struct bnxt_ulp_context *ulp_ctxt, if (set_flag) { pc_entry->parent_fid = parent_fid; + pc_entry->parent_ref_cnt++; } else { - if (pc_entry->parent_fid != parent_fid) - BNXT_DRV_DBG(ERR, "Panic: invalid parent id\n"); - pc_entry->parent_fid = 0; - + if (pc_entry->parent_ref_cnt > 0) + pc_entry->parent_ref_cnt--; /* Free the parent child db entry if no user present */ - if (!pc_entry->f2_cnt) + if (!pc_entry->parent_ref_cnt && !pc_entry->f2_cnt) ulp_flow_db_pc_db_entry_free(ulp_ctxt, pc_entry); } return 0; @@ -1444,7 +1442,7 @@ ulp_flow_db_pc_db_child_flow_set(struct bnxt_ulp_context *ulp_ctxt, ULP_INDEX_BITMAP_RESET(t[a_idx], child_fid); if (pc_entry->f2_cnt) pc_entry->f2_cnt--; - if (!pc_entry->f2_cnt && !pc_entry->parent_fid) + if (!pc_entry->f2_cnt && !pc_entry->parent_ref_cnt) ulp_flow_db_pc_db_entry_free(ulp_ctxt, pc_entry); } return 0; @@ -1536,7 +1534,7 @@ ulp_flow_db_parent_flow_count_accum_set(struct bnxt_ulp_context *ulp_ctxt, /* check for parent idx validity */ p_pdb = &flow_db->parent_child_db; if (pc_idx >= p_pdb->entries_count || - !p_pdb->parent_flow_tbl[pc_idx].parent_fid) { + !p_pdb->parent_flow_tbl[pc_idx].parent_ref_cnt) { BNXT_DRV_DBG(ERR, "Invalid parent child index %x\n", pc_idx); return -EINVAL; } @@ -1784,6 +1782,7 @@ ulp_flow_db_parent_flow_count_update(struct bnxt_ulp_context *ulp_ctxt, */ int32_t ulp_flow_db_parent_flow_count_get(struct bnxt_ulp_context *ulp_ctxt, + uint32_t flow_id, uint32_t pc_idx, uint64_t *packet_count, uint64_t *byte_count, uint8_t count_reset) { @@ -1796,6 +1795,13 @@ ulp_flow_db_parent_flow_count_get(struct bnxt_ulp_context *ulp_ctxt, return -EINVAL; } + /* stale parent fid */ + if (flow_id != pc_entry->parent_fid) { + *packet_count = 0; + *byte_count = 0; + return 0; + } + if (pc_entry->counter_acc) { *packet_count = pc_entry->pkt_count; *byte_count = pc_entry->byte_count; diff --git a/drivers/net/bnxt/tf_ulp/ulp_flow_db.h b/drivers/net/bnxt/tf_ulp/ulp_flow_db.h index 39810c81c4..5a4b5a1ebf 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_flow_db.h +++ b/drivers/net/bnxt/tf_ulp/ulp_flow_db.h @@ -63,6 +63,7 @@ struct bnxt_ulp_flow_tbl { struct ulp_fdb_parent_info { uint32_t valid; uint32_t parent_fid; + uint32_t parent_ref_cnt; uint32_t counter_acc; uint64_t pkt_count; uint64_t byte_count; @@ -389,6 +390,7 @@ ulp_flow_db_parent_flow_count_update(struct bnxt_ulp_context *ulp_ctxt, */ int32_t ulp_flow_db_parent_flow_count_get(struct bnxt_ulp_context *ulp_ctxt, + uint32_t flow_id, uint32_t pc_idx, uint64_t *packet_count, uint64_t *byte_count, diff --git a/drivers/net/bnxt/tf_ulp/ulp_matcher.c b/drivers/net/bnxt/tf_ulp/ulp_matcher.c index 2284fb6423..9e0a9458e7 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_matcher.c +++ b/drivers/net/bnxt/tf_ulp/ulp_matcher.c @@ -327,9 +327,17 @@ ulp_matcher_action_match(struct ulp_rte_parser_params *params, int32_t ulp_matcher_init(struct bnxt_ulp_context *ulp_ctx) { struct rte_hash_parameters hash_tbl_params = {0}; - char hash_class_tbl_name[64] = "bnxt_ulp_class_matcher"; - char hash_act_tbl_name[64] = "bnxt_ulp_act_matcher"; + char hash_class_tbl_name[64] = {0}; + char hash_act_tbl_name[64] = {0}; struct bnxt_ulp_matcher_data *data; + uint16_t port_id; + + /* append port_id to the buffer name */ + port_id = ulp_ctx->bp->eth_dev->data->port_id; + snprintf(hash_class_tbl_name, sizeof(hash_class_tbl_name), + "bnxt_ulp_class_matcher_%d", port_id); + snprintf(hash_act_tbl_name, sizeof(hash_act_tbl_name), + "bnxt_ulp_act_matcher_%d", port_id); data = rte_zmalloc("bnxt_ulp_matcher_data", sizeof(struct bnxt_ulp_matcher_data), 0); -- 2.39.3