RE: [PATCH v3 06/27] net/i40e: use unsigned types for queue comparisons

Morten Brørup
2026-02-11T21:03:16Z

> Currently, when we compare queue numbers against maximum traffic class
> value of 64, we do not use unsigned values, which results in compiler
> warning when attempting to compare `I40E_MAX_Q_PER_TC` to an unsigned
> value. Make it unsigned, and adjust callers to use correct types. As a
> consequence, `i40e_align_floor` now returns unsigned value as well -
> this
> is correct, because nothing about that function implies signed usage
> being
> a valid use case.
>
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
> drivers/net/intel/i40e/i40e_ethdev.c | 2 +-
> drivers/net/intel/i40e/i40e_ethdev.h | 6 +++---
> drivers/net/intel/i40e/i40e_hash.c | 4 ++--
> 3 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/intel/i40e/i40e_ethdev.c
> b/drivers/net/intel/i40e/i40e_ethdev.c
> index 2deb87b01b..d5c61cd577 100644
> --- a/drivers/net/intel/i40e/i40e_ethdev.c
> +++ b/drivers/net/intel/i40e/i40e_ethdev.c
> @@ -9058,7 +9058,7 @@ i40e_pf_reset_rss_reta(struct i40e_pf *pf)
> struct i40e_hw *hw = &pf->adapter->hw;
> uint8_t lut[RTE_ETH_RSS_RETA_SIZE_512];
> uint32_t i;
> - int num;
> + size_t num;

Why not just unsigned int? size_t seems weird when not counting bytes.

Or uint16_t, considering its use.

>
> /* If both VMDQ and RSS enabled, not all of PF queues are
> * configured. It's necessary to calculate the actual PF
> diff --git a/drivers/net/intel/i40e/i40e_ethdev.h
> b/drivers/net/intel/i40e/i40e_ethdev.h
> index 0de036f2d9..d144297360 100644
> --- a/drivers/net/intel/i40e/i40e_ethdev.h
> +++ b/drivers/net/intel/i40e/i40e_ethdev.h
> @@ -24,7 +24,7 @@
> #define I40E_AQ_LEN 32
> #define I40E_AQ_BUF_SZ 4096
> /* Number of queues per TC should be one of 1, 2, 4, 8, 16, 32, 64 */
> -#define I40E_MAX_Q_PER_TC 64
> +#define I40E_MAX_Q_PER_TC 64U
> #define I40E_NUM_DESC_DEFAULT 512
> #define I40E_NUM_DESC_ALIGN 32
> #define I40E_BUF_SIZE_MIN 1024
> @@ -1517,8 +1517,8 @@ i40e_init_adminq_parameter(struct i40e_hw *hw)
> hw->aq.asq_buf_size = I40E_AQ_BUF_SZ;
> }
>
> -static inline int
> -i40e_align_floor(int n)
> +static inline uint32_t
> +i40e_align_floor(uint32_t n)
> {
> if (n == 0)
> return 0;
> diff --git a/drivers/net/intel/i40e/i40e_hash.c
> b/drivers/net/intel/i40e/i40e_hash.c
> index f20b40e7d0..cbb377295d 100644
> --- a/drivers/net/intel/i40e/i40e_hash.c
> +++ b/drivers/net/intel/i40e/i40e_hash.c
> @@ -949,7 +949,7 @@ i40e_hash_parse_queues(const struct rte_eth_dev
> *dev,
> struct i40e_pf *pf;
> struct i40e_hw *hw;
> uint16_t i;
> - int max_queue;
> + size_t max_queue;

Why not just unsigned int? size_t seems weird when not counting bytes.

Or uint16_t, like rss_act->queue[i].
But then I40E_MAX_Q_PER_TC should maybe also be defined as UINT16_C(64), and maybe more should be uint16_t too.

>
> hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> if (!rss_act->queue_num ||
> @@ -971,7 +971,7 @@ i40e_hash_parse_queues(const struct rte_eth_dev
> *dev,
> max_queue = RTE_MIN(max_queue, I40E_MAX_Q_PER_TC);
>
> for (i = 0; i < rss_act->queue_num; i++) {
> - if ((int)rss_act->queue[i] >= max_queue)
> + if (rss_act->queue[i] >= max_queue)
> break;
> }
>
> --
> 2.47.3