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 E09C645D3D; Tue, 19 Nov 2024 06:35:11 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D30FE42799; Tue, 19 Nov 2024 06:35:11 +0100 (CET) Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by mails.dpdk.org (Postfix) with ESMTP id 2D089427A9 for ; Tue, 19 Nov 2024 06:35:10 +0100 (CET) Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-720d01caa66so3475645b3a.2 for ; Mon, 18 Nov 2024 21:35:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1731994509; x=1732599309; 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=BkiOHpZWa8Ppkt7Gxk2Wet+FZuG0onO2LTXVxUBXgXE=; b=FscBmGEslHvidfmZ0KYxCaI2Zr0mvdMEfoHZsexq1OBUE5LdaxkdsJC34wBtg+HtLL ApUQmEV+42F3pgVfzlZ8HOPcnFPJtmK2fOkllgOIKwUaXcf/kV5xkTklhcm/E9Wm7Vw5 lQoBRZUufI9PJVVFx2yrLgbo0iiCY0au38rko= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731994509; x=1732599309; 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=BkiOHpZWa8Ppkt7Gxk2Wet+FZuG0onO2LTXVxUBXgXE=; b=sHtsJZKpHRqz8AqTYju/iBL259dnQatSJeQKIOJ/tVZaJe53A26agQZhPUKufNAFtK 18XTZQUjP7Nc1rVa6r9EplMwbv5t+4dKuMq/BT4BITNxVpH8hG2AFeM8W1W67/R6Mrq5 JMpmx98uXeC+U2XUf8/b4E8cP//Z9oijCEYShPqn24fR9kjPIB2jU7zf45J/JDyIu7jR vQuSlfoahxIC3iQ7UdClVBpfa7wdglpcd1tIRRhxpyh5pt95mMOttGNb+Rj9IlqEJrTS hHksY4wU+LTt0RUFrNJomoAE4b9kDTHUhKx2qsgljqfybqoor1Fi5LTeLIIUwCceBbXm 0UnA== X-Gm-Message-State: AOJu0YzAK9H9m7ehYL+NajQ8npDt4k4EOJY2Oh+kcrt1/tdRPJ34LyLG WIk+RVQQOSR5r6lUeNJKjlRfwN2/6M34hnfyfbjqXjai2Vd+UKfXPygIvnK8OWqYj954Dwax0LQ ZCHpIe1fntWP+LJBBZmal/3phfSJjbizdYjfiieimzyph9oEEUi+ZnFj1ouMpZ7uuZ6T3R11DL2 KWaXEYcJvGSB7RQhuKL5YwQ6ZoSj9/1DLgls5ykRsEOQ== X-Google-Smtp-Source: AGHT+IHtcSI8Mj97cORVBahjUQg0lkK7/wJKGyk6BXbW+qdil6iSl7w8mL1/yYa2psMF3PFIqMC8nA== X-Received: by 2002:a05:6a20:244a:b0:1db:dce8:c26f with SMTP id adf61e73a8af0-1dc90bf7b8dmr18872712637.33.1731994508666; Mon, 18 Nov 2024 21:35:08 -0800 (PST) Received: from dhcp-10-123-154-23.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-724771c1142sm7399224b3a.109.2024.11.18.21.35.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2024 21:35:08 -0800 (PST) From: Sriharsha Basavapatna To: dev@dpdk.org Cc: Peter Spreadborough , Sriharsha Basavapatna Subject: [PATCH v2 5/5] net/bnxt/tf_ulp: fix coverity errors Date: Tue, 19 Nov 2024 11:15:50 +0530 Message-Id: <20241119054550.1255359-6-sriharsha.basavapatna@broadcom.com> X-Mailer: git-send-email 2.39.0.189.g4dbebc36b0 In-Reply-To: <20241119054550.1255359-1-sriharsha.basavapatna@broadcom.com> References: <20241119054550.1255359-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 patch fixes a few coverity errors reported in the feature patchset (merged) to support TruFlow on Thor2. Fixes: 0513f0af034d ("net/bnxt/tf_ulp: add stats cache for Thor2") Signed-off-by: Peter Spreadborough Signed-off-by: Sriharsha Basavapatna --- drivers/net/bnxt/hcapi/cfa_v3/mm/cfa_mm.c | 6 +++++- drivers/net/bnxt/tf_core/v3/tfc_em.c | 1 + drivers/net/bnxt/tf_core/v3/tfc_tbl_scope.c | 2 +- drivers/net/bnxt/tf_ulp/bnxt_ulp_utils.h | 3 ++- drivers/net/bnxt/tf_ulp/ulp_mapper.c | 10 +++++++--- drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 7 ++++++- drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c | 2 ++ 7 files changed, 24 insertions(+), 7 deletions(-) diff --git a/drivers/net/bnxt/hcapi/cfa_v3/mm/cfa_mm.c b/drivers/net/bnxt/hcapi/cfa_v3/mm/cfa_mm.c index 61fafadb20..05528dd3e4 100644 --- a/drivers/net/bnxt/hcapi/cfa_v3/mm/cfa_mm.c +++ b/drivers/net/bnxt/hcapi/cfa_v3/mm/cfa_mm.c @@ -123,7 +123,11 @@ int cfa_mm_open(void *cmm, struct cfa_mm_open_parms *parms) } for (i = 0; i < num_blocks; i++) { - context->blk_tbl[i].prev_blk_idx = i - 1; + if (i == 0) + context->blk_tbl[i].prev_blk_idx = CFA_MM_INVALID32; + else + context->blk_tbl[i].prev_blk_idx = i - 1; + context->blk_tbl[i].next_blk_idx = i + 1; context->blk_tbl[i].num_free_records = records_per_block; context->blk_tbl[i].first_free_record = 0; diff --git a/drivers/net/bnxt/tf_core/v3/tfc_em.c b/drivers/net/bnxt/tf_core/v3/tfc_em.c index a70e35b6b1..d460ff2ee0 100644 --- a/drivers/net/bnxt/tf_core/v3/tfc_em.c +++ b/drivers/net/bnxt/tf_core/v3/tfc_em.c @@ -560,6 +560,7 @@ int tfc_em_delete_raw(struct tfc *tfcp, mpc_msg_out.cmp_type = CMPL_BASE_TYPE_MID_PATH_LONG; mpc_msg_out.msg_data = &rx_msg[TFC_MPC_HEADER_SIZE_BYTES]; mpc_msg_out.msg_size = TFC_MPC_MAX_RX_BYTES; + mpc_msg_out.chnl_id = 0; rc = tfc_mpc_send(tfcp->bp, &mpc_msg_in, diff --git a/drivers/net/bnxt/tf_core/v3/tfc_tbl_scope.c b/drivers/net/bnxt/tf_core/v3/tfc_tbl_scope.c index 1770069295..c29933b803 100644 --- a/drivers/net/bnxt/tf_core/v3/tfc_tbl_scope.c +++ b/drivers/net/bnxt/tf_core/v3/tfc_tbl_scope.c @@ -468,7 +468,7 @@ static int alloc_link_pbl(struct tfc_ts_mem_cfg *mem_cfg, uint32_t page_size, * and page tables. The allocation will occur once only per backing * store and will located by name and reused on subsequent runs. */ - total_size = page_size * total_pages; + total_size = (uint64_t)page_size * (uint64_t)total_pages; if (total_size <= (1024 * 256)) mz_size = RTE_MEMZONE_256KB; diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_utils.h b/drivers/net/bnxt/tf_ulp/bnxt_ulp_utils.h index 5e0d906fbd..e849df2713 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_utils.h +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_utils.h @@ -1084,8 +1084,9 @@ bnxt_ulp_cap_feat_process(uint64_t feat_bits, uint64_t *out_bits) if (bit & BNXT_ULP_FEATURE_BIT_PARENT_DMAC) BNXT_DRV_DBG(ERR, "Parent Mac Address Feature is enabled\n"); - if (bit & BNXT_ULP_FEATURE_BIT_PORT_DMAC) + else if (bit & BNXT_ULP_FEATURE_BIT_PORT_DMAC) BNXT_DRV_DBG(ERR, "Port Mac Address Feature is enabled\n"); + if (bit & BNXT_ULP_FEATURE_BIT_MULTI_TUNNEL_FLOW) BNXT_DRV_DBG(ERR, "Multi Tunnel Flow Feature is enabled\n"); diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c index 2429ac2f1a..1a68cf5dfd 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c @@ -3612,9 +3612,13 @@ ulp_mapper_func_cond_list_process(struct bnxt_ulp_mapper_parms *parms, } } /* write the value into result */ - ulp_operand_read(val, res_local + res_size - - ULP_BITS_2_BYTE_NR(oper_size), - ULP_BITS_2_BYTE_NR(val_len)); + if (unlikely(ulp_operand_read(val, res_local + res_size - + ULP_BITS_2_BYTE_NR(oper_size), + ULP_BITS_2_BYTE_NR(val_len)))) { + BNXT_DRV_DBG(ERR, + "field idx operand read failed\n"); + return -EINVAL; + } /* convert the data to cpu format */ *res = tfp_be_to_cpu_64(*res); diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c index dd5985cd7b..f75606ca81 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c @@ -517,7 +517,12 @@ ulp_rte_parser_svif_set(struct ulp_rte_parser_params *params, else svif_type = BNXT_ULP_DRV_FUNC_SVIF; } - ulp_port_db_svif_get(params->ulp_ctx, ifindex, svif_type, &svif); + + if (ulp_port_db_svif_get(params->ulp_ctx, ifindex, svif_type, &svif)) { + BNXT_DRV_DBG(ERR, "ParseErr:ifindex is not valid\n"); + return BNXT_TF_RC_ERROR; + } + svif = rte_cpu_to_be_16(svif); mask = rte_cpu_to_be_16(mask); hdr_field = ¶ms->hdr_field[BNXT_ULP_PROTO_HDR_FIELD_SVIF_IDX]; diff --git a/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c index 5fa8e240db..d17ea11526 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c +++ b/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c @@ -191,6 +191,8 @@ static uint32_t ulp_stats_cache_main_loop(void *arg) uint8_t *data; int rc; + memset(&batch_info, 0, sizeof(batch_info)); + while (true) { ctxt = NULL; while (!ctxt) { -- 2.39.3