1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright IBM Corp. 2001, 2007
4 * Authors: Fritz Elfert (felfert@millenux.com)
5 * Peter Tiedemann (ptiedem@de.ibm.com)
7 * Belinda Thompson (belindat@us.ibm.com)
8 * Andy Richter (richtera@us.ibm.com)
13 #include <linux/module.h>
14 #include <linux/init.h>
15 #include <linux/kernel.h>
16 #include <linux/slab.h>
17 #include <linux/errno.h>
18 #include <linux/types.h>
19 #include <linux/interrupt.h>
20 #include <linux/timer.h>
21 #include <linux/bitops.h>
23 #include <linux/signal.h>
24 #include <linux/string.h>
27 #include <linux/if_arp.h>
28 #include <linux/tcp.h>
29 #include <linux/skbuff.h>
30 #include <linux/ctype.h>
34 #include <asm/ccwdev.h>
35 #include <asm/ccwgroup.h>
36 #include <linux/uaccess.h>
38 #include <asm/idals.h>
41 #include "ctcm_main.h"
44 * Definitions for the channel statemachine(s) for ctc and ctcmpc
46 * To allow better kerntyping, prefix-less definitions for channel states
47 * and channel events have been replaced :
48 * ch_event... -> ctc_ch_event...
49 * CH_EVENT... -> CTC_EVENT...
50 * ch_state... -> ctc_ch_state...
51 * CH_STATE... -> CTC_STATE...
54 * Events of the channel statemachine(s) for ctc and ctcmpc
58 * Events, representing return code of
59 * I/O operations (ccw_device_start, ccw_device_halt et al.)
70 * Events, representing unit-check
74 CTC_EVENT_UC_TXTIMEOUT
,
75 CTC_EVENT_UC_TXPARITY
,
77 CTC_EVENT_UC_RXPARITY
,
81 * Events, representing subchannel-check
85 * Events, representing machine checks
90 * Event, representing normal IRQ
95 * Event, representing timer expiry.
99 * Events, representing commands from upper levels.
105 * additional MPC events
107 CTC_EVENT_SEND_XID
= CTC_NR_EVENTS
,
108 CTC_EVENT_RSWEEP_TIMER
,
110 * MUST be always the last element!!
116 * States of the channel statemachine(s) for ctc and ctcmpc.
120 * Channel not assigned to any device,
121 * initial state, direction invalid
125 * Channel assigned but not operating
129 CTC_STATE_STARTRETRY
,
142 CTC_NR_STATES
, /* MUST be the last element of non-expanded states */
144 * additional MPC states
146 CH_XID0_PENDING
= CTC_NR_STATES
,
153 CTC_MPC_NR_STATES
, /* MUST be the last element of expanded mpc states */
156 extern const char *ctc_ch_event_names
[];
158 extern const char *ctc_ch_state_names
[];
160 void ctcm_ccw_check_rc(struct channel
*ch
, int rc
, char *msg
);
161 void ctcm_purge_skb_queue(struct sk_buff_head
*q
);
162 void fsm_action_nop(fsm_instance
*fi
, int event
, void *arg
);
165 * ----- non-static actions for ctcm channel statemachine -----
168 void ctcm_chx_txidle(fsm_instance
*fi
, int event
, void *arg
);
171 * ----- FSM (state/event/action) of the ctcm channel statemachine -----
173 extern const fsm_node ch_fsm
[];
174 extern int ch_fsm_len
;
178 * ----- non-static actions for ctcmpc channel statemachine ----
182 void ctcm_chx_txidle(fsm_instance * fi, int event, void *arg);
184 void ctcmpc_chx_rxidle(fsm_instance
*fi
, int event
, void *arg
);
187 * ----- FSM (state/event/action) of the ctcmpc channel statemachine -----
189 extern const fsm_node ctcmpc_ch_fsm
[];
190 extern int mpc_ch_fsm_len
;
193 * Definitions for the device interface statemachine for ctc and mpc
197 * States of the device interface statemachine.
201 DEV_STATE_STARTWAIT_RXTX
,
202 DEV_STATE_STARTWAIT_RX
,
203 DEV_STATE_STARTWAIT_TX
,
204 DEV_STATE_STOPWAIT_RXTX
,
205 DEV_STATE_STOPWAIT_RX
,
206 DEV_STATE_STOPWAIT_TX
,
209 * MUST be always the last element!!
214 extern const char *dev_state_names
[];
217 * Events of the device interface statemachine.
229 * MUST be always the last element!!
234 extern const char *dev_event_names
[];
237 * Actions for the device interface statemachine.
241 static void dev_action_start(fsm_instance * fi, int event, void *arg);
242 static void dev_action_stop(fsm_instance * fi, int event, void *arg);
243 static void dev_action_restart(fsm_instance *fi, int event, void *arg);
244 static void dev_action_chup(fsm_instance * fi, int event, void *arg);
245 static void dev_action_chdown(fsm_instance * fi, int event, void *arg);
249 * The (state/event/action) fsm table of the device interface statemachine.
252 extern const fsm_node dev_fsm
[];
253 extern int dev_fsm_len
;
257 * Definitions for the MPC Group statemachine
261 * MPC Group Station FSM States
263 State Name When In This State
264 ====================== =======================================
265 MPCG_STATE_RESET Initial State When Driver Loaded
266 We receive and send NOTHING
268 MPCG_STATE_INOP INOP Received.
269 Group level non-recoverable error
271 MPCG_STATE_READY XID exchanges for at least 1 write and
272 1 read channel have completed.
273 Group is ready for data transfer.
275 States from ctc_mpc_alloc_channel
276 ==============================================================
277 MPCG_STATE_XID2INITW Awaiting XID2(0) Initiation
278 ATTN from other side will start
280 Y-side protocol only.
282 MPCG_STATE_XID2INITX XID2(0) negotiations are in progress.
283 At least 1, but not all, XID2(0)'s
284 have been received from partner.
286 MPCG_STATE_XID7INITW XID2(0) complete
287 No XID2(7)'s have yet been received.
288 XID2(7) negotiations pending.
290 MPCG_STATE_XID7INITX XID2(7) negotiations in progress.
291 At least 1, but not all, XID2(7)'s
292 have been received from partner.
294 MPCG_STATE_XID7INITF XID2(7) negotiations complete.
295 Transitioning to READY.
297 MPCG_STATE_READY Ready for Data Transfer.
300 States from ctc_mpc_establish_connectivity call
301 ==============================================================
302 MPCG_STATE_XID0IOWAIT Initiating XID2(0) negotiations.
303 X-side protocol only.
304 ATTN-BUSY from other side will convert
305 this to Y-side protocol and the
306 ctc_mpc_alloc_channel flow will begin.
308 MPCG_STATE_XID0IOWAIX XID2(0) negotiations are in progress.
309 At least 1, but not all, XID2(0)'s
310 have been received from partner.
312 MPCG_STATE_XID7INITI XID2(0) complete
313 No XID2(7)'s have yet been received.
314 XID2(7) negotiations pending.
316 MPCG_STATE_XID7INITZ XID2(7) negotiations in progress.
317 At least 1, but not all, XID2(7)'s
318 have been received from partner.
320 MPCG_STATE_XID7INITF XID2(7) negotiations complete.
321 Transitioning to READY.
323 MPCG_STATE_READY Ready for Data Transfer.
342 MPCG_STATE_XID2INITW
,
343 MPCG_STATE_XID2INITX
,
344 MPCG_STATE_XID7INITW
,
345 MPCG_STATE_XID7INITX
,
346 MPCG_STATE_XID0IOWAIT
,
347 MPCG_STATE_XID0IOWAIX
,
348 MPCG_STATE_XID7INITI
,
349 MPCG_STATE_XID7INITZ
,
350 MPCG_STATE_XID7INITF
,
357 /* --- This is the END my friend --- */