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