Commit f8cf1be3 authored by Adam Wujek's avatar Adam Wujek 💬

proto-ext-whiterabbit: retry when spll calibration is not ready

In WRPC calibration took too long, it was possible that some frames received
(including PTP) on a network interface were lost due to RX fifo beeing full.
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent b6c53e91
......@@ -19,6 +19,7 @@ int wrpc_spll_locking_enable(struct pp_instance *ppi)
{
spll_init(SPLL_MODE_SLAVE, 0, 1);
spll_enable_ptracker(0, 1);
rxts_calibration_start();
return WR_SPLL_OK;
}
......@@ -39,7 +40,7 @@ int wrpc_spll_locking_poll(struct pp_instance *ppi, int grandmaster)
else if(locked && !t24p_calibrated) {
/*run t24p calibration if needed*/
if (calib_t24p(WRC_MODE_SLAVE, &cal_phase_transition) < 0)
return WR_SPLL_ERROR;
return WR_SPLL_CALIB_NOT_READY;
t24p_calibrated = 1;
}
......
......@@ -37,9 +37,10 @@ static inline struct hal_port_state *pp_wrs_lookup_port(char *name)
* whole ppsi */
/* White Rabbit softpll status values */
#define WR_SPLL_OK 0
#define WR_SPLL_READY 1
#define WR_SPLL_ERROR -1
#define WR_SPLL_OK 0
#define WR_SPLL_READY 1
#define WR_SPLL_CALIB_NOT_READY 2
#define WR_SPLL_ERROR -1
/* White Rabbit calibration defines */
#define WR_HW_CALIB_TX 1
......
......@@ -13,6 +13,7 @@ int wr_s_lock(struct pp_instance *ppi, unsigned char *pkt, int plen)
{
struct wr_dsport *wrp = WR_DSPOR(ppi);
int enable = 0;
int poll_ret;
if (ppi->is_new_state) {
wrp->wrStateRetry = WR_STATE_RETRY;
......@@ -30,11 +31,17 @@ int wr_s_lock(struct pp_instance *ppi, unsigned char *pkt, int plen)
__pp_timeout_set(ppi, PP_TO_EXT_0, WR_S_LOCK_TIMEOUT_MS);
}
if (wrp->ops->locking_poll(ppi, 0) == WR_SPLL_READY) {
ppi->next_delay = wrp->wrStateTimeout;
poll_ret = wrp->ops->locking_poll(ppi, 0);
if (poll_ret == WR_SPLL_READY) {
ppi->next_state = WRS_LOCKED;
wrp->ops->locking_disable(ppi);
} else if (poll_ret == WR_SPLL_CALIB_NOT_READY) {
/* rxts_calibration not ready, enter the same state without
* a delay */
ppi->next_delay = 0;
}
ppi->next_delay = wrp->wrStateTimeout;
return 0;
}
......@@ -49,9 +49,10 @@
#define WR_DEFAULT_PHY_CALIBRATION_REQUIRED FALSE
/* White Rabbit softpll status values */
#define WR_SPLL_OK 0
#define WR_SPLL_READY 1
#define WR_SPLL_ERROR -1
#define WR_SPLL_OK 0
#define WR_SPLL_READY 1
#define WR_SPLL_CALIB_NOT_READY 2
#define WR_SPLL_ERROR -1
/* White Rabbit calibration defines */
#define WR_HW_CALIB_TX 1
......
......@@ -65,7 +65,7 @@ void msg_pack_announce_wr_tlv(struct pp_instance *ppi)
/* GM: update clock Class, according to whether we are locked or not */
if (class < PP_CLASS_DEFAULT) {
locked = wrp->ops->locking_poll(ppi, 1);
if (locked > 0)
if (locked == WR_SPLL_READY)
class = PP_CLASS_WR_GM_LOCKED;
else
class = PP_CLASS_WR_GM_UNLOCKED;
......
......@@ -402,6 +402,7 @@ int wr_servo_update(struct pp_instance *ppi)
struct pp_time ts_offset;
int32_t ts_offset_ticks;
int32_t ts_offset_picos;
int locking_poll_ret;
if (!got_sync)
return 0;
......@@ -424,8 +425,9 @@ int wr_servo_update(struct pp_instance *ppi)
(long)ts_offset.secs, (long)ts_offset_ticks,
(long)ts_offset_picos);
if (wrp->ops->locking_poll(ppi, 0) != WR_SPLL_READY) {
locking_poll_ret = wrp->ops->locking_poll(ppi, 0);
if (locking_poll_ret != WR_SPLL_READY
&& locking_poll_ret != WR_SPLL_CALIB_NOT_READY) {
pp_diag(ppi, servo, 1, "PLL OutOfLock, should restart sync\n");
wrp->ops->enable_timing_output(ppi, 0);
/* TODO check
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment