2 * drivers/s390/net/qeth_l3_main.c
4 * Copyright IBM Corp. 2007
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>
11 #include <linux/module.h>
12 #include <linux/moduleparam.h>
13 #include <linux/string.h>
14 #include <linux/errno.h>
15 #include <linux/kernel.h>
16 #include <linux/etherdevice.h>
17 #include <linux/mii.h>
19 #include <linux/reboot.h>
20 #include <linux/inetdevice.h>
21 #include <linux/igmp.h>
26 #include <asm/s390_rdev.h>
29 #include "qeth_core_offl.h"
31 static int qeth_l3_set_offline(struct ccwgroup_device
*);
32 static int qeth_l3_recover(void *);
33 static int qeth_l3_stop(struct net_device
*);
34 static void qeth_l3_set_multicast_list(struct net_device
*);
35 static int qeth_l3_neigh_setup(struct net_device
*, struct neigh_parms
*);
36 static int qeth_l3_register_addr_entry(struct qeth_card
*,
37 struct qeth_ipaddr
*);
38 static int qeth_l3_deregister_addr_entry(struct qeth_card
*,
39 struct qeth_ipaddr
*);
40 static int __qeth_l3_set_online(struct ccwgroup_device
*, int);
41 static int __qeth_l3_set_offline(struct ccwgroup_device
*, int);
44 static int qeth_l3_isxdigit(char *buf
)
47 if (!isxdigit(*buf
++))
53 void qeth_l3_ipaddr4_to_string(const __u8
*addr
, char *buf
)
55 sprintf(buf
, "%i.%i.%i.%i", addr
[0], addr
[1], addr
[2], addr
[3]);
58 int qeth_l3_string_to_ipaddr4(const char *buf
, __u8
*addr
)
60 int count
= 0, rc
= 0;
64 rc
= sscanf(buf
, "%u.%u.%u.%u%c",
65 &in
[0], &in
[1], &in
[2], &in
[3], &c
);
66 if (rc
!= 4 && (rc
!= 5 || c
!= '\n'))
68 for (count
= 0; count
< 4; count
++) {
71 addr
[count
] = in
[count
];
76 void qeth_l3_ipaddr6_to_string(const __u8
*addr
, char *buf
)
78 sprintf(buf
, "%02x%02x:%02x%02x:%02x%02x:%02x%02x"
79 ":%02x%02x:%02x%02x:%02x%02x:%02x%02x",
80 addr
[0], addr
[1], addr
[2], addr
[3],
81 addr
[4], addr
[5], addr
[6], addr
[7],
82 addr
[8], addr
[9], addr
[10], addr
[11],
83 addr
[12], addr
[13], addr
[14], addr
[15]);
86 int qeth_l3_string_to_ipaddr6(const char *buf
, __u8
*addr
)
88 const char *end
, *end_tmp
, *start
;
91 int num2
, cnt
, out
, found
, save_cnt
;
92 unsigned short in_tmp
[8] = {0, };
94 cnt
= out
= found
= save_cnt
= num2
= 0;
99 end
= strchr(start
, ':');
101 end
= buf
+ strlen(buf
);
102 end_tmp
= strchr(start
, '\n');
109 if ((end
- start
) > 4)
111 memcpy(num
, start
, end
- start
);
112 if (!qeth_l3_isxdigit(num
))
114 sscanf(start
, "%x", &num2
);
116 in_tmp
[save_cnt
++] = num2
;
128 if (cnt
+ save_cnt
> 8)
132 in
[cnt
--] = in_tmp
[--save_cnt
];
136 void qeth_l3_ipaddr_to_string(enum qeth_prot_versions proto
, const __u8
*addr
,
139 if (proto
== QETH_PROT_IPV4
)
140 qeth_l3_ipaddr4_to_string(addr
, buf
);
141 else if (proto
== QETH_PROT_IPV6
)
142 qeth_l3_ipaddr6_to_string(addr
, buf
);
145 int qeth_l3_string_to_ipaddr(const char *buf
, enum qeth_prot_versions proto
,
148 if (proto
== QETH_PROT_IPV4
)
149 return qeth_l3_string_to_ipaddr4(buf
, addr
);
150 else if (proto
== QETH_PROT_IPV6
)
151 return qeth_l3_string_to_ipaddr6(buf
, addr
);
156 static void qeth_l3_convert_addr_to_bits(u8
*addr
, u8
*bits
, int len
)
161 for (i
= 0; i
< len
; ++i
) {
163 for (j
= 7; j
>= 0; --j
) {
164 bits
[i
*8 + j
] = octet
& 1;
170 static int qeth_l3_is_addr_covered_by_ipato(struct qeth_card
*card
,
171 struct qeth_ipaddr
*addr
)
173 struct qeth_ipato_entry
*ipatoe
;
174 u8 addr_bits
[128] = {0, };
175 u8 ipatoe_bits
[128] = {0, };
178 if (!card
->ipato
.enabled
)
181 qeth_l3_convert_addr_to_bits((u8
*) &addr
->u
, addr_bits
,
182 (addr
->proto
== QETH_PROT_IPV4
)? 4:16);
183 list_for_each_entry(ipatoe
, &card
->ipato
.entries
, entry
) {
184 if (addr
->proto
!= ipatoe
->proto
)
186 qeth_l3_convert_addr_to_bits(ipatoe
->addr
, ipatoe_bits
,
187 (ipatoe
->proto
== QETH_PROT_IPV4
) ?
189 if (addr
->proto
== QETH_PROT_IPV4
)
190 rc
= !memcmp(addr_bits
, ipatoe_bits
,
191 min(32, ipatoe
->mask_bits
));
193 rc
= !memcmp(addr_bits
, ipatoe_bits
,
194 min(128, ipatoe
->mask_bits
));
199 if ((addr
->proto
== QETH_PROT_IPV4
) && card
->ipato
.invert4
)
201 else if ((addr
->proto
== QETH_PROT_IPV6
) && card
->ipato
.invert6
)
208 * Add IP to be added to todo list. If there is already an "add todo"
209 * in this list we just incremenent the reference count.
210 * Returns 0 if we just incremented reference count.
212 static int __qeth_l3_insert_ip_todo(struct qeth_card
*card
,
213 struct qeth_ipaddr
*addr
, int add
)
215 struct qeth_ipaddr
*tmp
, *t
;
218 list_for_each_entry_safe(tmp
, t
, card
->ip_tbd_list
, entry
) {
219 if ((addr
->type
== QETH_IP_TYPE_DEL_ALL_MC
) &&
220 (tmp
->type
== QETH_IP_TYPE_DEL_ALL_MC
))
222 if ((tmp
->proto
== QETH_PROT_IPV4
) &&
223 (addr
->proto
== QETH_PROT_IPV4
) &&
224 (tmp
->type
== addr
->type
) &&
225 (tmp
->is_multicast
== addr
->is_multicast
) &&
226 (tmp
->u
.a4
.addr
== addr
->u
.a4
.addr
) &&
227 (tmp
->u
.a4
.mask
== addr
->u
.a4
.mask
)) {
231 if ((tmp
->proto
== QETH_PROT_IPV6
) &&
232 (addr
->proto
== QETH_PROT_IPV6
) &&
233 (tmp
->type
== addr
->type
) &&
234 (tmp
->is_multicast
== addr
->is_multicast
) &&
235 (tmp
->u
.a6
.pfxlen
== addr
->u
.a6
.pfxlen
) &&
236 (memcmp(&tmp
->u
.a6
.addr
, &addr
->u
.a6
.addr
,
237 sizeof(struct in6_addr
)) == 0)) {
243 if (addr
->users
!= 0)
244 tmp
->users
+= addr
->users
;
246 tmp
->users
+= add
? 1 : -1;
247 if (tmp
->users
== 0) {
248 list_del(&tmp
->entry
);
253 if (addr
->type
== QETH_IP_TYPE_DEL_ALL_MC
)
254 list_add(&addr
->entry
, card
->ip_tbd_list
);
256 if (addr
->users
== 0)
257 addr
->users
+= add
? 1 : -1;
258 if (add
&& (addr
->type
== QETH_IP_TYPE_NORMAL
) &&
259 qeth_l3_is_addr_covered_by_ipato(card
, addr
)) {
260 QETH_DBF_TEXT(TRACE
, 2, "tkovaddr");
261 addr
->set_flags
|= QETH_IPA_SETIP_TAKEOVER_FLAG
;
263 list_add_tail(&addr
->entry
, card
->ip_tbd_list
);
269 static int qeth_l3_delete_ip(struct qeth_card
*card
, struct qeth_ipaddr
*addr
)
274 QETH_DBF_TEXT(TRACE
, 4, "delip");
276 if (addr
->proto
== QETH_PROT_IPV4
)
277 QETH_DBF_HEX(TRACE
, 4, &addr
->u
.a4
.addr
, 4);
279 QETH_DBF_HEX(TRACE
, 4, &addr
->u
.a6
.addr
, 8);
280 QETH_DBF_HEX(TRACE
, 4, ((char *)&addr
->u
.a6
.addr
) + 8, 8);
282 spin_lock_irqsave(&card
->ip_lock
, flags
);
283 rc
= __qeth_l3_insert_ip_todo(card
, addr
, 0);
284 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
288 static int qeth_l3_add_ip(struct qeth_card
*card
, struct qeth_ipaddr
*addr
)
293 QETH_DBF_TEXT(TRACE
, 4, "addip");
294 if (addr
->proto
== QETH_PROT_IPV4
)
295 QETH_DBF_HEX(TRACE
, 4, &addr
->u
.a4
.addr
, 4);
297 QETH_DBF_HEX(TRACE
, 4, &addr
->u
.a6
.addr
, 8);
298 QETH_DBF_HEX(TRACE
, 4, ((char *)&addr
->u
.a6
.addr
) + 8, 8);
300 spin_lock_irqsave(&card
->ip_lock
, flags
);
301 rc
= __qeth_l3_insert_ip_todo(card
, addr
, 1);
302 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
307 static struct qeth_ipaddr
*qeth_l3_get_addr_buffer(
308 enum qeth_prot_versions prot
)
310 struct qeth_ipaddr
*addr
;
312 addr
= kzalloc(sizeof(struct qeth_ipaddr
), GFP_ATOMIC
);
314 PRINT_WARN("Not enough memory to add address\n");
317 addr
->type
= QETH_IP_TYPE_NORMAL
;
322 static void qeth_l3_delete_mc_addresses(struct qeth_card
*card
)
324 struct qeth_ipaddr
*iptodo
;
327 QETH_DBF_TEXT(TRACE
, 4, "delmc");
328 iptodo
= qeth_l3_get_addr_buffer(QETH_PROT_IPV4
);
330 QETH_DBF_TEXT(TRACE
, 2, "dmcnomem");
333 iptodo
->type
= QETH_IP_TYPE_DEL_ALL_MC
;
334 spin_lock_irqsave(&card
->ip_lock
, flags
);
335 if (!__qeth_l3_insert_ip_todo(card
, iptodo
, 0))
337 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
341 * Add/remove address to/from card's ip list, i.e. try to add or remove
342 * reference to/from an IP address that is already registered on the card.
344 * 0 address was on card and its reference count has been adjusted,
345 * but is still > 0, so nothing has to be done
346 * also returns 0 if card was not on card and the todo was to delete
347 * the address -> there is also nothing to be done
348 * 1 address was not on card and the todo is to add it to the card's ip
350 * -1 address was on card and its reference count has been decremented
351 * to <= 0 by the todo -> address must be removed from card
353 static int __qeth_l3_ref_ip_on_card(struct qeth_card
*card
,
354 struct qeth_ipaddr
*todo
, struct qeth_ipaddr
**__addr
)
356 struct qeth_ipaddr
*addr
;
359 list_for_each_entry(addr
, &card
->ip_list
, entry
) {
360 if ((addr
->proto
== QETH_PROT_IPV4
) &&
361 (todo
->proto
== QETH_PROT_IPV4
) &&
362 (addr
->type
== todo
->type
) &&
363 (addr
->u
.a4
.addr
== todo
->u
.a4
.addr
) &&
364 (addr
->u
.a4
.mask
== todo
->u
.a4
.mask
)) {
368 if ((addr
->proto
== QETH_PROT_IPV6
) &&
369 (todo
->proto
== QETH_PROT_IPV6
) &&
370 (addr
->type
== todo
->type
) &&
371 (addr
->u
.a6
.pfxlen
== todo
->u
.a6
.pfxlen
) &&
372 (memcmp(&addr
->u
.a6
.addr
, &todo
->u
.a6
.addr
,
373 sizeof(struct in6_addr
)) == 0)) {
379 addr
->users
+= todo
->users
;
380 if (addr
->users
<= 0) {
384 /* for VIPA and RXIP limit refcount to 1 */
385 if (addr
->type
!= QETH_IP_TYPE_NORMAL
)
390 if (todo
->users
> 0) {
391 /* for VIPA and RXIP limit refcount to 1 */
392 if (todo
->type
!= QETH_IP_TYPE_NORMAL
)
399 static void __qeth_l3_delete_all_mc(struct qeth_card
*card
,
400 unsigned long *flags
)
402 struct list_head fail_list
;
403 struct qeth_ipaddr
*addr
, *tmp
;
406 INIT_LIST_HEAD(&fail_list
);
408 list_for_each_entry_safe(addr
, tmp
, &card
->ip_list
, entry
) {
409 if (addr
->is_multicast
) {
410 list_del(&addr
->entry
);
411 spin_unlock_irqrestore(&card
->ip_lock
, *flags
);
412 rc
= qeth_l3_deregister_addr_entry(card
, addr
);
413 spin_lock_irqsave(&card
->ip_lock
, *flags
);
414 if (!rc
|| (rc
== IPA_RC_MC_ADDR_NOT_FOUND
))
417 list_add_tail(&addr
->entry
, &fail_list
);
421 list_splice(&fail_list
, &card
->ip_list
);
424 static void qeth_l3_set_ip_addr_list(struct qeth_card
*card
)
426 struct list_head
*tbd_list
;
427 struct qeth_ipaddr
*todo
, *addr
;
431 QETH_DBF_TEXT(TRACE
, 2, "sdiplist");
432 QETH_DBF_HEX(TRACE
, 2, &card
, sizeof(void *));
434 spin_lock_irqsave(&card
->ip_lock
, flags
);
435 tbd_list
= card
->ip_tbd_list
;
436 card
->ip_tbd_list
= kmalloc(sizeof(struct list_head
), GFP_ATOMIC
);
437 if (!card
->ip_tbd_list
) {
438 QETH_DBF_TEXT(TRACE
, 0, "silnomem");
439 card
->ip_tbd_list
= tbd_list
;
440 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
443 INIT_LIST_HEAD(card
->ip_tbd_list
);
445 while (!list_empty(tbd_list
)) {
446 todo
= list_entry(tbd_list
->next
, struct qeth_ipaddr
, entry
);
447 list_del(&todo
->entry
);
448 if (todo
->type
== QETH_IP_TYPE_DEL_ALL_MC
) {
449 __qeth_l3_delete_all_mc(card
, &flags
);
453 rc
= __qeth_l3_ref_ip_on_card(card
, todo
, &addr
);
455 /* nothing to be done; only adjusted refcount */
457 } else if (rc
== 1) {
458 /* new entry to be added to on-card list */
459 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
460 rc
= qeth_l3_register_addr_entry(card
, todo
);
461 spin_lock_irqsave(&card
->ip_lock
, flags
);
462 if (!rc
|| (rc
== IPA_RC_LAN_OFFLINE
))
463 list_add_tail(&todo
->entry
, &card
->ip_list
);
466 } else if (rc
== -1) {
467 /* on-card entry to be removed */
468 list_del_init(&addr
->entry
);
469 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
470 rc
= qeth_l3_deregister_addr_entry(card
, addr
);
471 spin_lock_irqsave(&card
->ip_lock
, flags
);
472 if (!rc
|| (rc
== IPA_RC_PRIMARY_ALREADY_DEFINED
))
475 list_add_tail(&addr
->entry
, &card
->ip_list
);
479 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
483 static void qeth_l3_clear_ip_list(struct qeth_card
*card
, int clean
,
486 struct qeth_ipaddr
*addr
, *tmp
;
489 QETH_DBF_TEXT(TRACE
, 4, "clearip");
490 spin_lock_irqsave(&card
->ip_lock
, flags
);
491 /* clear todo list */
492 list_for_each_entry_safe(addr
, tmp
, card
->ip_tbd_list
, entry
) {
493 list_del(&addr
->entry
);
497 while (!list_empty(&card
->ip_list
)) {
498 addr
= list_entry(card
->ip_list
.next
,
499 struct qeth_ipaddr
, entry
);
500 list_del_init(&addr
->entry
);
502 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
503 qeth_l3_deregister_addr_entry(card
, addr
);
504 spin_lock_irqsave(&card
->ip_lock
, flags
);
506 if (!recover
|| addr
->is_multicast
) {
510 list_add_tail(&addr
->entry
, card
->ip_tbd_list
);
512 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
515 static int qeth_l3_address_exists_in_list(struct list_head
*list
,
516 struct qeth_ipaddr
*addr
, int same_type
)
518 struct qeth_ipaddr
*tmp
;
520 list_for_each_entry(tmp
, list
, entry
) {
521 if ((tmp
->proto
== QETH_PROT_IPV4
) &&
522 (addr
->proto
== QETH_PROT_IPV4
) &&
523 ((same_type
&& (tmp
->type
== addr
->type
)) ||
524 (!same_type
&& (tmp
->type
!= addr
->type
))) &&
525 (tmp
->u
.a4
.addr
== addr
->u
.a4
.addr
))
528 if ((tmp
->proto
== QETH_PROT_IPV6
) &&
529 (addr
->proto
== QETH_PROT_IPV6
) &&
530 ((same_type
&& (tmp
->type
== addr
->type
)) ||
531 (!same_type
&& (tmp
->type
!= addr
->type
))) &&
532 (memcmp(&tmp
->u
.a6
.addr
, &addr
->u
.a6
.addr
,
533 sizeof(struct in6_addr
)) == 0))
540 static int qeth_l3_send_setdelmc(struct qeth_card
*card
,
541 struct qeth_ipaddr
*addr
, int ipacmd
)
544 struct qeth_cmd_buffer
*iob
;
545 struct qeth_ipa_cmd
*cmd
;
547 QETH_DBF_TEXT(TRACE
, 4, "setdelmc");
549 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, addr
->proto
);
550 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
551 memcpy(&cmd
->data
.setdelipm
.mac
, addr
->mac
, OSA_ADDR_LEN
);
552 if (addr
->proto
== QETH_PROT_IPV6
)
553 memcpy(cmd
->data
.setdelipm
.ip6
, &addr
->u
.a6
.addr
,
554 sizeof(struct in6_addr
));
556 memcpy(&cmd
->data
.setdelipm
.ip4
, &addr
->u
.a4
.addr
, 4);
558 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
563 static void qeth_l3_fill_netmask(u8
*netmask
, unsigned int len
)
566 for (i
= 0; i
< 16; i
++) {
571 netmask
[i
] = (u8
)(0xFF00 >> j
);
577 static int qeth_l3_send_setdelip(struct qeth_card
*card
,
578 struct qeth_ipaddr
*addr
, int ipacmd
, unsigned int flags
)
581 struct qeth_cmd_buffer
*iob
;
582 struct qeth_ipa_cmd
*cmd
;
585 QETH_DBF_TEXT(TRACE
, 4, "setdelip");
586 QETH_DBF_TEXT_(TRACE
, 4, "flags%02X", flags
);
588 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, addr
->proto
);
589 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
590 if (addr
->proto
== QETH_PROT_IPV6
) {
591 memcpy(cmd
->data
.setdelip6
.ip_addr
, &addr
->u
.a6
.addr
,
592 sizeof(struct in6_addr
));
593 qeth_l3_fill_netmask(netmask
, addr
->u
.a6
.pfxlen
);
594 memcpy(cmd
->data
.setdelip6
.mask
, netmask
,
595 sizeof(struct in6_addr
));
596 cmd
->data
.setdelip6
.flags
= flags
;
598 memcpy(cmd
->data
.setdelip4
.ip_addr
, &addr
->u
.a4
.addr
, 4);
599 memcpy(cmd
->data
.setdelip4
.mask
, &addr
->u
.a4
.mask
, 4);
600 cmd
->data
.setdelip4
.flags
= flags
;
603 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
608 static int qeth_l3_send_setrouting(struct qeth_card
*card
,
609 enum qeth_routing_types type
, enum qeth_prot_versions prot
)
612 struct qeth_ipa_cmd
*cmd
;
613 struct qeth_cmd_buffer
*iob
;
615 QETH_DBF_TEXT(TRACE
, 4, "setroutg");
616 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_SETRTG
, prot
);
617 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
618 cmd
->data
.setrtg
.type
= (type
);
619 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
624 static void qeth_l3_correct_routing_type(struct qeth_card
*card
,
625 enum qeth_routing_types
*type
, enum qeth_prot_versions prot
)
627 if (card
->info
.type
== QETH_CARD_TYPE_IQD
) {
630 case PRIMARY_CONNECTOR
:
631 case SECONDARY_CONNECTOR
:
632 case MULTICAST_ROUTER
:
641 case SECONDARY_ROUTER
:
643 case MULTICAST_ROUTER
:
644 if (qeth_is_ipafunc_supported(card
, prot
,
652 PRINT_WARN("Routing type '%s' not supported for interface %s.\n"
653 "Router status set to 'no router'.\n",
654 ((*type
== PRIMARY_ROUTER
)? "primary router" :
655 (*type
== SECONDARY_ROUTER
)? "secondary router" :
656 (*type
== PRIMARY_CONNECTOR
)? "primary connector" :
657 (*type
== SECONDARY_CONNECTOR
)? "secondary connector" :
658 (*type
== MULTICAST_ROUTER
)? "multicast router" :
664 int qeth_l3_setrouting_v4(struct qeth_card
*card
)
668 QETH_DBF_TEXT(TRACE
, 3, "setrtg4");
670 qeth_l3_correct_routing_type(card
, &card
->options
.route4
.type
,
673 rc
= qeth_l3_send_setrouting(card
, card
->options
.route4
.type
,
676 card
->options
.route4
.type
= NO_ROUTER
;
677 PRINT_WARN("Error (0x%04x) while setting routing type on %s. "
678 "Type set to 'no router'.\n",
679 rc
, QETH_CARD_IFNAME(card
));
684 int qeth_l3_setrouting_v6(struct qeth_card
*card
)
688 QETH_DBF_TEXT(TRACE
, 3, "setrtg6");
689 #ifdef CONFIG_QETH_IPV6
691 if (!qeth_is_supported(card
, IPA_IPV6
))
693 qeth_l3_correct_routing_type(card
, &card
->options
.route6
.type
,
696 rc
= qeth_l3_send_setrouting(card
, card
->options
.route6
.type
,
699 card
->options
.route6
.type
= NO_ROUTER
;
700 PRINT_WARN("Error (0x%04x) while setting routing type on %s. "
701 "Type set to 'no router'.\n",
702 rc
, QETH_CARD_IFNAME(card
));
709 * IP address takeover related functions
711 static void qeth_l3_clear_ipato_list(struct qeth_card
*card
)
714 struct qeth_ipato_entry
*ipatoe
, *tmp
;
717 spin_lock_irqsave(&card
->ip_lock
, flags
);
718 list_for_each_entry_safe(ipatoe
, tmp
, &card
->ipato
.entries
, entry
) {
719 list_del(&ipatoe
->entry
);
722 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
725 int qeth_l3_add_ipato_entry(struct qeth_card
*card
,
726 struct qeth_ipato_entry
*new)
728 struct qeth_ipato_entry
*ipatoe
;
732 QETH_DBF_TEXT(TRACE
, 2, "addipato");
733 spin_lock_irqsave(&card
->ip_lock
, flags
);
734 list_for_each_entry(ipatoe
, &card
->ipato
.entries
, entry
) {
735 if (ipatoe
->proto
!= new->proto
)
737 if (!memcmp(ipatoe
->addr
, new->addr
,
738 (ipatoe
->proto
== QETH_PROT_IPV4
)? 4:16) &&
739 (ipatoe
->mask_bits
== new->mask_bits
)) {
740 PRINT_WARN("ipato entry already exists!\n");
746 list_add_tail(&new->entry
, &card
->ipato
.entries
);
748 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
752 void qeth_l3_del_ipato_entry(struct qeth_card
*card
,
753 enum qeth_prot_versions proto
, u8
*addr
, int mask_bits
)
755 struct qeth_ipato_entry
*ipatoe
, *tmp
;
758 QETH_DBF_TEXT(TRACE
, 2, "delipato");
759 spin_lock_irqsave(&card
->ip_lock
, flags
);
760 list_for_each_entry_safe(ipatoe
, tmp
, &card
->ipato
.entries
, entry
) {
761 if (ipatoe
->proto
!= proto
)
763 if (!memcmp(ipatoe
->addr
, addr
,
764 (proto
== QETH_PROT_IPV4
)? 4:16) &&
765 (ipatoe
->mask_bits
== mask_bits
)) {
766 list_del(&ipatoe
->entry
);
770 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
774 * VIPA related functions
776 int qeth_l3_add_vipa(struct qeth_card
*card
, enum qeth_prot_versions proto
,
779 struct qeth_ipaddr
*ipaddr
;
783 ipaddr
= qeth_l3_get_addr_buffer(proto
);
785 if (proto
== QETH_PROT_IPV4
) {
786 QETH_DBF_TEXT(TRACE
, 2, "addvipa4");
787 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
788 ipaddr
->u
.a4
.mask
= 0;
789 } else if (proto
== QETH_PROT_IPV6
) {
790 QETH_DBF_TEXT(TRACE
, 2, "addvipa6");
791 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
792 ipaddr
->u
.a6
.pfxlen
= 0;
794 ipaddr
->type
= QETH_IP_TYPE_VIPA
;
795 ipaddr
->set_flags
= QETH_IPA_SETIP_VIPA_FLAG
;
796 ipaddr
->del_flags
= QETH_IPA_DELIP_VIPA_FLAG
;
799 spin_lock_irqsave(&card
->ip_lock
, flags
);
800 if (qeth_l3_address_exists_in_list(&card
->ip_list
, ipaddr
, 0) ||
801 qeth_l3_address_exists_in_list(card
->ip_tbd_list
, ipaddr
, 0))
803 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
805 PRINT_WARN("Cannot add VIPA. Address already exists!\n");
808 if (!qeth_l3_add_ip(card
, ipaddr
))
810 qeth_l3_set_ip_addr_list(card
);
814 void qeth_l3_del_vipa(struct qeth_card
*card
, enum qeth_prot_versions proto
,
817 struct qeth_ipaddr
*ipaddr
;
819 ipaddr
= qeth_l3_get_addr_buffer(proto
);
821 if (proto
== QETH_PROT_IPV4
) {
822 QETH_DBF_TEXT(TRACE
, 2, "delvipa4");
823 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
824 ipaddr
->u
.a4
.mask
= 0;
825 } else if (proto
== QETH_PROT_IPV6
) {
826 QETH_DBF_TEXT(TRACE
, 2, "delvipa6");
827 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
828 ipaddr
->u
.a6
.pfxlen
= 0;
830 ipaddr
->type
= QETH_IP_TYPE_VIPA
;
833 if (!qeth_l3_delete_ip(card
, ipaddr
))
835 qeth_l3_set_ip_addr_list(card
);
839 * proxy ARP related functions
841 int qeth_l3_add_rxip(struct qeth_card
*card
, enum qeth_prot_versions proto
,
844 struct qeth_ipaddr
*ipaddr
;
848 ipaddr
= qeth_l3_get_addr_buffer(proto
);
850 if (proto
== QETH_PROT_IPV4
) {
851 QETH_DBF_TEXT(TRACE
, 2, "addrxip4");
852 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
853 ipaddr
->u
.a4
.mask
= 0;
854 } else if (proto
== QETH_PROT_IPV6
) {
855 QETH_DBF_TEXT(TRACE
, 2, "addrxip6");
856 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
857 ipaddr
->u
.a6
.pfxlen
= 0;
859 ipaddr
->type
= QETH_IP_TYPE_RXIP
;
860 ipaddr
->set_flags
= QETH_IPA_SETIP_TAKEOVER_FLAG
;
861 ipaddr
->del_flags
= 0;
864 spin_lock_irqsave(&card
->ip_lock
, flags
);
865 if (qeth_l3_address_exists_in_list(&card
->ip_list
, ipaddr
, 0) ||
866 qeth_l3_address_exists_in_list(card
->ip_tbd_list
, ipaddr
, 0))
868 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
870 PRINT_WARN("Cannot add RXIP. Address already exists!\n");
873 if (!qeth_l3_add_ip(card
, ipaddr
))
875 qeth_l3_set_ip_addr_list(card
);
879 void qeth_l3_del_rxip(struct qeth_card
*card
, enum qeth_prot_versions proto
,
882 struct qeth_ipaddr
*ipaddr
;
884 ipaddr
= qeth_l3_get_addr_buffer(proto
);
886 if (proto
== QETH_PROT_IPV4
) {
887 QETH_DBF_TEXT(TRACE
, 2, "addrxip4");
888 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
889 ipaddr
->u
.a4
.mask
= 0;
890 } else if (proto
== QETH_PROT_IPV6
) {
891 QETH_DBF_TEXT(TRACE
, 2, "addrxip6");
892 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
893 ipaddr
->u
.a6
.pfxlen
= 0;
895 ipaddr
->type
= QETH_IP_TYPE_RXIP
;
898 if (!qeth_l3_delete_ip(card
, ipaddr
))
900 qeth_l3_set_ip_addr_list(card
);
903 static int qeth_l3_register_addr_entry(struct qeth_card
*card
,
904 struct qeth_ipaddr
*addr
)
910 if (addr
->proto
== QETH_PROT_IPV4
) {
911 QETH_DBF_TEXT(TRACE
, 2, "setaddr4");
912 QETH_DBF_HEX(TRACE
, 3, &addr
->u
.a4
.addr
, sizeof(int));
913 } else if (addr
->proto
== QETH_PROT_IPV6
) {
914 QETH_DBF_TEXT(TRACE
, 2, "setaddr6");
915 QETH_DBF_HEX(TRACE
, 3, &addr
->u
.a6
.addr
, 8);
916 QETH_DBF_HEX(TRACE
, 3, ((char *)&addr
->u
.a6
.addr
) + 8, 8);
918 QETH_DBF_TEXT(TRACE
, 2, "setaddr?");
919 QETH_DBF_HEX(TRACE
, 3, addr
, sizeof(struct qeth_ipaddr
));
922 if (addr
->is_multicast
)
923 rc
= qeth_l3_send_setdelmc(card
, addr
, IPA_CMD_SETIPM
);
925 rc
= qeth_l3_send_setdelip(card
, addr
, IPA_CMD_SETIP
,
928 QETH_DBF_TEXT(TRACE
, 2, "failed");
929 } while ((--cnt
> 0) && rc
);
931 QETH_DBF_TEXT(TRACE
, 2, "FAILED");
932 qeth_l3_ipaddr_to_string(addr
->proto
, (u8
*)&addr
->u
, buf
);
933 PRINT_WARN("Could not register IP address %s (rc=0x%x/%d)\n",
939 static int qeth_l3_deregister_addr_entry(struct qeth_card
*card
,
940 struct qeth_ipaddr
*addr
)
944 if (addr
->proto
== QETH_PROT_IPV4
) {
945 QETH_DBF_TEXT(TRACE
, 2, "deladdr4");
946 QETH_DBF_HEX(TRACE
, 3, &addr
->u
.a4
.addr
, sizeof(int));
947 } else if (addr
->proto
== QETH_PROT_IPV6
) {
948 QETH_DBF_TEXT(TRACE
, 2, "deladdr6");
949 QETH_DBF_HEX(TRACE
, 3, &addr
->u
.a6
.addr
, 8);
950 QETH_DBF_HEX(TRACE
, 3, ((char *)&addr
->u
.a6
.addr
) + 8, 8);
952 QETH_DBF_TEXT(TRACE
, 2, "deladdr?");
953 QETH_DBF_HEX(TRACE
, 3, addr
, sizeof(struct qeth_ipaddr
));
955 if (addr
->is_multicast
)
956 rc
= qeth_l3_send_setdelmc(card
, addr
, IPA_CMD_DELIPM
);
958 rc
= qeth_l3_send_setdelip(card
, addr
, IPA_CMD_DELIP
,
961 QETH_DBF_TEXT(TRACE
, 2, "failed");
962 /* TODO: re-activate this warning as soon as we have a
964 qeth_ipaddr_to_string(addr->proto, (u8 *)&addr->u, buf);
965 PRINT_WARN("Could not deregister IP address %s (rc=%x)\n",
973 static inline u8
qeth_l3_get_qeth_hdr_flags4(int cast_type
)
975 if (cast_type
== RTN_MULTICAST
)
976 return QETH_CAST_MULTICAST
;
977 if (cast_type
== RTN_BROADCAST
)
978 return QETH_CAST_BROADCAST
;
979 return QETH_CAST_UNICAST
;
982 static inline u8
qeth_l3_get_qeth_hdr_flags6(int cast_type
)
984 u8 ct
= QETH_HDR_PASSTHRU
| QETH_HDR_IPV6
;
985 if (cast_type
== RTN_MULTICAST
)
986 return ct
| QETH_CAST_MULTICAST
;
987 if (cast_type
== RTN_ANYCAST
)
988 return ct
| QETH_CAST_ANYCAST
;
989 if (cast_type
== RTN_BROADCAST
)
990 return ct
| QETH_CAST_BROADCAST
;
991 return ct
| QETH_CAST_UNICAST
;
994 static int qeth_l3_send_setadp_mode(struct qeth_card
*card
, __u32 command
,
998 struct qeth_cmd_buffer
*iob
;
999 struct qeth_ipa_cmd
*cmd
;
1001 QETH_DBF_TEXT(TRACE
, 4, "adpmode");
1003 iob
= qeth_get_adapter_cmd(card
, command
,
1004 sizeof(struct qeth_ipacmd_setadpparms
));
1005 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
1006 cmd
->data
.setadapterparms
.data
.mode
= mode
;
1007 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_default_setadapterparms_cb
,
1012 static int qeth_l3_setadapter_hstr(struct qeth_card
*card
)
1016 QETH_DBF_TEXT(TRACE
, 4, "adphstr");
1018 if (qeth_adp_supported(card
, IPA_SETADP_SET_BROADCAST_MODE
)) {
1019 rc
= qeth_l3_send_setadp_mode(card
,
1020 IPA_SETADP_SET_BROADCAST_MODE
,
1021 card
->options
.broadcast_mode
);
1023 PRINT_WARN("couldn't set broadcast mode on "
1025 CARD_BUS_ID(card
), rc
);
1026 rc
= qeth_l3_send_setadp_mode(card
,
1027 IPA_SETADP_ALTER_MAC_ADDRESS
,
1028 card
->options
.macaddr_mode
);
1030 PRINT_WARN("couldn't set macaddr mode on "
1031 "device %s: x%x\n", CARD_BUS_ID(card
), rc
);
1034 if (card
->options
.broadcast_mode
== QETH_TR_BROADCAST_LOCAL
)
1035 PRINT_WARN("set adapter parameters not available "
1036 "to set broadcast mode, using ALLRINGS "
1037 "on device %s:\n", CARD_BUS_ID(card
));
1038 if (card
->options
.macaddr_mode
== QETH_TR_MACADDR_CANONICAL
)
1039 PRINT_WARN("set adapter parameters not available "
1040 "to set macaddr mode, using NONCANONICAL "
1041 "on device %s:\n", CARD_BUS_ID(card
));
1045 static int qeth_l3_setadapter_parms(struct qeth_card
*card
)
1049 QETH_DBF_TEXT(SETUP
, 2, "setadprm");
1051 if (!qeth_is_supported(card
, IPA_SETADAPTERPARMS
)) {
1052 PRINT_WARN("set adapter parameters not supported "
1055 QETH_DBF_TEXT(SETUP
, 2, " notsupp");
1058 rc
= qeth_query_setadapterparms(card
);
1060 PRINT_WARN("couldn't set adapter parameters on device %s: "
1061 "x%x\n", CARD_BUS_ID(card
), rc
);
1064 if (qeth_adp_supported(card
, IPA_SETADP_ALTER_MAC_ADDRESS
)) {
1065 rc
= qeth_setadpparms_change_macaddr(card
);
1067 PRINT_WARN("couldn't get MAC address on "
1069 CARD_BUS_ID(card
), rc
);
1072 if ((card
->info
.link_type
== QETH_LINK_TYPE_HSTR
) ||
1073 (card
->info
.link_type
== QETH_LINK_TYPE_LANE_TR
))
1074 rc
= qeth_l3_setadapter_hstr(card
);
1079 static int qeth_l3_default_setassparms_cb(struct qeth_card
*card
,
1080 struct qeth_reply
*reply
, unsigned long data
)
1082 struct qeth_ipa_cmd
*cmd
;
1084 QETH_DBF_TEXT(TRACE
, 4, "defadpcb");
1086 cmd
= (struct qeth_ipa_cmd
*) data
;
1087 if (cmd
->hdr
.return_code
== 0) {
1088 cmd
->hdr
.return_code
= cmd
->data
.setassparms
.hdr
.return_code
;
1089 if (cmd
->hdr
.prot_version
== QETH_PROT_IPV4
)
1090 card
->options
.ipa4
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
1091 if (cmd
->hdr
.prot_version
== QETH_PROT_IPV6
)
1092 card
->options
.ipa6
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
1094 if (cmd
->data
.setassparms
.hdr
.assist_no
== IPA_INBOUND_CHECKSUM
&&
1095 cmd
->data
.setassparms
.hdr
.command_code
== IPA_CMD_ASS_START
) {
1096 card
->info
.csum_mask
= cmd
->data
.setassparms
.data
.flags_32bit
;
1097 QETH_DBF_TEXT_(TRACE
, 3, "csum:%d", card
->info
.csum_mask
);
1102 static struct qeth_cmd_buffer
*qeth_l3_get_setassparms_cmd(
1103 struct qeth_card
*card
, enum qeth_ipa_funcs ipa_func
, __u16 cmd_code
,
1104 __u16 len
, enum qeth_prot_versions prot
)
1106 struct qeth_cmd_buffer
*iob
;
1107 struct qeth_ipa_cmd
*cmd
;
1109 QETH_DBF_TEXT(TRACE
, 4, "getasscm");
1110 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_SETASSPARMS
, prot
);
1112 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
1113 cmd
->data
.setassparms
.hdr
.assist_no
= ipa_func
;
1114 cmd
->data
.setassparms
.hdr
.length
= 8 + len
;
1115 cmd
->data
.setassparms
.hdr
.command_code
= cmd_code
;
1116 cmd
->data
.setassparms
.hdr
.return_code
= 0;
1117 cmd
->data
.setassparms
.hdr
.seq_no
= 0;
1122 static int qeth_l3_send_setassparms(struct qeth_card
*card
,
1123 struct qeth_cmd_buffer
*iob
, __u16 len
, long data
,
1124 int (*reply_cb
)(struct qeth_card
*, struct qeth_reply
*,
1129 struct qeth_ipa_cmd
*cmd
;
1131 QETH_DBF_TEXT(TRACE
, 4, "sendassp");
1133 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
1134 if (len
<= sizeof(__u32
))
1135 cmd
->data
.setassparms
.data
.flags_32bit
= (__u32
) data
;
1136 else /* (len > sizeof(__u32)) */
1137 memcpy(&cmd
->data
.setassparms
.data
, (void *) data
, len
);
1139 rc
= qeth_send_ipa_cmd(card
, iob
, reply_cb
, reply_param
);
1143 #ifdef CONFIG_QETH_IPV6
1144 static int qeth_l3_send_simple_setassparms_ipv6(struct qeth_card
*card
,
1145 enum qeth_ipa_funcs ipa_func
, __u16 cmd_code
)
1148 struct qeth_cmd_buffer
*iob
;
1150 QETH_DBF_TEXT(TRACE
, 4, "simassp6");
1151 iob
= qeth_l3_get_setassparms_cmd(card
, ipa_func
, cmd_code
,
1153 rc
= qeth_l3_send_setassparms(card
, iob
, 0, 0,
1154 qeth_l3_default_setassparms_cb
, NULL
);
1159 static int qeth_l3_send_simple_setassparms(struct qeth_card
*card
,
1160 enum qeth_ipa_funcs ipa_func
, __u16 cmd_code
, long data
)
1164 struct qeth_cmd_buffer
*iob
;
1166 QETH_DBF_TEXT(TRACE
, 4, "simassp4");
1168 length
= sizeof(__u32
);
1169 iob
= qeth_l3_get_setassparms_cmd(card
, ipa_func
, cmd_code
,
1170 length
, QETH_PROT_IPV4
);
1171 rc
= qeth_l3_send_setassparms(card
, iob
, length
, data
,
1172 qeth_l3_default_setassparms_cb
, NULL
);
1176 static int qeth_l3_start_ipa_arp_processing(struct qeth_card
*card
)
1180 QETH_DBF_TEXT(TRACE
, 3, "ipaarp");
1182 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
1183 PRINT_WARN("ARP processing not supported "
1184 "on %s!\n", QETH_CARD_IFNAME(card
));
1187 rc
= qeth_l3_send_simple_setassparms(card
, IPA_ARP_PROCESSING
,
1188 IPA_CMD_ASS_START
, 0);
1190 PRINT_WARN("Could not start ARP processing "
1191 "assist on %s: 0x%x\n",
1192 QETH_CARD_IFNAME(card
), rc
);
1197 static int qeth_l3_start_ipa_ip_fragmentation(struct qeth_card
*card
)
1201 QETH_DBF_TEXT(TRACE
, 3, "ipaipfrg");
1203 if (!qeth_is_supported(card
, IPA_IP_FRAGMENTATION
)) {
1204 PRINT_INFO("Hardware IP fragmentation not supported on %s\n",
1205 QETH_CARD_IFNAME(card
));
1209 rc
= qeth_l3_send_simple_setassparms(card
, IPA_IP_FRAGMENTATION
,
1210 IPA_CMD_ASS_START
, 0);
1212 PRINT_WARN("Could not start Hardware IP fragmentation "
1213 "assist on %s: 0x%x\n",
1214 QETH_CARD_IFNAME(card
), rc
);
1216 PRINT_INFO("Hardware IP fragmentation enabled \n");
1220 static int qeth_l3_start_ipa_source_mac(struct qeth_card
*card
)
1224 QETH_DBF_TEXT(TRACE
, 3, "stsrcmac");
1226 if (!card
->options
.fake_ll
)
1229 if (!qeth_is_supported(card
, IPA_SOURCE_MAC
)) {
1230 PRINT_INFO("Inbound source address not "
1231 "supported on %s\n", QETH_CARD_IFNAME(card
));
1235 rc
= qeth_l3_send_simple_setassparms(card
, IPA_SOURCE_MAC
,
1236 IPA_CMD_ASS_START
, 0);
1238 PRINT_WARN("Could not start inbound source "
1239 "assist on %s: 0x%x\n",
1240 QETH_CARD_IFNAME(card
), rc
);
1244 static int qeth_l3_start_ipa_vlan(struct qeth_card
*card
)
1248 QETH_DBF_TEXT(TRACE
, 3, "strtvlan");
1250 if (!qeth_is_supported(card
, IPA_FULL_VLAN
)) {
1251 PRINT_WARN("VLAN not supported on %s\n",
1252 QETH_CARD_IFNAME(card
));
1256 rc
= qeth_l3_send_simple_setassparms(card
, IPA_VLAN_PRIO
,
1257 IPA_CMD_ASS_START
, 0);
1259 PRINT_WARN("Could not start vlan "
1260 "assist on %s: 0x%x\n",
1261 QETH_CARD_IFNAME(card
), rc
);
1263 PRINT_INFO("VLAN enabled \n");
1268 static int qeth_l3_start_ipa_multicast(struct qeth_card
*card
)
1272 QETH_DBF_TEXT(TRACE
, 3, "stmcast");
1274 if (!qeth_is_supported(card
, IPA_MULTICASTING
)) {
1275 PRINT_WARN("Multicast not supported on %s\n",
1276 QETH_CARD_IFNAME(card
));
1280 rc
= qeth_l3_send_simple_setassparms(card
, IPA_MULTICASTING
,
1281 IPA_CMD_ASS_START
, 0);
1283 PRINT_WARN("Could not start multicast "
1284 "assist on %s: rc=%i\n",
1285 QETH_CARD_IFNAME(card
), rc
);
1287 PRINT_INFO("Multicast enabled\n");
1288 card
->dev
->flags
|= IFF_MULTICAST
;
1293 static int qeth_l3_query_ipassists_cb(struct qeth_card
*card
,
1294 struct qeth_reply
*reply
, unsigned long data
)
1296 struct qeth_ipa_cmd
*cmd
;
1298 QETH_DBF_TEXT(SETUP
, 2, "qipasscb");
1300 cmd
= (struct qeth_ipa_cmd
*) data
;
1301 if (cmd
->hdr
.prot_version
== QETH_PROT_IPV4
) {
1302 card
->options
.ipa4
.supported_funcs
= cmd
->hdr
.ipa_supported
;
1303 card
->options
.ipa4
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
1305 card
->options
.ipa6
.supported_funcs
= cmd
->hdr
.ipa_supported
;
1306 card
->options
.ipa6
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
1308 QETH_DBF_TEXT(SETUP
, 2, "suppenbl");
1309 QETH_DBF_TEXT_(SETUP
, 2, "%x", cmd
->hdr
.ipa_supported
);
1310 QETH_DBF_TEXT_(SETUP
, 2, "%x", cmd
->hdr
.ipa_enabled
);
1314 static int qeth_l3_query_ipassists(struct qeth_card
*card
,
1315 enum qeth_prot_versions prot
)
1318 struct qeth_cmd_buffer
*iob
;
1320 QETH_DBF_TEXT_(SETUP
, 2, "qipassi%i", prot
);
1321 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_QIPASSIST
, prot
);
1322 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_l3_query_ipassists_cb
, NULL
);
1326 #ifdef CONFIG_QETH_IPV6
1327 static int qeth_l3_softsetup_ipv6(struct qeth_card
*card
)
1331 QETH_DBF_TEXT(TRACE
, 3, "softipv6");
1333 if (card
->info
.type
== QETH_CARD_TYPE_IQD
)
1336 rc
= qeth_l3_query_ipassists(card
, QETH_PROT_IPV6
);
1338 PRINT_ERR("IPv6 query ipassist failed on %s\n",
1339 QETH_CARD_IFNAME(card
));
1342 rc
= qeth_l3_send_simple_setassparms(card
, IPA_IPV6
,
1343 IPA_CMD_ASS_START
, 3);
1345 PRINT_WARN("IPv6 start assist (version 4) failed "
1347 QETH_CARD_IFNAME(card
), rc
);
1350 rc
= qeth_l3_send_simple_setassparms_ipv6(card
, IPA_IPV6
,
1353 PRINT_WARN("IPV6 start assist (version 6) failed "
1355 QETH_CARD_IFNAME(card
), rc
);
1358 rc
= qeth_l3_send_simple_setassparms_ipv6(card
, IPA_PASSTHRU
,
1361 PRINT_WARN("Could not enable passthrough "
1363 QETH_CARD_IFNAME(card
), rc
);
1367 PRINT_INFO("IPV6 enabled \n");
1372 static int qeth_l3_start_ipa_ipv6(struct qeth_card
*card
)
1376 QETH_DBF_TEXT(TRACE
, 3, "strtipv6");
1378 if (!qeth_is_supported(card
, IPA_IPV6
)) {
1379 PRINT_WARN("IPv6 not supported on %s\n",
1380 QETH_CARD_IFNAME(card
));
1383 #ifdef CONFIG_QETH_IPV6
1384 rc
= qeth_l3_softsetup_ipv6(card
);
1389 static int qeth_l3_start_ipa_broadcast(struct qeth_card
*card
)
1393 QETH_DBF_TEXT(TRACE
, 3, "stbrdcst");
1394 card
->info
.broadcast_capable
= 0;
1395 if (!qeth_is_supported(card
, IPA_FILTERING
)) {
1396 PRINT_WARN("Broadcast not supported on %s\n",
1397 QETH_CARD_IFNAME(card
));
1401 rc
= qeth_l3_send_simple_setassparms(card
, IPA_FILTERING
,
1402 IPA_CMD_ASS_START
, 0);
1404 PRINT_WARN("Could not enable broadcasting filtering "
1406 QETH_CARD_IFNAME(card
), rc
);
1410 rc
= qeth_l3_send_simple_setassparms(card
, IPA_FILTERING
,
1411 IPA_CMD_ASS_CONFIGURE
, 1);
1413 PRINT_WARN("Could not set up broadcast filtering on %s: 0x%x\n",
1414 QETH_CARD_IFNAME(card
), rc
);
1417 card
->info
.broadcast_capable
= QETH_BROADCAST_WITH_ECHO
;
1418 PRINT_INFO("Broadcast enabled \n");
1419 rc
= qeth_l3_send_simple_setassparms(card
, IPA_FILTERING
,
1420 IPA_CMD_ASS_ENABLE
, 1);
1422 PRINT_WARN("Could not set up broadcast echo filtering on "
1423 "%s: 0x%x\n", QETH_CARD_IFNAME(card
), rc
);
1426 card
->info
.broadcast_capable
= QETH_BROADCAST_WITHOUT_ECHO
;
1428 if (card
->info
.broadcast_capable
)
1429 card
->dev
->flags
|= IFF_BROADCAST
;
1431 card
->dev
->flags
&= ~IFF_BROADCAST
;
1435 static int qeth_l3_send_checksum_command(struct qeth_card
*card
)
1439 rc
= qeth_l3_send_simple_setassparms(card
, IPA_INBOUND_CHECKSUM
,
1440 IPA_CMD_ASS_START
, 0);
1442 PRINT_WARN("Starting Inbound HW Checksumming failed on %s: "
1443 "0x%x,\ncontinuing using Inbound SW Checksumming\n",
1444 QETH_CARD_IFNAME(card
), rc
);
1447 rc
= qeth_l3_send_simple_setassparms(card
, IPA_INBOUND_CHECKSUM
,
1449 card
->info
.csum_mask
);
1451 PRINT_WARN("Enabling Inbound HW Checksumming failed on %s: "
1452 "0x%x,\ncontinuing using Inbound SW Checksumming\n",
1453 QETH_CARD_IFNAME(card
), rc
);
1459 static int qeth_l3_start_ipa_checksum(struct qeth_card
*card
)
1463 QETH_DBF_TEXT(TRACE
, 3, "strtcsum");
1465 if (card
->options
.checksum_type
== NO_CHECKSUMMING
) {
1466 PRINT_WARN("Using no checksumming on %s.\n",
1467 QETH_CARD_IFNAME(card
));
1470 if (card
->options
.checksum_type
== SW_CHECKSUMMING
) {
1471 PRINT_WARN("Using SW checksumming on %s.\n",
1472 QETH_CARD_IFNAME(card
));
1475 if (!qeth_is_supported(card
, IPA_INBOUND_CHECKSUM
)) {
1476 PRINT_WARN("Inbound HW Checksumming not "
1477 "supported on %s,\ncontinuing "
1478 "using Inbound SW Checksumming\n",
1479 QETH_CARD_IFNAME(card
));
1480 card
->options
.checksum_type
= SW_CHECKSUMMING
;
1483 rc
= qeth_l3_send_checksum_command(card
);
1485 PRINT_INFO("HW Checksumming (inbound) enabled \n");
1490 static int qeth_l3_start_ipa_tso(struct qeth_card
*card
)
1494 QETH_DBF_TEXT(TRACE
, 3, "sttso");
1496 if (!qeth_is_supported(card
, IPA_OUTBOUND_TSO
)) {
1497 PRINT_WARN("Outbound TSO not supported on %s\n",
1498 QETH_CARD_IFNAME(card
));
1501 rc
= qeth_l3_send_simple_setassparms(card
, IPA_OUTBOUND_TSO
,
1502 IPA_CMD_ASS_START
, 0);
1504 PRINT_WARN("Could not start outbound TSO "
1505 "assist on %s: rc=%i\n",
1506 QETH_CARD_IFNAME(card
), rc
);
1508 PRINT_INFO("Outbound TSO enabled\n");
1510 if (rc
&& (card
->options
.large_send
== QETH_LARGE_SEND_TSO
)) {
1511 card
->options
.large_send
= QETH_LARGE_SEND_NO
;
1512 card
->dev
->features
&= ~(NETIF_F_TSO
| NETIF_F_SG
);
1517 static int qeth_l3_start_ipassists(struct qeth_card
*card
)
1519 QETH_DBF_TEXT(TRACE
, 3, "strtipas");
1520 qeth_l3_start_ipa_arp_processing(card
); /* go on*/
1521 qeth_l3_start_ipa_ip_fragmentation(card
); /* go on*/
1522 qeth_l3_start_ipa_source_mac(card
); /* go on*/
1523 qeth_l3_start_ipa_vlan(card
); /* go on*/
1524 qeth_l3_start_ipa_multicast(card
); /* go on*/
1525 qeth_l3_start_ipa_ipv6(card
); /* go on*/
1526 qeth_l3_start_ipa_broadcast(card
); /* go on*/
1527 qeth_l3_start_ipa_checksum(card
); /* go on*/
1528 qeth_l3_start_ipa_tso(card
); /* go on*/
1532 static int qeth_l3_put_unique_id(struct qeth_card
*card
)
1536 struct qeth_cmd_buffer
*iob
;
1537 struct qeth_ipa_cmd
*cmd
;
1539 QETH_DBF_TEXT(TRACE
, 2, "puniqeid");
1541 if ((card
->info
.unique_id
& UNIQUE_ID_NOT_BY_CARD
) ==
1542 UNIQUE_ID_NOT_BY_CARD
)
1544 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_DESTROY_ADDR
,
1546 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
1547 *((__u16
*) &cmd
->data
.create_destroy_addr
.unique_id
[6]) =
1548 card
->info
.unique_id
;
1549 memcpy(&cmd
->data
.create_destroy_addr
.unique_id
[0],
1550 card
->dev
->dev_addr
, OSA_ADDR_LEN
);
1551 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
1555 static int qeth_l3_iqd_read_initial_mac_cb(struct qeth_card
*card
,
1556 struct qeth_reply
*reply
, unsigned long data
)
1558 struct qeth_ipa_cmd
*cmd
;
1560 cmd
= (struct qeth_ipa_cmd
*) data
;
1561 if (cmd
->hdr
.return_code
== 0)
1562 memcpy(card
->dev
->dev_addr
,
1563 cmd
->data
.create_destroy_addr
.unique_id
, ETH_ALEN
);
1565 random_ether_addr(card
->dev
->dev_addr
);
1570 static int qeth_l3_iqd_read_initial_mac(struct qeth_card
*card
)
1573 struct qeth_cmd_buffer
*iob
;
1574 struct qeth_ipa_cmd
*cmd
;
1576 QETH_DBF_TEXT(SETUP
, 2, "hsrmac");
1578 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_CREATE_ADDR
,
1580 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
1581 *((__u16
*) &cmd
->data
.create_destroy_addr
.unique_id
[6]) =
1582 card
->info
.unique_id
;
1584 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_l3_iqd_read_initial_mac_cb
,
1589 static int qeth_l3_get_unique_id_cb(struct qeth_card
*card
,
1590 struct qeth_reply
*reply
, unsigned long data
)
1592 struct qeth_ipa_cmd
*cmd
;
1594 cmd
= (struct qeth_ipa_cmd
*) data
;
1595 if (cmd
->hdr
.return_code
== 0)
1596 card
->info
.unique_id
= *((__u16
*)
1597 &cmd
->data
.create_destroy_addr
.unique_id
[6]);
1599 card
->info
.unique_id
= UNIQUE_ID_IF_CREATE_ADDR_FAILED
|
1600 UNIQUE_ID_NOT_BY_CARD
;
1601 PRINT_WARN("couldn't get a unique id from the card on device "
1602 "%s (result=x%x), using default id. ipv6 "
1603 "autoconfig on other lpars may lead to duplicate "
1604 "ip addresses. please use manually "
1605 "configured ones.\n",
1606 CARD_BUS_ID(card
), cmd
->hdr
.return_code
);
1611 static int qeth_l3_get_unique_id(struct qeth_card
*card
)
1614 struct qeth_cmd_buffer
*iob
;
1615 struct qeth_ipa_cmd
*cmd
;
1617 QETH_DBF_TEXT(SETUP
, 2, "guniqeid");
1619 if (!qeth_is_supported(card
, IPA_IPV6
)) {
1620 card
->info
.unique_id
= UNIQUE_ID_IF_CREATE_ADDR_FAILED
|
1621 UNIQUE_ID_NOT_BY_CARD
;
1625 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_CREATE_ADDR
,
1627 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
1628 *((__u16
*) &cmd
->data
.create_destroy_addr
.unique_id
[6]) =
1629 card
->info
.unique_id
;
1631 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_l3_get_unique_id_cb
, NULL
);
1635 static void qeth_l3_get_mac_for_ipm(__u32 ipm
, char *mac
,
1636 struct net_device
*dev
)
1638 if (dev
->type
== ARPHRD_IEEE802_TR
)
1639 ip_tr_mc_map(ipm
, mac
);
1641 ip_eth_mc_map(ipm
, mac
);
1644 static void qeth_l3_add_mc(struct qeth_card
*card
, struct in_device
*in4_dev
)
1646 struct qeth_ipaddr
*ipm
;
1647 struct ip_mc_list
*im4
;
1648 char buf
[MAX_ADDR_LEN
];
1650 QETH_DBF_TEXT(TRACE
, 4, "addmc");
1651 for (im4
= in4_dev
->mc_list
; im4
; im4
= im4
->next
) {
1652 qeth_l3_get_mac_for_ipm(im4
->multiaddr
, buf
, in4_dev
->dev
);
1653 ipm
= qeth_l3_get_addr_buffer(QETH_PROT_IPV4
);
1656 ipm
->u
.a4
.addr
= im4
->multiaddr
;
1657 memcpy(ipm
->mac
, buf
, OSA_ADDR_LEN
);
1658 ipm
->is_multicast
= 1;
1659 if (!qeth_l3_add_ip(card
, ipm
))
1664 static void qeth_l3_add_vlan_mc(struct qeth_card
*card
)
1666 struct in_device
*in_dev
;
1667 struct vlan_group
*vg
;
1670 QETH_DBF_TEXT(TRACE
, 4, "addmcvl");
1671 if (!qeth_is_supported(card
, IPA_FULL_VLAN
) || (card
->vlangrp
== NULL
))
1675 for (i
= 0; i
< VLAN_GROUP_ARRAY_LEN
; i
++) {
1676 struct net_device
*netdev
= vlan_group_get_device(vg
, i
);
1677 if (netdev
== NULL
||
1678 !(netdev
->flags
& IFF_UP
))
1680 in_dev
= in_dev_get(netdev
);
1683 read_lock(&in_dev
->mc_list_lock
);
1684 qeth_l3_add_mc(card
, in_dev
);
1685 read_unlock(&in_dev
->mc_list_lock
);
1690 static void qeth_l3_add_multicast_ipv4(struct qeth_card
*card
)
1692 struct in_device
*in4_dev
;
1694 QETH_DBF_TEXT(TRACE
, 4, "chkmcv4");
1695 in4_dev
= in_dev_get(card
->dev
);
1696 if (in4_dev
== NULL
)
1698 read_lock(&in4_dev
->mc_list_lock
);
1699 qeth_l3_add_mc(card
, in4_dev
);
1700 qeth_l3_add_vlan_mc(card
);
1701 read_unlock(&in4_dev
->mc_list_lock
);
1702 in_dev_put(in4_dev
);
1705 #ifdef CONFIG_QETH_IPV6
1706 static void qeth_l3_add_mc6(struct qeth_card
*card
, struct inet6_dev
*in6_dev
)
1708 struct qeth_ipaddr
*ipm
;
1709 struct ifmcaddr6
*im6
;
1710 char buf
[MAX_ADDR_LEN
];
1712 QETH_DBF_TEXT(TRACE
, 4, "addmc6");
1713 for (im6
= in6_dev
->mc_list
; im6
!= NULL
; im6
= im6
->next
) {
1714 ndisc_mc_map(&im6
->mca_addr
, buf
, in6_dev
->dev
, 0);
1715 ipm
= qeth_l3_get_addr_buffer(QETH_PROT_IPV6
);
1718 ipm
->is_multicast
= 1;
1719 memcpy(ipm
->mac
, buf
, OSA_ADDR_LEN
);
1720 memcpy(&ipm
->u
.a6
.addr
, &im6
->mca_addr
.s6_addr
,
1721 sizeof(struct in6_addr
));
1722 if (!qeth_l3_add_ip(card
, ipm
))
1727 static void qeth_l3_add_vlan_mc6(struct qeth_card
*card
)
1729 struct inet6_dev
*in_dev
;
1730 struct vlan_group
*vg
;
1733 QETH_DBF_TEXT(TRACE
, 4, "admc6vl");
1734 if (!qeth_is_supported(card
, IPA_FULL_VLAN
) || (card
->vlangrp
== NULL
))
1738 for (i
= 0; i
< VLAN_GROUP_ARRAY_LEN
; i
++) {
1739 struct net_device
*netdev
= vlan_group_get_device(vg
, i
);
1740 if (netdev
== NULL
||
1741 !(netdev
->flags
& IFF_UP
))
1743 in_dev
= in6_dev_get(netdev
);
1746 read_lock_bh(&in_dev
->lock
);
1747 qeth_l3_add_mc6(card
, in_dev
);
1748 read_unlock_bh(&in_dev
->lock
);
1749 in6_dev_put(in_dev
);
1753 static void qeth_l3_add_multicast_ipv6(struct qeth_card
*card
)
1755 struct inet6_dev
*in6_dev
;
1757 QETH_DBF_TEXT(TRACE
, 4, "chkmcv6");
1758 if (!qeth_is_supported(card
, IPA_IPV6
))
1760 in6_dev
= in6_dev_get(card
->dev
);
1761 if (in6_dev
== NULL
)
1763 read_lock_bh(&in6_dev
->lock
);
1764 qeth_l3_add_mc6(card
, in6_dev
);
1765 qeth_l3_add_vlan_mc6(card
);
1766 read_unlock_bh(&in6_dev
->lock
);
1767 in6_dev_put(in6_dev
);
1769 #endif /* CONFIG_QETH_IPV6 */
1771 static void qeth_l3_free_vlan_addresses4(struct qeth_card
*card
,
1774 struct in_device
*in_dev
;
1775 struct in_ifaddr
*ifa
;
1776 struct qeth_ipaddr
*addr
;
1778 QETH_DBF_TEXT(TRACE
, 4, "frvaddr4");
1780 in_dev
= in_dev_get(vlan_group_get_device(card
->vlangrp
, vid
));
1783 for (ifa
= in_dev
->ifa_list
; ifa
; ifa
= ifa
->ifa_next
) {
1784 addr
= qeth_l3_get_addr_buffer(QETH_PROT_IPV4
);
1786 addr
->u
.a4
.addr
= ifa
->ifa_address
;
1787 addr
->u
.a4
.mask
= ifa
->ifa_mask
;
1788 addr
->type
= QETH_IP_TYPE_NORMAL
;
1789 if (!qeth_l3_delete_ip(card
, addr
))
1796 static void qeth_l3_free_vlan_addresses6(struct qeth_card
*card
,
1799 #ifdef CONFIG_QETH_IPV6
1800 struct inet6_dev
*in6_dev
;
1801 struct inet6_ifaddr
*ifa
;
1802 struct qeth_ipaddr
*addr
;
1804 QETH_DBF_TEXT(TRACE
, 4, "frvaddr6");
1806 in6_dev
= in6_dev_get(vlan_group_get_device(card
->vlangrp
, vid
));
1809 for (ifa
= in6_dev
->addr_list
; ifa
; ifa
= ifa
->lst_next
) {
1810 addr
= qeth_l3_get_addr_buffer(QETH_PROT_IPV6
);
1812 memcpy(&addr
->u
.a6
.addr
, &ifa
->addr
,
1813 sizeof(struct in6_addr
));
1814 addr
->u
.a6
.pfxlen
= ifa
->prefix_len
;
1815 addr
->type
= QETH_IP_TYPE_NORMAL
;
1816 if (!qeth_l3_delete_ip(card
, addr
))
1820 in6_dev_put(in6_dev
);
1821 #endif /* CONFIG_QETH_IPV6 */
1824 static void qeth_l3_free_vlan_addresses(struct qeth_card
*card
,
1829 qeth_l3_free_vlan_addresses4(card
, vid
);
1830 qeth_l3_free_vlan_addresses6(card
, vid
);
1833 static void qeth_l3_vlan_rx_register(struct net_device
*dev
,
1834 struct vlan_group
*grp
)
1836 struct qeth_card
*card
= netdev_priv(dev
);
1837 unsigned long flags
;
1839 QETH_DBF_TEXT(TRACE
, 4, "vlanreg");
1840 spin_lock_irqsave(&card
->vlanlock
, flags
);
1841 card
->vlangrp
= grp
;
1842 spin_unlock_irqrestore(&card
->vlanlock
, flags
);
1845 static void qeth_l3_vlan_rx_add_vid(struct net_device
*dev
, unsigned short vid
)
1847 struct net_device
*vlandev
;
1848 struct qeth_card
*card
= (struct qeth_card
*) dev
->priv
;
1849 struct in_device
*in_dev
;
1851 if (card
->info
.type
== QETH_CARD_TYPE_IQD
)
1854 vlandev
= vlan_group_get_device(card
->vlangrp
, vid
);
1855 vlandev
->neigh_setup
= qeth_l3_neigh_setup
;
1857 in_dev
= in_dev_get(vlandev
);
1858 #ifdef CONFIG_SYSCTL
1859 neigh_sysctl_unregister(in_dev
->arp_parms
);
1861 neigh_parms_release(&arp_tbl
, in_dev
->arp_parms
);
1863 in_dev
->arp_parms
= neigh_parms_alloc(vlandev
, &arp_tbl
);
1864 #ifdef CONFIG_SYSCTL
1865 neigh_sysctl_register(vlandev
, in_dev
->arp_parms
, NET_IPV4
,
1866 NET_IPV4_NEIGH
, "ipv4", NULL
, NULL
);
1872 static void qeth_l3_vlan_rx_kill_vid(struct net_device
*dev
, unsigned short vid
)
1874 struct qeth_card
*card
= netdev_priv(dev
);
1875 unsigned long flags
;
1877 QETH_DBF_TEXT_(TRACE
, 4, "kid:%d", vid
);
1878 spin_lock_irqsave(&card
->vlanlock
, flags
);
1879 /* unregister IP addresses of vlan device */
1880 qeth_l3_free_vlan_addresses(card
, vid
);
1881 vlan_group_set_device(card
->vlangrp
, vid
, NULL
);
1882 spin_unlock_irqrestore(&card
->vlanlock
, flags
);
1883 qeth_l3_set_multicast_list(card
->dev
);
1886 static inline __u16
qeth_l3_rebuild_skb(struct qeth_card
*card
,
1887 struct sk_buff
*skb
, struct qeth_hdr
*hdr
)
1889 unsigned short vlan_id
= 0;
1891 struct iphdr
*ip_hdr
;
1892 unsigned char tg_addr
[MAX_ADDR_LEN
];
1894 if (!(hdr
->hdr
.l3
.flags
& QETH_HDR_PASSTHRU
)) {
1895 prot
= htons((hdr
->hdr
.l3
.flags
& QETH_HDR_IPV6
)? ETH_P_IPV6
:
1897 switch (hdr
->hdr
.l3
.flags
& QETH_HDR_CAST_MASK
) {
1898 case QETH_CAST_MULTICAST
:
1900 #ifdef CONFIG_QETH_IPV6
1901 case __constant_htons(ETH_P_IPV6
):
1902 ndisc_mc_map((struct in6_addr
*)
1904 tg_addr
, card
->dev
, 0);
1907 case __constant_htons(ETH_P_IP
):
1908 ip_hdr
= (struct iphdr
*)skb
->data
;
1909 (card
->dev
->type
== ARPHRD_IEEE802_TR
) ?
1910 ip_tr_mc_map(ip_hdr
->daddr
, tg_addr
):
1911 ip_eth_mc_map(ip_hdr
->daddr
, tg_addr
);
1914 memcpy(tg_addr
, card
->dev
->broadcast
,
1915 card
->dev
->addr_len
);
1917 card
->stats
.multicast
++;
1918 skb
->pkt_type
= PACKET_MULTICAST
;
1920 case QETH_CAST_BROADCAST
:
1921 memcpy(tg_addr
, card
->dev
->broadcast
,
1922 card
->dev
->addr_len
);
1923 card
->stats
.multicast
++;
1924 skb
->pkt_type
= PACKET_BROADCAST
;
1926 case QETH_CAST_UNICAST
:
1927 case QETH_CAST_ANYCAST
:
1928 case QETH_CAST_NOCAST
:
1930 skb
->pkt_type
= PACKET_HOST
;
1931 memcpy(tg_addr
, card
->dev
->dev_addr
,
1932 card
->dev
->addr_len
);
1934 card
->dev
->header_ops
->create(skb
, card
->dev
, prot
, tg_addr
,
1935 "FAKELL", card
->dev
->addr_len
);
1939 if (card
->dev
->type
== ARPHRD_IEEE802_TR
)
1940 skb
->protocol
= tr_type_trans(skb
, card
->dev
);
1943 skb
->protocol
= eth_type_trans(skb
, card
->dev
);
1945 if (hdr
->hdr
.l3
.ext_flags
&
1946 (QETH_HDR_EXT_VLAN_FRAME
| QETH_HDR_EXT_INCLUDE_VLAN_TAG
)) {
1947 vlan_id
= (hdr
->hdr
.l3
.ext_flags
& QETH_HDR_EXT_VLAN_FRAME
)?
1948 hdr
->hdr
.l3
.vlan_id
: *((u16
*)&hdr
->hdr
.l3
.dest_addr
[12]);
1951 skb
->ip_summed
= card
->options
.checksum_type
;
1952 if (card
->options
.checksum_type
== HW_CHECKSUMMING
) {
1953 if ((hdr
->hdr
.l3
.ext_flags
&
1954 (QETH_HDR_EXT_CSUM_HDR_REQ
|
1955 QETH_HDR_EXT_CSUM_TRANSP_REQ
)) ==
1956 (QETH_HDR_EXT_CSUM_HDR_REQ
|
1957 QETH_HDR_EXT_CSUM_TRANSP_REQ
))
1958 skb
->ip_summed
= CHECKSUM_UNNECESSARY
;
1960 skb
->ip_summed
= SW_CHECKSUMMING
;
1966 static void qeth_l3_process_inbound_buffer(struct qeth_card
*card
,
1967 struct qeth_qdio_buffer
*buf
, int index
)
1969 struct qdio_buffer_element
*element
;
1970 struct sk_buff
*skb
;
1971 struct qeth_hdr
*hdr
;
1976 /* get first element of current buffer */
1977 element
= (struct qdio_buffer_element
*)&buf
->buffer
->element
[0];
1979 if (card
->options
.performance_stats
)
1980 card
->perf_stats
.bufs_rec
++;
1981 while ((skb
= qeth_core_get_next_skb(card
, buf
->buffer
, &element
,
1983 skb
->dev
= card
->dev
;
1984 /* is device UP ? */
1985 if (!(card
->dev
->flags
& IFF_UP
)) {
1986 dev_kfree_skb_any(skb
);
1990 switch (hdr
->hdr
.l3
.id
) {
1991 case QETH_HEADER_TYPE_LAYER3
:
1992 vlan_tag
= qeth_l3_rebuild_skb(card
, skb
, hdr
);
1996 vlan_hwaccel_rx(skb
, card
->vlangrp
,
1999 dev_kfree_skb_any(skb
);
2006 dev_kfree_skb_any(skb
);
2007 QETH_DBF_TEXT(TRACE
, 3, "inbunkno");
2008 QETH_DBF_HEX(CTRL
, 3, hdr
, QETH_DBF_CTRL_LEN
);
2012 card
->dev
->last_rx
= jiffies
;
2013 card
->stats
.rx_packets
++;
2014 card
->stats
.rx_bytes
+= len
;
2018 static int qeth_l3_verify_vlan_dev(struct net_device
*dev
,
2019 struct qeth_card
*card
)
2022 struct vlan_group
*vg
;
2029 for (i
= 0; i
< VLAN_GROUP_ARRAY_LEN
; i
++) {
2030 if (vlan_group_get_device(vg
, i
) == dev
) {
2031 rc
= QETH_VLAN_CARD
;
2036 if (rc
&& !(netdev_priv(vlan_dev_info(dev
)->real_dev
) == (void *)card
))
2042 static int qeth_l3_verify_dev(struct net_device
*dev
)
2044 struct qeth_card
*card
;
2045 unsigned long flags
;
2048 read_lock_irqsave(&qeth_core_card_list
.rwlock
, flags
);
2049 list_for_each_entry(card
, &qeth_core_card_list
.list
, list
) {
2050 if (card
->dev
== dev
) {
2051 rc
= QETH_REAL_CARD
;
2054 rc
= qeth_l3_verify_vlan_dev(dev
, card
);
2058 read_unlock_irqrestore(&qeth_core_card_list
.rwlock
, flags
);
2063 static struct qeth_card
*qeth_l3_get_card_from_dev(struct net_device
*dev
)
2065 struct qeth_card
*card
= NULL
;
2068 rc
= qeth_l3_verify_dev(dev
);
2069 if (rc
== QETH_REAL_CARD
)
2070 card
= netdev_priv(dev
);
2071 else if (rc
== QETH_VLAN_CARD
)
2072 card
= netdev_priv(vlan_dev_info(dev
)->real_dev
);
2073 if (card
->options
.layer2
)
2075 QETH_DBF_TEXT_(TRACE
, 4, "%d", rc
);
2079 static int qeth_l3_stop_card(struct qeth_card
*card
, int recovery_mode
)
2083 QETH_DBF_TEXT(SETUP
, 2, "stopcard");
2084 QETH_DBF_HEX(SETUP
, 2, &card
, sizeof(void *));
2086 qeth_set_allowed_threads(card
, 0, 1);
2087 if (qeth_wait_for_threads(card
, ~QETH_RECOVER_THREAD
))
2088 return -ERESTARTSYS
;
2089 if (card
->read
.state
== CH_STATE_UP
&&
2090 card
->write
.state
== CH_STATE_UP
&&
2091 (card
->state
== CARD_STATE_UP
)) {
2093 qeth_l3_stop(card
->dev
);
2096 dev_close(card
->dev
);
2099 if (!card
->use_hard_stop
) {
2100 rc
= qeth_send_stoplan(card
);
2102 QETH_DBF_TEXT_(SETUP
, 2, "1err%d", rc
);
2104 card
->state
= CARD_STATE_SOFTSETUP
;
2106 if (card
->state
== CARD_STATE_SOFTSETUP
) {
2107 qeth_l3_clear_ip_list(card
, !card
->use_hard_stop
, 1);
2108 qeth_clear_ipacmd_list(card
);
2109 card
->state
= CARD_STATE_HARDSETUP
;
2111 if (card
->state
== CARD_STATE_HARDSETUP
) {
2112 if (!card
->use_hard_stop
&&
2113 (card
->info
.type
!= QETH_CARD_TYPE_IQD
)) {
2114 rc
= qeth_l3_put_unique_id(card
);
2116 QETH_DBF_TEXT_(SETUP
, 2, "2err%d", rc
);
2118 qeth_qdio_clear_card(card
, 0);
2119 qeth_clear_qdio_buffers(card
);
2120 qeth_clear_working_pool_list(card
);
2121 card
->state
= CARD_STATE_DOWN
;
2123 if (card
->state
== CARD_STATE_DOWN
) {
2124 qeth_clear_cmd_buffers(&card
->read
);
2125 qeth_clear_cmd_buffers(&card
->write
);
2127 card
->use_hard_stop
= 0;
2131 static void qeth_l3_set_multicast_list(struct net_device
*dev
)
2133 struct qeth_card
*card
= netdev_priv(dev
);
2135 QETH_DBF_TEXT(TRACE
, 3, "setmulti");
2136 qeth_l3_delete_mc_addresses(card
);
2137 qeth_l3_add_multicast_ipv4(card
);
2138 #ifdef CONFIG_QETH_IPV6
2139 qeth_l3_add_multicast_ipv6(card
);
2141 qeth_l3_set_ip_addr_list(card
);
2142 if (!qeth_adp_supported(card
, IPA_SETADP_SET_PROMISC_MODE
))
2144 qeth_setadp_promisc_mode(card
);
2147 static const char *qeth_l3_arp_get_error_cause(int *rc
)
2150 case QETH_IPA_ARP_RC_FAILED
:
2152 return "operation failed";
2153 case QETH_IPA_ARP_RC_NOTSUPP
:
2155 return "operation not supported";
2156 case QETH_IPA_ARP_RC_OUT_OF_RANGE
:
2158 return "argument out of range";
2159 case QETH_IPA_ARP_RC_Q_NOTSUPP
:
2161 return "query operation not supported";
2162 case QETH_IPA_ARP_RC_Q_NO_DATA
:
2164 return "no query data available";
2166 return "unknown error";
2170 static int qeth_l3_arp_set_no_entries(struct qeth_card
*card
, int no_entries
)
2175 QETH_DBF_TEXT(TRACE
, 3, "arpstnoe");
2178 * currently GuestLAN only supports the ARP assist function
2179 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_SET_NO_ENTRIES;
2180 * thus we say EOPNOTSUPP for this ARP function
2182 if (card
->info
.guestlan
)
2184 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
2185 PRINT_WARN("ARP processing not supported "
2186 "on %s!\n", QETH_CARD_IFNAME(card
));
2189 rc
= qeth_l3_send_simple_setassparms(card
, IPA_ARP_PROCESSING
,
2190 IPA_CMD_ASS_ARP_SET_NO_ENTRIES
,
2194 PRINT_WARN("Could not set number of ARP entries on %s: "
2195 "%s (0x%x/%d)\n", QETH_CARD_IFNAME(card
),
2196 qeth_l3_arp_get_error_cause(&rc
), tmp
, tmp
);
2201 static void qeth_l3_copy_arp_entries_stripped(struct qeth_arp_query_info
*qinfo
,
2202 struct qeth_arp_query_data
*qdata
, int entry_size
,
2209 entry_ptr
= (char *)&qdata
->data
;
2210 uentry_ptr
= (char *)(qinfo
->udata
+ qinfo
->udata_offset
);
2211 for (i
= 0; i
< qdata
->no_entries
; ++i
) {
2212 /* strip off 32 bytes "media specific information" */
2213 memcpy(uentry_ptr
, (entry_ptr
+ 32), entry_size
- 32);
2214 entry_ptr
+= entry_size
;
2215 uentry_ptr
+= uentry_size
;
2219 static int qeth_l3_arp_query_cb(struct qeth_card
*card
,
2220 struct qeth_reply
*reply
, unsigned long data
)
2222 struct qeth_ipa_cmd
*cmd
;
2223 struct qeth_arp_query_data
*qdata
;
2224 struct qeth_arp_query_info
*qinfo
;
2229 QETH_DBF_TEXT(TRACE
, 4, "arpquecb");
2231 qinfo
= (struct qeth_arp_query_info
*) reply
->param
;
2232 cmd
= (struct qeth_ipa_cmd
*) data
;
2233 if (cmd
->hdr
.return_code
) {
2234 QETH_DBF_TEXT_(TRACE
, 4, "qaer1%i", cmd
->hdr
.return_code
);
2237 if (cmd
->data
.setassparms
.hdr
.return_code
) {
2238 cmd
->hdr
.return_code
= cmd
->data
.setassparms
.hdr
.return_code
;
2239 QETH_DBF_TEXT_(TRACE
, 4, "qaer2%i", cmd
->hdr
.return_code
);
2242 qdata
= &cmd
->data
.setassparms
.data
.query_arp
;
2243 switch (qdata
->reply_bits
) {
2245 uentry_size
= entry_size
= sizeof(struct qeth_arp_qi_entry5
);
2246 if (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
)
2247 uentry_size
= sizeof(struct qeth_arp_qi_entry5_short
);
2250 /* fall through to default */
2252 /* tr is the same as eth -> entry7 */
2253 uentry_size
= entry_size
= sizeof(struct qeth_arp_qi_entry7
);
2254 if (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
)
2255 uentry_size
= sizeof(struct qeth_arp_qi_entry7_short
);
2258 /* check if there is enough room in userspace */
2259 if ((qinfo
->udata_len
- qinfo
->udata_offset
) <
2260 qdata
->no_entries
* uentry_size
){
2261 QETH_DBF_TEXT_(TRACE
, 4, "qaer3%i", -ENOMEM
);
2262 cmd
->hdr
.return_code
= -ENOMEM
;
2263 PRINT_WARN("query ARP user space buffer is too small for "
2264 "the returned number of ARP entries. "
2265 "Aborting query!\n");
2268 QETH_DBF_TEXT_(TRACE
, 4, "anore%i",
2269 cmd
->data
.setassparms
.hdr
.number_of_replies
);
2270 QETH_DBF_TEXT_(TRACE
, 4, "aseqn%i", cmd
->data
.setassparms
.hdr
.seq_no
);
2271 QETH_DBF_TEXT_(TRACE
, 4, "anoen%i", qdata
->no_entries
);
2273 if (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
) {
2274 /* strip off "media specific information" */
2275 qeth_l3_copy_arp_entries_stripped(qinfo
, qdata
, entry_size
,
2278 /*copy entries to user buffer*/
2279 memcpy(qinfo
->udata
+ qinfo
->udata_offset
,
2280 (char *)&qdata
->data
, qdata
->no_entries
*uentry_size
);
2282 qinfo
->no_entries
+= qdata
->no_entries
;
2283 qinfo
->udata_offset
+= (qdata
->no_entries
*uentry_size
);
2284 /* check if all replies received ... */
2285 if (cmd
->data
.setassparms
.hdr
.seq_no
<
2286 cmd
->data
.setassparms
.hdr
.number_of_replies
)
2288 memcpy(qinfo
->udata
, &qinfo
->no_entries
, 4);
2289 /* keep STRIP_ENTRIES flag so the user program can distinguish
2290 * stripped entries from normal ones */
2291 if (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
)
2292 qdata
->reply_bits
|= QETH_QARP_STRIP_ENTRIES
;
2293 memcpy(qinfo
->udata
+ QETH_QARP_MASK_OFFSET
, &qdata
->reply_bits
, 2);
2297 memcpy(qinfo
->udata
, &i
, 4);
2301 static int qeth_l3_send_ipa_arp_cmd(struct qeth_card
*card
,
2302 struct qeth_cmd_buffer
*iob
, int len
,
2303 int (*reply_cb
)(struct qeth_card
*, struct qeth_reply
*,
2307 QETH_DBF_TEXT(TRACE
, 4, "sendarp");
2309 memcpy(iob
->data
, IPA_PDU_HEADER
, IPA_PDU_HEADER_SIZE
);
2310 memcpy(QETH_IPA_CMD_DEST_ADDR(iob
->data
),
2311 &card
->token
.ulp_connection_r
, QETH_MPC_TOKEN_LENGTH
);
2312 return qeth_send_control_data(card
, IPA_PDU_HEADER_SIZE
+ len
, iob
,
2313 reply_cb
, reply_param
);
2316 static int qeth_l3_arp_query(struct qeth_card
*card
, char __user
*udata
)
2318 struct qeth_cmd_buffer
*iob
;
2319 struct qeth_arp_query_info qinfo
= {0, };
2323 QETH_DBF_TEXT(TRACE
, 3, "arpquery");
2325 if (!qeth_is_supported(card
,/*IPA_QUERY_ARP_ADDR_INFO*/
2326 IPA_ARP_PROCESSING
)) {
2327 PRINT_WARN("ARP processing not supported "
2328 "on %s!\n", QETH_CARD_IFNAME(card
));
2331 /* get size of userspace buffer and mask_bits -> 6 bytes */
2332 if (copy_from_user(&qinfo
, udata
, 6))
2334 qinfo
.udata
= kzalloc(qinfo
.udata_len
, GFP_KERNEL
);
2337 qinfo
.udata_offset
= QETH_QARP_ENTRIES_OFFSET
;
2338 iob
= qeth_l3_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
2339 IPA_CMD_ASS_ARP_QUERY_INFO
,
2340 sizeof(int), QETH_PROT_IPV4
);
2342 rc
= qeth_l3_send_ipa_arp_cmd(card
, iob
,
2343 QETH_SETASS_BASE_LEN
+QETH_ARP_CMD_LEN
,
2344 qeth_l3_arp_query_cb
, (void *)&qinfo
);
2347 PRINT_WARN("Error while querying ARP cache on %s: %s "
2348 "(0x%x/%d)\n", QETH_CARD_IFNAME(card
),
2349 qeth_l3_arp_get_error_cause(&rc
), tmp
, tmp
);
2350 if (copy_to_user(udata
, qinfo
.udata
, 4))
2353 if (copy_to_user(udata
, qinfo
.udata
, qinfo
.udata_len
))
2360 static int qeth_l3_arp_add_entry(struct qeth_card
*card
,
2361 struct qeth_arp_cache_entry
*entry
)
2363 struct qeth_cmd_buffer
*iob
;
2368 QETH_DBF_TEXT(TRACE
, 3, "arpadent");
2371 * currently GuestLAN only supports the ARP assist function
2372 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_ADD_ENTRY;
2373 * thus we say EOPNOTSUPP for this ARP function
2375 if (card
->info
.guestlan
)
2377 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
2378 PRINT_WARN("ARP processing not supported "
2379 "on %s!\n", QETH_CARD_IFNAME(card
));
2383 iob
= qeth_l3_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
2384 IPA_CMD_ASS_ARP_ADD_ENTRY
,
2385 sizeof(struct qeth_arp_cache_entry
),
2387 rc
= qeth_l3_send_setassparms(card
, iob
,
2388 sizeof(struct qeth_arp_cache_entry
),
2389 (unsigned long) entry
,
2390 qeth_l3_default_setassparms_cb
, NULL
);
2393 qeth_l3_ipaddr4_to_string((u8
*)entry
->ipaddr
, buf
);
2394 PRINT_WARN("Could not add ARP entry for address %s on %s: "
2396 buf
, QETH_CARD_IFNAME(card
),
2397 qeth_l3_arp_get_error_cause(&rc
), tmp
, tmp
);
2402 static int qeth_l3_arp_remove_entry(struct qeth_card
*card
,
2403 struct qeth_arp_cache_entry
*entry
)
2405 struct qeth_cmd_buffer
*iob
;
2406 char buf
[16] = {0, };
2410 QETH_DBF_TEXT(TRACE
, 3, "arprment");
2413 * currently GuestLAN only supports the ARP assist function
2414 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_REMOVE_ENTRY;
2415 * thus we say EOPNOTSUPP for this ARP function
2417 if (card
->info
.guestlan
)
2419 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
2420 PRINT_WARN("ARP processing not supported "
2421 "on %s!\n", QETH_CARD_IFNAME(card
));
2424 memcpy(buf
, entry
, 12);
2425 iob
= qeth_l3_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
2426 IPA_CMD_ASS_ARP_REMOVE_ENTRY
,
2429 rc
= qeth_l3_send_setassparms(card
, iob
,
2430 12, (unsigned long)buf
,
2431 qeth_l3_default_setassparms_cb
, NULL
);
2435 qeth_l3_ipaddr4_to_string((u8
*)entry
->ipaddr
, buf
);
2436 PRINT_WARN("Could not delete ARP entry for address %s on %s: "
2438 buf
, QETH_CARD_IFNAME(card
),
2439 qeth_l3_arp_get_error_cause(&rc
), tmp
, tmp
);
2444 static int qeth_l3_arp_flush_cache(struct qeth_card
*card
)
2449 QETH_DBF_TEXT(TRACE
, 3, "arpflush");
2452 * currently GuestLAN only supports the ARP assist function
2453 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_FLUSH_CACHE;
2454 * thus we say EOPNOTSUPP for this ARP function
2456 if (card
->info
.guestlan
|| (card
->info
.type
== QETH_CARD_TYPE_IQD
))
2458 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
2459 PRINT_WARN("ARP processing not supported "
2460 "on %s!\n", QETH_CARD_IFNAME(card
));
2463 rc
= qeth_l3_send_simple_setassparms(card
, IPA_ARP_PROCESSING
,
2464 IPA_CMD_ASS_ARP_FLUSH_CACHE
, 0);
2467 PRINT_WARN("Could not flush ARP cache on %s: %s (0x%x/%d)\n",
2468 QETH_CARD_IFNAME(card
),
2469 qeth_l3_arp_get_error_cause(&rc
), tmp
, tmp
);
2474 static int qeth_l3_do_ioctl(struct net_device
*dev
, struct ifreq
*rq
, int cmd
)
2476 struct qeth_card
*card
= netdev_priv(dev
);
2477 struct qeth_arp_cache_entry arp_entry
;
2478 struct mii_ioctl_data
*mii_data
;
2484 if ((card
->state
!= CARD_STATE_UP
) &&
2485 (card
->state
!= CARD_STATE_SOFTSETUP
))
2489 case SIOC_QETH_ARP_SET_NO_ENTRIES
:
2490 if (!capable(CAP_NET_ADMIN
)) {
2494 rc
= qeth_l3_arp_set_no_entries(card
, rq
->ifr_ifru
.ifru_ivalue
);
2496 case SIOC_QETH_ARP_QUERY_INFO
:
2497 if (!capable(CAP_NET_ADMIN
)) {
2501 rc
= qeth_l3_arp_query(card
, rq
->ifr_ifru
.ifru_data
);
2503 case SIOC_QETH_ARP_ADD_ENTRY
:
2504 if (!capable(CAP_NET_ADMIN
)) {
2508 if (copy_from_user(&arp_entry
, rq
->ifr_ifru
.ifru_data
,
2509 sizeof(struct qeth_arp_cache_entry
)))
2512 rc
= qeth_l3_arp_add_entry(card
, &arp_entry
);
2514 case SIOC_QETH_ARP_REMOVE_ENTRY
:
2515 if (!capable(CAP_NET_ADMIN
)) {
2519 if (copy_from_user(&arp_entry
, rq
->ifr_ifru
.ifru_data
,
2520 sizeof(struct qeth_arp_cache_entry
)))
2523 rc
= qeth_l3_arp_remove_entry(card
, &arp_entry
);
2525 case SIOC_QETH_ARP_FLUSH_CACHE
:
2526 if (!capable(CAP_NET_ADMIN
)) {
2530 rc
= qeth_l3_arp_flush_cache(card
);
2532 case SIOC_QETH_ADP_SET_SNMP_CONTROL
:
2533 rc
= qeth_snmp_command(card
, rq
->ifr_ifru
.ifru_data
);
2535 case SIOC_QETH_GET_CARD_TYPE
:
2536 if ((card
->info
.type
== QETH_CARD_TYPE_OSAE
) &&
2537 !card
->info
.guestlan
)
2542 mii_data
= if_mii(rq
);
2543 mii_data
->phy_id
= 0;
2546 mii_data
= if_mii(rq
);
2547 if (mii_data
->phy_id
!= 0)
2550 mii_data
->val_out
= qeth_mdio_read(dev
,
2558 QETH_DBF_TEXT_(TRACE
, 2, "ioce%d", rc
);
2562 static void qeth_l3_fill_header(struct qeth_card
*card
, struct qeth_hdr
*hdr
,
2563 struct sk_buff
*skb
, int ipv
, int cast_type
)
2565 memset(hdr
, 0, sizeof(struct qeth_hdr
));
2566 hdr
->hdr
.l3
.id
= QETH_HEADER_TYPE_LAYER3
;
2567 hdr
->hdr
.l3
.ext_flags
= 0;
2570 * before we're going to overwrite this location with next hop ip.
2571 * v6 uses passthrough, v4 sets the tag in the QDIO header.
2573 if (card
->vlangrp
&& vlan_tx_tag_present(skb
)) {
2574 if ((ipv
== 4) || (card
->info
.type
== QETH_CARD_TYPE_IQD
))
2575 hdr
->hdr
.l3
.ext_flags
= QETH_HDR_EXT_VLAN_FRAME
;
2577 hdr
->hdr
.l3
.ext_flags
= QETH_HDR_EXT_INCLUDE_VLAN_TAG
;
2578 hdr
->hdr
.l3
.vlan_id
= vlan_tx_tag_get(skb
);
2581 hdr
->hdr
.l3
.length
= skb
->len
- sizeof(struct qeth_hdr
);
2584 hdr
->hdr
.l3
.flags
= qeth_l3_get_qeth_hdr_flags4(cast_type
);
2585 memset(hdr
->hdr
.l3
.dest_addr
, 0, 12);
2586 if ((skb
->dst
) && (skb
->dst
->neighbour
)) {
2587 *((u32
*) (&hdr
->hdr
.l3
.dest_addr
[12])) =
2588 *((u32
*) skb
->dst
->neighbour
->primary_key
);
2590 /* fill in destination address used in ip header */
2591 *((u32
*) (&hdr
->hdr
.l3
.dest_addr
[12])) =
2594 } else if (ipv
== 6) {
2596 hdr
->hdr
.l3
.flags
= qeth_l3_get_qeth_hdr_flags6(cast_type
);
2597 if (card
->info
.type
== QETH_CARD_TYPE_IQD
)
2598 hdr
->hdr
.l3
.flags
&= ~QETH_HDR_PASSTHRU
;
2599 if ((skb
->dst
) && (skb
->dst
->neighbour
)) {
2600 memcpy(hdr
->hdr
.l3
.dest_addr
,
2601 skb
->dst
->neighbour
->primary_key
, 16);
2603 /* fill in destination address used in ip header */
2604 memcpy(hdr
->hdr
.l3
.dest_addr
,
2605 &ipv6_hdr(skb
)->daddr
, 16);
2609 if ((skb
->dev
->type
== ARPHRD_IEEE802_TR
) &&
2610 !memcmp(skb
->data
+ sizeof(struct qeth_hdr
) +
2611 sizeof(__u16
), skb
->dev
->broadcast
, 6)) {
2612 hdr
->hdr
.l3
.flags
= QETH_CAST_BROADCAST
|
2614 } else if (!memcmp(skb
->data
+ sizeof(struct qeth_hdr
),
2615 skb
->dev
->broadcast
, 6)) {
2617 hdr
->hdr
.l3
.flags
= QETH_CAST_BROADCAST
|
2620 hdr
->hdr
.l3
.flags
= (cast_type
== RTN_MULTICAST
) ?
2621 QETH_CAST_MULTICAST
| QETH_HDR_PASSTHRU
:
2622 QETH_CAST_UNICAST
| QETH_HDR_PASSTHRU
;
2627 static int qeth_l3_hard_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
2631 struct qeth_hdr
*hdr
= NULL
;
2632 int elements_needed
= 0;
2633 struct qeth_card
*card
= netdev_priv(dev
);
2634 struct sk_buff
*new_skb
= NULL
;
2635 int ipv
= qeth_get_ip_version(skb
);
2636 int cast_type
= qeth_get_cast_type(card
, skb
);
2637 struct qeth_qdio_out_q
*queue
= card
->qdio
.out_qs
2638 [qeth_get_priority_queue(card
, skb
, ipv
, cast_type
)];
2639 int tx_bytes
= skb
->len
;
2640 enum qeth_large_send_types large_send
= QETH_LARGE_SEND_NO
;
2641 struct qeth_eddp_context
*ctx
= NULL
;
2643 if ((card
->info
.type
== QETH_CARD_TYPE_IQD
) &&
2644 (skb
->protocol
!= htons(ETH_P_IPV6
)) &&
2645 (skb
->protocol
!= htons(ETH_P_IP
)))
2648 if ((card
->state
!= CARD_STATE_UP
) || !card
->lan_online
) {
2649 card
->stats
.tx_carrier_errors
++;
2653 if ((cast_type
== RTN_BROADCAST
) &&
2654 (card
->info
.broadcast_capable
== 0))
2657 if (card
->options
.performance_stats
) {
2658 card
->perf_stats
.outbound_cnt
++;
2659 card
->perf_stats
.outbound_start_time
= qeth_get_micros();
2662 /* create a clone with writeable headroom */
2663 new_skb
= skb_realloc_headroom(skb
, sizeof(struct qeth_hdr_tso
) +
2668 if (card
->info
.type
== QETH_CARD_TYPE_IQD
) {
2669 skb_pull(new_skb
, ETH_HLEN
);
2671 if (new_skb
->protocol
== htons(ETH_P_IP
)) {
2672 if (card
->dev
->type
== ARPHRD_IEEE802_TR
)
2673 skb_pull(new_skb
, TR_HLEN
);
2675 skb_pull(new_skb
, ETH_HLEN
);
2678 if (new_skb
->protocol
== ETH_P_IPV6
&& card
->vlangrp
&&
2679 vlan_tx_tag_present(new_skb
)) {
2680 skb_push(new_skb
, VLAN_HLEN
);
2681 skb_copy_to_linear_data(new_skb
, new_skb
->data
+ 4, 4);
2682 skb_copy_to_linear_data_offset(new_skb
, 4,
2683 new_skb
->data
+ 8, 4);
2684 skb_copy_to_linear_data_offset(new_skb
, 8,
2685 new_skb
->data
+ 12, 4);
2686 tag
= (u16
*)(new_skb
->data
+ 12);
2687 *tag
= __constant_htons(ETH_P_8021Q
);
2688 *(tag
+ 1) = htons(vlan_tx_tag_get(new_skb
));
2689 VLAN_TX_SKB_CB(new_skb
)->magic
= 0;
2693 netif_stop_queue(dev
);
2695 if (skb_is_gso(new_skb
))
2696 large_send
= card
->options
.large_send
;
2698 /* fix hardware limitation: as long as we do not have sbal
2699 * chaining we can not send long frag lists so we temporary
2702 if ((large_send
== QETH_LARGE_SEND_TSO
) &&
2703 ((skb_shinfo(new_skb
)->nr_frags
+ 2) > 16))
2704 large_send
= QETH_LARGE_SEND_EDDP
;
2706 if ((large_send
== QETH_LARGE_SEND_TSO
) &&
2707 (cast_type
== RTN_UNSPEC
)) {
2708 hdr
= (struct qeth_hdr
*)skb_push(new_skb
,
2709 sizeof(struct qeth_hdr_tso
));
2710 memset(hdr
, 0, sizeof(struct qeth_hdr_tso
));
2711 qeth_l3_fill_header(card
, hdr
, new_skb
, ipv
, cast_type
);
2712 qeth_tso_fill_header(card
, hdr
, new_skb
);
2715 hdr
= (struct qeth_hdr
*)skb_push(new_skb
,
2716 sizeof(struct qeth_hdr
));
2717 qeth_l3_fill_header(card
, hdr
, new_skb
, ipv
, cast_type
);
2720 if (large_send
== QETH_LARGE_SEND_EDDP
) {
2721 /* new_skb is not owned by a socket so we use skb to get
2724 ctx
= qeth_eddp_create_context(card
, new_skb
, hdr
,
2725 skb
->sk
->sk_protocol
);
2727 PRINT_WARN("could not create eddp context\n");
2731 int elems
= qeth_get_elements_no(card
, (void *)hdr
, new_skb
,
2735 elements_needed
+= elems
;
2738 if ((large_send
== QETH_LARGE_SEND_NO
) &&
2739 (new_skb
->ip_summed
== CHECKSUM_PARTIAL
))
2740 qeth_tx_csum(new_skb
);
2742 if (card
->info
.type
!= QETH_CARD_TYPE_IQD
)
2743 rc
= qeth_do_send_packet(card
, queue
, new_skb
, hdr
,
2744 elements_needed
, ctx
);
2746 rc
= qeth_do_send_packet_fast(card
, queue
, new_skb
, hdr
,
2747 elements_needed
, ctx
);
2750 card
->stats
.tx_packets
++;
2751 card
->stats
.tx_bytes
+= tx_bytes
;
2753 dev_kfree_skb_any(skb
);
2754 if (card
->options
.performance_stats
) {
2755 if (large_send
!= QETH_LARGE_SEND_NO
) {
2756 card
->perf_stats
.large_send_bytes
+= tx_bytes
;
2757 card
->perf_stats
.large_send_cnt
++;
2759 if (skb_shinfo(new_skb
)->nr_frags
> 0) {
2760 card
->perf_stats
.sg_skbs_sent
++;
2761 /* nr_frags + skb->data */
2762 card
->perf_stats
.sg_frags_sent
+=
2763 skb_shinfo(new_skb
)->nr_frags
+ 1;
2768 qeth_eddp_put_context(ctx
);
2769 dev_kfree_skb_any(new_skb
);
2773 qeth_eddp_put_context(ctx
);
2777 dev_kfree_skb_any(new_skb
);
2778 return NETDEV_TX_BUSY
;
2783 netif_wake_queue(dev
);
2784 if (card
->options
.performance_stats
)
2785 card
->perf_stats
.outbound_time
+= qeth_get_micros() -
2786 card
->perf_stats
.outbound_start_time
;
2790 card
->stats
.tx_dropped
++;
2791 card
->stats
.tx_errors
++;
2792 if ((new_skb
!= skb
) && new_skb
)
2793 dev_kfree_skb_any(new_skb
);
2794 dev_kfree_skb_any(skb
);
2795 return NETDEV_TX_OK
;
2798 static int qeth_l3_open(struct net_device
*dev
)
2800 struct qeth_card
*card
= netdev_priv(dev
);
2802 QETH_DBF_TEXT(TRACE
, 4, "qethopen");
2803 if (card
->state
!= CARD_STATE_SOFTSETUP
)
2805 card
->data
.state
= CH_STATE_UP
;
2806 card
->state
= CARD_STATE_UP
;
2807 card
->dev
->flags
|= IFF_UP
;
2808 netif_start_queue(dev
);
2810 if (!card
->lan_online
&& netif_carrier_ok(dev
))
2811 netif_carrier_off(dev
);
2815 static int qeth_l3_stop(struct net_device
*dev
)
2817 struct qeth_card
*card
= netdev_priv(dev
);
2819 QETH_DBF_TEXT(TRACE
, 4, "qethstop");
2820 netif_tx_disable(dev
);
2821 card
->dev
->flags
&= ~IFF_UP
;
2822 if (card
->state
== CARD_STATE_UP
)
2823 card
->state
= CARD_STATE_SOFTSETUP
;
2827 static u32
qeth_l3_ethtool_get_rx_csum(struct net_device
*dev
)
2829 struct qeth_card
*card
= netdev_priv(dev
);
2831 return (card
->options
.checksum_type
== HW_CHECKSUMMING
);
2834 static int qeth_l3_ethtool_set_rx_csum(struct net_device
*dev
, u32 data
)
2836 struct qeth_card
*card
= netdev_priv(dev
);
2837 enum qeth_card_states old_state
;
2838 enum qeth_checksum_types csum_type
;
2840 if ((card
->state
!= CARD_STATE_UP
) &&
2841 (card
->state
!= CARD_STATE_DOWN
))
2845 csum_type
= HW_CHECKSUMMING
;
2847 csum_type
= SW_CHECKSUMMING
;
2849 if (card
->options
.checksum_type
!= csum_type
) {
2850 old_state
= card
->state
;
2851 if (card
->state
== CARD_STATE_UP
)
2852 __qeth_l3_set_offline(card
->gdev
, 1);
2853 card
->options
.checksum_type
= csum_type
;
2854 if (old_state
== CARD_STATE_UP
)
2855 __qeth_l3_set_online(card
->gdev
, 1);
2860 static int qeth_l3_ethtool_set_tso(struct net_device
*dev
, u32 data
)
2862 struct qeth_card
*card
= netdev_priv(dev
);
2865 if (card
->options
.large_send
== QETH_LARGE_SEND_NO
) {
2866 if (card
->info
.type
== QETH_CARD_TYPE_IQD
)
2867 card
->options
.large_send
= QETH_LARGE_SEND_EDDP
;
2869 card
->options
.large_send
= QETH_LARGE_SEND_TSO
;
2870 dev
->features
|= NETIF_F_TSO
;
2873 dev
->features
&= ~NETIF_F_TSO
;
2874 card
->options
.large_send
= QETH_LARGE_SEND_NO
;
2879 static struct ethtool_ops qeth_l3_ethtool_ops
= {
2880 .get_link
= ethtool_op_get_link
,
2881 .get_tx_csum
= ethtool_op_get_tx_csum
,
2882 .set_tx_csum
= ethtool_op_set_tx_hw_csum
,
2883 .get_rx_csum
= qeth_l3_ethtool_get_rx_csum
,
2884 .set_rx_csum
= qeth_l3_ethtool_set_rx_csum
,
2885 .get_sg
= ethtool_op_get_sg
,
2886 .set_sg
= ethtool_op_set_sg
,
2887 .get_tso
= ethtool_op_get_tso
,
2888 .set_tso
= qeth_l3_ethtool_set_tso
,
2889 .get_strings
= qeth_core_get_strings
,
2890 .get_ethtool_stats
= qeth_core_get_ethtool_stats
,
2891 .get_stats_count
= qeth_core_get_stats_count
,
2892 .get_drvinfo
= qeth_core_get_drvinfo
,
2893 .get_settings
= qeth_core_ethtool_get_settings
,
2897 * we need NOARP for IPv4 but we want neighbor solicitation for IPv6. Setting
2898 * NOARP on the netdevice is no option because it also turns off neighbor
2899 * solicitation. For IPv4 we install a neighbor_setup function. We don't want
2900 * arp resolution but we want the hard header (packet socket will work
2903 static int qeth_l3_neigh_setup_noarp(struct neighbour
*n
)
2905 n
->nud_state
= NUD_NOARP
;
2906 memcpy(n
->ha
, "FAKELL", 6);
2907 n
->output
= n
->ops
->connected_output
;
2912 qeth_l3_neigh_setup(struct net_device
*dev
, struct neigh_parms
*np
)
2914 if (np
->tbl
->family
== AF_INET
)
2915 np
->neigh_setup
= qeth_l3_neigh_setup_noarp
;
2920 static int qeth_l3_setup_netdev(struct qeth_card
*card
)
2922 if (card
->info
.type
== QETH_CARD_TYPE_OSAE
) {
2923 if ((card
->info
.link_type
== QETH_LINK_TYPE_LANE_TR
) ||
2924 (card
->info
.link_type
== QETH_LINK_TYPE_HSTR
)) {
2926 card
->dev
= alloc_trdev(0);
2931 card
->dev
= alloc_etherdev(0);
2934 card
->dev
->neigh_setup
= qeth_l3_neigh_setup
;
2936 /*IPv6 address autoconfiguration stuff*/
2937 qeth_l3_get_unique_id(card
);
2938 if (!(card
->info
.unique_id
& UNIQUE_ID_NOT_BY_CARD
))
2939 card
->dev
->dev_id
= card
->info
.unique_id
&
2942 } else if (card
->info
.type
== QETH_CARD_TYPE_IQD
) {
2943 card
->dev
= alloc_netdev(0, "hsi%d", ether_setup
);
2946 card
->dev
->flags
|= IFF_NOARP
;
2947 qeth_l3_iqd_read_initial_mac(card
);
2951 card
->dev
->hard_start_xmit
= qeth_l3_hard_start_xmit
;
2952 card
->dev
->priv
= card
;
2953 card
->dev
->tx_timeout
= &qeth_tx_timeout
;
2954 card
->dev
->watchdog_timeo
= QETH_TX_TIMEOUT
;
2955 card
->dev
->open
= qeth_l3_open
;
2956 card
->dev
->stop
= qeth_l3_stop
;
2957 card
->dev
->do_ioctl
= qeth_l3_do_ioctl
;
2958 card
->dev
->get_stats
= qeth_get_stats
;
2959 card
->dev
->change_mtu
= qeth_change_mtu
;
2960 card
->dev
->set_multicast_list
= qeth_l3_set_multicast_list
;
2961 card
->dev
->vlan_rx_register
= qeth_l3_vlan_rx_register
;
2962 card
->dev
->vlan_rx_add_vid
= qeth_l3_vlan_rx_add_vid
;
2963 card
->dev
->vlan_rx_kill_vid
= qeth_l3_vlan_rx_kill_vid
;
2964 card
->dev
->mtu
= card
->info
.initial_mtu
;
2965 card
->dev
->set_mac_address
= NULL
;
2966 SET_ETHTOOL_OPS(card
->dev
, &qeth_l3_ethtool_ops
);
2967 card
->dev
->features
|= NETIF_F_HW_VLAN_TX
|
2968 NETIF_F_HW_VLAN_RX
|
2969 NETIF_F_HW_VLAN_FILTER
;
2971 SET_NETDEV_DEV(card
->dev
, &card
->gdev
->dev
);
2972 return register_netdev(card
->dev
);
2975 static void qeth_l3_qdio_input_handler(struct ccw_device
*ccwdev
,
2976 unsigned int status
, unsigned int qdio_err
,
2977 unsigned int siga_err
, unsigned int queue
, int first_element
,
2978 int count
, unsigned long card_ptr
)
2980 struct net_device
*net_dev
;
2981 struct qeth_card
*card
;
2982 struct qeth_qdio_buffer
*buffer
;
2986 card
= (struct qeth_card
*) card_ptr
;
2987 net_dev
= card
->dev
;
2988 if (card
->options
.performance_stats
) {
2989 card
->perf_stats
.inbound_cnt
++;
2990 card
->perf_stats
.inbound_start_time
= qeth_get_micros();
2992 if (status
& QDIO_STATUS_LOOK_FOR_ERROR
) {
2993 if (status
& QDIO_STATUS_ACTIVATE_CHECK_CONDITION
) {
2994 QETH_DBF_TEXT(TRACE
, 1, "qdinchk");
2995 QETH_DBF_TEXT_(TRACE
, 1, "%s", CARD_BUS_ID(card
));
2996 QETH_DBF_TEXT_(TRACE
, 1, "%04X%04X",
2997 first_element
, count
);
2998 QETH_DBF_TEXT_(TRACE
, 1, "%04X%04X", queue
, status
);
2999 qeth_schedule_recovery(card
);
3003 for (i
= first_element
; i
< (first_element
+ count
); ++i
) {
3004 index
= i
% QDIO_MAX_BUFFERS_PER_Q
;
3005 buffer
= &card
->qdio
.in_q
->bufs
[index
];
3006 if (!((status
& QDIO_STATUS_LOOK_FOR_ERROR
) &&
3007 qeth_check_qdio_errors(buffer
->buffer
,
3008 qdio_err
, siga_err
, "qinerr")))
3009 qeth_l3_process_inbound_buffer(card
, buffer
, index
);
3010 /* clear buffer and give back to hardware */
3011 qeth_put_buffer_pool_entry(card
, buffer
->pool_entry
);
3012 qeth_queue_input_buffer(card
, index
);
3014 if (card
->options
.performance_stats
)
3015 card
->perf_stats
.inbound_time
+= qeth_get_micros() -
3016 card
->perf_stats
.inbound_start_time
;
3019 static int qeth_l3_probe_device(struct ccwgroup_device
*gdev
)
3021 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
3023 qeth_l3_create_device_attributes(&gdev
->dev
);
3024 card
->options
.layer2
= 0;
3025 card
->discipline
.input_handler
= (qdio_handler_t
*)
3026 qeth_l3_qdio_input_handler
;
3027 card
->discipline
.output_handler
= (qdio_handler_t
*)
3028 qeth_qdio_output_handler
;
3029 card
->discipline
.recover
= qeth_l3_recover
;
3033 static void qeth_l3_remove_device(struct ccwgroup_device
*cgdev
)
3035 struct qeth_card
*card
= dev_get_drvdata(&cgdev
->dev
);
3037 wait_event(card
->wait_q
, qeth_threads_running(card
, 0xffffffff) == 0);
3039 if (cgdev
->state
== CCWGROUP_ONLINE
) {
3040 card
->use_hard_stop
= 1;
3041 qeth_l3_set_offline(cgdev
);
3045 unregister_netdev(card
->dev
);
3049 qeth_l3_remove_device_attributes(&cgdev
->dev
);
3050 qeth_l3_clear_ip_list(card
, 0, 0);
3051 qeth_l3_clear_ipato_list(card
);
3055 static int __qeth_l3_set_online(struct ccwgroup_device
*gdev
, int recovery_mode
)
3057 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
3059 enum qeth_card_states recover_flag
;
3062 QETH_DBF_TEXT(SETUP
, 2, "setonlin");
3063 QETH_DBF_HEX(SETUP
, 2, &card
, sizeof(void *));
3065 qeth_set_allowed_threads(card
, QETH_RECOVER_THREAD
, 1);
3066 if (qeth_wait_for_threads(card
, ~QETH_RECOVER_THREAD
)) {
3067 PRINT_WARN("set_online of card %s interrupted by user!\n",
3069 return -ERESTARTSYS
;
3072 recover_flag
= card
->state
;
3073 rc
= ccw_device_set_online(CARD_RDEV(card
));
3075 QETH_DBF_TEXT_(SETUP
, 2, "1err%d", rc
);
3078 rc
= ccw_device_set_online(CARD_WDEV(card
));
3080 QETH_DBF_TEXT_(SETUP
, 2, "1err%d", rc
);
3083 rc
= ccw_device_set_online(CARD_DDEV(card
));
3085 QETH_DBF_TEXT_(SETUP
, 2, "1err%d", rc
);
3089 rc
= qeth_core_hardsetup_card(card
);
3091 QETH_DBF_TEXT_(SETUP
, 2, "2err%d", rc
);
3095 qeth_l3_query_ipassists(card
, QETH_PROT_IPV4
);
3097 if (!card
->dev
&& qeth_l3_setup_netdev(card
))
3100 card
->state
= CARD_STATE_HARDSETUP
;
3101 qeth_print_status_message(card
);
3104 QETH_DBF_TEXT(SETUP
, 2, "softsetp");
3106 rc
= qeth_send_startlan(card
);
3108 QETH_DBF_TEXT_(SETUP
, 2, "1err%d", rc
);
3110 PRINT_WARN("LAN on card %s if offline! "
3111 "Waiting for STARTLAN from card.\n",
3113 card
->lan_online
= 0;
3117 card
->lan_online
= 1;
3118 qeth_set_large_send(card
, card
->options
.large_send
);
3120 rc
= qeth_l3_setadapter_parms(card
);
3122 QETH_DBF_TEXT_(SETUP
, 2, "2err%d", rc
);
3123 rc
= qeth_l3_start_ipassists(card
);
3125 QETH_DBF_TEXT_(SETUP
, 2, "3err%d", rc
);
3126 rc
= qeth_l3_setrouting_v4(card
);
3128 QETH_DBF_TEXT_(SETUP
, 2, "4err%d", rc
);
3129 rc
= qeth_l3_setrouting_v6(card
);
3131 QETH_DBF_TEXT_(SETUP
, 2, "5err%d", rc
);
3132 netif_tx_disable(card
->dev
);
3134 rc
= qeth_init_qdio_queues(card
);
3136 QETH_DBF_TEXT_(SETUP
, 2, "6err%d", rc
);
3139 card
->state
= CARD_STATE_SOFTSETUP
;
3140 netif_carrier_on(card
->dev
);
3142 qeth_set_allowed_threads(card
, 0xffffffff, 0);
3143 if (recover_flag
== CARD_STATE_RECOVER
) {
3145 qeth_l3_open(card
->dev
);
3148 dev_open(card
->dev
);
3151 qeth_l3_set_multicast_list(card
->dev
);
3153 /* let user_space know that device is online */
3154 kobject_uevent(&gdev
->dev
.kobj
, KOBJ_CHANGE
);
3157 card
->use_hard_stop
= 1;
3158 qeth_l3_stop_card(card
, 0);
3159 ccw_device_set_offline(CARD_DDEV(card
));
3160 ccw_device_set_offline(CARD_WDEV(card
));
3161 ccw_device_set_offline(CARD_RDEV(card
));
3162 if (recover_flag
== CARD_STATE_RECOVER
)
3163 card
->state
= CARD_STATE_RECOVER
;
3165 card
->state
= CARD_STATE_DOWN
;
3169 static int qeth_l3_set_online(struct ccwgroup_device
*gdev
)
3171 return __qeth_l3_set_online(gdev
, 0);
3174 static int __qeth_l3_set_offline(struct ccwgroup_device
*cgdev
,
3177 struct qeth_card
*card
= dev_get_drvdata(&cgdev
->dev
);
3178 int rc
= 0, rc2
= 0, rc3
= 0;
3179 enum qeth_card_states recover_flag
;
3181 QETH_DBF_TEXT(SETUP
, 3, "setoffl");
3182 QETH_DBF_HEX(SETUP
, 3, &card
, sizeof(void *));
3184 if (card
->dev
&& netif_carrier_ok(card
->dev
))
3185 netif_carrier_off(card
->dev
);
3186 recover_flag
= card
->state
;
3187 if (qeth_l3_stop_card(card
, recovery_mode
) == -ERESTARTSYS
) {
3188 PRINT_WARN("Stopping card %s interrupted by user!\n",
3190 return -ERESTARTSYS
;
3192 rc
= ccw_device_set_offline(CARD_DDEV(card
));
3193 rc2
= ccw_device_set_offline(CARD_WDEV(card
));
3194 rc3
= ccw_device_set_offline(CARD_RDEV(card
));
3196 rc
= (rc2
) ? rc2
: rc3
;
3198 QETH_DBF_TEXT_(SETUP
, 2, "1err%d", rc
);
3199 if (recover_flag
== CARD_STATE_UP
)
3200 card
->state
= CARD_STATE_RECOVER
;
3201 /* let user_space know that device is offline */
3202 kobject_uevent(&cgdev
->dev
.kobj
, KOBJ_CHANGE
);
3206 static int qeth_l3_set_offline(struct ccwgroup_device
*cgdev
)
3208 return __qeth_l3_set_offline(cgdev
, 0);
3211 static int qeth_l3_recover(void *ptr
)
3213 struct qeth_card
*card
;
3216 card
= (struct qeth_card
*) ptr
;
3217 QETH_DBF_TEXT(TRACE
, 2, "recover1");
3218 QETH_DBF_HEX(TRACE
, 2, &card
, sizeof(void *));
3219 if (!qeth_do_run_thread(card
, QETH_RECOVER_THREAD
))
3221 QETH_DBF_TEXT(TRACE
, 2, "recover2");
3222 PRINT_WARN("Recovery of device %s started ...\n",
3224 card
->use_hard_stop
= 1;
3225 __qeth_l3_set_offline(card
->gdev
, 1);
3226 rc
= __qeth_l3_set_online(card
->gdev
, 1);
3227 /* don't run another scheduled recovery */
3228 qeth_clear_thread_start_bit(card
, QETH_RECOVER_THREAD
);
3229 qeth_clear_thread_running_bit(card
, QETH_RECOVER_THREAD
);
3231 PRINT_INFO("Device %s successfully recovered!\n",
3234 PRINT_INFO("Device %s could not be recovered!\n",
3239 static void qeth_l3_shutdown(struct ccwgroup_device
*gdev
)
3241 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
3242 qeth_l3_clear_ip_list(card
, 0, 0);
3243 qeth_qdio_clear_card(card
, 0);
3244 qeth_clear_qdio_buffers(card
);
3247 struct ccwgroup_driver qeth_l3_ccwgroup_driver
= {
3248 .probe
= qeth_l3_probe_device
,
3249 .remove
= qeth_l3_remove_device
,
3250 .set_online
= qeth_l3_set_online
,
3251 .set_offline
= qeth_l3_set_offline
,
3252 .shutdown
= qeth_l3_shutdown
,
3254 EXPORT_SYMBOL_GPL(qeth_l3_ccwgroup_driver
);
3256 static int qeth_l3_ip_event(struct notifier_block
*this,
3257 unsigned long event
, void *ptr
)
3259 struct in_ifaddr
*ifa
= (struct in_ifaddr
*)ptr
;
3260 struct net_device
*dev
= (struct net_device
*)ifa
->ifa_dev
->dev
;
3261 struct qeth_ipaddr
*addr
;
3262 struct qeth_card
*card
;
3264 if (dev_net(dev
) != &init_net
)
3267 QETH_DBF_TEXT(TRACE
, 3, "ipevent");
3268 card
= qeth_l3_get_card_from_dev(dev
);
3272 addr
= qeth_l3_get_addr_buffer(QETH_PROT_IPV4
);
3274 addr
->u
.a4
.addr
= ifa
->ifa_address
;
3275 addr
->u
.a4
.mask
= ifa
->ifa_mask
;
3276 addr
->type
= QETH_IP_TYPE_NORMAL
;
3282 if (!qeth_l3_add_ip(card
, addr
))
3286 if (!qeth_l3_delete_ip(card
, addr
))
3292 qeth_l3_set_ip_addr_list(card
);
3297 static struct notifier_block qeth_l3_ip_notifier
= {
3302 #ifdef CONFIG_QETH_IPV6
3304 * IPv6 event handler
3306 static int qeth_l3_ip6_event(struct notifier_block
*this,
3307 unsigned long event
, void *ptr
)
3309 struct inet6_ifaddr
*ifa
= (struct inet6_ifaddr
*)ptr
;
3310 struct net_device
*dev
= (struct net_device
*)ifa
->idev
->dev
;
3311 struct qeth_ipaddr
*addr
;
3312 struct qeth_card
*card
;
3314 QETH_DBF_TEXT(TRACE
, 3, "ip6event");
3316 card
= qeth_l3_get_card_from_dev(dev
);
3319 if (!qeth_is_supported(card
, IPA_IPV6
))
3322 addr
= qeth_l3_get_addr_buffer(QETH_PROT_IPV6
);
3324 memcpy(&addr
->u
.a6
.addr
, &ifa
->addr
, sizeof(struct in6_addr
));
3325 addr
->u
.a6
.pfxlen
= ifa
->prefix_len
;
3326 addr
->type
= QETH_IP_TYPE_NORMAL
;
3332 if (!qeth_l3_add_ip(card
, addr
))
3336 if (!qeth_l3_delete_ip(card
, addr
))
3342 qeth_l3_set_ip_addr_list(card
);
3347 static struct notifier_block qeth_l3_ip6_notifier
= {
3353 static int qeth_l3_register_notifiers(void)
3357 QETH_DBF_TEXT(TRACE
, 5, "regnotif");
3358 rc
= register_inetaddr_notifier(&qeth_l3_ip_notifier
);
3361 #ifdef CONFIG_QETH_IPV6
3362 rc
= register_inet6addr_notifier(&qeth_l3_ip6_notifier
);
3364 unregister_inetaddr_notifier(&qeth_l3_ip_notifier
);
3368 PRINT_WARN("layer 3 discipline no IPv6 support\n");
3373 static void qeth_l3_unregister_notifiers(void)
3376 QETH_DBF_TEXT(TRACE
, 5, "unregnot");
3377 BUG_ON(unregister_inetaddr_notifier(&qeth_l3_ip_notifier
));
3378 #ifdef CONFIG_QETH_IPV6
3379 BUG_ON(unregister_inet6addr_notifier(&qeth_l3_ip6_notifier
));
3380 #endif /* QETH_IPV6 */
3383 static int __init
qeth_l3_init(void)
3387 PRINT_INFO("register layer 3 discipline\n");
3388 rc
= qeth_l3_register_notifiers();
3392 static void __exit
qeth_l3_exit(void)
3394 qeth_l3_unregister_notifiers();
3395 PRINT_INFO("unregister layer 3 discipline\n");
3398 module_init(qeth_l3_init
);
3399 module_exit(qeth_l3_exit
);
3400 MODULE_AUTHOR("Frank Blaschka <frank.blaschka@de.ibm.com>");
3401 MODULE_DESCRIPTION("qeth layer 3 discipline");
3402 MODULE_LICENSE("GPL");