Skip to content

Commit 78c2c96

Browse files
sil-plvshemminger
authored andcommitted
net/ntnic: replace assert with internal macro
Use RTE_ASSERT instead of direct calling asserts Signed-off-by: Serhii Iliushyk <[email protected]>
1 parent 5c681f1 commit 78c2c96

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+279
-275
lines changed

drivers/net/ntnic/adapter/nt4ga_adapter.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,10 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
8989
* IMPORTANT: Most variables cannot be determined before nthw fpga model is instantiated
9090
* (nthw_fpga_init())
9191
*/
92+
#ifdef RTE_ENABLE_ASSERT
9293
int n_phy_ports = -1;
9394
int n_nim_ports = -1;
95+
#endif
9496
int res = -1;
9597
nthw_fpga_t *p_fpga = NULL;
9698

@@ -152,13 +154,15 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
152154
return res;
153155
}
154156

155-
assert(fpga_info);
157+
#ifdef RTE_ENABLE_ASSERT
158+
RTE_ASSERT(fpga_info);
156159
p_fpga = fpga_info->mp_fpga;
157-
assert(p_fpga);
160+
RTE_ASSERT(p_fpga);
158161
n_phy_ports = fpga_info->n_phy_ports;
159-
assert(n_phy_ports >= 1);
162+
RTE_ASSERT(n_phy_ports >= 1);
160163
n_nim_ports = fpga_info->n_nims;
161-
assert(n_nim_ports >= 1);
164+
RTE_ASSERT(n_nim_ports >= 1);
165+
#endif
162166

