^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * llc_s_st.c - Defines SAP component state machine transitions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * The followed transitions are SAP component state machine transitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * which are described in 802.2 LLC protocol standard document.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright (c) 1997 by Procom Technology, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * This program can be redistributed or modified under the terms of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * GNU General Public License as published by the Free Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * This program is distributed without any warranty or implied warranty
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * of merchantability or fitness for a particular purpose.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * See the GNU General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <net/llc_if.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <net/llc_s_ev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <net/llc_s_ac.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <net/llc_s_st.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) /* dummy last-transition indicator; common to all state transition groups
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * last entry for this state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * all members are zeros, .bss zeroes it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) static struct llc_sap_state_trans llc_sap_state_trans_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) /* state LLC_SAP_STATE_INACTIVE transition for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * LLC_SAP_EV_ACTIVATION_REQ event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) static const llc_sap_action_t llc_sap_inactive_state_actions_1[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) [0] = llc_sap_action_report_status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) [1] = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static struct llc_sap_state_trans llc_sap_inactive_state_trans_1 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) .ev = llc_sap_ev_activation_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) .next_state = LLC_SAP_STATE_ACTIVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) .ev_actions = llc_sap_inactive_state_actions_1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /* array of pointers; one to each transition */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) static struct llc_sap_state_trans *llc_sap_inactive_state_transitions[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) [0] = &llc_sap_inactive_state_trans_1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) [1] = &llc_sap_state_trans_end,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) /* state LLC_SAP_STATE_ACTIVE transition for LLC_SAP_EV_RX_UI event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) static const llc_sap_action_t llc_sap_active_state_actions_1[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) [0] = llc_sap_action_unitdata_ind,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) [1] = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) static struct llc_sap_state_trans llc_sap_active_state_trans_1 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) .ev = llc_sap_ev_rx_ui,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) .next_state = LLC_SAP_STATE_ACTIVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) .ev_actions = llc_sap_active_state_actions_1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) /* state LLC_SAP_STATE_ACTIVE transition for LLC_SAP_EV_UNITDATA_REQ event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) static const llc_sap_action_t llc_sap_active_state_actions_2[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) [0] = llc_sap_action_send_ui,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) [1] = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) static struct llc_sap_state_trans llc_sap_active_state_trans_2 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) .ev = llc_sap_ev_unitdata_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) .next_state = LLC_SAP_STATE_ACTIVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) .ev_actions = llc_sap_active_state_actions_2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /* state LLC_SAP_STATE_ACTIVE transition for LLC_SAP_EV_XID_REQ event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) static const llc_sap_action_t llc_sap_active_state_actions_3[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) [0] = llc_sap_action_send_xid_c,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) [1] = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) static struct llc_sap_state_trans llc_sap_active_state_trans_3 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) .ev = llc_sap_ev_xid_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) .next_state = LLC_SAP_STATE_ACTIVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) .ev_actions = llc_sap_active_state_actions_3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) /* state LLC_SAP_STATE_ACTIVE transition for LLC_SAP_EV_RX_XID_C event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) static const llc_sap_action_t llc_sap_active_state_actions_4[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) [0] = llc_sap_action_send_xid_r,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) [1] = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) static struct llc_sap_state_trans llc_sap_active_state_trans_4 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) .ev = llc_sap_ev_rx_xid_c,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) .next_state = LLC_SAP_STATE_ACTIVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) .ev_actions = llc_sap_active_state_actions_4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) /* state LLC_SAP_STATE_ACTIVE transition for LLC_SAP_EV_RX_XID_R event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) static const llc_sap_action_t llc_sap_active_state_actions_5[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) [0] = llc_sap_action_xid_ind,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) [1] = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) static struct llc_sap_state_trans llc_sap_active_state_trans_5 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) .ev = llc_sap_ev_rx_xid_r,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) .next_state = LLC_SAP_STATE_ACTIVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) .ev_actions = llc_sap_active_state_actions_5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) /* state LLC_SAP_STATE_ACTIVE transition for LLC_SAP_EV_TEST_REQ event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) static const llc_sap_action_t llc_sap_active_state_actions_6[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) [0] = llc_sap_action_send_test_c,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) [1] = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static struct llc_sap_state_trans llc_sap_active_state_trans_6 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) .ev = llc_sap_ev_test_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) .next_state = LLC_SAP_STATE_ACTIVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) .ev_actions = llc_sap_active_state_actions_6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) /* state LLC_SAP_STATE_ACTIVE transition for LLC_SAP_EV_RX_TEST_C event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static const llc_sap_action_t llc_sap_active_state_actions_7[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) [0] = llc_sap_action_send_test_r,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) [1] = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static struct llc_sap_state_trans llc_sap_active_state_trans_7 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) .ev = llc_sap_ev_rx_test_c,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) .next_state = LLC_SAP_STATE_ACTIVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) .ev_actions = llc_sap_active_state_actions_7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) /* state LLC_SAP_STATE_ACTIVE transition for LLC_SAP_EV_RX_TEST_R event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) static const llc_sap_action_t llc_sap_active_state_actions_8[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) [0] = llc_sap_action_test_ind,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) [1] = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) static struct llc_sap_state_trans llc_sap_active_state_trans_8 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) .ev = llc_sap_ev_rx_test_r,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) .next_state = LLC_SAP_STATE_ACTIVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) .ev_actions = llc_sap_active_state_actions_8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) /* state LLC_SAP_STATE_ACTIVE transition for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) * LLC_SAP_EV_DEACTIVATION_REQ event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) static const llc_sap_action_t llc_sap_active_state_actions_9[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) [0] = llc_sap_action_report_status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) [1] = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) static struct llc_sap_state_trans llc_sap_active_state_trans_9 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) .ev = llc_sap_ev_deactivation_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) .next_state = LLC_SAP_STATE_INACTIVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) .ev_actions = llc_sap_active_state_actions_9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) /* array of pointers; one to each transition */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) static struct llc_sap_state_trans *llc_sap_active_state_transitions[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) [0] = &llc_sap_active_state_trans_2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) [1] = &llc_sap_active_state_trans_1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) [2] = &llc_sap_active_state_trans_3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) [3] = &llc_sap_active_state_trans_4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) [4] = &llc_sap_active_state_trans_5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) [5] = &llc_sap_active_state_trans_6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) [6] = &llc_sap_active_state_trans_7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) [7] = &llc_sap_active_state_trans_8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) [8] = &llc_sap_active_state_trans_9,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) [9] = &llc_sap_state_trans_end,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) /* SAP state transition table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) struct llc_sap_state llc_sap_state_table[LLC_NR_SAP_STATES] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) [LLC_SAP_STATE_INACTIVE - 1] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) .curr_state = LLC_SAP_STATE_INACTIVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) .transitions = llc_sap_inactive_state_transitions,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) [LLC_SAP_STATE_ACTIVE - 1] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) .curr_state = LLC_SAP_STATE_ACTIVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) .transitions = llc_sap_active_state_transitions,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) };