1 /*
2 * drivers/s390/net/qeth_l3_main.c
3 *
4 * Copyright IBM Corp. 2007, 2009
5 * Author(s): Utz Bacher <utz.bacher@de.ibm.com>,
6 * Frank Pavlic <fpavlic@de.ibm.com>,
7 * Thomas Spatzier <tspat@de.ibm.com>,
8 * Frank Blaschka <frank.blaschka@de.ibm.com>
9 */
10
11 #define KMSG_COMPONENT "qeth"
12 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
13
14 #include <linux/module.h>
15 #include <linux/moduleparam.h>
16 #include <linux/string.h>
17 #include <linux/errno.h>
18 #include <linux/kernel.h>
19 #include <linux/etherdevice.h>
20 #include <linux/mii.h>
21 #include <linux/ip.h>
22 #include <linux/ipv6.h>
23 #include <linux/inetdevice.h>
24 #include <linux/igmp.h>
25 #include <linux/slab.h>
26
27 #include <net/ip.h>
28 #include <net/arp.h>
29 #include <net/ip6_checksum.h>
30
31 #include "qeth_l3.h"
32
33
34 static int qeth_l3_set_offline(struct ccwgroup_device *);
35 static int qeth_l3_recover(void *);
36 static int qeth_l3_stop(struct net_device *);
37 static void qeth_l3_set_multicast_list(struct net_device *);
38 static int qeth_l3_neigh_setup(struct net_device *, struct neigh_parms *);
39 static int qeth_l3_register_addr_entry(struct qeth_card *,
40 struct qeth_ipaddr *);
41 static int qeth_l3_deregister_addr_entry(struct qeth_card *,
42 struct qeth_ipaddr *);
43 static int __qeth_l3_set_online(struct ccwgroup_device *, int);
44 static int __qeth_l3_set_offline(struct ccwgroup_device *, int);
45
qeth_l3_set_large_send(struct qeth_card * card,enum qeth_large_send_types type)46 int qeth_l3_set_large_send(struct qeth_card *card,
47 enum qeth_large_send_types type)
48 {
49 int rc = 0;
50
51 card->options.large_send = type;
52 if (card->dev == NULL)
53 return 0;
54
55 if (card->options.large_send == QETH_LARGE_SEND_TSO) {
56 if (qeth_is_supported(card, IPA_OUTBOUND_TSO)) {
57 card->dev->features |= NETIF_F_TSO | NETIF_F_SG |
58 NETIF_F_IP_CSUM;
59 } else {
60 card->dev->features &= ~(NETIF_F_TSO | NETIF_F_SG |
61 NETIF_F_IP_CSUM);
62 card->options.large_send = QETH_LARGE_SEND_NO;
63 rc = -EOPNOTSUPP;
64 }
65 } else {
66 card->dev->features &= ~(NETIF_F_TSO | NETIF_F_SG |
67 NETIF_F_IP_CSUM);
68 card->options.large_send = QETH_LARGE_SEND_NO;
69 }
70 return rc;
71 }
72
qeth_l3_isxdigit(char * buf)73 static int qeth_l3_isxdigit(char *buf)
74 {
75 while (*buf) {
76 if (!isxdigit(*buf++))
77 return 0;
78 }
79 return 1;
80 }
81
qeth_l3_ipaddr4_to_string(const __u8 * addr,char * buf)82 void qeth_l3_ipaddr4_to_string(const __u8 *addr, char *buf)
83 {
84 sprintf(buf, "%i.%i.%i.%i", addr[0], addr[1], addr[2], addr[3]);
85 }
86
qeth_l3_string_to_ipaddr4(const char * buf,__u8 * addr)87 int qeth_l3_string_to_ipaddr4(const char *buf, __u8 *addr)
88 {
89 int count = 0, rc = 0;
90 int in[4];
91 char c;
92
93 rc = sscanf(buf, "%u.%u.%u.%u%c",
94 &in[0], &in[1], &in[2], &in[3], &c);
95 if (rc != 4 && (rc != 5 || c != '\n'))
96 return -EINVAL;
97 for (count = 0; count < 4; count++) {
98 if (in[count] > 255)
99 return -EINVAL;
100 addr[count] = in[count];
101 }
102 return 0;
103 }
104
qeth_l3_ipaddr6_to_string(const __u8 * addr,char * buf)105 void qeth_l3_ipaddr6_to_string(const __u8 *addr, char *buf)
106 {
107 sprintf(buf, "%pI6", addr);
108 }
109
qeth_l3_string_to_ipaddr6(const char * buf,__u8 * addr)110 int qeth_l3_string_to_ipaddr6(const char *buf, __u8 *addr)
111 {
112 const char *end, *end_tmp, *start;
113 __u16 *in;
114 char num[5];
115 int num2, cnt, out, found, save_cnt;
116 unsigned short in_tmp[8] = {0, };
117
118 cnt = out = found = save_cnt = num2 = 0;
119 end = start = buf;
120 in = (__u16 *) addr;
121 memset(in, 0, 16);
122 while (*end) {
123 end = strchr(start, ':');
124 if (end == NULL) {
125 end = buf + strlen(buf);
126 end_tmp = strchr(start, '\n');
127 if (end_tmp != NULL)
128 end = end_tmp;
129 out = 1;
130 }
131 if ((end - start)) {
132 memset(num, 0, 5);
133 if ((end - start) > 4)
134 return -EINVAL;
135 memcpy(num, start, end - start);
136 if (!qeth_l3_isxdigit(num))
137 return -EINVAL;
138 sscanf(start, "%x", &num2);
139 if (found)
140 in_tmp[save_cnt++] = num2;
141 else
142 in[cnt++] = num2;
143 if (out)
144 break;
145 } else {
146 if (found)
147 return -EINVAL;
148 found = 1;
149 }
150 start = ++end;
151 }
152 if (cnt + save_cnt > 8)
153 return -EINVAL;
154 cnt = 7;
155 while (save_cnt)
156 in[cnt--] = in_tmp[--save_cnt];
157 return 0;
158 }
159
qeth_l3_ipaddr_to_string(enum qeth_prot_versions proto,const __u8 * addr,char * buf)160 void qeth_l3_ipaddr_to_string(enum qeth_prot_versions proto, const __u8 *addr,
161 char *buf)
162 {
163 if (proto == QETH_PROT_IPV4)
164 qeth_l3_ipaddr4_to_string(addr, buf);
165 else if (proto == QETH_PROT_IPV6)
166 qeth_l3_ipaddr6_to_string(addr, buf);
167 }
168
qeth_l3_string_to_ipaddr(const char * buf,enum qeth_prot_versions proto,__u8 * addr)169 int qeth_l3_string_to_ipaddr(const char *buf, enum qeth_prot_versions proto,
170 __u8 *addr)
171 {
172 if (proto == QETH_PROT_IPV4)
173 return qeth_l3_string_to_ipaddr4(buf, addr);
174 else if (proto == QETH_PROT_IPV6)
175 return qeth_l3_string_to_ipaddr6(buf, addr);
176 else
177 return -EINVAL;
178 }
179
qeth_l3_convert_addr_to_bits(u8 * addr,u8 * bits,int len)180 static void qeth_l3_convert_addr_to_bits(u8 *addr, u8 *bits, int len)
181 {
182 int i, j;
183 u8 octet;
184
185 for (i = 0; i < len; ++i) {
186 octet = addr[i];
187 for (j = 7; j >= 0; --j) {
188 bits[i*8 + j] = octet & 1;
189 octet >>= 1;
190 }
191 }
192 }
193
qeth_l3_is_addr_covered_by_ipato(struct qeth_card * card,struct qeth_ipaddr * addr)194 int qeth_l3_is_addr_covered_by_ipato(struct qeth_card *card,
195 struct qeth_ipaddr *addr)
196 {
197 struct qeth_ipato_entry *ipatoe;
198 u8 addr_bits[128] = {0, };
199 u8 ipatoe_bits[128] = {0, };
200 int rc = 0;
201
202 if (!card->ipato.enabled)
203 return 0;
204
205 qeth_l3_convert_addr_to_bits((u8 *) &addr->u, addr_bits,
206 (addr->proto == QETH_PROT_IPV4)? 4:16);
207 list_for_each_entry(ipatoe, &card->ipato.entries, entry) {
208 if (addr->proto != ipatoe->proto)
209 continue;
210 qeth_l3_convert_addr_to_bits(ipatoe->addr, ipatoe_bits,
211 (ipatoe->proto == QETH_PROT_IPV4) ?
212 4 : 16);
213 if (addr->proto == QETH_PROT_IPV4)
214 rc = !memcmp(addr_bits, ipatoe_bits,
215 min(32, ipatoe->mask_bits));
216 else
217 rc = !memcmp(addr_bits, ipatoe_bits,
218 min(128, ipatoe->mask_bits));
219 if (rc)
220 break;
221 }
222 /* invert? */
223 if ((addr->proto == QETH_PROT_IPV4) && card->ipato.invert4)
224 rc = !rc;
225 else if ((addr->proto == QETH_PROT_IPV6) && card->ipato.invert6)
226 rc = !rc;
227
228 return rc;
229 }
230
231 /*
232 * Add IP to be added to todo list. If there is already an "add todo"
233 * in this list we just incremenent the reference count.
234 * Returns 0 if we just incremented reference count.
235 */
__qeth_l3_insert_ip_todo(struct qeth_card * card,struct qeth_ipaddr * addr,int add)236 static int __qeth_l3_insert_ip_todo(struct qeth_card *card,
237 struct qeth_ipaddr *addr, int add)
238 {
239 struct qeth_ipaddr *tmp, *t;
240 int found = 0;
241
242 if (card->options.sniffer)
243 return 0;
244 list_for_each_entry_safe(tmp, t, card->ip_tbd_list, entry) {
245 if ((addr->type == QETH_IP_TYPE_DEL_ALL_MC) &&
246 (tmp->type == QETH_IP_TYPE_DEL_ALL_MC))
247 return 0;
248 if ((tmp->proto == QETH_PROT_IPV4) &&
249 (addr->proto == QETH_PROT_IPV4) &&
250 (tmp->type == addr->type) &&
251 (tmp->is_multicast == addr->is_multicast) &&
252 (tmp->u.a4.addr == addr->u.a4.addr) &&
253 (tmp->u.a4.mask == addr->u.a4.mask)) {
254 found = 1;
255 break;
256 }
257 if ((tmp->proto == QETH_PROT_IPV6) &&
258 (addr->proto == QETH_PROT_IPV6) &&
259 (tmp->type == addr->type) &&
260 (tmp->is_multicast == addr->is_multicast) &&
261 (tmp->u.a6.pfxlen == addr->u.a6.pfxlen) &&
262 (memcmp(&tmp->u.a6.addr, &addr->u.a6.addr,
263 sizeof(struct in6_addr)) == 0)) {
264 found = 1;
265 break;
266 }
267 }
268 if (found) {
269 if (addr->users != 0)
270 tmp->users += addr->users;
271 else
272 tmp->users += add ? 1 : -1;
273 if (tmp->users == 0) {
274 list_del(&tmp->entry);
275 kfree(tmp);
276 }
277 return 0;
278 } else {
279 if (addr->type == QETH_IP_TYPE_DEL_ALL_MC)
280 list_add(&addr->entry, card->ip_tbd_list);
281 else {
282 if (addr->users == 0)
283 addr->users += add ? 1 : -1;
284 if (add && (addr->type == QETH_IP_TYPE_NORMAL) &&
285 qeth_l3_is_addr_covered_by_ipato(card, addr)) {
286 QETH_CARD_TEXT(card, 2, "tkovaddr");
287 addr->set_flags |= QETH_IPA_SETIP_TAKEOVER_FLAG;
288 }
289 list_add_tail(&addr->entry, card->ip_tbd_list);
290 }
291 return 1;
292 }
293 }
294
qeth_l3_delete_ip(struct qeth_card * card,struct qeth_ipaddr * addr)295 static int qeth_l3_delete_ip(struct qeth_card *card, struct qeth_ipaddr *addr)
296 {
297 unsigned long flags;
298 int rc = 0;
299
300 QETH_CARD_TEXT(card, 4, "delip");
301
302 if (addr->proto == QETH_PROT_IPV4)
303 QETH_CARD_HEX(card, 4, &addr->u.a4.addr, 4);
304 else {
305 QETH_CARD_HEX(card, 4, &addr->u.a6.addr, 8);
306 QETH_CARD_HEX(card, 4, ((char *)&addr->u.a6.addr) + 8, 8);
307 }
308 spin_lock_irqsave(&card->ip_lock, flags);
309 rc = __qeth_l3_insert_ip_todo(card, addr, 0);
310 spin_unlock_irqrestore(&card->ip_lock, flags);
311 return rc;
312 }
313
qeth_l3_add_ip(struct qeth_card * card,struct qeth_ipaddr * addr)314 static int qeth_l3_add_ip(struct qeth_card *card, struct qeth_ipaddr *addr)
315 {
316 unsigned long flags;
317 int rc = 0;
318
319 QETH_CARD_TEXT(card, 4, "addip");
320 if (addr->proto == QETH_PROT_IPV4)
321 QETH_CARD_HEX(card, 4, &addr->u.a4.addr, 4);
322 else {
323 QETH_CARD_HEX(card, 4, &addr->u.a6.addr, 8);
324 QETH_CARD_HEX(card, 4, ((char *)&addr->u.a6.addr) + 8, 8);
325 }
326 spin_lock_irqsave(&card->ip_lock, flags);
327 rc = __qeth_l3_insert_ip_todo(card, addr, 1);
328 spin_unlock_irqrestore(&card->ip_lock, flags);
329 return rc;
330 }
331
332
qeth_l3_get_addr_buffer(enum qeth_prot_versions prot)333 static struct qeth_ipaddr *qeth_l3_get_addr_buffer(
334 enum qeth_prot_versions prot)
335 {
336 struct qeth_ipaddr *addr;
337
338 addr = kzalloc(sizeof(struct qeth_ipaddr), GFP_ATOMIC);
339 if (addr == NULL) {
340 return NULL;
341 }
342 addr->type = QETH_IP_TYPE_NORMAL;
343 addr->proto = prot;
344 return addr;
345 }
346
qeth_l3_delete_mc_addresses(struct qeth_card * card)347 static void qeth_l3_delete_mc_addresses(struct qeth_card *card)
348 {
349 struct qeth_ipaddr *iptodo;
350 unsigned long flags;
351
352 QETH_CARD_TEXT(card, 4, "delmc");
353 iptodo = qeth_l3_get_addr_buffer(QETH_PROT_IPV4);
354 if (!iptodo) {
355 QETH_CARD_TEXT(card, 2, "dmcnomem");
356 return;
357 }
358 iptodo->type = QETH_IP_TYPE_DEL_ALL_MC;
359 spin_lock_irqsave(&card->ip_lock, flags);
360 if (!__qeth_l3_insert_ip_todo(card, iptodo, 0))
361 kfree(iptodo);
362 spin_unlock_irqrestore(&card->ip_lock, flags);
363 }
364
365 /*
366 * Add/remove address to/from card's ip list, i.e. try to add or remove
367 * reference to/from an IP address that is already registered on the card.
368 * Returns:
369 * 0 address was on card and its reference count has been adjusted,
370 * but is still > 0, so nothing has to be done
371 * also returns 0 if card was not on card and the todo was to delete
372 * the address -> there is also nothing to be done
373 * 1 address was not on card and the todo is to add it to the card's ip
374 * list
375 * -1 address was on card and its reference count has been decremented
376 * to <= 0 by the todo -> address must be removed from card
377 */
__qeth_l3_ref_ip_on_card(struct qeth_card * card,struct qeth_ipaddr * todo,struct qeth_ipaddr ** __addr)378 static int __qeth_l3_ref_ip_on_card(struct qeth_card *card,
379 struct qeth_ipaddr *todo, struct qeth_ipaddr **__addr)
380 {
381 struct qeth_ipaddr *addr;
382 int found = 0;
383
384 list_for_each_entry(addr, &card->ip_list, entry) {
385 if ((addr->proto == QETH_PROT_IPV4) &&
386 (todo->proto == QETH_PROT_IPV4) &&
387 (addr->type == todo->type) &&
388 (addr->u.a4.addr == todo->u.a4.addr) &&
389 (addr->u.a4.mask == todo->u.a4.mask)) {
390 found = 1;
391 break;
392 }
393 if ((addr->proto == QETH_PROT_IPV6) &&
394 (todo->proto == QETH_PROT_IPV6) &&
395 (addr->type == todo->type) &&
396 (addr->u.a6.pfxlen == todo->u.a6.pfxlen) &&
397 (memcmp(&addr->u.a6.addr, &todo->u.a6.addr,
398 sizeof(struct in6_addr)) == 0)) {
399 found = 1;
400 break;
401 }
402 }
403 if (found) {
404 addr->users += todo->users;
405 if (addr->users <= 0) {
406 *__addr = addr;
407 return -1;
408 } else {
409 /* for VIPA and RXIP limit refcount to 1 */
410 if (addr->type != QETH_IP_TYPE_NORMAL)
411 addr->users = 1;
412 return 0;
413 }
414 }
415 if (todo->users > 0) {
416 /* for VIPA and RXIP limit refcount to 1 */
417 if (todo->type != QETH_IP_TYPE_NORMAL)
418 todo->users = 1;
419 return 1;
420 } else
421 return 0;
422 }
423
__qeth_l3_delete_all_mc(struct qeth_card * card,unsigned long * flags)424 static void __qeth_l3_delete_all_mc(struct qeth_card *card,
425 unsigned long *flags)
426 {
427 struct list_head fail_list;
428 struct qeth_ipaddr *addr, *tmp;
429 int rc;
430
431 INIT_LIST_HEAD(&fail_list);
432 again:
433 list_for_each_entry_safe(addr, tmp, &card->ip_list, entry) {
434 if (addr->is_multicast) {
435 list_del(&addr->entry);
436 spin_unlock_irqrestore(&card->ip_lock, *flags);
437 rc = qeth_l3_deregister_addr_entry(card, addr);
438 spin_lock_irqsave(&card->ip_lock, *flags);
439 if (!rc || (rc == IPA_RC_MC_ADDR_NOT_FOUND))
440 kfree(addr);
441 else
442 list_add_tail(&addr->entry, &fail_list);
443 goto again;
444 }
445 }
446 list_splice(&fail_list, &card->ip_list);
447 }
448
qeth_l3_set_ip_addr_list(struct qeth_card * card)449 static void qeth_l3_set_ip_addr_list(struct qeth_card *card)
450 {
451 struct list_head *tbd_list;
452 struct qeth_ipaddr *todo, *addr;
453 unsigned long flags;
454 int rc;
455
456 QETH_CARD_TEXT(card, 2, "sdiplist");
457 QETH_CARD_HEX(card, 2, &card, sizeof(void *));
458
459 if ((card->state != CARD_STATE_UP &&
460 card->state != CARD_STATE_SOFTSETUP) || card->options.sniffer) {
461 return;
462 }
463
464 spin_lock_irqsave(&card->ip_lock, flags);
465 tbd_list = card->ip_tbd_list;
466 card->ip_tbd_list = kmalloc(sizeof(struct list_head), GFP_ATOMIC);
467 if (!card->ip_tbd_list) {
468 QETH_CARD_TEXT(card, 0, "silnomem");
469 card->ip_tbd_list = tbd_list;
470 spin_unlock_irqrestore(&card->ip_lock, flags);
471 return;
472 } else
473 INIT_LIST_HEAD(card->ip_tbd_list);
474
475 while (!list_empty(tbd_list)) {
476 todo = list_entry(tbd_list->next, struct qeth_ipaddr, entry);
477 list_del(&todo->entry);
478 if (todo->type == QETH_IP_TYPE_DEL_ALL_MC) {
479 __qeth_l3_delete_all_mc(card, &flags);
480 kfree(todo);
481 continue;
482 }
483 rc = __qeth_l3_ref_ip_on_card(card, todo, &addr);
484 if (rc == 0) {
485 /* nothing to be done; only adjusted refcount */
486 kfree(todo);
487 } else if (rc == 1) {
488 /* new entry to be added to on-card list */
489 spin_unlock_irqrestore(&card->ip_lock, flags);
490 rc = qeth_l3_register_addr_entry(card, todo);
491 spin_lock_irqsave(&card->ip_lock, flags);
492 if (!rc || (rc == IPA_RC_LAN_OFFLINE))
493 list_add_tail(&todo->entry, &card->ip_list);
494 else
495 kfree(todo);
496 } else if (rc == -1) {
497 /* on-card entry to be removed */
498 list_del_init(&addr->entry);
499 spin_unlock_irqrestore(&card->ip_lock, flags);
500 rc = qeth_l3_deregister_addr_entry(card, addr);
501 spin_lock_irqsave(&card->ip_lock, flags);
502 if (!rc || (rc == IPA_RC_IP_ADDRESS_NOT_DEFINED))
503 kfree(addr);
504 else
505 list_add_tail(&addr->entry, &card->ip_list);
506 kfree(todo);
507 }
508 }
509 spin_unlock_irqrestore(&card->ip_lock, flags);
510 kfree(tbd_list);
511 }
512
qeth_l3_clear_ip_list(struct qeth_card * card,int recover)513 static void qeth_l3_clear_ip_list(struct qeth_card *card, int recover)
514 {
515 struct qeth_ipaddr *addr, *tmp;
516 unsigned long flags;
517
518 QETH_CARD_TEXT(card, 4, "clearip");
519 if (recover && card->options.sniffer)
520 return;
521 spin_lock_irqsave(&card->ip_lock, flags);
522 /* clear todo list */
523 list_for_each_entry_safe(addr, tmp, card->ip_tbd_list, entry) {
524 list_del(&addr->entry);
525 kfree(addr);
526 }
527
528 while (!list_empty(&card->ip_list)) {
529 addr = list_entry(card->ip_list.next,
530 struct qeth_ipaddr, entry);
531 list_del_init(&addr->entry);
532 if (!recover || addr->is_multicast) {
533 kfree(addr);
534 continue;
535 }
536 list_add_tail(&addr->entry, card->ip_tbd_list);
537 }
538 spin_unlock_irqrestore(&card->ip_lock, flags);
539 }
540
qeth_l3_address_exists_in_list(struct list_head * list,struct qeth_ipaddr * addr,int same_type)541 static int qeth_l3_address_exists_in_list(struct list_head *list,
542 struct qeth_ipaddr *addr, int same_type)
543 {
544 struct qeth_ipaddr *tmp;
545
546 list_for_each_entry(tmp, list, entry) {
547 if ((tmp->proto == QETH_PROT_IPV4) &&
548 (addr->proto == QETH_PROT_IPV4) &&
549 ((same_type && (tmp->type == addr->type)) ||
550 (!same_type && (tmp->type != addr->type))) &&
551 (tmp->u.a4.addr == addr->u.a4.addr))
552 return 1;
553
554 if ((tmp->proto == QETH_PROT_IPV6) &&
555 (addr->proto == QETH_PROT_IPV6) &&
556 ((same_type && (tmp->type == addr->type)) ||
557 (!same_type && (tmp->type != addr->type))) &&
558 (memcmp(&tmp->u.a6.addr, &addr->u.a6.addr,
559 sizeof(struct in6_addr)) == 0))
560 return 1;
561
562 }
563 return 0;
564 }
565
qeth_l3_send_setdelmc(struct qeth_card * card,struct qeth_ipaddr * addr,int ipacmd)566 static int qeth_l3_send_setdelmc(struct qeth_card *card,
567 struct qeth_ipaddr *addr, int ipacmd)
568 {
569 int rc;
570 struct qeth_cmd_buffer *iob;
571 struct qeth_ipa_cmd *cmd;
572
573 QETH_CARD_TEXT(card, 4, "setdelmc");
574
575 iob = qeth_get_ipacmd_buffer(card, ipacmd, addr->proto);
576 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
577 memcpy(&cmd->data.setdelipm.mac, addr->mac, OSA_ADDR_LEN);
578 if (addr->proto == QETH_PROT_IPV6)
579 memcpy(cmd->data.setdelipm.ip6, &addr->u.a6.addr,
580 sizeof(struct in6_addr));
581 else
582 memcpy(&cmd->data.setdelipm.ip4, &addr->u.a4.addr, 4);
583
584 rc = qeth_send_ipa_cmd(card, iob, NULL, NULL);
585
586 return rc;
587 }
588
qeth_l3_fill_netmask(u8 * netmask,unsigned int len)589 static void qeth_l3_fill_netmask(u8 *netmask, unsigned int len)
590 {
591 int i, j;
592 for (i = 0; i < 16; i++) {
593 j = (len) - (i * 8);
594 if (j >= 8)
595 netmask[i] = 0xff;
596 else if (j > 0)
597 netmask[i] = (u8)(0xFF00 >> j);
598 else
599 netmask[i] = 0;
600 }
601 }
602
qeth_l3_send_setdelip(struct qeth_card * card,struct qeth_ipaddr * addr,int ipacmd,unsigned int flags)603 static int qeth_l3_send_setdelip(struct qeth_card *card,
604 struct qeth_ipaddr *addr, int ipacmd, unsigned int flags)
605 {
606 int rc;
607 struct qeth_cmd_buffer *iob;
608 struct qeth_ipa_cmd *cmd;
609 __u8 netmask[16];
610
611 QETH_CARD_TEXT(card, 4, "setdelip");
612 QETH_CARD_TEXT_(card, 4, "flags%02X", flags);
613
614 iob = qeth_get_ipacmd_buffer(card, ipacmd, addr->proto);
615 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
616 if (addr->proto == QETH_PROT_IPV6) {
617 memcpy(cmd->data.setdelip6.ip_addr, &addr->u.a6.addr,
618 sizeof(struct in6_addr));
619 qeth_l3_fill_netmask(netmask, addr->u.a6.pfxlen);
620 memcpy(cmd->data.setdelip6.mask, netmask,
621 sizeof(struct in6_addr));
622 cmd->data.setdelip6.flags = flags;
623 } else {
624 memcpy(cmd->data.setdelip4.ip_addr, &addr->u.a4.addr, 4);
625 memcpy(cmd->data.setdelip4.mask, &addr->u.a4.mask, 4);
626 cmd->data.setdelip4.flags = flags;
627 }
628
629 rc = qeth_send_ipa_cmd(card, iob, NULL, NULL);
630
631 return rc;
632 }
633
qeth_l3_send_setrouting(struct qeth_card * card,enum qeth_routing_types type,enum qeth_prot_versions prot)634 static int qeth_l3_send_setrouting(struct qeth_card *card,
635 enum qeth_routing_types type, enum qeth_prot_versions prot)
636 {
637 int rc;
638 struct qeth_ipa_cmd *cmd;
639 struct qeth_cmd_buffer *iob;
640
641 QETH_CARD_TEXT(card, 4, "setroutg");
642 iob = qeth_get_ipacmd_buffer(card, IPA_CMD_SETRTG, prot);
643 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
644 cmd->data.setrtg.type = (type);
645 rc = qeth_send_ipa_cmd(card, iob, NULL, NULL);
646
647 return rc;
648 }
649
qeth_l3_correct_routing_type(struct qeth_card * card,enum qeth_routing_types * type,enum qeth_prot_versions prot)650 static void qeth_l3_correct_routing_type(struct qeth_card *card,
651 enum qeth_routing_types *type, enum qeth_prot_versions prot)
652 {
653 if (card->info.type == QETH_CARD_TYPE_IQD) {
654 switch (*type) {
655 case NO_ROUTER:
656 case PRIMARY_CONNECTOR:
657 case SECONDARY_CONNECTOR:
658 case MULTICAST_ROUTER:
659 return;
660 default:
661 goto out_inval;
662 }
663 } else {
664 switch (*type) {
665 case NO_ROUTER:
666 case PRIMARY_ROUTER:
667 case SECONDARY_ROUTER:
668 return;
669 case MULTICAST_ROUTER:
670 if (qeth_is_ipafunc_supported(card, prot,
671 IPA_OSA_MC_ROUTER))
672 return;
673 default:
674 goto out_inval;
675 }
676 }
677 out_inval:
678 *type = NO_ROUTER;
679 }
680
qeth_l3_setrouting_v4(struct qeth_card * card)681 int qeth_l3_setrouting_v4(struct qeth_card *card)
682 {
683 int rc;
684
685 QETH_CARD_TEXT(card, 3, "setrtg4");
686
687 qeth_l3_correct_routing_type(card, &card->options.route4.type,
688 QETH_PROT_IPV4);
689
690 rc = qeth_l3_send_setrouting(card, card->options.route4.type,
691 QETH_PROT_IPV4);
692 if (rc) {
693 card->options.route4.type = NO_ROUTER;
694 QETH_DBF_MESSAGE(2, "Error (0x%04x) while setting routing type"
695 " on %s. Type set to 'no router'.\n", rc,
696 QETH_CARD_IFNAME(card));
697 }
698 return rc;
699 }
700
qeth_l3_setrouting_v6(struct qeth_card * card)701 int qeth_l3_setrouting_v6(struct qeth_card *card)
702 {
703 int rc = 0;
704
705 QETH_CARD_TEXT(card, 3, "setrtg6");
706 #ifdef CONFIG_QETH_IPV6
707
708 if (!qeth_is_supported(card, IPA_IPV6))
709 return 0;
710 qeth_l3_correct_routing_type(card, &card->options.route6.type,
711 QETH_PROT_IPV6);
712
713 rc = qeth_l3_send_setrouting(card, card->options.route6.type,
714 QETH_PROT_IPV6);
715 if (rc) {
716 card->options.route6.type = NO_ROUTER;
717 QETH_DBF_MESSAGE(2, "Error (0x%04x) while setting routing type"
718 " on %s. Type set to 'no router'.\n", rc,
719 QETH_CARD_IFNAME(card));
720 }
721 #endif
722 return rc;
723 }
724
725 /*
726 * IP address takeover related functions
727 */
qeth_l3_clear_ipato_list(struct qeth_card * card)728 static void qeth_l3_clear_ipato_list(struct qeth_card *card)
729 {
730
731 struct qeth_ipato_entry *ipatoe, *tmp;
732 unsigned long flags;
733
734 spin_lock_irqsave(&card->ip_lock, flags);
735 list_for_each_entry_safe(ipatoe, tmp, &card->ipato.entries, entry) {
736 list_del(&ipatoe->entry);
737 kfree(ipatoe);
738 }
739 spin_unlock_irqrestore(&card->ip_lock, flags);
740 }
741
qeth_l3_add_ipato_entry(struct qeth_card * card,struct qeth_ipato_entry * new)742 int qeth_l3_add_ipato_entry(struct qeth_card *card,
743 struct qeth_ipato_entry *new)
744 {
745 struct qeth_ipato_entry *ipatoe;
746 unsigned long flags;
747 int rc = 0;
748
749 QETH_CARD_TEXT(card, 2, "addipato");
750 spin_lock_irqsave(&card->ip_lock, flags);
751 list_for_each_entry(ipatoe, &card->ipato.entries, entry) {
752 if (ipatoe->proto != new->proto)
753 continue;
754 if (!memcmp(ipatoe->addr, new->addr,
755 (ipatoe->proto == QETH_PROT_IPV4)? 4:16) &&
756 (ipatoe->mask_bits == new->mask_bits)) {
757 rc = -EEXIST;
758 break;
759 }
760 }
761 if (!rc)
762 list_add_tail(&new->entry, &card->ipato.entries);
763
764 spin_unlock_irqrestore(&card->ip_lock, flags);
765 return rc;
766 }
767
qeth_l3_del_ipato_entry(struct qeth_card * card,enum qeth_prot_versions proto,u8 * addr,int mask_bits)768 void qeth_l3_del_ipato_entry(struct qeth_card *card,
769 enum qeth_prot_versions proto, u8 *addr, int mask_bits)
770 {
771 struct qeth_ipato_entry *ipatoe, *tmp;
772 unsigned long flags;
773
774 QETH_CARD_TEXT(card, 2, "delipato");
775 spin_lock_irqsave(&card->ip_lock, flags);
776 list_for_each_entry_safe(ipatoe, tmp, &card->ipato.entries, entry) {
777 if (ipatoe->proto != proto)
778 continue;
779 if (!memcmp(ipatoe->addr, addr,
780 (proto == QETH_PROT_IPV4)? 4:16) &&
781 (ipatoe->mask_bits == mask_bits)) {
782 list_del(&ipatoe->entry);
783 kfree(ipatoe);
784 }
785 }
786 spin_unlock_irqrestore(&card->ip_lock, flags);
787 }
788
789 /*
790 * VIPA related functions
791 */
qeth_l3_add_vipa(struct qeth_card * card,enum qeth_prot_versions proto,const u8 * addr)792 int qeth_l3_add_vipa(struct qeth_card *card, enum qeth_prot_versions proto,
793 const u8 *addr)
794 {
795 struct qeth_ipaddr *ipaddr;
796 unsigned long flags;
797 int rc = 0;
798
799 ipaddr = qeth_l3_get_addr_buffer(proto);
800 if (ipaddr) {
801 if (proto == QETH_PROT_IPV4) {
802 QETH_CARD_TEXT(card, 2, "addvipa4");
803 memcpy(&ipaddr->u.a4.addr, addr, 4);
804 ipaddr->u.a4.mask = 0;
805 } else if (proto == QETH_PROT_IPV6) {
806 QETH_CARD_TEXT(card, 2, "addvipa6");
807 memcpy(&ipaddr->u.a6.addr, addr, 16);
808 ipaddr->u.a6.pfxlen = 0;
809 }
810 ipaddr->type = QETH_IP_TYPE_VIPA;
811 ipaddr->set_flags = QETH_IPA_SETIP_VIPA_FLAG;
812 ipaddr->del_flags = QETH_IPA_DELIP_VIPA_FLAG;
813 } else
814 return -ENOMEM;
815 spin_lock_irqsave(&card->ip_lock, flags);
816 if (qeth_l3_address_exists_in_list(&card->ip_list, ipaddr, 0) ||
817 qeth_l3_address_exists_in_list(card->ip_tbd_list, ipaddr, 0))
818 rc = -EEXIST;
819 spin_unlock_irqrestore(&card->ip_lock, flags);
820 if (rc) {
821 return rc;
822 }
823 if (!qeth_l3_add_ip(card, ipaddr))
824 kfree(ipaddr);
825 qeth_l3_set_ip_addr_list(card);
826 return rc;
827 }
828
qeth_l3_del_vipa(struct qeth_card * card,enum qeth_prot_versions proto,const u8 * addr)829 void qeth_l3_del_vipa(struct qeth_card *card, enum qeth_prot_versions proto,
830 const u8 *addr)
831 {
832 struct qeth_ipaddr *ipaddr;
833
834 ipaddr = qeth_l3_get_addr_buffer(proto);
835 if (ipaddr) {
836 if (proto == QETH_PROT_IPV4) {
837 QETH_CARD_TEXT(card, 2, "delvipa4");
838 memcpy(&ipaddr->u.a4.addr, addr, 4);
839 ipaddr->u.a4.mask = 0;
840 } else if (proto == QETH_PROT_IPV6) {
841 QETH_CARD_TEXT(card, 2, "delvipa6");
842 memcpy(&ipaddr->u.a6.addr, addr, 16);
843 ipaddr->u.a6.pfxlen = 0;
844 }
845 ipaddr->type = QETH_IP_TYPE_VIPA;
846 } else
847 return;
848 if (!qeth_l3_delete_ip(card, ipaddr))
849 kfree(ipaddr);
850 qeth_l3_set_ip_addr_list(card);
851 }
852
853 /*
854 * proxy ARP related functions
855 */
qeth_l3_add_rxip(struct qeth_card * card,enum qeth_prot_versions proto,const u8 * addr)856 int qeth_l3_add_rxip(struct qeth_card *card, enum qeth_prot_versions proto,
857 const u8 *addr)
858 {
859 struct qeth_ipaddr *ipaddr;
860 unsigned long flags;
861 int rc = 0;
862
863 ipaddr = qeth_l3_get_addr_buffer(proto);
864 if (ipaddr) {
865 if (proto == QETH_PROT_IPV4) {
866 QETH_CARD_TEXT(card, 2, "addrxip4");
867 memcpy(&ipaddr->u.a4.addr, addr, 4);
868 ipaddr->u.a4.mask = 0;
869 } else if (proto == QETH_PROT_IPV6) {
870 QETH_CARD_TEXT(card, 2, "addrxip6");
871 memcpy(&ipaddr->u.a6.addr, addr, 16);
872 ipaddr->u.a6.pfxlen = 0;
873 }
874 ipaddr->type = QETH_IP_TYPE_RXIP;
875 ipaddr->set_flags = QETH_IPA_SETIP_TAKEOVER_FLAG;
876 ipaddr->del_flags = 0;
877 } else
878 return -ENOMEM;
879 spin_lock_irqsave(&card->ip_lock, flags);
880 if (qeth_l3_address_exists_in_list(&card->ip_list, ipaddr, 0) ||
881 qeth_l3_address_exists_in_list(card->ip_tbd_list, ipaddr, 0))
882 rc = -EEXIST;
883 spin_unlock_irqrestore(&card->ip_lock, flags);
884 if (rc) {
885 return rc;
886 }
887 if (!qeth_l3_add_ip(card, ipaddr))
888 kfree(ipaddr);
889 qeth_l3_set_ip_addr_list(card);
890 return 0;
891 }
892
qeth_l3_del_rxip(struct qeth_card * card,enum qeth_prot_versions proto,const u8 * addr)893 void qeth_l3_del_rxip(struct qeth_card *card, enum qeth_prot_versions proto,
894 const u8 *addr)
895 {
896 struct qeth_ipaddr *ipaddr;
897
898 ipaddr = qeth_l3_get_addr_buffer(proto);
899 if (ipaddr) {
900 if (proto == QETH_PROT_IPV4) {
901 QETH_CARD_TEXT(card, 2, "addrxip4");
902 memcpy(&ipaddr->u.a4.addr, addr, 4);
903 ipaddr->u.a4.mask = 0;
904 } else if (proto == QETH_PROT_IPV6) {
905 QETH_CARD_TEXT(card, 2, "addrxip6");
906 memcpy(&ipaddr->u.a6.addr, addr, 16);
907 ipaddr->u.a6.pfxlen = 0;
908 }
909 ipaddr->type = QETH_IP_TYPE_RXIP;
910 } else
911 return;
912 if (!qeth_l3_delete_ip(card, ipaddr))
913 kfree(ipaddr);
914 qeth_l3_set_ip_addr_list(card);
915 }
916
qeth_l3_register_addr_entry(struct qeth_card * card,struct qeth_ipaddr * addr)917 static int qeth_l3_register_addr_entry(struct qeth_card *card,
918 struct qeth_ipaddr *addr)
919 {
920 char buf[50];
921 int rc = 0;
922 int cnt = 3;
923
924 if (addr->proto == QETH_PROT_IPV4) {
925 QETH_CARD_TEXT(card, 2, "setaddr4");
926 QETH_CARD_HEX(card, 3, &addr->u.a4.addr, sizeof(int));
927 } else if (addr->proto == QETH_PROT_IPV6) {
928 QETH_CARD_TEXT(card, 2, "setaddr6");
929 QETH_CARD_HEX(card, 3, &addr->u.a6.addr, 8);
930 QETH_CARD_HEX(card, 3, ((char *)&addr->u.a6.addr) + 8, 8);
931 } else {
932 QETH_CARD_TEXT(card, 2, "setaddr?");
933 QETH_CARD_HEX(card, 3, addr, sizeof(struct qeth_ipaddr));
934 }
935 do {
936 if (addr->is_multicast)
937 rc = qeth_l3_send_setdelmc(card, addr, IPA_CMD_SETIPM);
938 else
939 rc = qeth_l3_send_setdelip(card, addr, IPA_CMD_SETIP,
940 addr->set_flags);
941 if (rc)
942 QETH_CARD_TEXT(card, 2, "failed");
943 } while ((--cnt > 0) && rc);
944 if (rc) {
945 QETH_CARD_TEXT(card, 2, "FAILED");
946 qeth_l3_ipaddr_to_string(addr->proto, (u8 *)&addr->u, buf);
947 dev_warn(&card->gdev->dev,
948 "Registering IP address %s failed\n", buf);
949 }
950 return rc;
951 }
952
qeth_l3_deregister_addr_entry(struct qeth_card * card,struct qeth_ipaddr * addr)953 static int qeth_l3_deregister_addr_entry(struct qeth_card *card,
954 struct qeth_ipaddr *addr)
955 {
956 int rc = 0;
957
958 if (addr->proto == QETH_PROT_IPV4) {
959 QETH_CARD_TEXT(card, 2, "deladdr4");
960 QETH_CARD_HEX(card, 3, &addr->u.a4.addr, sizeof(int));
961 } else if (addr->proto == QETH_PROT_IPV6) {
962 QETH_CARD_TEXT(card, 2, "deladdr6");
963 QETH_CARD_HEX(card, 3, &addr->u.a6.addr, 8);
964 QETH_CARD_HEX(card, 3, ((char *)&addr->u.a6.addr) + 8, 8);
965 } else {
966 QETH_CARD_TEXT(card, 2, "deladdr?");
967 QETH_CARD_HEX(card, 3, addr, sizeof(struct qeth_ipaddr));
968 }
969 if (addr->is_multicast)
970 rc = qeth_l3_send_setdelmc(card, addr, IPA_CMD_DELIPM);
971 else
972 rc = qeth_l3_send_setdelip(card, addr, IPA_CMD_DELIP,
973 addr->del_flags);
974 if (rc)
975 QETH_CARD_TEXT(card, 2, "failed");
976
977 return rc;
978 }
979
qeth_l3_get_qeth_hdr_flags4(int cast_type)980 static inline u8 qeth_l3_get_qeth_hdr_flags4(int cast_type)
981 {
982 if (cast_type == RTN_MULTICAST)
983 return QETH_CAST_MULTICAST;
984 if (cast_type == RTN_BROADCAST)
985 return QETH_CAST_BROADCAST;
986 return QETH_CAST_UNICAST;
987 }
988
qeth_l3_get_qeth_hdr_flags6(int cast_type)989 static inline u8 qeth_l3_get_qeth_hdr_flags6(int cast_type)
990 {
991 u8 ct = QETH_HDR_PASSTHRU | QETH_HDR_IPV6;
992 if (cast_type == RTN_MULTICAST)
993 return ct | QETH_CAST_MULTICAST;
994 if (cast_type == RTN_ANYCAST)
995 return ct | QETH_CAST_ANYCAST;
996 if (cast_type == RTN_BROADCAST)
997 return ct | QETH_CAST_BROADCAST;
998 return ct | QETH_CAST_UNICAST;
999 }
1000
qeth_l3_send_setadp_mode(struct qeth_card * card,__u32 command,__u32 mode)1001 static int qeth_l3_send_setadp_mode(struct qeth_card *card, __u32 command,
1002 __u32 mode)
1003 {
1004 int rc;
1005 struct qeth_cmd_buffer *iob;
1006 struct qeth_ipa_cmd *cmd;
1007
1008 QETH_CARD_TEXT(card, 4, "adpmode");
1009
1010 iob = qeth_get_adapter_cmd(card, command,
1011 sizeof(struct qeth_ipacmd_setadpparms));
1012 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
1013 cmd->data.setadapterparms.data.mode = mode;
1014 rc = qeth_send_ipa_cmd(card, iob, qeth_default_setadapterparms_cb,
1015 NULL);
1016 return rc;
1017 }
1018
qeth_l3_setadapter_hstr(struct qeth_card * card)1019 static int qeth_l3_setadapter_hstr(struct qeth_card *card)
1020 {
1021 int rc;
1022
1023 QETH_CARD_TEXT(card, 4, "adphstr");
1024
1025 if (qeth_adp_supported(card, IPA_SETADP_SET_BROADCAST_MODE)) {
1026 rc = qeth_l3_send_setadp_mode(card,
1027 IPA_SETADP_SET_BROADCAST_MODE,
1028 card->options.broadcast_mode);
1029 if (rc)
1030 QETH_DBF_MESSAGE(2, "couldn't set broadcast mode on "
1031 "device %s: x%x\n",
1032 CARD_BUS_ID(card), rc);
1033 rc = qeth_l3_send_setadp_mode(card,
1034 IPA_SETADP_ALTER_MAC_ADDRESS,
1035 card->options.macaddr_mode);
1036 if (rc)
1037 QETH_DBF_MESSAGE(2, "couldn't set macaddr mode on "
1038 "device %s: x%x\n", CARD_BUS_ID(card), rc);
1039 return rc;
1040 }
1041 if (card->options.broadcast_mode == QETH_TR_BROADCAST_LOCAL)
1042 QETH_DBF_MESSAGE(2, "set adapter parameters not available "
1043 "to set broadcast mode, using ALLRINGS "
1044 "on device %s:\n", CARD_BUS_ID(card));
1045 if (card->options.macaddr_mode == QETH_TR_MACADDR_CANONICAL)
1046 QETH_DBF_MESSAGE(2, "set adapter parameters not available "
1047 "to set macaddr mode, using NONCANONICAL "
1048 "on device %s:\n", CARD_BUS_ID(card));
1049 return 0;
1050 }
1051
qeth_l3_setadapter_parms(struct qeth_card * card)1052 static int qeth_l3_setadapter_parms(struct qeth_card *card)
1053 {
1054 int rc;
1055
1056 QETH_DBF_TEXT(SETUP, 2, "setadprm");
1057
1058 if (!qeth_is_supported(card, IPA_SETADAPTERPARMS)) {
1059 dev_info(&card->gdev->dev,
1060 "set adapter parameters not supported.\n");
1061 QETH_DBF_TEXT(SETUP, 2, " notsupp");
1062 return 0;
1063 }
1064 rc = qeth_query_setadapterparms(card);
1065 if (rc) {
1066 QETH_DBF_MESSAGE(2, "%s couldn't set adapter parameters: "
1067 "0x%x\n", dev_name(&card->gdev->dev), rc);
1068 return rc;
1069 }
1070 if (qeth_adp_supported(card, IPA_SETADP_ALTER_MAC_ADDRESS)) {
1071 rc = qeth_setadpparms_change_macaddr(card);
1072 if (rc)
1073 dev_warn(&card->gdev->dev, "Reading the adapter MAC"
1074 " address failed\n");
1075 }
1076
1077 if ((card->info.link_type == QETH_LINK_TYPE_HSTR) ||
1078 (card->info.link_type == QETH_LINK_TYPE_LANE_TR))
1079 rc = qeth_l3_setadapter_hstr(card);
1080
1081 return rc;
1082 }
1083
qeth_l3_default_setassparms_cb(struct qeth_card * card,struct qeth_reply * reply,unsigned long data)1084 static int qeth_l3_default_setassparms_cb(struct qeth_card *card,
1085 struct qeth_reply *reply, unsigned long data)
1086 {
1087 struct qeth_ipa_cmd *cmd;
1088
1089 QETH_CARD_TEXT(card, 4, "defadpcb");
1090
1091 cmd = (struct qeth_ipa_cmd *) data;
1092 if (cmd->hdr.return_code == 0) {
1093 cmd->hdr.return_code = cmd->data.setassparms.hdr.return_code;
1094 if (cmd->hdr.prot_version == QETH_PROT_IPV4)
1095 card->options.ipa4.enabled_funcs = cmd->hdr.ipa_enabled;
1096 if (cmd->hdr.prot_version == QETH_PROT_IPV6)
1097 card->options.ipa6.enabled_funcs = cmd->hdr.ipa_enabled;
1098 }
1099 if (cmd->data.setassparms.hdr.assist_no == IPA_INBOUND_CHECKSUM &&
1100 cmd->data.setassparms.hdr.command_code == IPA_CMD_ASS_START) {
1101 card->info.csum_mask = cmd->data.setassparms.data.flags_32bit;
1102 QETH_CARD_TEXT_(card, 3, "csum:%d", card->info.csum_mask);
1103 }
1104 if (cmd->data.setassparms.hdr.assist_no == IPA_OUTBOUND_CHECKSUM &&
1105 cmd->data.setassparms.hdr.command_code == IPA_CMD_ASS_START) {
1106 card->info.tx_csum_mask =
1107 cmd->data.setassparms.data.flags_32bit;
1108 QETH_CARD_TEXT_(card, 3, "tcsu:%d", card->info.tx_csum_mask);
1109 }
1110
1111 return 0;
1112 }
1113
qeth_l3_get_setassparms_cmd(struct qeth_card * card,enum qeth_ipa_funcs ipa_func,__u16 cmd_code,__u16 len,enum qeth_prot_versions prot)1114 static struct qeth_cmd_buffer *qeth_l3_get_setassparms_cmd(
1115 struct qeth_card *card, enum qeth_ipa_funcs ipa_func, __u16 cmd_code,
1116 __u16 len, enum qeth_prot_versions prot)
1117 {
1118 struct qeth_cmd_buffer *iob;
1119 struct qeth_ipa_cmd *cmd;
1120
1121 QETH_CARD_TEXT(card, 4, "getasscm");
1122 iob = qeth_get_ipacmd_buffer(card, IPA_CMD_SETASSPARMS, prot);
1123
1124 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
1125 cmd->data.setassparms.hdr.assist_no = ipa_func;
1126 cmd->data.setassparms.hdr.length = 8 + len;
1127 cmd->data.setassparms.hdr.command_code = cmd_code;
1128 cmd->data.setassparms.hdr.return_code = 0;
1129 cmd->data.setassparms.hdr.seq_no = 0;
1130
1131 return iob;
1132 }
1133
qeth_l3_send_setassparms(struct qeth_card * card,struct qeth_cmd_buffer * iob,__u16 len,long data,int (* reply_cb)(struct qeth_card *,struct qeth_reply *,unsigned long),void * reply_param)1134 static int qeth_l3_send_setassparms(struct qeth_card *card,
1135 struct qeth_cmd_buffer *iob, __u16 len, long data,
1136 int (*reply_cb)(struct qeth_card *, struct qeth_reply *,
1137 unsigned long),
1138 void *reply_param)
1139 {
1140 int rc;
1141 struct qeth_ipa_cmd *cmd;
1142
1143 QETH_CARD_TEXT(card, 4, "sendassp");
1144
1145 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
1146 if (len <= sizeof(__u32))
1147 cmd->data.setassparms.data.flags_32bit = (__u32) data;
1148 else /* (len > sizeof(__u32)) */
1149 memcpy(&cmd->data.setassparms.data, (void *) data, len);
1150
1151 rc = qeth_send_ipa_cmd(card, iob, reply_cb, reply_param);
1152 return rc;
1153 }
1154
1155 #ifdef CONFIG_QETH_IPV6
qeth_l3_send_simple_setassparms_ipv6(struct qeth_card * card,enum qeth_ipa_funcs ipa_func,__u16 cmd_code)1156 static int qeth_l3_send_simple_setassparms_ipv6(struct qeth_card *card,
1157 enum qeth_ipa_funcs ipa_func, __u16 cmd_code)
1158 {
1159 int rc;
1160 struct qeth_cmd_buffer *iob;
1161
1162 QETH_CARD_TEXT(card, 4, "simassp6");
1163 iob = qeth_l3_get_setassparms_cmd(card, ipa_func, cmd_code,
1164 0, QETH_PROT_IPV6);
1165 rc = qeth_l3_send_setassparms(card, iob, 0, 0,
1166 qeth_l3_default_setassparms_cb, NULL);
1167 return rc;
1168 }
1169 #endif
1170
qeth_l3_send_simple_setassparms(struct qeth_card * card,enum qeth_ipa_funcs ipa_func,__u16 cmd_code,long data)1171 static int qeth_l3_send_simple_setassparms(struct qeth_card *card,
1172 enum qeth_ipa_funcs ipa_func, __u16 cmd_code, long data)
1173 {
1174 int rc;
1175 int length = 0;
1176 struct qeth_cmd_buffer *iob;
1177
1178 QETH_CARD_TEXT(card, 4, "simassp4");
1179 if (data)
1180 length = sizeof(__u32);
1181 iob = qeth_l3_get_setassparms_cmd(card, ipa_func, cmd_code,
1182 length, QETH_PROT_IPV4);
1183 rc = qeth_l3_send_setassparms(card, iob, length, data,
1184 qeth_l3_default_setassparms_cb, NULL);
1185 return rc;
1186 }
1187
qeth_l3_start_ipa_arp_processing(struct qeth_card * card)1188 static int qeth_l3_start_ipa_arp_processing(struct qeth_card *card)
1189 {
1190 int rc;
1191
1192 QETH_CARD_TEXT(card, 3, "ipaarp");
1193
1194 if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) {
1195 dev_info(&card->gdev->dev,
1196 "ARP processing not supported on %s!\n",
1197 QETH_CARD_IFNAME(card));
1198 return 0;
1199 }
1200 rc = qeth_l3_send_simple_setassparms(card, IPA_ARP_PROCESSING,
1201 IPA_CMD_ASS_START, 0);
1202 if (rc) {
1203 dev_warn(&card->gdev->dev,
1204 "Starting ARP processing support for %s failed\n",
1205 QETH_CARD_IFNAME(card));
1206 }
1207 return rc;
1208 }
1209
qeth_l3_start_ipa_ip_fragmentation(struct qeth_card * card)1210 static int qeth_l3_start_ipa_ip_fragmentation(struct qeth_card *card)
1211 {
1212 int rc;
1213
1214 QETH_CARD_TEXT(card, 3, "ipaipfrg");
1215
1216 if (!qeth_is_supported(card, IPA_IP_FRAGMENTATION)) {
1217 dev_info(&card->gdev->dev,
1218 "Hardware IP fragmentation not supported on %s\n",
1219 QETH_CARD_IFNAME(card));
1220 return -EOPNOTSUPP;
1221 }
1222
1223 rc = qeth_l3_send_simple_setassparms(card, IPA_IP_FRAGMENTATION,
1224 IPA_CMD_ASS_START, 0);
1225 if (rc) {
1226 dev_warn(&card->gdev->dev,
1227 "Starting IP fragmentation support for %s failed\n",
1228 QETH_CARD_IFNAME(card));
1229 } else
1230 dev_info(&card->gdev->dev,
1231 "Hardware IP fragmentation enabled \n");
1232 return rc;
1233 }
1234
qeth_l3_start_ipa_source_mac(struct qeth_card * card)1235 static int qeth_l3_start_ipa_source_mac(struct qeth_card *card)
1236 {
1237 int rc;
1238
1239 QETH_CARD_TEXT(card, 3, "stsrcmac");
1240
1241 if (!qeth_is_supported(card, IPA_SOURCE_MAC)) {
1242 dev_info(&card->gdev->dev,
1243 "Inbound source MAC-address not supported on %s\n",
1244 QETH_CARD_IFNAME(card));
1245 return -EOPNOTSUPP;
1246 }
1247
1248 rc = qeth_l3_send_simple_setassparms(card, IPA_SOURCE_MAC,
1249 IPA_CMD_ASS_START, 0);
1250 if (rc)
1251 dev_warn(&card->gdev->dev,
1252 "Starting source MAC-address support for %s failed\n",
1253 QETH_CARD_IFNAME(card));
1254 return rc;
1255 }
1256
qeth_l3_start_ipa_vlan(struct qeth_card * card)1257 static int qeth_l3_start_ipa_vlan(struct qeth_card *card)
1258 {
1259 int rc = 0;
1260
1261 QETH_CARD_TEXT(card, 3, "strtvlan");
1262
1263 if (!qeth_is_supported(card, IPA_FULL_VLAN)) {
1264 dev_info(&card->gdev->dev,
1265 "VLAN not supported on %s\n", QETH_CARD_IFNAME(card));
1266 return -EOPNOTSUPP;
1267 }
1268
1269 rc = qeth_l3_send_simple_setassparms(card, IPA_VLAN_PRIO,
1270 IPA_CMD_ASS_START, 0);
1271 if (rc) {
1272 dev_warn(&card->gdev->dev,
1273 "Starting VLAN support for %s failed\n",
1274 QETH_CARD_IFNAME(card));
1275 } else {
1276 dev_info(&card->gdev->dev, "VLAN enabled\n");
1277 }
1278 return rc;
1279 }
1280
qeth_l3_start_ipa_multicast(struct qeth_card * card)1281 static int qeth_l3_start_ipa_multicast(struct qeth_card *card)
1282 {
1283 int rc;
1284
1285 QETH_CARD_TEXT(card, 3, "stmcast");
1286
1287 if (!qeth_is_supported(card, IPA_MULTICASTING)) {
1288 dev_info(&card->gdev->dev,
1289 "Multicast not supported on %s\n",
1290 QETH_CARD_IFNAME(card));
1291 return -EOPNOTSUPP;
1292 }
1293
1294 rc = qeth_l3_send_simple_setassparms(card, IPA_MULTICASTING,
1295 IPA_CMD_ASS_START, 0);
1296 if (rc) {
1297 dev_warn(&card->gdev->dev,
1298 "Starting multicast support for %s failed\n",
1299 QETH_CARD_IFNAME(card));
1300 } else {
1301 dev_info(&card->gdev->dev, "Multicast enabled\n");
1302 card->dev->flags |= IFF_MULTICAST;
1303 }
1304 return rc;
1305 }
1306
qeth_l3_query_ipassists_cb(struct qeth_card * card,struct qeth_reply * reply,unsigned long data)1307 static int qeth_l3_query_ipassists_cb(struct qeth_card *card,
1308 struct qeth_reply *reply, unsigned long data)
1309 {
1310 struct qeth_ipa_cmd *cmd;
1311
1312 QETH_DBF_TEXT(SETUP, 2, "qipasscb");
1313
1314 cmd = (struct qeth_ipa_cmd *) data;
1315 if (cmd->hdr.prot_version == QETH_PROT_IPV4) {
1316 card->options.ipa4.supported_funcs = cmd->hdr.ipa_supported;
1317 card->options.ipa4.enabled_funcs = cmd->hdr.ipa_enabled;
1318 } else {
1319 card->options.ipa6.supported_funcs = cmd->hdr.ipa_supported;
1320 card->options.ipa6.enabled_funcs = cmd->hdr.ipa_enabled;
1321 }
1322 QETH_DBF_TEXT(SETUP, 2, "suppenbl");
1323 QETH_DBF_TEXT_(SETUP, 2, "%x", cmd->hdr.ipa_supported);
1324 QETH_DBF_TEXT_(SETUP, 2, "%x", cmd->hdr.ipa_enabled);
1325 return 0;
1326 }
1327
qeth_l3_query_ipassists(struct qeth_card * card,enum qeth_prot_versions prot)1328 static int qeth_l3_query_ipassists(struct qeth_card *card,
1329 enum qeth_prot_versions prot)
1330 {
1331 int rc;
1332 struct qeth_cmd_buffer *iob;
1333
1334 QETH_DBF_TEXT_(SETUP, 2, "qipassi%i", prot);
1335 iob = qeth_get_ipacmd_buffer(card, IPA_CMD_QIPASSIST, prot);
1336 rc = qeth_send_ipa_cmd(card, iob, qeth_l3_query_ipassists_cb, NULL);
1337 return rc;
1338 }
1339
1340 #ifdef CONFIG_QETH_IPV6
qeth_l3_softsetup_ipv6(struct qeth_card * card)1341 static int qeth_l3_softsetup_ipv6(struct qeth_card *card)
1342 {
1343 int rc;
1344
1345 QETH_CARD_TEXT(card, 3, "softipv6");
1346
1347 if (card->info.type == QETH_CARD_TYPE_IQD)
1348 goto out;
1349
1350 rc = qeth_l3_query_ipassists(card, QETH_PROT_IPV6);
1351 if (rc) {
1352 dev_err(&card->gdev->dev,
1353 "Activating IPv6 support for %s failed\n",
1354 QETH_CARD_IFNAME(card));
1355 return rc;
1356 }
1357 rc = qeth_l3_send_simple_setassparms(card, IPA_IPV6,
1358 IPA_CMD_ASS_START, 3);
1359 if (rc) {
1360 dev_err(&card->gdev->dev,
1361 "Activating IPv6 support for %s failed\n",
1362 QETH_CARD_IFNAME(card));
1363 return rc;
1364 }
1365 rc = qeth_l3_send_simple_setassparms_ipv6(card, IPA_IPV6,
1366 IPA_CMD_ASS_START);
1367 if (rc) {
1368 dev_err(&card->gdev->dev,
1369 "Activating IPv6 support for %s failed\n",
1370 QETH_CARD_IFNAME(card));
1371 return rc;
1372 }
1373 rc = qeth_l3_send_simple_setassparms_ipv6(card, IPA_PASSTHRU,
1374 IPA_CMD_ASS_START);
1375 if (rc) {
1376 dev_warn(&card->gdev->dev,
1377 "Enabling the passthrough mode for %s failed\n",
1378 QETH_CARD_IFNAME(card));
1379 return rc;
1380 }
1381 out:
1382 dev_info(&card->gdev->dev, "IPV6 enabled\n");
1383 return 0;
1384 }
1385 #endif
1386
qeth_l3_start_ipa_ipv6(struct qeth_card * card)1387 static int qeth_l3_start_ipa_ipv6(struct qeth_card *card)
1388 {
1389 int rc = 0;
1390
1391 QETH_CARD_TEXT(card, 3, "strtipv6");
1392
1393 if (!qeth_is_supported(card, IPA_IPV6)) {
1394 dev_info(&card->gdev->dev,
1395 "IPv6 not supported on %s\n", QETH_CARD_IFNAME(card));
1396 return 0;
1397 }
1398 #ifdef CONFIG_QETH_IPV6
1399 rc = qeth_l3_softsetup_ipv6(card);
1400 #endif
1401 return rc ;
1402 }
1403
qeth_l3_start_ipa_broadcast(struct qeth_card * card)1404 static int qeth_l3_start_ipa_broadcast(struct qeth_card *card)
1405 {
1406 int rc;
1407
1408 QETH_CARD_TEXT(card, 3, "stbrdcst");
1409 card->info.broadcast_capable = 0;
1410 if (!qeth_is_supported(card, IPA_FILTERING)) {
1411 dev_info(&card->gdev->dev,
1412 "Broadcast not supported on %s\n",
1413 QETH_CARD_IFNAME(card));
1414 rc = -EOPNOTSUPP;
1415 goto out;
1416 }
1417 rc = qeth_l3_send_simple_setassparms(card, IPA_FILTERING,
1418 IPA_CMD_ASS_START, 0);
1419 if (rc) {
1420 dev_warn(&card->gdev->dev, "Enabling broadcast filtering for "
1421 "%s failed\n", QETH_CARD_IFNAME(card));
1422 goto out;
1423 }
1424
1425 rc = qeth_l3_send_simple_setassparms(card, IPA_FILTERING,
1426 IPA_CMD_ASS_CONFIGURE, 1);
1427 if (rc) {
1428 dev_warn(&card->gdev->dev,
1429 "Setting up broadcast filtering for %s failed\n",
1430 QETH_CARD_IFNAME(card));
1431 goto out;
1432 }
1433 card->info.broadcast_capable = QETH_BROADCAST_WITH_ECHO;
1434 dev_info(&card->gdev->dev, "Broadcast enabled\n");
1435 rc = qeth_l3_send_simple_setassparms(card, IPA_FILTERING,
1436 IPA_CMD_ASS_ENABLE, 1);
1437 if (rc) {
1438 dev_warn(&card->gdev->dev, "Setting up broadcast echo "
1439 "filtering for %s failed\n", QETH_CARD_IFNAME(card));
1440 goto out;
1441 }
1442 card->info.broadcast_capable = QETH_BROADCAST_WITHOUT_ECHO;
1443 out:
1444 if (card->info.broadcast_capable)
1445 card->dev->flags |= IFF_BROADCAST;
1446 else
1447 card->dev->flags &= ~IFF_BROADCAST;
1448 return rc;
1449 }
1450
qeth_l3_send_checksum_command(struct qeth_card * card)1451 static int qeth_l3_send_checksum_command(struct qeth_card *card)
1452 {
1453 int rc;
1454
1455 rc = qeth_l3_send_simple_setassparms(card, IPA_INBOUND_CHECKSUM,
1456 IPA_CMD_ASS_START, 0);
1457 if (rc) {
1458 dev_warn(&card->gdev->dev, "Starting HW checksumming for %s "
1459 "failed, using SW checksumming\n",
1460 QETH_CARD_IFNAME(card));
1461 return rc;
1462 }
1463 rc = qeth_l3_send_simple_setassparms(card, IPA_INBOUND_CHECKSUM,
1464 IPA_CMD_ASS_ENABLE,
1465 card->info.csum_mask);
1466 if (rc) {
1467 dev_warn(&card->gdev->dev, "Enabling HW checksumming for %s "
1468 "failed, using SW checksumming\n",
1469 QETH_CARD_IFNAME(card));
1470 return rc;
1471 }
1472 return 0;
1473 }
1474
qeth_l3_set_rx_csum(struct qeth_card * card,enum qeth_checksum_types csum_type)1475 int qeth_l3_set_rx_csum(struct qeth_card *card,
1476 enum qeth_checksum_types csum_type)
1477 {
1478 int rc = 0;
1479
1480 if (card->options.checksum_type == HW_CHECKSUMMING) {
1481 if ((csum_type != HW_CHECKSUMMING) &&
1482 (card->state != CARD_STATE_DOWN)) {
1483 rc = qeth_l3_send_simple_setassparms(card,
1484 IPA_INBOUND_CHECKSUM, IPA_CMD_ASS_STOP, 0);
1485 if (rc)
1486 return -EIO;
1487 }
1488 } else {
1489 if (csum_type == HW_CHECKSUMMING) {
1490 if (card->state != CARD_STATE_DOWN) {
1491 if (!qeth_is_supported(card,
1492 IPA_INBOUND_CHECKSUM))
1493 return -EPERM;
1494 rc = qeth_l3_send_checksum_command(card);
1495 if (rc)
1496 return -EIO;
1497 }
1498 }
1499 }
1500 card->options.checksum_type = csum_type;
1501 return rc;
1502 }
1503
qeth_l3_start_ipa_checksum(struct qeth_card * card)1504 static int qeth_l3_start_ipa_checksum(struct qeth_card *card)
1505 {
1506 int rc = 0;
1507
1508 QETH_CARD_TEXT(card, 3, "strtcsum");
1509
1510 if (card->options.checksum_type == NO_CHECKSUMMING) {
1511 dev_info(&card->gdev->dev,
1512 "Using no checksumming on %s.\n",
1513 QETH_CARD_IFNAME(card));
1514 return 0;
1515 }
1516 if (card->options.checksum_type == SW_CHECKSUMMING) {
1517 dev_info(&card->gdev->dev,
1518 "Using SW checksumming on %s.\n",
1519 QETH_CARD_IFNAME(card));
1520 return 0;
1521 }
1522 if (!qeth_is_supported(card, IPA_INBOUND_CHECKSUM)) {
1523 dev_info(&card->gdev->dev,
1524 "Inbound HW Checksumming not "
1525 "supported on %s,\ncontinuing "
1526 "using Inbound SW Checksumming\n",
1527 QETH_CARD_IFNAME(card));
1528 card->options.checksum_type = SW_CHECKSUMMING;
1529 return 0;
1530 }
1531 rc = qeth_l3_send_checksum_command(card);
1532 if (!rc)
1533 dev_info(&card->gdev->dev,
1534 "HW Checksumming (inbound) enabled\n");
1535
1536 return rc;
1537 }
1538
qeth_l3_start_ipa_tx_checksum(struct qeth_card * card)1539 static int qeth_l3_start_ipa_tx_checksum(struct qeth_card *card)
1540 {
1541 int rc = 0;
1542
1543 if (!qeth_is_supported(card, IPA_OUTBOUND_CHECKSUM))
1544 return rc;
1545 rc = qeth_l3_send_simple_setassparms(card, IPA_OUTBOUND_CHECKSUM,
1546 IPA_CMD_ASS_START, 0);
1547 if (rc)
1548 goto err_out;
1549 rc = qeth_l3_send_simple_setassparms(card, IPA_OUTBOUND_CHECKSUM,
1550 IPA_CMD_ASS_ENABLE, card->info.tx_csum_mask);
1551 if (rc)
1552 goto err_out;
1553 dev_info(&card->gdev->dev, "HW TX Checksumming enabled\n");
1554 return rc;
1555 err_out:
1556 dev_warn(&card->gdev->dev, "Enabling HW TX checksumming for %s "
1557 "failed, using SW TX checksumming\n", QETH_CARD_IFNAME(card));
1558 return rc;
1559 }
1560
qeth_l3_start_ipa_tso(struct qeth_card * card)1561 static int qeth_l3_start_ipa_tso(struct qeth_card *card)
1562 {
1563 int rc;
1564
1565 QETH_CARD_TEXT(card, 3, "sttso");
1566
1567 if (!qeth_is_supported(card, IPA_OUTBOUND_TSO)) {
1568 dev_info(&card->gdev->dev,
1569 "Outbound TSO not supported on %s\n",
1570 QETH_CARD_IFNAME(card));
1571 rc = -EOPNOTSUPP;
1572 } else {
1573 rc = qeth_l3_send_simple_setassparms(card, IPA_OUTBOUND_TSO,
1574 IPA_CMD_ASS_START, 0);
1575 if (rc)
1576 dev_warn(&card->gdev->dev, "Starting outbound TCP "
1577 "segmentation offload for %s failed\n",
1578 QETH_CARD_IFNAME(card));
1579 else
1580 dev_info(&card->gdev->dev,
1581 "Outbound TSO enabled\n");
1582 }
1583 if (rc && (card->options.large_send == QETH_LARGE_SEND_TSO)) {
1584 card->options.large_send = QETH_LARGE_SEND_NO;
1585 card->dev->features &= ~(NETIF_F_TSO | NETIF_F_SG);
1586 }
1587 return rc;
1588 }
1589
qeth_l3_start_ipassists(struct qeth_card * card)1590 static int qeth_l3_start_ipassists(struct qeth_card *card)
1591 {
1592 QETH_CARD_TEXT(card, 3, "strtipas");
1593
1594 qeth_set_access_ctrl_online(card); /* go on*/
1595 qeth_l3_start_ipa_arp_processing(card); /* go on*/
1596 qeth_l3_start_ipa_ip_fragmentation(card); /* go on*/
1597 qeth_l3_start_ipa_source_mac(card); /* go on*/
1598 qeth_l3_start_ipa_vlan(card); /* go on*/
1599 qeth_l3_start_ipa_multicast(card); /* go on*/
1600 qeth_l3_start_ipa_ipv6(card); /* go on*/
1601 qeth_l3_start_ipa_broadcast(card); /* go on*/
1602 qeth_l3_start_ipa_checksum(card); /* go on*/
1603 qeth_l3_start_ipa_tx_checksum(card);
1604 qeth_l3_start_ipa_tso(card); /* go on*/
1605 return 0;
1606 }
1607
qeth_l3_iqd_read_initial_mac_cb(struct qeth_card * card,struct qeth_reply * reply,unsigned long data)1608 static int qeth_l3_iqd_read_initial_mac_cb(struct qeth_card *card,
1609 struct qeth_reply *reply, unsigned long data)
1610 {
1611 struct qeth_ipa_cmd *cmd;
1612
1613 cmd = (struct qeth_ipa_cmd *) data;
1614 if (cmd->hdr.return_code == 0)
1615 memcpy(card->dev->dev_addr,
1616 cmd->data.create_destroy_addr.unique_id, ETH_ALEN);
1617 else
1618 random_ether_addr(card->dev->dev_addr);
1619
1620 return 0;
1621 }
1622
qeth_l3_iqd_read_initial_mac(struct qeth_card * card)1623 static int qeth_l3_iqd_read_initial_mac(struct qeth_card *card)
1624 {
1625 int rc = 0;
1626 struct qeth_cmd_buffer *iob;
1627 struct qeth_ipa_cmd *cmd;
1628
1629 QETH_DBF_TEXT(SETUP, 2, "hsrmac");
1630
1631 iob = qeth_get_ipacmd_buffer(card, IPA_CMD_CREATE_ADDR,
1632 QETH_PROT_IPV6);
1633 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
1634 *((__u16 *) &cmd->data.create_destroy_addr.unique_id[6]) =
1635 card->info.unique_id;
1636
1637 rc = qeth_send_ipa_cmd(card, iob, qeth_l3_iqd_read_initial_mac_cb,
1638 NULL);
1639 return rc;
1640 }
1641
qeth_l3_get_unique_id_cb(struct qeth_card * card,struct qeth_reply * reply,unsigned long data)1642 static int qeth_l3_get_unique_id_cb(struct qeth_card *card,
1643 struct qeth_reply *reply, unsigned long data)
1644 {
1645 struct qeth_ipa_cmd *cmd;
1646
1647 cmd = (struct qeth_ipa_cmd *) data;
1648 if (cmd->hdr.return_code == 0)
1649 card->info.unique_id = *((__u16 *)
1650 &cmd->data.create_destroy_addr.unique_id[6]);
1651 else {
1652 card->info.unique_id = UNIQUE_ID_IF_CREATE_ADDR_FAILED |
1653 UNIQUE_ID_NOT_BY_CARD;
1654 dev_warn(&card->gdev->dev, "The network adapter failed to "
1655 "generate a unique ID\n");
1656 }
1657 return 0;
1658 }
1659
qeth_l3_get_unique_id(struct qeth_card * card)1660 static int qeth_l3_get_unique_id(struct qeth_card *card)
1661 {
1662 int rc = 0;
1663 struct qeth_cmd_buffer *iob;
1664 struct qeth_ipa_cmd *cmd;
1665
1666 QETH_DBF_TEXT(SETUP, 2, "guniqeid");
1667
1668 if (!qeth_is_supported(card, IPA_IPV6)) {
1669 card->info.unique_id = UNIQUE_ID_IF_CREATE_ADDR_FAILED |
1670 UNIQUE_ID_NOT_BY_CARD;
1671 return 0;
1672 }
1673
1674 iob = qeth_get_ipacmd_buffer(card, IPA_CMD_CREATE_ADDR,
1675 QETH_PROT_IPV6);
1676 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
1677 *((__u16 *) &cmd->data.create_destroy_addr.unique_id[6]) =
1678 card->info.unique_id;
1679
1680 rc = qeth_send_ipa_cmd(card, iob, qeth_l3_get_unique_id_cb, NULL);
1681 return rc;
1682 }
1683
1684 static int
qeth_diags_trace_cb(struct qeth_card * card,struct qeth_reply * reply,unsigned long data)1685 qeth_diags_trace_cb(struct qeth_card *card, struct qeth_reply *reply,
1686 unsigned long data)
1687 {
1688 struct qeth_ipa_cmd *cmd;
1689 __u16 rc;
1690
1691 QETH_DBF_TEXT(SETUP, 2, "diastrcb");
1692
1693 cmd = (struct qeth_ipa_cmd *)data;
1694 rc = cmd->hdr.return_code;
1695 if (rc)
1696 QETH_CARD_TEXT_(card, 2, "dxter%x", rc);
1697 switch (cmd->data.diagass.action) {
1698 case QETH_DIAGS_CMD_TRACE_QUERY:
1699 break;
1700 case QETH_DIAGS_CMD_TRACE_DISABLE:
1701 switch (rc) {
1702 case 0:
1703 case IPA_RC_INVALID_SUBCMD:
1704 card->info.promisc_mode = SET_PROMISC_MODE_OFF;
1705 dev_info(&card->gdev->dev, "The HiperSockets network "
1706 "traffic analyzer is deactivated\n");
1707 break;
1708 default:
1709 break;
1710 }
1711 break;
1712 case QETH_DIAGS_CMD_TRACE_ENABLE:
1713 switch (rc) {
1714 case 0:
1715 card->info.promisc_mode = SET_PROMISC_MODE_ON;
1716 dev_info(&card->gdev->dev, "The HiperSockets network "
1717 "traffic analyzer is activated\n");
1718 break;
1719 case IPA_RC_HARDWARE_AUTH_ERROR:
1720 dev_warn(&card->gdev->dev, "The device is not "
1721 "authorized to run as a HiperSockets network "
1722 "traffic analyzer\n");
1723 break;
1724 case IPA_RC_TRACE_ALREADY_ACTIVE:
1725 dev_warn(&card->gdev->dev, "A HiperSockets "
1726 "network traffic analyzer is already "
1727 "active in the HiperSockets LAN\n");
1728 break;
1729 default:
1730 break;
1731 }
1732 break;
1733 default:
1734 QETH_DBF_MESSAGE(2, "Unknown sniffer action (0x%04x) on %s\n",
1735 cmd->data.diagass.action, QETH_CARD_IFNAME(card));
1736 }
1737
1738 return 0;
1739 }
1740
1741 static int
qeth_diags_trace(struct qeth_card * card,enum qeth_diags_trace_cmds diags_cmd)1742 qeth_diags_trace(struct qeth_card *card, enum qeth_diags_trace_cmds diags_cmd)
1743 {
1744 struct qeth_cmd_buffer *iob;
1745 struct qeth_ipa_cmd *cmd;
1746
1747 QETH_DBF_TEXT(SETUP, 2, "diagtrac");
1748
1749 iob = qeth_get_ipacmd_buffer(card, IPA_CMD_SET_DIAG_ASS, 0);
1750 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
1751 cmd->data.diagass.subcmd_len = 16;
1752 cmd->data.diagass.subcmd = QETH_DIAGS_CMD_TRACE;
1753 cmd->data.diagass.type = QETH_DIAGS_TYPE_HIPERSOCKET;
1754 cmd->data.diagass.action = diags_cmd;
1755 return qeth_send_ipa_cmd(card, iob, qeth_diags_trace_cb, NULL);
1756 }
1757
qeth_l3_get_mac_for_ipm(__u32 ipm,char * mac,struct net_device * dev)1758 static void qeth_l3_get_mac_for_ipm(__u32 ipm, char *mac,
1759 struct net_device *dev)
1760 {
1761 if (dev->type == ARPHRD_IEEE802_TR)
1762 ip_tr_mc_map(ipm, mac);
1763 else
1764 ip_eth_mc_map(ipm, mac);
1765 }
1766
qeth_l3_add_mc(struct qeth_card * card,struct in_device * in4_dev)1767 static void qeth_l3_add_mc(struct qeth_card *card, struct in_device *in4_dev)
1768 {
1769 struct qeth_ipaddr *ipm;
1770 struct ip_mc_list *im4;
1771 char buf[MAX_ADDR_LEN];
1772
1773 QETH_CARD_TEXT(card, 4, "addmc");
1774 for (im4 = rcu_dereference(in4_dev->mc_list); im4 != NULL;
1775 im4 = rcu_dereference(im4->next_rcu)) {
1776 qeth_l3_get_mac_for_ipm(im4->multiaddr, buf, in4_dev->dev);
1777 ipm = qeth_l3_get_addr_buffer(QETH_PROT_IPV4);
1778 if (!ipm)
1779 continue;
1780 ipm->u.a4.addr = im4->multiaddr;
1781 memcpy(ipm->mac, buf, OSA_ADDR_LEN);
1782 ipm->is_multicast = 1;
1783 if (!qeth_l3_add_ip(card, ipm))
1784 kfree(ipm);
1785 }
1786 }
1787
qeth_l3_add_vlan_mc(struct qeth_card * card)1788 static void qeth_l3_add_vlan_mc(struct qeth_card *card)
1789 {
1790 struct in_device *in_dev;
1791 struct vlan_group *vg;
1792 int i;
1793
1794 QETH_CARD_TEXT(card, 4, "addmcvl");
1795 if (!qeth_is_supported(card, IPA_FULL_VLAN) || (card->vlangrp == NULL))
1796 return;
1797
1798 vg = card->vlangrp;
1799 for (i = 0; i < VLAN_N_VID; i++) {
1800 struct net_device *netdev = vlan_group_get_device(vg, i);
1801 if (netdev == NULL ||
1802 !(netdev->flags & IFF_UP))
1803 continue;
1804 in_dev = in_dev_get(netdev);
1805 if (!in_dev)
1806 continue;
1807 rcu_read_lock();
1808 qeth_l3_add_mc(card, in_dev);
1809 rcu_read_unlock();
1810 in_dev_put(in_dev);
1811 }
1812 }
1813
qeth_l3_add_multicast_ipv4(struct qeth_card * card)1814 static void qeth_l3_add_multicast_ipv4(struct qeth_card *card)
1815 {
1816 struct in_device *in4_dev;
1817
1818 QETH_CARD_TEXT(card, 4, "chkmcv4");
1819 in4_dev = in_dev_get(card->dev);
1820 if (in4_dev == NULL)
1821 return;
1822 rcu_read_lock();
1823 qeth_l3_add_mc(card, in4_dev);
1824 qeth_l3_add_vlan_mc(card);
1825 rcu_read_unlock();
1826 in_dev_put(in4_dev);
1827 }
1828
1829 #ifdef CONFIG_QETH_IPV6
qeth_l3_add_mc6(struct qeth_card * card,struct inet6_dev * in6_dev)1830 static void qeth_l3_add_mc6(struct qeth_card *card, struct inet6_dev *in6_dev)
1831 {
1832 struct qeth_ipaddr *ipm;
1833 struct ifmcaddr6 *im6;
1834 char buf[MAX_ADDR_LEN];
1835
1836 QETH_CARD_TEXT(card, 4, "addmc6");
1837 for (im6 = in6_dev->mc_list; im6 != NULL; im6 = im6->next) {
1838 ndisc_mc_map(&im6->mca_addr, buf, in6_dev->dev, 0);
1839 ipm = qeth_l3_get_addr_buffer(QETH_PROT_IPV6);
1840 if (!ipm)
1841 continue;
1842 ipm->is_multicast = 1;
1843 memcpy(ipm->mac, buf, OSA_ADDR_LEN);
1844 memcpy(&ipm->u.a6.addr, &im6->mca_addr.s6_addr,
1845 sizeof(struct in6_addr));
1846 if (!qeth_l3_add_ip(card, ipm))
1847 kfree(ipm);
1848 }
1849 }
1850
qeth_l3_add_vlan_mc6(struct qeth_card * card)1851 static void qeth_l3_add_vlan_mc6(struct qeth_card *card)
1852 {
1853 struct inet6_dev *in_dev;
1854 struct vlan_group *vg;
1855 int i;
1856
1857 QETH_CARD_TEXT(card, 4, "admc6vl");
1858 if (!qeth_is_supported(card, IPA_FULL_VLAN) || (card->vlangrp == NULL))
1859 return;
1860
1861 vg = card->vlangrp;
1862 for (i = 0; i < VLAN_N_VID; i++) {
1863 struct net_device *netdev = vlan_group_get_device(vg, i);
1864 if (netdev == NULL ||
1865 !(netdev->flags & IFF_UP))
1866 continue;
1867 in_dev = in6_dev_get(netdev);
1868 if (!in_dev)
1869 continue;
1870 read_lock_bh(&in_dev->lock);
1871 qeth_l3_add_mc6(card, in_dev);
1872 read_unlock_bh(&in_dev->lock);
1873 in6_dev_put(in_dev);
1874 }
1875 }
1876
qeth_l3_add_multicast_ipv6(struct qeth_card * card)1877 static void qeth_l3_add_multicast_ipv6(struct qeth_card *card)
1878 {
1879 struct inet6_dev *in6_dev;
1880
1881 QETH_CARD_TEXT(card, 4, "chkmcv6");
1882 if (!qeth_is_supported(card, IPA_IPV6))
1883 return ;
1884 in6_dev = in6_dev_get(card->dev);
1885 if (in6_dev == NULL)
1886 return;
1887 read_lock_bh(&in6_dev->lock);
1888 qeth_l3_add_mc6(card, in6_dev);
1889 qeth_l3_add_vlan_mc6(card);
1890 read_unlock_bh(&in6_dev->lock);
1891 in6_dev_put(in6_dev);
1892 }
1893 #endif /* CONFIG_QETH_IPV6 */
1894
qeth_l3_free_vlan_addresses4(struct qeth_card * card,unsigned short vid)1895 static void qeth_l3_free_vlan_addresses4(struct qeth_card *card,
1896 unsigned short vid)
1897 {
1898 struct in_device *in_dev;
1899 struct in_ifaddr *ifa;
1900 struct qeth_ipaddr *addr;
1901
1902 QETH_CARD_TEXT(card, 4, "frvaddr4");
1903
1904 in_dev = in_dev_get(vlan_group_get_device(card->vlangrp, vid));
1905 if (!in_dev)
1906 return;
1907 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
1908 addr = qeth_l3_get_addr_buffer(QETH_PROT_IPV4);
1909 if (addr) {
1910 addr->u.a4.addr = ifa->ifa_address;
1911 addr->u.a4.mask = ifa->ifa_mask;
1912 addr->type = QETH_IP_TYPE_NORMAL;
1913 if (!qeth_l3_delete_ip(card, addr))
1914 kfree(addr);
1915 }
1916 }
1917 in_dev_put(in_dev);
1918 }
1919
qeth_l3_free_vlan_addresses6(struct qeth_card * card,unsigned short vid)1920 static void qeth_l3_free_vlan_addresses6(struct qeth_card *card,
1921 unsigned short vid)
1922 {
1923 #ifdef CONFIG_QETH_IPV6
1924 struct inet6_dev *in6_dev;
1925 struct inet6_ifaddr *ifa;
1926 struct qeth_ipaddr *addr;
1927
1928 QETH_CARD_TEXT(card, 4, "frvaddr6");
1929
1930 in6_dev = in6_dev_get(vlan_group_get_device(card->vlangrp, vid));
1931 if (!in6_dev)
1932 return;
1933 list_for_each_entry(ifa, &in6_dev->addr_list, if_list) {
1934 addr = qeth_l3_get_addr_buffer(QETH_PROT_IPV6);
1935 if (addr) {
1936 memcpy(&addr->u.a6.addr, &ifa->addr,
1937 sizeof(struct in6_addr));
1938 addr->u.a6.pfxlen = ifa->prefix_len;
1939 addr->type = QETH_IP_TYPE_NORMAL;
1940 if (!qeth_l3_delete_ip(card, addr))
1941 kfree(addr);
1942 }
1943 }
1944 in6_dev_put(in6_dev);
1945 #endif /* CONFIG_QETH_IPV6 */
1946 }
1947
qeth_l3_free_vlan_addresses(struct qeth_card * card,unsigned short vid)1948 static void qeth_l3_free_vlan_addresses(struct qeth_card *card,
1949 unsigned short vid)
1950 {
1951 if (!card->vlangrp)
1952 return;
1953 qeth_l3_free_vlan_addresses4(card, vid);
1954 qeth_l3_free_vlan_addresses6(card, vid);
1955 }
1956
qeth_l3_vlan_rx_register(struct net_device * dev,struct vlan_group * grp)1957 static void qeth_l3_vlan_rx_register(struct net_device *dev,
1958 struct vlan_group *grp)
1959 {
1960 struct qeth_card *card = dev->ml_priv;
1961 unsigned long flags;
1962
1963 QETH_CARD_TEXT(card, 4, "vlanreg");
1964 spin_lock_irqsave(&card->vlanlock, flags);
1965 card->vlangrp = grp;
1966 spin_unlock_irqrestore(&card->vlanlock, flags);
1967 }
1968
qeth_l3_vlan_rx_add_vid(struct net_device * dev,unsigned short vid)1969 static void qeth_l3_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
1970 {
1971 return;
1972 }
1973
qeth_l3_vlan_rx_kill_vid(struct net_device * dev,unsigned short vid)1974 static void qeth_l3_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
1975 {
1976 struct qeth_card *card = dev->ml_priv;
1977 unsigned long flags;
1978
1979 QETH_CARD_TEXT_(card, 4, "kid:%d", vid);
1980 if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) {
1981 QETH_CARD_TEXT(card, 3, "kidREC");
1982 return;
1983 }
1984 spin_lock_irqsave(&card->vlanlock, flags);
1985 /* unregister IP addresses of vlan device */
1986 qeth_l3_free_vlan_addresses(card, vid);
1987 vlan_group_set_device(card->vlangrp, vid, NULL);
1988 spin_unlock_irqrestore(&card->vlanlock, flags);
1989 qeth_l3_set_multicast_list(card->dev);
1990 }
1991
qeth_l3_rebuild_skb(struct qeth_card * card,struct sk_buff * skb,struct qeth_hdr * hdr,unsigned short * vlan_id)1992 static inline int qeth_l3_rebuild_skb(struct qeth_card *card,
1993 struct sk_buff *skb, struct qeth_hdr *hdr,
1994 unsigned short *vlan_id)
1995 {
1996 __be16 prot;
1997 struct iphdr *ip_hdr;
1998 unsigned char tg_addr[MAX_ADDR_LEN];
1999 int is_vlan = 0;
2000
2001 if (!(hdr->hdr.l3.flags & QETH_HDR_PASSTHRU)) {
2002 prot = htons((hdr->hdr.l3.flags & QETH_HDR_IPV6)? ETH_P_IPV6 :
2003 ETH_P_IP);
2004 switch (hdr->hdr.l3.flags & QETH_HDR_CAST_MASK) {
2005 case QETH_CAST_MULTICAST:
2006 switch (prot) {
2007 #ifdef CONFIG_QETH_IPV6
2008 case __constant_htons(ETH_P_IPV6):
2009 ndisc_mc_map((struct in6_addr *)
2010 skb->data + 24,
2011 tg_addr, card->dev, 0);
2012 break;
2013 #endif
2014 case __constant_htons(ETH_P_IP):
2015 ip_hdr = (struct iphdr *)skb->data;
2016 (card->dev->type == ARPHRD_IEEE802_TR) ?
2017 ip_tr_mc_map(ip_hdr->daddr, tg_addr):
2018 ip_eth_mc_map(ip_hdr->daddr, tg_addr);
2019 break;
2020 default:
2021 memcpy(tg_addr, card->dev->broadcast,
2022 card->dev->addr_len);
2023 }
2024 card->stats.multicast++;
2025 skb->pkt_type = PACKET_MULTICAST;
2026 break;
2027 case QETH_CAST_BROADCAST:
2028 memcpy(tg_addr, card->dev->broadcast,
2029 card->dev->addr_len);
2030 card->stats.multicast++;
2031 skb->pkt_type = PACKET_BROADCAST;
2032 break;
2033 case QETH_CAST_UNICAST:
2034 case QETH_CAST_ANYCAST:
2035 case QETH_CAST_NOCAST:
2036 default:
2037 if (card->options.sniffer)
2038 skb->pkt_type = PACKET_OTHERHOST;
2039 else
2040 skb->pkt_type = PACKET_HOST;
2041 memcpy(tg_addr, card->dev->dev_addr,
2042 card->dev->addr_len);
2043 }
2044 if (hdr->hdr.l3.ext_flags & QETH_HDR_EXT_SRC_MAC_ADDR)
2045 card->dev->header_ops->create(skb, card->dev, prot,
2046 tg_addr, &hdr->hdr.l3.dest_addr[2],
2047 card->dev->addr_len);
2048 else
2049 card->dev->header_ops->create(skb, card->dev, prot,
2050 tg_addr, "FAKELL", card->dev->addr_len);
2051 }
2052
2053 #ifdef CONFIG_TR
2054 if (card->dev->type == ARPHRD_IEEE802_TR)
2055 skb->protocol = tr_type_trans(skb, card->dev);
2056 else
2057 #endif
2058 skb->protocol = eth_type_trans(skb, card->dev);
2059
2060 if (hdr->hdr.l3.ext_flags &
2061 (QETH_HDR_EXT_VLAN_FRAME | QETH_HDR_EXT_INCLUDE_VLAN_TAG)) {
2062 *vlan_id = (hdr->hdr.l3.ext_flags & QETH_HDR_EXT_VLAN_FRAME) ?
2063 hdr->hdr.l3.vlan_id : *((u16 *)&hdr->hdr.l3.dest_addr[12]);
2064 is_vlan = 1;
2065 }
2066
2067 switch (card->options.checksum_type) {
2068 case SW_CHECKSUMMING:
2069 skb->ip_summed = CHECKSUM_NONE;
2070 break;
2071 case NO_CHECKSUMMING:
2072 skb->ip_summed = CHECKSUM_UNNECESSARY;
2073 break;
2074 case HW_CHECKSUMMING:
2075 if ((hdr->hdr.l3.ext_flags &
2076 (QETH_HDR_EXT_CSUM_HDR_REQ |
2077 QETH_HDR_EXT_CSUM_TRANSP_REQ)) ==
2078 (QETH_HDR_EXT_CSUM_HDR_REQ |
2079 QETH_HDR_EXT_CSUM_TRANSP_REQ))
2080 skb->ip_summed = CHECKSUM_UNNECESSARY;
2081 else
2082 skb->ip_summed = CHECKSUM_NONE;
2083 }
2084
2085 return is_vlan;
2086 }
2087
qeth_l3_process_inbound_buffer(struct qeth_card * card,int budget,int * done)2088 static int qeth_l3_process_inbound_buffer(struct qeth_card *card,
2089 int budget, int *done)
2090 {
2091 int work_done = 0;
2092 struct sk_buff *skb;
2093 struct qeth_hdr *hdr;
2094 __u16 vlan_tag = 0;
2095 int is_vlan;
2096 unsigned int len;
2097
2098 *done = 0;
2099 BUG_ON(!budget);
2100 while (budget) {
2101 skb = qeth_core_get_next_skb(card,
2102 card->qdio.in_q->bufs[card->rx.b_index].buffer,
2103 &card->rx.b_element, &card->rx.e_offset, &hdr);
2104 if (!skb) {
2105 *done = 1;
2106 break;
2107 }
2108 skb->dev = card->dev;
2109 switch (hdr->hdr.l3.id) {
2110 case QETH_HEADER_TYPE_LAYER3:
2111 is_vlan = qeth_l3_rebuild_skb(card, skb, hdr,
2112 &vlan_tag);
2113 len = skb->len;
2114 if (is_vlan && !card->options.sniffer)
2115 vlan_gro_receive(&card->napi, card->vlangrp,
2116 vlan_tag, skb);
2117 else
2118 napi_gro_receive(&card->napi, skb);
2119 break;
2120 case QETH_HEADER_TYPE_LAYER2: /* for HiperSockets sniffer */
2121 skb->pkt_type = PACKET_HOST;
2122 skb->protocol = eth_type_trans(skb, skb->dev);
2123 len = skb->len;
2124 netif_receive_skb(skb);
2125 break;
2126 default:
2127 dev_kfree_skb_any(skb);
2128 QETH_CARD_TEXT(card, 3, "inbunkno");
2129 QETH_DBF_HEX(CTRL, 3, hdr, QETH_DBF_CTRL_LEN);
2130 continue;
2131 }
2132 work_done++;
2133 budget--;
2134 card->stats.rx_packets++;
2135 card->stats.rx_bytes += len;
2136 }
2137 return work_done;
2138 }
2139
qeth_l3_poll(struct napi_struct * napi,int budget)2140 static int qeth_l3_poll(struct napi_struct *napi, int budget)
2141 {
2142 struct qeth_card *card = container_of(napi, struct qeth_card, napi);
2143 int work_done = 0;
2144 struct qeth_qdio_buffer *buffer;
2145 int done;
2146 int new_budget = budget;
2147
2148 if (card->options.performance_stats) {
2149 card->perf_stats.inbound_cnt++;
2150 card->perf_stats.inbound_start_time = qeth_get_micros();
2151 }
2152
2153 while (1) {
2154 if (!card->rx.b_count) {
2155 card->rx.qdio_err = 0;
2156 card->rx.b_count = qdio_get_next_buffers(
2157 card->data.ccwdev, 0, &card->rx.b_index,
2158 &card->rx.qdio_err);
2159 if (card->rx.b_count <= 0) {
2160 card->rx.b_count = 0;
2161 break;
2162 }
2163 card->rx.b_element =
2164 &card->qdio.in_q->bufs[card->rx.b_index]
2165 .buffer->element[0];
2166 card->rx.e_offset = 0;
2167 }
2168
2169 while (card->rx.b_count) {
2170 buffer = &card->qdio.in_q->bufs[card->rx.b_index];
2171 if (!(card->rx.qdio_err &&
2172 qeth_check_qdio_errors(card, buffer->buffer,
2173 card->rx.qdio_err, "qinerr")))
2174 work_done += qeth_l3_process_inbound_buffer(
2175 card, new_budget, &done);
2176 else
2177 done = 1;
2178
2179 if (done) {
2180 if (card->options.performance_stats)
2181 card->perf_stats.bufs_rec++;
2182 qeth_put_buffer_pool_entry(card,
2183 buffer->pool_entry);
2184 qeth_queue_input_buffer(card, card->rx.b_index);
2185 card->rx.b_count--;
2186 if (card->rx.b_count) {
2187 card->rx.b_index =
2188 (card->rx.b_index + 1) %
2189 QDIO_MAX_BUFFERS_PER_Q;
2190 card->rx.b_element =
2191 &card->qdio.in_q
2192 ->bufs[card->rx.b_index]
2193 .buffer->element[0];
2194 card->rx.e_offset = 0;
2195 }
2196 }
2197
2198 if (work_done >= budget)
2199 goto out;
2200 else
2201 new_budget = budget - work_done;
2202 }
2203 }
2204
2205 napi_complete(napi);
2206 if (qdio_start_irq(card->data.ccwdev, 0))
2207 napi_schedule(&card->napi);
2208 out:
2209 if (card->options.performance_stats)
2210 card->perf_stats.inbound_time += qeth_get_micros() -
2211 card->perf_stats.inbound_start_time;
2212 return work_done;
2213 }
2214
qeth_l3_verify_vlan_dev(struct net_device * dev,struct qeth_card * card)2215 static int qeth_l3_verify_vlan_dev(struct net_device *dev,
2216 struct qeth_card *card)
2217 {
2218 int rc = 0;
2219 struct vlan_group *vg;
2220 int i;
2221
2222 vg = card->vlangrp;
2223 if (!vg)
2224 return rc;
2225
2226 for (i = 0; i < VLAN_N_VID; i++) {
2227 if (vlan_group_get_device(vg, i) == dev) {
2228 rc = QETH_VLAN_CARD;
2229 break;
2230 }
2231 }
2232
2233 if (rc && !(vlan_dev_real_dev(dev)->ml_priv == (void *)card))
2234 return 0;
2235
2236 return rc;
2237 }
2238
qeth_l3_verify_dev(struct net_device * dev)2239 static int qeth_l3_verify_dev(struct net_device *dev)
2240 {
2241 struct qeth_card *card;
2242 unsigned long flags;
2243 int rc = 0;
2244
2245 read_lock_irqsave(&qeth_core_card_list.rwlock, flags);
2246 list_for_each_entry(card, &qeth_core_card_list.list, list) {
2247 if (card->dev == dev) {
2248 rc = QETH_REAL_CARD;
2249 break;
2250 }
2251 rc = qeth_l3_verify_vlan_dev(dev, card);
2252 if (rc)
2253 break;
2254 }
2255 read_unlock_irqrestore(&qeth_core_card_list.rwlock, flags);
2256
2257 return rc;
2258 }
2259
qeth_l3_get_card_from_dev(struct net_device * dev)2260 static struct qeth_card *qeth_l3_get_card_from_dev(struct net_device *dev)
2261 {
2262 struct qeth_card *card = NULL;
2263 int rc;
2264
2265 rc = qeth_l3_verify_dev(dev);
2266 if (rc == QETH_REAL_CARD)
2267 card = dev->ml_priv;
2268 else if (rc == QETH_VLAN_CARD)
2269 card = vlan_dev_real_dev(dev)->ml_priv;
2270 if (card && card->options.layer2)
2271 card = NULL;
2272 if (card)
2273 QETH_CARD_TEXT_(card, 4, "%d", rc);
2274 return card ;
2275 }
2276
qeth_l3_stop_card(struct qeth_card * card,int recovery_mode)2277 static int qeth_l3_stop_card(struct qeth_card *card, int recovery_mode)
2278 {
2279 int rc = 0;
2280
2281 QETH_DBF_TEXT(SETUP, 2, "stopcard");
2282 QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *));
2283
2284 qeth_set_allowed_threads(card, 0, 1);
2285 if (card->options.sniffer &&
2286 (card->info.promisc_mode == SET_PROMISC_MODE_ON))
2287 qeth_diags_trace(card, QETH_DIAGS_CMD_TRACE_DISABLE);
2288 if (card->read.state == CH_STATE_UP &&
2289 card->write.state == CH_STATE_UP &&
2290 (card->state == CARD_STATE_UP)) {
2291 if (recovery_mode)
2292 qeth_l3_stop(card->dev);
2293 else {
2294 rtnl_lock();
2295 dev_close(card->dev);
2296 rtnl_unlock();
2297 }
2298 card->state = CARD_STATE_SOFTSETUP;
2299 }
2300 if (card->state == CARD_STATE_SOFTSETUP) {
2301 qeth_l3_clear_ip_list(card, 1);
2302 qeth_clear_ipacmd_list(card);
2303 card->state = CARD_STATE_HARDSETUP;
2304 }
2305 if (card->state == CARD_STATE_HARDSETUP) {
2306 qeth_qdio_clear_card(card, 0);
2307 qeth_clear_qdio_buffers(card);
2308 qeth_clear_working_pool_list(card);
2309 card->state = CARD_STATE_DOWN;
2310 }
2311 if (card->state == CARD_STATE_DOWN) {
2312 qeth_clear_cmd_buffers(&card->read);
2313 qeth_clear_cmd_buffers(&card->write);
2314 }
2315 return rc;
2316 }
2317
2318 /*
2319 * test for and Switch promiscuous mode (on or off)
2320 * either for guestlan or HiperSocket Sniffer
2321 */
2322 static void
qeth_l3_handle_promisc_mode(struct qeth_card * card)2323 qeth_l3_handle_promisc_mode(struct qeth_card *card)
2324 {
2325 struct net_device *dev = card->dev;
2326
2327 if (((dev->flags & IFF_PROMISC) &&
2328 (card->info.promisc_mode == SET_PROMISC_MODE_ON)) ||
2329 (!(dev->flags & IFF_PROMISC) &&
2330 (card->info.promisc_mode == SET_PROMISC_MODE_OFF)))
2331 return;
2332
2333 if (card->info.guestlan) { /* Guestlan trace */
2334 if (qeth_adp_supported(card, IPA_SETADP_SET_PROMISC_MODE))
2335 qeth_setadp_promisc_mode(card);
2336 } else if (card->options.sniffer && /* HiperSockets trace */
2337 qeth_adp_supported(card, IPA_SETADP_SET_DIAG_ASSIST)) {
2338 if (dev->flags & IFF_PROMISC) {
2339 QETH_CARD_TEXT(card, 3, "+promisc");
2340 qeth_diags_trace(card, QETH_DIAGS_CMD_TRACE_ENABLE);
2341 } else {
2342 QETH_CARD_TEXT(card, 3, "-promisc");
2343 qeth_diags_trace(card, QETH_DIAGS_CMD_TRACE_DISABLE);
2344 }
2345 }
2346 }
2347
qeth_l3_set_multicast_list(struct net_device * dev)2348 static void qeth_l3_set_multicast_list(struct net_device *dev)
2349 {
2350 struct qeth_card *card = dev->ml_priv;
2351
2352 QETH_CARD_TEXT(card, 3, "setmulti");
2353 if (qeth_threads_running(card, QETH_RECOVER_THREAD) &&
2354 (card->state != CARD_STATE_UP))
2355 return;
2356 if (!card->options.sniffer) {
2357 qeth_l3_delete_mc_addresses(card);
2358 qeth_l3_add_multicast_ipv4(card);
2359 #ifdef CONFIG_QETH_IPV6
2360 qeth_l3_add_multicast_ipv6(card);
2361 #endif
2362 qeth_l3_set_ip_addr_list(card);
2363 if (!qeth_adp_supported(card, IPA_SETADP_SET_PROMISC_MODE))
2364 return;
2365 }
2366 qeth_l3_handle_promisc_mode(card);
2367 }
2368
qeth_l3_arp_get_error_cause(int * rc)2369 static const char *qeth_l3_arp_get_error_cause(int *rc)
2370 {
2371 switch (*rc) {
2372 case QETH_IPA_ARP_RC_FAILED:
2373 *rc = -EIO;
2374 return "operation failed";
2375 case QETH_IPA_ARP_RC_NOTSUPP:
2376 *rc = -EOPNOTSUPP;
2377 return "operation not supported";
2378 case QETH_IPA_ARP_RC_OUT_OF_RANGE:
2379 *rc = -EINVAL;
2380 return "argument out of range";
2381 case QETH_IPA_ARP_RC_Q_NOTSUPP:
2382 *rc = -EOPNOTSUPP;
2383 return "query operation not supported";
2384 case QETH_IPA_ARP_RC_Q_NO_DATA:
2385 *rc = -ENOENT;
2386 return "no query data available";
2387 default:
2388 return "unknown error";
2389 }
2390 }
2391
qeth_l3_arp_set_no_entries(struct qeth_card * card,int no_entries)2392 static int qeth_l3_arp_set_no_entries(struct qeth_card *card, int no_entries)
2393 {
2394 int tmp;
2395 int rc;
2396
2397 QETH_CARD_TEXT(card, 3, "arpstnoe");
2398
2399 /*
2400 * currently GuestLAN only supports the ARP assist function
2401 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_SET_NO_ENTRIES;
2402 * thus we say EOPNOTSUPP for this ARP function
2403 */
2404 if (card->info.guestlan)
2405 return -EOPNOTSUPP;
2406 if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) {
2407 return -EOPNOTSUPP;
2408 }
2409 rc = qeth_l3_send_simple_setassparms(card, IPA_ARP_PROCESSING,
2410 IPA_CMD_ASS_ARP_SET_NO_ENTRIES,
2411 no_entries);
2412 if (rc) {
2413 tmp = rc;
2414 QETH_DBF_MESSAGE(2, "Could not set number of ARP entries on "
2415 "%s: %s (0x%x/%d)\n", QETH_CARD_IFNAME(card),
2416 qeth_l3_arp_get_error_cause(&rc), tmp, tmp);
2417 }
2418 return rc;
2419 }
2420
get_arp_entry_size(struct qeth_card * card,struct qeth_arp_query_data * qdata,struct qeth_arp_entrytype * type,__u8 strip_entries)2421 static __u32 get_arp_entry_size(struct qeth_card *card,
2422 struct qeth_arp_query_data *qdata,
2423 struct qeth_arp_entrytype *type, __u8 strip_entries)
2424 {
2425 __u32 rc;
2426 __u8 is_hsi;
2427
2428 is_hsi = qdata->reply_bits == 5;
2429 if (type->ip == QETHARP_IP_ADDR_V4) {
2430 QETH_CARD_TEXT(card, 4, "arpev4");
2431 if (strip_entries) {
2432 rc = is_hsi ? sizeof(struct qeth_arp_qi_entry5_short) :
2433 sizeof(struct qeth_arp_qi_entry7_short);
2434 } else {
2435 rc = is_hsi ? sizeof(struct qeth_arp_qi_entry5) :
2436 sizeof(struct qeth_arp_qi_entry7);
2437 }
2438 } else if (type->ip == QETHARP_IP_ADDR_V6) {
2439 QETH_CARD_TEXT(card, 4, "arpev6");
2440 if (strip_entries) {
2441 rc = is_hsi ?
2442 sizeof(struct qeth_arp_qi_entry5_short_ipv6) :
2443 sizeof(struct qeth_arp_qi_entry7_short_ipv6);
2444 } else {
2445 rc = is_hsi ?
2446 sizeof(struct qeth_arp_qi_entry5_ipv6) :
2447 sizeof(struct qeth_arp_qi_entry7_ipv6);
2448 }
2449 } else {
2450 QETH_CARD_TEXT(card, 4, "arpinv");
2451 rc = 0;
2452 }
2453
2454 return rc;
2455 }
2456
arpentry_matches_prot(struct qeth_arp_entrytype * type,__u16 prot)2457 static int arpentry_matches_prot(struct qeth_arp_entrytype *type, __u16 prot)
2458 {
2459 return (type->ip == QETHARP_IP_ADDR_V4 && prot == QETH_PROT_IPV4) ||
2460 (type->ip == QETHARP_IP_ADDR_V6 && prot == QETH_PROT_IPV6);
2461 }
2462
qeth_l3_arp_query_cb(struct qeth_card * card,struct qeth_reply * reply,unsigned long data)2463 static int qeth_l3_arp_query_cb(struct qeth_card *card,
2464 struct qeth_reply *reply, unsigned long data)
2465 {
2466 struct qeth_ipa_cmd *cmd;
2467 struct qeth_arp_query_data *qdata;
2468 struct qeth_arp_query_info *qinfo;
2469 int i;
2470 int e;
2471 int entrybytes_done;
2472 int stripped_bytes;
2473 __u8 do_strip_entries;
2474
2475 QETH_CARD_TEXT(card, 3, "arpquecb");
2476
2477 qinfo = (struct qeth_arp_query_info *) reply->param;
2478 cmd = (struct qeth_ipa_cmd *) data;
2479 QETH_CARD_TEXT_(card, 4, "%i", cmd->hdr.prot_version);
2480 if (cmd->hdr.return_code) {
2481 QETH_CARD_TEXT(card, 4, "arpcberr");
2482 QETH_CARD_TEXT_(card, 4, "%i", cmd->hdr.return_code);
2483 return 0;
2484 }
2485 if (cmd->data.setassparms.hdr.return_code) {
2486 cmd->hdr.return_code = cmd->data.setassparms.hdr.return_code;
2487 QETH_CARD_TEXT(card, 4, "setaperr");
2488 QETH_CARD_TEXT_(card, 4, "%i", cmd->hdr.return_code);
2489 return 0;
2490 }
2491 qdata = &cmd->data.setassparms.data.query_arp;
2492 QETH_CARD_TEXT_(card, 4, "anoen%i", qdata->no_entries);
2493
2494 do_strip_entries = (qinfo->mask_bits & QETH_QARP_STRIP_ENTRIES) > 0;
2495 stripped_bytes = do_strip_entries ? QETH_QARP_MEDIASPECIFIC_BYTES : 0;
2496 entrybytes_done = 0;
2497 for (e = 0; e < qdata->no_entries; ++e) {
2498 char *cur_entry;
2499 __u32 esize;
2500 struct qeth_arp_entrytype *etype;
2501
2502 cur_entry = &qdata->data + entrybytes_done;
2503 etype = &((struct qeth_arp_qi_entry5 *) cur_entry)->type;
2504 if (!arpentry_matches_prot(etype, cmd->hdr.prot_version)) {
2505 QETH_CARD_TEXT(card, 4, "pmis");
2506 QETH_CARD_TEXT_(card, 4, "%i", etype->ip);
2507 break;
2508 }
2509 esize = get_arp_entry_size(card, qdata, etype,
2510 do_strip_entries);
2511 QETH_CARD_TEXT_(card, 5, "esz%i", esize);
2512 if (!esize)
2513 break;
2514
2515 if ((qinfo->udata_len - qinfo->udata_offset) < esize) {
2516 QETH_CARD_TEXT_(card, 4, "qaer3%i", -ENOMEM);
2517 cmd->hdr.return_code = -ENOMEM;
2518 goto out_error;
2519 }
2520
2521 memcpy(qinfo->udata + qinfo->udata_offset,
2522 &qdata->data + entrybytes_done + stripped_bytes,
2523 esize);
2524 entrybytes_done += esize + stripped_bytes;
2525 qinfo->udata_offset += esize;
2526 ++qinfo->no_entries;
2527 }
2528 /* check if all replies received ... */
2529 if (cmd->data.setassparms.hdr.seq_no <
2530 cmd->data.setassparms.hdr.number_of_replies)
2531 return 1;
2532 QETH_CARD_TEXT_(card, 4, "nove%i", qinfo->no_entries);
2533 memcpy(qinfo->udata, &qinfo->no_entries, 4);
2534 /* keep STRIP_ENTRIES flag so the user program can distinguish
2535 * stripped entries from normal ones */
2536 if (qinfo->mask_bits & QETH_QARP_STRIP_ENTRIES)
2537 qdata->reply_bits |= QETH_QARP_STRIP_ENTRIES;
2538 memcpy(qinfo->udata + QETH_QARP_MASK_OFFSET, &qdata->reply_bits, 2);
2539 QETH_CARD_TEXT_(card, 4, "rc%i", 0);
2540 return 0;
2541 out_error:
2542 i = 0;
2543 memcpy(qinfo->udata, &i, 4);
2544 return 0;
2545 }
2546
qeth_l3_send_ipa_arp_cmd(struct qeth_card * card,struct qeth_cmd_buffer * iob,int len,int (* reply_cb)(struct qeth_card *,struct qeth_reply *,unsigned long),void * reply_param)2547 static int qeth_l3_send_ipa_arp_cmd(struct qeth_card *card,
2548 struct qeth_cmd_buffer *iob, int len,
2549 int (*reply_cb)(struct qeth_card *, struct qeth_reply *,
2550 unsigned long),
2551 void *reply_param)
2552 {
2553 QETH_CARD_TEXT(card, 4, "sendarp");
2554
2555 memcpy(iob->data, IPA_PDU_HEADER, IPA_PDU_HEADER_SIZE);
2556 memcpy(QETH_IPA_CMD_DEST_ADDR(iob->data),
2557 &card->token.ulp_connection_r, QETH_MPC_TOKEN_LENGTH);
2558 return qeth_send_control_data(card, IPA_PDU_HEADER_SIZE + len, iob,
2559 reply_cb, reply_param);
2560 }
2561
qeth_l3_query_arp_cache_info(struct qeth_card * card,enum qeth_prot_versions prot,struct qeth_arp_query_info * qinfo)2562 static int qeth_l3_query_arp_cache_info(struct qeth_card *card,
2563 enum qeth_prot_versions prot,
2564 struct qeth_arp_query_info *qinfo)
2565 {
2566 struct qeth_cmd_buffer *iob;
2567 struct qeth_ipa_cmd *cmd;
2568 int tmp;
2569 int rc;
2570
2571 QETH_CARD_TEXT_(card, 3, "qarpipv%i", prot);
2572
2573 iob = qeth_l3_get_setassparms_cmd(card, IPA_ARP_PROCESSING,
2574 IPA_CMD_ASS_ARP_QUERY_INFO,
2575 sizeof(struct qeth_arp_query_data) - sizeof(char),
2576 prot);
2577 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
2578 cmd->data.setassparms.data.query_arp.request_bits = 0x000F;
2579 cmd->data.setassparms.data.query_arp.reply_bits = 0;
2580 cmd->data.setassparms.data.query_arp.no_entries = 0;
2581 rc = qeth_l3_send_ipa_arp_cmd(card, iob,
2582 QETH_SETASS_BASE_LEN+QETH_ARP_CMD_LEN,
2583 qeth_l3_arp_query_cb, (void *)qinfo);
2584 if (rc) {
2585 tmp = rc;
2586 QETH_DBF_MESSAGE(2,
2587 "Error while querying ARP cache on %s: %s "
2588 "(0x%x/%d)\n", QETH_CARD_IFNAME(card),
2589 qeth_l3_arp_get_error_cause(&rc), tmp, tmp);
2590 }
2591
2592 return rc;
2593 }
2594
qeth_l3_arp_query(struct qeth_card * card,char __user * udata)2595 static int qeth_l3_arp_query(struct qeth_card *card, char __user *udata)
2596 {
2597 struct qeth_arp_query_info qinfo = {0, };
2598 int rc;
2599
2600 QETH_CARD_TEXT(card, 3, "arpquery");
2601
2602 if (!qeth_is_supported(card,/*IPA_QUERY_ARP_ADDR_INFO*/
2603 IPA_ARP_PROCESSING)) {
2604 QETH_CARD_TEXT(card, 3, "arpqnsup");
2605 rc = -EOPNOTSUPP;
2606 goto out;
2607 }
2608 /* get size of userspace buffer and mask_bits -> 6 bytes */
2609 if (copy_from_user(&qinfo, udata, 6)) {
2610 rc = -EFAULT;
2611 goto out;
2612 }
2613 qinfo.udata = kzalloc(qinfo.udata_len, GFP_KERNEL);
2614 if (!qinfo.udata) {
2615 rc = -ENOMEM;
2616 goto out;
2617 }
2618 qinfo.udata_offset = QETH_QARP_ENTRIES_OFFSET;
2619 rc = qeth_l3_query_arp_cache_info(card, QETH_PROT_IPV4, &qinfo);
2620 if (rc) {
2621 if (copy_to_user(udata, qinfo.udata, 4))
2622 rc = -EFAULT;
2623 goto free_and_out;
2624 } else {
2625 #ifdef CONFIG_QETH_IPV6
2626 if (qinfo.mask_bits & QETH_QARP_WITH_IPV6) {
2627 /* fails in case of GuestLAN QDIO mode */
2628 qeth_l3_query_arp_cache_info(card, QETH_PROT_IPV6,
2629 &qinfo);
2630 }
2631 #endif
2632 if (copy_to_user(udata, qinfo.udata, qinfo.udata_len)) {
2633 QETH_CARD_TEXT(card, 4, "qactf");
2634 rc = -EFAULT;
2635 goto free_and_out;
2636 }
2637 QETH_CARD_TEXT_(card, 4, "qacts");
2638 }
2639 free_and_out:
2640 kfree(qinfo.udata);
2641 out:
2642 return rc;
2643 }
2644
qeth_l3_arp_add_entry(struct qeth_card * card,struct qeth_arp_cache_entry * entry)2645 static int qeth_l3_arp_add_entry(struct qeth_card *card,
2646 struct qeth_arp_cache_entry *entry)
2647 {
2648 struct qeth_cmd_buffer *iob;
2649 char buf[16];
2650 int tmp;
2651 int rc;
2652
2653 QETH_CARD_TEXT(card, 3, "arpadent");
2654
2655 /*
2656 * currently GuestLAN only supports the ARP assist function
2657 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_ADD_ENTRY;
2658 * thus we say EOPNOTSUPP for this ARP function
2659 */
2660 if (card->info.guestlan)
2661 return -EOPNOTSUPP;
2662 if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) {
2663 return -EOPNOTSUPP;
2664 }
2665
2666 iob = qeth_l3_get_setassparms_cmd(card, IPA_ARP_PROCESSING,
2667 IPA_CMD_ASS_ARP_ADD_ENTRY,
2668 sizeof(struct qeth_arp_cache_entry),
2669 QETH_PROT_IPV4);
2670 rc = qeth_l3_send_setassparms(card, iob,
2671 sizeof(struct qeth_arp_cache_entry),
2672 (unsigned long) entry,
2673 qeth_l3_default_setassparms_cb, NULL);
2674 if (rc) {
2675 tmp = rc;
2676 qeth_l3_ipaddr4_to_string((u8 *)entry->ipaddr, buf);
2677 QETH_DBF_MESSAGE(2, "Could not add ARP entry for address %s "
2678 "on %s: %s (0x%x/%d)\n", buf, QETH_CARD_IFNAME(card),
2679 qeth_l3_arp_get_error_cause(&rc), tmp, tmp);
2680 }
2681 return rc;
2682 }
2683
qeth_l3_arp_remove_entry(struct qeth_card * card,struct qeth_arp_cache_entry * entry)2684 static int qeth_l3_arp_remove_entry(struct qeth_card *card,
2685 struct qeth_arp_cache_entry *entry)
2686 {
2687 struct qeth_cmd_buffer *iob;
2688 char buf[16] = {0, };
2689 int tmp;
2690 int rc;
2691
2692 QETH_CARD_TEXT(card, 3, "arprment");
2693
2694 /*
2695 * currently GuestLAN only supports the ARP assist function
2696 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_REMOVE_ENTRY;
2697 * thus we say EOPNOTSUPP for this ARP function
2698 */
2699 if (card->info.guestlan)
2700 return -EOPNOTSUPP;
2701 if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) {
2702 return -EOPNOTSUPP;
2703 }
2704 memcpy(buf, entry, 12);
2705 iob = qeth_l3_get_setassparms_cmd(card, IPA_ARP_PROCESSING,
2706 IPA_CMD_ASS_ARP_REMOVE_ENTRY,
2707 12,
2708 QETH_PROT_IPV4);
2709 rc = qeth_l3_send_setassparms(card, iob,
2710 12, (unsigned long)buf,
2711 qeth_l3_default_setassparms_cb, NULL);
2712 if (rc) {
2713 tmp = rc;
2714 memset(buf, 0, 16);
2715 qeth_l3_ipaddr4_to_string((u8 *)entry->ipaddr, buf);
2716 QETH_DBF_MESSAGE(2, "Could not delete ARP entry for address %s"
2717 " on %s: %s (0x%x/%d)\n", buf, QETH_CARD_IFNAME(card),
2718 qeth_l3_arp_get_error_cause(&rc), tmp, tmp);
2719 }
2720 return rc;
2721 }
2722
qeth_l3_arp_flush_cache(struct qeth_card * card)2723 static int qeth_l3_arp_flush_cache(struct qeth_card *card)
2724 {
2725 int rc;
2726 int tmp;
2727
2728 QETH_CARD_TEXT(card, 3, "arpflush");
2729
2730 /*
2731 * currently GuestLAN only supports the ARP assist function
2732 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_FLUSH_CACHE;
2733 * thus we say EOPNOTSUPP for this ARP function
2734 */
2735 if (card->info.guestlan || (card->info.type == QETH_CARD_TYPE_IQD))
2736 return -EOPNOTSUPP;
2737 if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) {
2738 return -EOPNOTSUPP;
2739 }
2740 rc = qeth_l3_send_simple_setassparms(card, IPA_ARP_PROCESSING,
2741 IPA_CMD_ASS_ARP_FLUSH_CACHE, 0);
2742 if (rc) {
2743 tmp = rc;
2744 QETH_DBF_MESSAGE(2, "Could not flush ARP cache on %s: %s "
2745 "(0x%x/%d)\n", QETH_CARD_IFNAME(card),
2746 qeth_l3_arp_get_error_cause(&rc), tmp, tmp);
2747 }
2748 return rc;
2749 }
2750
qeth_l3_do_ioctl(struct net_device * dev,struct ifreq * rq,int cmd)2751 static int qeth_l3_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2752 {
2753 struct qeth_card *card = dev->ml_priv;
2754 struct qeth_arp_cache_entry arp_entry;
2755 struct mii_ioctl_data *mii_data;
2756 int rc = 0;
2757
2758 if (!card)
2759 return -ENODEV;
2760
2761 if ((card->state != CARD_STATE_UP) &&
2762 (card->state != CARD_STATE_SOFTSETUP))
2763 return -ENODEV;
2764
2765 switch (cmd) {
2766 case SIOC_QETH_ARP_SET_NO_ENTRIES:
2767 if (!capable(CAP_NET_ADMIN)) {
2768 rc = -EPERM;
2769 break;
2770 }
2771 rc = qeth_l3_arp_set_no_entries(card, rq->ifr_ifru.ifru_ivalue);
2772 break;
2773 case SIOC_QETH_ARP_QUERY_INFO:
2774 if (!capable(CAP_NET_ADMIN)) {
2775 rc = -EPERM;
2776 break;
2777 }
2778 rc = qeth_l3_arp_query(card, rq->ifr_ifru.ifru_data);
2779 break;
2780 case SIOC_QETH_ARP_ADD_ENTRY:
2781 if (!capable(CAP_NET_ADMIN)) {
2782 rc = -EPERM;
2783 break;
2784 }
2785 if (copy_from_user(&arp_entry, rq->ifr_ifru.ifru_data,
2786 sizeof(struct qeth_arp_cache_entry)))
2787 rc = -EFAULT;
2788 else
2789 rc = qeth_l3_arp_add_entry(card, &arp_entry);
2790 break;
2791 case SIOC_QETH_ARP_REMOVE_ENTRY:
2792 if (!capable(CAP_NET_ADMIN)) {
2793 rc = -EPERM;
2794 break;
2795 }
2796 if (copy_from_user(&arp_entry, rq->ifr_ifru.ifru_data,
2797 sizeof(struct qeth_arp_cache_entry)))
2798 rc = -EFAULT;
2799 else
2800 rc = qeth_l3_arp_remove_entry(card, &arp_entry);
2801 break;
2802 case SIOC_QETH_ARP_FLUSH_CACHE:
2803 if (!capable(CAP_NET_ADMIN)) {
2804 rc = -EPERM;
2805 break;
2806 }
2807 rc = qeth_l3_arp_flush_cache(card);
2808 break;
2809 case SIOC_QETH_ADP_SET_SNMP_CONTROL:
2810 rc = qeth_snmp_command(card, rq->ifr_ifru.ifru_data);
2811 break;
2812 case SIOC_QETH_GET_CARD_TYPE:
2813 if ((card->info.type == QETH_CARD_TYPE_OSD ||
2814 card->info.type == QETH_CARD_TYPE_OSX) &&
2815 !card->info.guestlan)
2816 return 1;
2817 return 0;
2818 break;
2819 case SIOCGMIIPHY:
2820 mii_data = if_mii(rq);
2821 mii_data->phy_id = 0;
2822 break;
2823 case SIOCGMIIREG:
2824 mii_data = if_mii(rq);
2825 if (mii_data->phy_id != 0)
2826 rc = -EINVAL;
2827 else
2828 mii_data->val_out = qeth_mdio_read(dev,
2829 mii_data->phy_id,
2830 mii_data->reg_num);
2831 break;
2832 default:
2833 rc = -EOPNOTSUPP;
2834 }
2835 if (rc)
2836 QETH_CARD_TEXT_(card, 2, "ioce%d", rc);
2837 return rc;
2838 }
2839
qeth_l3_get_cast_type(struct qeth_card * card,struct sk_buff * skb)2840 int inline qeth_l3_get_cast_type(struct qeth_card *card, struct sk_buff *skb)
2841 {
2842 int cast_type = RTN_UNSPEC;
2843
2844 if (skb_dst(skb) && skb_dst(skb)->neighbour) {
2845 cast_type = skb_dst(skb)->neighbour->type;
2846 if ((cast_type == RTN_BROADCAST) ||
2847 (cast_type == RTN_MULTICAST) ||
2848 (cast_type == RTN_ANYCAST))
2849 return cast_type;
2850 else
2851 return RTN_UNSPEC;
2852 }
2853 /* try something else */
2854 if (skb->protocol == ETH_P_IPV6)
2855 return (skb_network_header(skb)[24] == 0xff) ?
2856 RTN_MULTICAST : 0;
2857 else if (skb->protocol == ETH_P_IP)
2858 return ((skb_network_header(skb)[16] & 0xf0) == 0xe0) ?
2859 RTN_MULTICAST : 0;
2860 /* ... */
2861 if (!memcmp(skb->data, skb->dev->broadcast, 6))
2862 return RTN_BROADCAST;
2863 else {
2864 u16 hdr_mac;
2865
2866 hdr_mac = *((u16 *)skb->data);
2867 /* tr multicast? */
2868 switch (card->info.link_type) {
2869 case QETH_LINK_TYPE_HSTR:
2870 case QETH_LINK_TYPE_LANE_TR:
2871 if ((hdr_mac == QETH_TR_MAC_NC) ||
2872 (hdr_mac == QETH_TR_MAC_C))
2873 return RTN_MULTICAST;
2874 break;
2875 /* eth or so multicast? */
2876 default:
2877 if ((hdr_mac == QETH_ETH_MAC_V4) ||
2878 (hdr_mac == QETH_ETH_MAC_V6))
2879 return RTN_MULTICAST;
2880 }
2881 }
2882 return cast_type;
2883 }
2884
qeth_l3_fill_header(struct qeth_card * card,struct qeth_hdr * hdr,struct sk_buff * skb,int ipv,int cast_type)2885 static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
2886 struct sk_buff *skb, int ipv, int cast_type)
2887 {
2888 memset(hdr, 0, sizeof(struct qeth_hdr));
2889 hdr->hdr.l3.id = QETH_HEADER_TYPE_LAYER3;
2890 hdr->hdr.l3.ext_flags = 0;
2891
2892 /*
2893 * before we're going to overwrite this location with next hop ip.
2894 * v6 uses passthrough, v4 sets the tag in the QDIO header.
2895 */
2896 if (card->vlangrp && vlan_tx_tag_present(skb)) {
2897 if ((ipv == 4) || (card->info.type == QETH_CARD_TYPE_IQD))
2898 hdr->hdr.l3.ext_flags = QETH_HDR_EXT_VLAN_FRAME;
2899 else
2900 hdr->hdr.l3.ext_flags = QETH_HDR_EXT_INCLUDE_VLAN_TAG;
2901 hdr->hdr.l3.vlan_id = vlan_tx_tag_get(skb);
2902 }
2903
2904 hdr->hdr.l3.length = skb->len - sizeof(struct qeth_hdr);
2905 if (ipv == 4) {
2906 /* IPv4 */
2907 hdr->hdr.l3.flags = qeth_l3_get_qeth_hdr_flags4(cast_type);
2908 memset(hdr->hdr.l3.dest_addr, 0, 12);
2909 if ((skb_dst(skb)) && (skb_dst(skb)->neighbour)) {
2910 *((u32 *) (&hdr->hdr.l3.dest_addr[12])) =
2911 *((u32 *) skb_dst(skb)->neighbour->primary_key);
2912 } else {
2913 /* fill in destination address used in ip header */
2914 *((u32 *) (&hdr->hdr.l3.dest_addr[12])) =
2915 ip_hdr(skb)->daddr;
2916 }
2917 } else if (ipv == 6) {
2918 /* IPv6 */
2919 hdr->hdr.l3.flags = qeth_l3_get_qeth_hdr_flags6(cast_type);
2920 if (card->info.type == QETH_CARD_TYPE_IQD)
2921 hdr->hdr.l3.flags &= ~QETH_HDR_PASSTHRU;
2922 if ((skb_dst(skb)) && (skb_dst(skb)->neighbour)) {
2923 memcpy(hdr->hdr.l3.dest_addr,
2924 skb_dst(skb)->neighbour->primary_key, 16);
2925 } else {
2926 /* fill in destination address used in ip header */
2927 memcpy(hdr->hdr.l3.dest_addr,
2928 &ipv6_hdr(skb)->daddr, 16);
2929 }
2930 } else {
2931 /* passthrough */
2932 if ((skb->dev->type == ARPHRD_IEEE802_TR) &&
2933 !memcmp(skb->data + sizeof(struct qeth_hdr) +
2934 sizeof(__u16), skb->dev->broadcast, 6)) {
2935 hdr->hdr.l3.flags = QETH_CAST_BROADCAST |
2936 QETH_HDR_PASSTHRU;
2937 } else if (!memcmp(skb->data + sizeof(struct qeth_hdr),
2938 skb->dev->broadcast, 6)) {
2939 /* broadcast? */
2940 hdr->hdr.l3.flags = QETH_CAST_BROADCAST |
2941 QETH_HDR_PASSTHRU;
2942 } else {
2943 hdr->hdr.l3.flags = (cast_type == RTN_MULTICAST) ?
2944 QETH_CAST_MULTICAST | QETH_HDR_PASSTHRU :
2945 QETH_CAST_UNICAST | QETH_HDR_PASSTHRU;
2946 }
2947 }
2948 }
2949
qeth_l3_hdr_csum(struct qeth_card * card,struct qeth_hdr * hdr,struct sk_buff * skb)2950 static inline void qeth_l3_hdr_csum(struct qeth_card *card,
2951 struct qeth_hdr *hdr, struct sk_buff *skb)
2952 {
2953 struct iphdr *iph = ip_hdr(skb);
2954
2955 /* tcph->check contains already the pseudo hdr checksum
2956 * so just set the header flags
2957 */
2958 if (iph->protocol == IPPROTO_UDP)
2959 hdr->hdr.l3.ext_flags |= QETH_HDR_EXT_UDP;
2960 hdr->hdr.l3.ext_flags |= QETH_HDR_EXT_CSUM_TRANSP_REQ |
2961 QETH_HDR_EXT_CSUM_HDR_REQ;
2962 iph->check = 0;
2963 if (card->options.performance_stats)
2964 card->perf_stats.tx_csum++;
2965 }
2966
qeth_tso_fill_header(struct qeth_card * card,struct qeth_hdr * qhdr,struct sk_buff * skb)2967 static void qeth_tso_fill_header(struct qeth_card *card,
2968 struct qeth_hdr *qhdr, struct sk_buff *skb)
2969 {
2970 struct qeth_hdr_tso *hdr = (struct qeth_hdr_tso *)qhdr;
2971 struct tcphdr *tcph = tcp_hdr(skb);
2972 struct iphdr *iph = ip_hdr(skb);
2973 struct ipv6hdr *ip6h = ipv6_hdr(skb);
2974
2975 /*fix header to TSO values ...*/
2976 hdr->hdr.hdr.l3.id = QETH_HEADER_TYPE_TSO;
2977 hdr->hdr.hdr.l3.length = skb->len - sizeof(struct qeth_hdr_tso);
2978 /*set values which are fix for the first approach ...*/
2979 hdr->ext.hdr_tot_len = (__u16) sizeof(struct qeth_hdr_ext_tso);
2980 hdr->ext.imb_hdr_no = 1;
2981 hdr->ext.hdr_type = 1;
2982 hdr->ext.hdr_version = 1;
2983 hdr->ext.hdr_len = 28;
2984 /*insert non-fix values */
2985 hdr->ext.mss = skb_shinfo(skb)->gso_size;
2986 hdr->ext.dg_hdr_len = (__u16)(iph->ihl*4 + tcph->doff*4);
2987 hdr->ext.payload_len = (__u16)(skb->len - hdr->ext.dg_hdr_len -
2988 sizeof(struct qeth_hdr_tso));
2989 tcph->check = 0;
2990 if (skb->protocol == ETH_P_IPV6) {
2991 ip6h->payload_len = 0;
2992 tcph->check = ~csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr,
2993 0, IPPROTO_TCP, 0);
2994 } else {
2995 /*OSA want us to set these values ...*/
2996 tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
2997 0, IPPROTO_TCP, 0);
2998 iph->tot_len = 0;
2999 iph->check = 0;
3000 }
3001 }
3002
qeth_l3_tso_elements(struct sk_buff * skb)3003 static inline int qeth_l3_tso_elements(struct sk_buff *skb)
3004 {
3005 unsigned long tcpd = (unsigned long)tcp_hdr(skb) +
3006 tcp_hdr(skb)->doff * 4;
3007 int tcpd_len = skb->len - (tcpd - (unsigned long)skb->data);
3008 int elements = PFN_UP(tcpd + tcpd_len - 1) - PFN_DOWN(tcpd);
3009 elements += skb_shinfo(skb)->nr_frags;
3010 return elements;
3011 }
3012
qeth_l3_hard_start_xmit(struct sk_buff * skb,struct net_device * dev)3013 static int qeth_l3_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
3014 {
3015 int rc;
3016 u16 *tag;
3017 struct qeth_hdr *hdr = NULL;
3018 int elements_needed = 0;
3019 int elems;
3020 struct qeth_card *card = dev->ml_priv;
3021 struct sk_buff *new_skb = NULL;
3022 int ipv = qeth_get_ip_version(skb);
3023 int cast_type = qeth_l3_get_cast_type(card, skb);
3024 struct qeth_qdio_out_q *queue = card->qdio.out_qs
3025 [qeth_get_priority_queue(card, skb, ipv, cast_type)];
3026 int tx_bytes = skb->len;
3027 enum qeth_large_send_types large_send = QETH_LARGE_SEND_NO;
3028 int data_offset = -1;
3029 int nr_frags;
3030
3031 if (((card->info.type == QETH_CARD_TYPE_IQD) && (!ipv)) ||
3032 card->options.sniffer)
3033 goto tx_drop;
3034
3035 if ((card->state != CARD_STATE_UP) || !card->lan_online) {
3036 card->stats.tx_carrier_errors++;
3037 goto tx_drop;
3038 }
3039
3040 if ((cast_type == RTN_BROADCAST) &&
3041 (card->info.broadcast_capable == 0))
3042 goto tx_drop;
3043
3044 if (card->options.performance_stats) {
3045 card->perf_stats.outbound_cnt++;
3046 card->perf_stats.outbound_start_time = qeth_get_micros();
3047 }
3048
3049 if (skb_is_gso(skb))
3050 large_send = card->options.large_send;
3051
3052 if ((card->info.type == QETH_CARD_TYPE_IQD) && (!large_send) &&
3053 (skb_shinfo(skb)->nr_frags == 0)) {
3054 new_skb = skb;
3055 data_offset = ETH_HLEN;
3056 hdr = kmem_cache_alloc(qeth_core_header_cache, GFP_ATOMIC);
3057 if (!hdr)
3058 goto tx_drop;
3059 elements_needed++;
3060 } else {
3061 /* create a clone with writeable headroom */
3062 new_skb = skb_realloc_headroom(skb, sizeof(struct qeth_hdr_tso)
3063 + VLAN_HLEN);
3064 if (!new_skb)
3065 goto tx_drop;
3066 }
3067
3068 if (card->info.type == QETH_CARD_TYPE_IQD) {
3069 if (data_offset < 0)
3070 skb_pull(new_skb, ETH_HLEN);
3071 } else {
3072 if (ipv == 4) {
3073 if (card->dev->type == ARPHRD_IEEE802_TR)
3074 skb_pull(new_skb, TR_HLEN);
3075 else
3076 skb_pull(new_skb, ETH_HLEN);
3077 }
3078
3079 if (ipv != 4 && card->vlangrp &&
3080 vlan_tx_tag_present(new_skb)) {
3081 skb_push(new_skb, VLAN_HLEN);
3082 skb_copy_to_linear_data(new_skb, new_skb->data + 4, 4);
3083 skb_copy_to_linear_data_offset(new_skb, 4,
3084 new_skb->data + 8, 4);
3085 skb_copy_to_linear_data_offset(new_skb, 8,
3086 new_skb->data + 12, 4);
3087 tag = (u16 *)(new_skb->data + 12);
3088 *tag = __constant_htons(ETH_P_8021Q);
3089 *(tag + 1) = htons(vlan_tx_tag_get(new_skb));
3090 new_skb->vlan_tci = 0;
3091 }
3092 }
3093
3094 netif_stop_queue(dev);
3095
3096 /* fix hardware limitation: as long as we do not have sbal
3097 * chaining we can not send long frag lists
3098 */
3099 if (large_send == QETH_LARGE_SEND_TSO) {
3100 if (qeth_l3_tso_elements(new_skb) + 1 > 16) {
3101 if (skb_linearize(new_skb))
3102 goto tx_drop;
3103 if (card->options.performance_stats)
3104 card->perf_stats.tx_lin++;
3105 }
3106 }
3107
3108 if ((large_send == QETH_LARGE_SEND_TSO) &&
3109 (cast_type == RTN_UNSPEC)) {
3110 hdr = (struct qeth_hdr *)skb_push(new_skb,
3111 sizeof(struct qeth_hdr_tso));
3112 memset(hdr, 0, sizeof(struct qeth_hdr_tso));
3113 qeth_l3_fill_header(card, hdr, new_skb, ipv, cast_type);
3114 qeth_tso_fill_header(card, hdr, new_skb);
3115 elements_needed++;
3116 } else {
3117 if (data_offset < 0) {
3118 hdr = (struct qeth_hdr *)skb_push(new_skb,
3119 sizeof(struct qeth_hdr));
3120 qeth_l3_fill_header(card, hdr, new_skb, ipv,
3121 cast_type);
3122 } else {
3123 qeth_l3_fill_header(card, hdr, new_skb, ipv,
3124 cast_type);
3125 hdr->hdr.l3.length = new_skb->len - data_offset;
3126 }
3127
3128 if (skb->ip_summed == CHECKSUM_PARTIAL)
3129 qeth_l3_hdr_csum(card, hdr, new_skb);
3130 }
3131
3132 elems = qeth_get_elements_no(card, (void *)hdr, new_skb,
3133 elements_needed);
3134 if (!elems) {
3135 if (data_offset >= 0)
3136 kmem_cache_free(qeth_core_header_cache, hdr);
3137 goto tx_drop;
3138 }
3139 elements_needed += elems;
3140 nr_frags = skb_shinfo(new_skb)->nr_frags;
3141
3142 if (card->info.type != QETH_CARD_TYPE_IQD) {
3143 int len;
3144 if (large_send == QETH_LARGE_SEND_TSO)
3145 len = ((unsigned long)tcp_hdr(new_skb) +
3146 tcp_hdr(new_skb)->doff * 4) -
3147 (unsigned long)new_skb->data;
3148 else
3149 len = sizeof(struct qeth_hdr_layer3);
3150
3151 if (qeth_hdr_chk_and_bounce(new_skb, len))
3152 goto tx_drop;
3153 rc = qeth_do_send_packet(card, queue, new_skb, hdr,
3154 elements_needed);
3155 } else
3156 rc = qeth_do_send_packet_fast(card, queue, new_skb, hdr,
3157 elements_needed, data_offset, 0);
3158
3159 if (!rc) {
3160 card->stats.tx_packets++;
3161 card->stats.tx_bytes += tx_bytes;
3162 if (new_skb != skb)
3163 dev_kfree_skb_any(skb);
3164 if (card->options.performance_stats) {
3165 if (large_send != QETH_LARGE_SEND_NO) {
3166 card->perf_stats.large_send_bytes += tx_bytes;
3167 card->perf_stats.large_send_cnt++;
3168 }
3169 if (nr_frags) {
3170 card->perf_stats.sg_skbs_sent++;
3171 /* nr_frags + skb->data */
3172 card->perf_stats.sg_frags_sent += nr_frags + 1;
3173 }
3174 }
3175 rc = NETDEV_TX_OK;
3176 } else {
3177 if (data_offset >= 0)
3178 kmem_cache_free(qeth_core_header_cache, hdr);
3179
3180 if (rc == -EBUSY) {
3181 if (new_skb != skb)
3182 dev_kfree_skb_any(new_skb);
3183 return NETDEV_TX_BUSY;
3184 } else
3185 goto tx_drop;
3186 }
3187
3188 netif_wake_queue(dev);
3189 if (card->options.performance_stats)
3190 card->perf_stats.outbound_time += qeth_get_micros() -
3191 card->perf_stats.outbound_start_time;
3192 return rc;
3193
3194 tx_drop:
3195 card->stats.tx_dropped++;
3196 card->stats.tx_errors++;
3197 if ((new_skb != skb) && new_skb)
3198 dev_kfree_skb_any(new_skb);
3199 dev_kfree_skb_any(skb);
3200 netif_wake_queue(dev);
3201 return NETDEV_TX_OK;
3202 }
3203
__qeth_l3_open(struct net_device * dev)3204 static int __qeth_l3_open(struct net_device *dev)
3205 {
3206 struct qeth_card *card = dev->ml_priv;
3207 int rc = 0;
3208
3209 QETH_CARD_TEXT(card, 4, "qethopen");
3210 if (card->state == CARD_STATE_UP)
3211 return rc;
3212 if (card->state != CARD_STATE_SOFTSETUP)
3213 return -ENODEV;
3214 card->data.state = CH_STATE_UP;
3215 card->state = CARD_STATE_UP;
3216 netif_start_queue(dev);
3217
3218 if (qdio_stop_irq(card->data.ccwdev, 0) >= 0) {
3219 napi_enable(&card->napi);
3220 napi_schedule(&card->napi);
3221 } else
3222 rc = -EIO;
3223 return rc;
3224 }
3225
qeth_l3_open(struct net_device * dev)3226 static int qeth_l3_open(struct net_device *dev)
3227 {
3228 struct qeth_card *card = dev->ml_priv;
3229
3230 QETH_CARD_TEXT(card, 5, "qethope_");
3231 if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) {
3232 QETH_CARD_TEXT(card, 3, "openREC");
3233 return -ERESTARTSYS;
3234 }
3235 return __qeth_l3_open(dev);
3236 }
3237
qeth_l3_stop(struct net_device * dev)3238 static int qeth_l3_stop(struct net_device *dev)
3239 {
3240 struct qeth_card *card = dev->ml_priv;
3241
3242 QETH_CARD_TEXT(card, 4, "qethstop");
3243 netif_tx_disable(dev);
3244 if (card->state == CARD_STATE_UP) {
3245 card->state = CARD_STATE_SOFTSETUP;
3246 napi_disable(&card->napi);
3247 }
3248 return 0;
3249 }
3250
qeth_l3_ethtool_get_rx_csum(struct net_device * dev)3251 static u32 qeth_l3_ethtool_get_rx_csum(struct net_device *dev)
3252 {
3253 struct qeth_card *card = dev->ml_priv;
3254
3255 return (card->options.checksum_type == HW_CHECKSUMMING);
3256 }
3257
qeth_l3_ethtool_set_rx_csum(struct net_device * dev,u32 data)3258 static int qeth_l3_ethtool_set_rx_csum(struct net_device *dev, u32 data)
3259 {
3260 struct qeth_card *card = dev->ml_priv;
3261 enum qeth_checksum_types csum_type;
3262
3263 if (data)
3264 csum_type = HW_CHECKSUMMING;
3265 else
3266 csum_type = SW_CHECKSUMMING;
3267
3268 return qeth_l3_set_rx_csum(card, csum_type);
3269 }
3270
qeth_l3_ethtool_set_tso(struct net_device * dev,u32 data)3271 static int qeth_l3_ethtool_set_tso(struct net_device *dev, u32 data)
3272 {
3273 struct qeth_card *card = dev->ml_priv;
3274 int rc = 0;
3275
3276 if (data) {
3277 rc = qeth_l3_set_large_send(card, QETH_LARGE_SEND_TSO);
3278 } else {
3279 dev->features &= ~NETIF_F_TSO;
3280 card->options.large_send = QETH_LARGE_SEND_NO;
3281 }
3282 return rc;
3283 }
3284
qeth_l3_ethtool_set_tx_csum(struct net_device * dev,u32 data)3285 static int qeth_l3_ethtool_set_tx_csum(struct net_device *dev, u32 data)
3286 {
3287 struct qeth_card *card = dev->ml_priv;
3288
3289 if (data) {
3290 if (qeth_is_supported(card, IPA_OUTBOUND_CHECKSUM))
3291 dev->features |= NETIF_F_IP_CSUM;
3292 else
3293 return -EPERM;
3294 } else
3295 dev->features &= ~NETIF_F_IP_CSUM;
3296
3297 return 0;
3298 }
3299
3300 static const struct ethtool_ops qeth_l3_ethtool_ops = {
3301 .get_link = ethtool_op_get_link,
3302 .get_tx_csum = ethtool_op_get_tx_csum,
3303 .set_tx_csum = qeth_l3_ethtool_set_tx_csum,
3304 .get_rx_csum = qeth_l3_ethtool_get_rx_csum,
3305 .set_rx_csum = qeth_l3_ethtool_set_rx_csum,
3306 .get_sg = ethtool_op_get_sg,
3307 .set_sg = ethtool_op_set_sg,
3308 .get_tso = ethtool_op_get_tso,
3309 .set_tso = qeth_l3_ethtool_set_tso,
3310 .get_strings = qeth_core_get_strings,
3311 .get_ethtool_stats = qeth_core_get_ethtool_stats,
3312 .get_sset_count = qeth_core_get_sset_count,
3313 .get_drvinfo = qeth_core_get_drvinfo,
3314 .get_settings = qeth_core_ethtool_get_settings,
3315 };
3316
3317 /*
3318 * we need NOARP for IPv4 but we want neighbor solicitation for IPv6. Setting
3319 * NOARP on the netdevice is no option because it also turns off neighbor
3320 * solicitation. For IPv4 we install a neighbor_setup function. We don't want
3321 * arp resolution but we want the hard header (packet socket will work
3322 * e.g. tcpdump)
3323 */
qeth_l3_neigh_setup_noarp(struct neighbour * n)3324 static int qeth_l3_neigh_setup_noarp(struct neighbour *n)
3325 {
3326 n->nud_state = NUD_NOARP;
3327 memcpy(n->ha, "FAKELL", 6);
3328 n->output = n->ops->connected_output;
3329 return 0;
3330 }
3331
3332 static int
qeth_l3_neigh_setup(struct net_device * dev,struct neigh_parms * np)3333 qeth_l3_neigh_setup(struct net_device *dev, struct neigh_parms *np)
3334 {
3335 if (np->tbl->family == AF_INET)
3336 np->neigh_setup = qeth_l3_neigh_setup_noarp;
3337
3338 return 0;
3339 }
3340
3341 static const struct net_device_ops qeth_l3_netdev_ops = {
3342 .ndo_open = qeth_l3_open,
3343 .ndo_stop = qeth_l3_stop,
3344 .ndo_get_stats = qeth_get_stats,
3345 .ndo_start_xmit = qeth_l3_hard_start_xmit,
3346 .ndo_validate_addr = eth_validate_addr,
3347 .ndo_set_multicast_list = qeth_l3_set_multicast_list,
3348 .ndo_do_ioctl = qeth_l3_do_ioctl,
3349 .ndo_change_mtu = qeth_change_mtu,
3350 .ndo_vlan_rx_register = qeth_l3_vlan_rx_register,
3351 .ndo_vlan_rx_add_vid = qeth_l3_vlan_rx_add_vid,
3352 .ndo_vlan_rx_kill_vid = qeth_l3_vlan_rx_kill_vid,
3353 .ndo_tx_timeout = qeth_tx_timeout,
3354 };
3355
3356 static const struct net_device_ops qeth_l3_osa_netdev_ops = {
3357 .ndo_open = qeth_l3_open,
3358 .ndo_stop = qeth_l3_stop,
3359 .ndo_get_stats = qeth_get_stats,
3360 .ndo_start_xmit = qeth_l3_hard_start_xmit,
3361 .ndo_validate_addr = eth_validate_addr,
3362 .ndo_set_multicast_list = qeth_l3_set_multicast_list,
3363 .ndo_do_ioctl = qeth_l3_do_ioctl,
3364 .ndo_change_mtu = qeth_change_mtu,
3365 .ndo_vlan_rx_register = qeth_l3_vlan_rx_register,
3366 .ndo_vlan_rx_add_vid = qeth_l3_vlan_rx_add_vid,
3367 .ndo_vlan_rx_kill_vid = qeth_l3_vlan_rx_kill_vid,
3368 .ndo_tx_timeout = qeth_tx_timeout,
3369 .ndo_neigh_setup = qeth_l3_neigh_setup,
3370 };
3371
qeth_l3_setup_netdev(struct qeth_card * card)3372 static int qeth_l3_setup_netdev(struct qeth_card *card)
3373 {
3374 if (card->info.type == QETH_CARD_TYPE_OSD ||
3375 card->info.type == QETH_CARD_TYPE_OSX) {
3376 if ((card->info.link_type == QETH_LINK_TYPE_LANE_TR) ||
3377 (card->info.link_type == QETH_LINK_TYPE_HSTR)) {
3378 #ifdef CONFIG_TR
3379 card->dev = alloc_trdev(0);
3380 #endif
3381 if (!card->dev)
3382 return -ENODEV;
3383 card->dev->netdev_ops = &qeth_l3_netdev_ops;
3384 } else {
3385 card->dev = alloc_etherdev(0);
3386 if (!card->dev)
3387 return -ENODEV;
3388 card->dev->netdev_ops = &qeth_l3_osa_netdev_ops;
3389
3390 /*IPv6 address autoconfiguration stuff*/
3391 qeth_l3_get_unique_id(card);
3392 if (!(card->info.unique_id & UNIQUE_ID_NOT_BY_CARD))
3393 card->dev->dev_id = card->info.unique_id &
3394 0xffff;
3395 if (!card->info.guestlan)
3396 card->dev->features |= NETIF_F_GRO;
3397 }
3398 } else if (card->info.type == QETH_CARD_TYPE_IQD) {
3399 card->dev = alloc_netdev(0, "hsi%d", ether_setup);
3400 if (!card->dev)
3401 return -ENODEV;
3402 card->dev->flags |= IFF_NOARP;
3403 card->dev->netdev_ops = &qeth_l3_netdev_ops;
3404 qeth_l3_iqd_read_initial_mac(card);
3405 } else
3406 return -ENODEV;
3407
3408 card->dev->ml_priv = card;
3409 card->dev->watchdog_timeo = QETH_TX_TIMEOUT;
3410 card->dev->mtu = card->info.initial_mtu;
3411 SET_ETHTOOL_OPS(card->dev, &qeth_l3_ethtool_ops);
3412 card->dev->features |= NETIF_F_HW_VLAN_TX |
3413 NETIF_F_HW_VLAN_RX |
3414 NETIF_F_HW_VLAN_FILTER;
3415 card->dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
3416 card->dev->gso_max_size = 15 * PAGE_SIZE;
3417
3418 SET_NETDEV_DEV(card->dev, &card->gdev->dev);
3419 netif_napi_add(card->dev, &card->napi, qeth_l3_poll, QETH_NAPI_WEIGHT);
3420 return register_netdev(card->dev);
3421 }
3422
qeth_l3_probe_device(struct ccwgroup_device * gdev)3423 static int qeth_l3_probe_device(struct ccwgroup_device *gdev)
3424 {
3425 struct qeth_card *card = dev_get_drvdata(&gdev->dev);
3426
3427 qeth_l3_create_device_attributes(&gdev->dev);
3428 card->options.layer2 = 0;
3429 card->discipline.start_poll = qeth_qdio_start_poll;
3430 card->discipline.input_handler = (qdio_handler_t *)
3431 qeth_qdio_input_handler;
3432 card->discipline.output_handler = (qdio_handler_t *)
3433 qeth_qdio_output_handler;
3434 card->discipline.recover = qeth_l3_recover;
3435 if ((card->info.type == QETH_CARD_TYPE_OSD) ||
3436 (card->info.type == QETH_CARD_TYPE_OSX))
3437 card->options.checksum_type = HW_CHECKSUMMING;
3438 return 0;
3439 }
3440
qeth_l3_remove_device(struct ccwgroup_device * cgdev)3441 static void qeth_l3_remove_device(struct ccwgroup_device *cgdev)
3442 {
3443 struct qeth_card *card = dev_get_drvdata(&cgdev->dev);
3444
3445 qeth_l3_remove_device_attributes(&cgdev->dev);
3446
3447 qeth_set_allowed_threads(card, 0, 1);
3448 wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0);
3449
3450 if (cgdev->state == CCWGROUP_ONLINE)
3451 qeth_l3_set_offline(cgdev);
3452
3453 if (card->dev) {
3454 unregister_netdev(card->dev);
3455 card->dev = NULL;
3456 }
3457
3458 qeth_l3_clear_ip_list(card, 0);
3459 qeth_l3_clear_ipato_list(card);
3460 return;
3461 }
3462
__qeth_l3_set_online(struct ccwgroup_device * gdev,int recovery_mode)3463 static int __qeth_l3_set_online(struct ccwgroup_device *gdev, int recovery_mode)
3464 {
3465 struct qeth_card *card = dev_get_drvdata(&gdev->dev);
3466 int rc = 0;
3467 enum qeth_card_states recover_flag;
3468
3469 BUG_ON(!card);
3470 mutex_lock(&card->discipline_mutex);
3471 mutex_lock(&card->conf_mutex);
3472 QETH_DBF_TEXT(SETUP, 2, "setonlin");
3473 QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *));
3474
3475 recover_flag = card->state;
3476 rc = qeth_core_hardsetup_card(card);
3477 if (rc) {
3478 QETH_DBF_TEXT_(SETUP, 2, "2err%d", rc);
3479 rc = -ENODEV;
3480 goto out_remove;
3481 }
3482
3483 qeth_l3_query_ipassists(card, QETH_PROT_IPV4);
3484
3485 if (!card->dev && qeth_l3_setup_netdev(card)) {
3486 rc = -ENODEV;
3487 goto out_remove;
3488 }
3489
3490 card->state = CARD_STATE_HARDSETUP;
3491 memset(&card->rx, 0, sizeof(struct qeth_rx));
3492 qeth_print_status_message(card);
3493
3494 /* softsetup */
3495 QETH_DBF_TEXT(SETUP, 2, "softsetp");
3496
3497 rc = qeth_send_startlan(card);
3498 if (rc) {
3499 QETH_DBF_TEXT_(SETUP, 2, "1err%d", rc);
3500 if (rc == 0xe080) {
3501 dev_warn(&card->gdev->dev,
3502 "The LAN is offline\n");
3503 card->lan_online = 0;
3504 goto contin;
3505 }
3506 rc = -ENODEV;
3507 goto out_remove;
3508 } else
3509 card->lan_online = 1;
3510
3511 contin:
3512 rc = qeth_l3_setadapter_parms(card);
3513 if (rc)
3514 QETH_DBF_TEXT_(SETUP, 2, "2err%d", rc);
3515 if (!card->options.sniffer) {
3516 rc = qeth_l3_start_ipassists(card);
3517 if (rc)
3518 QETH_DBF_TEXT_(SETUP, 2, "3err%d", rc);
3519 qeth_l3_set_large_send(card, card->options.large_send);
3520 rc = qeth_l3_setrouting_v4(card);
3521 if (rc)
3522 QETH_DBF_TEXT_(SETUP, 2, "4err%d", rc);
3523 rc = qeth_l3_setrouting_v6(card);
3524 if (rc)
3525 QETH_DBF_TEXT_(SETUP, 2, "5err%d", rc);
3526 }
3527 netif_tx_disable(card->dev);
3528
3529 rc = qeth_init_qdio_queues(card);
3530 if (rc) {
3531 QETH_DBF_TEXT_(SETUP, 2, "6err%d", rc);
3532 rc = -ENODEV;
3533 goto out_remove;
3534 }
3535 card->state = CARD_STATE_SOFTSETUP;
3536
3537 qeth_set_allowed_threads(card, 0xffffffff, 0);
3538 qeth_l3_set_ip_addr_list(card);
3539 if (card->lan_online)
3540 netif_carrier_on(card->dev);
3541 else
3542 netif_carrier_off(card->dev);
3543 if (recover_flag == CARD_STATE_RECOVER) {
3544 if (recovery_mode)
3545 __qeth_l3_open(card->dev);
3546 else {
3547 rtnl_lock();
3548 dev_open(card->dev);
3549 rtnl_unlock();
3550 }
3551 qeth_l3_set_multicast_list(card->dev);
3552 }
3553 /* let user_space know that device is online */
3554 kobject_uevent(&gdev->dev.kobj, KOBJ_CHANGE);
3555 mutex_unlock(&card->conf_mutex);
3556 mutex_unlock(&card->discipline_mutex);
3557 return 0;
3558 out_remove:
3559 qeth_l3_stop_card(card, 0);
3560 ccw_device_set_offline(CARD_DDEV(card));
3561 ccw_device_set_offline(CARD_WDEV(card));
3562 ccw_device_set_offline(CARD_RDEV(card));
3563 if (recover_flag == CARD_STATE_RECOVER)
3564 card->state = CARD_STATE_RECOVER;
3565 else
3566 card->state = CARD_STATE_DOWN;
3567 mutex_unlock(&card->conf_mutex);
3568 mutex_unlock(&card->discipline_mutex);
3569 return rc;
3570 }
3571
qeth_l3_set_online(struct ccwgroup_device * gdev)3572 static int qeth_l3_set_online(struct ccwgroup_device *gdev)
3573 {
3574 return __qeth_l3_set_online(gdev, 0);
3575 }
3576
__qeth_l3_set_offline(struct ccwgroup_device * cgdev,int recovery_mode)3577 static int __qeth_l3_set_offline(struct ccwgroup_device *cgdev,
3578 int recovery_mode)
3579 {
3580 struct qeth_card *card = dev_get_drvdata(&cgdev->dev);
3581 int rc = 0, rc2 = 0, rc3 = 0;
3582 enum qeth_card_states recover_flag;
3583
3584 mutex_lock(&card->discipline_mutex);
3585 mutex_lock(&card->conf_mutex);
3586 QETH_DBF_TEXT(SETUP, 3, "setoffl");
3587 QETH_DBF_HEX(SETUP, 3, &card, sizeof(void *));
3588
3589 if (card->dev && netif_carrier_ok(card->dev))
3590 netif_carrier_off(card->dev);
3591 recover_flag = card->state;
3592 qeth_l3_stop_card(card, recovery_mode);
3593 rc = ccw_device_set_offline(CARD_DDEV(card));
3594 rc2 = ccw_device_set_offline(CARD_WDEV(card));
3595 rc3 = ccw_device_set_offline(CARD_RDEV(card));
3596 if (!rc)
3597 rc = (rc2) ? rc2 : rc3;
3598 if (rc)
3599 QETH_DBF_TEXT_(SETUP, 2, "1err%d", rc);
3600 if (recover_flag == CARD_STATE_UP)
3601 card->state = CARD_STATE_RECOVER;
3602 /* let user_space know that device is offline */
3603 kobject_uevent(&cgdev->dev.kobj, KOBJ_CHANGE);
3604 mutex_unlock(&card->conf_mutex);
3605 mutex_unlock(&card->discipline_mutex);
3606 return 0;
3607 }
3608
qeth_l3_set_offline(struct ccwgroup_device * cgdev)3609 static int qeth_l3_set_offline(struct ccwgroup_device *cgdev)
3610 {
3611 return __qeth_l3_set_offline(cgdev, 0);
3612 }
3613
qeth_l3_recover(void * ptr)3614 static int qeth_l3_recover(void *ptr)
3615 {
3616 struct qeth_card *card;
3617 int rc = 0;
3618
3619 card = (struct qeth_card *) ptr;
3620 QETH_CARD_TEXT(card, 2, "recover1");
3621 QETH_CARD_HEX(card, 2, &card, sizeof(void *));
3622 if (!qeth_do_run_thread(card, QETH_RECOVER_THREAD))
3623 return 0;
3624 QETH_CARD_TEXT(card, 2, "recover2");
3625 dev_warn(&card->gdev->dev,
3626 "A recovery process has been started for the device\n");
3627 __qeth_l3_set_offline(card->gdev, 1);
3628 rc = __qeth_l3_set_online(card->gdev, 1);
3629 if (!rc)
3630 dev_info(&card->gdev->dev,
3631 "Device successfully recovered!\n");
3632 else {
3633 rtnl_lock();
3634 dev_close(card->dev);
3635 rtnl_unlock();
3636 dev_warn(&card->gdev->dev, "The qeth device driver "
3637 "failed to recover an error on the device\n");
3638 }
3639 qeth_clear_thread_start_bit(card, QETH_RECOVER_THREAD);
3640 qeth_clear_thread_running_bit(card, QETH_RECOVER_THREAD);
3641 return 0;
3642 }
3643
qeth_l3_shutdown(struct ccwgroup_device * gdev)3644 static void qeth_l3_shutdown(struct ccwgroup_device *gdev)
3645 {
3646 struct qeth_card *card = dev_get_drvdata(&gdev->dev);
3647 qeth_qdio_clear_card(card, 0);
3648 qeth_clear_qdio_buffers(card);
3649 }
3650
qeth_l3_pm_suspend(struct ccwgroup_device * gdev)3651 static int qeth_l3_pm_suspend(struct ccwgroup_device *gdev)
3652 {
3653 struct qeth_card *card = dev_get_drvdata(&gdev->dev);
3654
3655 if (card->dev)
3656 netif_device_detach(card->dev);
3657 qeth_set_allowed_threads(card, 0, 1);
3658 wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0);
3659 if (gdev->state == CCWGROUP_OFFLINE)
3660 return 0;
3661 if (card->state == CARD_STATE_UP) {
3662 __qeth_l3_set_offline(card->gdev, 1);
3663 } else
3664 __qeth_l3_set_offline(card->gdev, 0);
3665 return 0;
3666 }
3667
qeth_l3_pm_resume(struct ccwgroup_device * gdev)3668 static int qeth_l3_pm_resume(struct ccwgroup_device *gdev)
3669 {
3670 struct qeth_card *card = dev_get_drvdata(&gdev->dev);
3671 int rc = 0;
3672
3673 if (gdev->state == CCWGROUP_OFFLINE)
3674 goto out;
3675
3676 if (card->state == CARD_STATE_RECOVER) {
3677 rc = __qeth_l3_set_online(card->gdev, 1);
3678 if (rc) {
3679 rtnl_lock();
3680 dev_close(card->dev);
3681 rtnl_unlock();
3682 }
3683 } else
3684 rc = __qeth_l3_set_online(card->gdev, 0);
3685 out:
3686 qeth_set_allowed_threads(card, 0xffffffff, 0);
3687 if (card->dev)
3688 netif_device_attach(card->dev);
3689 if (rc)
3690 dev_warn(&card->gdev->dev, "The qeth device driver "
3691 "failed to recover an error on the device\n");
3692 return rc;
3693 }
3694
3695 struct ccwgroup_driver qeth_l3_ccwgroup_driver = {
3696 .probe = qeth_l3_probe_device,
3697 .remove = qeth_l3_remove_device,
3698 .set_online = qeth_l3_set_online,
3699 .set_offline = qeth_l3_set_offline,
3700 .shutdown = qeth_l3_shutdown,
3701 .freeze = qeth_l3_pm_suspend,
3702 .thaw = qeth_l3_pm_resume,
3703 .restore = qeth_l3_pm_resume,
3704 };
3705 EXPORT_SYMBOL_GPL(qeth_l3_ccwgroup_driver);
3706
qeth_l3_ip_event(struct notifier_block * this,unsigned long event,void * ptr)3707 static int qeth_l3_ip_event(struct notifier_block *this,
3708 unsigned long event, void *ptr)
3709 {
3710 struct in_ifaddr *ifa = (struct in_ifaddr *)ptr;
3711 struct net_device *dev = (struct net_device *)ifa->ifa_dev->dev;
3712 struct qeth_ipaddr *addr;
3713 struct qeth_card *card;
3714
3715 if (dev_net(dev) != &init_net)
3716 return NOTIFY_DONE;
3717
3718 card = qeth_l3_get_card_from_dev(dev);
3719 QETH_CARD_TEXT(card, 3, "ipevent");
3720 if (!card)
3721 return NOTIFY_DONE;
3722
3723 addr = qeth_l3_get_addr_buffer(QETH_PROT_IPV4);
3724 if (addr != NULL) {
3725 addr->u.a4.addr = ifa->ifa_address;
3726 addr->u.a4.mask = ifa->ifa_mask;
3727 addr->type = QETH_IP_TYPE_NORMAL;
3728 } else
3729 goto out;
3730
3731 switch (event) {
3732 case NETDEV_UP:
3733 if (!qeth_l3_add_ip(card, addr))
3734 kfree(addr);
3735 break;
3736 case NETDEV_DOWN:
3737 if (!qeth_l3_delete_ip(card, addr))
3738 kfree(addr);
3739 break;
3740 default:
3741 break;
3742 }
3743 qeth_l3_set_ip_addr_list(card);
3744 out:
3745 return NOTIFY_DONE;
3746 }
3747
3748 static struct notifier_block qeth_l3_ip_notifier = {
3749 qeth_l3_ip_event,
3750 NULL,
3751 };
3752
3753 #ifdef CONFIG_QETH_IPV6
3754 /**
3755 * IPv6 event handler
3756 */
qeth_l3_ip6_event(struct notifier_block * this,unsigned long event,void * ptr)3757 static int qeth_l3_ip6_event(struct notifier_block *this,
3758 unsigned long event, void *ptr)
3759 {
3760 struct inet6_ifaddr *ifa = (struct inet6_ifaddr *)ptr;
3761 struct net_device *dev = (struct net_device *)ifa->idev->dev;
3762 struct qeth_ipaddr *addr;
3763 struct qeth_card *card;
3764
3765
3766 card = qeth_l3_get_card_from_dev(dev);
3767 if (!card)
3768 return NOTIFY_DONE;
3769 QETH_CARD_TEXT(card, 3, "ip6event");
3770 if (!qeth_is_supported(card, IPA_IPV6))
3771 return NOTIFY_DONE;
3772
3773 addr = qeth_l3_get_addr_buffer(QETH_PROT_IPV6);
3774 if (addr != NULL) {
3775 memcpy(&addr->u.a6.addr, &ifa->addr, sizeof(struct in6_addr));
3776 addr->u.a6.pfxlen = ifa->prefix_len;
3777 addr->type = QETH_IP_TYPE_NORMAL;
3778 } else
3779 goto out;
3780
3781 switch (event) {
3782 case NETDEV_UP:
3783 if (!qeth_l3_add_ip(card, addr))
3784 kfree(addr);
3785 break;
3786 case NETDEV_DOWN:
3787 if (!qeth_l3_delete_ip(card, addr))
3788 kfree(addr);
3789 break;
3790 default:
3791 break;
3792 }
3793 qeth_l3_set_ip_addr_list(card);
3794 out:
3795 return NOTIFY_DONE;
3796 }
3797
3798 static struct notifier_block qeth_l3_ip6_notifier = {
3799 qeth_l3_ip6_event,
3800 NULL,
3801 };
3802 #endif
3803
qeth_l3_register_notifiers(void)3804 static int qeth_l3_register_notifiers(void)
3805 {
3806 int rc;
3807
3808 QETH_DBF_TEXT(SETUP, 5, "regnotif");
3809 rc = register_inetaddr_notifier(&qeth_l3_ip_notifier);
3810 if (rc)
3811 return rc;
3812 #ifdef CONFIG_QETH_IPV6
3813 rc = register_inet6addr_notifier(&qeth_l3_ip6_notifier);
3814 if (rc) {
3815 unregister_inetaddr_notifier(&qeth_l3_ip_notifier);
3816 return rc;
3817 }
3818 #else
3819 pr_warning("There is no IPv6 support for the layer 3 discipline\n");
3820 #endif
3821 return 0;
3822 }
3823
qeth_l3_unregister_notifiers(void)3824 static void qeth_l3_unregister_notifiers(void)
3825 {
3826
3827 QETH_DBF_TEXT(SETUP, 5, "unregnot");
3828 BUG_ON(unregister_inetaddr_notifier(&qeth_l3_ip_notifier));
3829 #ifdef CONFIG_QETH_IPV6
3830 BUG_ON(unregister_inet6addr_notifier(&qeth_l3_ip6_notifier));
3831 #endif /* QETH_IPV6 */
3832 }
3833
qeth_l3_init(void)3834 static int __init qeth_l3_init(void)
3835 {
3836 int rc = 0;
3837
3838 pr_info("register layer 3 discipline\n");
3839 rc = qeth_l3_register_notifiers();
3840 return rc;
3841 }
3842
qeth_l3_exit(void)3843 static void __exit qeth_l3_exit(void)
3844 {
3845 qeth_l3_unregister_notifiers();
3846 pr_info("unregister layer 3 discipline\n");
3847 }
3848
3849 module_init(qeth_l3_init);
3850 module_exit(qeth_l3_exit);
3851 MODULE_AUTHOR("Frank Blaschka <frank.blaschka@de.ibm.com>");
3852 MODULE_DESCRIPTION("qeth layer 3 discipline");
3853 MODULE_LICENSE("GPL");
3854