summaryrefslogtreecommitdiff
path: root/drivers/s390/net/qeth_core_mpc.c
blob: 7b55768a959201070ada6cbf81590390d1c3a172 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
/*
 *    Copyright IBM Corp. 2007
 *    Author(s): Frank Pavlic <fpavlic@de.ibm.com>,
 *		 Thomas Spatzier <tspat@de.ibm.com>,
 *		 Frank Blaschka <frank.blaschka@de.ibm.com>
 */

#include <linux/module.h>
#include <asm/cio.h>
#include "qeth_core_mpc.h"

unsigned char IDX_ACTIVATE_READ[] = {
	0x00, 0x00, 0x80, 0x00,  0x00, 0x00, 0x00, 0x00,
	0x19, 0x01, 0x01, 0x80,  0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0xc8, 0xc1,
	0xd3, 0xd3, 0xd6, 0xd3,  0xc5, 0x40, 0x00, 0x00,
	0x00, 0x00
};

unsigned char IDX_ACTIVATE_WRITE[] = {
	0x00, 0x00, 0x80, 0x00,  0x00, 0x00, 0x00, 0x00,
	0x15, 0x01, 0x01, 0x80,  0x00, 0x00, 0x00, 0x00,
	0xff, 0xff, 0x00, 0x00,  0x00, 0x00, 0xc8, 0xc1,
	0xd3, 0xd3, 0xd6, 0xd3,  0xc5, 0x40, 0x00, 0x00,
	0x00, 0x00
};

unsigned char CM_ENABLE[] = {
	0x00, 0xe0, 0x00, 0x00,  0x00, 0x00, 0x00, 0x01,
	0x00, 0x00, 0x00, 0x14,  0x00, 0x00, 0x00, 0x63,
	0x10, 0x00, 0x00, 0x01,
	0x00, 0x00, 0x00, 0x00,
	0x81, 0x7e, 0x00, 0x01,  0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00,  0x00, 0x24, 0x00, 0x23,
	0x00, 0x00, 0x23, 0x05,  0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
	0x01, 0x00, 0x00, 0x23,  0x00, 0x00, 0x00, 0x40,
	0x00, 0x0c, 0x41, 0x02,  0x00, 0x17, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00,
	0x00, 0x0b, 0x04, 0x01,
	0x7e, 0x04, 0x05, 0x00,  0x01, 0x01, 0x0f,
	0x00,
	0x0c, 0x04, 0x02, 0xff,  0xff, 0xff, 0xff, 0xff,
	0xff, 0xff, 0xff
};

unsigned char CM_SETUP[] = {
	0x00, 0xe0, 0x00, 0x00,  0x00, 0x00, 0x00, 0x02,
	0x00, 0x00, 0x00, 0x14,  0x00, 0x00, 0x00, 0x64,
	0x10, 0x00, 0x00, 0x01,
	0x00, 0x00, 0x00, 0x00,
	0x81, 0x7e, 0x00, 0x01,  0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00,  0x00, 0x24, 0x00, 0x24,
	0x00, 0x00, 0x24, 0x05,  0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
	0x01, 0x00, 0x00, 0x24,  0x00, 0x00, 0x00, 0x40,
	0x00, 0x0c, 0x41, 0x04,  0x00, 0x18, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00,
	0x00, 0x09, 0x04, 0x04,
	0x05, 0x00, 0x01, 0x01,  0x11,
	0x00, 0x09, 0x04,
	0x05, 0x05, 0x00, 0x00,  0x00, 0x00,
	0x00, 0x06,
	0x04, 0x06, 0xc8, 0x00
};

