1 /*******************************************************
4 ********************************************************/
6 /*-----------------------------------------------------*
7 * CCW command codes for CLAW protocol *
8 *------------------------------------------------------*/
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 */
21 /*-----------------------------------------------------*
22 * CLAW Unique constants *
23 *------------------------------------------------------*/
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 */
31 /*-----------------------------------------------------*
32 * CLAW control command code *
33 *------------------------------------------------------*/
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 */
44 /*-----------------------------------------------------*
45 * CLAW adater sense bytes *
46 *------------------------------------------------------*/
48 #define CLAW_ADAPTER_SENSE_BYTE 0x41 /* Stop command issued to adapter */
50 /*-----------------------------------------------------*
51 * CLAW control command return codes *
52 *------------------------------------------------------*/
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*/
60 /*-----------------------------------------------------*
61 * CLAW Constants application name *
62 *------------------------------------------------------*/
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 "
74 #define MAX_ENVELOPE_SIZE 65536
75 #define CLAW_DEFAULT_MTU_SIZE 4096
76 #define DEF_PACK_BUFSIZE 32768
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 20+3
90 /* state machine codes used in claw_irq_handler */
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
98 /*-----------------------------------------------------*
100 *------------------------------------------------------*/
104 /*-----------------------------------------------------*
106 *------------------------------------------------------*/
107 #define CLAW_DBF_TEXT(level, name, text) \
109 debug_text_event(claw_dbf_##name, level, text); \
112 #define CLAW_DBF_HEX(level,name,addr,len) \
114 debug_event(claw_dbf_##name,level,(void*)(addr),len); \
117 /* Allow to sort out low debug levels early to avoid wasted sprints */
118 static inline int claw_dbf_passes(debug_info_t
*dbf_grp
, int level
)
120 return (level
<= dbf_grp
->level
);
123 #define CLAW_DBF_TEXT_(level,name,text...) \
125 if (claw_dbf_passes(claw_dbf_##name, level)) { \
126 sprintf(debug_buffer, text); \
127 debug_text_event(claw_dbf_##name, level, \
133 * Enum for classifying detected devices.
135 enum claw_channel_types
{
136 /* Device is not a channel */
137 claw_channel_type_none
,
139 /* Device is a CLAW channel device */
140 claw_channel_type_claw
144 /*******************************************************
145 * Define Control Blocks *
147 ********************************************************/
149 /*------------------------------------------------------*/
151 /*------------------------------------------------------*/
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 */
159 /*------------------------------------------------------*/
160 /* CLAW Packing header 4 bytes */
161 /*------------------------------------------------------*/
163 __u16 len
; /* Length of Packed Data Area */
164 __u8 flag
; /* Reserved not used */
165 __u8 link_num
; /* Link ID */
168 /*------------------------------------------------------*/
169 /* CLAW Ending struct ccwbk */
170 /*------------------------------------------------------*/
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
;
186 /*------------------------------------------------------*/
187 /* CLAW struct ccwbk */
188 /*------------------------------------------------------*/
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 */
205 /*------------------------------------------------------*/
206 /* CLAW control block */
207 /*------------------------------------------------------*/
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 */
220 /*------------------------------------------------------*/
221 /* Data for SYSTEMVALIDATE command */
222 /*------------------------------------------------------*/
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 */
231 /*------------------------------------------------------*/
232 /* Data for Connect command */
233 /*------------------------------------------------------*/
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 */
241 /*------------------------------------------------------*/
242 /* Data for CLAW error */
243 /*------------------------------------------------------*/
245 char reserved1
[8]; /* reserved */
246 char reserved2
[8]; /* reserved */
247 char reserved3
[8]; /* reserved */
250 /*------------------------------------------------------*/
251 /* Data buffer for CLAW */
252 /*------------------------------------------------------*/
254 char buffer
[MAX_ENVELOPE_SIZE
]; /* data buffer */
257 /*------------------------------------------------------*/
258 /* Channel control block for read and write channel */
259 /*------------------------------------------------------*/
264 char id
[CLAW_ID_SIZE
];
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
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 */
286 /*--------------------------------------------------------------*
287 * CLAW environment block *
288 *---------------------------------------------------------------*/
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? */
302 __u8 in_use
; /* device active flag */
303 struct net_device
*ndev
; /* backward ptr to the net dev*/
306 /*--------------------------------------------------------------*
307 * CLAW main control block *
308 *---------------------------------------------------------------*/
312 __u32 p_buff_ccw_num
;
314 __u32 p_buff_read_num
;
315 __u32 p_buff_pages_perread
;
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 */
332 int mtc_logical_link
;
333 void *p_mtc_envelope
;
334 struct sk_buff
*pk_skb
; /* packing buffer */
336 struct clawctl ctl_bk
;
337 struct claw_env
*p_env
;
338 __u8 system_validate_comp
;
340 __u8 checksum_received_ip_pkts
;
342 struct endccw end_ccw
;
348 /************************************************************/
349 /* define global constants */
350 /************************************************************/
352 #define CCWBK_SIZE sizeof(struct ccwbk)