Skip to content

Commit cf5fcc7

Browse files
committed
ice: Use FIELD_PREP for timestamp values
JIRA: https://issues.redhat.com/browse/RHEL-89579 Upstream commit(s): commit ea7029f Author: Karol Kolacinski <karol.kolacinski@intel.com> Date: Mon Sep 30 14:12:40 2024 +0200 ice: Use FIELD_PREP for timestamp values 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> Signed-off-by: Petr Oros <poros@redhat.com>
1 parent e6989b2 commit cf5fcc7

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

drivers/net/ethernet/intel/ice/ice_ptp_hw.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,9 +1576,8 @@ static int ice_read_ptp_tstamp_eth56g(struct ice_hw *hw, u8 port, u8 idx,
15761576
* lower 8 bits in the low register, and the upper 32 bits in the high
15771577
* register.
15781578
*/
1579-
*tstamp = FIELD_PREP(TS_PHY_HIGH_M, hi) |
1580-
FIELD_PREP(TS_PHY_LOW_M, lo);
1581-
1579+
*tstamp = FIELD_PREP(PHY_40B_HIGH_M, hi) |
1580+
FIELD_PREP(PHY_40B_LOW_M, lo);
15821581
return 0;
15831582
}
15841583

@@ -3213,7 +3212,8 @@ ice_read_phy_tstamp_e82x(struct ice_hw *hw, u8 quad, u8 idx, u64 *tstamp)
32133212
* lower 8 bits in the low register, and the upper 32 bits in the high
32143213
* register.
32153214
*/
3216-
*tstamp = FIELD_PREP(TS_PHY_HIGH_M, hi) | FIELD_PREP(TS_PHY_LOW_M, lo);
3215+
*tstamp = FIELD_PREP(PHY_40B_HIGH_M, hi) |
3216+
FIELD_PREP(PHY_40B_LOW_M, lo);
32173217

32183218
return 0;
32193219
}
@@ -4979,7 +4979,8 @@ ice_read_phy_tstamp_e810(struct ice_hw *hw, u8 lport, u8 idx, u64 *tstamp)
49794979
/* For E810 devices, the timestamp is reported with the lower 32 bits
49804980
* in the low register, and the upper 8 bits in the high register.
49814981
*/
4982-
*tstamp = ((u64)hi) << TS_HIGH_S | ((u64)lo & TS_LOW_M);
4982+
*tstamp = FIELD_PREP(PHY_EXT_40B_HIGH_M, hi) |
4983+
FIELD_PREP(PHY_EXT_40B_LOW_M, lo);
49834984

49844985
return 0;
49854986
}

drivers/net/ethernet/intel/ice/ice_ptp_hw.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -654,15 +654,16 @@ static inline bool ice_is_dual(struct ice_hw *hw)
654654
/* Source timer incval macros */
655655
#define INCVAL_HIGH_M 0xFF
656656

657-
/* Timestamp block macros */
657+
/* PHY 40b registers macros */
658+
#define PHY_EXT_40B_LOW_M GENMASK(31, 0)
659+
#define PHY_EXT_40B_HIGH_M GENMASK_ULL(39, 32)
660+
#define PHY_40B_LOW_M GENMASK(7, 0)
661+
#define PHY_40B_HIGH_M GENMASK_ULL(39, 8)
658662
#define TS_VALID BIT(0)
659663
#define TS_LOW_M 0xFFFFFFFF
660664
#define TS_HIGH_M 0xFF
661665
#define TS_HIGH_S 32
662666

663-
#define TS_PHY_LOW_M GENMASK(7, 0)
664-
#define TS_PHY_HIGH_M GENMASK_ULL(39, 8)
665-
666667
#define BYTES_PER_IDX_ADDR_L_U 8
667668
#define BYTES_PER_IDX_ADDR_L 4
668669

0 commit comments

Comments
 (0)