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