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