* [PATCH v1 00/25] net/ntnic: fixes and improvements
@ 2025-04-30 13:48 Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 01/25] net/ntnic: remove usage of the variable-length arrays Oleksandr Kolomeiets
` (24 more replies)
0 siblings, 25 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas
* Fix issues detected by static code analyzers CoverityScan and PVS studio
- PVS studio: https://inbox.dpdk.org/dev/CAOaVG170qdNxDFsTjCvJhZafY-Fs8e98xPBa3q8U--WX+K_Qvw@mail.gmail.com/1-a.txt
* Fix requested issues mentioned here https://inbox.dpdk.org/dev/20250222134157.73763253@hermes.local/
- Removed unnecessary casts to (void) in memset calls for better readability.
- Added null checks for pointers in various functions to prevent potential dereferencing of null pointers.
- Enhanced logging messages to provide clearer context
- Updated error handling to ensure proper return values when encountering invalid states.
- Refactored code to improve consistency in variable naming ('if_index' to 'n_intf_no')
- Ensured that memory is properly initialized and freed
* Fix ring queue usage and concurrency problem.
Danylo Vodopianov (18):
net/ntnic: improve logging format specifiers
net/ntnic: remove usless expressions
net/ntnic: remove unused code
net/ntnic: remove usless part of conditional expression
net/ntnic: add error logging for hsh
net/ntnic: add explicitly specificator
net/ntnic: add handle memory allocation failures
net/ntnic: remove redundant initialization
net/ntnic: enhance null checks and assertions
net/ntnic: add return value check
net/ntnic: remove redundant assignments and branching
net/ntnic: rework array usage
net/ntnic: avoid divide by zero
net/ntnic: remove unnecessary void cast
net/ntnic: remove unnecessary memset
net/ntnic: add null verification
net/ntnic: avoid possible deadlock
net/ntnic: fix operation with rte ring queue
Oleksandr Kolomeiets (7):
net/ntnic: remove usage of the variable-length arrays
net/ntnic: handle string truncations when using strlcpy
net/ntnic: replace pragma pack with DPDK defined macros
net/ntnic: remove extra memset
net/ntnic: include all queues into statistics
net/ntnic: avoid misleading variable names
net/ntnic: apply packing to the structure
drivers/net/ntnic/adapter/nt4ga_adapter.c | 7 +-
.../net/ntnic/adapter/nt4ga_stat/nt4ga_stat.c | 4 +-
drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c | 12 +-
drivers/net/ntnic/include/flow_api_engine.h | 2 +-
drivers/net/ntnic/include/hw_mod_flm_v25.h | 14 +-
drivers/net/ntnic/include/ntnic_virt_queue.h | 4 +-
.../link_mgmt/link_100g/nt4ga_link_100g.c | 6 +-
.../link_agx_100g/nt4ga_agx_link_100g.c | 63 ++--
drivers/net/ntnic/meson.build | 2 -
drivers/net/ntnic/nim/i2c_nim.c | 7 +-
.../core/nt200a0x/reset/nthw_fpga_rst9563.c | 11 -
.../nt200a0x/reset/nthw_fpga_rst_nt200a0x.c | 9 +
.../nthw/core/nt400dxx/nthw_fpga_nt400dxx.c | 3 +-
.../nt400dxx/reset/nthw_fpga_rst_nt400dxx.c | 4 +-
drivers/net/ntnic/nthw/core/nthw_fpga.c | 306 +-----------------
drivers/net/ntnic/nthw/core/nthw_hif.c | 10 +-
drivers/net/ntnic/nthw/core/nthw_iic.c | 7 +-
drivers/net/ntnic/nthw/core/nthw_pcie3.c | 5 +-
drivers/net/ntnic/nthw/core/nthw_phy_tile.c | 5 +-
drivers/net/ntnic/nthw/core/nthw_rpf.c | 5 +-
drivers/net/ntnic/nthw/core/nthw_sdc.c | 8 +-
drivers/net/ntnic/nthw/core/nthw_si5340.c | 5 +-
drivers/net/ntnic/nthw/core/nthw_spi_v3.c | 17 +-
drivers/net/ntnic/nthw/core/nthw_tsm.c | 6 +-
drivers/net/ntnic/nthw/flow_api/flow_api.c | 10 +-
drivers/net/ntnic/nthw/flow_api/flow_group.c | 17 +-
.../net/ntnic/nthw/flow_api/flow_hsh_cfg.c | 8 +-
.../net/ntnic/nthw/flow_api/flow_id_table.c | 3 +-
drivers/net/ntnic/nthw/flow_api/flow_km.c | 10 +-
.../nthw/flow_api/hw_mod/hw_mod_backend.c | 3 +-
.../ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c | 3 -
.../profile_inline/flow_api_hw_db_inline.c | 95 +++---
.../profile_inline/flow_api_profile_inline.c | 93 +++---
.../ntnic/nthw/flow_filter/flow_nthw_cat.c | 4 +-
.../ntnic/nthw/flow_filter/flow_nthw_csu.c | 4 +-
.../ntnic/nthw/flow_filter/flow_nthw_flm.c | 4 +-
.../ntnic/nthw/flow_filter/flow_nthw_hfu.c | 4 +-
.../ntnic/nthw/flow_filter/flow_nthw_hsh.c | 4 +-
.../ntnic/nthw/flow_filter/flow_nthw_ifr.c | 2 +-
.../ntnic/nthw/flow_filter/flow_nthw_info.c | 4 +-
.../net/ntnic/nthw/flow_filter/flow_nthw_km.c | 4 +-
.../ntnic/nthw/flow_filter/flow_nthw_pdb.c | 4 +-
.../ntnic/nthw/flow_filter/flow_nthw_qsl.c | 4 +-
.../ntnic/nthw/flow_filter/flow_nthw_rpp_lr.c | 7 +-
.../ntnic/nthw/flow_filter/flow_nthw_slc_lr.c | 4 +-
.../ntnic/nthw/flow_filter/flow_nthw_tx_cpy.c | 4 +-
.../ntnic/nthw/flow_filter/flow_nthw_tx_ins.c | 4 +-
.../ntnic/nthw/flow_filter/flow_nthw_tx_rpl.c | 4 +-
.../net/ntnic/nthw/model/nthw_fpga_model.c | 11 +-
drivers/net/ntnic/nthw/nthw_rac.c | 32 +-
.../net/ntnic/nthw/ntnic_meter/ntnic_meter.c | 6 +
drivers/net/ntnic/nthw/stat/nthw_stat.c | 5 +-
drivers/net/ntnic/ntnic_ethdev.c | 121 +++----
drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 64 ++--
drivers/net/ntnic/ntnic_vfio.c | 1 -
drivers/net/ntnic/ntnic_xstats/ntnic_xstats.c | 9 +-
56 files changed, 420 insertions(+), 654 deletions(-)
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 01/25] net/ntnic: remove usage of the variable-length arrays
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 02/25] net/ntnic: handle string truncations when using strlcpy Oleksandr Kolomeiets
` (23 subsequent siblings)
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas
VLAs with known upper limits are replaced with fixed-length arrays.
In case an upper limit of an array cannot be known in advance,
the memory for such an array is allocated dynamically using alloca.
In comparison to malloc family of functions, the alloca executes faster
due to working directly with a stack instead of a heap,
for the same reason it does not require manual memory management.
Signed-off-by: Oleksandr Kolomeiets <okl-plv@napatech.com>
---
drivers/net/ntnic/meson.build | 2 --
.../flow_api/profile_inline/flow_api_hw_db_inline.c | 13 ++++++++++---
.../profile_inline/flow_api_profile_inline.c | 8 ++++----
3 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ntnic/meson.build b/drivers/net/ntnic/meson.build
index 30a92130b5..b4c6cfe7de 100644
--- a/drivers/net/ntnic/meson.build
+++ b/drivers/net/ntnic/meson.build
@@ -124,5 +124,3 @@ sources = files(
'ntnic_vfio.c',
'ntnic_ethdev.c',
)
-
-cflags += no_wvla_cflag
diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c
index a016c82458..ae72b8775e 100644
--- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c
+++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c
@@ -1343,9 +1343,11 @@ static int hw_db_inline_alloc_prioritized_cfn(struct flow_nic_dev *ndev,
struct {
uint64_t priority;
uint32_t idx;
- } sorted_priority[db->nb_cat];
+ } *sorted_priority;
- memset(sorted_priority, 0x0, sizeof(sorted_priority));
+ sorted_priority = calloc(db->nb_cat, sizeof(*sorted_priority));
+ if (!sorted_priority)
+ return -1;
uint32_t in_use_count = 0;
@@ -1360,13 +1362,16 @@ static int hw_db_inline_alloc_prioritized_cfn(struct flow_nic_dev *ndev,
}
}
- if (in_use_count >= db->nb_cat - 1)
+ if (in_use_count >= db->nb_cat - 1) {
+ free(sorted_priority);
return -1;
+ }
if (in_use_count == 0) {
db->cfn[db_cfn_idx].ref = 1;
db->cfn[db_cfn_idx].cfn_hw = 1;
db->cfn[db_cfn_idx].priority = priority;
+ free(sorted_priority);
return db_cfn_idx;
}
@@ -1400,6 +1405,7 @@ static int hw_db_inline_alloc_prioritized_cfn(struct flow_nic_dev *ndev,
db->cfn[db_cfn_idx].ref = 1;
db->cfn[db_cfn_idx].cfn_hw = goal;
db->cfn[db_cfn_idx].priority = priority;
+ free(sorted_priority);
return db_cfn_idx;
}
@@ -1425,6 +1431,7 @@ static int hw_db_inline_alloc_prioritized_cfn(struct flow_nic_dev *ndev,
db->cfn[db_cfn_idx].ref = 1;
db->cfn[db_cfn_idx].cfn_hw = goal;
db->cfn[db_cfn_idx].priority = priority;
+ free(sorted_priority);
return db_cfn_idx;
}
diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
index 6824b35463..c0407574f0 100644
--- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
+++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
@@ -3198,15 +3198,15 @@ static void setup_db_qsl_data(struct nic_flow_def *fd, struct hw_db_inline_qsl_d
} else {
RTE_ASSERT(fd->dst_num_avail < HW_DB_INLINE_MAX_QST_PER_QSL);
- uint32_t ports[fd->dst_num_avail];
- uint32_t queues[fd->dst_num_avail];
+ uint32_t ports[HW_DB_INLINE_MAX_QST_PER_QSL];
+ uint32_t queues[HW_DB_INLINE_MAX_QST_PER_QSL];
uint32_t port_index = 0;
uint32_t queue_index = 0;
uint32_t max = num_dest_port > num_queues ? num_dest_port : num_queues;
- memset(ports, 0, fd->dst_num_avail);
- memset(queues, 0, fd->dst_num_avail);
+ memset(ports, 0, sizeof(ports));
+ memset(queues, 0, sizeof(queues));
qsl_data->table_size = max;
qsl_data->retransmit = num_dest_port > 0 ? 1 : 0;
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 02/25] net/ntnic: handle string truncations when using strlcpy
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 01/25] net/ntnic: remove usage of the variable-length arrays Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 03/25] net/ntnic: replace pragma pack with DPDK defined macros Oleksandr Kolomeiets
` (22 subsequent siblings)
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas
While strlcpy prevents out-of-bounds access,
it allows bugs to remain unnoticed.
If unexcepted truncation took place,
the respective warning message is emitted.
Signed-off-by: Oleksandr Kolomeiets <okl-plv@napatech.com>
---
drivers/net/ntnic/ntnic_xstats/ntnic_xstats.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ntnic/ntnic_xstats/ntnic_xstats.c b/drivers/net/ntnic/ntnic_xstats/ntnic_xstats.c
index cf3271d5de..a26cf5a07a 100644
--- a/drivers/net/ntnic/ntnic_xstats/ntnic_xstats.c
+++ b/drivers/net/ntnic/ntnic_xstats/ntnic_xstats.c
@@ -758,7 +758,10 @@ static int nthw_xstats_get_names(nt4ga_stat_t *p_nt4ga_stat,
return nb_names;
for (i = 0; i < size && i < nb_names; i++) {
- strlcpy(xstats_names[i].name, names[i].name, sizeof(xstats_names[i].name));
+ size_t written =
+ strlcpy(xstats_names[i].name, names[i].name, sizeof(xstats_names[i].name));
+ if (written >= sizeof(xstats_names[i].name))
+ NT_LOG(WRN, NTNIC, "xstats name %s truncated", names[i].name);
count++;
}
@@ -795,9 +798,11 @@ static int nthw_xstats_get_names_by_id(nt4ga_stat_t *p_nt4ga_stat,
for (i = 0; i < size; i++) {
if (ids[i] < nb_names) {
- strlcpy(xstats_names[i].name,
+ size_t written = strlcpy(xstats_names[i].name,
names[ids[i]].name,
RTE_ETH_XSTATS_NAME_SIZE);
+ if (written >= RTE_ETH_XSTATS_NAME_SIZE)
+ NT_LOG(WRN, NTNIC, "xstats name %s truncated", names[ids[i]].name);
}
count++;
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 03/25] net/ntnic: replace pragma pack with DPDK defined macros
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 01/25] net/ntnic: remove usage of the variable-length arrays Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 02/25] net/ntnic: handle string truncations when using strlcpy Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 04/25] net/ntnic: remove extra memset Oleksandr Kolomeiets
` (21 subsequent siblings)
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas
The macros __rte_packed_begin and __rte_packed_end are used instead
of #pragma pack(1) when structure or union memory should be minimized.
Signed-off-by: Oleksandr Kolomeiets <okl-plv@napatech.com>
---
drivers/net/ntnic/include/hw_mod_flm_v25.h | 14 ++++++--------
drivers/net/ntnic/nthw/core/nthw_spi_v3.c | 15 +++++++--------
2 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/drivers/net/ntnic/include/hw_mod_flm_v25.h b/drivers/net/ntnic/include/hw_mod_flm_v25.h
index 12135a652c..132a585802 100644
--- a/drivers/net/ntnic/include/hw_mod_flm_v25.h
+++ b/drivers/net/ntnic/include/hw_mod_flm_v25.h
@@ -226,8 +226,7 @@ struct flm_v25_scrub_s {
uint8_t inf;
};
-#pragma pack(1)
-struct flm_v25_lrn_data_s {
+struct __rte_packed_begin flm_v25_lrn_data_s {
uint32_t sw9; /* 31:0 (32) */
uint32_t sw8; /* 63:32 (32) */
uint32_t qw4[4];/* 191:64 (128) */
@@ -267,9 +266,9 @@ struct flm_v25_lrn_data_s {
uint64_t nofi : 1; /* 716:716 (1) */
uint64_t pad : 50; /* 766:717 (50) */
uint64_t eor : 1; /* 767:767 (1) */
-};
+} __rte_packed_end;
-struct flm_v25_inf_data_s {
+struct __rte_packed_begin flm_v25_inf_data_s {
uint64_t bytes;
uint64_t packets;
uint64_t ts;
@@ -277,9 +276,9 @@ struct flm_v25_inf_data_s {
uint64_t cause : 3;
uint64_t pad : 60;
uint64_t eor : 1;
-};
+} __rte_packed_end;
-struct flm_v25_sta_data_s {
+struct __rte_packed_begin flm_v25_sta_data_s {
uint32_t id;
uint64_t lds : 1;
uint64_t lfs : 1;
@@ -292,8 +291,7 @@ struct flm_v25_sta_data_s {
uint64_t pis : 1;
uint64_t pad : 54;
uint64_t eor : 1;
-};
-#pragma pack()
+} __rte_packed_end;
struct hw_mod_flm_v25_s {
struct flm_v25_control_s *control;
diff --git a/drivers/net/ntnic/nthw/core/nthw_spi_v3.c b/drivers/net/ntnic/nthw/core/nthw_spi_v3.c
index 0b611462a0..6ef739279a 100644
--- a/drivers/net/ntnic/nthw/core/nthw_spi_v3.c
+++ b/drivers/net/ntnic/nthw/core/nthw_spi_v3.c
@@ -171,26 +171,23 @@ int nthw_spi_v3_transfer(nthw_spi_v3_t *p, uint16_t opcode, struct tx_rx_buf *tx
const uint16_t max_payload_rx_size = rx_buf->size;
int result = 0;
-#pragma pack(push, 1)
- union {
+ union __rte_packed_begin {
uint32_t raw;
struct {
uint16_t opcode;
uint16_t size;
};
- } spi_tx_hdr;
+ } __rte_packed_end spi_tx_hdr;
- union {
+ union __rte_packed_begin {
uint32_t raw;
struct {
uint16_t error_code;
uint16_t size;
};
- } spi_rx_hdr;
-
-#pragma pack(pop)
+ } __rte_packed_end spi_rx_hdr;
#ifdef SPI_V3_DEBUG_PRINT
NT_LOG_DBG(DBG, NTHW, "Started");
@@ -294,7 +291,9 @@ int nthw_spi_v3_transfer(nthw_spi_v3_t *p, uint16_t opcode, struct tx_rx_buf *tx
if (result != 0)
return result;
- result = nthw_spis_read_rx_fifo(p->mp_spis_mod, &spi_rx_hdr.raw);
+ typeof(spi_rx_hdr.raw) raw;
+ result = nthw_spis_read_rx_fifo(p->mp_spis_mod, &raw);
+ spi_rx_hdr.raw = raw;
if (result != 0) {
NT_LOG(WRN, NTHW, "nthw_spis_read_rx_fifo failed");
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 04/25] net/ntnic: remove extra memset
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
` (2 preceding siblings ...)
2025-04-30 13:48 ` [PATCH v1 03/25] net/ntnic: replace pragma pack with DPDK defined macros Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 05/25] net/ntnic: include all queues into statistics Oleksandr Kolomeiets
` (20 subsequent siblings)
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas
The function rte_eth_stats_get fills the structure stats with zeroes
before it eventually calls dpdk_stats_collect.
That makes the call to memset inside dpdk_stats_collect redundant.
Signed-off-by: Oleksandr Kolomeiets <okl-plv@napatech.com>
---
drivers/net/ntnic/ntnic_ethdev.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c
index 9a6667b3be..f9644b5826 100644
--- a/drivers/net/ntnic/ntnic_ethdev.c
+++ b/drivers/net/ntnic/ntnic_ethdev.c
@@ -200,8 +200,6 @@ static int dpdk_stats_collect(struct pmd_internals *internals, struct rte_eth_st
*/
ntnic_filter_ops->poll_statistics(internals);
- memset(stats, 0, sizeof(*stats));
-
for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS && i < internals->nb_rx_queues; i++) {
stats->q_ipackets[i] = internals->rxq_scg[i].rx_pkts;
stats->q_ibytes[i] = internals->rxq_scg[i].rx_bytes;
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 05/25] net/ntnic: include all queues into statistics
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
` (3 preceding siblings ...)
2025-04-30 13:48 ` [PATCH v1 04/25] net/ntnic: remove extra memset Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 06/25] net/ntnic: avoid misleading variable names Oleksandr Kolomeiets
` (19 subsequent siblings)
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas
Queues with indices greater than or equal to RTE_ETHDEV_QUEUE_STAT_CNTRS
are ignored when calculating per-queue statistics,
however they should be taken into account for calculating the total.
Signed-off-by: Oleksandr Kolomeiets <okl-plv@napatech.com>
---
drivers/net/ntnic/ntnic_ethdev.c | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c
index f9644b5826..6857191ef2 100644
--- a/drivers/net/ntnic/ntnic_ethdev.c
+++ b/drivers/net/ntnic/ntnic_ethdev.c
@@ -200,20 +200,24 @@ static int dpdk_stats_collect(struct pmd_internals *internals, struct rte_eth_st
*/
ntnic_filter_ops->poll_statistics(internals);
- for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS && i < internals->nb_rx_queues; i++) {
- stats->q_ipackets[i] = internals->rxq_scg[i].rx_pkts;
- stats->q_ibytes[i] = internals->rxq_scg[i].rx_bytes;
- rx_total += stats->q_ipackets[i];
- rx_total_b += stats->q_ibytes[i];
- }
-
- for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS && i < internals->nb_tx_queues; i++) {
- stats->q_opackets[i] = internals->txq_scg[i].tx_pkts;
- stats->q_obytes[i] = internals->txq_scg[i].tx_bytes;
- stats->q_errors[i] = internals->txq_scg[i].err_pkts;
- tx_total += stats->q_opackets[i];
- tx_total_b += stats->q_obytes[i];
- tx_err_total += stats->q_errors[i];
+ for (i = 0; i < internals->nb_rx_queues; i++) {
+ if (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) {
+ stats->q_ipackets[i] = internals->rxq_scg[i].rx_pkts;
+ stats->q_ibytes[i] = internals->rxq_scg[i].rx_bytes;
+ }
+ rx_total += internals->rxq_scg[i].rx_pkts;
+ rx_total_b += internals->rxq_scg[i].rx_bytes;
+ }
+
+ for (i = 0; i < internals->nb_tx_queues; i++) {
+ if (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) {
+ stats->q_opackets[i] = internals->txq_scg[i].tx_pkts;
+ stats->q_obytes[i] = internals->txq_scg[i].tx_bytes;
+ stats->q_errors[i] = internals->txq_scg[i].err_pkts;
+ }
+ tx_total += internals->txq_scg[i].tx_pkts;
+ tx_total_b += internals->txq_scg[i].tx_bytes;
+ tx_err_total += internals->txq_scg[i].err_pkts;
}
stats->imissed = internals->rx_missed;
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 06/25] net/ntnic: avoid misleading variable names
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
` (4 preceding siblings ...)
2025-04-30 13:48 ` [PATCH v1 05/25] net/ntnic: include all queues into statistics Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 07/25] net/ntnic: apply packing to the structure Oleksandr Kolomeiets
` (18 subsequent siblings)
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas
In the context of the NTNIC driver,
the variables named if_index stand for the index of the PHY.
However, the term if_index could also refer to the interface index
assigned by the OS.
To mitigate potential confusion these variables were renamed.
Signed-off-by: Oleksandr Kolomeiets <okl-plv@napatech.com>
---
drivers/net/ntnic/ntnic_ethdev.c | 24 +++++-----
drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 44 +++++++++----------
2 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c
index 6857191ef2..6ba6769e47 100644
--- a/drivers/net/ntnic/ntnic_ethdev.c
+++ b/drivers/net/ntnic/ntnic_ethdev.c
@@ -181,15 +181,15 @@ static int dpdk_stats_collect(struct pmd_internals *internals, struct rte_eth_st
struct ntdrv_4ga_s *p_nt_drv = &p_drv->ntdrv;
nt4ga_stat_t *p_nt4ga_stat = &p_nt_drv->adapter_info.nt4ga_stat;
nthw_stat_t *p_nthw_stat = p_nt4ga_stat->mp_nthw_stat;
- const int if_index = internals->n_intf_no;
+ const int n_intf_no = internals->n_intf_no;
uint64_t rx_total = 0;
uint64_t rx_total_b = 0;
uint64_t tx_total = 0;
uint64_t tx_total_b = 0;
uint64_t tx_err_total = 0;
- if (!p_nthw_stat || !p_nt4ga_stat || !stats || if_index < 0 ||
- if_index > NUM_ADAPTER_PORTS_MAX) {
+ if (!p_nthw_stat || !p_nt4ga_stat || !stats || n_intf_no < 0 ||
+ n_intf_no > NUM_ADAPTER_PORTS_MAX) {
NT_LOG_DBGX(WRN, NTNIC, "error exit");
return -1;
}
@@ -315,8 +315,8 @@ static int eth_stats_reset(struct rte_eth_dev *eth_dev)
struct pmd_internals *internals = eth_dev->data->dev_private;
struct drv_s *p_drv = internals->p_drv;
struct ntdrv_4ga_s *p_nt_drv = &p_drv->ntdrv;
- const int if_index = internals->n_intf_no;
- dpdk_stats_reset(internals, p_nt_drv, if_index);
+ const int n_intf_no = internals->n_intf_no;
+ dpdk_stats_reset(internals, p_nt_drv, n_intf_no);
return 0;
}
@@ -1529,7 +1529,7 @@ static int eth_xstats_get(struct rte_eth_dev *eth_dev, struct rte_eth_xstat *sta
struct drv_s *p_drv = internals->p_drv;
ntdrv_4ga_t *p_nt_drv = &p_drv->ntdrv;
nt4ga_stat_t *p_nt4ga_stat = &p_nt_drv->adapter_info.nt4ga_stat;
- int if_index = internals->n_intf_no;
+ int n_intf_no = internals->n_intf_no;
int nb_xstats;
const struct ntnic_xstats_ops *ntnic_xstats_ops = get_ntnic_xstats_ops();
@@ -1540,7 +1540,7 @@ static int eth_xstats_get(struct rte_eth_dev *eth_dev, struct rte_eth_xstat *sta
}
rte_spinlock_lock(&p_nt_drv->stat_lck);
- nb_xstats = ntnic_xstats_ops->nthw_xstats_get(p_nt4ga_stat, stats, n, if_index);
+ nb_xstats = ntnic_xstats_ops->nthw_xstats_get(p_nt4ga_stat, stats, n, n_intf_no);
rte_spinlock_unlock(&p_nt_drv->stat_lck);
return nb_xstats;
}
@@ -1554,7 +1554,7 @@ static int eth_xstats_get_by_id(struct rte_eth_dev *eth_dev,
struct drv_s *p_drv = internals->p_drv;
ntdrv_4ga_t *p_nt_drv = &p_drv->ntdrv;
nt4ga_stat_t *p_nt4ga_stat = &p_nt_drv->adapter_info.nt4ga_stat;
- int if_index = internals->n_intf_no;
+ int n_intf_no = internals->n_intf_no;
int nb_xstats;
const struct ntnic_xstats_ops *ntnic_xstats_ops = get_ntnic_xstats_ops();
@@ -1566,7 +1566,7 @@ static int eth_xstats_get_by_id(struct rte_eth_dev *eth_dev,
rte_spinlock_lock(&p_nt_drv->stat_lck);
nb_xstats =
- ntnic_xstats_ops->nthw_xstats_get_by_id(p_nt4ga_stat, ids, values, n, if_index);
+ ntnic_xstats_ops->nthw_xstats_get_by_id(p_nt4ga_stat, ids, values, n, n_intf_no);
rte_spinlock_unlock(&p_nt_drv->stat_lck);
return nb_xstats;
}
@@ -1577,7 +1577,7 @@ static int eth_xstats_reset(struct rte_eth_dev *eth_dev)
struct drv_s *p_drv = internals->p_drv;
ntdrv_4ga_t *p_nt_drv = &p_drv->ntdrv;
nt4ga_stat_t *p_nt4ga_stat = &p_nt_drv->adapter_info.nt4ga_stat;
- int if_index = internals->n_intf_no;
+ int n_intf_no = internals->n_intf_no;
struct ntnic_xstats_ops *ntnic_xstats_ops = get_ntnic_xstats_ops();
@@ -1587,9 +1587,9 @@ static int eth_xstats_reset(struct rte_eth_dev *eth_dev)
}
rte_spinlock_lock(&p_nt_drv->stat_lck);
- ntnic_xstats_ops->nthw_xstats_reset(p_nt4ga_stat, if_index);
+ ntnic_xstats_ops->nthw_xstats_reset(p_nt4ga_stat, n_intf_no);
rte_spinlock_unlock(&p_nt_drv->stat_lck);
- return dpdk_stats_reset(internals, p_nt_drv, if_index);
+ return dpdk_stats_reset(internals, p_nt_drv, n_intf_no);
}
static int eth_xstats_get_names(struct rte_eth_dev *eth_dev,
diff --git a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c
index 1beba22b9d..29bfb2a121 100644
--- a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c
+++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c
@@ -1155,10 +1155,10 @@ static int poll_statistics(struct pmd_internals *internals)
struct drv_s *p_drv = internals->p_drv;
struct ntdrv_4ga_s *p_nt_drv = &p_drv->ntdrv;
nt4ga_stat_t *p_nt4ga_stat = &p_nt_drv->adapter_info.nt4ga_stat;
- const int if_index = internals->n_intf_no;
+ const int n_intf_no = internals->n_intf_no;
uint64_t last_stat_rtc = 0;
- if (!p_nt4ga_stat || if_index < 0 || if_index >= NUM_ADAPTER_PORTS_MAX)
+ if (!p_nt4ga_stat || n_intf_no < 0 || n_intf_no >= NUM_ADAPTER_PORTS_MAX)
return -1;
RTE_ASSERT(rte_tsc_freq > 0);
@@ -1184,36 +1184,36 @@ static int poll_statistics(struct pmd_internals *internals)
* Add the RX statistics increments since last time we polled.
* (No difference if physical or virtual port)
*/
- internals->rxq_scg[0].rx_pkts += p_nt4ga_stat->a_port_rx_packets_total[if_index] -
- p_nt4ga_stat->a_port_rx_packets_base[if_index];
- internals->rxq_scg[0].rx_bytes += p_nt4ga_stat->a_port_rx_octets_total[if_index] -
- p_nt4ga_stat->a_port_rx_octets_base[if_index];
+ internals->rxq_scg[0].rx_pkts += p_nt4ga_stat->a_port_rx_packets_total[n_intf_no] -
+ p_nt4ga_stat->a_port_rx_packets_base[n_intf_no];
+ internals->rxq_scg[0].rx_bytes += p_nt4ga_stat->a_port_rx_octets_total[n_intf_no] -
+ p_nt4ga_stat->a_port_rx_octets_base[n_intf_no];
internals->rxq_scg[0].err_pkts += 0;
- internals->rx_missed += p_nt4ga_stat->a_port_rx_drops_total[if_index] -
- p_nt4ga_stat->a_port_rx_drops_base[if_index];
+ internals->rx_missed += p_nt4ga_stat->a_port_rx_drops_total[n_intf_no] -
+ p_nt4ga_stat->a_port_rx_drops_base[n_intf_no];
/* Update the increment bases */
- p_nt4ga_stat->a_port_rx_packets_base[if_index] =
- p_nt4ga_stat->a_port_rx_packets_total[if_index];
- p_nt4ga_stat->a_port_rx_octets_base[if_index] =
- p_nt4ga_stat->a_port_rx_octets_total[if_index];
- p_nt4ga_stat->a_port_rx_drops_base[if_index] =
- p_nt4ga_stat->a_port_rx_drops_total[if_index];
+ p_nt4ga_stat->a_port_rx_packets_base[n_intf_no] =
+ p_nt4ga_stat->a_port_rx_packets_total[n_intf_no];
+ p_nt4ga_stat->a_port_rx_octets_base[n_intf_no] =
+ p_nt4ga_stat->a_port_rx_octets_total[n_intf_no];
+ p_nt4ga_stat->a_port_rx_drops_base[n_intf_no] =
+ p_nt4ga_stat->a_port_rx_drops_total[n_intf_no];
/* Tx (here we must distinguish between physical and virtual ports) */
if (internals->type == PORT_TYPE_PHYSICAL) {
/* Add the statistics increments since last time we polled */
- internals->txq_scg[0].tx_pkts += p_nt4ga_stat->a_port_tx_packets_total[if_index] -
- p_nt4ga_stat->a_port_tx_packets_base[if_index];
- internals->txq_scg[0].tx_bytes += p_nt4ga_stat->a_port_tx_octets_total[if_index] -
- p_nt4ga_stat->a_port_tx_octets_base[if_index];
+ internals->txq_scg[0].tx_pkts += p_nt4ga_stat->a_port_tx_packets_total[n_intf_no] -
+ p_nt4ga_stat->a_port_tx_packets_base[n_intf_no];
+ internals->txq_scg[0].tx_bytes += p_nt4ga_stat->a_port_tx_octets_total[n_intf_no] -
+ p_nt4ga_stat->a_port_tx_octets_base[n_intf_no];
internals->txq_scg[0].err_pkts += 0;
/* Update the increment bases */
- p_nt4ga_stat->a_port_tx_packets_base[if_index] =
- p_nt4ga_stat->a_port_tx_packets_total[if_index];
- p_nt4ga_stat->a_port_tx_octets_base[if_index] =
- p_nt4ga_stat->a_port_tx_octets_total[if_index];
+ p_nt4ga_stat->a_port_tx_packets_base[n_intf_no] =
+ p_nt4ga_stat->a_port_tx_packets_total[n_intf_no];
+ p_nt4ga_stat->a_port_tx_octets_base[n_intf_no] =
+ p_nt4ga_stat->a_port_tx_octets_total[n_intf_no];
}
/* Globally only once a second */
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 07/25] net/ntnic: apply packing to the structure
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
` (5 preceding siblings ...)
2025-04-30 13:48 ` [PATCH v1 06/25] net/ntnic: avoid misleading variable names Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 08/25] net/ntnic: improve logging format specifiers Oleksandr Kolomeiets
` (17 subsequent siblings)
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas
The structure virtq_desc should not contain any paddings,
so it has been wrapped with __rte_packed_begin and __rte_packed_end macros.
Signed-off-by: Oleksandr Kolomeiets <okl-plv@napatech.com>
---
drivers/net/ntnic/include/ntnic_virt_queue.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ntnic/include/ntnic_virt_queue.h b/drivers/net/ntnic/include/ntnic_virt_queue.h
index b95efabf97..072365c946 100644
--- a/drivers/net/ntnic/include/ntnic_virt_queue.h
+++ b/drivers/net/ntnic/include/ntnic_virt_queue.h
@@ -34,7 +34,7 @@ struct nthw_virt_queue;
/*
* Split Ring virtq Descriptor
*/
-struct __rte_aligned(8) virtq_desc {
+struct __rte_packed_begin virtq_desc {
/* Address (guest-physical). */
uint64_t addr;
/* Length. */
@@ -43,7 +43,7 @@ struct __rte_aligned(8) virtq_desc {
uint16_t flags;
/* Next field if flags & NEXT */
uint16_t next;
-};
+} __rte_packed_end;
/*
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 08/25] net/ntnic: improve logging format specifiers
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
` (6 preceding siblings ...)
2025-04-30 13:48 ` [PATCH v1 07/25] net/ntnic: apply packing to the structure Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 09/25] net/ntnic: remove usless expressions Oleksandr Kolomeiets
` (16 subsequent siblings)
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas, Danylo Vodopianov
From: Danylo Vodopianov <dvo-plv@napatech.com>
Updated logging format specifiers for better consistency
and to match the expected data types
Signed-off-by: Danylo Vodopianov <dvo-plv@napatech.com>
---
drivers/net/ntnic/adapter/nt4ga_adapter.c | 7 +-
drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c | 2 +-
.../link_agx_100g/nt4ga_agx_link_100g.c | 14 ++--
drivers/net/ntnic/nthw/core/nthw_hif.c | 5 +-
drivers/net/ntnic/nthw/core/nthw_iic.c | 2 +-
drivers/net/ntnic/nthw/core/nthw_phy_tile.c | 2 +-
drivers/net/ntnic/nthw/core/nthw_spi_v3.c | 2 +-
drivers/net/ntnic/nthw/flow_api/flow_api.c | 7 +-
.../net/ntnic/nthw/flow_api/flow_hsh_cfg.c | 8 +-
drivers/net/ntnic/nthw/flow_api/flow_km.c | 6 +-
.../profile_inline/flow_api_hw_db_inline.c | 77 +++++++++++--------
.../profile_inline/flow_api_profile_inline.c | 16 ++--
.../net/ntnic/nthw/model/nthw_fpga_model.c | 4 +-
drivers/net/ntnic/nthw/nthw_rac.c | 22 +++---
drivers/net/ntnic/ntnic_ethdev.c | 30 +++++---
drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 4 +-
16 files changed, 116 insertions(+), 92 deletions(-)
diff --git a/drivers/net/ntnic/adapter/nt4ga_adapter.c b/drivers/net/ntnic/adapter/nt4ga_adapter.c
index 889f47caab..526ecc8089 100644
--- a/drivers/net/ntnic/adapter/nt4ga_adapter.c
+++ b/drivers/net/ntnic/adapter/nt4ga_adapter.c
@@ -126,7 +126,7 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
PCIIDENT_TO_BUSNR(p_adapter_info->fpga_info.pciident),
PCIIDENT_TO_DEVNR(p_adapter_info->fpga_info.pciident),
PCIIDENT_TO_FUNCNR(p_adapter_info->fpga_info.pciident));
- NT_LOG(DBG, NTNIC, "%s: %s", p_adapter_id_str, p_dev_name);
+ NT_LOG(DBG, NTNIC, "%s: %s", p_adapter_id_str, p_dev_name ? p_dev_name : "NA");
}
{
@@ -147,8 +147,9 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
res = nthw_fpga_init(&p_adapter_info->fpga_info);
if (res) {
- NT_LOG_DBGX(ERR, NTNIC, "%s: %s: FPGA=%04d res=x%08X", p_adapter_id_str,
- p_dev_name, fpga_info->n_fpga_prod_id, res);
+ NT_LOG_DBGX(ERR, NTNIC, "%s: %s: FPGA=%04d res=x%08X",
+ p_adapter_id_str ? p_adapter_id_str : "NA",
+ p_dev_name ? p_dev_name : "NA", fpga_info->n_fpga_prod_id, res);
return res;
}
diff --git a/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c b/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c
index 69cd184680..cc09fdcc4a 100644
--- a/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c
+++ b/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c
@@ -397,7 +397,7 @@ static struct nthw_virt_queue *nthw_setup_rx_virt_queue(nthw_dbs_t *p_nthw_dbs,
int_enable = 0;
vec = 0;
istk = 0;
- NT_LOG_DBGX(DBG, NTNIC, "set_rx_uw_data int=0 irq_vector=%u", irq_vector);
+ NT_LOG_DBGX(DBG, NTNIC, "set_rx_uw_data int=0 irq_vector=%i", irq_vector);
if (set_rx_uw_data(p_nthw_dbs, index,
(uint64_t)used_struct_phys_addr,
diff --git a/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c b/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c
index d27ceeea88..f1c17ea80a 100644
--- a/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c
+++ b/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c
@@ -316,7 +316,7 @@ static void adjust_maturing_delay(adapter_info_t *drv, int port)
} else {
NT_LOG(WRN, NTNIC,
- "Port %u: Cannot set the RPF adjusted maturing delay to %i because "
+ "Port %i: Cannot set the RPF adjusted maturing delay to %i because "
"that value is outside the legal range [%i:%i]",
port, delay, min_delay, max_delay);
}
@@ -367,8 +367,8 @@ static void get_link_state(adapter_info_t *drv, nim_i2c_ctx_p ctx, link_state_t
&remote_fault);
if (curr_link_state != state->link_state)
- NT_LOG(DBG, NTNIC, "Port %d: Faults(Local = %d, Remote = %d)", port, local_fault,
- remote_fault);
+ NT_LOG(DBG, NTNIC, "Port %i: Faults(Local = %" PRIu32 ", Remote = %" PRIu32 ")",
+ port, local_fault, remote_fault);
state->nim_present = nim_is_present(ctx, port);
@@ -382,13 +382,13 @@ static void get_link_state(adapter_info_t *drv, nim_i2c_ctx_p ctx, link_state_t
if (remote_fault == 0) {
phy_reset_rx(drv, port);
- NT_LOG(DBG, NTNIC, "Port %u: resetRx due to local fault.", port);
+ NT_LOG(DBG, NTNIC, "Port %i: resetRx due to local fault.", port);
return;
}
/* In case of too many errors perform a reset */
if (nthw_phy_tile_get_rx_hi_ber(p, port)) {
- NT_LOG(INF, NTNIC, "Port %u: HiBer", port);
+ NT_LOG(INF, NTNIC, "Port %i: HiBer", port);
phy_reset_rx(drv, port);
return;
}
@@ -974,7 +974,7 @@ int nt4ga_agx_link_100g_ports_init(struct adapter_info_s *p_adapter_info, nthw_f
res = nthw_rpf_init(p_nthw_agx->p_rpf, fpga, adapter_no);
if (res != 0) {
- NT_LOG(ERR, NTNIC, "%s: Failed to initialize RPF module (%u)",
+ NT_LOG(ERR, NTNIC, "%s: Failed to initialize RPF module (%i)",
p_adapter_info->mp_adapter_id_str, res);
return res;
}
@@ -982,7 +982,7 @@ int nt4ga_agx_link_100g_ports_init(struct adapter_info_s *p_adapter_info, nthw_f
res = nthw_gfg_init(&gfg_mod[adapter_no], fpga, 0 /* Only one instance */);
if (res != 0) {
- NT_LOG(ERR, NTNIC, "%s: Failed to initialize GFG module (%u)",
+ NT_LOG(ERR, NTNIC, "%s: Failed to initialize GFG module (%i)",
p_adapter_info->mp_adapter_id_str, res);
return res;
}
diff --git a/drivers/net/ntnic/nthw/core/nthw_hif.c b/drivers/net/ntnic/nthw/core/nthw_hif.c
index e1ca80046d..ddb875f625 100644
--- a/drivers/net/ntnic/nthw/core/nthw_hif.c
+++ b/drivers/net/ntnic/nthw/core/nthw_hif.c
@@ -79,8 +79,9 @@ int nthw_hif_init(nthw_hif_t *p, nthw_fpga_t *p_fpga, int n_instance)
NT_LOG(DBG, NTHW, "%s: HIF %d: %d-%d-%d-%d-%d", p_adapter_id_str, p->mn_instance,
p->mn_fpga_id_item, p->mn_fpga_id_prod, p->mn_fpga_id_ver,
p->mn_fpga_id_rev, p->mn_fpga_id_build_no);
- NT_LOG(DBG, NTHW, "%s: HIF %d: HIF ref clock: %d Hz (%d ticks/ps)", p_adapter_id_str,
- p->mn_instance, p->mn_fpga_hif_ref_clk_freq, p->mn_fpga_param_hif_per_ps);
+ NT_LOG(DBG, NTHW, "%s: HIF %d: HIF ref clock: %" PRIu32 " Hz (%d ticks/ps)",
+ p_adapter_id_str, p->mn_instance, p->mn_fpga_hif_ref_clk_freq,
+ p->mn_fpga_param_hif_per_ps);
p->mp_reg_build_seed = NULL; /* Reg/Fld not present on HIF */
p->mp_fld_build_seed = NULL; /* Reg/Fld not present on HIF */
diff --git a/drivers/net/ntnic/nthw/core/nthw_iic.c b/drivers/net/ntnic/nthw/core/nthw_iic.c
index 0d50721710..f84eb7eeb2 100644
--- a/drivers/net/ntnic/nthw/core/nthw_iic.c
+++ b/drivers/net/ntnic/nthw/core/nthw_iic.c
@@ -239,7 +239,7 @@ int nthw_iic_init(nthw_iic_t *p, nthw_fpga_t *p_fpga, int n_iic_instance,
/* Setup controller timing */
if (p->mn_iic_cycle_time) {
- NT_LOG(DBG, NTHW, "%s: I2C%d: cycletime=%d", p_adapter_id_str,
+ NT_LOG(DBG, NTHW, "%s: I2C%d: cycletime=%" PRIu32 "", p_adapter_id_str,
p->mn_iic_instance, p->mn_iic_cycle_time);
nthw_iic_reg_set_timing(p, p->mn_iic_cycle_time);
}
diff --git a/drivers/net/ntnic/nthw/core/nthw_phy_tile.c b/drivers/net/ntnic/nthw/core/nthw_phy_tile.c
index 0dc2784034..eea220e40b 100644
--- a/drivers/net/ntnic/nthw/core/nthw_phy_tile.c
+++ b/drivers/net/ntnic/nthw/core/nthw_phy_tile.c
@@ -83,7 +83,7 @@ int nthw_phy_tile_init(nthw_phy_tile_t *p, nthw_fpga_t *p_fpga, int mn_phy_tile_
break;
default:
- NT_LOG_DBG(DBG, NTHW, "unknown product ID: %u", p_fpga->mn_product_id);
+ NT_LOG_DBG(DBG, NTHW, "unknown product ID: %i", p_fpga->mn_product_id);
break;
}
diff --git a/drivers/net/ntnic/nthw/core/nthw_spi_v3.c b/drivers/net/ntnic/nthw/core/nthw_spi_v3.c
index 6ef739279a..a995b1fb6e 100644
--- a/drivers/net/ntnic/nthw/core/nthw_spi_v3.c
+++ b/drivers/net/ntnic/nthw/core/nthw_spi_v3.c
@@ -125,7 +125,7 @@ static void dump_hex(uint8_t *p_data, uint16_t count)
int nthw_spi_v3_init(nthw_spi_v3_t *p, nthw_fpga_t *p_fpga, int n_instance_no)
{
const char *const p_adapter_id_str = p_fpga->p_fpga_info->mp_adapter_id_str;
- uint32_t result;
+ int result;
p->mn_instance_no = n_instance_no;
diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c
index 1455a1e508..358ea3e4fa 100644
--- a/drivers/net/ntnic/nthw/flow_api/flow_api.c
+++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c
@@ -211,7 +211,7 @@ void nthw_flow_nic_free_resource(struct flow_nic_dev *ndev, enum res_type_e res_
int nthw_flow_nic_ref_resource(struct flow_nic_dev *ndev, enum res_type_e res_type, int index)
{
- NT_LOG(DBG, FILTER, "Reference resource %s idx %i (before ref cnt %i)",
+ NT_LOG(DBG, FILTER, "Reference resource %s idx %i (before ref cnt %" PRIu32 ")",
dbg_res_descr[res_type], index, ndev->res[res_type].ref[index]);
RTE_ASSERT(flow_nic_is_resource_used(ndev, res_type, index));
@@ -224,7 +224,7 @@ int nthw_flow_nic_ref_resource(struct flow_nic_dev *ndev, enum res_type_e res_ty
int nthw_flow_nic_deref_resource(struct flow_nic_dev *ndev, enum res_type_e res_type, int index)
{
- NT_LOG(DBG, FILTER, "De-reference resource %s idx %i (before ref cnt %i)",
+ NT_LOG(DBG, FILTER, "De-reference resource %s idx %i (before ref cnt %" PRIu32 ")",
dbg_res_descr[res_type], index, ndev->res[res_type].ref[index]);
RTE_ASSERT(flow_nic_is_resource_used(ndev, res_type, index));
RTE_ASSERT(ndev->res[res_type].ref[index]);
@@ -425,7 +425,7 @@ static void flow_ndev_reset(struct flow_nic_dev *ndev)
int used = flow_nic_is_resource_used(ndev, i, ii);
if (ref || used) {
- NT_LOG(DBG, FILTER, " [%i]: ref cnt %i, used %i", ii, ref,
+ NT_LOG(DBG, FILTER, " [%u]: ref cnt %i, used %i", ii, ref,
used);
err = 1;
}
@@ -434,7 +434,6 @@ static void flow_ndev_reset(struct flow_nic_dev *ndev)
if (err)
NT_LOG(DBG, FILTER, "ERROR - some resources not freed");
}
-
}
int nthw_flow_delete_eth_dev(struct flow_eth_dev *eth_dev)
diff --git a/drivers/net/ntnic/nthw/flow_api/flow_hsh_cfg.c b/drivers/net/ntnic/nthw/flow_api/flow_hsh_cfg.c
index 624d1a26d1..b53252662b 100644
--- a/drivers/net/ntnic/nthw/flow_api/flow_hsh_cfg.c
+++ b/drivers/net/ntnic/nthw/flow_api/flow_hsh_cfg.c
@@ -71,11 +71,11 @@ static int hsh_set_part(struct flow_nic_dev *ndev, int hsh_idx, struct hsh_words
words[word].free = false;
res |= hw_mod_hsh_rcp_set(&ndev->be, words[word].pe, hsh_idx, 0, pe);
- NT_LOG(DBG, FILTER, "hw_mod_hsh_rcp_set(&ndev->be, %d, %d, 0, %d)", words[word].pe,
- hsh_idx, pe);
+ NT_LOG(DBG, FILTER, "hw_mod_hsh_rcp_set(&ndev->be, %d, %d, 0, %" PRIu32 ")",
+ (int)words[word].pe, hsh_idx, pe);
res |= hw_mod_hsh_rcp_set(&ndev->be, words[word].ofs, hsh_idx, 0, ofs);
- NT_LOG(DBG, FILTER, "hw_mod_hsh_rcp_set(&ndev->be, %d, %d, 0, %d)", words[word].ofs,
- hsh_idx, ofs);
+ NT_LOG(DBG, FILTER, "hw_mod_hsh_rcp_set(&ndev->be, %d, %d, 0, %" PRIu32 ")",
+ (int)words[word].ofs, hsh_idx, ofs);
/* set HW_HSH_RCP_WORD_MASK based on used QW/W and given 'bit_len' */
diff --git a/drivers/net/ntnic/nthw/flow_api/flow_km.c b/drivers/net/ntnic/nthw/flow_api/flow_km.c
index e7ba07d7db..7b0fdddeea 100644
--- a/drivers/net/ntnic/nthw/flow_api/flow_km.c
+++ b/drivers/net/ntnic/nthw/flow_api/flow_km.c
@@ -580,7 +580,7 @@ int km_rcp_set(struct km_flow_def_s *km, int index)
}
NT_LOG(DBG, FILTER,
- "Set KM QW0 sel A: dyn: %i, offs: %i, size: %i",
+ "Set KM QW0 sel A: dyn: %i, offs: %i, size: %" PRIu32 "",
km->match_map[i]->extr_start_offs_id,
km->match_map[i]->rel_offs, km->match_map[i]->word_len);
@@ -611,7 +611,7 @@ int km_rcp_set(struct km_flow_def_s *km, int index)
}
NT_LOG(DBG, FILTER,
- "Set KM QW4 sel A: dyn: %i, offs: %i, size: %i",
+ "Set KM QW4 sel A: dyn: %i, offs: %i, size: %" PRIu32 "",
km->match_map[i]->extr_start_offs_id,
km->match_map[i]->rel_offs, km->match_map[i]->word_len);
@@ -788,7 +788,7 @@ static int move_cuckoo_index(struct km_flow_def_s *km)
km->cam_dist[CAM_KM_DIST_IDX(km->bank_used) + 1].km_owner = NULL;
NT_LOG(DBG, FILTER,
- "KM Cuckoo hash moved from bank %i to bank %i (%04X => %04X)",
+ "KM Cuckoo hash moved from bank %i to bank %" PRIu32 " (%04X => %04X)",
km->bank_used, bank, CAM_KM_DIST_IDX(km->bank_used),
CAM_KM_DIST_IDX(bank));
km->bank_used = bank;
diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c
index ae72b8775e..fbb7b04cd1 100644
--- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c
+++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c
@@ -423,9 +423,10 @@ void hw_db_inline_dump(struct flow_nic_dev *ndev, void *db_handle, const struct
case HW_DB_IDX_TYPE_MATCH_SET: {
const struct hw_db_inline_match_set_data *data =
&db->match_set[idxs[i].ids].data;
- fprintf(file, " MATCH_SET %d, priority %d\n", idxs[i].ids,
- (int)data->priority);
- fprintf(file, " CAT id %d, KM id %d, KM_FT id %d, ACTION_SET id %d\n",
+ fprintf(file, " MATCH_SET %" PRIu32 ", priority %u\n", idxs[i].ids,
+ (unsigned int)data->priority);
+ fprintf(file, " CAT id %" PRIu32 ", KM id %" PRIu32
+ ", KM_FT id %" PRIu32 ", ACTION_SET id %" PRIu32 "\n",
data->cat.ids, data->km.id1, data->km_ft.id1,
data->action_set.ids);
@@ -435,7 +436,7 @@ void hw_db_inline_dump(struct flow_nic_dev *ndev, void *db_handle, const struct
data->jump, &group_orig) < 0)
fprintf(file, " Jumps to %d (encoded)\n", data->jump);
else
- fprintf(file, " Jumps to %d\n", group_orig);
+ fprintf(file, " Jumps to %" PRIu32 "\n", group_orig);
}
break;
}
@@ -443,7 +444,7 @@ void hw_db_inline_dump(struct flow_nic_dev *ndev, void *db_handle, const struct
case HW_DB_IDX_TYPE_ACTION_SET: {
const struct hw_db_inline_action_set_data *data =
&db->action_set[idxs[i].ids].data;
- fprintf(file, " ACTION_SET %d\n", idxs[i].ids);
+ fprintf(file, " ACTION_SET %" PRIu32 "\n", idxs[i].ids);
if (data->contains_jump) {
uint32_t group_orig = 0;
@@ -455,7 +456,9 @@ void hw_db_inline_dump(struct flow_nic_dev *ndev, void *db_handle, const struct
fprintf(file, " Jumps to %d\n", group_orig);
} else {
fprintf(file,
- " COT id %d, QSL id %d, SLC_LR id %d, TPE id %d, HSH id %d, SCRUB id %d\n",
+ " COT id %" PRIu32 ", QSL id %" PRIu32 ", SLC_LR id %"
+ PRIu32 ", TPE id %" PRIu32 ", HSH id %" PRIu32 ", SCRUB id %"
+ PRIu32 "\n",
data->cot.ids, data->qsl.ids, data->slc_lr.ids,
data->tpe.ids, data->hsh.ids, data->scrub.ids);
}
@@ -464,7 +467,7 @@ void hw_db_inline_dump(struct flow_nic_dev *ndev, void *db_handle, const struct
case HW_DB_IDX_TYPE_CAT: {
const struct hw_db_inline_cat_data *data = &db->cat[idxs[i].ids].data;
- fprintf(file, " CAT %d\n", idxs[i].ids);
+ fprintf(file, " CAT %" PRIu32 "\n", idxs[i].ids);
fprintf(file, " Port msk 0x%02x, VLAN msk 0x%02x\n",
(int)data->mac_port_mask, (int)data->vlan_mask);
fprintf(file,
@@ -479,7 +482,7 @@ void hw_db_inline_dump(struct flow_nic_dev *ndev, void *db_handle, const struct
case HW_DB_IDX_TYPE_QSL: {
const struct hw_db_inline_qsl_data *data = &db->qsl[idxs[i].ids].data;
- fprintf(file, " QSL %d\n", idxs[i].ids);
+ fprintf(file, " QSL %" PRIu32 "\n", idxs[i].ids);
if (data->discard) {
fprintf(file, " Discard\n");
@@ -491,7 +494,7 @@ void hw_db_inline_dump(struct flow_nic_dev *ndev, void *db_handle, const struct
break;
}
- fprintf(file, " Table size %d\n", data->table_size);
+ fprintf(file, " Table size %" PRIu32 "\n", data->table_size);
for (uint32_t i = 0;
i < data->table_size && i < HW_DB_INLINE_MAX_QST_PER_QSL; ++i) {
@@ -506,7 +509,7 @@ void hw_db_inline_dump(struct flow_nic_dev *ndev, void *db_handle, const struct
case HW_DB_IDX_TYPE_COT: {
const struct hw_db_inline_cot_data *data = &db->cot[idxs[i].ids].data;
- fprintf(file, " COT %d\n", idxs[i].ids);
+ fprintf(file, " COT %" PRIu32 "\n", idxs[i].ids);
fprintf(file, " Color contrib %d, frag rcp %d\n",
(int)data->matcher_color_contrib, (int)data->frag_rcp);
break;
@@ -515,7 +518,7 @@ void hw_db_inline_dump(struct flow_nic_dev *ndev, void *db_handle, const struct
case HW_DB_IDX_TYPE_SLC_LR: {
const struct hw_db_inline_slc_lr_data *data =
&db->slc_lr[idxs[i].ids].data;
- fprintf(file, " SLC_LR %d\n", idxs[i].ids);
+ fprintf(file, " SLC_LR %" PRIu32 "\n", idxs[i].ids);
fprintf(file, " Enable %u, dyn %u, ofs %u\n", data->head_slice_en,
data->head_slice_dyn, data->head_slice_ofs);
break;
@@ -523,7 +526,7 @@ void hw_db_inline_dump(struct flow_nic_dev *ndev, void *db_handle, const struct
case HW_DB_IDX_TYPE_TPE: {
const struct hw_db_inline_tpe_data *data = &db->tpe[idxs[i].ids].data;
- fprintf(file, " TPE %d\n", idxs[i].ids);
+ fprintf(file, " TPE %" PRIu32 "\n", idxs[i].ids);
fprintf(file, " Insert len %u, new outer %u, calc eth %u\n",
data->insert_len, data->new_outer,
data->calc_eth_type_from_inner_ip);
@@ -557,7 +560,7 @@ void hw_db_inline_dump(struct flow_nic_dev *ndev, void *db_handle, const struct
const struct hw_db_inline_tpe_ext_data *data =
&db->tpe_ext[idxs[i].ids].data;
const int rpl_rpl_length = ((int)data->size + 15) / 16;
- fprintf(file, " TPE_EXT %d\n", idxs[i].ids);
+ fprintf(file, " TPE_EXT %" PRIu32 "\n", idxs[i].ids);
fprintf(file, " Encap data, size %u\n", data->size);
for (int i = 0; i < rpl_rpl_length; ++i) {
@@ -575,25 +578,33 @@ void hw_db_inline_dump(struct flow_nic_dev *ndev, void *db_handle, const struct
case HW_DB_IDX_TYPE_FLM_RCP: {
const struct hw_db_inline_flm_rcp_data *data = &db->flm[idxs[i].id1].data;
- fprintf(file, " FLM_RCP %d\n", idxs[i].id1);
- fprintf(file, " QW0 dyn %u, ofs %u, QW4 dyn %u, ofs %u\n",
- data->qw0_dyn, data->qw0_ofs, data->qw4_dyn, data->qw4_ofs);
- fprintf(file, " SW8 dyn %u, ofs %u, SW9 dyn %u, ofs %u\n",
- data->sw8_dyn, data->sw8_ofs, data->sw9_dyn, data->sw9_ofs);
- fprintf(file, " Outer prot %u, inner prot %u\n", data->outer_prot,
- data->inner_prot);
+ fprintf(file, " FLM_RCP %" PRIu32 "\n", idxs[i].id1);
+ fprintf(file, " QW0 dyn %" PRIu64 ", ofs %" PRIu64
+ ", QW4 dyn %" PRIu64 ", ofs %" PRIu64 "\n",
+ (uint64_t)data->qw0_dyn, (uint64_t)data->qw0_ofs,
+ (uint64_t)data->qw4_dyn, (uint64_t)data->qw4_ofs);
+ fprintf(file, " SW8 dyn %" PRIu64 ", ofs %" PRIu64
+ ", SW9 dyn %" PRIu64 ", ofs %" PRIu64 "\n",
+ (uint64_t)data->sw8_dyn, (uint64_t)data->sw8_ofs,
+ (uint64_t)data->sw9_dyn, (uint64_t)data->sw9_ofs);
+ fprintf(file, " Outer prot %" PRIu64 ", inner prot %" PRIu64 "\n",
+ (uint64_t)data->outer_prot, (uint64_t)data->inner_prot);
fprintf(file, " Mask:\n");
- fprintf(file, " %08x %08x %08x %08x %08x\n", data->mask[0],
- data->mask[1], data->mask[2], data->mask[3], data->mask[4]);
- fprintf(file, " %08x %08x %08x %08x %08x\n", data->mask[5],
- data->mask[6], data->mask[7], data->mask[8], data->mask[9]);
+ fprintf(file, " %08x %08x %08x %08x %08x\n",
+ (uint32_t)data->mask[0], (uint32_t)data->mask[1],
+ (uint32_t)data->mask[2], (uint32_t)data->mask[3],
+ (uint32_t)data->mask[4]);
+ fprintf(file, " %08x %08x %08x %08x %08x\n",
+ (uint32_t)data->mask[5], (uint32_t)data->mask[6],
+ (uint32_t)data->mask[7], (uint32_t)data->mask[8],
+ (uint32_t)data->mask[9]);
break;
}
case HW_DB_IDX_TYPE_FLM_FT: {
const struct hw_db_inline_flm_ft_data *data =
&db->flm[idxs[i].id2].ft[idxs[i].id1].data;
- fprintf(file, " FLM_FT %d\n", idxs[i].id1);
+ fprintf(file, " FLM_FT %" PRIu32 "\n", idxs[i].id1);
if (data->is_group_zero)
fprintf(file, " Jump to %d\n", data->jump);
@@ -607,7 +618,7 @@ void hw_db_inline_dump(struct flow_nic_dev *ndev, void *db_handle, const struct
case HW_DB_IDX_TYPE_KM_RCP: {
const struct hw_db_inline_km_rcp_data *data = &db->km[idxs[i].id1].data;
- fprintf(file, " KM_RCP %d\n", idxs[i].id1);
+ fprintf(file, " KM_RCP %" PRIu32 "\n", idxs[i].id1);
fprintf(file, " HW id %u\n", data->rcp);
break;
}
@@ -615,25 +626,25 @@ void hw_db_inline_dump(struct flow_nic_dev *ndev, void *db_handle, const struct
case HW_DB_IDX_TYPE_KM_FT: {
const struct hw_db_inline_km_ft_data *data =
&db->km[idxs[i].id2].ft[idxs[i].id1].data;
- fprintf(file, " KM_FT %d\n", idxs[i].id1);
+ fprintf(file, " KM_FT %" PRIu32 "\n", idxs[i].id1);
fprintf(file, " ACTION_SET id %d\n", data->action_set.ids);
- fprintf(file, " KM_RCP id %d\n", data->km.ids);
- fprintf(file, " CAT id %d\n", data->cat.ids);
+ fprintf(file, " KM_RCP id %" PRIu32 "\n", data->km.ids);
+ fprintf(file, " CAT id %" PRIu32 "\n", data->cat.ids);
break;
}
case HW_DB_IDX_TYPE_FLM_SCRUB: {
const struct hw_db_inline_scrub_data *data = &db->scrub[idxs[i].ids].data;
- fprintf(file, " FLM_RCP %d\n", idxs[i].id1);
- fprintf(file, " SCRUB %d\n", idxs[i].ids);
- fprintf(file, " Timeout: %d, encoded timeout: %d\n",
+ fprintf(file, " FLM_RCP %" PRIu32 "\n", idxs[i].id1);
+ fprintf(file, " SCRUB %" PRIu32 "\n", idxs[i].ids);
+ fprintf(file, " Timeout: %" PRIu32 ", encoded timeout: %" PRIu32 "\n",
hw_mod_flm_scrub_timeout_decode(data->timeout), data->timeout);
break;
}
case HW_DB_IDX_TYPE_HSH: {
const struct hw_db_inline_hsh_data *data = &db->hsh[idxs[i].ids].data;
- fprintf(file, " HSH %d\n", idxs[i].ids);
+ fprintf(file, " HSH %" PRIu32 "\n", idxs[i].ids);
switch (data->func) {
case RTE_ETH_HASH_FUNCTION_DEFAULT:
diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
index c0407574f0..6bfa471321 100644
--- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
+++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
@@ -1159,8 +1159,9 @@ static int interpret_flow_actions(const struct flow_eth_dev *dev,
fd->dst_num_avail++;
NT_LOG(DBG, FILTER,
- "Dev:%p: RTE_FLOW_ACTION_TYPE_QUEUE port %u, queue index: %u, hw id %u",
- dev, dev->port, queue->index, hw_id);
+ "Dev:%p: RTE_FLOW_ACTION_TYPE_QUEUE port %u, queue index:"
+ "%" PRIu16 ",hw id %i",
+ dev, (unsigned int)dev->port, queue->index, hw_id);
fd->full_offload = 0;
*num_queues += 1;
@@ -1202,8 +1203,9 @@ static int interpret_flow_actions(const struct flow_eth_dev *dev,
fd->hsh.key_len = rss->key_len;
NT_LOG(DBG, FILTER,
- "Dev:%p: RSS func: %d, types: 0x%" PRIX64 ", key_len: %d",
- dev, rss->func, rss->types, rss->key_len);
+ "Dev:%p: RSS func: %i, types: 0x%" PRIX64
+ ", key_len: %" PRIu32 "",
+ dev, (int)rss->func, rss->types, rss->key_len);
fd->full_offload = 0;
*num_queues += rss->queue_num;
@@ -1222,7 +1224,7 @@ static int interpret_flow_actions(const struct flow_eth_dev *dev,
sizeof(struct rte_flow_action_mark));
fd->mark = mark->id;
- NT_LOG(DBG, FILTER, "Mark: %i", mark->id);
+ NT_LOG(DBG, FILTER, "Mark: %u", mark->id);
}
break;
@@ -3138,7 +3140,7 @@ static int copy_fd_to_fh_flm(struct flow_handle *fh, const struct nic_flow_def *
break;
default:
- NT_LOG(DBG, FILTER, "Unknown modify field: %d",
+ NT_LOG(DBG, FILTER, "Unknown modify field: %" PRIu32,
fd->modify_field[i].select);
break;
}
@@ -4516,7 +4518,7 @@ int flow_actions_update_profile_inline(struct flow_eth_dev *dev,
break;
default:
- NT_LOG(DBG, FILTER, "Unknown modify field: %d",
+ NT_LOG(DBG, FILTER, "Unknown modify field: %" PRIu32,
fd->modify_field[i].select);
break;
}
diff --git a/drivers/net/ntnic/nthw/model/nthw_fpga_model.c b/drivers/net/ntnic/nthw/model/nthw_fpga_model.c
index 43841b2f7b..fbaf0c2d6d 100644
--- a/drivers/net/ntnic/nthw/model/nthw_fpga_model.c
+++ b/drivers/net/ntnic/nthw/model/nthw_fpga_model.c
@@ -904,7 +904,9 @@ void nthw_field_init(nthw_field_t *p, nthw_register_t *p_reg, const nthw_fpga_fi
if (p->mn_debug_mode >= 0x100) {
NT_LOG_DBGX(DBG, NTHW,
- "fldid=%08d: [%08d:%08d] %08d/%08d: (%08d,%08d) (0x%08X,%08d,0x%08X)",
+ "fldid=%08" PRIu32 ": [%08" PRIu16 ":%08" PRIu16 "] %08" PRIu16 "/%08"
+ PRIu16 ": (%08i ,%08" PRIu32 ") (0x%08" PRIx32 ",%08"
+ PRIu32 ",0x%08" PRIx32 ")",
p_init->id, p_init->low, (p_init->low + p_init->bw),
p_init->bw, ((p_init->bw + 31) / 32), p->mn_first_word,
p->mn_first_bit, p->mn_front_mask, p->mn_body_length,
diff --git a/drivers/net/ntnic/nthw/nthw_rac.c b/drivers/net/ntnic/nthw/nthw_rac.c
index 2257dfb7dc..d6fdea2ddb 100644
--- a/drivers/net/ntnic/nthw/nthw_rac.c
+++ b/drivers/net/ntnic/nthw/nthw_rac.c
@@ -265,7 +265,7 @@ static inline int _nthw_rac_wait_for_rab_done(const nthw_rac_t *p, uint32_t addr
}
if (used < word_cnt) {
- NT_LOG(ERR, NTHW, "%s: Fail rab bus r/w addr=0x%08X used=%x wordcount=%d",
+ NT_LOG(ERR, NTHW, "%s: Fail rab bus r/w addr=0x%08X used=%x wordcount=%" PRIu32 "",
p_adapter_id_str, address, used, word_cnt);
return -1;
}
@@ -470,7 +470,8 @@ int nthw_rac_rab_write32_dma(nthw_rac_t *p, nthw_rab_bus_id_t bus_id, uint32_t a
if (word_cnt == 0 || word_cnt > 256) {
NT_LOG(ERR, NTHW,
- "%s: Failed rab dma write length check - bus: %d addr: 0x%08X wordcount: %d - inBufFree: 0x%08X",
+ "%s: Failed rab dma write length check - bus: %d addr: 0x%08X wordcount: %"
+ PRIu32 " - inBufFree: 0x%08X",
p_adapter_id_str, bus_id, address, word_cnt, p->m_in_free);
RTE_ASSERT(0); /* alert developer that something is wrong */
return -1;
@@ -509,7 +510,8 @@ int nthw_rac_rab_read32_dma(nthw_rac_t *p, nthw_rab_bus_id_t bus_id, uint32_t ad
if (word_cnt == 0 || word_cnt > 256) {
NT_LOG(ERR, NTHW,
- "%s: Failed rab dma read length check - bus: %d addr: 0x%08X wordcount: %d - inBufFree: 0x%08X",
+ "%s: Failed rab dma read length check - bus: %d addr: 0x%08X wordcount: %"
+ PRIu32 " - inBufFree: 0x%08X",
p_adapter_id_str, bus_id, address, word_cnt, p->m_in_free);
RTE_ASSERT(0); /* alert developer that something is wrong */
return -1;
@@ -560,19 +562,19 @@ int nthw_rac_rab_write32(nthw_rac_t *p, bool trc, nthw_rab_bus_id_t bus_id, uint
int res = 0;
if (address > (1 << RAB_ADDR_BW)) {
- NT_LOG(ERR, NTHW, "%s: RAB: Illegal address: value too large %d - max %d",
+ NT_LOG(ERR, NTHW, "%s: RAB: Illegal address: value too large %" PRIu32 " - max %d",
p_adapter_id_str, address, (1 << RAB_ADDR_BW));
return -1;
}
if (bus_id > (1 << RAB_BUSID_BW)) {
- NT_LOG(ERR, NTHW, "%s: RAB: Illegal bus id: value too large %d - max %d",
+ NT_LOG(ERR, NTHW, "%s: RAB: Illegal bus id: value too large %" PRIu32 " - max %d",
p_adapter_id_str, bus_id, (1 << RAB_BUSID_BW));
return -1;
}
if (word_cnt == 0) {
- NT_LOG(ERR, NTHW, "%s: RAB: Illegal word count: value is zero (%d)",
+ NT_LOG(ERR, NTHW, "%s: RAB: Illegal word count: value is zero (%" PRIu32 ")",
p_adapter_id_str, word_cnt);
return -1;
}
@@ -747,28 +749,28 @@ int nthw_rac_rab_read32(nthw_rac_t *p, bool trc, nthw_rab_bus_id_t bus_id, uint3
rte_spinlock_lock(&p->m_mutex);
if (address > (1 << RAB_ADDR_BW)) {
- NT_LOG(ERR, NTHW, "%s: RAB: Illegal address: value too large %d - max %d",
+ NT_LOG(ERR, NTHW, "%s: RAB: Illegal address: value too large %" PRIu32 " - max %d",
p_adapter_id_str, address, (1 << RAB_ADDR_BW));
res = -1;
goto exit_unlock_res;
}
if (bus_id > (1 << RAB_BUSID_BW)) {
- NT_LOG(ERR, NTHW, "%s: RAB: Illegal bus id: value too large %d - max %d",
+ NT_LOG(ERR, NTHW, "%s: RAB: Illegal bus id: value too large %" PRIu32 " - max %d",
p_adapter_id_str, bus_id, (1 << RAB_BUSID_BW));
res = -1;
goto exit_unlock_res;
}
if (word_cnt == 0) {
- NT_LOG(ERR, NTHW, "%s: RAB: Illegal word count: value is zero (%d)",
+ NT_LOG(ERR, NTHW, "%s: RAB: Illegal word count: value is zero (%" PRIu32 ")",
p_adapter_id_str, word_cnt);
res = -1;
goto exit_unlock_res;
}
if (word_cnt > (1 << RAB_CNT_BW)) {
- NT_LOG(ERR, NTHW, "%s: RAB: Illegal word count: value too large %d - max %d",
+ NT_LOG(ERR, NTHW, "%s: RAB: Illegal word count: value too large %" PRIu32 " - max %d",
p_adapter_id_str, word_cnt, (1 << RAB_CNT_BW));
res = -1;
goto exit_unlock_res;
diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c
index 6ba6769e47..87a0c3576b 100644
--- a/drivers/net/ntnic/ntnic_ethdev.c
+++ b/drivers/net/ntnic/ntnic_ethdev.c
@@ -844,7 +844,8 @@ static int allocate_hw_virtio_queues(struct rte_eth_dev *eth_dev, int vf_num, st
if (!hwq->pkt_buffers) {
NT_LOG(ERR, NTNIC,
- "Failed to allocated buffer array for hw-queue %p, total size %i, elements %i",
+ "Failed to allocated buffer array for hw-queue %p, total size %"
+ PRIu32 ", elements %i",
hwq->pkt_buffers, size, num_descr);
rte_free(virt);
return -1;
@@ -866,7 +867,8 @@ static int allocate_hw_virtio_queues(struct rte_eth_dev *eth_dev, int vf_num, st
res = nt_vfio_dma_map(vf_num, virt_addr, &iova_addr, size);
NT_LOG(DBG, NTNIC,
- "VFIO MMAP res %i, virt %p, iova %016" PRIX64 ", vf_num %i, num pkt bufs %i, tot size %i",
+ "VFIO MMAP res %i, virt %p, iova %016"
+ PRIX64 ", vf_num %i, num pkt bufs %i, tot size %" PRIu32 "",
res, virt_addr, iova_addr, vf_num, num_descr, size);
if (res != 0)
@@ -907,7 +909,8 @@ static int allocate_hw_virtio_queues(struct rte_eth_dev *eth_dev, int vf_num, st
if (!hwq->pkt_buffers) {
NT_LOG(ERR, NTNIC,
- "Failed to allocated buffer array for hw-queue %p, total size %i, elements %i",
+ "Failed to allocated buffer array for hw-queue %p, total size %"
+ PRIu32 ", elements %i",
hwq->pkt_buffers, size, num_descr);
rte_free(virt);
return -1;
@@ -973,7 +976,7 @@ static int num_queues_alloced;
static int allocate_queue(int num)
{
int next_free = num_queues_alloced;
- NT_LOG_DBGX(DBG, NTNIC, "num_queues_alloced=%u, New queues=%u, Max queues=%u",
+ NT_LOG_DBGX(DBG, NTNIC, "num_queues_alloced=%i, New queues=%i, Max queues=%d",
num_queues_alloced, num, MAX_TOTAL_QUEUES);
if (num_queues_alloced + num > MAX_TOTAL_QUEUES)
@@ -1011,7 +1014,8 @@ static int eth_rx_scg_queue_setup(struct rte_eth_dev *eth_dev,
return 0;
}
- NT_LOG(DBG, NTNIC, "(%i) NTNIC RX OVS-SW queue setup: queue id %i, hw queue index %i",
+ NT_LOG(DBG, NTNIC, "(%" PRIu32 ") NTNIC RX OVS-SW queue setup: queue id %"
+ PRIu16 ", hw queue index %i",
internals->port, rx_queue_id, rx_q->queue.hw_id);
rx_q->mb_pool = mb_pool;
@@ -1041,7 +1045,8 @@ static int eth_rx_scg_queue_setup(struct rte_eth_dev *eth_dev,
SPLIT_RING,
-1);
- NT_LOG(DBG, NTNIC, "(%i) NTNIC RX OVS-SW queues successfully setup", internals->port);
+ NT_LOG(DBG, NTNIC, "(%" PRIu32 ") NTNIC RX OVS-SW queues successfully setup",
+ internals->port);
return 0;
}
@@ -1075,7 +1080,7 @@ static int eth_tx_scg_queue_setup(struct rte_eth_dev *eth_dev,
return 0;
}
- NT_LOG(DBG, NTNIC, "(%i) NTNIC TX OVS-SW queue setup: queue id %i, hw queue index %i",
+ NT_LOG(DBG, NTNIC, "(%" PRIu32 ") NTNIC TX OVS-SW queue setup: queue id %" PRIu16 ", hw queue index %i",
tx_q->port, tx_queue_id, tx_q->queue.hw_id);
if (tx_queue_id > internals->nb_tx_queues) {
@@ -1135,7 +1140,8 @@ static int eth_tx_scg_queue_setup(struct rte_eth_dev *eth_dev,
tx_q->enabled = 1;
- NT_LOG(DBG, NTNIC, "(%i) NTNIC TX OVS-SW queues successfully setup", internals->port);
+ NT_LOG(DBG, NTNIC, "(%" PRIu32 ") NTNIC TX OVS-SW queues successfully setup",
+ internals->port);
if (internals->type == PORT_TYPE_PHYSICAL) {
struct adapter_info_s *p_adapter_info = &internals->p_drv->ntdrv.adapter_info;
@@ -1276,7 +1282,7 @@ eth_dev_start(struct rte_eth_dev *eth_dev)
const int n_intf_no = internals->n_intf_no;
struct adapter_info_s *p_adapter_info = &internals->p_drv->ntdrv.adapter_info;
- NT_LOG_DBGX(DBG, NTNIC, "Port %u", internals->n_intf_no);
+ NT_LOG_DBGX(DBG, NTNIC, "Port %i", internals->n_intf_no);
/* Start queues */
uint q;
@@ -1334,7 +1340,7 @@ eth_dev_stop(struct rte_eth_dev *eth_dev)
{
struct pmd_internals *internals = eth_dev->data->dev_private;
- NT_LOG_DBGX(DBG, NTNIC, "Port %u", internals->n_intf_no);
+ NT_LOG_DBGX(DBG, NTNIC, "Port %i", internals->n_intf_no);
if (internals->type != PORT_TYPE_VIRTUAL) {
uint q;
@@ -2304,13 +2310,13 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev)
/* Setup queue_ids */
if (nb_rx_queues > 1) {
NT_LOG(DBG, NTNIC,
- "(%i) NTNIC configured with Rx multi queues. %i queues",
+ "(%i) NTNIC configured with Rx multi queues. %" PRIu32 " queues",
internals->n_intf_no, nb_rx_queues);
}
if (nb_tx_queues > 1) {
NT_LOG(DBG, NTNIC,
- "(%i) NTNIC configured with Tx multi queues. %i queues",
+ "(%i) NTNIC configured with Tx multi queues. %" PRIu32 " queues",
internals->n_intf_no, nb_tx_queues);
}
diff --git a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c
index 29bfb2a121..551979cf0f 100644
--- a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c
+++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c
@@ -355,8 +355,8 @@ int nthw_create_action_elements_inline(struct cnv_action_s *action,
case RTE_ETH_HASH_FUNCTION_MAX:
default:
NT_LOG(ERR, FILTER,
- "RTE ACTION RSS - unsupported function: %u",
- rss->func);
+ "RTE ACTION RSS - unsupported function: %i",
+ (int)rss->func);
return -1;
}
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 09/25] net/ntnic: remove usless expressions
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
` (7 preceding siblings ...)
2025-04-30 13:48 ` [PATCH v1 08/25] net/ntnic: improve logging format specifiers Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 10/25] net/ntnic: remove unused code Oleksandr Kolomeiets
` (15 subsequent siblings)
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas, Danylo Vodopianov
From: Danylo Vodopianov <dvo-plv@napatech.com>
simplify conditionals and remove redundant checks
Signed-off-by: Danylo Vodopianov <dvo-plv@napatech.com>
---
drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c | 3 +-
.../link_agx_100g/nt4ga_agx_link_100g.c | 16 +++++------
drivers/net/ntnic/nim/i2c_nim.c | 3 +-
.../core/nt200a0x/reset/nthw_fpga_rst9563.c | 10 -------
.../nthw/core/nt400dxx/nthw_fpga_nt400dxx.c | 3 +-
drivers/net/ntnic/nthw/core/nthw_phy_tile.c | 2 +-
drivers/net/ntnic/nthw/core/nthw_sdc.c | 3 +-
drivers/net/ntnic/nthw/core/nthw_tsm.c | 6 ++--
drivers/net/ntnic/nthw/flow_api/flow_api.c | 3 +-
.../ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c | 3 --
.../profile_inline/flow_api_profile_inline.c | 9 +-----
drivers/net/ntnic/nthw/nthw_rac.c | 7 -----
drivers/net/ntnic/ntnic_ethdev.c | 28 ++++++++-----------
13 files changed, 28 insertions(+), 68 deletions(-)
diff --git a/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c b/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c
index cc09fdcc4a..c9a0580391 100644
--- a/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c
+++ b/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c
@@ -761,8 +761,7 @@ static struct nthw_virt_queue *nthw_setup_tx_virt_queue(nthw_dbs_t *p_nthw_dbs,
*/
if (irq_vector < 0) {
if (set_tx_am_data(p_nthw_dbs, index, (uint64_t)avail_struct_phys_addr,
- TX_AM_ENABLE, host_id, 0,
- irq_vector >= 0 ? 1 : 0) != 0) {
+ TX_AM_ENABLE, host_id, 0, 0) != 0) {
return NULL;
}
}
diff --git a/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c b/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c
index f1c17ea80a..4f6be900fd 100644
--- a/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c
+++ b/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c
@@ -1010,20 +1010,18 @@ int nt4ga_agx_link_100g_ports_init(struct adapter_info_s *p_adapter_info, nthw_f
nthw_rpf_set_ts_at_eof(p_nthw_agx->p_rpf, true);
- if (res == 0) {
- p_adapter_info->nt4ga_link.speed_capa = NT_LINK_SPEED_100G;
- p_adapter_info->nt4ga_link.variables_initialized = true;
- }
+
+ p_adapter_info->nt4ga_link.speed_capa = NT_LINK_SPEED_100G;
+ p_adapter_info->nt4ga_link.variables_initialized = true;
}
/*
* Create state-machine thread
*/
- if (res == 0) {
- if (!monitor_task_is_running[adapter_no]) {
- res = rte_thread_create(&monitor_tasks[adapter_no], NULL,
- nt4ga_agx_link_100g_mon, p_adapter_info);
- }
+
+ if (!monitor_task_is_running[adapter_no]) {
+ res = rte_thread_create(&monitor_tasks[adapter_no], NULL,
+ nt4ga_agx_link_100g_mon, p_adapter_info);
}
return res;
diff --git a/drivers/net/ntnic/nim/i2c_nim.c b/drivers/net/ntnic/nim/i2c_nim.c
index 654e2dd80e..5e8eeb16a7 100644
--- a/drivers/net/ntnic/nim/i2c_nim.c
+++ b/drivers/net/ntnic/nim/i2c_nim.c
@@ -123,8 +123,7 @@ static int nim_read_write_data_lin(nim_i2c_ctx_p ctx, bool m_page_addressing, ui
* Find out how much can be read from the current block in case of
* single byte access
*/
- if (multi_byte == 1)
- max_seq_cnt = block_size - (lin_addr % block_size);
+ max_seq_cnt = block_size - (lin_addr % block_size);
if (m_page_addressing) {
if (lin_addr >= 128) { /* Only page setup above this address */
diff --git a/drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c b/drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c
index ee2c2453e5..7b0c47e9b2 100644
--- a/drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c
+++ b/drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c
@@ -104,11 +104,6 @@ static int nthw_fpga_rst9563_setup(nthw_fpga_t *p_fpga, struct nthw_fpga_rst_nt2
nthw_register_get_field(p_curr_reg, RST9563_STAT_TS_MMCM_LOCKED);
p->mp_fld_stat_tsm_ref_mmcm_locked = NULL; /* Field not present on 9563 */
- if (!p->mp_fld_stat_tsm_ref_mmcm_locked) {
- NT_LOG(DBG, NTHW, "%s: No RST9563_STAT_TSM_REF_MMCM_LOCKED found",
- p_adapter_id_str);
- }
-
nthw_register_update(p_curr_reg);
/* STICKY register field pointers */
@@ -126,11 +121,6 @@ static int nthw_fpga_rst9563_setup(nthw_fpga_t *p_fpga, struct nthw_fpga_rst_nt2
p->mp_fld_sticky_pci_sys_mmcm_unlocked = NULL; /* Field not present on 9563 */
p->mp_fld_sticky_tsm_ref_mmcm_unlocked = NULL; /* Field not present on 9563 */
- if (!p->mp_fld_sticky_tsm_ref_mmcm_unlocked) {
- NT_LOG(DBG, NTHW, "%s: No RST9563_STICKY_TSM_REF_MMCM_UNLOCKED found",
- p_adapter_id_str);
- }
-
nthw_register_update(p_curr_reg);
/* POWER register field pointers */
diff --git a/drivers/net/ntnic/nthw/core/nt400dxx/nthw_fpga_nt400dxx.c b/drivers/net/ntnic/nthw/core/nt400dxx/nthw_fpga_nt400dxx.c
index d610e3a7cc..e7c9fec10d 100644
--- a/drivers/net/ntnic/nthw/core/nt400dxx/nthw_fpga_nt400dxx.c
+++ b/drivers/net/ntnic/nthw/core/nt400dxx/nthw_fpga_nt400dxx.c
@@ -184,8 +184,7 @@ static int nthw_fpga_nt400dxx_init(struct fpga_info_s *p_fpga_info)
/* reset specific */
switch (p_fpga_info->n_fpga_prod_id) {
case 9574:
- if (rst9574_ops)
- res = rst9574_ops->nthw_fpga_rst9574_init(p_fpga_info, &rst);
+ res = rst9574_ops->nthw_fpga_rst9574_init(p_fpga_info, &rst);
if (res) {
NT_LOG(ERR, NTHW,
diff --git a/drivers/net/ntnic/nthw/core/nthw_phy_tile.c b/drivers/net/ntnic/nthw/core/nthw_phy_tile.c
index eea220e40b..77400d2514 100644
--- a/drivers/net/ntnic/nthw/core/nthw_phy_tile.c
+++ b/drivers/net/ntnic/nthw/core/nthw_phy_tile.c
@@ -806,7 +806,7 @@ static uint32_t nthw_phy_tile_cpi_request(nthw_phy_tile_t *p, uint8_t intf_no, u
nt_os_wait_usec(10000);
- for (int i = 20; i > 0; i--) {
+ for (int i = 20; i >= 0; i--) {
data = nthw_phy_tile_read_xcvr(p, intf_no, lane, phy_addr + lane_offset);
value =
diff --git a/drivers/net/ntnic/nthw/core/nthw_sdc.c b/drivers/net/ntnic/nthw/core/nthw_sdc.c
index fc73e6957c..ae967e5ed9 100644
--- a/drivers/net/ntnic/nthw/core/nthw_sdc.c
+++ b/drivers/net/ntnic/nthw/core/nthw_sdc.c
@@ -132,8 +132,7 @@ int nthw_sdc_get_states(nthw_sdc_t *p, uint64_t *pn_result_mask)
if (val != 0)
n_err_cnt++;
- if (pn_result_mask)
- *pn_result_mask = n_mask;
+ *pn_result_mask = n_mask;
return n_err_cnt; /* 0 = all ok */
}
diff --git a/drivers/net/ntnic/nthw/core/nthw_tsm.c b/drivers/net/ntnic/nthw/core/nthw_tsm.c
index b88dcb9b0b..a748c4e1ae 100644
--- a/drivers/net/ntnic/nthw/core/nthw_tsm.c
+++ b/drivers/net/ntnic/nthw/core/nthw_tsm.c
@@ -89,8 +89,7 @@ int nthw_tsm_get_ts(nthw_tsm_t *p, uint64_t *p_ts)
val = ((((uint64_t)n_ts_hi) << 32UL) | n_ts_lo);
- if (p_ts)
- *p_ts = val;
+ *p_ts = val;
return 0;
}
@@ -108,8 +107,7 @@ int nthw_tsm_get_time(nthw_tsm_t *p, uint64_t *p_time)
val = ((((uint64_t)n_time_hi) << 32UL) | n_time_lo);
- if (p_time)
- *p_time = val;
+ *p_time = val;
return 0;
}
diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c
index 358ea3e4fa..90fc3f51a6 100644
--- a/drivers/net/ntnic/nthw/flow_api/flow_api.c
+++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c
@@ -829,8 +829,7 @@ struct flow_nic_dev *nthw_flow_api_create(uint8_t adapter_no,
err_exit:
- if (ndev)
- nthw_flow_api_done(ndev);
+ nthw_flow_api_done(ndev);
NT_LOG(DBG, FILTER, "ERR: %s", __func__);
return NULL;
diff --git a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c
index 69dec801f2..4babc30d2b 100644
--- a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c
+++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c
@@ -834,9 +834,6 @@ int hw_mod_flm_stat_get(struct flow_api_backend_s *be, enum hw_flm_e field, uint
break;
default: {
- if (_VER_ < 18)
- return UNSUP_FIELD;
-
switch (field) {
case HW_FLM_STAT_STA_DONE:
*value = be->flm.v25.sta_done->cnt;
diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
index 6bfa471321..c674531396 100644
--- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
+++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
@@ -4267,8 +4267,6 @@ int flow_destroy_locked_profile_inline(struct flow_eth_dev *dev,
RTE_ASSERT(dev);
RTE_ASSERT(fh);
- int err = 0;
-
nthw_flow_nic_set_error(ERR_SUCCESS, error);
/* take flow out of ndev list - may not have been put there yet */
@@ -4318,11 +4316,6 @@ int flow_destroy_locked_profile_inline(struct flow_eth_dev *dev,
fh->fd = NULL;
}
- if (err) {
- NT_LOG(ERR, FILTER, "FAILED removing flow: %p", fh);
- nthw_flow_nic_set_error(ERR_REMOVE_FLOW_FAILED, error);
- }
-
free(fh);
fh = NULL;
@@ -4330,7 +4323,7 @@ int flow_destroy_locked_profile_inline(struct flow_eth_dev *dev,
dev->ndev->be.iface->set_debug_mode(dev->ndev->be.be_dev, FLOW_BACKEND_DEBUG_MODE_NONE);
#endif
- return err;
+ return 0;
}
int flow_destroy_profile_inline(struct flow_eth_dev *dev, struct flow_handle *flow,
diff --git a/drivers/net/ntnic/nthw/nthw_rac.c b/drivers/net/ntnic/nthw/nthw_rac.c
index d6fdea2ddb..13813fe516 100644
--- a/drivers/net/ntnic/nthw/nthw_rac.c
+++ b/drivers/net/ntnic/nthw/nthw_rac.c
@@ -517,13 +517,6 @@ int nthw_rac_rab_read32_dma(nthw_rac_t *p, nthw_rab_bus_id_t bus_id, uint32_t ad
return -1;
}
- if ((word_cnt + 3) > RAB_DMA_BUF_CNT) {
- NT_LOG(ERR, NTHW,
- "%s: Failed rab dma read length check - bus: %d addr: 0x%08X wordcount: %d",
- p_adapter_id_str, bus_id, address, word_cnt);
- return -1;
- }
-
if (p->m_in_free < 3) {
/*
* No more memory available.
diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c
index 87a0c3576b..e3ed22b89b 100644
--- a/drivers/net/ntnic/ntnic_ethdev.c
+++ b/drivers/net/ntnic/ntnic_ethdev.c
@@ -1375,7 +1375,6 @@ eth_dev_set_link_up(struct rte_eth_dev *eth_dev)
return 0;
RTE_ASSERT(port >= 0 && port < NUM_ADAPTER_PORTS_MAX);
- RTE_ASSERT(port == internals->n_intf_no);
port_ops->set_adm_state(p_adapter_info, port, true);
@@ -1401,7 +1400,6 @@ eth_dev_set_link_down(struct rte_eth_dev *eth_dev)
return 0;
RTE_ASSERT(port >= 0 && port < NUM_ADAPTER_PORTS_MAX);
- RTE_ASSERT(port == internals->n_intf_no);
port_ops->set_link_status(p_adapter_info, port, false);
@@ -2201,25 +2199,23 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev)
NT_LOG(DBG, NTNIC, "Meter module is not initialized");
/* Initialize the queue system */
- if (err == 0) {
- sg_ops = get_sg_ops();
-
- if (sg_ops != NULL) {
- err = sg_ops->nthw_virt_queue_init(fpga_info);
+ sg_ops = get_sg_ops();
- if (err != 0) {
- NT_LOG(ERR, NTNIC,
- "%s: Cannot initialize scatter-gather queues",
- p_nt_drv->adapter_info.mp_adapter_id_str);
+ if (sg_ops != NULL) {
+ err = sg_ops->nthw_virt_queue_init(fpga_info);
- } else {
- NT_LOG(DBG, NTNIC, "%s: Initialized scatter-gather queues",
- p_nt_drv->adapter_info.mp_adapter_id_str);
- }
+ if (err != 0) {
+ NT_LOG(ERR, NTNIC,
+ "%s: Cannot initialize scatter-gather queues",
+ p_nt_drv->adapter_info.mp_adapter_id_str);
} else {
- NT_LOG_DBGX(DBG, NTNIC, "SG module is not initialized");
+ NT_LOG(DBG, NTNIC, "%s: Initialized scatter-gather queues",
+ p_nt_drv->adapter_info.mp_adapter_id_str);
}
+
+ } else {
+ NT_LOG_DBGX(DBG, NTNIC, "SG module is not initialized");
}
/* Start ctrl, monitor, stat thread only for primary process. */
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 10/25] net/ntnic: remove unused code
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
` (8 preceding siblings ...)
2025-04-30 13:48 ` [PATCH v1 09/25] net/ntnic: remove usless expressions Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 11/25] net/ntnic: remove usless part of conditional expression Oleksandr Kolomeiets
` (14 subsequent siblings)
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas, Danylo Vodopianov
From: Danylo Vodopianov <dvo-plv@napatech.com>
Remove unused CRC calculation and simplify AVR probe logging.
The condition is always false.
Signed-off-by: Danylo Vodopianov <dvo-plv@napatech.com>
---
drivers/net/ntnic/nthw/core/nthw_fpga.c | 299 +-----------------------
1 file changed, 11 insertions(+), 288 deletions(-)
diff --git a/drivers/net/ntnic/nthw/core/nthw_fpga.c b/drivers/net/ntnic/nthw/core/nthw_fpga.c
index 8831eeb4d3..485e912912 100644
--- a/drivers/net/ntnic/nthw/core/nthw_fpga.c
+++ b/drivers/net/ntnic/nthw/core/nthw_fpga.c
@@ -152,26 +152,6 @@ int nthw_fpga_silabs_detect(nthw_fpga_t *p_fpga, const int n_instance_no, const
return res;
}
-/*
- * Calculate CRC-16-CCITT of passed data
- * CRC-16-CCITT ^16 + ^12 + ^5 + 1 (0x1021) (X.25, HDLC, XMODEM, Bluetooth,
- * SD, many others; known as CRC-CCITT)
- */
-static uint16_t crc16(uint8_t *buffer, size_t length)
-{
- uint16_t seed = 0;
-
- while (length--) {
- seed = (uint16_t)(seed >> 8 | seed << 8);
- seed = (uint16_t)(seed ^ *buffer++);
- seed = (uint16_t)(seed ^ (seed & 0xff) >> 4);
- seed = (uint16_t)(seed ^ seed << 8 << 4);
- seed = (uint16_t)(seed ^ (seed & 0xff) << 4 << 1);
- }
-
- return seed;
-}
-
int nthw_fpga_avr_probe(nthw_fpga_t *p_fpga, const int n_instance_no)
{
struct fpga_info_s *p_fpga_info = p_fpga->p_fpga_info;
@@ -314,150 +294,15 @@ int nthw_fpga_avr_probe(nthw_fpga_t *p_fpga, const int n_instance_no)
rx_buf.p_buf = &rx_data;
res = nthw_spi_v3_transfer(p_avr_spi, AVR_OP_SYSINFO_2, &tx_buf, &rx_buf);
- if (res == 0 && avr_vpd_info.n_avr_spi_version >= 3 && rx_buf.size >= 16) {
- if (rx_buf.size != 16) {
- NT_LOG(WRN, NTHW,
- "%s: AVR%d: SYSINFO2: reply is larger than expected: %04X %04X",
- p_adapter_id_str, n_instance_no, rx_buf.size, 16);
-
- } else {
- NT_LOG(DBG, NTHW, "%s: AVR%d: SYSINFO2: OK: res=%d sz=%d",
- p_adapter_id_str, n_instance_no, res, rx_buf.size);
- }
-
- avr_vpd_info.sysinfo_container_version = rx_data[0];
- NT_LOG(DBG, NTHW, "%s: AVR%d: SYSINFO_REQ_VER: %d", p_adapter_id_str,
- n_instance_no, avr_vpd_info.sysinfo_container_version);
-
- memcpy(&avr_vpd_info.sysinfo_avr_libc_version, &rx_data[0 + 1],
- sizeof(avr_vpd_info.sysinfo_avr_libc_version));
- NT_LOG(DBG, NTHW, "%s: AVR%d: LIBC_VER: %d", p_adapter_id_str,
- n_instance_no, avr_vpd_info.sysinfo_avr_libc_version);
-
- avr_vpd_info.sysinfo_signature_0 = rx_data[5];
- avr_vpd_info.sysinfo_signature_1 = rx_data[6];
- avr_vpd_info.sysinfo_signature_2 = rx_data[7];
- NT_LOG(DBG, NTHW, "%s: AVR%d: SIGNATURE: %02x%02x%02x", p_adapter_id_str,
- n_instance_no, avr_vpd_info.sysinfo_signature_0,
- avr_vpd_info.sysinfo_signature_1, avr_vpd_info.sysinfo_signature_2);
-
- avr_vpd_info.sysinfo_spi_version = rx_data[8];
- NT_LOG(DBG, NTHW, "%s: AVR%d: SPI_VER: %d", p_adapter_id_str,
- n_instance_no, avr_vpd_info.sysinfo_spi_version);
-
- avr_vpd_info.sysinfo_hw_revision = rx_data[9];
- NT_LOG(DBG, NTHW, "%s: AVR%d: HW_REV: %d", p_adapter_id_str,
- n_instance_no, avr_vpd_info.sysinfo_hw_revision);
-
- avr_vpd_info.sysinfo_ticks_per_second = rx_data[10];
- NT_LOG(DBG, NTHW, "%s: AVR%d: TICKS_PER_SEC: %d", p_adapter_id_str,
- n_instance_no, avr_vpd_info.sysinfo_ticks_per_second);
-
- memcpy(&avr_vpd_info.sysinfo_uptime, &rx_data[11],
- sizeof(avr_vpd_info.sysinfo_uptime));
- NT_LOG(DBG, NTHW, "%s: AVR%d: UPTIME: %d", p_adapter_id_str,
- n_instance_no, avr_vpd_info.sysinfo_uptime);
-
- avr_vpd_info.sysinfo_osccal = rx_data[15];
- NT_LOG(DBG, NTHW, "%s: AVR%d: OSCCAL: %d", p_adapter_id_str,
- n_instance_no, avr_vpd_info.sysinfo_osccal);
-
- {
- bool b_spi_ver_match = (avr_vpd_info.n_avr_spi_version ==
- avr_vpd_info.sysinfo_spi_version);
- (void)b_spi_ver_match;
- NT_LOG(DBG, NTHW, "%s: AVR%d: SPI_VER_TST: %s (%d %d)",
- p_adapter_id_str, n_instance_no,
- (b_spi_ver_match ? "OK" : "MISMATCH"),
- avr_vpd_info.n_avr_spi_version,
- avr_vpd_info.sysinfo_spi_version);
- }
-
- /* SYSINFO2: if response: only populate hw_id not hw_id_emulated */
- p_fpga_info->nthw_hw_info.hw_id = avr_vpd_info.sysinfo_hw_revision;
-
- } else {
- /* AVR_OP_SYSINFO */
- tx_buf.size = 0;
- tx_buf.p_buf = NULL;
- rx_buf.size = sizeof(rx_data);
- rx_buf.p_buf = &rx_data;
- res = nthw_spi_v3_transfer(p_avr_spi, AVR_OP_SYSINFO, &tx_buf, &rx_buf);
-
- if (res == 0 && avr_vpd_info.n_avr_spi_version >= 3 && rx_buf.size >= 16) {
- if (rx_buf.size != 16) {
- NT_LOG(WRN, NTHW,
- "%s: AVR%d: SYSINFO: reply is larger than expected: %04X %04X",
- p_adapter_id_str, n_instance_no, rx_buf.size, 16);
-
- } else {
- NT_LOG(DBG, NTHW, "%s: AVR%d: SYSINFO: OK: res=%d sz=%d",
- p_adapter_id_str, n_instance_no, res, rx_buf.size);
- }
-
- avr_vpd_info.sysinfo_container_version = rx_data[0];
- NT_LOG(DBG, NTHW, "%s: AVR%d: SYSINFO_REQ_VER: %d",
- p_adapter_id_str, n_instance_no,
- avr_vpd_info.sysinfo_container_version);
-
- memcpy(&avr_vpd_info.sysinfo_avr_libc_version, &rx_data[0 + 1],
- sizeof(avr_vpd_info.sysinfo_avr_libc_version));
- NT_LOG(DBG, NTHW, "%s: AVR%d: LIBC_VER: %d", p_adapter_id_str,
- n_instance_no, avr_vpd_info.sysinfo_avr_libc_version);
-
- avr_vpd_info.sysinfo_signature_0 = rx_data[5];
- avr_vpd_info.sysinfo_signature_1 = rx_data[6];
- avr_vpd_info.sysinfo_signature_2 = rx_data[7];
- NT_LOG(DBG, NTHW, "%s: AVR%d: SIGNATURE: %02x%02x%02x",
- p_adapter_id_str, n_instance_no,
- avr_vpd_info.sysinfo_signature_0,
- avr_vpd_info.sysinfo_signature_1,
- avr_vpd_info.sysinfo_signature_2);
-
- avr_vpd_info.sysinfo_spi_version = rx_data[8];
- NT_LOG(DBG, NTHW, "%s: AVR%d: SPI_VER: %d", p_adapter_id_str,
- n_instance_no, avr_vpd_info.sysinfo_spi_version);
-
- avr_vpd_info.sysinfo_hw_revision = rx_data[9];
- NT_LOG(DBG, NTHW, "%s: AVR%d: HW_REV: %d", p_adapter_id_str,
- n_instance_no, avr_vpd_info.sysinfo_hw_revision);
- NT_LOG(INF, NTHW, "%s: AVR%d: HW_REV: %d", p_adapter_id_str,
- n_instance_no, avr_vpd_info.sysinfo_hw_revision);
-
- avr_vpd_info.sysinfo_ticks_per_second = rx_data[10];
- NT_LOG(DBG, NTHW, "%s: AVR%d: TICKS_PER_SEC: %d",
- p_adapter_id_str, n_instance_no,
- avr_vpd_info.sysinfo_ticks_per_second);
-
- memcpy(&avr_vpd_info.sysinfo_uptime, &rx_data[11],
- sizeof(avr_vpd_info.sysinfo_uptime));
- NT_LOG(DBG, NTHW, "%s: AVR%d: UPTIME: %d", p_adapter_id_str,
- n_instance_no, avr_vpd_info.sysinfo_uptime);
-
- avr_vpd_info.sysinfo_osccal = rx_data[15];
- NT_LOG(DBG, NTHW, "%s: AVR%d: OSCCAL: %d", p_adapter_id_str,
- n_instance_no, avr_vpd_info.sysinfo_osccal);
-
- {
- bool b_spi_ver_match = (avr_vpd_info.n_avr_spi_version ==
- avr_vpd_info.sysinfo_spi_version);
- (void)b_spi_ver_match;
- NT_LOG(DBG, NTHW, "%s: AVR%d: SPI_VER_TST: %s (%d %d)",
- p_adapter_id_str, n_instance_no,
- (b_spi_ver_match ? "OK" : "MISMATCH"),
- avr_vpd_info.n_avr_spi_version,
- avr_vpd_info.sysinfo_spi_version);
- }
-
- p_fpga_info->nthw_hw_info.hw_id = avr_vpd_info.sysinfo_hw_revision;
- p_fpga_info->nthw_hw_info.hw_id_emulated =
- avr_vpd_info.sysinfo_hw_revision;
+ /* AVR_OP_SYSINFO */
+ tx_buf.size = 0;
+ tx_buf.p_buf = NULL;
+ rx_buf.size = sizeof(rx_data);
+ rx_buf.p_buf = &rx_data;
+ res = nthw_spi_v3_transfer(p_avr_spi, AVR_OP_SYSINFO, &tx_buf, &rx_buf);
- } else {
- NT_LOG(ERR, NTHW, "%s: AVR%d: SYSINFO: NA: res=%d sz=%d",
- p_adapter_id_str, n_instance_no, res, rx_buf.size);
- }
- }
+ NT_LOG(ERR, NTHW, "%s: AVR%d: SYSINFO: NA: res=%d sz=%d",
+ p_adapter_id_str, n_instance_no, res, rx_buf.size);
/* AVR_OP_VPD_READ */
tx_buf.size = 0;
@@ -466,132 +311,10 @@ int nthw_fpga_avr_probe(nthw_fpga_t *p_fpga, const int n_instance_no)
rx_buf.p_buf = &rx_data;
res = nthw_spi_v3_transfer(p_avr_spi, AVR_OP_VPD_READ, &tx_buf, &rx_buf);
- if (res == 0 && avr_vpd_info.n_avr_spi_version >= 3 &&
- rx_buf.size >= GEN2_VPD_SIZE_TOTAL) {
- avr_vpd_info.n_crc16_calced = crc16(rx_buf.p_buf, rx_buf.size - 2);
- memcpy(&avr_vpd_info.n_crc16_stored, &rx_data[rx_buf.size - 2],
- sizeof(avr_vpd_info.n_crc16_stored));
- NT_LOG(DBG, NTHW, "%s: AVR%d: VPD_CRC: %04X %04X", p_adapter_id_str,
- n_instance_no, avr_vpd_info.n_crc16_stored,
- avr_vpd_info.n_crc16_calced);
-
- avr_vpd_info.b_crc16_valid =
- (avr_vpd_info.n_crc16_stored == avr_vpd_info.n_crc16_calced);
- NT_LOG(DBG, NTHW, "%s: AVR%d: CRC_TST: %s", p_adapter_id_str,
- n_instance_no, (avr_vpd_info.b_crc16_valid ? "OK" : "ERROR"));
-
- if (avr_vpd_info.b_crc16_valid) {
- memcpy(&avr_vpd_info.psu_hw_version, &rx_data[0],
- sizeof(avr_vpd_info.psu_hw_version));
- NT_LOG(DBG, NTHW, "%s: AVR%d: PSU_HW_VER: %d", p_adapter_id_str,
- n_instance_no, avr_vpd_info.psu_hw_version);
-
- memcpy(&avr_vpd_info.vpd_pn, &rx_data[0 + 1],
- sizeof(avr_vpd_info.vpd_pn));
- NT_LOG(DBG, NTHW, "%s: AVR%d: PN: '%.*s'", p_adapter_id_str,
- n_instance_no, GEN2_PN_SIZE, avr_vpd_info.vpd_pn);
-
- memcpy(&avr_vpd_info.vpd_pba, &rx_data[0 + 1 + GEN2_PN_SIZE],
- sizeof(avr_vpd_info.vpd_pba));
- NT_LOG(DBG, NTHW, "%s: AVR%d: PBA: '%.*s'", p_adapter_id_str,
- n_instance_no, GEN2_PBA_SIZE, avr_vpd_info.vpd_pba);
-
- memcpy(&avr_vpd_info.vpd_sn,
- &rx_data[0 + 1 + GEN2_PN_SIZE + GEN2_PBA_SIZE],
- sizeof(avr_vpd_info.vpd_sn));
- NT_LOG(DBG, NTHW, "%s: AVR%d: SN: '%.*s", p_adapter_id_str,
- n_instance_no, GEN2_SN_SIZE, avr_vpd_info.vpd_sn);
-
- memcpy(&avr_vpd_info.vpd_board_name,
- &rx_data[0 + 1 + GEN2_PN_SIZE + GEN2_PBA_SIZE +
- GEN2_SN_SIZE],
- sizeof(avr_vpd_info.vpd_board_name));
- NT_LOG(DBG, NTHW, "%s: AVR%d: BN: '%.*s'", p_adapter_id_str,
- n_instance_no, GEN2_BNAME_SIZE,
- avr_vpd_info.vpd_board_name);
-
- union mac_u {
- uint8_t a_u8[8];
- uint16_t a_u16[4];
- uint32_t a_u32[2];
- uint64_t a_u64[1];
- } mac;
-
- /* vpd_platform_section */
- uint8_t *p_vpd_board_info =
- (uint8_t *)(&rx_data[1 + GEN2_PN_SIZE + GEN2_PBA_SIZE +
- GEN2_SN_SIZE + GEN2_BNAME_SIZE]);
- memcpy(&avr_vpd_info.product_family, &p_vpd_board_info[0],
- sizeof(avr_vpd_info.product_family));
- NT_LOG(DBG, NTHW, "%s: AVR%d: PROD_FAM: %d", p_adapter_id_str,
- n_instance_no, avr_vpd_info.product_family);
-
- memcpy(&avr_vpd_info.feature_mask, &p_vpd_board_info[0 + 4],
- sizeof(avr_vpd_info.feature_mask));
- NT_LOG(DBG, NTHW, "%s: AVR%d: FMSK_VAL: 0x%08X",
- p_adapter_id_str, n_instance_no, avr_vpd_info.feature_mask);
-
- memcpy(&avr_vpd_info.invfeature_mask, &p_vpd_board_info[0 + 4 + 4],
- sizeof(avr_vpd_info.invfeature_mask));
- NT_LOG(DBG, NTHW, "%s: AVR%d: FMSK_INV: 0x%08X",
- p_adapter_id_str, n_instance_no,
- avr_vpd_info.invfeature_mask);
-
- avr_vpd_info.b_feature_mask_valid =
- (avr_vpd_info.feature_mask ==
- ~avr_vpd_info.invfeature_mask);
- NT_LOG(DBG, NTHW, "%s: AVR%d: FMSK_TST: %s", p_adapter_id_str,
- n_instance_no,
- (avr_vpd_info.b_feature_mask_valid ? "OK" : "ERROR"));
-
- memcpy(&avr_vpd_info.no_of_macs, &p_vpd_board_info[0 + 4 + 4 + 4],
- sizeof(avr_vpd_info.no_of_macs));
- NT_LOG(DBG, NTHW, "%s: AVR%d: NUM_MACS: %d", p_adapter_id_str,
- n_instance_no, avr_vpd_info.no_of_macs);
-
- memcpy(&avr_vpd_info.mac_address,
- &p_vpd_board_info[0 + 4 + 4 + 4 + 1],
- sizeof(avr_vpd_info.mac_address));
- NT_LOG(DBG, NTHW,
- "%s: AVR%d: MAC_ADDR: %02x:%02x:%02x:%02x:%02x:%02x",
- p_adapter_id_str, n_instance_no,
- avr_vpd_info.mac_address[0], avr_vpd_info.mac_address[1],
- avr_vpd_info.mac_address[2], avr_vpd_info.mac_address[3],
- avr_vpd_info.mac_address[4], avr_vpd_info.mac_address[5]);
-
- mac.a_u64[0] = 0;
- memcpy(&mac.a_u8[2], &avr_vpd_info.mac_address,
- sizeof(avr_vpd_info.mac_address));
- {
- const uint32_t u1 = ntohl(mac.a_u32[0]);
-
- if (u1 != mac.a_u32[0]) {
- const uint32_t u0 = ntohl(mac.a_u32[1]);
- mac.a_u32[0] = u0;
- mac.a_u32[1] = u1;
- }
- }
-
- avr_vpd_info.n_mac_val = mac.a_u64[0];
- NT_LOG(DBG, NTHW, "%s: AVR%d: MAC_U64: %012" PRIX64 "",
- p_adapter_id_str, n_instance_no, avr_vpd_info.n_mac_val);
- }
-
- p_fpga_info->nthw_hw_info.vpd_info.mn_mac_addr_count =
- avr_vpd_info.no_of_macs;
- p_fpga_info->nthw_hw_info.vpd_info.mn_mac_addr_value =
- avr_vpd_info.n_mac_val;
- memcpy(p_fpga_info->nthw_hw_info.vpd_info.ma_mac_addr_octets,
- avr_vpd_info.mac_address,
- ARRAY_SIZE(p_fpga_info->nthw_hw_info.vpd_info.ma_mac_addr_octets));
-
- } else {
- NT_LOG(ERR, NTHW, "%s:%u: res=%d", __func__, __LINE__, res);
- NT_LOG(ERR, NTHW, "%s: AVR%d: SYSINFO2: NA: res=%d sz=%d",
- p_adapter_id_str, n_instance_no, res, rx_buf.size);
- }
+ NT_LOG(ERR, NTHW, "%s:%u: res=%d", __func__, __LINE__, res);
+ NT_LOG(ERR, NTHW, "%s: AVR%d: SYSINFO2: NA: res=%d sz=%d",
+ p_adapter_id_str, n_instance_no, res, rx_buf.size);
}
-
return res;
}
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 11/25] net/ntnic: remove usless part of conditional expression
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
` (9 preceding siblings ...)
2025-04-30 13:48 ` [PATCH v1 10/25] net/ntnic: remove unused code Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 12/25] net/ntnic: add error logging for hsh Oleksandr Kolomeiets
` (13 subsequent siblings)
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas, Danylo Vodopianov
From: Danylo Vodopianov <dvo-plv@napatech.com>
The conditional expressions that always has unchanging state was removed
Signed-off-by: Danylo Vodopianov <dvo-plv@napatech.com>
---
drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c | 2 +-
drivers/net/ntnic/nthw/core/nthw_fpga.c | 4 +---
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c b/drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c
index dde185c62f..43b3c5a41f 100644
--- a/drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c
+++ b/drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c
@@ -672,7 +672,7 @@ static int nt4ga_link_100g_ports_init(struct adapter_info_s *p_adapter_info, nth
*/
RTE_ASSERT(adapter_no >= 0 && adapter_no < NUM_ADAPTER_MAX);
- if (res == 0 && !p_adapter_info->nt4ga_link.variables_initialized) {
+ if (!p_adapter_info->nt4ga_link.variables_initialized) {
nthw_mac_pcs_t *mac_pcs = p_adapter_info->nt4ga_link.u.var100g.mac_pcs100g;
nim_i2c_ctx_t *nim_ctx = p_adapter_info->nt4ga_link.u.var100g.nim_ctx;
nthw_gpio_phy_t *gpio_phy = p_adapter_info->nt4ga_link.u.var100g.gpio_phy;
diff --git a/drivers/net/ntnic/nthw/core/nthw_fpga.c b/drivers/net/ntnic/nthw/core/nthw_fpga.c
index 485e912912..47f4b4e7b1 100644
--- a/drivers/net/ntnic/nthw/core/nthw_fpga.c
+++ b/drivers/net/ntnic/nthw/core/nthw_fpga.c
@@ -550,10 +550,8 @@ int nthw_fpga_shutdown(struct fpga_info_s *p_fpga_info)
{
int res = -1;
- if (p_fpga_info) {
- if (p_fpga_info && p_fpga_info->mp_nthw_rac)
+ if (p_fpga_info->mp_nthw_rac)
res = nthw_rac_rab_reset(p_fpga_info->mp_nthw_rac);
- }
return res;
}
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 12/25] net/ntnic: add error logging for hsh
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
` (10 preceding siblings ...)
2025-04-30 13:48 ` [PATCH v1 11/25] net/ntnic: remove usless part of conditional expression Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 13/25] net/ntnic: add explicitly specificator Oleksandr Kolomeiets
` (12 subsequent siblings)
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas, Danylo Vodopianov
From: Danylo Vodopianov <dvo-plv@napatech.com>
Enhance error logging in hw_db_inline_hsh_deref function to ensure proper
handling of HSH RCP preset failures.
Signed-off-by: Danylo Vodopianov <dvo-plv@napatech.com>
---
.../nthw/flow_api/profile_inline/flow_api_hw_db_inline.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c
index fbb7b04cd1..52ca79f104 100644
--- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c
+++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c
@@ -10,6 +10,7 @@
#include "flow_api_hw_db_inline.h"
#include "flow_api_profile_inline_config.h"
#include "flow_hsh_cfg.h"
+#include "ntlog.h"
#define HW_DB_INLINE_ACTION_SET_NB 512
#define HW_DB_INLINE_MATCH_SET_NB 512
@@ -2914,7 +2915,9 @@ void hw_db_inline_hsh_deref(struct flow_nic_dev *ndev, void *db_handle, struct h
* it is not used by any flow
*/
if (idx.ids > 0) {
- hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_PRESET_ALL, idx.ids, 0, 0x0);
+ int res = hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_PRESET_ALL,
+ idx.ids, 0, 0x0);
+ NT_LOG(ERR, FILTER, "Failed to preset HSH RCP %u: %d", idx.ids, res);
hw_mod_hsh_rcp_flush(&ndev->be, idx.ids, 1);
memset(&db->hsh[idx.ids].data, 0x0, sizeof(struct hw_db_inline_hsh_data));
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 13/25] net/ntnic: add explicitly specificator
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
` (11 preceding siblings ...)
2025-04-30 13:48 ` [PATCH v1 12/25] net/ntnic: add error logging for hsh Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 14/25] net/ntnic: add handle memory allocation failures Oleksandr Kolomeiets
` (11 subsequent siblings)
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas, Danylo Vodopianov
From: Danylo Vodopianov <dvo-plv@napatech.com>
Add unsigned long long type to the value to ensure that
the value 1 is explicitly treated as a 64-bit unsigned integer.
Signed-off-by: Danylo Vodopianov <dvo-plv@napatech.com>
---
.../nthw/flow_api/profile_inline/flow_api_profile_inline.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
index c674531396..3fb867c993 100644
--- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
+++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
@@ -114,7 +114,7 @@ static inline uint64_t convert_policing_parameter(uint64_t value)
}
if (shift != 0) {
- uint64_t tmp = POLICING_PARAMETER_OFFSET * (1 << (shift - 1));
+ uint64_t tmp = POLICING_PARAMETER_OFFSET * (1ULL << (shift - 1ULL));
if (tmp > value) {
res = 0;
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 14/25] net/ntnic: add handle memory allocation failures
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
` (12 preceding siblings ...)
2025-04-30 13:48 ` [PATCH v1 13/25] net/ntnic: add explicitly specificator Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 15/25] net/ntnic: remove redundant initialization Oleksandr Kolomeiets
` (10 subsequent siblings)
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas, Danylo Vodopianov
From: Danylo Vodopianov <dvo-plv@napatech.com>
Added checks for `calloc` return values to handle memory
allocation failures.
Check for null in rpp_lr_nthw_init
Signed-off-by: Danylo Vodopianov <dvo-plv@napatech.com>
---
drivers/net/ntnic/nthw/flow_api/flow_group.c | 17 ++++++++++--
drivers/net/ntnic/nthw/flow_api/flow_km.c | 4 +++
.../profile_inline/flow_api_profile_inline.c | 26 +++++++++++++++++++
.../ntnic/nthw/flow_filter/flow_nthw_rpp_lr.c | 3 ++-
4 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ntnic/nthw/flow_api/flow_group.c b/drivers/net/ntnic/nthw/flow_api/flow_group.c
index 6e010c1b9e..f2c9bcaaa5 100644
--- a/drivers/net/ntnic/nthw/flow_api/flow_group.c
+++ b/drivers/net/ntnic/nthw/flow_api/flow_group.c
@@ -30,14 +30,27 @@ int nthw_flow_group_handle_create(void **handle, uint32_t group_count)
struct group_handle_s *group_handle;
*handle = calloc(1, sizeof(struct group_handle_s));
+ if (*handle == NULL)
+ return -1;
+
group_handle = *handle;
- group_handle->group_count = group_count;
group_handle->translation_table =
calloc((uint32_t)(group_count * PORT_COUNT * OWNER_ID_COUNT), sizeof(uint32_t));
group_handle->lookup_entries = calloc(group_count, sizeof(struct group_lookup_entry_s));
- return *handle != NULL ? 0 : -1;
+ if (group_handle->lookup_entries == NULL ||
+ group_handle->translation_table == NULL) {
+ free(group_handle->lookup_entries);
+ free(group_handle->translation_table);
+ free(*handle);
+ *handle = NULL;
+ return -1;
+ }
+
+ group_handle->group_count = group_count;
+
+ return 0;
}
int nthw_flow_group_handle_destroy(void **handle)
diff --git a/drivers/net/ntnic/nthw/flow_api/flow_km.c b/drivers/net/ntnic/nthw/flow_api/flow_km.c
index 7b0fdddeea..9c76e8639c 100644
--- a/drivers/net/ntnic/nthw/flow_api/flow_km.c
+++ b/drivers/net/ntnic/nthw/flow_api/flow_km.c
@@ -84,6 +84,10 @@ void km_attach_ndev_resource_management(struct km_flow_def_s *km, void **handle)
*handle = calloc(1,
(size_t)CAM_ENTRIES + sizeof(uint32_t) + (size_t)TCAM_ENTRIES +
sizeof(struct hasher_s));
+ if (!*handle) {
+ NT_LOG(ERR, FILTER, "Failed to allocate CAM and TCAM record manager");
+ return;
+ }
NT_LOG(DBG, FILTER, "Allocate NIC DEV CAM and TCAM record manager");
}
diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
index 3fb867c993..5bf8a9a3ea 100644
--- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
+++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
@@ -3476,6 +3476,12 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n
{
struct flow_handle *fh = calloc(1, sizeof(struct flow_handle));
+ if (fh == NULL) {
+ error->type = RTE_FLOW_ERROR_TYPE_UNSPECIFIED;
+ error->message = "Failed to allocate flow_handle";
+ goto error_out;
+ }
+
fh->type = FLOW_HANDLE_TYPE_FLOW;
fh->port_id = port_id;
fh->dev = dev;
@@ -4929,6 +4935,13 @@ struct flow_pattern_template *flow_pattern_template_create_profile_inline(struct
struct flow_pattern_template *template = calloc(1, sizeof(struct flow_pattern_template));
+ if (template == NULL) {
+ error->type = RTE_FLOW_ERROR_TYPE_UNSPECIFIED;
+ error->message = "Failed to allocate actions_template";
+ free(fd);
+ return NULL;
+ }
+
template->fd = fd;
return template;
@@ -4994,6 +5007,13 @@ flow_actions_template_create_profile_inline(struct flow_eth_dev *dev,
struct flow_actions_template *template = calloc(1, sizeof(struct flow_actions_template));
+ if (template == NULL) {
+ error->type = RTE_FLOW_ERROR_TYPE_UNSPECIFIED;
+ error->message = "Failed to allocate actions_template";
+ free(fd);
+ return NULL;
+ }
+
template->fd = fd;
template->num_dest_port = num_dest_port;
template->num_queues = num_queues;
@@ -5266,6 +5286,12 @@ struct flow_handle *flow_async_create_profile_inline(struct flow_eth_dev *dev,
if (fh == NULL && status == CELL_STATUS_INITIALIZED_TYPE_FLM) {
fh = calloc(1, sizeof(struct flow_handle));
+ if (fh == NULL) {
+ error->type = RTE_FLOW_ERROR_TYPE_UNSPECIFIED;
+ error->message = "Failed to allocate flow_handle";
+ goto err_exit;
+ }
+
fh->type = FLOW_HANDLE_TYPE_FLM;
fh->dev = dev;
fh->caller_id = template_table->caller_id;
diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_rpp_lr.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_rpp_lr.c
index 12d9f27e20..99245bddaf 100644
--- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_rpp_lr.c
+++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_rpp_lr.c
@@ -62,7 +62,8 @@ int rpp_lr_nthw_init(struct rpp_lr_nthw *p, nthw_fpga_t *p_fpga, int n_instance)
p->mp_rcp_data = nthw_module_get_register(p->m_rpp_lr, RPP_LR_RCP_DATA);
p->mp_rcp_data_exp = nthw_register_get_field(p->mp_rcp_data, RPP_LR_RCP_DATA_EXP);
- p->mp_ifr_rcp_ctrl = nthw_module_query_register(p->m_rpp_lr, RPP_LR_IFR_RCP_CTRL);
+ if (p->m_rpp_lr)
+ p->mp_ifr_rcp_ctrl = nthw_module_query_register(p->m_rpp_lr, RPP_LR_IFR_RCP_CTRL);
p->mp_ifr_rcp_addr =
nthw_register_query_field(p->mp_ifr_rcp_ctrl, RPP_LR_IFR_RCP_CTRL_ADR);
p->mp_ifr_rcp_cnt = nthw_register_query_field(p->mp_ifr_rcp_ctrl, RPP_LR_IFR_RCP_CTRL_CNT);
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 15/25] net/ntnic: remove redundant initialization
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
` (13 preceding siblings ...)
2025-04-30 13:48 ` [PATCH v1 14/25] net/ntnic: add handle memory allocation failures Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 16/25] net/ntnic: enhance null checks and assertions Oleksandr Kolomeiets
` (9 subsequent siblings)
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas, Danylo Vodopianov
From: Danylo Vodopianov <dvo-plv@napatech.com>
Some variables set twice in the code.
Fix host side FEC enablement
Signed-off-by: Danylo Vodopianov <dvo-plv@napatech.com>
---
drivers/net/ntnic/nim/i2c_nim.c | 2 +-
drivers/net/ntnic/nthw/core/nthw_phy_tile.c | 1 -
drivers/net/ntnic/ntnic_vfio.c | 1 -
3 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/net/ntnic/nim/i2c_nim.c b/drivers/net/ntnic/nim/i2c_nim.c
index 5e8eeb16a7..c6fa75e13a 100644
--- a/drivers/net/ntnic/nim/i2c_nim.c
+++ b/drivers/net/ntnic/nim/i2c_nim.c
@@ -877,7 +877,7 @@ bool nthw_qsfp28_set_fec_enable(nim_i2c_ctx_p ctx, bool media_side_fec, bool hos
write_data_lin(ctx, addr, sizeof(data), &data);
ctx->specific_u.qsfp.specific_u.qsfp28.media_side_fec_ena = media_side_fec;
- ctx->specific_u.qsfp.specific_u.qsfp28.media_side_fec_ena = host_side_fec;
+ ctx->specific_u.qsfp.specific_u.qsfp28.host_side_fec_ena = host_side_fec;
return true;
}
diff --git a/drivers/net/ntnic/nthw/core/nthw_phy_tile.c b/drivers/net/ntnic/nthw/core/nthw_phy_tile.c
index 77400d2514..5b2af77f7d 100644
--- a/drivers/net/ntnic/nthw/core/nthw_phy_tile.c
+++ b/drivers/net/ntnic/nthw/core/nthw_phy_tile.c
@@ -797,7 +797,6 @@ static uint32_t nthw_phy_tile_cpi_request(nthw_phy_tile_t *p, uint8_t intf_no, u
/* Find quad lane */
quad_lane = nthw_phy_tile_read_xcvr(p, intf_no, lane, 0xFFFFC) & 0x3;
- xcvr_instance = lane;
lane_offset = (uint32_t)(lane << 20);
cpi_cmd = (data << 16) | cpi_assert | cpi_set_get | (quad_lane << 8) | op_code;
diff --git a/drivers/net/ntnic/ntnic_vfio.c b/drivers/net/ntnic/ntnic_vfio.c
index a62234353b..8d955e8342 100644
--- a/drivers/net/ntnic/ntnic_vfio.c
+++ b/drivers/net/ntnic/ntnic_vfio.c
@@ -68,7 +68,6 @@ nt_vfio_setup(struct rte_pci_device *dev)
vfio->dev_fd = -1;
vfio->group_fd = -1;
- vfio->container_fd = -1;
vfio->iova_addr = START_VF_IOVA;
rte_pci_device_name(&dev->addr, devname, RTE_DEV_NAME_MAX_LEN);
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 16/25] net/ntnic: enhance null checks and assertions
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
` (14 preceding siblings ...)
2025-04-30 13:48 ` [PATCH v1 15/25] net/ntnic: remove redundant initialization Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 17/25] net/ntnic: add return value check Oleksandr Kolomeiets
` (8 subsequent siblings)
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas, Danylo Vodopianov
From: Danylo Vodopianov <dvo-plv@napatech.com>
Avoid usage before check
Signed-off-by: Danylo Vodopianov <dvo-plv@napatech.com>
---
drivers/net/ntnic/adapter/nt4ga_stat/nt4ga_stat.c | 4 ++--
drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c | 4 ++--
.../net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c | 2 +-
.../link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c | 3 ++-
.../nthw/core/nt400dxx/reset/nthw_fpga_rst_nt400dxx.c | 4 ++--
drivers/net/ntnic/nthw/core/nthw_fpga.c | 3 +--
drivers/net/ntnic/ntnic_ethdev.c | 5 +++++
drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 11 ++++++-----
8 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/drivers/net/ntnic/adapter/nt4ga_stat/nt4ga_stat.c b/drivers/net/ntnic/adapter/nt4ga_stat/nt4ga_stat.c
index 0ea40fdf42..ff83ba69f7 100644
--- a/drivers/net/ntnic/adapter/nt4ga_stat/nt4ga_stat.c
+++ b/drivers/net/ntnic/adapter/nt4ga_stat/nt4ga_stat.c
@@ -246,7 +246,7 @@ static int nt4ga_stat_collect_cap_v1_stats(struct adapter_info_s *p_adapter_info
(void)p_adapter_info;
const struct flow_filter_ops *flow_filter_ops = get_flow_filter_ops();
- if (flow_filter_ops == NULL)
+ if (flow_filter_ops == NULL || p_nt4ga_stat == NULL)
return -1;
nthw_stat_t *p_nthw_stat = p_nt4ga_stat->mp_nthw_stat;
@@ -256,7 +256,7 @@ static int nt4ga_stat_collect_cap_v1_stats(struct adapter_info_s *p_adapter_info
const int n_tx_ports = p_nt4ga_stat->mn_tx_ports;
int c, h, p;
- if (!p_nthw_stat || !p_nt4ga_stat)
+ if (p_nthw_stat == NULL)
return -1;
if (p_nthw_stat->mn_stat_layout_version < 6) {
diff --git a/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c b/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c
index c9a0580391..bb775c052c 100644
--- a/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c
+++ b/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c
@@ -592,11 +592,11 @@ static int nthw_release_mngd_rx_virt_queue(struct nthw_virt_queue *rxvq)
static int dbs_internal_release_tx_virt_queue(struct nthw_virt_queue *txvq)
{
- nthw_dbs_t *p_nthw_dbs = txvq->mp_nthw_dbs;
-
if (txvq == NULL)
return -1;
+ nthw_dbs_t *p_nthw_dbs = txvq->mp_nthw_dbs;
+
/* Clear UW */
txvq->used_struct_phys_addr = NULL;
diff --git a/drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c b/drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c
index 43b3c5a41f..ed9dabe27c 100644
--- a/drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c
+++ b/drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c
@@ -256,11 +256,11 @@ static int _create_nim(adapter_info_t *drv, int port, bool enable)
nim_i2c_ctx_t *nim_ctx;
sfp_nim_state_t nim;
nt4ga_link_t *link_info = &drv->nt4ga_link;
- nthw_mac_pcs_t *mac_pcs = &link_info->u.var100g.mac_pcs100g[port];
RTE_ASSERT(port >= 0 && port < NUM_ADAPTER_PORTS_MAX);
RTE_ASSERT(link_info->variables_initialized);
+ nthw_mac_pcs_t *mac_pcs = &link_info->u.var100g.mac_pcs100g[port];
gpio_phy = &link_info->u.var100g.gpio_phy[port];
nim_ctx = &link_info->u.var100g.nim_ctx[port];
diff --git a/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c b/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c
index 4f6be900fd..64db55f6e9 100644
--- a/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c
+++ b/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c
@@ -519,11 +519,12 @@ static int create_nim(adapter_info_t *drv, int port, bool enable)
const uint8_t valid_nim_id = NT_NIM_QSFP28;
sfp_nim_state_t nim;
nt4ga_link_t *link_info = &drv->nt4ga_link;
- nim_i2c_ctx_t *nim_ctx = &link_info->u.nim_ctx[port];
RTE_ASSERT(port >= 0 && port < NUM_ADAPTER_PORTS_MAX);
RTE_ASSERT(link_info->variables_initialized);
+ nim_i2c_ctx_t *nim_ctx = &link_info->u.nim_ctx[port];
+
if (!enable) {
phy_reset_rx(drv, port);
phy_reset_tx(drv, port);
diff --git a/drivers/net/ntnic/nthw/core/nt400dxx/reset/nthw_fpga_rst_nt400dxx.c b/drivers/net/ntnic/nthw/core/nt400dxx/reset/nthw_fpga_rst_nt400dxx.c
index 237c19bb95..d9c4281eeb 100644
--- a/drivers/net/ntnic/nthw/core/nt400dxx/reset/nthw_fpga_rst_nt400dxx.c
+++ b/drivers/net/ntnic/nthw/core/nt400dxx/reset/nthw_fpga_rst_nt400dxx.c
@@ -182,6 +182,8 @@ static int nthw_fpga_rst_nt400dxx_init(struct fpga_info_s *p_fpga_info)
static int nthw_fpga_rst_nt400dxx_reset(struct fpga_info_s *p_fpga_info)
{
+ RTE_ASSERT(p_fpga_info);
+
const char *const p_adapter_id_str = p_fpga_info->mp_adapter_id_str;
nthw_fpga_t *p_fpga = NULL;
int res = -1;
@@ -191,8 +193,6 @@ static int nthw_fpga_rst_nt400dxx_reset(struct fpga_info_s *p_fpga_info)
nthw_pcm_nt400dxx_t *p_pcm = p_fpga_info->mp_nthw_agx.p_pcm;
nthw_prm_nt400dxx_t *p_prm = p_fpga_info->mp_nthw_agx.p_prm;
- RTE_ASSERT(p_fpga_info);
-
NT_LOG(DBG, NTHW, "%s: %s: BEGIN", p_adapter_id_str, __PRETTY_FUNCTION__);
/* Create Phy Tile module */
diff --git a/drivers/net/ntnic/nthw/core/nthw_fpga.c b/drivers/net/ntnic/nthw/core/nthw_fpga.c
index 47f4b4e7b1..b74a1607fd 100644
--- a/drivers/net/ntnic/nthw/core/nthw_fpga.c
+++ b/drivers/net/ntnic/nthw/core/nthw_fpga.c
@@ -343,6 +343,7 @@ int nthw_fpga_si5340_clock_synth_init_fmt2(nthw_fpga_t *p_fpga, const uint8_t n_
int nthw_fpga_init(struct fpga_info_s *p_fpga_info)
{
+ RTE_ASSERT(p_fpga_info);
const char *const p_adapter_id_str = p_fpga_info->mp_adapter_id_str;
nthw_hif_t *p_nthw_hif = NULL;
@@ -359,8 +360,6 @@ int nthw_fpga_init(struct fpga_info_s *p_fpga_info)
int res = 0;
- RTE_ASSERT(p_fpga_info);
-
{
const uint64_t n_fpga_ident = nthw_fpga_read_ident(p_fpga_info);
const uint32_t n_fpga_build_time = nthw_fpga_read_buildtime(p_fpga_info);
diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c
index e3ed22b89b..a8ea7ee140 100644
--- a/drivers/net/ntnic/ntnic_ethdev.c
+++ b/drivers/net/ntnic/ntnic_ethdev.c
@@ -332,6 +332,11 @@ eth_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *dev_info
struct pmd_internals *internals = eth_dev->data->dev_private;
+ if (internals == NULL) {
+ NT_LOG(ERR, NTNIC, "PMD-specific private data not initialized");
+ return -1;
+ }
+
const int n_intf_no = internals->n_intf_no;
struct adapter_info_s *p_adapter_info = &internals->p_drv->ntdrv.adapter_info;
diff --git a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c
index 551979cf0f..5757c7c13c 100644
--- a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c
+++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c
@@ -478,11 +478,6 @@ static int convert_flow(struct rte_eth_dev *eth_dev,
struct rte_flow_error *error)
{
struct pmd_internals *internals = eth_dev->data->dev_private;
- struct fpga_info_s *fpga_info = &internals->p_drv->ntdrv.adapter_info.fpga_info;
-
- error->type = RTE_FLOW_ERROR_TYPE_NONE;
- error->message = "none";
- uint32_t queue_offset = 0;
if (!internals) {
rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -490,6 +485,12 @@ static int convert_flow(struct rte_eth_dev *eth_dev,
return -1;
}
+ struct fpga_info_s *fpga_info = &internals->p_drv->ntdrv.adapter_info.fpga_info;
+
+ error->type = RTE_FLOW_ERROR_TYPE_NONE;
+ error->message = "none";
+ uint32_t queue_offset = 0;
+
if (internals->type == PORT_TYPE_OVERRIDE && internals->vpq_nb_vq > 0) {
/*
* The queues coming from the main PMD will always start from 0
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 17/25] net/ntnic: add return value check
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
` (15 preceding siblings ...)
2025-04-30 13:48 ` [PATCH v1 16/25] net/ntnic: enhance null checks and assertions Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 18/25] net/ntnic: remove redundant assignments and branching Oleksandr Kolomeiets
` (7 subsequent siblings)
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas, Danylo Vodopianov
From: Danylo Vodopianov <dvo-plv@napatech.com>
Add separate return value verification and logs for function.
Signed-off-by: Danylo Vodopianov <dvo-plv@napatech.com>
---
.../nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c b/drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c
index 3528792845..cc6f7d13b5 100644
--- a/drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c
+++ b/drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c
@@ -528,7 +528,16 @@ static int nthw_fpga_rst_nt200a0x_init(struct fpga_info_s *p_fpga_info,
nthw_rac_rab_setup(p_fpga_info->mp_nthw_rac);
res = nthw_fpga_iic_scan(p_fpga, 0, 0);
+ if (res == -1) {
+ NT_LOG(ERR, NTHW, "Failed to init iic instance %d - %d for NT200 (%d)", 0, 0, res);
+ return -1;
+ }
+
res = nthw_fpga_iic_scan(p_fpga, 2, 3);
+ if (res == -1) {
+ NT_LOG(ERR, NTHW, "Failed to init iic instance %d - %d for NT200 (%d)", 2, 3, res);
+ return -1;
+ }
/*
* Detect clock synth model
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 18/25] net/ntnic: remove redundant assignments and branching
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
` (16 preceding siblings ...)
2025-04-30 13:48 ` [PATCH v1 17/25] net/ntnic: add return value check Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 19/25] net/ntnic: rework array usage Oleksandr Kolomeiets
` (6 subsequent siblings)
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas, Danylo Vodopianov
From: Danylo Vodopianov <dvo-plv@napatech.com>
Remove double if statement branching as far as it has the same fillings.
Signed-off-by: Danylo Vodopianov <dvo-plv@napatech.com>
---
.../link_agx_100g/nt4ga_agx_link_100g.c | 22 ++++++-------------
.../core/nt200a0x/reset/nthw_fpga_rst9563.c | 1 -
drivers/net/ntnic/nthw/nthw_rac.c | 3 ---
drivers/net/ntnic/nthw/stat/nthw_stat.c | 1 -
4 files changed, 7 insertions(+), 20 deletions(-)
diff --git a/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c b/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c
index 64db55f6e9..6d1d01d265 100644
--- a/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c
+++ b/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c
@@ -685,21 +685,13 @@ static int nim_ready_100_gb(adapter_info_t *p_info, int port)
return 1;
}
- if (port == 0) {
- /* setTxEqualization(uint8_t intf_no, uint8_t lane, uint32_t pre_tap2,
- * uint32_t main_tap, uint32_t pre_tap1, uint32_t post_tap1)
- */
- nthw_phy_tile_set_tx_equalization(p_phy_tile, port, 0, 0, 44, 2, 9);
- nthw_phy_tile_set_tx_equalization(p_phy_tile, port, 1, 0, 44, 2, 9);
- nthw_phy_tile_set_tx_equalization(p_phy_tile, port, 2, 0, 44, 2, 9);
- nthw_phy_tile_set_tx_equalization(p_phy_tile, port, 3, 0, 44, 2, 9);
-
- } else {
- nthw_phy_tile_set_tx_equalization(p_phy_tile, port, 0, 0, 44, 2, 9);
- nthw_phy_tile_set_tx_equalization(p_phy_tile, port, 1, 0, 44, 2, 9);
- nthw_phy_tile_set_tx_equalization(p_phy_tile, port, 2, 0, 44, 2, 9);
- nthw_phy_tile_set_tx_equalization(p_phy_tile, port, 3, 0, 44, 2, 9);
- }
+ /* setTxEqualization(uint8_t intf_no, uint8_t lane, uint32_t pre_tap2,
+ * uint32_t main_tap, uint32_t pre_tap1, uint32_t post_tap1)
+ */
+ nthw_phy_tile_set_tx_equalization(p_phy_tile, port, 0, 0, 44, 2, 9);
+ nthw_phy_tile_set_tx_equalization(p_phy_tile, port, 1, 0, 44, 2, 9);
+ nthw_phy_tile_set_tx_equalization(p_phy_tile, port, 2, 0, 44, 2, 9);
+ nthw_phy_tile_set_tx_equalization(p_phy_tile, port, 3, 0, 44, 2, 9);
/*
* Perform a full reset. If the RX is in reset from the start this sequence will
diff --git a/drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c b/drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c
index 7b0c47e9b2..918ac71a43 100644
--- a/drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c
+++ b/drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c
@@ -59,7 +59,6 @@ static int nthw_fpga_rst9563_setup(nthw_fpga_t *p_fpga, struct nthw_fpga_rst_nt2
p->mp_fld_rst_mac_rx = nthw_register_get_field(p_curr_reg, RST9563_RST_MAC_RX);
p->mp_fld_rst_mac_tx = NULL;
p->mp_fld_rst_ptp = nthw_register_get_field(p_curr_reg, RST9563_RST_PTP);
- p->mp_fld_rst_ptp = nthw_register_get_field(p_curr_reg, RST9563_RST_PTP);
p->mp_fld_rst_ts = nthw_register_get_field(p_curr_reg, RST9563_RST_TS);
p->mp_fld_rst_ptp_mmcm = nthw_register_get_field(p_curr_reg, RST9563_RST_PTP_MMCM);
p->mp_fld_rst_ts_mmcm = nthw_register_get_field(p_curr_reg, RST9563_RST_TS_MMCM);
diff --git a/drivers/net/ntnic/nthw/nthw_rac.c b/drivers/net/ntnic/nthw/nthw_rac.c
index 13813fe516..33e0caa581 100644
--- a/drivers/net/ntnic/nthw/nthw_rac.c
+++ b/drivers/net/ntnic/nthw/nthw_rac.c
@@ -93,9 +93,6 @@ int nthw_rac_init(nthw_rac_t *p, nthw_fpga_t *p_fpga, struct fpga_info_s *p_fpga
if (p->mp_reg_dbg_data)
p->mp_fld_dbg_data = nthw_register_query_field(p->mp_reg_dbg_data, RAC_DBG_DATA_D);
- else
- p->mp_reg_dbg_data = NULL;
-
p->mp_reg_rab_ib_data = nthw_module_get_register(p->mp_mod_rac, RAC_RAB_IB_DATA);
p->mp_fld_rab_ib_data = nthw_register_get_field(p->mp_reg_rab_ib_data, RAC_RAB_IB_DATA_D);
diff --git a/drivers/net/ntnic/nthw/stat/nthw_stat.c b/drivers/net/ntnic/nthw/stat/nthw_stat.c
index ed30173bdc..2ddef052a5 100644
--- a/drivers/net/ntnic/nthw/stat/nthw_stat.c
+++ b/drivers/net/ntnic/nthw/stat/nthw_stat.c
@@ -254,7 +254,6 @@ int nthw_stat_init(nthw_stat_t *p, nthw_fpga_t *p_fpga, int n_instance)
p->mn_stat_layout_version = 1;
} else {
- p->mn_stat_layout_version = 0;
NT_LOG(ERR, NTHW, "%s: unknown module_version 0x%08lX layout=%d",
p_adapter_id_str, n_module_version_packed64, p->mn_stat_layout_version);
}
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 19/25] net/ntnic: rework array usage
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
` (17 preceding siblings ...)
2025-04-30 13:48 ` [PATCH v1 18/25] net/ntnic: remove redundant assignments and branching Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 20/25] net/ntnic: avoid divide by zero Oleksandr Kolomeiets
` (5 subsequent siblings)
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas, Danylo Vodopianov
From: Danylo Vodopianov <dvo-plv@napatech.com>
Array usage made more explicitly, avoid pointer arithmetic.
Signed-off-by: Danylo Vodopianov <dvo-plv@napatech.com>
---
.../ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c | 8 ++++----
drivers/net/ntnic/ntnic_ethdev.c | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c b/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c
index 6d1d01d265..75a7504510 100644
--- a/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c
+++ b/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c
@@ -908,10 +908,10 @@ static void *_common_ptp_nim_state_machine(void *data)
RTE_ASSERT(new_state.br); /* Cannot be zero if NIM is present */
NT_LOG(DBG, NTNIC,
"%s: NIM id = %u (%s), br = %u, vendor = '%s', pn = '%s', sn='%s'",
- drv->mp_port_id_str[i], nim_ctx->nim_id,
- nthw_nim_id_to_text(nim_ctx->nim_id),
- (unsigned int)new_state.br, nim_ctx->vendor_name,
- nim_ctx->prod_no, nim_ctx->serial_no);
+ drv->mp_port_id_str[i], nim_ctx[i].nim_id,
+ nthw_nim_id_to_text(nim_ctx[i].nim_id),
+ (unsigned int)new_state.br, nim_ctx[i].vendor_name,
+ nim_ctx[i].prod_no, nim_ctx[i].serial_no);
link_state[i].lh_nim_absent = false;
NT_LOG(DBG, NTNIC, "%s: NIM module initialized",
drv->mp_port_id_str[i]);
diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c
index a8ea7ee140..e46e93e347 100644
--- a/drivers/net/ntnic/ntnic_ethdev.c
+++ b/drivers/net/ntnic/ntnic_ethdev.c
@@ -379,7 +379,7 @@ static __rte_always_inline int copy_virtqueue_to_mbuf(struct rte_mbuf *mbuf,
* 1. virtqueue packets may be segmented
* 2. the mbuf size may be too small and may need to be segmented
*/
- char *data = (char *)hw_recv->addr + SG_HDR_SIZE;
+ char *data = (char *)hw_recv[src_pkt].addr + SG_HDR_SIZE;
char *dst = (char *)mbuf->buf_addr + RTE_PKTMBUF_HEADROOM;
/* set packet length */
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 20/25] net/ntnic: avoid divide by zero
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
` (18 preceding siblings ...)
2025-04-30 13:48 ` [PATCH v1 19/25] net/ntnic: rework array usage Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 21/25] net/ntnic: remove unnecessary void cast Oleksandr Kolomeiets
` (4 subsequent siblings)
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas, Danylo Vodopianov
From: Danylo Vodopianov <dvo-plv@napatech.com>
Fix CID issue 457736 divide by 0. It was avoided by
adding adittional checking on the return value
for function.
Fixes: effa04693274 ("net/ntnic: add statistics")
Signed-off-by: Danylo Vodopianov <dvo-plv@napatech.com>
---
drivers/net/ntnic/nthw/stat/nthw_stat.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/ntnic/nthw/stat/nthw_stat.c b/drivers/net/ntnic/nthw/stat/nthw_stat.c
index 2ddef052a5..9bb97bf311 100644
--- a/drivers/net/ntnic/nthw/stat/nthw_stat.c
+++ b/drivers/net/ntnic/nthw/stat/nthw_stat.c
@@ -319,6 +319,10 @@ int nthw_stat_init(nthw_stat_t *p, nthw_fpga_t *p_fpga, int n_instance)
/* Set the sliding windows size for port load */
if (p->mp_fld_load_bin) {
uint32_t rpp = nthw_fpga_get_product_param(p_fpga, NT_RPP_PER_PS, 0);
+ if (rpp == 0) {
+ NT_LOG(ERR, NTHW, "RPP has wrong value"); /* Avoid divide by 0 */
+ return -1;
+ }
uint32_t bin =
(uint32_t)(((PORT_LOAD_WINDOWS_SIZE * 1000000000000ULL) / (32ULL * rpp)) -
1ULL);
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 21/25] net/ntnic: remove unnecessary void cast
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
` (19 preceding siblings ...)
2025-04-30 13:48 ` [PATCH v1 20/25] net/ntnic: avoid divide by zero Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 22/25] net/ntnic: remove unnecessary memset Oleksandr Kolomeiets
` (3 subsequent siblings)
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas, Danylo Vodopianov
From: Danylo Vodopianov <dvo-plv@napatech.com>
There is no need to cast memset to void.
Signed-off-by: Danylo Vodopianov <dvo-plv@napatech.com>
---
drivers/net/ntnic/nim/i2c_nim.c | 2 +-
drivers/net/ntnic/nthw/flow_filter/flow_nthw_cat.c | 4 ++--
drivers/net/ntnic/nthw/flow_filter/flow_nthw_csu.c | 4 ++--
drivers/net/ntnic/nthw/flow_filter/flow_nthw_flm.c | 4 ++--
drivers/net/ntnic/nthw/flow_filter/flow_nthw_hfu.c | 4 ++--
drivers/net/ntnic/nthw/flow_filter/flow_nthw_hsh.c | 4 ++--
drivers/net/ntnic/nthw/flow_filter/flow_nthw_ifr.c | 2 +-
drivers/net/ntnic/nthw/flow_filter/flow_nthw_info.c | 4 ++--
drivers/net/ntnic/nthw/flow_filter/flow_nthw_km.c | 4 ++--
drivers/net/ntnic/nthw/flow_filter/flow_nthw_pdb.c | 4 ++--
drivers/net/ntnic/nthw/flow_filter/flow_nthw_qsl.c | 4 ++--
drivers/net/ntnic/nthw/flow_filter/flow_nthw_rpp_lr.c | 4 ++--
drivers/net/ntnic/nthw/flow_filter/flow_nthw_slc_lr.c | 4 ++--
drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_cpy.c | 4 ++--
drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_ins.c | 4 ++--
drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_rpl.c | 4 ++--
drivers/net/ntnic/ntnic_ethdev.c | 2 +-
17 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/drivers/net/ntnic/nim/i2c_nim.c b/drivers/net/ntnic/nim/i2c_nim.c
index c6fa75e13a..66729e3ab4 100644
--- a/drivers/net/ntnic/nim/i2c_nim.c
+++ b/drivers/net/ntnic/nim/i2c_nim.c
@@ -304,7 +304,7 @@ static int qsfp_nim_state_build(nim_i2c_ctx_t *ctx, sfp_nim_state_t *state)
RTE_ASSERT(ctx && state);
RTE_ASSERT(ctx->nim_id != NT_NIM_UNKNOWN && "Nim is not initialized");
- (void)memset(state, 0, sizeof(*state));
+ memset(state, 0, sizeof(*state));
switch (ctx->nim_id) {
case 12U:
diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_cat.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_cat.c
index 23139b0305..d60dae6912 100644
--- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_cat.c
+++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_cat.c
@@ -18,7 +18,7 @@ struct cat_nthw *cat_nthw_new(void)
struct cat_nthw *p = malloc(sizeof(struct cat_nthw));
if (p)
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
return p;
}
@@ -26,7 +26,7 @@ struct cat_nthw *cat_nthw_new(void)
void cat_nthw_delete(struct cat_nthw *p)
{
if (p) {
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
free(p);
}
}
diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_csu.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_csu.c
index 945d46415c..4ad169b943 100644
--- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_csu.c
+++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_csu.c
@@ -22,7 +22,7 @@ struct csu_nthw *csu_nthw_new(void)
struct csu_nthw *p = malloc(sizeof(struct csu_nthw));
if (p)
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
return p;
}
@@ -30,7 +30,7 @@ struct csu_nthw *csu_nthw_new(void)
void csu_nthw_delete(struct csu_nthw *p)
{
if (p) {
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
free(p);
}
}
diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_flm.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_flm.c
index a56d3c5038..372f735c2b 100644
--- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_flm.c
+++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_flm.c
@@ -20,7 +20,7 @@ struct flm_nthw *flm_nthw_new(void)
struct flm_nthw *p = malloc(sizeof(struct flm_nthw));
if (p)
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
return p;
}
@@ -28,7 +28,7 @@ struct flm_nthw *flm_nthw_new(void)
void flm_nthw_delete(struct flm_nthw *p)
{
if (p) {
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
free(p);
}
}
diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_hfu.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_hfu.c
index 2559f2ec77..14ad74396f 100644
--- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_hfu.c
+++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_hfu.c
@@ -22,7 +22,7 @@ struct hfu_nthw *hfu_nthw_new(void)
struct hfu_nthw *p = malloc(sizeof(struct hfu_nthw));
if (p)
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
return p;
}
@@ -30,7 +30,7 @@ struct hfu_nthw *hfu_nthw_new(void)
void hfu_nthw_delete(struct hfu_nthw *p)
{
if (p) {
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
free(p);
}
}
diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_hsh.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_hsh.c
index ab9c793e3a..f8cfa94a15 100644
--- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_hsh.c
+++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_hsh.c
@@ -23,7 +23,7 @@ struct hsh_nthw *hsh_nthw_new(void)
struct hsh_nthw *p = malloc(sizeof(struct hsh_nthw));
if (p)
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
return p;
}
@@ -31,7 +31,7 @@ struct hsh_nthw *hsh_nthw_new(void)
void hsh_nthw_delete(struct hsh_nthw *p)
{
if (p) {
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
free(p);
}
}
diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_ifr.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_ifr.c
index 418dd41a53..78835654dc 100644
--- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_ifr.c
+++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_ifr.c
@@ -22,7 +22,7 @@ struct ifr_nthw *ifr_nthw_new(void)
struct ifr_nthw *p = malloc(sizeof(struct ifr_nthw));
if (p)
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
return p;
}
diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_info.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_info.c
index 2db4411c9e..f945f33fff 100644
--- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_info.c
+++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_info.c
@@ -23,7 +23,7 @@ struct info_nthw *info_nthw_new(void)
struct info_nthw *p = malloc(sizeof(struct info_nthw));
if (p)
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
return p;
}
@@ -31,7 +31,7 @@ struct info_nthw *info_nthw_new(void)
void info_nthw_delete(struct info_nthw *p)
{
if (p) {
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
free(p);
}
}
diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_km.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_km.c
index 57471ef430..10450b3600 100644
--- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_km.c
+++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_km.c
@@ -32,7 +32,7 @@ struct km_nthw *km_nthw_new(void)
struct km_nthw *p = malloc(sizeof(struct km_nthw));
if (p)
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
return p;
}
@@ -40,7 +40,7 @@ struct km_nthw *km_nthw_new(void)
void km_nthw_delete(struct km_nthw *p)
{
if (p) {
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
free(p);
}
}
diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_pdb.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_pdb.c
index 80dc8c14c4..132ee14baf 100644
--- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_pdb.c
+++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_pdb.c
@@ -23,7 +23,7 @@ struct pdb_nthw *pdb_nthw_new(void)
struct pdb_nthw *p = malloc(sizeof(struct pdb_nthw));
if (p)
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
return p;
}
@@ -31,7 +31,7 @@ struct pdb_nthw *pdb_nthw_new(void)
void pdb_nthw_delete(struct pdb_nthw *p)
{
if (p) {
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
free(p);
}
}
diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_qsl.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_qsl.c
index cf4dc2c8eb..d2c7130f2e 100644
--- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_qsl.c
+++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_qsl.c
@@ -23,7 +23,7 @@ struct qsl_nthw *qsl_nthw_new(void)
struct qsl_nthw *p = malloc(sizeof(struct qsl_nthw));
if (p)
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
return p;
}
@@ -31,7 +31,7 @@ struct qsl_nthw *qsl_nthw_new(void)
void qsl_nthw_delete(struct qsl_nthw *p)
{
if (p) {
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
free(p);
}
}
diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_rpp_lr.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_rpp_lr.c
index 99245bddaf..1bb69e740f 100644
--- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_rpp_lr.c
+++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_rpp_lr.c
@@ -22,7 +22,7 @@ struct rpp_lr_nthw *rpp_lr_nthw_new(void)
struct rpp_lr_nthw *p = malloc(sizeof(struct rpp_lr_nthw));
if (p)
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
return p;
}
@@ -30,7 +30,7 @@ struct rpp_lr_nthw *rpp_lr_nthw_new(void)
void rpp_lr_nthw_delete(struct rpp_lr_nthw *p)
{
if (p) {
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
free(p);
}
}
diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_slc_lr.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_slc_lr.c
index 78cee7ebea..f5030d1997 100644
--- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_slc_lr.c
+++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_slc_lr.c
@@ -23,7 +23,7 @@ struct slc_lr_nthw *slc_lr_nthw_new(void)
struct slc_lr_nthw *p = malloc(sizeof(struct slc_lr_nthw));
if (p)
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
return p;
}
@@ -31,7 +31,7 @@ struct slc_lr_nthw *slc_lr_nthw_new(void)
void slc_lr_nthw_delete(struct slc_lr_nthw *p)
{
if (p) {
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
free(p);
}
}
diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_cpy.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_cpy.c
index 0ecdeb8893..bb7b9c2946 100644
--- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_cpy.c
+++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_cpy.c
@@ -22,7 +22,7 @@ struct tx_cpy_nthw *tx_cpy_nthw_new(void)
struct tx_cpy_nthw *p = malloc(sizeof(struct tx_cpy_nthw));
if (p)
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
return p;
}
@@ -31,7 +31,7 @@ void tx_cpy_nthw_delete(struct tx_cpy_nthw *p)
{
if (p) {
free(p->m_writers);
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
free(p);
}
}
diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_ins.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_ins.c
index 3ac44c6743..2409875a5a 100644
--- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_ins.c
+++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_ins.c
@@ -22,7 +22,7 @@ struct tx_ins_nthw *tx_ins_nthw_new(void)
struct tx_ins_nthw *p = malloc(sizeof(struct tx_ins_nthw));
if (p)
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
return p;
}
@@ -30,7 +30,7 @@ struct tx_ins_nthw *tx_ins_nthw_new(void)
void tx_ins_nthw_delete(struct tx_ins_nthw *p)
{
if (p) {
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
free(p);
}
}
diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_rpl.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_rpl.c
index 9dfcaa99c7..b787c38ee2 100644
--- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_rpl.c
+++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_rpl.c
@@ -22,7 +22,7 @@ struct tx_rpl_nthw *tx_rpl_nthw_new(void)
struct tx_rpl_nthw *p = malloc(sizeof(struct tx_rpl_nthw));
if (p)
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
return p;
}
@@ -30,7 +30,7 @@ struct tx_rpl_nthw *tx_rpl_nthw_new(void)
void tx_rpl_nthw_delete(struct tx_rpl_nthw *p)
{
if (p) {
- (void)memset(p, 0, sizeof(*p));
+ memset(p, 0, sizeof(*p));
free(p);
}
}
diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c
index e46e93e347..d15e1fd13b 100644
--- a/drivers/net/ntnic/ntnic_ethdev.c
+++ b/drivers/net/ntnic/ntnic_ethdev.c
@@ -1256,7 +1256,7 @@ eth_set_mc_addr_list(struct rte_eth_dev *eth_dev,
mc_addrs[i] = mc_addr_set[i];
else
- (void)memset(&mc_addrs[i], 0, sizeof(mc_addrs[i]));
+ memset(&mc_addrs[i], 0, sizeof(mc_addrs[i]));
return 0;
}
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 22/25] net/ntnic: remove unnecessary memset
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
` (20 preceding siblings ...)
2025-04-30 13:48 ` [PATCH v1 21/25] net/ntnic: remove unnecessary void cast Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 23/25] net/ntnic: add null verification Oleksandr Kolomeiets
` (2 subsequent siblings)
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas, Danylo Vodopianov
From: Danylo Vodopianov <dvo-plv@napatech.com>
Calling memset before free() has no effect and will be flagged
by security parsing tools as a potential bug. None of these data
structures have sensitive information.
Signed-off-by: Danylo Vodopianov <dvo-plv@napatech.com>
---
drivers/net/ntnic/nthw/core/nthw_hif.c | 5 +----
drivers/net/ntnic/nthw/core/nthw_iic.c | 5 +----
drivers/net/ntnic/nthw/core/nthw_pcie3.c | 5 +----
drivers/net/ntnic/nthw/core/nthw_rpf.c | 5 +----
drivers/net/ntnic/nthw/core/nthw_sdc.c | 5 +----
drivers/net/ntnic/nthw/core/nthw_si5340.c | 5 +----
drivers/net/ntnic/nthw/model/nthw_fpga_model.c | 1 -
7 files changed, 6 insertions(+), 25 deletions(-)
diff --git a/drivers/net/ntnic/nthw/core/nthw_hif.c b/drivers/net/ntnic/nthw/core/nthw_hif.c
index ddb875f625..f2d6f372b0 100644
--- a/drivers/net/ntnic/nthw/core/nthw_hif.c
+++ b/drivers/net/ntnic/nthw/core/nthw_hif.c
@@ -23,10 +23,7 @@ nthw_hif_t *nthw_hif_new(void)
void nthw_hif_delete(nthw_hif_t *p)
{
- if (p) {
- memset(p, 0, sizeof(nthw_hif_t));
- free(p);
- }
+ free(p);
}
int nthw_hif_init(nthw_hif_t *p, nthw_fpga_t *p_fpga, int n_instance)
diff --git a/drivers/net/ntnic/nthw/core/nthw_iic.c b/drivers/net/ntnic/nthw/core/nthw_iic.c
index f84eb7eeb2..a96d878f25 100644
--- a/drivers/net/ntnic/nthw/core/nthw_iic.c
+++ b/drivers/net/ntnic/nthw/core/nthw_iic.c
@@ -253,10 +253,7 @@ int nthw_iic_init(nthw_iic_t *p, nthw_fpga_t *p_fpga, int n_iic_instance,
void nthw_iic_delete(nthw_iic_t *p)
{
- if (p) {
- memset(p, 0, sizeof(nthw_iic_t));
- free(p);
- }
+ free(p);
}
int nthw_iic_set_retry_params(nthw_iic_t *p, const int n_poll_delay, const int n_bus_ready_retry,
diff --git a/drivers/net/ntnic/nthw/core/nthw_pcie3.c b/drivers/net/ntnic/nthw/core/nthw_pcie3.c
index 5928f81629..bad1c31e35 100644
--- a/drivers/net/ntnic/nthw/core/nthw_pcie3.c
+++ b/drivers/net/ntnic/nthw/core/nthw_pcie3.c
@@ -24,10 +24,7 @@ nthw_pcie3_t *nthw_pcie3_new(void)
void nthw_pcie3_delete(nthw_pcie3_t *p)
{
- if (p) {
- memset(p, 0, sizeof(nthw_pcie3_t));
- free(p);
- }
+ free(p);
}
int nthw_pcie3_init(nthw_pcie3_t *p, nthw_fpga_t *p_fpga, int n_instance)
diff --git a/drivers/net/ntnic/nthw/core/nthw_rpf.c b/drivers/net/ntnic/nthw/core/nthw_rpf.c
index 1ed4d7b4e0..d5c19e312b 100644
--- a/drivers/net/ntnic/nthw/core/nthw_rpf.c
+++ b/drivers/net/ntnic/nthw/core/nthw_rpf.c
@@ -22,10 +22,7 @@ nthw_rpf_t *nthw_rpf_new(void)
void nthw_rpf_delete(nthw_rpf_t *p)
{
- if (p) {
- memset(p, 0, sizeof(nthw_rpf_t));
- free(p);
- }
+ free(p);
}
int nthw_rpf_init(nthw_rpf_t *p, nthw_fpga_t *p_fpga, int n_instance)
diff --git a/drivers/net/ntnic/nthw/core/nthw_sdc.c b/drivers/net/ntnic/nthw/core/nthw_sdc.c
index ae967e5ed9..a7242a8a67 100644
--- a/drivers/net/ntnic/nthw/core/nthw_sdc.c
+++ b/drivers/net/ntnic/nthw/core/nthw_sdc.c
@@ -22,10 +22,7 @@ nthw_sdc_t *nthw_sdc_new(void)
void nthw_sdc_delete(nthw_sdc_t *p)
{
- if (p) {
- memset(p, 0, sizeof(nthw_sdc_t));
- free(p);
- }
+ free(p);
}
int nthw_sdc_init(nthw_sdc_t *p, nthw_fpga_t *p_fpga, int n_instance)
diff --git a/drivers/net/ntnic/nthw/core/nthw_si5340.c b/drivers/net/ntnic/nthw/core/nthw_si5340.c
index 05cadc0bf4..ceaa58e0f7 100644
--- a/drivers/net/ntnic/nthw/core/nthw_si5340.c
+++ b/drivers/net/ntnic/nthw/core/nthw_si5340.c
@@ -44,10 +44,7 @@ int nthw_si5340_init(nthw_si5340_t *p, nthw_iic_t *p_nthw_iic, uint8_t n_iic_add
void nthw_si5340_delete(nthw_si5340_t *p)
{
- if (p) {
- memset(p, 0, sizeof(nthw_si5340_t));
- free(p);
- }
+ free(p);
}
/*
diff --git a/drivers/net/ntnic/nthw/model/nthw_fpga_model.c b/drivers/net/ntnic/nthw/model/nthw_fpga_model.c
index fbaf0c2d6d..0838527716 100644
--- a/drivers/net/ntnic/nthw/model/nthw_fpga_model.c
+++ b/drivers/net/ntnic/nthw/model/nthw_fpga_model.c
@@ -183,7 +183,6 @@ nthw_fpga_mgr_t *nthw_fpga_mgr_new(void)
void nthw_fpga_mgr_delete(nthw_fpga_mgr_t *p)
{
- memset(p, 0, sizeof(nthw_fpga_mgr_t));
free(p);
}
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 23/25] net/ntnic: add null verification
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
` (21 preceding siblings ...)
2025-04-30 13:48 ` [PATCH v1 22/25] net/ntnic: remove unnecessary memset Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 24/25] net/ntnic: avoid possible deadlock Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 25/25] net/ntnic: fix operation with rte ring queue Oleksandr Kolomeiets
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas, Danylo Vodopianov
From: Danylo Vodopianov <dvo-plv@napatech.com>
Add verification on NULL for variables before use it in the memset.
Signed-off-by: Danylo Vodopianov <dvo-plv@napatech.com>
---
drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c | 3 +++
.../link_mgmt/link_100g/nt4ga_link_100g.c | 2 ++
.../net/ntnic/nthw/flow_api/flow_id_table.c | 3 ++-
.../nthw/flow_api/hw_mod/hw_mod_backend.c | 3 ++-
.../profile_inline/flow_api_profile_inline.c | 18 ++++++++++++------
drivers/net/ntnic/nthw/model/nthw_fpga_model.c | 6 ++++--
.../net/ntnic/nthw/ntnic_meter/ntnic_meter.c | 6 ++++++
drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 5 +++++
8 files changed, 36 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c b/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c
index bb775c052c..94b0c97d27 100644
--- a/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c
+++ b/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c
@@ -911,6 +911,9 @@ static int nthw_setup_managed_virt_queue_packed(struct nthw_virt_queue *vq,
RTE_ASSERT(p_packet_buffers);
/* clean canvas */
+ if (p_virt_struct_area->virt_addr == NULL)
+ return -1;
+
memset(p_virt_struct_area->virt_addr, 0,
sizeof(struct pvirtq_desc) * vq->queue_size +
sizeof(struct pvirtq_event_suppress) * 2 + sizeof(int) * vq->queue_size);
diff --git a/drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c b/drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c
index ed9dabe27c..adb187d322 100644
--- a/drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c
+++ b/drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c
@@ -137,6 +137,8 @@ static int _link_state_build(adapter_info_t *drv, nthw_mac_pcs_t *mac_pcs,
uint32_t lh_internal_local_fault;
uint32_t lh_received_local_fault;
+ RTE_ASSERT(state);
+
memset(state, 0, sizeof(*state));
state->link_disabled = is_port_disabled;
nthw_mac_pcs_get_link_summary(mac_pcs, &abs, &phy_link_state, &lh_abs, &ll_phy_link_state,
diff --git a/drivers/net/ntnic/nthw/flow_api/flow_id_table.c b/drivers/net/ntnic/nthw/flow_api/flow_id_table.c
index a63f5542d1..c33308b5f7 100644
--- a/drivers/net/ntnic/nthw/flow_api/flow_id_table.c
+++ b/drivers/net/ntnic/nthw/flow_api/flow_id_table.c
@@ -114,7 +114,8 @@ void ntnic_id_table_free_id(void *id_table, uint32_t id)
struct ntnic_id_table_element *current_element =
ntnic_id_table_array_find_element(handle, id);
- memset(current_element, 0, sizeof(struct ntnic_id_table_element));
+ if (current_element)
+ memset(current_element, 0, sizeof(struct ntnic_id_table_element));
struct ntnic_id_table_element *element =
ntnic_id_table_array_find_element(handle, handle->free_head);
diff --git a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_backend.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_backend.c
index 299b9b913a..2e2ecfe253 100644
--- a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_backend.c
+++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_backend.c
@@ -86,7 +86,8 @@ void *nthw_callocate_mod(struct common_func_s *mod, int sets, ...)
void nthw_zero_module_cache(struct common_func_s *mod)
{
- memset(mod->base, 0, mod->alloced_size);
+ if (mod)
+ memset(mod->base, 0, mod->alloced_size);
}
int nthw_flow_api_backend_init(struct flow_api_backend_s *dev,
diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
index 5bf8a9a3ea..3133464675 100644
--- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
+++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
@@ -1714,15 +1714,14 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev,
*in_port_id = UINT32_MAX;
- memset(packet_data, 0x0, sizeof(uint32_t) * 10);
- memset(packet_mask, 0x0, sizeof(uint32_t) * 10);
- memset(key_def, 0x0, sizeof(struct flm_flow_key_def_s));
-
- if (elem == NULL) {
+ if (packet_data == NULL || packet_mask == NULL || key_def == NULL || elem == NULL) {
nthw_flow_nic_set_error(ERR_FAILED, error);
NT_LOG(ERR, FILTER, "Flow items missing");
return -1;
}
+ memset(packet_data, 0x0, sizeof(uint32_t) * 10);
+ memset(packet_mask, 0x0, sizeof(uint32_t) * 10);
+ memset(key_def, 0x0, sizeof(struct flm_flow_key_def_s));
if (implicit_vlan_vid > 0) {
uint32_t *sw_data = &packet_data[1 - sw_counter];
@@ -3192,6 +3191,9 @@ static int convert_fh_to_fh_flm(struct flow_handle *fh, const uint32_t *packet_d
static void setup_db_qsl_data(struct nic_flow_def *fd, struct hw_db_inline_qsl_data *qsl_data,
uint32_t num_dest_port, uint32_t num_queues)
{
+ if (qsl_data == NULL)
+ return;
+
memset(qsl_data, 0x0, sizeof(struct hw_db_inline_qsl_data));
if (fd->dst_num_avail <= 0) {
@@ -3236,6 +3238,9 @@ static void setup_db_qsl_data(struct nic_flow_def *fd, struct hw_db_inline_qsl_d
static void setup_db_hsh_data(struct nic_flow_def *fd, struct hw_db_inline_hsh_data *hsh_data)
{
+ if (hsh_data == NULL)
+ return;
+
memset(hsh_data, 0x0, sizeof(struct hw_db_inline_hsh_data));
hsh_data->func = fd->hsh.func;
@@ -4816,7 +4821,8 @@ int flow_info_get_profile_inline(struct flow_eth_dev *dev, uint8_t caller_id,
int res = 0;
nthw_flow_nic_set_error(ERR_SUCCESS, error);
- memset(port_info, 0, sizeof(struct rte_flow_port_info));
+ if (port_info)
+ memset(port_info, 0, sizeof(struct rte_flow_port_info));
port_info->max_nb_aging_objects = dev->nb_aging_objects;
diff --git a/drivers/net/ntnic/nthw/model/nthw_fpga_model.c b/drivers/net/ntnic/nthw/model/nthw_fpga_model.c
index 0838527716..5256adc648 100644
--- a/drivers/net/ntnic/nthw/model/nthw_fpga_model.c
+++ b/drivers/net/ntnic/nthw/model/nthw_fpga_model.c
@@ -854,8 +854,10 @@ void nthw_register_flush(const nthw_register_t *p, uint32_t cnt)
void nthw_register_clr(nthw_register_t *p)
{
- memset(p->mp_shadow, 0, p->mn_len * sizeof(uint32_t));
- nthw_register_make_dirty(p);
+ if (p->mp_shadow) {
+ memset(p->mp_shadow, 0, p->mn_len * sizeof(uint32_t));
+ nthw_register_make_dirty(p);
+ }
}
/*
diff --git a/drivers/net/ntnic/nthw/ntnic_meter/ntnic_meter.c b/drivers/net/ntnic/nthw/ntnic_meter/ntnic_meter.c
index 66cc02a865..303c2cd51a 100644
--- a/drivers/net/ntnic/nthw/ntnic_meter/ntnic_meter.c
+++ b/drivers/net/ntnic/nthw/ntnic_meter/ntnic_meter.c
@@ -51,6 +51,9 @@ static int eth_mtr_capabilities_get_inline(struct rte_eth_dev *eth_dev,
"Ethernet device does not support metering");
}
+ if (cap == NULL)
+ return -1;
+
memset(cap, 0x0, sizeof(struct rte_mtr_capabilities));
/* MBR records use 28-bit integers */
@@ -419,6 +422,9 @@ static int eth_mtr_stats_read_inline(struct rte_eth_dev *eth_dev,
"MTR id is out of range");
}
+ if (stats == NULL)
+ return -1;
+
memset(stats, 0x0, sizeof(struct rte_mtr_stats));
profile_inline_ops->flm_mtr_read_stats(internals->flw_dev, caller_id, mtr_id, stats_mask,
&stats->n_pkts[RTE_COLOR_GREEN],
diff --git a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c
index 5757c7c13c..fc06cf12c3 100644
--- a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c
+++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c
@@ -248,6 +248,11 @@ int nthw_interpret_raw_data(uint8_t *data, uint8_t *preserve, int size, struct r
int nthw_create_attr(struct cnv_attr_s *attribute, const struct rte_flow_attr *attr)
{
+ if (!attribute) {
+ NT_LOG(ERR, FILTER, "ERROR no attribute to iterate!");
+ return -1;
+ }
+
memset(&attribute->attr, 0x0, sizeof(struct rte_flow_attr));
if (attr) {
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 24/25] net/ntnic: avoid possible deadlock
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
` (22 preceding siblings ...)
2025-04-30 13:48 ` [PATCH v1 23/25] net/ntnic: add null verification Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
2025-04-30 14:05 ` Stephen Hemminger
2025-04-30 13:48 ` [PATCH v1 25/25] net/ntnic: fix operation with rte ring queue Oleksandr Kolomeiets
24 siblings, 1 reply; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas, Danylo Vodopianov
From: Danylo Vodopianov <dvo-plv@napatech.com>
Sometimes during high flow learn performance two threads
could cause deadlock using queue and mutex.
learn_ignored variable sets when flow learn and gets
when flow removes. Hence, learn_ignore should not be protected
as far as two thread could not access to the same flow
at the same time.
Signed-off-by: Danylo Vodopianov <dvo-plv@napatech.com>
---
drivers/net/ntnic/include/flow_api_engine.h | 2 +-
.../nthw/flow_api/profile_inline/flow_api_profile_inline.c | 2 --
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/net/ntnic/include/flow_api_engine.h b/drivers/net/ntnic/include/flow_api_engine.h
index 859c76656a..10b09f0297 100644
--- a/drivers/net/ntnic/include/flow_api_engine.h
+++ b/drivers/net/ntnic/include/flow_api_engine.h
@@ -297,7 +297,7 @@ struct flow_handle {
enum flow_handle_type type;
uint32_t flm_id;
uint16_t caller_id;
- uint16_t learn_ignored;
+ RTE_ATOMIC(uint16_t)learn_ignored;
struct flow_eth_dev *dev;
struct flow_handle *next;
diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
index 3133464675..d12bd5a4af 100644
--- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
+++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
@@ -518,9 +518,7 @@ static void flm_mtr_read_sta_records(struct flow_eth_dev *dev, uint32_t *data, u
uint8_t port;
bool remote_caller = is_remote_caller(caller_id, &port);
- rte_spinlock_lock(&dev->ndev->mtx);
((struct flow_handle *)flm_h.p)->learn_ignored = 1;
- rte_spinlock_unlock(&dev->ndev->mtx);
struct flm_status_event_s data = {
.flow = flm_h.p,
.learn_ignore = sta_data->lis,
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v1 25/25] net/ntnic: fix operation with rte ring queue
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
` (23 preceding siblings ...)
2025-04-30 13:48 ` [PATCH v1 24/25] net/ntnic: avoid possible deadlock Oleksandr Kolomeiets
@ 2025-04-30 13:48 ` Oleksandr Kolomeiets
24 siblings, 0 replies; 27+ messages in thread
From: Oleksandr Kolomeiets @ 2025-04-30 13:48 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas, Danylo Vodopianov
From: Danylo Vodopianov <dvo-plv@napatech.com>
User should call rte_ring_dequeue_zc_elem_finish to complete the
dequeue operation. However this complete step if record absent.
This change rework queue read operation.
Fixes: 96c8249be53e ("net/ntnic: learn flow queue handling")
Signed-off-by: Danylo Vodopianov <dvo-plv@napatech.com>
---
.../profile_inline/flow_api_profile_inline.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
index d12bd5a4af..70f9d751c9 100644
--- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
+++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
@@ -398,18 +398,14 @@ static uint32_t flm_lrn_update(struct flow_eth_dev *dev, uint32_t *inf_word_cnt,
uint32_t *sta_word_cnt)
{
read_record r = flm_lrn_queue_get_read_buffer(flm_lrn_queue_arr);
+ uint32_t handled_records = 0;
if (r.num) {
- uint32_t handled_records = 0;
-
- if (hw_mod_flm_lrn_data_set_flush(&dev->ndev->be, HW_FLM_FLOW_LRN_DATA, r.p, r.num,
- &handled_records, inf_word_cnt, sta_word_cnt)) {
+ if (hw_mod_flm_lrn_data_set_flush(&dev->ndev->be, HW_FLM_FLOW_LRN_DATA, r.p,
+ r.num, &handled_records, inf_word_cnt, sta_word_cnt))
NT_LOG(ERR, FILTER, "Flow programming failed");
-
- } else if (handled_records > 0) {
- flm_lrn_queue_release_read_buffer(flm_lrn_queue_arr, handled_records);
- }
}
+ flm_lrn_queue_release_read_buffer(flm_lrn_queue_arr, handled_records);
return r.num;
}
--
2.47.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v1 24/25] net/ntnic: avoid possible deadlock
2025-04-30 13:48 ` [PATCH v1 24/25] net/ntnic: avoid possible deadlock Oleksandr Kolomeiets
@ 2025-04-30 14:05 ` Stephen Hemminger
0 siblings, 0 replies; 27+ messages in thread
From: Stephen Hemminger @ 2025-04-30 14:05 UTC (permalink / raw)
To: Oleksandr Kolomeiets
Cc: dev, mko-plv, sil-plv, ckm, thomas, Danylo Vodopianov
On Wed, 30 Apr 2025 15:48:36 +0200
Oleksandr Kolomeiets <okl-plv@napatech.com> wrote:
> From: Danylo Vodopianov <dvo-plv@napatech.com>
>
> Sometimes during high flow learn performance two threads
> could cause deadlock using queue and mutex.
>
> learn_ignored variable sets when flow learn and gets
> when flow removes. Hence, learn_ignore should not be protected
> as far as two thread could not access to the same flow
> at the same time.
>
> Signed-off-by: Danylo Vodopianov <dvo-plv@napatech.com>
If you are going to do this, then you need to use rte_atomic_store/fetch.
If two threads read/write same variable outside of lock, need the CPU
to use special instructions on weakly ordered platforms like ARM.
> --- a/drivers/net/ntnic/include/flow_api_engine.h
> +++ b/drivers/net/ntnic/include/flow_api_engine.h
> @@ -297,7 +297,7 @@ struct flow_handle {
> enum flow_handle_type type;
> uint32_t flm_id;
> uint16_t caller_id;
> - uint16_t learn_ignored;
> + RTE_ATOMIC(uint16_t)learn_ignored;
The preferred spacing would be:
RTE_ATOMIC(uint16_t) learn_ignored;
^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2025-04-30 14:05 UTC | newest]
Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-30 13:48 [PATCH v1 00/25] net/ntnic: fixes and improvements Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 01/25] net/ntnic: remove usage of the variable-length arrays Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 02/25] net/ntnic: handle string truncations when using strlcpy Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 03/25] net/ntnic: replace pragma pack with DPDK defined macros Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 04/25] net/ntnic: remove extra memset Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 05/25] net/ntnic: include all queues into statistics Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 06/25] net/ntnic: avoid misleading variable names Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 07/25] net/ntnic: apply packing to the structure Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 08/25] net/ntnic: improve logging format specifiers Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 09/25] net/ntnic: remove usless expressions Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 10/25] net/ntnic: remove unused code Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 11/25] net/ntnic: remove usless part of conditional expression Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 12/25] net/ntnic: add error logging for hsh Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 13/25] net/ntnic: add explicitly specificator Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 14/25] net/ntnic: add handle memory allocation failures Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 15/25] net/ntnic: remove redundant initialization Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 16/25] net/ntnic: enhance null checks and assertions Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 17/25] net/ntnic: add return value check Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 18/25] net/ntnic: remove redundant assignments and branching Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 19/25] net/ntnic: rework array usage Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 20/25] net/ntnic: avoid divide by zero Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 21/25] net/ntnic: remove unnecessary void cast Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 22/25] net/ntnic: remove unnecessary memset Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 23/25] net/ntnic: add null verification Oleksandr Kolomeiets
2025-04-30 13:48 ` [PATCH v1 24/25] net/ntnic: avoid possible deadlock Oleksandr Kolomeiets
2025-04-30 14:05 ` Stephen Hemminger
2025-04-30 13:48 ` [PATCH v1 25/25] net/ntnic: fix operation with rte ring queue Oleksandr Kolomeiets
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).