/* Period of refresh of top bits of timestamp, give ourselves a 8x margin. *Thisshouldtranslatetoonceaminute. *Theuseofnsecs_to_jiffies()shouldbesafefora<=40bnsecvalue.
*/ #define FBNIC_TS_HIGH_REFRESH_JIF nsecs_to_jiffies((1ULL << 40) / 16)
/* This function is "slow" because we could try guessing which high part *iscorrectbasedonlowinsteadofre-reading,andskipreading@hi *twicealtogetherif@loisfarenoughfrom0.
*/ static u64 __fbnic_time_get_slow(struct fbnic_dev *fbd)
{
u32 hi, lo;
lockdep_assert_held(&fbd->time_lock);
do {
hi = fbnic_rd32(fbd, FBNIC_PTP_CTR_VAL_HI);
lo = fbnic_rd32(fbd, FBNIC_PTP_CTR_VAL_LO);
} while (hi != fbnic_rd32(fbd, FBNIC_PTP_CTR_VAL_HI));
spin_lock_irqsave(&fbd->time_lock, flags);
hi = fbnic_rd32(fbn->fbd, FBNIC_PTP_CTR_VAL_HI); if (!fbnic_present(fbd)) goto out; /* Don't bother handling, reset is pending */ /* Let's keep high cached value a bit lower to avoid race with *incomingtimestamps.Thelogicinfbnic_ts40_to_ns()will *takecareofoverflowinthiscase.Itwillmakecachedtime *~1minutelowerandincomingtimestampwillalwaysbelater *thencachedtime.
*/
WRITE_ONCE(fbn->time_high, hi - 16);
fbd->last_read = jiffies;
out:
spin_unlock_irqrestore(&fbd->time_lock, flags);
}
/* d_clock is 600 MHz; which in Q16.32 fixed point ns is: */
dclk_period = (((u64)1000000000) << 32) / FBNIC_CLOCK_FREQ;
addend = adjust_by_scaled_ppm(dclk_period, scaled_ppm);
/* Flush, make sure FBNIC_PTP_ADD_VAL_* is stable for at least 4 clks */
fbnic_rd32(fbd, FBNIC_PTP_SPARE);
spin_unlock_irqrestore(&fbd->time_lock, flags);
void fbnic_time_init(struct fbnic_net *fbn)
{ /* This is not really a statistic, but the lockng primitive fits *ourusecaseperfectly,weneedanatomic8bytesREAD_ONCE()/ *WRITE_ONCE()behavior.
*/
u64_stats_init(&fbn->time_seq);
}
int fbnic_time_start(struct fbnic_net *fbn)
{
fbnic_ptp_refresh_time(fbn->fbd, fbn); /* Assume that fbnic_ptp_do_aux_work() will never be called if not *scheduledhere
*/ return ptp_schedule_worker(fbn->fbd->ptp, FBNIC_TS_HIGH_REFRESH_JIF);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.