unsigned char ULP_ENABLE[] = {
	0x00, 0xe0, 0x00, 0x00,  0x00, 0x00, 0x00, 0x03,
	0x00, 0x00, 0x00, 0x14,  0x00, 0x00, 0x00, 0x6b,
	0x10, 0x00, 0x00, 0x01,
	0x00, 0x00, 0x00, 0x00,
	0x41, 0x7e, 0x00, 0x01,  0x00, 0x00, 0x00, 0x01,
	0x00, 0x00, 0x00, 0x00,  0x00, 0x24, 0x00, 0x2b,
	0x00, 0x00, 0x2b, 0x05,  0x20, 0x01, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
	0x01, 0x00, 0x00, 0x2b,  0x00, 0x00, 0x00, 0x40,
	0x00, 0x0c, 0x41, 0x02,  0x00, 0x1f, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00,
	0x00, 0x0b, 0x04, 0x01,
	0x03, 0x04, 0x05, 0x00,  0x01, 0x01, 0x12,
	0x00,
	0x14, 0x04, 0x0a, 0x00,  0x20, 0x00, 0x00, 0xff,
	0xff, 0x00, 0x08, 0xc8,  0xe8, 0xc4, 0xf1, 0xc7,
	0xf1, 0x00, 0x00
};

unsigned char ULP_SETUP[] = {
	0x00, 0xe0, 0x00, 0x00,  0x00, 0x00, 0x00, 0x04,
	0x00, 0x00, 0x00, 0x14,  0x00, 0x00, 0x00, 0x6c,
	0x10, 0x00, 0x00, 0x01,
	0x00, 0x00, 0x00, 0x00,
	0x41, 0x7e, 0x00, 0x01,  0x00, 0x00, 0x00, 0x02,
	0x00, 0x00, 0x00, 0x01,  0x00, 0x24, 0x00, 0x2c,
	0x00, 0x00, 0x2c, 0x05,  0x20, 0x01, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
	0x01, 0x00, 0x00, 0x2c,  0x00, 0x00, 0x00, 0x40,
	0x00, 0x0c, 0x41, 0x04,  0x00, 0x20, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00,
	0x00, 0x09, 0x04, 0x04,
	0x05, 0x00, 0x01, 0x01,  0x14,
	0x00, 0x09, 0x04,
	0x05, 0x05, 0x30, 0x01,  0x00, 0x00,
	0x00, 0x06,
	0x04, 0x06, 0x40, 0x00,
	0x00, 0x08, 0x04, 0x0b,
	0x00, 0x00, 0x00, 0x00
};

unsigned char DM_ACT[] = {
	0x00, 0xe0, 0x00, 0x00,  0x00, 0x00, 0x00, 0x05,
	0x00, 0x00, 0x00, 0x14,  0x00, 0x00, 0x00, 0x55,
	0x10, 0x00, 0x00, 0x01,
	0x00, 0x00, 0x00, 0x00,
	0x41, 0x7e, 0x00, 0x01,  0x00, 0x00, 0x00, 0x03,
	0x00, 0x00, 0x00, 0x02,  0x00, 0x24, 0x00, 0x15,
	0x00, 0x00, 0x2c, 0x05,  0x20, 0x01, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
	0x01, 0x00, 0x00, 0x15,  0x00, 0x00, 0x00, 0x40,
	0x00, 0x0c, 0x43, 0x60,  0x00, 0x09, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00,
	0x00, 0x09, 0x04, 0x04,
	0x05, 0x40, 0x01, 0x01,  0x00
};

unsigned char IPA_PDU_HEADER[] = {
	0x00, 0xe0, 0x00, 0x00,  0x77, 0x77, 0x77, 0x77,
	0x00, 0x00, 0x00, 0x14,  0x00, 0x00,
		(IPA_PDU_HEADER_SIZE+sizeof(struct qeth_ipa_cmd)) / 256,
		(IPA_PDU_HEADER_SIZE+sizeof(struct qeth_ipa_cmd)) % 256,
	0x10, 0x00, 0x00, 0x01,  0x00, 0x00, 0x00, 0x00,
	0xc1, 0x03, 0x00, 0x01,  0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00,  0x00, 0x24,
		sizeof(struct qeth_ipa_cmd) / 256,
		sizeof(struct qeth_ipa_cmd) % 256,
	0x00,
		sizeof(struct qeth_ipa_cmd) / 256,
		sizeof(struct qeth_ipa_cmd) % 256,
	0x05,
	0x77, 0x77, 0x77, 0x77,
	0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
	0x01, 0x00,
		sizeof(struct qeth_ipa_cmd) / 256,
		sizeof(struct qeth_ipa_cmd) % 256,
	0x00, 0x00, 0x00, 0x40,
};
EXPORT_SYMBOL_GPL(IPA_PDU_HEADER);

