wrong impementation of shmemState in hal_shmem?
Probably shmemState
in hal_shmem
is set to HAL_SHMEM_STATE_INITITALIZED
too early. It is suspected that the intention was that HAL_SHMEM_STATE_INITITALIZED
is after the LPDC calibration takes place.
When checking whether all ports are initialized (function hal_port_all_ports_initialized
) the following if condition:
if ( ps->in_use && fsm_get_state( &ps->fsm ) ==HAL_PORT_STATE_INIT ) {
does not take into account that port's fsm (ps->fsm
) can be not initialized (fsm_get_state(&ps->fsm)
returns -1 value).
As a consequence, the function hal_port_all_ports_initialized
reports that all ports are initialized before they even enter init (HAL_PORT_STATE_INIT
) state.
The call of fsm_fire_state(&ps->fsm , HAL_PORT_STATE_INIT);
in the function hal_port_state_fsm_init_all
does not change the state of the port's fsm (ps->fsm
). The transition to a new state is done after the call of fsm_generic_run
.
The function fsm_fire_state
does not change the current state, it only changes the value of newState
:
/* schedules next state of the FSM to newState */
static inline void fsm_fire_state(fsm_t *fsm, int newState)
{
fsm->st.nextState=newState;
}
rtud at startup waits for the HAL_SHMEM_STATE_INITITALIZED
. In case HAL_SHMEM_STATE_INITITALIZED
is set after the LPDC is finished, it is too late. In rtud the number of retries to connect to hal's shmem exceeds HAL_SHMEM_RETRIES
. It causes the process to fail. Since rtud is not running wrs_vlans is not able to configure VLANs. Monit eventually restarts rtud process, but wrs_vlans is run only once by init.
Proposed solution:
Remove shmemState==HAL_SHMEM_STATE_INITITALIZED
(entire while loop) check from wrsw_rtud/rtu_drv.c
and add the condition || fsm_get_state(&ps->fsm) < 0
to the if statement in the function hal_port_all_ports_initialized
(file wrsw_hal/hal_ports.c
).