blob: 1bc5904df19ff550d3094ed939faab28f5cac44c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*******************************************************
2* Define constants *
3* *
4********************************************************/
Heiko Carstense018ba12006-02-01 03:06:31 -08005
Linus Torvalds1da177e2005-04-16 15:20:36 -07006/*-----------------------------------------------------*
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/*-----------------------------------------------------*
Matt LaPlante0779bf22006-11-30 05:24:39 +010032* CLAW control command code *
Linus Torvalds1da177e2005-04-16 15:20:36 -070033*------------------------------------------------------*/
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
Heiko Carstens319cb082010-08-12 01:58:27 +000077#define READ_CHANNEL 0
78#define WRITE_CHANNEL 1
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
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
Kay Sievers2a0217d2008-10-10 21:33:09 +020088#define CLAW_ID_SIZE 20+3
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
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
Peter Tiedemannf33780d2008-02-08 13:09:05 +0100117/* Allow to sort out low debug levels early to avoid wasted sprints */
118static inline int claw_dbf_passes(debug_info_t *dbf_grp, int level)
119{
120 return (level <= dbf_grp->level);
121}
122
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123#define CLAW_DBF_TEXT_(level,name,text...) \
Peter Tiedemannf33780d2008-02-08 13:09:05 +0100124 do { \
125 if (claw_dbf_passes(claw_dbf_##name, level)) { \
126 sprintf(debug_buffer, text); \
127 debug_text_event(claw_dbf_##name, level, \
128 debug_buffer); \
129 } \
130 } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131
Ursula Braun0ca8cc62009-11-12 21:46:29 +0000132/**
133 * Enum for classifying detected devices.
134 */
135enum claw_channel_types {
136 /* Device is not a channel */
137 claw_channel_type_none,
138
139 /* Device is a CLAW channel device */
140 claw_channel_type_claw
141};
142
143
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144/*******************************************************
145* Define Control Blocks *
146* *
147********************************************************/
148
149/*------------------------------------------------------*/
150/* CLAW header */
151/*------------------------------------------------------*/
152
153struct clawh {
154 __u16 length; /* length of data read by preceding read CCW */
155 __u8 opcode; /* equivalent read CCW */
156 __u8 flag; /* flag of FF to indicate read was completed */
157};
158
159/*------------------------------------------------------*/
160/* CLAW Packing header 4 bytes */
161/*------------------------------------------------------*/
162struct clawph {
163 __u16 len; /* Length of Packed Data Area */
164 __u8 flag; /* Reserved not used */
165 __u8 link_num; /* Link ID */
166};
167
168/*------------------------------------------------------*/
169/* CLAW Ending struct ccwbk */
170/*------------------------------------------------------*/
171struct endccw {
172 __u32 real; /* real address of this block */
173 __u8 write1; /* write 1 is active */
174 __u8 read1; /* read 1 is active */
175 __u16 reserved; /* reserved for future use */
176 struct ccw1 write1_nop1;
177 struct ccw1 write1_nop2;
178 struct ccw1 write2_nop1;
179 struct ccw1 write2_nop2;
180 struct ccw1 read1_nop1;
181 struct ccw1 read1_nop2;
182 struct ccw1 read2_nop1;
183 struct ccw1 read2_nop2;
184};
185
186/*------------------------------------------------------*/
187/* CLAW struct ccwbk */
188/*------------------------------------------------------*/
189struct ccwbk {
190 void *next; /* pointer to next ccw block */
191 __u32 real; /* real address of this ccw */
192 void *p_buffer; /* virtual address of data */
193 struct clawh header; /* claw header */
194 struct ccw1 write; /* write CCW */
195 struct ccw1 w_read_FF; /* read FF */
196 struct ccw1 w_TIC_1; /* TIC */
197 struct ccw1 read; /* read CCW */
198 struct ccw1 read_h; /* read header */
199 struct ccw1 signal; /* signal SMOD */
200 struct ccw1 r_TIC_1; /* TIC1 */
201 struct ccw1 r_read_FF; /* read FF */
202 struct ccw1 r_TIC_2; /* TIC2 */
203};
204
205/*------------------------------------------------------*/
206/* CLAW control block */
207/*------------------------------------------------------*/
208struct clawctl {
209 __u8 command; /* control command */
210 __u8 version; /* CLAW protocol version */
211 __u8 linkid; /* link ID */
212 __u8 correlator; /* correlator */
213 __u8 rc; /* return code */
214 __u8 reserved1; /* reserved */
215 __u8 reserved2; /* reserved */
216 __u8 reserved3; /* reserved */
217 __u8 data[24]; /* command specific fields */
218};
219
220/*------------------------------------------------------*/
221/* Data for SYSTEMVALIDATE command */
222/*------------------------------------------------------*/
223struct sysval {
224 char WS_name[8]; /* Workstation System name */
225 char host_name[8]; /* Host system name */
226 __u16 read_frame_size; /* read frame size */
227 __u16 write_frame_size; /* write frame size */
228 __u8 reserved[4]; /* reserved */
229};
230
231/*------------------------------------------------------*/
232/* Data for Connect command */
233/*------------------------------------------------------*/
234struct conncmd {
235 char WS_name[8]; /* Workstation application name */
236 char host_name[8]; /* Host application name */
237 __u16 reserved1[2]; /* read frame size */
238 __u8 reserved2[4]; /* reserved */
239};
240
241/*------------------------------------------------------*/
242/* Data for CLAW error */
243/*------------------------------------------------------*/
244struct clawwerror {
245 char reserved1[8]; /* reserved */
246 char reserved2[8]; /* reserved */
247 char reserved3[8]; /* reserved */
248};
249
250/*------------------------------------------------------*/
251/* Data buffer for CLAW */
252/*------------------------------------------------------*/
253struct clawbuf {
254 char buffer[MAX_ENVELOPE_SIZE]; /* data buffer */
255};
256
257/*------------------------------------------------------*/
258/* Channel control block for read and write channel */
259/*------------------------------------------------------*/
260
261struct chbk {
262 unsigned int devno;
263 int irq;
264 char id[CLAW_ID_SIZE];
265 __u32 IO_active;
266 __u8 claw_state;
267 struct irb *irb;
268 struct ccw_device *cdev; /* pointer to the channel device */
269 struct net_device *ndev;
270 wait_queue_head_t wait;
271 struct tasklet_struct tasklet;
272 struct timer_list timer;
273 unsigned long flag_a; /* atomic flags */
274#define CLAW_BH_ACTIVE 0
275 unsigned long flag_b; /* atomic flags */
276#define CLAW_WRITE_ACTIVE 0
277 __u8 last_dstat;
278 __u8 flag;
279 struct sk_buff_head collect_queue;
280 spinlock_t collect_lock;
281#define CLAW_WRITE 0x02 /* - Set if this is a write channel */
282#define CLAW_READ 0x01 /* - Set if this is a read channel */
283#define CLAW_TIMER 0x80 /* - Set if timer made the wake_up */
284};
285
286/*--------------------------------------------------------------*
287* CLAW environment block *
288*---------------------------------------------------------------*/
289
290struct claw_env {
291 unsigned int devno[2]; /* device number */
292 char host_name[9]; /* Host name */
293 char adapter_name [9]; /* adapter name */
294 char api_type[9]; /* TCPIP, API or PACKED */
295 void *p_priv; /* privptr */
296 __u16 read_buffers; /* read buffer number */
297 __u16 write_buffers; /* write buffer number */
298 __u16 read_size; /* read buffer size */
299 __u16 write_size; /* write buffer size */
300 __u16 dev_id; /* device ident */
301 __u8 packing; /* are we packing? */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302 __u8 in_use; /* device active flag */
303 struct net_device *ndev; /* backward ptr to the net dev*/
304};
305
306/*--------------------------------------------------------------*
307* CLAW main control block *
308*---------------------------------------------------------------*/
309
310struct claw_privbk {
311 void *p_buff_ccw;
312 __u32 p_buff_ccw_num;
313 void *p_buff_read;
314 __u32 p_buff_read_num;
315 __u32 p_buff_pages_perread;
316 void *p_buff_write;
317 __u32 p_buff_write_num;
318 __u32 p_buff_pages_perwrite;
319 long active_link_ID; /* Active logical link ID */
320 struct ccwbk *p_write_free_chain; /* pointer to free ccw chain */
321 struct ccwbk *p_write_active_first; /* ptr to the first write ccw */
322 struct ccwbk *p_write_active_last; /* ptr to the last write ccw */
323 struct ccwbk *p_read_active_first; /* ptr to the first read ccw */
324 struct ccwbk *p_read_active_last; /* ptr to the last read ccw */
325 struct endccw *p_end_ccw; /*ptr to ending ccw */
326 struct ccwbk *p_claw_signal_blk; /* ptr to signal block */
327 __u32 write_free_count; /* number of free bufs for write */
328 struct net_device_stats stats; /* device status */
329 struct chbk channel[2]; /* Channel control blocks */
330 __u8 mtc_skipping;
331 int mtc_offset;
332 int mtc_logical_link;
333 void *p_mtc_envelope;
334 struct sk_buff *pk_skb; /* packing buffer */
335 int pk_cnt;
336 struct clawctl ctl_bk;
337 struct claw_env *p_env;
338 __u8 system_validate_comp;
339 __u8 release_pend;
340 __u8 checksum_received_ip_pkts;
341 __u8 buffs_alloc;
342 struct endccw end_ccw;
343 unsigned long tbusy;
344
345};
346
347
348/************************************************************/
349/* define global constants */
350/************************************************************/
351
352#define CCWBK_SIZE sizeof(struct ccwbk)
353
354