1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright IBM Corp. 2007, 2009
4 * Author(s): Utz Bacher <utz.bacher@de.ibm.com>,
5 * Frank Pavlic <fpavlic@de.ibm.com>,
6 * Thomas Spatzier <tspat@de.ibm.com>,
7 * Frank Blaschka <frank.blaschka@de.ibm.com>
10 #define KMSG_COMPONENT "qeth"
11 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
13 #include <linux/module.h>
14 #include <linux/moduleparam.h>
15 #include <linux/bitops.h>
16 #include <linux/string.h>
17 #include <linux/errno.h>
18 #include <linux/kernel.h>
19 #include <linux/etherdevice.h>
21 #include <linux/ipv6.h>
22 #include <linux/inetdevice.h>
23 #include <linux/igmp.h>
24 #include <linux/slab.h>
25 #include <linux/if_vlan.h>
29 #include <net/route.h>
30 #include <net/ip6_fib.h>
31 #include <net/ip6_checksum.h>
32 #include <net/iucv/af_iucv.h>
33 #include <linux/hashtable.h>
38 static int qeth_l3_set_offline(struct ccwgroup_device
*);
39 static int qeth_l3_stop(struct net_device
*);
40 static void qeth_l3_set_multicast_list(struct net_device
*);
41 static int qeth_l3_register_addr_entry(struct qeth_card
*,
42 struct qeth_ipaddr
*);
43 static int qeth_l3_deregister_addr_entry(struct qeth_card
*,
44 struct qeth_ipaddr
*);
46 static int qeth_l3_isxdigit(char *buf
)
49 if (!isxdigit(*buf
++))
55 static void qeth_l3_ipaddr4_to_string(const __u8
*addr
, char *buf
)
57 sprintf(buf
, "%pI4", addr
);
60 static int qeth_l3_string_to_ipaddr4(const char *buf
, __u8
*addr
)
62 int count
= 0, rc
= 0;
66 rc
= sscanf(buf
, "%u.%u.%u.%u%c",
67 &in
[0], &in
[1], &in
[2], &in
[3], &c
);
68 if (rc
!= 4 && (rc
!= 5 || c
!= '\n'))
70 for (count
= 0; count
< 4; count
++) {
73 addr
[count
] = in
[count
];
78 static void qeth_l3_ipaddr6_to_string(const __u8
*addr
, char *buf
)
80 sprintf(buf
, "%pI6", addr
);
83 static int qeth_l3_string_to_ipaddr6(const char *buf
, __u8
*addr
)
85 const char *end
, *end_tmp
, *start
;
88 int num2
, cnt
, out
, found
, save_cnt
;
89 unsigned short in_tmp
[8] = {0, };
91 cnt
= out
= found
= save_cnt
= num2
= 0;
96 end
= strchr(start
, ':');
98 end
= buf
+ strlen(buf
);
99 end_tmp
= strchr(start
, '\n');
106 if ((end
- start
) > 4)
108 memcpy(num
, start
, end
- start
);
109 if (!qeth_l3_isxdigit(num
))
111 sscanf(start
, "%x", &num2
);
113 in_tmp
[save_cnt
++] = num2
;
125 if (cnt
+ save_cnt
> 8)
129 in
[cnt
--] = in_tmp
[--save_cnt
];
133 void qeth_l3_ipaddr_to_string(enum qeth_prot_versions proto
, const __u8
*addr
,
136 if (proto
== QETH_PROT_IPV4
)
137 qeth_l3_ipaddr4_to_string(addr
, buf
);
138 else if (proto
== QETH_PROT_IPV6
)
139 qeth_l3_ipaddr6_to_string(addr
, buf
);
142 int qeth_l3_string_to_ipaddr(const char *buf
, enum qeth_prot_versions proto
,
145 if (proto
== QETH_PROT_IPV4
)
146 return qeth_l3_string_to_ipaddr4(buf
, addr
);
147 else if (proto
== QETH_PROT_IPV6
)
148 return qeth_l3_string_to_ipaddr6(buf
, addr
);
153 static void qeth_l3_convert_addr_to_bits(u8
*addr
, u8
*bits
, int len
)
158 for (i
= 0; i
< len
; ++i
) {
160 for (j
= 7; j
>= 0; --j
) {
161 bits
[i
*8 + j
] = octet
& 1;
167 int qeth_l3_is_addr_covered_by_ipato(struct qeth_card
*card
,
168 struct qeth_ipaddr
*addr
)
170 struct qeth_ipato_entry
*ipatoe
;
171 u8 addr_bits
[128] = {0, };
172 u8 ipatoe_bits
[128] = {0, };
175 if (!card
->ipato
.enabled
)
178 qeth_l3_convert_addr_to_bits((u8
*) &addr
->u
, addr_bits
,
179 (addr
->proto
== QETH_PROT_IPV4
)? 4:16);
180 list_for_each_entry(ipatoe
, &card
->ipato
.entries
, entry
) {
181 if (addr
->proto
!= ipatoe
->proto
)
183 qeth_l3_convert_addr_to_bits(ipatoe
->addr
, ipatoe_bits
,
184 (ipatoe
->proto
== QETH_PROT_IPV4
) ?
186 if (addr
->proto
== QETH_PROT_IPV4
)
187 rc
= !memcmp(addr_bits
, ipatoe_bits
,
188 min(32, ipatoe
->mask_bits
));
190 rc
= !memcmp(addr_bits
, ipatoe_bits
,
191 min(128, ipatoe
->mask_bits
));
196 if ((addr
->proto
== QETH_PROT_IPV4
) && card
->ipato
.invert4
)
198 else if ((addr
->proto
== QETH_PROT_IPV6
) && card
->ipato
.invert6
)
205 qeth_l3_ipaddrs_is_equal(struct qeth_ipaddr
*addr1
, struct qeth_ipaddr
*addr2
)
207 return addr1
->proto
== addr2
->proto
&&
208 !memcmp(&addr1
->u
, &addr2
->u
, sizeof(addr1
->u
)) &&
209 !memcmp(&addr1
->mac
, &addr2
->mac
, sizeof(addr1
->mac
));
212 static struct qeth_ipaddr
*
213 qeth_l3_ip_from_hash(struct qeth_card
*card
, struct qeth_ipaddr
*tmp_addr
)
215 struct qeth_ipaddr
*addr
;
217 if (tmp_addr
->is_multicast
) {
218 hash_for_each_possible(card
->ip_mc_htable
, addr
,
219 hnode
, qeth_l3_ipaddr_hash(tmp_addr
))
220 if (qeth_l3_ipaddrs_is_equal(tmp_addr
, addr
))
223 hash_for_each_possible(card
->ip_htable
, addr
,
224 hnode
, qeth_l3_ipaddr_hash(tmp_addr
))
225 if (qeth_l3_ipaddrs_is_equal(tmp_addr
, addr
))
232 int qeth_l3_delete_ip(struct qeth_card
*card
, struct qeth_ipaddr
*tmp_addr
)
235 struct qeth_ipaddr
*addr
;
237 QETH_CARD_TEXT(card
, 4, "delip");
239 if (tmp_addr
->proto
== QETH_PROT_IPV4
)
240 QETH_CARD_HEX(card
, 4, &tmp_addr
->u
.a4
.addr
, 4);
242 QETH_CARD_HEX(card
, 4, &tmp_addr
->u
.a6
.addr
, 8);
243 QETH_CARD_HEX(card
, 4, ((char *)&tmp_addr
->u
.a6
.addr
) + 8, 8);
246 addr
= qeth_l3_ip_from_hash(card
, tmp_addr
);
251 if (addr
->ref_counter
> 0 && (addr
->type
== QETH_IP_TYPE_NORMAL
||
252 addr
->type
== QETH_IP_TYPE_RXIP
))
254 if (addr
->in_progress
)
257 if (!qeth_card_hw_is_reachable(card
)) {
258 addr
->disp_flag
= QETH_DISP_ADDR_DELETE
;
262 rc
= qeth_l3_deregister_addr_entry(card
, addr
);
264 hash_del(&addr
->hnode
);
270 int qeth_l3_add_ip(struct qeth_card
*card
, struct qeth_ipaddr
*tmp_addr
)
273 struct qeth_ipaddr
*addr
;
275 QETH_CARD_TEXT(card
, 4, "addip");
277 if (tmp_addr
->proto
== QETH_PROT_IPV4
)
278 QETH_CARD_HEX(card
, 4, &tmp_addr
->u
.a4
.addr
, 4);
280 QETH_CARD_HEX(card
, 4, &tmp_addr
->u
.a6
.addr
, 8);
281 QETH_CARD_HEX(card
, 4, ((char *)&tmp_addr
->u
.a6
.addr
) + 8, 8);
284 addr
= qeth_l3_ip_from_hash(card
, tmp_addr
);
286 addr
= qeth_l3_get_addr_buffer(tmp_addr
->proto
);
290 memcpy(addr
, tmp_addr
, sizeof(struct qeth_ipaddr
));
291 addr
->ref_counter
= 1;
293 if (addr
->type
== QETH_IP_TYPE_NORMAL
&&
294 qeth_l3_is_addr_covered_by_ipato(card
, addr
)) {
295 QETH_CARD_TEXT(card
, 2, "tkovaddr");
296 addr
->set_flags
|= QETH_IPA_SETIP_TAKEOVER_FLAG
;
298 hash_add(card
->ip_htable
, &addr
->hnode
,
299 qeth_l3_ipaddr_hash(addr
));
301 if (!qeth_card_hw_is_reachable(card
)) {
302 addr
->disp_flag
= QETH_DISP_ADDR_ADD
;
306 /* qeth_l3_register_addr_entry can go to sleep
307 * if we add a IPV4 addr. It is caused by the reason
308 * that SETIP ipa cmd starts ARP staff for IPV4 addr.
309 * Thus we should unlock spinlock, and make a protection
310 * using in_progress variable to indicate that there is
311 * an hardware operation with this IPV4 address
313 if (addr
->proto
== QETH_PROT_IPV4
) {
314 addr
->in_progress
= 1;
315 spin_unlock_bh(&card
->ip_lock
);
316 rc
= qeth_l3_register_addr_entry(card
, addr
);
317 spin_lock_bh(&card
->ip_lock
);
318 addr
->in_progress
= 0;
320 rc
= qeth_l3_register_addr_entry(card
, addr
);
322 if (!rc
|| (rc
== IPA_RC_DUPLICATE_IP_ADDRESS
) ||
323 (rc
== IPA_RC_LAN_OFFLINE
)) {
324 addr
->disp_flag
= QETH_DISP_ADDR_DO_NOTHING
;
325 if (addr
->ref_counter
< 1) {
326 qeth_l3_delete_ip(card
, addr
);
330 hash_del(&addr
->hnode
);
334 if (addr
->type
== QETH_IP_TYPE_NORMAL
||
335 addr
->type
== QETH_IP_TYPE_RXIP
)
343 struct qeth_ipaddr
*qeth_l3_get_addr_buffer(
344 enum qeth_prot_versions prot
)
346 struct qeth_ipaddr
*addr
;
348 addr
= kzalloc(sizeof(struct qeth_ipaddr
), GFP_ATOMIC
);
352 addr
->type
= QETH_IP_TYPE_NORMAL
;
353 addr
->disp_flag
= QETH_DISP_ADDR_DO_NOTHING
;
359 static void qeth_l3_clear_ip_htable(struct qeth_card
*card
, int recover
)
361 struct qeth_ipaddr
*addr
;
362 struct hlist_node
*tmp
;
365 QETH_CARD_TEXT(card
, 4, "clearip");
367 if (recover
&& card
->options
.sniffer
)
370 spin_lock_bh(&card
->ip_lock
);
372 hash_for_each_safe(card
->ip_htable
, i
, tmp
, addr
, hnode
) {
374 hash_del(&addr
->hnode
);
378 addr
->disp_flag
= QETH_DISP_ADDR_ADD
;
381 spin_unlock_bh(&card
->ip_lock
);
383 spin_lock_bh(&card
->mclock
);
385 hash_for_each_safe(card
->ip_mc_htable
, i
, tmp
, addr
, hnode
) {
386 hash_del(&addr
->hnode
);
390 spin_unlock_bh(&card
->mclock
);
394 static void qeth_l3_recover_ip(struct qeth_card
*card
)
396 struct qeth_ipaddr
*addr
;
397 struct hlist_node
*tmp
;
401 QETH_CARD_TEXT(card
, 4, "recovrip");
403 spin_lock_bh(&card
->ip_lock
);
405 hash_for_each_safe(card
->ip_htable
, i
, tmp
, addr
, hnode
) {
406 if (addr
->disp_flag
== QETH_DISP_ADDR_DELETE
) {
407 qeth_l3_deregister_addr_entry(card
, addr
);
408 hash_del(&addr
->hnode
);
410 } else if (addr
->disp_flag
== QETH_DISP_ADDR_ADD
) {
411 if (addr
->proto
== QETH_PROT_IPV4
) {
412 addr
->in_progress
= 1;
413 spin_unlock_bh(&card
->ip_lock
);
414 rc
= qeth_l3_register_addr_entry(card
, addr
);
415 spin_lock_bh(&card
->ip_lock
);
416 addr
->in_progress
= 0;
418 rc
= qeth_l3_register_addr_entry(card
, addr
);
421 addr
->disp_flag
= QETH_DISP_ADDR_DO_NOTHING
;
422 if (addr
->ref_counter
< 1)
423 qeth_l3_delete_ip(card
, addr
);
425 hash_del(&addr
->hnode
);
431 spin_unlock_bh(&card
->ip_lock
);
435 static int qeth_l3_send_setdelmc(struct qeth_card
*card
,
436 struct qeth_ipaddr
*addr
, int ipacmd
)
439 struct qeth_cmd_buffer
*iob
;
440 struct qeth_ipa_cmd
*cmd
;
442 QETH_CARD_TEXT(card
, 4, "setdelmc");
444 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, addr
->proto
);
447 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
448 memcpy(&cmd
->data
.setdelipm
.mac
, addr
->mac
, OSA_ADDR_LEN
);
449 if (addr
->proto
== QETH_PROT_IPV6
)
450 memcpy(cmd
->data
.setdelipm
.ip6
, &addr
->u
.a6
.addr
,
451 sizeof(struct in6_addr
));
453 memcpy(&cmd
->data
.setdelipm
.ip4
, &addr
->u
.a4
.addr
, 4);
455 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
460 static void qeth_l3_fill_netmask(u8
*netmask
, unsigned int len
)
463 for (i
= 0; i
< 16; i
++) {
468 netmask
[i
] = (u8
)(0xFF00 >> j
);
474 static int qeth_l3_send_setdelip(struct qeth_card
*card
,
475 struct qeth_ipaddr
*addr
, int ipacmd
, unsigned int flags
)
478 struct qeth_cmd_buffer
*iob
;
479 struct qeth_ipa_cmd
*cmd
;
482 QETH_CARD_TEXT(card
, 4, "setdelip");
483 QETH_CARD_TEXT_(card
, 4, "flags%02X", flags
);
485 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, addr
->proto
);
488 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
489 if (addr
->proto
== QETH_PROT_IPV6
) {
490 memcpy(cmd
->data
.setdelip6
.ip_addr
, &addr
->u
.a6
.addr
,
491 sizeof(struct in6_addr
));
492 qeth_l3_fill_netmask(netmask
, addr
->u
.a6
.pfxlen
);
493 memcpy(cmd
->data
.setdelip6
.mask
, netmask
,
494 sizeof(struct in6_addr
));
495 cmd
->data
.setdelip6
.flags
= flags
;
497 memcpy(cmd
->data
.setdelip4
.ip_addr
, &addr
->u
.a4
.addr
, 4);
498 memcpy(cmd
->data
.setdelip4
.mask
, &addr
->u
.a4
.mask
, 4);
499 cmd
->data
.setdelip4
.flags
= flags
;
502 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
507 static int qeth_l3_send_setrouting(struct qeth_card
*card
,
508 enum qeth_routing_types type
, enum qeth_prot_versions prot
)
511 struct qeth_ipa_cmd
*cmd
;
512 struct qeth_cmd_buffer
*iob
;
514 QETH_CARD_TEXT(card
, 4, "setroutg");
515 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_SETRTG
, prot
);
518 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
519 cmd
->data
.setrtg
.type
= (type
);
520 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
525 static int qeth_l3_correct_routing_type(struct qeth_card
*card
,
526 enum qeth_routing_types
*type
, enum qeth_prot_versions prot
)
528 if (card
->info
.type
== QETH_CARD_TYPE_IQD
) {
531 case PRIMARY_CONNECTOR
:
532 case SECONDARY_CONNECTOR
:
533 case MULTICAST_ROUTER
:
542 case SECONDARY_ROUTER
:
544 case MULTICAST_ROUTER
:
545 if (qeth_is_ipafunc_supported(card
, prot
,
557 int qeth_l3_setrouting_v4(struct qeth_card
*card
)
561 QETH_CARD_TEXT(card
, 3, "setrtg4");
563 rc
= qeth_l3_correct_routing_type(card
, &card
->options
.route4
.type
,
568 rc
= qeth_l3_send_setrouting(card
, card
->options
.route4
.type
,
571 card
->options
.route4
.type
= NO_ROUTER
;
572 QETH_DBF_MESSAGE(2, "Error (0x%04x) while setting routing type"
573 " on %s. Type set to 'no router'.\n", rc
,
574 QETH_CARD_IFNAME(card
));
579 int qeth_l3_setrouting_v6(struct qeth_card
*card
)
583 QETH_CARD_TEXT(card
, 3, "setrtg6");
584 #ifdef CONFIG_QETH_IPV6
586 if (!qeth_is_supported(card
, IPA_IPV6
))
588 rc
= qeth_l3_correct_routing_type(card
, &card
->options
.route6
.type
,
593 rc
= qeth_l3_send_setrouting(card
, card
->options
.route6
.type
,
596 card
->options
.route6
.type
= NO_ROUTER
;
597 QETH_DBF_MESSAGE(2, "Error (0x%04x) while setting routing type"
598 " on %s. Type set to 'no router'.\n", rc
,
599 QETH_CARD_IFNAME(card
));
606 * IP address takeover related functions
608 static void qeth_l3_clear_ipato_list(struct qeth_card
*card
)
610 struct qeth_ipato_entry
*ipatoe
, *tmp
;
612 spin_lock_bh(&card
->ip_lock
);
614 list_for_each_entry_safe(ipatoe
, tmp
, &card
->ipato
.entries
, entry
) {
615 list_del(&ipatoe
->entry
);
619 spin_unlock_bh(&card
->ip_lock
);
622 int qeth_l3_add_ipato_entry(struct qeth_card
*card
,
623 struct qeth_ipato_entry
*new)
625 struct qeth_ipato_entry
*ipatoe
;
628 QETH_CARD_TEXT(card
, 2, "addipato");
630 spin_lock_bh(&card
->ip_lock
);
632 list_for_each_entry(ipatoe
, &card
->ipato
.entries
, entry
) {
633 if (ipatoe
->proto
!= new->proto
)
635 if (!memcmp(ipatoe
->addr
, new->addr
,
636 (ipatoe
->proto
== QETH_PROT_IPV4
)? 4:16) &&
637 (ipatoe
->mask_bits
== new->mask_bits
)) {
644 list_add_tail(&new->entry
, &card
->ipato
.entries
);
646 spin_unlock_bh(&card
->ip_lock
);
651 void qeth_l3_del_ipato_entry(struct qeth_card
*card
,
652 enum qeth_prot_versions proto
, u8
*addr
, int mask_bits
)
654 struct qeth_ipato_entry
*ipatoe
, *tmp
;
656 QETH_CARD_TEXT(card
, 2, "delipato");
658 spin_lock_bh(&card
->ip_lock
);
660 list_for_each_entry_safe(ipatoe
, tmp
, &card
->ipato
.entries
, entry
) {
661 if (ipatoe
->proto
!= proto
)
663 if (!memcmp(ipatoe
->addr
, addr
,
664 (proto
== QETH_PROT_IPV4
)? 4:16) &&
665 (ipatoe
->mask_bits
== mask_bits
)) {
666 list_del(&ipatoe
->entry
);
671 spin_unlock_bh(&card
->ip_lock
);
675 * VIPA related functions
677 int qeth_l3_add_vipa(struct qeth_card
*card
, enum qeth_prot_versions proto
,
680 struct qeth_ipaddr
*ipaddr
;
683 ipaddr
= qeth_l3_get_addr_buffer(proto
);
685 if (proto
== QETH_PROT_IPV4
) {
686 QETH_CARD_TEXT(card
, 2, "addvipa4");
687 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
688 ipaddr
->u
.a4
.mask
= 0;
689 } else if (proto
== QETH_PROT_IPV6
) {
690 QETH_CARD_TEXT(card
, 2, "addvipa6");
691 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
692 ipaddr
->u
.a6
.pfxlen
= 0;
694 ipaddr
->type
= QETH_IP_TYPE_VIPA
;
695 ipaddr
->set_flags
= QETH_IPA_SETIP_VIPA_FLAG
;
696 ipaddr
->del_flags
= QETH_IPA_DELIP_VIPA_FLAG
;
700 spin_lock_bh(&card
->ip_lock
);
702 if (qeth_l3_ip_from_hash(card
, ipaddr
))
705 qeth_l3_add_ip(card
, ipaddr
);
707 spin_unlock_bh(&card
->ip_lock
);
714 void qeth_l3_del_vipa(struct qeth_card
*card
, enum qeth_prot_versions proto
,
717 struct qeth_ipaddr
*ipaddr
;
719 ipaddr
= qeth_l3_get_addr_buffer(proto
);
721 if (proto
== QETH_PROT_IPV4
) {
722 QETH_CARD_TEXT(card
, 2, "delvipa4");
723 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
724 ipaddr
->u
.a4
.mask
= 0;
725 } else if (proto
== QETH_PROT_IPV6
) {
726 QETH_CARD_TEXT(card
, 2, "delvipa6");
727 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
728 ipaddr
->u
.a6
.pfxlen
= 0;
730 ipaddr
->type
= QETH_IP_TYPE_VIPA
;
734 spin_lock_bh(&card
->ip_lock
);
735 qeth_l3_delete_ip(card
, ipaddr
);
736 spin_unlock_bh(&card
->ip_lock
);
742 * proxy ARP related functions
744 int qeth_l3_add_rxip(struct qeth_card
*card
, enum qeth_prot_versions proto
,
747 struct qeth_ipaddr
*ipaddr
;
750 ipaddr
= qeth_l3_get_addr_buffer(proto
);
752 if (proto
== QETH_PROT_IPV4
) {
753 QETH_CARD_TEXT(card
, 2, "addrxip4");
754 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
755 ipaddr
->u
.a4
.mask
= 0;
756 } else if (proto
== QETH_PROT_IPV6
) {
757 QETH_CARD_TEXT(card
, 2, "addrxip6");
758 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
759 ipaddr
->u
.a6
.pfxlen
= 0;
762 ipaddr
->type
= QETH_IP_TYPE_RXIP
;
763 ipaddr
->set_flags
= QETH_IPA_SETIP_TAKEOVER_FLAG
;
764 ipaddr
->del_flags
= 0;
768 spin_lock_bh(&card
->ip_lock
);
770 if (qeth_l3_ip_from_hash(card
, ipaddr
))
773 qeth_l3_add_ip(card
, ipaddr
);
775 spin_unlock_bh(&card
->ip_lock
);
782 void qeth_l3_del_rxip(struct qeth_card
*card
, enum qeth_prot_versions proto
,
785 struct qeth_ipaddr
*ipaddr
;
787 ipaddr
= qeth_l3_get_addr_buffer(proto
);
789 if (proto
== QETH_PROT_IPV4
) {
790 QETH_CARD_TEXT(card
, 2, "delrxip4");
791 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
792 ipaddr
->u
.a4
.mask
= 0;
793 } else if (proto
== QETH_PROT_IPV6
) {
794 QETH_CARD_TEXT(card
, 2, "delrxip6");
795 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
796 ipaddr
->u
.a6
.pfxlen
= 0;
798 ipaddr
->type
= QETH_IP_TYPE_RXIP
;
802 spin_lock_bh(&card
->ip_lock
);
803 qeth_l3_delete_ip(card
, ipaddr
);
804 spin_unlock_bh(&card
->ip_lock
);
809 static int qeth_l3_register_addr_entry(struct qeth_card
*card
,
810 struct qeth_ipaddr
*addr
)
817 if (addr
->proto
== QETH_PROT_IPV4
) {
818 QETH_CARD_TEXT(card
, 2, "setaddr4");
819 QETH_CARD_HEX(card
, 3, &addr
->u
.a4
.addr
, sizeof(int));
820 } else if (addr
->proto
== QETH_PROT_IPV6
) {
821 QETH_CARD_TEXT(card
, 2, "setaddr6");
822 QETH_CARD_HEX(card
, 3, &addr
->u
.a6
.addr
, 8);
823 QETH_CARD_HEX(card
, 3, ((char *)&addr
->u
.a6
.addr
) + 8, 8);
825 QETH_CARD_TEXT(card
, 2, "setaddr?");
826 QETH_CARD_HEX(card
, 3, addr
, sizeof(struct qeth_ipaddr
));
829 if (addr
->is_multicast
)
830 rc
= qeth_l3_send_setdelmc(card
, addr
, IPA_CMD_SETIPM
);
832 rc
= qeth_l3_send_setdelip(card
, addr
, IPA_CMD_SETIP
,
835 QETH_CARD_TEXT(card
, 2, "failed");
836 } while ((--cnt
> 0) && rc
);
838 QETH_CARD_TEXT(card
, 2, "FAILED");
839 qeth_l3_ipaddr_to_string(addr
->proto
, (u8
*)&addr
->u
, buf
);
840 dev_warn(&card
->gdev
->dev
,
841 "Registering IP address %s failed\n", buf
);
846 static int qeth_l3_deregister_addr_entry(struct qeth_card
*card
,
847 struct qeth_ipaddr
*addr
)
851 if (addr
->proto
== QETH_PROT_IPV4
) {
852 QETH_CARD_TEXT(card
, 2, "deladdr4");
853 QETH_CARD_HEX(card
, 3, &addr
->u
.a4
.addr
, sizeof(int));
854 } else if (addr
->proto
== QETH_PROT_IPV6
) {
855 QETH_CARD_TEXT(card
, 2, "deladdr6");
856 QETH_CARD_HEX(card
, 3, &addr
->u
.a6
.addr
, 8);
857 QETH_CARD_HEX(card
, 3, ((char *)&addr
->u
.a6
.addr
) + 8, 8);
859 QETH_CARD_TEXT(card
, 2, "deladdr?");
860 QETH_CARD_HEX(card
, 3, addr
, sizeof(struct qeth_ipaddr
));
862 if (addr
->is_multicast
)
863 rc
= qeth_l3_send_setdelmc(card
, addr
, IPA_CMD_DELIPM
);
865 rc
= qeth_l3_send_setdelip(card
, addr
, IPA_CMD_DELIP
,
868 QETH_CARD_TEXT(card
, 2, "failed");
873 static u8
qeth_l3_get_qeth_hdr_flags4(int cast_type
)
875 if (cast_type
== RTN_MULTICAST
)
876 return QETH_CAST_MULTICAST
;
877 if (cast_type
== RTN_BROADCAST
)
878 return QETH_CAST_BROADCAST
;
879 return QETH_CAST_UNICAST
;
882 static u8
qeth_l3_get_qeth_hdr_flags6(int cast_type
)
884 u8 ct
= QETH_HDR_PASSTHRU
| QETH_HDR_IPV6
;
885 if (cast_type
== RTN_MULTICAST
)
886 return ct
| QETH_CAST_MULTICAST
;
887 if (cast_type
== RTN_ANYCAST
)
888 return ct
| QETH_CAST_ANYCAST
;
889 if (cast_type
== RTN_BROADCAST
)
890 return ct
| QETH_CAST_BROADCAST
;
891 return ct
| QETH_CAST_UNICAST
;
894 static int qeth_l3_setadapter_parms(struct qeth_card
*card
)
898 QETH_DBF_TEXT(SETUP
, 2, "setadprm");
900 if (qeth_adp_supported(card
, IPA_SETADP_ALTER_MAC_ADDRESS
)) {
901 rc
= qeth_setadpparms_change_macaddr(card
);
903 dev_warn(&card
->gdev
->dev
, "Reading the adapter MAC"
904 " address failed\n");
910 #ifdef CONFIG_QETH_IPV6
911 static int qeth_l3_send_simple_setassparms_ipv6(struct qeth_card
*card
,
912 enum qeth_ipa_funcs ipa_func
, __u16 cmd_code
)
915 struct qeth_cmd_buffer
*iob
;
917 QETH_CARD_TEXT(card
, 4, "simassp6");
918 iob
= qeth_get_setassparms_cmd(card
, ipa_func
, cmd_code
,
922 rc
= qeth_send_setassparms(card
, iob
, 0, 0,
923 qeth_setassparms_cb
, NULL
);
928 static int qeth_l3_start_ipa_arp_processing(struct qeth_card
*card
)
932 QETH_CARD_TEXT(card
, 3, "ipaarp");
934 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
935 dev_info(&card
->gdev
->dev
,
936 "ARP processing not supported on %s!\n",
937 QETH_CARD_IFNAME(card
));
940 rc
= qeth_send_simple_setassparms(card
, IPA_ARP_PROCESSING
,
941 IPA_CMD_ASS_START
, 0);
943 dev_warn(&card
->gdev
->dev
,
944 "Starting ARP processing support for %s failed\n",
945 QETH_CARD_IFNAME(card
));
950 static int qeth_l3_start_ipa_source_mac(struct qeth_card
*card
)
954 QETH_CARD_TEXT(card
, 3, "stsrcmac");
956 if (!qeth_is_supported(card
, IPA_SOURCE_MAC
)) {
957 dev_info(&card
->gdev
->dev
,
958 "Inbound source MAC-address not supported on %s\n",
959 QETH_CARD_IFNAME(card
));
963 rc
= qeth_send_simple_setassparms(card
, IPA_SOURCE_MAC
,
964 IPA_CMD_ASS_START
, 0);
966 dev_warn(&card
->gdev
->dev
,
967 "Starting source MAC-address support for %s failed\n",
968 QETH_CARD_IFNAME(card
));
972 static int qeth_l3_start_ipa_vlan(struct qeth_card
*card
)
976 QETH_CARD_TEXT(card
, 3, "strtvlan");
978 if (!qeth_is_supported(card
, IPA_FULL_VLAN
)) {
979 dev_info(&card
->gdev
->dev
,
980 "VLAN not supported on %s\n", QETH_CARD_IFNAME(card
));
984 rc
= qeth_send_simple_setassparms(card
, IPA_VLAN_PRIO
,
985 IPA_CMD_ASS_START
, 0);
987 dev_warn(&card
->gdev
->dev
,
988 "Starting VLAN support for %s failed\n",
989 QETH_CARD_IFNAME(card
));
991 dev_info(&card
->gdev
->dev
, "VLAN enabled\n");
996 static int qeth_l3_start_ipa_multicast(struct qeth_card
*card
)
1000 QETH_CARD_TEXT(card
, 3, "stmcast");
1002 if (!qeth_is_supported(card
, IPA_MULTICASTING
)) {
1003 dev_info(&card
->gdev
->dev
,
1004 "Multicast not supported on %s\n",
1005 QETH_CARD_IFNAME(card
));
1009 rc
= qeth_send_simple_setassparms(card
, IPA_MULTICASTING
,
1010 IPA_CMD_ASS_START
, 0);
1012 dev_warn(&card
->gdev
->dev
,
1013 "Starting multicast support for %s failed\n",
1014 QETH_CARD_IFNAME(card
));
1016 dev_info(&card
->gdev
->dev
, "Multicast enabled\n");
1017 card
->dev
->flags
|= IFF_MULTICAST
;
1022 #ifdef CONFIG_QETH_IPV6
1023 static int qeth_l3_softsetup_ipv6(struct qeth_card
*card
)
1027 QETH_CARD_TEXT(card
, 3, "softipv6");
1029 rc
= qeth_query_ipassists(card
, QETH_PROT_IPV6
);
1031 dev_err(&card
->gdev
->dev
,
1032 "Activating IPv6 support for %s failed\n",
1033 QETH_CARD_IFNAME(card
));
1037 if (card
->info
.type
== QETH_CARD_TYPE_IQD
)
1040 rc
= qeth_send_simple_setassparms(card
, IPA_IPV6
,
1041 IPA_CMD_ASS_START
, 3);
1043 dev_err(&card
->gdev
->dev
,
1044 "Activating IPv6 support for %s failed\n",
1045 QETH_CARD_IFNAME(card
));
1048 rc
= qeth_l3_send_simple_setassparms_ipv6(card
, IPA_IPV6
,
1051 dev_err(&card
->gdev
->dev
,
1052 "Activating IPv6 support for %s failed\n",
1053 QETH_CARD_IFNAME(card
));
1056 rc
= qeth_l3_send_simple_setassparms_ipv6(card
, IPA_PASSTHRU
,
1059 dev_warn(&card
->gdev
->dev
,
1060 "Enabling the passthrough mode for %s failed\n",
1061 QETH_CARD_IFNAME(card
));
1065 dev_info(&card
->gdev
->dev
, "IPV6 enabled\n");
1070 static int qeth_l3_start_ipa_ipv6(struct qeth_card
*card
)
1074 QETH_CARD_TEXT(card
, 3, "strtipv6");
1076 if (!qeth_is_supported(card
, IPA_IPV6
)) {
1077 dev_info(&card
->gdev
->dev
,
1078 "IPv6 not supported on %s\n", QETH_CARD_IFNAME(card
));
1081 #ifdef CONFIG_QETH_IPV6
1082 rc
= qeth_l3_softsetup_ipv6(card
);
1087 static int qeth_l3_start_ipa_broadcast(struct qeth_card
*card
)
1091 QETH_CARD_TEXT(card
, 3, "stbrdcst");
1092 card
->info
.broadcast_capable
= 0;
1093 if (!qeth_is_supported(card
, IPA_FILTERING
)) {
1094 dev_info(&card
->gdev
->dev
,
1095 "Broadcast not supported on %s\n",
1096 QETH_CARD_IFNAME(card
));
1100 rc
= qeth_send_simple_setassparms(card
, IPA_FILTERING
,
1101 IPA_CMD_ASS_START
, 0);
1103 dev_warn(&card
->gdev
->dev
, "Enabling broadcast filtering for "
1104 "%s failed\n", QETH_CARD_IFNAME(card
));
1108 rc
= qeth_send_simple_setassparms(card
, IPA_FILTERING
,
1109 IPA_CMD_ASS_CONFIGURE
, 1);
1111 dev_warn(&card
->gdev
->dev
,
1112 "Setting up broadcast filtering for %s failed\n",
1113 QETH_CARD_IFNAME(card
));
1116 card
->info
.broadcast_capable
= QETH_BROADCAST_WITH_ECHO
;
1117 dev_info(&card
->gdev
->dev
, "Broadcast enabled\n");
1118 rc
= qeth_send_simple_setassparms(card
, IPA_FILTERING
,
1119 IPA_CMD_ASS_ENABLE
, 1);
1121 dev_warn(&card
->gdev
->dev
, "Setting up broadcast echo "
1122 "filtering for %s failed\n", QETH_CARD_IFNAME(card
));
1125 card
->info
.broadcast_capable
= QETH_BROADCAST_WITHOUT_ECHO
;
1127 if (card
->info
.broadcast_capable
)
1128 card
->dev
->flags
|= IFF_BROADCAST
;
1130 card
->dev
->flags
&= ~IFF_BROADCAST
;
1134 static int qeth_l3_start_ipassists(struct qeth_card
*card
)
1136 QETH_CARD_TEXT(card
, 3, "strtipas");
1138 if (qeth_set_access_ctrl_online(card
, 0))
1140 qeth_l3_start_ipa_arp_processing(card
); /* go on*/
1141 qeth_l3_start_ipa_source_mac(card
); /* go on*/
1142 qeth_l3_start_ipa_vlan(card
); /* go on*/
1143 qeth_l3_start_ipa_multicast(card
); /* go on*/
1144 qeth_l3_start_ipa_ipv6(card
); /* go on*/
1145 qeth_l3_start_ipa_broadcast(card
); /* go on*/
1149 static int qeth_l3_iqd_read_initial_mac_cb(struct qeth_card
*card
,
1150 struct qeth_reply
*reply
, unsigned long data
)
1152 struct qeth_ipa_cmd
*cmd
;
1154 cmd
= (struct qeth_ipa_cmd
*) data
;
1155 if (cmd
->hdr
.return_code
== 0)
1156 memcpy(card
->dev
->dev_addr
,
1157 cmd
->data
.create_destroy_addr
.unique_id
, ETH_ALEN
);
1159 eth_random_addr(card
->dev
->dev_addr
);
1164 static int qeth_l3_iqd_read_initial_mac(struct qeth_card
*card
)
1167 struct qeth_cmd_buffer
*iob
;
1168 struct qeth_ipa_cmd
*cmd
;
1170 QETH_DBF_TEXT(SETUP
, 2, "hsrmac");
1172 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_CREATE_ADDR
,
1176 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
1177 *((__u16
*) &cmd
->data
.create_destroy_addr
.unique_id
[6]) =
1178 card
->info
.unique_id
;
1180 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_l3_iqd_read_initial_mac_cb
,
1185 static int qeth_l3_get_unique_id_cb(struct qeth_card
*card
,
1186 struct qeth_reply
*reply
, unsigned long data
)
1188 struct qeth_ipa_cmd
*cmd
;
1190 cmd
= (struct qeth_ipa_cmd
*) data
;
1191 if (cmd
->hdr
.return_code
== 0)
1192 card
->info
.unique_id
= *((__u16
*)
1193 &cmd
->data
.create_destroy_addr
.unique_id
[6]);
1195 card
->info
.unique_id
= UNIQUE_ID_IF_CREATE_ADDR_FAILED
|
1196 UNIQUE_ID_NOT_BY_CARD
;
1197 dev_warn(&card
->gdev
->dev
, "The network adapter failed to "
1198 "generate a unique ID\n");
1203 static int qeth_l3_get_unique_id(struct qeth_card
*card
)
1206 struct qeth_cmd_buffer
*iob
;
1207 struct qeth_ipa_cmd
*cmd
;
1209 QETH_DBF_TEXT(SETUP
, 2, "guniqeid");
1211 if (!qeth_is_supported(card
, IPA_IPV6
)) {
1212 card
->info
.unique_id
= UNIQUE_ID_IF_CREATE_ADDR_FAILED
|
1213 UNIQUE_ID_NOT_BY_CARD
;
1217 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_CREATE_ADDR
,
1221 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
1222 *((__u16
*) &cmd
->data
.create_destroy_addr
.unique_id
[6]) =
1223 card
->info
.unique_id
;
1225 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_l3_get_unique_id_cb
, NULL
);
1230 qeth_diags_trace_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
1233 struct qeth_ipa_cmd
*cmd
;
1236 QETH_DBF_TEXT(SETUP
, 2, "diastrcb");
1238 cmd
= (struct qeth_ipa_cmd
*)data
;
1239 rc
= cmd
->hdr
.return_code
;
1241 QETH_CARD_TEXT_(card
, 2, "dxter%x", rc
);
1242 switch (cmd
->data
.diagass
.action
) {
1243 case QETH_DIAGS_CMD_TRACE_QUERY
:
1245 case QETH_DIAGS_CMD_TRACE_DISABLE
:
1248 case IPA_RC_INVALID_SUBCMD
:
1249 card
->info
.promisc_mode
= SET_PROMISC_MODE_OFF
;
1250 dev_info(&card
->gdev
->dev
, "The HiperSockets network "
1251 "traffic analyzer is deactivated\n");
1257 case QETH_DIAGS_CMD_TRACE_ENABLE
:
1260 card
->info
.promisc_mode
= SET_PROMISC_MODE_ON
;
1261 dev_info(&card
->gdev
->dev
, "The HiperSockets network "
1262 "traffic analyzer is activated\n");
1264 case IPA_RC_HARDWARE_AUTH_ERROR
:
1265 dev_warn(&card
->gdev
->dev
, "The device is not "
1266 "authorized to run as a HiperSockets network "
1267 "traffic analyzer\n");
1269 case IPA_RC_TRACE_ALREADY_ACTIVE
:
1270 dev_warn(&card
->gdev
->dev
, "A HiperSockets "
1271 "network traffic analyzer is already "
1272 "active in the HiperSockets LAN\n");
1279 QETH_DBF_MESSAGE(2, "Unknown sniffer action (0x%04x) on %s\n",
1280 cmd
->data
.diagass
.action
, QETH_CARD_IFNAME(card
));
1287 qeth_diags_trace(struct qeth_card
*card
, enum qeth_diags_trace_cmds diags_cmd
)
1289 struct qeth_cmd_buffer
*iob
;
1290 struct qeth_ipa_cmd
*cmd
;
1292 QETH_DBF_TEXT(SETUP
, 2, "diagtrac");
1294 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_SET_DIAG_ASS
, 0);
1297 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
1298 cmd
->data
.diagass
.subcmd_len
= 16;
1299 cmd
->data
.diagass
.subcmd
= QETH_DIAGS_CMD_TRACE
;
1300 cmd
->data
.diagass
.type
= QETH_DIAGS_TYPE_HIPERSOCKET
;
1301 cmd
->data
.diagass
.action
= diags_cmd
;
1302 return qeth_send_ipa_cmd(card
, iob
, qeth_diags_trace_cb
, NULL
);
1305 static void qeth_l3_get_mac_for_ipm(__be32 ipm
, char *mac
)
1307 ip_eth_mc_map(ipm
, mac
);
1310 static void qeth_l3_mark_all_mc_to_be_deleted(struct qeth_card
*card
)
1312 struct qeth_ipaddr
*addr
;
1315 hash_for_each(card
->ip_mc_htable
, i
, addr
, hnode
)
1316 addr
->disp_flag
= QETH_DISP_ADDR_DELETE
;
1320 static void qeth_l3_add_all_new_mc(struct qeth_card
*card
)
1322 struct qeth_ipaddr
*addr
;
1323 struct hlist_node
*tmp
;
1327 hash_for_each_safe(card
->ip_mc_htable
, i
, tmp
, addr
, hnode
) {
1328 if (addr
->disp_flag
== QETH_DISP_ADDR_ADD
) {
1329 rc
= qeth_l3_register_addr_entry(card
, addr
);
1330 if (!rc
|| (rc
== IPA_RC_LAN_OFFLINE
))
1331 addr
->ref_counter
= 1;
1333 hash_del(&addr
->hnode
);
1341 static void qeth_l3_delete_nonused_mc(struct qeth_card
*card
)
1343 struct qeth_ipaddr
*addr
;
1344 struct hlist_node
*tmp
;
1348 hash_for_each_safe(card
->ip_mc_htable
, i
, tmp
, addr
, hnode
) {
1349 if (addr
->disp_flag
== QETH_DISP_ADDR_DELETE
) {
1350 rc
= qeth_l3_deregister_addr_entry(card
, addr
);
1351 if (!rc
|| (rc
== IPA_RC_MC_ADDR_NOT_FOUND
)) {
1352 hash_del(&addr
->hnode
);
1362 qeth_l3_add_mc_to_hash(struct qeth_card
*card
, struct in_device
*in4_dev
)
1364 struct ip_mc_list
*im4
;
1365 struct qeth_ipaddr
*tmp
, *ipm
;
1366 char buf
[MAX_ADDR_LEN
];
1368 QETH_CARD_TEXT(card
, 4, "addmc");
1370 tmp
= qeth_l3_get_addr_buffer(QETH_PROT_IPV4
);
1374 for (im4
= rcu_dereference(in4_dev
->mc_list
); im4
!= NULL
;
1375 im4
= rcu_dereference(im4
->next_rcu
)) {
1376 qeth_l3_get_mac_for_ipm(im4
->multiaddr
, buf
);
1378 tmp
->u
.a4
.addr
= be32_to_cpu(im4
->multiaddr
);
1379 memcpy(tmp
->mac
, buf
, sizeof(tmp
->mac
));
1380 tmp
->is_multicast
= 1;
1382 ipm
= qeth_l3_ip_from_hash(card
, tmp
);
1384 ipm
->disp_flag
= QETH_DISP_ADDR_DO_NOTHING
;
1386 ipm
= qeth_l3_get_addr_buffer(QETH_PROT_IPV4
);
1389 memcpy(ipm
->mac
, buf
, sizeof(tmp
->mac
));
1390 ipm
->u
.a4
.addr
= be32_to_cpu(im4
->multiaddr
);
1391 ipm
->is_multicast
= 1;
1392 ipm
->disp_flag
= QETH_DISP_ADDR_ADD
;
1393 hash_add(card
->ip_mc_htable
,
1394 &ipm
->hnode
, qeth_l3_ipaddr_hash(ipm
));
1401 /* called with rcu_read_lock */
1402 static void qeth_l3_add_vlan_mc(struct qeth_card
*card
)
1404 struct in_device
*in_dev
;
1407 QETH_CARD_TEXT(card
, 4, "addmcvl");
1409 if (!qeth_is_supported(card
, IPA_FULL_VLAN
))
1412 for_each_set_bit(vid
, card
->active_vlans
, VLAN_N_VID
) {
1413 struct net_device
*netdev
;
1415 netdev
= __vlan_find_dev_deep_rcu(card
->dev
, htons(ETH_P_8021Q
),
1417 if (netdev
== NULL
||
1418 !(netdev
->flags
& IFF_UP
))
1420 in_dev
= __in_dev_get_rcu(netdev
);
1423 qeth_l3_add_mc_to_hash(card
, in_dev
);
1427 static void qeth_l3_add_multicast_ipv4(struct qeth_card
*card
)
1429 struct in_device
*in4_dev
;
1431 QETH_CARD_TEXT(card
, 4, "chkmcv4");
1434 in4_dev
= __in_dev_get_rcu(card
->dev
);
1435 if (in4_dev
== NULL
)
1437 qeth_l3_add_mc_to_hash(card
, in4_dev
);
1438 qeth_l3_add_vlan_mc(card
);
1443 #ifdef CONFIG_QETH_IPV6
1445 qeth_l3_add_mc6_to_hash(struct qeth_card
*card
, struct inet6_dev
*in6_dev
)
1447 struct qeth_ipaddr
*ipm
;
1448 struct ifmcaddr6
*im6
;
1449 struct qeth_ipaddr
*tmp
;
1450 char buf
[MAX_ADDR_LEN
];
1452 QETH_CARD_TEXT(card
, 4, "addmc6");
1454 tmp
= qeth_l3_get_addr_buffer(QETH_PROT_IPV6
);
1458 for (im6
= in6_dev
->mc_list
; im6
!= NULL
; im6
= im6
->next
) {
1459 ndisc_mc_map(&im6
->mca_addr
, buf
, in6_dev
->dev
, 0);
1461 memcpy(tmp
->mac
, buf
, sizeof(tmp
->mac
));
1462 memcpy(&tmp
->u
.a6
.addr
, &im6
->mca_addr
.s6_addr
,
1463 sizeof(struct in6_addr
));
1464 tmp
->is_multicast
= 1;
1466 ipm
= qeth_l3_ip_from_hash(card
, tmp
);
1468 ipm
->disp_flag
= QETH_DISP_ADDR_DO_NOTHING
;
1472 ipm
= qeth_l3_get_addr_buffer(QETH_PROT_IPV6
);
1476 memcpy(ipm
->mac
, buf
, OSA_ADDR_LEN
);
1477 memcpy(&ipm
->u
.a6
.addr
, &im6
->mca_addr
.s6_addr
,
1478 sizeof(struct in6_addr
));
1479 ipm
->is_multicast
= 1;
1480 ipm
->disp_flag
= QETH_DISP_ADDR_ADD
;
1481 hash_add(card
->ip_mc_htable
,
1482 &ipm
->hnode
, qeth_l3_ipaddr_hash(ipm
));
1488 /* called with rcu_read_lock */
1489 static void qeth_l3_add_vlan_mc6(struct qeth_card
*card
)
1491 struct inet6_dev
*in_dev
;
1494 QETH_CARD_TEXT(card
, 4, "admc6vl");
1496 if (!qeth_is_supported(card
, IPA_FULL_VLAN
))
1499 for_each_set_bit(vid
, card
->active_vlans
, VLAN_N_VID
) {
1500 struct net_device
*netdev
;
1502 netdev
= __vlan_find_dev_deep_rcu(card
->dev
, htons(ETH_P_8021Q
),
1504 if (netdev
== NULL
||
1505 !(netdev
->flags
& IFF_UP
))
1507 in_dev
= in6_dev_get(netdev
);
1510 read_lock_bh(&in_dev
->lock
);
1511 qeth_l3_add_mc6_to_hash(card
, in_dev
);
1512 read_unlock_bh(&in_dev
->lock
);
1513 in6_dev_put(in_dev
);
1517 static void qeth_l3_add_multicast_ipv6(struct qeth_card
*card
)
1519 struct inet6_dev
*in6_dev
;
1521 QETH_CARD_TEXT(card
, 4, "chkmcv6");
1523 if (!qeth_is_supported(card
, IPA_IPV6
))
1525 in6_dev
= in6_dev_get(card
->dev
);
1530 read_lock_bh(&in6_dev
->lock
);
1531 qeth_l3_add_mc6_to_hash(card
, in6_dev
);
1532 qeth_l3_add_vlan_mc6(card
);
1533 read_unlock_bh(&in6_dev
->lock
);
1535 in6_dev_put(in6_dev
);
1537 #endif /* CONFIG_QETH_IPV6 */
1539 static void qeth_l3_free_vlan_addresses4(struct qeth_card
*card
,
1542 struct in_device
*in_dev
;
1543 struct in_ifaddr
*ifa
;
1544 struct qeth_ipaddr
*addr
;
1545 struct net_device
*netdev
;
1547 QETH_CARD_TEXT(card
, 4, "frvaddr4");
1549 netdev
= __vlan_find_dev_deep_rcu(card
->dev
, htons(ETH_P_8021Q
), vid
);
1552 in_dev
= in_dev_get(netdev
);
1556 addr
= qeth_l3_get_addr_buffer(QETH_PROT_IPV4
);
1560 spin_lock_bh(&card
->ip_lock
);
1562 for (ifa
= in_dev
->ifa_list
; ifa
; ifa
= ifa
->ifa_next
) {
1563 addr
->u
.a4
.addr
= be32_to_cpu(ifa
->ifa_address
);
1564 addr
->u
.a4
.mask
= be32_to_cpu(ifa
->ifa_mask
);
1565 addr
->type
= QETH_IP_TYPE_NORMAL
;
1566 qeth_l3_delete_ip(card
, addr
);
1569 spin_unlock_bh(&card
->ip_lock
);
1576 static void qeth_l3_free_vlan_addresses6(struct qeth_card
*card
,
1579 #ifdef CONFIG_QETH_IPV6
1580 struct inet6_dev
*in6_dev
;
1581 struct inet6_ifaddr
*ifa
;
1582 struct qeth_ipaddr
*addr
;
1583 struct net_device
*netdev
;
1585 QETH_CARD_TEXT(card
, 4, "frvaddr6");
1587 netdev
= __vlan_find_dev_deep_rcu(card
->dev
, htons(ETH_P_8021Q
), vid
);
1591 in6_dev
= in6_dev_get(netdev
);
1595 addr
= qeth_l3_get_addr_buffer(QETH_PROT_IPV6
);
1599 spin_lock_bh(&card
->ip_lock
);
1601 list_for_each_entry(ifa
, &in6_dev
->addr_list
, if_list
) {
1602 memcpy(&addr
->u
.a6
.addr
, &ifa
->addr
,
1603 sizeof(struct in6_addr
));
1604 addr
->u
.a6
.pfxlen
= ifa
->prefix_len
;
1605 addr
->type
= QETH_IP_TYPE_NORMAL
;
1606 qeth_l3_delete_ip(card
, addr
);
1609 spin_unlock_bh(&card
->ip_lock
);
1613 in6_dev_put(in6_dev
);
1614 #endif /* CONFIG_QETH_IPV6 */
1617 static void qeth_l3_free_vlan_addresses(struct qeth_card
*card
,
1621 qeth_l3_free_vlan_addresses4(card
, vid
);
1622 qeth_l3_free_vlan_addresses6(card
, vid
);
1626 static int qeth_l3_vlan_rx_add_vid(struct net_device
*dev
,
1627 __be16 proto
, u16 vid
)
1629 struct qeth_card
*card
= dev
->ml_priv
;
1631 set_bit(vid
, card
->active_vlans
);
1635 static int qeth_l3_vlan_rx_kill_vid(struct net_device
*dev
,
1636 __be16 proto
, u16 vid
)
1638 struct qeth_card
*card
= dev
->ml_priv
;
1640 QETH_CARD_TEXT_(card
, 4, "kid:%d", vid
);
1642 if (qeth_wait_for_threads(card
, QETH_RECOVER_THREAD
)) {
1643 QETH_CARD_TEXT(card
, 3, "kidREC");
1646 /* unregister IP addresses of vlan device */
1647 qeth_l3_free_vlan_addresses(card
, vid
);
1648 clear_bit(vid
, card
->active_vlans
);
1649 qeth_l3_set_multicast_list(card
->dev
);
1653 static void qeth_l3_rebuild_skb(struct qeth_card
*card
, struct sk_buff
*skb
,
1654 struct qeth_hdr
*hdr
)
1657 struct iphdr
*ip_hdr
;
1658 unsigned char tg_addr
[MAX_ADDR_LEN
];
1660 if (!(hdr
->hdr
.l3
.flags
& QETH_HDR_PASSTHRU
)) {
1661 prot
= (hdr
->hdr
.l3
.flags
& QETH_HDR_IPV6
) ? ETH_P_IPV6
:
1663 switch (hdr
->hdr
.l3
.flags
& QETH_HDR_CAST_MASK
) {
1664 case QETH_CAST_MULTICAST
:
1666 #ifdef CONFIG_QETH_IPV6
1668 ndisc_mc_map((struct in6_addr
*)
1670 tg_addr
, card
->dev
, 0);
1674 ip_hdr
= (struct iphdr
*)skb
->data
;
1675 ip_eth_mc_map(ip_hdr
->daddr
, tg_addr
);
1678 memcpy(tg_addr
, card
->dev
->broadcast
,
1679 card
->dev
->addr_len
);
1681 card
->stats
.multicast
++;
1682 skb
->pkt_type
= PACKET_MULTICAST
;
1684 case QETH_CAST_BROADCAST
:
1685 memcpy(tg_addr
, card
->dev
->broadcast
,
1686 card
->dev
->addr_len
);
1687 card
->stats
.multicast
++;
1688 skb
->pkt_type
= PACKET_BROADCAST
;
1690 case QETH_CAST_UNICAST
:
1691 case QETH_CAST_ANYCAST
:
1692 case QETH_CAST_NOCAST
:
1694 if (card
->options
.sniffer
)
1695 skb
->pkt_type
= PACKET_OTHERHOST
;
1697 skb
->pkt_type
= PACKET_HOST
;
1698 memcpy(tg_addr
, card
->dev
->dev_addr
,
1699 card
->dev
->addr_len
);
1701 if (hdr
->hdr
.l3
.ext_flags
& QETH_HDR_EXT_SRC_MAC_ADDR
)
1702 card
->dev
->header_ops
->create(skb
, card
->dev
, prot
,
1703 tg_addr
, &hdr
->hdr
.l3
.dest_addr
[2],
1704 card
->dev
->addr_len
);
1706 card
->dev
->header_ops
->create(skb
, card
->dev
, prot
,
1707 tg_addr
, "FAKELL", card
->dev
->addr_len
);
1710 skb
->protocol
= eth_type_trans(skb
, card
->dev
);
1712 /* copy VLAN tag from hdr into skb */
1713 if (!card
->options
.sniffer
&&
1714 (hdr
->hdr
.l3
.ext_flags
& (QETH_HDR_EXT_VLAN_FRAME
|
1715 QETH_HDR_EXT_INCLUDE_VLAN_TAG
))) {
1716 u16 tag
= (hdr
->hdr
.l3
.ext_flags
& QETH_HDR_EXT_VLAN_FRAME
) ?
1717 hdr
->hdr
.l3
.vlan_id
:
1718 *((u16
*)&hdr
->hdr
.l3
.dest_addr
[12]);
1719 __vlan_hwaccel_put_tag(skb
, htons(ETH_P_8021Q
), tag
);
1722 if (card
->dev
->features
& NETIF_F_RXCSUM
) {
1723 if ((hdr
->hdr
.l3
.ext_flags
&
1724 (QETH_HDR_EXT_CSUM_HDR_REQ
|
1725 QETH_HDR_EXT_CSUM_TRANSP_REQ
)) ==
1726 (QETH_HDR_EXT_CSUM_HDR_REQ
|
1727 QETH_HDR_EXT_CSUM_TRANSP_REQ
))
1728 skb
->ip_summed
= CHECKSUM_UNNECESSARY
;
1730 skb
->ip_summed
= CHECKSUM_NONE
;
1732 skb
->ip_summed
= CHECKSUM_NONE
;
1735 static int qeth_l3_process_inbound_buffer(struct qeth_card
*card
,
1736 int budget
, int *done
)
1739 struct sk_buff
*skb
;
1740 struct qeth_hdr
*hdr
;
1745 WARN_ON_ONCE(!budget
);
1747 skb
= qeth_core_get_next_skb(card
,
1748 &card
->qdio
.in_q
->bufs
[card
->rx
.b_index
],
1749 &card
->rx
.b_element
, &card
->rx
.e_offset
, &hdr
);
1754 skb
->dev
= card
->dev
;
1755 switch (hdr
->hdr
.l3
.id
) {
1756 case QETH_HEADER_TYPE_LAYER3
:
1757 magic
= *(__u16
*)skb
->data
;
1758 if ((card
->info
.type
== QETH_CARD_TYPE_IQD
) &&
1759 (magic
== ETH_P_AF_IUCV
)) {
1760 skb
->protocol
= cpu_to_be16(ETH_P_AF_IUCV
);
1761 skb
->pkt_type
= PACKET_HOST
;
1762 skb
->mac_header
= NET_SKB_PAD
;
1763 skb
->dev
= card
->dev
;
1765 card
->dev
->header_ops
->create(skb
, card
->dev
, 0,
1766 card
->dev
->dev_addr
, "FAKELL",
1767 card
->dev
->addr_len
);
1768 netif_receive_skb(skb
);
1770 qeth_l3_rebuild_skb(card
, skb
, hdr
);
1772 napi_gro_receive(&card
->napi
, skb
);
1775 case QETH_HEADER_TYPE_LAYER2
: /* for HiperSockets sniffer */
1776 skb
->pkt_type
= PACKET_HOST
;
1777 skb
->protocol
= eth_type_trans(skb
, skb
->dev
);
1779 netif_receive_skb(skb
);
1782 dev_kfree_skb_any(skb
);
1783 QETH_CARD_TEXT(card
, 3, "inbunkno");
1784 QETH_DBF_HEX(CTRL
, 3, hdr
, QETH_DBF_CTRL_LEN
);
1789 card
->stats
.rx_packets
++;
1790 card
->stats
.rx_bytes
+= len
;
1795 static int qeth_l3_verify_vlan_dev(struct net_device
*dev
,
1796 struct qeth_card
*card
)
1801 for_each_set_bit(vid
, card
->active_vlans
, VLAN_N_VID
) {
1802 struct net_device
*netdev
;
1805 netdev
= __vlan_find_dev_deep_rcu(card
->dev
, htons(ETH_P_8021Q
),
1808 if (netdev
== dev
) {
1809 rc
= QETH_VLAN_CARD
;
1814 if (rc
&& !(vlan_dev_real_dev(dev
)->ml_priv
== (void *)card
))
1820 static int qeth_l3_verify_dev(struct net_device
*dev
)
1822 struct qeth_card
*card
;
1824 unsigned long flags
;
1826 read_lock_irqsave(&qeth_core_card_list
.rwlock
, flags
);
1827 list_for_each_entry(card
, &qeth_core_card_list
.list
, list
) {
1828 if (card
->dev
== dev
) {
1829 rc
= QETH_REAL_CARD
;
1832 rc
= qeth_l3_verify_vlan_dev(dev
, card
);
1836 read_unlock_irqrestore(&qeth_core_card_list
.rwlock
, flags
);
1841 static struct qeth_card
*qeth_l3_get_card_from_dev(struct net_device
*dev
)
1843 struct qeth_card
*card
= NULL
;
1846 rc
= qeth_l3_verify_dev(dev
);
1847 if (rc
== QETH_REAL_CARD
)
1848 card
= dev
->ml_priv
;
1849 else if (rc
== QETH_VLAN_CARD
)
1850 card
= vlan_dev_real_dev(dev
)->ml_priv
;
1851 if (card
&& card
->options
.layer2
)
1854 QETH_CARD_TEXT_(card
, 4, "%d", rc
);
1858 static void qeth_l3_stop_card(struct qeth_card
*card
, int recovery_mode
)
1860 QETH_DBF_TEXT(SETUP
, 2, "stopcard");
1861 QETH_DBF_HEX(SETUP
, 2, &card
, sizeof(void *));
1863 qeth_set_allowed_threads(card
, 0, 1);
1864 if (card
->options
.sniffer
&&
1865 (card
->info
.promisc_mode
== SET_PROMISC_MODE_ON
))
1866 qeth_diags_trace(card
, QETH_DIAGS_CMD_TRACE_DISABLE
);
1867 if (card
->read
.state
== CH_STATE_UP
&&
1868 card
->write
.state
== CH_STATE_UP
&&
1869 (card
->state
== CARD_STATE_UP
)) {
1871 qeth_l3_stop(card
->dev
);
1874 dev_close(card
->dev
);
1877 card
->state
= CARD_STATE_SOFTSETUP
;
1879 if (card
->state
== CARD_STATE_SOFTSETUP
) {
1880 qeth_l3_clear_ip_htable(card
, 1);
1881 qeth_clear_ipacmd_list(card
);
1882 card
->state
= CARD_STATE_HARDSETUP
;
1884 if (card
->state
== CARD_STATE_HARDSETUP
) {
1885 qeth_qdio_clear_card(card
, 0);
1886 qeth_clear_qdio_buffers(card
);
1887 qeth_clear_working_pool_list(card
);
1888 card
->state
= CARD_STATE_DOWN
;
1890 if (card
->state
== CARD_STATE_DOWN
) {
1891 qeth_clear_cmd_buffers(&card
->read
);
1892 qeth_clear_cmd_buffers(&card
->write
);
1897 * test for and Switch promiscuous mode (on or off)
1898 * either for guestlan or HiperSocket Sniffer
1901 qeth_l3_handle_promisc_mode(struct qeth_card
*card
)
1903 struct net_device
*dev
= card
->dev
;
1905 if (((dev
->flags
& IFF_PROMISC
) &&
1906 (card
->info
.promisc_mode
== SET_PROMISC_MODE_ON
)) ||
1907 (!(dev
->flags
& IFF_PROMISC
) &&
1908 (card
->info
.promisc_mode
== SET_PROMISC_MODE_OFF
)))
1911 if (card
->info
.guestlan
) { /* Guestlan trace */
1912 if (qeth_adp_supported(card
, IPA_SETADP_SET_PROMISC_MODE
))
1913 qeth_setadp_promisc_mode(card
);
1914 } else if (card
->options
.sniffer
&& /* HiperSockets trace */
1915 qeth_adp_supported(card
, IPA_SETADP_SET_DIAG_ASSIST
)) {
1916 if (dev
->flags
& IFF_PROMISC
) {
1917 QETH_CARD_TEXT(card
, 3, "+promisc");
1918 qeth_diags_trace(card
, QETH_DIAGS_CMD_TRACE_ENABLE
);
1920 QETH_CARD_TEXT(card
, 3, "-promisc");
1921 qeth_diags_trace(card
, QETH_DIAGS_CMD_TRACE_DISABLE
);
1926 static void qeth_l3_set_multicast_list(struct net_device
*dev
)
1928 struct qeth_card
*card
= dev
->ml_priv
;
1930 QETH_CARD_TEXT(card
, 3, "setmulti");
1931 if (qeth_threads_running(card
, QETH_RECOVER_THREAD
) &&
1932 (card
->state
!= CARD_STATE_UP
))
1934 if (!card
->options
.sniffer
) {
1936 spin_lock_bh(&card
->mclock
);
1938 qeth_l3_mark_all_mc_to_be_deleted(card
);
1940 qeth_l3_add_multicast_ipv4(card
);
1941 #ifdef CONFIG_QETH_IPV6
1942 qeth_l3_add_multicast_ipv6(card
);
1944 qeth_l3_delete_nonused_mc(card
);
1945 qeth_l3_add_all_new_mc(card
);
1947 spin_unlock_bh(&card
->mclock
);
1949 if (!qeth_adp_supported(card
, IPA_SETADP_SET_PROMISC_MODE
))
1952 qeth_l3_handle_promisc_mode(card
);
1955 static const char *qeth_l3_arp_get_error_cause(int *rc
)
1958 case QETH_IPA_ARP_RC_FAILED
:
1960 return "operation failed";
1961 case QETH_IPA_ARP_RC_NOTSUPP
:
1963 return "operation not supported";
1964 case QETH_IPA_ARP_RC_OUT_OF_RANGE
:
1966 return "argument out of range";
1967 case QETH_IPA_ARP_RC_Q_NOTSUPP
:
1969 return "query operation not supported";
1970 case QETH_IPA_ARP_RC_Q_NO_DATA
:
1972 return "no query data available";
1974 return "unknown error";
1978 static int qeth_l3_arp_set_no_entries(struct qeth_card
*card
, int no_entries
)
1983 QETH_CARD_TEXT(card
, 3, "arpstnoe");
1986 * currently GuestLAN only supports the ARP assist function
1987 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_SET_NO_ENTRIES;
1988 * thus we say EOPNOTSUPP for this ARP function
1990 if (card
->info
.guestlan
)
1992 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
1995 rc
= qeth_send_simple_setassparms(card
, IPA_ARP_PROCESSING
,
1996 IPA_CMD_ASS_ARP_SET_NO_ENTRIES
,
2000 QETH_DBF_MESSAGE(2, "Could not set number of ARP entries on "
2001 "%s: %s (0x%x/%d)\n", QETH_CARD_IFNAME(card
),
2002 qeth_l3_arp_get_error_cause(&rc
), tmp
, tmp
);
2007 static __u32
get_arp_entry_size(struct qeth_card
*card
,
2008 struct qeth_arp_query_data
*qdata
,
2009 struct qeth_arp_entrytype
*type
, __u8 strip_entries
)
2014 is_hsi
= qdata
->reply_bits
== 5;
2015 if (type
->ip
== QETHARP_IP_ADDR_V4
) {
2016 QETH_CARD_TEXT(card
, 4, "arpev4");
2017 if (strip_entries
) {
2018 rc
= is_hsi
? sizeof(struct qeth_arp_qi_entry5_short
) :
2019 sizeof(struct qeth_arp_qi_entry7_short
);
2021 rc
= is_hsi
? sizeof(struct qeth_arp_qi_entry5
) :
2022 sizeof(struct qeth_arp_qi_entry7
);
2024 } else if (type
->ip
== QETHARP_IP_ADDR_V6
) {
2025 QETH_CARD_TEXT(card
, 4, "arpev6");
2026 if (strip_entries
) {
2028 sizeof(struct qeth_arp_qi_entry5_short_ipv6
) :
2029 sizeof(struct qeth_arp_qi_entry7_short_ipv6
);
2032 sizeof(struct qeth_arp_qi_entry5_ipv6
) :
2033 sizeof(struct qeth_arp_qi_entry7_ipv6
);
2036 QETH_CARD_TEXT(card
, 4, "arpinv");
2043 static int arpentry_matches_prot(struct qeth_arp_entrytype
*type
, __u16 prot
)
2045 return (type
->ip
== QETHARP_IP_ADDR_V4
&& prot
== QETH_PROT_IPV4
) ||
2046 (type
->ip
== QETHARP_IP_ADDR_V6
&& prot
== QETH_PROT_IPV6
);
2049 static int qeth_l3_arp_query_cb(struct qeth_card
*card
,
2050 struct qeth_reply
*reply
, unsigned long data
)
2052 struct qeth_ipa_cmd
*cmd
;
2053 struct qeth_arp_query_data
*qdata
;
2054 struct qeth_arp_query_info
*qinfo
;
2057 int entrybytes_done
;
2059 __u8 do_strip_entries
;
2061 QETH_CARD_TEXT(card
, 3, "arpquecb");
2063 qinfo
= (struct qeth_arp_query_info
*) reply
->param
;
2064 cmd
= (struct qeth_ipa_cmd
*) data
;
2065 QETH_CARD_TEXT_(card
, 4, "%i", cmd
->hdr
.prot_version
);
2066 if (cmd
->hdr
.return_code
) {
2067 QETH_CARD_TEXT(card
, 4, "arpcberr");
2068 QETH_CARD_TEXT_(card
, 4, "%i", cmd
->hdr
.return_code
);
2071 if (cmd
->data
.setassparms
.hdr
.return_code
) {
2072 cmd
->hdr
.return_code
= cmd
->data
.setassparms
.hdr
.return_code
;
2073 QETH_CARD_TEXT(card
, 4, "setaperr");
2074 QETH_CARD_TEXT_(card
, 4, "%i", cmd
->hdr
.return_code
);
2077 qdata
= &cmd
->data
.setassparms
.data
.query_arp
;
2078 QETH_CARD_TEXT_(card
, 4, "anoen%i", qdata
->no_entries
);
2080 do_strip_entries
= (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
) > 0;
2081 stripped_bytes
= do_strip_entries
? QETH_QARP_MEDIASPECIFIC_BYTES
: 0;
2082 entrybytes_done
= 0;
2083 for (e
= 0; e
< qdata
->no_entries
; ++e
) {
2086 struct qeth_arp_entrytype
*etype
;
2088 cur_entry
= &qdata
->data
+ entrybytes_done
;
2089 etype
= &((struct qeth_arp_qi_entry5
*) cur_entry
)->type
;
2090 if (!arpentry_matches_prot(etype
, cmd
->hdr
.prot_version
)) {
2091 QETH_CARD_TEXT(card
, 4, "pmis");
2092 QETH_CARD_TEXT_(card
, 4, "%i", etype
->ip
);
2095 esize
= get_arp_entry_size(card
, qdata
, etype
,
2097 QETH_CARD_TEXT_(card
, 5, "esz%i", esize
);
2101 if ((qinfo
->udata_len
- qinfo
->udata_offset
) < esize
) {
2102 QETH_CARD_TEXT_(card
, 4, "qaer3%i", -ENOMEM
);
2103 cmd
->hdr
.return_code
= IPA_RC_ENOMEM
;
2107 memcpy(qinfo
->udata
+ qinfo
->udata_offset
,
2108 &qdata
->data
+ entrybytes_done
+ stripped_bytes
,
2110 entrybytes_done
+= esize
+ stripped_bytes
;
2111 qinfo
->udata_offset
+= esize
;
2112 ++qinfo
->no_entries
;
2114 /* check if all replies received ... */
2115 if (cmd
->data
.setassparms
.hdr
.seq_no
<
2116 cmd
->data
.setassparms
.hdr
.number_of_replies
)
2118 QETH_CARD_TEXT_(card
, 4, "nove%i", qinfo
->no_entries
);
2119 memcpy(qinfo
->udata
, &qinfo
->no_entries
, 4);
2120 /* keep STRIP_ENTRIES flag so the user program can distinguish
2121 * stripped entries from normal ones */
2122 if (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
)
2123 qdata
->reply_bits
|= QETH_QARP_STRIP_ENTRIES
;
2124 memcpy(qinfo
->udata
+ QETH_QARP_MASK_OFFSET
, &qdata
->reply_bits
, 2);
2125 QETH_CARD_TEXT_(card
, 4, "rc%i", 0);
2129 memcpy(qinfo
->udata
, &i
, 4);
2133 static int qeth_l3_send_ipa_arp_cmd(struct qeth_card
*card
,
2134 struct qeth_cmd_buffer
*iob
, int len
,
2135 int (*reply_cb
)(struct qeth_card
*, struct qeth_reply
*,
2139 QETH_CARD_TEXT(card
, 4, "sendarp");
2141 memcpy(iob
->data
, IPA_PDU_HEADER
, IPA_PDU_HEADER_SIZE
);
2142 memcpy(QETH_IPA_CMD_DEST_ADDR(iob
->data
),
2143 &card
->token
.ulp_connection_r
, QETH_MPC_TOKEN_LENGTH
);
2144 return qeth_send_control_data(card
, IPA_PDU_HEADER_SIZE
+ len
, iob
,
2145 reply_cb
, reply_param
);
2148 static int qeth_l3_query_arp_cache_info(struct qeth_card
*card
,
2149 enum qeth_prot_versions prot
,
2150 struct qeth_arp_query_info
*qinfo
)
2152 struct qeth_cmd_buffer
*iob
;
2153 struct qeth_ipa_cmd
*cmd
;
2157 QETH_CARD_TEXT_(card
, 3, "qarpipv%i", prot
);
2159 iob
= qeth_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
2160 IPA_CMD_ASS_ARP_QUERY_INFO
,
2161 sizeof(struct qeth_arp_query_data
)
2166 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
2167 cmd
->data
.setassparms
.data
.query_arp
.request_bits
= 0x000F;
2168 cmd
->data
.setassparms
.data
.query_arp
.reply_bits
= 0;
2169 cmd
->data
.setassparms
.data
.query_arp
.no_entries
= 0;
2170 rc
= qeth_l3_send_ipa_arp_cmd(card
, iob
,
2171 QETH_SETASS_BASE_LEN
+QETH_ARP_CMD_LEN
,
2172 qeth_l3_arp_query_cb
, (void *)qinfo
);
2176 "Error while querying ARP cache on %s: %s "
2177 "(0x%x/%d)\n", QETH_CARD_IFNAME(card
),
2178 qeth_l3_arp_get_error_cause(&rc
), tmp
, tmp
);
2184 static int qeth_l3_arp_query(struct qeth_card
*card
, char __user
*udata
)
2186 struct qeth_arp_query_info qinfo
= {0, };
2189 QETH_CARD_TEXT(card
, 3, "arpquery");
2191 if (!qeth_is_supported(card
,/*IPA_QUERY_ARP_ADDR_INFO*/
2192 IPA_ARP_PROCESSING
)) {
2193 QETH_CARD_TEXT(card
, 3, "arpqnsup");
2197 /* get size of userspace buffer and mask_bits -> 6 bytes */
2198 if (copy_from_user(&qinfo
, udata
, 6)) {
2202 qinfo
.udata
= kzalloc(qinfo
.udata_len
, GFP_KERNEL
);
2207 qinfo
.udata_offset
= QETH_QARP_ENTRIES_OFFSET
;
2208 rc
= qeth_l3_query_arp_cache_info(card
, QETH_PROT_IPV4
, &qinfo
);
2210 if (copy_to_user(udata
, qinfo
.udata
, 4))
2214 #ifdef CONFIG_QETH_IPV6
2215 if (qinfo
.mask_bits
& QETH_QARP_WITH_IPV6
) {
2216 /* fails in case of GuestLAN QDIO mode */
2217 qeth_l3_query_arp_cache_info(card
, QETH_PROT_IPV6
, &qinfo
);
2220 if (copy_to_user(udata
, qinfo
.udata
, qinfo
.udata_len
)) {
2221 QETH_CARD_TEXT(card
, 4, "qactf");
2225 QETH_CARD_TEXT(card
, 4, "qacts");
2233 static int qeth_l3_arp_add_entry(struct qeth_card
*card
,
2234 struct qeth_arp_cache_entry
*entry
)
2236 struct qeth_cmd_buffer
*iob
;
2241 QETH_CARD_TEXT(card
, 3, "arpadent");
2244 * currently GuestLAN only supports the ARP assist function
2245 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_ADD_ENTRY;
2246 * thus we say EOPNOTSUPP for this ARP function
2248 if (card
->info
.guestlan
)
2250 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
2254 iob
= qeth_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
2255 IPA_CMD_ASS_ARP_ADD_ENTRY
,
2256 sizeof(struct qeth_arp_cache_entry
),
2260 rc
= qeth_send_setassparms(card
, iob
,
2261 sizeof(struct qeth_arp_cache_entry
),
2262 (unsigned long) entry
,
2263 qeth_setassparms_cb
, NULL
);
2266 qeth_l3_ipaddr4_to_string((u8
*)entry
->ipaddr
, buf
);
2267 QETH_DBF_MESSAGE(2, "Could not add ARP entry for address %s "
2268 "on %s: %s (0x%x/%d)\n", buf
, QETH_CARD_IFNAME(card
),
2269 qeth_l3_arp_get_error_cause(&rc
), tmp
, tmp
);
2274 static int qeth_l3_arp_remove_entry(struct qeth_card
*card
,
2275 struct qeth_arp_cache_entry
*entry
)
2277 struct qeth_cmd_buffer
*iob
;
2278 char buf
[16] = {0, };
2282 QETH_CARD_TEXT(card
, 3, "arprment");
2285 * currently GuestLAN only supports the ARP assist function
2286 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_REMOVE_ENTRY;
2287 * thus we say EOPNOTSUPP for this ARP function
2289 if (card
->info
.guestlan
)
2291 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
2294 memcpy(buf
, entry
, 12);
2295 iob
= qeth_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
2296 IPA_CMD_ASS_ARP_REMOVE_ENTRY
,
2301 rc
= qeth_send_setassparms(card
, iob
,
2302 12, (unsigned long)buf
,
2303 qeth_setassparms_cb
, NULL
);
2307 qeth_l3_ipaddr4_to_string((u8
*)entry
->ipaddr
, buf
);
2308 QETH_DBF_MESSAGE(2, "Could not delete ARP entry for address %s"
2309 " on %s: %s (0x%x/%d)\n", buf
, QETH_CARD_IFNAME(card
),
2310 qeth_l3_arp_get_error_cause(&rc
), tmp
, tmp
);
2315 static int qeth_l3_arp_flush_cache(struct qeth_card
*card
)
2320 QETH_CARD_TEXT(card
, 3, "arpflush");
2323 * currently GuestLAN only supports the ARP assist function
2324 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_FLUSH_CACHE;
2325 * thus we say EOPNOTSUPP for this ARP function
2327 if (card
->info
.guestlan
|| (card
->info
.type
== QETH_CARD_TYPE_IQD
))
2329 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
2332 rc
= qeth_send_simple_setassparms(card
, IPA_ARP_PROCESSING
,
2333 IPA_CMD_ASS_ARP_FLUSH_CACHE
, 0);
2336 QETH_DBF_MESSAGE(2, "Could not flush ARP cache on %s: %s "
2337 "(0x%x/%d)\n", QETH_CARD_IFNAME(card
),
2338 qeth_l3_arp_get_error_cause(&rc
), tmp
, tmp
);
2343 static int qeth_l3_do_ioctl(struct net_device
*dev
, struct ifreq
*rq
, int cmd
)
2345 struct qeth_card
*card
= dev
->ml_priv
;
2346 struct qeth_arp_cache_entry arp_entry
;
2350 case SIOC_QETH_ARP_SET_NO_ENTRIES
:
2351 if (!capable(CAP_NET_ADMIN
)) {
2355 rc
= qeth_l3_arp_set_no_entries(card
, rq
->ifr_ifru
.ifru_ivalue
);
2357 case SIOC_QETH_ARP_QUERY_INFO
:
2358 if (!capable(CAP_NET_ADMIN
)) {
2362 rc
= qeth_l3_arp_query(card
, rq
->ifr_ifru
.ifru_data
);
2364 case SIOC_QETH_ARP_ADD_ENTRY
:
2365 if (!capable(CAP_NET_ADMIN
)) {
2369 if (copy_from_user(&arp_entry
, rq
->ifr_ifru
.ifru_data
,
2370 sizeof(struct qeth_arp_cache_entry
)))
2373 rc
= qeth_l3_arp_add_entry(card
, &arp_entry
);
2375 case SIOC_QETH_ARP_REMOVE_ENTRY
:
2376 if (!capable(CAP_NET_ADMIN
)) {
2380 if (copy_from_user(&arp_entry
, rq
->ifr_ifru
.ifru_data
,
2381 sizeof(struct qeth_arp_cache_entry
)))
2384 rc
= qeth_l3_arp_remove_entry(card
, &arp_entry
);
2386 case SIOC_QETH_ARP_FLUSH_CACHE
:
2387 if (!capable(CAP_NET_ADMIN
)) {
2391 rc
= qeth_l3_arp_flush_cache(card
);
2399 static int qeth_l3_get_cast_type(struct qeth_card
*card
, struct sk_buff
*skb
)
2401 int cast_type
= RTN_UNSPEC
;
2402 struct neighbour
*n
= NULL
;
2403 struct dst_entry
*dst
;
2408 n
= dst_neigh_lookup_skb(dst
, skb
);
2410 cast_type
= n
->type
;
2413 if ((cast_type
== RTN_BROADCAST
) ||
2414 (cast_type
== RTN_MULTICAST
) ||
2415 (cast_type
== RTN_ANYCAST
))
2422 /* try something else */
2423 if (be16_to_cpu(skb
->protocol
) == ETH_P_IPV6
)
2424 return (skb_network_header(skb
)[24] == 0xff) ?
2426 else if (be16_to_cpu(skb
->protocol
) == ETH_P_IP
)
2427 return ((skb_network_header(skb
)[16] & 0xf0) == 0xe0) ?
2430 if (!memcmp(skb
->data
, skb
->dev
->broadcast
, 6))
2431 return RTN_BROADCAST
;
2435 hdr_mac
= *((u16
*)skb
->data
);
2437 switch (card
->info
.link_type
) {
2438 case QETH_LINK_TYPE_HSTR
:
2439 case QETH_LINK_TYPE_LANE_TR
:
2440 if ((hdr_mac
== QETH_TR_MAC_NC
) ||
2441 (hdr_mac
== QETH_TR_MAC_C
))
2442 return RTN_MULTICAST
;
2444 /* eth or so multicast? */
2446 if ((hdr_mac
== QETH_ETH_MAC_V4
) ||
2447 (hdr_mac
== QETH_ETH_MAC_V6
))
2448 return RTN_MULTICAST
;
2454 static void qeth_l3_fill_af_iucv_hdr(struct qeth_card
*card
,
2455 struct qeth_hdr
*hdr
, struct sk_buff
*skb
)
2458 struct af_iucv_trans_hdr
*iucv_hdr
;
2460 memset(hdr
, 0, sizeof(struct qeth_hdr
));
2461 hdr
->hdr
.l3
.id
= QETH_HEADER_TYPE_LAYER3
;
2462 hdr
->hdr
.l3
.ext_flags
= 0;
2463 hdr
->hdr
.l3
.length
= skb
->len
- ETH_HLEN
;
2464 hdr
->hdr
.l3
.flags
= QETH_HDR_IPV6
| QETH_CAST_UNICAST
;
2466 iucv_hdr
= (struct af_iucv_trans_hdr
*) (skb
->data
+ ETH_HLEN
);
2467 memset(daddr
, 0, sizeof(daddr
));
2470 memcpy(&daddr
[8], iucv_hdr
->destUserID
, 8);
2471 memcpy(hdr
->hdr
.l3
.dest_addr
, daddr
, 16);
2474 static void qeth_l3_fill_header(struct qeth_card
*card
, struct qeth_hdr
*hdr
,
2475 struct sk_buff
*skb
, int ipv
, int cast_type
)
2477 struct dst_entry
*dst
;
2479 memset(hdr
, 0, sizeof(struct qeth_hdr
));
2480 hdr
->hdr
.l3
.id
= QETH_HEADER_TYPE_LAYER3
;
2481 hdr
->hdr
.l3
.ext_flags
= 0;
2484 * before we're going to overwrite this location with next hop ip.
2485 * v6 uses passthrough, v4 sets the tag in the QDIO header.
2487 if (skb_vlan_tag_present(skb
)) {
2488 if ((ipv
== 4) || (card
->info
.type
== QETH_CARD_TYPE_IQD
))
2489 hdr
->hdr
.l3
.ext_flags
= QETH_HDR_EXT_VLAN_FRAME
;
2491 hdr
->hdr
.l3
.ext_flags
= QETH_HDR_EXT_INCLUDE_VLAN_TAG
;
2492 hdr
->hdr
.l3
.vlan_id
= skb_vlan_tag_get(skb
);
2495 hdr
->hdr
.l3
.length
= skb
->len
- sizeof(struct qeth_hdr
);
2500 struct rtable
*rt
= (struct rtable
*) dst
;
2501 __be32
*pkey
= &ip_hdr(skb
)->daddr
;
2503 if (rt
&& rt
->rt_gateway
)
2504 pkey
= &rt
->rt_gateway
;
2507 hdr
->hdr
.l3
.flags
= qeth_l3_get_qeth_hdr_flags4(cast_type
);
2508 memset(hdr
->hdr
.l3
.dest_addr
, 0, 12);
2509 *((__be32
*) (&hdr
->hdr
.l3
.dest_addr
[12])) = *pkey
;
2510 } else if (ipv
== 6) {
2511 struct rt6_info
*rt
= (struct rt6_info
*) dst
;
2512 struct in6_addr
*pkey
= &ipv6_hdr(skb
)->daddr
;
2514 if (rt
&& !ipv6_addr_any(&rt
->rt6i_gateway
))
2515 pkey
= &rt
->rt6i_gateway
;
2518 hdr
->hdr
.l3
.flags
= qeth_l3_get_qeth_hdr_flags6(cast_type
);
2519 if (card
->info
.type
== QETH_CARD_TYPE_IQD
)
2520 hdr
->hdr
.l3
.flags
&= ~QETH_HDR_PASSTHRU
;
2521 memcpy(hdr
->hdr
.l3
.dest_addr
, pkey
, 16);
2523 if (!memcmp(skb
->data
+ sizeof(struct qeth_hdr
),
2524 skb
->dev
->broadcast
, 6)) {
2526 hdr
->hdr
.l3
.flags
= QETH_CAST_BROADCAST
|
2529 hdr
->hdr
.l3
.flags
= (cast_type
== RTN_MULTICAST
) ?
2530 QETH_CAST_MULTICAST
| QETH_HDR_PASSTHRU
:
2531 QETH_CAST_UNICAST
| QETH_HDR_PASSTHRU
;
2537 static void qeth_l3_hdr_csum(struct qeth_card
*card
, struct qeth_hdr
*hdr
,
2538 struct sk_buff
*skb
)
2540 struct iphdr
*iph
= ip_hdr(skb
);
2542 /* tcph->check contains already the pseudo hdr checksum
2543 * so just set the header flags
2545 if (iph
->protocol
== IPPROTO_UDP
)
2546 hdr
->hdr
.l3
.ext_flags
|= QETH_HDR_EXT_UDP
;
2547 hdr
->hdr
.l3
.ext_flags
|= QETH_HDR_EXT_CSUM_TRANSP_REQ
|
2548 QETH_HDR_EXT_CSUM_HDR_REQ
;
2550 if (card
->options
.performance_stats
)
2551 card
->perf_stats
.tx_csum
++;
2554 static void qeth_tso_fill_header(struct qeth_card
*card
,
2555 struct qeth_hdr
*qhdr
, struct sk_buff
*skb
)
2557 struct qeth_hdr_tso
*hdr
= (struct qeth_hdr_tso
*)qhdr
;
2558 struct tcphdr
*tcph
= tcp_hdr(skb
);
2559 struct iphdr
*iph
= ip_hdr(skb
);
2560 struct ipv6hdr
*ip6h
= ipv6_hdr(skb
);
2562 /*fix header to TSO values ...*/
2563 hdr
->hdr
.hdr
.l3
.id
= QETH_HEADER_TYPE_TSO
;
2564 hdr
->hdr
.hdr
.l3
.length
= skb
->len
- sizeof(struct qeth_hdr_tso
);
2565 /*set values which are fix for the first approach ...*/
2566 hdr
->ext
.hdr_tot_len
= (__u16
) sizeof(struct qeth_hdr_ext_tso
);
2567 hdr
->ext
.imb_hdr_no
= 1;
2568 hdr
->ext
.hdr_type
= 1;
2569 hdr
->ext
.hdr_version
= 1;
2570 hdr
->ext
.hdr_len
= 28;
2571 /*insert non-fix values */
2572 hdr
->ext
.mss
= skb_shinfo(skb
)->gso_size
;
2573 hdr
->ext
.dg_hdr_len
= (__u16
)(ip_hdrlen(skb
) + tcp_hdrlen(skb
));
2574 hdr
->ext
.payload_len
= (__u16
)(skb
->len
- hdr
->ext
.dg_hdr_len
-
2575 sizeof(struct qeth_hdr_tso
));
2577 if (be16_to_cpu(skb
->protocol
) == ETH_P_IPV6
) {
2578 ip6h
->payload_len
= 0;
2579 tcph
->check
= ~csum_ipv6_magic(&ip6h
->saddr
, &ip6h
->daddr
,
2582 /*OSA want us to set these values ...*/
2583 tcph
->check
= ~csum_tcpudp_magic(iph
->saddr
, iph
->daddr
,
2591 * qeth_l3_get_elements_no_tso() - find number of SBALEs for skb data for tso
2592 * @card: qeth card structure, to check max. elems.
2594 * @extra_elems: extra elems needed, to check against max.
2596 * Returns the number of pages, and thus QDIO buffer elements, needed to cover
2597 * skb data, including linear part and fragments, but excluding TCP header.
2598 * (Exclusion of TCP header distinguishes it from qeth_get_elements_no().)
2599 * Checks if the result plus extra_elems fits under the limit for the card.
2600 * Returns 0 if it does not.
2601 * Note: extra_elems is not included in the returned result.
2603 static int qeth_l3_get_elements_no_tso(struct qeth_card
*card
,
2604 struct sk_buff
*skb
, int extra_elems
)
2606 addr_t tcpdptr
= (addr_t
)tcp_hdr(skb
) + tcp_hdrlen(skb
);
2607 int elements
= qeth_get_elements_for_range(
2609 (addr_t
)skb
->data
+ skb_headlen(skb
)) +
2610 qeth_get_elements_for_frags(skb
);
2612 if ((elements
+ extra_elems
) > QETH_MAX_BUFFER_ELEMENTS(card
)) {
2614 "Invalid size of TSO IP packet (Number=%d / Length=%d). Discarded.\n",
2615 elements
+ extra_elems
, skb
->len
);
2621 static netdev_tx_t
qeth_l3_hard_start_xmit(struct sk_buff
*skb
,
2622 struct net_device
*dev
)
2626 struct qeth_hdr
*hdr
= NULL
;
2627 int hdr_elements
= 0;
2629 struct qeth_card
*card
= dev
->ml_priv
;
2630 struct sk_buff
*new_skb
= NULL
;
2631 int ipv
= qeth_get_ip_version(skb
);
2632 int cast_type
= qeth_l3_get_cast_type(card
, skb
);
2633 struct qeth_qdio_out_q
*queue
=
2634 card
->qdio
.out_qs
[card
->qdio
.do_prio_queueing
2635 || (cast_type
&& card
->info
.is_multicast_different
) ?
2636 qeth_get_priority_queue(card
, skb
, ipv
, cast_type
) :
2637 card
->qdio
.default_out_queue
];
2638 int tx_bytes
= skb
->len
;
2639 unsigned int hd_len
= 0;
2641 int data_offset
= -1;
2642 unsigned int nr_frags
;
2644 if (((card
->info
.type
== QETH_CARD_TYPE_IQD
) &&
2645 (((card
->options
.cq
!= QETH_CQ_ENABLED
) && !ipv
) ||
2646 ((card
->options
.cq
== QETH_CQ_ENABLED
) &&
2647 (be16_to_cpu(skb
->protocol
) != ETH_P_AF_IUCV
)))) ||
2648 card
->options
.sniffer
)
2651 if ((card
->state
!= CARD_STATE_UP
) || !card
->lan_online
) {
2652 card
->stats
.tx_carrier_errors
++;
2656 if ((cast_type
== RTN_BROADCAST
) &&
2657 (card
->info
.broadcast_capable
== 0))
2660 if (card
->options
.performance_stats
) {
2661 card
->perf_stats
.outbound_cnt
++;
2662 card
->perf_stats
.outbound_start_time
= qeth_get_micros();
2665 /* Ignore segment size from skb_is_gso(), 1 page is always used. */
2666 use_tso
= skb_is_gso(skb
) &&
2667 (skb_shinfo(skb
)->gso_type
& SKB_GSO_TCPV4
);
2669 if (card
->info
.type
== QETH_CARD_TYPE_IQD
) {
2671 data_offset
= ETH_HLEN
;
2672 hd_len
= sizeof(*hdr
);
2673 hdr
= kmem_cache_alloc(qeth_core_header_cache
, GFP_ATOMIC
);
2678 /* create a clone with writeable headroom */
2679 new_skb
= skb_realloc_headroom(skb
, sizeof(struct qeth_hdr_tso
)
2685 skb_pull(new_skb
, ETH_HLEN
);
2688 if (ipv
!= 4 && skb_vlan_tag_present(new_skb
)) {
2689 skb_push(new_skb
, VLAN_HLEN
);
2690 skb_copy_to_linear_data(new_skb
, new_skb
->data
+ 4, 4);
2691 skb_copy_to_linear_data_offset(new_skb
, 4,
2692 new_skb
->data
+ 8, 4);
2693 skb_copy_to_linear_data_offset(new_skb
, 8,
2694 new_skb
->data
+ 12, 4);
2695 tag
= (__be16
*)(new_skb
->data
+ 12);
2696 *tag
= cpu_to_be16(ETH_P_8021Q
);
2697 *(tag
+ 1) = cpu_to_be16(skb_vlan_tag_get(new_skb
));
2701 netif_stop_queue(dev
);
2703 /* fix hardware limitation: as long as we do not have sbal
2704 * chaining we can not send long frag lists
2706 if ((card
->info
.type
!= QETH_CARD_TYPE_IQD
) &&
2707 ((use_tso
&& !qeth_l3_get_elements_no_tso(card
, new_skb
, 1)) ||
2708 (!use_tso
&& !qeth_get_elements_no(card
, new_skb
, 0, 0)))) {
2709 int lin_rc
= skb_linearize(new_skb
);
2711 if (card
->options
.performance_stats
) {
2713 card
->perf_stats
.tx_linfail
++;
2715 card
->perf_stats
.tx_lin
++;
2720 nr_frags
= skb_shinfo(new_skb
)->nr_frags
;
2723 hdr
= skb_push(new_skb
, sizeof(struct qeth_hdr_tso
));
2724 memset(hdr
, 0, sizeof(struct qeth_hdr_tso
));
2725 qeth_l3_fill_header(card
, hdr
, new_skb
, ipv
, cast_type
);
2726 qeth_tso_fill_header(card
, hdr
, new_skb
);
2729 if (data_offset
< 0) {
2730 hdr
= skb_push(new_skb
, sizeof(struct qeth_hdr
));
2731 qeth_l3_fill_header(card
, hdr
, new_skb
, ipv
,
2734 if (be16_to_cpu(new_skb
->protocol
) == ETH_P_AF_IUCV
)
2735 qeth_l3_fill_af_iucv_hdr(card
, hdr
, new_skb
);
2737 qeth_l3_fill_header(card
, hdr
, new_skb
, ipv
,
2739 hdr
->hdr
.l3
.length
= new_skb
->len
- data_offset
;
2743 if (skb
->ip_summed
== CHECKSUM_PARTIAL
)
2744 qeth_l3_hdr_csum(card
, hdr
, new_skb
);
2747 elements
= use_tso
?
2748 qeth_l3_get_elements_no_tso(card
, new_skb
, hdr_elements
) :
2749 qeth_get_elements_no(card
, new_skb
, hdr_elements
,
2750 (data_offset
> 0) ? data_offset
: 0);
2752 if (data_offset
>= 0)
2753 kmem_cache_free(qeth_core_header_cache
, hdr
);
2756 elements
+= hdr_elements
;
2758 if (card
->info
.type
!= QETH_CARD_TYPE_IQD
) {
2761 hd_len
= sizeof(struct qeth_hdr_tso
) +
2762 ip_hdrlen(new_skb
) + tcp_hdrlen(new_skb
);
2765 len
= sizeof(struct qeth_hdr_layer3
);
2768 if (qeth_hdr_chk_and_bounce(new_skb
, &hdr
, len
))
2770 rc
= qeth_do_send_packet(card
, queue
, new_skb
, hdr
, hd_len
,
2773 rc
= qeth_do_send_packet_fast(queue
, new_skb
, hdr
, data_offset
,
2777 card
->stats
.tx_packets
++;
2778 card
->stats
.tx_bytes
+= tx_bytes
;
2780 dev_kfree_skb_any(skb
);
2781 if (card
->options
.performance_stats
) {
2783 card
->perf_stats
.large_send_bytes
+= tx_bytes
;
2784 card
->perf_stats
.large_send_cnt
++;
2787 card
->perf_stats
.sg_skbs_sent
++;
2788 /* nr_frags + skb->data */
2789 card
->perf_stats
.sg_frags_sent
+= nr_frags
+ 1;
2794 if (data_offset
>= 0)
2795 kmem_cache_free(qeth_core_header_cache
, hdr
);
2799 dev_kfree_skb_any(new_skb
);
2800 return NETDEV_TX_BUSY
;
2805 netif_wake_queue(dev
);
2806 if (card
->options
.performance_stats
)
2807 card
->perf_stats
.outbound_time
+= qeth_get_micros() -
2808 card
->perf_stats
.outbound_start_time
;
2812 card
->stats
.tx_dropped
++;
2813 card
->stats
.tx_errors
++;
2814 if ((new_skb
!= skb
) && new_skb
)
2815 dev_kfree_skb_any(new_skb
);
2816 dev_kfree_skb_any(skb
);
2817 netif_wake_queue(dev
);
2818 return NETDEV_TX_OK
;
2821 static int __qeth_l3_open(struct net_device
*dev
)
2823 struct qeth_card
*card
= dev
->ml_priv
;
2826 QETH_CARD_TEXT(card
, 4, "qethopen");
2827 if (card
->state
== CARD_STATE_UP
)
2829 if (card
->state
!= CARD_STATE_SOFTSETUP
)
2831 card
->data
.state
= CH_STATE_UP
;
2832 card
->state
= CARD_STATE_UP
;
2833 netif_start_queue(dev
);
2835 if (qdio_stop_irq(card
->data
.ccwdev
, 0) >= 0) {
2836 napi_enable(&card
->napi
);
2837 napi_schedule(&card
->napi
);
2843 static int qeth_l3_open(struct net_device
*dev
)
2845 struct qeth_card
*card
= dev
->ml_priv
;
2847 QETH_CARD_TEXT(card
, 5, "qethope_");
2848 if (qeth_wait_for_threads(card
, QETH_RECOVER_THREAD
)) {
2849 QETH_CARD_TEXT(card
, 3, "openREC");
2850 return -ERESTARTSYS
;
2852 return __qeth_l3_open(dev
);
2855 static int qeth_l3_stop(struct net_device
*dev
)
2857 struct qeth_card
*card
= dev
->ml_priv
;
2859 QETH_CARD_TEXT(card
, 4, "qethstop");
2860 netif_tx_disable(dev
);
2861 if (card
->state
== CARD_STATE_UP
) {
2862 card
->state
= CARD_STATE_SOFTSETUP
;
2863 napi_disable(&card
->napi
);
2868 static const struct ethtool_ops qeth_l3_ethtool_ops
= {
2869 .get_link
= ethtool_op_get_link
,
2870 .get_strings
= qeth_core_get_strings
,
2871 .get_ethtool_stats
= qeth_core_get_ethtool_stats
,
2872 .get_sset_count
= qeth_core_get_sset_count
,
2873 .get_drvinfo
= qeth_core_get_drvinfo
,
2874 .get_link_ksettings
= qeth_core_ethtool_get_link_ksettings
,
2878 * we need NOARP for IPv4 but we want neighbor solicitation for IPv6. Setting
2879 * NOARP on the netdevice is no option because it also turns off neighbor
2880 * solicitation. For IPv4 we install a neighbor_setup function. We don't want
2881 * arp resolution but we want the hard header (packet socket will work
2884 static int qeth_l3_neigh_setup_noarp(struct neighbour
*n
)
2886 n
->nud_state
= NUD_NOARP
;
2887 memcpy(n
->ha
, "FAKELL", 6);
2888 n
->output
= n
->ops
->connected_output
;
2893 qeth_l3_neigh_setup(struct net_device
*dev
, struct neigh_parms
*np
)
2895 if (np
->tbl
->family
== AF_INET
)
2896 np
->neigh_setup
= qeth_l3_neigh_setup_noarp
;
2901 static const struct net_device_ops qeth_l3_netdev_ops
= {
2902 .ndo_open
= qeth_l3_open
,
2903 .ndo_stop
= qeth_l3_stop
,
2904 .ndo_get_stats
= qeth_get_stats
,
2905 .ndo_start_xmit
= qeth_l3_hard_start_xmit
,
2906 .ndo_validate_addr
= eth_validate_addr
,
2907 .ndo_set_rx_mode
= qeth_l3_set_multicast_list
,
2908 .ndo_do_ioctl
= qeth_do_ioctl
,
2909 .ndo_change_mtu
= qeth_change_mtu
,
2910 .ndo_fix_features
= qeth_fix_features
,
2911 .ndo_set_features
= qeth_set_features
,
2912 .ndo_vlan_rx_add_vid
= qeth_l3_vlan_rx_add_vid
,
2913 .ndo_vlan_rx_kill_vid
= qeth_l3_vlan_rx_kill_vid
,
2914 .ndo_tx_timeout
= qeth_tx_timeout
,
2917 static const struct net_device_ops qeth_l3_osa_netdev_ops
= {
2918 .ndo_open
= qeth_l3_open
,
2919 .ndo_stop
= qeth_l3_stop
,
2920 .ndo_get_stats
= qeth_get_stats
,
2921 .ndo_start_xmit
= qeth_l3_hard_start_xmit
,
2922 .ndo_features_check
= qeth_features_check
,
2923 .ndo_validate_addr
= eth_validate_addr
,
2924 .ndo_set_rx_mode
= qeth_l3_set_multicast_list
,
2925 .ndo_do_ioctl
= qeth_do_ioctl
,
2926 .ndo_change_mtu
= qeth_change_mtu
,
2927 .ndo_fix_features
= qeth_fix_features
,
2928 .ndo_set_features
= qeth_set_features
,
2929 .ndo_vlan_rx_add_vid
= qeth_l3_vlan_rx_add_vid
,
2930 .ndo_vlan_rx_kill_vid
= qeth_l3_vlan_rx_kill_vid
,
2931 .ndo_tx_timeout
= qeth_tx_timeout
,
2932 .ndo_neigh_setup
= qeth_l3_neigh_setup
,
2935 static int qeth_l3_setup_netdev(struct qeth_card
*card
)
2939 if (card
->info
.type
== QETH_CARD_TYPE_OSD
||
2940 card
->info
.type
== QETH_CARD_TYPE_OSX
) {
2941 if ((card
->info
.link_type
== QETH_LINK_TYPE_LANE_TR
) ||
2942 (card
->info
.link_type
== QETH_LINK_TYPE_HSTR
)) {
2943 pr_info("qeth_l3: ignoring TR device\n");
2946 card
->dev
= alloc_etherdev(0);
2949 card
->dev
->netdev_ops
= &qeth_l3_osa_netdev_ops
;
2951 /*IPv6 address autoconfiguration stuff*/
2952 qeth_l3_get_unique_id(card
);
2953 if (!(card
->info
.unique_id
& UNIQUE_ID_NOT_BY_CARD
))
2954 card
->dev
->dev_id
= card
->info
.unique_id
&
2956 if (!card
->info
.guestlan
) {
2957 card
->dev
->hw_features
= NETIF_F_SG
|
2958 NETIF_F_RXCSUM
| NETIF_F_IP_CSUM
|
2960 card
->dev
->vlan_features
= NETIF_F_SG
|
2961 NETIF_F_RXCSUM
| NETIF_F_IP_CSUM
|
2963 card
->dev
->features
|= NETIF_F_SG
;
2966 } else if (card
->info
.type
== QETH_CARD_TYPE_IQD
) {
2967 card
->dev
= alloc_netdev(0, "hsi%d", NET_NAME_UNKNOWN
,
2971 card
->dev
->flags
|= IFF_NOARP
;
2972 card
->dev
->netdev_ops
= &qeth_l3_netdev_ops
;
2973 rc
= qeth_l3_iqd_read_initial_mac(card
);
2976 if (card
->options
.hsuid
[0])
2977 memcpy(card
->dev
->perm_addr
, card
->options
.hsuid
, 9);
2981 card
->dev
->ml_priv
= card
;
2982 card
->dev
->watchdog_timeo
= QETH_TX_TIMEOUT
;
2983 card
->dev
->mtu
= card
->info
.initial_mtu
;
2984 card
->dev
->min_mtu
= 64;
2985 card
->dev
->max_mtu
= ETH_MAX_MTU
;
2986 card
->dev
->ethtool_ops
= &qeth_l3_ethtool_ops
;
2987 card
->dev
->features
|= NETIF_F_HW_VLAN_CTAG_TX
|
2988 NETIF_F_HW_VLAN_CTAG_RX
|
2989 NETIF_F_HW_VLAN_CTAG_FILTER
;
2990 netif_keep_dst(card
->dev
);
2991 netif_set_gso_max_size(card
->dev
, (QETH_MAX_BUFFER_ELEMENTS(card
) - 1) *
2994 SET_NETDEV_DEV(card
->dev
, &card
->gdev
->dev
);
2995 netif_napi_add(card
->dev
, &card
->napi
, qeth_poll
, QETH_NAPI_WEIGHT
);
2996 netif_carrier_off(card
->dev
);
2997 return register_netdev(card
->dev
);
3000 static const struct device_type qeth_l3_devtype
= {
3001 .name
= "qeth_layer3",
3002 .groups
= qeth_l3_attr_groups
,
3005 static int qeth_l3_probe_device(struct ccwgroup_device
*gdev
)
3007 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
3010 if (gdev
->dev
.type
== &qeth_generic_devtype
) {
3011 rc
= qeth_l3_create_device_attributes(&gdev
->dev
);
3015 hash_init(card
->ip_htable
);
3016 hash_init(card
->ip_mc_htable
);
3017 card
->options
.layer2
= 0;
3018 card
->info
.hwtrap
= 0;
3022 static void qeth_l3_remove_device(struct ccwgroup_device
*cgdev
)
3024 struct qeth_card
*card
= dev_get_drvdata(&cgdev
->dev
);
3026 if (cgdev
->dev
.type
== &qeth_generic_devtype
)
3027 qeth_l3_remove_device_attributes(&cgdev
->dev
);
3029 qeth_set_allowed_threads(card
, 0, 1);
3030 wait_event(card
->wait_q
, qeth_threads_running(card
, 0xffffffff) == 0);
3032 if (cgdev
->state
== CCWGROUP_ONLINE
)
3033 qeth_l3_set_offline(cgdev
);
3036 netif_napi_del(&card
->napi
);
3037 unregister_netdev(card
->dev
);
3041 qeth_l3_clear_ip_htable(card
, 0);
3042 qeth_l3_clear_ipato_list(card
);
3046 static int __qeth_l3_set_online(struct ccwgroup_device
*gdev
, int recovery_mode
)
3048 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
3050 enum qeth_card_states recover_flag
;
3052 mutex_lock(&card
->discipline_mutex
);
3053 mutex_lock(&card
->conf_mutex
);
3054 QETH_DBF_TEXT(SETUP
, 2, "setonlin");
3055 QETH_DBF_HEX(SETUP
, 2, &card
, sizeof(void *));
3057 recover_flag
= card
->state
;
3058 rc
= qeth_core_hardsetup_card(card
);
3060 QETH_DBF_TEXT_(SETUP
, 2, "2err%04x", rc
);
3065 if (!card
->dev
&& qeth_l3_setup_netdev(card
)) {
3070 if (qeth_is_diagass_supported(card
, QETH_DIAGS_CMD_TRAP
)) {
3071 if (card
->info
.hwtrap
&&
3072 qeth_hw_trap(card
, QETH_DIAGS_TRAP_ARM
))
3073 card
->info
.hwtrap
= 0;
3075 card
->info
.hwtrap
= 0;
3077 card
->state
= CARD_STATE_HARDSETUP
;
3078 memset(&card
->rx
, 0, sizeof(struct qeth_rx
));
3079 qeth_print_status_message(card
);
3082 QETH_DBF_TEXT(SETUP
, 2, "softsetp");
3084 rc
= qeth_l3_setadapter_parms(card
);
3086 QETH_DBF_TEXT_(SETUP
, 2, "2err%04x", rc
);
3087 if (!card
->options
.sniffer
) {
3088 rc
= qeth_l3_start_ipassists(card
);
3090 QETH_DBF_TEXT_(SETUP
, 2, "3err%d", rc
);
3093 rc
= qeth_l3_setrouting_v4(card
);
3095 QETH_DBF_TEXT_(SETUP
, 2, "4err%04x", rc
);
3096 rc
= qeth_l3_setrouting_v6(card
);
3098 QETH_DBF_TEXT_(SETUP
, 2, "5err%04x", rc
);
3100 netif_tx_disable(card
->dev
);
3102 rc
= qeth_init_qdio_queues(card
);
3104 QETH_DBF_TEXT_(SETUP
, 2, "6err%d", rc
);
3108 card
->state
= CARD_STATE_SOFTSETUP
;
3110 qeth_set_allowed_threads(card
, 0xffffffff, 0);
3111 qeth_l3_recover_ip(card
);
3112 if (card
->lan_online
)
3113 netif_carrier_on(card
->dev
);
3115 netif_carrier_off(card
->dev
);
3116 if (recover_flag
== CARD_STATE_RECOVER
) {
3119 __qeth_l3_open(card
->dev
);
3121 dev_open(card
->dev
);
3122 qeth_l3_set_multicast_list(card
->dev
);
3123 qeth_recover_features(card
->dev
);
3126 qeth_trace_features(card
);
3127 /* let user_space know that device is online */
3128 kobject_uevent(&gdev
->dev
.kobj
, KOBJ_CHANGE
);
3129 mutex_unlock(&card
->conf_mutex
);
3130 mutex_unlock(&card
->discipline_mutex
);
3133 qeth_l3_stop_card(card
, 0);
3134 ccw_device_set_offline(CARD_DDEV(card
));
3135 ccw_device_set_offline(CARD_WDEV(card
));
3136 ccw_device_set_offline(CARD_RDEV(card
));
3137 qdio_free(CARD_DDEV(card
));
3138 if (recover_flag
== CARD_STATE_RECOVER
)
3139 card
->state
= CARD_STATE_RECOVER
;
3141 card
->state
= CARD_STATE_DOWN
;
3142 mutex_unlock(&card
->conf_mutex
);
3143 mutex_unlock(&card
->discipline_mutex
);
3147 static int qeth_l3_set_online(struct ccwgroup_device
*gdev
)
3149 return __qeth_l3_set_online(gdev
, 0);
3152 static int __qeth_l3_set_offline(struct ccwgroup_device
*cgdev
,
3155 struct qeth_card
*card
= dev_get_drvdata(&cgdev
->dev
);
3156 int rc
= 0, rc2
= 0, rc3
= 0;
3157 enum qeth_card_states recover_flag
;
3159 mutex_lock(&card
->discipline_mutex
);
3160 mutex_lock(&card
->conf_mutex
);
3161 QETH_DBF_TEXT(SETUP
, 3, "setoffl");
3162 QETH_DBF_HEX(SETUP
, 3, &card
, sizeof(void *));
3164 if (card
->dev
&& netif_carrier_ok(card
->dev
))
3165 netif_carrier_off(card
->dev
);
3166 recover_flag
= card
->state
;
3167 if ((!recovery_mode
&& card
->info
.hwtrap
) || card
->info
.hwtrap
== 2) {
3168 qeth_hw_trap(card
, QETH_DIAGS_TRAP_DISARM
);
3169 card
->info
.hwtrap
= 1;
3171 qeth_l3_stop_card(card
, recovery_mode
);
3172 if ((card
->options
.cq
== QETH_CQ_ENABLED
) && card
->dev
) {
3174 call_netdevice_notifiers(NETDEV_REBOOT
, card
->dev
);
3177 rc
= ccw_device_set_offline(CARD_DDEV(card
));
3178 rc2
= ccw_device_set_offline(CARD_WDEV(card
));
3179 rc3
= ccw_device_set_offline(CARD_RDEV(card
));
3181 rc
= (rc2
) ? rc2
: rc3
;
3183 QETH_DBF_TEXT_(SETUP
, 2, "1err%d", rc
);
3184 qdio_free(CARD_DDEV(card
));
3185 if (recover_flag
== CARD_STATE_UP
)
3186 card
->state
= CARD_STATE_RECOVER
;
3187 /* let user_space know that device is offline */
3188 kobject_uevent(&cgdev
->dev
.kobj
, KOBJ_CHANGE
);
3189 mutex_unlock(&card
->conf_mutex
);
3190 mutex_unlock(&card
->discipline_mutex
);
3194 static int qeth_l3_set_offline(struct ccwgroup_device
*cgdev
)
3196 return __qeth_l3_set_offline(cgdev
, 0);
3199 static int qeth_l3_recover(void *ptr
)
3201 struct qeth_card
*card
;
3204 card
= (struct qeth_card
*) ptr
;
3205 QETH_CARD_TEXT(card
, 2, "recover1");
3206 QETH_CARD_HEX(card
, 2, &card
, sizeof(void *));
3207 if (!qeth_do_run_thread(card
, QETH_RECOVER_THREAD
))
3209 QETH_CARD_TEXT(card
, 2, "recover2");
3210 dev_warn(&card
->gdev
->dev
,
3211 "A recovery process has been started for the device\n");
3212 qeth_set_recovery_task(card
);
3213 __qeth_l3_set_offline(card
->gdev
, 1);
3214 rc
= __qeth_l3_set_online(card
->gdev
, 1);
3216 dev_info(&card
->gdev
->dev
,
3217 "Device successfully recovered!\n");
3219 qeth_close_dev(card
);
3220 dev_warn(&card
->gdev
->dev
, "The qeth device driver "
3221 "failed to recover an error on the device\n");
3223 qeth_clear_recovery_task(card
);
3224 qeth_clear_thread_start_bit(card
, QETH_RECOVER_THREAD
);
3225 qeth_clear_thread_running_bit(card
, QETH_RECOVER_THREAD
);
3229 static int qeth_l3_pm_suspend(struct ccwgroup_device
*gdev
)
3231 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
3234 netif_device_detach(card
->dev
);
3235 qeth_set_allowed_threads(card
, 0, 1);
3236 wait_event(card
->wait_q
, qeth_threads_running(card
, 0xffffffff) == 0);
3237 if (gdev
->state
== CCWGROUP_OFFLINE
)
3239 if (card
->state
== CARD_STATE_UP
) {
3240 if (card
->info
.hwtrap
)
3241 qeth_hw_trap(card
, QETH_DIAGS_TRAP_DISARM
);
3242 __qeth_l3_set_offline(card
->gdev
, 1);
3244 __qeth_l3_set_offline(card
->gdev
, 0);
3248 static int qeth_l3_pm_resume(struct ccwgroup_device
*gdev
)
3250 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
3253 if (gdev
->state
== CCWGROUP_OFFLINE
)
3256 if (card
->state
== CARD_STATE_RECOVER
) {
3257 rc
= __qeth_l3_set_online(card
->gdev
, 1);
3260 dev_close(card
->dev
);
3264 rc
= __qeth_l3_set_online(card
->gdev
, 0);
3266 qeth_set_allowed_threads(card
, 0xffffffff, 0);
3268 netif_device_attach(card
->dev
);
3270 dev_warn(&card
->gdev
->dev
, "The qeth device driver "
3271 "failed to recover an error on the device\n");
3275 /* Returns zero if the command is successfully "consumed" */
3276 static int qeth_l3_control_event(struct qeth_card
*card
,
3277 struct qeth_ipa_cmd
*cmd
)
3282 struct qeth_discipline qeth_l3_discipline
= {
3283 .devtype
= &qeth_l3_devtype
,
3284 .start_poll
= qeth_qdio_start_poll
,
3285 .input_handler
= (qdio_handler_t
*) qeth_qdio_input_handler
,
3286 .output_handler
= (qdio_handler_t
*) qeth_qdio_output_handler
,
3287 .process_rx_buffer
= qeth_l3_process_inbound_buffer
,
3288 .recover
= qeth_l3_recover
,
3289 .setup
= qeth_l3_probe_device
,
3290 .remove
= qeth_l3_remove_device
,
3291 .set_online
= qeth_l3_set_online
,
3292 .set_offline
= qeth_l3_set_offline
,
3293 .freeze
= qeth_l3_pm_suspend
,
3294 .thaw
= qeth_l3_pm_resume
,
3295 .restore
= qeth_l3_pm_resume
,
3296 .do_ioctl
= qeth_l3_do_ioctl
,
3297 .control_event_handler
= qeth_l3_control_event
,
3299 EXPORT_SYMBOL_GPL(qeth_l3_discipline
);
3301 static int qeth_l3_ip_event(struct notifier_block
*this,
3302 unsigned long event
, void *ptr
)
3305 struct in_ifaddr
*ifa
= (struct in_ifaddr
*)ptr
;
3306 struct net_device
*dev
= (struct net_device
*)ifa
->ifa_dev
->dev
;
3307 struct qeth_ipaddr
*addr
;
3308 struct qeth_card
*card
;
3310 if (dev_net(dev
) != &init_net
)
3313 card
= qeth_l3_get_card_from_dev(dev
);
3316 QETH_CARD_TEXT(card
, 3, "ipevent");
3318 addr
= qeth_l3_get_addr_buffer(QETH_PROT_IPV4
);
3320 addr
->u
.a4
.addr
= be32_to_cpu(ifa
->ifa_address
);
3321 addr
->u
.a4
.mask
= be32_to_cpu(ifa
->ifa_mask
);
3322 addr
->type
= QETH_IP_TYPE_NORMAL
;
3328 spin_lock_bh(&card
->ip_lock
);
3329 qeth_l3_add_ip(card
, addr
);
3330 spin_unlock_bh(&card
->ip_lock
);
3333 spin_lock_bh(&card
->ip_lock
);
3334 qeth_l3_delete_ip(card
, addr
);
3335 spin_unlock_bh(&card
->ip_lock
);
3343 static struct notifier_block qeth_l3_ip_notifier
= {
3348 #ifdef CONFIG_QETH_IPV6
3350 * IPv6 event handler
3352 static int qeth_l3_ip6_event(struct notifier_block
*this,
3353 unsigned long event
, void *ptr
)
3355 struct inet6_ifaddr
*ifa
= (struct inet6_ifaddr
*)ptr
;
3356 struct net_device
*dev
= (struct net_device
*)ifa
->idev
->dev
;
3357 struct qeth_ipaddr
*addr
;
3358 struct qeth_card
*card
;
3360 card
= qeth_l3_get_card_from_dev(dev
);
3363 QETH_CARD_TEXT(card
, 3, "ip6event");
3364 if (!qeth_is_supported(card
, IPA_IPV6
))
3367 addr
= qeth_l3_get_addr_buffer(QETH_PROT_IPV6
);
3369 memcpy(&addr
->u
.a6
.addr
, &ifa
->addr
, sizeof(struct in6_addr
));
3370 addr
->u
.a6
.pfxlen
= ifa
->prefix_len
;
3371 addr
->type
= QETH_IP_TYPE_NORMAL
;
3377 spin_lock_bh(&card
->ip_lock
);
3378 qeth_l3_add_ip(card
, addr
);
3379 spin_unlock_bh(&card
->ip_lock
);
3382 spin_lock_bh(&card
->ip_lock
);
3383 qeth_l3_delete_ip(card
, addr
);
3384 spin_unlock_bh(&card
->ip_lock
);
3392 static struct notifier_block qeth_l3_ip6_notifier
= {
3398 static int qeth_l3_register_notifiers(void)
3402 QETH_DBF_TEXT(SETUP
, 5, "regnotif");
3403 rc
= register_inetaddr_notifier(&qeth_l3_ip_notifier
);
3406 #ifdef CONFIG_QETH_IPV6
3407 rc
= register_inet6addr_notifier(&qeth_l3_ip6_notifier
);
3409 unregister_inetaddr_notifier(&qeth_l3_ip_notifier
);
3413 pr_warn("There is no IPv6 support for the layer 3 discipline\n");
3418 static void qeth_l3_unregister_notifiers(void)
3421 QETH_DBF_TEXT(SETUP
, 5, "unregnot");
3422 WARN_ON(unregister_inetaddr_notifier(&qeth_l3_ip_notifier
));
3423 #ifdef CONFIG_QETH_IPV6
3424 WARN_ON(unregister_inet6addr_notifier(&qeth_l3_ip6_notifier
));
3425 #endif /* QETH_IPV6 */
3428 static int __init
qeth_l3_init(void)
3432 pr_info("register layer 3 discipline\n");
3433 rc
= qeth_l3_register_notifiers();
3437 static void __exit
qeth_l3_exit(void)
3439 qeth_l3_unregister_notifiers();
3440 pr_info("unregister layer 3 discipline\n");
3443 module_init(qeth_l3_init
);
3444 module_exit(qeth_l3_exit
);
3445 MODULE_AUTHOR("Frank Blaschka <frank.blaschka@de.ibm.com>");
3446 MODULE_DESCRIPTION("qeth layer 3 discipline");
3447 MODULE_LICENSE("GPL");