ctcm_mpc.h 5.2 KB

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