* [PATCH v1] net/ntnic: fix incorrect initializations
@ 2025-03-13 16:42 Serhii Iliushyk
2025-03-13 17:17 ` Stephen Hemminger
2025-03-14 9:33 ` [PATCH v2] " Serhii Iliushyk
0 siblings, 2 replies; 4+ messages in thread
From: Serhii Iliushyk @ 2025-03-13 16:42 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas
Compiling without enabled RTE_ASSERT leads to an error during
initialization
Fix incorrect assert conditions
Fixes: ff04525d90d3 ("net/ntnic: replace assert with RTE assert")
Signed-off-by: Serhii Iliushyk <sil-plv@napatech.com>
---
drivers/net/ntnic/adapter/nt4ga_adapter.c | 8 +++++---
drivers/net/ntnic/nthw/flow_filter/flow_nthw_flm.c | 6 +++---
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ntnic/adapter/nt4ga_adapter.c b/drivers/net/ntnic/adapter/nt4ga_adapter.c
index a9ae1fa3f8..cb80c718c3 100644
--- a/drivers/net/ntnic/adapter/nt4ga_adapter.c
+++ b/drivers/net/ntnic/adapter/nt4ga_adapter.c
@@ -85,6 +85,8 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
fpga_info_t *fpga_info = &p_adapter_info->fpga_info;
hw_info_t *p_hw_info = &p_adapter_info->hw_info;
+ RTE_ASSERT(fpga_info);
+
/*
* IMPORTANT: Most variables cannot be determined before nthw fpga model is instantiated
* (nthw_fpga_init())
@@ -155,15 +157,15 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
}
#ifdef RTE_ENABLE_ASSERT
- RTE_ASSERT(fpga_info);
- p_fpga = fpga_info->mp_fpga;
- RTE_ASSERT(p_fpga);
n_phy_ports = fpga_info->n_phy_ports;
RTE_ASSERT(n_phy_ports >= 1);
n_nim_ports = fpga_info->n_nims;
RTE_ASSERT(n_nim_ports >= 1);
#endif
+ p_fpga = fpga_info->mp_fpga;
+ RTE_ASSERT(p_fpga);
+
/* Nt4ga Init Filter */
nt4ga_filter_t *p_filter = &p_adapter_info->nt4ga_filter;
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 9bae6a32c8..a56d3c5038 100644
--- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_flm.c
+++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_flm.c
@@ -685,7 +685,7 @@ int flm_nthw_buf_ctrl_update(const struct flm_nthw *p, uint32_t *lrn_free, uint3
if (ret == 0) {
nthw_rac_rab_read32_dma(rac, bus_id, address_bufctrl, 2, &bc_buf);
ret = rac->m_dma_active ? nthw_rac_rab_dma_commit(rac) : -1;
- RTE_ASSERT(ret == -1);
+ RTE_ASSERT(ret != -1);
rte_spinlock_unlock(&rac->m_mutex);
if (ret != 0)
@@ -785,7 +785,7 @@ int flm_nthw_lrn_data_flush(const struct flm_nthw *p, const uint32_t *data, uint
nthw_rac_rab_read32_dma(rac, bus_id, address_bufctrl, 2, &bc_buf);
int ret = rac->m_dma_active ? nthw_rac_rab_dma_commit(rac) : -1;
- RTE_ASSERT(ret == -1);
+ RTE_ASSERT(ret != -1);
rte_spinlock_unlock(&rac->m_mutex);
if (ret != 0)
return -1;
@@ -847,7 +847,7 @@ int flm_nthw_inf_sta_data_update(const struct flm_nthw *p, uint32_t *inf_data,
nthw_rac_rab_read32_dma(rac, bus_id, address_bufctrl, 2, &bc_buf);
ret = rac->m_dma_active ? nthw_rac_rab_dma_commit(rac) : -1;
- RTE_ASSERT(ret == -1);
+ RTE_ASSERT(ret != -1);
rte_spinlock_unlock(&rac->m_mutex);
if (ret != 0)
--
2.45.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1] net/ntnic: fix incorrect initializations
2025-03-13 16:42 [PATCH v1] net/ntnic: fix incorrect initializations Serhii Iliushyk
@ 2025-03-13 17:17 ` Stephen Hemminger
2025-03-14 9:33 ` [PATCH v2] " Serhii Iliushyk
1 sibling, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2025-03-13 17:17 UTC (permalink / raw)
To: Serhii Iliushyk; +Cc: dev, mko-plv, ckm, thomas
On Thu, 13 Mar 2025 17:42:03 +0100
Serhii Iliushyk <sil-plv@napatech.com> wrote:
> Compiling without enabled RTE_ASSERT leads to an error during
> initialization
> Fix incorrect assert conditions
>
> Fixes: ff04525d90d3 ("net/ntnic: replace assert with RTE assert")
>
> Signed-off-by: Serhii Iliushyk <sil-plv@napatech.com>
> ---
> drivers/net/ntnic/adapter/nt4ga_adapter.c | 8 +++++---
> drivers/net/ntnic/nthw/flow_filter/flow_nthw_flm.c | 6 +++---
> 2 files changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ntnic/adapter/nt4ga_adapter.c b/drivers/net/ntnic/adapter/nt4ga_adapter.c
> index a9ae1fa3f8..cb80c718c3 100644
> --- a/drivers/net/ntnic/adapter/nt4ga_adapter.c
> +++ b/drivers/net/ntnic/adapter/nt4ga_adapter.c
> @@ -85,6 +85,8 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
> fpga_info_t *fpga_info = &p_adapter_info->fpga_info;
> hw_info_t *p_hw_info = &p_adapter_info->hw_info;
>
> + RTE_ASSERT(fpga_info);
> +
> /*
> * IMPORTANT: Most variables cannot be determined before nthw fpga model is instantiated
> * (nthw_fpga_init())
> @@ -155,15 +157,15 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
> }
>
> #ifdef RTE_ENABLE_ASSERT
> - RTE_ASSERT(fpga_info);
> - p_fpga = fpga_info->mp_fpga;
> - RTE_ASSERT(p_fpga);
> n_phy_ports = fpga_info->n_phy_ports;
> RTE_ASSERT(n_phy_ports >= 1);
> n_nim_ports = fpga_info->n_nims;
> RTE_ASSERT(n_nim_ports >= 1);
> #endif
This whole #ifdef is bad idea.
You are depending on implementation and creating side effects.
Better to just put all the expressions in the RTE_ASSERT()
>
> + p_fpga = fpga_info->mp_fpga;
> + RTE_ASSERT(p_fpga);
The RTE_ASSERT() checking for NULL really doesn't add that much safety.
if p_fpga is NULL RTE_ASSERT will crash the application anyway.
> /* Nt4ga Init Filter */
> nt4ga_filter_t *p_filter = &p_adapter_info->nt4ga_filter;
>
> 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 9bae6a32c8..a56d3c5038 100644
> --- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_flm.c
> +++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_flm.c
> @@ -685,7 +685,7 @@ int flm_nthw_buf_ctrl_update(const struct flm_nthw *p, uint32_t *lrn_free, uint3
> if (ret == 0) {
> nthw_rac_rab_read32_dma(rac, bus_id, address_bufctrl, 2, &bc_buf);
> ret = rac->m_dma_active ? nthw_rac_rab_dma_commit(rac) : -1;
> - RTE_ASSERT(ret == -1);
> + RTE_ASSERT(ret != -1);
> rte_spinlock_unlock(&rac->m_mutex);
>
> if (ret != 0)
> @@ -785,7 +785,7 @@ int flm_nthw_lrn_data_flush(const struct flm_nthw *p, const uint32_t *data, uint
> nthw_rac_rab_read32_dma(rac, bus_id, address_bufctrl, 2, &bc_buf);
>
> int ret = rac->m_dma_active ? nthw_rac_rab_dma_commit(rac) : -1;
> - RTE_ASSERT(ret == -1);
> + RTE_ASSERT(ret != -1);
> rte_spinlock_unlock(&rac->m_mutex);
> if (ret != 0)
> return -1;
> @@ -847,7 +847,7 @@ int flm_nthw_inf_sta_data_update(const struct flm_nthw *p, uint32_t *inf_data,
>
> nthw_rac_rab_read32_dma(rac, bus_id, address_bufctrl, 2, &bc_buf);
> ret = rac->m_dma_active ? nthw_rac_rab_dma_commit(rac) : -1;
> - RTE_ASSERT(ret == -1);
> + RTE_ASSERT(ret != -1);
> rte_spinlock_unlock(&rac->m_mutex);
>
> if (ret != 0)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] net/ntnic: fix incorrect initializations
2025-03-13 16:42 [PATCH v1] net/ntnic: fix incorrect initializations Serhii Iliushyk
2025-03-13 17:17 ` Stephen Hemminger
@ 2025-03-14 9:33 ` Serhii Iliushyk
1 sibling, 0 replies; 4+ messages in thread
From: Serhii Iliushyk @ 2025-03-14 9:33 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas
Compiling without enabled RTE_ASSERT leads to an error during
initialization
Fix incorrect assert conditions
Fixes: ff04525d90d3 ("net/ntnic: replace assert with RTE assert")
Signed-off-by: Serhii Iliushyk <sil-plv@napatech.com>
---
v2
* Remove ifdef wrapper
---
drivers/net/ntnic/adapter/nt4ga_adapter.c | 16 +++++-----------
.../net/ntnic/nthw/flow_filter/flow_nthw_flm.c | 6 +++---
2 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/drivers/net/ntnic/adapter/nt4ga_adapter.c b/drivers/net/ntnic/adapter/nt4ga_adapter.c
index a9ae1fa3f8..889f47caab 100644
--- a/drivers/net/ntnic/adapter/nt4ga_adapter.c
+++ b/drivers/net/ntnic/adapter/nt4ga_adapter.c
@@ -85,14 +85,12 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
fpga_info_t *fpga_info = &p_adapter_info->fpga_info;
hw_info_t *p_hw_info = &p_adapter_info->hw_info;
+ RTE_ASSERT(fpga_info);
+
/*
* IMPORTANT: Most variables cannot be determined before nthw fpga model is instantiated
* (nthw_fpga_init())
*/
-#ifdef RTE_ENABLE_ASSERT
- int n_phy_ports = -1;
- int n_nim_ports = -1;
-#endif
int res = -1;
nthw_fpga_t *p_fpga = NULL;
@@ -154,15 +152,11 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
return res;
}
-#ifdef RTE_ENABLE_ASSERT
- RTE_ASSERT(fpga_info);
+ RTE_ASSERT(fpga_info->n_phy_ports >= 1);
+ RTE_ASSERT(fpga_info->n_nims >= 1);
+
p_fpga = fpga_info->mp_fpga;
RTE_ASSERT(p_fpga);
- n_phy_ports = fpga_info->n_phy_ports;
- RTE_ASSERT(n_phy_ports >= 1);
- n_nim_ports = fpga_info->n_nims;
- RTE_ASSERT(n_nim_ports >= 1);
-#endif
/* Nt4ga Init Filter */
nt4ga_filter_t *p_filter = &p_adapter_info->nt4ga_filter;
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 9bae6a32c8..a56d3c5038 100644
--- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_flm.c
+++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_flm.c
@@ -685,7 +685,7 @@ int flm_nthw_buf_ctrl_update(const struct flm_nthw *p, uint32_t *lrn_free, uint3
if (ret == 0) {
nthw_rac_rab_read32_dma(rac, bus_id, address_bufctrl, 2, &bc_buf);
ret = rac->m_dma_active ? nthw_rac_rab_dma_commit(rac) : -1;
- RTE_ASSERT(ret == -1);
+ RTE_ASSERT(ret != -1);
rte_spinlock_unlock(&rac->m_mutex);
if (ret != 0)
@@ -785,7 +785,7 @@ int flm_nthw_lrn_data_flush(const struct flm_nthw *p, const uint32_t *data, uint
nthw_rac_rab_read32_dma(rac, bus_id, address_bufctrl, 2, &bc_buf);
int ret = rac->m_dma_active ? nthw_rac_rab_dma_commit(rac) : -1;
- RTE_ASSERT(ret == -1);
+ RTE_ASSERT(ret != -1);
rte_spinlock_unlock(&rac->m_mutex);
if (ret != 0)
return -1;
@@ -847,7 +847,7 @@ int flm_nthw_inf_sta_data_update(const struct flm_nthw *p, uint32_t *inf_data,
nthw_rac_rab_read32_dma(rac, bus_id, address_bufctrl, 2, &bc_buf);
ret = rac->m_dma_active ? nthw_rac_rab_dma_commit(rac) : -1;
- RTE_ASSERT(ret == -1);
+ RTE_ASSERT(ret != -1);
rte_spinlock_unlock(&rac->m_mutex);
if (ret != 0)
--
2.45.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v1] net/ntnic: fix incorrect initializations
@ 2025-03-13 18:28 Serhii Iliushyk
0 siblings, 0 replies; 4+ messages in thread
From: Serhii Iliushyk @ 2025-03-13 18:28 UTC (permalink / raw)
To: dev; +Cc: mko-plv, sil-plv, ckm, stephen, thomas
Compiling without enabled RTE_ASSERT leads to an error during
initialization
Fix incorrect assert conditions
Fixes: ff04525d90d3 ("net/ntnic: replace assert with RTE assert")
Signed-off-by: Serhii Iliushyk <sil-plv@napatech.com>
---
drivers/net/ntnic/adapter/nt4ga_adapter.c | 8 +++++---
drivers/net/ntnic/nthw/flow_filter/flow_nthw_flm.c | 6 +++---
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ntnic/adapter/nt4ga_adapter.c b/drivers/net/ntnic/adapter/nt4ga_adapter.c
index a9ae1fa3f8..cb80c718c3 100644
--- a/drivers/net/ntnic/adapter/nt4ga_adapter.c
+++ b/drivers/net/ntnic/adapter/nt4ga_adapter.c
@@ -85,6 +85,8 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
fpga_info_t *fpga_info = &p_adapter_info->fpga_info;
hw_info_t *p_hw_info = &p_adapter_info->hw_info;
+ RTE_ASSERT(fpga_info);
+
/*
* IMPORTANT: Most variables cannot be determined before nthw fpga model is instantiated
* (nthw_fpga_init())
@@ -155,15 +157,15 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
}
#ifdef RTE_ENABLE_ASSERT
- RTE_ASSERT(fpga_info);
- p_fpga = fpga_info->mp_fpga;
- RTE_ASSERT(p_fpga);
n_phy_ports = fpga_info->n_phy_ports;
RTE_ASSERT(n_phy_ports >= 1);
n_nim_ports = fpga_info->n_nims;
RTE_ASSERT(n_nim_ports >= 1);
#endif
+ p_fpga = fpga_info->mp_fpga;
+ RTE_ASSERT(p_fpga);
+
/* Nt4ga Init Filter */
nt4ga_filter_t *p_filter = &p_adapter_info->nt4ga_filter;
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 9bae6a32c8..a56d3c5038 100644
--- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_flm.c
+++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_flm.c
@@ -685,7 +685,7 @@ int flm_nthw_buf_ctrl_update(const struct flm_nthw *p, uint32_t *lrn_free, uint3
if (ret == 0) {
nthw_rac_rab_read32_dma(rac, bus_id, address_bufctrl, 2, &bc_buf);
ret = rac->m_dma_active ? nthw_rac_rab_dma_commit(rac) : -1;
- RTE_ASSERT(ret == -1);
+ RTE_ASSERT(ret != -1);
rte_spinlock_unlock(&rac->m_mutex);
if (ret != 0)
@@ -785,7 +785,7 @@ int flm_nthw_lrn_data_flush(const struct flm_nthw *p, const uint32_t *data, uint
nthw_rac_rab_read32_dma(rac, bus_id, address_bufctrl, 2, &bc_buf);
int ret = rac->m_dma_active ? nthw_rac_rab_dma_commit(rac) : -1;
- RTE_ASSERT(ret == -1);
+ RTE_ASSERT(ret != -1);
rte_spinlock_unlock(&rac->m_mutex);
if (ret != 0)
return -1;
@@ -847,7 +847,7 @@ int flm_nthw_inf_sta_data_update(const struct flm_nthw *p, uint32_t *inf_data,
nthw_rac_rab_read32_dma(rac, bus_id, address_bufctrl, 2, &bc_buf);
ret = rac->m_dma_active ? nthw_rac_rab_dma_commit(rac) : -1;
- RTE_ASSERT(ret == -1);
+ RTE_ASSERT(ret != -1);
rte_spinlock_unlock(&rac->m_mutex);
if (ret != 0)
--
2.45.0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-03-14 9:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-13 16:42 [PATCH v1] net/ntnic: fix incorrect initializations Serhii Iliushyk
2025-03-13 17:17 ` Stephen Hemminger
2025-03-14 9:33 ` [PATCH v2] " Serhii Iliushyk
2025-03-13 18:28 [PATCH v1] " Serhii Iliushyk
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).