aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/net/claw.h
blob: 3339b9b607b3aa6ca5ad5ba60c20cd5c3144df55 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
/*******************************************************
*  Define constants                                    *
*                                                      *
********************************************************/

/*-----------------------------------------------------*
*     CCW command codes for CLAW protocol              *
*------------------------------------------------------*/

#define CCW_CLAW_CMD_WRITE           0x01      /* write - not including link */
#define CCW_CLAW_CMD_READ            0x02      /* read */
#define CCW_CLAW_CMD_NOP             0x03      /* NOP */
#define CCW_CLAW_CMD_SENSE           0x04      /* Sense */
#define CCW_CLAW_CMD_SIGNAL_SMOD     0x05      /* Signal Status Modifier */
#define CCW_CLAW_CMD_TIC             0x08      /* TIC */
#define CCW_CLAW_CMD_READHEADER      0x12      /* read header data */
#define CCW_CLAW_CMD_READFF          0x22      /* read an FF */
#define CCW_CLAW_CMD_SENSEID         0xe4      /* Sense ID */


/*-----------------------------------------------------*
*    CLAW Unique constants                             *
*------------------------------------------------------*/

#define MORE_to_COME_FLAG       0x04   /* OR with write CCW in case of m-t-c */
#define CLAW_IDLE               0x00   /* flag to indicate CLAW is idle */
#define CLAW_BUSY               0xff   /* flag to indicate CLAW is busy */
#define CLAW_PENDING            0x00   /* flag to indicate i/o is pending */
#define CLAW_COMPLETE           0xff   /* flag to indicate i/o completed */

/*-----------------------------------------------------*
*     CLAW control command code                        *
*------------------------------------------------------*/

#define SYSTEM_VALIDATE_REQUEST   0x01  /* System Validate request */
#define SYSTEM_VALIDATE_RESPONSE  0x02  /* System Validate response */
#define CONNECTION_REQUEST        0x21  /* Connection request */
#define CONNECTION_RESPONSE       0x22  /* Connection response */
#define CONNECTION_CONFIRM        0x23  /* Connection confirm */
#define DISCONNECT                0x24  /* Disconnect */
#define CLAW_ERROR                0x41  /* CLAW error message */
#define CLAW_VERSION_ID           2     /* CLAW version ID */

/*-----------------------------------------------------*
*  CLAW adater sense bytes                             *
*------------------------------------------------------*/

#define CLAW_ADAPTER_SENSE_BYTE 0x41   /* Stop command issued to adapter */

/*-----------------------------------------------------*
*      CLAW control command return codes               *
*------------------------------------------------------*/

#define CLAW_RC_NAME_MISMATCH       166  /*  names do not match */
#define CLAW_RC_WRONG_VERSION       167  /*  wrong CLAW version number */
#define CLAW_RC_HOST_RCV_TOO_SMALL  180  /*  Host maximum receive is   */
					 /*  less than Linux on zSeries*/
                                         /*  transmit size             */

/*-----------------------------------------------------*
*      CLAW Constants application name                 *
*------------------------------------------------------*/

#define HOST_APPL_NAME          "TCPIP   "
#define WS_APPL_NAME_IP_LINK    "TCPIP   "
#define WS_APPL_NAME_IP_NAME	"IP      "
#define WS_APPL_NAME_API_LINK   "API     "
#define WS_APPL_NAME_PACKED     "PACKED  "
#define WS_NAME_NOT_DEF         "NOT_DEF "
#define PACKING_ASK		1
#define PACK_SEND		2
#define DO_PACKED		3

#define MAX_ENVELOPE_SIZE       65536
#define CLAW_DEFAULT_MTU_SIZE   4096
#define DEF_PACK_BUFSIZE	32768
#define READ_CHANNEL		0
#define WRITE_CHANNEL		1

#define TB_TX                   0          /* sk buffer handling in process  */
#define TB_STOP                 1          /* network device stop in process */
#define TB_RETRY                2          /* retry in process               */
#define TB_NOBUFFER             3          /* no buffer on free queue        */
#define CLAW_MAX_LINK_ID        1
#define CLAW_MAX_DEV            256        /*      max claw devices          */
#define MAX_NAME_LEN            8          /* host name, adapter name length */
#define CLAW_FRAME_SIZE         4096
#define CLAW_ID_SIZE		20+3

/* state machine codes used in claw_irq_handler */

#define CLAW_STOP                0
#define CLAW_START_HALT_IO       1
#define CLAW_START_SENSEID       2
#define CLAW_START_READ          3
#define CLAW_START_WRITE         4

