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