mlxsw: update adjfine to use adjust_by_scaled_ppm
Subsystems (3)
PATCH 1/1 mlxsw: update adjfine to use adjust_by_scaled_ppm
The mlxsw adjfine implementation in the spectrum_ptp.c file converts scaled_ppm into ppb before updating a cyclecounter multiplier using the standard "base * ppb / 1billion" calculation.
This can be re-written to use adjust_by_scaled_ppm, directly using the scaled parts per million and reducing the amount of code required to express this calculation.
We still calculate the parts per billion for passing into mlxsw_sp_ptp_phc_adjfreq because this function requires the input to be in parts per billion.
---
Noticed this while investigating conversion of max_adj to scaled PPM format. This was missed in the previous round of updates that modified drivers to use the adjust_by_scaled_ppm interface.
.../net/ethernet/mellanox/mlxsw/spectrum_ptp.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c +3 -15
@@ -189,29 +189,17 @@ mlxsw_sp1_ptp_phc_settime(struct mlxsw_sp1_ptp_clock *clock, u64 nsec)static int mlxsw_sp1_ptp_adjfine (struct ptp_clock_info *ptp,long scaled_ppm) {struct mlxsw_sp1_ptp_clock *clock =mlxsw_sp1_ptp_clock (ptp); -int neg_adj =0 ; -u32 diff; -u64 adj;s32 ppb; ppb =scaled_ppm_to_ppb (scaled_ppm); -if (ppb <0 ) { - neg_adj =1 ; - ppb = -ppb; - } - - adj = clock->nominal_c_mult; - adj *= ppb; - diff =div_u64 (adj,NSEC_PER_SEC ); -spin_lock_bh (&clock->lock);timecounter_read (&clock->tc); - clock->cycles.mult = neg_adj ? clock->nominal_c_mult - diff : - clock->nominal_c_mult + diff; + clock->cycles.mult =adjust_by_scaled_ppm (clock->nominal_c_mult, + scaled_ppm);spin_unlock_bh (&clock->lock); -return mlxsw_sp_ptp_phc_adjfreq (&clock->common, neg_adj ? -ppb : ppb); +return mlxsw_sp_ptp_phc_adjfreq (&clock->common, ppb); }static int mlxsw_sp1_ptp_adjtime (struct ptp_clock_info *ptp,s64 delta)
base-commit: f12ed9c04804eec4f1819097a0fd0b4800adac2f
Signature · 1 line
2.38.1.420.g319605f8f00e
Ido Schimmel
maintainerQuoted 8 lines · Jacob Keller
The mlxsw adjfine implementation in the
spectrum_ptp.cfile convertsscaled_ppminto ppb before updating a cyclecounter multiplier using the standard "base * ppb / 1billion" calculation.This can be re-written to use
adjust_by_scaled_ppm, directly using the scaled parts per million and reducing the amount of code required to express this calculation.
Quoted 8 lines
We still calculate the parts per billion for passing into
mlxsw_sp_ptp_phc_adjfreqbecause this function requires the input to be in parts per billion.Signed-off-by Jacob Keller <[email protected]>Cc Amit Cohen <[email protected]>Cc Ido Schimmel <[email protected]>Cc Petr Machata <[email protected]>
Thanks for the patch, code looks good to me.
Petr, please apply this patch to our tree for testing.
Quoted 13 lines · Ido Schimmel
Quoted 12 lines · Jacob Keller
The mlxsw adjfine implementation in the
spectrum_ptp.cfile convertsscaled_ppminto ppb before updating a cyclecounter multiplier using the standard "base * ppb / 1billion" calculation.This can be re-written to use
adjust_by_scaled_ppm, directly using the scaled parts per million and reducing the amount of code required to express this calculation.We still calculate the parts per billion for passing into
mlxsw_sp_ptp_phc_adjfreqbecause this function requires the input to be in parts per billion.
Quoted 8 lines
Quoted 4 lines
Signed-off-by Jacob Keller <[email protected]>Cc Amit Cohen <[email protected]>Cc Ido Schimmel <[email protected]>Cc Petr Machata <[email protected]>Thanks for the patch, code looks good to me.
Petr, please apply this patch to our tree for testing.
Applied. Jacob, we'll let you know tomorrow whether it exploded.
Quoted 8 lines · Jacob Keller
The mlxsw adjfine implementation in the
spectrum_ptp.cfile convertsscaled_ppminto ppb before updating a cyclecounter multiplier using the standard "base * ppb / 1billion" calculation.This can be re-written to use
adjust_by_scaled_ppm, directly using the scaled parts per million and reducing the amount of code required to express this calculation.
Quoted 5 lines
We still calculate the parts per billion for passing into
mlxsw_sp_ptp_phc_adjfreqbecause this function requires the input to be in parts per billion.Signed-off-by Jacob Keller <[email protected]>
Jakub Kicinski
maintainerQuoted 9 lines · On Wed, 16 Nov 2022 10:01:18 +0200 Ido Schimmel wrote:
Quoted 8 lines · Jacob Keller
The mlxsw adjfine implementation in the
spectrum_ptp.cfile convertsscaled_ppminto ppb before updating a cyclecounter multiplier using the standard "base * ppb / 1billion" calculation.This can be re-written to use
adjust_by_scaled_ppm, directly using the scaled parts per million and reducing the amount of code required to express this calculation.
Quoted 8 lines
Quoted 5 lines
We still calculate the parts per billion for passing into
mlxsw_sp_ptp_phc_adjfreqbecause this function requires the input to be in parts per billion.Signed-off-by Jacob Keller <[email protected]>Reviewed-by Ido Schimmel <[email protected]>Tested-by Ido Schimmel <[email protected]>
FTR this patch got marked as 'not applicable' in pw but I'm not sure why, so applying...
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Mon, 14 Nov 2022 13:37:01 -0800 you wrote:
The mlxsw adjfine implementation in the
spectrum_ptp.cfile convertsscaled_ppminto ppb before updating a cyclecounter multiplier using the standard "base * ppb / 1billion" calculation.This can be re-written to use
adjust_by_scaled_ppm, directly using the scaled parts per million and reducing the amount of code required to express this calculation.[...]
Here is the summary with links:
- [net-next] mlxsw: update adjfine to use adjust_by_scaled_ppm
https://git.kernel.org/netdev/net-next/c/d82303df0648
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html