claw.h 14 KB

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