Merge branch 'drm-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied...
[cascardo/linux.git] / drivers / s390 / net / qeth_core_mpc.h
1 /*
2  *  drivers/s390/net/qeth_core_mpc.h
3  *
4  *    Copyright IBM Corp. 2007
5  *    Author(s): Frank Pavlic <fpavlic@de.ibm.com>,
6  *               Thomas Spatzier <tspat@de.ibm.com>,
7  *               Frank Blaschka <frank.blaschka@de.ibm.com>
8  */
9
10 #ifndef __QETH_CORE_MPC_H__
11 #define __QETH_CORE_MPC_H__
12
13 #include <asm/qeth.h>
14
15 #define IPA_PDU_HEADER_SIZE     0x40
16 #define QETH_IPA_PDU_LEN_TOTAL(buffer) (buffer + 0x0e)
17 #define QETH_IPA_PDU_LEN_PDU1(buffer) (buffer + 0x26)
18 #define QETH_IPA_PDU_LEN_PDU2(buffer) (buffer + 0x29)
19 #define QETH_IPA_PDU_LEN_PDU3(buffer) (buffer + 0x3a)
20
21 extern unsigned char IPA_PDU_HEADER[];
22 #define QETH_IPA_CMD_DEST_ADDR(buffer) (buffer + 0x2c)
23
24 #define IPA_CMD_LENGTH  (IPA_PDU_HEADER_SIZE + sizeof(struct qeth_ipa_cmd))
25
26 #define QETH_SEQ_NO_LENGTH      4
27 #define QETH_MPC_TOKEN_LENGTH   4
28 #define QETH_MCL_LENGTH         4
29 #define OSA_ADDR_LEN            6
30
31 #define QETH_TIMEOUT            (10 * HZ)
32 #define QETH_IPA_TIMEOUT        (45 * HZ)
33 #define QETH_IDX_COMMAND_SEQNO  0xffff0000
34 #define SR_INFO_LEN             16
35
36 #define QETH_CLEAR_CHANNEL_PARM -10
37 #define QETH_HALT_CHANNEL_PARM  -11
38 #define QETH_RCD_PARM -12
39
40 /*****************************************************************************/
41 /* IP Assist related definitions                                             */
42 /*****************************************************************************/
43 #define IPA_CMD_INITIATOR_HOST  0x00
44 #define IPA_CMD_INITIATOR_OSA   0x01
45 #define IPA_CMD_INITIATOR_HOST_REPLY  0x80
46 #define IPA_CMD_INITIATOR_OSA_REPLY   0x81
47 #define IPA_CMD_PRIM_VERSION_NO 0x01
48
49 enum qeth_card_types {
50         QETH_CARD_TYPE_UNKNOWN = 0,
51         QETH_CARD_TYPE_OSAE    = 10,
52         QETH_CARD_TYPE_IQD     = 1234,
53         QETH_CARD_TYPE_OSN     = 11,
54 };
55
56 #define QETH_MPC_DIFINFO_LEN_INDICATES_LINK_TYPE 0x18
57 /* only the first two bytes are looked at in qeth_get_cardname_short */
58 enum qeth_link_types {
59         QETH_LINK_TYPE_FAST_ETH     = 0x01,
60         QETH_LINK_TYPE_HSTR         = 0x02,
61         QETH_LINK_TYPE_GBIT_ETH     = 0x03,
62         QETH_LINK_TYPE_OSN          = 0x04,
63         QETH_LINK_TYPE_10GBIT_ETH   = 0x10,
64         QETH_LINK_TYPE_LANE_ETH100  = 0x81,
65         QETH_LINK_TYPE_LANE_TR      = 0x82,
66         QETH_LINK_TYPE_LANE_ETH1000 = 0x83,
67         QETH_LINK_TYPE_LANE         = 0x88,
68         QETH_LINK_TYPE_ATM_NATIVE   = 0x90,
69 };
70
71 enum qeth_tr_macaddr_modes {
72         QETH_TR_MACADDR_NONCANONICAL = 0,
73         QETH_TR_MACADDR_CANONICAL    = 1,
74 };
75
76 enum qeth_tr_broadcast_modes {
77         QETH_TR_BROADCAST_ALLRINGS = 0,
78         QETH_TR_BROADCAST_LOCAL    = 1,
79 };
80
81 /* these values match CHECKSUM_* in include/linux/skbuff.h */
82 enum qeth_checksum_types {
83         SW_CHECKSUMMING = 0, /* TODO: set to bit flag used in IPA Command */
84         HW_CHECKSUMMING = 1,
85         NO_CHECKSUMMING = 2,
86 };
87 #define QETH_CHECKSUM_DEFAULT SW_CHECKSUMMING
88
89 /*
90  * Routing stuff
91  */
92 #define RESET_ROUTING_FLAG 0x10 /* indicate that routing type shall be set */
93 enum qeth_routing_types {
94         /* TODO: set to bit flag used in IPA Command */
95         NO_ROUTER               = 0,
96         PRIMARY_ROUTER          = 1,
97         SECONDARY_ROUTER        = 2,
98         MULTICAST_ROUTER        = 3,
99         PRIMARY_CONNECTOR       = 4,
100         SECONDARY_CONNECTOR     = 5,
101 };
102
103 /* IPA Commands */
104 enum qeth_ipa_cmds {
105         IPA_CMD_STARTLAN                = 0x01,
106         IPA_CMD_STOPLAN                 = 0x02,
107         IPA_CMD_SETVMAC                 = 0x21,
108         IPA_CMD_DELVMAC                 = 0x22,
109         IPA_CMD_SETGMAC                 = 0x23,
110         IPA_CMD_DELGMAC                 = 0x24,
111         IPA_CMD_SETVLAN                 = 0x25,
112         IPA_CMD_DELVLAN                 = 0x26,
113         IPA_CMD_SETCCID                 = 0x41,
114         IPA_CMD_DELCCID                 = 0x42,
115         IPA_CMD_MODCCID                 = 0x43,
116         IPA_CMD_SETIP                   = 0xb1,
117         IPA_CMD_QIPASSIST               = 0xb2,
118         IPA_CMD_SETASSPARMS             = 0xb3,
119         IPA_CMD_SETIPM                  = 0xb4,
120         IPA_CMD_DELIPM                  = 0xb5,
121         IPA_CMD_SETRTG                  = 0xb6,
122         IPA_CMD_DELIP                   = 0xb7,
123         IPA_CMD_SETADAPTERPARMS         = 0xb8,
124         IPA_CMD_SET_DIAG_ASS            = 0xb9,
125         IPA_CMD_CREATE_ADDR             = 0xc3,
126         IPA_CMD_DESTROY_ADDR            = 0xc4,
127         IPA_CMD_REGISTER_LOCAL_ADDR     = 0xd1,
128         IPA_CMD_UNREGISTER_LOCAL_ADDR   = 0xd2,
129         IPA_CMD_UNKNOWN                 = 0x00
130 };
131
132 enum qeth_ip_ass_cmds {
133         IPA_CMD_ASS_START       = 0x0001,
134         IPA_CMD_ASS_STOP        = 0x0002,
135         IPA_CMD_ASS_CONFIGURE   = 0x0003,
136         IPA_CMD_ASS_ENABLE      = 0x0004,
137 };
138
139 enum qeth_arp_process_subcmds {
140         IPA_CMD_ASS_ARP_SET_NO_ENTRIES  = 0x0003,
141         IPA_CMD_ASS_ARP_QUERY_CACHE     = 0x0004,
142         IPA_CMD_ASS_ARP_ADD_ENTRY       = 0x0005,
143         IPA_CMD_ASS_ARP_REMOVE_ENTRY    = 0x0006,
144         IPA_CMD_ASS_ARP_FLUSH_CACHE     = 0x0007,
145         IPA_CMD_ASS_ARP_QUERY_INFO      = 0x0104,
146         IPA_CMD_ASS_ARP_QUERY_STATS     = 0x0204,
147 };
148
149
150 /* Return Codes for IPA Commands
151  * according to OSA card Specs */
152
153 enum qeth_ipa_return_codes {
154         IPA_RC_SUCCESS                  = 0x0000,
155         IPA_RC_NOTSUPP                  = 0x0001,
156         IPA_RC_IP_TABLE_FULL            = 0x0002,
157         IPA_RC_UNKNOWN_ERROR            = 0x0003,
158         IPA_RC_UNSUPPORTED_COMMAND      = 0x0004,
159         IPA_RC_DUP_IPV6_REMOTE          = 0x0008,
160         IPA_RC_DUP_IPV6_HOME            = 0x0010,
161         IPA_RC_UNREGISTERED_ADDR        = 0x0011,
162         IPA_RC_NO_ID_AVAILABLE          = 0x0012,
163         IPA_RC_ID_NOT_FOUND             = 0x0013,
164         IPA_RC_INVALID_IP_VERSION       = 0x0020,
165         IPA_RC_LAN_FRAME_MISMATCH       = 0x0040,
166         IPA_RC_L2_UNSUPPORTED_CMD       = 0x2003,
167         IPA_RC_L2_DUP_MAC               = 0x2005,
168         IPA_RC_L2_ADDR_TABLE_FULL       = 0x2006,
169         IPA_RC_L2_DUP_LAYER3_MAC        = 0x200a,
170         IPA_RC_L2_GMAC_NOT_FOUND        = 0x200b,
171         IPA_RC_L2_MAC_NOT_AUTH_BY_HYP   = 0x200c,
172         IPA_RC_L2_MAC_NOT_AUTH_BY_ADP   = 0x200d,
173         IPA_RC_L2_MAC_NOT_FOUND         = 0x2010,
174         IPA_RC_L2_INVALID_VLAN_ID       = 0x2015,
175         IPA_RC_L2_DUP_VLAN_ID           = 0x2016,
176         IPA_RC_L2_VLAN_ID_NOT_FOUND     = 0x2017,
177         IPA_RC_DATA_MISMATCH            = 0xe001,
178         IPA_RC_INVALID_MTU_SIZE         = 0xe002,
179         IPA_RC_INVALID_LANTYPE          = 0xe003,
180         IPA_RC_INVALID_LANNUM           = 0xe004,
181         IPA_RC_DUPLICATE_IP_ADDRESS     = 0xe005,
182         IPA_RC_IP_ADDR_TABLE_FULL       = 0xe006,
183         IPA_RC_LAN_PORT_STATE_ERROR     = 0xe007,
184         IPA_RC_SETIP_NO_STARTLAN        = 0xe008,
185         IPA_RC_SETIP_ALREADY_RECEIVED   = 0xe009,
186         IPA_RC_IP_ADDR_ALREADY_USED     = 0xe00a,
187         IPA_RC_MC_ADDR_NOT_FOUND        = 0xe00b,
188         IPA_RC_SETIP_INVALID_VERSION    = 0xe00d,
189         IPA_RC_UNSUPPORTED_SUBCMD       = 0xe00e,
190         IPA_RC_ARP_ASSIST_NO_ENABLE     = 0xe00f,
191         IPA_RC_PRIMARY_ALREADY_DEFINED  = 0xe010,
192         IPA_RC_SECOND_ALREADY_DEFINED   = 0xe011,
193         IPA_RC_INVALID_SETRTG_INDICATOR = 0xe012,
194         IPA_RC_MC_ADDR_ALREADY_DEFINED  = 0xe013,
195         IPA_RC_LAN_OFFLINE              = 0xe080,
196         IPA_RC_INVALID_IP_VERSION2      = 0xf001,
197         IPA_RC_FFFF                     = 0xffff
198 };
199
200 /* IPA function flags; each flag marks availability of respective function */
201 enum qeth_ipa_funcs {
202         IPA_ARP_PROCESSING      = 0x00000001L,
203         IPA_INBOUND_CHECKSUM    = 0x00000002L,
204         IPA_OUTBOUND_CHECKSUM   = 0x00000004L,
205         IPA_IP_FRAGMENTATION    = 0x00000008L,
206         IPA_FILTERING           = 0x00000010L,
207         IPA_IPV6                = 0x00000020L,
208         IPA_MULTICASTING        = 0x00000040L,
209         IPA_IP_REASSEMBLY       = 0x00000080L,
210         IPA_QUERY_ARP_COUNTERS  = 0x00000100L,
211         IPA_QUERY_ARP_ADDR_INFO = 0x00000200L,
212         IPA_SETADAPTERPARMS     = 0x00000400L,
213         IPA_VLAN_PRIO           = 0x00000800L,
214         IPA_PASSTHRU            = 0x00001000L,
215         IPA_FLUSH_ARP_SUPPORT   = 0x00002000L,
216         IPA_FULL_VLAN           = 0x00004000L,
217         IPA_INBOUND_PASSTHRU    = 0x00008000L,
218         IPA_SOURCE_MAC          = 0x00010000L,
219         IPA_OSA_MC_ROUTER       = 0x00020000L,
220         IPA_QUERY_ARP_ASSIST    = 0x00040000L,
221         IPA_INBOUND_TSO         = 0x00080000L,
222         IPA_OUTBOUND_TSO        = 0x00100000L,
223 };
224
225 /* SETIP/DELIP IPA Command: ***************************************************/
226 enum qeth_ipa_setdelip_flags {
227         QETH_IPA_SETDELIP_DEFAULT          = 0x00L, /* default */
228         QETH_IPA_SETIP_VIPA_FLAG           = 0x01L, /* no grat. ARP */
229         QETH_IPA_SETIP_TAKEOVER_FLAG       = 0x02L, /* nofail on grat. ARP */
230         QETH_IPA_DELIP_ADDR_2_B_TAKEN_OVER = 0x20L,
231         QETH_IPA_DELIP_VIPA_FLAG           = 0x40L,
232         QETH_IPA_DELIP_ADDR_NEEDS_SETIP    = 0x80L,
233 };
234
235 /* SETADAPTER IPA Command: ****************************************************/
236 enum qeth_ipa_setadp_cmd {
237         IPA_SETADP_QUERY_COMMANDS_SUPPORTED     = 0x00000001L,
238         IPA_SETADP_ALTER_MAC_ADDRESS            = 0x00000002L,
239         IPA_SETADP_ADD_DELETE_GROUP_ADDRESS     = 0x00000004L,
240         IPA_SETADP_ADD_DELETE_FUNCTIONAL_ADDR   = 0x00000008L,
241         IPA_SETADP_SET_ADDRESSING_MODE          = 0x00000010L,
242         IPA_SETADP_SET_CONFIG_PARMS             = 0x00000020L,
243         IPA_SETADP_SET_CONFIG_PARMS_EXTENDED    = 0x00000040L,
244         IPA_SETADP_SET_BROADCAST_MODE           = 0x00000080L,
245         IPA_SETADP_SEND_OSA_MESSAGE             = 0x00000100L,
246         IPA_SETADP_SET_SNMP_CONTROL             = 0x00000200L,
247         IPA_SETADP_QUERY_CARD_INFO              = 0x00000400L,
248         IPA_SETADP_SET_PROMISC_MODE             = 0x00000800L,
249         IPA_SETADP_SET_ACCESS_CONTROL           = 0x00010000L,
250 };
251 enum qeth_ipa_mac_ops {
252         CHANGE_ADDR_READ_MAC            = 0,
253         CHANGE_ADDR_REPLACE_MAC         = 1,
254         CHANGE_ADDR_ADD_MAC             = 2,
255         CHANGE_ADDR_DEL_MAC             = 4,
256         CHANGE_ADDR_RESET_MAC           = 8,
257 };
258 enum qeth_ipa_addr_ops {
259         CHANGE_ADDR_READ_ADDR           = 0,
260         CHANGE_ADDR_ADD_ADDR            = 1,
261         CHANGE_ADDR_DEL_ADDR            = 2,
262         CHANGE_ADDR_FLUSH_ADDR_TABLE    = 4,
263 };
264 enum qeth_ipa_promisc_modes {
265         SET_PROMISC_MODE_OFF            = 0,
266         SET_PROMISC_MODE_ON             = 1,
267 };
268 enum qeth_ipa_isolation_modes {
269         ISOLATION_MODE_NONE             = 0x00000000L,
270         ISOLATION_MODE_FWD              = 0x00000001L,
271         ISOLATION_MODE_DROP             = 0x00000002L,
272 };
273 enum qeth_ipa_set_access_mode_rc {
274         SET_ACCESS_CTRL_RC_SUCCESS              = 0x0000,
275         SET_ACCESS_CTRL_RC_NOT_SUPPORTED        = 0x0004,
276         SET_ACCESS_CTRL_RC_ALREADY_NOT_ISOLATED = 0x0008,
277         SET_ACCESS_CTRL_RC_ALREADY_ISOLATED     = 0x0010,
278         SET_ACCESS_CTRL_RC_NONE_SHARED_ADAPTER  = 0x0014,
279         SET_ACCESS_CTRL_RC_ACTIVE_CHECKSUM_OFF  = 0x0018,
280 };
281
282
283 /* (SET)DELIP(M) IPA stuff ***************************************************/
284 struct qeth_ipacmd_setdelip4 {
285         __u8   ip_addr[4];
286         __u8   mask[4];
287         __u32  flags;
288 } __attribute__ ((packed));
289
290 struct qeth_ipacmd_setdelip6 {
291         __u8   ip_addr[16];
292         __u8   mask[16];
293         __u32  flags;
294 } __attribute__ ((packed));
295
296 struct qeth_ipacmd_setdelipm {
297         __u8 mac[6];
298         __u8 padding[2];
299         __u8 ip6[12];
300         __u8 ip4[4];
301 } __attribute__ ((packed));
302
303 struct qeth_ipacmd_layer2setdelmac {
304         __u32 mac_length;
305         __u8 mac[6];
306 } __attribute__ ((packed));
307
308 struct qeth_ipacmd_layer2setdelvlan {
309         __u16 vlan_id;
310 } __attribute__ ((packed));
311
312
313 struct qeth_ipacmd_setassparms_hdr {
314         __u32 assist_no;
315         __u16 length;
316         __u16 command_code;
317         __u16 return_code;
318         __u8 number_of_replies;
319         __u8 seq_no;
320 } __attribute__((packed));
321
322 struct qeth_arp_query_data {
323         __u16 request_bits;
324         __u16 reply_bits;
325         __u32 no_entries;
326         char data;
327 } __attribute__((packed));
328
329 /* used as parameter for arp_query reply */
330 struct qeth_arp_query_info {
331         __u32 udata_len;
332         __u16 mask_bits;
333         __u32 udata_offset;
334         __u32 no_entries;
335         char *udata;
336 };
337
338 /* SETASSPARMS IPA Command: */
339 struct qeth_ipacmd_setassparms {
340         struct qeth_ipacmd_setassparms_hdr hdr;
341         union {
342                 __u32 flags_32bit;
343                 struct qeth_arp_cache_entry add_arp_entry;
344                 struct qeth_arp_query_data query_arp;
345                 __u8 ip[16];
346         } data;
347 } __attribute__ ((packed));
348
349
350 /* SETRTG IPA Command:    ****************************************************/
351 struct qeth_set_routing {
352         __u8 type;
353 };
354
355 /* SETADAPTERPARMS IPA Command:    *******************************************/
356 struct qeth_query_cmds_supp {
357         __u32 no_lantypes_supp;
358         __u8 lan_type;
359         __u8 reserved1[3];
360         __u32 supported_cmds;
361         __u8 reserved2[8];
362 } __attribute__ ((packed));
363
364 struct qeth_change_addr {
365         __u32 cmd;
366         __u32 addr_size;
367         __u32 no_macs;
368         __u8 addr[OSA_ADDR_LEN];
369 } __attribute__ ((packed));
370
371
372 struct qeth_snmp_cmd {
373         __u8  token[16];
374         __u32 request;
375         __u32 interface;
376         __u32 returncode;
377         __u32 firmwarelevel;
378         __u32 seqno;
379         __u8  data;
380 } __attribute__ ((packed));
381
382 struct qeth_snmp_ureq_hdr {
383         __u32   data_len;
384         __u32   req_len;
385         __u32   reserved1;
386         __u32   reserved2;
387 } __attribute__ ((packed));
388
389 struct qeth_snmp_ureq {
390         struct qeth_snmp_ureq_hdr hdr;
391         struct qeth_snmp_cmd cmd;
392 } __attribute__((packed));
393
394 /* SET_ACCESS_CONTROL: same format for request and reply */
395 struct qeth_set_access_ctrl {
396         __u32 subcmd_code;
397 } __attribute__((packed));
398
399 struct qeth_ipacmd_setadpparms_hdr {
400         __u32 supp_hw_cmds;
401         __u32 reserved1;
402         __u16 cmdlength;
403         __u16 reserved2;
404         __u32 command_code;
405         __u16 return_code;
406         __u8  used_total;
407         __u8  seq_no;
408         __u32 reserved3;
409 } __attribute__ ((packed));
410
411 struct qeth_ipacmd_setadpparms {
412         struct qeth_ipacmd_setadpparms_hdr hdr;
413         union {
414                 struct qeth_query_cmds_supp query_cmds_supp;
415                 struct qeth_change_addr change_addr;
416                 struct qeth_snmp_cmd snmp;
417                 struct qeth_set_access_ctrl set_access_ctrl;
418                 __u32 mode;
419         } data;
420 } __attribute__ ((packed));
421
422 /* CREATE_ADDR IPA Command:    ***********************************************/
423 struct qeth_create_destroy_address {
424         __u8 unique_id[8];
425 } __attribute__ ((packed));
426
427 /* Header for each IPA command */
428 struct qeth_ipacmd_hdr {
429         __u8   command;
430         __u8   initiator;
431         __u16  seqno;
432         __u16  return_code;
433         __u8   adapter_type;
434         __u8   rel_adapter_no;
435         __u8   prim_version_no;
436         __u8   param_count;
437         __u16  prot_version;
438         __u32  ipa_supported;
439         __u32  ipa_enabled;
440 } __attribute__ ((packed));
441
442 /* The IPA command itself */
443 struct qeth_ipa_cmd {
444         struct qeth_ipacmd_hdr hdr;
445         union {
446                 struct qeth_ipacmd_setdelip4            setdelip4;
447                 struct qeth_ipacmd_setdelip6            setdelip6;
448                 struct qeth_ipacmd_setdelipm            setdelipm;
449                 struct qeth_ipacmd_setassparms          setassparms;
450                 struct qeth_ipacmd_layer2setdelmac      setdelmac;
451                 struct qeth_ipacmd_layer2setdelvlan     setdelvlan;
452                 struct qeth_create_destroy_address      create_destroy_addr;
453                 struct qeth_ipacmd_setadpparms          setadapterparms;
454                 struct qeth_set_routing                 setrtg;
455         } data;
456 } __attribute__ ((packed));
457
458 /*
459  * special command for ARP processing.
460  * this is not included in setassparms command before, because we get
461  * problem with the size of struct qeth_ipacmd_setassparms otherwise
462  */
463 enum qeth_ipa_arp_return_codes {
464         QETH_IPA_ARP_RC_SUCCESS      = 0x0000,
465         QETH_IPA_ARP_RC_FAILED       = 0x0001,
466         QETH_IPA_ARP_RC_NOTSUPP      = 0x0002,
467         QETH_IPA_ARP_RC_OUT_OF_RANGE = 0x0003,
468         QETH_IPA_ARP_RC_Q_NOTSUPP    = 0x0004,
469         QETH_IPA_ARP_RC_Q_NO_DATA    = 0x0008,
470 };
471
472
473 extern char *qeth_get_ipa_msg(enum qeth_ipa_return_codes rc);
474 extern char *qeth_get_ipa_cmd_name(enum qeth_ipa_cmds cmd);
475
476 #define QETH_SETASS_BASE_LEN (sizeof(struct qeth_ipacmd_hdr) + \
477                                sizeof(struct qeth_ipacmd_setassparms_hdr))
478 #define QETH_IPA_ARP_DATA_POS(buffer) (buffer + IPA_PDU_HEADER_SIZE + \
479                                        QETH_SETASS_BASE_LEN)
480 #define QETH_SETADP_BASE_LEN (sizeof(struct qeth_ipacmd_hdr) + \
481                               sizeof(struct qeth_ipacmd_setadpparms_hdr))
482 #define QETH_SNMP_SETADP_CMDLENGTH 16
483
484 #define QETH_ARP_DATA_SIZE 3968
485 #define QETH_ARP_CMD_LEN (QETH_ARP_DATA_SIZE + 8)
486 /* Helper functions */
487 #define IS_IPA_REPLY(cmd) ((cmd->hdr.initiator == IPA_CMD_INITIATOR_HOST) || \
488                            (cmd->hdr.initiator == IPA_CMD_INITIATOR_OSA_REPLY))
489
490 /*****************************************************************************/
491 /* END OF   IP Assist related definitions                                    */
492 /*****************************************************************************/
493
494
495 extern unsigned char WRITE_CCW[];
496 extern unsigned char READ_CCW[];
497
498 extern unsigned char CM_ENABLE[];
499 #define CM_ENABLE_SIZE 0x63
500 #define QETH_CM_ENABLE_ISSUER_RM_TOKEN(buffer) (buffer + 0x2c)
501 #define QETH_CM_ENABLE_FILTER_TOKEN(buffer) (buffer + 0x53)
502 #define QETH_CM_ENABLE_USER_DATA(buffer) (buffer + 0x5b)
503
504 #define QETH_CM_ENABLE_RESP_FILTER_TOKEN(buffer) \
505                 (PDU_ENCAPSULATION(buffer) + 0x13)
506
507
508 extern unsigned char CM_SETUP[];
509 #define CM_SETUP_SIZE 0x64
510 #define QETH_CM_SETUP_DEST_ADDR(buffer) (buffer + 0x2c)
511 #define QETH_CM_SETUP_CONNECTION_TOKEN(buffer) (buffer + 0x51)
512 #define QETH_CM_SETUP_FILTER_TOKEN(buffer) (buffer + 0x5a)
513
514 #define QETH_CM_SETUP_RESP_DEST_ADDR(buffer) \
515                 (PDU_ENCAPSULATION(buffer) + 0x1a)
516
517 extern unsigned char ULP_ENABLE[];
518 #define ULP_ENABLE_SIZE 0x6b
519 #define QETH_ULP_ENABLE_LINKNUM(buffer) (buffer + 0x61)
520 #define QETH_ULP_ENABLE_DEST_ADDR(buffer) (buffer + 0x2c)
521 #define QETH_ULP_ENABLE_FILTER_TOKEN(buffer) (buffer + 0x53)
522 #define QETH_ULP_ENABLE_PORTNAME_AND_LL(buffer) (buffer + 0x62)
523 #define QETH_ULP_ENABLE_RESP_FILTER_TOKEN(buffer) \
524                 (PDU_ENCAPSULATION(buffer) + 0x13)
525 #define QETH_ULP_ENABLE_RESP_MAX_MTU(buffer) \
526                 (PDU_ENCAPSULATION(buffer) + 0x1f)
527 #define QETH_ULP_ENABLE_RESP_DIFINFO_LEN(buffer) \
528                 (PDU_ENCAPSULATION(buffer) + 0x17)
529 #define QETH_ULP_ENABLE_RESP_LINK_TYPE(buffer) \
530                 (PDU_ENCAPSULATION(buffer) + 0x2b)
531 /* Layer 2 definitions */
532 #define QETH_PROT_LAYER2 0x08
533 #define QETH_PROT_TCPIP  0x03
534 #define QETH_PROT_OSN2   0x0a
535 #define QETH_ULP_ENABLE_PROT_TYPE(buffer) (buffer + 0x50)
536 #define QETH_IPA_CMD_PROT_TYPE(buffer) (buffer + 0x19)
537
538 extern unsigned char ULP_SETUP[];
539 #define ULP_SETUP_SIZE 0x6c
540 #define QETH_ULP_SETUP_DEST_ADDR(buffer) (buffer + 0x2c)
541 #define QETH_ULP_SETUP_CONNECTION_TOKEN(buffer) (buffer + 0x51)
542 #define QETH_ULP_SETUP_FILTER_TOKEN(buffer) (buffer + 0x5a)
543 #define QETH_ULP_SETUP_CUA(buffer) (buffer + 0x68)
544 #define QETH_ULP_SETUP_REAL_DEVADDR(buffer) (buffer + 0x6a)
545
546 #define QETH_ULP_SETUP_RESP_CONNECTION_TOKEN(buffer) \
547                 (PDU_ENCAPSULATION(buffer) + 0x1a)
548
549
550 extern unsigned char DM_ACT[];
551 #define DM_ACT_SIZE 0x55
552 #define QETH_DM_ACT_DEST_ADDR(buffer) (buffer + 0x2c)
553 #define QETH_DM_ACT_CONNECTION_TOKEN(buffer) (buffer + 0x51)
554
555
556
557 #define QETH_TRANSPORT_HEADER_SEQ_NO(buffer) (buffer + 4)
558 #define QETH_PDU_HEADER_SEQ_NO(buffer) (buffer + 0x1c)
559 #define QETH_PDU_HEADER_ACK_SEQ_NO(buffer) (buffer + 0x20)
560
561 extern unsigned char IDX_ACTIVATE_READ[];
562 extern unsigned char IDX_ACTIVATE_WRITE[];
563
564 #define IDX_ACTIVATE_SIZE       0x22
565 #define QETH_IDX_ACT_PNO(buffer) (buffer+0x0b)
566 #define QETH_IDX_ACT_ISSUER_RM_TOKEN(buffer) (buffer + 0x0c)
567 #define QETH_IDX_NO_PORTNAME_REQUIRED(buffer) ((buffer)[0x0b] & 0x80)
568 #define QETH_IDX_ACT_FUNC_LEVEL(buffer) (buffer + 0x10)
569 #define QETH_IDX_ACT_DATASET_NAME(buffer) (buffer + 0x16)
570 #define QETH_IDX_ACT_QDIO_DEV_CUA(buffer) (buffer + 0x1e)
571 #define QETH_IDX_ACT_QDIO_DEV_REALADDR(buffer) (buffer + 0x20)
572 #define QETH_IS_IDX_ACT_POS_REPLY(buffer) (((buffer)[0x08] & 3) == 2)
573 #define QETH_IDX_REPLY_LEVEL(buffer) (buffer + 0x12)
574 #define QETH_IDX_ACT_CAUSE_CODE(buffer) (buffer)[0x09]
575
576 #define PDU_ENCAPSULATION(buffer) \
577         (buffer + *(buffer + (*(buffer + 0x0b)) + \
578          *(buffer + *(buffer + 0x0b) + 0x11) + 0x07))
579
580 #define IS_IPA(buffer) \
581         ((buffer) && \
582          (*(buffer + ((*(buffer + 0x0b)) + 4)) == 0xc1))
583
584 #define ADDR_FRAME_TYPE_DIX 1
585 #define ADDR_FRAME_TYPE_802_3 2
586 #define ADDR_FRAME_TYPE_TR_WITHOUT_SR 0x10
587 #define ADDR_FRAME_TYPE_TR_WITH_SR 0x20
588
589 #endif