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 E40A445D38; Mon, 18 Nov 2024 17:07:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0771640A84; Mon, 18 Nov 2024 17:07:13 +0100 (CET) Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by mails.dpdk.org (Postfix) with ESMTP id D942A40A6E for ; Mon, 18 Nov 2024 17:07:11 +0100 (CET) Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-71e79f73aaeso3211213b3a.3 for ; Mon, 18 Nov 2024 08:07:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1731946030; x=1732550830; 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=RGWEeFgNuFzCeAKqqIgTWRE7oI4HpFtX8oLeERreJeM=; b=RAXoVd4fqXUY5l1+NBcZNX9lM/vwINPxJJahOWIyIeetwg25PlI5Eadk+LQhaS018L LBrg3BLi+dpySI0j5TsvKZfFkLE7DbZ8tcEEN+H0DmDvKS4t5HnsPdLwlk69+gilnySq 3z3CEfU+y+mUigGQbz/9SsOrXBlr7JLu8PTe8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731946030; x=1732550830; 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=RGWEeFgNuFzCeAKqqIgTWRE7oI4HpFtX8oLeERreJeM=; b=ZQ2fJxU/fCKEvhwC56XWcSWgcBNJIoiUGQQjT5MRmF3UYbvE9VbF4AnBRsOqdlx1lw WAvyG0ngxMlRzwtKnRKx/0oevZ8wLOxhuc479MzBwBGJ1fWYMprhlf7mAgTmoigPurcj +htN3RZ+MvGtjoH3oyFUqwVBtZLSFean2/W5VxZjjetXuLy0AUFfeZ3BSnUlOByBQuMU /XyxOkE7GXe7oUtjU9EKVIP44FscGQo0c5P9yAWPOjnESTPaLfq61QEJjjAtv42iDt/8 8vljfc+JK0dA5OJ8rSeHPWFQ6l4c57EF0lYHJQBGMQyxMKiWSlfLDecjPROCb08vNOv4 iSCw== X-Gm-Message-State: AOJu0YzKXLNr7N44a2SLFDpqC/0otwt77YrJeQ7bgAKf6Z6/xqbuBu0y +e0XAUdWCgfXaUiaEYrL7dBd6j0DUcFnXx0r1pXDkKo229pTSgFB/GutVuZVPKNXEgxC+eMp3Eo rxviFH9BmpfaM95JyIW0i8HaIHwbprZrcu+jPbeDu1iddbcUAhHULnFN5F5JW7u7CBqFjMtb+v6 /YKmHOnJh41XvB7TgUHZAM9OY6+WJrvcxlOfBjOj+Atw== X-Google-Smtp-Source: AGHT+IGi6b1sGw2IKi1VhaUmMYUyFK33reYzpli8m80vgf97T4cMKIbuJdVXGZtBnUdgn6gPvz/5iA== X-Received: by 2002:a05:6a00:9297:b0:724:5c66:ecbd with SMTP id d2e1a72fcca58-72476d5bf7bmr17723993b3a.23.1731946030187; Mon, 18 Nov 2024 08:07:10 -0800 (PST) Received: from dhcp-10-123-154-23.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-724771c0baesm6368830b3a.92.2024.11.18.08.07.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2024 08:07:09 -0800 (PST) From: Sriharsha Basavapatna To: dev@dpdk.org Cc: Shuanglin Wang , Kishore Padmanabha , Sangtani Parag Satishbhai , Sriharsha Basavapatna Subject: [PATCH v1 1/4] net/bnxt/tf_ulp: fix F1F2 vxlan counter acccumulation for Thor2 Date: Mon, 18 Nov 2024 21:48:55 +0530 Message-Id: <20241118161858.1181992-2-sriharsha.basavapatna@broadcom.com> X-Mailer: git-send-email 2.39.0.189.g4dbebc36b0 In-Reply-To: <20241118161858.1181992-1-sriharsha.basavapatna@broadcom.com> References: <20241118161858.1181992-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: Shuanglin Wang Add code for Thor2 to support the counter accumulation for F1F2 vxlan parent-child flows. Also, add a check for device state in the TF tunnel free API, if it is zero then TF will skip the resource free as it was already done by bnxt_free_all_hwrm_resources. Fixes: 0513f0af034d ("net/bnxt/tf_ulp: add stats cache for Thor2") Reviewed-by: Kishore Padmanabha Signed-off-by: Shuanglin Wang Signed-off-by: Sangtani Parag Satishbhai Signed-off-by: Sriharsha Basavapatna --- drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c | 12 ++- drivers/net/bnxt/tf_ulp/ulp_flow_db.c | 4 +- drivers/net/bnxt/tf_ulp/ulp_flow_db.h | 13 +++ drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c | 110 +++++++++++++++++++-- drivers/net/bnxt/tf_ulp/ulp_sc_mgr.h | 18 +++- 5 files changed, 142 insertions(+), 15 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c b/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c index c8f3a5abc2..5854f13447 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c @@ -587,10 +587,16 @@ bnxt_pmd_global_tunnel_set(struct bnxt_ulp_context *ulp_ctx, return -EINVAL; } - if (udp_port) + if (udp_port) { rc = bnxt_udp_tunnel_port_add_op(eth_dev, &udp_tunnel); - else - rc = bnxt_udp_tunnel_port_del_op(eth_dev, &udp_tunnel); + } else { + /* TODO: Make the counters shareable so the resource + * free can be synced up between core dpdk path and + * the tf path. + */ + if (eth_dev->data->dev_started != 0) + rc = bnxt_udp_tunnel_port_del_op(eth_dev, &udp_tunnel); + } } else { bp = bnxt_pmd_get_bp(port_id); if (!bp) { diff --git a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c index d6fd653b4a..943c9b799c 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c +++ b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c @@ -1176,7 +1176,7 @@ ulp_default_flow_db_cfa_action_get(struct bnxt_ulp_context *ulp_ctx, } /* internal validation function for parent flow tbl */ -static struct ulp_fdb_parent_info * +struct ulp_fdb_parent_info * ulp_flow_db_pc_db_entry_get(struct bnxt_ulp_context *ulp_ctxt, uint32_t pc_idx) { @@ -1634,6 +1634,8 @@ ulp_flow_db_parent_flow_create(struct bnxt_ulp_mapper_parms *parms) } } + /* Set parent flow entry idx in stats cache entry */ + ulp_sc_mgr_set_pc_idx(parms->ulp_ctx, parms->flow_id, pc_idx); return 0; } diff --git a/drivers/net/bnxt/tf_ulp/ulp_flow_db.h b/drivers/net/bnxt/tf_ulp/ulp_flow_db.h index 762ebb039d..4301094cfe 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_flow_db.h +++ b/drivers/net/bnxt/tf_ulp/ulp_flow_db.h @@ -417,4 +417,17 @@ void ulp_flow_db_shared_session_set(struct ulp_flow_db_res_params *res, */ enum bnxt_ulp_session_type ulp_flow_db_shared_session_get(struct ulp_flow_db_res_params *res); + +/* + * Get the parent flow table info + * + * ulp_ctxt [in] Ptr to ulp_context + * pc_idx [in] The index to parent child db + * + * returns Pointer of parent flow tbl + */ +struct ulp_fdb_parent_info * +ulp_flow_db_pc_db_entry_get(struct bnxt_ulp_context *ulp_ctxt, + uint32_t pc_idx); + #endif /* _ULP_FLOW_DB_H_ */ diff --git a/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c index 13069126f0..1317668555 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c +++ b/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c @@ -441,8 +441,17 @@ int ulp_sc_mgr_query_count_get(struct bnxt_ulp_context *ctxt, { struct ulp_sc_tfc_stats_cache_entry *sce; struct bnxt_ulp_sc_info *ulp_sc_info; + struct ulp_fdb_parent_info *pc_entry; + struct bnxt_ulp_flow_db *flow_db; + uint32_t max_array; + uint32_t child_fid; + uint32_t a_idx; + uint32_t f2_cnt; + uint64_t *t; + uint64_t bs; int rc = 0; + /* Get stats cache info */ ulp_sc_info = bnxt_ulp_cntxt_ptr2_sc_info_get(ctxt); if (!ulp_sc_info) return -ENODEV; @@ -450,18 +459,66 @@ int ulp_sc_mgr_query_count_get(struct bnxt_ulp_context *ctxt, sce = ulp_sc_info->stats_cache_tbl; sce += flow_id; - /* If entry is not valid return an error */ - if (!(sce->flags & ULP_SC_ENTRY_FLAG_VALID)) - return -EBUSY; - - count->hits = sce->packet_count; - count->hits_set = 1; - count->bytes = sce->byte_count; - count->bytes_set = 1; + /* To handle the parent flow */ + if (sce->flags & ULP_SC_ENTRY_FLAG_PARENT) { + flow_db = bnxt_ulp_cntxt_ptr2_flow_db_get(ctxt); + if (!flow_db) { + BNXT_DRV_DBG(ERR, "parent child db validation failed\n"); + return -EINVAL; + } - if (count->reset) - sce->reset = true; + /* Validate the arguments and parent child entry */ + pc_entry = ulp_flow_db_pc_db_entry_get(ctxt, sce->pc_idx); + if (!pc_entry) { + BNXT_DRV_DBG(ERR, "failed to get the parent child entry\n"); + return -EINVAL; + } + t = pc_entry->child_fid_bitset; + f2_cnt = pc_entry->f2_cnt; + max_array = flow_db->parent_child_db.child_bitset_size * 8 / ULP_INDEX_BITMAP_SIZE; + + /* Iterate all possible child flows */ + for (a_idx = 0; (a_idx < max_array) && f2_cnt; a_idx++) { + /* If it is zero, then check the next bitset */ + bs = t[a_idx]; + if (!bs) + continue; + + /* check one bitset */ + do { + /* get the next child fid */ + child_fid = (a_idx * ULP_INDEX_BITMAP_SIZE) + rte_clz64(bs); + sce = ulp_sc_info->stats_cache_tbl; + sce += child_fid; + + /* clear the bit for this child flow */ + ULP_INDEX_BITMAP_RESET(bs, child_fid); + f2_cnt--; + + /* no counter action, then ignore flows */ + if (!(sce->flags & ULP_SC_ENTRY_FLAG_VALID)) + continue; + count->hits += sce->packet_count; + count->hits_set = 1; + count->bytes += sce->byte_count; + count->bytes_set = 1; + } while (bs && f2_cnt); + } + } else { + /* To handle regular or child flows */ + /* If entry is not valid return an error */ + if (!(sce->flags & ULP_SC_ENTRY_FLAG_VALID)) + return -EBUSY; + + count->hits = sce->packet_count; + count->hits_set = 1; + count->bytes = sce->byte_count; + count->bytes_set = 1; + + if (count->reset) + sce->reset = true; + } return rc; } @@ -491,6 +548,8 @@ int ulp_sc_mgr_entry_alloc(struct bnxt_ulp_mapper_parms *parms, memset(sce, 0, sizeof(*sce)); sce->ctxt = parms->ulp_ctx; sce->flags |= ULP_SC_ENTRY_FLAG_VALID; + if (parms->parent_flow) + sce->flags |= ULP_SC_ENTRY_FLAG_PARENT; sce->handle = counter_handle; sce->dir = tbl->direction; ulp_sc_info->num_entries++; @@ -524,3 +583,34 @@ void ulp_sc_mgr_entry_free(struct bnxt_ulp_context *ulp, pthread_mutex_unlock(&ulp_sc_info->sc_lock); } + +/* + * Set pc_idx for the flow if stat cache info is valid + * + * ctxt [in] The ulp context for the flow counter manager + * + * flow_id [in] The HW flow ID + * + * pc_idx [in] The parent flow entry idx + * + */ +void ulp_sc_mgr_set_pc_idx(struct bnxt_ulp_context *ctxt, + uint32_t flow_id, + uint32_t pc_idx) +{ + struct ulp_sc_tfc_stats_cache_entry *sce; + struct bnxt_ulp_sc_info *ulp_sc_info; + + /* Get stats cache info */ + ulp_sc_info = bnxt_ulp_cntxt_ptr2_sc_info_get(ctxt); + if (!ulp_sc_info) + return; + + pthread_mutex_lock(&ulp_sc_info->sc_lock); + + sce = ulp_sc_info->stats_cache_tbl; + sce += flow_id; + sce->pc_idx = pc_idx & ULP_SC_PC_IDX_MASK; + + pthread_mutex_unlock(&ulp_sc_info->sc_lock); +} diff --git a/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.h b/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.h index 85524ce371..2c08d08b17 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.h +++ b/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.h @@ -13,13 +13,16 @@ #define ULP_FLAG_SC_THREAD BIT(0) #define ULP_SC_ENTRY_FLAG_VALID BIT(0) +#define ULP_SC_ENTRY_FLAG_PARENT BIT(1) +#define ULP_SC_PC_IDX_MASK 0xFFFFF #define ULP_SC_BATCH_SIZE 64 #define ULP_SC_PAGE_SIZE 4096 struct ulp_sc_tfc_stats_cache_entry { struct bnxt_ulp_context *ctxt; - uint32_t flags; + uint32_t flags : 8; + uint32_t pc_idx : 24; uint64_t timestamp; uint64_t handle; uint8_t dir; @@ -137,6 +140,19 @@ int ulp_sc_mgr_entry_alloc(struct bnxt_ulp_mapper_parms *parms, void ulp_sc_mgr_entry_free(struct bnxt_ulp_context *ulp, uint32_t fid); + +/* + * Set pc_idx for the flow if stat cache info is valid + * + * ctxt [in] The ulp context for the flow counter manager + * flow_id [in] The HW flow ID + * pc_idx [in] The parent flow entry idx + * + */ +void ulp_sc_mgr_set_pc_idx(struct bnxt_ulp_context *ctxt, + uint32_t flow_id, + uint32_t pc_idx); + extern const struct bnxt_ulp_sc_core_ops ulp_sc_tfc_core_ops; #endif /* _ULP_SC_MGR_H_ */ -- 2.39.3