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
50
Issues
50
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
d68c31e7
Commit
d68c31e7
authored
Sep 16, 2013
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'servo-fixes'
parents
89107dda
6dcafdcf
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
285 additions
and
223 deletions
+285
-223
ieee1588_types.h
include/ppsi/ieee1588_types.h
+1
-1
pp-instance.h
include/ppsi/pp-instance.h
+5
-22
ppsi.h
include/ppsi/ppsi.h
+5
-7
cmdline.c
lib/cmdline.c
+3
-3
hooks.c
proto-ext-whiterabbit/hooks.c
+3
-3
bmc.c
proto-standard/bmc.c
+1
-1
common-fun.c
proto-standard/common-fun.c
+2
-4
open-close.c
proto-standard/open-close.c
+0
-1
servo.c
proto-standard/servo.c
+247
-175
state-initializing.c
proto-standard/state-initializing.c
+0
-1
state-slave.c
proto-standard/state-slave.c
+5
-5
unix-time.c
time-unix/unix-time.c
+13
-0
No files found.
include/ppsi/ieee1588_types.h
View file @
d68c31e7
...
...
@@ -231,7 +231,7 @@ typedef struct DSCurrent { /* page 67 */
/* Dynamic */
UInteger16
stepsRemoved
;
TimeInternal
offsetFromMaster
;
TimeInternal
meanPath
Delay
;
TimeInternal
oneWay
Delay
;
/* White Rabbit extension begin */
UInteger16
primarySlavePortNumber
;
/* White Rabbit extension end */
...
...
include/ppsi/pp-instance.h
View file @
d68c31e7
...
...
@@ -26,7 +26,6 @@ struct pp_runtime_opts {
/* ethernet_mode:1, -- moved to ppsi, is no more global */
/* e2e_mode:1, -- no more: we only support e2e */
/* gptp_mode:1, -- no more: peer-to-peer unsupported */
ofst_first_updated
:
1
,
no_rst_clk
:
1
;
Integer16
ap
,
ai
;
Integer16
s
;
...
...
@@ -72,39 +71,23 @@ struct pp_frgn_master {
* are used in servo.c src, where specific function for time setting of the
* machine are implemented.
*
* pp_ofm_fltr: The FIR filtering of the offset from master input is a simple,
* two-sample average
*
* pp_owd_fltr: It is a variable cutoff/delay low-pass, infinite impulse
* pp_avg_fltr: It is a variable cutoff/delay low-pass, infinite impulse
* response (IIR) filter. The one-way delay filter has the difference equation:
* s*y[n] - (s-1)*y[n-1] = x[n]/2 + x[n-1]/2,
* where increasing the stiffness (s) lowers the cutoff and increases the delay.
*/
struct
pp_ofm_fltr
{
Integer32
nsec_prev
;
Integer32
y
;
};
struct
pp_owd_fltr
{
Integer32
nsec_prev
;
struct
pp_avg_fltr
{
Integer32
m
;
/* magnitude */
Integer32
y
;
Integer32
s_exp
;
};
struct
pp_servo
{
/* TODO check. Which is the difference between m_to_s_dly (which
* comes from ptpd's master_to_slave_delay) and delay_ms (which comes
* from ptpd's delay_MS? Seems like ptpd actually uses only delay_MS.
* The same of course must be checked for their equivalents,
* s_to_m_dly and delay_sm
*/
TimeInternal
m_to_s_dly
;
TimeInternal
s_to_m_dly
;
TimeInternal
delay_ms
;
TimeInternal
delay_sm
;
Integer32
obs_drift
;
struct
pp_
owd
_fltr
owd_fltr
;
struct
pp_
ofm
_fltr
ofm_fltr
;
struct
pp_
avg
_fltr
owd_fltr
;
struct
pp_
avg
_fltr
ofm_fltr
;
};
/*
...
...
include/ppsi/ppsi.h
View file @
d68c31e7
...
...
@@ -117,7 +117,7 @@ struct pp_ext_hooks {
int
(
*
master_msg
)(
struct
pp_instance
*
ppi
,
unsigned
char
*
pkt
,
int
plen
,
int
msgtype
);
int
(
*
new_slave
)(
struct
pp_instance
*
ppi
,
unsigned
char
*
pkt
,
int
plen
);
int
(
*
update_delay
)(
struct
pp_instance
*
ppi
);
int
(
*
handle_resp
)(
struct
pp_instance
*
ppi
);
void
(
*
s1
)(
struct
pp_instance
*
ppi
,
MsgHeader
*
hdr
,
MsgAnnounce
*
ann
);
int
(
*
execute_slave
)(
struct
pp_instance
*
ppi
);
void
(
*
handle_announce
)(
struct
pp_instance
*
ppi
);
...
...
@@ -164,6 +164,7 @@ struct pp_time_operations {
int
(
*
adjust
)(
struct
pp_instance
*
ppi
,
long
offset_ns
,
long
freq_ppm
);
int
(
*
adjust_offset
)(
struct
pp_instance
*
ppi
,
long
offset_ns
);
int
(
*
adjust_freq
)(
struct
pp_instance
*
ppi
,
long
freq_ppm
);
int
(
*
init_servo
)(
struct
pp_instance
*
ppi
);
/* calc_timeout cannot return zero */
unsigned
long
(
*
calc_timeout
)(
struct
pp_instance
*
ppi
,
int
millisec
);
};
...
...
@@ -257,12 +258,9 @@ extern int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv);
extern
int
pp_parse_conf
(
struct
pp_globals
*
ppg
,
char
*
conf
,
int
len
);
/* Servo */
extern
void
pp_init_clock
(
struct
pp_instance
*
ppi
);
extern
void
pp_update_delay
(
struct
pp_instance
*
ppi
,
TimeInternal
*
correction_field
);
extern
void
pp_update_offset
(
struct
pp_instance
*
ppi
,
TimeInternal
*
correctionField
);
extern
void
pp_update_clock
(
struct
pp_instance
*
ppi
);
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 */
/* bmc.c */
...
...
lib/cmdline.c
View file @
d68c31e7
...
...
@@ -104,7 +104,7 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv)
cmd_line_print_help
();
return
-
1
;
}
if
(
1
)
{
/* ARub: I don't want to rein
tent it all now
*/
if
(
1
)
{
/* ARub: I don't want to rein
dent it all
*/
switch
(
a
[
1
])
{
case
'V'
:
pp_diag_verbosity
++
;
...
...
@@ -120,7 +120,7 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv)
case
'O'
:
a
=
argv
[
++
i
];
GOPTS
(
ppg
)
->
max_rst
=
atoi
(
a
);
if
(
GOPTS
(
ppg
)
->
max_rst
<
PP_NSEC_PER_SEC
)
{
if
(
GOPTS
(
ppg
)
->
max_rst
>
PP_NSEC_PER_SEC
)
{
pp_printf
(
"Use -x to prevent jumps of"
" more than one second
\n
"
);
return
-
1
;
...
...
@@ -129,7 +129,7 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv)
case
'M'
:
a
=
argv
[
++
i
];
GOPTS
(
ppg
)
->
max_dly
=
atoi
(
a
);
if
(
GOPTS
(
ppg
)
->
max_dly
<
PP_NSEC_PER_SEC
)
{
if
(
GOPTS
(
ppg
)
->
max_dly
>
PP_NSEC_PER_SEC
)
{
pp_printf
(
"Use -x to prevent jumps of"
" more than one second
\n
"
);
return
-
1
;
...
...
proto-ext-whiterabbit/hooks.c
View file @
d68c31e7
...
...
@@ -105,7 +105,7 @@ static int wr_new_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
return
0
;
}
static
int
wr_
update_delay
(
struct
pp_instance
*
ppi
)
static
int
wr_
handle_resp
(
struct
pp_instance
*
ppi
)
{
MsgHeader
*
hdr
=
&
ppi
->
received_ptp_header
;
TimeInternal
correction_field
;
...
...
@@ -115,7 +115,7 @@ static int wr_update_delay(struct pp_instance *ppi)
/* If no WR mode is on, run normal code */
if
(
!
WR_DSPOR
(
ppi
)
->
wrModeOn
)
{
pp_
update_delay
(
ppi
,
&
correction_field
);
pp_
servo_got_resp
(
ppi
);
return
0
;
}
wr_servo_got_delay
(
ppi
,
hdr
->
correctionfield
.
lsb
);
...
...
@@ -197,7 +197,7 @@ struct pp_ext_hooks pp_hooks = {
.
listening
=
wr_listening
,
.
master_msg
=
wr_master_msg
,
.
new_slave
=
wr_new_slave
,
.
update_delay
=
wr_update_delay
,
.
handle_resp
=
wr_handle_resp
,
.
s1
=
wr_s1
,
.
execute_slave
=
wr_execute_slave
,
.
handle_announce
=
wr_handle_announce
,
...
...
proto-standard/bmc.c
View file @
d68c31e7
...
...
@@ -25,7 +25,7 @@ void m1(struct pp_instance *ppi)
/* Current data set update */
DSCUR
(
ppi
)
->
stepsRemoved
=
0
;
clear_TimeInternal
(
&
DSCUR
(
ppi
)
->
offsetFromMaster
);
clear_TimeInternal
(
&
DSCUR
(
ppi
)
->
meanPath
Delay
);
clear_TimeInternal
(
&
DSCUR
(
ppi
)
->
oneWay
Delay
);
/* Parent data set: we are the parent */
memset
(
parent
,
0
,
sizeof
(
*
parent
));
...
...
proto-standard/common-fun.c
View file @
d68c31e7
...
...
@@ -151,8 +151,7 @@ int st_com_slave_handle_sync(struct pp_instance *ppi, unsigned char *buf,
ppi
->
waiting_for_follow
=
FALSE
;
to_TimeInternal
(
&
ppi
->
t1
,
&
sync
.
originTimestamp
);
pp_update_offset
(
ppi
,
&
ppi
->
cField
);
pp_update_clock
(
ppi
);
pp_servo_got_sync
(
ppi
);
return
0
;
}
...
...
@@ -198,8 +197,7 @@ int st_com_slave_handle_followup(struct pp_instance *ppi, unsigned char *buf,
if
(
ret
<
0
)
return
ret
;
pp_update_offset
(
ppi
,
&
ppi
->
cField
);
pp_update_clock
(
ppi
);
pp_servo_got_sync
(
ppi
);
return
0
;
}
...
...
proto-standard/open-close.c
View file @
d68c31e7
...
...
@@ -28,7 +28,6 @@ struct pp_runtime_opts default_rt_opts = {
.
ap
=
PP_DEFAULT_AP
,
.
ai
=
PP_DEFAULT_AI
,
.
s
=
PP_DEFAULT_DELAY_S
,
.
ofst_first_updated
=
0
,
/* FIXME: is it a option or a state var? */
.
announce_intvl
=
PP_DEFAULT_ANNOUNCE_INTERVAL
,
.
sync_intvl
=
PP_DEFAULT_SYNC_INTERVAL
,
.
prio1
=
PP_DEFAULT_PRIORITY1
,
...
...
proto-standard/servo.c
View file @
d68c31e7
This diff is collapsed.
Click to expand it.
proto-standard/state-initializing.c
View file @
d68c31e7
...
...
@@ -57,7 +57,6 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
pp_diag
(
ppi
,
time
,
1
,
"%s: can't init timers
\n
"
,
__func__
);
goto
failure
;
}
pp_init_clock
(
ppi
);
pp_diag
(
ppi
,
bmc
,
1
,
"clock class = %d
\n
"
,
DSDEF
(
ppi
)
->
clockQuality
.
clockClass
);
...
...
proto-standard/state-slave.c
View file @
d68c31e7
...
...
@@ -17,7 +17,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
int
d1
,
d2
;
if
(
ppi
->
is_new_state
)
{
pp_
init_clock
(
ppi
);
pp_
servo_init
(
ppi
);
if
(
pp_hooks
.
new_slave
)
e
=
pp_hooks
.
new_slave
(
ppi
,
pkt
,
plen
);
...
...
@@ -79,10 +79,10 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
* generating t4, and report back a modified t4
*/
if
(
pp_hooks
.
update_delay
)
e
=
pp_hooks
.
update_delay
(
ppi
);
if
(
pp_hooks
.
handle_resp
)
e
=
pp_hooks
.
handle_resp
(
ppi
);
else
pp_
update_delay
(
ppi
,
&
ppi
->
cField
);
pp_
servo_got_resp
(
ppi
);
if
(
e
)
goto
out
;
...
...
@@ -138,7 +138,7 @@ out:
pp_timeout_clr
(
ppi
,
PP_TO_ANN_RECEIPT
);
pp_timeout_clr
(
ppi
,
PP_TO_DELAYREQ
);
pp_
init_clock
(
ppi
);
pp_
servo_init
(
ppi
);
}
d1
=
d2
=
pp_ms_to_timeout
(
ppi
,
PP_TO_ANN_RECEIPT
);
if
(
ppi
->
timeouts
[
PP_TO_DELAYREQ
])
...
...
time-unix/unix-time.c
View file @
d68c31e7
...
...
@@ -45,6 +45,18 @@ static int32_t unix_time_set(struct pp_instance *ppi, TimeInternal *t)
return
0
;
}
static
int
unix_time_init_servo
(
struct
pp_instance
*
ppi
)
{
struct
timex
t
;
/* We must set MOD_PLL and recover the current frequency value */
t
.
modes
=
MOD_STATUS
;
t
.
status
=
STA_PLL
;
if
(
adjtimex
(
&
t
)
<
0
)
return
-
1
;
return
(
t
.
freq
>>
16
)
*
1000
;
/* positive or negative, not -1 */
}
static
int
unix_time_adjust
(
struct
pp_instance
*
ppi
,
long
offset_ns
,
long
freq_ppm
)
{
struct
timex
t
;
...
...
@@ -103,5 +115,6 @@ struct pp_time_operations unix_time_ops = {
.
adjust
=
unix_time_adjust
,
.
adjust_offset
=
unix_time_adjust_offset
,
.
adjust_freq
=
unix_time_adjust_freq
,
.
init_servo
=
unix_time_init_servo
,
.
calc_timeout
=
unix_calc_timeout
,
};
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