163167
/* Nt4ga Init Filter */
164168
nt4ga_filter_t *p_filter = &p_adapter_info->nt4ga_filter;
@@ -176,7 +180,7 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
176180
{
177181
int i;
178182
const struct link_ops_s *link_ops = NULL;
179-
assert(fpga_info->n_fpga_prod_id > 0);
183+
RTE_ASSERT(fpga_info->n_fpga_prod_id > 0);
180184

181185
for (i = 0; i < NUM_ADAPTER_PORTS_MAX; i++) {
182186
/* Disable all ports. Must be enabled later */

drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static void dbs_init_tx_queue(nthw_dbs_t *p_nthw_dbs, uint32_t queue, uint32_t s
207207

208208
static int nthw_virt_queue_init(struct fpga_info_s *p_fpga_info)
209209
{
210-
assert(p_fpga_info);
210+
RTE_ASSERT(p_fpga_info);
211211

212212
nthw_fpga_t *const p_fpga = p_fpga_info->mp_fpga;
213213
nthw_dbs_t *p_nthw_dbs;
@@ -906,8 +906,8 @@ static int nthw_setup_managed_virt_queue_packed(struct nthw_virt_queue *vq,
906906
int rx)
907907
{
908908
/* page aligned */
909-
assert(((uintptr_t)p_virt_struct_area->phys_addr & 0xfff) == 0);
910-
assert(p_packet_buffers);
909+
RTE_ASSERT(((uintptr_t)p_virt_struct_area->phys_addr & 0xfff) == 0);
910+
RTE_ASSERT(p_packet_buffers);
911911

912912
/* clean canvas */
913913
memset(p_virt_struct_area->virt_addr, 0,

drivers/net/ntnic/include/flow_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ extern const char *dbg_res_descr[];
202202
size_t _temp_index = (index); \
203203
NT_LOG(DBG, FILTER, "mark resource used: %s idx %zu", \
204204
dbg_res_descr[_temp_res_type], _temp_index); \
205-
assert(flow_nic_is_bit_set(_temp_ndev->res[_temp_res_type].alloc_bm, \
205+
RTE_ASSERT(flow_nic_is_bit_set(_temp_ndev->res[_temp_res_type].alloc_bm, \
206206
_temp_index) == 0); \
207207
flow_nic_set_bit(_temp_ndev->res[_temp_res_type].alloc_bm, _temp_index); \
208208
} while (0)

drivers/net/ntnic/link_mgmt/link_100g/nt4ga_link_100g.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static int _link_state_build(adapter_info_t *drv, nthw_mac_pcs_t *mac_pcs,
144144
&lh_remote_fault, &lh_internal_local_fault,
145145
&lh_received_local_fault);
146146

147-
assert(port >= 0 && port < NUM_ADAPTER_PORTS_MAX);
147+
RTE_ASSERT(port >= 0 && port < NUM_ADAPTER_PORTS_MAX);
148148
state->nim_present = nthw_gpio_phy_is_module_present(gpio_phy, (uint8_t)port);
149149
state->lh_nim_absent = !state->nim_present;
150150
state->link_up = phy_link_state ? true : false;
@@ -177,7 +177,7 @@ static int _link_state_build(adapter_info_t *drv, nthw_mac_pcs_t *mac_pcs,
177177
*/
178178
static bool _nim_is_present(nthw_gpio_phy_t *gpio_phy, uint8_t if_no)
179179
{
180-
assert(if_no < NUM_ADAPTER_PORTS_MAX);
180+
RTE_ASSERT(if_no < NUM_ADAPTER_PORTS_MAX);
181181

182182
return nthw_gpio_phy_is_module_present(gpio_phy, if_no);
183183
}
@@ -258,8 +258,8 @@ static int _create_nim(adapter_info_t *drv, int port, bool enable)
258258
nt4ga_link_t *link_info = &drv->nt4ga_link;
259259
nthw_mac_pcs_t *mac_pcs = &link_info->u.var100g.mac_pcs100g[port];
260260

261-
assert(port >= 0 && port < NUM_ADAPTER_PORTS_MAX);
262-
assert(link_info->variables_initialized);
261+
RTE_ASSERT(port >= 0 && port < NUM_ADAPTER_PORTS_MAX);
262+
RTE_ASSERT(link_info->variables_initialized);
263263

264264
gpio_phy = &link_info->u.var100g.gpio_phy[port];
265265
nim_ctx = &link_info->u.var100g.nim_ctx[port];
@@ -355,8 +355,8 @@ static int _port_init(adapter_info_t *drv, nthw_fpga_t *fpga, int port)
355355

356356
nthw_mac_pcs_t *mac_pcs;
357357

358-
assert(port >= 0 && port < NUM_ADAPTER_PORTS_MAX);
359-
assert(link_info->variables_initialized);
358+
RTE_ASSERT(port >= 0 && port < NUM_ADAPTER_PORTS_MAX);
359+
RTE_ASSERT(link_info->variables_initialized);
360360

361361
if (fpga && fpga->p_fpga_info) {
362362
adapter_id = fpga->p_fpga_info->n_nthw_adapter_id;
@@ -444,7 +444,7 @@ static int _port_init(adapter_info_t *drv, nthw_fpga_t *fpga, int port)
444444

445445
} else {
446446
NT_LOG(ERR, NTNIC, "Unhandled AdapterId/HwId: %02x_hwid%d", adapter_id, hw_id);
447-
assert(0);
447+
RTE_ASSERT(0);
448448
}
449449

450450
_reset_rx(drv, mac_pcs);
@@ -494,7 +494,7 @@ static int _common_ptp_nim_state_machine(void *data)
494494
goto NT4GA_LINK_100G_MON_EXIT;
495495
}
496496

497-
assert(adapter_no >= 0 && adapter_no < NUM_ADAPTER_MAX);
497+
RTE_ASSERT(adapter_no >= 0 && adapter_no < NUM_ADAPTER_MAX);
498498
nim_ctx = link_info->u.var100g.nim_ctx;
499499
link_state = link_info->link_state;
500500
mac_pcs = link_info->u.var100g.mac_pcs100g;
@@ -521,7 +521,7 @@ static int _common_ptp_nim_state_machine(void *data)
521521
break;
522522

523523
/* Has the administrative port state changed? */
524-
assert(!(disable_port && enable_port));
524+
RTE_ASSERT(!(disable_port && enable_port));
525525

526526
if (disable_port) {
527527
memset(&link_state[i], 0, sizeof(link_state[i]));
@@ -603,7 +603,7 @@ static int _common_ptp_nim_state_machine(void *data)
603603
continue;
604604
}
605605

606-
assert(new_state.br); /* Cannot be zero if NIM is present */
606+
RTE_ASSERT(new_state.br); /* Cannot be zero if NIM is present */
607607
NT_LOG(DBG, NTNIC,
608608
"%s: NIM id = %u (%s), br = %u, vendor = '%s', pn = '%s', sn='%s'",
609609
drv->mp_port_id_str[i], nim_ctx->nim_id,
@@ -669,7 +669,7 @@ static int nt4ga_link_100g_ports_init(struct adapter_info_s *p_adapter_info, nth
669669
/*
670670
* Initialize global variables
671671
*/
672-
assert(adapter_no >= 0 && adapter_no < NUM_ADAPTER_MAX);
672+
RTE_ASSERT(adapter_no >= 0 && adapter_no < NUM_ADAPTER_MAX);
673673

674674
if (res == 0 && !p_adapter_info->nt4ga_link.variables_initialized) {
675675
nthw_mac_pcs_t *mac_pcs = p_adapter_info->nt4ga_link.u.var100g.mac_pcs100g;

drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ static void phy_get_link_state(adapter_info_t *drv,
7878
static void phy_rx_path_rst(adapter_info_t *drv, int port, bool reset)
7979
{
8080
nthw_phy_tile_t *p = drv->fpga_info.mp_nthw_agx.p_phy_tile;
81-
NT_LOG(DBG, NTNIC, "Port %d: %s", port, reset ? "assert" : "deassert");
81+
NT_LOG(DBG, NTNIC, "Port %d: %s", port, reset ? "RTE_ASSERT" : "deassert");
8282
nthw_phy_tile_set_rx_reset(p, port, reset);
8383
}
8484

8585
static void phy_tx_path_rst(adapter_info_t *drv, int port, bool reset)
8686
{
8787
nthw_phy_tile_t *p = drv->fpga_info.mp_nthw_agx.p_phy_tile;
88-
NT_LOG(DBG, NTNIC, "Port %d: %s", port, reset ? "assert" : "deassert");
88+
NT_LOG(DBG, NTNIC, "Port %d: %s", port, reset ? "RTE_ASSERT" : "deassert");
8989
nthw_phy_tile_set_tx_reset(p, port, reset);
9090
}
9191

@@ -246,7 +246,7 @@ static void nim_set_reset(struct nim_i2c_ctx *ctx, uint8_t nim_idx, bool reset)
246246

247247
static bool nim_is_present(nim_i2c_ctx_p ctx, uint8_t nim_idx)
248248
{
249-
assert(nim_idx < NUM_ADAPTER_PORTS_MAX);
249+
RTE_ASSERT(nim_idx < NUM_ADAPTER_PORTS_MAX);
250250

251251
nthw_pcal6416a_t *p = ctx->hwagx.p_io_nim;
252252
uint8_t data = 0;
@@ -521,8 +521,8 @@ static int create_nim(adapter_info_t *drv, int port, bool enable)
521521
nt4ga_link_t *link_info = &drv->nt4ga_link;
522522
nim_i2c_ctx_t *nim_ctx = &link_info->u.nim_ctx[port];
523523

524-
assert(port >= 0 && port < NUM_ADAPTER_PORTS_MAX);
525-
assert(link_info->variables_initialized);
524+
RTE_ASSERT(port >= 0 && port < NUM_ADAPTER_PORTS_MAX);
525+
RTE_ASSERT(link_info->variables_initialized);
526526

527527
if (!enable) {
528528
phy_reset_rx(drv, port);
@@ -722,8 +722,8 @@ static int _port_init(adapter_info_t *p_info, nthw_fpga_t *fpga, int port)
722722
nthw_phy_tile_t *p_phy_tile = p_info->fpga_info.mp_nthw_agx.p_phy_tile;
723723
nthw_rpf_t *p_rpf = p_info->fpga_info.mp_nthw_agx.p_rpf;
724724

725-
assert(port >= 0 && port < NUM_ADAPTER_PORTS_MAX);
726-
assert(link_info->variables_initialized);
725+
RTE_ASSERT(port >= 0 && port < NUM_ADAPTER_PORTS_MAX);
726+
RTE_ASSERT(link_info->variables_initialized);
727727

728728
link_info->link_info[port].link_speed = NT_LINK_SPEED_100G;
729729
link_info->link_info[port].link_duplex = NT_LINK_DUPLEX_FULL;
@@ -794,7 +794,7 @@ static void *_common_ptp_nim_state_machine(void *data)
794794
goto NT4GA_LINK_100G_MON_EXIT;
795795
}
796796

797-
assert(adapter_no >= 0 && adapter_no < NUM_ADAPTER_MAX);
797+
RTE_ASSERT(adapter_no >= 0 && adapter_no < NUM_ADAPTER_MAX);
798798

799799
monitor_task_is_running[adapter_no] = 1;
800800
memset(last_lpbk_mode, 0, sizeof(last_lpbk_mode));
@@ -828,7 +828,7 @@ static void *_common_ptp_nim_state_machine(void *data)
828828
/*
829829
* Has the administrative port state changed?
830830
*/
831-
assert(!(disable_port && enable_port));
831+
RTE_ASSERT(!(disable_port && enable_port));
832832

833833
if (disable_port) {
834834
memset(&link_state[i], 0, sizeof(link_state[i]));
@@ -912,7 +912,7 @@ static void *_common_ptp_nim_state_machine(void *data)
912912
continue;
913913
}
914914

915-
assert(new_state.br); /* Cannot be zero if NIM is present */
915+
RTE_ASSERT(new_state.br); /* Cannot be zero if NIM is present */
916916
NT_LOG(DBG, NTNIC,
917917
"%s: NIM id = %u (%s), br = %u, vendor = '%s', pn = '%s', sn='%s'",
918918
drv->mp_port_id_str[i], nim_ctx->nim_id,

drivers/net/ntnic/nim/i2c_nim.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ static int qsfp_nim_state_build(nim_i2c_ctx_t *ctx, sfp_nim_state_t *state)
302302
{
303303
int res = 0; /* unused due to no readings from HW */
304304

305-
assert(ctx && state);
306-
assert(ctx->nim_id != NT_NIM_UNKNOWN && "Nim is not initialized");
305+
RTE_ASSERT(ctx && state);
306+
RTE_ASSERT(ctx->nim_id != NT_NIM_UNKNOWN && "Nim is not initialized");
307307

308308
(void)memset(state, 0, sizeof(*state));
309309

@@ -628,7 +628,7 @@ static void qsfpplus_set_speed_mask(nim_i2c_ctx_p ctx)
628628

629629
static void qsfpplus_construct(nim_i2c_ctx_p ctx, int8_t lane_idx)
630630
{
631-
assert(lane_idx < 4);
631+
RTE_ASSERT(lane_idx < 4);
632632
ctx->specific_u.qsfp.qsfp28 = false;
633633
ctx->lane_idx = lane_idx;
634634
ctx->lane_count = 4;

drivers/net/ntnic/nthw/core/nt200a0x/nthw_fpga_nt200a0x.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
static int nthw_fpga_nt200a0x_init(struct fpga_info_s *p_fpga_info)
1212
{
13-
assert(p_fpga_info);
13+
RTE_ASSERT(p_fpga_info);
1414

1515
const char *const p_adapter_id_str = p_fpga_info->mp_adapter_id_str;
1616
struct nthw_fpga_rst_nt200a0x rst;

drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static int nthw_fpga_rst9563_setup(nthw_fpga_t *p_fpga, struct nthw_fpga_rst_nt2
2121
nthw_module_t *p_mod_rst;
2222
nthw_register_t *p_curr_reg;
2323

24-
assert(p);
24+
RTE_ASSERT(p);
2525
p->mn_fpga_product_id = n_fpga_product_id;
2626
p->mn_fpga_version = n_fpga_version;
2727
p->mn_fpga_revision = n_fpga_revision;
@@ -195,8 +195,8 @@ static int nthw_fpga_rst9563_clock_synth_init(nthw_fpga_t *p_fpga,
195195
static int nthw_fpga_rst9563_init(struct fpga_info_s *p_fpga_info,
196196
struct nthw_fpga_rst_nt200a0x *p_rst)
197197
{
198-
assert(p_fpga_info);
199-
assert(p_rst);
198+
RTE_ASSERT(p_fpga_info);
199+
RTE_ASSERT(p_rst);
200200

201201
const char *const p_adapter_id_str = p_fpga_info->mp_adapter_id_str;
202202
(void)p_adapter_id_str;

drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ static int nthw_fpga_rst_nt200a0x_reset(nthw_fpga_t *p_fpga,
224224
NT_LOG_DBGX(DBG, NTHW, "%s: FPGA reset sequence: FPGA %04d-%02d-%02d @ HWId%d",
225225
p_adapter_id_str, n_fpga_product_id, n_fpga_version, n_fpga_revision,
226226
n_hw_id);
227-
assert(n_fpga_product_id == p_fpga->mn_product_id);
227+
RTE_ASSERT(n_fpga_product_id == p_fpga->mn_product_id);
228228

229229
/*
230230
* Reset all domains / modules except peripherals
@@ -296,7 +296,7 @@ static int nthw_fpga_rst_nt200a0x_reset(nthw_fpga_t *p_fpga,
296296
nthw_field_update_register(p->mp_fld_ctrl_ts_clk_sel);
297297
nthw_field_set_flush(p->mp_fld_ctrl_ts_clk_sel);
298298

299-
/* 4: De-assert sys reset, CORE and SYS MMCM resets */
299+
/* 4: De-RTE_ASSERT sys reset, CORE and SYS MMCM resets */
300300
NT_LOG(DBG, NTHW, "%s: De-asserting SYS, CORE and SYS MMCM resets", p_adapter_id_str);
301301
nthw_field_update_register(p->mp_fld_rst_sys);
302302
nthw_field_clr_flush(p->mp_fld_rst_sys);
@@ -353,7 +353,7 @@ static int nthw_fpga_rst_nt200a0x_reset(nthw_fpga_t *p_fpga,
353353
nthw_field_clr_flush(p->mp_fld_rst_phy);
354354

355355
/*
356-
* 8: De-assert reset for remaining domains/modules resets except
356+
* 8: De-RTE_ASSERT reset for remaining domains/modules resets except
357357
* TS, PTP, PTP_MMCM and TS_MMCM
358358
*/
359359
NT_LOG(DBG, NTHW, "%s: De-asserting TMC RST", p_adapter_id_str);
@@ -408,7 +408,7 @@ static int nthw_fpga_rst_nt200a0x_reset(nthw_fpga_t *p_fpga,
408408

409409
/*
410410
* Timesync/PTP reset sequence
411-
* De-assert TS_MMCM reset
411+
* De-RTE_ASSERT TS_MMCM reset
412412
*/
413413
NT_LOG(DBG, NTHW, "%s: De-asserting TS MMCM RST", p_adapter_id_str);
414414
nthw_field_clr_flush(p->mp_fld_rst_ts_mmcm);
@@ -437,7 +437,7 @@ static int nthw_fpga_rst_nt200a0x_reset(nthw_fpga_t *p_fpga,
437437
if (p->mp_fld_sticky_pci_sys_mmcm_unlocked)
438438
nthw_field_set_flush(p->mp_fld_sticky_pci_sys_mmcm_unlocked);
439439

440-
/* De-assert TS reset bit */
440+
/* De-RTE_ASSERT TS reset bit */
441441
NT_LOG(DBG, NTHW, "%s: De-asserting TS RST", p_adapter_id_str);
442442
nthw_field_clr_flush(p->mp_fld_rst_ts);
443443

@@ -513,7 +513,7 @@ static int nthw_fpga_rst_nt200a0x_reset(nthw_fpga_t *p_fpga,
513513
static int nthw_fpga_rst_nt200a0x_init(struct fpga_info_s *p_fpga_info,
514514
struct nthw_fpga_rst_nt200a0x *p_rst)
515515
{
516-
assert(p_fpga_info);
516+
RTE_ASSERT(p_fpga_info);
517517

518518
const char *const p_adapter_id_str = p_fpga_info->mp_adapter_id_str;
519519
int res = -1;

drivers/net/ntnic/nthw/core/nt400dxx/nthw_fpga_nt400dxx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,15 @@ static int nthw_fpga_nt400dxx_init_sub_systems(struct fpga_info_s *p_fpga_info)
112112

113113
static int nthw_fpga_nt400dxx_init(struct fpga_info_s *p_fpga_info)
114114
{
115-
assert(p_fpga_info);
115+
RTE_ASSERT(p_fpga_info);
116116
struct rst9574_ops *rst9574_ops = NULL;
117117

118118
const char *const p_adapter_id_str = p_fpga_info->mp_adapter_id_str;
119119
struct nthw_fpga_rst_nt400dxx rst;
120120
int res = -1;
121121

122122
nthw_fpga_t *p_fpga = p_fpga_info->mp_fpga;
123-
assert(p_fpga);
123+
RTE_ASSERT(p_fpga);
124124

125125
switch (p_fpga_info->n_fpga_prod_id) {
126126
case 9574:

0 commit comments

Comments
 (0)