/* The scaled_ppm parameter is ppm (parts per million) with a 16-bit fractional * part, which means that a value of 1 in one of those fields actually means * 2^-16 ppm, and 2^16=65536 is 1 ppm.
*/ #define PTP_SCALE_FACTOR 65536000000ULL
/* If the difference is above the threshold, assume it's a wraparound. * Otherwise assume it's an old read and ignore it.
*/ if (gp2 < mld->ptp_data.last_gp2) { if (mld->ptp_data.last_gp2 - gp2 <
IWL_PTP_WRAP_THRESHOLD_USEC) {
IWL_DEBUG_PTP(mld, "PTP: ignore old read (gp2=%u, last_gp2=%u)\n",
gp2, mld->ptp_data.last_gp2); return;
}
mld->ptp_data.wrap_counter++;
IWL_DEBUG_PTP(mld, "PTP: wraparound detected (new counter=%u)\n",
mld->ptp_data.wrap_counter);
}
/* It is possible that a GP2 timestamp was received from fw before the * last scale update.
*/ if (base_time_ns < scale_time_gp2_ns) {
diff = scale_time_gp2_ns - base_time_ns;
scaled_diff = -mul_u64_u64_div_u64(diff,
data->scaled_freq,
PTP_SCALE_FACTOR);
} else {
diff = base_time_ns - scale_time_gp2_ns;
scaled_diff = mul_u64_u64_div_u64(diff,
data->scaled_freq,
PTP_SCALE_FACTOR);
}
/* Must call iwl_mld_ptp_get_adj_time() before updating * data->scale_update_gp2 or data->scaled_freq since * scale_update_adj_time_ns should reflect the previous scaled_freq.
*/ if (iwl_mld_get_systime(mld, &gp2)) {
IWL_DEBUG_PTP(mld, "adjfine: failed to read systime\n"); return -EBUSY;
}
/* scale_update_adj_time_ns now relects the configured delta, the * wrap_counter and the previous scaled frequency. Thus delta and * wrap_counter should be reset, and the scale frequency is updated * to the new frequency.
*/
data->delta = 0;
data->wrap_counter = 0;
data->scaled_freq = PTP_SCALE_FACTOR + scaled_ppm;
IWL_DEBUG_PTP(mld, "adjfine: scaled_ppm=%ld new=%llu\n",
scaled_ppm, (unsignedlonglong)data->scaled_freq);
spin_unlock_bh(&data->lock); return 0;
}
/* Give a short 'friendly name' to identify the PHC clock */
snprintf(mld->ptp_data.ptp_clock_info.name, sizeof(mld->ptp_data.ptp_clock_info.name), "%s", "iwlwifi-PTP");
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.