Commit cd3ee739 authored by Jean-Claude BAU's avatar Jean-Claude BAU Committed by Adam Wujek

Implement one-step clock for HA & WR profiles

The one-step clock didn't work for HA & WR profiles. This new
implementation is based on a new hook "handle_sync" called in case of
one-step clock mode.
parent 2caf77d5
......@@ -213,6 +213,7 @@ struct pp_ext_hooks {
void (*s1)(struct pp_instance *ppi, struct pp_frgn_master *frgn_master);
int (*execute_slave)(struct pp_instance *ppi);
int (*handle_announce)(struct pp_instance *ppi);
int (*handle_sync)(struct pp_instance *ppi, struct pp_time *orig);
int (*handle_followup)(struct pp_instance *ppi, struct pp_time *orig);
int (*handle_preq) (struct pp_instance * ppi);
int (*handle_presp) (struct pp_instance * ppi);
......
......@@ -173,13 +173,9 @@ static int l1e_handle_resp(struct pp_instance *ppi)
return 0;
}
/* Hmm... "execute_slave" should look for errors; but it's off in WR too */
static int l1e_handle_followup(struct pp_instance *ppi,
struct pp_time *t1)
{
static int l1e_sync_followup(struct pp_instance *ppi, struct pp_time *t1) {
l1e_ext_portDS_t *pds=L1E_DSPOR(ppi);
pp_diag(ppi, ext, 2, "hook: %s\n", __func__);
if ((pds->basic.L1SyncState != L1SYNC_UP) || !pds->head.extModeOn )
return 0;
......@@ -191,6 +187,23 @@ static int l1e_handle_followup(struct pp_instance *ppi,
return 1; /* the caller returns too */
}
/* Hmm... "execute_slave" should look for errors; but it's off in WR too */
static int l1e_handle_followup(struct pp_instance *ppi,
struct pp_time *t1)
{
/* This handle is called in case of two step clock */
pp_diag(ppi, ext, 2, "hook: %s\n", __func__);
return l1e_sync_followup(ppi,t1);
}
static int l1e_handle_sync(struct pp_instance *ppi,
struct pp_time *t1)
{
/* This handle is called in case of one step clock */
pp_diag(ppi, ext, 2, "hook: %s\n", __func__);
return l1e_sync_followup(ppi,t1);
}
static __attribute__((used)) int l1e_handle_presp(struct pp_instance *ppi)
{
struct pp_time *ofm = &SRV(ppi)->offsetFromMaster;
......@@ -260,6 +273,7 @@ struct pp_ext_hooks l1e_ext_hooks = {
.run_ext_state_machine = l1e_run_state_machine,
.ready_for_slave = l1e_ready_for_slave,
.handle_resp = l1e_handle_resp,
.handle_sync = l1e_handle_sync,
.handle_followup = l1e_handle_followup,
#if CONFIG_HAS_P2P
.handle_presp = l1e_handle_presp,
......
......@@ -187,10 +187,8 @@ static int wr_handle_announce(struct pp_instance *ppi)
return 0;
}
static int wr_handle_followup(struct pp_instance *ppi,
struct pp_time *t1) /* t1 == &ppi->t1 */
{
pp_diag(ppi, ext, 2, "hook: %s\n", __func__);
static int wr_sync_followup(struct pp_instance *ppi, struct pp_time *t1) {
if (!WR_DSPOR(ppi)->head.extModeOn)
return 0;
......@@ -202,6 +200,20 @@ static int wr_handle_followup(struct pp_instance *ppi,
return 1; /* the caller returns too */
}
static int wr_handle_sync(struct pp_instance *ppi, struct pp_time *t1)
{
/* This handle is called in case of one step clock */
pp_diag(ppi, ext, 2, "hook: %s\n", __func__);
return wr_sync_followup(ppi,t1);
}
static int wr_handle_followup(struct pp_instance *ppi, struct pp_time *t1)
{
/* This handle is called in case of two step clock */
pp_diag(ppi, ext, 2, "hook: %s\n", __func__);
return wr_sync_followup(ppi,t1);
}
static __attribute__((used)) int wr_handle_presp(struct pp_instance *ppi)
{
struct wr_dsport *wrp = WR_DSPOR(ppi);
......@@ -326,6 +338,7 @@ struct pp_ext_hooks wr_ext_hooks = {
.s1 = wr_s1,
.execute_slave = wr_execute_slave,
.handle_announce = wr_handle_announce,
.handle_sync = wr_handle_sync,
.handle_followup = wr_handle_followup,
#if CONFIG_HAS_P2P
.handle_presp = wr_handle_presp,
......
......@@ -38,6 +38,7 @@ static int slave_handle_sync(struct pp_instance *ppi, void *buf,
{
MsgHeader *hdr = &ppi->received_ptp_header;
MsgSync sync;
int ret;
if (!msg_from_current_master(ppi))
return 0;
......@@ -64,6 +65,13 @@ static int slave_handle_sync(struct pp_instance *ppi, void *buf,
ppi->t1 = sync.originTimestamp;
pp_time_add(&ppi->t1, &hdr->cField);
ppi->syncCF = 0;
/* Call the extension; it may do it all and ask to return */
if (ppi->ext_hooks->handle_sync)
ret = ppi->ext_hooks->handle_sync(ppi, &ppi->t1);
if (ret == 1)
return 0;
if (ret < 0)
return ret;
if (CONFIG_HAS_P2P && ppi->delayMechanism == P2P)
pp_servo_got_psync(ppi);
else
......
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