* [dpdk-dev] [PATCH 1/3] app/test: use RTE_DIM instead of ARRAY_SIZE
@ 2019-10-11 4:07 pbhagavatula
2019-10-11 4:07 ` [dpdk-dev] [PATCH 2/3] drivers: " pbhagavatula
` (3 more replies)
0 siblings, 4 replies; 15+ messages in thread
From: pbhagavatula @ 2019-10-11 4:07 UTC (permalink / raw)
To: Declan Doherty, Gage Eads, Olivier Matz; +Cc: dev, Pavan Nikhilesh
From: Pavan Nikhilesh <pbhagavatula@marvell.com>
Use RTE_DIM instead of re-defining ARRAY_SIZE.
Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
app/test/test_cryptodev_asym.c | 8 ++------
app/test/test_metrics.c | 11 +++++------
app/test/test_stack_perf.c | 8 +++-----
3 files changed, 10 insertions(+), 17 deletions(-)
diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index e8177e73a..7ff631600 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -26,10 +26,6 @@
#define TEST_NUM_BUFS 10
#define TEST_NUM_SESSIONS 4
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-#endif
-
#ifndef TEST_DATA_SIZE
#define TEST_DATA_SIZE 4096
#endif
@@ -473,7 +469,7 @@ load_test_vectors(void)
{
uint32_t i = 0, v_size = 0;
/* Load MODEX vector*/
- v_size = ARRAY_SIZE(modex_test_case);
+ v_size = RTE_DIM(modex_test_case);
for (i = 0; i < v_size; i++) {
if (test_vector.size >= (TEST_VECTOR_SIZE)) {
RTE_LOG(DEBUG, USER1,
@@ -484,7 +480,7 @@ load_test_vectors(void)
test_vector.size++;
}
/* Load MODINV vector*/
- v_size = ARRAY_SIZE(modinv_test_case);
+ v_size = RTE_DIM(modinv_test_case);
for (i = 0; i < v_size; i++) {
if (test_vector.size >= (TEST_VECTOR_SIZE)) {
RTE_LOG(DEBUG, USER1,
diff --git a/app/test/test_metrics.c b/app/test/test_metrics.c
index 78b3936ee..e736019ae 100644
--- a/app/test/test_metrics.c
+++ b/app/test/test_metrics.c
@@ -12,7 +12,6 @@
#include "test.h"
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define REG_METRIC_COUNT 6
#define METRIC_LESSER_COUNT 3
#define KEY 1
@@ -106,7 +105,7 @@ test_metrics_reg_names(void)
};
/* Success Test: valid array and count size */
- err = rte_metrics_reg_names(&mnames[0], ARRAY_SIZE(mnames));
+ err = rte_metrics_reg_names(&mnames[0], RTE_DIM(mnames));
TEST_ASSERT(err >= 0, "%s, %d", __func__, __LINE__);
return TEST_SUCCESS;
@@ -167,20 +166,20 @@ test_metrics_update_values(void)
/* Failed Test: Invalid count size */
err = rte_metrics_update_values(RTE_METRICS_GLOBAL,
- KEY, &value[0], ARRAY_SIZE(value));
+ KEY, &value[0], RTE_DIM(value));
TEST_ASSERT(err < 0, "%s, %d", __func__, __LINE__);
/* Failed Test: Invalid port_id(lower value) and valid data */
- err = rte_metrics_update_values(-2, KEY, &value[0], ARRAY_SIZE(value));
+ err = rte_metrics_update_values(-2, KEY, &value[0], RTE_DIM(value));
TEST_ASSERT(err == -EINVAL, "%s, %d", __func__, __LINE__);
/* Failed Test: Invalid port_id(higher value) and valid data */
- err = rte_metrics_update_values(39, 1, &value[0], ARRAY_SIZE(value));
+ err = rte_metrics_update_values(39, 1, &value[0], RTE_DIM(value));
TEST_ASSERT(err == -EINVAL, "%s, %d", __func__, __LINE__);
/* Failed Test: Invalid array */
err = rte_metrics_update_values(RTE_METRICS_GLOBAL,
- KEY, NULL, ARRAY_SIZE(value));
+ KEY, NULL, RTE_DIM(value));
TEST_ASSERT(err == -EINVAL, "%s, %d", __func__, __LINE__);
return TEST_SUCCESS;
diff --git a/app/test/test_stack_perf.c b/app/test/test_stack_perf.c
index 70561fecd..3ab7267b1 100644
--- a/app/test/test_stack_perf.c
+++ b/app/test/test_stack_perf.c
@@ -18,8 +18,6 @@
#define MAX_BURST 32
#define STACK_SIZE (RTE_MAX_LCORE * MAX_BURST)
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
/*
* Push/pop bulk sizes, marked volatile so they aren't treated as compile-time
* constants.
@@ -176,7 +174,7 @@ run_on_core_pair(struct lcore_pair *cores, struct rte_stack *s,
struct thread_args args[2];
unsigned int i;
- for (i = 0; i < ARRAY_SIZE(bulk_sizes); i++) {
+ for (i = 0; i < RTE_DIM(bulk_sizes); i++) {
rte_atomic32_set(&lcore_barrier, 2);
args[0].sz = args[1].sz = bulk_sizes[i];
@@ -205,7 +203,7 @@ run_on_n_cores(struct rte_stack *s, lcore_function_t fn, int n)
struct thread_args args[RTE_MAX_LCORE];
unsigned int i;
- for (i = 0; i < ARRAY_SIZE(bulk_sizes); i++) {
+ for (i = 0; i < RTE_DIM(bulk_sizes); i++) {
unsigned int lcore_id;
int cnt = 0;
double avg;
@@ -280,7 +278,7 @@ test_bulk_push_pop(struct rte_stack *s)
void *objs[MAX_BURST];
unsigned int sz, i;
- for (sz = 0; sz < ARRAY_SIZE(bulk_sizes); sz++) {
+ for (sz = 0; sz < RTE_DIM(bulk_sizes); sz++) {
uint64_t start = rte_rdtsc();
for (i = 0; i < iterations; i++) {
--
2.17.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH 2/3] drivers: use RTE_DIM instead of ARRAY_SIZE
2019-10-11 4:07 [dpdk-dev] [PATCH 1/3] app/test: use RTE_DIM instead of ARRAY_SIZE pbhagavatula
@ 2019-10-11 4:07 ` pbhagavatula
2019-10-11 4:37 ` Hemant Agrawal
` (2 more replies)
2019-10-11 4:07 ` [dpdk-dev] [PATCH 3/3] bitrate: " pbhagavatula
` (2 subsequent siblings)
3 siblings, 3 replies; 15+ messages in thread
From: pbhagavatula @ 2019-10-11 4:07 UTC (permalink / raw)
To: Hemant Agrawal, Sachin Saxena, Akhil Goyal, Igor Russkikh,
Pavel Belous, Ravi Kumar, Rasesh Mody, Shahed Shaikh,
Rahul Lakkireddy, Marcin Wojtas, Michal Krawczyk, Guy Tzalik,
Evgeny Schemeilin, Igor Chauskin, John Daley, Hyong Youb Kim,
Wei Hu (Xavier), Min Hu (Connor),
Yisen Zhuang, Beilei Xing, Qi Zhang, Jingjing Wu, Wenzhuo Lu,
Qiming Yang, Alejandro Lucero, Andrew Rybchenko, Jerin Jacob,
Maciej Czekaj, Rosen Xu, Tianfei zhang
Cc: dev, Pavan Nikhilesh
From: Pavan Nikhilesh <pbhagavatula@marvell.com>
Use RTE_DIM instead of re-defining ARRAY_SIZE.
Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
drivers/bus/dpaa/base/qbman/qman.c | 6 ++--
drivers/bus/dpaa/include/compat.h | 5 ----
drivers/crypto/dpaa2_sec/hw/compat.h | 8 -----
drivers/crypto/dpaa2_sec/hw/rta/jump_cmd.h | 6 ++--
drivers/crypto/dpaa2_sec/hw/rta/nfifo_cmd.h | 2 +-
drivers/net/atlantic/atl_hw_regs.h | 1 -
drivers/net/atlantic/hw_atl/hw_atl_utils.c | 4 +--
.../net/atlantic/hw_atl/hw_atl_utils_fw2x.c | 2 +-
drivers/net/axgbe/axgbe_common.h | 3 --
drivers/net/axgbe/axgbe_dev.c | 2 +-
drivers/net/bnx2x/bnx2x.c | 6 ++--
drivers/net/bnx2x/bnx2x.h | 6 ----
drivers/net/bnx2x/ecore_init.h | 8 ++---
drivers/net/bnx2x/ecore_sp.c | 2 +-
drivers/net/bnx2x/elink.c | 14 ++++-----
drivers/net/bnx2x/elink.h | 1 -
drivers/net/cxgbe/base/t4_hw.c | 16 +++++-----
drivers/net/cxgbe/base/t4vf_hw.c | 4 +--
drivers/net/cxgbe/cxgbe_compat.h | 2 --
drivers/net/cxgbe/cxgbe_flow.c | 4 +--
drivers/net/cxgbe/cxgbe_main.c | 10 +++----
drivers/net/cxgbe/sge.c | 2 +-
drivers/net/ena/ena_ethdev.c | 8 ++---
drivers/net/enic/base/vnic_dev.c | 4 +--
drivers/net/enic/base/vnic_devcmd.h | 2 --
drivers/net/hns3/hns3_cmd.c | 2 +-
drivers/net/hns3/hns3_ethdev.h | 2 --
drivers/net/hns3/hns3_flow.c | 18 +++++------
drivers/net/i40e/base/i40e_diag.c | 2 +-
drivers/net/i40e/base/i40e_osdep.h | 2 --
drivers/net/iavf/base/iavf_osdep.h | 2 --
drivers/net/ice/base/ice_fdir.c | 2 +-
drivers/net/ice/base/ice_flex_pipe.c | 2 +-
drivers/net/ice/base/ice_flow.c | 2 +-
drivers/net/ice/base/ice_osdep.h | 1 -
drivers/net/ice/base/ice_switch.c | 2 +-
.../net/nfp/nfpcore/nfp-common/nfp_platform.h | 4 ---
drivers/net/nfp/nfpcore/nfp_cppcore.c | 2 +-
drivers/net/nfp/nfpcore/nfp_nsp.c | 2 +-
drivers/net/nfp/nfpcore/nfp_nsp_eth.c | 4 +--
drivers/net/sfc/base/ef10_ev.c | 4 +--
drivers/net/sfc/base/ef10_filter.c | 12 ++++----
drivers/net/sfc/base/ef10_mac.c | 18 +++++------
drivers/net/sfc/base/ef10_nic.c | 4 +--
drivers/net/sfc/base/ef10_nvram.c | 6 ++--
drivers/net/sfc/base/efx.h | 3 --
drivers/net/sfc/base/efx_port.c | 2 +-
drivers/net/sfc/base/efx_rx.c | 2 +-
drivers/net/sfc/base/siena_mac.c | 2 +-
drivers/net/sfc/base/siena_nic.c | 20 ++++++-------
drivers/net/sfc/base/siena_nvram.c | 6 ++--
drivers/net/thunderx/base/nicvf_hw.c | 30 +++++++++----------
drivers/net/thunderx/base/nicvf_hw.h | 2 --
.../raw/ifpga/base/osdep_rte/osdep_generic.h | 2 --
54 files changed, 120 insertions(+), 170 deletions(-)
diff --git a/drivers/bus/dpaa/base/qbman/qman.c b/drivers/bus/dpaa/base/qbman/qman.c
index e43fc65ef..019be95e2 100644
--- a/drivers/bus/dpaa/base/qbman/qman.c
+++ b/drivers/bus/dpaa/base/qbman/qman.c
@@ -1956,7 +1956,7 @@ int qman_query_wq(u8 query_dedicated, struct qm_mcr_querywq *wq)
int i, array_len;
wq->channel.id = be16_to_cpu(mcr->querywq.channel.id);
- array_len = ARRAY_SIZE(mcr->querywq.wq_len);
+ array_len = RTE_DIM(mcr->querywq.wq_len);
for (i = 0; i < array_len; i++)
wq->wq_len[i] = be32_to_cpu(mcr->querywq.wq_len[i]);
}
@@ -2023,7 +2023,7 @@ int qman_query_cgr(struct qman_cgr *cgr, struct qm_mcr_querycgr *cgrd)
be32_to_cpu(cgrd->cgr.wr_parm_r.word);
cgrd->cgr.cscn_targ = be32_to_cpu(cgrd->cgr.cscn_targ);
cgrd->cgr.__cs_thres = be16_to_cpu(cgrd->cgr.__cs_thres);
- for (i = 0; i < ARRAY_SIZE(cgrd->cscn_targ_swp); i++)
+ for (i = 0; i < RTE_DIM(cgrd->cscn_targ_swp); i++)
cgrd->cscn_targ_swp[i] =
be32_to_cpu(cgrd->cscn_targ_swp[i]);
return 0;
@@ -2049,7 +2049,7 @@ int qman_query_congestion(struct qm_mcr_querycongestion *congestion)
pr_err("QUERY_CONGESTION failed: %s\n", mcr_result_str(res));
return -EIO;
}
- for (i = 0; i < ARRAY_SIZE(congestion->state.state); i++)
+ for (i = 0; i < RTE_DIM(congestion->state.state); i++)
congestion->state.state[i] =
be32_to_cpu(congestion->state.state[i]);
return 0;
diff --git a/drivers/bus/dpaa/include/compat.h b/drivers/bus/dpaa/include/compat.h
index 277ce6369..8654a4db6 100644
--- a/drivers/bus/dpaa/include/compat.h
+++ b/drivers/bus/dpaa/include/compat.h
@@ -67,11 +67,6 @@
#define __stringify_1(x) #x
#define __stringify(x) __stringify_1(x)
-#ifdef ARRAY_SIZE
-#undef ARRAY_SIZE
-#endif
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
-
/* Debugging */
#define prflush(fmt, args...) \
do { \
diff --git a/drivers/crypto/dpaa2_sec/hw/compat.h b/drivers/crypto/dpaa2_sec/hw/compat.h
index ce946ccb5..8d27a518e 100644
--- a/drivers/crypto/dpaa2_sec/hw/compat.h
+++ b/drivers/crypto/dpaa2_sec/hw/compat.h
@@ -67,14 +67,6 @@
#endif
#endif /* pr_warn */
-/**
- * ARRAY_SIZE - returns the number of elements in an array
- * @x: array
- */
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-#endif
-
#ifndef ALIGN
#define ALIGN(x, a) (((x) + ((__typeof__(x))(a) - 1)) & \
~((__typeof__(x))(a) - 1))
diff --git a/drivers/crypto/dpaa2_sec/hw/rta/jump_cmd.h b/drivers/crypto/dpaa2_sec/hw/rta/jump_cmd.h
index 18f781e37..340e96b13 100644
--- a/drivers/crypto/dpaa2_sec/hw/rta/jump_cmd.h
+++ b/drivers/crypto/dpaa2_sec/hw/rta/jump_cmd.h
@@ -132,12 +132,12 @@ rta_jump(struct program *program, uint64_t address,
/* write test condition field */
if ((jump_type != LOCAL_JUMP_INC) && (jump_type != LOCAL_JUMP_DEC)) {
__rta_map_flags(test_condition, jump_test_cond,
- ARRAY_SIZE(jump_test_cond), &opcode);
+ RTE_DIM(jump_test_cond), &opcode);
} else {
uint32_t val = 0;
ret = __rta_map_opcode(src_dst, jump_src_dst,
- ARRAY_SIZE(jump_src_dst), &val);
+ RTE_DIM(jump_src_dst), &val);
if (ret < 0) {
pr_err("JUMP_INCDEC: SRC_DST not supported. SEC PC: %d; Instr: %d\n",
program->current_pc,
@@ -147,7 +147,7 @@ rta_jump(struct program *program, uint64_t address,
opcode |= val;
__rta_map_flags(test_condition, jump_test_math_cond,
- ARRAY_SIZE(jump_test_math_cond), &opcode);
+ RTE_DIM(jump_test_math_cond), &opcode);
}
/* write local offset field for local jumps and user-defined halt */
diff --git a/drivers/crypto/dpaa2_sec/hw/rta/nfifo_cmd.h b/drivers/crypto/dpaa2_sec/hw/rta/nfifo_cmd.h
index 85092d961..421f6c763 100644
--- a/drivers/crypto/dpaa2_sec/hw/rta/nfifo_cmd.h
+++ b/drivers/crypto/dpaa2_sec/hw/rta/nfifo_cmd.h
@@ -118,7 +118,7 @@ rta_nfifo_load(struct program *program, uint32_t src,
opcode |= val;
/* write type field */
- ret = __rta_map_opcode(data, nfifo_data, ARRAY_SIZE(nfifo_data), &val);
+ ret = __rta_map_opcode(data, nfifo_data, RTE_DIM(nfifo_data), &val);
if (ret < 0) {
pr_err("NFIFO: Invalid data. SEC PC: %d; Instr: %d\n",
program->current_pc, program->current_instruction);
diff --git a/drivers/net/atlantic/atl_hw_regs.h b/drivers/net/atlantic/atl_hw_regs.h
index a2d6ca804..e642747c3 100644
--- a/drivers/net/atlantic/atl_hw_regs.h
+++ b/drivers/net/atlantic/atl_hw_regs.h
@@ -26,7 +26,6 @@
#define mdelay rte_delay_ms
#define udelay rte_delay_us
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#define BIT(x) (1UL << (x))
#define AQ_HW_WAIT_FOR(_B_, _US_, _N_) \
diff --git a/drivers/net/atlantic/hw_atl/hw_atl_utils.c b/drivers/net/atlantic/hw_atl/hw_atl_utils.c
index 84d11ab3a..351f61d76 100644
--- a/drivers/net/atlantic/hw_atl/hw_atl_utils.c
+++ b/drivers/net/atlantic/hw_atl/hw_atl_utils.c
@@ -647,7 +647,7 @@ static int hw_atl_utils_get_mac_permanent(struct aq_hw_s *self,
aq_hw_read_reg(self, 0x00000374U) +
(40U * 4U),
mac_addr,
- ARRAY_SIZE(mac_addr));
+ RTE_DIM(mac_addr));
if (err < 0) {
mac_addr[0] = 0U;
mac_addr[1] = 0U;
@@ -827,7 +827,7 @@ static const u32 hw_atl_utils_hw_mac_regs[] = {
unsigned int hw_atl_utils_hw_get_reg_length(void)
{
- return ARRAY_SIZE(hw_atl_utils_hw_mac_regs);
+ return RTE_DIM(hw_atl_utils_hw_mac_regs);
}
int hw_atl_utils_hw_get_regs(struct aq_hw_s *self,
diff --git a/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c b/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
index 70d6e14bb..5ff795df9 100644
--- a/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
+++ b/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
@@ -221,7 +221,7 @@ int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8 *mac)
err = hw_atl_utils_fw_downld_dwords(self,
efuse_addr + (40U * 4U),
mac_addr,
- ARRAY_SIZE(mac_addr));
+ RTE_DIM(mac_addr));
if (err)
return err;
mac_addr[0] = rte_constant_bswap32(mac_addr[0]);
diff --git a/drivers/net/axgbe/axgbe_common.h b/drivers/net/axgbe/axgbe_common.h
index 34f60f156..8152f4691 100644
--- a/drivers/net/axgbe/axgbe_common.h
+++ b/drivers/net/axgbe/axgbe_common.h
@@ -40,9 +40,6 @@
#include <rte_io.h>
#define BIT(nr) (1 << (nr))
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
-#endif
#define AXGBE_HZ 250
diff --git a/drivers/net/axgbe/axgbe_dev.c b/drivers/net/axgbe/axgbe_dev.c
index b1f0bbc8e..ae0d73764 100644
--- a/drivers/net/axgbe/axgbe_dev.c
+++ b/drivers/net/axgbe/axgbe_dev.c
@@ -640,7 +640,7 @@ static int axgbe_write_rss_lookup_table(struct axgbe_port *pdata)
unsigned int i;
int ret;
- for (i = 0; i < ARRAY_SIZE(pdata->rss_table); i++) {
+ for (i = 0; i < RTE_DIM(pdata->rss_table); i++) {
ret = axgbe_write_rss_reg(pdata,
AXGBE_RSS_LOOKUP_TABLE_TYPE, i,
pdata->rss_table[i]);
diff --git a/drivers/net/bnx2x/bnx2x.c b/drivers/net/bnx2x/bnx2x.c
index 1a088269f..579e39c55 100644
--- a/drivers/net/bnx2x/bnx2x.c
+++ b/drivers/net/bnx2x/bnx2x.c
@@ -11054,14 +11054,12 @@ static void bnx2x_tx_hw_flushed(struct bnx2x_softc *sc, uint32_t poll_count)
uint32_t i;
/* Verify the command queues are flushed P0, P1, P4 */
- for (i = 0; i < ARRAY_SIZE(cmd_regs); i++) {
+ for (i = 0; i < RTE_DIM(cmd_regs); i++)
bnx2x_pbf_pN_cmd_flushed(sc, &cmd_regs[i], poll_count);
- }
/* Verify the transmission buffers are flushed P0, P1, P4 */
- for (i = 0; i < ARRAY_SIZE(buf_regs); i++) {
+ for (i = 0; i < RTE_DIM(buf_regs); i++)
bnx2x_pbf_pN_buf_flushed(sc, &buf_regs[i], poll_count);
- }
}
static void bnx2x_hw_enable_status(struct bnx2x_softc *sc)
diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index ceaecb031..be98dc333 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -91,12 +91,6 @@
#define PCIM_EXP_CTL_MAX_READ_REQUEST PCIEM_CTL_MAX_READ_REQUEST
#endif
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
-#endif
-#ifndef ARRSIZE
-#define ARRSIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
-#endif
#ifndef DIV_ROUND_UP
#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
#endif
diff --git a/drivers/net/bnx2x/ecore_init.h b/drivers/net/bnx2x/ecore_init.h
index 97dfe69b5..050da3287 100644
--- a/drivers/net/bnx2x/ecore_init.h
+++ b/drivers/net/bnx2x/ecore_init.h
@@ -709,7 +709,7 @@ static inline void ecore_set_mcp_parity(struct bnx2x_softc *sc, uint8_t enable)
uint32_t i;
uint32_t reg_val;
- for (i = 0; i < ARRSIZE(mcp_attn_ctl_regs); i++) {
+ for (i = 0; i < RTE_DIM(mcp_attn_ctl_regs); i++) {
reg_val = REG_RD(sc, mcp_attn_ctl_regs[i]);
if (enable)
@@ -735,7 +735,7 @@ static inline void ecore_disable_blocks_parity(struct bnx2x_softc *sc)
{
uint32_t i;
- for (i = 0; i < ARRSIZE(ecore_blocks_parity_data); i++) {
+ for (i = 0; i < RTE_DIM(ecore_blocks_parity_data); i++) {
uint32_t dis_mask = ecore_parity_reg_mask(sc, i);
if (dis_mask) {
@@ -769,7 +769,7 @@ static inline void ecore_clear_blocks_parity(struct bnx2x_softc *sc)
REG_WR(sc, USEM_REG_FAST_MEMORY + SEM_FAST_REG_PARITY_RST, 0x1);
REG_WR(sc, CSEM_REG_FAST_MEMORY + SEM_FAST_REG_PARITY_RST, 0x1);
- for (i = 0; i < ARRSIZE(ecore_blocks_parity_data); i++) {
+ for (i = 0; i < RTE_DIM(ecore_blocks_parity_data); i++) {
uint32_t reg_mask = ecore_parity_reg_mask(sc, i);
if (reg_mask) {
@@ -801,7 +801,7 @@ static inline void ecore_enable_blocks_parity(struct bnx2x_softc *sc)
{
uint32_t i;
- for (i = 0; i < ARRSIZE(ecore_blocks_parity_data); i++) {
+ for (i = 0; i < RTE_DIM(ecore_blocks_parity_data); i++) {
uint32_t reg_mask = ecore_parity_reg_mask(sc, i);
if (reg_mask)
diff --git a/drivers/net/bnx2x/ecore_sp.c b/drivers/net/bnx2x/ecore_sp.c
index 5ac22e725..7a65c56fd 100644
--- a/drivers/net/bnx2x/ecore_sp.c
+++ b/drivers/net/bnx2x/ecore_sp.c
@@ -5231,7 +5231,7 @@ static int ecore_func_send_tx_start(struct bnx2x_softc *sc, struct ecore_func_st
rdata->dcb_version = tx_start_params->dcb_version;
rdata->dont_add_pri_0 = tx_start_params->dont_add_pri_0;
- for (i = 0; i < ARRAY_SIZE(rdata->traffic_type_to_priority_cos); i++)
+ for (i = 0; i < RTE_DIM(rdata->traffic_type_to_priority_cos); i++)
rdata->traffic_type_to_priority_cos[i] =
tx_start_params->traffic_type_to_priority_cos[i];
diff --git a/drivers/net/bnx2x/elink.c b/drivers/net/bnx2x/elink.c
index b65126d71..65ad309f9 100644
--- a/drivers/net/bnx2x/elink.c
+++ b/drivers/net/bnx2x/elink.c
@@ -4514,7 +4514,7 @@ static void elink_warpcore_enable_AN_KR2(struct elink_phy *phy,
elink_cl45_read_or_write(sc, phy, MDIO_WC_DEVAD,
MDIO_WC_REG_CL49_USERB0_CTRL, (3 << 6));
- for (i = 0; i < ARRAY_SIZE(reg_set); i++)
+ for (i = 0; i < RTE_DIM(reg_set); i++)
elink_cl45_write(sc, phy, reg_set[i].devad, reg_set[i].reg,
reg_set[i].val);
@@ -4549,7 +4549,7 @@ static void elink_disable_kr2(struct elink_params *params,
};
ELINK_DEBUG_P0(sc, "Disabling 20G-KR2");
- for (i = 0; i < (int)ARRAY_SIZE(reg_set); i++)
+ for (i = 0; i < (int)RTE_DIM(reg_set); i++)
elink_cl45_write(sc, phy, reg_set[i].devad, reg_set[i].reg,
reg_set[i].val);
params->link_attr_sync &= ~LINK_ATTR_SYNC_KR2_ENABLE;
@@ -4603,7 +4603,7 @@ static void elink_warpcore_enable_AN_KR(struct elink_phy *phy,
};
ELINK_DEBUG_P0(sc, "Enable Auto Negotiation for KR");
/* Set to default registers that may be overridden by 10G force */
- for (i = 0; i < ARRAY_SIZE(reg_set); i++)
+ for (i = 0; i < RTE_DIM(reg_set); i++)
elink_cl45_write(sc, phy, reg_set[i].devad, reg_set[i].reg,
reg_set[i].val);
@@ -4757,7 +4757,7 @@ static void elink_warpcore_set_10G_KR(struct elink_phy *phy,
{MDIO_PMA_DEVAD, MDIO_WC_REG_PMD_KR_CONTROL, 0x2}
};
- for (i = 0; i < ARRAY_SIZE(reg_set); i++)
+ for (i = 0; i < RTE_DIM(reg_set); i++)
elink_cl45_write(sc, phy, reg_set[i].devad, reg_set[i].reg,
reg_set[i].val);
@@ -5176,7 +5176,7 @@ static void elink_warpcore_clear_regs(struct elink_phy *phy,
elink_cl45_read_or_write(sc, phy, MDIO_WC_DEVAD,
MDIO_WC_REG_RX66_CONTROL, (3 << 13));
- for (i = 0; i < ARRAY_SIZE(wc_regs); i++)
+ for (i = 0; i < RTE_DIM(wc_regs); i++)
elink_cl45_write(sc, phy, wc_regs[i].devad, wc_regs[i].reg,
wc_regs[i].val);
@@ -10652,7 +10652,7 @@ static void elink_save_848xx_spirom_version(struct elink_phy *phy,
} else {
/* For 32-bit registers in 848xx, access via MDIO2ARM i/f. */
/* (1) set reg 0xc200_0014(SPI_BRIDGE_CTRL_2) to 0x03000000 */
- for (i = 0; i < ARRAY_SIZE(reg_set); i++)
+ for (i = 0; i < RTE_DIM(reg_set); i++)
elink_cl45_write(sc, phy, reg_set[i].devad,
reg_set[i].reg, reg_set[i].val);
@@ -10723,7 +10723,7 @@ static void elink_848xx_set_led(struct bnx2x_softc *sc,
MDIO_PMA_DEVAD,
MDIO_PMA_REG_8481_LINK_SIGNAL, val);
- for (i = 0; i < ARRAY_SIZE(reg_set); i++)
+ for (i = 0; i < RTE_DIM(reg_set); i++)
elink_cl45_write(sc, phy, reg_set[i].devad, reg_set[i].reg,
reg_set[i].val);
diff --git a/drivers/net/bnx2x/elink.h b/drivers/net/bnx2x/elink.h
index dd70ac6c6..3a1070b46 100644
--- a/drivers/net/bnx2x/elink.h
+++ b/drivers/net/bnx2x/elink.h
@@ -86,7 +86,6 @@ extern void elink_cb_notify_link_changed(struct bnx2x_softc *sc);
#define ELINK_EVENT_ID_SFP_UNQUALIFIED_MODULE 1
#define ELINK_EVENT_ID_SFP_POWER_FAULT 2
-#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
/* Debug prints */
#ifdef ELINK_DEBUG
diff --git a/drivers/net/cxgbe/base/t4_hw.c b/drivers/net/cxgbe/base/t4_hw.c
index 71ad1cb0f..56e19d225 100644
--- a/drivers/net/cxgbe/base/t4_hw.c
+++ b/drivers/net/cxgbe/base/t4_hw.c
@@ -387,7 +387,7 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox,
*/
if (sleep_ok) {
ms = delay[delay_idx]; /* last element may repeat */
- if (delay_idx < ARRAY_SIZE(delay) - 1)
+ if (delay_idx < RTE_DIM(delay) - 1)
delay_idx++;
msleep(ms);
} else {
@@ -470,7 +470,7 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox,
for (i = 0; i < timeout && !(pcie_fw & F_PCIE_FW_ERR); i += ms) {
if (sleep_ok) {
ms = delay[delay_idx]; /* last element may repeat */
- if (delay_idx < ARRAY_SIZE(delay) - 1)
+ if (delay_idx < RTE_DIM(delay) - 1)
delay_idx++;
msleep(ms);
} else {
@@ -1923,12 +1923,12 @@ void t4_get_regs(struct adapter *adap, void *buf, size_t buf_size)
switch (chip_version) {
case CHELSIO_T5:
reg_ranges = t5_reg_ranges;
- reg_ranges_size = ARRAY_SIZE(t5_reg_ranges);
+ reg_ranges_size = RTE_DIM(t5_reg_ranges);
break;
case CHELSIO_T6:
reg_ranges = t6_reg_ranges;
- reg_ranges_size = ARRAY_SIZE(t6_reg_ranges);
+ reg_ranges_size = RTE_DIM(t6_reg_ranges);
break;
default:
@@ -2653,7 +2653,7 @@ static int t4_get_exprom_version(struct adapter *adapter, u32 *vers)
int ret;
ret = t4_read_flash(adapter, FLASH_EXP_ROM_START,
- ARRAY_SIZE(exprom_header_buf),
+ RTE_DIM(exprom_header_buf),
exprom_header_buf, 0);
if (ret)
return ret;
@@ -3112,7 +3112,7 @@ const char *t4_get_port_type_description(enum fw_port_type port_type)
"KR_SFP28",
};
- if (port_type < ARRAY_SIZE(port_type_description))
+ if (port_type < RTE_DIM(port_type_description))
return port_type_description[port_type];
return "UNKNOWN";
}
@@ -4492,7 +4492,7 @@ static const char *t4_link_down_rc_str(unsigned char link_down_rc)
"Reserved",
};
- if (link_down_rc >= ARRAY_SIZE(reason))
+ if (link_down_rc >= RTE_DIM(reason))
return "Bad Reason Code";
return reason[link_down_rc];
@@ -4815,7 +4815,7 @@ int t4_get_flash_params(struct adapter *adapter)
/**
* Check to see if it's one of our non-standard supported Flash parts.
*/
- for (part = 0; part < ARRAY_SIZE(supported_flash); part++) {
+ for (part = 0; part < RTE_DIM(supported_flash); part++) {
if (supported_flash[part].vendor_and_model_id == flashid) {
adapter->params.sf_size =
supported_flash[part].size_mb;
diff --git a/drivers/net/cxgbe/base/t4vf_hw.c b/drivers/net/cxgbe/base/t4vf_hw.c
index 649bacfb2..70eaa79d0 100644
--- a/drivers/net/cxgbe/base/t4vf_hw.c
+++ b/drivers/net/cxgbe/base/t4vf_hw.c
@@ -143,7 +143,7 @@ int t4vf_wr_mbox_core(struct adapter *adapter,
*/
if (sleep_ok) {
ms = delay[delay_idx]; /* last element may repeat */
- if (delay_idx < ARRAY_SIZE(delay) - 1)
+ if (delay_idx < RTE_DIM(delay) - 1)
delay_idx++;
msleep(ms);
} else {
@@ -186,7 +186,7 @@ int t4vf_wr_mbox_core(struct adapter *adapter,
for (i = 0; i < FW_CMD_MAX_TIMEOUT; i++) {
if (sleep_ok) {
ms = delay[delay_idx]; /* last element may repeat */
- if (delay_idx < ARRAY_SIZE(delay) - 1)
+ if (delay_idx < RTE_DIM(delay) - 1)
delay_idx++;
msleep(ms);
} else {
diff --git a/drivers/net/cxgbe/cxgbe_compat.h b/drivers/net/cxgbe/cxgbe_compat.h
index 20e4f8af2..61478cba9 100644
--- a/drivers/net/cxgbe/cxgbe_compat.h
+++ b/drivers/net/cxgbe/cxgbe_compat.h
@@ -144,8 +144,6 @@ typedef uint64_t dma_addr_t;
(type *)((char *)__mptr - offsetof(type, member)); })
#endif
-#define ARRAY_SIZE(arr) RTE_DIM(arr)
-
#define cpu_to_be16(o) rte_cpu_to_be_16(o)
#define cpu_to_be32(o) rte_cpu_to_be_32(o)
#define cpu_to_be64(o) rte_cpu_to_be_64(o)
diff --git a/drivers/net/cxgbe/cxgbe_flow.c b/drivers/net/cxgbe/cxgbe_flow.c
index 9ee8353ae..1a1765036 100644
--- a/drivers/net/cxgbe/cxgbe_flow.c
+++ b/drivers/net/cxgbe/cxgbe_flow.c
@@ -891,13 +891,13 @@ cxgbe_rtef_parse_items(struct rte_flow *flow,
{
struct adapter *adap = ethdev2adap(flow->dev);
const struct rte_flow_item *i;
- char repeat[ARRAY_SIZE(parseitem)] = {0};
+ char repeat[RTE_DIM(parseitem)] = {0};
for (i = items; i->type != RTE_FLOW_ITEM_TYPE_END; i++) {
struct chrte_fparse *idx;
int ret;
- if (i->type >= ARRAY_SIZE(parseitem))
+ if (i->type >= RTE_DIM(parseitem))
return rte_flow_error_set(e, ENOTSUP,
RTE_FLOW_ERROR_TYPE_ITEM,
i, "Item not supported");
diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c
index f6967a3e4..d647dd751 100644
--- a/drivers/net/cxgbe/cxgbe_main.c
+++ b/drivers/net/cxgbe/cxgbe_main.c
@@ -208,7 +208,7 @@ static int closest_timer(const struct sge *s, int time)
unsigned int i, match = 0;
int delta, min_delta = INT_MAX;
- for (i = 0; i < ARRAY_SIZE(s->timer_val); i++) {
+ for (i = 0; i < RTE_DIM(s->timer_val); i++) {
delta = time - s->timer_val[i];
if (delta < 0)
delta = -delta;
@@ -225,7 +225,7 @@ static int closest_thres(const struct sge *s, int thres)
unsigned int i, match = 0;
int delta, min_delta = INT_MAX;
- for (i = 0; i < ARRAY_SIZE(s->counter_val); i++) {
+ for (i = 0; i < RTE_DIM(s->counter_val); i++) {
delta = thres - s->counter_val[i];
if (delta < 0)
delta = -delta;
@@ -547,7 +547,7 @@ void cxgbe_cfg_queues(struct rte_eth_dev *eth_dev)
qidx += pi->n_rx_qsets;
}
- for (i = 0; i < ARRAY_SIZE(s->ethrxq); i++) {
+ for (i = 0; i < RTE_DIM(s->ethrxq); i++) {
struct sge_eth_rxq *r = &s->ethrxq[i];
init_rspq(adap, &r->rspq, 5, 32, 1024, 64);
@@ -555,7 +555,7 @@ void cxgbe_cfg_queues(struct rte_eth_dev *eth_dev)
r->fl.size = (r->usembufs ? 1024 : 72);
}
- for (i = 0; i < ARRAY_SIZE(s->ethtxq); i++)
+ for (i = 0; i < RTE_DIM(s->ethtxq); i++)
s->ethtxq[i].q.size = 1024;
init_rspq(adap, &adap->sge.fw_evtq, 0, 0, 1024, 64);
@@ -1325,7 +1325,7 @@ void t4_os_portmod_changed(const struct adapter *adap, int port_id)
if (pi->mod_type == FW_PORT_MOD_TYPE_NONE)
dev_info(adap, "Port%d: port module unplugged\n", pi->port_id);
- else if (pi->mod_type < ARRAY_SIZE(mod_str))
+ else if (pi->mod_type < RTE_DIM(mod_str))
dev_info(adap, "Port%d: %s port module inserted\n", pi->port_id,
mod_str[pi->mod_type]);
else if (pi->mod_type == FW_PORT_MOD_TYPE_NOTSUPPORTED)
diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index aba85a209..e6b84c083 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c
@@ -2298,7 +2298,7 @@ void t4_free_sge_resources(struct adapter *adap)
}
/* clean up control Tx queues */
- for (i = 0; i < ARRAY_SIZE(adap->sge.ctrlq); i++) {
+ for (i = 0; i < RTE_DIM(adap->sge.ctrlq); i++) {
struct sge_ctrl_txq *cq = &adap->sge.ctrlq[i];
if (cq->q.desc) {
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index aa84fabc5..d4f29acc4 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -54,8 +54,6 @@
#define ENA_HASH_KEY_SIZE 40
#define ETH_GSTRING_LEN 32
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
#define ENA_MIN_RING_DESC 128
enum ethtool_stringset {
@@ -119,9 +117,9 @@ static const struct ena_stats ena_stats_rx_strings[] = {
ENA_STAT_RX_ENTRY(bad_req_id),
};
-#define ENA_STATS_ARRAY_GLOBAL ARRAY_SIZE(ena_stats_global_strings)
-#define ENA_STATS_ARRAY_TX ARRAY_SIZE(ena_stats_tx_strings)
-#define ENA_STATS_ARRAY_RX ARRAY_SIZE(ena_stats_rx_strings)
+#define ENA_STATS_ARRAY_GLOBAL RTE_DIM(ena_stats_global_strings)
+#define ENA_STATS_ARRAY_TX RTE_DIM(ena_stats_tx_strings)
+#define ENA_STATS_ARRAY_RX RTE_DIM(ena_stats_rx_strings)
#define QUEUE_OFFLOADS (DEV_TX_OFFLOAD_TCP_CKSUM |\
DEV_TX_OFFLOAD_UDP_CKSUM |\
diff --git a/drivers/net/enic/base/vnic_dev.c b/drivers/net/enic/base/vnic_dev.c
index 8e190687d..3b9a336ff 100644
--- a/drivers/net/enic/base/vnic_dev.c
+++ b/drivers/net/enic/base/vnic_dev.c
@@ -417,11 +417,11 @@ int vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
switch (vdev->proxy) {
case PROXY_BY_INDEX:
err = vnic_dev_cmd_proxy(vdev, CMD_PROXY_BY_INDEX, cmd,
- args, ARRAY_SIZE(args), wait);
+ args, RTE_DIM(args), wait);
break;
case PROXY_BY_BDF:
err = vnic_dev_cmd_proxy(vdev, CMD_PROXY_BY_BDF, cmd,
- args, ARRAY_SIZE(args), wait);
+ args, RTE_DIM(args), wait);
break;
case PROXY_NONE:
default:
diff --git a/drivers/net/enic/base/vnic_devcmd.h b/drivers/net/enic/base/vnic_devcmd.h
index fffe307e0..5a4f48106 100644
--- a/drivers/net/enic/base/vnic_devcmd.h
+++ b/drivers/net/enic/base/vnic_devcmd.h
@@ -63,8 +63,6 @@
#define _CMD_VTYPE(cmd) (((cmd) >> _CMD_VTYPESHIFT) & _CMD_VTYPEMASK)
#define _CMD_N(cmd) (((cmd) >> _CMD_NSHIFT) & _CMD_NMASK)
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
enum vnic_devcmd_cmd {
CMD_NONE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_NONE, 0),
diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c
index 3eebfdd42..1d31b11d6 100644
--- a/drivers/net/hns3/hns3_cmd.c
+++ b/drivers/net/hns3/hns3_cmd.c
@@ -268,7 +268,7 @@ hns3_is_special_opcode(uint16_t opcode)
HNS3_OPC_QUERY_64_BIT_REG};
uint32_t i;
- for (i = 0; i < ARRAY_SIZE(spec_opcode); i++)
+ for (i = 0; i < RTE_DIM(spec_opcode); i++)
if (spec_opcode[i] == opcode)
return true;
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index 9710e45fb..c52f27d5b 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -570,8 +570,6 @@ static inline uint32_t hns3_read_reg(void *base, uint32_t reg)
#define hns3_read_dev(a, reg) \
hns3_read_reg((a)->io_base, (reg))
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
#define NEXT_ITEM_OF_ACTION(act, actions, index) \
do { \
act = (actions) + (index); \
diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index bcd121f48..e689e034f 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -982,37 +982,37 @@ hns3_parse_normal(const struct rte_flow_item *item,
case RTE_FLOW_ITEM_TYPE_ETH:
ret = hns3_parse_eth(item, rule, error);
step_mngr->items = L2_next_items;
- step_mngr->count = ARRAY_SIZE(L2_next_items);
+ step_mngr->count = RTE_DIM(L2_next_items);
break;
case RTE_FLOW_ITEM_TYPE_VLAN:
ret = hns3_parse_vlan(item, rule, error);
step_mngr->items = L2_next_items;
- step_mngr->count = ARRAY_SIZE(L2_next_items);
+ step_mngr->count = RTE_DIM(L2_next_items);
break;
case RTE_FLOW_ITEM_TYPE_IPV4:
ret = hns3_parse_ipv4(item, rule, error);
step_mngr->items = L3_next_items;
- step_mngr->count = ARRAY_SIZE(L3_next_items);
+ step_mngr->count = RTE_DIM(L3_next_items);
break;
case RTE_FLOW_ITEM_TYPE_IPV6:
ret = hns3_parse_ipv6(item, rule, error);
step_mngr->items = L3_next_items;
- step_mngr->count = ARRAY_SIZE(L3_next_items);
+ step_mngr->count = RTE_DIM(L3_next_items);
break;
case RTE_FLOW_ITEM_TYPE_TCP:
ret = hns3_parse_tcp(item, rule, error);
step_mngr->items = L4_next_items;
- step_mngr->count = ARRAY_SIZE(L4_next_items);
+ step_mngr->count = RTE_DIM(L4_next_items);
break;
case RTE_FLOW_ITEM_TYPE_UDP:
ret = hns3_parse_udp(item, rule, error);
step_mngr->items = L4_next_items;
- step_mngr->count = ARRAY_SIZE(L4_next_items);
+ step_mngr->count = RTE_DIM(L4_next_items);
break;
case RTE_FLOW_ITEM_TYPE_SCTP:
ret = hns3_parse_sctp(item, rule, error);
step_mngr->items = L4_next_items;
- step_mngr->count = ARRAY_SIZE(L4_next_items);
+ step_mngr->count = RTE_DIM(L4_next_items);
break;
default:
return rte_flow_error_set(error, ENOTSUP,
@@ -1122,7 +1122,7 @@ hns3_parse_fdir_filter(struct rte_eth_dev *dev,
"fdir_conf.mode isn't perfect");
step_mngr.items = first_items;
- step_mngr.count = ARRAY_SIZE(first_items);
+ step_mngr.count = RTE_DIM(first_items);
for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
if (item->type == RTE_FLOW_ITEM_TYPE_VOID)
continue;
@@ -1136,7 +1136,7 @@ hns3_parse_fdir_filter(struct rte_eth_dev *dev,
if (ret)
return ret;
step_mngr.items = tunnel_next_items;
- step_mngr.count = ARRAY_SIZE(tunnel_next_items);
+ step_mngr.count = RTE_DIM(tunnel_next_items);
} else {
ret = hns3_parse_normal(item, rule, &step_mngr, error);
if (ret)
diff --git a/drivers/net/i40e/base/i40e_diag.c b/drivers/net/i40e/base/i40e_diag.c
index 3ccbea482..ca6d70762 100644
--- a/drivers/net/i40e/base/i40e_diag.c
+++ b/drivers/net/i40e/base/i40e_diag.c
@@ -37,7 +37,7 @@ static enum i40e_status_code i40e_diag_reg_pattern_test(struct i40e_hw *hw,
int i;
orig_val = rd32(hw, reg);
- for (i = 0; i < ARRAY_SIZE(patterns); i++) {
+ for (i = 0; i < RTE_DIM(patterns); i++) {
pat = patterns[i];
wr32(hw, reg, (pat & mask));
val = rd32(hw, reg);
diff --git a/drivers/net/i40e/base/i40e_osdep.h b/drivers/net/i40e/base/i40e_osdep.h
index 8a2d82a8d..704913e2a 100644
--- a/drivers/net/i40e/base/i40e_osdep.h
+++ b/drivers/net/i40e/base/i40e_osdep.h
@@ -150,8 +150,6 @@ static inline uint32_t i40e_read_addr(volatile void *addr)
I40E_PCI_REG_WRITE(I40E_PCI_REG_ADDR((a), (reg)), (value))
#define flush(a) i40e_read_addr(I40E_PCI_REG_ADDR((a), (I40E_GLGEN_STAT)))
-#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
-
/* memory allocation tracking */
struct i40e_dma_mem {
void *va;
diff --git a/drivers/net/iavf/base/iavf_osdep.h b/drivers/net/iavf/base/iavf_osdep.h
index 648026693..308ebdade 100644
--- a/drivers/net/iavf/base/iavf_osdep.h
+++ b/drivers/net/iavf/base/iavf_osdep.h
@@ -121,8 +121,6 @@ uint32_t iavf_read_addr(volatile void *addr)
#define wr32(a, reg, value) \
IAVF_PCI_REG_WRITE(IAVF_PCI_REG_ADDR((a), (reg)), (value))
-#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
-
#define iavf_debug(h, m, s, ...) \
do { \
if (((m) & (h)->debug_mask)) \
diff --git a/drivers/net/ice/base/ice_fdir.c b/drivers/net/ice/base/ice_fdir.c
index 219588c46..6a0b189a7 100644
--- a/drivers/net/ice/base/ice_fdir.c
+++ b/drivers/net/ice/base/ice_fdir.c
@@ -350,7 +350,7 @@ static const struct ice_fdir_base_pkt ice_fdir_pkt[] = {
},
};
-#define ICE_FDIR_NUM_PKT ARRAY_SIZE(ice_fdir_pkt)
+#define ICE_FDIR_NUM_PKT RTE_DIM(ice_fdir_pkt)
/* Flow Direcotr (FD) filter program descriptor Context */
static const struct ice_ctx_ele ice_fd_fltr_desc_ctx_info[] = {
diff --git a/drivers/net/ice/base/ice_flex_pipe.c b/drivers/net/ice/base/ice_flex_pipe.c
index 75bb87079..b295b82d5 100644
--- a/drivers/net/ice/base/ice_flex_pipe.c
+++ b/drivers/net/ice/base/ice_flex_pipe.c
@@ -4219,7 +4219,7 @@ static const struct ice_fd_src_dst_pair ice_fd_pairs[] = {
{ ICE_PROT_SCTP_IL, 1, 2 }
};
-#define ICE_FD_SRC_DST_PAIR_COUNT ARRAY_SIZE(ice_fd_pairs)
+#define ICE_FD_SRC_DST_PAIR_COUNT RTE_DIM(ice_fd_pairs)
/**
* ice_update_fd_swap - set register appropriately for a FD FV extraction
diff --git a/drivers/net/ice/base/ice_flow.c b/drivers/net/ice/base/ice_flow.c
index e03c5d0e7..bbf2197f8 100644
--- a/drivers/net/ice/base/ice_flow.c
+++ b/drivers/net/ice/base/ice_flow.c
@@ -794,7 +794,7 @@ ice_flow_xtract_raws(struct ice_hw *hw, struct ice_flow_prof_params *params,
return ICE_SUCCESS;
if (params->prof->segs[seg].raws_cnt >
- ARRAY_SIZE(params->prof->segs[seg].raws))
+ RTE_DIM(params->prof->segs[seg].raws))
return ICE_ERR_MAX_LIMIT;
/* Offsets within the segment headers are not supported */
diff --git a/drivers/net/ice/base/ice_osdep.h b/drivers/net/ice/base/ice_osdep.h
index 27c1830c5..4b5a8f8ad 100644
--- a/drivers/net/ice/base/ice_osdep.h
+++ b/drivers/net/ice/base/ice_osdep.h
@@ -90,7 +90,6 @@ typedef uint64_t s64;
#define min(a, b) RTE_MIN(a, b)
#define max(a, b) RTE_MAX(a, b)
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
#define FIELD_SIZEOF(t, f) (sizeof(((t *)0)->f))
#define MAKEMASK(m, s) ((m) << (s))
diff --git a/drivers/net/ice/base/ice_switch.c b/drivers/net/ice/base/ice_switch.c
index 80afa74cd..6e3338135 100644
--- a/drivers/net/ice/base/ice_switch.c
+++ b/drivers/net/ice/base/ice_switch.c
@@ -4774,7 +4774,7 @@ ice_fill_valid_words(struct ice_adv_lkup_elem *rule,
for (j = 0; j < sizeof(rule->m_u) / sizeof(u16); j++)
if (((u16 *)&rule->m_u)[j] &&
- (unsigned long)rule->type < ARRAY_SIZE(ice_prot_ext)) {
+ (unsigned long)rule->type < RTE_DIM(ice_prot_ext)) {
/* No more space to accommodate */
if (word >= ICE_MAX_CHAIN_WORDS)
return 0;
diff --git a/drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h b/drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h
index d46574b10..ead813f1d 100644
--- a/drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h
+++ b/drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h
@@ -22,10 +22,6 @@
#define BIT_ULL(x) (1ULL << (x))
#endif
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-#endif
-
#define NFP_ERRNO(err) (errno = (err), -1)
#define NFP_ERRNO_RET(err, ret) (errno = (err), (ret))
#define NFP_NOERR(errv) (errno)
diff --git a/drivers/net/nfp/nfpcore/nfp_cppcore.c b/drivers/net/nfp/nfpcore/nfp_cppcore.c
index dec4a8b6d..02974ee7a 100644
--- a/drivers/net/nfp/nfpcore/nfp_cppcore.c
+++ b/drivers/net/nfp/nfpcore/nfp_cppcore.c
@@ -573,7 +573,7 @@ nfp_cpp_alloc(struct rte_pci_device *dev, int driver_lock_needed)
uint32_t xpbaddr;
size_t tgt;
- for (tgt = 0; tgt < ARRAY_SIZE(cpp->imb_cat_table); tgt++) {
+ for (tgt = 0; tgt < RTE_DIM(cpp->imb_cat_table); tgt++) {
/* Hardcoded XPB IMB Base, island 0 */
xpbaddr = 0x000a0000 + (tgt * 4);
err = nfp_xpb_readl(cpp, xpbaddr,
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.c b/drivers/net/nfp/nfpcore/nfp_nsp.c
index 876a4017c..6a39dd305 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp.c
+++ b/drivers/net/nfp/nfpcore/nfp_nsp.c
@@ -60,7 +60,7 @@ nfp_nsp_print_extended_error(uint32_t ret_val)
if (!ret_val)
return;
- for (i = 0; i < (int)ARRAY_SIZE(nsp_errors); i++)
+ for (i = 0; i < (int)RTE_DIM(nsp_errors); i++)
if (ret_val == (uint32_t)nsp_errors[i].code)
printf("err msg: %s\n", nsp_errors[i].msg);
}
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
index 67946891a..16e425470 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
+++ b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
@@ -138,7 +138,7 @@ nfp_eth_rate2speed(enum nfp_eth_rate rate)
{
int i;
- for (i = 0; i < (int)ARRAY_SIZE(nsp_eth_rate_tbl); i++)
+ for (i = 0; i < (int)RTE_DIM(nsp_eth_rate_tbl); i++)
if (nsp_eth_rate_tbl[i].rate == rate)
return nsp_eth_rate_tbl[i].speed;
@@ -150,7 +150,7 @@ nfp_eth_speed2rate(unsigned int speed)
{
int i;
- for (i = 0; i < (int)ARRAY_SIZE(nsp_eth_rate_tbl); i++)
+ for (i = 0; i < (int)RTE_DIM(nsp_eth_rate_tbl); i++)
if (nsp_eth_rate_tbl[i].speed == speed)
return nsp_eth_rate_tbl[i].rate;
diff --git a/drivers/net/sfc/base/ef10_ev.c b/drivers/net/sfc/base/ef10_ev.c
index 8cabb4e92..df1986370 100644
--- a/drivers/net/sfc/base/ef10_ev.c
+++ b/drivers/net/sfc/base/ef10_ev.c
@@ -1408,7 +1408,7 @@ ef10_ev_rxlabel_init(
#endif
_NOTE(ARGUNUSED(type))
- EFSYS_ASSERT3U(label, <, EFX_ARRAY_SIZE(eep->ee_rxq_state));
+ EFSYS_ASSERT3U(label, <, RTE_DIM(eep->ee_rxq_state));
eersp = &eep->ee_rxq_state[label];
EFSYS_ASSERT3U(eersp->eers_rx_mask, ==, 0);
@@ -1457,7 +1457,7 @@ ef10_ev_rxlabel_fini(
{
efx_evq_rxq_state_t *eersp;
- EFSYS_ASSERT3U(label, <, EFX_ARRAY_SIZE(eep->ee_rxq_state));
+ EFSYS_ASSERT3U(label, <, RTE_DIM(eep->ee_rxq_state));
eersp = &eep->ee_rxq_state[label];
EFSYS_ASSERT3U(eersp->eers_rx_mask, !=, 0);
diff --git a/drivers/net/sfc/base/ef10_filter.c b/drivers/net/sfc/base/ef10_filter.c
index e4f8de51c..1b30d7d09 100644
--- a/drivers/net/sfc/base/ef10_filter.c
+++ b/drivers/net/sfc/base/ef10_filter.c
@@ -1209,7 +1209,7 @@ ef10_filter_insert_multicast_list(
count = 0;
if (count + (brdcst ? 1 : 0) >
- EFX_ARRAY_SIZE(eftp->eft_mulcst_filter_indexes)) {
+ RTE_DIM(eftp->eft_mulcst_filter_indexes)) {
/* Too many MAC addresses */
rc = EINVAL;
goto fail1;
@@ -1378,8 +1378,8 @@ ef10_filter_insert_encap_filters(
uint32_t i;
efx_rc_t rc;
- EFX_STATIC_ASSERT(EFX_ARRAY_SIZE(ef10_filter_encap_list) <=
- EFX_ARRAY_SIZE(table->eft_encap_filter_indexes));
+ EFX_STATIC_ASSERT(RTE_DIM(ef10_filter_encap_list) <=
+ RTE_DIM(table->eft_encap_filter_indexes));
/*
* On Medford, full-featured firmware can identify packets as being
@@ -1396,7 +1396,7 @@ ef10_filter_insert_encap_filters(
* may well, however, fail to insert on unprivileged functions.)
*/
table->eft_encap_filter_count = 0;
- for (i = 0; i < EFX_ARRAY_SIZE(ef10_filter_encap_list); i++) {
+ for (i = 0; i < RTE_DIM(ef10_filter_encap_list); i++) {
efx_filter_spec_t spec;
ef10_filter_encap_entry_t *encap_filter =
&ef10_filter_encap_list[i];
@@ -1448,7 +1448,7 @@ ef10_filter_remove_old(
ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
uint32_t i;
- for (i = 0; i < EFX_ARRAY_SIZE(table->eft_entry); i++) {
+ for (i = 0; i < RTE_DIM(table->eft_entry); i++) {
if (ef10_filter_entry_is_auto_old(table, i)) {
(void) ef10_filter_delete_internal(enp, i);
}
@@ -1708,7 +1708,7 @@ ef10_filter_reconfigure(
EFSYS_PROBE1(fail1, efx_rc_t, rc);
/* Clear auto old flags */
- for (i = 0; i < EFX_ARRAY_SIZE(table->eft_entry); i++) {
+ for (i = 0; i < RTE_DIM(table->eft_entry); i++) {
if (ef10_filter_entry_is_auto_old(table, i)) {
ef10_filter_set_entry_not_auto_old(table, i);
}
diff --git a/drivers/net/sfc/base/ef10_mac.c b/drivers/net/sfc/base/ef10_mac.c
index 3f3153889..b110649e1 100644
--- a/drivers/net/sfc/base/ef10_mac.c
+++ b/drivers/net/sfc/base/ef10_mac.c
@@ -472,7 +472,7 @@ ef10_mac_stats_get_mask(
efx_rc_t rc;
if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size,
- ef10_common, EFX_ARRAY_SIZE(ef10_common))) != 0)
+ ef10_common, RTE_DIM(ef10_common))) != 0)
goto fail1;
if (epp->ep_phy_cap_mask & (1 << MC_CMD_PHY_CAP_40000FDX_LBN)) {
@@ -481,18 +481,18 @@ ef10_mac_stats_get_mask(
};
if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size,
- ef10_40g_extra, EFX_ARRAY_SIZE(ef10_40g_extra))) != 0)
+ ef10_40g_extra, RTE_DIM(ef10_40g_extra))) != 0)
goto fail2;
if (encp->enc_mac_stats_40g_tx_size_bins) {
if ((rc = efx_mac_stats_mask_add_ranges(maskp,
mask_size, ef10_tx_size_bins,
- EFX_ARRAY_SIZE(ef10_tx_size_bins))) != 0)
+ RTE_DIM(ef10_tx_size_bins))) != 0)
goto fail3;
}
} else {
if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size,
- ef10_tx_size_bins, EFX_ARRAY_SIZE(ef10_tx_size_bins))) != 0)
+ ef10_tx_size_bins, RTE_DIM(ef10_tx_size_bins))) != 0)
goto fail4;
}
@@ -502,7 +502,7 @@ ef10_mac_stats_get_mask(
};
if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size,
- ef10_pm_and_rxdp, EFX_ARRAY_SIZE(ef10_pm_and_rxdp))) != 0)
+ ef10_pm_and_rxdp, RTE_DIM(ef10_pm_and_rxdp))) != 0)
goto fail5;
}
@@ -513,7 +513,7 @@ ef10_mac_stats_get_mask(
};
if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size,
- ef10_vadaptor, EFX_ARRAY_SIZE(ef10_vadaptor))) != 0)
+ ef10_vadaptor, RTE_DIM(ef10_vadaptor))) != 0)
goto fail6;
}
@@ -523,7 +523,7 @@ ef10_mac_stats_get_mask(
EFX_MAC_FEC_CORRECTED_SYMBOLS_LANE3 },
};
if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size,
- ef10_fec, EFX_ARRAY_SIZE(ef10_fec))) != 0)
+ ef10_fec, RTE_DIM(ef10_fec))) != 0)
goto fail7;
}
@@ -534,7 +534,7 @@ ef10_mac_stats_get_mask(
};
if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size,
- ef10_rxdp_sdt, EFX_ARRAY_SIZE(ef10_rxdp_sdt))) != 0)
+ ef10_rxdp_sdt, RTE_DIM(ef10_rxdp_sdt))) != 0)
goto fail8;
}
@@ -543,7 +543,7 @@ ef10_mac_stats_get_mask(
{ EFX_MAC_RXDP_HLB_IDLE, EFX_MAC_RXDP_HLB_TIMEOUT },
};
if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size,
- ef10_hlb, EFX_ARRAY_SIZE(ef10_hlb))) != 0)
+ ef10_hlb, RTE_DIM(ef10_hlb))) != 0)
goto fail9;
}
diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index b25ce1908..ab6cc1cca 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -821,7 +821,7 @@ ef10_nic_alloc_piobufs(
unsigned int i;
EFSYS_ASSERT3U(max_piobuf_count, <=,
- EFX_ARRAY_SIZE(enp->en_arch.ef10.ena_piobuf_handle));
+ RTE_DIM(enp->en_arch.ef10.ena_piobuf_handle));
enp->en_arch.ef10.ena_piobuf_count = 0;
@@ -1718,7 +1718,7 @@ ef10_external_port_mapping(
* Infer the internal port -> external number mapping from
* the possible port modes for this NIC.
*/
- for (i = 0; i < EFX_ARRAY_SIZE(__ef10_external_port_mappings); ++i) {
+ for (i = 0; i < RTE_DIM(__ef10_external_port_mappings); ++i) {
struct ef10_external_port_map_s *eepmp =
&__ef10_external_port_mappings[i];
if (eepmp->family != enp->en_family)
diff --git a/drivers/net/sfc/base/ef10_nvram.c b/drivers/net/sfc/base/ef10_nvram.c
index 0d5378ddf..39e276a75 100644
--- a/drivers/net/sfc/base/ef10_nvram.c
+++ b/drivers/net/sfc/base/ef10_nvram.c
@@ -2357,17 +2357,17 @@ ef10_parttbl_get(
switch (enp->en_family) {
case EFX_FAMILY_HUNTINGTON:
*parttblp = hunt_parttbl;
- *parttbl_rowsp = EFX_ARRAY_SIZE(hunt_parttbl);
+ *parttbl_rowsp = RTE_DIM(hunt_parttbl);
break;
case EFX_FAMILY_MEDFORD:
*parttblp = medford_parttbl;
- *parttbl_rowsp = EFX_ARRAY_SIZE(medford_parttbl);
+ *parttbl_rowsp = RTE_DIM(medford_parttbl);
break;
case EFX_FAMILY_MEDFORD2:
*parttblp = medford2_parttbl;
- *parttbl_rowsp = EFX_ARRAY_SIZE(medford2_parttbl);
+ *parttbl_rowsp = RTE_DIM(medford2_parttbl);
break;
default:
diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index 53ddaa987..6b05a95d6 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -20,9 +20,6 @@ extern "C" {
#define EFX_STATIC_ASSERT(_cond) \
((void)sizeof (char[(_cond) ? 1 : -1]))
-#define EFX_ARRAY_SIZE(_array) \
- (sizeof (_array) / sizeof ((_array)[0]))
-
#define EFX_FIELD_OFFSET(_type, _field) \
((size_t)&(((_type *)0)->_field))
diff --git a/drivers/net/sfc/base/efx_port.c b/drivers/net/sfc/base/efx_port.c
index 5fff932be..8810d8679 100644
--- a/drivers/net/sfc/base/efx_port.c
+++ b/drivers/net/sfc/base/efx_port.c
@@ -190,7 +190,7 @@ efx_loopback_type_name(
__in efx_nic_t *enp,
__in efx_loopback_type_t type)
{
- EFX_STATIC_ASSERT(EFX_ARRAY_SIZE(__efx_loopback_type_name) ==
+ EFX_STATIC_ASSERT(RTE_DIM(__efx_loopback_type_name) ==
EFX_LOOPBACK_NTYPES);
_NOTE(ARGUNUSED(enp))
diff --git a/drivers/net/sfc/base/efx_rx.c b/drivers/net/sfc/base/efx_rx.c
index 26999a92f..c603aae02 100644
--- a/drivers/net/sfc/base/efx_rx.c
+++ b/drivers/net/sfc/base/efx_rx.c
@@ -566,7 +566,7 @@ efx_rx_scale_mode_set(
unsigned int type_nflags;
rc = efx_rx_scale_hash_flags_get(enp, alg, type_flags,
- EFX_ARRAY_SIZE(type_flags), &type_nflags);
+ RTE_DIM(type_flags), &type_nflags);
if (rc != 0)
goto fail2;
diff --git a/drivers/net/sfc/base/siena_mac.c b/drivers/net/sfc/base/siena_mac.c
index 928dfc340..c209428db 100644
--- a/drivers/net/sfc/base/siena_mac.c
+++ b/drivers/net/sfc/base/siena_mac.c
@@ -223,7 +223,7 @@ siena_mac_stats_get_mask(
_NOTE(ARGUNUSED(enp))
if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size,
- siena_stats, EFX_ARRAY_SIZE(siena_stats))) != 0)
+ siena_stats, RTE_DIM(siena_stats))) != 0)
goto fail1;
return (0);
diff --git a/drivers/net/sfc/base/siena_nic.c b/drivers/net/sfc/base/siena_nic.c
index 7ba595b75..6474eb410 100644
--- a/drivers/net/sfc/base/siena_nic.c
+++ b/drivers/net/sfc/base/siena_nic.c
@@ -743,10 +743,10 @@ siena_nic_register_test(
efx_rc_t rc;
/* Fill out the register mask entries */
- EFX_STATIC_ASSERT(EFX_ARRAY_SIZE(__siena_register_masks)
- == EFX_ARRAY_SIZE(__siena_registers) * 4);
+ EFX_STATIC_ASSERT(RTE_DIM(__siena_register_masks)
+ == RTE_DIM(__siena_registers) * 4);
- nitems = EFX_ARRAY_SIZE(__siena_registers);
+ nitems = RTE_DIM(__siena_registers);
dwordp = __siena_register_masks;
for (count = 0; count < nitems; ++count) {
rsp = __siena_registers + count;
@@ -757,10 +757,10 @@ siena_nic_register_test(
}
/* Fill out the register table entries */
- EFX_STATIC_ASSERT(EFX_ARRAY_SIZE(__siena_table_masks)
- == EFX_ARRAY_SIZE(__siena_tables) * 4);
+ EFX_STATIC_ASSERT(RTE_DIM(__siena_table_masks)
+ == RTE_DIM(__siena_tables) * 4);
- nitems = EFX_ARRAY_SIZE(__siena_tables);
+ nitems = RTE_DIM(__siena_tables);
dwordp = __siena_table_masks;
for (count = 0; count < nitems; ++count) {
rsp = __siena_tables + count;
@@ -771,21 +771,21 @@ siena_nic_register_test(
}
if ((rc = siena_nic_test_registers(enp, __siena_registers,
- EFX_ARRAY_SIZE(__siena_registers))) != 0)
+ RTE_DIM(__siena_registers))) != 0)
goto fail1;
if ((rc = siena_nic_test_tables(enp, __siena_tables,
EFX_PATTERN_BYTE_ALTERNATE,
- EFX_ARRAY_SIZE(__siena_tables))) != 0)
+ RTE_DIM(__siena_tables))) != 0)
goto fail2;
if ((rc = siena_nic_test_tables(enp, __siena_tables,
EFX_PATTERN_BYTE_CHANGING,
- EFX_ARRAY_SIZE(__siena_tables))) != 0)
+ RTE_DIM(__siena_tables))) != 0)
goto fail3;
if ((rc = siena_nic_test_tables(enp, __siena_tables,
- EFX_PATTERN_BIT_SWEEP, EFX_ARRAY_SIZE(__siena_tables))) != 0)
+ EFX_PATTERN_BIT_SWEEP, RTE_DIM(__siena_tables))) != 0)
goto fail4;
return (0);
diff --git a/drivers/net/sfc/base/siena_nvram.c b/drivers/net/sfc/base/siena_nvram.c
index 51e601ec1..e278a4a74 100644
--- a/drivers/net/sfc/base/siena_nvram.c
+++ b/drivers/net/sfc/base/siena_nvram.c
@@ -246,7 +246,7 @@ siena_nvram_type_to_partn(
EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES);
EFSYS_ASSERT(partnp != NULL);
- for (i = 0; i < EFX_ARRAY_SIZE(siena_parttbl); i++) {
+ for (i = 0; i < RTE_DIM(siena_parttbl); i++) {
siena_parttbl_entry_t *entry = &siena_parttbl[i];
if (entry->port == emip->emi_port && entry->nvtype == type) {
@@ -274,7 +274,7 @@ siena_nvram_test(
* Iterate over the list of supported partition types
* applicable to *this* port
*/
- for (i = 0; i < EFX_ARRAY_SIZE(siena_parttbl); i++) {
+ for (i = 0; i < RTE_DIM(siena_parttbl); i++) {
entry = &siena_parttbl[i];
if (entry->port != emip->emi_port ||
@@ -517,7 +517,7 @@ siena_nvram_partn_get_version(
* that have access to this partition.
*/
version[0] = version[1] = version[2] = version[3] = 0;
- for (i = 0; i < EFX_ARRAY_SIZE(siena_parttbl); i++) {
+ for (i = 0; i < RTE_DIM(siena_parttbl); i++) {
siena_mc_fw_version_t *verp;
unsigned int nitems;
uint16_t temp[4];
diff --git a/drivers/net/thunderx/base/nicvf_hw.c b/drivers/net/thunderx/base/nicvf_hw.c
index 5b1abe201..1146807b6 100644
--- a/drivers/net/thunderx/base/nicvf_hw.c
+++ b/drivers/net/thunderx/base/nicvf_hw.c
@@ -134,7 +134,7 @@ nicvf_reg_dump(struct nicvf *nic, uint64_t *data)
dump_stdout = data ? 0 : 1;
- for (i = 0; i < NICVF_ARRAY_SIZE(nicvf_reg_tbl); i++)
+ for (i = 0; i < RTE_DIM(nicvf_reg_tbl); i++)
if (dump_stdout)
nicvf_log("%24s = 0x%" PRIx64 "\n",
nicvf_reg_tbl[i].name,
@@ -142,7 +142,7 @@ nicvf_reg_dump(struct nicvf *nic, uint64_t *data)
else
*data++ = nicvf_reg_read(nic, nicvf_reg_tbl[i].offset);
- for (i = 0; i < NICVF_ARRAY_SIZE(nicvf_multi_reg_tbl); i++)
+ for (i = 0; i < RTE_DIM(nicvf_multi_reg_tbl); i++)
if (dump_stdout)
nicvf_log("%24s = 0x%" PRIx64 "\n",
nicvf_multi_reg_tbl[i].name,
@@ -153,7 +153,7 @@ nicvf_reg_dump(struct nicvf *nic, uint64_t *data)
nicvf_multi_reg_tbl[i].offset);
for (q = 0; q < MAX_CMP_QUEUES_PER_QS; q++)
- for (i = 0; i < NICVF_ARRAY_SIZE(nicvf_qset_cq_reg_tbl); i++)
+ for (i = 0; i < RTE_DIM(nicvf_qset_cq_reg_tbl); i++)
if (dump_stdout)
nicvf_log("%30s(%d) = 0x%" PRIx64 "\n",
nicvf_qset_cq_reg_tbl[i].name, q,
@@ -164,7 +164,7 @@ nicvf_reg_dump(struct nicvf *nic, uint64_t *data)
nicvf_qset_cq_reg_tbl[i].offset, q);
for (q = 0; q < MAX_RCV_QUEUES_PER_QS; q++)
- for (i = 0; i < NICVF_ARRAY_SIZE(nicvf_qset_rq_reg_tbl); i++)
+ for (i = 0; i < RTE_DIM(nicvf_qset_rq_reg_tbl); i++)
if (dump_stdout)
nicvf_log("%30s(%d) = 0x%" PRIx64 "\n",
nicvf_qset_rq_reg_tbl[i].name, q,
@@ -175,7 +175,7 @@ nicvf_reg_dump(struct nicvf *nic, uint64_t *data)
nicvf_qset_rq_reg_tbl[i].offset, q);
for (q = 0; q < MAX_SND_QUEUES_PER_QS; q++)
- for (i = 0; i < NICVF_ARRAY_SIZE(nicvf_qset_sq_reg_tbl); i++)
+ for (i = 0; i < RTE_DIM(nicvf_qset_sq_reg_tbl); i++)
if (dump_stdout)
nicvf_log("%30s(%d) = 0x%" PRIx64 "\n",
nicvf_qset_sq_reg_tbl[i].name, q,
@@ -186,7 +186,7 @@ nicvf_reg_dump(struct nicvf *nic, uint64_t *data)
nicvf_qset_sq_reg_tbl[i].offset, q);
for (q = 0; q < MAX_RCV_BUF_DESC_RINGS_PER_QS; q++)
- for (i = 0; i < NICVF_ARRAY_SIZE(nicvf_qset_rbdr_reg_tbl); i++)
+ for (i = 0; i < RTE_DIM(nicvf_qset_rbdr_reg_tbl); i++)
if (dump_stdout)
nicvf_log("%30s(%d) = 0x%" PRIx64 "\n",
nicvf_qset_rbdr_reg_tbl[i].name, q,
@@ -203,15 +203,15 @@ nicvf_reg_get_count(void)
{
int nr_regs;
- nr_regs = NICVF_ARRAY_SIZE(nicvf_reg_tbl);
- nr_regs += NICVF_ARRAY_SIZE(nicvf_multi_reg_tbl);
- nr_regs += NICVF_ARRAY_SIZE(nicvf_qset_cq_reg_tbl) *
+ nr_regs = RTE_DIM(nicvf_reg_tbl);
+ nr_regs += RTE_DIM(nicvf_multi_reg_tbl);
+ nr_regs += RTE_DIM(nicvf_qset_cq_reg_tbl) *
MAX_CMP_QUEUES_PER_QS;
- nr_regs += NICVF_ARRAY_SIZE(nicvf_qset_rq_reg_tbl) *
+ nr_regs += RTE_DIM(nicvf_qset_rq_reg_tbl) *
MAX_RCV_QUEUES_PER_QS;
- nr_regs += NICVF_ARRAY_SIZE(nicvf_qset_sq_reg_tbl) *
+ nr_regs += RTE_DIM(nicvf_qset_sq_reg_tbl) *
MAX_SND_QUEUES_PER_QS;
- nr_regs += NICVF_ARRAY_SIZE(nicvf_qset_rbdr_reg_tbl) *
+ nr_regs += RTE_DIM(nicvf_qset_rbdr_reg_tbl) *
MAX_RCV_BUF_DESC_RINGS_PER_QS;
return nr_regs;
@@ -470,7 +470,7 @@ nicvf_qsize_rbdr_roundup(uint32_t val)
RBDR_QUEUE_SZ_32K, RBDR_QUEUE_SZ_64K,
RBDR_QUEUE_SZ_128K, RBDR_QUEUE_SZ_256K,
RBDR_QUEUE_SZ_512K};
- return nicvf_roundup_list(val, list, NICVF_ARRAY_SIZE(list));
+ return nicvf_roundup_list(val, list, RTE_DIM(list));
}
int
@@ -579,7 +579,7 @@ nicvf_qsize_sq_roundup(uint32_t val)
SND_QUEUE_SZ_4K, SND_QUEUE_SZ_8K,
SND_QUEUE_SZ_16K, SND_QUEUE_SZ_32K,
SND_QUEUE_SZ_64K};
- return nicvf_roundup_list(val, list, NICVF_ARRAY_SIZE(list));
+ return nicvf_roundup_list(val, list, RTE_DIM(list));
}
int
@@ -684,7 +684,7 @@ nicvf_qsize_cq_roundup(uint32_t val)
CMP_QUEUE_SZ_4K, CMP_QUEUE_SZ_8K,
CMP_QUEUE_SZ_16K, CMP_QUEUE_SZ_32K,
CMP_QUEUE_SZ_64K};
- return nicvf_roundup_list(val, list, NICVF_ARRAY_SIZE(list));
+ return nicvf_roundup_list(val, list, RTE_DIM(list));
}
diff --git a/drivers/net/thunderx/base/nicvf_hw.h b/drivers/net/thunderx/base/nicvf_hw.h
index fd13ea84b..80596ddba 100644
--- a/drivers/net/thunderx/base/nicvf_hw.h
+++ b/drivers/net/thunderx/base/nicvf_hw.h
@@ -17,8 +17,6 @@
#define PCI_SUB_DEVICE_ID_CN81XX_NICVF 0xA234
#define PCI_SUB_DEVICE_ID_CN83XX_NICVF 0xA334
-#define NICVF_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
-
#define NICVF_GET_RX_STATS(reg) \
nicvf_reg_read(nic, NIC_VNIC_RX_STAT_0_13 | (reg << 3))
#define NICVF_GET_TX_STATS(reg) \
diff --git a/drivers/raw/ifpga/base/osdep_rte/osdep_generic.h b/drivers/raw/ifpga/base/osdep_rte/osdep_generic.h
index 3ff49a892..7ad8e17c3 100644
--- a/drivers/raw/ifpga/base/osdep_rte/osdep_generic.h
+++ b/drivers/raw/ifpga/base/osdep_rte/osdep_generic.h
@@ -34,8 +34,6 @@
#define opae_zmalloc(size) rte_zmalloc(NULL, size, 0)
#define opae_free(addr) rte_free(addr)
-#define ARRAY_SIZE(arr) RTE_DIM(arr)
-
#define min(a, b) RTE_MIN(a, b)
#define max(a, b) RTE_MAX(a, b)
--
2.17.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH 3/3] bitrate: use RTE_DIM instead of ARRAY_SIZE
2019-10-11 4:07 [dpdk-dev] [PATCH 1/3] app/test: use RTE_DIM instead of ARRAY_SIZE pbhagavatula
2019-10-11 4:07 ` [dpdk-dev] [PATCH 2/3] drivers: " pbhagavatula
@ 2019-10-11 4:07 ` pbhagavatula
2019-10-11 14:20 ` [dpdk-dev] [PATCH 1/3] app/test: " Eads, Gage
2019-10-17 12:09 ` [dpdk-dev] [PATCH v2 1/2] " pbhagavatula
3 siblings, 0 replies; 15+ messages in thread
From: pbhagavatula @ 2019-10-11 4:07 UTC (permalink / raw)
Cc: dev, Pavan Nikhilesh
From: Pavan Nikhilesh <pbhagavatula@marvell.com>
Use RTE_DIM instead of re-defining ARRAY_SIZE.
Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
lib/librte_bitratestats/rte_bitrate.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/lib/librte_bitratestats/rte_bitrate.c b/lib/librte_bitratestats/rte_bitrate.c
index 639e47547..d18152365 100644
--- a/lib/librte_bitratestats/rte_bitrate.c
+++ b/lib/librte_bitratestats/rte_bitrate.c
@@ -8,8 +8,6 @@
#include <rte_metrics.h>
#include <rte_bitrate.h>
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
/*
* Persistent bit-rate data.
* @internal
@@ -50,7 +48,7 @@ rte_stats_bitrate_reg(struct rte_stats_bitrates *bitrate_data)
if (bitrate_data == NULL)
return -EINVAL;
- return_value = rte_metrics_reg_names(&names[0], ARRAY_SIZE(names));
+ return_value = rte_metrics_reg_names(&names[0], RTE_DIM(names));
if (return_value >= 0)
bitrate_data->id_stats_set = return_value;
return return_value;
@@ -126,7 +124,7 @@ rte_stats_bitrate_calc(struct rte_stats_bitrates *bitrate_data,
values[4] = port_data->peak_ibits;
values[5] = port_data->peak_obits;
ret = rte_metrics_update_values(port_id, bitrate_data->id_stats_set,
- values, ARRAY_SIZE(values));
+ values, RTE_DIM(values));
if (ret < 0)
return ret;
--
2.17.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH 2/3] drivers: use RTE_DIM instead of ARRAY_SIZE
2019-10-11 4:07 ` [dpdk-dev] [PATCH 2/3] drivers: " pbhagavatula
@ 2019-10-11 4:37 ` Hemant Agrawal
2019-10-11 9:32 ` Ananyev, Konstantin
2019-10-11 6:14 ` Andrew Rybchenko
2019-10-11 9:00 ` Hyong Youb Kim (hyonkim)
2 siblings, 1 reply; 15+ messages in thread
From: Hemant Agrawal @ 2019-10-11 4:37 UTC (permalink / raw)
To: pbhagavatula, Sachin Saxena, Akhil Goyal, Igor Russkikh,
Pavel Belous, Ravi Kumar, Rasesh Mody, Shahed Shaikh,
Rahul Lakkireddy, Marcin Wojtas, Michal Krawczyk, Guy Tzalik,
Evgeny Schemeilin, Igor Chauskin, John Daley, Hyong Youb Kim,
Wei Hu (Xavier), Min Hu (Connor),
Yisen Zhuang, Beilei Xing, Qi Zhang, Jingjing Wu, Wenzhuo Lu,
Qiming Yang, Alejandro Lucero, Andrew Rybchenko, Jerin Jacob,
Maciej Czekaj, Rosen Xu, Tianfei zhang
Cc: dev
Hi Pavan,
>
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>
> Use RTE_DIM instead of re-defining ARRAY_SIZE.
>
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> ---
> drivers/bus/dpaa/base/qbman/qman.c | 6 ++--
> drivers/bus/dpaa/include/compat.h | 5 ----
> drivers/crypto/dpaa2_sec/hw/compat.h | 8 -----
> drivers/crypto/dpaa2_sec/hw/rta/jump_cmd.h | 6 ++--
> drivers/crypto/dpaa2_sec/hw/rta/nfifo_cmd.h | 2 +-
> drivers/net/atlantic/atl_hw_regs.h | 1 -
> drivers/net/atlantic/hw_atl/hw_atl_utils.c | 4 +--
> .../net/atlantic/hw_atl/hw_atl_utils_fw2x.c | 2 +-
> drivers/net/axgbe/axgbe_common.h | 3 --
> drivers/net/axgbe/axgbe_dev.c | 2 +-
> drivers/net/bnx2x/bnx2x.c | 6 ++--
> drivers/net/bnx2x/bnx2x.h | 6 ----
> drivers/net/bnx2x/ecore_init.h | 8 ++---
> drivers/net/bnx2x/ecore_sp.c | 2 +-
> drivers/net/bnx2x/elink.c | 14 ++++-----
> drivers/net/bnx2x/elink.h | 1 -
> drivers/net/cxgbe/base/t4_hw.c | 16 +++++-----
> drivers/net/cxgbe/base/t4vf_hw.c | 4 +--
> drivers/net/cxgbe/cxgbe_compat.h | 2 --
> drivers/net/cxgbe/cxgbe_flow.c | 4 +--
> drivers/net/cxgbe/cxgbe_main.c | 10 +++----
> drivers/net/cxgbe/sge.c | 2 +-
> drivers/net/ena/ena_ethdev.c | 8 ++---
> drivers/net/enic/base/vnic_dev.c | 4 +--
> drivers/net/enic/base/vnic_devcmd.h | 2 --
> drivers/net/hns3/hns3_cmd.c | 2 +-
> drivers/net/hns3/hns3_ethdev.h | 2 --
> drivers/net/hns3/hns3_flow.c | 18 +++++------
> drivers/net/i40e/base/i40e_diag.c | 2 +-
> drivers/net/i40e/base/i40e_osdep.h | 2 --
> drivers/net/iavf/base/iavf_osdep.h | 2 --
> drivers/net/ice/base/ice_fdir.c | 2 +-
> drivers/net/ice/base/ice_flex_pipe.c | 2 +-
> drivers/net/ice/base/ice_flow.c | 2 +-
> drivers/net/ice/base/ice_osdep.h | 1 -
> drivers/net/ice/base/ice_switch.c | 2 +-
> .../net/nfp/nfpcore/nfp-common/nfp_platform.h | 4 ---
> drivers/net/nfp/nfpcore/nfp_cppcore.c | 2 +-
> drivers/net/nfp/nfpcore/nfp_nsp.c | 2 +-
> drivers/net/nfp/nfpcore/nfp_nsp_eth.c | 4 +--
> drivers/net/sfc/base/ef10_ev.c | 4 +--
> drivers/net/sfc/base/ef10_filter.c | 12 ++++----
> drivers/net/sfc/base/ef10_mac.c | 18 +++++------
> drivers/net/sfc/base/ef10_nic.c | 4 +--
> drivers/net/sfc/base/ef10_nvram.c | 6 ++--
> drivers/net/sfc/base/efx.h | 3 --
> drivers/net/sfc/base/efx_port.c | 2 +-
> drivers/net/sfc/base/efx_rx.c | 2 +-
> drivers/net/sfc/base/siena_mac.c | 2 +-
> drivers/net/sfc/base/siena_nic.c | 20 ++++++-------
> drivers/net/sfc/base/siena_nvram.c | 6 ++--
> drivers/net/thunderx/base/nicvf_hw.c | 30 +++++++++----------
> drivers/net/thunderx/base/nicvf_hw.h | 2 --
> .../raw/ifpga/base/osdep_rte/osdep_generic.h | 2 --
> 54 files changed, 120 insertions(+), 170 deletions(-)
>
> diff --git a/drivers/bus/dpaa/base/qbman/qman.c
> b/drivers/bus/dpaa/base/qbman/qman.c
> index e43fc65ef..019be95e2 100644
> --- a/drivers/bus/dpaa/base/qbman/qman.c
> +++ b/drivers/bus/dpaa/base/qbman/qman.c
> @@ -1956,7 +1956,7 @@ int qman_query_wq(u8 query_dedicated, struct
> qm_mcr_querywq *wq)
> int i, array_len;
>
> wq->channel.id = be16_to_cpu(mcr->querywq.channel.id);
> - array_len = ARRAY_SIZE(mcr->querywq.wq_len);
> + array_len = RTE_DIM(mcr->querywq.wq_len);
[Hemant] some of these files are common Flibs and they are shared with other projects (Linux/uboot) etc. It will be more appropriate to map the ARRAY_SIZE to RTE_DIM in compat.h instead of changing this code inline.
This way we need not to maintain diff from the common HW lib codes.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH 2/3] drivers: use RTE_DIM instead of ARRAY_SIZE
2019-10-11 4:07 ` [dpdk-dev] [PATCH 2/3] drivers: " pbhagavatula
2019-10-11 4:37 ` Hemant Agrawal
@ 2019-10-11 6:14 ` Andrew Rybchenko
2019-10-11 9:03 ` Igor Russkikh
2019-10-11 9:00 ` Hyong Youb Kim (hyonkim)
2 siblings, 1 reply; 15+ messages in thread
From: Andrew Rybchenko @ 2019-10-11 6:14 UTC (permalink / raw)
To: pbhagavatula, Hemant Agrawal, Sachin Saxena, Akhil Goyal,
Igor Russkikh, Pavel Belous, Ravi Kumar, Rasesh Mody,
Shahed Shaikh, Rahul Lakkireddy, Marcin Wojtas, Michal Krawczyk,
Guy Tzalik, Evgeny Schemeilin, Igor Chauskin, John Daley,
Hyong Youb Kim, Wei Hu (Xavier), Min Hu (Connor),
Yisen Zhuang, Beilei Xing, Qi Zhang, Jingjing Wu, Wenzhuo Lu,
Qiming Yang, Alejandro Lucero, Jerin Jacob, Maciej Czekaj,
Rosen Xu, Tianfei zhang
Cc: dev
On 10/11/19 7:07 AM, pbhagavatula@marvell.com wrote:
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>
> Use RTE_DIM instead of re-defining ARRAY_SIZE.
>
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
[snip]
> drivers/net/sfc/base/ef10_ev.c | 4 +--
> drivers/net/sfc/base/ef10_filter.c | 12 ++++----
> drivers/net/sfc/base/ef10_mac.c | 18 +++++------
> drivers/net/sfc/base/ef10_nic.c | 4 +--
> drivers/net/sfc/base/ef10_nvram.c | 6 ++--
> drivers/net/sfc/base/efx.h | 3 --
> drivers/net/sfc/base/efx_port.c | 2 +-
> drivers/net/sfc/base/efx_rx.c | 2 +-
> drivers/net/sfc/base/siena_mac.c | 2 +-
> drivers/net/sfc/base/siena_nic.c | 20 ++++++-------
> drivers/net/sfc/base/siena_nvram.c | 6 ++--
NACK
No changes in net/sfc/base please. It is the base driver
which is used on other platforms. So, it can't use DPDK
specific macros.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH 2/3] drivers: use RTE_DIM instead of ARRAY_SIZE
2019-10-11 4:07 ` [dpdk-dev] [PATCH 2/3] drivers: " pbhagavatula
2019-10-11 4:37 ` Hemant Agrawal
2019-10-11 6:14 ` Andrew Rybchenko
@ 2019-10-11 9:00 ` Hyong Youb Kim (hyonkim)
2 siblings, 0 replies; 15+ messages in thread
From: Hyong Youb Kim (hyonkim) @ 2019-10-11 9:00 UTC (permalink / raw)
To: pbhagavatula, Hemant Agrawal, Sachin Saxena, Akhil Goyal,
Igor Russkikh, Pavel Belous, Ravi Kumar, Rasesh Mody,
Shahed Shaikh, Rahul Lakkireddy, Marcin Wojtas, Michal Krawczyk,
Guy Tzalik, Evgeny Schemeilin, Igor Chauskin,
John Daley (johndale), Wei Hu (Xavier), Min Hu (Connor),
Yisen Zhuang, Beilei Xing, Qi Zhang, Jingjing Wu, Wenzhuo Lu,
Qiming Yang, Alejandro Lucero, Andrew Rybchenko, Jerin Jacob,
Maciej Czekaj, Rosen Xu, Tianfei zhang
Cc: dev
> -----Original Message-----
> From: pbhagavatula@marvell.com <pbhagavatula@marvell.com>
> Sent: Friday, October 11, 2019 1:07 PM
[...]
> Subject: [dpdk-dev] [PATCH 2/3] drivers: use RTE_DIM instead of
> ARRAY_SIZE
>
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>
> Use RTE_DIM instead of re-defining ARRAY_SIZE.
>
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> ---
[...]
> drivers/net/enic/base/vnic_dev.c | 4 +--
> drivers/net/enic/base/vnic_devcmd.h | 2 --
[...]
> diff --git a/drivers/net/enic/base/vnic_dev.c
> b/drivers/net/enic/base/vnic_dev.c
> index 8e190687d..3b9a336ff 100644
> --- a/drivers/net/enic/base/vnic_dev.c
> +++ b/drivers/net/enic/base/vnic_dev.c
> @@ -417,11 +417,11 @@ int vnic_dev_cmd(struct vnic_dev *vdev, enum
> vnic_devcmd_cmd cmd,
> switch (vdev->proxy) {
> case PROXY_BY_INDEX:
> err = vnic_dev_cmd_proxy(vdev, CMD_PROXY_BY_INDEX,
> cmd,
> - args, ARRAY_SIZE(args), wait);
> + args, RTE_DIM(args), wait);
> break;
> case PROXY_BY_BDF:
> err = vnic_dev_cmd_proxy(vdev, CMD_PROXY_BY_BDF,
> cmd,
> - args, ARRAY_SIZE(args), wait);
> + args, RTE_DIM(args), wait);
> break;
> case PROXY_NONE:
> default:
> diff --git a/drivers/net/enic/base/vnic_devcmd.h
> b/drivers/net/enic/base/vnic_devcmd.h
> index fffe307e0..5a4f48106 100644
> --- a/drivers/net/enic/base/vnic_devcmd.h
> +++ b/drivers/net/enic/base/vnic_devcmd.h
> @@ -63,8 +63,6 @@
> #define _CMD_VTYPE(cmd) (((cmd) >> _CMD_VTYPESHIFT) &
> _CMD_VTYPEMASK)
> #define _CMD_N(cmd) (((cmd) >> _CMD_NSHIFT) & _CMD_NMASK)
>
> -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
> -
> enum vnic_devcmd_cmd {
> CMD_NONE = _CMDC(_CMD_DIR_NONE,
> _CMD_VTYPE_NONE, 0),
>
[...]
For enic.
Acked-by: Hyong Youb Kim <hyonkim@cisco.com>
Thanks.
-Hyong
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH 2/3] drivers: use RTE_DIM instead of ARRAY_SIZE
2019-10-11 6:14 ` Andrew Rybchenko
@ 2019-10-11 9:03 ` Igor Russkikh
0 siblings, 0 replies; 15+ messages in thread
From: Igor Russkikh @ 2019-10-11 9:03 UTC (permalink / raw)
To: Andrew Rybchenko, pbhagavatula, Hemant Agrawal, Sachin Saxena,
Akhil Goyal, Pavel Belous, Ravi Kumar, Rasesh Mody,
Shahed Shaikh, Rahul Lakkireddy, Marcin Wojtas, Michal Krawczyk,
Guy Tzalik, Evgeny Schemeilin, Igor Chauskin, John Daley,
Hyong Youb Kim, Wei Hu (Xavier), Min Hu (Connor),
Yisen Zhuang, Beilei Xing, Qi Zhang, Jingjing Wu, Wenzhuo Lu,
Qiming Yang, Alejandro Lucero, Jerin Jacob, Maciej Czekaj,
Rosen Xu, Tianfei zhang
Cc: dev
>
> [snip]
>
>> drivers/net/sfc/base/ef10_ev.c | 4 +--
>> drivers/net/sfc/base/ef10_filter.c | 12 ++++----
>> drivers/net/sfc/base/ef10_mac.c | 18 +++++------
>> drivers/net/sfc/base/ef10_nic.c | 4 +--
>> drivers/net/sfc/base/ef10_nvram.c | 6 ++--
>> drivers/net/sfc/base/efx.h | 3 --
>> drivers/net/sfc/base/efx_port.c | 2 +-
>> drivers/net/sfc/base/efx_rx.c | 2 +-
>> drivers/net/sfc/base/siena_mac.c | 2 +-
>> drivers/net/sfc/base/siena_nic.c | 20 ++++++-------
>> drivers/net/sfc/base/siena_nvram.c | 6 ++--
>
> NACK
> No changes in net/sfc/base please. It is the base driver
> which is used on other platforms. So, it can't use DPDK
> specific macros.
>
Hi Pravan,
>
> drivers/net/atlantic/atl_hw_regs.h | 1 -
> drivers/net/atlantic/hw_atl/hw_atl_utils.c | 4 +--
> .../net/atlantic/hw_atl/hw_atl_utils_fw2x.c | 2 +-
We also tend to share these modules with linux and other codebases.
Less diffs we have to review is better.
Why not keep ARRAY_SIZE as a widely used compat alternative?
Regards,
Igor
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH 2/3] drivers: use RTE_DIM instead of ARRAY_SIZE
2019-10-11 4:37 ` Hemant Agrawal
@ 2019-10-11 9:32 ` Ananyev, Konstantin
2019-10-11 13:48 ` Ferruh Yigit
0 siblings, 1 reply; 15+ messages in thread
From: Ananyev, Konstantin @ 2019-10-11 9:32 UTC (permalink / raw)
To: Hemant Agrawal, pbhagavatula, Sachin Saxena, Akhil Goyal,
Igor Russkikh, Pavel Belous, Ravi Kumar, Rasesh Mody,
Shahed Shaikh, Rahul Lakkireddy, Marcin Wojtas, Michal Krawczyk,
Guy Tzalik, Evgeny Schemeilin, Igor Chauskin, John Daley,
Hyong Youb Kim, Wei Hu (Xavier), Min Hu (Connor),
Yisen Zhuang, Xing, Beilei, Zhang, Qi Z, Wu, Jingjing, Lu,
Wenzhuo, Yang, Qiming, Alejandro Lucero, Andrew Rybchenko,
Jerin Jacob, Maciej Czekaj, Xu, Rosen, Zhang, Tianfei
Cc: dev
> Hi Pavan,
>
> >
> > From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> >
> > Use RTE_DIM instead of re-defining ARRAY_SIZE.
> >
> > Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > ---
> > drivers/bus/dpaa/base/qbman/qman.c | 6 ++--
> > drivers/bus/dpaa/include/compat.h | 5 ----
> > drivers/crypto/dpaa2_sec/hw/compat.h | 8 -----
> > drivers/crypto/dpaa2_sec/hw/rta/jump_cmd.h | 6 ++--
> > drivers/crypto/dpaa2_sec/hw/rta/nfifo_cmd.h | 2 +-
> > drivers/net/atlantic/atl_hw_regs.h | 1 -
> > drivers/net/atlantic/hw_atl/hw_atl_utils.c | 4 +--
> > .../net/atlantic/hw_atl/hw_atl_utils_fw2x.c | 2 +-
> > drivers/net/axgbe/axgbe_common.h | 3 --
> > drivers/net/axgbe/axgbe_dev.c | 2 +-
> > drivers/net/bnx2x/bnx2x.c | 6 ++--
> > drivers/net/bnx2x/bnx2x.h | 6 ----
> > drivers/net/bnx2x/ecore_init.h | 8 ++---
> > drivers/net/bnx2x/ecore_sp.c | 2 +-
> > drivers/net/bnx2x/elink.c | 14 ++++-----
> > drivers/net/bnx2x/elink.h | 1 -
> > drivers/net/cxgbe/base/t4_hw.c | 16 +++++-----
> > drivers/net/cxgbe/base/t4vf_hw.c | 4 +--
> > drivers/net/cxgbe/cxgbe_compat.h | 2 --
> > drivers/net/cxgbe/cxgbe_flow.c | 4 +--
> > drivers/net/cxgbe/cxgbe_main.c | 10 +++----
> > drivers/net/cxgbe/sge.c | 2 +-
> > drivers/net/ena/ena_ethdev.c | 8 ++---
> > drivers/net/enic/base/vnic_dev.c | 4 +--
> > drivers/net/enic/base/vnic_devcmd.h | 2 --
> > drivers/net/hns3/hns3_cmd.c | 2 +-
> > drivers/net/hns3/hns3_ethdev.h | 2 --
> > drivers/net/hns3/hns3_flow.c | 18 +++++------
> > drivers/net/i40e/base/i40e_diag.c | 2 +-
> > drivers/net/i40e/base/i40e_osdep.h | 2 --
> > drivers/net/iavf/base/iavf_osdep.h | 2 --
> > drivers/net/ice/base/ice_fdir.c | 2 +-
> > drivers/net/ice/base/ice_flex_pipe.c | 2 +-
> > drivers/net/ice/base/ice_flow.c | 2 +-
> > drivers/net/ice/base/ice_osdep.h | 1 -
> > drivers/net/ice/base/ice_switch.c | 2 +-
> > .../net/nfp/nfpcore/nfp-common/nfp_platform.h | 4 ---
> > drivers/net/nfp/nfpcore/nfp_cppcore.c | 2 +-
> > drivers/net/nfp/nfpcore/nfp_nsp.c | 2 +-
> > drivers/net/nfp/nfpcore/nfp_nsp_eth.c | 4 +--
> > drivers/net/sfc/base/ef10_ev.c | 4 +--
> > drivers/net/sfc/base/ef10_filter.c | 12 ++++----
> > drivers/net/sfc/base/ef10_mac.c | 18 +++++------
> > drivers/net/sfc/base/ef10_nic.c | 4 +--
> > drivers/net/sfc/base/ef10_nvram.c | 6 ++--
> > drivers/net/sfc/base/efx.h | 3 --
> > drivers/net/sfc/base/efx_port.c | 2 +-
> > drivers/net/sfc/base/efx_rx.c | 2 +-
> > drivers/net/sfc/base/siena_mac.c | 2 +-
> > drivers/net/sfc/base/siena_nic.c | 20 ++++++-------
> > drivers/net/sfc/base/siena_nvram.c | 6 ++--
> > drivers/net/thunderx/base/nicvf_hw.c | 30 +++++++++----------
> > drivers/net/thunderx/base/nicvf_hw.h | 2 --
> > .../raw/ifpga/base/osdep_rte/osdep_generic.h | 2 --
> > 54 files changed, 120 insertions(+), 170 deletions(-)
> >
> > diff --git a/drivers/bus/dpaa/base/qbman/qman.c
> > b/drivers/bus/dpaa/base/qbman/qman.c
> > index e43fc65ef..019be95e2 100644
> > --- a/drivers/bus/dpaa/base/qbman/qman.c
> > +++ b/drivers/bus/dpaa/base/qbman/qman.c
> > @@ -1956,7 +1956,7 @@ int qman_query_wq(u8 query_dedicated, struct
> > qm_mcr_querywq *wq)
> > int i, array_len;
> >
> > wq->channel.id = be16_to_cpu(mcr->querywq.channel.id);
> > - array_len = ARRAY_SIZE(mcr->querywq.wq_len);
> > + array_len = RTE_DIM(mcr->querywq.wq_len);
>
> [Hemant] some of these files are common Flibs and they are shared with other projects (Linux/uboot) etc. It will be more appropriate to
> map the ARRAY_SIZE to RTE_DIM in compat.h instead of changing this code inline.
> This way we need not to maintain diff from the common HW lib codes.
+1 to this suggestion
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH 2/3] drivers: use RTE_DIM instead of ARRAY_SIZE
2019-10-11 9:32 ` Ananyev, Konstantin
@ 2019-10-11 13:48 ` Ferruh Yigit
0 siblings, 0 replies; 15+ messages in thread
From: Ferruh Yigit @ 2019-10-11 13:48 UTC (permalink / raw)
To: Ananyev, Konstantin, Hemant Agrawal, pbhagavatula, Sachin Saxena,
Akhil Goyal, Igor Russkikh, Pavel Belous, Ravi Kumar,
Rasesh Mody, Shahed Shaikh, Rahul Lakkireddy, Marcin Wojtas,
Michal Krawczyk, Guy Tzalik, Evgeny Schemeilin, Igor Chauskin,
John Daley, Hyong Youb Kim, Wei Hu (Xavier), Min Hu (Connor),
Yisen Zhuang, Xing, Beilei, Zhang, Qi Z, Wu, Jingjing, Lu,
Wenzhuo, Yang, Qiming, Alejandro Lucero, Andrew Rybchenko,
Jerin Jacob, Maciej Czekaj, Xu, Rosen, Zhang, Tianfei
Cc: dev
On 10/11/2019 10:32 AM, Ananyev, Konstantin wrote:
>
>
>> Hi Pavan,
>>
>>>
>>> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>>>
>>> Use RTE_DIM instead of re-defining ARRAY_SIZE.
>>>
>>> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
>>> ---
>>> drivers/bus/dpaa/base/qbman/qman.c | 6 ++--
>>> drivers/bus/dpaa/include/compat.h | 5 ----
>>> drivers/crypto/dpaa2_sec/hw/compat.h | 8 -----
>>> drivers/crypto/dpaa2_sec/hw/rta/jump_cmd.h | 6 ++--
>>> drivers/crypto/dpaa2_sec/hw/rta/nfifo_cmd.h | 2 +-
>>> drivers/net/atlantic/atl_hw_regs.h | 1 -
>>> drivers/net/atlantic/hw_atl/hw_atl_utils.c | 4 +--
>>> .../net/atlantic/hw_atl/hw_atl_utils_fw2x.c | 2 +-
>>> drivers/net/axgbe/axgbe_common.h | 3 --
>>> drivers/net/axgbe/axgbe_dev.c | 2 +-
>>> drivers/net/bnx2x/bnx2x.c | 6 ++--
>>> drivers/net/bnx2x/bnx2x.h | 6 ----
>>> drivers/net/bnx2x/ecore_init.h | 8 ++---
>>> drivers/net/bnx2x/ecore_sp.c | 2 +-
>>> drivers/net/bnx2x/elink.c | 14 ++++-----
>>> drivers/net/bnx2x/elink.h | 1 -
>>> drivers/net/cxgbe/base/t4_hw.c | 16 +++++-----
>>> drivers/net/cxgbe/base/t4vf_hw.c | 4 +--
>>> drivers/net/cxgbe/cxgbe_compat.h | 2 --
>>> drivers/net/cxgbe/cxgbe_flow.c | 4 +--
>>> drivers/net/cxgbe/cxgbe_main.c | 10 +++----
>>> drivers/net/cxgbe/sge.c | 2 +-
>>> drivers/net/ena/ena_ethdev.c | 8 ++---
>>> drivers/net/enic/base/vnic_dev.c | 4 +--
>>> drivers/net/enic/base/vnic_devcmd.h | 2 --
>>> drivers/net/hns3/hns3_cmd.c | 2 +-
>>> drivers/net/hns3/hns3_ethdev.h | 2 --
>>> drivers/net/hns3/hns3_flow.c | 18 +++++------
>>> drivers/net/i40e/base/i40e_diag.c | 2 +-
>>> drivers/net/i40e/base/i40e_osdep.h | 2 --
>>> drivers/net/iavf/base/iavf_osdep.h | 2 --
>>> drivers/net/ice/base/ice_fdir.c | 2 +-
>>> drivers/net/ice/base/ice_flex_pipe.c | 2 +-
>>> drivers/net/ice/base/ice_flow.c | 2 +-
>>> drivers/net/ice/base/ice_osdep.h | 1 -
>>> drivers/net/ice/base/ice_switch.c | 2 +-
>>> .../net/nfp/nfpcore/nfp-common/nfp_platform.h | 4 ---
>>> drivers/net/nfp/nfpcore/nfp_cppcore.c | 2 +-
>>> drivers/net/nfp/nfpcore/nfp_nsp.c | 2 +-
>>> drivers/net/nfp/nfpcore/nfp_nsp_eth.c | 4 +--
>>> drivers/net/sfc/base/ef10_ev.c | 4 +--
>>> drivers/net/sfc/base/ef10_filter.c | 12 ++++----
>>> drivers/net/sfc/base/ef10_mac.c | 18 +++++------
>>> drivers/net/sfc/base/ef10_nic.c | 4 +--
>>> drivers/net/sfc/base/ef10_nvram.c | 6 ++--
>>> drivers/net/sfc/base/efx.h | 3 --
>>> drivers/net/sfc/base/efx_port.c | 2 +-
>>> drivers/net/sfc/base/efx_rx.c | 2 +-
>>> drivers/net/sfc/base/siena_mac.c | 2 +-
>>> drivers/net/sfc/base/siena_nic.c | 20 ++++++-------
>>> drivers/net/sfc/base/siena_nvram.c | 6 ++--
>>> drivers/net/thunderx/base/nicvf_hw.c | 30 +++++++++----------
>>> drivers/net/thunderx/base/nicvf_hw.h | 2 --
>>> .../raw/ifpga/base/osdep_rte/osdep_generic.h | 2 --
>>> 54 files changed, 120 insertions(+), 170 deletions(-)
>>>
>>> diff --git a/drivers/bus/dpaa/base/qbman/qman.c
>>> b/drivers/bus/dpaa/base/qbman/qman.c
>>> index e43fc65ef..019be95e2 100644
>>> --- a/drivers/bus/dpaa/base/qbman/qman.c
>>> +++ b/drivers/bus/dpaa/base/qbman/qman.c
>>> @@ -1956,7 +1956,7 @@ int qman_query_wq(u8 query_dedicated, struct
>>> qm_mcr_querywq *wq)
>>> int i, array_len;
>>>
>>> wq->channel.id = be16_to_cpu(mcr->querywq.channel.id);
>>> - array_len = ARRAY_SIZE(mcr->querywq.wq_len);
>>> + array_len = RTE_DIM(mcr->querywq.wq_len);
>>
>> [Hemant] some of these files are common Flibs and they are shared with other projects (Linux/uboot) etc. It will be more appropriate to
>> map the ARRAY_SIZE to RTE_DIM in compat.h instead of changing this code inline.
>> This way we need not to maintain diff from the common HW lib codes.
>
> +1 to this suggestion
>
What about dropping the drivers patch form this patchset but continue with others?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH 1/3] app/test: use RTE_DIM instead of ARRAY_SIZE
2019-10-11 4:07 [dpdk-dev] [PATCH 1/3] app/test: use RTE_DIM instead of ARRAY_SIZE pbhagavatula
2019-10-11 4:07 ` [dpdk-dev] [PATCH 2/3] drivers: " pbhagavatula
2019-10-11 4:07 ` [dpdk-dev] [PATCH 3/3] bitrate: " pbhagavatula
@ 2019-10-11 14:20 ` Eads, Gage
2019-10-17 12:09 ` [dpdk-dev] [PATCH v2 1/2] " pbhagavatula
3 siblings, 0 replies; 15+ messages in thread
From: Eads, Gage @ 2019-10-11 14:20 UTC (permalink / raw)
To: pbhagavatula, Doherty, Declan, Olivier Matz; +Cc: dev
> -----Original Message-----
> From: pbhagavatula@marvell.com [mailto:pbhagavatula@marvell.com]
> Sent: Thursday, October 10, 2019 11:07 PM
> To: Doherty, Declan <declan.doherty@intel.com>; Eads, Gage
> <gage.eads@intel.com>; Olivier Matz <olivier.matz@6wind.com>
> Cc: dev@dpdk.org; Pavan Nikhilesh <pbhagavatula@marvell.com>
> Subject: [dpdk-dev] [PATCH 1/3] app/test: use RTE_DIM instead of
> ARRAY_SIZE
>
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>
> Use RTE_DIM instead of re-defining ARRAY_SIZE.
>
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> ---
Acked-by: Gage Eads <gage.eads@intel.com>
Thanks,
Gage
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH v2 1/2] app/test: use RTE_DIM instead of ARRAY_SIZE
2019-10-11 4:07 [dpdk-dev] [PATCH 1/3] app/test: use RTE_DIM instead of ARRAY_SIZE pbhagavatula
` (2 preceding siblings ...)
2019-10-11 14:20 ` [dpdk-dev] [PATCH 1/3] app/test: " Eads, Gage
@ 2019-10-17 12:09 ` pbhagavatula
2019-10-17 12:10 ` [dpdk-dev] [PATCH v2 2/2] bitrate: " pbhagavatula
2019-10-27 13:35 ` [dpdk-dev] [PATCH v2 1/2] app/test: " David Marchand
3 siblings, 2 replies; 15+ messages in thread
From: pbhagavatula @ 2019-10-17 12:09 UTC (permalink / raw)
To: ferruh.yigit, jerinj, Declan Doherty, Gage Eads, Olivier Matz
Cc: dev, Pavan Nikhilesh
From: Pavan Nikhilesh <pbhagavatula@marvell.com>
Use RTE_DIM instead of re-defining ARRAY_SIZE.
Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Acked-by: Gage Eads <gage.eads@intel.com>
---
v2 Changes:
----------
- Drop [2/3] drivers: use RTE_DIM instead of ARRAY_SIZE as the same sources
might be reused outside DPDK.
app/test/test_cryptodev_asym.c | 8 ++------
app/test/test_metrics.c | 11 +++++------
app/test/test_stack_perf.c | 8 +++-----
3 files changed, 10 insertions(+), 17 deletions(-)
diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index e8177e73a..7ff631600 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -26,10 +26,6 @@
#define TEST_NUM_BUFS 10
#define TEST_NUM_SESSIONS 4
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-#endif
-
#ifndef TEST_DATA_SIZE
#define TEST_DATA_SIZE 4096
#endif
@@ -473,7 +469,7 @@ load_test_vectors(void)
{
uint32_t i = 0, v_size = 0;
/* Load MODEX vector*/
- v_size = ARRAY_SIZE(modex_test_case);
+ v_size = RTE_DIM(modex_test_case);
for (i = 0; i < v_size; i++) {
if (test_vector.size >= (TEST_VECTOR_SIZE)) {
RTE_LOG(DEBUG, USER1,
@@ -484,7 +480,7 @@ load_test_vectors(void)
test_vector.size++;
}
/* Load MODINV vector*/
- v_size = ARRAY_SIZE(modinv_test_case);
+ v_size = RTE_DIM(modinv_test_case);
for (i = 0; i < v_size; i++) {
if (test_vector.size >= (TEST_VECTOR_SIZE)) {
RTE_LOG(DEBUG, USER1,
diff --git a/app/test/test_metrics.c b/app/test/test_metrics.c
index 78b3936ee..e736019ae 100644
--- a/app/test/test_metrics.c
+++ b/app/test/test_metrics.c
@@ -12,7 +12,6 @@
#include "test.h"
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define REG_METRIC_COUNT 6
#define METRIC_LESSER_COUNT 3
#define KEY 1
@@ -106,7 +105,7 @@ test_metrics_reg_names(void)
};
/* Success Test: valid array and count size */
- err = rte_metrics_reg_names(&mnames[0], ARRAY_SIZE(mnames));
+ err = rte_metrics_reg_names(&mnames[0], RTE_DIM(mnames));
TEST_ASSERT(err >= 0, "%s, %d", __func__, __LINE__);
return TEST_SUCCESS;
@@ -167,20 +166,20 @@ test_metrics_update_values(void)
/* Failed Test: Invalid count size */
err = rte_metrics_update_values(RTE_METRICS_GLOBAL,
- KEY, &value[0], ARRAY_SIZE(value));
+ KEY, &value[0], RTE_DIM(value));
TEST_ASSERT(err < 0, "%s, %d", __func__, __LINE__);
/* Failed Test: Invalid port_id(lower value) and valid data */
- err = rte_metrics_update_values(-2, KEY, &value[0], ARRAY_SIZE(value));
+ err = rte_metrics_update_values(-2, KEY, &value[0], RTE_DIM(value));
TEST_ASSERT(err == -EINVAL, "%s, %d", __func__, __LINE__);
/* Failed Test: Invalid port_id(higher value) and valid data */
- err = rte_metrics_update_values(39, 1, &value[0], ARRAY_SIZE(value));
+ err = rte_metrics_update_values(39, 1, &value[0], RTE_DIM(value));
TEST_ASSERT(err == -EINVAL, "%s, %d", __func__, __LINE__);
/* Failed Test: Invalid array */
err = rte_metrics_update_values(RTE_METRICS_GLOBAL,
- KEY, NULL, ARRAY_SIZE(value));
+ KEY, NULL, RTE_DIM(value));
TEST_ASSERT(err == -EINVAL, "%s, %d", __func__, __LINE__);
return TEST_SUCCESS;
diff --git a/app/test/test_stack_perf.c b/app/test/test_stack_perf.c
index 70561fecd..3ab7267b1 100644
--- a/app/test/test_stack_perf.c
+++ b/app/test/test_stack_perf.c
@@ -18,8 +18,6 @@
#define MAX_BURST 32
#define STACK_SIZE (RTE_MAX_LCORE * MAX_BURST)
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
/*
* Push/pop bulk sizes, marked volatile so they aren't treated as compile-time
* constants.
@@ -176,7 +174,7 @@ run_on_core_pair(struct lcore_pair *cores, struct rte_stack *s,
struct thread_args args[2];
unsigned int i;
- for (i = 0; i < ARRAY_SIZE(bulk_sizes); i++) {
+ for (i = 0; i < RTE_DIM(bulk_sizes); i++) {
rte_atomic32_set(&lcore_barrier, 2);
args[0].sz = args[1].sz = bulk_sizes[i];
@@ -205,7 +203,7 @@ run_on_n_cores(struct rte_stack *s, lcore_function_t fn, int n)
struct thread_args args[RTE_MAX_LCORE];
unsigned int i;
- for (i = 0; i < ARRAY_SIZE(bulk_sizes); i++) {
+ for (i = 0; i < RTE_DIM(bulk_sizes); i++) {
unsigned int lcore_id;
int cnt = 0;
double avg;
@@ -280,7 +278,7 @@ test_bulk_push_pop(struct rte_stack *s)
void *objs[MAX_BURST];
unsigned int sz, i;
- for (sz = 0; sz < ARRAY_SIZE(bulk_sizes); sz++) {
+ for (sz = 0; sz < RTE_DIM(bulk_sizes); sz++) {
uint64_t start = rte_rdtsc();
for (i = 0; i < iterations; i++) {
--
2.17.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH v2 2/2] bitrate: use RTE_DIM instead of ARRAY_SIZE
2019-10-17 12:09 ` [dpdk-dev] [PATCH v2 1/2] " pbhagavatula
@ 2019-10-17 12:10 ` pbhagavatula
2019-10-27 13:36 ` David Marchand
2019-10-27 13:35 ` [dpdk-dev] [PATCH v2 1/2] app/test: " David Marchand
1 sibling, 1 reply; 15+ messages in thread
From: pbhagavatula @ 2019-10-17 12:10 UTC (permalink / raw)
To: ferruh.yigit, jerinj; +Cc: dev, Pavan Nikhilesh
From: Pavan Nikhilesh <pbhagavatula@marvell.com>
Use RTE_DIM instead of re-defining ARRAY_SIZE.
Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
lib/librte_bitratestats/rte_bitrate.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/lib/librte_bitratestats/rte_bitrate.c b/lib/librte_bitratestats/rte_bitrate.c
index 639e47547..d18152365 100644
--- a/lib/librte_bitratestats/rte_bitrate.c
+++ b/lib/librte_bitratestats/rte_bitrate.c
@@ -8,8 +8,6 @@
#include <rte_metrics.h>
#include <rte_bitrate.h>
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
/*
* Persistent bit-rate data.
* @internal
@@ -50,7 +48,7 @@ rte_stats_bitrate_reg(struct rte_stats_bitrates *bitrate_data)
if (bitrate_data == NULL)
return -EINVAL;
- return_value = rte_metrics_reg_names(&names[0], ARRAY_SIZE(names));
+ return_value = rte_metrics_reg_names(&names[0], RTE_DIM(names));
if (return_value >= 0)
bitrate_data->id_stats_set = return_value;
return return_value;
@@ -126,7 +124,7 @@ rte_stats_bitrate_calc(struct rte_stats_bitrates *bitrate_data,
values[4] = port_data->peak_ibits;
values[5] = port_data->peak_obits;
ret = rte_metrics_update_values(port_id, bitrate_data->id_stats_set,
- values, ARRAY_SIZE(values));
+ values, RTE_DIM(values));
if (ret < 0)
return ret;
--
2.17.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/2] app/test: use RTE_DIM instead of ARRAY_SIZE
2019-10-17 12:09 ` [dpdk-dev] [PATCH v2 1/2] " pbhagavatula
2019-10-17 12:10 ` [dpdk-dev] [PATCH v2 2/2] bitrate: " pbhagavatula
@ 2019-10-27 13:35 ` David Marchand
1 sibling, 0 replies; 15+ messages in thread
From: David Marchand @ 2019-10-27 13:35 UTC (permalink / raw)
To: Pavan Nikhilesh
Cc: Yigit, Ferruh, Jerin Jacob Kollanukkaran, Declan Doherty,
Gage Eads, Olivier Matz, dev
On Thu, Oct 17, 2019 at 2:10 PM <pbhagavatula@marvell.com> wrote:
>
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>
> Use RTE_DIM instead of re-defining ARRAY_SIZE.
>
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> Acked-by: Gage Eads <gage.eads@intel.com>
Applied, thanks.
I had a similar patch in store :-).
If you want to continue on this topic, look at other files in app/test:
$ git grep -l sizeof.*sizeof.*\\[ app/test
app/test/test.c
app/test/test_cmdline_etheraddr.c
app/test/test_cmdline_ipaddr.c
app/test/test_cmdline_num.c
app/test/test_cmdline_portlist.c
app/test/test_cmdline_string.c
app/test/test_debug.c
app/test/test_eal_flags.c
app/test/test_errno.c
app/test/test_lpm.c
app/test/test_lpm6.c
app/test/test_lpm6_data.h
app/test/test_malloc.c
app/test/test_memcpy.c
app/test/test_memcpy_perf.c
app/test/test_mp_secondary.c
app/test/test_pdump.c
app/test/test_pmd_ring_perf.c
app/test/test_ring_perf.c
app/test/test_timer_secondary.c
--
David Marchand
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH v2 2/2] bitrate: use RTE_DIM instead of ARRAY_SIZE
2019-10-17 12:10 ` [dpdk-dev] [PATCH v2 2/2] bitrate: " pbhagavatula
@ 2019-10-27 13:36 ` David Marchand
0 siblings, 0 replies; 15+ messages in thread
From: David Marchand @ 2019-10-27 13:36 UTC (permalink / raw)
To: Pavan Nikhilesh; +Cc: Yigit, Ferruh, Jerin Jacob Kollanukkaran, dev
On Thu, Oct 17, 2019 at 2:10 PM <pbhagavatula@marvell.com> wrote:
>
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>
> Use RTE_DIM instead of re-defining ARRAY_SIZE.
>
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
Applied, thanks.
--
David Marchand
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH 2/3] drivers: use RTE_DIM instead of ARRAY_SIZE
@ 2019-10-14 6:58 Pavan Nikhilesh Bhagavatula
0 siblings, 0 replies; 15+ messages in thread
From: Pavan Nikhilesh Bhagavatula @ 2019-10-14 6:58 UTC (permalink / raw)
To: Ferruh Yigit, Ananyev, Konstantin, Hemant Agrawal, Sachin Saxena,
Akhil Goyal, Igor Russkikh, Pavel Belous, Ravi Kumar,
Rasesh Mody, Shahed Shaikh, Rahul Lakkireddy, Marcin Wojtas,
Michal Krawczyk, Guy Tzalik, Evgeny Schemeilin, Igor Chauskin,
John Daley, Hyong Youb Kim, Wei Hu (Xavier), Min Hu (Connor),
Yisen Zhuang, Xing, Beilei, Zhang, Qi Z, Wu, Jingjing, Lu,
Wenzhuo, Yang, Qiming, Alejandro Lucero, Andrew Rybchenko,
Jerin Jacob Kollanukkaran, Maciej Czekaj, Xu, Rosen, Zhang,
Tianfei
Cc: dev
>-----Original Message-----
>From: Ferruh Yigit <ferruh.yigit@intel.com>
>Sent: Friday, October 11, 2019 7:18 PM
>To: Ananyev, Konstantin <konstantin.ananyev@intel.com>; Hemant
>Agrawal <hemant.agrawal@nxp.com>; Pavan Nikhilesh Bhagavatula
><pbhagavatula@marvell.com>; Sachin Saxena
><sachin.saxena@nxp.com>; Akhil Goyal <akhil.goyal@nxp.com>; Igor
>Russkikh <igor.russkikh@aquantia.com>; Pavel Belous
><pavel.belous@aquantia.com>; Ravi Kumar <ravi1.kumar@amd.com>;
>Rasesh Mody <rmody@marvell.com>; Shahed Shaikh
><shshaikh@marvell.com>; Rahul Lakkireddy
><rahul.lakkireddy@chelsio.com>; Marcin Wojtas <mw@semihalf.com>;
>Michal Krawczyk <mk@semihalf.com>; Guy Tzalik
><gtzalik@amazon.com>; Evgeny Schemeilin <evgenys@amazon.com>;
>Igor Chauskin <igorch@amazon.com>; John Daley
><johndale@cisco.com>; Hyong Youb Kim <hyonkim@cisco.com>; Wei
>Hu (Xavier) <xavier.huwei@huawei.com>; Min Hu (Connor)
><humin29@huawei.com>; Yisen Zhuang <yisen.zhuang@huawei.com>;
>Xing, Beilei <beilei.xing@intel.com>; Zhang, Qi Z
><qi.z.zhang@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Lu,
>Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
><qiming.yang@intel.com>; Alejandro Lucero
><alejandro.lucero@netronome.com>; Andrew Rybchenko
><arybchenko@solarflare.com>; Jerin Jacob Kollanukkaran
><jerinj@marvell.com>; Maciej Czekaj <mczekaj@marvell.com>; Xu,
>Rosen <rosen.xu@intel.com>; Zhang, Tianfei
><tianfei.zhang@intel.com>
>Cc: dev@dpdk.org
>Subject: Re: [dpdk-dev] [PATCH 2/3] drivers: use RTE_DIM instead
>of ARRAY_SIZE
>On 10/11/2019 10:32 AM, Ananyev, Konstantin wrote:
>>
>>
>>> Hi Pavan,
>>>
>>>>
>>>> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>>>>
>>>> Use RTE_DIM instead of re-defining ARRAY_SIZE.
>>>>
>>>> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
>>>> ---
>>>> drivers/bus/dpaa/base/qbman/qman.c | 6 ++--
>>>> drivers/bus/dpaa/include/compat.h | 5 ----
>>>> drivers/crypto/dpaa2_sec/hw/compat.h | 8 -----
>>>> drivers/crypto/dpaa2_sec/hw/rta/jump_cmd.h | 6 ++--
>>>> drivers/crypto/dpaa2_sec/hw/rta/nfifo_cmd.h | 2 +-
>>>> drivers/net/atlantic/atl_hw_regs.h | 1 -
>>>> drivers/net/atlantic/hw_atl/hw_atl_utils.c | 4 +--
>>>> .../net/atlantic/hw_atl/hw_atl_utils_fw2x.c | 2 +-
>>>> drivers/net/axgbe/axgbe_common.h | 3 --
>>>> drivers/net/axgbe/axgbe_dev.c | 2 +-
>>>> drivers/net/bnx2x/bnx2x.c | 6 ++--
>>>> drivers/net/bnx2x/bnx2x.h | 6 ----
>>>> drivers/net/bnx2x/ecore_init.h | 8 ++---
>>>> drivers/net/bnx2x/ecore_sp.c | 2 +-
>>>> drivers/net/bnx2x/elink.c | 14 ++++-----
>>>> drivers/net/bnx2x/elink.h | 1 -
>>>> drivers/net/cxgbe/base/t4_hw.c | 16 +++++-----
>>>> drivers/net/cxgbe/base/t4vf_hw.c | 4 +--
>>>> drivers/net/cxgbe/cxgbe_compat.h | 2 --
>>>> drivers/net/cxgbe/cxgbe_flow.c | 4 +--
>>>> drivers/net/cxgbe/cxgbe_main.c | 10 +++----
>>>> drivers/net/cxgbe/sge.c | 2 +-
>>>> drivers/net/ena/ena_ethdev.c | 8 ++---
>>>> drivers/net/enic/base/vnic_dev.c | 4 +--
>>>> drivers/net/enic/base/vnic_devcmd.h | 2 --
>>>> drivers/net/hns3/hns3_cmd.c | 2 +-
>>>> drivers/net/hns3/hns3_ethdev.h | 2 --
>>>> drivers/net/hns3/hns3_flow.c | 18 +++++------
>>>> drivers/net/i40e/base/i40e_diag.c | 2 +-
>>>> drivers/net/i40e/base/i40e_osdep.h | 2 --
>>>> drivers/net/iavf/base/iavf_osdep.h | 2 --
>>>> drivers/net/ice/base/ice_fdir.c | 2 +-
>>>> drivers/net/ice/base/ice_flex_pipe.c | 2 +-
>>>> drivers/net/ice/base/ice_flow.c | 2 +-
>>>> drivers/net/ice/base/ice_osdep.h | 1 -
>>>> drivers/net/ice/base/ice_switch.c | 2 +-
>>>> .../net/nfp/nfpcore/nfp-common/nfp_platform.h | 4 ---
>>>> drivers/net/nfp/nfpcore/nfp_cppcore.c | 2 +-
>>>> drivers/net/nfp/nfpcore/nfp_nsp.c | 2 +-
>>>> drivers/net/nfp/nfpcore/nfp_nsp_eth.c | 4 +--
>>>> drivers/net/sfc/base/ef10_ev.c | 4 +--
>>>> drivers/net/sfc/base/ef10_filter.c | 12 ++++----
>>>> drivers/net/sfc/base/ef10_mac.c | 18 +++++------
>>>> drivers/net/sfc/base/ef10_nic.c | 4 +--
>>>> drivers/net/sfc/base/ef10_nvram.c | 6 ++--
>>>> drivers/net/sfc/base/efx.h | 3 --
>>>> drivers/net/sfc/base/efx_port.c | 2 +-
>>>> drivers/net/sfc/base/efx_rx.c | 2 +-
>>>> drivers/net/sfc/base/siena_mac.c | 2 +-
>>>> drivers/net/sfc/base/siena_nic.c | 20 ++++++-------
>>>> drivers/net/sfc/base/siena_nvram.c | 6 ++--
>>>> drivers/net/thunderx/base/nicvf_hw.c | 30 +++++++++--------
>--
>>>> drivers/net/thunderx/base/nicvf_hw.h | 2 --
>>>> .../raw/ifpga/base/osdep_rte/osdep_generic.h | 2 --
>>>> 54 files changed, 120 insertions(+), 170 deletions(-)
>>>>
>>>> diff --git a/drivers/bus/dpaa/base/qbman/qman.c
>>>> b/drivers/bus/dpaa/base/qbman/qman.c
>>>> index e43fc65ef..019be95e2 100644
>>>> --- a/drivers/bus/dpaa/base/qbman/qman.c
>>>> +++ b/drivers/bus/dpaa/base/qbman/qman.c
>>>> @@ -1956,7 +1956,7 @@ int qman_query_wq(u8
>query_dedicated, struct
>>>> qm_mcr_querywq *wq)
>>>> int i, array_len;
>>>>
>>>> wq->channel.id = be16_to_cpu(mcr-
>>querywq.channel.id);
>>>> - array_len = ARRAY_SIZE(mcr->querywq.wq_len);
>>>> + array_len = RTE_DIM(mcr->querywq.wq_len);
>>>
>>> [Hemant] some of these files are common Flibs and they are shared
>with other projects (Linux/uboot) etc. It will be more appropriate to
>>> map the ARRAY_SIZE to RTE_DIM in compat.h instead of changing
>this code inline.
>>> This way we need not to maintain diff from the common HW lib
>codes.
>>
>> +1 to this suggestion
>>
>
>What about dropping the drivers patch form this patchset but continue
>with others?
I will drop the drivers patch from this patchset and send v2 for the rest.
Pavan.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2019-10-27 13:37 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-11 4:07 [dpdk-dev] [PATCH 1/3] app/test: use RTE_DIM instead of ARRAY_SIZE pbhagavatula
2019-10-11 4:07 ` [dpdk-dev] [PATCH 2/3] drivers: " pbhagavatula
2019-10-11 4:37 ` Hemant Agrawal
2019-10-11 9:32 ` Ananyev, Konstantin
2019-10-11 13:48 ` Ferruh Yigit
2019-10-11 6:14 ` Andrew Rybchenko
2019-10-11 9:03 ` Igor Russkikh
2019-10-11 9:00 ` Hyong Youb Kim (hyonkim)
2019-10-11 4:07 ` [dpdk-dev] [PATCH 3/3] bitrate: " pbhagavatula
2019-10-11 14:20 ` [dpdk-dev] [PATCH 1/3] app/test: " Eads, Gage
2019-10-17 12:09 ` [dpdk-dev] [PATCH v2 1/2] " pbhagavatula
2019-10-17 12:10 ` [dpdk-dev] [PATCH v2 2/2] bitrate: " pbhagavatula
2019-10-27 13:36 ` David Marchand
2019-10-27 13:35 ` [dpdk-dev] [PATCH v2 1/2] app/test: " David Marchand
2019-10-14 6:58 [dpdk-dev] [PATCH 2/3] drivers: " Pavan Nikhilesh Bhagavatula
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).