Boolean device args to ice driver are sometimes stored as an int and
sometimes as a uint8_t. The parse bool function stores them as an int,
leading to overflow when storing a uint8_t value.

Fix all these by standardizing on "bool" type, both for the arg values
in the structure and inside the parsing function.

Bugzilla ID: 2037
Fixes: 603beeb970b5 ("net/ice: add safe mode devarg")
Cc: [email protected]

Signed-off-by: Bruce Richardson <[email protected]>
---
Note: this fix is superceded by the kvargs numeric args patchset [1].
However, that patchset relies on new kvargs features unlikely to be
backported, so this standalone fix is useful for backporting or if the
whole other set doesn't make the 26.11 release.

[1] https://patches.dpdk.org/project/dpdk/list/?series=39247
---
 drivers/net/intel/ice/ice_ethdev.c | 13 +++++++------
 drivers/net/intel/ice/ice_ethdev.h | 10 +++++-----
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/net/intel/ice/ice_ethdev.c 
b/drivers/net/intel/ice/ice_ethdev.c
index 76b8ff0a72..3938186228 100644
--- a/drivers/net/intel/ice/ice_ethdev.c
+++ b/drivers/net/intel/ice/ice_ethdev.c
@@ -1083,7 +1083,7 @@ ice_init_mac_address(struct rte_eth_dev *dev)
                return -ENOMEM;
        }
        /* store it to dev data */
-       if (ad->devargs.default_mac_disable != 1)
+       if (!ad->devargs.default_mac_disable)
                rte_ether_addr_copy((struct rte_ether_addr 
*)hw->port_info[0].mac.perm_addr,
                        &dev->data->mac_addrs[0]);
        return 0;
@@ -1113,7 +1113,7 @@ ice_add_mac_filter(struct ice_vsi *vsi, struct 
rte_ether_addr *mac_addr)
        struct ice_adapter *ad = (struct ice_adapter *)hw->back;
        int ret = 0;
 
-       if (ad->devargs.default_mac_disable == 1 && 
rte_is_same_ether_addr(mac_addr,
+       if (ad->devargs.default_mac_disable && rte_is_same_ether_addr(mac_addr,
                        (struct rte_ether_addr 
*)hw->port_info[0].mac.perm_addr)) {
                PMD_DRV_LOG(ERR, "This Default MAC filter is disabled.");
                return 0;
@@ -1763,7 +1763,7 @@ ice_setup_vsi(struct ice_pf *pf, enum ice_vsi_type type)
                 */
                vsi_ctx.info.sw_id = hw->port_info->sw_id;
                /* Source Prune */
-               if (ad->devargs.source_prune != 1) {
+               if (!ad->devargs.source_prune) {
                        /* Disable source prune to support VRRP
                         * when source-prune devarg is not set
                         */
@@ -2139,7 +2139,7 @@ ice_base_queue_get(struct ice_pf *pf)
 static int
 parse_bool(const char *key, const char *value, void *args)
 {
-       int *i = args;
+       bool *i = args;
 
        if (value == NULL || value[0] == '\0') {
                PMD_DRV_LOG(WARNING, "key:\"%s\", requires a value, which must 
be 0 or 1", key);
@@ -2758,7 +2758,7 @@ ice_dev_init(struct rte_eth_dev *dev)
        }
 
        if (ret) {
-               if (ad->devargs.safe_mode_support == 0) {
+               if (!ad->devargs.safe_mode_support) {
                        PMD_INIT_LOG(ERR, "Failed to load the DDP package,"
                                        "Use safe-mode-support=1 to enter Safe 
Mode");
                        goto err_init_fw;
@@ -4211,7 +4211,8 @@ __vsi_queues_bind_intr(struct ice_vsi *vsi, uint16_t 
msix_vect,
 {
        struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
        uint32_t val, val_tx;
-       int rx_low_latency, i;
+       bool rx_low_latency;
+       int i;
 
        rx_low_latency = vsi->adapter->devargs.rx_low_latency;
        for (i = 0; i < nb_queue; i++) {
diff --git a/drivers/net/intel/ice/ice_ethdev.h 
b/drivers/net/intel/ice/ice_ethdev.h
index 7ee3ea8a70..3ca820ccb6 100644
--- a/drivers/net/intel/ice/ice_ethdev.h
+++ b/drivers/net/intel/ice/ice_ethdev.h
@@ -622,16 +622,16 @@ struct ice_pf {
  * Cache devargs parse result.
  */
 struct ice_devargs {
-       int rx_low_latency;
-       int safe_mode_support;
+       bool rx_low_latency;
+       bool safe_mode_support;
        uint8_t proto_xtr_dflt;
-       uint8_t default_mac_disable;
+       bool default_mac_disable;
        uint8_t proto_xtr[ICE_MAX_QUEUE_NUM];
        uint8_t pin_idx;
        uint8_t pps_out_ena;
-       uint8_t ddp_load_sched;
+       bool ddp_load_sched;
        uint8_t tm_exposed_levels;
-       uint8_t source_prune;
+       bool source_prune;
        uint32_t rl_burst_size;
        int link_state_on_close;
        int xtr_field_offs;
-- 
2.53.0

Reply via email to