netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Karol Kolacinski <karol.kolacinski@intel.com>
Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
	anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com
Subject: Re: [PATCH v5 iwl-next 2/6] ice: Use FIELD_PREP for timestamp values
Date: Sat, 10 Aug 2024 09:18:51 +0100	[thread overview]
Message-ID: <20240810081851.GE1951@kernel.org> (raw)
In-Reply-To: <20240808125825.560093-10-karol.kolacinski@intel.com>

On Thu, Aug 08, 2024 at 02:57:44PM +0200, Karol Kolacinski wrote:
> Instead of using shifts and casts, use FIELD_PREP after reading 40b
> timestamp values.
> 
> Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com>
> ---
>  drivers/net/ethernet/intel/ice/ice_ptp_hw.c |  6 ++++--
>  drivers/net/ethernet/intel/ice/ice_ptp_hw.h | 13 +++++--------
>  2 files changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
> index 00c6483dbffc..d1b87838986d 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
> @@ -1520,7 +1520,8 @@ static int ice_read_ptp_tstamp_eth56g(struct ice_hw *hw, u8 port, u8 idx,
>  	 * lower 8 bits in the low register, and the upper 32 bits in the high
>  	 * register.
>  	 */
> -	*tstamp = ((u64)hi) << TS_PHY_HIGH_S | ((u64)lo & TS_PHY_LOW_M);
> +	*tstamp = FIELD_PREP(PHY_40B_HIGH_M, hi) |
> +		  FIELD_PREP(PHY_40B_LOW_M, lo);
>  
>  	return 0;
>  }
> @@ -4952,7 +4953,8 @@ ice_read_phy_tstamp_e810(struct ice_hw *hw, u8 lport, u8 idx, u64 *tstamp)
>  	/* For E810 devices, the timestamp is reported with the lower 32 bits
>  	 * in the low register, and the upper 8 bits in the high register.
>  	 */
> -	*tstamp = ((u64)hi) << TS_HIGH_S | ((u64)lo & TS_LOW_M);
> +	*tstamp = FIELD_PREP(PHY_EXT_40B_HIGH_M, hi) |
> +		  FIELD_PREP(PHY_EXT_40B_LOW_M, lo);
>  
>  	return 0;
>  }
> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.h b/drivers/net/ethernet/intel/ice/ice_ptp_hw.h
> index 8a28155b206f..df94230d820f 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.h
> +++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.h
> @@ -673,15 +673,12 @@ static inline u64 ice_get_base_incval(struct ice_hw *hw)
>  /* Source timer incval macros */
>  #define INCVAL_HIGH_M			0xFF
>  
> -/* Timestamp block macros */
> +/* PHY 40b registers macros */
> +#define PHY_EXT_40B_LOW_M		GENMASK(31, 0)
> +#define PHY_EXT_40B_HIGH_M		GENMASK_ULL(39, 32)
> +#define PHY_40B_LOW_M			GENMASK(7, 0)
> +#define PHY_40B_HIGH_M			GENMASK_ULL(39, 8)
>  #define TS_VALID			BIT(0)
> -#define TS_LOW_M			0xFFFFFFFF
> -#define TS_HIGH_M			0xFF
> -#define TS_HIGH_S			32
> -
> -#define TS_PHY_LOW_M			0xFF
> -#define TS_PHY_HIGH_M			0xFFFFFFFF

I think it it would be best to defer removing (at least)
TS_PHY_LOW_M and TS_PHY_HIGH_M until the following patch,
as they are still in use until then.

As is, this patch results in build failures.

> -#define TS_PHY_HIGH_S			8
>  
>  #define BYTES_PER_IDX_ADDR_L_U		8
>  #define BYTES_PER_IDX_ADDR_L		4
> -- 
> 2.45.2
> 
> 

  reply	other threads:[~2024-08-10  8:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-08 12:57 [PATCH v5 iwl-next 0/6] ice: Implement PTP support for E830 devices Karol Kolacinski
2024-08-08 12:57 ` [PATCH v5 iwl-next 1/6] ice: Remove unncecessary ice_is_e8xx() functions Karol Kolacinski
2024-08-08 12:57 ` [PATCH v5 iwl-next 2/6] ice: Use FIELD_PREP for timestamp values Karol Kolacinski
2024-08-10  8:18   ` Simon Horman [this message]
2024-08-08 12:57 ` [PATCH v5 iwl-next 3/6] ice: Implement PTP support for E830 devices Karol Kolacinski
2024-08-08 12:57 ` [PATCH v5 iwl-next 4/6] ice: Process TSYN IRQ in a separate function Karol Kolacinski
2024-08-08 12:57 ` [PATCH v5 iwl-next 5/6] ice: Add timestamp ready bitmap for E830 products Karol Kolacinski
2024-08-08 12:57 ` [PATCH v5 iwl-next 6/6] ice: combine cross timestamp functions for E82x and E830 Karol Kolacinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240810081851.GE1951@kernel.org \
    --to=horms@kernel.org \
    --cc=anthony.l.nguyen@intel.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=karol.kolacinski@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=przemyslaw.kitszel@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).