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 D92B845D38; Mon, 18 Nov 2024 17:07:33 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B6E6840F35; Mon, 18 Nov 2024 17:07:18 +0100 (CET) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by mails.dpdk.org (Postfix) with ESMTP id 3AB1B40ED9 for ; Mon, 18 Nov 2024 17:07:17 +0100 (CET) Received: by mail-pl1-f196.google.com with SMTP id d9443c01a7336-211a4682fcaso29605605ad.2 for ; Mon, 18 Nov 2024 08:07:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1731946036; x=1732550836; 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=UWePuABMrvFD+vI7j4Et44LY2FTCPj7QulbKFltOH9s=; b=GSlnMraqHn1ldc1BCQbQleyiEcy4iReQcK7AdpPA/oa4jno5NOcMPnU1wQ18KKKXnu aqHhrj29eODhZcfj/rlkEGhq36qW6n9pFGmnoMPuaGDGI8zI9Ab3wGFCss/fpZt3qq+C t4vwcwcbj3YRHl+rQm9Qm90ypRBbeZ9ra4Y/o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731946036; x=1732550836; 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=UWePuABMrvFD+vI7j4Et44LY2FTCPj7QulbKFltOH9s=; b=agUt5HPpTpBJMWhsbTsbR712/ut7WiOA+e+r8RFsjHvxRJK9TPCjiBjVweM7SXzspz d6BL6fIGyyiMi9/CGO5stmmxRIBJTJ2BEIF0cssq/iv8gXJp6PC46qPgeuosCV90LrKD i6eADInkpnJZEK2oN7iIjVYWqqqpJDFLshfkCGtj9fM7eJPwuVGgMHsGHVTUH3jHR66F mslw8WXvTUMz+t8h+FIFrQH8T7F3cF3U0aYfwsI9LCpTo4k//Tj5dU4H14g4gjGnV7sH GyU7ENiekvdswzr/wx8Py2MLkkFTuVM9PuarpIB2q4pyyLkiJFgWjbxC482FI56K5gF3 B7/A== X-Gm-Message-State: AOJu0YyHENhNoZ/QA8bAHlEzeTKNea0nj9dby78KUWdNYKejfpfB6ZeZ KafJmUD/tZITj5c5my0vR3hEQt4NIEXBO7nR96hGjM8cn6WrbHHSbXy4AtHUYlQl4tsgPPyo1MN G7unNyRZjqh/VIQ77eI7C1SO0RjOOARCdfcDy8O2C5LCaCnGrHRVgcmhZWuyO59HrVgKDsAquBd fI36DpTaY5DZPvfPTbVBA6Yks3K3LeE0pMhid0Frb5XFRq X-Google-Smtp-Source: AGHT+IFo2ZbP5FoystnUzv/ruLQnKwJdyAzRREsFId3nrFIsNwcmwad2YINiEPXOGJpk0m6/CFog7g== X-Received: by 2002:a17:902:e843:b0:211:6b31:2f30 with SMTP id d9443c01a7336-211d0ed2bc3mr167203145ad.50.1731946035305; Mon, 18 Nov 2024 08:07:15 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2024 08:07:14 -0800 (PST) From: Sriharsha Basavapatna To: dev@dpdk.org Cc: Peter Spreadborough , Farah Smith , Jay Ding , Sriharsha Basavapatna Subject: [PATCH v1 3/4] net/bnxt/tf_ulp: performance and tuning changes for thor2 stats cache Date: Mon, 18 Nov 2024 21:48:57 +0530 Message-Id: <20241118161858.1181992-4-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: Peter Spreadborough This change adds changes the act get API to expect a physical address for the host memory rather than a pointer to a local virtual address. The change was made because the virt->phys API call has a very high overhead. Also included in this change to the mutex locks and delays within the main loop. Fixes: 0513f0af034d ("net/bnxt/tf_ulp: add stats cache for Thor2") Reviewed-by: Farah Smith Reviewed-by: Jay Ding Signed-off-by: Peter Spreadborough Signed-off-by: Sriharsha Basavapatna --- drivers/net/bnxt/tf_core/v3/tfc.h | 12 ++++--- drivers/net/bnxt/tf_core/v3/tfc_act.c | 26 ++++++-------- drivers/net/bnxt/tf_ulp/ulp_fc_mgr_tfc.c | 5 ++- drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c | 45 ++++++++++++++++++++---- drivers/net/bnxt/tf_ulp/ulp_sc_mgr.h | 3 +- drivers/net/bnxt/tf_ulp/ulp_sc_mgr_tfc.c | 4 +-- 6 files changed, 65 insertions(+), 30 deletions(-) diff --git a/drivers/net/bnxt/tf_core/v3/tfc.h b/drivers/net/bnxt/tf_core/v3/tfc.h index 98725b32c2..4176aa01bd 100644 --- a/drivers/net/bnxt/tf_core/v3/tfc.h +++ b/drivers/net/bnxt/tf_core/v3/tfc.h @@ -705,7 +705,9 @@ enum tfc_tbl_scope_bucket_factor { TFC_TBL_SCOPE_BUCKET_FACTOR_4 = 4, TFC_TBL_SCOPE_BUCKET_FACTOR_8 = 8, TFC_TBL_SCOPE_BUCKET_FACTOR_16 = 16, - TFC_TBL_SCOPE_BUCKET_FACTOR_MAX = TFC_TBL_SCOPE_BUCKET_FACTOR_16 + TFC_TBL_SCOPE_BUCKET_FACTOR_32 = 32, + TFC_TBL_SCOPE_BUCKET_FACTOR_64 = 64, + TFC_TBL_SCOPE_BUCKET_FACTOR_MAX = TFC_TBL_SCOPE_BUCKET_FACTOR_64 }; /** @@ -1420,8 +1422,9 @@ int tfc_act_set(struct tfc *tfcp, * @param[in] cmm_clr * Pointer to cmm clr * - * @param[in,out] data - * Data read. Must be word aligned, i.e. [1:0] must be 0. + * @param[in,out] host_address + * Data read. Must be word aligned, i.e. [1:0] must be 0. The address + * must be the ret_mem_virt2iova() version of the virt address. * * @param[in,out] data_sz_words * Data buffer size in words. Size could be 8/16/24/32/64B @@ -1437,7 +1440,8 @@ int tfc_act_get(struct tfc *tfcp, struct tfc_mpc_batch_info_t *batch_info, const struct tfc_cmm_info *cmm_info, struct tfc_cmm_clr *clr, - uint8_t *data, uint16_t *data_sz_words); + uint64_t *host_address, + uint16_t *data_sz_words); /** * Free a CMM Resource diff --git a/drivers/net/bnxt/tf_core/v3/tfc_act.c b/drivers/net/bnxt/tf_core/v3/tfc_act.c index 3e215f4881..0e98bd30d7 100644 --- a/drivers/net/bnxt/tf_core/v3/tfc_act.c +++ b/drivers/net/bnxt/tf_core/v3/tfc_act.c @@ -367,7 +367,7 @@ int tfc_act_get_only_response(struct cfa_bld_mpcinfo *mpc_info, static int tfc_act_get_only(struct tfc *tfcp, struct tfc_mpc_batch_info_t *batch_info, const struct tfc_cmm_info *cmm_info, - uint8_t *data, + uint64_t *host_address, uint16_t *data_sz_words) { int rc = 0; @@ -378,7 +378,6 @@ static int tfc_act_get_only(struct tfc *tfcp, uint32_t buff_len; struct cfa_mpc_data_obj fields_cmd[CFA_BLD_MPC_READ_CMD_MAX_FLD] = { {0} }; uint32_t entry_offset; - uint64_t host_address; struct bnxt_mpc_mbuf mpc_msg_in; struct bnxt_mpc_mbuf mpc_msg_out; uint32_t record_size; @@ -405,13 +404,11 @@ static int tfc_act_get_only(struct tfc *tfcp, } /* Check that data pointer is word aligned */ - if (unlikely(((uint64_t)data) & 0x3ULL)) { + if (unlikely(*host_address & 0x3ULL)) { PMD_DRV_LOG_LINE(ERR, "data pointer not word aligned"); return -EINVAL; } - host_address = (uint64_t)rte_mem_virt2iova(data); - /* Check that MPC APIs are bound */ if (unlikely(mpc_info->mpcops == NULL)) { PMD_DRV_LOG_LINE(ERR, "MPC not initialized"); @@ -450,7 +447,7 @@ static int tfc_act_get_only(struct tfc *tfcp, fields_cmd[CFA_BLD_MPC_READ_CMD_HOST_ADDRESS_FLD].field_id = CFA_BLD_MPC_READ_CMD_HOST_ADDRESS_FLD; - fields_cmd[CFA_BLD_MPC_READ_CMD_HOST_ADDRESS_FLD].val = host_address; + fields_cmd[CFA_BLD_MPC_READ_CMD_HOST_ADDRESS_FLD].val = *host_address; buff_len = TFC_MPC_MAX_TX_BYTES; @@ -547,7 +544,7 @@ int tfc_act_get_clear_response(struct cfa_bld_mpcinfo *mpc_info, static int tfc_act_get_clear(struct tfc *tfcp, struct tfc_mpc_batch_info_t *batch_info, const struct tfc_cmm_info *cmm_info, - uint8_t *data, + uint64_t *host_address, uint16_t *data_sz_words, uint8_t clr_offset, uint8_t clr_size) @@ -560,7 +557,6 @@ static int tfc_act_get_clear(struct tfc *tfcp, uint32_t buff_len; struct cfa_mpc_data_obj fields_cmd[CFA_BLD_MPC_READ_CLR_CMD_MAX_FLD] = { {0} }; uint32_t entry_offset; - uint64_t host_address; struct bnxt_mpc_mbuf mpc_msg_in; struct bnxt_mpc_mbuf mpc_msg_out; uint32_t record_size; @@ -589,13 +585,11 @@ static int tfc_act_get_clear(struct tfc *tfcp, } /* Check that data pointer is word aligned */ - if (unlikely(((uint64_t)data) & 0x3ULL)) { + if (unlikely(*host_address & 0x3ULL)) { PMD_DRV_LOG_LINE(ERR, "data pointer not word aligned"); return -EINVAL; } - host_address = (uint64_t)rte_mem_virt2iova(data); - /* Check that MPC APIs are bound */ if (unlikely(mpc_info->mpcops == NULL)) { PMD_DRV_LOG_LINE(ERR, "MPC not initialized"); @@ -634,7 +628,7 @@ static int tfc_act_get_clear(struct tfc *tfcp, fields_cmd[CFA_BLD_MPC_READ_CLR_CMD_HOST_ADDRESS_FLD].field_id = CFA_BLD_MPC_READ_CLR_CMD_HOST_ADDRESS_FLD; - fields_cmd[CFA_BLD_MPC_READ_CLR_CMD_HOST_ADDRESS_FLD].val = host_address; + fields_cmd[CFA_BLD_MPC_READ_CLR_CMD_HOST_ADDRESS_FLD].val = *host_address; for (i = clr_offset; i < clr_size; i++) mask |= (1 << i); @@ -700,7 +694,8 @@ int tfc_act_get(struct tfc *tfcp, struct tfc_mpc_batch_info_t *batch_info, const struct tfc_cmm_info *cmm_info, struct tfc_cmm_clr *clr, - uint8_t *data, uint16_t *data_sz_words) + uint64_t *host_address, + uint16_t *data_sz_words) { /* It's not an error to pass clr as a Null pointer, just means that read * and clear is not being requested. Also allow the user to manage @@ -718,14 +713,15 @@ int tfc_act_get(struct tfc *tfcp, return tfc_act_get_clear(tfcp, batch_info, cmm_info, - data, data_sz_words, + host_address, + data_sz_words, clr->offset_in_byte / 2, clr->sz_in_byte / 2); } else { return tfc_act_get_only(tfcp, batch_info, cmm_info, - data, + host_address, data_sz_words); } } diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr_tfc.c b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr_tfc.c index e73fdcd1c7..4a1d0bf3df 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr_tfc.c +++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr_tfc.c @@ -53,6 +53,7 @@ ulp_fc_tfc_update_accum_stats(__rte_unused struct bnxt_ulp_context *ctxt, } static uint8_t *data; +static uint64_t virt2iova_data; static int32_t ulp_fc_tfc_flow_stat_get(struct bnxt_ulp_context *ctxt, @@ -84,6 +85,8 @@ ulp_fc_tfc_flow_stat_get(struct bnxt_ulp_context *ctxt, BNXT_DRV_DBG(ERR, "Failed to allocate dma buffer\n"); return -EINVAL; } + + virt2iova_data = (uint64_t)rte_mem_virt2iova(data); } /* Ensure that data is large enough to read words */ @@ -105,7 +108,7 @@ ulp_fc_tfc_flow_stat_get(struct bnxt_ulp_context *ctxt, cmm_clr.sz_in_byte = sizeof(data64[ULP_FC_TFC_PKT_CNT_OFFS]) + sizeof(data64[ULP_FC_TFC_BYTE_CNT_OFFS]); } - rc = tfc_act_get(tfcp, NULL, &cmm_info, &cmm_clr, data, &word_size); + rc = tfc_act_get(tfcp, NULL, &cmm_info, &cmm_clr, &virt2iova_data, &word_size); if (rc) { BNXT_DRV_DBG(ERR, "Failed to read stat memory hndl=0x%" PRIx64 "\n", diff --git a/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c index c82fdaf6dd..5fa8e240db 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c +++ b/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c @@ -3,6 +3,8 @@ * All rights reserved. */ +#include +#include #include #include #include @@ -56,7 +58,9 @@ int32_t ulp_sc_mgr_init(struct bnxt_ulp_context *ctxt) struct bnxt_ulp_sc_info *ulp_sc_info; uint32_t stats_cache_tbl_sz; uint32_t dev_id; + uint8_t *data; int rc; + int i; if (!ctxt) { BNXT_DRV_DBG(DEBUG, "Invalid ULP CTXT\n"); @@ -124,6 +128,12 @@ int32_t ulp_sc_mgr_init(struct bnxt_ulp_context *ctxt) goto error; } + data = ulp_sc_info->read_data; + for (i = 0; i < ULP_SC_BATCH_SIZE; i++) { + ulp_sc_info->read_data_iova[i] = (uint64_t)rte_mem_virt2iova(data); + data += ULP_SC_PAGE_SIZE; + } + rc = ulp_sc_mgr_thread_start(ctxt); if (rc) BNXT_DRV_DBG(DEBUG, "Stats counter thread start failed\n"); @@ -241,12 +251,12 @@ static uint32_t ulp_stats_cache_main_loop(void *arg) (uint64_t)sce; rc = sc_ops->ulp_stats_cache_update(tfcp, - sce->dir, - data, - sce->handle, - &words, - &batch_info, - sce->reset); + sce->dir, + &ulp_sc_info->read_data_iova[batch], + sce->handle, + &words, + &batch_info, + sce->reset); if (unlikely(rc)) { /* Abort this batch */ PMD_DRV_LOG_LINE(ERR, @@ -330,18 +340,39 @@ int32_t ulp_sc_mgr_thread_start(struct bnxt_ulp_context *ctxt) { struct bnxt_ulp_sc_info *ulp_sc_info; + rte_thread_attr_t attr; + rte_cpuset_t mask; + size_t i; int rc; ulp_sc_info = bnxt_ulp_cntxt_ptr2_sc_info_get(ctxt); if (ulp_sc_info && !(ulp_sc_info->flags & ULP_FLAG_SC_THREAD)) { + rte_thread_attr_init(&attr); + + rte_thread_get_affinity(&mask); + + for (i = 1; i < CPU_SETSIZE; i++) { + if (CPU_ISSET(i, &mask)) { + CPU_ZERO(&mask); + CPU_SET(i + 2, &mask); + break; + } + } + + rc = rte_thread_attr_set_affinity(&attr, &mask); + if (rc) + return rc; + rc = rte_thread_create(&ulp_sc_info->tid, - NULL, + &attr, &ulp_stats_cache_main_loop, (void *)ctxt->cfg_data); if (rc) return rc; + rte_thread_set_prefixed_name(ulp_sc_info->tid, "ulp_sc_mgr"); + ulp_sc_info->flags |= ULP_FLAG_SC_THREAD; } diff --git a/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.h b/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.h index d5c835cd75..5501dc18fd 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.h +++ b/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.h @@ -36,6 +36,7 @@ struct ulp_sc_tfc_stats_cache_entry { struct bnxt_ulp_sc_info { struct ulp_sc_tfc_stats_cache_entry *stats_cache_tbl; uint8_t *read_data; + uint64_t read_data_iova[ULP_SC_BATCH_SIZE]; uint32_t flags; uint32_t num_entries; uint32_t num_counters; @@ -48,7 +49,7 @@ struct bnxt_ulp_sc_core_ops { int32_t (*ulp_stats_cache_update)(struct tfc *tfcp, int dir, - uint8_t *data, + uint64_t *host_address, uint64_t handle, uint16_t *words, struct tfc_mpc_batch_info_t *batch_info, diff --git a/drivers/net/bnxt/tf_ulp/ulp_sc_mgr_tfc.c b/drivers/net/bnxt/tf_ulp/ulp_sc_mgr_tfc.c index a8141980d8..23edf9f755 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_sc_mgr_tfc.c +++ b/drivers/net/bnxt/tf_ulp/ulp_sc_mgr_tfc.c @@ -24,7 +24,7 @@ static int32_t ulp_sc_tfc_stats_cache_update(struct tfc *tfcp, int dir, - uint8_t *data, + uint64_t *host_address, uint64_t handle, uint16_t *words, struct tfc_mpc_batch_info_t *batch_info, @@ -48,7 +48,7 @@ ulp_sc_tfc_stats_cache_update(struct tfc *tfcp, batch_info, &cmm_info, &cmm_clr, - data, + host_address, words); return rc; -- 2.39.3