• Jon Paul Maloy's avatar
    tipc: improve link FSM implementation · 6ab30f9c
    Jon Paul Maloy authored
    The link FSM implementation is currently unnecessarily complex.
    It sometimes checks for conditional state outside the FSM data
    before deciding next state, and often performs actions directly
    inside the FSM logics.
    
    In this commit, we create a second, simpler FSM implementation,
    that as far as possible acts only on states and events that it is
    strictly defined for, and postpone any actions until it is finished
    with its decisions. It also returns an event flag field and an a
    buffer queue which may potentially contain a protocol message to
    be sent by the caller.
    
    Unfortunately, we cannot yet make the FSM "clean", in the sense
    that its decisions are only based on FSM state and event, and that
    state changes happen only here. That will have to wait until the
    activate/reset logics has been cleaned up in a future commit.
    
    We also rename the link states as follows:
    
    WORKING_WORKING -> TIPC_LINK_WORKING
    WORKING_UNKNOWN -> TIPC_LINK_PROBING
    RESET_UNKNOWN   -> TIPC_LINK_RESETTING
    RESET_RESET     -> TIPC_LINK_ESTABLISHING
    
    The existing FSM function, link_state_event(), is still needed for
    a while, so we redesign it to make use of the new function.
    Reviewed-by: default avatarYing Xue <ying.xue@windriver.com>
    Signed-off-by: default avatarJon Maloy <jon.maloy@ericsson.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    6ab30f9c
link.c 60.9 KB