drivers_net: use 64-bit shift and avoid signed/unsigned mismatch
PATCH 1/1 drivers_net: use 64-bit shift and avoid signed/unsigned mismatch
This patch avoids warnings like the ones below emitted by MSVC:
1)
../drivers/net/ice/base/ice_flg_rd.c(71): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
2)
../drivers/net/ice/ice_dcf_sched.c(177): warning C4018: '>=':
signed/unsigned mismatch
The fix for (1) is to use 64-bit shifting when appropriate (according to what the result is used for).
The fix for (2) is to explicitly cast the variables used in the comparison.
--- drivers/net/i40e/i40e_ethdev.c | 22 +++++++++++----------- drivers/net/iavf/iavf_ethdev.c | 2 +- drivers/net/iavf/iavf_rxtx.c | 2 +- drivers/net/iavf/iavf_vchnl.c | 2 +- drivers/net/ice/base/ice_flg_rd.c | 4 ++-- drivers/net/ice/base/ice_parser_rt.c | 16 ++++++++-------- drivers/net/ice/base/ice_xlt_kb.c | 2 +- drivers/net/ice/ice_dcf_sched.c | 2 +- drivers/net/ice/ice_ethdev.c | 4 ++-- drivers/net/ice/ice_rxtx.c | 2 +- drivers/net/ixgbe/ixgbe_ethdev.c | 2 +- drivers/net/vmxnet3/vmxnet3_ethdev.h | 6 +++--- 12 files changed, 33 insertions(+), 33 deletions(-)
drivers/net/i40e/i40e_ethdev.c +11 -11
@@ -3094,7 +3094,7 @@ i40e_stat_update_48_in_64(struct i40e_hw *hw, uint32_t hireg,/* enlarge the limitation when statistics counters overflowed */ if (offset_loaded) {if (I40E_RXTX_BYTES_L_48_BIT (*prev_stat) > *stat) - *stat += (uint64_t )1 <<I40E_48_BIT_WIDTH ; + *stat +=RTE_BIT64 (I40E_48_BIT_WIDTH ); *stat +=I40E_RXTX_BYTES_H_16_BIT (*prev_stat); } *prev_stat = *stat;
@@ -4494,7 +4494,7 @@ i40e_macaddr_remove(struct rte_eth_dev *dev, uint32_t index) pool_sel = dev->data->mac_pool_sel[index];for (i =0 ; i <sizeof (pool_sel) *CHAR_BIT ; i++) { -if (pool_sel & (1ULL << i)) { +if (pool_sel &RTE_BIT64 (i)) {if (i ==0 ) vsi = pf->main_vsi;else {
@@ -4630,7 +4630,7 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev,for (i =0 ; i < reta_size; i++) { idx = i /RTE_ETH_RETA_GROUP_SIZE ; shift = i %RTE_ETH_RETA_GROUP_SIZE ; -if (reta_conf[idx].mask & (1ULL << shift)) +if (reta_conf[idx].mask &RTE_BIT64 (shift)) lut[i] = reta_conf[idx].reta[shift]; } ret =i40e_set_rss_lut (pf->main_vsi, lut, reta_size);
@@ -4674,7 +4674,7 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev,for (i =0 ; i < reta_size; i++) { idx = i /RTE_ETH_RETA_GROUP_SIZE ; shift = i %RTE_ETH_RETA_GROUP_SIZE ; -if (reta_conf[idx].mask & (1ULL << shift)) +if (reta_conf[idx].mask &RTE_BIT64 (shift)) reta_conf[idx].reta[shift] = lut[i]; }
@@ -6712,7 +6712,7 @@ i40e_vmdq_setup(struct rte_eth_dev *dev) loop =sizeof (vmdq_conf->pool_map[0 ].pools) *CHAR_BIT ;for (i =0 ; i < vmdq_conf->nb_pool_maps; i++) {for (j =0 ; j < loop && j < pf->nb_cfg_vmdq_vsi; j++) { -if (vmdq_conf->pool_map[i].pools & (1UL << j)) { +if (vmdq_conf->pool_map[i].pools &RTE_BIT64 (j)) {PMD_INIT_LOG (INFO ,"Add vlan %u to vmdq pool %u" , vmdq_conf->pool_map[i].vlan_id, j);
@@ -6761,7 +6761,7 @@ i40e_stat_update_32(struct i40e_hw *hw, *stat = (uint64_t )(new_data - *offset); else *stat = (uint64_t )((new_data + - ((uint64_t )1 <<I40E_32_BIT_WIDTH )) - *offset); +RTE_BIT64 (I40E_32_BIT_WIDTH )) - *offset); } static void
@@ -6789,7 +6789,7 @@ i40e_stat_update_48(struct i40e_hw *hw, *stat = new_data - *offset; else *stat = (uint64_t )((new_data + - ((uint64_t )1 <<I40E_48_BIT_WIDTH )) - *offset); +RTE_BIT64 (I40E_48_BIT_WIDTH )) - *offset); *stat &=I40E_48_BIT_MASK ; }
@@ -7730,7 +7730,7 @@ i40e_config_hena(const struct i40e_adapter *adapter, uint64_t flags)return hena;for (i =RTE_ETH_FLOW_UNKNOWN +1 ; i <I40E_FLOW_TYPE_MAX ; i++) { -if (flags & (1ULL << i)) +if (flags &RTE_BIT64 (i)) hena |= adapter->pctypes_tbl[i]; }
@@ -7749,7 +7749,7 @@ i40e_parse_hena(const struct i40e_adapter *adapter, uint64_t flags)for (i =RTE_ETH_FLOW_UNKNOWN +1 ; i <I40E_FLOW_TYPE_MAX ; i++) {if (flags & adapter->pctypes_tbl[i]) - rss_hf |= (1ULL << i); + rss_hf |=RTE_BIT64 (i); }return rss_hf; }
@@ -10162,7 +10162,7 @@ i40e_flowtype_to_pctype(const struct i40e_adapter *adapter, uint16_t flow_type)if (flow_type <I40E_FLOW_TYPE_MAX ) { pctype_mask = adapter->pctypes_tbl[flow_type];for (i =I40E_FILTER_PCTYPE_MAX -1 ; i >0 ; i--) { -if (pctype_mask & (1ULL << i)) +if (pctype_mask &RTE_BIT64 (i))return (enum i40e_filter_pctype )i; } }
@@ -10174,7 +10174,7 @@ i40e_pctype_to_flowtype(const struct i40e_adapter *adapter, enum i40e_filter_pctype pctype) {uint16_t flowtype; -uint64_t pctype_mask =1ULL << pctype; +uint64_t pctype_mask =RTE_BIT64 (pctype);for (flowtype =RTE_ETH_FLOW_UNKNOWN +1 ; flowtype <I40E_FLOW_TYPE_MAX ; flowtype++) {
drivers/net/iavf/iavf_ethdev.c +1 -1
@@ -2485,7 +2485,7 @@ iavf_init_proto_xtr(struct rte_eth_dev *dev)if (!xtr_ol->required)continue ; -if (!(vf->supported_rxdid &BIT (rxdid))) { +if (!(vf->supported_rxdid &RTE_BIT64 (rxdid))) {PMD_DRV_LOG (ERR ,"rxdid[%u] is not supported in hardware" , rxdid);
drivers/net/iavf/iavf_rxtx.c +1 -1
@@ -3915,7 +3915,7 @@ iavf_set_rx_function(struct rte_eth_dev *dev)PMD_DRV_LOG (NOTICE ,"request RXDID[%d] in Queue[%d] is legacy, " "set rx_pkt_burst as legacy for all queues" , rxq->rxdid, i); use_flex = false; - }else if (!(vf->supported_rxdid &BIT (rxq->rxdid))) { + }else if (!(vf->supported_rxdid &RTE_BIT64 (rxq->rxdid))) {PMD_DRV_LOG (NOTICE ,"request RXDID[%d] in Queue[%d] is not supported, " "set rx_pkt_burst as legacy for all queues" , rxq->rxdid, i); use_flex = false;
drivers/net/iavf/iavf_vchnl.c +1 -1
@@ -1265,7 +1265,7 @@ iavf_configure_queues(struct iavf_adapter *adapter,#ifndef RTE_LIBRTE_IAVF_16BYTE_RX_DESC if (vf->vf_res->vf_cap_flags &VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC ) { -if (vf->supported_rxdid &BIT (rxq[i]->rxdid)) { +if (vf->supported_rxdid &RTE_BIT64 (rxq[i]->rxdid)) { vc_qp->rxq.rxdid = rxq[i]->rxdid;PMD_DRV_LOG (NOTICE ,"request RXDID[%d] in Queue[%d]" , vc_qp->rxq.rxdid, i);
drivers/net/ice/base/ice_flg_rd.c +2 -2
@@ -68,8 +68,8 @@ u64 ice_flg_redirect(struct ice_flg_rd_item *table, u64 psr_flg)if (!item->expose)continue ; -if (psr_flg & (1ul << item->intr_flg_id)) - flg |= (1ul << i); +if (psr_flg &RTE_BIT64 (item->intr_flg_id)) + flg |=RTE_BIT64 (i); }return flg;
drivers/net/ice/base/ice_parser_rt.c +8 -8
@@ -90,7 +90,7 @@ void ice_parser_rt_reset(struct ice_parser_rt *rt) rt->psr = psr;for (i =0 ; i <64 ; i++) { -if ((mi->flags & (1ul << i)) !=0ul ) +if ((mi->flags &RTE_BIT64 (i)) !=0ul )_rt_flag_set (rt, i, true); } }
@@ -399,11 +399,11 @@ static void _pg_exe(struct ice_parser_rt *rt)static void _flg_add (struct ice_parser_rt *rt,int idx,bool val) { - rt->pu.flg_msk |= (1ul << idx); + rt->pu.flg_msk |=RTE_BIT64 (idx);if (val) - rt->pu.flg_val |= (1ul << idx); + rt->pu.flg_val |=RTE_BIT64 (idx);else - rt->pu.flg_val &= ~(1ul << idx); + rt->pu.flg_val &= ~RTE_BIT64 (idx);ice_debug (rt->psr->hw,ICE_DBG_PARSER ,"Pending update for flag %d value %d\n" , idx, val);
@@ -468,9 +468,9 @@ static void _err_add(struct ice_parser_rt *rt, int idx, bool val) { rt->pu.err_msk |= (u16)(1 << idx);if (val) - rt->pu.flg_val |= (1ULL << idx); + rt->pu.flg_val |=RTE_BIT64 (idx);else - rt->pu.flg_val &= ~(1ULL << idx); + rt->pu.flg_val &= ~RTE_BIT64 (idx);ice_debug (rt->psr->hw,ICE_DBG_PARSER ,"Pending update for error %d value %d\n" , idx, val);
@@ -600,8 +600,8 @@ static void _pu_exe(struct ice_parser_rt *rt) }for (i =0 ; i <64 ; i++) { -if (pu->flg_msk & (1ul << i)) -_rt_flag_set (rt, i, pu->flg_val & (1ul << i)); +if (pu->flg_msk &RTE_BIT64 (i)) +_rt_flag_set (rt, i, pu->flg_val &RTE_BIT64 (i)); }for (i =0 ; i <16 ; i++) {
drivers/net/ice/base/ice_xlt_kb.c +1 -1
@@ -208,7 +208,7 @@ u16 ice_xlt_kb_flag_get(struct ice_xlt_kb *kb, u64 pkt_flag)/* only check first entry */ u16 idx = (u16)(entry->flg0_14_sel[i] &0x3f ); -if (pkt_flag & (1ul << idx)) +if (pkt_flag &RTE_BIT64 (idx)) flg |= (u16)(1u << i); }
drivers/net/ice/ice_dcf_sched.c +1 -1
@@ -174,7 +174,7 @@ ice_dcf_node_param_check(struct ice_dcf_hw *hw, uint32_t node_id, }/* for non-leaf node */ -if (node_id >=8 * hw->num_vfs) { +if (node_id >= (uint32_t )(8 * hw->num_vfs)) {if (params->nonleaf.wfq_weight_mode) { error->type =RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE ;
drivers/net/ice/ice_ethdev.c +2 -2
@@ -2469,13 +2469,13 @@ ice_get_supported_rxdid(struct ice_hw *hw)uint32_t regval;int i; - supported_rxdid |=BIT (ICE_RXDID_LEGACY_1 ); + supported_rxdid |=RTE_BIT64 (ICE_RXDID_LEGACY_1 );for (i =ICE_RXDID_FLEX_NIC ; i <ICE_FLEX_DESC_RXDID_MAX_NUM ; i++) { regval =ICE_READ_REG (hw,GLFLXP_RXDID_FLAGS (i,0 ));if ((regval >>GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_S ) &GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_M ) - supported_rxdid |=BIT (i); + supported_rxdid |=RTE_BIT64 (i); }return supported_rxdid; }
drivers/net/ice/ice_rxtx.c +1 -1
@@ -399,7 +399,7 @@ ice_program_hw_rx_queue(struct ice_rx_queue *rxq)PMD_DRV_LOG (DEBUG ,"Port (%u) - Rx queue (%u) is set with RXDID : %u" , rxq->port_id, rxq->queue_id, rxdid); -if (!(pf->supported_rxdid &BIT (rxdid))) { +if (!(pf->supported_rxdid &RTE_BIT64 (rxdid))) {PMD_DRV_LOG (ERR ,"currently package doesn't support RXDID (%u)" , rxdid);return -EINVAL ;
drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
@@ -2722,7 +2722,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev)ixgbe_set_vf_rate_limit ( dev, vf, vfinfo[vf].tx_rate[idx], -1 << idx); +RTE_BIT64 (idx)); }ixgbe_restore_statistics_mapping (dev);
drivers/net/vmxnet3/vmxnet3_ethdev.h +3 -3
@@ -186,14 +186,14 @@ static inline uint8_t vmxnet3_get_ring_idx(struct vmxnet3_hw *hw, uint32 rqID) {return (rqID >= hw->num_rx_queues && - rqID <2 * hw->num_rx_queues) ?1 :0 ; + rqID < (uint32 )2 * hw->num_rx_queues) ?1 :0 ; }static inline bool vmxnet3_rx_data_ring (struct vmxnet3_hw *hw,uint32 rqID) { -return (rqID >=2 * hw->num_rx_queues && - rqID <3 * hw->num_rx_queues); +return (rqID >= (uint32 )2 * hw->num_rx_queues && + rqID < (uint32 )3 * hw->num_rx_queues); }/*
Signature · 1 line
2.47.0.vfs.0.3
Quoted 18 lines · Andre Muezerie
This patch avoids warnings like the ones below emitted by MSVC:
1)
../drivers/net/ice/base/ice_flg_rd.c(71): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)2)
../drivers/net/ice/ice_dcf_sched.c(177): warning C4018: '>=':
signed/unsigned mismatchThe fix for (1) is to use 64-bit shifting when appropriate (according to what the result is used for).
The fix for (2) is to explicitly cast the variables used in the comparison.
Signed-off-by Andre Muezerie <[email protected]>
Quoted 12 lines
--- drivers/net/i40e/i40e_ethdev.c | 22 +++++++++++----------- drivers/net/iavf/iavf_ethdev.c | 2 +- drivers/net/iavf/iavf_rxtx.c | 2 +- drivers/net/iavf/iavf_vchnl.c | 2 +- drivers/net/ice/base/ice_flg_rd.c | 4 ++-- drivers/net/ice/base/ice_parser_rt.c | 16 ++++++++-------- drivers/net/ice/base/ice_xlt_kb.c | 2 +- drivers/net/ice/ice_dcf_sched.c | 2 +- drivers/net/ice/ice_ethdev.c | 4 ++-- drivers/net/ice/ice_rxtx.c | 2 +- drivers/net/ixgbe/ixgbe_ethdev.c | 2 +-
Most of these changes to the intel drivers look fine to me. However, for the base code files, we try to avoid modifying those as they come from a common, shared internal source which we regularly sync with. Therefore, for the 3 base files, can the errors/warning be suppressed instead?
Regards,
/Bruce
Quoted 32 lines · Bruce Richardson
Quoted 18 lines · Andre Muezerie
This patch avoids warnings like the ones below emitted by MSVC:
1)
../drivers/net/ice/base/ice_flg_rd.c(71): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)2)
../drivers/net/ice/ice_dcf_sched.c(177): warning C4018: '>=':
signed/unsigned mismatchThe fix for (1) is to use 64-bit shifting when appropriate (according to what the result is used for).
The fix for (2) is to explicitly cast the variables used in the comparison.
Signed-off-by Andre Muezerie <[email protected]>Quoted 12 lines
--- drivers/net/i40e/i40e_ethdev.c | 22 +++++++++++----------- drivers/net/iavf/iavf_ethdev.c | 2 +- drivers/net/iavf/iavf_rxtx.c | 2 +- drivers/net/iavf/iavf_vchnl.c | 2 +- drivers/net/ice/base/ice_flg_rd.c | 4 ++-- drivers/net/ice/base/ice_parser_rt.c | 16 ++++++++-------- drivers/net/ice/base/ice_xlt_kb.c | 2 +- drivers/net/ice/ice_dcf_sched.c | 2 +- drivers/net/ice/ice_ethdev.c | 4 ++-- drivers/net/ice/ice_rxtx.c | 2 +- drivers/net/ixgbe/ixgbe_ethdev.c | 2 +-
Quoted 7 lines
Most of these changes to the intel drivers look fine to me. However, for the base code files, we try to avoid modifying those as they come from a common, shared internal source which we regularly sync with. Therefore, for the 3 base files, can the errors/warning be suppressed instead?
Regards,
/Bruce
I wasn't aware of that. Thanks for letting me know. I'll make the modifications suggested in v2 of this series.
PATCH v2 1/1 drivers/net: use 64-bit shift and avoid signed/unsigned mismatch
In reply to Andre MuezerieThis patch avoids warnings like the ones below emitted by MSVC:
1)
../drivers/net/ice/base/ice_flg_rd.c(71): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
2)
../drivers/net/ice/ice_dcf_sched.c(177): warning C4018: '>=':
signed/unsigned mismatch
The fix for (1) is to use 64-bit shifting when appropriate (according to what the result is used for).
The fix for (2) is to explicitly cast the variables used in the comparison.
--- drivers/net/i40e/i40e_ethdev.c | 22 +++++++++++----------- drivers/net/iavf/iavf_ethdev.c | 2 +- drivers/net/iavf/iavf_rxtx.c | 2 +- drivers/net/iavf/iavf_vchnl.c | 2 +- drivers/net/ice/base/ice_flg_rd.c | 4 ++-- drivers/net/ice/base/ice_parser_rt.c | 16 ++++++++-------- drivers/net/ice/base/ice_xlt_kb.c | 2 +- drivers/net/ice/base/meson.build | 19 +++++++++++++------ drivers/net/ice/ice_dcf_sched.c | 2 +- drivers/net/ice/ice_ethdev.c | 4 ++-- drivers/net/ice/ice_rxtx.c | 2 +- drivers/net/ixgbe/ixgbe_ethdev.c | 2 +- drivers/net/vmxnet3/vmxnet3_ethdev.h | 6 +++--- 13 files changed, 46 insertions(+), 39 deletions(-)
drivers/net/i40e/i40e_ethdev.c +11 -11
@@ -3094,7 +3094,7 @@ i40e_stat_update_48_in_64(struct i40e_hw *hw, uint32_t hireg,/* enlarge the limitation when statistics counters overflowed */ if (offset_loaded) {if (I40E_RXTX_BYTES_L_48_BIT (*prev_stat) > *stat) - *stat += (uint64_t )1 <<I40E_48_BIT_WIDTH ; + *stat +=RTE_BIT64 (I40E_48_BIT_WIDTH ); *stat +=I40E_RXTX_BYTES_H_16_BIT (*prev_stat); } *prev_stat = *stat;
@@ -4494,7 +4494,7 @@ i40e_macaddr_remove(struct rte_eth_dev *dev, uint32_t index) pool_sel = dev->data->mac_pool_sel[index];for (i =0 ; i <sizeof (pool_sel) *CHAR_BIT ; i++) { -if (pool_sel & (1ULL << i)) { +if (pool_sel &RTE_BIT64 (i)) {if (i ==0 ) vsi = pf->main_vsi;else {
@@ -4630,7 +4630,7 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev,for (i =0 ; i < reta_size; i++) { idx = i /RTE_ETH_RETA_GROUP_SIZE ; shift = i %RTE_ETH_RETA_GROUP_SIZE ; -if (reta_conf[idx].mask & (1ULL << shift)) +if (reta_conf[idx].mask &RTE_BIT64 (shift)) lut[i] = reta_conf[idx].reta[shift]; } ret =i40e_set_rss_lut (pf->main_vsi, lut, reta_size);
@@ -4674,7 +4674,7 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev,for (i =0 ; i < reta_size; i++) { idx = i /RTE_ETH_RETA_GROUP_SIZE ; shift = i %RTE_ETH_RETA_GROUP_SIZE ; -if (reta_conf[idx].mask & (1ULL << shift)) +if (reta_conf[idx].mask &RTE_BIT64 (shift)) reta_conf[idx].reta[shift] = lut[i]; }
@@ -6712,7 +6712,7 @@ i40e_vmdq_setup(struct rte_eth_dev *dev) loop =sizeof (vmdq_conf->pool_map[0 ].pools) *CHAR_BIT ;for (i =0 ; i < vmdq_conf->nb_pool_maps; i++) {for (j =0 ; j < loop && j < pf->nb_cfg_vmdq_vsi; j++) { -if (vmdq_conf->pool_map[i].pools & (1UL << j)) { +if (vmdq_conf->pool_map[i].pools &RTE_BIT64 (j)) {PMD_INIT_LOG (INFO ,"Add vlan %u to vmdq pool %u" , vmdq_conf->pool_map[i].vlan_id, j);
@@ -6761,7 +6761,7 @@ i40e_stat_update_32(struct i40e_hw *hw, *stat = (uint64_t )(new_data - *offset); else *stat = (uint64_t )((new_data + - ((uint64_t )1 <<I40E_32_BIT_WIDTH )) - *offset); +RTE_BIT64 (I40E_32_BIT_WIDTH )) - *offset); } static void
@@ -6789,7 +6789,7 @@ i40e_stat_update_48(struct i40e_hw *hw, *stat = new_data - *offset; else *stat = (uint64_t )((new_data + - ((uint64_t )1 <<I40E_48_BIT_WIDTH )) - *offset); +RTE_BIT64 (I40E_48_BIT_WIDTH )) - *offset); *stat &=I40E_48_BIT_MASK ; }
@@ -7730,7 +7730,7 @@ i40e_config_hena(const struct i40e_adapter *adapter, uint64_t flags)return hena;for (i =RTE_ETH_FLOW_UNKNOWN +1 ; i <I40E_FLOW_TYPE_MAX ; i++) { -if (flags & (1ULL << i)) +if (flags &RTE_BIT64 (i)) hena |= adapter->pctypes_tbl[i]; }
@@ -7749,7 +7749,7 @@ i40e_parse_hena(const struct i40e_adapter *adapter, uint64_t flags)for (i =RTE_ETH_FLOW_UNKNOWN +1 ; i <I40E_FLOW_TYPE_MAX ; i++) {if (flags & adapter->pctypes_tbl[i]) - rss_hf |= (1ULL << i); + rss_hf |=RTE_BIT64 (i); }return rss_hf; }
@@ -10162,7 +10162,7 @@ i40e_flowtype_to_pctype(const struct i40e_adapter *adapter, uint16_t flow_type)if (flow_type <I40E_FLOW_TYPE_MAX ) { pctype_mask = adapter->pctypes_tbl[flow_type];for (i =I40E_FILTER_PCTYPE_MAX -1 ; i >0 ; i--) { -if (pctype_mask & (1ULL << i)) +if (pctype_mask &RTE_BIT64 (i))return (enum i40e_filter_pctype )i; } }
@@ -10174,7 +10174,7 @@ i40e_pctype_to_flowtype(const struct i40e_adapter *adapter, enum i40e_filter_pctype pctype) {uint16_t flowtype; -uint64_t pctype_mask =1ULL << pctype; +uint64_t pctype_mask =RTE_BIT64 (pctype);for (flowtype =RTE_ETH_FLOW_UNKNOWN +1 ; flowtype <I40E_FLOW_TYPE_MAX ; flowtype++) {
drivers/net/iavf/iavf_ethdev.c +1 -1
@@ -2485,7 +2485,7 @@ iavf_init_proto_xtr(struct rte_eth_dev *dev)if (!xtr_ol->required)continue ; -if (!(vf->supported_rxdid &BIT (rxdid))) { +if (!(vf->supported_rxdid &RTE_BIT64 (rxdid))) {PMD_DRV_LOG (ERR ,"rxdid[%u] is not supported in hardware" , rxdid);
drivers/net/iavf/iavf_rxtx.c +1 -1
@@ -3915,7 +3915,7 @@ iavf_set_rx_function(struct rte_eth_dev *dev)PMD_DRV_LOG (NOTICE ,"request RXDID[%d] in Queue[%d] is legacy, " "set rx_pkt_burst as legacy for all queues" , rxq->rxdid, i); use_flex = false; - }else if (!(vf->supported_rxdid &BIT (rxq->rxdid))) { + }else if (!(vf->supported_rxdid &RTE_BIT64 (rxq->rxdid))) {PMD_DRV_LOG (NOTICE ,"request RXDID[%d] in Queue[%d] is not supported, " "set rx_pkt_burst as legacy for all queues" , rxq->rxdid, i); use_flex = false;
drivers/net/iavf/iavf_vchnl.c +1 -1
@@ -1265,7 +1265,7 @@ iavf_configure_queues(struct iavf_adapter *adapter,#ifndef RTE_LIBRTE_IAVF_16BYTE_RX_DESC if (vf->vf_res->vf_cap_flags &VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC ) { -if (vf->supported_rxdid &BIT (rxq[i]->rxdid)) { +if (vf->supported_rxdid &RTE_BIT64 (rxq[i]->rxdid)) { vc_qp->rxq.rxdid = rxq[i]->rxdid;PMD_DRV_LOG (NOTICE ,"request RXDID[%d] in Queue[%d]" , vc_qp->rxq.rxdid, i);
drivers/net/ice/base/ice_flg_rd.c +2 -2
@@ -68,8 +68,8 @@ u64 ice_flg_redirect(struct ice_flg_rd_item *table, u64 psr_flg)if (!item->expose)continue ; -if (psr_flg & (1ul << item->intr_flg_id)) - flg |= (1ul << i); +if (psr_flg &RTE_BIT64 (item->intr_flg_id)) + flg |=RTE_BIT64 (i); }return flg;
drivers/net/ice/base/ice_parser_rt.c +8 -8
@@ -90,7 +90,7 @@ void ice_parser_rt_reset(struct ice_parser_rt *rt) rt->psr = psr;for (i =0 ; i <64 ; i++) { -if ((mi->flags & (1ul << i)) !=0ul ) +if ((mi->flags &RTE_BIT64 (i)) !=0ul )_rt_flag_set (rt, i, true); } }
@@ -399,11 +399,11 @@ static void _pg_exe(struct ice_parser_rt *rt)static void _flg_add (struct ice_parser_rt *rt,int idx,bool val) { - rt->pu.flg_msk |= (1ul << idx); + rt->pu.flg_msk |=RTE_BIT64 (idx);if (val) - rt->pu.flg_val |= (1ul << idx); + rt->pu.flg_val |=RTE_BIT64 (idx);else - rt->pu.flg_val &= ~(1ul << idx); + rt->pu.flg_val &= ~RTE_BIT64 (idx);ice_debug (rt->psr->hw,ICE_DBG_PARSER ,"Pending update for flag %d value %d\n" , idx, val);
@@ -468,9 +468,9 @@ static void _err_add(struct ice_parser_rt *rt, int idx, bool val) { rt->pu.err_msk |= (u16)(1 << idx);if (val) - rt->pu.flg_val |= (1ULL << idx); + rt->pu.flg_val |=RTE_BIT64 (idx);else - rt->pu.flg_val &= ~(1ULL << idx); + rt->pu.flg_val &= ~RTE_BIT64 (idx);ice_debug (rt->psr->hw,ICE_DBG_PARSER ,"Pending update for error %d value %d\n" , idx, val);
@@ -600,8 +600,8 @@ static void _pu_exe(struct ice_parser_rt *rt) }for (i =0 ; i <64 ; i++) { -if (pu->flg_msk & (1ul << i)) -_rt_flag_set (rt, i, pu->flg_val & (1ul << i)); +if (pu->flg_msk &RTE_BIT64 (i)) +_rt_flag_set (rt, i, pu->flg_val &RTE_BIT64 (i)); }for (i =0 ; i <16 ; i++) {
drivers/net/ice/base/ice_xlt_kb.c +1 -1
@@ -208,7 +208,7 @@ u16 ice_xlt_kb_flag_get(struct ice_xlt_kb *kb, u64 pkt_flag)/* only check first entry */ u16 idx = (u16)(entry->flg0_14_sel[i] &0x3f ); -if (pkt_flag & (1ul << idx)) +if (pkt_flag &RTE_BIT64 (idx)) flg |= (u16)(1u << i); }
drivers/net/ice/base/meson.build +13 -6
@@ -31,18 +31,25 @@ sources = [ 'ice_vf_mbx.c', ] -error_cflags = [ - '-Wno-unused-but-set-variable', - '-Wno-unused-variable', - '-Wno-unused-parameter', -] +if is_ms_compiler + error_cflags = [ + '/wd4101', # unreferenced local variable + '/wd4334', # result of 32-bit shift implicitly converted to 64 bits + ] +else + error_cflags = [ + '-Wno-unused-but-set-variable', + '-Wno-unused-variable', + '-Wno-unused-parameter', + ] +endif # Bugzilla ID: 678 if (toolchain == 'gcc' and cc.version().version_compare('>=11.0.0')) error_cflags += ['-Wno-array-bounds'] endif -if is_windows and cc.get_id() != 'clang' +if is_windows and not is_ms_compiler and cc.get_id() != 'clang' cflags += ['-fno-asynchronous-unwind-tables'] endif
drivers/net/ice/ice_dcf_sched.c +1 -1
@@ -174,7 +174,7 @@ ice_dcf_node_param_check(struct ice_dcf_hw *hw, uint32_t node_id, }/* for non-leaf node */ -if (node_id >=8 * hw->num_vfs) { +if (node_id >= (uint32_t )(8 * hw->num_vfs)) {if (params->nonleaf.wfq_weight_mode) { error->type =RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE ;
drivers/net/ice/ice_ethdev.c +2 -2
@@ -2469,13 +2469,13 @@ ice_get_supported_rxdid(struct ice_hw *hw)uint32_t regval;int i; - supported_rxdid |=BIT (ICE_RXDID_LEGACY_1 ); + supported_rxdid |=RTE_BIT64 (ICE_RXDID_LEGACY_1 );for (i =ICE_RXDID_FLEX_NIC ; i <ICE_FLEX_DESC_RXDID_MAX_NUM ; i++) { regval =ICE_READ_REG (hw,GLFLXP_RXDID_FLAGS (i,0 ));if ((regval >>GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_S ) &GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_M ) - supported_rxdid |=BIT (i); + supported_rxdid |=RTE_BIT64 (i); }return supported_rxdid; }
drivers/net/ice/ice_rxtx.c +1 -1
@@ -399,7 +399,7 @@ ice_program_hw_rx_queue(struct ice_rx_queue *rxq)PMD_DRV_LOG (DEBUG ,"Port (%u) - Rx queue (%u) is set with RXDID : %u" , rxq->port_id, rxq->queue_id, rxdid); -if (!(pf->supported_rxdid &BIT (rxdid))) { +if (!(pf->supported_rxdid &RTE_BIT64 (rxdid))) {PMD_DRV_LOG (ERR ,"currently package doesn't support RXDID (%u)" , rxdid);return -EINVAL ;
drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
@@ -2722,7 +2722,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev)ixgbe_set_vf_rate_limit ( dev, vf, vfinfo[vf].tx_rate[idx], -1 << idx); +RTE_BIT64 (idx)); }ixgbe_restore_statistics_mapping (dev);
drivers/net/vmxnet3/vmxnet3_ethdev.h +3 -3
@@ -186,14 +186,14 @@ static inline uint8_t vmxnet3_get_ring_idx(struct vmxnet3_hw *hw, uint32 rqID) {return (rqID >= hw->num_rx_queues && - rqID <2 * hw->num_rx_queues) ?1 :0 ; + rqID < (uint32 )2 * hw->num_rx_queues) ?1 :0 ; }static inline bool vmxnet3_rx_data_ring (struct vmxnet3_hw *hw,uint32 rqID) { -return (rqID >=2 * hw->num_rx_queues && - rqID <3 * hw->num_rx_queues); +return (rqID >= (uint32 )2 * hw->num_rx_queues && + rqID < (uint32 )3 * hw->num_rx_queues); }/*
Signature · 1 line
2.47.0.vfs.0.3
Re: [PATCH v2] drivers/net: use 64-bit shift and avoid signed/unsigned mismatch
Quoted 18 lines · On Mon, 6 Jan 2025 13:16:55 -0800 Andre Muezerie…
This patch avoids warnings like the ones below emitted by MSVC:
1)
../drivers/net/ice/base/ice_flg_rd.c(71): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)2)
../drivers/net/ice/ice_dcf_sched.c(177): warning C4018: '>=':
signed/unsigned mismatchThe fix for (1) is to use 64-bit shifting when appropriate (according to what the result is used for).
The fix for (2) is to explicitly cast the variables used in the comparison.
Signed-off-by Andre Muezerie <[email protected]>
Quoted 9 lines
--- drivers/net/i40e/i40e_ethdev.c | 22 +++++++++++----------- drivers/net/iavf/iavf_ethdev.c | 2 +- drivers/net/iavf/iavf_rxtx.c | 2 +- drivers/net/iavf/iavf_vchnl.c | 2 +- drivers/net/ice/base/ice_flg_rd.c | 4 ++-- drivers/net/ice/base/ice_parser_rt.c | 16 ++++++++-------- drivers/net/ice/base/ice_xlt_kb.c | 2 +- drivers/net/ice/base/meson.build | 19 +++++++++++++------
Patches to base driver need to be avoided if at all possible. Please resubmit without that part
Re: [PATCH v2] drivers/net: use 64-bit shift and avoid signed/unsigned mismatch
Quoted 31 lines · Stephen Hemminger
Quoted 18 lines · On Mon, 6 Jan 2025 13:16:55 -0800 Andre Muezerie…
This patch avoids warnings like the ones below emitted by MSVC:
1)
../drivers/net/ice/base/ice_flg_rd.c(71): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)2)
../drivers/net/ice/ice_dcf_sched.c(177): warning C4018: '>=':
signed/unsigned mismatchThe fix for (1) is to use 64-bit shifting when appropriate (according to what the result is used for).
The fix for (2) is to explicitly cast the variables used in the comparison.
Signed-off-by Andre Muezerie <[email protected]>Quoted 9 lines
--- drivers/net/i40e/i40e_ethdev.c | 22 +++++++++++----------- drivers/net/iavf/iavf_ethdev.c | 2 +- drivers/net/iavf/iavf_rxtx.c | 2 +- drivers/net/iavf/iavf_vchnl.c | 2 +- drivers/net/ice/base/ice_flg_rd.c | 4 ++-- drivers/net/ice/base/ice_parser_rt.c | 16 ++++++++-------- drivers/net/ice/base/ice_xlt_kb.c | 2 +- drivers/net/ice/base/meson.build | 19 +++++++++++++------
Quoted 2 lines
Patches to base driver need to be avoided if at all possible. Please resubmit without that part
Thanks for the information. I sent out a v3 for this series. It does contain _coding style issues_ for preexisting code. Hopefuly that can be ignored.
Re: [PATCH v2] drivers/net: use 64-bit shift and avoid signed/unsigned mismatch
Quoted 7 lines · On Tue, 14 Jan 2025 13:08:28 -0800 Andre Muezerie…
Quoted 3 lines
Patches to base driver need to be avoided if at all possible. Please resubmit without that part
Thanks for the information. I sent out a v3 for this series. It does contain
_codingstyleissues_for preexisting code. Hopefuly that can be ignored.
Yeah, that is common. I always look to see why checkpatch is whining before merging.
PATCH v3 1/1 drivers/net: use 64-bit shift and avoid signed/unsigned mismatch
In reply to Andre MuezerieThis patch avoids warnings like the ones below emitted by MSVC:
1)
../drivers/net/ice/base/ice_flg_rd.c(71): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
2)
../drivers/net/ice/ice_dcf_sched.c(177): warning C4018: '>=':
signed/unsigned mismatch
The fix for (1) is to use 64-bit shifting when appropriate (according to what the result is used for).
The fix for (2) is to explicitly cast the variables used in the comparison.
--- drivers/net/i40e/i40e_ethdev.c | 22 +++++++++++----------- drivers/net/iavf/iavf_ethdev.c | 2 +- drivers/net/iavf/iavf_rxtx.c | 2 +- drivers/net/iavf/iavf_vchnl.c | 2 +- drivers/net/ice/base/meson.build | 19 +++++++++++++------ drivers/net/ice/ice_dcf_sched.c | 2 +- drivers/net/ice/ice_ethdev.c | 4 ++-- drivers/net/ice/ice_rxtx.c | 2 +- drivers/net/ixgbe/ixgbe_ethdev.c | 2 +- drivers/net/vmxnet3/vmxnet3_ethdev.h | 6 +++--- 10 files changed, 35 insertions(+), 28 deletions(-)
drivers/net/i40e/i40e_ethdev.c +11 -11
@@ -3094,7 +3094,7 @@ i40e_stat_update_48_in_64(struct i40e_hw *hw, uint32_t hireg,/* enlarge the limitation when statistics counters overflowed */ if (offset_loaded) {if (I40E_RXTX_BYTES_L_48_BIT (*prev_stat) > *stat) - *stat += (uint64_t )1 <<I40E_48_BIT_WIDTH ; + *stat +=RTE_BIT64 (I40E_48_BIT_WIDTH ); *stat +=I40E_RXTX_BYTES_H_16_BIT (*prev_stat); } *prev_stat = *stat;
@@ -4494,7 +4494,7 @@ i40e_macaddr_remove(struct rte_eth_dev *dev, uint32_t index) pool_sel = dev->data->mac_pool_sel[index];for (i =0 ; i <sizeof (pool_sel) *CHAR_BIT ; i++) { -if (pool_sel & (1ULL << i)) { +if (pool_sel &RTE_BIT64 (i)) {if (i ==0 ) vsi = pf->main_vsi;else {
@@ -4630,7 +4630,7 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev,for (i =0 ; i < reta_size; i++) { idx = i /RTE_ETH_RETA_GROUP_SIZE ; shift = i %RTE_ETH_RETA_GROUP_SIZE ; -if (reta_conf[idx].mask & (1ULL << shift)) +if (reta_conf[idx].mask &RTE_BIT64 (shift)) lut[i] = reta_conf[idx].reta[shift]; } ret =i40e_set_rss_lut (pf->main_vsi, lut, reta_size);
@@ -4674,7 +4674,7 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev,for (i =0 ; i < reta_size; i++) { idx = i /RTE_ETH_RETA_GROUP_SIZE ; shift = i %RTE_ETH_RETA_GROUP_SIZE ; -if (reta_conf[idx].mask & (1ULL << shift)) +if (reta_conf[idx].mask &RTE_BIT64 (shift)) reta_conf[idx].reta[shift] = lut[i]; }
@@ -6712,7 +6712,7 @@ i40e_vmdq_setup(struct rte_eth_dev *dev) loop =sizeof (vmdq_conf->pool_map[0 ].pools) *CHAR_BIT ;for (i =0 ; i < vmdq_conf->nb_pool_maps; i++) {for (j =0 ; j < loop && j < pf->nb_cfg_vmdq_vsi; j++) { -if (vmdq_conf->pool_map[i].pools & (1UL << j)) { +if (vmdq_conf->pool_map[i].pools &RTE_BIT64 (j)) {PMD_INIT_LOG (INFO ,"Add vlan %u to vmdq pool %u" , vmdq_conf->pool_map[i].vlan_id, j);
@@ -6761,7 +6761,7 @@ i40e_stat_update_32(struct i40e_hw *hw, *stat = (uint64_t )(new_data - *offset); else *stat = (uint64_t )((new_data + - ((uint64_t )1 <<I40E_32_BIT_WIDTH )) - *offset); +RTE_BIT64 (I40E_32_BIT_WIDTH )) - *offset); } static void
@@ -6789,7 +6789,7 @@ i40e_stat_update_48(struct i40e_hw *hw, *stat = new_data - *offset; else *stat = (uint64_t )((new_data + - ((uint64_t )1 <<I40E_48_BIT_WIDTH )) - *offset); +RTE_BIT64 (I40E_48_BIT_WIDTH )) - *offset); *stat &=I40E_48_BIT_MASK ; }
@@ -7730,7 +7730,7 @@ i40e_config_hena(const struct i40e_adapter *adapter, uint64_t flags)return hena;for (i =RTE_ETH_FLOW_UNKNOWN +1 ; i <I40E_FLOW_TYPE_MAX ; i++) { -if (flags & (1ULL << i)) +if (flags &RTE_BIT64 (i)) hena |= adapter->pctypes_tbl[i]; }
@@ -7749,7 +7749,7 @@ i40e_parse_hena(const struct i40e_adapter *adapter, uint64_t flags)for (i =RTE_ETH_FLOW_UNKNOWN +1 ; i <I40E_FLOW_TYPE_MAX ; i++) {if (flags & adapter->pctypes_tbl[i]) - rss_hf |= (1ULL << i); + rss_hf |=RTE_BIT64 (i); }return rss_hf; }
@@ -10162,7 +10162,7 @@ i40e_flowtype_to_pctype(const struct i40e_adapter *adapter, uint16_t flow_type)if (flow_type <I40E_FLOW_TYPE_MAX ) { pctype_mask = adapter->pctypes_tbl[flow_type];for (i =I40E_FILTER_PCTYPE_MAX -1 ; i >0 ; i--) { -if (pctype_mask & (1ULL << i)) +if (pctype_mask &RTE_BIT64 (i))return (enum i40e_filter_pctype )i; } }
@@ -10174,7 +10174,7 @@ i40e_pctype_to_flowtype(const struct i40e_adapter *adapter, enum i40e_filter_pctype pctype) {uint16_t flowtype; -uint64_t pctype_mask =1ULL << pctype; +uint64_t pctype_mask =RTE_BIT64 (pctype);for (flowtype =RTE_ETH_FLOW_UNKNOWN +1 ; flowtype <I40E_FLOW_TYPE_MAX ; flowtype++) {
drivers/net/iavf/iavf_ethdev.c +1 -1
@@ -2485,7 +2485,7 @@ iavf_init_proto_xtr(struct rte_eth_dev *dev)if (!xtr_ol->required)continue ; -if (!(vf->supported_rxdid &BIT (rxdid))) { +if (!(vf->supported_rxdid &RTE_BIT64 (rxdid))) {PMD_DRV_LOG (ERR ,"rxdid[%u] is not supported in hardware" , rxdid);
drivers/net/iavf/iavf_rxtx.c +1 -1
@@ -3915,7 +3915,7 @@ iavf_set_rx_function(struct rte_eth_dev *dev)PMD_DRV_LOG (NOTICE ,"request RXDID[%d] in Queue[%d] is legacy, " "set rx_pkt_burst as legacy for all queues" , rxq->rxdid, i); use_flex = false; - }else if (!(vf->supported_rxdid &BIT (rxq->rxdid))) { + }else if (!(vf->supported_rxdid &RTE_BIT64 (rxq->rxdid))) {PMD_DRV_LOG (NOTICE ,"request RXDID[%d] in Queue[%d] is not supported, " "set rx_pkt_burst as legacy for all queues" , rxq->rxdid, i); use_flex = false;
drivers/net/iavf/iavf_vchnl.c +1 -1
@@ -1265,7 +1265,7 @@ iavf_configure_queues(struct iavf_adapter *adapter,#ifndef RTE_LIBRTE_IAVF_16BYTE_RX_DESC if (vf->vf_res->vf_cap_flags &VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC ) { -if (vf->supported_rxdid &BIT (rxq[i]->rxdid)) { +if (vf->supported_rxdid &RTE_BIT64 (rxq[i]->rxdid)) { vc_qp->rxq.rxdid = rxq[i]->rxdid;PMD_DRV_LOG (NOTICE ,"request RXDID[%d] in Queue[%d]" , vc_qp->rxq.rxdid, i);
drivers/net/ice/base/meson.build +13 -6
@@ -31,18 +31,25 @@ sources = [ 'ice_vf_mbx.c', ] -error_cflags = [ - '-Wno-unused-but-set-variable', - '-Wno-unused-variable', - '-Wno-unused-parameter', -] +if is_ms_compiler + error_cflags = [ + '/wd4101', # unreferenced local variable + '/wd4334', # result of 32-bit shift implicitly converted to 64 bits + ] +else + error_cflags = [ + '-Wno-unused-but-set-variable', + '-Wno-unused-variable', + '-Wno-unused-parameter', + ] +endif # Bugzilla ID: 678 if (toolchain == 'gcc' and cc.version().version_compare('>=11.0.0')) error_cflags += ['-Wno-array-bounds'] endif -if is_windows and cc.get_id() != 'clang' +if is_windows and not is_ms_compiler and cc.get_id() != 'clang' cflags += ['-fno-asynchronous-unwind-tables'] endif
drivers/net/ice/ice_dcf_sched.c +1 -1
@@ -174,7 +174,7 @@ ice_dcf_node_param_check(struct ice_dcf_hw *hw, uint32_t node_id, }/* for non-leaf node */ -if (node_id >=8 * hw->num_vfs) { +if (node_id >= (uint32_t )(8 * hw->num_vfs)) {if (params->nonleaf.wfq_weight_mode) { error->type =RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE ;
drivers/net/ice/ice_ethdev.c +2 -2
@@ -2469,13 +2469,13 @@ ice_get_supported_rxdid(struct ice_hw *hw)uint32_t regval;int i; - supported_rxdid |=BIT (ICE_RXDID_LEGACY_1 ); + supported_rxdid |=RTE_BIT64 (ICE_RXDID_LEGACY_1 );for (i =ICE_RXDID_FLEX_NIC ; i <ICE_FLEX_DESC_RXDID_MAX_NUM ; i++) { regval =ICE_READ_REG (hw,GLFLXP_RXDID_FLAGS (i,0 ));if ((regval >>GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_S ) &GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_M ) - supported_rxdid |=BIT (i); + supported_rxdid |=RTE_BIT64 (i); }return supported_rxdid; }
drivers/net/ice/ice_rxtx.c +1 -1
@@ -399,7 +399,7 @@ ice_program_hw_rx_queue(struct ice_rx_queue *rxq)PMD_DRV_LOG (DEBUG ,"Port (%u) - Rx queue (%u) is set with RXDID : %u" , rxq->port_id, rxq->queue_id, rxdid); -if (!(pf->supported_rxdid &BIT (rxdid))) { +if (!(pf->supported_rxdid &RTE_BIT64 (rxdid))) {PMD_DRV_LOG (ERR ,"currently package doesn't support RXDID (%u)" , rxdid);return -EINVAL ;
drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
@@ -2722,7 +2722,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev)ixgbe_set_vf_rate_limit ( dev, vf, vfinfo[vf].tx_rate[idx], -1 << idx); +RTE_BIT64 (idx)); }ixgbe_restore_statistics_mapping (dev);
drivers/net/vmxnet3/vmxnet3_ethdev.h +3 -3
@@ -186,14 +186,14 @@ static inline uint8_t vmxnet3_get_ring_idx(struct vmxnet3_hw *hw, uint32 rqID) {return (rqID >= hw->num_rx_queues && - rqID <2 * hw->num_rx_queues) ?1 :0 ; + rqID < (uint32 )2 * hw->num_rx_queues) ?1 :0 ; }static inline bool vmxnet3_rx_data_ring (struct vmxnet3_hw *hw,uint32 rqID) { -return (rqID >=2 * hw->num_rx_queues && - rqID <3 * hw->num_rx_queues); +return (rqID >= (uint32 )2 * hw->num_rx_queues && + rqID < (uint32 )3 * hw->num_rx_queues); }/*
Signature · 1 line
2.47.0.vfs.0.3
Re: [PATCH v3] drivers/net: use 64-bit shift and avoid signed/unsigned mismatch
Quoted 11 lines · On Tue, 14 Jan 2025 13:05:02 -0800 Andre Muezerie…
This patch avoids warnings like the ones below emitted by MSVC:
1)
../drivers/net/ice/base/ice_flg_rd.c(71): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)2)
../drivers/net/ice/ice_dcf_sched.c(177): warning C4018: '>=':
signed/unsigned mismatch
Quoted 8 lines
The fix for (1) is to use 64-bit shifting when appropriate (according to what the result is used for).
The fix for (2) is to explicitly cast the variables used in the comparison.
Signed-off-by Andre Muezerie <[email protected]>---
Needs rebase, the Intel drivers got reorganized.
Re: [PATCH v3] drivers/net: use 64-bit shift and avoid signed/unsigned mismatch
Quoted 17 lines · Stephen Hemminger
Quoted 14 lines · On Tue, 14 Jan 2025 13:05:02 -0800 Andre Muezerie…
This patch avoids warnings like the ones below emitted by MSVC:
1)
../drivers/net/ice/base/ice_flg_rd.c(71): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)2)
../drivers/net/ice/ice_dcf_sched.c(177): warning C4018: '>=':
signed/unsigned mismatchThe fix for (1) is to use 64-bit shifting when appropriate (according to what the result is used for).
Quoted 7 lines
Quoted 5 lines
The fix for (2) is to explicitly cast the variables used in the comparison.
Signed-off-by Andre Muezerie <[email protected]>---
Needs rebase, the Intel drivers got reorganized.
Thanks for letting me know. I rebased and sent out the updated patch.
PATCH v4 1/1 drivers/net: use 64-bit shift and avoid signed/unsigned mismatch
In reply to Andre MuezerieThis patch avoids warnings like the ones below emitted by MSVC:
1)
../drivers/net/ice/base/ice_flg_rd.c(71): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
2)
../drivers/net/ice/ice_dcf_sched.c(177): warning C4018: '>=':
signed/unsigned mismatch
The fix for (1) is to use 64-bit shifting when appropriate (according to what the result is used for).
The fix for (2) is to explicitly cast the variables used in the comparison.
--- drivers/net/intel/i40e/i40e_ethdev.c | 22 +++++++++++----------- drivers/net/intel/iavf/iavf_ethdev.c | 2 +- drivers/net/intel/iavf/iavf_rxtx.c | 2 +- drivers/net/intel/iavf/iavf_vchnl.c | 2 +- drivers/net/intel/ice/base/meson.build | 19 +++++++++++++------ drivers/net/intel/ice/ice_dcf_sched.c | 2 +- drivers/net/intel/ice/ice_ethdev.c | 4 ++-- drivers/net/intel/ice/ice_rxtx.c | 2 +- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 2 +- drivers/net/vmxnet3/vmxnet3_ethdev.h | 6 +++--- 10 files changed, 35 insertions(+), 28 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +11 -11
@@ -3094,7 +3094,7 @@ i40e_stat_update_48_in_64(struct i40e_hw *hw, uint32_t hireg,/* enlarge the limitation when statistics counters overflowed */ if (offset_loaded) {if (I40E_RXTX_BYTES_L_48_BIT (*prev_stat) > *stat) - *stat += (uint64_t )1 <<I40E_48_BIT_WIDTH ; + *stat +=RTE_BIT64 (I40E_48_BIT_WIDTH ); *stat +=I40E_RXTX_BYTES_H_16_BIT (*prev_stat); } *prev_stat = *stat;
@@ -4494,7 +4494,7 @@ i40e_macaddr_remove(struct rte_eth_dev *dev, uint32_t index) pool_sel = dev->data->mac_pool_sel[index];for (i =0 ; i <sizeof (pool_sel) *CHAR_BIT ; i++) { -if (pool_sel & (1ULL << i)) { +if (pool_sel &RTE_BIT64 (i)) {if (i ==0 ) vsi = pf->main_vsi;else {
@@ -4630,7 +4630,7 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev,for (i =0 ; i < reta_size; i++) { idx = i /RTE_ETH_RETA_GROUP_SIZE ; shift = i %RTE_ETH_RETA_GROUP_SIZE ; -if (reta_conf[idx].mask & (1ULL << shift)) +if (reta_conf[idx].mask &RTE_BIT64 (shift)) lut[i] = reta_conf[idx].reta[shift]; } ret =i40e_set_rss_lut (pf->main_vsi, lut, reta_size);
@@ -4674,7 +4674,7 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev,for (i =0 ; i < reta_size; i++) { idx = i /RTE_ETH_RETA_GROUP_SIZE ; shift = i %RTE_ETH_RETA_GROUP_SIZE ; -if (reta_conf[idx].mask & (1ULL << shift)) +if (reta_conf[idx].mask &RTE_BIT64 (shift)) reta_conf[idx].reta[shift] = lut[i]; }
@@ -6712,7 +6712,7 @@ i40e_vmdq_setup(struct rte_eth_dev *dev) loop =sizeof (vmdq_conf->pool_map[0 ].pools) *CHAR_BIT ;for (i =0 ; i < vmdq_conf->nb_pool_maps; i++) {for (j =0 ; j < loop && j < pf->nb_cfg_vmdq_vsi; j++) { -if (vmdq_conf->pool_map[i].pools & (1UL << j)) { +if (vmdq_conf->pool_map[i].pools &RTE_BIT64 (j)) {PMD_INIT_LOG (INFO ,"Add vlan %u to vmdq pool %u" , vmdq_conf->pool_map[i].vlan_id, j);
@@ -6761,7 +6761,7 @@ i40e_stat_update_32(struct i40e_hw *hw, *stat = (uint64_t )(new_data - *offset); else *stat = (uint64_t )((new_data + - ((uint64_t )1 <<I40E_32_BIT_WIDTH )) - *offset); +RTE_BIT64 (I40E_32_BIT_WIDTH )) - *offset); } static void
@@ -6789,7 +6789,7 @@ i40e_stat_update_48(struct i40e_hw *hw, *stat = new_data - *offset; else *stat = (uint64_t )((new_data + - ((uint64_t )1 <<I40E_48_BIT_WIDTH )) - *offset); +RTE_BIT64 (I40E_48_BIT_WIDTH )) - *offset); *stat &=I40E_48_BIT_MASK ; }
@@ -7730,7 +7730,7 @@ i40e_config_hena(const struct i40e_adapter *adapter, uint64_t flags)return hena;for (i =RTE_ETH_FLOW_UNKNOWN +1 ; i <I40E_FLOW_TYPE_MAX ; i++) { -if (flags & (1ULL << i)) +if (flags &RTE_BIT64 (i)) hena |= adapter->pctypes_tbl[i]; }
@@ -7749,7 +7749,7 @@ i40e_parse_hena(const struct i40e_adapter *adapter, uint64_t flags)for (i =RTE_ETH_FLOW_UNKNOWN +1 ; i <I40E_FLOW_TYPE_MAX ; i++) {if (flags & adapter->pctypes_tbl[i]) - rss_hf |= (1ULL << i); + rss_hf |=RTE_BIT64 (i); }return rss_hf; }
@@ -10162,7 +10162,7 @@ i40e_flowtype_to_pctype(const struct i40e_adapter *adapter, uint16_t flow_type)if (flow_type <I40E_FLOW_TYPE_MAX ) { pctype_mask = adapter->pctypes_tbl[flow_type];for (i =I40E_FILTER_PCTYPE_MAX -1 ; i >0 ; i--) { -if (pctype_mask & (1ULL << i)) +if (pctype_mask &RTE_BIT64 (i))return (enum i40e_filter_pctype )i; } }
@@ -10174,7 +10174,7 @@ i40e_pctype_to_flowtype(const struct i40e_adapter *adapter, enum i40e_filter_pctype pctype) {uint16_t flowtype; -uint64_t pctype_mask =1ULL << pctype; +uint64_t pctype_mask =RTE_BIT64 (pctype);for (flowtype =RTE_ETH_FLOW_UNKNOWN +1 ; flowtype <I40E_FLOW_TYPE_MAX ; flowtype++) {
drivers/net/intel/iavf/iavf_ethdev.c +1 -1
@@ -2485,7 +2485,7 @@ iavf_init_proto_xtr(struct rte_eth_dev *dev)if (!xtr_ol->required)continue ; -if (!(vf->supported_rxdid &BIT (rxdid))) { +if (!(vf->supported_rxdid &RTE_BIT64 (rxdid))) {PMD_DRV_LOG (ERR ,"rxdid[%u] is not supported in hardware" , rxdid);
drivers/net/intel/iavf/iavf_rxtx.c +1 -1
@@ -3871,7 +3871,7 @@ iavf_set_rx_function(struct rte_eth_dev *dev)PMD_DRV_LOG (NOTICE ,"request RXDID[%d] in Queue[%d] is legacy, " "set rx_pkt_burst as legacy for all queues" , rxq->rxdid, i); use_flex = false; - }else if (!(vf->supported_rxdid &BIT (rxq->rxdid))) { + }else if (!(vf->supported_rxdid &RTE_BIT64 (rxq->rxdid))) {PMD_DRV_LOG (NOTICE ,"request RXDID[%d] in Queue[%d] is not supported, " "set rx_pkt_burst as legacy for all queues" , rxq->rxdid, i); use_flex = false;
drivers/net/intel/iavf/iavf_vchnl.c +1 -1
@@ -1263,7 +1263,7 @@ iavf_configure_queues(struct iavf_adapter *adapter,#ifndef RTE_LIBRTE_IAVF_16BYTE_RX_DESC if (vf->vf_res->vf_cap_flags &VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC ) { -if (vf->supported_rxdid &BIT (rxq[i]->rxdid)) { +if (vf->supported_rxdid &RTE_BIT64 (rxq[i]->rxdid)) { vc_qp->rxq.rxdid = rxq[i]->rxdid;PMD_DRV_LOG (NOTICE ,"request RXDID[%d] in Queue[%d]" , vc_qp->rxq.rxdid, i);
drivers/net/intel/ice/base/meson.build +13 -6
@@ -31,18 +31,25 @@ sources = [ 'ice_vf_mbx.c', ] -error_cflags = [ - '-Wno-unused-but-set-variable', - '-Wno-unused-variable', - '-Wno-unused-parameter', -] +if is_ms_compiler + error_cflags = [ + '/wd4101', # unreferenced local variable + '/wd4334', # result of 32-bit shift implicitly converted to 64 bits + ] +else + error_cflags = [ + '-Wno-unused-but-set-variable', + '-Wno-unused-variable', + '-Wno-unused-parameter', + ] +endif # Bugzilla ID: 678 if (toolchain == 'gcc' and cc.version().version_compare('>=11.0.0')) error_cflags += ['-Wno-array-bounds'] endif -if is_windows and cc.get_id() != 'clang' +if is_windows and not is_ms_compiler and cc.get_id() != 'clang' cflags += ['-fno-asynchronous-unwind-tables'] endif
drivers/net/intel/ice/ice_dcf_sched.c +1 -1
@@ -174,7 +174,7 @@ ice_dcf_node_param_check(struct ice_dcf_hw *hw, uint32_t node_id, }/* for non-leaf node */ -if (node_id >=8 * hw->num_vfs) { +if (node_id >= (uint32_t )(8 * hw->num_vfs)) {if (params->nonleaf.wfq_weight_mode) { error->type =RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE ;
drivers/net/intel/ice/ice_ethdev.c +2 -2
@@ -2469,13 +2469,13 @@ ice_get_supported_rxdid(struct ice_hw *hw)uint32_t regval;int i; - supported_rxdid |=BIT (ICE_RXDID_LEGACY_1 ); + supported_rxdid |=RTE_BIT64 (ICE_RXDID_LEGACY_1 );for (i =ICE_RXDID_FLEX_NIC ; i <ICE_FLEX_DESC_RXDID_MAX_NUM ; i++) { regval =ICE_READ_REG (hw,GLFLXP_RXDID_FLAGS (i,0 ));if ((regval >>GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_S ) &GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_M ) - supported_rxdid |=BIT (i); + supported_rxdid |=RTE_BIT64 (i); }return supported_rxdid; }
drivers/net/intel/ice/ice_rxtx.c +1 -1
@@ -399,7 +399,7 @@ ice_program_hw_rx_queue(struct ice_rx_queue *rxq)PMD_DRV_LOG (DEBUG ,"Port (%u) - Rx queue (%u) is set with RXDID : %u" , rxq->port_id, rxq->queue_id, rxdid); -if (!(pf->supported_rxdid &BIT (rxdid))) { +if (!(pf->supported_rxdid &RTE_BIT64 (rxdid))) {PMD_DRV_LOG (ERR ,"currently package doesn't support RXDID (%u)" , rxdid);return -EINVAL ;
drivers/net/intel/ixgbe/ixgbe_ethdev.c +1 -1
@@ -2722,7 +2722,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev)ixgbe_set_vf_rate_limit ( dev, vf, vfinfo[vf].tx_rate[idx], -1 << idx); +RTE_BIT64 (idx)); }ixgbe_restore_statistics_mapping (dev);
drivers/net/vmxnet3/vmxnet3_ethdev.h +3 -3
@@ -186,14 +186,14 @@ static inline uint8_t vmxnet3_get_ring_idx(struct vmxnet3_hw *hw, uint32 rqID) {return (rqID >= hw->num_rx_queues && - rqID <2 * hw->num_rx_queues) ?1 :0 ; + rqID < (uint32 )2 * hw->num_rx_queues) ?1 :0 ; }static inline bool vmxnet3_rx_data_ring (struct vmxnet3_hw *hw,uint32 rqID) { -return (rqID >=2 * hw->num_rx_queues && - rqID <3 * hw->num_rx_queues); +return (rqID >= (uint32 )2 * hw->num_rx_queues && + rqID < (uint32 )3 * hw->num_rx_queues); }/*
Signature · 1 line
2.47.2.vfs.0.1
Re: [PATCH v4] drivers/net: use 64-bit shift and avoid signed/unsigned mismatch
Quoted 189 lines · Andre Muezerie
This patch avoids warnings like the ones below emitted by MSVC:
1)
../drivers/net/ice/base/ice_flg_rd.c(71): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)2)
../drivers/net/ice/ice_dcf_sched.c(177): warning C4018: '>=':
signed/unsigned mismatchThe fix for (1) is to use 64-bit shifting when appropriate (according to what the result is used for).
The fix for (2) is to explicitly cast the variables used in the comparison.
Signed-off-by Andre Muezerie <[email protected]>--- drivers/net/intel/i40e/i40e_ethdev.c | 22 +++++++++++----------- drivers/net/intel/iavf/iavf_ethdev.c | 2 +- drivers/net/intel/iavf/iavf_rxtx.c | 2 +- drivers/net/intel/iavf/iavf_vchnl.c | 2 +- drivers/net/intel/ice/base/meson.build | 19 +++++++++++++------ drivers/net/intel/ice/ice_dcf_sched.c | 2 +- drivers/net/intel/ice/ice_ethdev.c | 4 ++-- drivers/net/intel/ice/ice_rxtx.c | 2 +- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 2 +- drivers/net/vmxnet3/vmxnet3_ethdev.h | 6 +++--- 10 files changed, 35 insertions(+), 28 deletions(-)drivers/net/intel/i40e/i40e_ethdev.c +11
-11@@ -3094,7 +3094,7 @@ i40e_stat_update_48_in_64(struct i40e_hw *hw, uint32_t hireg,/* enlarge the limitation when statistics counters overflowed */ if (offset_loaded) {if (I40E_RXTX_BYTES_L_48_BIT (*prev_stat) > *stat) - *stat += (uint64_t )1 <<I40E_48_BIT_WIDTH ; + *stat +=RTE_BIT64 (I40E_48_BIT_WIDTH ); *stat +=I40E_RXTX_BYTES_H_16_BIT (*prev_stat); } *prev_stat = *stat;@@ -4494,7 +4494,7 @@ i40e_macaddr_remove(struct rte_eth_dev *dev, uint32_t index) pool_sel = dev->data->mac_pool_sel[index];for (i =0 ; i <sizeof (pool_sel) *CHAR_BIT ; i++) { -if (pool_sel & (1ULL << i)) { +if (pool_sel &RTE_BIT64 (i)) {if (i ==0 ) vsi = pf->main_vsi;else {@@ -4630,7 +4630,7 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev,for (i =0 ; i < reta_size; i++) { idx = i /RTE_ETH_RETA_GROUP_SIZE ; shift = i %RTE_ETH_RETA_GROUP_SIZE ; -if (reta_conf[idx].mask & (1ULL << shift)) +if (reta_conf[idx].mask &RTE_BIT64 (shift)) lut[i] = reta_conf[idx].reta[shift]; } ret =i40e_set_rss_lut (pf->main_vsi, lut, reta_size);@@ -4674,7 +4674,7 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev,for (i =0 ; i < reta_size; i++) { idx = i /RTE_ETH_RETA_GROUP_SIZE ; shift = i %RTE_ETH_RETA_GROUP_SIZE ; -if (reta_conf[idx].mask & (1ULL << shift)) +if (reta_conf[idx].mask &RTE_BIT64 (shift)) reta_conf[idx].reta[shift] = lut[i]; }@@ -6712,7 +6712,7 @@ i40e_vmdq_setup(struct rte_eth_dev *dev) loop =sizeof (vmdq_conf->pool_map[0 ].pools) *CHAR_BIT ;for (i =0 ; i < vmdq_conf->nb_pool_maps; i++) {for (j =0 ; j < loop && j < pf->nb_cfg_vmdq_vsi; j++) { -if (vmdq_conf->pool_map[i].pools & (1UL << j)) { +if (vmdq_conf->pool_map[i].pools &RTE_BIT64 (j)) {PMD_INIT_LOG (INFO ,"Add vlan %u to vmdq pool %u" , vmdq_conf->pool_map[i].vlan_id, j);@@ -6761,7 +6761,7 @@ i40e_stat_update_32(struct i40e_hw *hw, *stat = (uint64_t )(new_data - *offset); else *stat = (uint64_t )((new_data + - ((uint64_t )1 <<I40E_32_BIT_WIDTH )) - *offset); +RTE_BIT64 (I40E_32_BIT_WIDTH )) - *offset); } static void@@ -6789,7 +6789,7 @@ i40e_stat_update_48(struct i40e_hw *hw, *stat = new_data - *offset; else *stat = (uint64_t )((new_data + - ((uint64_t )1 <<I40E_48_BIT_WIDTH )) - *offset); +RTE_BIT64 (I40E_48_BIT_WIDTH )) - *offset); *stat &=I40E_48_BIT_MASK ; }@@ -7730,7 +7730,7 @@ i40e_config_hena(const struct i40e_adapter *adapter, uint64_t flags)return hena;for (i =RTE_ETH_FLOW_UNKNOWN +1 ; i <I40E_FLOW_TYPE_MAX ; i++) { -if (flags & (1ULL << i)) +if (flags &RTE_BIT64 (i)) hena |= adapter->pctypes_tbl[i]; }@@ -7749,7 +7749,7 @@ i40e_parse_hena(const struct i40e_adapter *adapter, uint64_t flags)for (i =RTE_ETH_FLOW_UNKNOWN +1 ; i <I40E_FLOW_TYPE_MAX ; i++) {if (flags & adapter->pctypes_tbl[i]) - rss_hf |= (1ULL << i); + rss_hf |=RTE_BIT64 (i); }return rss_hf; }@@ -10162,7 +10162,7 @@ i40e_flowtype_to_pctype(const struct i40e_adapter *adapter, uint16_t flow_type)if (flow_type <I40E_FLOW_TYPE_MAX ) { pctype_mask = adapter->pctypes_tbl[flow_type];for (i =I40E_FILTER_PCTYPE_MAX -1 ; i >0 ; i--) { -if (pctype_mask & (1ULL << i)) +if (pctype_mask &RTE_BIT64 (i))return (enum i40e_filter_pctype )i; } }@@ -10174,7 +10174,7 @@ i40e_pctype_to_flowtype(const struct i40e_adapter *adapter, enum i40e_filter_pctype pctype) {uint16_t flowtype; -uint64_t pctype_mask =1ULL << pctype; +uint64_t pctype_mask =RTE_BIT64 (pctype);for (flowtype =RTE_ETH_FLOW_UNKNOWN +1 ; flowtype <I40E_FLOW_TYPE_MAX ; flowtype++) {drivers/net/intel/iavf/iavf_ethdev.c +1
-1@@ -2485,7 +2485,7 @@ iavf_init_proto_xtr(struct rte_eth_dev *dev)if (!xtr_ol->required)continue ; -if (!(vf->supported_rxdid &BIT (rxdid))) { +if (!(vf->supported_rxdid &RTE_BIT64 (rxdid))) {PMD_DRV_LOG (ERR ,"rxdid[%u] is not supported in hardware" , rxdid);drivers/net/intel/iavf/iavf_rxtx.c +1
-1@@ -3871,7 +3871,7 @@ iavf_set_rx_function(struct rte_eth_dev *dev)PMD_DRV_LOG (NOTICE ,"request RXDID[%d] in Queue[%d] is legacy, " "set rx_pkt_burst as legacy for all queues" , rxq->rxdid, i); use_flex = false; - }else if (!(vf->supported_rxdid &BIT (rxq->rxdid))) { + }else if (!(vf->supported_rxdid &RTE_BIT64 (rxq->rxdid))) {PMD_DRV_LOG (NOTICE ,"request RXDID[%d] in Queue[%d] is not supported, " "set rx_pkt_burst as legacy for all queues" , rxq->rxdid, i); use_flex = false;drivers/net/intel/iavf/iavf_vchnl.c +1
-1@@ -1263,7 +1263,7 @@ iavf_configure_queues(struct iavf_adapter *adapter,#ifndef RTE_LIBRTE_IAVF_16BYTE_RX_DESC if (vf->vf_res->vf_cap_flags &VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC ) { -if (vf->supported_rxdid &BIT (rxq[i]->rxdid)) { +if (vf->supported_rxdid &RTE_BIT64 (rxq[i]->rxdid)) { vc_qp->rxq.rxdid = rxq[i]->rxdid;PMD_DRV_LOG (NOTICE ,"request RXDID[%d] in Queue[%d]" , vc_qp->rxq.rxdid, i);drivers/net/intel/ice/base/meson.build +3
-5@@ -31,18 +31,25 @@ sources = [ 'ice_vf_mbx.c', ] -error_cflags = [ - '-Wno-unused-but-set-variable', - '-Wno-unused-variable', - '-Wno-unused-parameter', -] +if is_ms_compiler + error_cflags = [ + '/wd4101', # unreferenced local variable
drivers/net/intel/ice/base/meson.build sources = [ · line 46
Quoted 10 lines
drivers/net/intel/ice/base/meson.build +9
-0+ '/wd4334', # result of 32-bit shift implicitly converted to 64 bits + ] +else + error_cflags = [ + '-Wno-unused-but-set-variable', + '-Wno-unused-variable', + '-Wno-unused-parameter', + ] +endif
Do we actually need these if-else blocks here? The way
the code is structured is that we check if the flags work to the current compiler and use only those that are relevant. Therefore, we should just be able to have a list of error flags and leave meson to filter out the incorrect ones.
drivers/net/intel/ice/base/meson.build sources = [ · line 52
Quoted 7 lines
drivers/net/intel/ice/base/meson.build +1
-1# Bugzilla ID: 678 if (toolchain == 'gcc' and cc.version().version_compare('>=11.0.0')) error_cflags += ['-Wno-array-bounds'] endif -if is_windows and cc.get_id() != 'clang' +if is_windows and not is_ms_compiler and cc.get_id() != 'clang'
Are there other supported compiler options for windows other than MSVC and clang? For what compiler are we adding this flag?
Quoted 67 lines
drivers/net/intel/ice/base/meson.build +0
-0cflags += ['-fno-asynchronous-unwind-tables'] endifdrivers/net/intel/ice/ice_dcf_sched.c +1
-1@@ -174,7 +174,7 @@ ice_dcf_node_param_check(struct ice_dcf_hw *hw, uint32_t node_id, }/* for non-leaf node */ -if (node_id >=8 * hw->num_vfs) { +if (node_id >= (uint32_t )(8 * hw->num_vfs)) {if (params->nonleaf.wfq_weight_mode) { error->type =RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE ;drivers/net/intel/ice/ice_ethdev.c +2
-2@@ -2469,13 +2469,13 @@ ice_get_supported_rxdid(struct ice_hw *hw)uint32_t regval;int i; - supported_rxdid |=BIT (ICE_RXDID_LEGACY_1 ); + supported_rxdid |=RTE_BIT64 (ICE_RXDID_LEGACY_1 );for (i =ICE_RXDID_FLEX_NIC ; i <ICE_FLEX_DESC_RXDID_MAX_NUM ; i++) { regval =ICE_READ_REG (hw,GLFLXP_RXDID_FLAGS (i,0 ));if ((regval >>GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_S ) &GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_M ) - supported_rxdid |=BIT (i); + supported_rxdid |=RTE_BIT64 (i); }return supported_rxdid; }drivers/net/intel/ice/ice_rxtx.c +1
-1@@ -399,7 +399,7 @@ ice_program_hw_rx_queue(struct ice_rx_queue *rxq)PMD_DRV_LOG (DEBUG ,"Port (%u) - Rx queue (%u) is set with RXDID : %u" , rxq->port_id, rxq->queue_id, rxdid); -if (!(pf->supported_rxdid &BIT (rxdid))) { +if (!(pf->supported_rxdid &RTE_BIT64 (rxdid))) {PMD_DRV_LOG (ERR ,"currently package doesn't support RXDID (%u)" , rxdid);return -EINVAL ;drivers/net/intel/ixgbe/ixgbe_ethdev.c +1
-1@@ -2722,7 +2722,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev)ixgbe_set_vf_rate_limit ( dev, vf, vfinfo[vf].tx_rate[idx], -1 << idx); +RTE_BIT64 (idx)); }ixgbe_restore_statistics_mapping (dev);drivers/net/vmxnet3/vmxnet3_ethdev.h +0
-0
drivers/net/vmxnet3/vmxnet3_ethdev.h static inline uint8_t · line 189
Quoted 5 lines
drivers/net/vmxnet3/vmxnet3_ethdev.h +1
-1@@ -186,14 +186,14 @@ static inline uint8_t vmxnet3_get_ring_idx(struct vmxnet3_hw *hw, uint32 rqID) {return (rqID >= hw->num_rx_queues && - rqID <2 * hw->num_rx_queues) ?1 :0 ; + rqID < (uint32 )2 * hw->num_rx_queues) ?1 :0 ;
Why uint32 rather than uint32_t which are the normal types we use in DPDK? Could this also be simplified to just 2U?
Quoted 15 lines
drivers/net/vmxnet3/vmxnet3_ethdev.h +2
-2}static inline bool vmxnet3_rx_data_ring (struct vmxnet3_hw *hw,uint32 rqID) { -return (rqID >=2 * hw->num_rx_queues && - rqID <3 * hw->num_rx_queues); +return (rqID >= (uint32 )2 * hw->num_rx_queues && + rqID < (uint32 )3 * hw->num_rx_queues); }/* Signature · 1 line
2.47.2.vfs.0.1
Re: [PATCH v4] drivers/net: use 64-bit shift and avoid signed/unsigned mismatch
Quoted 198 lines · Bruce Richardson
Quoted 197 lines · Andre Muezerie
This patch avoids warnings like the ones below emitted by MSVC:
1)
../drivers/net/ice/base/ice_flg_rd.c(71): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)2)
../drivers/net/ice/ice_dcf_sched.c(177): warning C4018: '>=':
signed/unsigned mismatchThe fix for (1) is to use 64-bit shifting when appropriate (according to what the result is used for).
The fix for (2) is to explicitly cast the variables used in the comparison.
Signed-off-by Andre Muezerie <[email protected]>--- drivers/net/intel/i40e/i40e_ethdev.c | 22 +++++++++++----------- drivers/net/intel/iavf/iavf_ethdev.c | 2 +- drivers/net/intel/iavf/iavf_rxtx.c | 2 +- drivers/net/intel/iavf/iavf_vchnl.c | 2 +- drivers/net/intel/ice/base/meson.build | 19 +++++++++++++------ drivers/net/intel/ice/ice_dcf_sched.c | 2 +- drivers/net/intel/ice/ice_ethdev.c | 4 ++-- drivers/net/intel/ice/ice_rxtx.c | 2 +- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 2 +- drivers/net/vmxnet3/vmxnet3_ethdev.h | 6 +++--- 10 files changed, 35 insertions(+), 28 deletions(-)drivers/net/intel/i40e/i40e_ethdev.c +11
-11@@ -3094,7 +3094,7 @@ i40e_stat_update_48_in_64(struct i40e_hw *hw, uint32_t hireg,/* enlarge the limitation when statistics counters overflowed */ if (offset_loaded) {if (I40E_RXTX_BYTES_L_48_BIT (*prev_stat) > *stat) - *stat += (uint64_t )1 <<I40E_48_BIT_WIDTH ; + *stat +=RTE_BIT64 (I40E_48_BIT_WIDTH ); *stat +=I40E_RXTX_BYTES_H_16_BIT (*prev_stat); } *prev_stat = *stat;@@ -4494,7 +4494,7 @@ i40e_macaddr_remove(struct rte_eth_dev *dev, uint32_t index) pool_sel = dev->data->mac_pool_sel[index];for (i =0 ; i <sizeof (pool_sel) *CHAR_BIT ; i++) { -if (pool_sel & (1ULL << i)) { +if (pool_sel &RTE_BIT64 (i)) {if (i ==0 ) vsi = pf->main_vsi;else {@@ -4630,7 +4630,7 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev,for (i =0 ; i < reta_size; i++) { idx = i /RTE_ETH_RETA_GROUP_SIZE ; shift = i %RTE_ETH_RETA_GROUP_SIZE ; -if (reta_conf[idx].mask & (1ULL << shift)) +if (reta_conf[idx].mask &RTE_BIT64 (shift)) lut[i] = reta_conf[idx].reta[shift]; } ret =i40e_set_rss_lut (pf->main_vsi, lut, reta_size);@@ -4674,7 +4674,7 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev,for (i =0 ; i < reta_size; i++) { idx = i /RTE_ETH_RETA_GROUP_SIZE ; shift = i %RTE_ETH_RETA_GROUP_SIZE ; -if (reta_conf[idx].mask & (1ULL << shift)) +if (reta_conf[idx].mask &RTE_BIT64 (shift)) reta_conf[idx].reta[shift] = lut[i]; }@@ -6712,7 +6712,7 @@ i40e_vmdq_setup(struct rte_eth_dev *dev) loop =sizeof (vmdq_conf->pool_map[0 ].pools) *CHAR_BIT ;for (i =0 ; i < vmdq_conf->nb_pool_maps; i++) {for (j =0 ; j < loop && j < pf->nb_cfg_vmdq_vsi; j++) { -if (vmdq_conf->pool_map[i].pools & (1UL << j)) { +if (vmdq_conf->pool_map[i].pools &RTE_BIT64 (j)) {PMD_INIT_LOG (INFO ,"Add vlan %u to vmdq pool %u" , vmdq_conf->pool_map[i].vlan_id, j);@@ -6761,7 +6761,7 @@ i40e_stat_update_32(struct i40e_hw *hw, *stat = (uint64_t )(new_data - *offset); else *stat = (uint64_t )((new_data + - ((uint64_t )1 <<I40E_32_BIT_WIDTH )) - *offset); +RTE_BIT64 (I40E_32_BIT_WIDTH )) - *offset); } static void@@ -6789,7 +6789,7 @@ i40e_stat_update_48(struct i40e_hw *hw, *stat = new_data - *offset; else *stat = (uint64_t )((new_data + - ((uint64_t )1 <<I40E_48_BIT_WIDTH )) - *offset); +RTE_BIT64 (I40E_48_BIT_WIDTH )) - *offset); *stat &=I40E_48_BIT_MASK ; }@@ -7730,7 +7730,7 @@ i40e_config_hena(const struct i40e_adapter *adapter, uint64_t flags)return hena;for (i =RTE_ETH_FLOW_UNKNOWN +1 ; i <I40E_FLOW_TYPE_MAX ; i++) { -if (flags & (1ULL << i)) +if (flags &RTE_BIT64 (i)) hena |= adapter->pctypes_tbl[i]; }@@ -7749,7 +7749,7 @@ i40e_parse_hena(const struct i40e_adapter *adapter, uint64_t flags)for (i =RTE_ETH_FLOW_UNKNOWN +1 ; i <I40E_FLOW_TYPE_MAX ; i++) {if (flags & adapter->pctypes_tbl[i]) - rss_hf |= (1ULL << i); + rss_hf |=RTE_BIT64 (i); }return rss_hf; }@@ -10162,7 +10162,7 @@ i40e_flowtype_to_pctype(const struct i40e_adapter *adapter, uint16_t flow_type)if (flow_type <I40E_FLOW_TYPE_MAX ) { pctype_mask = adapter->pctypes_tbl[flow_type];for (i =I40E_FILTER_PCTYPE_MAX -1 ; i >0 ; i--) { -if (pctype_mask & (1ULL << i)) +if (pctype_mask &RTE_BIT64 (i))return (enum i40e_filter_pctype )i; } }@@ -10174,7 +10174,7 @@ i40e_pctype_to_flowtype(const struct i40e_adapter *adapter, enum i40e_filter_pctype pctype) {uint16_t flowtype; -uint64_t pctype_mask =1ULL << pctype; +uint64_t pctype_mask =RTE_BIT64 (pctype);for (flowtype =RTE_ETH_FLOW_UNKNOWN +1 ; flowtype <I40E_FLOW_TYPE_MAX ; flowtype++) {drivers/net/intel/iavf/iavf_ethdev.c +1
-1@@ -2485,7 +2485,7 @@ iavf_init_proto_xtr(struct rte_eth_dev *dev)if (!xtr_ol->required)continue ; -if (!(vf->supported_rxdid &BIT (rxdid))) { +if (!(vf->supported_rxdid &RTE_BIT64 (rxdid))) {PMD_DRV_LOG (ERR ,"rxdid[%u] is not supported in hardware" , rxdid);drivers/net/intel/iavf/iavf_rxtx.c +1
-1@@ -3871,7 +3871,7 @@ iavf_set_rx_function(struct rte_eth_dev *dev)PMD_DRV_LOG (NOTICE ,"request RXDID[%d] in Queue[%d] is legacy, " "set rx_pkt_burst as legacy for all queues" , rxq->rxdid, i); use_flex = false; - }else if (!(vf->supported_rxdid &BIT (rxq->rxdid))) { + }else if (!(vf->supported_rxdid &RTE_BIT64 (rxq->rxdid))) {PMD_DRV_LOG (NOTICE ,"request RXDID[%d] in Queue[%d] is not supported, " "set rx_pkt_burst as legacy for all queues" , rxq->rxdid, i); use_flex = false;drivers/net/intel/iavf/iavf_vchnl.c +1
-1@@ -1263,7 +1263,7 @@ iavf_configure_queues(struct iavf_adapter *adapter,#ifndef RTE_LIBRTE_IAVF_16BYTE_RX_DESC if (vf->vf_res->vf_cap_flags &VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC ) { -if (vf->supported_rxdid &BIT (rxq[i]->rxdid)) { +if (vf->supported_rxdid &RTE_BIT64 (rxq[i]->rxdid)) { vc_qp->rxq.rxdid = rxq[i]->rxdid;PMD_DRV_LOG (NOTICE ,"request RXDID[%d] in Queue[%d]" , vc_qp->rxq.rxdid, i);drivers/net/intel/ice/base/meson.build +11
-5@@ -31,18 +31,25 @@ sources = [ 'ice_vf_mbx.c', ] -error_cflags = [ - '-Wno-unused-but-set-variable', - '-Wno-unused-variable', - '-Wno-unused-parameter', -] +if is_ms_compiler + error_cflags = [ + '/wd4101', # unreferenced local variable + '/wd4334', # result of 32-bit shift implicitly converted to 64 bits + ] +else + error_cflags = [ + '-Wno-unused-but-set-variable', + '-Wno-unused-variable', + '-Wno-unused-parameter', + ]
Quoted 8 lines
drivers/net/intel/ice/base/meson.build sources = [ · line 46
Quoted 2 lines
drivers/net/intel/ice/base/meson.build +1
-0+endifDo we actually need these if-else blocks here? The way
the code is structured is that we check if the flags work to the current compiler and use only those that are relevant. Therefore, we should just be able to have a list of error flags and leave meson to filter out the incorrect ones.
Both approaches work. I personally find the if-else approach in this case a little more readable as it makes clear to which compiler the flags apply (considering that there might be multiple flags with the same purpose, one for each compiler). But I'm open to updating the patch following your suggestion.
Quoted 11 lines
drivers/net/intel/ice/base/meson.build sources = [ · line 52
Quoted 8 lines
drivers/net/intel/ice/base/meson.build +1
-1# Bugzilla ID: 678 if (toolchain == 'gcc' and cc.version().version_compare('>=11.0.0')) error_cflags += ['-Wno-array-bounds'] endif -if is_windows and cc.get_id() != 'clang' +if is_windows and not is_ms_compiler and cc.get_id() != 'clang'Are there other supported compiler options for windows other than MSVC and clang? For what compiler are we adding this flag?
Yes, MinGW-w64 is also supported on Windows, so effectively this flag applies to this compiler.
https://doc.dpdk.org/guides/windows_gsg/build_dpdk.html
Note that this flag was already there. I just changed the expression so that it is not used with msvc.
Quoted 62 lines
Quoted 62 lines
drivers/net/intel/ice/base/meson.build +0
-0cflags += ['-fno-asynchronous-unwind-tables'] endifdrivers/net/intel/ice/ice_dcf_sched.c +1
-1@@ -174,7 +174,7 @@ ice_dcf_node_param_check(struct ice_dcf_hw *hw, uint32_t node_id, }/* for non-leaf node */ -if (node_id >=8 * hw->num_vfs) { +if (node_id >= (uint32_t )(8 * hw->num_vfs)) {if (params->nonleaf.wfq_weight_mode) { error->type =RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE ;drivers/net/intel/ice/ice_ethdev.c +2
-2@@ -2469,13 +2469,13 @@ ice_get_supported_rxdid(struct ice_hw *hw)uint32_t regval;int i; - supported_rxdid |=BIT (ICE_RXDID_LEGACY_1 ); + supported_rxdid |=RTE_BIT64 (ICE_RXDID_LEGACY_1 );for (i =ICE_RXDID_FLEX_NIC ; i <ICE_FLEX_DESC_RXDID_MAX_NUM ; i++) { regval =ICE_READ_REG (hw,GLFLXP_RXDID_FLAGS (i,0 ));if ((regval >>GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_S ) &GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_M ) - supported_rxdid |=BIT (i); + supported_rxdid |=RTE_BIT64 (i); }return supported_rxdid; }drivers/net/intel/ice/ice_rxtx.c +1
-1@@ -399,7 +399,7 @@ ice_program_hw_rx_queue(struct ice_rx_queue *rxq)PMD_DRV_LOG (DEBUG ,"Port (%u) - Rx queue (%u) is set with RXDID : %u" , rxq->port_id, rxq->queue_id, rxdid); -if (!(pf->supported_rxdid &BIT (rxdid))) { +if (!(pf->supported_rxdid &RTE_BIT64 (rxdid))) {PMD_DRV_LOG (ERR ,"currently package doesn't support RXDID (%u)" , rxdid);return -EINVAL ;drivers/net/intel/ixgbe/ixgbe_ethdev.c +1
-1@@ -2722,7 +2722,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev)ixgbe_set_vf_rate_limit ( dev, vf, vfinfo[vf].tx_rate[idx], -1 << idx); +RTE_BIT64 (idx)); }
Quoted 14 lines
drivers/net/vmxnet3/vmxnet3_ethdev.h static inline uint8_t · line 189
Quoted 11 lines
drivers/net/intel/ixgbe/ixgbe_ethdev.c +0
-0ixgbe_restore_statistics_mapping (dev);drivers/net/vmxnet3/vmxnet3_ethdev.h +1
-1@@ -186,14 +186,14 @@ static inline uint8_t vmxnet3_get_ring_idx(struct vmxnet3_hw *hw, uint32 rqID) {return (rqID >= hw->num_rx_queues && - rqID <2 * hw->num_rx_queues) ?1 :0 ; + rqID < (uint32 )2 * hw->num_rx_queues) ?1 :0 ;Why uint32 rather than
uint32_twhich are the normal types we use in DPDK? Could this also be simplified to just 2U?
Well, I had just used the same type used for rqID (a few lines above). BTW, there are more than 100 hits in DPDK when searching for "uint32 ". I'm happy to use 2U instead though.
Quoted 16 lines
Quoted 16 lines
drivers/net/vmxnet3/vmxnet3_ethdev.h +2
-2}static inline bool vmxnet3_rx_data_ring (struct vmxnet3_hw *hw,uint32 rqID) { -return (rqID >=2 * hw->num_rx_queues && - rqID <3 * hw->num_rx_queues); +return (rqID >= (uint32 )2 * hw->num_rx_queues && + rqID < (uint32 )3 * hw->num_rx_queues); }/* Signature · 1 line
2.47.2.vfs.0.1
Re: [PATCH v4] drivers/net: use 64-bit shift and avoid signed/unsigned mismatch
Quoted 33 lines · Andre Muezerie
Quoted 32 lines · Bruce Richardson
Quoted 31 lines · Andre Muezerie
This patch avoids warnings like the ones below emitted by MSVC:
1)
../drivers/net/ice/base/ice_flg_rd.c(71): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)2)
../drivers/net/ice/ice_dcf_sched.c(177): warning C4018: '>=':
signed/unsigned mismatchThe fix for (1) is to use 64-bit shifting when appropriate (according to what the result is used for).
The fix for (2) is to explicitly cast the variables used in the comparison.
Signed-off-by Andre Muezerie <[email protected]>--- drivers/net/intel/i40e/i40e_ethdev.c | 22 +++++++++++----------- drivers/net/intel/iavf/iavf_ethdev.c | 2 +- drivers/net/intel/iavf/iavf_rxtx.c | 2 +- drivers/net/intel/iavf/iavf_vchnl.c | 2 +- drivers/net/intel/ice/base/meson.build | 19 +++++++++++++------ drivers/net/intel/ice/ice_dcf_sched.c | 2 +- drivers/net/intel/ice/ice_ethdev.c | 4 ++-- drivers/net/intel/ice/ice_rxtx.c | 2 +- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 2 +- drivers/net/vmxnet3/vmxnet3_ethdev.h | 6 +++--- 10 files changed, 35 insertions(+), 28 deletions(-)
<snip>
Quoted 33 lines
Quoted 24 lines
Quoted 24 lines
drivers/net/intel/ice/base/meson.build +11
-5@@ -31,18 +31,25 @@ sources = [ 'ice_vf_mbx.c', ] -error_cflags = [ - '-Wno-unused-but-set-variable', - '-Wno-unused-variable', - '-Wno-unused-parameter', -] +if is_ms_compiler + error_cflags = [ + '/wd4101', # unreferenced local variable + '/wd4334', # result of 32-bit shift implicitly converted to 64 bits + ] +else + error_cflags = [ + '-Wno-unused-but-set-variable', + '-Wno-unused-variable', + '-Wno-unused-parameter', + ]Quoted 8 lines
drivers/net/intel/ice/base/meson.build sources = [ · line 46
Quoted 2 lines
drivers/net/intel/ice/base/meson.build +1
-0+endifDo we actually need these if-else blocks here? The way
the code is structured is that we check if the flags work to the current compiler and use only those that are relevant. Therefore, we should just be able to have a list of error flags and leave meson to filter out the incorrect ones.
Quoted 5 lines
Both approaches work. I personally find the if-else approach in this case a little more readable as it makes clear to which compiler the flags apply (considering that there might be multiple flags with the same purpose, one for each compiler). But I'm open to updating the patch following your suggestion.
If you find it more readable, ok to keep as-is.
Quoted 12 lines
Quoted 11 lines
drivers/net/intel/ice/base/meson.build sources = [ · line 52
Quoted 8 lines
drivers/net/intel/ice/base/meson.build +1
-1# Bugzilla ID: 678 if (toolchain == 'gcc' and cc.version().version_compare('>=11.0.0')) error_cflags += ['-Wno-array-bounds'] endif -if is_windows and cc.get_id() != 'clang' +if is_windows and not is_ms_compiler and cc.get_id() != 'clang'Are there other supported compiler options for windows other than MSVC and clang? For what compiler are we adding this flag?
Quoted 4 lines
Yes, MinGW-w64 is also supported on Windows, so effectively this flag applies to this compiler.
https://doc.dpdk.org/guides/windows_gsg/build_dpdk.html
Note that this flag was already there. I just changed the expression so that it is not used with msvc.
Ok, thanks for clarifying.
Do we have a flag or check for identifying MinGW, because if we do that may be clearer in the check.
Quoted 77 lines
Quoted 62 lines
Quoted 62 lines
drivers/net/intel/ice/base/meson.build +0
-0cflags += ['-fno-asynchronous-unwind-tables'] endifdrivers/net/intel/ice/ice_dcf_sched.c +1
-1@@ -174,7 +174,7 @@ ice_dcf_node_param_check(struct ice_dcf_hw *hw, uint32_t node_id, }/* for non-leaf node */ -if (node_id >=8 * hw->num_vfs) { +if (node_id >= (uint32_t )(8 * hw->num_vfs)) {if (params->nonleaf.wfq_weight_mode) { error->type =RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE ;drivers/net/intel/ice/ice_ethdev.c +2
-2@@ -2469,13 +2469,13 @@ ice_get_supported_rxdid(struct ice_hw *hw)uint32_t regval;int i; - supported_rxdid |=BIT (ICE_RXDID_LEGACY_1 ); + supported_rxdid |=RTE_BIT64 (ICE_RXDID_LEGACY_1 );for (i =ICE_RXDID_FLEX_NIC ; i <ICE_FLEX_DESC_RXDID_MAX_NUM ; i++) { regval =ICE_READ_REG (hw,GLFLXP_RXDID_FLAGS (i,0 ));if ((regval >>GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_S ) &GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_M ) - supported_rxdid |=BIT (i); + supported_rxdid |=RTE_BIT64 (i); }return supported_rxdid; }drivers/net/intel/ice/ice_rxtx.c +1
-1@@ -399,7 +399,7 @@ ice_program_hw_rx_queue(struct ice_rx_queue *rxq)PMD_DRV_LOG (DEBUG ,"Port (%u) - Rx queue (%u) is set with RXDID : %u" , rxq->port_id, rxq->queue_id, rxdid); -if (!(pf->supported_rxdid &BIT (rxdid))) { +if (!(pf->supported_rxdid &RTE_BIT64 (rxdid))) {PMD_DRV_LOG (ERR ,"currently package doesn't support RXDID (%u)" , rxdid);return -EINVAL ;drivers/net/intel/ixgbe/ixgbe_ethdev.c +1
-1@@ -2722,7 +2722,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev)ixgbe_set_vf_rate_limit ( dev, vf, vfinfo[vf].tx_rate[idx], -1 << idx); +RTE_BIT64 (idx)); }Quoted 14 lines
drivers/net/vmxnet3/vmxnet3_ethdev.h static inline uint8_t · line 189
Quoted 11 lines
drivers/net/intel/ixgbe/ixgbe_ethdev.c +0
-0ixgbe_restore_statistics_mapping (dev);drivers/net/vmxnet3/vmxnet3_ethdev.h +1
-1@@ -186,14 +186,14 @@ static inline uint8_t vmxnet3_get_ring_idx(struct vmxnet3_hw *hw, uint32 rqID) {return (rqID >= hw->num_rx_queues && - rqID <2 * hw->num_rx_queues) ?1 :0 ; + rqID < (uint32 )2 * hw->num_rx_queues) ?1 :0 ;Why uint32 rather than
uint32_twhich are the normal types we use in DPDK? Could this also be simplified to just 2U?
Quoted 4 lines
Well, I had just used the same type used for rqID (a few lines above). BTW, there are more than 100 hits in DPDK when searching for "uint32 ". I'm happy to use 2U instead though.
I generally don't like to see uint32 rather than the normal uint32_t type. Probably prefer 2U though since it's shorter. However, if you don't feel like doing a new revision, ok to keep this as you have it.
/Bruce
Re: [PATCH v4] drivers/net: use 64-bit shift and avoid signed/unsigned mismatch
Quoted 70 lines · Bruce Richardson
Quoted 33 lines · Andre Muezerie
Quoted 32 lines · Bruce Richardson
Quoted 31 lines · Andre Muezerie
This patch avoids warnings like the ones below emitted by MSVC:
1)
../drivers/net/ice/base/ice_flg_rd.c(71): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)2)
../drivers/net/ice/ice_dcf_sched.c(177): warning C4018: '>=':
signed/unsigned mismatchThe fix for (1) is to use 64-bit shifting when appropriate (according to what the result is used for).
The fix for (2) is to explicitly cast the variables used in the comparison.
Signed-off-by Andre Muezerie <[email protected]>--- drivers/net/intel/i40e/i40e_ethdev.c | 22 +++++++++++----------- drivers/net/intel/iavf/iavf_ethdev.c | 2 +- drivers/net/intel/iavf/iavf_rxtx.c | 2 +- drivers/net/intel/iavf/iavf_vchnl.c | 2 +- drivers/net/intel/ice/base/meson.build | 19 +++++++++++++------ drivers/net/intel/ice/ice_dcf_sched.c | 2 +- drivers/net/intel/ice/ice_ethdev.c | 4 ++-- drivers/net/intel/ice/ice_rxtx.c | 2 +- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 2 +- drivers/net/vmxnet3/vmxnet3_ethdev.h | 6 +++--- 10 files changed, 35 insertions(+), 28 deletions(-)<snip>
Quoted 33 lines
Quoted 32 lines
Quoted 16 lines
drivers/net/intel/ice/base/meson.build +3
-5@@ -31,18 +31,25 @@ sources = [ 'ice_vf_mbx.c', ] -error_cflags = [ - '-Wno-unused-but-set-variable', - '-Wno-unused-variable', - '-Wno-unused-parameter', -] +if is_ms_compiler + error_cflags = [ + '/wd4101', # unreferenced local variabledrivers/net/intel/ice/base/meson.build sources = [ · line 46
Quoted 10 lines
drivers/net/intel/ice/base/meson.build +9
-0+ '/wd4334', # result of 32-bit shift implicitly converted to 64 bits + ] +else + error_cflags = [ + '-Wno-unused-but-set-variable', + '-Wno-unused-variable', + '-Wno-unused-parameter', + ] +endifDo we actually need these if-else blocks here? The way
the code is structured is that we check if the flags work to the current compiler and use only those that are relevant. Therefore, we should just be able to have a list of error flags and leave meson to filter out the incorrect ones.
Quoted 7 lines
Quoted 5 lines
Both approaches work. I personally find the if-else approach in this case a little more readable as it makes clear to which compiler the flags apply (considering that there might be multiple flags with the same purpose, one for each compiler). But I'm open to updating the patch following your suggestion.
If you find it more readable, ok to keep as-is.
Ok. I'll keep this as-is then.
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
drivers/net/intel/ice/base/meson.build sources = [ · line 52
Quoted 9 lines
drivers/net/intel/ice/base/meson.build +1
-1# Bugzilla ID: 678 if (toolchain == 'gcc' and cc.version().version_compare('>=11.0.0')) error_cflags += ['-Wno-array-bounds'] endif -if is_windows and cc.get_id() != 'clang' +if is_windows and not is_ms_compiler and cc.get_id() != 'clang'Are there other supported compiler options for windows other than MSVC and clang? For what compiler are we adding this flag?
Quoted 8 lines
Quoted 4 lines
Yes, MinGW-w64 is also supported on Windows, so effectively this flag applies to this compiler.
https://doc.dpdk.org/guides/windows_gsg/build_dpdk.html
Note that this flag was already there. I just changed the expression so that it is not used with msvc.Ok, thanks for clarifying.
Do we have a flag or check for identifying MinGW, because if we do that may be clearer in the check.
I checked on my system and MinGW identifies as "gcc". We can probably rely on that, so I simplified the expression as suggested.
Quoted 83 lines
Quoted 78 lines
Quoted 63 lines
Quoted 63 lines
drivers/net/intel/ice/base/meson.build +0
-0cflags += ['-fno-asynchronous-unwind-tables'] endifdrivers/net/intel/ice/ice_dcf_sched.c +1
-1@@ -174,7 +174,7 @@ ice_dcf_node_param_check(struct ice_dcf_hw *hw, uint32_t node_id, }/* for non-leaf node */ -if (node_id >=8 * hw->num_vfs) { +if (node_id >= (uint32_t )(8 * hw->num_vfs)) {if (params->nonleaf.wfq_weight_mode) { error->type =RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE ;drivers/net/intel/ice/ice_ethdev.c +2
-2@@ -2469,13 +2469,13 @@ ice_get_supported_rxdid(struct ice_hw *hw)uint32_t regval;int i; - supported_rxdid |=BIT (ICE_RXDID_LEGACY_1 ); + supported_rxdid |=RTE_BIT64 (ICE_RXDID_LEGACY_1 );for (i =ICE_RXDID_FLEX_NIC ; i <ICE_FLEX_DESC_RXDID_MAX_NUM ; i++) { regval =ICE_READ_REG (hw,GLFLXP_RXDID_FLAGS (i,0 ));if ((regval >>GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_S ) &GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_M ) - supported_rxdid |=BIT (i); + supported_rxdid |=RTE_BIT64 (i); }return supported_rxdid; }drivers/net/intel/ice/ice_rxtx.c +1
-1@@ -399,7 +399,7 @@ ice_program_hw_rx_queue(struct ice_rx_queue *rxq)PMD_DRV_LOG (DEBUG ,"Port (%u) - Rx queue (%u) is set with RXDID : %u" , rxq->port_id, rxq->queue_id, rxdid); -if (!(pf->supported_rxdid &BIT (rxdid))) { +if (!(pf->supported_rxdid &RTE_BIT64 (rxdid))) {PMD_DRV_LOG (ERR ,"currently package doesn't support RXDID (%u)" , rxdid);return -EINVAL ;drivers/net/intel/ixgbe/ixgbe_ethdev.c +1
-1@@ -2722,7 +2722,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev)ixgbe_set_vf_rate_limit ( dev, vf, vfinfo[vf].tx_rate[idx], -1 << idx); +RTE_BIT64 (idx)); }Quoted 14 lines
drivers/net/vmxnet3/vmxnet3_ethdev.h static inline uint8_t · line 189
Quoted 11 lines
drivers/net/intel/ixgbe/ixgbe_ethdev.c +0
-0ixgbe_restore_statistics_mapping (dev);drivers/net/vmxnet3/vmxnet3_ethdev.h +1
-1@@ -186,14 +186,14 @@ static inline uint8_t vmxnet3_get_ring_idx(struct vmxnet3_hw *hw, uint32 rqID) {return (rqID >= hw->num_rx_queues && - rqID <2 * hw->num_rx_queues) ?1 :0 ; + rqID < (uint32 )2 * hw->num_rx_queues) ?1 :0 ;Why uint32 rather than
uint32_twhich are the normal types we use in DPDK? Could this also be simplified to just 2U?Quoted 4 lines
Well, I had just used the same type used for rqID (a few lines above). BTW, there are more than 100 hits in DPDK when searching for "uint32 ". I'm happy to use 2U instead though.
Quoted 5 lines
I generally don't like to see uint32 rather than the normal
uint32_ttype. Probably prefer 2U though since it's shorter. However, if you don't feel like doing a new revision, ok to keep this as you have it./Bruce
I replaced that with 2U. I also took the opportunity to update the type in the function signature and also updated the variable name to avoid a checkpatch warning.
--
Andre Muezerie
Stephen Hemminger
AppliedRe: [PATCH v4] drivers/net: use 64-bit shift and avoid signed/unsigned mismatch
In reply to Andre MuezerieQuoted 11 lines · On Wed, 5 Feb 2025 11:32:24 -0800 Andre Muezerie…
This patch avoids warnings like the ones below emitted by MSVC:
1)
../drivers/net/ice/base/ice_flg_rd.c(71): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)2)
../drivers/net/ice/ice_dcf_sched.c(177): warning C4018: '>=':
signed/unsigned mismatch
Quoted 7 lines
The fix for (1) is to use 64-bit shifting when appropriate (according to what the result is used for).
The fix for (2) is to explicitly cast the variables used in the comparison.
Signed-off-by Andre Muezerie <[email protected]>
Applied to next-net with some rewording of commit title.
v5 cover use 64-bit shift, avoid signed/unsigned mismatch
In reply to Andre MuezerieThis patch avoids warnings like the ones below emitted by MSVC:
1)
../drivers/net/ice/base/ice_flg_rd.c(71): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
2)
../drivers/net/ice/ice_dcf_sched.c(177): warning C4018: '>=':
signed/unsigned mismatch
The fix for (1) is to use 64-bit shifting when appropriate (according to what the result is used for).
The fix for (2) is to explicitly cast the variables used in the comparison.
v5:
* rebase
* use uint32_t instead of uint32, to better conform to DPDK standards
* rename variable rqID to rq_id to better conform to DPDK standards and avoid checkpatch warning
* use 2U instead of (uint32)2, which is shorter
* simplify expression in meson.build using compiler id "gcc"
Andre Muezerie (1):
drivers/net: use 64-bit shift and avoid signed/unsigned mismatch
drivers/net/intel/i40e/i40e_ethdev.c | 22 +++++++++++----------- drivers/net/intel/iavf/iavf_ethdev.c | 2 +- drivers/net/intel/iavf/iavf_rxtx.c | 2 +- drivers/net/intel/iavf/iavf_vchnl.c | 2 +- drivers/net/intel/ice/base/meson.build | 19 +++++++++++++------ drivers/net/intel/ice/ice_dcf_sched.c | 2 +- drivers/net/intel/ice/ice_ethdev.c | 4 ++-- drivers/net/intel/ice/ice_rxtx.c | 2 +- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 2 +- 9 files changed, 32 insertions(+), 25 deletions(-)
--
2.47.2.vfs.0.1
PATCH v5 1/1 drivers/net: use 64-bit shift and avoid signed/unsigned mismatch
This patch avoids warnings like the ones below emitted by MSVC:
1)
../drivers/net/ice/base/ice_flg_rd.c(71): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
2)
../drivers/net/ice/ice_dcf_sched.c(177): warning C4018: '>=':
signed/unsigned mismatch
The fix for (1) is to use 64-bit shifting when appropriate (according to what the result is used for).
The fix for (2) is to explicitly cast the variables used in the comparison.
--- drivers/net/intel/i40e/i40e_ethdev.c | 22 +++++++++++----------- drivers/net/intel/iavf/iavf_ethdev.c | 2 +- drivers/net/intel/iavf/iavf_rxtx.c | 2 +- drivers/net/intel/iavf/iavf_vchnl.c | 2 +- drivers/net/intel/ice/base/meson.build | 19 +++++++++++++------ drivers/net/intel/ice/ice_dcf_sched.c | 2 +- drivers/net/intel/ice/ice_ethdev.c | 4 ++-- drivers/net/intel/ice/ice_rxtx.c | 2 +- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 2 +- 9 files changed, 32 insertions(+), 25 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +11 -11
@@ -3094,7 +3094,7 @@ i40e_stat_update_48_in_64(struct i40e_hw *hw, uint32_t hireg,/* enlarge the limitation when statistics counters overflowed */ if (offset_loaded) {if (I40E_RXTX_BYTES_L_48_BIT (*prev_stat) > *stat) - *stat += (uint64_t )1 <<I40E_48_BIT_WIDTH ; + *stat +=RTE_BIT64 (I40E_48_BIT_WIDTH ); *stat +=I40E_RXTX_BYTES_H_16_BIT (*prev_stat); } *prev_stat = *stat;
@@ -4494,7 +4494,7 @@ i40e_macaddr_remove(struct rte_eth_dev *dev, uint32_t index) pool_sel = dev->data->mac_pool_sel[index];for (i =0 ; i <sizeof (pool_sel) *CHAR_BIT ; i++) { -if (pool_sel & (1ULL << i)) { +if (pool_sel &RTE_BIT64 (i)) {if (i ==0 ) vsi = pf->main_vsi;else {
@@ -4630,7 +4630,7 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev,for (i =0 ; i < reta_size; i++) { idx = i /RTE_ETH_RETA_GROUP_SIZE ; shift = i %RTE_ETH_RETA_GROUP_SIZE ; -if (reta_conf[idx].mask & (1ULL << shift)) +if (reta_conf[idx].mask &RTE_BIT64 (shift)) lut[i] = reta_conf[idx].reta[shift]; } ret =i40e_set_rss_lut (pf->main_vsi, lut, reta_size);
@@ -4674,7 +4674,7 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev,for (i =0 ; i < reta_size; i++) { idx = i /RTE_ETH_RETA_GROUP_SIZE ; shift = i %RTE_ETH_RETA_GROUP_SIZE ; -if (reta_conf[idx].mask & (1ULL << shift)) +if (reta_conf[idx].mask &RTE_BIT64 (shift)) reta_conf[idx].reta[shift] = lut[i]; }
@@ -6712,7 +6712,7 @@ i40e_vmdq_setup(struct rte_eth_dev *dev) loop =sizeof (vmdq_conf->pool_map[0 ].pools) *CHAR_BIT ;for (i =0 ; i < vmdq_conf->nb_pool_maps; i++) {for (j =0 ; j < loop && j < pf->nb_cfg_vmdq_vsi; j++) { -if (vmdq_conf->pool_map[i].pools & (1UL << j)) { +if (vmdq_conf->pool_map[i].pools &RTE_BIT64 (j)) {PMD_INIT_LOG (INFO ,"Add vlan %u to vmdq pool %u" , vmdq_conf->pool_map[i].vlan_id, j);
@@ -6761,7 +6761,7 @@ i40e_stat_update_32(struct i40e_hw *hw, *stat = (uint64_t )(new_data - *offset); else *stat = (uint64_t )((new_data + - ((uint64_t )1 <<I40E_32_BIT_WIDTH )) - *offset); +RTE_BIT64 (I40E_32_BIT_WIDTH )) - *offset); } static void
@@ -6789,7 +6789,7 @@ i40e_stat_update_48(struct i40e_hw *hw, *stat = new_data - *offset; else *stat = (uint64_t )((new_data + - ((uint64_t )1 <<I40E_48_BIT_WIDTH )) - *offset); +RTE_BIT64 (I40E_48_BIT_WIDTH )) - *offset); *stat &=I40E_48_BIT_MASK ; }
@@ -7730,7 +7730,7 @@ i40e_config_hena(const struct i40e_adapter *adapter, uint64_t flags)return hena;for (i =RTE_ETH_FLOW_UNKNOWN +1 ; i <I40E_FLOW_TYPE_MAX ; i++) { -if (flags & (1ULL << i)) +if (flags &RTE_BIT64 (i)) hena |= adapter->pctypes_tbl[i]; }
@@ -7749,7 +7749,7 @@ i40e_parse_hena(const struct i40e_adapter *adapter, uint64_t flags)for (i =RTE_ETH_FLOW_UNKNOWN +1 ; i <I40E_FLOW_TYPE_MAX ; i++) {if (flags & adapter->pctypes_tbl[i]) - rss_hf |= (1ULL << i); + rss_hf |=RTE_BIT64 (i); }return rss_hf; }
@@ -10162,7 +10162,7 @@ i40e_flowtype_to_pctype(const struct i40e_adapter *adapter, uint16_t flow_type)if (flow_type <I40E_FLOW_TYPE_MAX ) { pctype_mask = adapter->pctypes_tbl[flow_type];for (i =I40E_FILTER_PCTYPE_MAX -1 ; i >0 ; i--) { -if (pctype_mask & (1ULL << i)) +if (pctype_mask &RTE_BIT64 (i))return (enum i40e_filter_pctype )i; } }
@@ -10174,7 +10174,7 @@ i40e_pctype_to_flowtype(const struct i40e_adapter *adapter, enum i40e_filter_pctype pctype) {uint16_t flowtype; -uint64_t pctype_mask =1ULL << pctype; +uint64_t pctype_mask =RTE_BIT64 (pctype);for (flowtype =RTE_ETH_FLOW_UNKNOWN +1 ; flowtype <I40E_FLOW_TYPE_MAX ; flowtype++) {
drivers/net/intel/iavf/iavf_ethdev.c +1 -1
@@ -2485,7 +2485,7 @@ iavf_init_proto_xtr(struct rte_eth_dev *dev)if (!xtr_ol->required)continue ; -if (!(vf->supported_rxdid &BIT (rxdid))) { +if (!(vf->supported_rxdid &RTE_BIT64 (rxdid))) {PMD_DRV_LOG (ERR ,"rxdid[%u] is not supported in hardware" , rxdid);
drivers/net/intel/iavf/iavf_rxtx.c +1 -1
@@ -3871,7 +3871,7 @@ iavf_set_rx_function(struct rte_eth_dev *dev)PMD_DRV_LOG (NOTICE ,"request RXDID[%d] in Queue[%d] is legacy, " "set rx_pkt_burst as legacy for all queues" , rxq->rxdid, i); use_flex = false; - }else if (!(vf->supported_rxdid &BIT (rxq->rxdid))) { + }else if (!(vf->supported_rxdid &RTE_BIT64 (rxq->rxdid))) {PMD_DRV_LOG (NOTICE ,"request RXDID[%d] in Queue[%d] is not supported, " "set rx_pkt_burst as legacy for all queues" , rxq->rxdid, i); use_flex = false;
drivers/net/intel/iavf/iavf_vchnl.c +1 -1
@@ -1263,7 +1263,7 @@ iavf_configure_queues(struct iavf_adapter *adapter,#ifndef RTE_LIBRTE_IAVF_16BYTE_RX_DESC if (vf->vf_res->vf_cap_flags &VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC ) { -if (vf->supported_rxdid &BIT (rxq[i]->rxdid)) { +if (vf->supported_rxdid &RTE_BIT64 (rxq[i]->rxdid)) { vc_qp->rxq.rxdid = rxq[i]->rxdid;PMD_DRV_LOG (NOTICE ,"request RXDID[%d] in Queue[%d]" , vc_qp->rxq.rxdid, i);
drivers/net/intel/ice/base/meson.build +13 -6
@@ -31,18 +31,25 @@ sources = [ 'ice_vf_mbx.c', ] -error_cflags = [ - '-Wno-unused-but-set-variable', - '-Wno-unused-variable', - '-Wno-unused-parameter', -] +if is_ms_compiler + error_cflags = [ + '/wd4101', # unreferenced local variable + '/wd4334', # result of 32-bit shift implicitly converted to 64 bits + ] +else + error_cflags = [ + '-Wno-unused-but-set-variable', + '-Wno-unused-variable', + '-Wno-unused-parameter', + ] +endif # Bugzilla ID: 678 if (toolchain == 'gcc' and cc.version().version_compare('>=11.0.0')) error_cflags += ['-Wno-array-bounds'] endif -if is_windows and cc.get_id() != 'clang' +if is_windows and cc.get_id() == 'gcc' cflags += ['-fno-asynchronous-unwind-tables'] endif
drivers/net/intel/ice/ice_dcf_sched.c +1 -1
@@ -174,7 +174,7 @@ ice_dcf_node_param_check(struct ice_dcf_hw *hw, uint32_t node_id, }/* for non-leaf node */ -if (node_id >=8 * hw->num_vfs) { +if (node_id >= (uint32_t )(8 * hw->num_vfs)) {if (params->nonleaf.wfq_weight_mode) { error->type =RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE ;
drivers/net/intel/ice/ice_ethdev.c +2 -2
@@ -2469,13 +2469,13 @@ ice_get_supported_rxdid(struct ice_hw *hw)uint32_t regval;int i; - supported_rxdid |=BIT (ICE_RXDID_LEGACY_1 ); + supported_rxdid |=RTE_BIT64 (ICE_RXDID_LEGACY_1 );for (i =ICE_RXDID_FLEX_NIC ; i <ICE_FLEX_DESC_RXDID_MAX_NUM ; i++) { regval =ICE_READ_REG (hw,GLFLXP_RXDID_FLAGS (i,0 ));if ((regval >>GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_S ) &GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_M ) - supported_rxdid |=BIT (i); + supported_rxdid |=RTE_BIT64 (i); }return supported_rxdid; }
drivers/net/intel/ice/ice_rxtx.c +1 -1
@@ -399,7 +399,7 @@ ice_program_hw_rx_queue(struct ice_rx_queue *rxq)PMD_DRV_LOG (DEBUG ,"Port (%u) - Rx queue (%u) is set with RXDID : %u" , rxq->port_id, rxq->queue_id, rxdid); -if (!(pf->supported_rxdid &BIT (rxdid))) { +if (!(pf->supported_rxdid &RTE_BIT64 (rxdid))) {PMD_DRV_LOG (ERR ,"currently package doesn't support RXDID (%u)" , rxdid);return -EINVAL ;
drivers/net/intel/ixgbe/ixgbe_ethdev.c +1 -1
@@ -2722,7 +2722,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev)ixgbe_set_vf_rate_limit ( dev, vf, vfinfo[vf].tx_rate[idx], -1 << idx); +RTE_BIT64 (idx)); }ixgbe_restore_statistics_mapping (dev);
Signature · 1 line
2.47.2.vfs.0.1
Re: [PATCH v5 0/1] use 64-bit shift, avoid signed/unsigned mismatch
In reply to Andre MuezerieQuoted 28 lines · On Fri, 7 Feb 2025 09:41:08 -0800 Andre Muezerie…
This patch avoids warnings like the ones below emitted by MSVC:
1)
../drivers/net/ice/base/ice_flg_rd.c(71): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)2)
../drivers/net/ice/ice_dcf_sched.c(177): warning C4018: '>=':
signed/unsigned mismatchThe fix for (1) is to use 64-bit shifting when appropriate (according to what the result is used for).
The fix for (2) is to explicitly cast the variables used in the comparison.
v5:
* rebase
* useuint32_tinstead of uint32, to better conform to DPDK standards
* rename variable rqID torq_idto better conform to DPDK standards and avoid checkpatch warning
* use 2U instead of (uint32)2, which is shorter
* simplify expression in meson.build using compiler id "gcc"Andre Muezerie (1):
drivers/net: use 64-bit shift and avoid signed/unsigned mismatch
Quoted 10 lines
drivers/net/intel/i40e/i40e_ethdev.c | 22 +++++++++++----------- drivers/net/intel/iavf/iavf_ethdev.c | 2 +- drivers/net/intel/iavf/iavf_rxtx.c | 2 +- drivers/net/intel/iavf/iavf_vchnl.c | 2 +- drivers/net/intel/ice/base/meson.build | 19 +++++++++++++------ drivers/net/intel/ice/ice_dcf_sched.c | 2 +- drivers/net/intel/ice/ice_ethdev.c | 4 ++-- drivers/net/intel/ice/ice_rxtx.c | 2 +- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 2 +- 9 files changed, 32 insertions(+), 25 deletions(-)
Okay, put this in next-net
Re: [PATCH v5 0/1] use 64-bit shift, avoid signed/unsigned mismatch
In reply to Andre MuezerieQuoted 28 lines · On Fri, 7 Feb 2025 09:41:08 -0800 Andre Muezerie…
This patch avoids warnings like the ones below emitted by MSVC:
1)
../drivers/net/ice/base/ice_flg_rd.c(71): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)2)
../drivers/net/ice/ice_dcf_sched.c(177): warning C4018: '>=':
signed/unsigned mismatchThe fix for (1) is to use 64-bit shifting when appropriate (according to what the result is used for).
The fix for (2) is to explicitly cast the variables used in the comparison.
v5:
* rebase
* useuint32_tinstead of uint32, to better conform to DPDK standards
* rename variable rqID torq_idto better conform to DPDK standards and avoid checkpatch warning
* use 2U instead of (uint32)2, which is shorter
* simplify expression in meson.build using compiler id "gcc"Andre Muezerie (1):
drivers/net: use 64-bit shift and avoid signed/unsigned mismatch
Quoted 10 lines
drivers/net/intel/i40e/i40e_ethdev.c | 22 +++++++++++----------- drivers/net/intel/iavf/iavf_ethdev.c | 2 +- drivers/net/intel/iavf/iavf_rxtx.c | 2 +- drivers/net/intel/iavf/iavf_vchnl.c | 2 +- drivers/net/intel/ice/base/meson.build | 19 +++++++++++++------ drivers/net/intel/ice/ice_dcf_sched.c | 2 +- drivers/net/intel/ice/ice_ethdev.c | 4 ++-- drivers/net/intel/ice/ice_rxtx.c | 2 +- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 2 +- 9 files changed, 32 insertions(+), 25 deletions(-)
Since all intel, this should get picked up by next-intel
Re: [PATCH v5 0/1] use 64-bit shift, avoid signed/unsigned mismatch
Quoted 43 lines · Stephen Hemminger
Quoted 28 lines · On Fri, 7 Feb 2025 09:41:08 -0800 Andre Muezerie…
This patch avoids warnings like the ones below emitted by MSVC:
1)
../drivers/net/ice/base/ice_flg_rd.c(71): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)2)
../drivers/net/ice/ice_dcf_sched.c(177): warning C4018: '>=':
signed/unsigned mismatchThe fix for (1) is to use 64-bit shifting when appropriate (according to what the result is used for).
The fix for (2) is to explicitly cast the variables used in the comparison.
v5:
* rebase
* useuint32_tinstead of uint32, to better conform to DPDK standards
* rename variable rqID torq_idto better conform to DPDK standards and avoid checkpatch warning
* use 2U instead of (uint32)2, which is shorter
* simplify expression in meson.build using compiler id "gcc"Andre Muezerie (1):
drivers/net: use 64-bit shift and avoid signed/unsigned mismatchQuoted 10 lines
drivers/net/intel/i40e/i40e_ethdev.c | 22 +++++++++++----------- drivers/net/intel/iavf/iavf_ethdev.c | 2 +- drivers/net/intel/iavf/iavf_rxtx.c | 2 +- drivers/net/intel/iavf/iavf_vchnl.c | 2 +- drivers/net/intel/ice/base/meson.build | 19 +++++++++++++------ drivers/net/intel/ice/ice_dcf_sched.c | 2 +- drivers/net/intel/ice/ice_ethdev.c | 4 ++-- drivers/net/intel/ice/ice_rxtx.c | 2 +- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 2 +- 9 files changed, 32 insertions(+), 25 deletions(-)
Quoted 1 line
Since all intel, this should get picked up by next-intel
V4 had some non-intel changes too. Did they get missed in v5?
Re: [PATCH v5 0/1] use 64-bit shift, avoid signed/unsigned mismatch
Quoted 44 lines · Bruce Richardson
Quoted 43 lines · Stephen Hemminger
Quoted 38 lines · On Fri, 7 Feb 2025 09:41:08 -0800 Andre Muezerie…
This patch avoids warnings like the ones below emitted by MSVC:
1)
../drivers/net/ice/base/ice_flg_rd.c(71): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)2)
../drivers/net/ice/ice_dcf_sched.c(177): warning C4018: '>=':
signed/unsigned mismatchThe fix for (1) is to use 64-bit shifting when appropriate (according to what the result is used for).
The fix for (2) is to explicitly cast the variables used in the comparison.
v5:
* rebase
* useuint32_tinstead of uint32, to better conform to DPDK standards
* rename variable rqID torq_idto better conform to DPDK standards and avoid checkpatch warning
* use 2U instead of (uint32)2, which is shorter
* simplify expression in meson.build using compiler id "gcc"Andre Muezerie (1):
drivers/net: use 64-bit shift and avoid signed/unsigned mismatchdrivers/net/intel/i40e/i40e_ethdev.c | 22 +++++++++++----------- drivers/net/intel/iavf/iavf_ethdev.c | 2 +- drivers/net/intel/iavf/iavf_rxtx.c | 2 +- drivers/net/intel/iavf/iavf_vchnl.c | 2 +- drivers/net/intel/ice/base/meson.build | 19 +++++++++++++------ drivers/net/intel/ice/ice_dcf_sched.c | 2 +- drivers/net/intel/ice/ice_ethdev.c | 4 ++-- drivers/net/intel/ice/ice_rxtx.c | 2 +- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 2 +- 9 files changed, 32 insertions(+), 25 deletions(-)
Quoted 3 lines
Quoted 1 line
Since all intel, this should get picked up by next-intel
V4 had some non-intel changes too. Did they get missed in v5?
I've taken v5 into next-next-intel. Any missed bits can be submitted as a separate patch later.
However, since the patch really contains two separate fixes - one for bitshifting, another for typecasting - I've actually split it into two patches. This avoids having a really long commit title - the "and" in the middle is a bit of a giveaway that the patch should be split IMHO! Andre, Please review on next-net-intel tree
[https://git.dpdk.org/next/dpdk-next-net-intel/log/]
Applied to dpdk-next-net-intel.
Thanks,
/Bruce
Re: [PATCH v5 0/1] use 64-bit shift, avoid signed/unsigned mismatch
Quoted 61 lines · Bruce Richardson
Quoted 44 lines · Bruce Richardson
Quoted 43 lines · Stephen Hemminger
Quoted 38 lines · On Fri, 7 Feb 2025 09:41:08 -0800 Andre Muezerie…
This patch avoids warnings like the ones below emitted by MSVC:
1)
../drivers/net/ice/base/ice_flg_rd.c(71): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)2)
../drivers/net/ice/ice_dcf_sched.c(177): warning C4018: '>=':
signed/unsigned mismatchThe fix for (1) is to use 64-bit shifting when appropriate (according to what the result is used for).
The fix for (2) is to explicitly cast the variables used in the comparison.
v5:
* rebase
* useuint32_tinstead of uint32, to better conform to DPDK standards
* rename variable rqID torq_idto better conform to DPDK standards and avoid checkpatch warning
* use 2U instead of (uint32)2, which is shorter
* simplify expression in meson.build using compiler id "gcc"Andre Muezerie (1):
drivers/net: use 64-bit shift and avoid signed/unsigned mismatchdrivers/net/intel/i40e/i40e_ethdev.c | 22 +++++++++++----------- drivers/net/intel/iavf/iavf_ethdev.c | 2 +- drivers/net/intel/iavf/iavf_rxtx.c | 2 +- drivers/net/intel/iavf/iavf_vchnl.c | 2 +- drivers/net/intel/ice/base/meson.build | 19 +++++++++++++------ drivers/net/intel/ice/ice_dcf_sched.c | 2 +- drivers/net/intel/ice/ice_ethdev.c | 4 ++-- drivers/net/intel/ice/ice_rxtx.c | 2 +- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 2 +- 9 files changed, 32 insertions(+), 25 deletions(-)Quoted 3 lines
Quoted 1 line
Since all intel, this should get picked up by next-intel
V4 had some non-intel changes too. Did they get missed in v5?
Acked-by Bruce Richardson <[email protected]>I've taken v5 into next-next-intel. Any missed bits can be submitted as a separate patch later.
However, since the patch really contains two separate fixes - one for bitshifting, another for typecasting - I've actually split it into two patches. This avoids having a really long commit title - the "and" in the middle is a bit of a giveaway that the patch should be split IMHO! Andre, Please review on next-net-intel tree
[https://git.dpdk.org/next/dpdk-next-net-intel/log/]
Quoted 4 lines
Applied to dpdk-next-net-intel.
Thanks,
/Bruce
I reviewed the split patches on next-net-intel and they look good. Thanks,
Andre Muezerie
Re: [PATCH v5 0/1] use 64-bit shift, avoid signed/unsigned mismatch
In reply to Bruce RichardsonQuoted 44 lines · Bruce Richardson
Quoted 43 lines · Stephen Hemminger
Quoted 38 lines · On Fri, 7 Feb 2025 09:41:08 -0800 Andre Muezerie…
This patch avoids warnings like the ones below emitted by MSVC:
1)
../drivers/net/ice/base/ice_flg_rd.c(71): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)2)
../drivers/net/ice/ice_dcf_sched.c(177): warning C4018: '>=':
signed/unsigned mismatchThe fix for (1) is to use 64-bit shifting when appropriate (according to what the result is used for).
The fix for (2) is to explicitly cast the variables used in the comparison.
v5:
* rebase
* useuint32_tinstead of uint32, to better conform to DPDK standards
* rename variable rqID torq_idto better conform to DPDK standards and avoid checkpatch warning
* use 2U instead of (uint32)2, which is shorter
* simplify expression in meson.build using compiler id "gcc"Andre Muezerie (1):
drivers/net: use 64-bit shift and avoid signed/unsigned mismatchdrivers/net/intel/i40e/i40e_ethdev.c | 22 +++++++++++----------- drivers/net/intel/iavf/iavf_ethdev.c | 2 +- drivers/net/intel/iavf/iavf_rxtx.c | 2 +- drivers/net/intel/iavf/iavf_vchnl.c | 2 +- drivers/net/intel/ice/base/meson.build | 19 +++++++++++++------ drivers/net/intel/ice/ice_dcf_sched.c | 2 +- drivers/net/intel/ice/ice_ethdev.c | 4 ++-- drivers/net/intel/ice/ice_rxtx.c | 2 +- drivers/net/intel/ixgbe/ixgbe_ethdev.c | 2 +- 9 files changed, 32 insertions(+), 25 deletions(-)
Quoted 3 lines
Quoted 1 line
Since all intel, this should get picked up by next-intel
V4 had some non-intel changes too. Did they get missed in v5?
Indeed, I ended up missing one file. I'll send it as a separate patch.