ctcm_fsms.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. /*
  2. * drivers/s390/net/ctcm_fsms.h
  3. *
  4. * Copyright IBM Corp. 2001, 2007
  5. * Authors: Fritz Elfert (felfert@millenux.com)
  6. * Peter Tiedemann (ptiedem@de.ibm.com)
  7. * MPC additions :
  8. * Belinda Thompson (belindat@us.ibm.com)
  9. * Andy Richter (richtera@us.ibm.com)
  10. */
  11. #ifndef _CTCM_FSMS_H_
  12. #define _CTCM_FSMS_H_
  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>
  22. #include <linux/signal.h>
  23. #include <linux/string.h>
  24. #include <linux/ip.h>
  25. #include <linux/if_arp.h>
  26. #include <linux/tcp.h>
  27. #include <linux/skbuff.h>
  28. #include <linux/ctype.h>
  29. #include <net/dst.h>
  30. #include <linux/io.h>
  31. #include <asm/ccwdev.h>
  32. #include <asm/ccwgroup.h>
  33. #include <linux/uaccess.h>
  34. #include <asm/idals.h>
  35. #include "fsm.h"
  36. #include "ctcm_main.h"
  37. /*
  38. * Definitions for the channel statemachine(s) for ctc and ctcmpc
  39. *
  40. * To allow better kerntyping, prefix-less definitions for channel states
  41. * and channel events have been replaced :
  42. * ch_event... -> ctc_ch_event...
  43. * CH_EVENT... -> CTC_EVENT...
  44. * ch_state... -> ctc_ch_state...
  45. * CH_STATE... -> CTC_STATE...
  46. */
  47. /*
  48. * Events of the channel statemachine(s) for ctc and ctcmpc
  49. */
  50. enum ctc_ch_events {
  51. /*
  52. * Events, representing return code of
  53. * I/O operations (ccw_device_start, ccw_device_halt et al.)
  54. */
  55. CTC_EVENT_IO_SUCCESS,
  56. CTC_EVENT_IO_EBUSY,
  57. CTC_EVENT_IO_ENODEV,
  58. CTC_EVENT_IO_UNKNOWN,
  59. CTC_EVENT_ATTNBUSY,
  60. CTC_EVENT_ATTN,
  61. CTC_EVENT_BUSY,
  62. /*
  63. * Events, representing unit-check
  64. */
  65. CTC_EVENT_UC_RCRESET,
  66. CTC_EVENT_UC_RSRESET,
  67. CTC_EVENT_UC_TXTIMEOUT,
  68. CTC_EVENT_UC_TXPARITY,
  69. CTC_EVENT_UC_HWFAIL,
  70. CTC_EVENT_UC_RXPARITY,
  71. CTC_EVENT_UC_ZERO,
  72. CTC_EVENT_UC_UNKNOWN,
  73. /*
  74. * Events, representing subchannel-check
  75. */
  76. CTC_EVENT_SC_UNKNOWN,
  77. /*
  78. * Events, representing machine checks
  79. */
  80. CTC_EVENT_MC_FAIL,
  81. CTC_EVENT_MC_GOOD,
  82. /*
  83. * Event, representing normal IRQ
  84. */
  85. CTC_EVENT_IRQ,
  86. CTC_EVENT_FINSTAT,
  87. /*
  88. * Event, representing timer expiry.
  89. */
  90. CTC_EVENT_TIMER,
  91. /*
  92. * Events, representing commands from upper levels.
  93. */
  94. CTC_EVENT_START,
  95. CTC_EVENT_STOP,
  96. CTC_NR_EVENTS,
  97. /*
  98. * additional MPC events
  99. */
  100. CTC_EVENT_SEND_XID = CTC_NR_EVENTS,
  101. CTC_EVENT_RSWEEP_TIMER,
  102. /*
  103. * MUST be always the last element!!
  104. */
  105. CTC_MPC_NR_EVENTS,
  106. };
  107. /*
  108. * States of the channel statemachine(s) for ctc and ctcmpc.
  109. */
  110. enum ctc_ch_states {
  111. /*
  112. * Channel not assigned to any device,
  113. * initial state, direction invalid
  114. */
  115. CTC_STATE_IDLE,
  116. /*
  117. * Channel assigned but not operating
  118. */
  119. CTC_STATE_STOPPED,
  120. CTC_STATE_STARTWAIT,
  121. CTC_STATE_STARTRETRY,
  122. CTC_STATE_SETUPWAIT,
  123. CTC_STATE_RXINIT,
  124. CTC_STATE_TXINIT,
  125. CTC_STATE_RX,
  126. CTC_STATE_TX,
  127. CTC_STATE_RXIDLE,
  128. CTC_STATE_TXIDLE,
  129. CTC_STATE_RXERR,
  130. CTC_STATE_TXERR,
  131. CTC_STATE_TERM,
  132. CTC_STATE_DTERM,
  133. CTC_STATE_NOTOP,
  134. CTC_NR_STATES, /* MUST be the last element of non-expanded states */
  135. /*
  136. * additional MPC states
  137. */
  138. CH_XID0_PENDING = CTC_NR_STATES,
  139. CH_XID0_INPROGRESS,
  140. CH_XID7_PENDING,
  141. CH_XID7_PENDING1,
  142. CH_XID7_PENDING2,
  143. CH_XID7_PENDING3,
  144. CH_XID7_PENDING4,
  145. CTC_MPC_NR_STATES, /* MUST be the last element of expanded mpc states */
  146. };
  147. extern const char *ctc_ch_event_names[];
  148. extern const char *ctc_ch_state_names[];
  149. void ctcm_ccw_check_rc(struct channel *ch, int rc, char *msg);
  150. void ctcm_purge_skb_queue(struct sk_buff_head *q);
  151. void fsm_action_nop(fsm_instance *fi, int event, void *arg);
  152. /*
  153. * ----- non-static actions for ctcm channel statemachine -----
  154. *
  155. */
  156. void ctcm_chx_txidle(fsm_instance *fi, int event, void *arg);
  157. /*
  158. * ----- FSM (state/event/action) of the ctcm channel statemachine -----
  159. */
  160. extern const fsm_node ch_fsm[];
  161. extern int ch_fsm_len;
  162. /*
  163. * ----- non-static actions for ctcmpc channel statemachine ----
  164. *
  165. */
  166. /* shared :
  167. void ctcm_chx_txidle(fsm_instance * fi, int event, void *arg);
  168. */
  169. void ctcmpc_chx_rxidle(fsm_instance *fi, int event, void *arg);
  170. /*
  171. * ----- FSM (state/event/action) of the ctcmpc channel statemachine -----
  172. */
  173. extern const fsm_node ctcmpc_ch_fsm[];
  174. extern int mpc_ch_fsm_len;
  175. /*
  176. * Definitions for the device interface statemachine for ctc and mpc
  177. */
  178. /*
  179. * States of the device interface statemachine.
  180. */
  181. enum dev_states {
  182. DEV_STATE_STOPPED,
  183. DEV_STATE_STARTWAIT_RXTX,
  184. DEV_STATE_STARTWAIT_RX,
  185. DEV_STATE_STARTWAIT_TX,
  186. DEV_STATE_STOPWAIT_RXTX,
  187. DEV_STATE_STOPWAIT_RX,
  188. DEV_STATE_STOPWAIT_TX,
  189. DEV_STATE_RUNNING,
  190. /*
  191. * MUST be always the last element!!
  192. */
  193. CTCM_NR_DEV_STATES
  194. };
  195. extern const char *dev_state_names[];
  196. /*
  197. * Events of the device interface statemachine.
  198. * ctcm and ctcmpc
  199. */
  200. enum dev_events {
  201. DEV_EVENT_START,
  202. DEV_EVENT_STOP,
  203. DEV_EVENT_RXUP,
  204. DEV_EVENT_TXUP,
  205. DEV_EVENT_RXDOWN,
  206. DEV_EVENT_TXDOWN,
  207. DEV_EVENT_RESTART,
  208. /*
  209. * MUST be always the last element!!
  210. */
  211. CTCM_NR_DEV_EVENTS
  212. };
  213. extern const char *dev_event_names[];
  214. /*
  215. * Actions for the device interface statemachine.
  216. * ctc and ctcmpc
  217. */
  218. /*
  219. static void dev_action_start(fsm_instance * fi, int event, void *arg);
  220. static void dev_action_stop(fsm_instance * fi, int event, void *arg);
  221. static void dev_action_restart(fsm_instance *fi, int event, void *arg);
  222. static void dev_action_chup(fsm_instance * fi, int event, void *arg);
  223. static void dev_action_chdown(fsm_instance * fi, int event, void *arg);
  224. */
  225. /*
  226. * The (state/event/action) fsm table of the device interface statemachine.
  227. * ctcm and ctcmpc
  228. */
  229. extern const fsm_node dev_fsm[];
  230. extern int dev_fsm_len;
  231. /*
  232. * Definitions for the MPC Group statemachine
  233. */
  234. /*
  235. * MPC Group Station FSM States
  236. State Name When In This State
  237. ====================== =======================================
  238. MPCG_STATE_RESET Initial State When Driver Loaded
  239. We receive and send NOTHING
  240. MPCG_STATE_INOP INOP Received.
  241. Group level non-recoverable error
  242. MPCG_STATE_READY XID exchanges for at least 1 write and
  243. 1 read channel have completed.
  244. Group is ready for data transfer.
  245. States from ctc_mpc_alloc_channel
  246. ==============================================================
  247. MPCG_STATE_XID2INITW Awaiting XID2(0) Initiation
  248. ATTN from other side will start
  249. XID negotiations.
  250. Y-side protocol only.
  251. MPCG_STATE_XID2INITX XID2(0) negotiations are in progress.
  252. At least 1, but not all, XID2(0)'s
  253. have been received from partner.
  254. MPCG_STATE_XID7INITW XID2(0) complete
  255. No XID2(7)'s have yet been received.
  256. XID2(7) negotiations pending.
  257. MPCG_STATE_XID7INITX XID2(7) negotiations in progress.
  258. At least 1, but not all, XID2(7)'s
  259. have been received from partner.
  260. MPCG_STATE_XID7INITF XID2(7) negotiations complete.
  261. Transitioning to READY.
  262. MPCG_STATE_READY Ready for Data Transfer.
  263. States from ctc_mpc_establish_connectivity call
  264. ==============================================================
  265. MPCG_STATE_XID0IOWAIT Initiating XID2(0) negotiations.
  266. X-side protocol only.
  267. ATTN-BUSY from other side will convert
  268. this to Y-side protocol and the
  269. ctc_mpc_alloc_channel flow will begin.
  270. MPCG_STATE_XID0IOWAIX XID2(0) negotiations are in progress.
  271. At least 1, but not all, XID2(0)'s
  272. have been received from partner.
  273. MPCG_STATE_XID7INITI XID2(0) complete
  274. No XID2(7)'s have yet been received.
  275. XID2(7) negotiations pending.
  276. MPCG_STATE_XID7INITZ XID2(7) negotiations in progress.
  277. At least 1, but not all, XID2(7)'s
  278. have been received from partner.
  279. MPCG_STATE_XID7INITF XID2(7) negotiations complete.
  280. Transitioning to READY.
  281. MPCG_STATE_READY Ready for Data Transfer.
  282. */
  283. enum mpcg_events {
  284. MPCG_EVENT_INOP,
  285. MPCG_EVENT_DISCONC,
  286. MPCG_EVENT_XID0DO,
  287. MPCG_EVENT_XID2,
  288. MPCG_EVENT_XID2DONE,
  289. MPCG_EVENT_XID7DONE,
  290. MPCG_EVENT_TIMER,
  291. MPCG_EVENT_DOIO,
  292. MPCG_NR_EVENTS,
  293. };
  294. enum mpcg_states {
  295. MPCG_STATE_RESET,
  296. MPCG_STATE_INOP,
  297. MPCG_STATE_XID2INITW,
  298. MPCG_STATE_XID2INITX,
  299. MPCG_STATE_XID7INITW,
  300. MPCG_STATE_XID7INITX,
  301. MPCG_STATE_XID0IOWAIT,
  302. MPCG_STATE_XID0IOWAIX,
  303. MPCG_STATE_XID7INITI,
  304. MPCG_STATE_XID7INITZ,
  305. MPCG_STATE_XID7INITF,
  306. MPCG_STATE_FLOWC,
  307. MPCG_STATE_READY,
  308. MPCG_NR_STATES,
  309. };
  310. #endif
  311. /* --- This is the END my friend --- */