unsigned char WRITE_CCW[] = {
	0x01, CCW_FLAG_SLI, 0, 0,
	0, 0, 0, 0
};

unsigned char READ_CCW[] = {
	0x02, CCW_FLAG_SLI, 0, 0,
	0, 0, 0, 0
};


struct ipa_rc_msg {
	enum qeth_ipa_return_codes rc;
	char *msg;
};

static struct ipa_rc_msg qeth_ipa_rc_msg[] = {
	{IPA_RC_SUCCESS,		"success"},
	{IPA_RC_NOTSUPP,		"Command not supported"},
	{IPA_RC_IP_TABLE_FULL,		"Add Addr IP Table Full - ipv6"},
	{IPA_RC_UNKNOWN_ERROR,		"IPA command failed - reason unknown"},
	{IPA_RC_UNSUPPORTED_COMMAND,	"Command not supported"},
	{IPA_RC_DUP_IPV6_REMOTE, "ipv6 address already registered remote"},
	{IPA_RC_DUP_IPV6_HOME,		"ipv6 address already registered"},
	{IPA_RC_UNREGISTERED_ADDR,	"Address not registered"},
	{IPA_RC_NO_ID_AVAILABLE,	"No identifiers available"},
	{IPA_RC_ID_NOT_FOUND,		"Identifier not found"},
	{IPA_RC_INVALID_IP_VERSION,	"IP version incorrect"},
	{IPA_RC_LAN_FRAME_MISMATCH,	"LAN and frame mismatch"},
	{IPA_RC_L2_UNSUPPORTED_CMD,	"Unsupported layer 2 command"},
	{IPA_RC_L2_DUP_MAC,		"Duplicate MAC address"},
	{IPA_RC_L2_ADDR_TABLE_FULL,	"Layer2 address table full"},
	{IPA_RC_L2_DUP_LAYER3_MAC,	"Duplicate with layer 3 MAC"},
	{IPA_RC_L2_GMAC_NOT_FOUND,	"GMAC not found"},
	{IPA_RC_L2_MAC_NOT_AUTH_BY_HYP,	"L2 mac not authorized by hypervisor"},
	{IPA_RC_L2_MAC_NOT_AUTH_BY_ADP,	"L2 mac not authorized by adapter"},
	{IPA_RC_L2_MAC_NOT_FOUND,	"L2 mac address not found"},
	{IPA_RC_L2_INVALID_VLAN_ID,	"L2 invalid vlan id"},
	{IPA_RC_L2_DUP_VLAN_ID,		"L2 duplicate vlan id"},
	{IPA_RC_L2_VLAN_ID_NOT_FOUND,	"L2 vlan id not found"},
	{IPA_RC_DATA_MISMATCH,		"Data field mismatch (v4/v6 mixed)"},
	{IPA_RC_INVALID_MTU_SIZE,	"Invalid MTU size"},
	{IPA_RC_INVALID_LANTYPE,	"Invalid LAN type"},
	{IPA_RC_INVALID_LANNUM,		"Invalid LAN num"},
	{IPA_RC_DUPLICATE_IP_ADDRESS,	"Address already registered"},
	{IPA_RC_IP_ADDR_TABLE_FULL,	"IP address table full"},
	{IPA_RC_LAN_PORT_STATE_ERROR,	"LAN port state error"},
	{IPA_RC_SETIP_NO_STARTLAN,	"Setip no startlan received"},
	{IPA_RC_SETIP_ALREADY_RECEIVED,	"Setip already received"},
	{IPA_RC_IP_ADDR_ALREADY_USED,	"IP address already in use on LAN"},
	{IPA_RC_MC_ADDR_NOT_FOUND,	"Multicast address not found"},
	{IPA_RC_SETIP_INVALID_VERSION,	"SETIP invalid IP version"},
	{IPA_RC_UNSUPPORTED_SUBCMD,	"Unsupported assist subcommand"},
	{IPA_RC_ARP_ASSIST_NO_ENABLE,	"Only partial success, no enable"},
	{IPA_RC_PRIMARY_ALREADY_DEFINED, "Primary already defined"},
	{IPA_RC_SECOND_ALREADY_DEFINED,	"Secondary already defined"},
	{IPA_RC_INVALID_SETRTG_INDICATOR, "Invalid SETRTG indicator"},
	{IPA_RC_MC_ADDR_ALREADY_DEFINED, "Multicast address already defined"},
	{IPA_RC_LAN_OFFLINE,		"STRTLAN_LAN_DISABLED - LAN offline"},
	{IPA_RC_VEPA_TO_VEB_TRANSITION,	"Adj. switch disabled port mode RR"},
	{IPA_RC_INVALID_IP_VERSION2,	"Invalid IP version"},
	{IPA_RC_ENOMEM,			"Memory problem"},
	{IPA_RC_FFFF,			"Unknown Error"}
};



