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
4e36fbda
Commit
4e36fbda
authored
Mar 07, 2023
by
Tristan Gingold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove dynamic allocation of timeouts
Timeout indexes are now static. Reduce .data size
parent
6824eb22
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
96 additions
and
113 deletions
+96
-113
main-loop.c
arch-wrs/main-loop.c
+5
-4
timeout_def.h
include/ppsi/timeout_def.h
+9
-4
timeout_prot.h
include/ppsi/timeout_prot.h
+8
-14
l1e-api.h
proto-ext-l1sync/l1e-api.h
+0
-8
l1e-hooks.c
proto-ext-l1sync/l1e-hooks.c
+5
-13
l1e-state-machine.c
proto-ext-l1sync/l1e-state-machine.c
+14
-14
hooks.c
proto-ext-whiterabbit/hooks.c
+1
-4
state-wr-calibrated.c
proto-ext-whiterabbit/state-wr-calibrated.c
+3
-3
state-wr-locked.c
proto-ext-whiterabbit/state-wr-locked.c
+3
-3
state-wr-m-lock.c
proto-ext-whiterabbit/state-wr-m-lock.c
+3
-3
state-wr-present.c
proto-ext-whiterabbit/state-wr-present.c
+3
-3
state-wr-resp-calib-req.c
proto-ext-whiterabbit/state-wr-resp-calib-req.c
+3
-3
state-wr-s-lock.c
proto-ext-whiterabbit/state-wr-s-lock.c
+2
-2
wr-api.h
proto-ext-whiterabbit/wr-api.h
+0
-1
state-abscal.c
proto-standard/state-abscal.c
+1
-3
wrs-time.c
time-wrs/wrs-time.c
+5
-5
timeout.c
timeout.c
+31
-26
No files found.
arch-wrs/main-loop.c
View file @
4e36fbda
...
...
@@ -113,8 +113,9 @@ static unsigned int run_all_state_machines(struct pp_globals *ppg)
int
delay_ms
=
0
,
delay_ms_j
;
if
(
portInfoTmoIdx
==-
1
)
{
portInfoTmoIdx
=
pp_gtimeout_get_timer
(
ppg
,
"SEND_PORT_INFO"
,
TO_RAND_NONE
,
0
);
pp_gtimeout_set
(
ppg
,
portInfoTmoIdx
,
2000
);
// Update interface info every 2 seconds
pp_gtimeout_get_timer
(
ppg
,
PP_TO_WRS_SEND_PORT_INFO
,
TO_RAND_NONE
);
portInfoTmoIdx
=
1
;
pp_gtimeout_set
(
ppg
,
PP_TO_WRS_SEND_PORT_INFO
,
2000
);
// Update interface info every 2 seconds
pp_gtimeout_set
(
ppg
,
PP_TO_BMC
,
TMO_DEFAULT_BMCA_MS
);
}
...
...
@@ -215,9 +216,9 @@ static unsigned int run_all_state_machines(struct pp_globals *ppg)
delay_ms
=
delay_bmca
;
}
if
(
pp_gtimeout
(
ppg
,
portInfoTmoIdx
)
)
{
if
(
pp_gtimeout
(
ppg
,
PP_TO_WRS_SEND_PORT_INFO
)
)
{
wrs_update_port_info
(
ppg
);
pp_gtimeout_reset
(
ppg
,
portInfoTmoIdx
);
pp_gtimeout_reset
(
ppg
,
PP_TO_WRS_SEND_PORT_INFO
);
}
return
delay_ms
;
...
...
include/ppsi/timeout_def.h
View file @
4e36fbda
...
...
@@ -40,12 +40,17 @@ enum pp_timeouts {
PP_TO_PROT_STATE
,
PP_TO_IN_STATE
,
PP_TO_GM_BY_BMCA
,
PP_TO_PREDEF_COUNTERS
/* Number of predefined counters */
PP_TO_PREDEF_COUNTERS
,
/* Number of predefined counters */
PP_TO_L1E_TX_SYNC
=
PP_TO_PREDEF_COUNTERS
,
PP_TO_L1E_RX_SYNC
,
PP_TO_WR_EXT_0
,
#if CONFIG_ARCH_IS_WRS == 1
PP_TO_WRS_SEND_PORT_INFO
,
PP_TO_WRS_GM_REFRESH
,
#endif
PP_TO_COUNT
};
#define PP_TO_MAX_FREE_COUNTERS 6
#define PP_TO_COUNT (PP_TO_PREDEF_COUNTERS+PP_TO_MAX_FREE_COUNTERS)
/* Control flags */
#define TMO_CF_INSTANCE_DEPENDENT 1
/* PPSi instance dependent: each instance has its own counters */
#define TMO_CF_ALLOW_COMMON_SET 2
/* Counter reseted when pp_timeout_setall() is called */
...
...
include/ppsi/timeout_prot.h
View file @
4e36fbda
...
...
@@ -13,7 +13,7 @@
#define TIMEOUT_DISABLE_VALUE -1
extern
void
pp_timeout_init
(
struct
pp_instance
*
ppi
);
extern
void
__pp_timeout_reset
(
struct
pp_instance
*
ppi
,
int
index
,
unsigned
int
multiplier
);
extern
void
__pp_timeout_reset
(
struct
pp_instance
*
ppi
,
int
index
,
unsigned
int
multiplier
);
extern
int
pp_timeout_get
(
struct
pp_instance
*
ppi
,
int
index
);
extern
void
pp_timeout_setall
(
struct
pp_instance
*
ppi
);
extern
int
pp_timeout
(
struct
pp_instance
*
ppi
,
int
index
)
...
...
@@ -21,10 +21,8 @@ extern int pp_timeout(struct pp_instance *ppi, int index)
extern
int
pp_next_delay_1
(
struct
pp_instance
*
ppi
,
int
i1
);
extern
int
pp_next_delay_2
(
struct
pp_instance
*
ppi
,
int
i1
,
int
i2
);
extern
int
pp_next_delay_3
(
struct
pp_instance
*
ppi
,
int
i1
,
int
i2
,
int
i3
);
extern
int
pp_timeout_get_timer
(
struct
pp_instance
*
ppi
,
char
*
name
,
to_rand_t
rand
,
int
ctl_flags
);
extern
void
pp_timeout_free_timer
(
struct
pp_instance
*
ppi
,
int
index
);
extern
void
pp_timeout_set_rename
(
struct
pp_instance
*
ppi
,
int
index
,
int
millisec
,
char
*
name
);
extern
int
pp_timeout_get_timer
(
struct
pp_instance
*
ppi
,
int
index
,
to_rand_t
rand
);
extern
void
pp_timeout_set_rename
(
struct
pp_instance
*
ppi
,
int
index
,
int
millisec
);
extern
void
pp_timeout_disable_all
(
struct
pp_instance
*
ppi
);
...
...
@@ -37,12 +35,12 @@ static inline int pp_gtimeout_get(struct pp_globals *ppg, int index) {
return
pp_timeout_get
(
INST
(
ppg
,
0
),
index
);
}
static
inline
void
pp_timeout_set
(
struct
pp_instance
*
ppi
,
int
index
,
int
millisec
)
static
inline
void
pp_timeout_set
(
struct
pp_instance
*
ppi
,
int
index
,
int
millisec
)
{
pp_timeout_set_rename
(
ppi
,
index
,
millisec
,
NULL
);
pp_timeout_set_rename
(
ppi
,
index
,
millisec
);
}
static
inline
void
pp_gtimeout_set
(
struct
pp_globals
*
ppg
,
int
index
,
int
millisec
)
{
static
inline
void
pp_gtimeout_set
(
struct
pp_globals
*
ppg
,
int
index
,
int
millisec
)
{
pp_timeout_set
(
INST
(
ppg
,
0
),
index
,
millisec
);
}
...
...
@@ -78,12 +76,8 @@ static inline int pp_gnext_delay_1(struct pp_globals *ppg, int index) {
return
pp_next_delay_1
(
INST
(
ppg
,
0
),
index
);
}
static
inline
int
pp_gtimeout_get_timer
(
struct
pp_globals
*
ppg
,
char
*
name
,
to_rand_t
rand
,
int
ctl_flags
){
return
pp_timeout_get_timer
(
INST
(
ppg
,
0
),
name
,
rand
,
ctl_flags
);
}
static
inline
void
pp_gtimeout_free_timer
(
struct
pp_globals
*
ppg
,
int
index
){
pp_timeout_free_timer
(
INST
(
ppg
,
0
),
index
);
static
inline
int
pp_gtimeout_get_timer
(
struct
pp_globals
*
ppg
,
int
index
,
to_rand_t
rand
){
return
pp_timeout_get_timer
(
INST
(
ppg
,
0
),
index
,
rand
);
}
static
inline
void
pp_timeout_reset
(
struct
pp_instance
*
ppi
,
int
index
)
...
...
proto-ext-l1sync/l1e-api.h
View file @
4e36fbda
...
...
@@ -18,10 +18,6 @@
#define PROTO_EXT_L1SYNC (1)
/* Rename the timeouts, for readability */
#define L1E_TIMEOUT_TX_SYNC l1eTmoTxSync
#define L1E_TIMEOUT_RX_SYNC l1eTmoRxSync
/* Time-out */
#define L1E_DEFAULT_L1SYNC_INTERVAL 0
#define L1E_MIN_L1SYNC_INTERVAL -4
...
...
@@ -164,10 +160,6 @@ static inline int l1e_servo_got_presp(struct pp_instance *ppi) {
return
wrh_servo_got_presp
(
ppi
);
}
/* Timer indexes */
extern
int
l1eTmoTxSync
;
extern
int
l1eTmoRxSync
;
#else
#define PROTO_EXT_L1SYNC (0)
#endif
/* CONFIG_EXT_L1SYNC == 1 */
...
...
proto-ext-l1sync/l1e-hooks.c
View file @
4e36fbda
...
...
@@ -19,13 +19,9 @@ char *l1e_state_name[] = {
[
L1SYNC_UP
]
=
"L1SYNC_UP"
,
};
int
l1eTmoTxSync
=
0
;
int
l1eTmoRxSync
=
0
;
void
l1e_print_L1Sync_basic_bitmaps
(
struct
pp_instance
*
ppi
,
uint8_t
configed
,
uint8_t
active
,
char
*
text
)
{
pp_diag
(
ppi
,
ext
,
2
,
"ML: L1Sync %s
\n
"
,
text
);
pp_diag
(
ppi
,
ext
,
2
,
"ML:
\t
Config: TxC=%d RxC=%d Cong=%d Param=%d
\n
"
,
((
configed
&
L1E_TX_COHERENT
)
==
L1E_TX_COHERENT
),
...
...
@@ -54,15 +50,11 @@ static int l1e_init(struct pp_instance *ppi, void *buf, int len)
pp_diag
(
ppi
,
ext
,
2
,
"hook: %s -- ext %i
\n
"
,
__func__
,
ppi
->
protocol_extension
);
if
(
l1eTmoTxSync
==
0
)
{
l1eTmoTxSync
=
pp_timeout_get_timer
(
ppi
,
"L1E_TX_SYNC"
,
TO_RAND_NONE
,
TMO_CF_INSTANCE_DEPENDENT
);
}
if
(
l1eTmoRxSync
==
0
)
l1eTmoRxSync
=
pp_timeout_get_timer
(
ppi
,
"L1E_RX_SYNC"
,
TO_RAND_NONE
,
TMO_CF_INSTANCE_DEPENDENT
);
pp_timeout_get_timer
(
ppi
,
PP_TO_L1E_TX_SYNC
,
TO_RAND_NONE
);
pp_timeout_get_timer
(
ppi
,
PP_TO_L1E_RX_SYNC
,
TO_RAND_NONE
);
pp_timeout_set
(
ppi
,
L1E_TIMEOUT
_TX_SYNC
,
100
);
/* Will be set later to the appropriate value */
pp_timeout_set
(
ppi
,
L1E_TIMEOUT
_RX_SYNC
,
100
);
/* Will be set later to the appropriate value */
pp_timeout_set
(
ppi
,
PP_TO_L1E
_TX_SYNC
,
100
);
/* Will be set later to the appropriate value */
pp_timeout_set
(
ppi
,
PP_TO_L1E
_RX_SYNC
,
100
);
/* Will be set later to the appropriate value */
// init dynamic data set members with zeros/defaults
bds
->
L1SyncLinkAlive
=
FALSE
;
...
...
@@ -101,7 +93,7 @@ static int l1e_handle_signaling(struct pp_instance * ppi, void *buf, int len)
/* Valid Sync message */
/* Reset reception timeout */
pp_timeout_set
(
ppi
,
L1E_TIMEOUT
_RX_SYNC
,
l1e_get_rx_tmo_ms
(
bds
));
pp_timeout_set
(
ppi
,
PP_TO_L1E
_RX_SYNC
,
l1e_get_rx_tmo_ms
(
bds
));
bds
->
L1SyncLinkAlive
=
TRUE
;
if
(
ppi
->
extState
==
PP_EXSTATE_PTP
)
{
...
...
proto-ext-l1sync/l1e-state-machine.c
View file @
4e36fbda
...
...
@@ -64,7 +64,7 @@ int l1e_run_state_machine(struct pp_instance *ppi, void *buf, int len) {
return
PP_DEFAULT_NEXT_DELAY_MS
;
/* Return default delay */
if
(
nextState
>=
MAX_STATE_ACTIONS
)
return
pp_next_delay_2
(
ppi
,
L1E_TIMEOUT_TX_SYNC
,
L1E_TIMEOUT
_RX_SYNC
);
return
pp_next_delay_2
(
ppi
,
PP_TO_L1E_TX_SYNC
,
PP_TO_L1E
_RX_SYNC
);
/*
* Update the L1SYNC dynamic data independent of the state machine
...
...
@@ -74,15 +74,15 @@ int l1e_run_state_machine(struct pp_instance *ppi, void *buf, int len) {
basicDS
->
isTxCoherent
=
ppi
->
link_up
?
1
:
0
;
/* Check L1SYNC reception Time-out */
if
(
pp_timeout
(
ppi
,
L1E_TIMEOUT
_RX_SYNC
)
)
{
if
(
pp_timeout
(
ppi
,
PP_TO_L1E
_RX_SYNC
)
)
{
/* Time-out detected */
pp_timeout_set
(
ppi
,
L1E_TIMEOUT
_RX_SYNC
,
l1e_get_rx_tmo_ms
(
basicDS
));
pp_timeout_set
(
ppi
,
PP_TO_L1E
_RX_SYNC
,
l1e_get_rx_tmo_ms
(
basicDS
));
basicDS
->
L1SyncLinkAlive
=
FALSE
;
*
execute_state_machine
=
TRUE
;
}
/* Check L1SYNC transmission Time-out */
if
(
pp_timeout
(
ppi
,
L1E_TIMEOUT
_TX_SYNC
)
)
{
if
(
pp_timeout
(
ppi
,
PP_TO_L1E
_TX_SYNC
)
)
{
*
execute_state_machine
=
TRUE
;
}
...
...
@@ -101,7 +101,7 @@ int l1e_run_state_machine(struct pp_instance *ppi, void *buf, int len) {
*/
delay
=
(
*
le1_state_actions
[
basicDS
->
L1SyncState
].
action
)
(
ppi
,
newState
);
}
else
delay
=
pp_next_delay_2
(
ppi
,
L1E_TIMEOUT_TX_SYNC
,
L1E_TIMEOUT
_RX_SYNC
);
/* Return the shorter timeout */
delay
=
pp_next_delay_2
(
ppi
,
PP_TO_L1E_TX_SYNC
,
PP_TO_L1E
_RX_SYNC
);
/* Return the shorter timeout */
/* If return delay is 0, it means that the state machine should be executed at last call */
*
execute_state_machine
=
(
delay
==
0
);
...
...
@@ -112,7 +112,7 @@ int l1e_run_state_machine(struct pp_instance *ppi, void *buf, int len) {
}
static
int
l1e_empty_action
(
struct
pp_instance
*
ppi
,
Boolean
new_state
){
return
pp_next_delay_2
(
ppi
,
L1E_TIMEOUT_TX_SYNC
,
L1E_TIMEOUT
_RX_SYNC
);
/* Return the shorter timeout */
return
pp_next_delay_2
(
ppi
,
PP_TO_L1E_TX_SYNC
,
PP_TO_L1E
_RX_SYNC
);
/* Return the shorter timeout */
}
/* L1_SYNC_RESET event */
...
...
@@ -206,7 +206,7 @@ static __inline__ int measure_last_time(struct pp_instance *ppi, int fmeas) {
static
void
l1e_send_sync_msg
(
struct
pp_instance
*
ppi
,
Boolean
immediatSend
)
{
if
(
immediatSend
||
pp_timeout
(
ppi
,
L1E_TIMEOUT
_TX_SYNC
)
)
{
if
(
immediatSend
||
pp_timeout
(
ppi
,
PP_TO_L1E
_TX_SYNC
)
)
{
int
len
;
int
fmeas
,
lmeas
;
int
diff
;
...
...
@@ -226,7 +226,7 @@ static void l1e_send_sync_msg(struct pp_instance *ppi, Boolean immediatSend) {
tmo_ms
=
pp_timeout_log_to_ms
(
L1E_DSPOR_BS
(
ppi
)
->
logL1SyncInterval
);
if
(
tmo_ms
>=
diff
)
/* to be sure to have a positive value */
tmo_ms
-=
diff
;
pp_timeout_set
(
ppi
,
L1E_TIMEOUT
_TX_SYNC
,
tmo_ms
);
/* loop ever since */
pp_timeout_set
(
ppi
,
PP_TO_L1E
_TX_SYNC
,
tmo_ms
);
/* loop ever since */
}
}
...
...
@@ -257,7 +257,7 @@ static int l1e_handle_state_disabled(struct pp_instance *ppi, Boolean new_state)
L1E_DSPOR_BS
(
ppi
)
->
next_state
=
L1SYNC_IDLE
;
return
0
;
/* no wait to evaluate next state */
}
return
pp_next_delay_2
(
ppi
,
L1E_TIMEOUT_TX_SYNC
,
L1E_TIMEOUT
_RX_SYNC
);
/* Return the shorter timeout */
return
pp_next_delay_2
(
ppi
,
PP_TO_L1E_TX_SYNC
,
PP_TO_L1E
_RX_SYNC
);
/* Return the shorter timeout */
}
/* IDLE state */
...
...
@@ -292,7 +292,7 @@ static int l1e_handle_state_idle(struct pp_instance *ppi, Boolean new_state){
}
/* Iterative treatment */
l1e_send_sync_msg
(
ppi
,
0
);
return
pp_next_delay_2
(
ppi
,
L1E_TIMEOUT_TX_SYNC
,
L1E_TIMEOUT
_RX_SYNC
);
/* Return the shorter timeout */
return
pp_next_delay_2
(
ppi
,
PP_TO_L1E_TX_SYNC
,
PP_TO_L1E
_RX_SYNC
);
/* Return the shorter timeout */
}
/* LINK_ALIVE state */
...
...
@@ -302,7 +302,7 @@ static int l1e_handle_state_link_alive(struct pp_instance *ppi, Boolean new_stat
/* State initialization */
if
(
new_state
)
{
/* Initialize time-out peer L1SYNC reception */
pp_timeout_set
(
ppi
,
L1E_TIMEOUT
_RX_SYNC
,
l1e_get_rx_tmo_ms
(
basic
));
pp_timeout_set
(
ppi
,
PP_TO_L1E
_RX_SYNC
,
l1e_get_rx_tmo_ms
(
basic
));
}
/* Check if state transition needed */
...
...
@@ -318,7 +318,7 @@ static int l1e_handle_state_link_alive(struct pp_instance *ppi, Boolean new_stat
}
/* Iterative treatment */
l1e_send_sync_msg
(
ppi
,
0
);
return
pp_next_delay_2
(
ppi
,
L1E_TIMEOUT_TX_SYNC
,
L1E_TIMEOUT
_RX_SYNC
);
/* Return the shorter timeout */
return
pp_next_delay_2
(
ppi
,
PP_TO_L1E_TX_SYNC
,
PP_TO_L1E
_RX_SYNC
);
/* Return the shorter timeout */
}
/* CONFIG_MATCH state */
...
...
@@ -361,7 +361,7 @@ static int l1e_handle_state_config_match(struct pp_instance *ppi, Boolean new_st
}
/* Iterative treatment */
l1e_send_sync_msg
(
ppi
,
0
);
return
pp_next_delay_2
(
ppi
,
L1E_TIMEOUT_TX_SYNC
,
L1E_TIMEOUT
_RX_SYNC
);
/* Return the shorter timeout */
return
pp_next_delay_2
(
ppi
,
PP_TO_L1E_TX_SYNC
,
PP_TO_L1E
_RX_SYNC
);
/* Return the shorter timeout */
}
/* UP state */
...
...
@@ -402,5 +402,5 @@ static int l1e_handle_state_up(struct pp_instance *ppi, Boolean new_state){
pdstate_enable_extension
(
ppi
);
wrh_update_correction_values
(
ppi
);
l1e_send_sync_msg
(
ppi
,
0
);
return
pp_next_delay_2
(
ppi
,
L1E_TIMEOUT_TX_SYNC
,
L1E_TIMEOUT
_RX_SYNC
);
/* Return the shorter timeout */
return
pp_next_delay_2
(
ppi
,
PP_TO_L1E_TX_SYNC
,
PP_TO_L1E
_RX_SYNC
);
/* Return the shorter timeout */
}
proto-ext-whiterabbit/hooks.c
View file @
4e36fbda
...
...
@@ -9,8 +9,6 @@ typedef struct {
UInteger16
wrFlags
;
}
wr_announce_field_t
;
int
wrTmoIdx
=
0
;
/* TimeOut Index */
#if 0
// Useful function used for debugging
#include <stdio.h>
...
...
@@ -30,8 +28,7 @@ static int wr_init(struct pp_instance *ppi, void *buf, int len)
{
pp_diag
(
ppi
,
ext
,
2
,
"hook: %s
\n
"
,
__func__
);
if
(
wrTmoIdx
==
0
)
wrTmoIdx
=
pp_timeout_get_timer
(
ppi
,
"WR_EXT_0"
,
TO_RAND_NONE
,
TMO_CF_INSTANCE_DEPENDENT
);
pp_timeout_get_timer
(
ppi
,
PP_TO_WR_EXT_0
,
TO_RAND_NONE
);
wr_reset_process
(
ppi
,
WR_ROLE_NONE
);
ppi
->
pdstate
=
PP_PDSTATE_WAIT_MSG
;
...
...
proto-ext-whiterabbit/state-wr-calibrated.c
View file @
4e36fbda
...
...
@@ -22,7 +22,7 @@ int wr_calibrated(struct pp_instance *ppi, void *buf, int len, int new_state)
if
(
new_state
)
{
wrp
->
wrStateRetry
=
WR_STATE_RETRY
;
pp_timeout_set_rename
(
ppi
,
wrTmoIdx
,
WR_TMO_MS
*
(
WR_STATE_RETRY
+
1
),
WR_TMO_NAME
);
pp_timeout_set_rename
(
ppi
,
PP_TO_WR_EXT_0
,
WR_TMO_MS
*
(
WR_STATE_RETRY
+
1
)
);
sendmsg
=
1
;
}
else
{
...
...
@@ -48,7 +48,7 @@ int wr_calibrated(struct pp_instance *ppi, void *buf, int len, int new_state)
}
{
/* Check if tmo expired */
int
rms
=
pp_next_delay_1
(
ppi
,
wrTmoIdx
);
int
rms
=
pp_next_delay_1
(
ppi
,
PP_TO_WR_EXT_0
);
if
(
rms
<=
(
wrp
->
wrStateRetry
*
WR_TMO_MS
))
{
if
(
!
rms
)
{
pp_diag
(
ppi
,
time
,
1
,
"timeout expired: %s
\n
"
,
WR_TMO_NAME
);
...
...
@@ -65,5 +65,5 @@ int wr_calibrated(struct pp_instance *ppi, void *buf, int len, int new_state)
msg_issue_wrsig
(
ppi
,
CALIBRATED
);
}
return
pp_next_delay_1
(
ppi
,
wrTmoIdx
)
-
wrp
->
wrStateRetry
*
WR_TMO_MS
;
return
pp_next_delay_1
(
ppi
,
PP_TO_WR_EXT_0
)
-
wrp
->
wrStateRetry
*
WR_TMO_MS
;
}
proto-ext-whiterabbit/state-wr-locked.c
View file @
4e36fbda
...
...
@@ -23,7 +23,7 @@ int wr_locked(struct pp_instance *ppi, void *buf, int len, int new_state)
if
(
new_state
)
{
wrp
->
wrStateRetry
=
WR_STATE_RETRY
;
WRH_SRV
(
ppi
)
->
readyForSync
=
TRUE
;
/* We can start synchronization in the servo */
pp_timeout_set_rename
(
ppi
,
wrTmoIdx
,
WR_TMO_MS
*
(
WR_STATE_RETRY
+
1
),
WR_TMO_NAME
);
pp_timeout_set_rename
(
ppi
,
PP_TO_WR_EXT_0
,
WR_TMO_MS
*
(
WR_STATE_RETRY
+
1
)
);
sendmsg
=
1
;
}
else
{
if
(
ppi
->
received_ptp_header
.
messageType
==
PPM_SIGNALING
)
{
...
...
@@ -41,7 +41,7 @@ int wr_locked(struct pp_instance *ppi, void *buf, int len, int new_state)
}
{
/* Check remaining time */
int
rms
=
pp_next_delay_1
(
ppi
,
wrTmoIdx
);
int
rms
=
pp_next_delay_1
(
ppi
,
PP_TO_WR_EXT_0
);
if
(
rms
<=
(
wrp
->
wrStateRetry
*
WR_TMO_MS
))
{
if
(
!
rms
)
{
pp_diag
(
ppi
,
time
,
1
,
"timeout expired: %s
\n
"
,
WR_TMO_NAME
);
...
...
@@ -58,5 +58,5 @@ int wr_locked(struct pp_instance *ppi, void *buf, int len, int new_state)
msg_issue_wrsig
(
ppi
,
LOCKED
);
}
return
pp_next_delay_1
(
ppi
,
wrTmoIdx
)
-
wrp
->
wrStateRetry
*
WR_TMO_MS
;
return
pp_next_delay_1
(
ppi
,
PP_TO_WR_EXT_0
)
-
wrp
->
wrStateRetry
*
WR_TMO_MS
;
}
proto-ext-whiterabbit/state-wr-m-lock.c
View file @
4e36fbda
...
...
@@ -23,7 +23,7 @@ int wr_m_lock(struct pp_instance *ppi, void *buf, int len, int new_state)
if
(
new_state
)
{
wr_reset_process
(
ppi
,
WR_MASTER
);
wrp
->
wrStateRetry
=
WR_STATE_RETRY
;
pp_timeout_set_rename
(
ppi
,
wrTmoIdx
,
WR_TMO_MS
*
(
WR_STATE_RETRY
+
1
),
WR_TMO_NAME
);
pp_timeout_set_rename
(
ppi
,
PP_TO_WR_EXT_0
,
WR_TMO_MS
*
(
WR_STATE_RETRY
+
1
)
);
sendmsg
=
1
;
}
else
{
if
(
ppi
->
received_ptp_header
.
messageType
==
PPM_SIGNALING
)
{
...
...
@@ -41,7 +41,7 @@ int wr_m_lock(struct pp_instance *ppi, void *buf, int len, int new_state)
}
{
/* Check remaining time */
int
rms
=
pp_next_delay_1
(
ppi
,
wrTmoIdx
);
int
rms
=
pp_next_delay_1
(
ppi
,
PP_TO_WR_EXT_0
);
if
(
rms
<=
(
wrp
->
wrStateRetry
*
WR_TMO_MS
))
{
if
(
!
rms
)
{
pp_diag
(
ppi
,
time
,
1
,
"timeout expired: %s
\n
"
,
WR_TMO_NAME
);
...
...
@@ -58,5 +58,5 @@ int wr_m_lock(struct pp_instance *ppi, void *buf, int len, int new_state)
msg_issue_wrsig
(
ppi
,
LOCK
);
}
return
pp_next_delay_1
(
ppi
,
wrTmoIdx
)
-
wrp
->
wrStateRetry
*
WR_TMO_MS
;
return
pp_next_delay_1
(
ppi
,
PP_TO_WR_EXT_0
)
-
wrp
->
wrStateRetry
*
WR_TMO_MS
;
}
proto-ext-whiterabbit/state-wr-present.c
View file @
4e36fbda
...
...
@@ -25,7 +25,7 @@ int wr_present(struct pp_instance *ppi, void *buf, int len, int new_state)
if
(
new_state
)
{
wr_servo_init
(
ppi
);
wrp
->
wrStateRetry
=
WR_STATE_RETRY
;
pp_timeout_set_rename
(
ppi
,
wrTmoIdx
,
WR_TMO_MS
*
(
WR_STATE_RETRY
+
1
),
WR_TMO_NAME
);
pp_timeout_set_rename
(
ppi
,
PP_TO_WR_EXT_0
,
WR_TMO_MS
*
(
WR_STATE_RETRY
+
1
)
);
sendmsg
=
1
;
}
else
{
if
(
ppi
->
received_ptp_header
.
messageType
==
PPM_SIGNALING
)
{
...
...
@@ -43,7 +43,7 @@ int wr_present(struct pp_instance *ppi, void *buf, int len, int new_state)
}
{
/* Check remaining time */
int
rms
=
pp_next_delay_1
(
ppi
,
wrTmoIdx
);
int
rms
=
pp_next_delay_1
(
ppi
,
PP_TO_WR_EXT_0
);
if
(
rms
<=
(
wrp
->
wrStateRetry
*
WR_TMO_MS
))
{
if
(
!
rms
)
{
pp_diag
(
ppi
,
time
,
1
,
"timeout expired: %s
\n
"
,
WR_TMO_NAME
);
...
...
@@ -61,5 +61,5 @@ int wr_present(struct pp_instance *ppi, void *buf, int len, int new_state)
}
return
pp_next_delay_1
(
ppi
,
wrTmoIdx
)
-
wrp
->
wrStateRetry
*
WR_TMO_MS
;
return
pp_next_delay_1
(
ppi
,
PP_TO_WR_EXT_0
)
-
wrp
->
wrStateRetry
*
WR_TMO_MS
;
}
proto-ext-whiterabbit/state-wr-resp-calib-req.c
View file @
4e36fbda
...
...
@@ -17,7 +17,7 @@ int wr_resp_calib_req(struct pp_instance *ppi, void *buf, int len, int new_state
if
(
new_state
)
{
wrp
->
wrStateRetry
=
WR_STATE_RETRY
;
pp_timeout_set_rename
(
ppi
,
wrTmoIdx
,
WR_TMO_MS
*
(
WR_STATE_RETRY
+
1
),
WR_TMO_NAME
);
pp_timeout_set_rename
(
ppi
,
PP_TO_WR_EXT_0
,
WR_TMO_MS
*
(
WR_STATE_RETRY
+
1
)
);
}
/* Check whether a message is received, otherwise it may downgrade a link to ptp for wrs v5.0.x */
...
...
@@ -43,7 +43,7 @@ int wr_resp_calib_req(struct pp_instance *ppi, void *buf, int len, int new_state
}
{
/* Check remaining time */
int
rms
=
pp_next_delay_1
(
ppi
,
wrTmoIdx
);
int
rms
=
pp_next_delay_1
(
ppi
,
PP_TO_WR_EXT_0
);
if
(
rms
<=
(
wrp
->
wrStateRetry
*
WR_TMO_MS
))
{
if
(
!
rms
)
{
pp_diag
(
ppi
,
time
,
1
,
"timeout expired: %s
\n
"
,
WR_TMO_NAME
);
...
...
@@ -54,5 +54,5 @@ int wr_resp_calib_req(struct pp_instance *ppi, void *buf, int len, int new_state
}
}
return
pp_next_delay_1
(
ppi
,
wrTmoIdx
)
-
wrp
->
wrStateRetry
*
WR_TMO_MS
;
return
pp_next_delay_1
(
ppi
,
PP_TO_WR_EXT_0
)
-
wrp
->
wrStateRetry
*
WR_TMO_MS
;
}
proto-ext-whiterabbit/state-wr-s-lock.c
View file @
4e36fbda
...
...
@@ -18,7 +18,7 @@ int wr_s_lock(struct pp_instance *ppi, void *buf, int len, int new_state)
if
(
new_state
)
{
wrp
->
wrStateRetry
=
WR_STATE_RETRY
;
pp_timeout_set_rename
(
ppi
,
wrTmoIdx
,
WR_TMO_MS
*
(
WR_STATE_RETRY
+
1
),
WR_TMO_NAME
);
pp_timeout_set_rename
(
ppi
,
PP_TO_WR_EXT_0
,
WR_TMO_MS
*
(
WR_STATE_RETRY
+
1
)
);
enable
=
1
;
}
else
{
...
...
@@ -29,7 +29,7 @@ int wr_s_lock(struct pp_instance *ppi, void *buf, int len, int new_state)
}
{
/* Check remaining time */
int
rms
=
pp_next_delay_1
(
ppi
,
wrTmoIdx
);
int
rms
=
pp_next_delay_1
(
ppi
,
PP_TO_WR_EXT_0
);
if
(
rms
<=
(
wrp
->
wrStateRetry
*
WR_TMO_MS
))
{
WRH_OPER
()
->
locking_disable
(
ppi
);
if
(
rms
==
0
)
{
...
...
proto-ext-whiterabbit/wr-api.h
View file @
4e36fbda
...
...
@@ -137,7 +137,6 @@ static inline struct wr_servo_ext *WRE_SRV(struct pp_instance *ppi)
}
extern
const
struct
pp_ext_hooks
wr_ext_hooks
;
extern
int
wrTmoIdx
;
/* Servo routines */
static
inline
void
wr_servo_reset
(
struct
pp_instance
*
ppi
)
{
...
...
proto-standard/state-abscal.c
View file @
4e36fbda
...
...
@@ -22,8 +22,6 @@ static int next_pps_ms(struct pp_instance *ppi, struct pp_time *t)
* This is using a software loop during the last 10ms in order to get
* right after the pps event
*/
#define WR_TMO_NAME "PP_ABSCAL"
int
pp_abscal
(
struct
pp_instance
*
ppi
,
void
*
buf
,
int
plen
)
{
struct
pp_time
t
;
...
...
@@ -31,7 +29,7 @@ int pp_abscal(struct pp_instance *ppi, void *buf, int plen)
if
(
ppi
->
is_new_state
)
{
/* add 1s to be enough in the future, the first time */
pp_timeout_set_rename
(
ppi
,
PP_TO_SYNC_SEND
,
990
+
next_pps_ms
(
ppi
,
&
t
)
,
WR_TMO_NAME
);
pp_timeout_set_rename
(
ppi
,
PP_TO_SYNC_SEND
,
990
+
next_pps_ms
(
ppi
,
&
t
));
ppi
->
bmca_execute
=
0
;
/* print header for the serial port stream of stamps */
pp_printf
(
"### t4.phase is already corrected for bitslide
\n
"
);
...
...
time-wrs/wrs-time.c
View file @
4e36fbda
...
...
@@ -195,13 +195,14 @@ int wrs_get_timing_mode_state(struct pp_globals *ppg, wrh_timing_mode_pll_state_
if
(
timing_mode
==
WRH_TM_GRAND_MASTER
){
if
(
tmoIndex
==
0
)
{
/* First time. Timer must be initialized */
if
(
(
tmoIndex
=
pp_gtimeout_get_timer
(
ppg
,
"GM_REFRESH"
,
TO_RAND_NONE
,
0
))
>
0
)
pp_gtimeout_set
(
ppg
,
tmoIndex
,
TIMEOUT_REFRESH_GRAND_MASTER_MS
);
pp_gtimeout_get_timer
(
ppg
,
PP_TO_WRS_GM_REFRESH
,
TO_RAND_NONE
);
pp_gtimeout_set
(
ppg
,
PP_TO_WRS_GM_REFRESH
,
TIMEOUT_REFRESH_GRAND_MASTER_MS
);
tmoIndex
=
1
;
}
if
(
tmoIndex
>
0
)
{
if
(
pp_gtimeout
(
ppg
,
tmoIndex
)
)
{
if
(
pp_gtimeout
(
ppg
,
PP_TO_WRS_GM_REFRESH
)
)
{
wrs_set_timing_mode
(
ppg
,
WRH_TM_GRAND_MASTER
);
pp_gtimeout_reset
(
ppg
,
tmoIndex
);
pp_gtimeout_reset
(
ppg
,
PP_TO_WRS_GM_REFRESH
);
pp_diag
(
NULL
,
time
,
3
,
"Refresh (hw) timing mode GM
\n
"
);
}
}
...
...
@@ -212,7 +213,6 @@ int wrs_get_timing_mode_state(struct pp_globals *ppg, wrh_timing_mode_pll_state_
/* Free the timer: Next unlock state, we will wait then 60s again
* before to set again the Timing mode.
*/
pp_gtimeout_free_timer
(
ppg
,
tmoIndex
);
tmoIndex
=
0
;
}
}
...
...
timeout.c
View file @
4e36fbda
...
...
@@ -18,7 +18,7 @@ typedef struct {
}
timeOutConfig_t
;
static
timeOutConfig_t
timeOutConfigs
[
PP_TO_COUNT
]
=
{
static
const
timeOutConfig_t
timeOutConfigs
[
PP_TO_COUNT
]
=
{
{
.
name
=
"REQUEST"
,
.
ctrlFlag
=
TMO_CF_INSTANCE_DEPENDENT
|
TMO_CF_ALLOW_COMMON_SET
,
...
...
@@ -54,6 +54,28 @@ static timeOutConfig_t timeOutConfigs[PP_TO_COUNT]= {
.
name
=
"GM_BY_BMCA"
,
.
ctrlFlag
=
0
,
},
{
.
name
=
"L1E_TX_SYNC"
,
.
ctrlFlag
=
TMO_CF_INSTANCE_DEPENDENT
},
{
.
name
=
"L1E_RX_SYNC"
,
.
ctrlFlag
=
TMO_CF_INSTANCE_DEPENDENT
},
{
.
name
=
"WR_EXT"
,
.
ctrlFlag
=
TMO_CF_INSTANCE_DEPENDENT
},
#if CONFIG_ARCH_IS_WRS == 1
{
.
name
=
"SEND_PORT_INDEX"
,
.
ctrlFlag
=
0
,
},
{
.
name
=
"GM_REFRESH"
,
.
ctrlFlag
=
0
,
},
#endif
};
static
inline
timeOutInstCnt_t
*
__pp_get_counter
(
struct
pp_instance
*
ppi
,
int
index
)
{
...
...
@@ -72,28 +94,13 @@ void pp_timeout_disable_all(struct pp_instance *ppi) {
}
/* Return counter index or -1 if not available */
int
pp_timeout_get_timer
(
struct
pp_instance
*
ppi
,
char
*
name
,
to_rand_t
rand
,
int
ctl_flags
)
{
int
i
;
int
pp_timeout_get_timer
(
struct
pp_instance
*
ppi
,
int
index
,
to_rand_t
rand
)
{
timeOutInstCnt_t
*
tmoCnt
;
timeOutConfig_t
*
cfg
=&
timeOutConfigs
[
0
];
for
(
i
=
0
;
i
<
PP_TO_COUNT
;
i
++
)
{
if
(
!
cfg
->
name
)
{
cfg
->
name
=
name
;
cfg
->
ctrlFlag
=
ctl_flags
;
tmoCnt
=
__pp_get_counter
(
ppi
,
i
);
tmoCnt
->
which_rand
=
rand
;
ppi
->
tmo_cfg
[
i
].
initValueMs
=
TIMEOUT_DISABLE_VALUE
;
return
i
;
}
cfg
++
;
}
pp_diag
(
ppi
,
time
,
1
,
"No free timer for %s
\n
"
,
name
);
return
-
1
;
}
void
pp_timeout_free_timer
(
struct
pp_instance
*
ppi
,
int
index
){
if
(
index
>=
PP_TO_PREDEF_COUNTERS
)
timeOutConfigs
[
index
].
name
=
NULL
;
tmoCnt
=
__pp_get_counter
(
ppi
,
index
);
tmoCnt
->
which_rand
=
rand
;
ppi
->
tmo_cfg
[
index
].
initValueMs
=
TIMEOUT_DISABLE_VALUE
;
return
index
;
}
int
pp_timeout_log_to_ms
(
Integer8
logValue
)
{
...
...
@@ -160,18 +167,16 @@ int pp_timeout_get(struct pp_instance *ppi, int index) {
return
tmoCnt
->
initValueMs
;
}
static
inline
void
__pp_timeout_set
(
struct
pp_instance
*
ppi
,
int
index
,
int
millisec
)
{
static
inline
void
__pp_timeout_set
(
struct
pp_instance
*
ppi
,
int
index
,
int
millisec
)
{
timeOutInstCnt_t
*
tmoCnt
=
__pp_get_counter
(
ppi
,
index
);
tmoCnt
->
tmo
=
TOPS
(
ppi
)
->
calc_timeout
(
ppi
,
millisec
);
}
void
pp_timeout_set_rename
(
struct
pp_instance
*
ppi
,
int
index
,
int
millisec
,
char
*
name
)
void
pp_timeout_set_rename
(
struct
pp_instance
*
ppi
,
int
index
,
int
millisec
)
{
timeOutInstCnt_t
*
tmoCnt
=
__pp_get_counter
(
ppi
,
index
);
if
(
name
!=
NULL
)
timeOutConfigs
[
index
].
name
=
name
;
tmoCnt
->
initValueMs
=
millisec
;
__pp_timeout_set
(
ppi
,
index
,
millisec
);
pp_diag
(
ppi
,
time
,
3
,
"timeout overwr.: %s - %i / %lu
\n
"
,
...
...
@@ -241,7 +246,7 @@ void pp_timeout_setall(struct pp_instance *ppi)
{
int
i
;
for
(
i
=
0
;
i
<
PP_TO_COUNT
;
i
++
)
{
if
(
timeOutConfigs
[
i
].
ctrlFlag
&
TMO_CF_ALLOW_COMMON_SET
)
if
(
timeOutConfigs
[
i
].
ctrlFlag
&
TMO_CF_ALLOW_COMMON_SET
)
pp_timeout_reset
(
ppi
,
i
);
}
/* but announce_send must be send soon */
...
...
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