]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ice: Use FIELD_PREP for timestamp values
authorKarol Kolacinski <karol.kolacinski@intel.com>
Mon, 30 Sep 2024 12:12:40 +0000 (14:12 +0200)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Mon, 10 Feb 2025 18:43:47 +0000 (10:43 -0800)
Instead of using shifts and casts, use FIELD_PREP after reading 40b
timestamp values.

Rename a couple defines for better clarity and consistency.

Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com>
Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ice/ice_ptp_hw.c
drivers/net/ethernet/intel/ice/ice_ptp_hw.h

index 8475d422f1ec41955d27292ea9601e1358c3cf58..a2a666e6df863628bbcd7958dde606c5a7dafbac 100644 (file)
@@ -1576,9 +1576,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 = FIELD_PREP(TS_PHY_HIGH_M, hi) |
-                 FIELD_PREP(TS_PHY_LOW_M, lo);
-
+       *tstamp = FIELD_PREP(PHY_40B_HIGH_M, hi) |
+                 FIELD_PREP(PHY_40B_LOW_M, lo);
        return 0;
 }
 
@@ -3213,7 +3212,8 @@ ice_read_phy_tstamp_e82x(struct ice_hw *hw, u8 quad, u8 idx, u64 *tstamp)
         * lower 8 bits in the low register, and the upper 32 bits in the high
         * register.
         */
-       *tstamp = FIELD_PREP(TS_PHY_HIGH_M, hi) | FIELD_PREP(TS_PHY_LOW_M, lo);
+       *tstamp = FIELD_PREP(PHY_40B_HIGH_M, hi) |
+                 FIELD_PREP(PHY_40B_LOW_M, lo);
 
        return 0;
 }
@@ -4979,7 +4979,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;
 }
index 6b46794075584477b82ffd36c12364237dcdccc8..4381ef4a6c771a82477e306dd85c624c7aba0587 100644 (file)
@@ -652,15 +652,16 @@ static inline bool ice_is_dual(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                   GENMASK(7, 0)
-#define TS_PHY_HIGH_M                  GENMASK_ULL(39, 8)
-
 #define BYTES_PER_IDX_ADDR_L_U         8
 #define BYTES_PER_IDX_ADDR_L           4