claw.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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 command 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_CHANNEL 0
  64. #define WRITE_CHANNEL 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 20+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. if (debug_level_enabled(claw_dbf_##name, level)) { \
  99. sprintf(debug_buffer, text); \
  100. debug_text_event(claw_dbf_##name, level, \
  101. debug_buffer); \
  102. } \
  103. } while (0)
  104. /**
  105. * Enum for classifying detected devices.
  106. */
  107. enum claw_channel_types {
  108. /* Device is not a channel */
  109. claw_channel_type_none,
  110. /* Device is a CLAW channel device */
  111. claw_channel_type_claw
  112. };
  113. /*******************************************************
  114. * Define Control Blocks *
  115. * *
  116. ********************************************************/
  117. /*------------------------------------------------------*/
  118. /* CLAW header */
  119. /*------------------------------------------------------*/
  120. struct clawh {
  121. __u16 length; /* length of data read by preceding read CCW */
  122. __u8 opcode; /* equivalent read CCW */
  123. __u8 flag; /* flag of FF to indicate read was completed */
  124. };
  125. /*------------------------------------------------------*/
  126. /* CLAW Packing header 4 bytes */
  127. /*------------------------------------------------------*/
  128. struct clawph {
  129. __u16 len; /* Length of Packed Data Area */
  130. __u8 flag; /* Reserved not used */
  131. __u8 link_num; /* Link ID */
  132. };
  133. /*------------------------------------------------------*/
  134. /* CLAW Ending struct ccwbk */
  135. /*------------------------------------------------------*/
  136. struct endccw {
  137. __u32 real; /* real address of this block */
  138. __u8 write1; /* write 1 is active */
  139. __u8 read1; /* read 1 is active */
  140. __u16 reserved; /* reserved for future use */
  141. struct ccw1 write1_nop1;
  142. struct ccw1 write1_nop2;
  143. struct ccw1 write2_nop1;
  144. struct ccw1 write2_nop2;
  145. struct ccw1 read1_nop1;
  146. struct ccw1 read1_nop2;
  147. struct ccw1 read2_nop1;
  148. struct ccw1 read2_nop2;
  149. };
  150. /*------------------------------------------------------*/
  151. /* CLAW struct ccwbk */
  152. /*------------------------------------------------------*/
  153. struct ccwbk {
  154. void *next; /* pointer to next ccw block */
  155. __u32 real; /* real address of this ccw */
  156. void *p_buffer; /* virtual address of data */
  157. struct clawh header; /* claw header */
  158. struct ccw1 write; /* write CCW */
  159. struct ccw1 w_read_FF; /* read FF */
  160. struct ccw1 w_TIC_1; /* TIC */
  161. struct ccw1 read; /* read CCW */
  162. struct ccw1 read_h; /* read header */
  163. struct ccw1 signal; /* signal SMOD */
  164. struct ccw1 r_TIC_1; /* TIC1 */
  165. struct ccw1 r_read_FF; /* read FF */
  166. struct ccw1 r_TIC_2; /* TIC2 */
  167. };
  168. /*------------------------------------------------------*/
  169. /* CLAW control block */
  170. /*------------------------------------------------------*/
  171. struct clawctl {
  172. __u8 command; /* control command */
  173. __u8 version; /* CLAW protocol version */
  174. __u8 linkid; /* link ID */
  175. __u8 correlator; /* correlator */
  176. __u8 rc; /* return code */
  177. __u8 reserved1; /* reserved */
  178. __u8 reserved2; /* reserved */
  179. __u8 reserved3; /* reserved */
  180. __u8 data[24]; /* command specific fields */
  181. };
  182. /*------------------------------------------------------*/
  183. /* Data for SYSTEMVALIDATE command */
  184. /*------------------------------------------------------*/
  185. struct sysval {
  186. char WS_name[8]; /* Workstation System name */
  187. char host_name[8]; /* Host system name */
  188. __u16 read_frame_size; /* read frame size */
  189. __u16 write_frame_size; /* write frame size */
  190. __u8 reserved[4]; /* reserved */
  191. };
  192. /*------------------------------------------------------*/
  193. /* Data for Connect command */
  194. /*------------------------------------------------------*/
  195. struct conncmd {
  196. char WS_name[8]; /* Workstation application name */
  197. char host_name[8]; /* Host application name */
  198. __u16 reserved1[2]; /* read frame size */
  199. __u8 reserved2[4]; /* reserved */
  200. };
  201. /*------------------------------------------------------*/
  202. /* Data for CLAW error */
  203. /*------------------------------------------------------*/
  204. struct clawwerror {
  205. char reserved1[8]; /* reserved */
  206. char reserved2[8]; /* reserved */
  207. char reserved3[8]; /* reserved */
  208. };
  209. /*------------------------------------------------------*/
  210. /* Data buffer for CLAW */
  211. /*------------------------------------------------------*/
  212. struct clawbuf {
  213. char buffer[MAX_ENVELOPE_SIZE]; /* data buffer */
  214. };
  215. /*------------------------------------------------------*/
  216. /* Channel control block for read and write channel */
  217. /*------------------------------------------------------*/
  218. struct chbk {
  219. unsigned int devno;
  220. int irq;
  221. char id[CLAW_ID_SIZE];
  222. __u32 IO_active;
  223. __u8 claw_state;
  224. struct irb *irb;
  225. struct ccw_device *cdev; /* pointer to the channel device */
  226. struct net_device *ndev;
  227. wait_queue_head_t wait;
  228. struct tasklet_struct tasklet;
  229. struct timer_list timer;
  230. unsigned long flag_a; /* atomic flags */
  231. #define CLAW_BH_ACTIVE 0
  232. unsigned long flag_b; /* atomic flags */
  233. #define CLAW_WRITE_ACTIVE 0
  234. __u8 last_dstat;
  235. __u8 flag;
  236. struct sk_buff_head collect_queue;
  237. spinlock_t collect_lock;
  238. #define CLAW_WRITE 0x02 /* - Set if this is a write channel */
  239. #define CLAW_READ 0x01 /* - Set if this is a read channel */
  240. #define CLAW_TIMER 0x80 /* - Set if timer made the wake_up */
  241. };
  242. /*--------------------------------------------------------------*
  243. * CLAW environment block *
  244. *---------------------------------------------------------------*/
  245. struct claw_env {
  246. unsigned int devno[2]; /* device number */
  247. char host_name[9]; /* Host name */
  248. char adapter_name [9]; /* adapter name */
  249. char api_type[9]; /* TCPIP, API or PACKED */
  250. void *p_priv; /* privptr */
  251. __u16 read_buffers; /* read buffer number */
  252. __u16 write_buffers; /* write buffer number */
  253. __u16 read_size; /* read buffer size */
  254. __u16 write_size; /* write buffer size */
  255. __u16 dev_id; /* device ident */
  256. __u8 packing; /* are we packing? */
  257. __u8 in_use; /* device active flag */
  258. struct net_device *ndev; /* backward ptr to the net dev*/
  259. };
  260. /*--------------------------------------------------------------*
  261. * CLAW main control block *
  262. *---------------------------------------------------------------*/
  263. struct claw_privbk {
  264. void *p_buff_ccw;
  265. __u32 p_buff_ccw_num;
  266. void *p_buff_read;
  267. __u32 p_buff_read_num;
  268. __u32 p_buff_pages_perread;
  269. void *p_buff_write;
  270. __u32 p_buff_write_num;
  271. __u32 p_buff_pages_perwrite;
  272. long active_link_ID; /* Active logical link ID */
  273. struct ccwbk *p_write_free_chain; /* pointer to free ccw chain */
  274. struct ccwbk *p_write_active_first; /* ptr to the first write ccw */
  275. struct ccwbk *p_write_active_last; /* ptr to the last write ccw */
  276. struct ccwbk *p_read_active_first; /* ptr to the first read ccw */
  277. struct ccwbk *p_read_active_last; /* ptr to the last read ccw */
  278. struct endccw *p_end_ccw; /*ptr to ending ccw */
  279. struct ccwbk *p_claw_signal_blk; /* ptr to signal block */
  280. __u32 write_free_count; /* number of free bufs for write */
  281. struct net_device_stats stats; /* device status */
  282. struct chbk channel[2]; /* Channel control blocks */
  283. __u8 mtc_skipping;
  284. int mtc_offset;
  285. int mtc_logical_link;
  286. void *p_mtc_envelope;
  287. struct sk_buff *pk_skb; /* packing buffer */
  288. int pk_cnt;
  289. struct clawctl ctl_bk;
  290. struct claw_env *p_env;
  291. __u8 system_validate_comp;
  292. __u8 release_pend;
  293. __u8 checksum_received_ip_pkts;
  294. __u8 buffs_alloc;
  295. struct endccw end_ccw;
  296. unsigned long tbusy;
  297. };
  298. /************************************************************/
  299. /* define global constants */
  300. /************************************************************/
  301. #define CCWBK_SIZE sizeof(struct ccwbk)