claw.h 14 KB

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