claw.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. /*******************************************************
  2. * Define constants *
  3. * *
  4. ********************************************************/
  5. /*-----------------------------------------------------*
  6. * CCW command codes for CLAW protocol *
  7. *------------------------------------------------------*/
  8. #define CCW_CLAW_CMD_WRITE 0x01 /* write - not including link */
  9. #define CCW_CLAW_CMD_READ 0x02 /* read */
  10. #define CCW_CLAW_CMD_NOP 0x03 /* NOP */
  11. #define CCW_CLAW_CMD_SENSE 0x04 /* Sense */
  12. #define CCW_CLAW_CMD_SIGNAL_SMOD 0x05 /* Signal Status Modifier */
  13. #define CCW_CLAW_CMD_TIC 0x08 /* TIC */
  14. #define CCW_CLAW_CMD_READHEADER 0x12 /* read header data */
  15. #define CCW_CLAW_CMD_READFF 0x22 /* read an FF */
  16. #define CCW_CLAW_CMD_SENSEID 0xe4 /* Sense ID */
  17. /*-----------------------------------------------------*
  18. * CLAW Unique constants *
  19. *------------------------------------------------------*/
  20. #define MORE_to_COME_FLAG 0x04 /* OR with write CCW in case of m-t-c */
  21. #define CLAW_IDLE 0x00 /* flag to indicate CLAW is idle */
  22. #define CLAW_BUSY 0xff /* flag to indicate CLAW is busy */
  23. #define CLAW_PENDING 0x00 /* flag to indicate i/o is pending */
  24. #define CLAW_COMPLETE 0xff /* flag to indicate i/o completed */
  25. /*-----------------------------------------------------*
  26. * CLAW control comand code *
  27. *------------------------------------------------------*/
  28. #define SYSTEM_VALIDATE_REQUEST 0x01 /* System Validate request */
  29. #define SYSTEM_VALIDATE_RESPONSE 0x02 /* System Validate response */
  30. #define CONNECTION_REQUEST 0x21 /* Connection request */
  31. #define CONNECTION_RESPONSE 0x22 /* Connection response */
  32. #define CONNECTION_CONFIRM 0x23 /* Connection confirm */
  33. #define DISCONNECT 0x24 /* Disconnect */
  34. #define CLAW_ERROR 0x41 /* CLAW error message */
  35. #define CLAW_VERSION_ID 2 /* CLAW version ID */
  36. /*-----------------------------------------------------*
  37. * CLAW adater sense bytes *
  38. *------------------------------------------------------*/
  39. #define CLAW_ADAPTER_SENSE_BYTE 0x41 /* Stop command issued to adapter */
  40. /*-----------------------------------------------------*
  41. * CLAW control command return codes *
  42. *------------------------------------------------------*/
  43. #define CLAW_RC_NAME_MISMATCH 166 /* names do not match */
  44. #define CLAW_RC_WRONG_VERSION 167 /* wrong CLAW version number */
  45. #define CLAW_RC_HOST_RCV_TOO_SMALL 180 /* Host maximum receive is */
  46. /* less than Linux on zSeries*/
  47. /* transmit size */
  48. /*-----------------------------------------------------*
  49. * CLAW Constants application name *
  50. *------------------------------------------------------*/
  51. #define HOST_APPL_NAME "TCPIP "
  52. #define WS_APPL_NAME_IP_LINK "TCPIP "
  53. #define WS_APPL_NAME_IP_NAME "IP "
  54. #define WS_APPL_NAME_API_LINK "API "
  55. #define WS_APPL_NAME_PACKED "PACKED "
  56. #define WS_NAME_NOT_DEF "NOT_DEF "
  57. #define PACKING_ASK 1
  58. #define PACK_SEND 2
  59. #define DO_PACKED 3
  60. #define MAX_ENVELOPE_SIZE 65536
  61. #define CLAW_DEFAULT_MTU_SIZE 4096
  62. #define DEF_PACK_BUFSIZE 32768
  63. #define READ 0
  64. #define WRITE 1
  65. #define TB_TX 0 /* sk buffer handling in process */
  66. #define TB_STOP 1 /* network device stop in process */
  67. #define TB_RETRY 2 /* retry in process */
  68. #define TB_NOBUFFER 3 /* no buffer on free queue */
  69. #define CLAW_MAX_LINK_ID 1
  70. #define CLAW_MAX_DEV 256 /* max claw devices */
  71. #define MAX_NAME_LEN 8 /* host name, adapter name length */
  72. #define CLAW_FRAME_SIZE 4096
  73. #define CLAW_ID_SIZE BUS_ID_SIZE+3
  74. /* state machine codes used in claw_irq_handler */
  75. #define CLAW_STOP 0
  76. #define CLAW_START_HALT_IO 1
  77. #define CLAW_START_SENSEID 2
  78. #define CLAW_START_READ 3
  79. #define CLAW_START_WRITE 4
  80. /*-----------------------------------------------------*
  81. * Lock flag *
  82. *------------------------------------------------------*/
  83. #define LOCK_YES 0
  84. #define LOCK_NO 1
  85. /*-----------------------------------------------------*
  86. * DBF Debug macros *
  87. *------------------------------------------------------*/
  88. #define CLAW_DBF_TEXT(level, name, text) \
  89. do { \
  90. debug_text_event(claw_dbf_##name, level, text); \
  91. } while (0)
  92. #define CLAW_DBF_HEX(level,name,addr,len) \
  93. do { \
  94. debug_event(claw_dbf_##name,level,(void*)(addr),len); \
  95. } while (0)
  96. #define CLAW_DBF_TEXT_(level,name,text...) \
  97. do { \
  98. sprintf(debug_buffer, text); \
  99. debug_text_event(claw_dbf_##name,level, debug_buffer);\
  100. } while (0)
  101. /*******************************************************
  102. * Define Control Blocks *
  103. * *
  104. ********************************************************/
  105. /*------------------------------------------------------*/
  106. /* CLAW header */
  107. /*------------------------------------------------------*/
  108. struct clawh {
  109. __u16 length; /* length of data read by preceding read CCW */
  110. __u8 opcode; /* equivalent read CCW */
  111. __u8 flag; /* flag of FF to indicate read was completed */
  112. };
  113. /*------------------------------------------------------*/
  114. /* CLAW Packing header 4 bytes */
  115. /*------------------------------------------------------*/
  116. struct clawph {
  117. __u16 len; /* Length of Packed Data Area */
  118. __u8 flag; /* Reserved not used */
  119. __u8 link_num; /* Link ID */
  120. };
  121. /*------------------------------------------------------*/
  122. /* CLAW Ending struct ccwbk */
  123. /*------------------------------------------------------*/
  124. struct endccw {
  125. __u32 real; /* real address of this block */
  126. __u8 write1; /* write 1 is active */
  127. __u8 read1; /* read 1 is active */
  128. __u16 reserved; /* reserved for future use */
  129. struct ccw1 write1_nop1;
  130. struct ccw1 write1_nop2;
  131. struct ccw1 write2_nop1;
  132. struct ccw1 write2_nop2;
  133. struct ccw1 read1_nop1;
  134. struct ccw1 read1_nop2;
  135. struct ccw1 read2_nop1;
  136. struct ccw1 read2_nop2;
  137. };
  138. /*------------------------------------------------------*/
  139. /* CLAW struct ccwbk */
  140. /*------------------------------------------------------*/
  141. struct ccwbk {
  142. void *next; /* pointer to next ccw block */
  143. __u32 real; /* real address of this ccw */
  144. void *p_buffer; /* virtual address of data */
  145. struct clawh header; /* claw header */
  146. struct ccw1 write; /* write CCW */
  147. struct ccw1 w_read_FF; /* read FF */
  148. struct ccw1 w_TIC_1; /* TIC */
  149. struct ccw1 read; /* read CCW */
  150. struct ccw1 read_h; /* read header */
  151. struct ccw1 signal; /* signal SMOD */
  152. struct ccw1 r_TIC_1; /* TIC1 */
  153. struct ccw1 r_read_FF; /* read FF */
  154. struct ccw1 r_TIC_2; /* TIC2 */
  155. };
  156. /*------------------------------------------------------*/
  157. /* CLAW control block */
  158. /*------------------------------------------------------*/
  159. struct clawctl {
  160. __u8 command; /* control command */
  161. __u8 version; /* CLAW protocol version */
  162. __u8 linkid; /* link ID */
  163. __u8 correlator; /* correlator */
  164. __u8 rc; /* return code */
  165. __u8 reserved1; /* reserved */
  166. __u8 reserved2; /* reserved */
  167. __u8 reserved3; /* reserved */
  168. __u8 data[24]; /* command specific fields */
  169. };
  170. /*------------------------------------------------------*/
  171. /* Data for SYSTEMVALIDATE command */
  172. /*------------------------------------------------------*/
  173. struct sysval {
  174. char WS_name[8]; /* Workstation System name */
  175. char host_name[8]; /* Host system name */
  176. __u16 read_frame_size; /* read frame size */
  177. __u16 write_frame_size; /* write frame size */
  178. __u8 reserved[4]; /* reserved */
  179. };
  180. /*------------------------------------------------------*/
  181. /* Data for Connect command */
  182. /*------------------------------------------------------*/
  183. struct conncmd {
  184. char WS_name[8]; /* Workstation application name */
  185. char host_name[8]; /* Host application name */
  186. __u16 reserved1[2]; /* read frame size */
  187. __u8 reserved2[4]; /* reserved */
  188. };
  189. /*------------------------------------------------------*/
  190. /* Data for CLAW error */
  191. /*------------------------------------------------------*/
  192. struct clawwerror {
  193. char reserved1[8]; /* reserved */
  194. char reserved2[8]; /* reserved */
  195. char reserved3[8]; /* reserved */
  196. };
  197. /*------------------------------------------------------*/
  198. /* Data buffer for CLAW */
  199. /*------------------------------------------------------*/
  200. struct clawbuf {
  201. char buffer[MAX_ENVELOPE_SIZE]; /* data buffer */
  202. };
  203. /*------------------------------------------------------*/
  204. /* Channel control block for read and write channel */
  205. /*------------------------------------------------------*/
  206. struct chbk {
  207. unsigned int devno;
  208. int irq;
  209. char id[CLAW_ID_SIZE];
  210. __u32 IO_active;
  211. __u8 claw_state;
  212. struct irb *irb;
  213. struct ccw_device *cdev; /* pointer to the channel device */
  214. struct net_device *ndev;
  215. wait_queue_head_t wait;
  216. struct tasklet_struct tasklet;
  217. struct timer_list timer;
  218. unsigned long flag_a; /* atomic flags */
  219. #define CLAW_BH_ACTIVE 0
  220. unsigned long flag_b; /* atomic flags */
  221. #define CLAW_WRITE_ACTIVE 0
  222. __u8 last_dstat;
  223. __u8 flag;
  224. struct sk_buff_head collect_queue;
  225. spinlock_t collect_lock;
  226. #define CLAW_WRITE 0x02 /* - Set if this is a write channel */
  227. #define CLAW_READ 0x01 /* - Set if this is a read channel */
  228. #define CLAW_TIMER 0x80 /* - Set if timer made the wake_up */
  229. };
  230. /*--------------------------------------------------------------*
  231. * CLAW environment block *
  232. *---------------------------------------------------------------*/
  233. struct claw_env {
  234. unsigned int devno[2]; /* device number */
  235. char host_name[9]; /* Host name */
  236. char adapter_name [9]; /* adapter name */
  237. char api_type[9]; /* TCPIP, API or PACKED */
  238. void *p_priv; /* privptr */
  239. __u16 read_buffers; /* read buffer number */
  240. __u16 write_buffers; /* write buffer number */
  241. __u16 read_size; /* read buffer size */
  242. __u16 write_size; /* write buffer size */
  243. __u16 dev_id; /* device ident */
  244. __u8 packing; /* are we packing? */
  245. volatile __u8 queme_switch; /* gate for imed packing */
  246. volatile unsigned long pk_delay; /* Delay for adaptive packing */
  247. __u8 in_use; /* device active flag */
  248. struct net_device *ndev; /* backward ptr to the net dev*/
  249. };
  250. /*--------------------------------------------------------------*
  251. * CLAW main control block *
  252. *---------------------------------------------------------------*/
  253. struct claw_privbk {
  254. void *p_buff_ccw;
  255. __u32 p_buff_ccw_num;
  256. void *p_buff_read;
  257. __u32 p_buff_read_num;
  258. __u32 p_buff_pages_perread;
  259. void *p_buff_write;
  260. __u32 p_buff_write_num;
  261. __u32 p_buff_pages_perwrite;
  262. long active_link_ID; /* Active logical link ID */
  263. struct ccwbk *p_write_free_chain; /* pointer to free ccw chain */
  264. struct ccwbk *p_write_active_first; /* ptr to the first write ccw */
  265. struct ccwbk *p_write_active_last; /* ptr to the last write ccw */
  266. struct ccwbk *p_read_active_first; /* ptr to the first read ccw */
  267. struct ccwbk *p_read_active_last; /* ptr to the last read ccw */
  268. struct endccw *p_end_ccw; /*ptr to ending ccw */
  269. struct ccwbk *p_claw_signal_blk; /* ptr to signal block */
  270. __u32 write_free_count; /* number of free bufs for write */
  271. struct net_device_stats stats; /* device status */
  272. struct chbk channel[2]; /* Channel control blocks */
  273. __u8 mtc_skipping;
  274. int mtc_offset;
  275. int mtc_logical_link;
  276. void *p_mtc_envelope;
  277. struct sk_buff *pk_skb; /* packing buffer */
  278. int pk_cnt;
  279. struct clawctl ctl_bk;
  280. struct claw_env *p_env;
  281. __u8 system_validate_comp;
  282. __u8 release_pend;
  283. __u8 checksum_received_ip_pkts;
  284. __u8 buffs_alloc;
  285. struct endccw end_ccw;
  286. unsigned long tbusy;
  287. };
  288. /************************************************************/
  289. /* define global constants */
  290. /************************************************************/
  291. #define CCWBK_SIZE sizeof(struct ccwbk)