[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140919073820.GA5954@netboy>
Date: Fri, 19 Sep 2014 09:38:20 +0200
From: Richard Cochran <richardcochran@...il.com>
To: Alexander Duyck <alexander.h.duyck@...el.com>
Cc: davem@...emloft.net, nhorman@...hat.com, netdev@...r.kernel.org,
john.fastabend@...il.com, matthew.vick@...el.com,
jeffrey.t.kirsher@...el.com, sassmann@...hat.com
Subject: Re: [net-next PATCH 28/29] fm10k: Add support for ptp to hw specific
files
On Thu, Sep 18, 2014 at 06:40:30PM -0400, Alexander Duyck wrote:
> +static s32 fm10k_adjust_systime_pf(struct fm10k_hw *hw, s32 ppb)
> +{
> + u64 systime_adjust;
> +
> + /* if sw_addr is not set we don't have switch register access */
> + if (!hw->sw_addr)
> + return ppb ? FM10K_ERR_PARAM : 0;
> +
> + /* we must convert the value from parts per billion to parts per
> + * 2^48 cycles. In addition we can only use the upper 30 bits of
> + * the value when making the change so that restricts us futher.
> + * The math for this is equivilent to ABS(pps) * 2^40 / 10 ^ 9,
Huh? Converting ppb to parts per 2^48 should be (ppb * 2^48 / 10^9),
shouldn't it?
Did you mean, "we must convert ... to parts per 2^40 cycles" ?
Also, the comment about using the upper 30 bits is not clear. Do you
mean that the hardware ignores the two least significant bits?
> + * the function below is roughly ABS(pps) * 2 ^ 31 / 5 ^ 9 which
> + * is as close as we can get to the exact value with numbers as
> + * small as possible.
> + */
> + systime_adjust = (ppb < 0) ? -ppb : ppb;
> + systime_adjust <<= 31;
> + do_div(systime_adjust, 1953125);
> +
> + /* verify the requested adjustment value is in range */
> + if (systime_adjust > FM10K_SW_SYSTIME_ADJUST_MASK)
> + return FM10K_ERR_PARAM;
> +
> + if (ppb < 0)
> + systime_adjust |= FM10K_SW_SYSTIME_ADJUST_DIR_NEGATIVE;
> +
> + fm10k_write_sw_reg(hw, FM10K_SW_SYSTIME_ADJUST, (u32)systime_adjust);
> +
> + return 0;
> +}
Thanks,
Richard
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists