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