xref: /openbmc/linux/drivers/s390/net/qeth_core_mpc.h (revision e2c75e76)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  *    Copyright IBM Corp. 2007
4  *    Author(s): Frank Pavlic <fpavlic@de.ibm.com>,
5  *		 Thomas Spatzier <tspat@de.ibm.com>,
6  *		 Frank Blaschka <frank.blaschka@de.ibm.com>
7  */
8 
9 #ifndef __QETH_CORE_MPC_H__
10 #define __QETH_CORE_MPC_H__
11 
12 #include <asm/qeth.h>
13 #include <uapi/linux/if_ether.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 
30 #define QETH_TIMEOUT		(10 * HZ)
31 #define QETH_IPA_TIMEOUT	(45 * HZ)
32 #define QETH_IDX_COMMAND_SEQNO	0xffff0000
33 
34 #define QETH_CLEAR_CHANNEL_PARM	-10
35 #define QETH_HALT_CHANNEL_PARM	-11
36 #define QETH_RCD_PARM -12
37 
38 /*****************************************************************************/
39 /* IP Assist related definitions                                             */
40 /*****************************************************************************/
41 #define IPA_CMD_INITIATOR_HOST  0x00
42 #define IPA_CMD_INITIATOR_OSA   0x01
43 #define IPA_CMD_INITIATOR_HOST_REPLY  0x80
44 #define IPA_CMD_INITIATOR_OSA_REPLY   0x81
45 #define IPA_CMD_PRIM_VERSION_NO 0x01
46 
47 enum qeth_card_types {
48 	QETH_CARD_TYPE_OSD     = 1,
49 	QETH_CARD_TYPE_IQD     = 5,
50 	QETH_CARD_TYPE_OSN     = 6,
51 	QETH_CARD_TYPE_OSM     = 3,
52 	QETH_CARD_TYPE_OSX     = 2,
53 };
54 
55 #define QETH_MPC_DIFINFO_LEN_INDICATES_LINK_TYPE 0x18
56 /* only the first two bytes are looked at in qeth_get_cardname_short */
57 enum qeth_link_types {
58 	QETH_LINK_TYPE_FAST_ETH     = 0x01,
59 	QETH_LINK_TYPE_HSTR         = 0x02,
60 	QETH_LINK_TYPE_GBIT_ETH     = 0x03,
61 	QETH_LINK_TYPE_OSN          = 0x04,
62 	QETH_LINK_TYPE_10GBIT_ETH   = 0x10,
63 	QETH_LINK_TYPE_LANE_ETH100  = 0x81,
64 	QETH_LINK_TYPE_LANE_TR      = 0x82,
65 	QETH_LINK_TYPE_LANE_ETH1000 = 0x83,
66 	QETH_LINK_TYPE_LANE         = 0x88,
67 };
68 
69 /*
70  * Routing stuff
71  */
72 #define RESET_ROUTING_FLAG 0x10 /* indicate that routing type shall be set */
73 enum qeth_routing_types {
74 	/* TODO: set to bit flag used in IPA Command */
75 	NO_ROUTER		= 0,
76 	PRIMARY_ROUTER		= 1,
77 	SECONDARY_ROUTER	= 2,
78 	MULTICAST_ROUTER	= 3,
79 	PRIMARY_CONNECTOR	= 4,
80 	SECONDARY_CONNECTOR	= 5,
81 };
82 
83 /* IPA Commands */
84 enum qeth_ipa_cmds {
85 	IPA_CMD_STARTLAN		= 0x01,
86 	IPA_CMD_STOPLAN			= 0x02,
87 	IPA_CMD_SETVMAC			= 0x21,
88 	IPA_CMD_DELVMAC			= 0x22,
89 	IPA_CMD_SETGMAC			= 0x23,
90 	IPA_CMD_DELGMAC			= 0x24,
91 	IPA_CMD_SETVLAN			= 0x25,
92 	IPA_CMD_DELVLAN			= 0x26,
93 	IPA_CMD_VNICC			= 0x2a,
94 	IPA_CMD_SETBRIDGEPORT_OSA	= 0x2b,
95 	IPA_CMD_SETCCID			= 0x41,
96 	IPA_CMD_DELCCID			= 0x42,
97 	IPA_CMD_MODCCID			= 0x43,
98 	IPA_CMD_SETIP			= 0xb1,
99 	IPA_CMD_QIPASSIST		= 0xb2,
100 	IPA_CMD_SETASSPARMS		= 0xb3,
101 	IPA_CMD_SETIPM			= 0xb4,
102 	IPA_CMD_DELIPM			= 0xb5,
103 	IPA_CMD_SETRTG			= 0xb6,
104 	IPA_CMD_DELIP			= 0xb7,
105 	IPA_CMD_SETADAPTERPARMS		= 0xb8,
106 	IPA_CMD_SET_DIAG_ASS		= 0xb9,
107 	IPA_CMD_SETBRIDGEPORT_IQD	= 0xbe,
108 	IPA_CMD_CREATE_ADDR		= 0xc3,
109 	IPA_CMD_DESTROY_ADDR		= 0xc4,
110 	IPA_CMD_REGISTER_LOCAL_ADDR	= 0xd1,
111 	IPA_CMD_UNREGISTER_LOCAL_ADDR	= 0xd2,
112 	IPA_CMD_ADDRESS_CHANGE_NOTIF	= 0xd3,
113 	IPA_CMD_UNKNOWN			= 0x00
114 };
115 
116 enum qeth_ip_ass_cmds {
117 	IPA_CMD_ASS_START	= 0x0001,
118 	IPA_CMD_ASS_STOP	= 0x0002,
119 	IPA_CMD_ASS_CONFIGURE	= 0x0003,
120 	IPA_CMD_ASS_ENABLE	= 0x0004,
121 };
122 
123 enum qeth_arp_process_subcmds {
124 	IPA_CMD_ASS_ARP_SET_NO_ENTRIES	= 0x0003,
125 	IPA_CMD_ASS_ARP_QUERY_CACHE	= 0x0004,
126 	IPA_CMD_ASS_ARP_ADD_ENTRY	= 0x0005,
127 	IPA_CMD_ASS_ARP_REMOVE_ENTRY	= 0x0006,
128 	IPA_CMD_ASS_ARP_FLUSH_CACHE	= 0x0007,
129 	IPA_CMD_ASS_ARP_QUERY_INFO	= 0x0104,
130 	IPA_CMD_ASS_ARP_QUERY_STATS	= 0x0204,
131 };
132 
133 
134 /* Return Codes for IPA Commands
135  * according to OSA card Specs */
136 
137 enum qeth_ipa_return_codes {
138 	IPA_RC_SUCCESS			= 0x0000,
139 	IPA_RC_NOTSUPP			= 0x0001,
140 	IPA_RC_IP_TABLE_FULL		= 0x0002,
141 	IPA_RC_UNKNOWN_ERROR		= 0x0003,
142 	IPA_RC_UNSUPPORTED_COMMAND	= 0x0004,
143 	IPA_RC_TRACE_ALREADY_ACTIVE	= 0x0005,
144 	IPA_RC_INVALID_FORMAT		= 0x0006,
145 	IPA_RC_DUP_IPV6_REMOTE		= 0x0008,
146 	IPA_RC_SBP_IQD_NOT_CONFIGURED	= 0x000C,
147 	IPA_RC_DUP_IPV6_HOME		= 0x0010,
148 	IPA_RC_UNREGISTERED_ADDR	= 0x0011,
149 	IPA_RC_NO_ID_AVAILABLE		= 0x0012,
150 	IPA_RC_ID_NOT_FOUND		= 0x0013,
151 	IPA_RC_SBP_IQD_ANO_DEV_PRIMARY	= 0x0014,
152 	IPA_RC_SBP_IQD_CURRENT_SECOND	= 0x0018,
153 	IPA_RC_SBP_IQD_LIMIT_SECOND	= 0x001C,
154 	IPA_RC_INVALID_IP_VERSION	= 0x0020,
155 	IPA_RC_SBP_IQD_CURRENT_PRIMARY	= 0x0024,
156 	IPA_RC_LAN_FRAME_MISMATCH	= 0x0040,
157 	IPA_RC_SBP_IQD_NO_QDIO_QUEUES	= 0x00EB,
158 	IPA_RC_L2_UNSUPPORTED_CMD	= 0x2003,
159 	IPA_RC_L2_DUP_MAC		= 0x2005,
160 	IPA_RC_L2_ADDR_TABLE_FULL	= 0x2006,
161 	IPA_RC_L2_DUP_LAYER3_MAC	= 0x200a,
162 	IPA_RC_L2_GMAC_NOT_FOUND	= 0x200b,
163 	IPA_RC_L2_MAC_NOT_AUTH_BY_HYP	= 0x200c,
164 	IPA_RC_L2_MAC_NOT_AUTH_BY_ADP	= 0x200d,
165 	IPA_RC_L2_MAC_NOT_FOUND		= 0x2010,
166 	IPA_RC_L2_INVALID_VLAN_ID	= 0x2015,
167 	IPA_RC_L2_DUP_VLAN_ID		= 0x2016,
168 	IPA_RC_L2_VLAN_ID_NOT_FOUND	= 0x2017,
169 	IPA_RC_L2_VLAN_ID_NOT_ALLOWED	= 0x2050,
170 	IPA_RC_VNICC_VNICBP		= 0x20B0,
171 	IPA_RC_SBP_OSA_NOT_CONFIGURED	= 0x2B0C,
172 	IPA_RC_SBP_OSA_OS_MISMATCH	= 0x2B10,
173 	IPA_RC_SBP_OSA_ANO_DEV_PRIMARY	= 0x2B14,
174 	IPA_RC_SBP_OSA_CURRENT_SECOND	= 0x2B18,
175 	IPA_RC_SBP_OSA_LIMIT_SECOND	= 0x2B1C,
176 	IPA_RC_SBP_OSA_NOT_AUTHD_BY_ZMAN = 0x2B20,
177 	IPA_RC_SBP_OSA_CURRENT_PRIMARY	= 0x2B24,
178 	IPA_RC_SBP_OSA_NO_QDIO_QUEUES	= 0x2BEB,
179 	IPA_RC_DATA_MISMATCH		= 0xe001,
180 	IPA_RC_INVALID_MTU_SIZE		= 0xe002,
181 	IPA_RC_INVALID_LANTYPE		= 0xe003,
182 	IPA_RC_INVALID_LANNUM		= 0xe004,
183 	IPA_RC_DUPLICATE_IP_ADDRESS	= 0xe005,
184 	IPA_RC_IP_ADDR_TABLE_FULL	= 0xe006,
185 	IPA_RC_LAN_PORT_STATE_ERROR	= 0xe007,
186 	IPA_RC_SETIP_NO_STARTLAN	= 0xe008,
187 	IPA_RC_SETIP_ALREADY_RECEIVED	= 0xe009,
188 	IPA_RC_IP_ADDR_ALREADY_USED	= 0xe00a,
189 	IPA_RC_MC_ADDR_NOT_FOUND	= 0xe00b,
190 	IPA_RC_SETIP_INVALID_VERSION	= 0xe00d,
191 	IPA_RC_UNSUPPORTED_SUBCMD	= 0xe00e,
192 	IPA_RC_ARP_ASSIST_NO_ENABLE	= 0xe00f,
193 	IPA_RC_PRIMARY_ALREADY_DEFINED	= 0xe010,
194 	IPA_RC_SECOND_ALREADY_DEFINED	= 0xe011,
195 	IPA_RC_INVALID_SETRTG_INDICATOR	= 0xe012,
196 	IPA_RC_MC_ADDR_ALREADY_DEFINED	= 0xe013,
197 	IPA_RC_LAN_OFFLINE		= 0xe080,
198 	IPA_RC_VEPA_TO_VEB_TRANSITION	= 0xe090,
199 	IPA_RC_INVALID_IP_VERSION2	= 0xf001,
200 	IPA_RC_ENOMEM			= 0xfffe,
201 	IPA_RC_FFFF			= 0xffff
202 };
203 /* for VNIC Characteristics */
204 #define IPA_RC_VNICC_OOSEQ 0x0005
205 
206 /* for SET_DIAGNOSTIC_ASSIST */
207 #define IPA_RC_INVALID_SUBCMD		IPA_RC_IP_TABLE_FULL
208 #define IPA_RC_HARDWARE_AUTH_ERROR	IPA_RC_UNKNOWN_ERROR
209 
210 /* for SETBRIDGEPORT (double occupancies) */
211 #define IPA_RC_SBP_IQD_OS_MISMATCH	 IPA_RC_DUP_IPV6_HOME
212 #define IPA_RC_SBP_IQD_NOT_AUTHD_BY_ZMAN IPA_RC_INVALID_IP_VERSION
213 
214 /* IPA function flags; each flag marks availability of respective function */
215 enum qeth_ipa_funcs {
216 	IPA_ARP_PROCESSING      = 0x00000001L,
217 	IPA_INBOUND_CHECKSUM    = 0x00000002L,
218 	IPA_OUTBOUND_CHECKSUM   = 0x00000004L,
219 	/* RESERVED		= 0x00000008L,*/
220 	IPA_FILTERING           = 0x00000010L,
221 	IPA_IPV6                = 0x00000020L,
222 	IPA_MULTICASTING        = 0x00000040L,
223 	IPA_IP_REASSEMBLY       = 0x00000080L,
224 	IPA_QUERY_ARP_COUNTERS  = 0x00000100L,
225 	IPA_QUERY_ARP_ADDR_INFO = 0x00000200L,
226 	IPA_SETADAPTERPARMS     = 0x00000400L,
227 	IPA_VLAN_PRIO           = 0x00000800L,
228 	IPA_PASSTHRU            = 0x00001000L,
229 	IPA_FLUSH_ARP_SUPPORT   = 0x00002000L,
230 	IPA_FULL_VLAN           = 0x00004000L,
231 	IPA_INBOUND_PASSTHRU    = 0x00008000L,
232 	IPA_SOURCE_MAC          = 0x00010000L,
233 	IPA_OSA_MC_ROUTER       = 0x00020000L,
234 	IPA_QUERY_ARP_ASSIST	= 0x00040000L,
235 	IPA_INBOUND_TSO         = 0x00080000L,
236 	IPA_OUTBOUND_TSO        = 0x00100000L,
237 };
238 
239 /* SETIP/DELIP IPA Command: ***************************************************/
240 enum qeth_ipa_setdelip_flags {
241 	QETH_IPA_SETDELIP_DEFAULT          = 0x00L, /* default */
242 	QETH_IPA_SETIP_VIPA_FLAG           = 0x01L, /* no grat. ARP */
243 	QETH_IPA_SETIP_TAKEOVER_FLAG       = 0x02L, /* nofail on grat. ARP */
244 	QETH_IPA_DELIP_ADDR_2_B_TAKEN_OVER = 0x20L,
245 	QETH_IPA_DELIP_VIPA_FLAG           = 0x40L,
246 	QETH_IPA_DELIP_ADDR_NEEDS_SETIP    = 0x80L,
247 };
248 
249 /* SETADAPTER IPA Command: ****************************************************/
250 enum qeth_ipa_setadp_cmd {
251 	IPA_SETADP_QUERY_COMMANDS_SUPPORTED	= 0x00000001L,
252 	IPA_SETADP_ALTER_MAC_ADDRESS		= 0x00000002L,
253 	IPA_SETADP_ADD_DELETE_GROUP_ADDRESS	= 0x00000004L,
254 	IPA_SETADP_ADD_DELETE_FUNCTIONAL_ADDR	= 0x00000008L,
255 	IPA_SETADP_SET_ADDRESSING_MODE		= 0x00000010L,
256 	IPA_SETADP_SET_CONFIG_PARMS		= 0x00000020L,
257 	IPA_SETADP_SET_CONFIG_PARMS_EXTENDED	= 0x00000040L,
258 	IPA_SETADP_SET_BROADCAST_MODE		= 0x00000080L,
259 	IPA_SETADP_SEND_OSA_MESSAGE		= 0x00000100L,
260 	IPA_SETADP_SET_SNMP_CONTROL		= 0x00000200L,
261 	IPA_SETADP_QUERY_CARD_INFO		= 0x00000400L,
262 	IPA_SETADP_SET_PROMISC_MODE		= 0x00000800L,
263 	IPA_SETADP_SET_DIAG_ASSIST		= 0x00002000L,
264 	IPA_SETADP_SET_ACCESS_CONTROL		= 0x00010000L,
265 	IPA_SETADP_QUERY_OAT			= 0x00080000L,
266 	IPA_SETADP_QUERY_SWITCH_ATTRIBUTES	= 0x00100000L,
267 };
268 enum qeth_ipa_mac_ops {
269 	CHANGE_ADDR_READ_MAC		= 0,
270 	CHANGE_ADDR_REPLACE_MAC		= 1,
271 	CHANGE_ADDR_ADD_MAC		= 2,
272 	CHANGE_ADDR_DEL_MAC		= 4,
273 	CHANGE_ADDR_RESET_MAC		= 8,
274 };
275 enum qeth_ipa_addr_ops {
276 	CHANGE_ADDR_READ_ADDR		= 0,
277 	CHANGE_ADDR_ADD_ADDR		= 1,
278 	CHANGE_ADDR_DEL_ADDR		= 2,
279 	CHANGE_ADDR_FLUSH_ADDR_TABLE	= 4,
280 };
281 enum qeth_ipa_promisc_modes {
282 	SET_PROMISC_MODE_OFF		= 0,
283 	SET_PROMISC_MODE_ON		= 1,
284 };
285 enum qeth_ipa_isolation_modes {
286 	ISOLATION_MODE_NONE		= 0x00000000L,
287 	ISOLATION_MODE_FWD		= 0x00000001L,
288 	ISOLATION_MODE_DROP		= 0x00000002L,
289 };
290 enum qeth_ipa_set_access_mode_rc {
291 	SET_ACCESS_CTRL_RC_SUCCESS		= 0x0000,
292 	SET_ACCESS_CTRL_RC_NOT_SUPPORTED	= 0x0004,
293 	SET_ACCESS_CTRL_RC_ALREADY_NOT_ISOLATED	= 0x0008,
294 	SET_ACCESS_CTRL_RC_ALREADY_ISOLATED	= 0x0010,
295 	SET_ACCESS_CTRL_RC_NONE_SHARED_ADAPTER	= 0x0014,
296 	SET_ACCESS_CTRL_RC_ACTIVE_CHECKSUM_OFF	= 0x0018,
297 	SET_ACCESS_CTRL_RC_REFLREL_UNSUPPORTED	= 0x0022,
298 	SET_ACCESS_CTRL_RC_REFLREL_FAILED	= 0x0024,
299 	SET_ACCESS_CTRL_RC_REFLREL_DEACT_FAILED	= 0x0028,
300 };
301 enum qeth_card_info_card_type {
302 	CARD_INFO_TYPE_1G_COPPER_A	= 0x61,
303 	CARD_INFO_TYPE_1G_FIBRE_A	= 0x71,
304 	CARD_INFO_TYPE_10G_FIBRE_A	= 0x91,
305 	CARD_INFO_TYPE_1G_COPPER_B	= 0xb1,
306 	CARD_INFO_TYPE_1G_FIBRE_B	= 0xa1,
307 	CARD_INFO_TYPE_10G_FIBRE_B	= 0xc1,
308 };
309 enum qeth_card_info_port_mode {
310 	CARD_INFO_PORTM_HALFDUPLEX	= 0x0002,
311 	CARD_INFO_PORTM_FULLDUPLEX	= 0x0003,
312 };
313 enum qeth_card_info_port_speed {
314 	CARD_INFO_PORTS_10M		= 0x00000005,
315 	CARD_INFO_PORTS_100M		= 0x00000006,
316 	CARD_INFO_PORTS_1G		= 0x00000007,
317 	CARD_INFO_PORTS_10G		= 0x00000008,
318 };
319 
320 /* (SET)DELIP(M) IPA stuff ***************************************************/
321 struct qeth_ipacmd_setdelip4 {
322 	__u8   ip_addr[4];
323 	__u8   mask[4];
324 	__u32  flags;
325 } __attribute__ ((packed));
326 
327 struct qeth_ipacmd_setdelip6 {
328 	__u8   ip_addr[16];
329 	__u8   mask[16];
330 	__u32  flags;
331 } __attribute__ ((packed));
332 
333 struct qeth_ipacmd_setdelipm {
334 	__u8 mac[6];
335 	__u8 padding[2];
336 	__u8 ip6[12];
337 	__u8 ip4[4];
338 } __attribute__ ((packed));
339 
340 struct qeth_ipacmd_layer2setdelmac {
341 	__u32 mac_length;
342 	__u8 mac[6];
343 } __attribute__ ((packed));
344 
345 struct qeth_ipacmd_layer2setdelvlan {
346 	__u16 vlan_id;
347 } __attribute__ ((packed));
348 
349 
350 struct qeth_ipacmd_setassparms_hdr {
351 	__u32 assist_no;
352 	__u16 length;
353 	__u16 command_code;
354 	__u16 return_code;
355 	__u8 number_of_replies;
356 	__u8 seq_no;
357 } __attribute__((packed));
358 
359 struct qeth_arp_query_data {
360 	__u16 request_bits;
361 	__u16 reply_bits;
362 	__u32 no_entries;
363 	char data; /* only for replies */
364 } __attribute__((packed));
365 
366 /* used as parameter for arp_query reply */
367 struct qeth_arp_query_info {
368 	__u32 udata_len;
369 	__u16 mask_bits;
370 	__u32 udata_offset;
371 	__u32 no_entries;
372 	char *udata;
373 };
374 
375 /* IPA set assist segmentation bit definitions for receive and
376  * transmit checksum offloading.
377  */
378 enum qeth_ipa_checksum_bits {
379 	QETH_IPA_CHECKSUM_IP_HDR	= 0x0002,
380 	QETH_IPA_CHECKSUM_UDP		= 0x0008,
381 	QETH_IPA_CHECKSUM_TCP		= 0x0010,
382 	QETH_IPA_CHECKSUM_LP2LP		= 0x0020
383 };
384 
385 /* IPA Assist checksum offload reply layout. */
386 struct qeth_checksum_cmd {
387 	__u32 supported;
388 	__u32 enabled;
389 } __packed;
390 
391 /* SETASSPARMS IPA Command: */
392 struct qeth_ipacmd_setassparms {
393 	struct qeth_ipacmd_setassparms_hdr hdr;
394 	union {
395 		__u32 flags_32bit;
396 		struct qeth_checksum_cmd chksum;
397 		struct qeth_arp_cache_entry add_arp_entry;
398 		struct qeth_arp_query_data query_arp;
399 		__u8 ip[16];
400 	} data;
401 } __attribute__ ((packed));
402 
403 
404 /* SETRTG IPA Command:    ****************************************************/
405 struct qeth_set_routing {
406 	__u8 type;
407 };
408 
409 /* SETADAPTERPARMS IPA Command:    *******************************************/
410 struct qeth_query_cmds_supp {
411 	__u32 no_lantypes_supp;
412 	__u8 lan_type;
413 	__u8 reserved1[3];
414 	__u32 supported_cmds;
415 	__u8 reserved2[8];
416 } __attribute__ ((packed));
417 
418 struct qeth_change_addr {
419 	u32 cmd;
420 	u32 addr_size;
421 	u32 no_macs;
422 	u8 addr[ETH_ALEN];
423 };
424 
425 struct qeth_snmp_cmd {
426 	__u8  token[16];
427 	__u32 request;
428 	__u32 interface;
429 	__u32 returncode;
430 	__u32 firmwarelevel;
431 	__u32 seqno;
432 	__u8  data;
433 } __attribute__ ((packed));
434 
435 struct qeth_snmp_ureq_hdr {
436 	__u32   data_len;
437 	__u32   req_len;
438 	__u32   reserved1;
439 	__u32   reserved2;
440 } __attribute__ ((packed));
441 
442 struct qeth_snmp_ureq {
443 	struct qeth_snmp_ureq_hdr hdr;
444 	struct qeth_snmp_cmd cmd;
445 } __attribute__((packed));
446 
447 /* SET_ACCESS_CONTROL: same format for request and reply */
448 struct qeth_set_access_ctrl {
449 	__u32 subcmd_code;
450 	__u8 reserved[8];
451 } __attribute__((packed));
452 
453 struct qeth_query_oat {
454 	__u32 subcmd_code;
455 	__u8 reserved[12];
456 } __packed;
457 
458 struct qeth_qoat_priv {
459 	__u32 buffer_len;
460 	__u32 response_len;
461 	char *buffer;
462 };
463 
464 struct qeth_query_card_info {
465 	__u8	card_type;
466 	__u8	reserved1;
467 	__u16	port_mode;
468 	__u32	port_speed;
469 	__u32	reserved2;
470 };
471 
472 #define QETH_SWITCH_FORW_802_1		0x00000001
473 #define QETH_SWITCH_FORW_REFL_RELAY	0x00000002
474 #define QETH_SWITCH_CAP_RTE		0x00000004
475 #define QETH_SWITCH_CAP_ECP		0x00000008
476 #define QETH_SWITCH_CAP_VDP		0x00000010
477 
478 struct qeth_query_switch_attributes {
479 	__u8  version;
480 	__u8  reserved1;
481 	__u16 reserved2;
482 	__u32 capabilities;
483 	__u32 settings;
484 	__u8  reserved3[8];
485 };
486 
487 struct qeth_ipacmd_setadpparms_hdr {
488 	__u32 supp_hw_cmds;
489 	__u32 reserved1;
490 	__u16 cmdlength;
491 	__u16 reserved2;
492 	__u32 command_code;
493 	__u16 return_code;
494 	__u8  used_total;
495 	__u8  seq_no;
496 	__u32 reserved3;
497 } __attribute__ ((packed));
498 
499 struct qeth_ipacmd_setadpparms {
500 	struct qeth_ipacmd_setadpparms_hdr hdr;
501 	union {
502 		struct qeth_query_cmds_supp query_cmds_supp;
503 		struct qeth_change_addr change_addr;
504 		struct qeth_snmp_cmd snmp;
505 		struct qeth_set_access_ctrl set_access_ctrl;
506 		struct qeth_query_oat query_oat;
507 		struct qeth_query_card_info card_info;
508 		struct qeth_query_switch_attributes query_switch_attributes;
509 		__u32 mode;
510 	} data;
511 } __attribute__ ((packed));
512 
513 /* CREATE_ADDR IPA Command:    ***********************************************/
514 struct qeth_create_destroy_address {
515 	__u8 unique_id[8];
516 } __attribute__ ((packed));
517 
518 /* SET DIAGNOSTIC ASSIST IPA Command:	 *************************************/
519 
520 enum qeth_diags_cmds {
521 	QETH_DIAGS_CMD_QUERY	= 0x0001,
522 	QETH_DIAGS_CMD_TRAP	= 0x0002,
523 	QETH_DIAGS_CMD_TRACE	= 0x0004,
524 	QETH_DIAGS_CMD_NOLOG	= 0x0008,
525 	QETH_DIAGS_CMD_DUMP	= 0x0010,
526 };
527 
528 enum qeth_diags_trace_types {
529 	QETH_DIAGS_TYPE_HIPERSOCKET	= 0x02,
530 };
531 
532 enum qeth_diags_trace_cmds {
533 	QETH_DIAGS_CMD_TRACE_ENABLE	= 0x0001,
534 	QETH_DIAGS_CMD_TRACE_DISABLE	= 0x0002,
535 	QETH_DIAGS_CMD_TRACE_MODIFY	= 0x0004,
536 	QETH_DIAGS_CMD_TRACE_REPLACE	= 0x0008,
537 	QETH_DIAGS_CMD_TRACE_QUERY	= 0x0010,
538 };
539 
540 enum qeth_diags_trap_action {
541 	QETH_DIAGS_TRAP_ARM	= 0x01,
542 	QETH_DIAGS_TRAP_DISARM	= 0x02,
543 	QETH_DIAGS_TRAP_CAPTURE = 0x04,
544 };
545 
546 struct qeth_ipacmd_diagass {
547 	__u32  host_tod2;
548 	__u32:32;
549 	__u16  subcmd_len;
550 	__u16:16;
551 	__u32  subcmd;
552 	__u8   type;
553 	__u8   action;
554 	__u16  options;
555 	__u32  ext;
556 	__u8   cdata[64];
557 } __attribute__ ((packed));
558 
559 /* VNIC Characteristics IPA Command: *****************************************/
560 /* IPA commands/sub commands for VNICC */
561 #define IPA_VNICC_QUERY_CHARS		0x00000000L
562 #define IPA_VNICC_QUERY_CMDS		0x00000001L
563 #define IPA_VNICC_ENABLE		0x00000002L
564 #define IPA_VNICC_DISABLE		0x00000004L
565 #define IPA_VNICC_SET_TIMEOUT		0x00000008L
566 #define IPA_VNICC_GET_TIMEOUT		0x00000010L
567 
568 /* VNICC flags */
569 #define QETH_VNICC_FLOODING		0x80000000
570 #define QETH_VNICC_MCAST_FLOODING	0x40000000
571 #define QETH_VNICC_LEARNING		0x20000000
572 #define QETH_VNICC_TAKEOVER_SETVMAC	0x10000000
573 #define QETH_VNICC_TAKEOVER_LEARNING	0x08000000
574 #define QETH_VNICC_BRIDGE_INVISIBLE	0x04000000
575 #define QETH_VNICC_RX_BCAST		0x02000000
576 
577 /* VNICC default values */
578 #define QETH_VNICC_ALL			0xff000000
579 #define QETH_VNICC_DEFAULT		QETH_VNICC_RX_BCAST
580 /* default VNICC timeout in seconds */
581 #define QETH_VNICC_DEFAULT_TIMEOUT	600
582 
583 /* VNICC header */
584 struct qeth_ipacmd_vnicc_hdr {
585 	u32 sup;
586 	u32 cur;
587 };
588 
589 /* VNICC sub command header */
590 struct qeth_vnicc_sub_hdr {
591 	u16 data_length;
592 	u16 reserved;
593 	u32 sub_command;
594 };
595 
596 /* query supported commands for VNIC characteristic */
597 struct qeth_vnicc_query_cmds {
598 	u32 vnic_char;
599 	u32 sup_cmds;
600 };
601 
602 /* enable/disable VNIC characteristic */
603 struct qeth_vnicc_set_char {
604 	u32 vnic_char;
605 };
606 
607 /* get/set timeout for VNIC characteristic */
608 struct qeth_vnicc_getset_timeout {
609 	u32 vnic_char;
610 	u32 timeout;
611 };
612 
613 /* complete VNICC IPA command message */
614 struct qeth_ipacmd_vnicc {
615 	struct qeth_ipacmd_vnicc_hdr hdr;
616 	struct qeth_vnicc_sub_hdr sub_hdr;
617 	union {
618 		struct qeth_vnicc_query_cmds query_cmds;
619 		struct qeth_vnicc_set_char set_char;
620 		struct qeth_vnicc_getset_timeout getset_timeout;
621 	};
622 };
623 
624 /* SETBRIDGEPORT IPA Command:	 *********************************************/
625 enum qeth_ipa_sbp_cmd {
626 	IPA_SBP_QUERY_COMMANDS_SUPPORTED	= 0x00000000L,
627 	IPA_SBP_RESET_BRIDGE_PORT_ROLE		= 0x00000001L,
628 	IPA_SBP_SET_PRIMARY_BRIDGE_PORT		= 0x00000002L,
629 	IPA_SBP_SET_SECONDARY_BRIDGE_PORT	= 0x00000004L,
630 	IPA_SBP_QUERY_BRIDGE_PORTS		= 0x00000008L,
631 	IPA_SBP_BRIDGE_PORT_STATE_CHANGE	= 0x00000010L,
632 };
633 
634 struct net_if_token {
635 	__u16 devnum;
636 	__u8 cssid;
637 	__u8 iid;
638 	__u8 ssid;
639 	__u8 chpid;
640 	__u16 chid;
641 } __packed;
642 
643 struct mac_addr_lnid {
644 	__u8 mac[6];
645 	__u16 lnid;
646 } __packed;
647 
648 struct qeth_ipacmd_sbp_hdr {
649 	__u32 supported_sbp_cmds;
650 	__u32 enabled_sbp_cmds;
651 	__u16 cmdlength;
652 	__u16 reserved1;
653 	__u32 command_code;
654 	__u16 return_code;
655 	__u8  used_total;
656 	__u8  seq_no;
657 	__u32 reserved2;
658 } __packed;
659 
660 struct qeth_sbp_query_cmds_supp {
661 	__u32 supported_cmds;
662 	__u32 reserved;
663 } __packed;
664 
665 struct qeth_sbp_reset_role {
666 } __packed;
667 
668 struct qeth_sbp_set_primary {
669 	struct net_if_token token;
670 } __packed;
671 
672 struct qeth_sbp_set_secondary {
673 } __packed;
674 
675 struct qeth_sbp_port_entry {
676 		__u8 role;
677 		__u8 state;
678 		__u8 reserved1;
679 		__u8 reserved2;
680 		struct net_if_token token;
681 } __packed;
682 
683 struct qeth_sbp_query_ports {
684 	__u8 primary_bp_supported;
685 	__u8 secondary_bp_supported;
686 	__u8 num_entries;
687 	__u8 entry_length;
688 	struct qeth_sbp_port_entry entry[];
689 } __packed;
690 
691 struct qeth_sbp_state_change {
692 	__u8 primary_bp_supported;
693 	__u8 secondary_bp_supported;
694 	__u8 num_entries;
695 	__u8 entry_length;
696 	struct qeth_sbp_port_entry entry[];
697 } __packed;
698 
699 struct qeth_ipacmd_setbridgeport {
700 	struct qeth_ipacmd_sbp_hdr hdr;
701 	union {
702 		struct qeth_sbp_query_cmds_supp query_cmds_supp;
703 		struct qeth_sbp_reset_role reset_role;
704 		struct qeth_sbp_set_primary set_primary;
705 		struct qeth_sbp_set_secondary set_secondary;
706 		struct qeth_sbp_query_ports query_ports;
707 		struct qeth_sbp_state_change state_change;
708 	} data;
709 } __packed;
710 
711 /* ADDRESS_CHANGE_NOTIFICATION adapter-initiated "command" *******************/
712 /* Bitmask for entry->change_code. Both bits may be raised.		     */
713 enum qeth_ipa_addr_change_code {
714 	IPA_ADDR_CHANGE_CODE_VLANID		= 0x01,
715 	IPA_ADDR_CHANGE_CODE_MACADDR		= 0x02,
716 	IPA_ADDR_CHANGE_CODE_REMOVAL		= 0x80,	/* else addition */
717 };
718 
719 struct qeth_ipacmd_addr_change_entry {
720 	struct net_if_token token;
721 	struct mac_addr_lnid addr_lnid;
722 	__u8 change_code;
723 	__u8 reserved1;
724 	__u16 reserved2;
725 } __packed;
726 
727 struct qeth_ipacmd_addr_change {
728 	__u8 lost_event_mask;
729 	__u8 reserved;
730 	__u16 num_entries;
731 	struct qeth_ipacmd_addr_change_entry entry[];
732 } __packed;
733 
734 /* Header for each IPA command */
735 struct qeth_ipacmd_hdr {
736 	__u8   command;
737 	__u8   initiator;
738 	__u16  seqno;
739 	__u16  return_code;
740 	__u8   adapter_type;
741 	__u8   rel_adapter_no;
742 	__u8   prim_version_no;
743 	__u8   param_count;
744 	__u16  prot_version;
745 	__u32  ipa_supported;
746 	__u32  ipa_enabled;
747 } __attribute__ ((packed));
748 
749 /* The IPA command itself */
750 struct qeth_ipa_cmd {
751 	struct qeth_ipacmd_hdr hdr;
752 	union {
753 		struct qeth_ipacmd_setdelip4		setdelip4;
754 		struct qeth_ipacmd_setdelip6		setdelip6;
755 		struct qeth_ipacmd_setdelipm		setdelipm;
756 		struct qeth_ipacmd_setassparms		setassparms;
757 		struct qeth_ipacmd_layer2setdelmac	setdelmac;
758 		struct qeth_ipacmd_layer2setdelvlan	setdelvlan;
759 		struct qeth_create_destroy_address	create_destroy_addr;
760 		struct qeth_ipacmd_setadpparms		setadapterparms;
761 		struct qeth_set_routing			setrtg;
762 		struct qeth_ipacmd_diagass		diagass;
763 		struct qeth_ipacmd_setbridgeport	sbp;
764 		struct qeth_ipacmd_addr_change		addrchange;
765 		struct qeth_ipacmd_vnicc		vnicc;
766 	} data;
767 } __attribute__ ((packed));
768 
769 /*
770  * special command for ARP processing.
771  * this is not included in setassparms command before, because we get
772  * problem with the size of struct qeth_ipacmd_setassparms otherwise
773  */
774 enum qeth_ipa_arp_return_codes {
775 	QETH_IPA_ARP_RC_SUCCESS      = 0x0000,
776 	QETH_IPA_ARP_RC_FAILED       = 0x0001,
777 	QETH_IPA_ARP_RC_NOTSUPP      = 0x0002,
778 	QETH_IPA_ARP_RC_OUT_OF_RANGE = 0x0003,
779 	QETH_IPA_ARP_RC_Q_NOTSUPP    = 0x0004,
780 	QETH_IPA_ARP_RC_Q_NO_DATA    = 0x0008,
781 };
782 
783 extern char *qeth_get_ipa_msg(enum qeth_ipa_return_codes rc);
784 extern char *qeth_get_ipa_cmd_name(enum qeth_ipa_cmds cmd);
785 
786 #define QETH_SETASS_BASE_LEN (sizeof(struct qeth_ipacmd_hdr) + \
787 			       sizeof(struct qeth_ipacmd_setassparms_hdr))
788 #define QETH_IPA_ARP_DATA_POS(buffer) (buffer + IPA_PDU_HEADER_SIZE + \
789 				       QETH_SETASS_BASE_LEN)
790 #define QETH_SETADP_BASE_LEN (sizeof(struct qeth_ipacmd_hdr) + \
791 			      sizeof(struct qeth_ipacmd_setadpparms_hdr))
792 #define QETH_SNMP_SETADP_CMDLENGTH 16
793 
794 #define QETH_ARP_DATA_SIZE 3968
795 #define QETH_ARP_CMD_LEN (QETH_ARP_DATA_SIZE + 8)
796 /* Helper functions */
797 #define IS_IPA_REPLY(cmd) ((cmd->hdr.initiator == IPA_CMD_INITIATOR_HOST) || \
798 			   (cmd->hdr.initiator == IPA_CMD_INITIATOR_OSA_REPLY))
799 
800 /*****************************************************************************/
801 /* END OF   IP Assist related definitions                                    */
802 /*****************************************************************************/
803 
804 
805 extern unsigned char WRITE_CCW[];
806 extern unsigned char READ_CCW[];
807 
808 extern unsigned char CM_ENABLE[];
809 #define CM_ENABLE_SIZE 0x63
810 #define QETH_CM_ENABLE_ISSUER_RM_TOKEN(buffer) (buffer + 0x2c)
811 #define QETH_CM_ENABLE_FILTER_TOKEN(buffer) (buffer + 0x53)
812 #define QETH_CM_ENABLE_USER_DATA(buffer) (buffer + 0x5b)
813 
814 #define QETH_CM_ENABLE_RESP_FILTER_TOKEN(buffer) \
815 		(PDU_ENCAPSULATION(buffer) + 0x13)
816 
817 
818 extern unsigned char CM_SETUP[];
819 #define CM_SETUP_SIZE 0x64
820 #define QETH_CM_SETUP_DEST_ADDR(buffer) (buffer + 0x2c)
821 #define QETH_CM_SETUP_CONNECTION_TOKEN(buffer) (buffer + 0x51)
822 #define QETH_CM_SETUP_FILTER_TOKEN(buffer) (buffer + 0x5a)
823 
824 #define QETH_CM_SETUP_RESP_DEST_ADDR(buffer) \
825 		(PDU_ENCAPSULATION(buffer) + 0x1a)
826 
827 extern unsigned char ULP_ENABLE[];
828 #define ULP_ENABLE_SIZE 0x6b
829 #define QETH_ULP_ENABLE_LINKNUM(buffer) (buffer + 0x61)
830 #define QETH_ULP_ENABLE_DEST_ADDR(buffer) (buffer + 0x2c)
831 #define QETH_ULP_ENABLE_FILTER_TOKEN(buffer) (buffer + 0x53)
832 #define QETH_ULP_ENABLE_PORTNAME_AND_LL(buffer) (buffer + 0x62)
833 #define QETH_ULP_ENABLE_RESP_FILTER_TOKEN(buffer) \
834 		(PDU_ENCAPSULATION(buffer) + 0x13)
835 #define QETH_ULP_ENABLE_RESP_MAX_MTU(buffer) \
836 		(PDU_ENCAPSULATION(buffer) + 0x1f)
837 #define QETH_ULP_ENABLE_RESP_DIFINFO_LEN(buffer) \
838 		(PDU_ENCAPSULATION(buffer) + 0x17)
839 #define QETH_ULP_ENABLE_RESP_LINK_TYPE(buffer) \
840 		(PDU_ENCAPSULATION(buffer) + 0x2b)
841 /* Layer 2 definitions */
842 #define QETH_PROT_LAYER2 0x08
843 #define QETH_PROT_TCPIP  0x03
844 #define QETH_PROT_OSN2   0x0a
845 #define QETH_ULP_ENABLE_PROT_TYPE(buffer) (buffer + 0x50)
846 #define QETH_IPA_CMD_PROT_TYPE(buffer) (buffer + 0x19)
847 
848 extern unsigned char ULP_SETUP[];
849 #define ULP_SETUP_SIZE 0x6c
850 #define QETH_ULP_SETUP_DEST_ADDR(buffer) (buffer + 0x2c)
851 #define QETH_ULP_SETUP_CONNECTION_TOKEN(buffer) (buffer + 0x51)
852 #define QETH_ULP_SETUP_FILTER_TOKEN(buffer) (buffer + 0x5a)
853 #define QETH_ULP_SETUP_CUA(buffer) (buffer + 0x68)
854 #define QETH_ULP_SETUP_REAL_DEVADDR(buffer) (buffer + 0x6a)
855 
856 #define QETH_ULP_SETUP_RESP_CONNECTION_TOKEN(buffer) \
857 		(PDU_ENCAPSULATION(buffer) + 0x1a)
858 
859 
860 extern unsigned char DM_ACT[];
861 #define DM_ACT_SIZE 0x55
862 #define QETH_DM_ACT_DEST_ADDR(buffer) (buffer + 0x2c)
863 #define QETH_DM_ACT_CONNECTION_TOKEN(buffer) (buffer + 0x51)
864 
865 
866 
867 #define QETH_TRANSPORT_HEADER_SEQ_NO(buffer) (buffer + 4)
868 #define QETH_PDU_HEADER_SEQ_NO(buffer) (buffer + 0x1c)
869 #define QETH_PDU_HEADER_ACK_SEQ_NO(buffer) (buffer + 0x20)
870 
871 extern unsigned char IDX_ACTIVATE_READ[];
872 extern unsigned char IDX_ACTIVATE_WRITE[];
873 
874 #define IDX_ACTIVATE_SIZE	0x22
875 #define QETH_IDX_ACT_PNO(buffer) (buffer+0x0b)
876 #define QETH_IDX_ACT_ISSUER_RM_TOKEN(buffer) (buffer + 0x0c)
877 #define QETH_IDX_NO_PORTNAME_REQUIRED(buffer) ((buffer)[0x0b] & 0x80)
878 #define QETH_IDX_ACT_FUNC_LEVEL(buffer) (buffer + 0x10)
879 #define QETH_IDX_ACT_DATASET_NAME(buffer) (buffer + 0x16)
880 #define QETH_IDX_ACT_QDIO_DEV_CUA(buffer) (buffer + 0x1e)
881 #define QETH_IDX_ACT_QDIO_DEV_REALADDR(buffer) (buffer + 0x20)
882 #define QETH_IS_IDX_ACT_POS_REPLY(buffer) (((buffer)[0x08] & 3) == 2)
883 #define QETH_IDX_REPLY_LEVEL(buffer) (buffer + 0x12)
884 #define QETH_IDX_ACT_CAUSE_CODE(buffer) (buffer)[0x09]
885 #define QETH_IDX_ACT_ERR_EXCL		0x19
886 #define QETH_IDX_ACT_ERR_AUTH		0x1E
887 #define QETH_IDX_ACT_ERR_AUTH_USER	0x20
888 
889 #define PDU_ENCAPSULATION(buffer) \
890 	(buffer + *(buffer + (*(buffer + 0x0b)) + \
891 	 *(buffer + *(buffer + 0x0b) + 0x11) + 0x07))
892 
893 #define IS_IPA(buffer) \
894 	((buffer) && \
895 	 (*(buffer + ((*(buffer + 0x0b)) + 4)) == 0xc1))
896 
897 #endif
898