char *qeth_get_ipa_msg(enum qeth_ipa_return_codes rc)
{
	int x = 0;
	qeth_ipa_rc_msg[sizeof(qeth_ipa_rc_msg) /
			sizeof(struct ipa_rc_msg) - 1].rc = rc;
	while (qeth_ipa_rc_msg[x].rc != rc)
		x++;
	return qeth_ipa_rc_msg[x].msg;
}


struct ipa_cmd_names {
	enum qeth_ipa_cmds cmd;
	char *name;
};

static struct ipa_cmd_names qeth_ipa_cmd_names[] = {
	{IPA_CMD_STARTLAN,	"startlan"},
	{IPA_CMD_STOPLAN,	"stoplan"},
	{IPA_CMD_SETVMAC,	"setvmac"},
	{IPA_CMD_DELVMAC,	"delvmac"},
	{IPA_CMD_SETGMAC,	"setgmac"},
	{IPA_CMD_DELGMAC,	"delgmac"},
	{IPA_CMD_SETVLAN,	"setvlan"},
	{IPA_CMD_DELVLAN,	"delvlan"},
	{IPA_CMD_SETCCID,	"setccid"},
	{IPA_CMD_DELCCID,	"delccid"},
	{IPA_CMD_MODCCID,	"modccid"},
	{IPA_CMD_SETIP,		"setip"},
	{IPA_CMD_QIPASSIST,	"qipassist"},
	{IPA_CMD_SETASSPARMS,	"setassparms"},
	{IPA_CMD_SETIPM,	"setipm"},
	{IPA_CMD_DELIPM,	"delipm"},
	{IPA_CMD_SETRTG,	"setrtg"},
	{IPA_CMD_DELIP,		"delip"},
	{IPA_CMD_SETADAPTERPARMS, "setadapterparms"},
	{IPA_CMD_SET_DIAG_ASS,	"set_diag_ass"},
	{IPA_CMD_SETBRIDGEPORT,	"set_bridge_port"},
	{IPA_CMD_CREATE_ADDR,	"create_addr"},
	{IPA_CMD_DESTROY_ADDR,	"destroy_addr"},
	{IPA_CMD_REGISTER_LOCAL_ADDR,	"register_local_addr"},
	{IPA_CMD_UNREGISTER_LOCAL_ADDR,	"unregister_local_addr"},
	{IPA_CMD_ADDRESS_CHANGE_NOTIF, "address_change_notification"},
	{IPA_CMD_UNKNOWN,	"unknown"},
};

char *qeth_get_ipa_cmd_name(enum qeth_ipa_cmds cmd)
{
	int x = 0;
	qeth_ipa_cmd_names[
		sizeof(qeth_ipa_cmd_names) /
			sizeof(struct ipa_cmd_names)-1].cmd = cmd;
	while (qeth_ipa_cmd_names[x].cmd != cmd)
		x++;
	return qeth_ipa_cmd_names[x].name;
}