Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
PPSi
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
47
Issues
47
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
PPSi
Commits
70423873
Commit
70423873
authored
Jul 01, 2015
by
Cesar Prados
Committed by
Alessandro Rubini
May 16, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pdelay/servo: add calculation of mean path delay and offset to master for peer delay
Signed-off-by:
C.Prados
<
c.prados@gsi.de
>
parent
d5846ed6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
0 deletions
+79
-0
ppsi.h
include/ppsi/ppsi.h
+2
-0
servo.c
proto-standard/servo.c
+77
-0
No files found.
include/ppsi/ppsi.h
View file @
70423873
...
...
@@ -377,6 +377,8 @@ extern int f_simple_int(struct pp_argline *l, int lineno,
extern
void
pp_servo_init
(
struct
pp_instance
*
ppi
);
extern
void
pp_servo_got_sync
(
struct
pp_instance
*
ppi
);
/* got t1 and t2 */
extern
void
pp_servo_got_resp
(
struct
pp_instance
*
ppi
);
/* got all t1..t4 */
extern
void
pp_servo_got_psync
(
struct
pp_instance
*
ppi
);
/* got t1 and t2 */
extern
void
pp_servo_got_presp
(
struct
pp_instance
*
ppi
);
/* got all t3..t6 */
extern
void
pp_servo_mpd_fltr
(
struct
pp_instance
*
ppi
,
struct
pp_avg_fltr
*
mpd_fltr
,
TimeInternal
*
mpd
);
...
...
proto-standard/servo.c
View file @
70423873
...
...
@@ -62,6 +62,45 @@ void pp_servo_got_sync(struct pp_instance *ppi)
fmt_TI
(
&
ppi
->
cField
));
}
/* Called by slave and uncalib when we have t1 and t2 */
void
pp_servo_got_psync
(
struct
pp_instance
*
ppi
)
{
TimeInternal
*
m_to_s_dly
=
&
SRV
(
ppi
)
->
m_to_s_dly
;
TimeInternal
*
mpd
=
&
DSCUR
(
ppi
)
->
meanPathDelay
;
TimeInternal
*
ofm
=
&
DSCUR
(
ppi
)
->
offsetFromMaster
;
Integer32
adj
;
pp_diag
(
ppi
,
servo
,
2
,
"T1: %s
\n
"
,
fmt_TI
(
&
ppi
->
t1
));
pp_diag
(
ppi
,
servo
,
2
,
"T2: %s
\n
"
,
fmt_TI
(
&
ppi
->
t2
));
/*
* calc 'master_to_slave_delay', removing the correction field
* added by transparent clocks in the path.
*/
sub_TimeInternal
(
m_to_s_dly
,
&
ppi
->
t2
,
&
ppi
->
t1
);
sub_TimeInternal
(
m_to_s_dly
,
m_to_s_dly
,
&
ppi
->
cField
);
pp_diag
(
ppi
,
servo
,
3
,
"correction field 1: %s
\n
"
,
fmt_TI
(
&
ppi
->
cField
));
/* update 'offsetFromMaster', (End to End mode) */
pp_servo_offset_master
(
ppi
,
mpd
,
ofm
,
m_to_s_dly
);
/* PI controller */
adj
=
pp_servo_pi_controller
(
ppi
,
ofm
);
/* apply controller output as a clock tick rate adjustment, if
* provided by arch, or as a raw offset otherwise */
if
(
pp_can_adjust
(
ppi
))
{
if
(
ppi
->
t_ops
->
adjust_freq
)
ppi
->
t_ops
->
adjust_freq
(
ppi
,
-
adj
);
else
ppi
->
t_ops
->
adjust_offset
(
ppi
,
-
adj
);
}
pp_diag
(
ppi
,
servo
,
2
,
"Observed drift: %9i
\n
"
,
(
int
)
SRV
(
ppi
)
->
obs_drift
>>
10
);
}
/*
* This function makes the necessary checks to discard a set of t1..t4.
* It relies on mpd to be already calculated.
...
...
@@ -158,6 +197,44 @@ void pp_servo_got_resp(struct pp_instance *ppi)
(
int
)
SRV
(
ppi
)
->
obs_drift
>>
10
);
}
/* called by slave states when delay_resp is received (all t1..t4 are valid) */
void
pp_servo_got_presp
(
struct
pp_instance
*
ppi
)
{
TimeInternal
*
m_to_s_dly
=
&
SRV
(
ppi
)
->
m_to_s_dly
;
TimeInternal
*
s_to_m_dly
=
&
SRV
(
ppi
)
->
s_to_m_dly
;
TimeInternal
*
mpd
=
&
DSCUR
(
ppi
)
->
meanPathDelay
;
struct
pp_avg_fltr
*
mpd_fltr
=
&
SRV
(
ppi
)
->
mpd_fltr
;
/*
* calc 'slave_to_master_delay', removing the correction field
* added by transparent clocks in the path.
*/
sub_TimeInternal
(
s_to_m_dly
,
&
ppi
->
t6
,
&
ppi
->
t5
);
sub_TimeInternal
(
s_to_m_dly
,
s_to_m_dly
,
&
ppi
->
cField
);
pp_diag
(
ppi
,
servo
,
3
,
"correction field 2: %s
\n
"
,
fmt_TI
(
&
ppi
->
cField
));
sub_TimeInternal
(
m_to_s_dly
,
&
ppi
->
t4
,
&
ppi
->
t3
);
pp_diag
(
ppi
,
servo
,
2
,
"T3: %s
\n
"
,
fmt_TI
(
&
ppi
->
t3
));
pp_diag
(
ppi
,
servo
,
2
,
"T4: %s
\n
"
,
fmt_TI
(
&
ppi
->
t4
));
pp_diag
(
ppi
,
servo
,
2
,
"T5: %s
\n
"
,
fmt_TI
(
&
ppi
->
t5
));
pp_diag
(
ppi
,
servo
,
2
,
"T6: %s
\n
"
,
fmt_TI
(
&
ppi
->
t6
));
pp_diag
(
ppi
,
servo
,
1
,
"Master to slave: %s
\n
"
,
fmt_TI
(
m_to_s_dly
));
pp_diag
(
ppi
,
servo
,
1
,
"Slave to master: %s
\n
"
,
fmt_TI
(
s_to_m_dly
));
/* Calc mean path delay, used later to calc "offset from master" */
add_TimeInternal
(
mpd
,
&
SRV
(
ppi
)
->
m_to_s_dly
,
&
SRV
(
ppi
)
->
s_to_m_dly
);
div2_TimeInternal
(
mpd
);
pp_diag
(
ppi
,
servo
,
1
,
"meanPathDelay: %s
\n
"
,
fmt_TI
(
mpd
));
/* if this succeeds mpd->seconds == 0 is true */
if
(
pp_servo_bad_event
(
ppi
))
return
;
pp_servo_mpd_fltr
(
ppi
,
mpd_fltr
,
mpd
);
}
void
pp_servo_mpd_fltr
(
struct
pp_instance
*
ppi
,
struct
pp_avg_fltr
*
mpd_fltr
,
TimeInternal
*
mpd
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment