From: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
To: dev@dpdk.org
Cc: Peter Spreadborough <peter.spreadborough@broadcom.com>,
Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Subject: [PATCH v2 5/5] net/bnxt/tf_ulp: fix coverity errors
Date: Tue, 19 Nov 2024 11:15:50 +0530 [thread overview]
Message-ID: <20241119054550.1255359-6-sriharsha.basavapatna@broadcom.com> (raw)
In-Reply-To: <20241119054550.1255359-1-sriharsha.basavapatna@broadcom.com>
From: Peter Spreadborough <peter.spreadborough@broadcom.com>
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 <peter.spreadborough@broadcom.com>
Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
---
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
prev parent reply other threads:[~2024-11-19 5:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-19 5:45 [PATCH v2 0/5] TruFlow fixes for Thor2 Sriharsha Basavapatna
2024-11-19 5:45 ` [PATCH v2 1/5] net/bnxt/tf_ulp: fix F1F2 vxlan counter acccumulation " Sriharsha Basavapatna
2024-11-19 5:45 ` [PATCH v2 2/5] net/bnxt/tf_ulp: fix vfr clean up and stats lockup Sriharsha Basavapatna
2024-11-19 5:45 ` [PATCH v2 3/5] net/bnxt/tf_ulp: performance and tuning changes for thor2 stats cache Sriharsha Basavapatna
2024-11-19 5:45 ` [PATCH v2 4/5] net/bnxt/tf_ulp: update template files Sriharsha Basavapatna
2024-11-19 5:45 ` Sriharsha Basavapatna [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241119054550.1255359-6-sriharsha.basavapatna@broadcom.com \
--to=sriharsha.basavapatna@broadcom.com \
--cc=dev@dpdk.org \
--cc=peter.spreadborough@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).