ctcm_mpc.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright IBM Corp. 2007
  4. * Authors: Peter Tiedemann ([email protected])
  5. *
  6. * MPC additions:
  7. * Belinda Thompson ([email protected])
  8. * Andy Richter ([email protected])
  9. */
  10. #ifndef _CTC_MPC_H_
  11. #define _CTC_MPC_H_
  12. #include <linux/interrupt.h>
  13. #include <linux/skbuff.h>
  14. #include "fsm.h"
  15. /*
  16. * MPC external interface
  17. * Note that ctc_mpc_xyz are called with a lock on ................
  18. */
  19. /* port_number is the mpc device 0, 1, 2 etc mpc2 is port_number 2 */
  20. /* passive open Just wait for XID2 exchange */
  21. extern int ctc_mpc_alloc_channel(int port,
  22. void (*callback)(int port_num, int max_write_size));
  23. /* active open Alloc then send XID2 */
  24. extern void ctc_mpc_establish_connectivity(int port,
  25. void (*callback)(int port_num, int rc, int max_write_size));
  26. extern void ctc_mpc_dealloc_ch(int port);
  27. extern void ctc_mpc_flow_control(int port, int flowc);
  28. /*
  29. * other MPC Group prototypes and structures
  30. */
  31. #define ETH_P_SNA_DIX 0x80D5
  32. /*
  33. * Declaration of an XID2
  34. *
  35. */
  36. #define ALLZEROS 0x0000000000000000
  37. #define XID_FM2 0x20
  38. #define XID2_0 0x00
  39. #define XID2_7 0x07
  40. #define XID2_WRITE_SIDE 0x04
  41. #define XID2_READ_SIDE 0x05
  42. struct xid2 {
  43. __u8 xid2_type_id;
  44. __u8 xid2_len;
  45. __u32 xid2_adj_id;
  46. __u8 xid2_rlen;
  47. __u8 xid2_resv1;
  48. __u8 xid2_flag1;
  49. __u8 xid2_fmtt;
  50. __u8 xid2_flag4;
  51. __u16 xid2_resv2;
  52. __u8 xid2_tgnum;
  53. __u32 xid2_sender_id;
  54. __u8 xid2_flag2;
  55. __u8 xid2_option;
  56. char xid2_resv3[8];
  57. __u16 xid2_resv4;
  58. __u8 xid2_dlc_type;
  59. __u16 xid2_resv5;
  60. __u8 xid2_mpc_flag;
  61. __u8 xid2_resv6;
  62. __u16 xid2_buf_len;
  63. char xid2_buffer[255 - (13 * sizeof(__u8) +
  64. 2 * sizeof(__u32) +
  65. 4 * sizeof(__u16) +
  66. 8 * sizeof(char))];
  67. } __attribute__ ((packed));
  68. #define XID2_LENGTH (sizeof(struct xid2))
  69. struct th_header {
  70. __u8 th_seg;
  71. __u8 th_ch_flag;
  72. #define TH_HAS_PDU 0xf0
  73. #define TH_IS_XID 0x01
  74. #define TH_SWEEP_REQ 0xfe
  75. #define TH_SWEEP_RESP 0xff
  76. __u8 th_blk_flag;
  77. #define TH_DATA_IS_XID 0x80
  78. #define TH_RETRY 0x40
  79. #define TH_DISCONTACT 0xc0
  80. #define TH_SEG_BLK 0x20
  81. #define TH_LAST_SEG 0x10
  82. #define TH_PDU_PART 0x08
  83. __u8 th_is_xid; /* is 0x01 if this is XID */
  84. __u32 th_seq_num;
  85. } __attribute__ ((packed));
  86. struct th_addon {
  87. __u32 th_last_seq;
  88. __u32 th_resvd;
  89. } __attribute__ ((packed));
  90. struct th_sweep {
  91. struct th_header th;
  92. struct th_addon sw;
  93. } __attribute__ ((packed));
  94. #define TH_HEADER_LENGTH (sizeof(struct th_header))
  95. #define TH_SWEEP_LENGTH (sizeof(struct th_sweep))
  96. #define PDU_LAST 0x80
  97. #define PDU_CNTL 0x40
  98. #define PDU_FIRST 0x20
  99. struct pdu {
  100. __u32 pdu_offset;
  101. __u8 pdu_flag;
  102. __u8 pdu_proto; /* 0x01 is APPN SNA */
  103. __u16 pdu_seq;
  104. } __attribute__ ((packed));
  105. #define PDU_HEADER_LENGTH (sizeof(struct pdu))
  106. struct qllc {
  107. __u8 qllc_address;
  108. #define QLLC_REQ 0xFF
  109. #define QLLC_RESP 0x00
  110. __u8 qllc_commands;
  111. #define QLLC_DISCONNECT 0x53
  112. #define QLLC_UNSEQACK 0x73
  113. #define QLLC_SETMODE 0x93
  114. #define QLLC_EXCHID 0xBF
  115. } __attribute__ ((packed));
  116. /*
  117. * Definition of one MPC group
  118. */
  119. #define MAX_MPCGCHAN 10
  120. #define MPC_XID_TIMEOUT_VALUE 10000
  121. #define MPC_CHANNEL_ADD 0
  122. #define MPC_CHANNEL_REMOVE 1
  123. #define MPC_CHANNEL_ATTN 2
  124. #define XSIDE 1
  125. #define YSIDE 0
  126. struct mpcg_info {
  127. struct sk_buff *skb;
  128. struct channel *ch;
  129. struct xid2 *xid;
  130. struct th_sweep *sweep;
  131. struct th_header *th;
  132. };
  133. struct mpc_group {
  134. struct tasklet_struct mpc_tasklet;
  135. struct tasklet_struct mpc_tasklet2;
  136. int changed_side;
  137. int saved_state;
  138. int channels_terminating;
  139. int out_of_sequence;
  140. int flow_off_called;
  141. int port_num;
  142. int port_persist;
  143. int alloc_called;
  144. __u32 xid2_adj_id;
  145. __u8 xid2_tgnum;
  146. __u32 xid2_sender_id;
  147. int num_channel_paths;
  148. int active_channels[2];
  149. __u16 group_max_buflen;
  150. int outstanding_xid2;
  151. int outstanding_xid7;
  152. int outstanding_xid7_p2;
  153. int sweep_req_pend_num;
  154. int sweep_rsp_pend_num;
  155. struct sk_buff *xid_skb;
  156. char *xid_skb_data;
  157. struct th_header *xid_th;
  158. struct xid2 *xid;
  159. char *xid_id;
  160. struct th_header *rcvd_xid_th;
  161. struct sk_buff *rcvd_xid_skb;
  162. char *rcvd_xid_data;
  163. __u8 in_sweep;
  164. __u8 roll;
  165. struct xid2 *saved_xid2;
  166. void (*allochanfunc)(int, int);
  167. int allocchan_callback_retries;
  168. void (*estconnfunc)(int, int, int);
  169. int estconn_callback_retries;
  170. int estconn_called;
  171. int xidnogood;
  172. int send_qllc_disc;
  173. fsm_timer timer;
  174. fsm_instance *fsm; /* group xid fsm */
  175. };
  176. #ifdef DEBUGDATA
  177. void ctcmpc_dumpit(char *buf, int len);
  178. #else
  179. static inline void ctcmpc_dumpit(char *buf, int len)
  180. {
  181. }
  182. #endif
  183. #ifdef DEBUGDATA
  184. /*
  185. * Dump header and first 16 bytes of an sk_buff for debugging purposes.
  186. *
  187. * skb The struct sk_buff to dump.
  188. * offset Offset relative to skb-data, where to start the dump.
  189. */
  190. void ctcmpc_dump_skb(struct sk_buff *skb, int offset);
  191. #else
  192. static inline void ctcmpc_dump_skb(struct sk_buff *skb, int offset)
  193. {}
  194. #endif
  195. static inline void ctcmpc_dump32(char *buf, int len)
  196. {
  197. if (len < 32)
  198. ctcmpc_dumpit(buf, len);
  199. else
  200. ctcmpc_dumpit(buf, 32);
  201. }
  202. void ctcm_ccw_check_rc(struct channel *, int, char *);
  203. void mpc_group_ready(unsigned long adev);
  204. void mpc_channel_action(struct channel *ch, int direction, int action);
  205. void mpc_action_send_discontact(unsigned long thischan);
  206. void mpc_action_discontact(fsm_instance *fi, int event, void *arg);
  207. void ctcmpc_bh(unsigned long thischan);
  208. #endif
  209. /* --- This is the END my friend --- */