[v2,125/148] net/ice/base: fix compile issues on some targets

Message ID c0e2b6c3464f5cc84d5f93b7060bed08159428cb.1718204529.git.anatoly.burakov@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Bruce Richardson
Headers
Series Update net/ice base driver to latest upstream snapshot |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Burakov, Anatoly June 12, 2024, 3:01 p.m. UTC
To avoid triggering compile errors reported on some targets, use
explicit type casts to specify type conversion.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 drivers/net/ice/base/ice_flow.h   | 2 +-
 drivers/net/ice/base/ice_parser.c | 7 ++++---
 drivers/net/ice/base/ice_ptp_hw.c | 9 +++++----
 drivers/net/ice/base/ice_switch.c | 7 ++++---
 4 files changed, 14 insertions(+), 11 deletions(-)
  

Comments

Bruce Richardson June 18, 2024, 5:05 p.m. UTC | #1
On Wed, Jun 12, 2024 at 04:01:59PM +0100, Anatoly Burakov wrote:
> To avoid triggering compile errors reported on some targets, use
> explicit type casts to specify type conversion.
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
>  drivers/net/ice/base/ice_flow.h   | 2 +-
>  drivers/net/ice/base/ice_parser.c | 7 ++++---
>  drivers/net/ice/base/ice_ptp_hw.c | 9 +++++----
>  drivers/net/ice/base/ice_switch.c | 7 ++++---
>  4 files changed, 14 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/ice/base/ice_flow.h b/drivers/net/ice/base/ice_flow.h
> index fd2ec39c1e..65b261beca 100644
> --- a/drivers/net/ice/base/ice_flow.h
> +++ b/drivers/net/ice/base/ice_flow.h
> @@ -485,7 +485,7 @@ struct ice_flow_entry {
>  	u8 acts_cnt;
>  };
>  
> -#define ICE_FLOW_ENTRY_HNDL(e)	((intptr_t)e)
> +#define ICE_FLOW_ENTRY_HNDL(e)	((u64)e)
>  #define ICE_FLOW_ENTRY_PTR(h)	((struct ice_flow_entry *)(h))
>  
>  struct ice_flow_prof {
> diff --git a/drivers/net/ice/base/ice_parser.c b/drivers/net/ice/base/ice_parser.c
> index c9bcf9ea5e..e242fa8353 100644
> --- a/drivers/net/ice/base/ice_parser.c
> +++ b/drivers/net/ice/base/ice_parser.c
> @@ -96,7 +96,7 @@ void *ice_parser_sect_item_get(u32 sect_type, void *section,
>  	if (index >= LE16_TO_CPU(hdr->count))
>  		return NULL;
>  
> -	return (void *)((uintptr_t)section + data_off + index * size);
> +	return (void *)((u64)section + data_off + index * size);
>  }
>  

This change (and below) gives compilation errors with 32-bit, since you are
casting from a 64-bit int to a 32-bit pointer. Better to keep as uintptr_t.


>  /**
> @@ -146,9 +146,10 @@ void *ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
>  			if (no_offset)
>  				idx++;
>  			else
> -				idx = hdr->offset + state.entry_idx;
> +				idx = LE16_TO_CPU(hdr->offset) +
> +							state.entry_idx;
>  			parse_item(hw, idx,
> -				   (void *)((uintptr_t)table + idx * item_size),
> +				   (void *)((u64)table + idx * item_size),
>  				   data, item_size);
>  		}
>  	} while (data);

/Bruce
  

Patch

diff --git a/drivers/net/ice/base/ice_flow.h b/drivers/net/ice/base/ice_flow.h
index fd2ec39c1e..65b261beca 100644
--- a/drivers/net/ice/base/ice_flow.h
+++ b/drivers/net/ice/base/ice_flow.h
@@ -485,7 +485,7 @@  struct ice_flow_entry {
 	u8 acts_cnt;
 };
 
-#define ICE_FLOW_ENTRY_HNDL(e)	((intptr_t)e)
+#define ICE_FLOW_ENTRY_HNDL(e)	((u64)e)
 #define ICE_FLOW_ENTRY_PTR(h)	((struct ice_flow_entry *)(h))
 
 struct ice_flow_prof {
diff --git a/drivers/net/ice/base/ice_parser.c b/drivers/net/ice/base/ice_parser.c
index c9bcf9ea5e..e242fa8353 100644
--- a/drivers/net/ice/base/ice_parser.c
+++ b/drivers/net/ice/base/ice_parser.c
@@ -96,7 +96,7 @@  void *ice_parser_sect_item_get(u32 sect_type, void *section,
 	if (index >= LE16_TO_CPU(hdr->count))
 		return NULL;
 
-	return (void *)((uintptr_t)section + data_off + index * size);
+	return (void *)((u64)section + data_off + index * size);
 }
 
 /**
@@ -146,9 +146,10 @@  void *ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
 			if (no_offset)
 				idx++;
 			else
-				idx = hdr->offset + state.entry_idx;
+				idx = LE16_TO_CPU(hdr->offset) +
+							state.entry_idx;
 			parse_item(hw, idx,
-				   (void *)((uintptr_t)table + idx * item_size),
+				   (void *)((u64)table + idx * item_size),
 				   data, item_size);
 		}
 	} while (data);
diff --git a/drivers/net/ice/base/ice_ptp_hw.c b/drivers/net/ice/base/ice_ptp_hw.c
index 48d60b7731..13bcd1de27 100644
--- a/drivers/net/ice/base/ice_ptp_hw.c
+++ b/drivers/net/ice/base/ice_ptp_hw.c
@@ -4027,7 +4027,7 @@  ice_phy_calc_pmd_adj_e822(struct ice_hw *hw, u8 port,
 			return err;
 		}
 
-		rx_cycle = val & P_REG_RX_80_TO_160_CNT_RXCYC_M;
+		rx_cycle = (u8)(val & P_REG_RX_80_TO_160_CNT_RXCYC_M);
 		if (rx_cycle) {
 			mult = rx_cycle * 40;
 
@@ -5850,13 +5850,14 @@  int ice_ptp_init_time(struct ice_hw *hw, u64 time, bool wr_main_tmr)
 	/* Fill Rx and Tx ports and send msg to PHY */
 	switch (hw->phy_model) {
 	case ICE_PHY_ETH56G:
-		err = ice_ptp_prep_phy_time_eth56g(hw, time & 0xFFFFFFFF);
+		err = ice_ptp_prep_phy_time_eth56g(hw,
+						   (u32)(time & 0xFFFFFFFF));
 		break;
 	case ICE_PHY_E810:
-		err = ice_ptp_prep_phy_time_e810(hw, time & 0xFFFFFFFF);
+		err = ice_ptp_prep_phy_time_e810(hw, (u32)(time & 0xFFFFFFFF));
 		break;
 	case ICE_PHY_E822:
-		err = ice_ptp_prep_phy_time_e822(hw, time & 0xFFFFFFFF);
+		err = ice_ptp_prep_phy_time_e822(hw, (u32)(time & 0xFFFFFFFF));
 		break;
 	default:
 		err = ICE_ERR_NOT_SUPPORTED;
diff --git a/drivers/net/ice/base/ice_switch.c b/drivers/net/ice/base/ice_switch.c
index 2305707920..0b946444ee 100644
--- a/drivers/net/ice/base/ice_switch.c
+++ b/drivers/net/ice/base/ice_switch.c
@@ -7794,7 +7794,8 @@  ice_add_sw_recipe(struct ice_hw *hw, struct ice_sw_recipe *rm,
 		}
 
 		for (i = 0; i < entry->r_group.n_val_pairs; i++) {
-			buf[recps].content.lkup_indx[i + 1] = entry->fv_idx[i];
+			buf[recps].content.lkup_indx[i + 1] =
+				(u8)entry->fv_idx[i];
 			buf[recps].content.mask[i + 1] =
 				CPU_TO_LE16(entry->fv_mask[i]);
 		}
@@ -7815,8 +7816,8 @@  ice_add_sw_recipe(struct ice_hw *hw, struct ice_sw_recipe *rm,
 				((chain_idx << ICE_AQ_RECIPE_RESULT_DATA_S) &
 				 ICE_AQ_RECIPE_RESULT_DATA_M);
 			ice_clear_bit(chain_idx, result_idx_bm);
-			chain_idx = ice_find_first_bit(result_idx_bm,
-						       ICE_MAX_FV_WORDS);
+			chain_idx = (u8)ice_find_first_bit(result_idx_bm,
+							   ICE_MAX_FV_WORDS);
 		}
 
 		/* fill recipe dependencies */