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