eal: introduce division round up macro
PATCH 1/1 eal: introduce division round up macro
A number of drivers define the DIV_ROUND_UP macro -- add it to RTE_COMMON so that other code looking to use that functionality doesn't have to re-define it.
Replace usage of DIV_ROUND_UP in existing places with RTE_DIV_ROUND_UP.
--- app/proc-info/main.c | 3 +-- drivers/common/nfp/nfp_platform.h | 2 -- drivers/net/bnx2x/bnx2x.c | 4 ++-- drivers/net/bnx2x/bnx2x.h | 11 ++++------- drivers/net/cxgbe/base/t4_hw.c | 4 ++-- drivers/net/cxgbe/base/t4vf_hw.c | 10 +++++----- drivers/net/cxgbe/cxgbe_compat.h | 3 +-- 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_eth_com.h | 4 ++-- drivers/net/ena/base/ena_plat_dpdk.h | 1 - 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 | 5 +++-- drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 3 ++- drivers/net/nfp/nfpcore/nfp_nsp.c | 2 +- drivers/net/qede/base/bcm_osal.h | 2 -- drivers/net/qede/base/ecore_chain.h | 2 +- drivers/net/qede/base/ecore_cxt.c | 20 +++++++++++--------- drivers/net/qede/base/ecore_init_fw_funcs.c | 21 ++++++++++++--------- drivers/net/qede/base/ecore_mcp.c | 6 +++--- 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 | 5 +++++ 33 files changed, 92 insertions(+), 100 deletions(-)
app/proc-info/main.c +1 -2
@@ -48,7 +48,6 @@#define ETHDEV_FWVERS_LEN 32#define RTE_RETA_CONF_GROUP_NUM 32 -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#define EEPROM_DUMP_CHUNKSIZE 1024#define STATS_BDR_FMT "========================================"
@@ -1830,7 +1829,7 @@ show_port_rss_reta_info(void)return ; } - num =DIV_ROUND_UP (dev_info.reta_size,RTE_ETH_RETA_GROUP_SIZE ); + num =RTE_DIV_ROUND_UP (dev_info.reta_size,RTE_ETH_RETA_GROUP_SIZE );memset (reta_conf,0 ,sizeof (reta_conf));for (i =0 ; i < num; i++) reta_conf[i].mask = ~0ULL ;
drivers/common/nfp/nfp_platform.h +0 -2
@@ -10,8 +10,6 @@#include <rte_bitops.h> -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) -#define DMA_BIT_MASK (n) ((1ULL << (n)) - 1)#define BITS_PER_LONG (__SIZEOF_LONG__ * 8)
drivers/net/bnx2x/bnx2x.c +2 -2
@@ -2334,8 +2334,8 @@ static void bnx2x_ilt_set_info(struct bnx2x_softc *sc) ilt_client->start = line;/* 4 bytes for each cid */ - line +=DIV_ROUND_UP (sc->qm_cid_count *QM_QUEUES_PER_FUNC *4 , -QM_ILT_PAGE_SZ ); + line +=RTE_DIV_ROUND_UP (sc->qm_cid_count *QM_QUEUES_PER_FUNC *4 , +QM_ILT_PAGE_SZ ); ilt_client->end = (line -1 ); }
drivers/net/bnx2x/bnx2x.h +4 -7
@@ -37,9 +37,6 @@#ifndef ARRAY_SIZE #define ARRAY_SIZE (arr) RTE_DIM(arr)#endif -#ifndef DIV_ROUND_UP -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) -#endif #ifndef roundup#define roundup (x, y) ((((x) + ((y) - 1)) / (y)) * (y))#endif
@@ -393,7 +390,7 @@ union cdu_context {#define CNIC_ISCSI_CID_MAX 256#define CNIC_FCOE_CID_MAX 2048#define CNIC_CID_MAX (CNIC_ISCSI_CID_MAX + CNIC_FCOE_CID_MAX) -#define CNIC_ILT_LINES DIV_ROUND_UP(CNIC_CID_MAX, ILT_PAGE_CIDS) +#define CNIC_ILT_LINES RTE_DIV_ROUND_UP(CNIC_CID_MAX, ILT_PAGE_CIDS)#define QM_ILT_PAGE_SZ_HW 0#define QM_ILT_PAGE_SZ (4096 << QM_ILT_PAGE_SZ_HW)/* 4K */
@@ -405,7 +402,7 @@ union cdu_context {/*#define TM_CONN_NUM (CNIC_STARTING_CID+CNIC_ISCSI_CXT_MAX) */ #define TM_CONN_NUM 1024#define TM_ILT_SZ (8 * TM_CONN_NUM) -#define TM_ILT_LINES DIV_ROUND_UP(TM_ILT_SZ, TM_ILT_PAGE_SZ) +#define TM_ILT_LINES RTE_DIV_ROUND_UP(TM_ILT_SZ, TM_ILT_PAGE_SZ)/* SRC (Searcher) host DB constants */ #define SRC_ILT_PAGE_SZ_HW 0
@@ -414,7 +411,7 @@ union cdu_context {#define SRC_CONN_NUM (1 << SRC_HASH_BITS)/* 1024 */ #define SRC_ILT_SZ (sizeof(struct src_ent) * SRC_CONN_NUM)#define SRC_T2_SZ SRC_ILT_SZ -#define SRC_ILT_LINES DIV_ROUND_UP(SRC_ILT_SZ, SRC_ILT_PAGE_SZ) +#define SRC_ILT_LINES RTE_DIV_ROUND_UP(SRC_ILT_SZ, SRC_ILT_PAGE_SZ)struct hw_context {struct bnx2x_dma vcxt_dma;
@@ -1258,7 +1255,7 @@ struct bnx2x_softc {#define BNX2X_L2_CID_COUNT (sc) \ (BNX2X_NUM_ETH_QUEUES(sc) * ECORE_MULTI_TX_COS + 2 * CNIC_SUPPORT(sc))#define L2_ILT_LINES (sc) \ - (DIV_ROUND_UP(BNX2X_L2_CID_COUNT(sc), ILT_PAGE_CIDS)) + (RTE_DIV_ROUND_UP(BNX2X_L2_CID_COUNT(sc), ILT_PAGE_CIDS))int qm_cid_count;
drivers/net/cxgbe/base/t4_hw.c +2 -2
@@ -2630,8 +2630,8 @@ static int t4_get_exprom_version(struct adapter *adapter, u32 *vers)unsigned char hdr_arr[16 ];/* must start with 0x55aa */ unsigned char hdr_ver[4 ];/* Expansion ROM version */ } *hdr; -u32 exprom_header_buf[DIV_ROUND_UP (sizeof (struct exprom_header ), -sizeof (u32))]; +u32 exprom_header_buf[RTE_DIV_ROUND_UP (sizeof (struct exprom_header ), +sizeof (u32))];int ret; ret = t4_read_flash(adapter, FLASH_EXP_ROM_START,
drivers/net/cxgbe/base/t4vf_hw.c +5 -5
@@ -362,8 +362,8 @@ int t4vf_query_params(struct adapter *adapter, unsigned int nparams, cmd.op_to_vfn =cpu_to_be32 (V_FW_CMD_OP (FW_PARAMS_CMD ) |F_FW_CMD_REQUEST |F_FW_CMD_READ ); - len16 =DIV_ROUND_UP (offsetof(struct fw_params_cmd , - param[nparams]), 16); + len16 =RTE_DIV_ROUND_UP (offsetof(struct fw_params_cmd , + param[nparams]), 16); cmd.retval_len16 =cpu_to_be32 (V_FW_CMD_LEN16 (len16));for (i =0 , p = &cmd.param[0 ]; i < nparams; i++, p++) p->mnem =cpu_to_be32 (*params++);
@@ -458,8 +458,8 @@ int t4vf_set_params(struct adapter *adapter, unsigned int nparams, cmd.op_to_vfn =cpu_to_be32 (V_FW_CMD_OP (FW_PARAMS_CMD ) |F_FW_CMD_REQUEST |F_FW_CMD_WRITE ); - len16 =DIV_ROUND_UP (offsetof(struct fw_params_cmd , - param[nparams]), 16); + len16 =RTE_DIV_ROUND_UP (offsetof(struct fw_params_cmd , + param[nparams]), 16); cmd.retval_len16 =cpu_to_be32 (V_FW_CMD_LEN16 (len16));for (i =0 , p = &cmd.param[0 ]; i < nparams; i++, p++) { p->mnem =cpu_to_be32 (*params++);
@@ -626,7 +626,7 @@ static int t4vf_get_port_stats_fw(struct adapter *adapter, int pidx,struct fw_vi_stats_cmd cmd, rpl;size_t len = (offsetof(struct fw_vi_stats_cmd , u) +sizeof (struct fw_vi_stats_ctl )); -size_t len16 =DIV_ROUND_UP (len,16 ); +size_t len16 =RTE_DIV_ROUND_UP (len,16 );int ret;memset (&cmd,0 ,sizeof (cmd));
drivers/net/cxgbe/cxgbe_compat.h +1 -2
@@ -166,11 +166,10 @@ typedef uint64_t dma_addr_t;typedef char *caddr_t ;#endif -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#define DELAY (x) rte_delay_us(x)#define udelay (x) DELAY(x)#define msleep (x) DELAY(1000 * (x)) -#define usleep_range (min, max) msleep(DIV_ROUND_UP(min, 1000)) +#define usleep_range (min, max) msleep(RTE_DIV_ROUND_UP(min, 1000))static inline uint8_t hweight32 (uint32_t word32) {
drivers/net/cxgbe/cxgbe_filter.c +3 -3
@@ -219,7 +219,7 @@ static inline void mk_set_tcb_field_ulp(struct filter_entry *f, txpkt->cmd_dest =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_PKT ) |V_ULP_TXPKT_DEST (0 )); - txpkt->len =cpu_to_be32 (DIV_ROUND_UP (sizeof (*req),16 )); + txpkt->len =cpu_to_be32 (RTE_DIV_ROUND_UP (sizeof (*req),16 )); sc->cmd_more =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_SC_IMM )); sc->len =cpu_to_be32 (sizeof (*req) -sizeof (struct work_request_hdr ));OPCODE_TID (req) =cpu_to_be32 (MK_OPCODE_TID (CPL_SET_TCB_FIELD , f->tid));
@@ -371,7 +371,7 @@ static void mk_abort_req_ulp(struct cpl_abort_req *abort_req, txpkt->cmd_dest =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_PKT ) |V_ULP_TXPKT_DEST (0 )); - txpkt->len =cpu_to_be32 (DIV_ROUND_UP (sizeof (*abort_req),16 )); + txpkt->len =cpu_to_be32 (RTE_DIV_ROUND_UP (sizeof (*abort_req),16 )); sc->cmd_more =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_SC_IMM )); sc->len =cpu_to_be32 (sizeof (*abort_req) -sizeof (struct work_request_hdr ));
@@ -395,7 +395,7 @@ static void mk_abort_rpl_ulp(struct cpl_abort_rpl *abort_rpl, txpkt->cmd_dest =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_PKT ) |V_ULP_TXPKT_DEST (0 )); - txpkt->len =cpu_to_be32 (DIV_ROUND_UP (sizeof (*abort_rpl),16 )); + txpkt->len =cpu_to_be32 (RTE_DIV_ROUND_UP (sizeof (*abort_rpl),16 )); sc->cmd_more =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_SC_IMM )); sc->len =cpu_to_be32 (sizeof (*abort_rpl) -sizeof (struct work_request_hdr ));
drivers/net/cxgbe/cxgbe_ofld.h +2 -2
@@ -14,7 +14,7 @@ (w)->wr.wr_hi =cpu_to_be32 (V_FW_WR_OP (FW_TP_WR ) | \V_FW_WR_IMMDLEN (sizeof (*w) -sizeof (w->wr))); \ (w)->wr.wr_mid =cpu_to_be32 ( \ -V_FW_WR_LEN16 (DIV_ROUND_UP (sizeof (*w),16 )) | \ +V_FW_WR_LEN16 (RTE_DIV_ROUND_UP (sizeof (*w),16 )) | \V_FW_WR_FLOWID (tid)); \ (w)->wr.wr_lo =cpu_to_be64 (0 ); \ }while (0 )
@@ -27,7 +27,7 @@#define INIT_ULPTX_WR (w, wrlen, atomic, tid) do { \ (w)->wr.wr_hi = cpu_to_be32(V_FW_WR_OP(FW_ULPTX_WR) | \ V_FW_WR_ATOMIC(atomic)); \ - (w)->wr.wr_mid = cpu_to_be32(V_FW_WR_LEN16(DIV_ROUND_UP(wrlen, 16)) | \ + (w)->wr.wr_mid = cpu_to_be32(V_FW_WR_LEN16(RTE_DIV_ROUND_UP(wrlen, 16)) | \ V_FW_WR_FLOWID(tid)); \ (w)->wr.wr_lo = cpu_to_be64(0); \ } while (0)
drivers/net/cxgbe/sge.c +7 -7
@@ -459,7 +459,7 @@ static inline unsigned int sgl_len(unsigned int n)*/ static inline unsigned int flits_to_desc (unsigned int n) { -return DIV_ROUND_UP (n,8 ); +return RTE_DIV_ROUND_UP (n,8 ); }/**
@@ -505,7 +505,7 @@ static inline unsigned int calc_tx_flits(const struct rte_mbuf *m, hdrlen =is_eth_imm (m);if (hdrlen) -return DIV_ROUND_UP (m->pkt_len + hdrlen,sizeof (__be64)); +return RTE_DIV_ROUND_UP (m->pkt_len + hdrlen,sizeof (__be64));/* * Otherwise, we're going to have to construct a Scatter gather list
@@ -779,7 +779,7 @@ static inline void ship_tx_pkt_coalesce_wr(struct adapter *adap, wr = (void *)&q->desc[q->pidx]; vmwr = (void *)&q->desc[q->pidx]; - wr_mid =V_FW_WR_LEN16 (DIV_ROUND_UP (q->coalesce.flits,2 )); + wr_mid =V_FW_WR_LEN16 (RTE_DIV_ROUND_UP (q->coalesce.flits,2 )); ndesc =flits_to_desc (q->coalesce.flits); wr->equiq_to_len16 =htonl (wr_mid); wr->plen =cpu_to_be16 (q->coalesce.len);
@@ -866,7 +866,7 @@ static inline int should_tx_packet_coalesce(struct sge_eth_txq *txq,/* If coalescing is on, the mbuf is added to a pkts WR */ if (q->coalesce.idx) { - ndesc =DIV_ROUND_UP (q->coalesce.flits + flits,8 ); + ndesc =RTE_DIV_ROUND_UP (q->coalesce.flits + flits,8 ); credits =txq_avail (q) - ndesc;if (unlikely (wraps_around (q, ndesc)))
@@ -950,7 +950,7 @@ static inline int tx_do_packet_coalesce(struct sge_eth_txq *txq, mc->cmd_dest =htonl (V_ULPTX_CMD (4 ) |V_ULP_TXPKT_DEST (0 ) |V_ULP_TXPKT_FID (adap->sge.fw_evtq.cntxt_id) |F_ULP_TXPKT_RO ); - mc->len =htonl (DIV_ROUND_UP (flits,2 )); + mc->len =htonl (RTE_DIV_ROUND_UP (flits,2 )); sc_imm = (struct ulptx_idata *)(mc +1 ); sc_imm->cmd_more =htonl (V_ULPTX_CMD (ULP_TX_SC_IMM ) |F_ULP_TX_SC_MORE );
@@ -1116,7 +1116,7 @@ int t4_eth_xmit(struct sge_eth_txq *txq, struct rte_mbuf *mbuf, goto out_free; } - wr_mid =V_FW_WR_LEN16 (DIV_ROUND_UP (flits,2 )); + wr_mid =V_FW_WR_LEN16 (RTE_DIV_ROUND_UP (flits,2 ));if (Q_IDXDIFF (&txq->q, equeidx) >=64 ) { txq->q.equeidx = txq->q.pidx; wr_mid |=F_FW_WR_EQUEQ ;
@@ -1322,7 +1322,7 @@ static int ctrl_xmit(struct sge_ctrl_txq *q, struct rte_mbuf *mbuf) }reclaim_completed_tx_imm (&q->q); - ndesc =DIV_ROUND_UP (mbuf->pkt_len,sizeof (struct tx_desc )); + ndesc =RTE_DIV_ROUND_UP (mbuf->pkt_len,sizeof (struct tx_desc ));t4_os_lock (&q->ctrlq_lock); q->full =txq_avail (&q->q) < ndesc ?1 :0 ;
drivers/net/ena/base/ena_eth_com.h +2 -2
@@ -160,8 +160,8 @@ static inline bool ena_com_is_doorbell_needed(struct ena_com_io_sq *io_sq,if (num_descs > llq_info->descs_num_before_header) { descs_after_first_entry = num_descs - llq_info->descs_num_before_header; - num_entries_needed +=DIV_ROUND_UP (descs_after_first_entry, - llq_info->descs_per_entry); + num_entries_needed +=RTE_DIV_ROUND_UP (descs_after_first_entry, + llq_info->descs_per_entry); } ena_trc_dbg(ena_com_io_sq_to_ena_dev(io_sq),
drivers/net/ena/base/ena_plat_dpdk.h +0 -1
@@ -304,7 +304,6 @@ ena_mem_alloc_coherent(struct rte_eth_dev_data *data, size_t size,rte_write64_relaxed (*from, to); \ } while(0) -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#define ENA_FFS (x) ffs(x)
drivers/net/hinic/base/hinic_compat.h +1 -4
@@ -70,11 +70,8 @@ typedef uint64_t dma_addr_t;#define upper_32_bits (n) ((u32)(((n) >> 16) >> 16))#define lower_32_bits (n) ((u32)(n)) -/* Returns X / Y, rounding up. X must be nonnegative to round correctly. */ -#define DIV_ROUND_UP (X ,Y ) (((X) + ((Y) - 1)) / (Y)) -/* Returns X rounded up to the nearest multiple of Y. */ -#define ROUND_UP (X ,Y ) (DIV_ROUND_UP(X, Y) * (Y)) +#define ROUND_UP (X ,Y ) (RTE_DIV_ROUND_UP(X, Y) * (Y))#undef ALIGN#define ALIGN (x, a) RTE_ALIGN(x, a)
drivers/net/hns3/hns3_ethdev.h +0 -2
@@ -978,8 +978,6 @@ static inline struct hns3_vf *HNS3_DEV_HW_TO_VF(struct hns3_hw *hw)#define roundup (x, y) ((((x) + ((y) - 1)) / (y)) * (y))#define rounddown (x, y) ((x) - ((x) % (y))) -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) -/* * Because hardware always access register in little-endian mode based on hns3 * network engine, so driver should also call rte_cpu_to_le_32 to convert data
drivers/net/hns3/hns3_fdir.c +1 -1
@@ -129,7 +129,7 @@ static const struct key_info tuple_key_info[] = {#define MAX_KEY_LENGTH 400#define MAX_200B_KEY_LENGTH 200#define MAX_META_DATA_LENGTH 16 -#define MAX_KEY_DWORDS DIV_ROUND_UP(MAX_KEY_LENGTH / HNS3_BITS_PER_BYTE, 4) +#define MAX_KEY_DWORDS RTE_DIV_ROUND_UP(MAX_KEY_LENGTH / HNS3_BITS_PER_BYTE, 4)#define MAX_KEY_BYTES (MAX_KEY_DWORDS * 4)enum HNS3_FD_PACKET_TYPE {
drivers/net/hns3/hns3_regs.c +4 -4
@@ -1034,8 +1034,8 @@ hns3_get_32_bit_regs(struct hns3_hw *hw, uint32_t regs_num, struct rte_dev_reg_iif (regs_num ==0 )return 0 ; - cmd_num =DIV_ROUND_UP (regs_num +HNS3_32_BIT_DESC_NODATA_LEN , -HNS3_32_BIT_REG_RTN_DATANUM ); + cmd_num =RTE_DIV_ROUND_UP (regs_num +HNS3_32_BIT_DESC_NODATA_LEN , +HNS3_32_BIT_REG_RTN_DATANUM ); desc =rte_zmalloc ("hns3-32bit-regs" ,sizeof (struct hns3_cmd_desc ) * cmd_num,0 );if (desc ==NULL ) {
@@ -1093,8 +1093,8 @@ hns3_get_64_bit_regs(struct hns3_hw *hw, uint32_t regs_num, struct rte_dev_reg_iif (regs_num ==0 )return 0 ; - cmd_num =DIV_ROUND_UP (regs_num +HNS3_64_BIT_DESC_NODATA_LEN , -HNS3_64_BIT_REG_RTN_DATANUM ); + cmd_num =RTE_DIV_ROUND_UP (regs_num +HNS3_64_BIT_DESC_NODATA_LEN , +HNS3_64_BIT_REG_RTN_DATANUM ); desc =rte_zmalloc ("hns3-64bit-regs" ,sizeof (struct hns3_cmd_desc ) * cmd_num,0 );if (desc ==NULL ) {
drivers/net/hns3/hns3_rss.c +4 -4
@@ -295,7 +295,7 @@ hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo, req = (struct hns3_rss_generic_config_cmd *)desc.data; - max_bd_num =DIV_ROUND_UP (key_len,HNS3_RSS_HASH_KEY_NUM ); + max_bd_num =RTE_DIV_ROUND_UP (key_len,HNS3_RSS_HASH_KEY_NUM );for (idx =0 ; idx < max_bd_num; idx++) {hns3_cmd_setup_basic_desc (&desc,HNS3_OPC_RSS_GENERIC_CONFIG , false);
@@ -335,7 +335,7 @@ hns3_rss_get_algo_key(struct hns3_hw *hw, uint8_t *hash_algo,int ret; req = (struct hns3_rss_generic_config_cmd *)desc.data; - max_bd_num =DIV_ROUND_UP (key_len,HNS3_RSS_HASH_KEY_NUM ); + max_bd_num =RTE_DIV_ROUND_UP (key_len,HNS3_RSS_HASH_KEY_NUM );for (idx =0 ; idx < max_bd_num; idx++) {hns3_cmd_setup_basic_desc (&desc,HNS3_OPC_RSS_GENERIC_CONFIG , true);
@@ -381,7 +381,7 @@ hns3_set_rss_indir_table(struct hns3_hw *hw, uint16_t *indir, uint16_t size)int ret; req = (struct hns3_rss_indirection_table_cmd *)desc.data; - max_bd_num =DIV_ROUND_UP (size,HNS3_RSS_CFG_TBL_SIZE ); + max_bd_num =RTE_DIV_ROUND_UP (size,HNS3_RSS_CFG_TBL_SIZE );for (i =0 ; i < max_bd_num; i++) {hns3_cmd_setup_basic_desc (&desc,HNS3_OPC_RSS_INDIR_TABLE , false);
@@ -431,7 +431,7 @@ hns3_get_rss_indir_table(struct hns3_hw *hw, uint16_t *indir, uint16_t size)int ret; req = (struct hns3_rss_indirection_table_cmd *)desc.data; - max_bd_num =DIV_ROUND_UP (size,HNS3_RSS_CFG_TBL_SIZE ); + max_bd_num =RTE_DIV_ROUND_UP (size,HNS3_RSS_CFG_TBL_SIZE );for (i =0 ; i < max_bd_num; i++) {hns3_cmd_setup_basic_desc (&desc,HNS3_OPC_RSS_INDIR_TABLE , true);
drivers/net/intel/i40e/base/i40e_osdep.h +1 -2
@@ -227,12 +227,11 @@ struct i40e_spinlock {#define i40e_memset (a, b, c, d) memset((a), (b), (c))#define i40e_memcpy (a, b, c, d) memcpy((a), (b), (c)) -#define DIV_ROUND_UP (n,d) (((n) + (d) - 1) / (d))#define DELAY (x) rte_delay_us_sleep(x)#define i40e_usec_delay (x) DELAY(x)#define i40e_msec_delay (x) DELAY(1000 * (x))#define udelay (x) DELAY(x)#define msleep (x) DELAY(1000*(x)) -#define usleep_range (min, max) msleep(DIV_ROUND_UP(min, 1000)) +#define usleep_range (min, max) msleep(RTE_DIV_ROUND_UP(min, 1000))#endif /* _I40E_OSDEP_H_ */
drivers/net/intel/ice/base/ice_osdep.h +1 -2
@@ -311,13 +311,12 @@ ice_hweight32(u32 num)return bits; } -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#define DELAY (x) rte_delay_us(x)#define ice_usec_delay (x, y) rte_delay_us(x)#define ice_msec_delay (x, y) rte_delay_us(1000 * (x))#define udelay (x) DELAY(x)#define msleep (x) DELAY(1000 * (x)) -#define usleep_range (min, max) msleep(DIV_ROUND_UP(min, 1000)) +#define usleep_range (min, max) msleep(RTE_DIV_ROUND_UP(min, 1000))struct ice_list_entry {LIST_ENTRY (ice_list_entry) next;
drivers/net/intel/idpf/base/idpf_osdep.h +1 -2
@@ -291,13 +291,12 @@ idpf_hweight32(u32 num)return bits; } -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#define DELAY (x) rte_delay_us(x)#define idpf_usec_delay (x) rte_delay_us(x)#define idpf_msec_delay (x, y) rte_delay_us(1000 * (x))#define udelay (x) DELAY(x)#define msleep (x) DELAY(1000 * (x)) -#define usleep_range (min, max) msleep(DIV_ROUND_UP(min, 1000)) +#define usleep_range (min, max) msleep(RTE_DIV_ROUND_UP(min, 1000))#ifndef IDPF_DBG_TRACE #define IDPF_DBG_TRACE BIT_ULL(0)
drivers/net/nfp/nfdk/nfp_nfdk.h +3 -2
@@ -168,8 +168,9 @@ static inline uint16_t nfp_net_nfdk_headlen_to_segs(uint16_t headlen) {/* First descriptor fits less data, so adjust for that */ -return DIV_ROUND_UP (headlen +NFDK_TX_MAX_DATA_PER_DESC -NFDK_TX_MAX_DATA_PER_HEAD , -NFDK_TX_MAX_DATA_PER_DESC ); +return RTE_DIV_ROUND_UP (headlen +NFDK_TX_MAX_DATA_PER_DESC - +NFDK_TX_MAX_DATA_PER_HEAD , +NFDK_TX_MAX_DATA_PER_DESC ); }/* Set TX CSUM offload flags in TX descriptor of nfdk */
drivers/net/nfp/nfdk/nfp_nfdk_dp.c +2 -1
@@ -103,7 +103,8 @@ nfp_net_nfdk_tx_maybe_close_block(struct nfp_net_txq *txq, n_descs =nfp_net_nfdk_headlen_to_segs (pkt_temp->data_len);while (pkt_temp->next !=NULL ) { pkt_temp = pkt_temp->next; - n_descs +=DIV_ROUND_UP (pkt_temp->data_len,NFDK_TX_MAX_DATA_PER_DESC ); + n_descs +=RTE_DIV_ROUND_UP (pkt_temp->data_len, +NFDK_TX_MAX_DATA_PER_DESC ); }if (unlikely (n_descs >NFDK_TX_DESC_GATHER_MAX ))
drivers/net/nfp/nfpcore/nfp_nsp.c +1 -1
@@ -542,7 +542,7 @@ nfp_nsp_command_buf_dma_sg(struct nfp_nsp *nsp,struct nfp_nsp_dma_desc *descs; chunk_size =RTE_BIT64 (chunk_order); - nseg =DIV_ROUND_UP (max_size, chunk_size); + nseg =RTE_DIV_ROUND_UP (max_size, chunk_size);/* Malloc memory */ total_len = sizeof(struct nfp_nsp_dma_buf) +
drivers/net/qede/base/bcm_osal.h +0 -2
@@ -396,8 +396,6 @@ int qede_save_fw_dump(uint16_t port_id);/* Utility functions */ -#define RTE_DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) -#define DIV_ROUND_UP (size, to_what) RTE_DIV_ROUND_UP(size, to_what)#define RTE_ROUNDUP (x, y) ((((x) + ((y) - 1)) / (y)) * (y))#define ROUNDUP (value, to_what) RTE_ROUNDUP((value), (to_what))
drivers/net/qede/base/ecore_chain.h +1 -1
@@ -157,7 +157,7 @@ struct ecore_chain { UNUSABLE_ELEMS_PER_PAGE(elem_size, mode)))#define ECORE_CHAIN_PAGE_CNT (elem_cnt, elem_size, mode) \ - DIV_ROUND_UP(elem_cnt, USABLE_ELEMS_PER_PAGE(elem_size, mode)) + RTE_DIV_ROUND_UP(elem_cnt, USABLE_ELEMS_PER_PAGE(elem_size, mode))#define is_chain_u16 (p) ((p)->cnt_type == ECORE_CHAIN_CNT_TYPE_U16)#define is_chain_u32 (p) ((p)->cnt_type == ECORE_CHAIN_CNT_TYPE_U32)
drivers/net/qede/base/ecore_cxt.c +11 -9
@@ -341,7 +341,8 @@ static void ecore_ilt_cli_adv_line(struct ecore_hwfn *p_hwfn, p_cli->first.val = *p_line; p_cli->active = true; - *p_line +=DIV_ROUND_UP (p_blk->total_size, p_blk->real_size_in_page); + *p_line +=RTE_DIV_ROUND_UP (p_blk->total_size, + p_blk->real_size_in_page); p_cli->last.val = *p_line -1 ; DP_VERBOSE(p_hwfn, ECORE_MSG_ILT,
@@ -761,7 +762,7 @@ static enum _ecore_status_t ecore_cxt_src_t2_alloc(struct ecore_hwfn *p_hwfn)/* use the same page size as the SRC ILT client */ psz =ILT_PAGE_IN_BYTES (p_src->p_size.val); p_t2 = &p_mngr->src_t2; - p_t2->num_pages =DIV_ROUND_UP (total_size, psz); + p_t2->num_pages =RTE_DIV_ROUND_UP (total_size, psz);/* allocate t2 */ p_t2->dma_mem = OSAL_ZALLOC(p_hwfn->p_dev, GFP_KERNEL,
@@ -877,7 +878,8 @@ ecore_ilt_blk_alloc(struct ecore_hwfn *p_hwfn, sz_left = p_blk->total_size; lines_to_skip = p_blk->dynamic_line_cnt; - lines =DIV_ROUND_UP (sz_left, p_blk->real_size_in_page) - lines_to_skip; + lines =RTE_DIV_ROUND_UP (sz_left, p_blk->real_size_in_page) - + lines_to_skip; line = p_blk->start_line + start_line_offset - p_hwfn->p_cxt_mngr->pf_start_line; first_skipped_line = line + p_blk->dynamic_line_offset;
@@ -1000,7 +1002,7 @@ __ecore_cid_map_alloc_single(struct ecore_hwfn *p_hwfn, u32 type,if (!cid_count)return ECORE_SUCCESS ; - size =MAP_WORD_SIZE *DIV_ROUND_UP (cid_count,BITS_PER_MAP_WORD ); + size =MAP_WORD_SIZE *RTE_DIV_ROUND_UP (cid_count,BITS_PER_MAP_WORD ); p_map->cid_map =OSAL_ZALLOC (p_hwfn->p_dev,GFP_KERNEL , size);if (p_map->cid_map ==OSAL_NULL )return ECORE_NOMEM ;
@@ -1217,8 +1219,8 @@ void ecore_cxt_mngr_setup(struct ecore_hwfn *p_hwfn) p_cfg = &p_mngr->conn_cfg[type];if (p_cfg->cid_count) { p_map = &p_mngr->acquired[type]; - len =DIV_ROUND_UP (p_map->max_count, -BITS_PER_MAP_WORD ) * + len =RTE_DIV_ROUND_UP (p_map->max_count, +BITS_PER_MAP_WORD ) *MAP_WORD_SIZE ;OSAL_MEM_ZERO (p_map->cid_map, len); }
@@ -1228,8 +1230,8 @@ void ecore_cxt_mngr_setup(struct ecore_hwfn *p_hwfn)for (vf =0 ; vf < max_num_vfs; vf++) { p_map = &p_mngr->acquired_vf[type][vf]; - len =DIV_ROUND_UP (p_map->max_count, -BITS_PER_MAP_WORD ) * + len =RTE_DIV_ROUND_UP (p_map->max_count, +BITS_PER_MAP_WORD ) *MAP_WORD_SIZE ;OSAL_MEM_ZERO (p_map->cid_map, len); }
@@ -2184,7 +2186,7 @@ static u16 ecore_blk_calculate_pages(struct ecore_ilt_cli_blk *p_blk)if (p_blk->real_size_in_page ==0 )return 0 ; -return DIV_ROUND_UP (p_blk->total_size, p_blk->real_size_in_page); +return RTE_DIV_ROUND_UP (p_blk->total_size, p_blk->real_size_in_page); }u16 ecore_get_cdut_num_pf_init_pages (struct ecore_hwfn *p_hwfn)
drivers/net/qede/base/ecore_init_fw_funcs.c +12 -9
@@ -24,9 +24,11 @@ static u16 task_region_offsets[1][NUM_OF_CONNECTION_TYPES] = {/* General constants */ #define QM_PQ_MEM_4KB (pq_size) \ - (pq_size ? DIV_ROUND_UP((pq_size + 1) * QM_PQ_ELEMENT_SIZE, 0x1000) : 0) + (pq_size \ + ? RTE_DIV_ROUND_UP((pq_size + 1) * QM_PQ_ELEMENT_SIZE, 0x1000) \ + : 0)#define QM_PQ_SIZE_256B (pq_size) \ - (pq_size ? DIV_ROUND_UP(pq_size, 0x100) - 1 : 0) + (pq_size ? RTE_DIV_ROUND_UP(pq_size, 0x100) - 1 : 0)#define QM_INVALID_PQ_ID 0xffff/* Max link speed (in Mbps) */
@@ -1313,10 +1315,10 @@ void ecore_init_brb_ram(struct ecore_hwfn *p_hwfn,u32 active_port_blocks, reg_offset =0 ;u8 port, active_ports =0 ; - tc_headroom_blocks = (u32 )DIV_ROUND_UP (req->headroom_per_tc, -BRB_BLOCK_SIZE ); - min_pkt_size_blocks = (u32 )DIV_ROUND_UP (req->min_pkt_size, -BRB_BLOCK_SIZE ); + tc_headroom_blocks = (u32 )RTE_DIV_ROUND_UP (req->headroom_per_tc, +BRB_BLOCK_SIZE ); + min_pkt_size_blocks = (u32 )RTE_DIV_ROUND_UP (req->min_pkt_size, +BRB_BLOCK_SIZE ); total_blocks =ECORE_IS_K2 (p_hwfn->p_dev) ?BRB_TOTAL_RAM_BLOCKS_K2 :BRB_TOTAL_RAM_BLOCKS_BB ;
@@ -1334,8 +1336,9 @@ void ecore_init_brb_ram(struct ecore_hwfn *p_hwfn,u8 tc;/* Calculate per-port sizes */ - tc_guaranteed_blocks = (u32 )DIV_ROUND_UP (req->guranteed_per_tc, -BRB_BLOCK_SIZE ); + tc_guaranteed_blocks = + (u32 )RTE_DIV_ROUND_UP (req->guranteed_per_tc, +BRB_BLOCK_SIZE ); port_blocks = req->num_active_tcs[port] ? active_port_blocks :0 ; port_guaranteed_blocks = req->num_active_tcs[port] *
@@ -2059,7 +2062,7 @@ void ecore_enable_context_validation(struct ecore_hwfn *p_hwfn,ecore_wr (p_hwfn, p_ptt,CDU_REG_TCFC_CTX_VALID0 , ctx_validation); } -#define PHYS_ADDR_DWORDS DIV_ROUND_UP(sizeof(dma_addr_t), 4) +#define PHYS_ADDR_DWORDS RTE_DIV_ROUND_UP(sizeof(dma_addr_t), 4)#define OVERLAY_HDR_SIZE_DWORDS (sizeof(struct fw_overlay_buf_hdr) / 4) static u32 ecore_get_overlay_addr_ram_addr(struct ecore_hwfn *p_hwfn,
drivers/net/qede/base/ecore_mcp.c +3 -3
@@ -713,7 +713,7 @@ ecore_mcp_cmd_and_union(struct ecore_hwfn *p_hwfn, }#endif if (ECORE_MB_FLAGS_IS_SET (p_mb_params,CAN_SLEEP )) { - max_retries =DIV_ROUND_UP (max_retries,1000 ); + max_retries =RTE_DIV_ROUND_UP (max_retries,1000 ); usecs *=1000 ; }
@@ -4243,8 +4243,8 @@ ecore_mcp_resc_lock(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,if (retry_cnt) {if (p_params->sleep_b4_retry) {u16 retry_interval_in_ms = -DIV_ROUND_UP (p_params->retry_interval, -1000 ); +RTE_DIV_ROUND_UP (p_params->retry_interval, +1000 );OSAL_MSLEEP (retry_interval_in_ms); }else {
drivers/net/qede/qede_debug.c +8 -8
@@ -332,7 +332,7 @@ struct split_type_defs {#define BYTES_IN_DWORD sizeof(u32)/* In the macros below, size and offset are specified in bits */ -#define CEIL_DWORDS (size) DIV_ROUND_UP(size, 32) +#define CEIL_DWORDS (size) RTE_DIV_ROUND_UP(size, 32)#define FIELD_BIT_OFFSET (type, field) type ## _ ## field ## _ ## OFFSET#define FIELD_BIT_SIZE (type, field) type ## _ ## field ## _ ## SIZE#define FIELD_DWORD_OFFSET (type, field) \
@@ -3060,7 +3060,7 @@ static u32 qed_grc_dump_big_ram(struct ecore_hwfn *p_hwfn,return offset + ram_size;/* Dump Big RAM */ -for (i =0 ; i <DIV_ROUND_UP (ram_size,BRB_REG_BIG_RAM_DATA_SIZE ); +for (i =0 ; i <RTE_DIV_ROUND_UP (ram_size,BRB_REG_BIG_RAM_DATA_SIZE ); i++) {u32 addr, len;
@@ -4161,8 +4161,8 @@ static enum dbg_status qed_mcp_trace_dump(struct ecore_hwfn *p_hwfn,/* Find trace data size */ trace_data_size_dwords = -DIV_ROUND_UP (trace_data_size_bytes +sizeof (struct mcp_trace ), -BYTES_IN_DWORD ); +RTE_DIV_ROUND_UP (trace_data_size_bytes +sizeof (struct mcp_trace ), +BYTES_IN_DWORD );/* Dump trace data section header and param */ offset += qed_dump_section_hdr(dump_buf + offset,
@@ -4817,10 +4817,10 @@ static u32 qed_ilt_dump(struct ecore_hwfn *p_hwfn, offset += num_pages *PAGE_MEM_DESC_SIZE_DWORDS ; } - valid_conn_pf_pages =DIV_ROUND_UP (valid_conn_pf_cids, - num_cids_per_page); - valid_conn_vf_pages =DIV_ROUND_UP (valid_conn_vf_cids, - num_cids_per_page); + valid_conn_pf_pages =RTE_DIV_ROUND_UP (valid_conn_pf_cids, + num_cids_per_page); + valid_conn_vf_pages =RTE_DIV_ROUND_UP (valid_conn_vf_cids, + num_cids_per_page);/* Dump ILT pages IDs */ offset += qed_ilt_dump_pages_section(p_hwfn,
drivers/net/rnp/base/rnp_osdep.h +2 -3
@@ -53,10 +53,9 @@ typedef uint64_t u64;#define cpu_to_le32 (v) rte_cpu_to_le_32((u32)(v))#endif -#ifndef DIV_ROUND_UP -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) +#ifndef BITS_TO_LONGS #define BITS_PER_BYTE (8) -#define BITS_TO_LONGS (nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) +#define BITS_TO_LONGS (nr) RTE_DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))#endif #define fls (n) rte_fls_u32(n)
drivers/net/rnp/rnp_rxtx.c +1 -1
@@ -1165,7 +1165,7 @@ rnp_calc_pkt_desc(struct rte_mbuf *tx_pkt)uint16_t count =0 ;while (txd !=NULL ) { - count +=DIV_ROUND_UP (txd->data_len,RNP_MAX_TSO_SEG_LEN ); + count +=RTE_DIV_ROUND_UP (txd->data_len,RNP_MAX_TSO_SEG_LEN ); txd = txd->next; }
drivers/raw/ifpga/base/opae_osdep.h +1 -2
@@ -71,10 +71,9 @@ struct uuid { } while (0)#endif -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#define udelay (x) opae_udelay(x)#define msleep (x) opae_udelay(1000 * (x)) -#define usleep_range (min, max) msleep(DIV_ROUND_UP(min, 1000)) +#define usleep_range (min, max) msleep(RTE_DIV_ROUND_UP(min, 1000))#define time_after (a, b) ((long)((b) - (a)) < 0)#define time_before (a, b) time_after(b, a)
lib/eal/include/rte_common.h +5 -0
@@ -717,6 +717,11 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) (ceil - (v)) > ((v) - floor) ? floor : ceil; \ }) +/** +* Macro to divide dividend n by divisor d, rounding up if d does not divide n. +*/ +#define RTE_DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) +/** * Checks if a pointer is aligned to a given power-of-two value *
Signature · 1 line
2.55.0.691.gc56d675ccc-goog
Quoted 8 lines · On Wed, 12 Aug 2026 15:30:17 -0700 Joshua Washington <[email protected]>…
A number of drivers define the
DIV_ROUND_UPmacro -- add it toRTE_COMMONso that other code looking to use that functionality doesn't have to re-define it.Replace usage of
DIV_ROUND_UPin existing places withRTE_DIV_ROUND_UP.Signed-off-by Joshua Washington <[email protected]>---
Makes sense, but this is the kind of change that is best done as a patch series so that each driver vendor looks at their code; and if something is broken only one change needs to be reverted. Make blast radius smaller
v2 cover Introduce RTE_DIV_ROUND_UP
In reply to Joshua WashingtonNumerous drivers 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.
Changes in v2:
- Split single patch into series.
Joshua Washington (14):
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
drivers: use common division round up macro app/procinfo: use common division round up macro
app/proc-info/main.c | 3 +-- drivers/common/nfp/nfp_platform.h | 2 -- drivers/net/bnx2x/bnx2x.c | 4 ++-- drivers/net/bnx2x/bnx2x.h | 11 ++++------- drivers/net/cxgbe/base/t4_hw.c | 4 ++-- drivers/net/cxgbe/base/t4vf_hw.c | 10 +++++----- drivers/net/cxgbe/cxgbe_compat.h | 3 +-- 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_eth_com.h | 4 ++-- drivers/net/ena/base/ena_plat_dpdk.h | 1 - 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 | 5 +++-- drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 3 ++- drivers/net/nfp/nfpcore/nfp_nsp.c | 2 +- drivers/net/qede/base/bcm_osal.h | 2 -- drivers/net/qede/base/ecore_chain.h | 2 +- drivers/net/qede/base/ecore_cxt.c | 20 +++++++++++--------- drivers/net/qede/base/ecore_init_fw_funcs.c | 21 ++++++++++++--------- drivers/net/qede/base/ecore_mcp.c | 6 +++--- 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 | 5 +++++ 33 files changed, 92 insertions(+), 100 deletions(-)
Signature · 1 line
2.55.0.691.gc56d675ccc-goog
PATCH v2 1/14 eal: introduce division round up macro
A number of drivers define the DIV_ROUND_UP macro -- add it to rte_common.h so that other code looking to use that functionality doesn't have to re-define it.
---
Changes in v2:
- Split out patches replacing usages
--- lib/eal/include/rte_common.h | 5 +++++ 1 file changed, 5 insertions(+)
lib/eal/include/rte_common.h +5 -0
@@ -717,6 +717,11 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) (ceil - (v)) > ((v) - floor) ? floor : ceil; \ }) +/** +* Macro to divide dividend n by divisor d, rounding up if d does not divide n. +*/ +#define RTE_DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) +/** * Checks if a pointer is aligned to a given power-of-two value *
Signature · 1 line
2.55.0.691.gc56d675ccc-goog
PATCH v2 2/14 net/i40e: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- drivers/net/intel/i40e/base/i40e_osdep.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/intel/i40e/base/i40e_osdep.h +1 -2
@@ -227,12 +227,11 @@ struct i40e_spinlock {#define i40e_memset (a, b, c, d) memset((a), (b), (c))#define i40e_memcpy (a, b, c, d) memcpy((a), (b), (c)) -#define DIV_ROUND_UP (n,d) (((n) + (d) - 1) / (d))#define DELAY (x) rte_delay_us_sleep(x)#define i40e_usec_delay (x) DELAY(x)#define i40e_msec_delay (x) DELAY(1000 * (x))#define udelay (x) DELAY(x)#define msleep (x) DELAY(1000*(x)) -#define usleep_range (min, max) msleep(DIV_ROUND_UP(min, 1000)) +#define usleep_range (min, max) msleep(RTE_DIV_ROUND_UP(min, 1000))#endif /* _I40E_OSDEP_H_ */
Signature · 1 line
2.55.0.691.gc56d675ccc-goog
PATCH v2 3/14 net/idpf: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- drivers/net/intel/idpf/base/idpf_osdep.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/intel/idpf/base/idpf_osdep.h +1 -2
@@ -291,13 +291,12 @@ idpf_hweight32(u32 num)return bits; } -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#define DELAY (x) rte_delay_us(x)#define idpf_usec_delay (x) rte_delay_us(x)#define idpf_msec_delay (x, y) rte_delay_us(1000 * (x))#define udelay (x) DELAY(x)#define msleep (x) DELAY(1000 * (x)) -#define usleep_range (min, max) msleep(DIV_ROUND_UP(min, 1000)) +#define usleep_range (min, max) msleep(RTE_DIV_ROUND_UP(min, 1000))#ifndef IDPF_DBG_TRACE #define IDPF_DBG_TRACE BIT_ULL(0)
Signature · 1 line
2.55.0.691.gc56d675ccc-goog
PATCH v2 4/14 net/ice: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- drivers/net/intel/ice/base/ice_osdep.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/intel/ice/base/ice_osdep.h +1 -2
@@ -311,13 +311,12 @@ ice_hweight32(u32 num)return bits; } -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#define DELAY (x) rte_delay_us(x)#define ice_usec_delay (x, y) rte_delay_us(x)#define ice_msec_delay (x, y) rte_delay_us(1000 * (x))#define udelay (x) DELAY(x)#define msleep (x) DELAY(1000 * (x)) -#define usleep_range (min, max) msleep(DIV_ROUND_UP(min, 1000)) +#define usleep_range (min, max) msleep(RTE_DIV_ROUND_UP(min, 1000))struct ice_list_entry {LIST_ENTRY (ice_list_entry) next;
Signature · 1 line
2.55.0.691.gc56d675ccc-goog
PATCH v2 5/14 net/qede: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP and RTE_DIV_ROUND_UP definitions redundant.
--- drivers/net/qede/base/bcm_osal.h | 2 -- drivers/net/qede/base/ecore_chain.h | 2 +- drivers/net/qede/base/ecore_cxt.c | 20 +++++++++++--------- drivers/net/qede/base/ecore_init_fw_funcs.c | 21 ++++++++++++--------- drivers/net/qede/base/ecore_mcp.c | 6 +++--- drivers/net/qede/qede_debug.c | 16 ++++++++-------- 6 files changed, 35 insertions(+), 32 deletions(-)
drivers/net/qede/base/bcm_osal.h +0 -2
@@ -396,8 +396,6 @@ int qede_save_fw_dump(uint16_t port_id);/* Utility functions */ -#define RTE_DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) -#define DIV_ROUND_UP (size, to_what) RTE_DIV_ROUND_UP(size, to_what)#define RTE_ROUNDUP (x, y) ((((x) + ((y) - 1)) / (y)) * (y))#define ROUNDUP (value, to_what) RTE_ROUNDUP((value), (to_what))
drivers/net/qede/base/ecore_chain.h +1 -1
@@ -157,7 +157,7 @@ struct ecore_chain { UNUSABLE_ELEMS_PER_PAGE(elem_size, mode)))#define ECORE_CHAIN_PAGE_CNT (elem_cnt, elem_size, mode) \ - DIV_ROUND_UP(elem_cnt, USABLE_ELEMS_PER_PAGE(elem_size, mode)) + RTE_DIV_ROUND_UP(elem_cnt, USABLE_ELEMS_PER_PAGE(elem_size, mode))#define is_chain_u16 (p) ((p)->cnt_type == ECORE_CHAIN_CNT_TYPE_U16)#define is_chain_u32 (p) ((p)->cnt_type == ECORE_CHAIN_CNT_TYPE_U32)
drivers/net/qede/base/ecore_cxt.c +11 -9
@@ -341,7 +341,8 @@ static void ecore_ilt_cli_adv_line(struct ecore_hwfn *p_hwfn, p_cli->first.val = *p_line; p_cli->active = true; - *p_line +=DIV_ROUND_UP (p_blk->total_size, p_blk->real_size_in_page); + *p_line +=RTE_DIV_ROUND_UP (p_blk->total_size, + p_blk->real_size_in_page); p_cli->last.val = *p_line -1 ; DP_VERBOSE(p_hwfn, ECORE_MSG_ILT,
@@ -761,7 +762,7 @@ static enum _ecore_status_t ecore_cxt_src_t2_alloc(struct ecore_hwfn *p_hwfn)/* use the same page size as the SRC ILT client */ psz =ILT_PAGE_IN_BYTES (p_src->p_size.val); p_t2 = &p_mngr->src_t2; - p_t2->num_pages =DIV_ROUND_UP (total_size, psz); + p_t2->num_pages =RTE_DIV_ROUND_UP (total_size, psz);/* allocate t2 */ p_t2->dma_mem = OSAL_ZALLOC(p_hwfn->p_dev, GFP_KERNEL,
@@ -877,7 +878,8 @@ ecore_ilt_blk_alloc(struct ecore_hwfn *p_hwfn, sz_left = p_blk->total_size; lines_to_skip = p_blk->dynamic_line_cnt; - lines =DIV_ROUND_UP (sz_left, p_blk->real_size_in_page) - lines_to_skip; + lines =RTE_DIV_ROUND_UP (sz_left, p_blk->real_size_in_page) - + lines_to_skip; line = p_blk->start_line + start_line_offset - p_hwfn->p_cxt_mngr->pf_start_line; first_skipped_line = line + p_blk->dynamic_line_offset;
@@ -1000,7 +1002,7 @@ __ecore_cid_map_alloc_single(struct ecore_hwfn *p_hwfn, u32 type,if (!cid_count)return ECORE_SUCCESS ; - size =MAP_WORD_SIZE *DIV_ROUND_UP (cid_count,BITS_PER_MAP_WORD ); + size =MAP_WORD_SIZE *RTE_DIV_ROUND_UP (cid_count,BITS_PER_MAP_WORD ); p_map->cid_map =OSAL_ZALLOC (p_hwfn->p_dev,GFP_KERNEL , size);if (p_map->cid_map ==OSAL_NULL )return ECORE_NOMEM ;
@@ -1217,8 +1219,8 @@ void ecore_cxt_mngr_setup(struct ecore_hwfn *p_hwfn) p_cfg = &p_mngr->conn_cfg[type];if (p_cfg->cid_count) { p_map = &p_mngr->acquired[type]; - len =DIV_ROUND_UP (p_map->max_count, -BITS_PER_MAP_WORD ) * + len =RTE_DIV_ROUND_UP (p_map->max_count, +BITS_PER_MAP_WORD ) *MAP_WORD_SIZE ;OSAL_MEM_ZERO (p_map->cid_map, len); }
@@ -1228,8 +1230,8 @@ void ecore_cxt_mngr_setup(struct ecore_hwfn *p_hwfn)for (vf =0 ; vf < max_num_vfs; vf++) { p_map = &p_mngr->acquired_vf[type][vf]; - len =DIV_ROUND_UP (p_map->max_count, -BITS_PER_MAP_WORD ) * + len =RTE_DIV_ROUND_UP (p_map->max_count, +BITS_PER_MAP_WORD ) *MAP_WORD_SIZE ;OSAL_MEM_ZERO (p_map->cid_map, len); }
@@ -2184,7 +2186,7 @@ static u16 ecore_blk_calculate_pages(struct ecore_ilt_cli_blk *p_blk)if (p_blk->real_size_in_page ==0 )return 0 ; -return DIV_ROUND_UP (p_blk->total_size, p_blk->real_size_in_page); +return RTE_DIV_ROUND_UP (p_blk->total_size, p_blk->real_size_in_page); }u16 ecore_get_cdut_num_pf_init_pages (struct ecore_hwfn *p_hwfn)
drivers/net/qede/base/ecore_init_fw_funcs.c +12 -9
@@ -24,9 +24,11 @@ static u16 task_region_offsets[1][NUM_OF_CONNECTION_TYPES] = {/* General constants */ #define QM_PQ_MEM_4KB (pq_size) \ - (pq_size ? DIV_ROUND_UP((pq_size + 1) * QM_PQ_ELEMENT_SIZE, 0x1000) : 0) + (pq_size \ + ? RTE_DIV_ROUND_UP((pq_size + 1) * QM_PQ_ELEMENT_SIZE, 0x1000) \ + : 0)#define QM_PQ_SIZE_256B (pq_size) \ - (pq_size ? DIV_ROUND_UP(pq_size, 0x100) - 1 : 0) + (pq_size ? RTE_DIV_ROUND_UP(pq_size, 0x100) - 1 : 0)#define QM_INVALID_PQ_ID 0xffff/* Max link speed (in Mbps) */
@@ -1313,10 +1315,10 @@ void ecore_init_brb_ram(struct ecore_hwfn *p_hwfn,u32 active_port_blocks, reg_offset =0 ;u8 port, active_ports =0 ; - tc_headroom_blocks = (u32 )DIV_ROUND_UP (req->headroom_per_tc, -BRB_BLOCK_SIZE ); - min_pkt_size_blocks = (u32 )DIV_ROUND_UP (req->min_pkt_size, -BRB_BLOCK_SIZE ); + tc_headroom_blocks = (u32 )RTE_DIV_ROUND_UP (req->headroom_per_tc, +BRB_BLOCK_SIZE ); + min_pkt_size_blocks = (u32 )RTE_DIV_ROUND_UP (req->min_pkt_size, +BRB_BLOCK_SIZE ); total_blocks =ECORE_IS_K2 (p_hwfn->p_dev) ?BRB_TOTAL_RAM_BLOCKS_K2 :BRB_TOTAL_RAM_BLOCKS_BB ;
@@ -1334,8 +1336,9 @@ void ecore_init_brb_ram(struct ecore_hwfn *p_hwfn,u8 tc;/* Calculate per-port sizes */ - tc_guaranteed_blocks = (u32 )DIV_ROUND_UP (req->guranteed_per_tc, -BRB_BLOCK_SIZE ); + tc_guaranteed_blocks = + (u32 )RTE_DIV_ROUND_UP (req->guranteed_per_tc, +BRB_BLOCK_SIZE ); port_blocks = req->num_active_tcs[port] ? active_port_blocks :0 ; port_guaranteed_blocks = req->num_active_tcs[port] *
@@ -2059,7 +2062,7 @@ void ecore_enable_context_validation(struct ecore_hwfn *p_hwfn,ecore_wr (p_hwfn, p_ptt,CDU_REG_TCFC_CTX_VALID0 , ctx_validation); } -#define PHYS_ADDR_DWORDS DIV_ROUND_UP(sizeof(dma_addr_t), 4) +#define PHYS_ADDR_DWORDS RTE_DIV_ROUND_UP(sizeof(dma_addr_t), 4)#define OVERLAY_HDR_SIZE_DWORDS (sizeof(struct fw_overlay_buf_hdr) / 4) static u32 ecore_get_overlay_addr_ram_addr(struct ecore_hwfn *p_hwfn,
drivers/net/qede/base/ecore_mcp.c +3 -3
@@ -713,7 +713,7 @@ ecore_mcp_cmd_and_union(struct ecore_hwfn *p_hwfn, }#endif if (ECORE_MB_FLAGS_IS_SET (p_mb_params,CAN_SLEEP )) { - max_retries =DIV_ROUND_UP (max_retries,1000 ); + max_retries =RTE_DIV_ROUND_UP (max_retries,1000 ); usecs *=1000 ; }
@@ -4243,8 +4243,8 @@ ecore_mcp_resc_lock(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,if (retry_cnt) {if (p_params->sleep_b4_retry) {u16 retry_interval_in_ms = -DIV_ROUND_UP (p_params->retry_interval, -1000 ); +RTE_DIV_ROUND_UP (p_params->retry_interval, +1000 );OSAL_MSLEEP (retry_interval_in_ms); }else {
drivers/net/qede/qede_debug.c +8 -8
@@ -332,7 +332,7 @@ struct split_type_defs {#define BYTES_IN_DWORD sizeof(u32)/* In the macros below, size and offset are specified in bits */ -#define CEIL_DWORDS (size) DIV_ROUND_UP(size, 32) +#define CEIL_DWORDS (size) RTE_DIV_ROUND_UP(size, 32)#define FIELD_BIT_OFFSET (type, field) type ## _ ## field ## _ ## OFFSET#define FIELD_BIT_SIZE (type, field) type ## _ ## field ## _ ## SIZE#define FIELD_DWORD_OFFSET (type, field) \
@@ -3060,7 +3060,7 @@ static u32 qed_grc_dump_big_ram(struct ecore_hwfn *p_hwfn,return offset + ram_size;/* Dump Big RAM */ -for (i =0 ; i <DIV_ROUND_UP (ram_size,BRB_REG_BIG_RAM_DATA_SIZE ); +for (i =0 ; i <RTE_DIV_ROUND_UP (ram_size,BRB_REG_BIG_RAM_DATA_SIZE ); i++) {u32 addr, len;
@@ -4161,8 +4161,8 @@ static enum dbg_status qed_mcp_trace_dump(struct ecore_hwfn *p_hwfn,/* Find trace data size */ trace_data_size_dwords = -DIV_ROUND_UP (trace_data_size_bytes +sizeof (struct mcp_trace ), -BYTES_IN_DWORD ); +RTE_DIV_ROUND_UP (trace_data_size_bytes +sizeof (struct mcp_trace ), +BYTES_IN_DWORD );/* Dump trace data section header and param */ offset += qed_dump_section_hdr(dump_buf + offset,
@@ -4817,10 +4817,10 @@ static u32 qed_ilt_dump(struct ecore_hwfn *p_hwfn, offset += num_pages *PAGE_MEM_DESC_SIZE_DWORDS ; } - valid_conn_pf_pages =DIV_ROUND_UP (valid_conn_pf_cids, - num_cids_per_page); - valid_conn_vf_pages =DIV_ROUND_UP (valid_conn_vf_cids, - num_cids_per_page); + valid_conn_pf_pages =RTE_DIV_ROUND_UP (valid_conn_pf_cids, + num_cids_per_page); + valid_conn_vf_pages =RTE_DIV_ROUND_UP (valid_conn_vf_cids, + num_cids_per_page);/* Dump ILT pages IDs */ offset += qed_ilt_dump_pages_section(p_hwfn,
Signature · 1 line
2.55.0.691.gc56d675ccc-goog
PATCH v2 6/14 net/rnp: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
Base BITS_PER_BYTE and BITS_TO_LONGS definitions on whether BITS_TO_LONGS is defined instead.
--- drivers/net/rnp/base/rnp_osdep.h | 5 ++--- drivers/net/rnp/rnp_rxtx.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/net/rnp/base/rnp_osdep.h +2 -3
@@ -53,10 +53,9 @@ typedef uint64_t u64;#define cpu_to_le32 (v) rte_cpu_to_le_32((u32)(v))#endif -#ifndef DIV_ROUND_UP -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) +#ifndef BITS_TO_LONGS #define BITS_PER_BYTE (8) -#define BITS_TO_LONGS (nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) +#define BITS_TO_LONGS (nr) RTE_DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))#endif #define fls (n) rte_fls_u32(n)
drivers/net/rnp/rnp_rxtx.c +1 -1
@@ -1165,7 +1165,7 @@ rnp_calc_pkt_desc(struct rte_mbuf *tx_pkt)uint16_t count =0 ;while (txd !=NULL ) { - count +=DIV_ROUND_UP (txd->data_len,RNP_MAX_TSO_SEG_LEN ); + count +=RTE_DIV_ROUND_UP (txd->data_len,RNP_MAX_TSO_SEG_LEN ); txd = txd->next; }
Signature · 1 line
2.55.0.691.gc56d675ccc-goog
PATCH v2 7/14 net/hns3: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- 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 ++++---- 4 files changed, 9 insertions(+), 11 deletions(-)
drivers/net/hns3/hns3_ethdev.h +0 -2
@@ -978,8 +978,6 @@ static inline struct hns3_vf *HNS3_DEV_HW_TO_VF(struct hns3_hw *hw)#define roundup (x, y) ((((x) + ((y) - 1)) / (y)) * (y))#define rounddown (x, y) ((x) - ((x) % (y))) -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) -/* * Because hardware always access register in little-endian mode based on hns3 * network engine, so driver should also call rte_cpu_to_le_32 to convert data
drivers/net/hns3/hns3_fdir.c +1 -1
@@ -129,7 +129,7 @@ static const struct key_info tuple_key_info[] = {#define MAX_KEY_LENGTH 400#define MAX_200B_KEY_LENGTH 200#define MAX_META_DATA_LENGTH 16 -#define MAX_KEY_DWORDS DIV_ROUND_UP(MAX_KEY_LENGTH / HNS3_BITS_PER_BYTE, 4) +#define MAX_KEY_DWORDS RTE_DIV_ROUND_UP(MAX_KEY_LENGTH / HNS3_BITS_PER_BYTE, 4)#define MAX_KEY_BYTES (MAX_KEY_DWORDS * 4)enum HNS3_FD_PACKET_TYPE {
drivers/net/hns3/hns3_regs.c +4 -4
@@ -1034,8 +1034,8 @@ hns3_get_32_bit_regs(struct hns3_hw *hw, uint32_t regs_num, struct rte_dev_reg_iif (regs_num ==0 )return 0 ; - cmd_num =DIV_ROUND_UP (regs_num +HNS3_32_BIT_DESC_NODATA_LEN , -HNS3_32_BIT_REG_RTN_DATANUM ); + cmd_num =RTE_DIV_ROUND_UP (regs_num +HNS3_32_BIT_DESC_NODATA_LEN , +HNS3_32_BIT_REG_RTN_DATANUM ); desc =rte_zmalloc ("hns3-32bit-regs" ,sizeof (struct hns3_cmd_desc ) * cmd_num,0 );if (desc ==NULL ) {
@@ -1093,8 +1093,8 @@ hns3_get_64_bit_regs(struct hns3_hw *hw, uint32_t regs_num, struct rte_dev_reg_iif (regs_num ==0 )return 0 ; - cmd_num =DIV_ROUND_UP (regs_num +HNS3_64_BIT_DESC_NODATA_LEN , -HNS3_64_BIT_REG_RTN_DATANUM ); + cmd_num =RTE_DIV_ROUND_UP (regs_num +HNS3_64_BIT_DESC_NODATA_LEN , +HNS3_64_BIT_REG_RTN_DATANUM ); desc =rte_zmalloc ("hns3-64bit-regs" ,sizeof (struct hns3_cmd_desc ) * cmd_num,0 );if (desc ==NULL ) {
drivers/net/hns3/hns3_rss.c +4 -4
@@ -295,7 +295,7 @@ hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo, req = (struct hns3_rss_generic_config_cmd *)desc.data; - max_bd_num =DIV_ROUND_UP (key_len,HNS3_RSS_HASH_KEY_NUM ); + max_bd_num =RTE_DIV_ROUND_UP (key_len,HNS3_RSS_HASH_KEY_NUM );for (idx =0 ; idx < max_bd_num; idx++) {hns3_cmd_setup_basic_desc (&desc,HNS3_OPC_RSS_GENERIC_CONFIG , false);
@@ -335,7 +335,7 @@ hns3_rss_get_algo_key(struct hns3_hw *hw, uint8_t *hash_algo,int ret; req = (struct hns3_rss_generic_config_cmd *)desc.data; - max_bd_num =DIV_ROUND_UP (key_len,HNS3_RSS_HASH_KEY_NUM ); + max_bd_num =RTE_DIV_ROUND_UP (key_len,HNS3_RSS_HASH_KEY_NUM );for (idx =0 ; idx < max_bd_num; idx++) {hns3_cmd_setup_basic_desc (&desc,HNS3_OPC_RSS_GENERIC_CONFIG , true);
@@ -381,7 +381,7 @@ hns3_set_rss_indir_table(struct hns3_hw *hw, uint16_t *indir, uint16_t size)int ret; req = (struct hns3_rss_indirection_table_cmd *)desc.data; - max_bd_num =DIV_ROUND_UP (size,HNS3_RSS_CFG_TBL_SIZE ); + max_bd_num =RTE_DIV_ROUND_UP (size,HNS3_RSS_CFG_TBL_SIZE );for (i =0 ; i < max_bd_num; i++) {hns3_cmd_setup_basic_desc (&desc,HNS3_OPC_RSS_INDIR_TABLE , false);
@@ -431,7 +431,7 @@ hns3_get_rss_indir_table(struct hns3_hw *hw, uint16_t *indir, uint16_t size)int ret; req = (struct hns3_rss_indirection_table_cmd *)desc.data; - max_bd_num =DIV_ROUND_UP (size,HNS3_RSS_CFG_TBL_SIZE ); + max_bd_num =RTE_DIV_ROUND_UP (size,HNS3_RSS_CFG_TBL_SIZE );for (i =0 ; i < max_bd_num; i++) {hns3_cmd_setup_basic_desc (&desc,HNS3_OPC_RSS_INDIR_TABLE , true);
Signature · 1 line
2.55.0.691.gc56d675ccc-goog
PATCH v2 8/14 net/hinic: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- drivers/net/hinic/base/hinic_compat.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/hinic/base/hinic_compat.h +1 -4
@@ -70,11 +70,8 @@ typedef uint64_t dma_addr_t;#define upper_32_bits (n) ((u32)(((n) >> 16) >> 16))#define lower_32_bits (n) ((u32)(n)) -/* Returns X / Y, rounding up. X must be nonnegative to round correctly. */ -#define DIV_ROUND_UP (X ,Y ) (((X) + ((Y) - 1)) / (Y)) -/* Returns X rounded up to the nearest multiple of Y. */ -#define ROUND_UP (X ,Y ) (DIV_ROUND_UP(X, Y) * (Y)) +#define ROUND_UP (X ,Y ) (RTE_DIV_ROUND_UP(X, Y) * (Y))#undef ALIGN#define ALIGN (x, a) RTE_ALIGN(x, a)
Signature · 1 line
2.55.0.691.gc56d675ccc-goog
PATCH v2 9/14 net/bnx2x: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- drivers/net/bnx2x/bnx2x.c | 4 ++-- drivers/net/bnx2x/bnx2x.h | 11 ++++------- 2 files changed, 6 insertions(+), 9 deletions(-)
drivers/net/bnx2x/bnx2x.c +2 -2
@@ -2334,8 +2334,8 @@ static void bnx2x_ilt_set_info(struct bnx2x_softc *sc) ilt_client->start = line;/* 4 bytes for each cid */ - line +=DIV_ROUND_UP (sc->qm_cid_count *QM_QUEUES_PER_FUNC *4 , -QM_ILT_PAGE_SZ ); + line +=RTE_DIV_ROUND_UP (sc->qm_cid_count *QM_QUEUES_PER_FUNC *4 , +QM_ILT_PAGE_SZ ); ilt_client->end = (line -1 ); }
drivers/net/bnx2x/bnx2x.h +4 -7
@@ -37,9 +37,6 @@#ifndef ARRAY_SIZE #define ARRAY_SIZE (arr) RTE_DIM(arr)#endif -#ifndef DIV_ROUND_UP -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) -#endif #ifndef roundup#define roundup (x, y) ((((x) + ((y) - 1)) / (y)) * (y))#endif
@@ -393,7 +390,7 @@ union cdu_context {#define CNIC_ISCSI_CID_MAX 256#define CNIC_FCOE_CID_MAX 2048#define CNIC_CID_MAX (CNIC_ISCSI_CID_MAX + CNIC_FCOE_CID_MAX) -#define CNIC_ILT_LINES DIV_ROUND_UP(CNIC_CID_MAX, ILT_PAGE_CIDS) +#define CNIC_ILT_LINES RTE_DIV_ROUND_UP(CNIC_CID_MAX, ILT_PAGE_CIDS)#define QM_ILT_PAGE_SZ_HW 0#define QM_ILT_PAGE_SZ (4096 << QM_ILT_PAGE_SZ_HW)/* 4K */
@@ -405,7 +402,7 @@ union cdu_context {/*#define TM_CONN_NUM (CNIC_STARTING_CID+CNIC_ISCSI_CXT_MAX) */ #define TM_CONN_NUM 1024#define TM_ILT_SZ (8 * TM_CONN_NUM) -#define TM_ILT_LINES DIV_ROUND_UP(TM_ILT_SZ, TM_ILT_PAGE_SZ) +#define TM_ILT_LINES RTE_DIV_ROUND_UP(TM_ILT_SZ, TM_ILT_PAGE_SZ)/* SRC (Searcher) host DB constants */ #define SRC_ILT_PAGE_SZ_HW 0
@@ -414,7 +411,7 @@ union cdu_context {#define SRC_CONN_NUM (1 << SRC_HASH_BITS)/* 1024 */ #define SRC_ILT_SZ (sizeof(struct src_ent) * SRC_CONN_NUM)#define SRC_T2_SZ SRC_ILT_SZ -#define SRC_ILT_LINES DIV_ROUND_UP(SRC_ILT_SZ, SRC_ILT_PAGE_SZ) +#define SRC_ILT_LINES RTE_DIV_ROUND_UP(SRC_ILT_SZ, SRC_ILT_PAGE_SZ)struct hw_context {struct bnx2x_dma vcxt_dma;
@@ -1258,7 +1255,7 @@ struct bnx2x_softc {#define BNX2X_L2_CID_COUNT (sc) \ (BNX2X_NUM_ETH_QUEUES(sc) * ECORE_MULTI_TX_COS + 2 * CNIC_SUPPORT(sc))#define L2_ILT_LINES (sc) \ - (DIV_ROUND_UP(BNX2X_L2_CID_COUNT(sc), ILT_PAGE_CIDS)) + (RTE_DIV_ROUND_UP(BNX2X_L2_CID_COUNT(sc), ILT_PAGE_CIDS))int qm_cid_count;
Signature · 1 line
2.55.0.691.gc56d675ccc-goog
PATCH v2 10/14 net/cxgbe: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- drivers/net/cxgbe/base/t4_hw.c | 4 ++-- drivers/net/cxgbe/base/t4vf_hw.c | 10 +++++----- drivers/net/cxgbe/cxgbe_compat.h | 3 +-- drivers/net/cxgbe/cxgbe_filter.c | 6 +++--- drivers/net/cxgbe/cxgbe_ofld.h | 4 ++-- drivers/net/cxgbe/sge.c | 14 +++++++------- 6 files changed, 20 insertions(+), 21 deletions(-)
drivers/net/cxgbe/base/t4_hw.c +2 -2
@@ -2630,8 +2630,8 @@ static int t4_get_exprom_version(struct adapter *adapter, u32 *vers)unsigned char hdr_arr[16 ];/* must start with 0x55aa */ unsigned char hdr_ver[4 ];/* Expansion ROM version */ } *hdr; -u32 exprom_header_buf[DIV_ROUND_UP (sizeof (struct exprom_header ), -sizeof (u32))]; +u32 exprom_header_buf[RTE_DIV_ROUND_UP (sizeof (struct exprom_header ), +sizeof (u32))];int ret; ret = t4_read_flash(adapter, FLASH_EXP_ROM_START,
drivers/net/cxgbe/base/t4vf_hw.c +5 -5
@@ -362,8 +362,8 @@ int t4vf_query_params(struct adapter *adapter, unsigned int nparams, cmd.op_to_vfn =cpu_to_be32 (V_FW_CMD_OP (FW_PARAMS_CMD ) |F_FW_CMD_REQUEST |F_FW_CMD_READ ); - len16 =DIV_ROUND_UP (offsetof(struct fw_params_cmd , - param[nparams]), 16); + len16 =RTE_DIV_ROUND_UP (offsetof(struct fw_params_cmd , + param[nparams]), 16); cmd.retval_len16 =cpu_to_be32 (V_FW_CMD_LEN16 (len16));for (i =0 , p = &cmd.param[0 ]; i < nparams; i++, p++) p->mnem =cpu_to_be32 (*params++);
@@ -458,8 +458,8 @@ int t4vf_set_params(struct adapter *adapter, unsigned int nparams, cmd.op_to_vfn =cpu_to_be32 (V_FW_CMD_OP (FW_PARAMS_CMD ) |F_FW_CMD_REQUEST |F_FW_CMD_WRITE ); - len16 =DIV_ROUND_UP (offsetof(struct fw_params_cmd , - param[nparams]), 16); + len16 =RTE_DIV_ROUND_UP (offsetof(struct fw_params_cmd , + param[nparams]), 16); cmd.retval_len16 =cpu_to_be32 (V_FW_CMD_LEN16 (len16));for (i =0 , p = &cmd.param[0 ]; i < nparams; i++, p++) { p->mnem =cpu_to_be32 (*params++);
@@ -626,7 +626,7 @@ static int t4vf_get_port_stats_fw(struct adapter *adapter, int pidx,struct fw_vi_stats_cmd cmd, rpl;size_t len = (offsetof(struct fw_vi_stats_cmd , u) +sizeof (struct fw_vi_stats_ctl )); -size_t len16 =DIV_ROUND_UP (len,16 ); +size_t len16 =RTE_DIV_ROUND_UP (len,16 );int ret;memset (&cmd,0 ,sizeof (cmd));
drivers/net/cxgbe/cxgbe_compat.h +1 -2
@@ -166,11 +166,10 @@ typedef uint64_t dma_addr_t;typedef char *caddr_t ;#endif -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#define DELAY (x) rte_delay_us(x)#define udelay (x) DELAY(x)#define msleep (x) DELAY(1000 * (x)) -#define usleep_range (min, max) msleep(DIV_ROUND_UP(min, 1000)) +#define usleep_range (min, max) msleep(RTE_DIV_ROUND_UP(min, 1000))static inline uint8_t hweight32 (uint32_t word32) {
drivers/net/cxgbe/cxgbe_filter.c +3 -3
@@ -219,7 +219,7 @@ static inline void mk_set_tcb_field_ulp(struct filter_entry *f, txpkt->cmd_dest =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_PKT ) |V_ULP_TXPKT_DEST (0 )); - txpkt->len =cpu_to_be32 (DIV_ROUND_UP (sizeof (*req),16 )); + txpkt->len =cpu_to_be32 (RTE_DIV_ROUND_UP (sizeof (*req),16 )); sc->cmd_more =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_SC_IMM )); sc->len =cpu_to_be32 (sizeof (*req) -sizeof (struct work_request_hdr ));OPCODE_TID (req) =cpu_to_be32 (MK_OPCODE_TID (CPL_SET_TCB_FIELD , f->tid));
@@ -371,7 +371,7 @@ static void mk_abort_req_ulp(struct cpl_abort_req *abort_req, txpkt->cmd_dest =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_PKT ) |V_ULP_TXPKT_DEST (0 )); - txpkt->len =cpu_to_be32 (DIV_ROUND_UP (sizeof (*abort_req),16 )); + txpkt->len =cpu_to_be32 (RTE_DIV_ROUND_UP (sizeof (*abort_req),16 )); sc->cmd_more =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_SC_IMM )); sc->len =cpu_to_be32 (sizeof (*abort_req) -sizeof (struct work_request_hdr ));
@@ -395,7 +395,7 @@ static void mk_abort_rpl_ulp(struct cpl_abort_rpl *abort_rpl, txpkt->cmd_dest =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_PKT ) |V_ULP_TXPKT_DEST (0 )); - txpkt->len =cpu_to_be32 (DIV_ROUND_UP (sizeof (*abort_rpl),16 )); + txpkt->len =cpu_to_be32 (RTE_DIV_ROUND_UP (sizeof (*abort_rpl),16 )); sc->cmd_more =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_SC_IMM )); sc->len =cpu_to_be32 (sizeof (*abort_rpl) -sizeof (struct work_request_hdr ));
drivers/net/cxgbe/cxgbe_ofld.h +2 -2
@@ -14,7 +14,7 @@ (w)->wr.wr_hi =cpu_to_be32 (V_FW_WR_OP (FW_TP_WR ) | \V_FW_WR_IMMDLEN (sizeof (*w) -sizeof (w->wr))); \ (w)->wr.wr_mid =cpu_to_be32 ( \ -V_FW_WR_LEN16 (DIV_ROUND_UP (sizeof (*w),16 )) | \ +V_FW_WR_LEN16 (RTE_DIV_ROUND_UP (sizeof (*w),16 )) | \V_FW_WR_FLOWID (tid)); \ (w)->wr.wr_lo =cpu_to_be64 (0 ); \ }while (0 )
@@ -27,7 +27,7 @@#define INIT_ULPTX_WR (w, wrlen, atomic, tid) do { \ (w)->wr.wr_hi = cpu_to_be32(V_FW_WR_OP(FW_ULPTX_WR) | \ V_FW_WR_ATOMIC(atomic)); \ - (w)->wr.wr_mid = cpu_to_be32(V_FW_WR_LEN16(DIV_ROUND_UP(wrlen, 16)) | \ + (w)->wr.wr_mid = cpu_to_be32(V_FW_WR_LEN16(RTE_DIV_ROUND_UP(wrlen, 16)) | \ V_FW_WR_FLOWID(tid)); \ (w)->wr.wr_lo = cpu_to_be64(0); \ } while (0)
drivers/net/cxgbe/sge.c +7 -7
@@ -459,7 +459,7 @@ static inline unsigned int sgl_len(unsigned int n)*/ static inline unsigned int flits_to_desc (unsigned int n) { -return DIV_ROUND_UP (n,8 ); +return RTE_DIV_ROUND_UP (n,8 ); }/**
@@ -505,7 +505,7 @@ static inline unsigned int calc_tx_flits(const struct rte_mbuf *m, hdrlen =is_eth_imm (m);if (hdrlen) -return DIV_ROUND_UP (m->pkt_len + hdrlen,sizeof (__be64)); +return RTE_DIV_ROUND_UP (m->pkt_len + hdrlen,sizeof (__be64));/* * Otherwise, we're going to have to construct a Scatter gather list
@@ -779,7 +779,7 @@ static inline void ship_tx_pkt_coalesce_wr(struct adapter *adap, wr = (void *)&q->desc[q->pidx]; vmwr = (void *)&q->desc[q->pidx]; - wr_mid =V_FW_WR_LEN16 (DIV_ROUND_UP (q->coalesce.flits,2 )); + wr_mid =V_FW_WR_LEN16 (RTE_DIV_ROUND_UP (q->coalesce.flits,2 )); ndesc =flits_to_desc (q->coalesce.flits); wr->equiq_to_len16 =htonl (wr_mid); wr->plen =cpu_to_be16 (q->coalesce.len);
@@ -866,7 +866,7 @@ static inline int should_tx_packet_coalesce(struct sge_eth_txq *txq,/* If coalescing is on, the mbuf is added to a pkts WR */ if (q->coalesce.idx) { - ndesc =DIV_ROUND_UP (q->coalesce.flits + flits,8 ); + ndesc =RTE_DIV_ROUND_UP (q->coalesce.flits + flits,8 ); credits =txq_avail (q) - ndesc;if (unlikely (wraps_around (q, ndesc)))
@@ -950,7 +950,7 @@ static inline int tx_do_packet_coalesce(struct sge_eth_txq *txq, mc->cmd_dest =htonl (V_ULPTX_CMD (4 ) |V_ULP_TXPKT_DEST (0 ) |V_ULP_TXPKT_FID (adap->sge.fw_evtq.cntxt_id) |F_ULP_TXPKT_RO ); - mc->len =htonl (DIV_ROUND_UP (flits,2 )); + mc->len =htonl (RTE_DIV_ROUND_UP (flits,2 )); sc_imm = (struct ulptx_idata *)(mc +1 ); sc_imm->cmd_more =htonl (V_ULPTX_CMD (ULP_TX_SC_IMM ) |F_ULP_TX_SC_MORE );
@@ -1116,7 +1116,7 @@ int t4_eth_xmit(struct sge_eth_txq *txq, struct rte_mbuf *mbuf, goto out_free; } - wr_mid =V_FW_WR_LEN16 (DIV_ROUND_UP (flits,2 )); + wr_mid =V_FW_WR_LEN16 (RTE_DIV_ROUND_UP (flits,2 ));if (Q_IDXDIFF (&txq->q, equeidx) >=64 ) { txq->q.equeidx = txq->q.pidx; wr_mid |=F_FW_WR_EQUEQ ;
@@ -1322,7 +1322,7 @@ static int ctrl_xmit(struct sge_ctrl_txq *q, struct rte_mbuf *mbuf) }reclaim_completed_tx_imm (&q->q); - ndesc =DIV_ROUND_UP (mbuf->pkt_len,sizeof (struct tx_desc )); + ndesc =RTE_DIV_ROUND_UP (mbuf->pkt_len,sizeof (struct tx_desc ));t4_os_lock (&q->ctrlq_lock); q->full =txq_avail (&q->q) < ndesc ?1 :0 ;
Signature · 1 line
2.55.0.691.gc56d675ccc-goog
PATCH v2 11/14 net/ena: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- drivers/net/ena/base/ena_eth_com.h | 4 ++-- drivers/net/ena/base/ena_plat_dpdk.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/net/ena/base/ena_eth_com.h +2 -2
@@ -160,8 +160,8 @@ static inline bool ena_com_is_doorbell_needed(struct ena_com_io_sq *io_sq,if (num_descs > llq_info->descs_num_before_header) { descs_after_first_entry = num_descs - llq_info->descs_num_before_header; - num_entries_needed +=DIV_ROUND_UP (descs_after_first_entry, - llq_info->descs_per_entry); + num_entries_needed +=RTE_DIV_ROUND_UP (descs_after_first_entry, + llq_info->descs_per_entry); } ena_trc_dbg(ena_com_io_sq_to_ena_dev(io_sq),
drivers/net/ena/base/ena_plat_dpdk.h +0 -1
@@ -304,7 +304,6 @@ ena_mem_alloc_coherent(struct rte_eth_dev_data *data, size_t size,rte_write64_relaxed (*from, to); \ } while(0) -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#define ENA_FFS (x) ffs(x)
Signature · 1 line
2.55.0.691.gc56d675ccc-goog
PATCH v2 12/14 raw/ifpga/base: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- drivers/raw/ifpga/base/opae_osdep.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/raw/ifpga/base/opae_osdep.h +1 -2
@@ -71,10 +71,9 @@ struct uuid { } while (0)#endif -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#define udelay (x) opae_udelay(x)#define msleep (x) opae_udelay(1000 * (x)) -#define usleep_range (min, max) msleep(DIV_ROUND_UP(min, 1000)) +#define usleep_range (min, max) msleep(RTE_DIV_ROUND_UP(min, 1000))#define time_after (a, b) ((long)((b) - (a)) < 0)#define time_before (a, b) time_after(b, a)
Signature · 1 line
2.55.0.691.gc56d675ccc-goog
PATCH v2 13/14 drivers: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- drivers/common/nfp/nfp_platform.h | 2 -- drivers/net/nfp/nfdk/nfp_nfdk.h | 5 +++-- drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 3 ++- drivers/net/nfp/nfpcore/nfp_nsp.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)
drivers/common/nfp/nfp_platform.h +0 -2
@@ -10,8 +10,6 @@#include <rte_bitops.h> -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) -#define DMA_BIT_MASK (n) ((1ULL << (n)) - 1)#define BITS_PER_LONG (__SIZEOF_LONG__ * 8)
drivers/net/nfp/nfdk/nfp_nfdk.h +3 -2
@@ -168,8 +168,9 @@ static inline uint16_t nfp_net_nfdk_headlen_to_segs(uint16_t headlen) {/* First descriptor fits less data, so adjust for that */ -return DIV_ROUND_UP (headlen +NFDK_TX_MAX_DATA_PER_DESC -NFDK_TX_MAX_DATA_PER_HEAD , -NFDK_TX_MAX_DATA_PER_DESC ); +return RTE_DIV_ROUND_UP (headlen +NFDK_TX_MAX_DATA_PER_DESC - +NFDK_TX_MAX_DATA_PER_HEAD , +NFDK_TX_MAX_DATA_PER_DESC ); }/* Set TX CSUM offload flags in TX descriptor of nfdk */
drivers/net/nfp/nfdk/nfp_nfdk_dp.c +2 -1
@@ -103,7 +103,8 @@ nfp_net_nfdk_tx_maybe_close_block(struct nfp_net_txq *txq, n_descs =nfp_net_nfdk_headlen_to_segs (pkt_temp->data_len);while (pkt_temp->next !=NULL ) { pkt_temp = pkt_temp->next; - n_descs +=DIV_ROUND_UP (pkt_temp->data_len,NFDK_TX_MAX_DATA_PER_DESC ); + n_descs +=RTE_DIV_ROUND_UP (pkt_temp->data_len, +NFDK_TX_MAX_DATA_PER_DESC ); }if (unlikely (n_descs >NFDK_TX_DESC_GATHER_MAX ))
drivers/net/nfp/nfpcore/nfp_nsp.c +1 -1
@@ -542,7 +542,7 @@ nfp_nsp_command_buf_dma_sg(struct nfp_nsp *nsp,struct nfp_nsp_dma_desc *descs; chunk_size =RTE_BIT64 (chunk_order); - nseg =DIV_ROUND_UP (max_size, chunk_size); + nseg =RTE_DIV_ROUND_UP (max_size, chunk_size);/* Malloc memory */ total_len = sizeof(struct nfp_nsp_dma_buf) +
Signature · 1 line
2.55.0.691.gc56d675ccc-goog
PATCH v2 14/14 app/procinfo: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- app/proc-info/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
app/proc-info/main.c +1 -2
@@ -48,7 +48,6 @@#define ETHDEV_FWVERS_LEN 32#define RTE_RETA_CONF_GROUP_NUM 32 -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#define EEPROM_DUMP_CHUNKSIZE 1024#define STATS_BDR_FMT "========================================"
@@ -1830,7 +1829,7 @@ show_port_rss_reta_info(void)return ; } - num =DIV_ROUND_UP (dev_info.reta_size,RTE_ETH_RETA_GROUP_SIZE ); + num =RTE_DIV_ROUND_UP (dev_info.reta_size,RTE_ETH_RETA_GROUP_SIZE );memset (reta_conf,0 ,sizeof (reta_conf));for (i =0 ; i < num; i++) reta_conf[i].mask = ~0ULL ;
Signature · 1 line
2.55.0.691.gc56d675ccc-goog
Re: [PATCH v2 00/14] Introduce RTE_DIV_ROUND_UP
In reply to Joshua WashingtonQuoted 49 lines · On Thu, 13 Aug 2026 10:22:25 -0700 Joshua Washington <[email protected]>…
Numerous drivers independently define the
DIV_ROUND_UPmacro, using the same definition. Attempt to commonize by introducingRTE_DIV_ROUND_UPtorte_common.hand replacing usages ofDIV_ROUND_UPwithRTE_DIV_ROUND_UP.Changes in v2:
- Split single patch into series.Joshua Washington (14):
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
drivers: use common division round up macro app/procinfo: use common division round up macroapp/proc-info/main.c | 3 +-- drivers/common/nfp/nfp_platform.h | 2 -- drivers/net/bnx2x/bnx2x.c | 4 ++-- drivers/net/bnx2x/bnx2x.h | 11 ++++------- drivers/net/cxgbe/base/t4_hw.c | 4 ++-- drivers/net/cxgbe/base/t4vf_hw.c | 10 +++++----- drivers/net/cxgbe/cxgbe_compat.h | 3 +-- 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_eth_com.h | 4 ++-- drivers/net/ena/base/ena_plat_dpdk.h | 1 - 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 | 5 +++-- drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 3 ++- drivers/net/nfp/nfpcore/nfp_nsp.c | 2 +- drivers/net/qede/base/bcm_osal.h | 2 -- drivers/net/qede/base/ecore_chain.h | 2 +- drivers/net/qede/base/ecore_cxt.c | 20 +++++++++++---------
Quoted 9 lines
drivers/net/qede/base/ecore_init_fw_funcs.c | 21 ++++++++++++--------- drivers/net/qede/base/ecore_mcp.c | 6 +++--- 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 | 5 +++++ 33 files changed, 92 insertions(+), 100 deletions(-)
Looks good, the only feedback from AI runs were noise about blank lines etc.
Re: [PATCH v2 00/14] Introduce RTE_DIV_ROUND_UP
In reply to Joshua WashingtonQuoted 3 lines · On Thu, 13 Aug 2026 10:22:25 -0700 Joshua Washington <[email protected]>…
Numerous drivers independently define the
DIV_ROUND_UPmacro, using the same definition. Attempt to commonize by introducingRTE_DIV_ROUND_UPtorte_common.hand replacing usages ofDIV_ROUND_UPwithRTE_DIV_ROUND_UP.
Looks ok, predates use of AI review, so ran it manually.
The biggest issue reported is tat changing base/ code here is problematic. You can do it a base/ wrapper header but not directly at call sites.
Tested: applies cleanly to main, builds with -Werror on x86/gcc for all touched drivers, and no DIV_ROUND_UP users remain.
Patch 1:
Needs a test in app/test/test_common.c (exact, remainder, n=0, d=1). Needs a release notes entry.
Doxygen should document the params and the caveats: d evaluated twice, unsigned only, and n + d - 1 can wrap (RTE_DIV_ROUND_UP(UINT32_MAX, 2) on uint32_t is 0). Consider ((n) / (d) + ((n) % (d) != 0)) instead. DIV_CEIL in app/test/test_compressdev.c and app/test-compress-perf/comp_perf_test_common.c could be converted too.
Base code (qede, cxgbe, ena):
Please don't edit call sites under base/. That code is synced from vendor trees (ena-com is shared with Linux and FreeBSD) and this will conflict on the next update. Do what i40e/ice/idpf did: keep #define DIV_ROUND_UP(n, d) RTE_DIV_ROUND_UP(n, d)
in the osdep/platform header and leave base/ alone.
Minor:
qede, nfp: drop the rewraps; the original lines fit in 100 columns.
hinic: the "X must be nonnegative" comment is lost; move it to the rte_common.h doxygen.
ena: leaves a double blank line in ena_plat_dpdk.h. 13/14: subject should be "net/nfp:", not "drivers:".
The osdep-only patches (i40e, idpf, ice, hns3, bnx2x, ifpga, procinfo) look fine.
v3 cover Introduce RTE_DIV_ROUND_UP
In reply to Joshua WashingtonNumerous 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(-)
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
PATCH v3 1/16 eal: introduce division round up macro
A number of drivers define the DIV_ROUND_UP macro -- add it to rte_common.h so that other code looking to use that functionality doesn't have to re-define it.
---
Changes in v3:
- Add unit tests in app/test/test_common.c.
- Add release notes entry.
- Enhance Doxygen documentation to document parameters and caveats (divisor evaluation, non-negative inputs, wraparound).
Changes in v2:
- Split out patches replacing usages
--- app/test/test_common.c | 10 ++++++++++ doc/guides/rel_notes/release_26_11.rst | 5 +++++ lib/eal/include/rte_common.h | 18 ++++++++++++++++++ 3 files changed, 33 insertions(+)
app/test/test_common.c +10 -0
@@ -47,6 +47,16 @@ test_macros(int __rte_unused unused_parm) "RTE_MAX");RTE_TEST_ASSERT_EQUAL (RTE_MIN (SMALLER ,BIGGER ),SMALLER ,"RTE_MIN" ); +RTE_TEST_ASSERT_EQUAL (RTE_DIV_ROUND_UP (10 ,5 ),2 , +"RTE_DIV_ROUND_UP exact" ); +RTE_TEST_ASSERT_EQUAL (RTE_DIV_ROUND_UP (11 ,5 ),3 , +"RTE_DIV_ROUND_UP remainder" ); +RTE_TEST_ASSERT_EQUAL (RTE_DIV_ROUND_UP (0 ,5 ),0 , +"RTE_DIV_ROUND_UP n=0" ); +RTE_TEST_ASSERT_EQUAL (RTE_DIV_ROUND_UP (0 ,1 ),0 , +"RTE_DIV_ROUND_UP n=0, d=1" ); +RTE_TEST_ASSERT_EQUAL (RTE_DIV_ROUND_UP (5 ,1 ),5 , +"RTE_DIV_ROUND_UP d=1" );RTE_TEST_ASSERT_EQUAL (RTE_PTR_ADD (arr +1 ,sizeof (arr[0 ])), &arr[2 ],"RTE_PTR_ADD(expr, x)" );
doc/guides/rel_notes/release_26_11.rst +5 -0
@@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added division round up macro.** + + Added the ``RTE_DIV_ROUND_UP`` macro in ``rte_common.h`` to divide dividend + by divisor, rounding up to the nearest integer. + Removed Items -------------
lib/eal/include/rte_common.h +18 -0
@@ -717,6 +717,24 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) (ceil - (v)) > ((v) - floor) ? floor : ceil; \ }) +/** +* Macro to divide dividend @p n by divisor @p d, rounding up if @p d does not divide @p n. +* +* @param n +* Dividend. Must be a non-negative integer to round correctly. +* @param d +* Divisor. Must be a positive integer. Evaluated twice. +* @return +* Result of dividing @p n by @p d, rounded up. +* +* @note The divisor @p d is evaluated twice. Arguments must not have side effects. +* @note Both @p n and @p d must be non-negative to round correctly. +* @note The sum @c (n) + (d) - 1 can wrap around if @p n is close to the maximum +* representable value of its type (e.g. RTE_DIV_ROUND_UP(UINT32_MAX, 2) +* on uint32_t wraps to 0). +*/ +#define RTE_DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) +/** * Checks if a pointer is aligned to a given power-of-two value *
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
Quoted 5 lines · Joshua Washington
A number of drivers define the
DIV_ROUND_UPmacro -- add it torte_common.hso that other code looking to use that functionality doesn't have to re-define it.Signed-off-by Joshua Washington <[email protected]>
Quoted 5 lines · Joshua Washington
A number of drivers define the
DIV_ROUND_UPmacro -- add it torte_common.hso that other code looking to use that functionality doesn't have to re-define it.Signed-off-by Joshua Washington <[email protected]>
PATCH v3 2/16 net/i40e: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- drivers/net/intel/i40e/base/i40e_osdep.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/intel/i40e/base/i40e_osdep.h +1 -2
@@ -227,12 +227,11 @@ struct i40e_spinlock {#define i40e_memset (a, b, c, d) memset((a), (b), (c))#define i40e_memcpy (a, b, c, d) memcpy((a), (b), (c)) -#define DIV_ROUND_UP (n,d) (((n) + (d) - 1) / (d))#define DELAY (x) rte_delay_us_sleep(x)#define i40e_usec_delay (x) DELAY(x)#define i40e_msec_delay (x) DELAY(1000 * (x))#define udelay (x) DELAY(x)#define msleep (x) DELAY(1000*(x)) -#define usleep_range (min, max) msleep(DIV_ROUND_UP(min, 1000)) +#define usleep_range (min, max) msleep(RTE_DIV_ROUND_UP(min, 1000))#endif /* _I40E_OSDEP_H_ */
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
Re: [PATCH v3 02/16] net/i40e: use common division round up macro
Quoted 4 lines · Joshua Washington
The
RTE_DIV_ROUND_UPinrte_common.hmakesDIV_ROUND_UPredundant.Signed-off-by Joshua Washington <[email protected]>Reviewed-by Stephen Hemminger <[email protected]>
Quoted 25 lines
--- drivers/net/intel/i40e/base/i40e_osdep.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/net/intel/i40e/base/i40e_osdep.h +1
-2@@ -227,12 +227,11 @@ struct i40e_spinlock {#define i40e_memset (a, b, c, d) memset((a), (b), (c))#define i40e_memcpy (a, b, c, d) memcpy((a), (b), (c)) -#define DIV_ROUND_UP (n,d) (((n) + (d) - 1) / (d))#define DELAY (x) rte_delay_us_sleep(x)#define i40e_usec_delay (x) DELAY(x)#define i40e_msec_delay (x) DELAY(1000 * (x))#define udelay (x) DELAY(x)#define msleep (x) DELAY(1000*(x)) -#define usleep_range (min, max) msleep(DIV_ROUND_UP(min, 1000)) +#define usleep_range (min, max) msleep(RTE_DIV_ROUND_UP(min, 1000))#endif /* _I40E_OSDEP_H_ */ Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
Re: [PATCH v3 02/16] net/i40e: use common division round up macro
Quoted 10 lines · Bruce Richardson
Quoted 4 lines · Joshua Washington
The
RTE_DIV_ROUND_UPinrte_common.hmakesDIV_ROUND_UPredundant.Signed-off-by Joshua Washington <[email protected]>Reviewed-by Stephen Hemminger <[email protected]>Acked-by Bruce Richardson <[email protected]>Quoted 4 lines
--- drivers/net/intel/i40e/base/i40e_osdep.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
FYI: Just a note for i40e and the other intel drivers: the osdep.h files have moved in the repo in next-net-intel tree, so this patch will conflict once those changes are merged to main. Therefore, I'd suggest not merging this till after the pull, and then adjusting the paths in the patch on apply for simplicity of merge.
Thanks,
/Bruce
Quoted 21 lines
Quoted 21 lines
drivers/net/intel/i40e/base/i40e_osdep.h +1
-2@@ -227,12 +227,11 @@ struct i40e_spinlock {#define i40e_memset (a, b, c, d) memset((a), (b), (c))#define i40e_memcpy (a, b, c, d) memcpy((a), (b), (c)) -#define DIV_ROUND_UP (n,d) (((n) + (d) - 1) / (d))#define DELAY (x) rte_delay_us_sleep(x)#define i40e_usec_delay (x) DELAY(x)#define i40e_msec_delay (x) DELAY(1000 * (x))#define udelay (x) DELAY(x)#define msleep (x) DELAY(1000*(x)) -#define usleep_range (min, max) msleep(DIV_ROUND_UP(min, 1000)) +#define usleep_range (min, max) msleep(RTE_DIV_ROUND_UP(min, 1000))#endif /* _I40E_OSDEP_H_ */ Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
Re: [PATCH v3 02/16] net/i40e: use common division round up macro
Quoted 39 lines · On Wed, Sep 23, 2026, 00:35 Bruce Richardson <[email protected]> wrote:
Quoted 10 lines · Bruce Richardson
Quoted 4 lines · Joshua Washington
The
RTE_DIV_ROUND_UPinrte_common.hmakesDIV_ROUND_UPredundant.Signed-off-by Joshua Washington <[email protected]>Reviewed-by Stephen Hemminger <[email protected]>Acked-by Bruce Richardson <[email protected]>Quoted 4 lines
--- drivers/net/intel/i40e/base/i40e_osdep.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)FYI: Just a note for i40e and the other intel drivers: the
osdep.hfiles have moved in the repo in next-net-intel tree, so this patch will conflict once those changes are merged to main. Therefore, I'd suggest not merging this till after the pull, and then adjusting the paths in the patch on apply for simplicity of merge.Thanks,
/BruceQuoted 1 line
Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/net/intel/i40e/base/i40e_osdep.hQuoted 16 lines
Quoted 16 lines
index
9c5a94f055..93620f5c50100644drivers/net/intel/i40e/base/i40e_osdep.h +1
-2@@ -227,12 +227,11 @@ struct i40e_spinlock {#define i40e_memset (a, b, c, d) memset((a), (b), (c))#define i40e_memcpy (a, b, c, d) memcpy((a), (b), (c)) -#define DIV_ROUND_UP (n,d) (((n) + (d) - 1) / (d))#define DELAY (x) rte_delay_us_sleep(x)#define i40e_usec_delay (x) DELAY(x)#define i40e_msec_delay (x) DELAY(1000 * (x))#define udelay (x) DELAY(x)#define msleep (x) DELAY(1000*(x)) -#define usleep_range (min, max) msleep(DIV_ROUND_UP(min, 1000)) +#define usleep_range (min, max) msleep(RTE_DIV_ROUND_UP(min, 1000))
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/net/intel/i40e/base/i40e_osdep.h +0
-1#endif /* _I40E_OSDEP_H_ */ --2.55.0.1082.g2b9226bbc0-goog
Ah, I missed this. Thanks for the update. I will hold off on a v3 if it is necessary until the main branch is updated.
Re: [PATCH v3 02/16] net/i40e: use common division round up macro
Quoted 45 lines · Joshua Washington
On Wed, Sep 23, 2026, 00:35 Bruce Richardson <[1][email protected]> wrote: On Wed, Sep 23, 2026 at 08:30:18AM +0100, Bruce Richardson wrote: > On Tue, Sep 22, 2026 at 06:07:25PM -0700, Joshua Washington wrote: > > The RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant. > > > > Signed-off-by: Joshua Washington <[2][email protected]> > > Reviewed-by: Stephen Hemminger <[3][email protected]> > Acked-by: Bruce Richardson <[4][email protected]> > > --- > > drivers/net/intel/i40e/base/i40e_osdep.h | 3 +-- > > 1 file changed, 1 insertion(+), 2 deletions(-) > > FYI: Just a note for i40e and the other intel drivers: the osdep.h files have moved in the repo in next-net-intel tree, so this patch will conflict once those changes are merged to main. Therefore, I'd suggest not merging this till after the pull, and then adjusting the paths in the patch on apply for simplicity of merge. Thanks, /Bruce > > diff --git a/drivers/net/intel/i40e/base/i40e_osdep.h b/drivers/net/intel/i40e/base/i40e_osdep.h > > index 9c5a94f055..93620f5c50 100644 > > --- a/drivers/net/intel/i40e/base/i40e_osdep.h > > +++ b/drivers/net/intel/i40e/base/i40e_osdep.h > > @@ -227,12 +227,11 @@ struct i40e_spinlock { > > #define i40e_memset(a, b, c, d) memset((a), (b), (c)) > > #define i40e_memcpy(a, b, c, d) memcpy((a), (b), (c)) > > > > -#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) > > #define DELAY(x) rte_delay_us_sleep(x) > > #define i40e_usec_delay(x) DELAY(x) > > #define i40e_msec_delay(x) DELAY(1000 * (x)) > > #define udelay(x) DELAY(x) > > #define msleep(x) DELAY(1000*(x)) > > -#define usleep_range(min, max) msleep(DIV_ROUND_UP(min, 1000)) > > +#define usleep_range(min, max) msleep(RTE_DIV_ROUND_UP(min, 1000))
Quoted 9 lines
> >
> > #endif /* _I40E_OSDEP_H_ */
> > --
> > 2.55.0.1082.g2b9226bbc0-goog
> >
Ah, I missed this. Thanks for the update. I will hold off on a v3 if it
is necessary until the main branch is updated.The next-net-intel tree has been pulled, so the move of the osdep files is completed now. Maybe respin this patch so it applies cleanly again?
PATCH v3 3/16 net/idpf: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- drivers/net/intel/idpf/base/idpf_osdep.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/intel/idpf/base/idpf_osdep.h +1 -2
@@ -291,13 +291,12 @@ idpf_hweight32(u32 num)return bits; } -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#define DELAY (x) rte_delay_us(x)#define idpf_usec_delay (x) rte_delay_us(x)#define idpf_msec_delay (x, y) rte_delay_us(1000 * (x))#define udelay (x) DELAY(x)#define msleep (x) DELAY(1000 * (x)) -#define usleep_range (min, max) msleep(DIV_ROUND_UP(min, 1000)) +#define usleep_range (min, max) msleep(RTE_DIV_ROUND_UP(min, 1000))#ifndef IDPF_DBG_TRACE #define IDPF_DBG_TRACE BIT_ULL(0)
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
Re: [PATCH v3 03/16] net/idpf: use common division round up macro
Quoted 5 lines · Joshua Washington
The
RTE_DIV_ROUND_UPinrte_common.hmakesDIV_ROUND_UPredundant.Signed-off-by Joshua Washington <[email protected]>Reviewed-by Stephen Hemminger <[email protected]>---
Quoted 25 lines
drivers/net/intel/idpf/base/idpf_osdep.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/net/intel/idpf/base/idpf_osdep.h +1
-2@@ -291,13 +291,12 @@ idpf_hweight32(u32 num)return bits; } -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#define DELAY (x) rte_delay_us(x)#define idpf_usec_delay (x) rte_delay_us(x)#define idpf_msec_delay (x, y) rte_delay_us(1000 * (x))#define udelay (x) DELAY(x)#define msleep (x) DELAY(1000 * (x)) -#define usleep_range (min, max) msleep(DIV_ROUND_UP(min, 1000)) +#define usleep_range (min, max) msleep(RTE_DIV_ROUND_UP(min, 1000))#ifndef IDPF_DBG_TRACE #define IDPF_DBG_TRACE BIT_ULL(0)Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
PATCH v3 4/16 net/ice: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- drivers/net/intel/ice/base/ice_osdep.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/intel/ice/base/ice_osdep.h +1 -2
@@ -311,13 +311,12 @@ ice_hweight32(u32 num)return bits; } -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#define DELAY (x) rte_delay_us(x)#define ice_usec_delay (x, y) rte_delay_us(x)#define ice_msec_delay (x, y) rte_delay_us(1000 * (x))#define udelay (x) DELAY(x)#define msleep (x) DELAY(1000 * (x)) -#define usleep_range (min, max) msleep(DIV_ROUND_UP(min, 1000)) +#define usleep_range (min, max) msleep(RTE_DIV_ROUND_UP(min, 1000))struct ice_list_entry {LIST_ENTRY (ice_list_entry) next;
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
Re: [PATCH v3 04/16] net/ice: use common division round up macro
Quoted 5 lines · Joshua Washington
The
RTE_DIV_ROUND_UPinrte_common.hmakesDIV_ROUND_UPredundant.Signed-off-by Joshua Washington <[email protected]>Reviewed-by Stephen Hemminger <[email protected]>---
Quoted 25 lines
drivers/net/intel/ice/base/ice_osdep.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/net/intel/ice/base/ice_osdep.h +1
-2@@ -311,13 +311,12 @@ ice_hweight32(u32 num)return bits; } -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#define DELAY (x) rte_delay_us(x)#define ice_usec_delay (x, y) rte_delay_us(x)#define ice_msec_delay (x, y) rte_delay_us(1000 * (x))#define udelay (x) DELAY(x)#define msleep (x) DELAY(1000 * (x)) -#define usleep_range (min, max) msleep(DIV_ROUND_UP(min, 1000)) +#define usleep_range (min, max) msleep(RTE_DIV_ROUND_UP(min, 1000))struct ice_list_entry {LIST_ENTRY (ice_list_entry) next;Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
PATCH v3 5/16 net/qede: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP and RTE_DIV_ROUND_UP definitions redundant.
---
Changes in v3:
- Leave call sites in base/ alone and map DIV_ROUND_UP to RTE_DIV_ROUND_UP in bcm_osal.h.
- Drop line rewraps.
--- drivers/net/qede/base/bcm_osal.h | 1 - drivers/net/qede/qede_debug.c | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-)
drivers/net/qede/base/bcm_osal.h +0 -1
@@ -396,7 +396,6 @@ int qede_save_fw_dump(uint16_t port_id);/* Utility functions */ -#define RTE_DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#define DIV_ROUND_UP (size, to_what) RTE_DIV_ROUND_UP(size, to_what)#define RTE_ROUNDUP (x, y) ((((x) + ((y) - 1)) / (y)) * (y))#define ROUNDUP (value, to_what) RTE_ROUNDUP((value), (to_what))
drivers/net/qede/qede_debug.c +8 -8
@@ -332,7 +332,7 @@ struct split_type_defs {#define BYTES_IN_DWORD sizeof(u32)/* In the macros below, size and offset are specified in bits */ -#define CEIL_DWORDS (size) DIV_ROUND_UP(size, 32) +#define CEIL_DWORDS (size) RTE_DIV_ROUND_UP(size, 32)#define FIELD_BIT_OFFSET (type, field) type ## _ ## field ## _ ## OFFSET#define FIELD_BIT_SIZE (type, field) type ## _ ## field ## _ ## SIZE#define FIELD_DWORD_OFFSET (type, field) \
@@ -3060,7 +3060,7 @@ static u32 qed_grc_dump_big_ram(struct ecore_hwfn *p_hwfn,return offset + ram_size;/* Dump Big RAM */ -for (i =0 ; i <DIV_ROUND_UP (ram_size,BRB_REG_BIG_RAM_DATA_SIZE ); +for (i =0 ; i <RTE_DIV_ROUND_UP (ram_size,BRB_REG_BIG_RAM_DATA_SIZE ); i++) {u32 addr, len;
@@ -4161,8 +4161,8 @@ static enum dbg_status qed_mcp_trace_dump(struct ecore_hwfn *p_hwfn,/* Find trace data size */ trace_data_size_dwords = -DIV_ROUND_UP (trace_data_size_bytes +sizeof (struct mcp_trace ), -BYTES_IN_DWORD ); +RTE_DIV_ROUND_UP (trace_data_size_bytes +sizeof (struct mcp_trace ), +BYTES_IN_DWORD );/* Dump trace data section header and param */ offset += qed_dump_section_hdr(dump_buf + offset,
@@ -4817,10 +4817,10 @@ static u32 qed_ilt_dump(struct ecore_hwfn *p_hwfn, offset += num_pages *PAGE_MEM_DESC_SIZE_DWORDS ; } - valid_conn_pf_pages =DIV_ROUND_UP (valid_conn_pf_cids, - num_cids_per_page); - valid_conn_vf_pages =DIV_ROUND_UP (valid_conn_vf_cids, - num_cids_per_page); + valid_conn_pf_pages =RTE_DIV_ROUND_UP (valid_conn_pf_cids, + num_cids_per_page); + valid_conn_vf_pages =RTE_DIV_ROUND_UP (valid_conn_vf_cids, + num_cids_per_page);/* Dump ILT pages IDs */ offset += qed_ilt_dump_pages_section(p_hwfn,
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
PATCH v3 6/16 net/rnp: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
Base BITS_PER_BYTE and BITS_TO_LONGS definitions on whether BITS_TO_LONGS is defined instead.
--- drivers/net/rnp/base/rnp_osdep.h | 5 ++--- drivers/net/rnp/rnp_rxtx.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/net/rnp/base/rnp_osdep.h +2 -3
@@ -53,10 +53,9 @@ typedef uint64_t u64;#define cpu_to_le32 (v) rte_cpu_to_le_32((u32)(v))#endif -#ifndef DIV_ROUND_UP -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) +#ifndef BITS_TO_LONGS #define BITS_PER_BYTE (8) -#define BITS_TO_LONGS (nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) +#define BITS_TO_LONGS (nr) RTE_DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))#endif #define fls (n) rte_fls_u32(n)
drivers/net/rnp/rnp_rxtx.c +1 -1
@@ -1165,7 +1165,7 @@ rnp_calc_pkt_desc(struct rte_mbuf *tx_pkt)uint16_t count =0 ;while (txd !=NULL ) { - count +=DIV_ROUND_UP (txd->data_len,RNP_MAX_TSO_SEG_LEN ); + count +=RTE_DIV_ROUND_UP (txd->data_len,RNP_MAX_TSO_SEG_LEN ); txd = txd->next; }
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
PATCH v3 7/16 net/hns3: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- 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 ++++---- 4 files changed, 9 insertions(+), 11 deletions(-)
drivers/net/hns3/hns3_ethdev.h +0 -2
@@ -978,8 +978,6 @@ static inline struct hns3_vf *HNS3_DEV_HW_TO_VF(struct hns3_hw *hw)#define roundup (x, y) ((((x) + ((y) - 1)) / (y)) * (y))#define rounddown (x, y) ((x) - ((x) % (y))) -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) -/* * Because hardware always access register in little-endian mode based on hns3 * network engine, so driver should also call rte_cpu_to_le_32 to convert data
drivers/net/hns3/hns3_fdir.c +1 -1
@@ -129,7 +129,7 @@ static const struct key_info tuple_key_info[] = {#define MAX_KEY_LENGTH 400#define MAX_200B_KEY_LENGTH 200#define MAX_META_DATA_LENGTH 16 -#define MAX_KEY_DWORDS DIV_ROUND_UP(MAX_KEY_LENGTH / HNS3_BITS_PER_BYTE, 4) +#define MAX_KEY_DWORDS RTE_DIV_ROUND_UP(MAX_KEY_LENGTH / HNS3_BITS_PER_BYTE, 4)#define MAX_KEY_BYTES (MAX_KEY_DWORDS * 4)enum HNS3_FD_PACKET_TYPE {
drivers/net/hns3/hns3_regs.c +4 -4
@@ -1034,8 +1034,8 @@ hns3_get_32_bit_regs(struct hns3_hw *hw, uint32_t regs_num, struct rte_dev_reg_iif (regs_num ==0 )return 0 ; - cmd_num =DIV_ROUND_UP (regs_num +HNS3_32_BIT_DESC_NODATA_LEN , -HNS3_32_BIT_REG_RTN_DATANUM ); + cmd_num =RTE_DIV_ROUND_UP (regs_num +HNS3_32_BIT_DESC_NODATA_LEN , +HNS3_32_BIT_REG_RTN_DATANUM ); desc =rte_zmalloc ("hns3-32bit-regs" ,sizeof (struct hns3_cmd_desc ) * cmd_num,0 );if (desc ==NULL ) {
@@ -1093,8 +1093,8 @@ hns3_get_64_bit_regs(struct hns3_hw *hw, uint32_t regs_num, struct rte_dev_reg_iif (regs_num ==0 )return 0 ; - cmd_num =DIV_ROUND_UP (regs_num +HNS3_64_BIT_DESC_NODATA_LEN , -HNS3_64_BIT_REG_RTN_DATANUM ); + cmd_num =RTE_DIV_ROUND_UP (regs_num +HNS3_64_BIT_DESC_NODATA_LEN , +HNS3_64_BIT_REG_RTN_DATANUM ); desc =rte_zmalloc ("hns3-64bit-regs" ,sizeof (struct hns3_cmd_desc ) * cmd_num,0 );if (desc ==NULL ) {
drivers/net/hns3/hns3_rss.c +4 -4
@@ -295,7 +295,7 @@ hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo, req = (struct hns3_rss_generic_config_cmd *)desc.data; - max_bd_num =DIV_ROUND_UP (key_len,HNS3_RSS_HASH_KEY_NUM ); + max_bd_num =RTE_DIV_ROUND_UP (key_len,HNS3_RSS_HASH_KEY_NUM );for (idx =0 ; idx < max_bd_num; idx++) {hns3_cmd_setup_basic_desc (&desc,HNS3_OPC_RSS_GENERIC_CONFIG , false);
@@ -335,7 +335,7 @@ hns3_rss_get_algo_key(struct hns3_hw *hw, uint8_t *hash_algo,int ret; req = (struct hns3_rss_generic_config_cmd *)desc.data; - max_bd_num =DIV_ROUND_UP (key_len,HNS3_RSS_HASH_KEY_NUM ); + max_bd_num =RTE_DIV_ROUND_UP (key_len,HNS3_RSS_HASH_KEY_NUM );for (idx =0 ; idx < max_bd_num; idx++) {hns3_cmd_setup_basic_desc (&desc,HNS3_OPC_RSS_GENERIC_CONFIG , true);
@@ -381,7 +381,7 @@ hns3_set_rss_indir_table(struct hns3_hw *hw, uint16_t *indir, uint16_t size)int ret; req = (struct hns3_rss_indirection_table_cmd *)desc.data; - max_bd_num =DIV_ROUND_UP (size,HNS3_RSS_CFG_TBL_SIZE ); + max_bd_num =RTE_DIV_ROUND_UP (size,HNS3_RSS_CFG_TBL_SIZE );for (i =0 ; i < max_bd_num; i++) {hns3_cmd_setup_basic_desc (&desc,HNS3_OPC_RSS_INDIR_TABLE , false);
@@ -431,7 +431,7 @@ hns3_get_rss_indir_table(struct hns3_hw *hw, uint16_t *indir, uint16_t size)int ret; req = (struct hns3_rss_indirection_table_cmd *)desc.data; - max_bd_num =DIV_ROUND_UP (size,HNS3_RSS_CFG_TBL_SIZE ); + max_bd_num =RTE_DIV_ROUND_UP (size,HNS3_RSS_CFG_TBL_SIZE );for (i =0 ; i < max_bd_num; i++) {hns3_cmd_setup_basic_desc (&desc,HNS3_OPC_RSS_INDIR_TABLE , true);
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
Re: [PATCH v3 07/16] net/hns3: use common division round up macro
Quoted 10 lines · Joshua Washington
The
RTE_DIV_ROUND_UPinrte_common.hmakesDIV_ROUND_UPredundant.Signed-off-by Joshua Washington <[email protected]>Reviewed-by Stephen Hemminger <[email protected]>--- 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 ++++---- 4 files changed, 9 insertions(+), 11 deletions(-)
PATCH v3 8/16 net/hinic: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- drivers/net/hinic/base/hinic_compat.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/hinic/base/hinic_compat.h +1 -4
@@ -70,11 +70,8 @@ typedef uint64_t dma_addr_t;#define upper_32_bits (n) ((u32)(((n) >> 16) >> 16))#define lower_32_bits (n) ((u32)(n)) -/* Returns X / Y, rounding up. X must be nonnegative to round correctly. */ -#define DIV_ROUND_UP (X ,Y ) (((X) + ((Y) - 1)) / (Y)) -/* Returns X rounded up to the nearest multiple of Y. */ -#define ROUND_UP (X ,Y ) (DIV_ROUND_UP(X, Y) * (Y)) +#define ROUND_UP (X ,Y ) (RTE_DIV_ROUND_UP(X, Y) * (Y))#undef ALIGN#define ALIGN (x, a) RTE_ALIGN(x, a)
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
PATCH v3 9/16 net/bnx2x: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- drivers/net/bnx2x/bnx2x.c | 4 ++-- drivers/net/bnx2x/bnx2x.h | 11 ++++------- 2 files changed, 6 insertions(+), 9 deletions(-)
drivers/net/bnx2x/bnx2x.c +2 -2
@@ -2334,8 +2334,8 @@ static void bnx2x_ilt_set_info(struct bnx2x_softc *sc) ilt_client->start = line;/* 4 bytes for each cid */ - line +=DIV_ROUND_UP (sc->qm_cid_count *QM_QUEUES_PER_FUNC *4 , -QM_ILT_PAGE_SZ ); + line +=RTE_DIV_ROUND_UP (sc->qm_cid_count *QM_QUEUES_PER_FUNC *4 , +QM_ILT_PAGE_SZ ); ilt_client->end = (line -1 ); }
drivers/net/bnx2x/bnx2x.h +4 -7
@@ -37,9 +37,6 @@#ifndef ARRAY_SIZE #define ARRAY_SIZE (arr) RTE_DIM(arr)#endif -#ifndef DIV_ROUND_UP -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) -#endif #ifndef roundup#define roundup (x, y) ((((x) + ((y) - 1)) / (y)) * (y))#endif
@@ -393,7 +390,7 @@ union cdu_context {#define CNIC_ISCSI_CID_MAX 256#define CNIC_FCOE_CID_MAX 2048#define CNIC_CID_MAX (CNIC_ISCSI_CID_MAX + CNIC_FCOE_CID_MAX) -#define CNIC_ILT_LINES DIV_ROUND_UP(CNIC_CID_MAX, ILT_PAGE_CIDS) +#define CNIC_ILT_LINES RTE_DIV_ROUND_UP(CNIC_CID_MAX, ILT_PAGE_CIDS)#define QM_ILT_PAGE_SZ_HW 0#define QM_ILT_PAGE_SZ (4096 << QM_ILT_PAGE_SZ_HW)/* 4K */
@@ -405,7 +402,7 @@ union cdu_context {/*#define TM_CONN_NUM (CNIC_STARTING_CID+CNIC_ISCSI_CXT_MAX) */ #define TM_CONN_NUM 1024#define TM_ILT_SZ (8 * TM_CONN_NUM) -#define TM_ILT_LINES DIV_ROUND_UP(TM_ILT_SZ, TM_ILT_PAGE_SZ) +#define TM_ILT_LINES RTE_DIV_ROUND_UP(TM_ILT_SZ, TM_ILT_PAGE_SZ)/* SRC (Searcher) host DB constants */ #define SRC_ILT_PAGE_SZ_HW 0
@@ -414,7 +411,7 @@ union cdu_context {#define SRC_CONN_NUM (1 << SRC_HASH_BITS)/* 1024 */ #define SRC_ILT_SZ (sizeof(struct src_ent) * SRC_CONN_NUM)#define SRC_T2_SZ SRC_ILT_SZ -#define SRC_ILT_LINES DIV_ROUND_UP(SRC_ILT_SZ, SRC_ILT_PAGE_SZ) +#define SRC_ILT_LINES RTE_DIV_ROUND_UP(SRC_ILT_SZ, SRC_ILT_PAGE_SZ)struct hw_context {struct bnx2x_dma vcxt_dma;
@@ -1258,7 +1255,7 @@ struct bnx2x_softc {#define BNX2X_L2_CID_COUNT (sc) \ (BNX2X_NUM_ETH_QUEUES(sc) * ECORE_MULTI_TX_COS + 2 * CNIC_SUPPORT(sc))#define L2_ILT_LINES (sc) \ - (DIV_ROUND_UP(BNX2X_L2_CID_COUNT(sc), ILT_PAGE_CIDS)) + (RTE_DIV_ROUND_UP(BNX2X_L2_CID_COUNT(sc), ILT_PAGE_CIDS))int qm_cid_count;
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
PATCH v3 10/16 net/cxgbe: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
---
Changes in v3:
- Leave call sites in base/ alone and map DIV_ROUND_UP to RTE_DIV_ROUND_UP in cxgbe_compat.h.
--- 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 +++++++------- 4 files changed, 13 insertions(+), 13 deletions(-)
drivers/net/cxgbe/cxgbe_compat.h +1 -1
@@ -166,7 +166,7 @@ typedef uint64_t dma_addr_t;typedef char *caddr_t ;#endif -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) +#define DIV_ROUND_UP (n, d) RTE_DIV_ROUND_UP(n, d)#define DELAY (x) rte_delay_us(x)#define udelay (x) DELAY(x)#define msleep (x) DELAY(1000 * (x))
drivers/net/cxgbe/cxgbe_filter.c +3 -3
@@ -219,7 +219,7 @@ static inline void mk_set_tcb_field_ulp(struct filter_entry *f, txpkt->cmd_dest =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_PKT ) |V_ULP_TXPKT_DEST (0 )); - txpkt->len =cpu_to_be32 (DIV_ROUND_UP (sizeof (*req),16 )); + txpkt->len =cpu_to_be32 (RTE_DIV_ROUND_UP (sizeof (*req),16 )); sc->cmd_more =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_SC_IMM )); sc->len =cpu_to_be32 (sizeof (*req) -sizeof (struct work_request_hdr ));OPCODE_TID (req) =cpu_to_be32 (MK_OPCODE_TID (CPL_SET_TCB_FIELD , f->tid));
@@ -371,7 +371,7 @@ static void mk_abort_req_ulp(struct cpl_abort_req *abort_req, txpkt->cmd_dest =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_PKT ) |V_ULP_TXPKT_DEST (0 )); - txpkt->len =cpu_to_be32 (DIV_ROUND_UP (sizeof (*abort_req),16 )); + txpkt->len =cpu_to_be32 (RTE_DIV_ROUND_UP (sizeof (*abort_req),16 )); sc->cmd_more =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_SC_IMM )); sc->len =cpu_to_be32 (sizeof (*abort_req) -sizeof (struct work_request_hdr ));
@@ -395,7 +395,7 @@ static void mk_abort_rpl_ulp(struct cpl_abort_rpl *abort_rpl, txpkt->cmd_dest =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_PKT ) |V_ULP_TXPKT_DEST (0 )); - txpkt->len =cpu_to_be32 (DIV_ROUND_UP (sizeof (*abort_rpl),16 )); + txpkt->len =cpu_to_be32 (RTE_DIV_ROUND_UP (sizeof (*abort_rpl),16 )); sc->cmd_more =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_SC_IMM )); sc->len =cpu_to_be32 (sizeof (*abort_rpl) -sizeof (struct work_request_hdr ));
drivers/net/cxgbe/cxgbe_ofld.h +2 -2
@@ -14,7 +14,7 @@ (w)->wr.wr_hi =cpu_to_be32 (V_FW_WR_OP (FW_TP_WR ) | \V_FW_WR_IMMDLEN (sizeof (*w) -sizeof (w->wr))); \ (w)->wr.wr_mid =cpu_to_be32 ( \ -V_FW_WR_LEN16 (DIV_ROUND_UP (sizeof (*w),16 )) | \ +V_FW_WR_LEN16 (RTE_DIV_ROUND_UP (sizeof (*w),16 )) | \V_FW_WR_FLOWID (tid)); \ (w)->wr.wr_lo =cpu_to_be64 (0 ); \ }while (0 )
@@ -27,7 +27,7 @@#define INIT_ULPTX_WR (w, wrlen, atomic, tid) do { \ (w)->wr.wr_hi = cpu_to_be32(V_FW_WR_OP(FW_ULPTX_WR) | \ V_FW_WR_ATOMIC(atomic)); \ - (w)->wr.wr_mid = cpu_to_be32(V_FW_WR_LEN16(DIV_ROUND_UP(wrlen, 16)) | \ + (w)->wr.wr_mid = cpu_to_be32(V_FW_WR_LEN16(RTE_DIV_ROUND_UP(wrlen, 16)) | \ V_FW_WR_FLOWID(tid)); \ (w)->wr.wr_lo = cpu_to_be64(0); \ } while (0)
drivers/net/cxgbe/sge.c +7 -7
@@ -459,7 +459,7 @@ static inline unsigned int sgl_len(unsigned int n)*/ static inline unsigned int flits_to_desc (unsigned int n) { -return DIV_ROUND_UP (n,8 ); +return RTE_DIV_ROUND_UP (n,8 ); }/**
@@ -505,7 +505,7 @@ static inline unsigned int calc_tx_flits(const struct rte_mbuf *m, hdrlen =is_eth_imm (m);if (hdrlen) -return DIV_ROUND_UP (m->pkt_len + hdrlen,sizeof (__be64)); +return RTE_DIV_ROUND_UP (m->pkt_len + hdrlen,sizeof (__be64));/* * Otherwise, we're going to have to construct a Scatter gather list
@@ -779,7 +779,7 @@ static inline void ship_tx_pkt_coalesce_wr(struct adapter *adap, wr = (void *)&q->desc[q->pidx]; vmwr = (void *)&q->desc[q->pidx]; - wr_mid =V_FW_WR_LEN16 (DIV_ROUND_UP (q->coalesce.flits,2 )); + wr_mid =V_FW_WR_LEN16 (RTE_DIV_ROUND_UP (q->coalesce.flits,2 )); ndesc =flits_to_desc (q->coalesce.flits); wr->equiq_to_len16 =htonl (wr_mid); wr->plen =cpu_to_be16 (q->coalesce.len);
@@ -866,7 +866,7 @@ static inline int should_tx_packet_coalesce(struct sge_eth_txq *txq,/* If coalescing is on, the mbuf is added to a pkts WR */ if (q->coalesce.idx) { - ndesc =DIV_ROUND_UP (q->coalesce.flits + flits,8 ); + ndesc =RTE_DIV_ROUND_UP (q->coalesce.flits + flits,8 ); credits =txq_avail (q) - ndesc;if (unlikely (wraps_around (q, ndesc)))
@@ -950,7 +950,7 @@ static inline int tx_do_packet_coalesce(struct sge_eth_txq *txq, mc->cmd_dest =htonl (V_ULPTX_CMD (4 ) |V_ULP_TXPKT_DEST (0 ) |V_ULP_TXPKT_FID (adap->sge.fw_evtq.cntxt_id) |F_ULP_TXPKT_RO ); - mc->len =htonl (DIV_ROUND_UP (flits,2 )); + mc->len =htonl (RTE_DIV_ROUND_UP (flits,2 )); sc_imm = (struct ulptx_idata *)(mc +1 ); sc_imm->cmd_more =htonl (V_ULPTX_CMD (ULP_TX_SC_IMM ) |F_ULP_TX_SC_MORE );
@@ -1116,7 +1116,7 @@ int t4_eth_xmit(struct sge_eth_txq *txq, struct rte_mbuf *mbuf, goto out_free; } - wr_mid =V_FW_WR_LEN16 (DIV_ROUND_UP (flits,2 )); + wr_mid =V_FW_WR_LEN16 (RTE_DIV_ROUND_UP (flits,2 ));if (Q_IDXDIFF (&txq->q, equeidx) >=64 ) { txq->q.equeidx = txq->q.pidx; wr_mid |=F_FW_WR_EQUEQ ;
@@ -1322,7 +1322,7 @@ static int ctrl_xmit(struct sge_ctrl_txq *q, struct rte_mbuf *mbuf) }reclaim_completed_tx_imm (&q->q); - ndesc =DIV_ROUND_UP (mbuf->pkt_len,sizeof (struct tx_desc )); + ndesc =RTE_DIV_ROUND_UP (mbuf->pkt_len,sizeof (struct tx_desc ));t4_os_lock (&q->ctrlq_lock); q->full =txq_avail (&q->q) < ndesc ?1 :0 ;
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
PATCH v3 11/16 net/ena: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
---
Changes in v3:
- Leave call sites in base/ alone and map DIV_ROUND_UP to RTE_DIV_ROUND_UP in ena_plat_dpdk.h.
- Remove extraneous blank line in ena_plat_dpdk.h.
--- drivers/net/ena/base/ena_plat_dpdk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ena/base/ena_plat_dpdk.h +1 -1
@@ -304,7 +304,7 @@ ena_mem_alloc_coherent(struct rte_eth_dev_data *data, size_t size,rte_write64_relaxed (*from, to); \ } while(0) -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) +#define DIV_ROUND_UP (n, d) RTE_DIV_ROUND_UP(n, d)#define ENA_FFS (x) ffs(x)
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
PATCH v3 12/16 raw/ifpga/base: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- drivers/raw/ifpga/base/opae_osdep.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/raw/ifpga/base/opae_osdep.h +1 -2
@@ -71,10 +71,9 @@ struct uuid { } while (0)#endif -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#define udelay (x) opae_udelay(x)#define msleep (x) opae_udelay(1000 * (x)) -#define usleep_range (min, max) msleep(DIV_ROUND_UP(min, 1000)) +#define usleep_range (min, max) msleep(RTE_DIV_ROUND_UP(min, 1000))#define time_after (a, b) ((long)((b) - (a)) < 0)#define time_before (a, b) time_after(b, a)
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
PATCH v3 13/16 net/nfp: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
---
Changes in v3:
- Change commit subject prefix from "drivers:" to "net/nfp:".
- Drop line rewraps in nfp_nfdk.h and nfp_nfdk_dp.c.
--- drivers/common/nfp/nfp_platform.h | 2 -- 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 +- 4 files changed, 3 insertions(+), 5 deletions(-)
drivers/common/nfp/nfp_platform.h +0 -2
@@ -10,8 +10,6 @@#include <rte_bitops.h> -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) -#define DMA_BIT_MASK (n) ((1ULL << (n)) - 1)#define BITS_PER_LONG (__SIZEOF_LONG__ * 8)
drivers/net/nfp/nfdk/nfp_nfdk.h +1 -1
@@ -168,7 +168,7 @@ static inline uint16_t nfp_net_nfdk_headlen_to_segs(uint16_t headlen) {/* First descriptor fits less data, so adjust for that */ -return DIV_ROUND_UP (headlen +NFDK_TX_MAX_DATA_PER_DESC -NFDK_TX_MAX_DATA_PER_HEAD , +return RTE_DIV_ROUND_UP (headlen +NFDK_TX_MAX_DATA_PER_DESC -NFDK_TX_MAX_DATA_PER_HEAD ,NFDK_TX_MAX_DATA_PER_DESC ); }
drivers/net/nfp/nfdk/nfp_nfdk_dp.c +1 -1
@@ -103,7 +103,7 @@ nfp_net_nfdk_tx_maybe_close_block(struct nfp_net_txq *txq, n_descs =nfp_net_nfdk_headlen_to_segs (pkt_temp->data_len);while (pkt_temp->next !=NULL ) { pkt_temp = pkt_temp->next; - n_descs +=DIV_ROUND_UP (pkt_temp->data_len,NFDK_TX_MAX_DATA_PER_DESC ); + n_descs +=RTE_DIV_ROUND_UP (pkt_temp->data_len,NFDK_TX_MAX_DATA_PER_DESC ); }if (unlikely (n_descs >NFDK_TX_DESC_GATHER_MAX ))
drivers/net/nfp/nfpcore/nfp_nsp.c +1 -1
@@ -542,7 +542,7 @@ nfp_nsp_command_buf_dma_sg(struct nfp_nsp *nsp,struct nfp_nsp_dma_desc *descs; chunk_size =RTE_BIT64 (chunk_order); - nseg =DIV_ROUND_UP (max_size, chunk_size); + nseg =RTE_DIV_ROUND_UP (max_size, chunk_size);/* Malloc memory */ total_len = sizeof(struct nfp_nsp_dma_buf) +
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
PATCH v3 14/16 app/procinfo: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- app/proc-info/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
app/proc-info/main.c +1 -2
@@ -48,7 +48,6 @@#define ETHDEV_FWVERS_LEN 32#define RTE_RETA_CONF_GROUP_NUM 32 -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#define EEPROM_DUMP_CHUNKSIZE 1024#define STATS_BDR_FMT "========================================"
@@ -1830,7 +1829,7 @@ show_port_rss_reta_info(void)return ; } - num =DIV_ROUND_UP (dev_info.reta_size,RTE_ETH_RETA_GROUP_SIZE ); + num =RTE_DIV_ROUND_UP (dev_info.reta_size,RTE_ETH_RETA_GROUP_SIZE );memset (reta_conf,0 ,sizeof (reta_conf));for (i =0 ; i < num; i++) reta_conf[i].mask = ~0ULL ;
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
Re: [PATCH v3 14/16] app/procinfo: use common division round up macro
Quoted 4 lines · Joshua Washington
The
RTE_DIV_ROUND_UPinrte_common.hmakesDIV_ROUND_UPredundant.Signed-off-by Joshua Washington <[email protected]>Reviewed-by Stephen Hemminger <[email protected]>
PATCH v3 15/16 app/test: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_CEIL redundant.
---
Changes in v3:
- New patch converting DIV_CEIL in test_compressdev.c.
--- app/test/test_compressdev.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
app/test/test_compressdev.c +1 -3
@@ -18,8 +18,6 @@#include "test_compressdev_test_buffer.h" #include "test.h" -#define DIV_CEIL (a, b) ((a) / (b) + ((a) % (b) != 0)) -#define DEFAULT_WINDOW_SIZE 15#define DEFAULT_MEM_LEVEL 8#define MAX_DEQD_RETRIES 10
@@ -688,7 +686,7 @@ prepare_sgl_bufs(const char *test_buf, struct rte_mbuf *head_buf, uint16_t seg_size) {uint32_t remaining_data = total_data_size; -uint16_t num_remaining_segs =DIV_CEIL (remaining_data, seg_size); +uint16_t num_remaining_segs =RTE_DIV_ROUND_UP (remaining_data, seg_size);struct rte_mempool *pool;struct rte_mbuf *next_seg;uint32_t data_size;
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
Re: [PATCH v3 15/16] app/test: use common division round up macro
Quoted 3 lines · Joshua Washington
The
RTE_DIV_ROUND_UPinrte_common.hmakesDIV_CEILredundant.Signed-off-by Joshua Washington <[email protected]>
Quoted 32 lines
---
Changes in v3:
- New patch convertingDIV_CEILintest_compressdev.c.--- app/test/test_compressdev.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)app/test/test_compressdev.c +1
-3@@ -18,8 +18,6 @@#include "test_compressdev_test_buffer.h" #include "test.h" -#define DIV_CEIL (a, b) ((a) / (b) + ((a) % (b) != 0)) -#define DEFAULT_WINDOW_SIZE 15#define DEFAULT_MEM_LEVEL 8#define MAX_DEQD_RETRIES 10@@ -688,7 +686,7 @@ prepare_sgl_bufs(const char *test_buf, struct rte_mbuf *head_buf, uint16_t seg_size) {uint32_t remaining_data = total_data_size; -uint16_t num_remaining_segs =DIV_CEIL (remaining_data, seg_size); +uint16_t num_remaining_segs =RTE_DIV_ROUND_UP (remaining_data, seg_size);struct rte_mempool *pool;struct rte_mbuf *next_seg;uint32_t data_size;Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
Re: [PATCH v3 15/16] app/test: use common division round up macro
In reply to Joshua WashingtonQuoted 3 lines · Joshua Washington
The
RTE_DIV_ROUND_UPinrte_common.hmakesDIV_CEILredundant.Signed-off-by Joshua Washington <[email protected]>
PATCH v3 16/16 app/test-compress-perf: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_CEIL redundant.
---
Changes in v3:
- New patch converting DIV_CEIL in comp_perf_test_common.c.
--- app/test-compress-perf/comp_perf_test_common.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
app/test-compress-perf/comp_perf_test_common.c +5 -8
@@ -14,9 +14,6 @@#include "comp_perf_test_common.h" #include "comp_perf_test_verify.h" - -#define DIV_CEIL (a, b) ((a) / (b) + ((a) % (b) != 0)) -struct cperf_buffer_info {uint16_t total_segments;uint16_t segment_sz;
@@ -238,8 +235,8 @@ comp_perf_allocate_memory(struct comp_test_data *test_data,* Number of segments for input and output * (compression and decompression) */ - test_data->total_segs =DIV_CEIL (test_data->input_data_sz, - test_data->seg_sz); + test_data->total_segs =RTE_DIV_ROUND_UP (test_data->input_data_sz, + test_data->seg_sz); }else {/* * When application does decompression only, input data is
@@ -292,8 +289,8 @@ comp_perf_allocate_memory(struct comp_test_data *test_data,return -1 ; } - mem->total_bufs =DIV_CEIL (test_data->total_segs, - test_data->max_sgl_segs); + mem->total_bufs =RTE_DIV_ROUND_UP (test_data->total_segs, + test_data->max_sgl_segs);snprintf (pool_name,sizeof (pool_name),"op_pool_%u_qp_%u" , mem->dev_id, mem->qp_id);
@@ -557,7 +554,7 @@ prepare_bufs(struct comp_test_data *test_data, struct cperf_mem_resources *mem)void print_test_dynamics (const struct comp_test_data *test_data) { -uint32_t opt_total_segs =DIV_CEIL (buffer_info.input_data_sz, +uint32_t opt_total_segs =RTE_DIV_ROUND_UP (buffer_info.input_data_sz,MAX_SEG_SIZE );if (buffer_info.total_buffs >1 ) {
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
Re: [PATCH v3 16/16] app/test-compress-perf: use common division round up macro
Quoted 3 lines · Joshua Washington
The
RTE_DIV_ROUND_UPinrte_common.hmakesDIV_CEILredundant.Signed-off-by Joshua Washington <[email protected]>
Quoted 55 lines
---
Changes in v3:
- New patch convertingDIV_CEILincomp_perf_test_common.c.--- app/test-compress-perf/comp_perf_test_common.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)app/test-compress-perf/comp_perf_test_common.c +5
-8@@ -14,9 +14,6 @@#include "comp_perf_test_common.h" #include "comp_perf_test_verify.h" - -#define DIV_CEIL (a, b) ((a) / (b) + ((a) % (b) != 0)) -struct cperf_buffer_info {uint16_t total_segments;uint16_t segment_sz;@@ -238,8 +235,8 @@ comp_perf_allocate_memory(struct comp_test_data *test_data,* Number of segments for input and output * (compression and decompression) */ - test_data->total_segs =DIV_CEIL (test_data->input_data_sz, - test_data->seg_sz); + test_data->total_segs =RTE_DIV_ROUND_UP (test_data->input_data_sz, + test_data->seg_sz); }else {/* * When application does decompression only, input data is @@ -292,8 +289,8 @@ comp_perf_allocate_memory(struct comp_test_data *test_data,return -1 ; } - mem->total_bufs =DIV_CEIL (test_data->total_segs, - test_data->max_sgl_segs); + mem->total_bufs =RTE_DIV_ROUND_UP (test_data->total_segs, + test_data->max_sgl_segs);snprintf (pool_name,sizeof (pool_name),"op_pool_%u_qp_%u" , mem->dev_id, mem->qp_id);@@ -557,7 +554,7 @@ prepare_bufs(struct comp_test_data *test_data, struct cperf_mem_resources *mem)void print_test_dynamics (const struct comp_test_data *test_data) { -uint32_t opt_total_segs =DIV_CEIL (buffer_info.input_data_sz, +uint32_t opt_total_segs =RTE_DIV_ROUND_UP (buffer_info.input_data_sz,MAX_SEG_SIZE );if (buffer_info.total_buffs >1 ) {Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
Re: [PATCH v3 16/16] app/test-compress-perf: use common division round up macro
In reply to Joshua WashingtonQuoted 3 lines · Joshua Washington
The
RTE_DIV_ROUND_UPinrte_common.hmakesDIV_CEILredundant.Signed-off-by Joshua Washington <[email protected]>
Re: [PATCH v3 00/16] Introduce RTE_DIV_ROUND_UP
In reply to Joshua WashingtonQuoted 63 lines · On Tue, 22 Sep 2026 18:07:23 -0700 Joshua Washington <[email protected]>…
Numerous components independently define the
DIV_ROUND_UPmacro, using the same definition. Attempt to commonize by introducingRTE_DIV_ROUND_UPtorte_common.hand replacing usages ofDIV_ROUND_UPwithRTE_DIV_ROUND_UP. Similarly, replaceDIV_CEIL, which is functionally identical, toRTE_DIV_ROUND_UP.Changes in v3:
- eal: Add unit tests inapp/test/test_common.c.
- eal: Add release notes entry forRTE_DIV_ROUND_UP.
- eal: Expand Doxygen documentation with parameters and caveats (divisor evaluation, non-negative inputs, wraparound).
- base code (qede, cxgbe, ena): KeepDIV_ROUND_UPmacro 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 inena_plat_dpdk.h.
- app: ConvertDIV_CEILin app/test and app/test-compress-perf toRTE_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 macroapp/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 +-
Quoted 9 lines
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.
v4 cover Introduce RTE_DIV_ROUND_UP
In reply to Joshua WashingtonNumerous 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 v4:
- eal: Fix merge conflict in release notes after rebase.
- various commits: add rte_common.h includes where missing to fix compilation issues.
- opae: drop RTE_DIV_ROUND_UP change due to shered osdep file for RTE and raw drivers.
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 (15):
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 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 | 14 ++++++-------- app/test/test_common.c | 10 ++++++++++ app/test/test_compressdev.c | 5 ++--- 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 | 12 +++++------- 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 | 3 ++- drivers/net/hinic/base/hinic_compat.h | 5 +---- drivers/net/hns3/hns3_ethdev.h | 2 -- drivers/net/hns3/hns3_fdir.c | 3 ++- drivers/net/hns3/hns3_regs.c | 9 +++++---- drivers/net/hns3/hns3_rss.c | 9 +++++---- drivers/net/intel/i40e/i40e_osdep.h | 3 +-- drivers/net/intel/ice/ice_osdep.h | 3 +-- drivers/net/intel/idpf/idpf_osdep.h | 3 +-- drivers/net/nfp/nfdk/nfp_nfdk.h | 3 ++- drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 2 +- drivers/net/nfp/nfpcore/nfp_nsp.c | 2 +- drivers/net/qede/base/bcm_osal.h | 2 +- drivers/net/qede/qede_debug.c | 16 ++++++++-------- drivers/net/rnp/base/rnp_osdep.h | 5 ++--- drivers/net/rnp/rnp_rxtx.c | 2 +- lib/eal/include/rte_common.h | 18 ++++++++++++++++++ 29 files changed, 96 insertions(+), 75 deletions(-)
Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog
PATCH v4 1/15 eal: introduce division round up macro
A number of drivers define the DIV_ROUND_UP macro -- add it to rte_common.h so that other code looking to use that functionality doesn't have to re-define it.
---
Changes in v4:
- Rebased changes
Changes in v3:
- Add unit tests in app/test/test_common.c.
- Add release notes entry.
- Enhance Doxygen documentation to document parameters and caveats (divisor evaluation, non-negative inputs, wraparound).
Changes in v2:
- Split out patches replacing usages
--- app/test/test_common.c | 10 ++++++++++ doc/guides/rel_notes/release_26_11.rst | 5 +++++ lib/eal/include/rte_common.h | 18 ++++++++++++++++++ 3 files changed, 33 insertions(+)
app/test/test_common.c +10 -0
@@ -47,6 +47,16 @@ test_macros(int __rte_unused unused_parm) "RTE_MAX");RTE_TEST_ASSERT_EQUAL (RTE_MIN (SMALLER ,BIGGER ),SMALLER ,"RTE_MIN" ); +RTE_TEST_ASSERT_EQUAL (RTE_DIV_ROUND_UP (10 ,5 ),2 , +"RTE_DIV_ROUND_UP exact" ); +RTE_TEST_ASSERT_EQUAL (RTE_DIV_ROUND_UP (11 ,5 ),3 , +"RTE_DIV_ROUND_UP remainder" ); +RTE_TEST_ASSERT_EQUAL (RTE_DIV_ROUND_UP (0 ,5 ),0 , +"RTE_DIV_ROUND_UP n=0" ); +RTE_TEST_ASSERT_EQUAL (RTE_DIV_ROUND_UP (0 ,1 ),0 , +"RTE_DIV_ROUND_UP n=0, d=1" ); +RTE_TEST_ASSERT_EQUAL (RTE_DIV_ROUND_UP (5 ,1 ),5 , +"RTE_DIV_ROUND_UP d=1" );RTE_TEST_ASSERT_EQUAL (RTE_PTR_ADD (arr +1 ,sizeof (arr[0 ])), &arr[2 ],"RTE_PTR_ADD(expr, x)" );
doc/guides/rel_notes/release_26_11.rst +5 -0
@@ -138,6 +138,11 @@ New Features Added ``rte_bbdev_queue_stats_get()`` function to retrieve statistics for a specific queue, complementing the existing device-level statistics API. +* **Added division round up macro.** + + Added the ``RTE_DIV_ROUND_UP`` macro in ``rte_common.h`` to divide dividend + by divisor, rounding up to the nearest integer. + Removed Items -------------
lib/eal/include/rte_common.h +18 -0
@@ -704,6 +704,24 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) (ceil - (v)) > ((v) - floor) ? floor : ceil; \ }) +/** +* Macro to divide dividend @p n by divisor @p d, rounding up if @p d does not divide @p n. +* +* @param n +* Dividend. Must be a non-negative integer to round correctly. +* @param d +* Divisor. Must be a positive integer. Evaluated twice. +* @return +* Result of dividing @p n by @p d, rounded up. +* +* @note The divisor @p d is evaluated twice. Arguments must not have side effects. +* @note Both @p n and @p d must be non-negative to round correctly. +* @note The sum @c (n) + (d) - 1 can wrap around if @p n is close to the maximum +* representable value of its type (e.g. RTE_DIV_ROUND_UP(UINT32_MAX, 2) +* on uint32_t wraps to 0). +*/ +#define RTE_DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) +/** * Checks if a pointer is aligned to a given power-of-two value *
Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog
PATCH v4 2/15 net/i40e: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- drivers/net/intel/i40e/i40e_osdep.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/intel/i40e/i40e_osdep.h +1 -2
@@ -229,12 +229,11 @@ struct i40e_spinlock {#define i40e_memset (a, b, c, d) memset((a), (b), (c))#define i40e_memcpy (a, b, c, d) memcpy((a), (b), (c)) -#define DIV_ROUND_UP (n,d) (((n) + (d) - 1) / (d))#define DELAY (x) rte_delay_us_sleep(x)#define i40e_usec_delay (x) DELAY(x)#define i40e_msec_delay (x) DELAY(1000 * (x))#define udelay (x) DELAY(x)#define msleep (x) DELAY(1000*(x)) -#define usleep_range (min, max) msleep(DIV_ROUND_UP(min, 1000)) +#define usleep_range (min, max) msleep(RTE_DIV_ROUND_UP(min, 1000))#endif /* _I40E_OSDEP_H_ */
Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog
PATCH v4 3/15 net/idpf: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- drivers/net/intel/idpf/idpf_osdep.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/intel/idpf/idpf_osdep.h +1 -2
@@ -293,13 +293,12 @@ idpf_hweight32(u32 num)return bits; } -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#define DELAY (x) rte_delay_us(x)#define idpf_usec_delay (x) rte_delay_us(x)#define idpf_msec_delay (x, y) rte_delay_us(1000 * (x))#define udelay (x) DELAY(x)#define msleep (x) DELAY(1000 * (x)) -#define usleep_range (min, max) msleep(DIV_ROUND_UP(min, 1000)) +#define usleep_range (min, max) msleep(RTE_DIV_ROUND_UP(min, 1000))#ifndef IDPF_DBG_TRACE #define IDPF_DBG_TRACE BIT_ULL(0)
Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog
PATCH v4 4/15 net/ice: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- drivers/net/intel/ice/ice_osdep.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/intel/ice/ice_osdep.h +1 -2
@@ -313,13 +313,12 @@ ice_hweight32(u32 num)return bits; } -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#define DELAY (x) rte_delay_us(x)#define ice_usec_delay (x, y) rte_delay_us(x)#define ice_msec_delay (x, y) rte_delay_us(1000 * (x))#define udelay (x) DELAY(x)#define msleep (x) DELAY(1000 * (x)) -#define usleep_range (min, max) msleep(DIV_ROUND_UP(min, 1000)) +#define usleep_range (min, max) msleep(RTE_DIV_ROUND_UP(min, 1000))struct ice_list_entry {LIST_ENTRY (ice_list_entry) next;
Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog
PATCH v4 5/15 net/qede: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP and RTE_DIV_ROUND_UP definitions redundant.
---
Changes in v4:
- Add rte_common.h include.
Changes in v3:
- Leave call sites in base/ alone and map DIV_ROUND_UP to RTE_DIV_ROUND_UP in bcm_osal.h.
- Drop line rewraps.
--- drivers/net/qede/base/bcm_osal.h | 2 +- drivers/net/qede/qede_debug.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/net/qede/base/bcm_osal.h +1 -1
@@ -11,6 +11,7 @@#include <pthread.h> #include <time.h> +#include <rte_common.h> #include <rte_bitops.h> #include <rte_branch_prediction.h> #include <rte_byteorder.h>
@@ -396,7 +397,6 @@ int qede_save_fw_dump(uint16_t port_id);/* Utility functions */ -#define RTE_DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#define DIV_ROUND_UP (size, to_what) RTE_DIV_ROUND_UP(size, to_what)#define RTE_ROUNDUP (x, y) ((((x) + ((y) - 1)) / (y)) * (y))#define ROUNDUP (value, to_what) RTE_ROUNDUP((value), (to_what))
drivers/net/qede/qede_debug.c +8 -8
@@ -332,7 +332,7 @@ struct split_type_defs {#define BYTES_IN_DWORD sizeof(u32)/* In the macros below, size and offset are specified in bits */ -#define CEIL_DWORDS (size) DIV_ROUND_UP(size, 32) +#define CEIL_DWORDS (size) RTE_DIV_ROUND_UP(size, 32)#define FIELD_BIT_OFFSET (type, field) type ## _ ## field ## _ ## OFFSET#define FIELD_BIT_SIZE (type, field) type ## _ ## field ## _ ## SIZE#define FIELD_DWORD_OFFSET (type, field) \
@@ -3053,7 +3053,7 @@ static u32 qed_grc_dump_big_ram(struct ecore_hwfn *p_hwfn,return offset + ram_size;/* Dump Big RAM */ -for (i =0 ; i <DIV_ROUND_UP (ram_size,BRB_REG_BIG_RAM_DATA_SIZE ); +for (i =0 ; i <RTE_DIV_ROUND_UP (ram_size,BRB_REG_BIG_RAM_DATA_SIZE ); i++) {u32 addr, len;
@@ -4154,8 +4154,8 @@ static enum dbg_status qed_mcp_trace_dump(struct ecore_hwfn *p_hwfn,/* Find trace data size */ trace_data_size_dwords = -DIV_ROUND_UP (trace_data_size_bytes +sizeof (struct mcp_trace ), -BYTES_IN_DWORD ); +RTE_DIV_ROUND_UP (trace_data_size_bytes +sizeof (struct mcp_trace ), +BYTES_IN_DWORD );/* Dump trace data section header and param */ offset += qed_dump_section_hdr(dump_buf + offset,
@@ -4810,10 +4810,10 @@ static u32 qed_ilt_dump(struct ecore_hwfn *p_hwfn, offset += num_pages *PAGE_MEM_DESC_SIZE_DWORDS ; } - valid_conn_pf_pages =DIV_ROUND_UP (valid_conn_pf_cids, - num_cids_per_page); - valid_conn_vf_pages =DIV_ROUND_UP (valid_conn_vf_cids, - num_cids_per_page); + valid_conn_pf_pages =RTE_DIV_ROUND_UP (valid_conn_pf_cids, + num_cids_per_page); + valid_conn_vf_pages =RTE_DIV_ROUND_UP (valid_conn_vf_cids, + num_cids_per_page);/* Dump ILT pages IDs */ offset += qed_ilt_dump_pages_section(p_hwfn,
Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog
PATCH v4 6/15 net/rnp: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
Base BITS_PER_BYTE and BITS_TO_LONGS definitions on whether BITS_TO_LONGS is defined instead.
--- drivers/net/rnp/base/rnp_osdep.h | 5 ++--- drivers/net/rnp/rnp_rxtx.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/net/rnp/base/rnp_osdep.h +2 -3
@@ -53,10 +53,9 @@ typedef uint64_t u64;#define cpu_to_le32 (v) rte_cpu_to_le_32((u32)(v))#endif -#ifndef DIV_ROUND_UP -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) +#ifndef BITS_TO_LONGS #define BITS_PER_BYTE (8) -#define BITS_TO_LONGS (nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) +#define BITS_TO_LONGS (nr) RTE_DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))#endif #define fls (n) rte_fls_u32(n)
drivers/net/rnp/rnp_rxtx.c +1 -1
@@ -1165,7 +1165,7 @@ rnp_calc_pkt_desc(struct rte_mbuf *tx_pkt)uint16_t count =0 ;while (txd !=NULL ) { - count +=DIV_ROUND_UP (txd->data_len,RNP_MAX_TSO_SEG_LEN ); + count +=RTE_DIV_ROUND_UP (txd->data_len,RNP_MAX_TSO_SEG_LEN ); txd = txd->next; }
Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog
PATCH v4 7/15 net/hns3: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
---
Changes in v4:
- Add rte_common.h includes.
--- drivers/net/hns3/hns3_ethdev.h | 2 -- drivers/net/hns3/hns3_fdir.c | 3 ++- drivers/net/hns3/hns3_regs.c | 9 +++++---- drivers/net/hns3/hns3_rss.c | 9 +++++---- 4 files changed, 12 insertions(+), 11 deletions(-)
drivers/net/hns3/hns3_ethdev.h +0 -2
@@ -978,8 +978,6 @@ static inline struct hns3_vf *HNS3_DEV_HW_TO_VF(struct hns3_hw *hw)#define roundup (x, y) ((((x) + ((y) - 1)) / (y)) * (y))#define rounddown (x, y) ((x) - ((x) % (y))) -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) -/* * Because hardware always access register in little-endian mode based on hns3 * network engine, so driver should also call rte_cpu_to_le_32 to convert data
drivers/net/hns3/hns3_fdir.c +2 -1
@@ -7,6 +7,7 @@#include <rte_hash_crc.h> #include <rte_io.h> #include <rte_malloc.h> +#include <rte_common.h> #include "hns3_ethdev.h" #include "hns3_logs.h"
@@ -129,7 +130,7 @@ static const struct key_info tuple_key_info[] = {#define MAX_KEY_LENGTH 400#define MAX_200B_KEY_LENGTH 200#define MAX_META_DATA_LENGTH 16 -#define MAX_KEY_DWORDS DIV_ROUND_UP(MAX_KEY_LENGTH / HNS3_BITS_PER_BYTE, 4) +#define MAX_KEY_DWORDS RTE_DIV_ROUND_UP(MAX_KEY_LENGTH / HNS3_BITS_PER_BYTE, 4)#define MAX_KEY_BYTES (MAX_KEY_DWORDS * 4)enum HNS3_FD_PACKET_TYPE {
drivers/net/hns3/hns3_regs.c +5 -4
@@ -4,6 +4,7 @@#include <ethdev_pci.h> #include <rte_io.h> +#include <rte_common.h> #include "hns3_ethdev.h" #include "hns3_logs.h"
@@ -1034,8 +1035,8 @@ hns3_get_32_bit_regs(struct hns3_hw *hw, uint32_t regs_num, struct rte_dev_reg_iif (regs_num ==0 )return 0 ; - cmd_num =DIV_ROUND_UP (regs_num +HNS3_32_BIT_DESC_NODATA_LEN , -HNS3_32_BIT_REG_RTN_DATANUM ); + cmd_num =RTE_DIV_ROUND_UP (regs_num +HNS3_32_BIT_DESC_NODATA_LEN , +HNS3_32_BIT_REG_RTN_DATANUM ); desc =rte_zmalloc ("hns3-32bit-regs" ,sizeof (struct hns3_cmd_desc ) * cmd_num,0 );if (desc ==NULL ) {
@@ -1093,8 +1094,8 @@ hns3_get_64_bit_regs(struct hns3_hw *hw, uint32_t regs_num, struct rte_dev_reg_iif (regs_num ==0 )return 0 ; - cmd_num =DIV_ROUND_UP (regs_num +HNS3_64_BIT_DESC_NODATA_LEN , -HNS3_64_BIT_REG_RTN_DATANUM ); + cmd_num =RTE_DIV_ROUND_UP (regs_num +HNS3_64_BIT_DESC_NODATA_LEN , +HNS3_64_BIT_REG_RTN_DATANUM ); desc =rte_zmalloc ("hns3-64bit-regs" ,sizeof (struct hns3_cmd_desc ) * cmd_num,0 );if (desc ==NULL ) {
drivers/net/hns3/hns3_rss.c +5 -4
@@ -5,6 +5,7 @@#include <rte_ethdev.h> #include <rte_io.h> #include <rte_malloc.h> +#include <rte_common.h> #include "hns3_ethdev.h" #include "hns3_logs.h"
@@ -295,7 +296,7 @@ hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo, req = (struct hns3_rss_generic_config_cmd *)desc.data; - max_bd_num =DIV_ROUND_UP (key_len,HNS3_RSS_HASH_KEY_NUM ); + max_bd_num =RTE_DIV_ROUND_UP (key_len,HNS3_RSS_HASH_KEY_NUM );for (idx =0 ; idx < max_bd_num; idx++) {hns3_cmd_setup_basic_desc (&desc,HNS3_OPC_RSS_GENERIC_CONFIG , false);
@@ -335,7 +336,7 @@ hns3_rss_get_algo_key(struct hns3_hw *hw, uint8_t *hash_algo,int ret; req = (struct hns3_rss_generic_config_cmd *)desc.data; - max_bd_num =DIV_ROUND_UP (key_len,HNS3_RSS_HASH_KEY_NUM ); + max_bd_num =RTE_DIV_ROUND_UP (key_len,HNS3_RSS_HASH_KEY_NUM );for (idx =0 ; idx < max_bd_num; idx++) {hns3_cmd_setup_basic_desc (&desc,HNS3_OPC_RSS_GENERIC_CONFIG , true);
@@ -381,7 +382,7 @@ hns3_set_rss_indir_table(struct hns3_hw *hw, uint16_t *indir, uint16_t size)int ret; req = (struct hns3_rss_indirection_table_cmd *)desc.data; - max_bd_num =DIV_ROUND_UP (size,HNS3_RSS_CFG_TBL_SIZE ); + max_bd_num =RTE_DIV_ROUND_UP (size,HNS3_RSS_CFG_TBL_SIZE );for (i =0 ; i < max_bd_num; i++) {hns3_cmd_setup_basic_desc (&desc,HNS3_OPC_RSS_INDIR_TABLE , false);
@@ -431,7 +432,7 @@ hns3_get_rss_indir_table(struct hns3_hw *hw, uint16_t *indir, uint16_t size)int ret; req = (struct hns3_rss_indirection_table_cmd *)desc.data; - max_bd_num =DIV_ROUND_UP (size,HNS3_RSS_CFG_TBL_SIZE ); + max_bd_num =RTE_DIV_ROUND_UP (size,HNS3_RSS_CFG_TBL_SIZE );for (i =0 ; i < max_bd_num; i++) {hns3_cmd_setup_basic_desc (&desc,HNS3_OPC_RSS_INDIR_TABLE , true);
Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog
PATCH v4 8/15 net/hinic: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- drivers/net/hinic/base/hinic_compat.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/hinic/base/hinic_compat.h +1 -4
@@ -70,11 +70,8 @@ typedef uint64_t dma_addr_t;#define upper_32_bits (n) ((u32)(((n) >> 16) >> 16))#define lower_32_bits (n) ((u32)(n)) -/* Returns X / Y, rounding up. X must be nonnegative to round correctly. */ -#define DIV_ROUND_UP (X ,Y ) (((X) + ((Y) - 1)) / (Y)) -/* Returns X rounded up to the nearest multiple of Y. */ -#define ROUND_UP (X ,Y ) (DIV_ROUND_UP(X, Y) * (Y)) +#define ROUND_UP (X ,Y ) (RTE_DIV_ROUND_UP(X, Y) * (Y))#undef ALIGN#define ALIGN (x, a) RTE_ALIGN(x, a)
Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog
PATCH v4 9/15 net/bnx2x: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
---
Changes in v4:
- Add rte_common.h include.
--- drivers/net/bnx2x/bnx2x.c | 4 ++-- drivers/net/bnx2x/bnx2x.h | 12 +++++------- 2 files changed, 7 insertions(+), 9 deletions(-)
drivers/net/bnx2x/bnx2x.c +2 -2
@@ -2334,8 +2334,8 @@ static void bnx2x_ilt_set_info(struct bnx2x_softc *sc) ilt_client->start = line;/* 4 bytes for each cid */ - line +=DIV_ROUND_UP (sc->qm_cid_count *QM_QUEUES_PER_FUNC *4 , -QM_ILT_PAGE_SZ ); + line +=RTE_DIV_ROUND_UP (sc->qm_cid_count *QM_QUEUES_PER_FUNC *4 , +QM_ILT_PAGE_SZ ); ilt_client->end = (line -1 ); }
drivers/net/bnx2x/bnx2x.h +5 -7
@@ -18,6 +18,7 @@#include <rte_spinlock.h> #include <bus_pci_driver.h> #include <rte_io.h> +#include <rte_common.h> #include "bnx2x_osal.h" #include "bnx2x_ethdev.h"
@@ -37,9 +38,6 @@#ifndef ARRAY_SIZE #define ARRAY_SIZE (arr) RTE_DIM(arr)#endif -#ifndef DIV_ROUND_UP -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) -#endif #ifndef roundup#define roundup (x, y) ((((x) + ((y) - 1)) / (y)) * (y))#endif
@@ -393,7 +391,7 @@ union cdu_context {#define CNIC_ISCSI_CID_MAX 256#define CNIC_FCOE_CID_MAX 2048#define CNIC_CID_MAX (CNIC_ISCSI_CID_MAX + CNIC_FCOE_CID_MAX) -#define CNIC_ILT_LINES DIV_ROUND_UP(CNIC_CID_MAX, ILT_PAGE_CIDS) +#define CNIC_ILT_LINES RTE_DIV_ROUND_UP(CNIC_CID_MAX, ILT_PAGE_CIDS)#define QM_ILT_PAGE_SZ_HW 0#define QM_ILT_PAGE_SZ (4096 << QM_ILT_PAGE_SZ_HW)/* 4K */
@@ -405,7 +403,7 @@ union cdu_context {/*#define TM_CONN_NUM (CNIC_STARTING_CID+CNIC_ISCSI_CXT_MAX) */ #define TM_CONN_NUM 1024#define TM_ILT_SZ (8 * TM_CONN_NUM) -#define TM_ILT_LINES DIV_ROUND_UP(TM_ILT_SZ, TM_ILT_PAGE_SZ) +#define TM_ILT_LINES RTE_DIV_ROUND_UP(TM_ILT_SZ, TM_ILT_PAGE_SZ)/* SRC (Searcher) host DB constants */ #define SRC_ILT_PAGE_SZ_HW 0
@@ -414,7 +412,7 @@ union cdu_context {#define SRC_CONN_NUM (1 << SRC_HASH_BITS)/* 1024 */ #define SRC_ILT_SZ (sizeof(struct src_ent) * SRC_CONN_NUM)#define SRC_T2_SZ SRC_ILT_SZ -#define SRC_ILT_LINES DIV_ROUND_UP(SRC_ILT_SZ, SRC_ILT_PAGE_SZ) +#define SRC_ILT_LINES RTE_DIV_ROUND_UP(SRC_ILT_SZ, SRC_ILT_PAGE_SZ)struct hw_context {struct bnx2x_dma vcxt_dma;
@@ -1258,7 +1256,7 @@ struct bnx2x_softc {#define BNX2X_L2_CID_COUNT (sc) \ (BNX2X_NUM_ETH_QUEUES(sc) * ECORE_MULTI_TX_COS + 2 * CNIC_SUPPORT(sc))#define L2_ILT_LINES (sc) \ - (DIV_ROUND_UP(BNX2X_L2_CID_COUNT(sc), ILT_PAGE_CIDS)) + (RTE_DIV_ROUND_UP(BNX2X_L2_CID_COUNT(sc), ILT_PAGE_CIDS))int qm_cid_count;
Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog
PATCH v4 10/15 net/cxgbe: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
---
Changes in v3:
- Leave call sites in base/ alone and map DIV_ROUND_UP to RTE_DIV_ROUND_UP in cxgbe_compat.h.
--- 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 +++++++------- 4 files changed, 13 insertions(+), 13 deletions(-)
drivers/net/cxgbe/cxgbe_compat.h +1 -1
@@ -166,7 +166,7 @@ typedef uint64_t dma_addr_t;typedef char *caddr_t ;#endif -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) +#define DIV_ROUND_UP (n, d) RTE_DIV_ROUND_UP(n, d)#define DELAY (x) rte_delay_us(x)#define udelay (x) DELAY(x)#define msleep (x) DELAY(1000 * (x))
drivers/net/cxgbe/cxgbe_filter.c +3 -3
@@ -219,7 +219,7 @@ static inline void mk_set_tcb_field_ulp(struct filter_entry *f, txpkt->cmd_dest =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_PKT ) |V_ULP_TXPKT_DEST (0 )); - txpkt->len =cpu_to_be32 (DIV_ROUND_UP (sizeof (*req),16 )); + txpkt->len =cpu_to_be32 (RTE_DIV_ROUND_UP (sizeof (*req),16 )); sc->cmd_more =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_SC_IMM )); sc->len =cpu_to_be32 (sizeof (*req) -sizeof (struct work_request_hdr ));OPCODE_TID (req) =cpu_to_be32 (MK_OPCODE_TID (CPL_SET_TCB_FIELD , f->tid));
@@ -371,7 +371,7 @@ static void mk_abort_req_ulp(struct cpl_abort_req *abort_req, txpkt->cmd_dest =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_PKT ) |V_ULP_TXPKT_DEST (0 )); - txpkt->len =cpu_to_be32 (DIV_ROUND_UP (sizeof (*abort_req),16 )); + txpkt->len =cpu_to_be32 (RTE_DIV_ROUND_UP (sizeof (*abort_req),16 )); sc->cmd_more =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_SC_IMM )); sc->len =cpu_to_be32 (sizeof (*abort_req) -sizeof (struct work_request_hdr ));
@@ -395,7 +395,7 @@ static void mk_abort_rpl_ulp(struct cpl_abort_rpl *abort_rpl, txpkt->cmd_dest =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_PKT ) |V_ULP_TXPKT_DEST (0 )); - txpkt->len =cpu_to_be32 (DIV_ROUND_UP (sizeof (*abort_rpl),16 )); + txpkt->len =cpu_to_be32 (RTE_DIV_ROUND_UP (sizeof (*abort_rpl),16 )); sc->cmd_more =cpu_to_be32 (V_ULPTX_CMD (ULP_TX_SC_IMM )); sc->len =cpu_to_be32 (sizeof (*abort_rpl) -sizeof (struct work_request_hdr ));
drivers/net/cxgbe/cxgbe_ofld.h +2 -2
@@ -14,7 +14,7 @@ (w)->wr.wr_hi =cpu_to_be32 (V_FW_WR_OP (FW_TP_WR ) | \V_FW_WR_IMMDLEN (sizeof (*w) -sizeof (w->wr))); \ (w)->wr.wr_mid =cpu_to_be32 ( \ -V_FW_WR_LEN16 (DIV_ROUND_UP (sizeof (*w),16 )) | \ +V_FW_WR_LEN16 (RTE_DIV_ROUND_UP (sizeof (*w),16 )) | \V_FW_WR_FLOWID (tid)); \ (w)->wr.wr_lo =cpu_to_be64 (0 ); \ }while (0 )
@@ -27,7 +27,7 @@#define INIT_ULPTX_WR (w, wrlen, atomic, tid) do { \ (w)->wr.wr_hi = cpu_to_be32(V_FW_WR_OP(FW_ULPTX_WR) | \ V_FW_WR_ATOMIC(atomic)); \ - (w)->wr.wr_mid = cpu_to_be32(V_FW_WR_LEN16(DIV_ROUND_UP(wrlen, 16)) | \ + (w)->wr.wr_mid = cpu_to_be32(V_FW_WR_LEN16(RTE_DIV_ROUND_UP(wrlen, 16)) | \ V_FW_WR_FLOWID(tid)); \ (w)->wr.wr_lo = cpu_to_be64(0); \ } while (0)
drivers/net/cxgbe/sge.c +7 -7
@@ -459,7 +459,7 @@ static inline unsigned int sgl_len(unsigned int n)*/ static inline unsigned int flits_to_desc (unsigned int n) { -return DIV_ROUND_UP (n,8 ); +return RTE_DIV_ROUND_UP (n,8 ); }/**
@@ -505,7 +505,7 @@ static inline unsigned int calc_tx_flits(const struct rte_mbuf *m, hdrlen =is_eth_imm (m);if (hdrlen) -return DIV_ROUND_UP (m->pkt_len + hdrlen,sizeof (__be64)); +return RTE_DIV_ROUND_UP (m->pkt_len + hdrlen,sizeof (__be64));/* * Otherwise, we're going to have to construct a Scatter gather list
@@ -779,7 +779,7 @@ static inline void ship_tx_pkt_coalesce_wr(struct adapter *adap, wr = (void *)&q->desc[q->pidx]; vmwr = (void *)&q->desc[q->pidx]; - wr_mid =V_FW_WR_LEN16 (DIV_ROUND_UP (q->coalesce.flits,2 )); + wr_mid =V_FW_WR_LEN16 (RTE_DIV_ROUND_UP (q->coalesce.flits,2 )); ndesc =flits_to_desc (q->coalesce.flits); wr->equiq_to_len16 =htonl (wr_mid); wr->plen =cpu_to_be16 (q->coalesce.len);
@@ -866,7 +866,7 @@ static inline int should_tx_packet_coalesce(struct sge_eth_txq *txq,/* If coalescing is on, the mbuf is added to a pkts WR */ if (q->coalesce.idx) { - ndesc =DIV_ROUND_UP (q->coalesce.flits + flits,8 ); + ndesc =RTE_DIV_ROUND_UP (q->coalesce.flits + flits,8 ); credits =txq_avail (q) - ndesc;if (unlikely (wraps_around (q, ndesc)))
@@ -950,7 +950,7 @@ static inline int tx_do_packet_coalesce(struct sge_eth_txq *txq, mc->cmd_dest =htonl (V_ULPTX_CMD (4 ) |V_ULP_TXPKT_DEST (0 ) |V_ULP_TXPKT_FID (adap->sge.fw_evtq.cntxt_id) |F_ULP_TXPKT_RO ); - mc->len =htonl (DIV_ROUND_UP (flits,2 )); + mc->len =htonl (RTE_DIV_ROUND_UP (flits,2 )); sc_imm = (struct ulptx_idata *)(mc +1 ); sc_imm->cmd_more =htonl (V_ULPTX_CMD (ULP_TX_SC_IMM ) |F_ULP_TX_SC_MORE );
@@ -1116,7 +1116,7 @@ int t4_eth_xmit(struct sge_eth_txq *txq, struct rte_mbuf *mbuf, goto out_free; } - wr_mid =V_FW_WR_LEN16 (DIV_ROUND_UP (flits,2 )); + wr_mid =V_FW_WR_LEN16 (RTE_DIV_ROUND_UP (flits,2 ));if (Q_IDXDIFF (&txq->q, equeidx) >=64 ) { txq->q.equeidx = txq->q.pidx; wr_mid |=F_FW_WR_EQUEQ ;
@@ -1322,7 +1322,7 @@ static int ctrl_xmit(struct sge_ctrl_txq *q, struct rte_mbuf *mbuf) }reclaim_completed_tx_imm (&q->q); - ndesc =DIV_ROUND_UP (mbuf->pkt_len,sizeof (struct tx_desc )); + ndesc =RTE_DIV_ROUND_UP (mbuf->pkt_len,sizeof (struct tx_desc ));t4_os_lock (&q->ctrlq_lock); q->full =txq_avail (&q->q) < ndesc ?1 :0 ;
Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog
PATCH v4 11/15 net/ena: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
---
Changes in v4:
- Add rte_common.h include.
Changes in v3:
- Leave call sites in base/ alone and map DIV_ROUND_UP to RTE_DIV_ROUND_UP in ena_plat_dpdk.h.
- Remove extraneous blank line in ena_plat_dpdk.h.
--- drivers/net/ena/base/ena_plat_dpdk.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ena/base/ena_plat_dpdk.h +2 -1
@@ -17,6 +17,7 @@#include <ethdev_driver.h> #include <rte_atomic.h> #include <rte_branch_prediction.h> +#include <rte_common.h> #include <rte_cycles.h> #include <rte_io.h> #include <rte_log.h>
@@ -308,7 +309,7 @@ ena_mem_alloc_coherent(struct rte_eth_dev_data *data, size_t size,rte_write64_relaxed (*from, to); \ } while(0) -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) +#define DIV_ROUND_UP (n, d) RTE_DIV_ROUND_UP(n, d)#define ENA_FFS (x) ffs(x)
Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog
PATCH v4 12/15 net/nfp: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
---
Changes in v4:
- Add rte_common.h include.
Changes in v3:
- Change commit subject prefix from "drivers:" to "net/nfp:".
- Drop line rewraps in nfp_nfdk.h and nfp_nfdk_dp.c.
--- drivers/common/nfp/nfp_platform.h | 2 -- drivers/net/nfp/nfdk/nfp_nfdk.h | 3 ++- drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 2 +- drivers/net/nfp/nfpcore/nfp_nsp.c | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-)
drivers/common/nfp/nfp_platform.h +0 -2
@@ -10,8 +10,6 @@#include <rte_bitops.h> -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) -#define DMA_BIT_MASK (n) ((1ULL << (n)) - 1)#define BITS_PER_LONG (__SIZEOF_LONG__ * 8)
drivers/net/nfp/nfdk/nfp_nfdk.h +2 -1
@@ -7,6 +7,7 @@#define __NFP_NFDK_H__#include <nfp_platform.h> +#include <rte_common.h> #include "../nfp_rxtx.h" #include "nfp_net_common.h"
@@ -168,7 +169,7 @@ static inline uint16_t nfp_net_nfdk_headlen_to_segs(uint16_t headlen) {/* First descriptor fits less data, so adjust for that */ -return DIV_ROUND_UP (headlen +NFDK_TX_MAX_DATA_PER_DESC -NFDK_TX_MAX_DATA_PER_HEAD , +return RTE_DIV_ROUND_UP (headlen +NFDK_TX_MAX_DATA_PER_DESC -NFDK_TX_MAX_DATA_PER_HEAD ,NFDK_TX_MAX_DATA_PER_DESC ); }
drivers/net/nfp/nfdk/nfp_nfdk_dp.c +1 -1
@@ -103,7 +103,7 @@ nfp_net_nfdk_tx_maybe_close_block(struct nfp_net_txq *txq, n_descs =nfp_net_nfdk_headlen_to_segs (pkt_temp->data_len);while (pkt_temp->next !=NULL ) { pkt_temp = pkt_temp->next; - n_descs +=DIV_ROUND_UP (pkt_temp->data_len,NFDK_TX_MAX_DATA_PER_DESC ); + n_descs +=RTE_DIV_ROUND_UP (pkt_temp->data_len,NFDK_TX_MAX_DATA_PER_DESC ); }if (unlikely (n_descs >NFDK_TX_DESC_GATHER_MAX ))
drivers/net/nfp/nfpcore/nfp_nsp.c +1 -1
@@ -542,7 +542,7 @@ nfp_nsp_command_buf_dma_sg(struct nfp_nsp *nsp,struct nfp_nsp_dma_desc *descs; chunk_size =RTE_BIT64 (chunk_order); - nseg =DIV_ROUND_UP (max_size, chunk_size); + nseg =RTE_DIV_ROUND_UP (max_size, chunk_size);/* Malloc memory */ total_len = sizeof(struct nfp_nsp_dma_buf) +
Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog
PATCH v4 13/15 app/procinfo: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_ROUND_UP redundant.
--- app/proc-info/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
app/proc-info/main.c +1 -2
@@ -48,7 +48,6 @@#define ETHDEV_FWVERS_LEN 32#define RTE_RETA_CONF_GROUP_NUM 32 -#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#define EEPROM_DUMP_CHUNKSIZE 1024#define STATS_BDR_FMT "========================================"
@@ -1830,7 +1829,7 @@ show_port_rss_reta_info(void)return ; } - num =DIV_ROUND_UP (dev_info.reta_size,RTE_ETH_RETA_GROUP_SIZE ); + num =RTE_DIV_ROUND_UP (dev_info.reta_size,RTE_ETH_RETA_GROUP_SIZE );memset (reta_conf,0 ,sizeof (reta_conf));for (i =0 ; i < num; i++) reta_conf[i].mask = ~0ULL ;
Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog
PATCH v4 14/15 app/test: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_CEIL redundant.
---
Changes in v4:
- Add rte_common.h include.
Changes in v3:
- New patch converting DIV_CEIL in test_compressdev.c.
--- app/test/test_compressdev.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
app/test/test_compressdev.c +2 -3
@@ -14,12 +14,11 @@#include <rte_mbuf.h> #include <rte_compressdev.h> #include <rte_string_fns.h> +#include <rte_common.h> #include "test_compressdev_test_buffer.h" #include "test.h" -#define DIV_CEIL (a, b) ((a) / (b) + ((a) % (b) != 0)) -#define DEFAULT_WINDOW_SIZE 15#define DEFAULT_MEM_LEVEL 8#define MAX_DEQD_RETRIES 10
@@ -688,7 +687,7 @@ prepare_sgl_bufs(const char *test_buf, struct rte_mbuf *head_buf, uint16_t seg_size) {uint32_t remaining_data = total_data_size; -uint16_t num_remaining_segs =DIV_CEIL (remaining_data, seg_size); +uint16_t num_remaining_segs =RTE_DIV_ROUND_UP (remaining_data, seg_size);struct rte_mempool *pool;struct rte_mbuf *next_seg;uint32_t data_size;
Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog
PATCH v4 15/15 app/test-compress-perf: use common division round up macro
In reply to Joshua WashingtonThe RTE_DIV_ROUND_UP in rte_common.h makes DIV_CEIL redundant.
---
Changes in v4:
- Add rte_common.h include.
Changes in v3:
- New patch converting DIV_CEIL in comp_perf_test_common.c.
--- app/test-compress-perf/comp_perf_test_common.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
app/test-compress-perf/comp_perf_test_common.c +6 -8
@@ -6,6 +6,7 @@#include <rte_eal.h> #include <rte_log.h> #include <rte_compressdev.h> +#include <rte_common.h> #include "comp_perf.h" #include "comp_perf_options.h"
@@ -14,9 +15,6 @@#include "comp_perf_test_common.h" #include "comp_perf_test_verify.h" - -#define DIV_CEIL (a, b) ((a) / (b) + ((a) % (b) != 0)) -struct cperf_buffer_info {uint16_t total_segments;uint16_t segment_sz;
@@ -238,8 +236,8 @@ comp_perf_allocate_memory(struct comp_test_data *test_data,* Number of segments for input and output * (compression and decompression) */ - test_data->total_segs =DIV_CEIL (test_data->input_data_sz, - test_data->seg_sz); + test_data->total_segs =RTE_DIV_ROUND_UP (test_data->input_data_sz, + test_data->seg_sz); }else {/* * When application does decompression only, input data is
@@ -292,8 +290,8 @@ comp_perf_allocate_memory(struct comp_test_data *test_data,return -1 ; } - mem->total_bufs =DIV_CEIL (test_data->total_segs, - test_data->max_sgl_segs); + mem->total_bufs =RTE_DIV_ROUND_UP (test_data->total_segs, + test_data->max_sgl_segs);snprintf (pool_name,sizeof (pool_name),"op_pool_%u_qp_%u" , mem->dev_id, mem->qp_id);
@@ -557,7 +555,7 @@ prepare_bufs(struct comp_test_data *test_data, struct cperf_mem_resources *mem)void print_test_dynamics (const struct comp_test_data *test_data) { -uint32_t opt_total_segs =DIV_CEIL (buffer_info.input_data_sz, +uint32_t opt_total_segs =RTE_DIV_ROUND_UP (buffer_info.input_data_sz,MAX_SEG_SIZE );if (buffer_info.total_buffs >1 ) {
Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog
Re: [PATCH v4 00/15] Introduce RTE_DIV_ROUND_UP
In reply to Joshua WashingtonQuoted 6 lines · On Mon, 5 Oct 2026 19:30:36 -0700 Joshua Washington <[email protected]>…
Numerous components independently define the
DIV_ROUND_UPmacro, using the same definition. Attempt to commonize by introducingRTE_DIV_ROUND_UPtorte_common.hand replacing usages ofDIV_ROUND_UPwithRTE_DIV_ROUND_UP. Similarly, replaceDIV_CEIL, which is functionally identical, toRTE_DIV_ROUND_UP.
Quoted 6 lines
Changes in v4:
- eal: Fix merge conflict in release notes after rebase.
- various commits: addrte_common.hincludes where missing to fix compilation issues.
- opae: dropRTE_DIV_ROUND_UPchange due to shered osdep file for RTE and raw drivers.
Looks good, some minor AI notes on commit messages and doc
Review: [PATCH v4 00/15] division round up consolidation
Series applies cleanly to main. Each patch touches a disjoint set of files, so with 01/15 first the series is bisect safe. Build of all affected drivers, dpdk-proc-info, dpdk-test and dpdk-test-compress-perf with -Dwerror=true is clean.
No errors or warnings.
Series
Info: remaining private copies not covered by this series, candidates for a follow-up:
drivers/raw/ifpga/base/opae_osdep.h DIV_ROUND_UP (map like cxgbe)
drivers/crypto/ccp/ccp_dev.h CCP_DIV_ROUND_UP
drivers/common/qat/dev/qat_dev_gen_lce.c LCE_DIV_ROUND_UP
drivers/net/sfc/sfc_dp.h SFC_DIV_ROUND_UP drivers/common/sxe2/sxe2_osal.h SXE2_DIV_ROUND_UP drivers/common/cnxk/roc_platform.h PLT_DIV_CEIL
sfc_efx base (EFX_DIV_ROUND_UP) is shared code and should stay.
Patch 01/15 eal: introduce division round up macro
Info: the Doxygen repeats itself. "Evaluated twice" is in @param d and again in the first @note; "non-negative" is in @param n and again in the second @note. Keep the @param text and drop the duplicate notes.
The plain expression form (not a statement expression with typeof) is correct here: several converted users need an integer constant expression (array bound via BITS_TO_LONGS in rnp.h, MAX_KEY_DWORDS in hns3_fdir.c, CNIC_ILT_LINES in bnx2x.h).
Patch 05/15 net/qede, 10/15 net/cxgbe, 11/15 net/ena
Info: commit message says RTE_DIV_ROUND_UP "makes DIV_ROUND_UP redundant", but these patches keep DIV_ROUND_UP as an alias for base/ code. Say that instead, e.g.:
Map DIV_ROUND_UP to RTE_DIV_ROUND_UP for the shared base code and use RTE_DIV_ROUND_UP directly elsewhere in the driver.
Patch 05/15 net/qede
Info: bcm_osal.h still defines RTE_ROUNDUP in the driver, squatting on the RTE_ namespace the same way the removed RTE_DIV_ROUND_UP did. RTE_ALIGN_MUL_CEIL() is the equivalent. Follow-up, not this series.
Patch 06/15 net/rnp
Info: nothing in DPDK defines BITS_TO_LONGS, so the new #ifndef guard does nothing; drop it.
Re: [PATCH v4 00/15] Introduce RTE_DIV_ROUND_UP
06/10/2026 18:38, Stephen Hemminger:
Quoted 9 lines
Quoted 6 lines · On Mon, 5 Oct 2026 19:30:36 -0700 Joshua Washington <[email protected]>…
Numerous components independently define the
DIV_ROUND_UPmacro, using the same definition. Attempt to commonize by introducingRTE_DIV_ROUND_UPtorte_common.hand replacing usages ofDIV_ROUND_UPwithRTE_DIV_ROUND_UP. Similarly, replaceDIV_CEIL, which is functionally identical, toRTE_DIV_ROUND_UP.
Quoted 8 lines
Quoted 6 lines
Changes in v4:
- eal: Fix merge conflict in release notes after rebase.
- various commits: addrte_common.hincludes where missing to fix compilation issues.
- opae: dropRTE_DIV_ROUND_UPchange due to shered osdep file for RTE and raw drivers.Looks good, some minor AI notes on commit messages and doc
I consider the minor notes as candidates for follow-up or not relevant.
Applied (with a bit of squashing), thanks.
Quoted 8 lines
Info: remaining private copies not covered by this series, candidates for a follow-up:
drivers/raw/ifpga/base/opae_osdep.hDIV_ROUND_UP(map like cxgbe)
drivers/crypto/ccp/ccp_dev.hCCP_DIV_ROUND_UP
drivers/common/qat/dev/qat_dev_gen_lce.cLCE_DIV_ROUND_UPdrivers/net/sfc/sfc_dp.h SFC_DIV_ROUND_UP drivers/common/sxe2/sxe2_osal.h SXE2_DIV_ROUND_UP drivers/common/cnxk/roc_platform.h PLT_DIV_CEIL
Would be nice to address in a new series, yes.
Quoted 3 lines
Info: the Doxygen repeats itself. "Evaluated twice" is in @param d and again in the first @note; "non-negative" is in @param n and again in the second @note. Keep the @param text and drop the duplicate notes.
I think this repeat is fine.
Quoted 2 lines
Info: nothing in DPDK defines
BITS_TO_LONGS, so the new #ifndef guard does nothing; drop it.
It is in rnp_osdep.h, probably to allow including in a different environment.