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