Commit c85d25aa authored by Jean-Claude BAU's avatar Jean-Claude BAU

Update of portDs.meanLinkDelay for P2P mechanism

- Update of portDs.meanLinkDelay for P2P mechanism
- Fix issue updating currentDS.meanDelay
parent 18edcef4
......@@ -279,6 +279,7 @@ typedef struct { /* page 72 */
Integer8 logMinPdelayReqInterval; /*draft P1588_v_29: page 124 */
UInteger4 minorVersionNumber; /*draft P1588_v_29: page 124 */
TimeInterval delayAsymmetry; /*draft P1588_v_29: page 124 */
TimeInterval meanLinkDelay; /* P2P: estimation of the current one-way propagation delay */
/** Optional: */
Boolean portEnable; /*draft P1588_v_29: page 124 */
Boolean masterOnly; /*draft P1588_v_29: page 124 */
......
......@@ -8,6 +8,7 @@
#include <ppsi/ppsi.h>
#include "l1e-constants.h"
#include <libwr/shmem.h>
#include "../proto-standard/common-fun.h"
static const char *l1e_servo_state_name[] = {
[L1E_UNINITIALIZED] = "Uninitialized",
......@@ -267,7 +268,7 @@ static int l1e_p2p_delay(struct pp_instance *ppi, struct l1e_servo_state *s)
s->delayMS_ps = meanLinkDelay_ps + interval_to_picos(ppi->portDS->delayAsymmetry);
picos_to_pp_time(s->delayMS_ps, &SRV(ppi)->delayMS);
DSCUR(ppi)->meanDelay=picos_to_interval(meanLinkDelay_ps); /* update currentDS.meanDelay */
update_meanDelay(ppi,picos_to_interval(meanLinkDelay_ps)); /* update currentDS.meanDelay and portDS.meanLinkDelay (idf needed) */
picos_to_pp_time(meanLinkDelay_ps,&SRV(ppi)->meanDelay); /* update servo.meanDelay */
return 1;
......@@ -378,7 +379,7 @@ static int l1e_e2e_offset(struct pp_instance *ppi, struct l1e_servo_state *s,
DSCUR(ppi)->offsetFromMaster = pp_time_to_interval(offsetMS); /* Update currentDS.offsetFromMaster */
picos_to_pp_time(meanPathDelay_ps,&SRV(ppi)->meanDelay); /* update servo.meanDelay */
DSCUR(ppi)->meanDelay=picos_to_interval(meanPathDelay_ps); /* update currentDS.meanDelay */
update_meanDelay(ppi,picos_to_interval(meanPathDelay_ps)); /* update currentDS.meanDelay and portDS.meanLinkDelay (idf needed) */
return 1;
}
......
#include <ppsi/ppsi.h>
#include <ppsi/assert.h>
#include <libwr/shmem.h>
#include "../proto-standard/common-fun.h"
/* prototypes */
static int wr_p2p_delay(struct pp_instance *ppi, struct wr_servo_state *s);
......@@ -183,12 +184,13 @@ int wr_servo_got_delay(struct pp_instance *ppi)
}
/* update currentDS.meanDelay */
static void update_meanDelay(struct pp_instance *ppi,struct wr_servo_state *s) {
static void calculate_update_meanDelay(struct pp_instance *ppi,struct wr_servo_state *s) {
struct pp_time mtime;
mtime=s->delayMM;
pp_time_div2(&mtime);
DSCUR(ppi)->meanDelay=pp_time_to_interval(&mtime);
update_meanDelay(ppi,pp_time_to_interval(&mtime));
}
/* update currentDS.delayAsymmetry */
......@@ -240,7 +242,7 @@ static int wr_p2p_delay(struct pp_instance *ppi, struct wr_servo_state *s)
+ s->delta_txm_ps + s->delta_rxs_ps;
picos_to_pp_time(s->delayMS_ps,&SRV(ppi)->delayMS);
update_meanDelay(ppi,s); /* update currentDS.meanDelay */
calculate_update_meanDelay(ppi,s); /* calculate and update currentDS.meanDelay & portDS.meanLinkDelay*/
update_delayAsymmetry(ppi,s); /* update currentDS.delayAsymmetry */
return 1;
......@@ -343,7 +345,7 @@ static int wr_e2e_offset(struct pp_instance *ppi,
picos_to_pp_time(s->delayMS_ps,&SRV(ppi)->delayMS);
update_offsetFromMaster(ppi,offset); /* Update currentDS.offsetFromMaster */
update_meanDelay(ppi,s); /* update currentDS.meanDelay */
calculate_update_meanDelay(ppi,s); /* calculate and update currentDS.meanDelay & portDS.meanLinkDelay*/
update_delayAsymmetry(ppi,s); /* update currentDS.delayAsymmetry */
return 1;
......
......@@ -157,4 +157,18 @@ int st_com_peer_handle_preq(struct pp_instance *ppi, void *buf,
return 0;
}
/* Update currentDS.meanDelay and portDS.meanLinkDelay
* This function overwrite the one declared if the P2P mechanism is not compiled
*/
void update_meanDelay(struct pp_instance *ppi, TimeInterval meanDelay) {
/* clause 11.4.2.d.f : the <meanLinkDelay> shall be stored ... for the P2P port in the PTP SLAVE state in currentDS.meanDelay.*/
if ( ppi->delayMechanism==P2P ) {
DSPOR(ppi)->meanLinkDelay=meanDelay;
if ( ppi->state != PPS_SLAVE )
return;
}
DSCUR(ppi)->meanDelay=meanDelay;
}
#endif
......@@ -166,3 +166,12 @@ int __send_and_log(struct pp_instance *ppi, int msglen, int chtype,enum pp_msg_f
return 0;
}
/* Update currentDS.meanDelay
* This function can be redeclared if P2P mechanism is compiled
*/
void __attribute__((weak)) update_meanDelay(struct pp_instance *ppi, TimeInterval meanDelay) {
DSCUR(ppi)->meanDelay=meanDelay;
}
......@@ -18,6 +18,7 @@ int st_com_peer_handle_pres(struct pp_instance *ppi, void *buf, int len);
int st_com_peer_handle_pres_followup(struct pp_instance *ppi, void *buf, int len);
int st_com_handle_announce(struct pp_instance *ppi, void *buf, int len);
int st_com_handle_signaling(struct pp_instance *ppi, void *buf, int len);
void update_meanDelay(struct pp_instance *ppi, TimeInterval meanDelay);
int __send_and_log(struct pp_instance *ppi, int msglen, int chtype,enum pp_msg_format msg_fmt);
......
......@@ -7,6 +7,7 @@
*/
#include <ppsi/ppsi.h>
#include "../proto-standard/common-fun.h"
#ifdef CONFIG_ARCH_WRS
......@@ -180,7 +181,7 @@ void pp_servo_got_resp(struct pp_instance *ppi)
*mpd = SRV(ppi)->delayMS;
pp_time_add(mpd, &SRV(ppi)->delaySM);
pp_time_div2(mpd);
DSCUR(ppi)->meanDelay=pp_time_to_interval (mpd); /* Update currentDS */
update_meanDelay(ppi,pp_time_to_interval(mpd)); /* update currentDS.meanDelay and portDS.meanLinkDelay (idf needed) */
pp_diag(ppi, servo, 1, "meanDelay: %s\n", fmt_ppt(mpd));
if (mpd->secs) {/* Hmm.... we called this "bad event" */
......@@ -249,7 +250,7 @@ void pp_servo_got_presp(struct pp_instance *ppi)
*mpd = SRV(ppi)->delayMS;
pp_time_add(mpd, &SRV(ppi)->delaySM);
pp_time_div2(mpd);
DSCUR(ppi)->meanDelay=pp_time_to_interval(mpd); /* Update currentDS */
update_meanDelay(ppi,pp_time_to_interval(mpd)); /* update currentDS.meanDelay and portDS.meanLinkDelay (idf needed) */
pp_diag(ppi, servo, 1, "meanDelay: %s\n", fmt_ppt(mpd));
if (!mpd->secs) /* =0 Hmm.... we called this "bad event" */
......@@ -314,7 +315,7 @@ static void pp_servo_mpd_fltr(struct pp_instance *ppi, struct pp_avg_fltr *mpd_f
y = (mpd_fltr->y * (mpd_fltr->s_exp - 1) + mpd->scaled_nsecs);
__div64_32(&y, mpd_fltr->s_exp);
mpd->scaled_nsecs = mpd_fltr->y = y;
DSCUR(ppi)->meanDelay=pp_time_to_interval(mpd); /* Update meanDelay in CurrentDS */
update_meanDelay(ppi,picos_to_interval(pp_time_to_interval(mpd))); /* update currentDS.meanDelay and portDS.meanLinkDelay (idf needed) */
pp_diag(ppi, servo, 1, "After avg(%i), meanDelay: %i\n",
(int)mpd_fltr->s_exp, (int)(mpd->scaled_nsecs >> 16));
}
......
......@@ -209,6 +209,7 @@ struct dump_info portDS_info [] = {
DUMP_FIELD(Integer8, logSyncInterval),
DUMP_FIELD(pointer, ext_dsport),
DUMP_FIELD(Integer8, logMinPdelayReqInterval),
DUMP_FIELD(TimeInterval, meanLinkDelay),
DUMP_FIELD(UInteger4, versionNumber),
DUMP_FIELD(UInteger4, minorVersionNumber),
DUMP_FIELD(TimeInterval, delayAsymmetry),
......
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