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 16-bit, 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 <[email protected]>
---
 drivers/net/intel/i40e/i40e_ethdev.c | 11 ++++++-----
 drivers/net/intel/i40e/i40e_ethdev.h |  8 ++++----
 drivers/net/intel/i40e/i40e_hash.c   |  4 ++--
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/net/intel/i40e/i40e_ethdev.c 
b/drivers/net/intel/i40e/i40e_ethdev.c
index 2deb87b01b..608a6cff4d 100644
--- a/drivers/net/intel/i40e/i40e_ethdev.c
+++ b/drivers/net/intel/i40e/i40e_ethdev.c
@@ -8978,11 +8978,12 @@ i40e_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
 }
 
 /* Calculate the maximum number of contiguous PF queues that are configured */
-int
+uint16_t
 i40e_pf_calc_configured_queues_num(struct i40e_pf *pf)
 {
        struct rte_eth_dev_data *data = pf->dev_data;
-       int i, num;
+       int i;
+       uint16_t num;
        struct ci_rx_queue *rxq;
 
        num = 0;
@@ -9058,7 +9059,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;
+       uint16_t num;
 
        /* If both VMDQ and RSS enabled, not all of PF queues are
         * configured. It's necessary to calculate the actual PF
@@ -9074,7 +9075,7 @@ i40e_pf_reset_rss_reta(struct i40e_pf *pf)
                return 0;
 
        for (i = 0; i < hw->func_caps.rss_table_size; i++)
-               lut[i] = (uint8_t)(i % (uint32_t)num);
+               lut[i] = (uint8_t)(i % num);
 
        return i40e_set_rss_lut(pf->main_vsi, lut, (uint16_t)i);
 }
@@ -10771,7 +10772,7 @@ i40e_vsi_update_queue_mapping(struct i40e_vsi *vsi,
                PMD_INIT_LOG(ERR, " number of queues is less that tcs.");
                return I40E_ERR_INVALID_QP_ID;
        }
-       qpnum_per_tc = RTE_MIN(i40e_align_floor(qpnum_per_tc),
+       qpnum_per_tc = RTE_MIN((uint16_t)i40e_align_floor(qpnum_per_tc),
                                I40E_MAX_Q_PER_TC);
        bsf = rte_bsf32(qpnum_per_tc);
 
diff --git a/drivers/net/intel/i40e/i40e_ethdev.h 
b/drivers/net/intel/i40e/i40e_ethdev.h
index 0de036f2d9..ca6638b32c 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         UINT16_C(64)
 #define I40E_NUM_DESC_DEFAULT     512
 #define I40E_NUM_DESC_ALIGN       32
 #define I40E_BUF_SIZE_MIN         1024
@@ -1456,7 +1456,7 @@ int i40e_flush_queue_region_all_conf(struct rte_eth_dev 
*dev,
 void i40e_init_queue_region_conf(struct rte_eth_dev *dev);
 void i40e_flex_payload_reg_set_default(struct i40e_hw *hw);
 void i40e_pf_disable_rss(struct i40e_pf *pf);
-int i40e_pf_calc_configured_queues_num(struct i40e_pf *pf);
+uint16_t i40e_pf_calc_configured_queues_num(struct i40e_pf *pf);
 int i40e_pf_reset_rss_reta(struct i40e_pf *pf);
 int i40e_pf_reset_rss_key(struct i40e_pf *pf);
 int i40e_pf_config_rss(struct i40e_pf *pf);
@@ -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..5756ebf255 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;
+       uint16_t max_queue;
 
        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

Reply via email to