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
884bcf0a
Commit
884bcf0a
authored
Nov 07, 2014
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'no-bitfields'
parents
ea6042b4
996e152b
Hide whitespace changes
Inline
Side-by-side
Showing
34 changed files
with
113 additions
and
120 deletions
+113
-120
constants.h
arch-bare-i386/include/arch/constants.h
+2
-2
constants.h
arch-bare-x86-64/include/arch/constants.h
+2
-2
sim-startup.c
arch-sim/sim-startup.c
+3
-10
main-loop.c
arch-unix/main-loop.c
+1
-1
unix-startup.c
arch-unix/unix-startup.c
+7
-9
constants.h
arch-wrpc/include/arch/constants.h
+2
-2
wrc_ptp_ppsi.c
arch-wrpc/wrc_ptp_ppsi.c
+4
-6
main-loop.c
arch-wrs/main-loop.c
+1
-1
wrs-startup.c
arch-wrs/wrs-startup.c
+2
-11
ppsi-manual.in
doc/ppsi-manual.in
+3
-2
fsm.c
fsm.c
+4
-4
constants.h
include/ppsi/constants.h
+4
-3
diag-macros.h
include/ppsi/diag-macros.h
+5
-5
pp-instance.h
include/ppsi/pp-instance.h
+26
-14
bare-startup.c
lib-bare/bare-startup.c
+1
-1
cmdline.c
lib/cmdline.c
+5
-5
conf.c
lib/conf.c
+2
-2
wr-servo.c
proto-ext-whiterabbit/wr-servo.c
+1
-1
bmc.c
proto-standard/bmc.c
+2
-2
common-fun.c
proto-standard/common-fun.c
+7
-7
msg.c
proto-standard/msg.c
+3
-3
open-close.c
proto-standard/open-close.c
+3
-4
servo.c
proto-standard/servo.c
+4
-4
state-initializing.c
proto-standard/state-initializing.c
+1
-1
state-master.c
proto-standard/state-master.c
+1
-1
state-slave.c
proto-standard/state-slave.c
+2
-2
bare-socket.c
time-bare/bare-socket.c
+2
-2
bare-time.c
time-bare/bare-time.c
+1
-1
sim-time.c
time-sim/sim-time.c
+1
-1
unix-socket.c
time-unix/unix-socket.c
+5
-5
unix-time.c
time-unix/unix-time.c
+1
-1
wrpc-time.c
time-wrpc/wrpc-time.c
+1
-1
wrs-socket.c
time-wrs/wrs-socket.c
+3
-3
wrs-time.c
time-wrs/wrs-time.c
+1
-1
No files found.
arch-bare-i386/include/arch/constants.h
View file @
884bcf0a
...
...
@@ -6,8 +6,8 @@
#Warning "Please include <ppsi/constants.h> before <arch/constants.h>"
#endif
#undef PP_DEFAULT_
ETHERNET_MODE
#define PP_DEFAULT_
ETHERNET_MODE 1
/* We only use raw ethernet */
#undef PP_DEFAULT_
PROTO
#define PP_DEFAULT_
PROTO PPSI_PROTO_RAW
/* We only use raw ethernet */
#endif
/* __PPSI_ARCH_CONSTANTS_H__ */
arch-bare-x86-64/include/arch/constants.h
View file @
884bcf0a
...
...
@@ -6,8 +6,8 @@
#Warning "Please include <ppsi/constants.h> before <arch/constants.h>"
#endif
#undef PP_DEFAULT_
ETHERNET_MODE
#define PP_DEFAULT_
ETHERNET_MODE 1
/* We only use raw ethernet */
#undef PP_DEFAULT_
PROTO
#define PP_DEFAULT_
PROTO PPSI_PROTO_RAW
/* We only use raw ethernet */
#endif
/* __PPSI_ARCH_CONSTANTS_H__ */
arch-sim/sim-startup.c
View file @
884bcf0a
...
...
@@ -20,8 +20,7 @@ static struct pp_runtime_opts sim_master_rt_opts = {
.
outbound_latency
=
{
0
,
PP_DEFAULT_OUTBOUND_LATENCY
},
.
max_rst
=
PP_DEFAULT_MAX_RESET
,
.
max_dly
=
PP_DEFAULT_MAX_DELAY
,
.
no_adjust
=
PP_DEFAULT_NO_ADJUST
,
.
no_rst_clk
=
PP_DEFAULT_NO_RESET_CLOCK
,
.
flags
=
PP_DEFAULT_FLAGS
,
.
ap
=
PP_DEFAULT_AP
,
.
ai
=
PP_DEFAULT_AI
,
.
s
=
PP_DEFAULT_DELAY_S
,
...
...
@@ -58,6 +57,7 @@ int sim_set_global_DS(struct pp_instance *ppi)
static
int
sim_ppi_init
(
struct
pp_instance
*
ppi
,
int
which_ppi
)
{
struct
sim_ppi_arch_data
*
data
;
ppi
->
proto
=
PP_DEFAULT_PROTO
;
ppi
->
arch_data
=
calloc
(
1
,
sizeof
(
struct
sim_ppi_arch_data
));
ppi
->
portDS
=
calloc
(
1
,
sizeof
(
*
ppi
->
portDS
));
if
((
!
ppi
->
arch_data
)
||
(
!
ppi
->
portDS
))
...
...
@@ -143,16 +143,9 @@ int main(int argc, char **argv)
if
(
ppi
->
cfg
.
proto
==
PPSI_PROTO_RAW
)
pp_printf
(
"Warning: simulator doesn't support raw "
"ethernet. Using UDP
\n
"
);
ppi
->
ethernet_mode
=
0
;
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
=
-
1
;
NP
(
ppi
)
->
ch
[
PP_NP_EVT
].
fd
=
-
1
;
if
(
ppi
->
cfg
.
role
==
PPSI_ROLE_MASTER
)
{
ppi
->
master_only
=
1
;
ppi
->
slave_only
=
0
;
}
else
if
(
ppi
->
cfg
.
role
==
PPSI_ROLE_SLAVE
)
{
ppi
->
master_only
=
0
;
ppi
->
slave_only
=
1
;
}
ppi
->
role
=
ppi
->
cfg
.
role
;
ppi
->
t_ops
=
&
DEFAULT_TIME_OPS
;
ppi
->
n_ops
=
&
DEFAULT_NET_OPS
;
if
(
pp_sim_is_master
(
ppi
))
...
...
arch-unix/main-loop.c
View file @
884bcf0a
...
...
@@ -52,7 +52,7 @@ void unix_main_loop(struct pp_globals *ppg)
* If we are sending or receiving raw ethernet frames,
* the ptp payload is one-eth-header bytes into the frame
*/
if
(
ppi
->
ethernet_mode
)
if
(
ppi
->
proto
==
PPSI_PROTO_RAW
)
NP
(
ppi
)
->
ptp_offset
=
ETH_HLEN
;
/*
...
...
arch-unix/unix-startup.c
View file @
884bcf0a
...
...
@@ -55,6 +55,11 @@ int main(int argc, char **argv)
ppg
->
max_links
=
PP_MAX_LINKS
;
ppg
->
arch_data
=
calloc
(
1
,
sizeof
(
struct
unix_arch_data
));
ppg
->
pp_instances
=
calloc
(
ppg
->
max_links
,
sizeof
(
struct
pp_instance
));
for
(
i
=
0
;
i
<
ppg
->
max_links
;
i
++
)
{
ppi
=
INST
(
ppg
,
i
);
ppi
->
proto
=
PP_DEFAULT_PROTO
;
ppi
->
role
=
PP_DEFAULT_ROLE
;
}
if
((
!
ppg
->
arch_data
)
||
(
!
ppg
->
pp_instances
))
exit
(
__LINE__
);
...
...
@@ -82,15 +87,8 @@ int main(int argc, char **argv)
ppi
->
iface_name
=
ppi
->
cfg
.
iface_name
;
ppi
->
port_name
=
ppi
->
cfg
.
port_name
;
/* this old-fashioned "ethernet_mode" is a single bit */
ppi
->
ethernet_mode
=
(
ppi
->
cfg
.
proto
==
PPSI_PROTO_RAW
);
if
(
ppi
->
cfg
.
role
==
PPSI_ROLE_MASTER
)
{
ppi
->
master_only
=
1
;
ppi
->
slave_only
=
0
;
}
else
if
(
ppi
->
cfg
.
role
==
PPSI_ROLE_SLAVE
)
{
ppi
->
master_only
=
0
;
ppi
->
slave_only
=
1
;
}
ppi
->
proto
=
ppi
->
cfg
.
proto
;
ppi
->
role
=
ppi
->
cfg
.
role
;
/* FIXME set ppi ext enable as defined in its pp_link */
...
...
arch-wrpc/include/arch/constants.h
View file @
884bcf0a
...
...
@@ -6,8 +6,8 @@
#Warning "Please include <ppsi/constants.h> before <arch/constants.h>"
#endif
#undef PP_DEFAULT_
ETHERNET_MODE
#define PP_DEFAULT_
ETHERNET_MODE 1
/* We only use raw ethernet */
#undef PP_DEFAULT_
PROTO
#define PP_DEFAULT_
PROTO PPSI_PROTO_RAW
/* We only use raw ethernet */
#endif
/* __PPSI_ARCH_CONSTANTS_H__ */
arch-wrpc/wrc_ptp_ppsi.c
View file @
884bcf0a
...
...
@@ -74,6 +74,7 @@ struct pp_instance ppi_static = {
.
portDS
=
&
portDS
,
.
n_ops
=
&
wrpc_net_ops
,
.
t_ops
=
&
wrpc_time_ops
,
.
proto
=
PP_DEFAULT_PROTO
,
.
iface_name
=
"wr1"
,
.
port_name
=
"wr1"
,
};
...
...
@@ -124,8 +125,7 @@ int wrc_ptp_set_mode(int mode)
switch
(
mode
)
{
case
WRC_MODE_GM
:
wrp
->
wrConfig
=
WR_M_ONLY
;
ppi
->
master_only
=
TRUE
;
ppi
->
slave_only
=
FALSE
;
ppi
->
role
=
PPSI_ROLE_MASTER
;
*
class_ptr
=
PP_CLASS_WR_GM_LOCKED
;
spll_init
(
SPLL_MODE_GRAND_MASTER
,
0
,
1
);
lock_timeout
=
LOCK_TIMEOUT_GM
;
...
...
@@ -133,8 +133,7 @@ int wrc_ptp_set_mode(int mode)
case
WRC_MODE_MASTER
:
wrp
->
wrConfig
=
WR_M_ONLY
;
ppi
->
master_only
=
TRUE
;
ppi
->
slave_only
=
FALSE
;
ppi
->
role
=
PPSI_ROLE_MASTER
;
*
class_ptr
=
PP_CLASS_DEFAULT
;
spll_init
(
SPLL_MODE_FREE_RUNNING_MASTER
,
0
,
1
);
lock_timeout
=
LOCK_TIMEOUT_FM
;
...
...
@@ -142,8 +141,7 @@ int wrc_ptp_set_mode(int mode)
case
WRC_MODE_SLAVE
:
wrp
->
wrConfig
=
WR_S_ONLY
;
ppi
->
master_only
=
FALSE
;
ppi
->
slave_only
=
TRUE
;
ppi
->
role
=
PPSI_ROLE_SLAVE
;
*
class_ptr
=
PP_CLASS_SLAVE_ONLY
;
spll_init
(
SPLL_MODE_SLAVE
,
0
,
1
);
break
;
...
...
arch-wrs/main-loop.c
View file @
884bcf0a
...
...
@@ -88,7 +88,7 @@ void wrs_main_loop(struct pp_globals *ppg)
* If we are sending or receiving raw ethernet frames,
* the ptp payload is one-eth-header bytes into the frame
*/
if
(
ppi
->
ethernet_mode
)
if
(
ppi
->
proto
==
PPSI_PROTO_RAW
)
NP
(
ppi
)
->
ptp_offset
=
ETH_HLEN
;
/*
...
...
arch-wrs/wrs-startup.c
View file @
884bcf0a
...
...
@@ -155,17 +155,8 @@ int main(int argc, char **argv)
ppi
->
glbs
=
ppg
;
ppi
->
iface_name
=
ppi
->
cfg
.
iface_name
;
ppi
->
port_name
=
ppi
->
cfg
.
port_name
;
/* this old-fashioned "ethernet_mode" is a single bit */
ppi
->
ethernet_mode
=
(
ppi
->
cfg
.
proto
==
PPSI_PROTO_RAW
);
if
(
ppi
->
cfg
.
role
==
PPSI_ROLE_MASTER
)
{
ppi
->
master_only
=
1
;
ppi
->
slave_only
=
0
;
}
else
if
(
ppi
->
cfg
.
role
==
PPSI_ROLE_SLAVE
)
{
ppi
->
master_only
=
0
;
ppi
->
slave_only
=
1
;
}
ppi
->
proto
=
ppi
->
cfg
.
proto
;
ppi
->
role
=
ppi
->
cfg
.
role
;
ppi
->
portDS
=
calloc
(
1
,
sizeof
(
*
ppi
->
portDS
));
if
(
!
ppi
->
portDS
)
exit
(
__LINE__
);
...
...
doc/ppsi-manual.in
View file @
884bcf0a
...
...
@@ -35,7 +35,7 @@
@setchapternewpage off
@set update-month
July
2014
@set update-month
November
2014
@set release
__
RELEASE
_
GIT
_
ID
__
@finalout
...
...
@@ -356,7 +356,8 @@ unfair to hide them.
We want to allow run-time modification of diagnostics flags
with a per-link granularity. Currently we have configuration-based
per-link diagnostic flags and global flags that can be changed
per-link diagnostic flags and global diagnostic
flags that can be changed
at run time (for example, arch-wrpc offers that through a shell
command). We think this feature is useful
when you run more than a pair of interfaces and have problems
...
...
fsm.c
View file @
884bcf0a
...
...
@@ -6,7 +6,7 @@
*/
#include <ppsi/ppsi.h>
unsigned
long
pp_global_flags
;
/* This is the only "global" file in ppsi */
unsigned
long
pp_global_
d_
flags
;
/* This is the only "global" file in ppsi */
/*
* This is somehow a duplicate of __pp_diag, but I still want
...
...
@@ -17,15 +17,15 @@ static void pp_fsm_printf(struct pp_instance *ppi, char *fmt, ...)
{
va_list
args
;
TimeInternal
t
;
unsigned
long
oflags
=
pp_global_flags
;
unsigned
long
oflags
=
pp_global_
d_
flags
;
if
(
!
pp_diag_allow
(
ppi
,
fsm
,
1
))
return
;
/* temporarily set NOTIMELOG, as we'll print the time ourselves */
pp_global_flags
|=
PP_FLAG_NOTIMELOG
;
pp_global_
d_
flags
|=
PP_FLAG_NOTIMELOG
;
ppi
->
t_ops
->
get
(
ppi
,
&
t
);
pp_global_flags
=
oflags
;
pp_global_
d_
flags
=
oflags
;
pp_printf
(
"diag-fsm-1-%s: %09d.%03d: "
,
ppi
->
port_name
,
(
int
)
t
.
seconds
,
(
int
)
t
.
nanoseconds
/
1000000
);
...
...
include/ppsi/constants.h
View file @
884bcf0a
...
...
@@ -13,13 +13,15 @@
#define PP_NSEC_PER_SEC (1000*1000*1000)
/* implementation specific constants */
#define PP_DEFAULT_PPI_FLAGS 0
/* UDP mode */
#define PP_MAX_LINKS 64
#define PP_DEFAULT_CONFIGFILE "/etc/ppsi.conf"
#define PP_DEFAULT_INBOUND_LATENCY 0
/* in nsec */
#define PP_DEFAULT_OUTBOUND_LATENCY 0
/* in nsec */
#define PP_DEFAULT_NO_RESET_CLOCK 0
#define PP_DEFAULT_ETHERNET_MODE 0
#define PP_DEFAULT_FLAGS 0
#define PP_DEFAULT_ROLE PPSI_ROLE_AUTO
#define PP_DEFAULT_PROTO PPSI_PROTO_UDP
/* overridden by arch */
#define PP_DEFAULT_DOMAIN_NUMBER 0
#define PP_DEFAULT_AP 10
#define PP_DEFAULT_AI 1000
...
...
@@ -46,7 +48,6 @@
#define PP_NR_FOREIGN_RECORDS 5
#define PP_DEFAULT_MAX_RESET 0
#define PP_DEFAULT_MAX_DELAY 0
#define PP_DEFAULT_NO_ADJUST 0
#define PP_DEFAULT_TTL 1
/* We use an array of timeouts, with these indexes */
...
...
include/ppsi/diag-macros.h
View file @
884bcf0a
...
...
@@ -6,8 +6,8 @@
#define pp_error(...) pp_printf("ERROR: " __VA_ARGS__)
/*
* The "new" diagnostics is based on flags: there are per-instance flags
* and global flags.
* The "new" diagnostics is based on flags: there are per-instance
d_
flags
* and global
d_
flags.
*
* Basically, we may have just bits about what to print, but we might
* want to add extra-verbose stuff for specific cases, like looking at
...
...
@@ -37,17 +37,17 @@ enum pp_diag_things {
/*
* Note: we may use less bits and have more things, without changing
* anything. Set's say levels are ony 0..3 -- still,I prefer to be
* able to print the active flags as %x while debugging this very
* able to print the active
d_
flags as %x while debugging this very
* mechanism).
*/
extern
unsigned
long
pp_global_flags
;
/* Supplement ppi-specific ones */
extern
unsigned
long
pp_global_
d_
flags
;
/* Supplement ppi-specific ones */
#define PP_FLAG_NOTIMELOG 1
/* This is for a special case, I'm sorry */
/* So, extract the level */
#define __PP_FLAGS(ppi) ((ppi ? ppi->
flags : 0) | pp_global
_flags)
#define __PP_FLAGS(ppi) ((ppi ? ppi->
d_flags : 0) | pp_global_d
_flags)
#define __PP_DIAG_ALLOW(ppi, th, level) \
((__PP_FLAGS(ppi) >> (4 * (th)) & 0xf) >= level)
...
...
include/ppsi/pp-instance.h
View file @
884bcf0a
...
...
@@ -20,13 +20,7 @@ struct pp_runtime_opts {
Integer32
max_rst
;
/* Maximum number of nanoseconds to reset */
Integer32
max_dly
;
/* Maximum number of nanoseconds of delay */
Integer32
ttl
;
UInteger32
/* slave_only:1, -- moved to ppsi, is no more global */
/* master_only:1, -- moved to ppsi, is no more global */
no_adjust
:
1
,
/* 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 */
no_rst_clk
:
1
;
int
flags
;
/* see below */
Integer16
ap
,
ai
;
Integer16
s
;
Integer8
announce_intvl
;
...
...
@@ -37,6 +31,23 @@ struct pp_runtime_opts {
void
*
arch_opts
;
};
/*
* Flags for the above structure
*/
#define PP_FLAG_NO_ADJUST 0x01
#define PP_FLAG_NO_RESET 0x02
/* I'd love to use inlines, but we still miss some structure at this point*/
#define pp_can_adjust(ppi) (!(OPTS(ppi)->flags & PP_FLAG_NO_ADJUST))
#define pp_can_reset_clock(ppi) (!(OPTS(ppi)->flags & PP_FLAG_NO_RESET))
/* slave_only:1, -- moved to ppi, no more global */
/* master_only:1, -- moved to ppi, no more global */
/* ethernet_mode:1, -- moved to ppi, no more global */
/* e2e_mode:1, -- no more: we only support e2e */
/* gptp_mode:1, -- no more: peer-to-peer unsupported */
/* We need a globally-accessible structure with preset defaults */
extern
struct
pp_runtime_opts
__pp_default_rt_opts
;
...
...
@@ -129,7 +140,10 @@ struct pp_instance {
int
next_state
,
next_delay
,
is_new_state
;
/* set by state processing */
void
*
arch_data
;
/* if arch needs it */
void
*
ext_data
;
/* if protocol ext needs it */
unsigned
long
flags
;
/* ppi-specific flags (diag mainly) */
unsigned
long
d_flags
;
/* diagnostics, ppi-specific flags */
unsigned
char
flags
,
/* protocol flags (see below) */
role
,
/* same as in config file */
proto
;
/* same as in config file */
/* Pointer to global instance owning this pp_instance*/
struct
pp_globals
*
glbs
;
...
...
@@ -171,18 +185,16 @@ struct pp_instance {
UInteger16
sent_seq
[
__PP_NR_MESSAGES_TYPES
];
/* last sent this type */
MsgHeader
received_ptp_header
;
MsgHeader
delay_req_hdr
;
UInteger32
is_from_cur_par
:
1
,
waiting_for_follow
:
1
,
slave_only
:
1
,
master_only
:
1
,
ethernet_mode
:
1
;
char
*
iface_name
;
/* for direct actions on hardware */
char
*
port_name
;
/* for diagnostics, mainly */
int
port_idx
;
struct
pp_instance_cfg
cfg
;
};
/* The following things used to be bit fields. Other flags are now enums */
#define PPI_FLAG_FROM_CURRENT_PARENT 0x01
#define PPI_FLAG_WAITING_FOR_F_UP 0x02
struct
pp_globals_cfg
{
int
cfg_items
;
/* Remember how many we parsed */
...
...
lib-bare/bare-startup.c
View file @
884bcf0a
...
...
@@ -39,7 +39,7 @@ static struct pp_instance ppi_static = {
.
t_ops
=
&
bare_time_ops
,
.
iface_name
=
"eth0"
,
.
port_name
=
"eth0"
,
.
ethernet_mode
=
PP_DEFAULT_ETHERNET_MODE
,
.
proto
=
PP_DEFAULT_PROTO
,
};
/* We now have a structure with all globals, and multiple ppi inside */
...
...
lib/cmdline.c
View file @
884bcf0a
...
...
@@ -110,7 +110,7 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv)
case
'd'
:
/* Use the general flags, per-instance TBD */
a
=
argv
[
++
i
];
pp_global_flags
=
pp_diag_parse
(
a
);
pp_global_
d_
flags
=
pp_diag_parse
(
a
);
break
;
case
'C'
:
if
(
pp_config_string
(
ppg
,
argv
[
++
i
])
!=
0
)
...
...
@@ -121,7 +121,7 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv)
return
-
1
;
break
;
case
'x'
:
GOPTS
(
ppg
)
->
no_rst_clk
=
1
;
GOPTS
(
ppg
)
->
flags
|=
PP_FLAG_NO_RESET
;
break
;
case
'O'
:
a
=
argv
[
++
i
];
...
...
@@ -142,7 +142,7 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv)
}
break
;
case
't'
:
GOPTS
(
ppg
)
->
no_adjust
=
1
;
GOPTS
(
ppg
)
->
flags
|=
PP_FLAG_NO_ADJUST
;
break
;
case
'a'
:
a
=
argv
[
++
i
];
...
...
@@ -198,7 +198,7 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv)
=
PP_CLASS_SLAVE_ONLY
;
/* Apply -g option globally, to each configured link */
for
(
j
=
0
;
j
<
ppg
->
nlinks
;
j
++
)
INST
(
ppg
,
j
)
->
slave_only
=
1
;
INST
(
ppg
,
j
)
->
role
=
PPSI_ROLE_SLAVE
;
break
;
case
'v'
:
a
=
argv
[
++
i
];
...
...
@@ -229,7 +229,7 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv)
case
'e'
:
/* Apply -e option globally, to each configured link */
for
(
j
=
0
;
j
<
ppg
->
nlinks
;
j
++
)
INST
(
ppg
,
j
)
->
ethernet_mode
=
1
;
INST
(
ppg
,
j
)
->
proto
=
PPSI_PROTO_RAW
;
break
;
case
'G'
:
/* gptp_mode not supported: fall through */
...
...
lib/conf.c
View file @
884bcf0a
...
...
@@ -112,9 +112,9 @@ static int f_diag(int lineno, struct pp_globals *ppg, union pp_cfg_arg *arg)
unsigned
long
level
=
pp_diag_parse
(
arg
->
s
);
if
(
ppg
->
cfg
.
cur_ppi_n
>=
0
)
CUR_PPI
(
ppg
)
->
flags
=
level
;
CUR_PPI
(
ppg
)
->
d_
flags
=
level
;
else
pp_global_flags
=
level
;
pp_global_
d_
flags
=
level
;
return
0
;
}
...
...
proto-ext-whiterabbit/wr-servo.c
View file @
884bcf0a
...
...
@@ -260,7 +260,7 @@ int wr_servo_update(struct pp_instance *ppi)
got_sync
=
0
;
if
(
__PP_DIAG_ALLOW_FLAGS
(
pp_global_flags
,
pp_dt_servo
,
1
))
{
if
(
__PP_DIAG_ALLOW_FLAGS
(
pp_global_
d_
flags
,
pp_dt_servo
,
1
))
{
dump_timestamp
(
ppi
,
"servo:t1"
,
s
->
t1
);
dump_timestamp
(
ppi
,
"servo:t2"
,
s
->
t2
);
dump_timestamp
(
ppi
,
"servo:t3"
,
s
->
t3
);
...
...
proto-standard/bmc.c
View file @
884bcf0a
...
...
@@ -192,10 +192,10 @@ static int bmc_state_decision(struct pp_instance *ppi,
int
cmpres
;
struct
pp_frgn_master
myself
;
if
(
ppi
->
master_only
)
if
(
ppi
->
role
==
PPSI_ROLE_MASTER
)
goto
master
;
if
(
ppi
->
slave_only
)
if
(
ppi
->
role
==
PPSI_ROLE_SLAVE
)
goto
slave
;
if
((
!
ppi
->
frgn_rec_num
)
&&
(
ppi
->
state
==
PPS_LISTENING
))
...
...
proto-standard/common-fun.c
View file @
884bcf0a
...
...
@@ -50,7 +50,7 @@ int st_com_execute_slave(struct pp_instance *ppi)
if
(
pp_timeout_z
(
ppi
,
PP_TO_ANN_RECEIPT
))
{
ppi
->
frgn_rec_num
=
0
;
if
(
DSDEF
(
ppi
)
->
clockQuality
.
clockClass
!=
PP_CLASS_SLAVE_ONLY
&&
!
ppi
->
slave_only
)
{
&&
(
ppi
->
role
!=
PPSI_ROLE_SLAVE
)
)
{
m1
(
ppi
);
ppi
->
next_state
=
PPS_MASTER
;
}
else
{
...
...
@@ -131,7 +131,7 @@ int st_com_slave_handle_sync(struct pp_instance *ppi, unsigned char *buf,
if
(
len
<
PP_SYNC_LENGTH
)
return
-
1
;
if
(
!
ppi
->
is_from_cur_par
)
if
(
!
(
ppi
->
flags
&
PPI_FLAG_FROM_CURRENT_PARENT
)
)
return
0
;
/* t2 may be overriden by follow-up, cField is always valid */
...
...
@@ -139,12 +139,12 @@ int st_com_slave_handle_sync(struct pp_instance *ppi, unsigned char *buf,
cField_to_TimeInternal
(
&
ppi
->
cField
,
hdr
->
correctionfield
);
if
((
hdr
->
flagField
[
0
]
&
PP_TWO_STEP_FLAG
)
!=
0
)
{
ppi
->
waiting_for_follow
=
TRUE
;
ppi
->
flags
|=
PPI_FLAG_WAITING_FOR_F_UP
;
ppi
->
recv_sync_sequence_id
=
hdr
->
sequenceId
;
return
0
;
}
msg_unpack_sync
(
buf
,
&
sync
);
ppi
->
waiting_for_follow
=
FALSE
;
ppi
->
flags
&=
~
PPI_FLAG_WAITING_FOR_F_UP
;
to_TimeInternal
(
&
ppi
->
t1
,
&
sync
.
originTimestamp
);
pp_servo_got_sync
(
ppi
);
...
...
@@ -163,13 +163,13 @@ int st_com_slave_handle_followup(struct pp_instance *ppi, unsigned char *buf,
if
(
len
<
PP_FOLLOW_UP_LENGTH
)
return
-
1
;
if
(
!
ppi
->
is_from_cur_par
)
{
if
(
!
(
ppi
->
flags
&
PPI_FLAG_FROM_CURRENT_PARENT
)
)
{
pp_error
(
"%s: Follow up message is not from current parent
\n
"
,
__func__
);
return
0
;
}
if
(
!
ppi
->
waiting_for_follow
)
{
if
(
!
(
ppi
->
flags
&
PPI_FLAG_WAITING_FOR_F_UP
)
)
{
pp_error
(
"%s: Slave was not waiting a follow up message
\n
"
,
__func__
);
return
0
;
...
...
@@ -182,7 +182,7 @@ int st_com_slave_handle_followup(struct pp_instance *ppi, unsigned char *buf,
}
msg_unpack_follow_up
(
buf
,
&
follow
);
ppi
->
waiting_for_follow
=
FALSE
;
ppi
->
flags
&=
~
PPI_FLAG_WAITING_FOR_F_UP
;
to_TimeInternal
(
&
ppi
->
t1
,
&
follow
.
preciseOriginTimestamp
);
/* Call the extension; it may do it all and ask to return */
...
...
proto-standard/msg.c
View file @
884bcf0a
...
...
@@ -49,7 +49,7 @@ int msg_unpack_header(struct pp_instance *ppi, void *buf, int plen)
return
-
1
;
/*
* This
"is_from_cur_par"
must be killed. Meanwhile, say it's
* This
FLAG_FROM_CURRENT_PARENT
must be killed. Meanwhile, say it's
* from current parent if we have no current parent, so the rest works
*/
if
(
!
DSPAR
(
ppi
)
->
parentPortIdentity
.
portNumber
||
...
...
@@ -58,9 +58,9 @@ int msg_unpack_header(struct pp_instance *ppi, void *buf, int plen)
PP_CLOCK_IDENTITY_LENGTH
)
&&
(
DSPAR
(
ppi
)
->
parentPortIdentity
.
portNumber
==
hdr
->
sourcePortIdentity
.
portNumber
)))
ppi
->
is_from_cur_par
=
1
;
ppi
->
flags
|=
PPI_FLAG_FROM_CURRENT_PARENT
;
else
ppi
->
is_from_cur_par
=
0
;
ppi
->
flags
&=
~
PPI_FLAG_FROM_CURRENT_PARENT
;
return
0
;
}
...
...
proto-standard/open-close.c
View file @
884bcf0a
...
...
@@ -21,8 +21,7 @@ struct pp_runtime_opts __pp_default_rt_opts = {
.
outbound_latency
=
{
0
,
PP_DEFAULT_OUTBOUND_LATENCY
},
.
max_rst
=
PP_DEFAULT_MAX_RESET
,
.
max_dly
=
PP_DEFAULT_MAX_DELAY
,
.
no_adjust
=
PP_DEFAULT_NO_ADJUST
,
.
no_rst_clk
=
PP_DEFAULT_NO_RESET_CLOCK
,
.
flags
=
PP_DEFAULT_FLAGS
,
.
ap
=
PP_DEFAULT_AP
,
.
ai
=
PP_DEFAULT_AI
,
.
s
=
PP_DEFAULT_DELAY_S
,
...
...
@@ -63,7 +62,7 @@ int pp_init_globals(struct pp_globals *ppg, struct pp_runtime_opts *pp_rt_opts)
sizeof
(
ClockQuality
));
if
(
def
->
numberPorts
==
1
)
def
->
slaveOnly
=
INST
(
ppg
,
0
)
->
slave_only
;
def
->
slaveOnly
=
(
INST
(
ppg
,
0
)
->
role
==
PPSI_ROLE_SLAVE
)
;
else
def
->
slaveOnly
=
1
;
/* the for cycle below will set it to 0 if not
* ports are not all slave_only */
...
...
@@ -75,7 +74,7 @@ int pp_init_globals(struct pp_globals *ppg, struct pp_runtime_opts *pp_rt_opts)
for
(
i
=
0
;
i
<
def
->
numberPorts
;
i
++
)
{
struct
pp_instance
*
ppi
=
INST
(
ppg
,
i
);
if
(
def
->
slaveOnly
&&
!
ppi
->
slave_only
)
if
(
def
->
slaveOnly
&&
ppi
->
role
!=
PPSI_ROLE_SLAVE
)
def
->
slaveOnly
=
0
;
ppi
->
state
=
PPS_INITIALIZING
;
...
...
proto-standard/servo.c
View file @
884bcf0a
...
...
@@ -26,7 +26,7 @@ void pp_servo_init(struct pp_instance *ppi)
SRV
(
ppi
)
->
obs_drift
=
-
d
<<
10
;
/* note "-" */
}
else
{
/* level clock */
if
(
!
OPTS
(
ppi
)
->
no_adjust
)
if
(
pp_can_adjust
(
ppi
)
)
ppi
->
t_ops
->
adjust
(
ppi
,
0
,
0
);
SRV
(
ppi
)
->
obs_drift
=
0
;
}
...
...
@@ -209,8 +209,8 @@ void pp_servo_got_resp(struct pp_instance *ppi)
TimeInternal
time_tmp
;
/* if secs, reset clock or set freq adjustment to max */
if
(
!
OPTS
(
ppi
)
->
no_adjust
)
{
if
(
!
OPTS
(
ppi
)
->
no_rst_clk
)
{
if
(
pp_can_adjust
(
ppi
)
)
{
if
(
pp_can_reset_clock
(
ppi
)
)
{
/* Can't use adjust, limited to +/- 2s */
time_tmp
=
ppi
->
t4
;
add_TimeInternal
(
&
time_tmp
,
&
time_tmp
,
...
...
@@ -278,7 +278,7 @@ void pp_servo_got_resp(struct pp_instance *ppi)
/* apply controller output as a clock tick rate adjustment, if
* provided by arch, or as a raw offset otherwise */
if
(
!
OPTS
(
ppi
)
->
no_adjust
)
{
if
(
pp_can_adjust
(
ppi
)
)
{
if
(
ppi
->
t_ops
->
adjust_freq
)
ppi
->
t_ops
->
adjust_freq
(
ppi
,
-
adj
);
else
...
...
proto-standard/state-initializing.c
View file @
884bcf0a
...
...
@@ -68,7 +68,7 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
msg_pack_header
(
ppi
,
ppi
->
tx_ptp
);
/* This is used for all tx */
if
(
!
ppi
->
master_only
)
if
(
ppi
->
role
!=
PPSI_ROLE_MASTER
)
ppi
->
next_state
=
PPS_LISTENING
;
else
ppi
->
next_state
=
PPS_MASTER
;
...
...
proto-standard/state-master.c
View file @
884bcf0a
...
...
@@ -98,7 +98,7 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
out:
if
(
e
==
0
)
{
if
(
DSDEF
(
ppi
)
->
clockQuality
.
clockClass
==
PP_CLASS_SLAVE_ONLY
||
ppi
->
slave_only
)
||
(
ppi
->
role
==
PPSI_ROLE_SLAVE
)
)
ppi
->
next_state
=
PPS_LISTENING
;
}
else
{
ppi
->
next_state
=
PPS_FAULTY
;
...
...
proto-standard/state-slave.c
View file @
884bcf0a
...
...
@@ -24,7 +24,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
if
(
e
)
goto
out
;
ppi
->
waiting_for_follow
=
FALSE
;
ppi
->
flags
&=
~
PPI_FLAG_WAITING_FOR_F_UP
;
pp_timeout_restart_annrec
(
ppi
);
...
...
@@ -69,7 +69,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
hdr
->
sequenceId
)
&&
(
DSPOR
(
ppi
)
->
portIdentity
.
portNumber
==
resp
.
requestingPortIdentity
.
portNumber
)
&&
ppi
->
is_from_cur_par
)
{
&&
(
ppi
->
flags
&
PPI_FLAG_FROM_CURRENT_PARENT
)
)
{
to_TimeInternal
(
&
ppi
->
t4
,
&
resp
.
receiveTimestamp
);
...
...
time-bare/bare-socket.c
View file @
884bcf0a
...
...
@@ -63,7 +63,7 @@ static int bare_open_ch(struct pp_instance *ppi, char *ifname)
struct
bare_packet_mreq
pmr
;
char
*
context
;
if
(
ppi
->
ethernet_mode
)
{
if
(
ppi
->
proto
==
PPSI_PROTO_RAW
)
{
/* open socket */
context
=
"socket()"
;
sock
=
sys_socket
(
PF_PACKET
,
SOCK_RAW
,
ETH_P_1588
);
...
...
@@ -141,7 +141,7 @@ static int bare_net_init(struct pp_instance *ppi)
/* The buffer is inside ppi, but we need to set pointers and align */
pp_prepare_pointers
(
ppi
);
if
(
ppi
->
ethernet_mode
)
{
if
(
ppi
->
proto
==
PPSI_PROTO_RAW
)
{
pp_diag
(
ppi
,
frames
,
1
,
"bare_net_init IEEE 802.3
\n
"
);
/* raw sockets implementation always use gen socket */
...
...
time-bare/bare-time.c
View file @
884bcf0a
...
...
@@ -19,7 +19,7 @@ static int bare_time_get(struct pp_instance *ppi, TimeInternal *t)
/* TAI = UTC + 35 */
t
->
seconds
=
tv
.
tv_sec
+
DSPRO
(
ppi
)
->
currentUtcOffset
;
t
->
nanoseconds
=
tv
.
tv_usec
*
1000
;
if
(
!
(
pp_global_flags
&
PP_FLAG_NOTIMELOG
))
if
(
!
(
pp_global_
d_
flags
&
PP_FLAG_NOTIMELOG
))
pp_diag
(
ppi
,
time
,
2
,
"%s: %9li.%06li
\n
"
,
__func__
,
tv
.
tv_sec
,
tv
.
tv_usec
);
return
0
;
...
...
time-sim/sim-time.c
View file @
884bcf0a
...
...
@@ -54,7 +54,7 @@ static int sim_time_get(struct pp_instance *ppi, TimeInternal *t)
(
long
long
)
PP_NSEC_PER_SEC
;
t
->
correct
=
1
;
if
(
!
(
pp_global_flags
&
PP_FLAG_NOTIMELOG
))
if
(
!
(
pp_global_
d_
flags
&
PP_FLAG_NOTIMELOG
))
pp_diag
(
ppi
,
time
,
2
,
"%s: %9li.%09li
\n
"
,
__func__
,
(
long
)
t
->
seconds
,
(
long
)
t
->
nanoseconds
);
return
0
;
...
...
time-unix/unix-socket.c
View file @
884bcf0a
...
...
@@ -106,7 +106,7 @@ static int unix_net_recv(struct pp_instance *ppi, void *pkt, int len,
struct
pp_channel
*
ch1
,
*
ch2
;
int
ret
;
if
(
ppi
->
ethernet_mode
)
{
if
(
ppi
->
proto
==
PPSI_PROTO_RAW
)
{
int
fd
=
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
;
ret
=
unix_recv_msg
(
ppi
,
fd
,
pkt
,
len
,
t
);
...
...
@@ -146,7 +146,7 @@ static int unix_net_send(struct pp_instance *ppi, void *pkt, int len,
return
len
;
}
if
(
ppi
->
ethernet_mode
)
{
if
(
ppi
->
proto
==
PPSI_PROTO_RAW
)
{
hdr
->
h_proto
=
htons
(
ETH_P_1588
);
memcpy
(
hdr
->
h_dest
,
PP_MCAST_MACADDRESS
,
ETH_ALEN
);
...
...
@@ -193,7 +193,7 @@ static int unix_open_ch(struct pp_instance *ppi, char *ifname, int chtype)
char
addr_str
[
INET_ADDRSTRLEN
];
char
*
context
;
if
(
ppi
->
ethernet_mode
)
{
if
(
ppi
->
proto
==
PPSI_PROTO_RAW
)
{
/* open socket */
context
=
"socket()"
;
sock
=
socket
(
PF_PACKET
,
SOCK_RAW
,
ETH_P_1588
);
...
...
@@ -359,7 +359,7 @@ static int unix_net_init(struct pp_instance *ppi)
/* The buffer is inside ppi, but we need to set pointers and align */
pp_prepare_pointers
(
ppi
);
if
(
ppi
->
ethernet_mode
)
{
if
(
ppi
->
proto
==
PPSI_PROTO_RAW
)
{
pp_diag
(
ppi
,
frames
,
1
,
"unix_net_init IEEE 802.3
\n
"
);
/* raw sockets implementation always use gen socket */
...
...
@@ -385,7 +385,7 @@ static int unix_net_exit(struct pp_instance *ppi)
int
fd
;
int
i
;
if
(
ppi
->
ethernet_mode
)
{
if
(
ppi
->
proto
==
PPSI_PROTO_RAW
)
{
fd
=
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
;
if
(
fd
>
0
)
{
close
(
fd
);
...
...
time-unix/unix-time.c
View file @
884bcf0a
...
...
@@ -32,7 +32,7 @@ static int unix_time_get(struct pp_instance *ppi, TimeInternal *t)
t
->
seconds
=
tp
.
tv_sec
+
DSPRO
(
ppi
)
->
currentUtcOffset
;
t
->
nanoseconds
=
tp
.
tv_nsec
;
t
->
correct
=
1
;
if
(
!
(
pp_global_flags
&
PP_FLAG_NOTIMELOG
))
if
(
!
(
pp_global_
d_
flags
&
PP_FLAG_NOTIMELOG
))
pp_diag
(
ppi
,
time
,
2
,
"%s: %9li.%09li
\n
"
,
__func__
,
tp
.
tv_sec
,
tp
.
tv_nsec
);
return
0
;
...
...
time-wrpc/wrpc-time.c
View file @
884bcf0a
...
...
@@ -18,7 +18,7 @@ static int wrpc_time_get(struct pp_instance *ppi, TimeInternal *t)
t
->
seconds
=
sec
;
t
->
nanoseconds
=
nsec
;
if
(
!
(
pp_global_flags
&
PP_FLAG_NOTIMELOG
))
if
(
!
(
pp_global_
d_
flags
&
PP_FLAG_NOTIMELOG
))
pp_diag
(
ppi
,
time
,
2
,
"%s: %9lu.%09li
\n
"
,
__func__
,
(
long
)
sec
,
(
long
)
nsec
);
return
0
;
...
...
time-wrs/wrs-socket.c
View file @
884bcf0a
...
...
@@ -248,7 +248,7 @@ int wrs_net_recv(struct pp_instance *ppi, void *pkt, int len,
struct
pp_channel
*
ch1
,
*
ch2
;
int
ret
=
-
1
;
if
(
ppi
->
ethernet_mode
)
{
if
(
ppi
->
proto
==
PPSI_PROTO_RAW
)
{
int
fd
=
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
;
ret
=
wrs_recv_msg
(
ppi
,
fd
,
pkt
,
len
,
t
);
...
...
@@ -317,7 +317,7 @@ static void poll_tx_timestamp(struct pp_instance *ppi,
* a tx timestamp. Udp doesn't so don't check in udp mode
* (the pointer is only checked for non-null)
*/
if
(
!
ppi
->
ethernet_mode
)
if
(
!
(
ppi
->
proto
==
PPSI_PROTO_RAW
)
)
serr
=
(
void
*
)
1
;
for
(
cmsg
=
CMSG_FIRSTHDR
(
&
msg
);
...
...
@@ -361,7 +361,7 @@ int wrs_net_send(struct pp_instance *ppi, void *pkt, int len,
*/
drop
=
ppsi_drop_tx
();
if
(
ppi
->
ethernet_mode
)
{
if
(
ppi
->
proto
==
PPSI_PROTO_RAW
)
{
fd
=
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
;
hdr
->
h_proto
=
htons
(
ETH_P_1588
);
if
(
drop
)
...
...
time-wrs/wrs-time.c
View file @
884bcf0a
...
...
@@ -176,7 +176,7 @@ static int wrs_time_get(struct pp_instance *ppi, TimeInternal *t)
t
->
nanoseconds
=
p
.
current_nsec
;
t
->
correct
=
p
.
pps_valid
;
if
(
!
(
pp_global_flags
&
PP_FLAG_NOTIMELOG
))
if
(
!
(
pp_global_
d_
flags
&
PP_FLAG_NOTIMELOG
))
pp_diag
(
ppi
,
time
,
2
,
"%s: (valid %x) %9li.%09li
\n
"
,
__func__
,
p
.
pps_valid
,
(
long
)
p
.
current_sec
,
(
long
)
p
.
current_nsec
);
...
...
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