/*-----------------------------------------------------*
*    Lock flag                                         *
*------------------------------------------------------*/
#define LOCK_YES             0
#define LOCK_NO              1

/*-----------------------------------------------------*
*    DBF Debug macros                                  *
*------------------------------------------------------*/
#define CLAW_DBF_TEXT(level, name, text) \
	do { \
		debug_text_event(claw_dbf_##name, level, text); \
	} while (0)

#define CLAW_DBF_HEX(level,name,addr,len) \
do { \
	debug_event(claw_dbf_##name,level,(void*)(addr),len); \
} while (0)

#define CLAW_DBF_TEXT_(level,name,text...) \
	do { \
		if (debug_level_enabled(claw_dbf_##name, level)) { \
			sprintf(debug_buffer, text); \
			debug_text_event(claw_dbf_##name, level, \
						debug_buffer); \
		} \
	} while (0)

/**
 * Enum for classifying detected devices.
 */
enum claw_channel_types {
	/* Device is not a channel  */
	claw_channel_type_none,

	/* Device is a CLAW channel device */
	claw_channel_type_claw
};


/*******************************************************
*  Define Control Blocks                               *
*                                                      *
********************************************************/

/*------------------------------------------------------*/
/*     CLAW header                                      */
/*------------------------------------------------------*/

struct clawh {
        __u16  length;     /* length of data read by preceding read CCW */
        __u8   opcode;     /* equivalent read CCW */
        __u8   flag;       /* flag of FF to indicate read was completed */
};

/*------------------------------------------------------*/
/*     CLAW Packing header   4 bytes                    */
/*------------------------------------------------------*/
struct clawph {
       __u16 len;  	/* Length of Packed Data Area   */
       __u8  flag;  	/* Reserved not used            */
       __u8  link_num;	/* Link ID                      */
};

/*------------------------------------------------------*/
/*     CLAW Ending struct ccwbk                         */
/*------------------------------------------------------*/
struct endccw {
	__u32     real;            /* real address of this block */
       __u8      write1;          /* write 1 is active */
        __u8      read1;           /* read 1 is active  */
        __u16     reserved;        /* reserved for future use */
        struct ccw1    write1_nop1;
        struct ccw1    write1_nop2;
        struct ccw1    write2_nop1;
        struct ccw1    write2_nop2;
        struct ccw1    read1_nop1;
        struct ccw1    read1_nop2;
        struct ccw1    read2_nop1;
        struct ccw1    read2_nop2;
};

/*------------------------------------------------------*/
/*     CLAW struct ccwbk                                       */
/*------------------------------------------------------*/
struct ccwbk {
        void   *next;        /* pointer to next ccw block */
        __u32     real;         /* real address of this ccw */
        void      *p_buffer;    /* virtual address of data */
        struct clawh     header;       /* claw header */
        struct ccw1    write;   /* write CCW    */
        struct ccw1    w_read_FF; /* read FF */
        struct ccw1    w_TIC_1;        /* TIC */
        struct ccw1    read;         /* read CCW  */
        struct ccw1    read_h;        /* read header */
        struct ccw1    signal;       /* signal SMOD  */
        struct ccw1    r_TIC_1;        /* TIC1 */
        struct ccw1    r_read_FF;      /* read FF  */
        struct ccw1    r_TIC_2;        /* TIC2 */
};

/*------------------------------------------------------*/
/*     CLAW control block                               */
/*------------------------------------------------------*/
struct clawctl {
        __u8    command;      /* control command */
        __u8    version;      /* CLAW protocol version */
        __u8    linkid;       /* link ID   */
        __u8    correlator;   /* correlator */
        __u8    rc;           /* return code */
        __u8    reserved1;    /* reserved */
        __u8    reserved2;    /* reserved */
        __u8    reserved3;    /* reserved */
        __u8    data[24];     /* command specific fields */
};

/*------------------------------------------------------*/
/*     Data for SYSTEMVALIDATE command                  */
/*------------------------------------------------------*/
struct sysval  {
        char    WS_name[8];        /* Workstation System name  */
        char    host_name[8];      /* Host system name     */
        __u16   read_frame_size;   /* read frame size */
        __u16   write_frame_size;  /* write frame size */
        __u8    reserved[4];       /* reserved */
};

/*------------------------------------------------------*/
/*     Data for Connect command                         */
/*------------------------------------------------------*/
struct conncmd  {
        char     WS_name[8];       /* Workstation application name  */
        char     host_name[8];     /* Host application name      */
        __u16    reserved1[2];     /* read frame size */
        __u8     reserved2[4];     /* reserved  */
};

/*------------------------------------------------------*/
/*     Data for CLAW error                              */
/*------------------------------------------------------*/
struct clawwerror  {
        char      reserved1[8];   /* reserved */
        char      reserved2[8];   /* reserved  */
        char      reserved3[8];   /* reserved  */
};

/*------------------------------------------------------*/
/*     Data buffer for CLAW                             */
/*------------------------------------------------------*/
struct clawbuf  {
       char      buffer[MAX_ENVELOPE_SIZE];   /* data buffer */
};

/*------------------------------------------------------*/
/*     Channel control block for read and write channel */
/*------------------------------------------------------*/

struct chbk {
        unsigned int        devno;
        int                 irq;
	char 		    id[CLAW_ID_SIZE];
       __u32               IO_active;
        __u8                claw_state;
        struct irb          *irb;
       	struct ccw_device   *cdev;  /* pointer to the channel device */
	struct net_device   *ndev;
        wait_queue_head_t   wait;
        struct tasklet_struct    tasklet;
        struct timer_list   timer;
        unsigned long       flag_a;    /* atomic flags */
#define CLAW_BH_ACTIVE      0
        unsigned long       flag_b;    /* atomic flags */
#define CLAW_WRITE_ACTIVE   0
        __u8                last_dstat;
        __u8                flag;
	struct sk_buff_head collect_queue;
	spinlock_t collect_lock;
#define CLAW_WRITE      0x02      /* - Set if this is a write channel */
#define CLAW_READ	0x01      /* - Set if this is a read channel  */
#define CLAW_TIMER      0x80      /* - Set if timer made the wake_up  */
};

/*--------------------------------------------------------------*
*           CLAW  environment block                             *
*---------------------------------------------------------------*/

struct claw_env {
        unsigned int            devno[2];       /* device number */
        char                    host_name[9];   /* Host name */
        char                    adapter_name [9]; /* adapter name */
        char                    api_type[9];    /* TCPIP, API or PACKED */
        void                    *p_priv;        /* privptr */
        __u16                   read_buffers;   /* read buffer number */
        __u16                   write_buffers;  /* write buffer number */
        __u16                   read_size;      /* read buffer size */
        __u16                   write_size;     /* write buffer size */
        __u16                   dev_id;         /* device ident */
	__u8			packing;	/* are we packing? */
        __u8                    in_use;         /* device active flag */
        struct net_device       *ndev;    	/* backward ptr to the net dev*/
};

/*--------------------------------------------------------------*
*           CLAW  main control block                            *
*---------------------------------------------------------------*/

struct claw_privbk {
        void *p_buff_ccw;
        __u32      p_buff_ccw_num;
        void  *p_buff_read;
        __u32      p_buff_read_num;
        __u32      p_buff_pages_perread;
        void  *p_buff_write;
        __u32      p_buff_write_num;
        __u32      p_buff_pages_perwrite;
        long       active_link_ID;           /* Active logical link ID */
        struct ccwbk *p_write_free_chain;     /* pointer to free ccw chain */
        struct ccwbk *p_write_active_first;   /* ptr to the first write ccw */
        struct ccwbk *p_write_active_last;    /* ptr to the last write ccw */
        struct ccwbk *p_read_active_first;    /* ptr to the first read ccw */
        struct ccwbk *p_read_active_last;     /* ptr to the last read ccw */
        struct endccw *p_end_ccw;              /*ptr to ending ccw */
        struct ccwbk *p_claw_signal_blk;      /* ptr to signal block */
        __u32      write_free_count;       /* number of free bufs for write */
	struct     net_device_stats  stats; /* 	 device status    */
        struct chbk channel[2];            /* Channel control blocks */
        __u8       mtc_skipping;
        int        mtc_offset;
        int        mtc_logical_link;
        void       *p_mtc_envelope;
	struct	   sk_buff	*pk_skb;	/* packing buffer    */
	int	   pk_cnt;
        struct clawctl ctl_bk;
        struct claw_env *p_env;
        __u8       system_validate_comp;
        __u8       release_pend;
        __u8      checksum_received_ip_pkts;
	__u8      buffs_alloc;
        struct endccw  end_ccw;
        unsigned long  tbusy;

};


/************************************************************/
/* define global constants                                  */
/************************************************************/

#define CCWBK_SIZE sizeof(struct ccwbk)