On Tue, 22 Sep 2026 18:07:23 -0700
Joshua Washington <[email protected]> wrote:
> Numerous components independently define the DIV_ROUND_UP macro, using
> the same definition. Attempt to commonize by introducing
> RTE_DIV_ROUND_UP to rte_common.h and replacing usages of DIV_ROUND_UP
> with RTE_DIV_ROUND_UP. Similarly, replace DIV_CEIL, which is
> functionally identical, to RTE_DIV_ROUND_UP.
>
> Changes in v3:
> - eal: Add unit tests in app/test/test_common.c.
> - eal: Add release notes entry for RTE_DIV_ROUND_UP.
> - eal: Expand Doxygen documentation with parameters and caveats
> (divisor evaluation, non-negative inputs, wraparound).
> - base code (qede, cxgbe, ena): Keep DIV_ROUND_UP macro in osdep/platform
> headers and avoid modifying call sites under base/.
> - nfp: Change commit subject prefix from "drivers:" to "net/nfp:".
> - qede, nfp: Drop unnecessary line rewraps.
> - ena: Remove extraneous blank line in ena_plat_dpdk.h.
> - app: Convert DIV_CEIL in app/test and app/test-compress-perf to
> RTE_DIV_ROUND_UP.
>
> Changes in v2:
> - Split single patch into series.
>
> Joshua Washington (16):
> eal: introduce division round up macro
> net/i40e: use common division round up macro
> net/idpf: use common division round up macro
> net/ice: use common division round up macro
> net/qede: use common division round up macro
> net/rnp: use common division round up macro
> net/hns3: use common division round up macro
> net/hinic: use common division round up macro
> net/bnx2x: use common division round up macro
> net/cxgbe: use common division round up macro
> net/ena: use common division round up macro
> raw/ifpga/base: use common division round up macro
> net/nfp: use common division round up macro
> app/procinfo: use common division round up macro
> app/test: use common division round up macro
> app/test-compress-perf: use common division round up macro
>
> app/proc-info/main.c | 3 +--
> app/test-compress-perf/comp_perf_test_common.c | 13 +++++--------
> app/test/test_common.c | 10 ++++++++++
> app/test/test_compressdev.c | 4 +---
> doc/guides/rel_notes/release_26_11.rst | 5 +++++
> drivers/common/nfp/nfp_platform.h | 2 --
> drivers/net/bnx2x/bnx2x.c | 4 ++--
> drivers/net/bnx2x/bnx2x.h | 11 ++++-------
> drivers/net/cxgbe/cxgbe_compat.h | 2 +-
> drivers/net/cxgbe/cxgbe_filter.c | 6 +++---
> drivers/net/cxgbe/cxgbe_ofld.h | 4 ++--
> drivers/net/cxgbe/sge.c | 14 +++++++-------
> drivers/net/ena/base/ena_plat_dpdk.h | 2 +-
> drivers/net/hinic/base/hinic_compat.h | 5 +----
> drivers/net/hns3/hns3_ethdev.h | 2 --
> drivers/net/hns3/hns3_fdir.c | 2 +-
> drivers/net/hns3/hns3_regs.c | 8 ++++----
> drivers/net/hns3/hns3_rss.c | 8 ++++----
> drivers/net/intel/i40e/base/i40e_osdep.h | 3 +--
> drivers/net/intel/ice/base/ice_osdep.h | 3 +--
> drivers/net/intel/idpf/base/idpf_osdep.h | 3 +--
> drivers/net/nfp/nfdk/nfp_nfdk.h | 2 +-
> drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 2 +-
> drivers/net/nfp/nfpcore/nfp_nsp.c | 2 +-
> drivers/net/qede/base/bcm_osal.h | 1 -
> drivers/net/qede/qede_debug.c | 16 ++++++++--------
> drivers/net/rnp/base/rnp_osdep.h | 5 ++---
> drivers/net/rnp/rnp_rxtx.c | 2 +-
> drivers/raw/ifpga/base/opae_osdep.h | 3 +--
> lib/eal/include/rte_common.h | 18 ++++++++++++++++++
> 30 files changed, 88 insertions(+), 77 deletions(-)
>
Since the next-net-intel tree is now merged in main this will need
a rebase. Detailed AI review also found other issues:
Review: [PATCH v3 01/16..16/16] common division round up macro
Series
------
Error
Patches 02-04 do not apply to main. The osdep headers moved out of
base/ in:
968a7e52ef50 ("net/i40e: move editable files out of base folder")
2eb2950a8e17 ("net/ice: move editable files out of base folder")
7b8be7b1c614 ("net/idpf: move editable files out of base folder")
Patch 01 also conflicts in release_26_11.rst. Needs a rebase; the
changes carry over as is to drivers/net/intel/{i40e,ice,idpf}/.
With paths adjusted, every commit builds with -Dwerror=true for all
touched drivers and apps, and common_autotest passes.
Warning
Patches 05, 10 and 11 say DIV_ROUND_UP is now redundant, but v3
keeps it in bcm_osal.h, cxgbe_compat.h and ena_plat_dpdk.h as an
alias for base/ code. Update the commit bodies to match, e.g.:
Map DIV_ROUND_UP to RTE_DIV_ROUND_UP for base code and use
RTE_DIV_ROUND_UP directly elsewhere in the driver.
For 05, what actually goes away is the local RTE_DIV_ROUND_UP.
Info
Private copies not covered by the series, for a follow-up:
drivers/crypto/ccp/ccp_dev.h CCP_DIV_ROUND_UP
drivers/common/qat/dev/qat_dev_gen_lce.c LCE_DIV_ROUND_UP (unused)
drivers/common/sxe2/sxe2_osal.h SXE2_DIV_ROUND_UP
examples/ip_fragmentation/main.c ROUNDUP_DIV (unused)
Patch 01/16 eal: introduce division round up macro
--------------------------------------------------
Warning
The Doxygen block contradicts itself on the divisor:
+ * Divisor. Must be a positive integer. Evaluated twice.
+ * @note Both @p n and @p d must be non-negative to round correctly.
d == 0 is non-negative. The first two @note lines only repeat the
@param text; drop them. Also @c formats a single word, so
"@c (n) + (d) - 1" renders only "(n)" as code. Suggest:
/**
* Divide @p n by @p d, rounding up.
*
* @param n
* Dividend. Must be non-negative.
* @param d
* Divisor. Must be positive. Evaluated twice.
* @return
* @p n divided by @p d, rounded up.
*
* @note (n) + (d) - 1 wraps if @p n is near the maximum of its
* type, e.g. RTE_DIV_ROUND_UP(UINT32_MAX, 2) is 0.
*/
Patch 03/16 net/idpf: use common division round up macro
--------------------------------------------------------
Info
Pre-existing, not introduced by this patch. After the rebase
idpf_osdep.h still carries a second copy, with no users in the tree:
#define DIVIDE_AND_ROUND_UP(a, b) (((a) + (b) - 1) / (b))
Drop it or alias it to RTE_DIV_ROUND_UP.
Patch 04/16 net/ice: use common division round up macro
-------------------------------------------------------
Info
Pre-existing, not introduced by this patch. ice_osdep.h has the same
DIVIDE_AND_ROUND_UP copy, used by base code (ice_acl_ctrl.c,
ice_flow.c, ice_sched.c). Now that the file is outside base/, map it
to RTE_DIV_ROUND_UP as done for cxgbe and ena.