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
be3e6c27
Commit
be3e6c27
authored
Mar 03, 2016
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
timeout: reset them all at FSM new state
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
6305e770
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
16 additions
and
44 deletions
+16
-44
fsm.c
fsm.c
+2
-0
state-wr-present.c
proto-ext-whiterabbit/state-wr-present.c
+0
-3
state-faulty.c
proto-standard/state-faulty.c
+0
-4
state-listening.c
proto-standard/state-listening.c
+0
-9
state-master.c
proto-standard/state-master.c
+0
-10
state-passive.c
proto-standard/state-passive.c
+0
-9
state-slave.c
proto-standard/state-slave.c
+1
-9
timeout.c
timeout.c
+13
-0
No files found.
fsm.c
View file @
be3e6c27
...
@@ -119,6 +119,8 @@ int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen)
...
@@ -119,6 +119,8 @@ int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen)
if
(
ppi
->
state
!=
ppi
->
next_state
)
{
if
(
ppi
->
state
!=
ppi
->
next_state
)
{
ppi
->
state
=
ppi
->
next_state
;
ppi
->
state
=
ppi
->
next_state
;
ppi
->
is_new_state
=
1
;
ppi
->
is_new_state
=
1
;
pp_timeout_setall
(
ppi
);
ppi
->
flags
&=
~
PPI_FLAGS_WAITING
;
pp_diag_fsm
(
ppi
,
ip
->
name
,
STATE_LEAVE
,
0
);
pp_diag_fsm
(
ppi
,
ip
->
name
,
STATE_LEAVE
,
0
);
return
0
;
/* next_delay unused: go to new state now */
return
0
;
/* next_delay unused: go to new state now */
}
}
...
...
proto-ext-whiterabbit/state-wr-present.c
View file @
be3e6c27
...
@@ -57,9 +57,6 @@ out:
...
@@ -57,9 +57,6 @@ out:
else
else
ppi
->
next_state
=
PPS_FAULTY
;
ppi
->
next_state
=
PPS_FAULTY
;
if
(
ppi
->
next_state
!=
ppi
->
state
)
pp_timeout_clr
(
ppi
,
PP_TO_ANN_RECEIPT
);
ppi
->
next_delay
=
WR_DSPOR
(
ppi
)
->
wrStateTimeout
;
ppi
->
next_delay
=
WR_DSPOR
(
ppi
)
->
wrStateTimeout
;
return
e
;
return
e
;
...
...
proto-standard/state-faulty.c
View file @
be3e6c27
...
@@ -15,10 +15,6 @@
...
@@ -15,10 +15,6 @@
int
pp_faulty
(
struct
pp_instance
*
ppi
,
unsigned
char
*
pkt
,
int
plen
)
int
pp_faulty
(
struct
pp_instance
*
ppi
,
unsigned
char
*
pkt
,
int
plen
)
{
{
if
(
ppi
->
is_new_state
)
{
pp_timeout_set
(
ppi
,
PP_TO_FAULTY
);
}
if
(
pp_timeout
(
ppi
,
PP_TO_FAULTY
))
{
if
(
pp_timeout
(
ppi
,
PP_TO_FAULTY
))
{
ppi
->
next_state
=
PPS_INITIALIZING
;
ppi
->
next_state
=
PPS_INITIALIZING
;
return
0
;
return
0
;
...
...
proto-standard/state-listening.c
View file @
be3e6c27
...
@@ -20,11 +20,6 @@ int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
...
@@ -20,11 +20,6 @@ int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
if
(
e
)
if
(
e
)
goto
out
;
goto
out
;
if
(
ppi
->
is_new_state
)
{
pp_timeout_restart_annrec
(
ppi
);
pp_timeout_set
(
ppi
,
PP_TO_REQUEST
);
}
/* when the clock is using peer-delay, listening must send it too */
/* when the clock is using peer-delay, listening must send it too */
if
(
ppi
->
glbs
->
delay_mech
==
PP_P2P_MECH
if
(
ppi
->
glbs
->
delay_mech
==
PP_P2P_MECH
&&
pp_timeout_z
(
ppi
,
PP_TO_REQUEST
))
{
&&
pp_timeout_z
(
ppi
,
PP_TO_REQUEST
))
{
...
@@ -102,10 +97,6 @@ out:
...
@@ -102,10 +97,6 @@ out:
if
(
e
!=
0
)
if
(
e
!=
0
)
ppi
->
next_state
=
PPS_FAULTY
;
ppi
->
next_state
=
PPS_FAULTY
;
/* Leaving this state */
if
(
ppi
->
next_state
!=
ppi
->
state
)
pp_timeout_clr
(
ppi
,
PP_TO_ANN_RECEIPT
);
ppi
->
next_delay
=
pp_ms_to_timeout
(
ppi
,
PP_TO_ANN_RECEIPT
);
ppi
->
next_delay
=
pp_ms_to_timeout
(
ppi
,
PP_TO_ANN_RECEIPT
);
return
0
;
return
0
;
...
...
proto-standard/state-master.c
View file @
be3e6c27
...
@@ -67,16 +67,6 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
...
@@ -67,16 +67,6 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
MsgHeader
*
hdr
=
&
ppi
->
received_ptp_header
;
MsgHeader
*
hdr
=
&
ppi
->
received_ptp_header
;
MsgPDelayRespFollowUp
respFllw
;
MsgPDelayRespFollowUp
respFllw
;
if
(
ppi
->
is_new_state
)
{
pp_timeout_set
(
ppi
,
PP_TO_SYNC_SEND
);
pp_timeout_set
(
ppi
,
PP_TO_REQUEST
);
pp_timeout_set
(
ppi
,
PP_TO_ANN_SEND
);
/* Send an announce immediately, when becomes master */
if
((
e
=
pp_master_issue_announce
(
ppi
))
<
0
)
goto
out
;
}
if
(
pp_timeout_z
(
ppi
,
PP_TO_SYNC_SEND
))
{
if
(
pp_timeout_z
(
ppi
,
PP_TO_SYNC_SEND
))
{
/* Restart the timeout for next time */
/* Restart the timeout for next time */
pp_timeout_set
(
ppi
,
PP_TO_SYNC_SEND
);
pp_timeout_set
(
ppi
,
PP_TO_SYNC_SEND
);
...
...
proto-standard/state-passive.c
View file @
be3e6c27
...
@@ -15,11 +15,6 @@ int pp_passive(struct pp_instance *ppi, unsigned char *pkt, int plen)
...
@@ -15,11 +15,6 @@ int pp_passive(struct pp_instance *ppi, unsigned char *pkt, int plen)
MsgHeader
*
hdr
=
&
ppi
->
received_ptp_header
;
MsgHeader
*
hdr
=
&
ppi
->
received_ptp_header
;
MsgPDelayRespFollowUp
respFllw
;
MsgPDelayRespFollowUp
respFllw
;
if
(
ppi
->
is_new_state
)
{
pp_timeout_restart_annrec
(
ppi
);
pp_timeout_set
(
ppi
,
PP_TO_REQUEST
);
}
/* when the clock is using peer-delay, listening must send it too */
/* when the clock is using peer-delay, listening must send it too */
if
(
ppi
->
glbs
->
delay_mech
==
PP_P2P_MECH
if
(
ppi
->
glbs
->
delay_mech
==
PP_P2P_MECH
&&
pp_timeout_z
(
ppi
,
PP_TO_REQUEST
))
{
&&
pp_timeout_z
(
ppi
,
PP_TO_REQUEST
))
{
...
@@ -96,10 +91,6 @@ no_incoming_msg:
...
@@ -96,10 +91,6 @@ no_incoming_msg:
if
(
e
!=
0
)
if
(
e
!=
0
)
ppi
->
next_state
=
PPS_FAULTY
;
ppi
->
next_state
=
PPS_FAULTY
;
if
(
ppi
->
next_state
!=
ppi
->
state
)
{
pp_timeout_clr
(
ppi
,
PP_TO_ANN_RECEIPT
);
}
ppi
->
next_delay
=
PP_DEFAULT_NEXT_DELAY_MS
;
ppi
->
next_delay
=
PP_DEFAULT_NEXT_DELAY_MS
;
return
0
;
return
0
;
...
...
proto-standard/state-slave.c
View file @
be3e6c27
...
@@ -27,12 +27,6 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
...
@@ -27,12 +27,6 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
e
=
pp_hooks
.
new_slave
(
ppi
,
pkt
,
plen
);
e
=
pp_hooks
.
new_slave
(
ppi
,
pkt
,
plen
);
if
(
e
)
if
(
e
)
goto
out
;
goto
out
;
ppi
->
flags
&=
~
PPI_FLAGS_WAITING
;
pp_timeout_restart_annrec
(
ppi
);
pp_timeout_set
(
ppi
,
PP_TO_REQUEST
);
}
}
if
(
plen
==
0
)
if
(
plen
==
0
)
...
@@ -167,10 +161,8 @@ out:
...
@@ -167,10 +161,8 @@ out:
}
}
if
(
ppi
->
next_state
!=
ppi
->
state
)
{
if
(
ppi
->
next_state
!=
ppi
->
state
)
{
pp_timeout_clr
(
ppi
,
PP_TO_ANN_RECEIPT
);
pp_timeout_clr
(
ppi
,
PP_TO_REQUEST
);
pp_servo_init
(
ppi
);
pp_servo_init
(
ppi
);
return
e
;
}
}
d1
=
d2
=
pp_ms_to_timeout
(
ppi
,
PP_TO_ANN_RECEIPT
);
d1
=
d2
=
pp_ms_to_timeout
(
ppi
,
PP_TO_ANN_RECEIPT
);
if
(
ppi
->
timeouts
[
PP_TO_REQUEST
])
if
(
ppi
->
timeouts
[
PP_TO_REQUEST
])
...
...
timeout.c
View file @
be3e6c27
...
@@ -90,6 +90,19 @@ void pp_timeout_set(struct pp_instance *ppi, int index)
...
@@ -90,6 +90,19 @@ void pp_timeout_set(struct pp_instance *ppi, int index)
__pp_timeout_set
(
ppi
,
index
,
millisec
);
__pp_timeout_set
(
ppi
,
index
,
millisec
);
}
}
/*
* When we enter a new fsm state, we init all timeouts. Who cares if
* some of them are not used (and even if some have no default timeout)
*/
void
pp_timeout_setall
(
struct
pp_instance
*
ppi
)
{
int
i
;
for
(
i
=
0
;
i
<
__PP_TO_ARRAY_SIZE
;
i
++
)
pp_timeout_set
(
ppi
,
i
);
/* but announce_send must be send soon */
__pp_timeout_set
(
ppi
,
PP_TO_ANN_SEND
,
20
);
}
void
pp_timeout_clr
(
struct
pp_instance
*
ppi
,
int
index
)
void
pp_timeout_clr
(
struct
pp_instance
*
ppi
,
int
index
)
{
{
ppi
->
timeouts
[
index
]
=
0
;
ppi
->
timeouts
[
index
]
=
0
;
...
...
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