ctcm_mpc.h 5.2 KB

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