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>
22 #include <linux/ipv6.h>
23 #include <linux/inetdevice.h>
24 #include <linux/igmp.h>
25 #include <linux/slab.h>
26 #include <linux/if_ether.h>
27 #include <linux/if_vlan.h>
28 #include <linux/skbuff.h>
32 #include <net/route.h>
34 #include <net/ip6_route.h>
35 #include <net/ip6_fib.h>
36 #include <net/iucv/af_iucv.h>
37 #include <linux/hashtable.h>
42 static int qeth_l3_set_offline(struct ccwgroup_device
*);
43 static void qeth_l3_set_rx_mode(struct net_device
*dev
);
44 static int qeth_l3_register_addr_entry(struct qeth_card
*,
45 struct qeth_ipaddr
*);
46 static int qeth_l3_deregister_addr_entry(struct qeth_card
*,
47 struct qeth_ipaddr
*);
49 static void qeth_l3_ipaddr4_to_string(const __u8
*addr
, char *buf
)
51 sprintf(buf
, "%pI4", addr
);
54 static void qeth_l3_ipaddr6_to_string(const __u8
*addr
, char *buf
)
56 sprintf(buf
, "%pI6", addr
);
59 void qeth_l3_ipaddr_to_string(enum qeth_prot_versions proto
, const __u8
*addr
,
62 if (proto
== QETH_PROT_IPV4
)
63 qeth_l3_ipaddr4_to_string(addr
, buf
);
64 else if (proto
== QETH_PROT_IPV6
)
65 qeth_l3_ipaddr6_to_string(addr
, buf
);
68 static struct qeth_ipaddr
*qeth_l3_get_addr_buffer(enum qeth_prot_versions prot
)
70 struct qeth_ipaddr
*addr
= kmalloc(sizeof(*addr
), GFP_ATOMIC
);
73 qeth_l3_init_ipaddr(addr
, QETH_IP_TYPE_NORMAL
, prot
);
77 static struct qeth_ipaddr
*qeth_l3_find_addr_by_ip(struct qeth_card
*card
,
78 struct qeth_ipaddr
*query
)
80 u64 key
= qeth_l3_ipaddr_hash(query
);
81 struct qeth_ipaddr
*addr
;
83 if (query
->is_multicast
) {
84 hash_for_each_possible(card
->ip_mc_htable
, addr
, hnode
, key
)
85 if (qeth_l3_addr_match_ip(addr
, query
))
88 hash_for_each_possible(card
->ip_htable
, addr
, hnode
, key
)
89 if (qeth_l3_addr_match_ip(addr
, query
))
95 static void qeth_l3_convert_addr_to_bits(u8
*addr
, u8
*bits
, int len
)
100 for (i
= 0; i
< len
; ++i
) {
102 for (j
= 7; j
>= 0; --j
) {
103 bits
[i
*8 + j
] = octet
& 1;
109 static bool qeth_l3_is_addr_covered_by_ipato(struct qeth_card
*card
,
110 struct qeth_ipaddr
*addr
)
112 struct qeth_ipato_entry
*ipatoe
;
113 u8 addr_bits
[128] = {0, };
114 u8 ipatoe_bits
[128] = {0, };
117 if (!card
->ipato
.enabled
)
119 if (addr
->type
!= QETH_IP_TYPE_NORMAL
)
122 qeth_l3_convert_addr_to_bits((u8
*) &addr
->u
, addr_bits
,
123 (addr
->proto
== QETH_PROT_IPV4
)? 4:16);
124 list_for_each_entry(ipatoe
, &card
->ipato
.entries
, entry
) {
125 if (addr
->proto
!= ipatoe
->proto
)
127 qeth_l3_convert_addr_to_bits(ipatoe
->addr
, ipatoe_bits
,
128 (ipatoe
->proto
== QETH_PROT_IPV4
) ?
130 if (addr
->proto
== QETH_PROT_IPV4
)
131 rc
= !memcmp(addr_bits
, ipatoe_bits
,
132 min(32, ipatoe
->mask_bits
));
134 rc
= !memcmp(addr_bits
, ipatoe_bits
,
135 min(128, ipatoe
->mask_bits
));
140 if ((addr
->proto
== QETH_PROT_IPV4
) && card
->ipato
.invert4
)
142 else if ((addr
->proto
== QETH_PROT_IPV6
) && card
->ipato
.invert6
)
148 static int qeth_l3_delete_ip(struct qeth_card
*card
,
149 struct qeth_ipaddr
*tmp_addr
)
152 struct qeth_ipaddr
*addr
;
154 if (tmp_addr
->type
== QETH_IP_TYPE_RXIP
)
155 QETH_CARD_TEXT(card
, 2, "delrxip");
156 else if (tmp_addr
->type
== QETH_IP_TYPE_VIPA
)
157 QETH_CARD_TEXT(card
, 2, "delvipa");
159 QETH_CARD_TEXT(card
, 2, "delip");
161 if (tmp_addr
->proto
== QETH_PROT_IPV4
)
162 QETH_CARD_HEX(card
, 4, &tmp_addr
->u
.a4
.addr
, 4);
164 QETH_CARD_HEX(card
, 4, &tmp_addr
->u
.a6
.addr
, 8);
165 QETH_CARD_HEX(card
, 4, ((char *)&tmp_addr
->u
.a6
.addr
) + 8, 8);
168 addr
= qeth_l3_find_addr_by_ip(card
, tmp_addr
);
169 if (!addr
|| !qeth_l3_addr_match_all(addr
, tmp_addr
))
173 if (addr
->type
== QETH_IP_TYPE_NORMAL
&& addr
->ref_counter
> 0)
175 if (addr
->in_progress
)
178 if (qeth_card_hw_is_reachable(card
))
179 rc
= qeth_l3_deregister_addr_entry(card
, addr
);
181 hash_del(&addr
->hnode
);
187 static int qeth_l3_add_ip(struct qeth_card
*card
, struct qeth_ipaddr
*tmp_addr
)
190 struct qeth_ipaddr
*addr
;
193 if (tmp_addr
->type
== QETH_IP_TYPE_RXIP
)
194 QETH_CARD_TEXT(card
, 2, "addrxip");
195 else if (tmp_addr
->type
== QETH_IP_TYPE_VIPA
)
196 QETH_CARD_TEXT(card
, 2, "addvipa");
198 QETH_CARD_TEXT(card
, 2, "addip");
200 if (tmp_addr
->proto
== QETH_PROT_IPV4
)
201 QETH_CARD_HEX(card
, 4, &tmp_addr
->u
.a4
.addr
, 4);
203 QETH_CARD_HEX(card
, 4, &tmp_addr
->u
.a6
.addr
, 8);
204 QETH_CARD_HEX(card
, 4, ((char *)&tmp_addr
->u
.a6
.addr
) + 8, 8);
207 addr
= qeth_l3_find_addr_by_ip(card
, tmp_addr
);
209 if (tmp_addr
->type
!= QETH_IP_TYPE_NORMAL
)
211 if (qeth_l3_addr_match_all(addr
, tmp_addr
)) {
215 qeth_l3_ipaddr_to_string(tmp_addr
->proto
, (u8
*)&tmp_addr
->u
,
217 dev_warn(&card
->gdev
->dev
,
218 "Registering IP address %s failed\n", buf
);
221 addr
= qeth_l3_get_addr_buffer(tmp_addr
->proto
);
225 memcpy(addr
, tmp_addr
, sizeof(struct qeth_ipaddr
));
226 addr
->ref_counter
= 1;
228 if (qeth_l3_is_addr_covered_by_ipato(card
, addr
)) {
229 QETH_CARD_TEXT(card
, 2, "tkovaddr");
232 hash_add(card
->ip_htable
, &addr
->hnode
,
233 qeth_l3_ipaddr_hash(addr
));
235 if (!qeth_card_hw_is_reachable(card
)) {
236 addr
->disp_flag
= QETH_DISP_ADDR_ADD
;
240 /* qeth_l3_register_addr_entry can go to sleep
241 * if we add a IPV4 addr. It is caused by the reason
242 * that SETIP ipa cmd starts ARP staff for IPV4 addr.
243 * Thus we should unlock spinlock, and make a protection
244 * using in_progress variable to indicate that there is
245 * an hardware operation with this IPV4 address
247 if (addr
->proto
== QETH_PROT_IPV4
) {
248 addr
->in_progress
= 1;
249 mutex_unlock(&card
->ip_lock
);
250 rc
= qeth_l3_register_addr_entry(card
, addr
);
251 mutex_lock(&card
->ip_lock
);
252 addr
->in_progress
= 0;
254 rc
= qeth_l3_register_addr_entry(card
, addr
);
256 if (!rc
|| rc
== -EADDRINUSE
|| rc
== -ENETDOWN
) {
257 addr
->disp_flag
= QETH_DISP_ADDR_DO_NOTHING
;
258 if (addr
->ref_counter
< 1) {
259 qeth_l3_deregister_addr_entry(card
, addr
);
260 hash_del(&addr
->hnode
);
264 hash_del(&addr
->hnode
);
271 static int qeth_l3_modify_ip(struct qeth_card
*card
, struct qeth_ipaddr
*addr
,
276 mutex_lock(&card
->ip_lock
);
277 rc
= add
? qeth_l3_add_ip(card
, addr
) : qeth_l3_delete_ip(card
, addr
);
278 mutex_unlock(&card
->ip_lock
);
283 static void qeth_l3_drain_rx_mode_cache(struct qeth_card
*card
)
285 struct qeth_ipaddr
*addr
;
286 struct hlist_node
*tmp
;
289 hash_for_each_safe(card
->ip_mc_htable
, i
, tmp
, addr
, hnode
) {
290 hash_del(&addr
->hnode
);
295 static void qeth_l3_clear_ip_htable(struct qeth_card
*card
, int recover
)
297 struct qeth_ipaddr
*addr
;
298 struct hlist_node
*tmp
;
301 QETH_CARD_TEXT(card
, 4, "clearip");
303 mutex_lock(&card
->ip_lock
);
305 hash_for_each_safe(card
->ip_htable
, i
, tmp
, addr
, hnode
) {
307 hash_del(&addr
->hnode
);
311 addr
->disp_flag
= QETH_DISP_ADDR_ADD
;
314 mutex_unlock(&card
->ip_lock
);
317 static void qeth_l3_recover_ip(struct qeth_card
*card
)
319 struct qeth_ipaddr
*addr
;
320 struct hlist_node
*tmp
;
324 QETH_CARD_TEXT(card
, 4, "recovrip");
326 mutex_lock(&card
->ip_lock
);
328 hash_for_each_safe(card
->ip_htable
, i
, tmp
, addr
, hnode
) {
329 if (addr
->disp_flag
== QETH_DISP_ADDR_ADD
) {
330 if (addr
->proto
== QETH_PROT_IPV4
) {
331 addr
->in_progress
= 1;
332 mutex_unlock(&card
->ip_lock
);
333 rc
= qeth_l3_register_addr_entry(card
, addr
);
334 mutex_lock(&card
->ip_lock
);
335 addr
->in_progress
= 0;
337 rc
= qeth_l3_register_addr_entry(card
, addr
);
340 addr
->disp_flag
= QETH_DISP_ADDR_DO_NOTHING
;
341 if (addr
->ref_counter
< 1)
342 qeth_l3_delete_ip(card
, addr
);
344 hash_del(&addr
->hnode
);
350 mutex_unlock(&card
->ip_lock
);
353 static int qeth_l3_setdelip_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
356 struct qeth_ipa_cmd
*cmd
= (struct qeth_ipa_cmd
*) data
;
358 switch (cmd
->hdr
.return_code
) {
361 case IPA_RC_DUPLICATE_IP_ADDRESS
:
363 case IPA_RC_MC_ADDR_NOT_FOUND
:
365 case IPA_RC_LAN_OFFLINE
:
372 static int qeth_l3_send_setdelmc(struct qeth_card
*card
,
373 struct qeth_ipaddr
*addr
, int ipacmd
)
375 struct qeth_cmd_buffer
*iob
;
376 struct qeth_ipa_cmd
*cmd
;
378 QETH_CARD_TEXT(card
, 4, "setdelmc");
380 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, addr
->proto
);
383 cmd
= __ipa_cmd(iob
);
384 ether_addr_copy(cmd
->data
.setdelipm
.mac
, addr
->mac
);
385 if (addr
->proto
== QETH_PROT_IPV6
)
386 memcpy(cmd
->data
.setdelipm
.ip6
, &addr
->u
.a6
.addr
,
387 sizeof(struct in6_addr
));
389 memcpy(&cmd
->data
.setdelipm
.ip4
, &addr
->u
.a4
.addr
, 4);
391 return qeth_send_ipa_cmd(card
, iob
, qeth_l3_setdelip_cb
, NULL
);
394 static void qeth_l3_fill_netmask(u8
*netmask
, unsigned int len
)
397 for (i
= 0; i
< 16; i
++) {
402 netmask
[i
] = (u8
)(0xFF00 >> j
);
408 static u32
qeth_l3_get_setdelip_flags(struct qeth_ipaddr
*addr
, bool set
)
410 switch (addr
->type
) {
411 case QETH_IP_TYPE_RXIP
:
412 return (set
) ? QETH_IPA_SETIP_TAKEOVER_FLAG
: 0;
413 case QETH_IP_TYPE_VIPA
:
414 return (set
) ? QETH_IPA_SETIP_VIPA_FLAG
:
415 QETH_IPA_DELIP_VIPA_FLAG
;
417 return (set
&& addr
->ipato
) ? QETH_IPA_SETIP_TAKEOVER_FLAG
: 0;
421 static int qeth_l3_send_setdelip(struct qeth_card
*card
,
422 struct qeth_ipaddr
*addr
,
423 enum qeth_ipa_cmds ipacmd
)
425 struct qeth_cmd_buffer
*iob
;
426 struct qeth_ipa_cmd
*cmd
;
430 QETH_CARD_TEXT(card
, 4, "setdelip");
432 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, addr
->proto
);
435 cmd
= __ipa_cmd(iob
);
437 flags
= qeth_l3_get_setdelip_flags(addr
, ipacmd
== IPA_CMD_SETIP
);
438 QETH_CARD_TEXT_(card
, 4, "flags%02X", flags
);
440 if (addr
->proto
== QETH_PROT_IPV6
) {
441 memcpy(cmd
->data
.setdelip6
.ip_addr
, &addr
->u
.a6
.addr
,
442 sizeof(struct in6_addr
));
443 qeth_l3_fill_netmask(netmask
, addr
->u
.a6
.pfxlen
);
444 memcpy(cmd
->data
.setdelip6
.mask
, netmask
,
445 sizeof(struct in6_addr
));
446 cmd
->data
.setdelip6
.flags
= flags
;
448 memcpy(cmd
->data
.setdelip4
.ip_addr
, &addr
->u
.a4
.addr
, 4);
449 memcpy(cmd
->data
.setdelip4
.mask
, &addr
->u
.a4
.mask
, 4);
450 cmd
->data
.setdelip4
.flags
= flags
;
453 return qeth_send_ipa_cmd(card
, iob
, qeth_l3_setdelip_cb
, NULL
);
456 static int qeth_l3_send_setrouting(struct qeth_card
*card
,
457 enum qeth_routing_types type
, enum qeth_prot_versions prot
)
460 struct qeth_ipa_cmd
*cmd
;
461 struct qeth_cmd_buffer
*iob
;
463 QETH_CARD_TEXT(card
, 4, "setroutg");
464 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_SETRTG
, prot
);
467 cmd
= __ipa_cmd(iob
);
468 cmd
->data
.setrtg
.type
= (type
);
469 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
474 static int qeth_l3_correct_routing_type(struct qeth_card
*card
,
475 enum qeth_routing_types
*type
, enum qeth_prot_versions prot
)
480 case PRIMARY_CONNECTOR
:
481 case SECONDARY_CONNECTOR
:
482 case MULTICAST_ROUTER
:
491 case SECONDARY_ROUTER
:
493 case MULTICAST_ROUTER
:
494 if (qeth_is_ipafunc_supported(card
, prot
,
506 int qeth_l3_setrouting_v4(struct qeth_card
*card
)
510 QETH_CARD_TEXT(card
, 3, "setrtg4");
512 rc
= qeth_l3_correct_routing_type(card
, &card
->options
.route4
.type
,
517 rc
= qeth_l3_send_setrouting(card
, card
->options
.route4
.type
,
520 card
->options
.route4
.type
= NO_ROUTER
;
521 QETH_DBF_MESSAGE(2, "Error (%#06x) while setting routing type on device %x. Type set to 'no router'.\n",
522 rc
, CARD_DEVID(card
));
527 int qeth_l3_setrouting_v6(struct qeth_card
*card
)
531 QETH_CARD_TEXT(card
, 3, "setrtg6");
533 if (!qeth_is_supported(card
, IPA_IPV6
))
535 rc
= qeth_l3_correct_routing_type(card
, &card
->options
.route6
.type
,
540 rc
= qeth_l3_send_setrouting(card
, card
->options
.route6
.type
,
543 card
->options
.route6
.type
= NO_ROUTER
;
544 QETH_DBF_MESSAGE(2, "Error (%#06x) while setting routing type on device %x. Type set to 'no router'.\n",
545 rc
, CARD_DEVID(card
));
551 * IP address takeover related functions
555 * qeth_l3_update_ipato() - Update 'takeover' property, for all NORMAL IPs.
557 * Caller must hold ip_lock.
559 void qeth_l3_update_ipato(struct qeth_card
*card
)
561 struct qeth_ipaddr
*addr
;
564 hash_for_each(card
->ip_htable
, i
, addr
, hnode
) {
565 if (addr
->type
!= QETH_IP_TYPE_NORMAL
)
567 addr
->ipato
= qeth_l3_is_addr_covered_by_ipato(card
, addr
);
571 static void qeth_l3_clear_ipato_list(struct qeth_card
*card
)
573 struct qeth_ipato_entry
*ipatoe
, *tmp
;
575 mutex_lock(&card
->ip_lock
);
577 list_for_each_entry_safe(ipatoe
, tmp
, &card
->ipato
.entries
, entry
) {
578 list_del(&ipatoe
->entry
);
582 qeth_l3_update_ipato(card
);
583 mutex_unlock(&card
->ip_lock
);
586 int qeth_l3_add_ipato_entry(struct qeth_card
*card
,
587 struct qeth_ipato_entry
*new)
589 struct qeth_ipato_entry
*ipatoe
;
592 QETH_CARD_TEXT(card
, 2, "addipato");
594 mutex_lock(&card
->ip_lock
);
596 list_for_each_entry(ipatoe
, &card
->ipato
.entries
, entry
) {
597 if (ipatoe
->proto
!= new->proto
)
599 if (!memcmp(ipatoe
->addr
, new->addr
,
600 (ipatoe
->proto
== QETH_PROT_IPV4
)? 4:16) &&
601 (ipatoe
->mask_bits
== new->mask_bits
)) {
608 list_add_tail(&new->entry
, &card
->ipato
.entries
);
609 qeth_l3_update_ipato(card
);
612 mutex_unlock(&card
->ip_lock
);
617 int qeth_l3_del_ipato_entry(struct qeth_card
*card
,
618 enum qeth_prot_versions proto
, u8
*addr
,
621 struct qeth_ipato_entry
*ipatoe
, *tmp
;
624 QETH_CARD_TEXT(card
, 2, "delipato");
626 mutex_lock(&card
->ip_lock
);
628 list_for_each_entry_safe(ipatoe
, tmp
, &card
->ipato
.entries
, entry
) {
629 if (ipatoe
->proto
!= proto
)
631 if (!memcmp(ipatoe
->addr
, addr
,
632 (proto
== QETH_PROT_IPV4
)? 4:16) &&
633 (ipatoe
->mask_bits
== mask_bits
)) {
634 list_del(&ipatoe
->entry
);
635 qeth_l3_update_ipato(card
);
641 mutex_unlock(&card
->ip_lock
);
645 int qeth_l3_modify_rxip_vipa(struct qeth_card
*card
, bool add
, const u8
*ip
,
646 enum qeth_ip_types type
,
647 enum qeth_prot_versions proto
)
649 struct qeth_ipaddr addr
;
651 qeth_l3_init_ipaddr(&addr
, type
, proto
);
652 if (proto
== QETH_PROT_IPV4
)
653 memcpy(&addr
.u
.a4
.addr
, ip
, 4);
655 memcpy(&addr
.u
.a6
.addr
, ip
, 16);
657 return qeth_l3_modify_ip(card
, &addr
, add
);
660 int qeth_l3_modify_hsuid(struct qeth_card
*card
, bool add
)
662 struct qeth_ipaddr addr
;
665 qeth_l3_init_ipaddr(&addr
, QETH_IP_TYPE_NORMAL
, QETH_PROT_IPV6
);
666 addr
.u
.a6
.addr
.s6_addr
[0] = 0xfe;
667 addr
.u
.a6
.addr
.s6_addr
[1] = 0x80;
668 for (i
= 0; i
< 8; i
++)
669 addr
.u
.a6
.addr
.s6_addr
[8+i
] = card
->options
.hsuid
[i
];
671 return qeth_l3_modify_ip(card
, &addr
, add
);
674 static int qeth_l3_register_addr_entry(struct qeth_card
*card
,
675 struct qeth_ipaddr
*addr
)
681 if (card
->options
.sniffer
)
684 if (addr
->proto
== QETH_PROT_IPV4
) {
685 QETH_CARD_TEXT(card
, 2, "setaddr4");
686 QETH_CARD_HEX(card
, 3, &addr
->u
.a4
.addr
, sizeof(int));
687 } else if (addr
->proto
== QETH_PROT_IPV6
) {
688 QETH_CARD_TEXT(card
, 2, "setaddr6");
689 QETH_CARD_HEX(card
, 3, &addr
->u
.a6
.addr
, 8);
690 QETH_CARD_HEX(card
, 3, ((char *)&addr
->u
.a6
.addr
) + 8, 8);
692 QETH_CARD_TEXT(card
, 2, "setaddr?");
693 QETH_CARD_HEX(card
, 3, addr
, sizeof(struct qeth_ipaddr
));
696 if (addr
->is_multicast
)
697 rc
= qeth_l3_send_setdelmc(card
, addr
, IPA_CMD_SETIPM
);
699 rc
= qeth_l3_send_setdelip(card
, addr
, IPA_CMD_SETIP
);
701 QETH_CARD_TEXT(card
, 2, "failed");
702 } while ((--cnt
> 0) && rc
);
704 QETH_CARD_TEXT(card
, 2, "FAILED");
705 qeth_l3_ipaddr_to_string(addr
->proto
, (u8
*)&addr
->u
, buf
);
706 dev_warn(&card
->gdev
->dev
,
707 "Registering IP address %s failed\n", buf
);
712 static int qeth_l3_deregister_addr_entry(struct qeth_card
*card
,
713 struct qeth_ipaddr
*addr
)
717 if (card
->options
.sniffer
)
720 if (addr
->proto
== QETH_PROT_IPV4
) {
721 QETH_CARD_TEXT(card
, 2, "deladdr4");
722 QETH_CARD_HEX(card
, 3, &addr
->u
.a4
.addr
, sizeof(int));
723 } else if (addr
->proto
== QETH_PROT_IPV6
) {
724 QETH_CARD_TEXT(card
, 2, "deladdr6");
725 QETH_CARD_HEX(card
, 3, &addr
->u
.a6
.addr
, 8);
726 QETH_CARD_HEX(card
, 3, ((char *)&addr
->u
.a6
.addr
) + 8, 8);
728 QETH_CARD_TEXT(card
, 2, "deladdr?");
729 QETH_CARD_HEX(card
, 3, addr
, sizeof(struct qeth_ipaddr
));
731 if (addr
->is_multicast
)
732 rc
= qeth_l3_send_setdelmc(card
, addr
, IPA_CMD_DELIPM
);
734 rc
= qeth_l3_send_setdelip(card
, addr
, IPA_CMD_DELIP
);
736 QETH_CARD_TEXT(card
, 2, "failed");
741 static int qeth_l3_setadapter_parms(struct qeth_card
*card
)
745 QETH_DBF_TEXT(SETUP
, 2, "setadprm");
747 if (qeth_adp_supported(card
, IPA_SETADP_ALTER_MAC_ADDRESS
)) {
748 rc
= qeth_setadpparms_change_macaddr(card
);
750 dev_warn(&card
->gdev
->dev
, "Reading the adapter MAC"
751 " address failed\n");
757 static int qeth_l3_start_ipa_arp_processing(struct qeth_card
*card
)
761 QETH_CARD_TEXT(card
, 3, "ipaarp");
763 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
764 dev_info(&card
->gdev
->dev
,
765 "ARP processing not supported on %s!\n",
766 QETH_CARD_IFNAME(card
));
769 rc
= qeth_send_simple_setassparms(card
, IPA_ARP_PROCESSING
,
770 IPA_CMD_ASS_START
, 0);
772 dev_warn(&card
->gdev
->dev
,
773 "Starting ARP processing support for %s failed\n",
774 QETH_CARD_IFNAME(card
));
779 static int qeth_l3_start_ipa_source_mac(struct qeth_card
*card
)
783 QETH_CARD_TEXT(card
, 3, "stsrcmac");
785 if (!qeth_is_supported(card
, IPA_SOURCE_MAC
)) {
786 dev_info(&card
->gdev
->dev
,
787 "Inbound source MAC-address not supported on %s\n",
788 QETH_CARD_IFNAME(card
));
792 rc
= qeth_send_simple_setassparms(card
, IPA_SOURCE_MAC
,
793 IPA_CMD_ASS_START
, 0);
795 dev_warn(&card
->gdev
->dev
,
796 "Starting source MAC-address support for %s failed\n",
797 QETH_CARD_IFNAME(card
));
801 static int qeth_l3_start_ipa_vlan(struct qeth_card
*card
)
805 QETH_CARD_TEXT(card
, 3, "strtvlan");
807 if (!qeth_is_supported(card
, IPA_FULL_VLAN
)) {
808 dev_info(&card
->gdev
->dev
,
809 "VLAN not supported on %s\n", QETH_CARD_IFNAME(card
));
813 rc
= qeth_send_simple_setassparms(card
, IPA_VLAN_PRIO
,
814 IPA_CMD_ASS_START
, 0);
816 dev_warn(&card
->gdev
->dev
,
817 "Starting VLAN support for %s failed\n",
818 QETH_CARD_IFNAME(card
));
820 dev_info(&card
->gdev
->dev
, "VLAN enabled\n");
825 static int qeth_l3_start_ipa_multicast(struct qeth_card
*card
)
829 QETH_CARD_TEXT(card
, 3, "stmcast");
831 if (!qeth_is_supported(card
, IPA_MULTICASTING
)) {
832 dev_info(&card
->gdev
->dev
,
833 "Multicast not supported on %s\n",
834 QETH_CARD_IFNAME(card
));
838 rc
= qeth_send_simple_setassparms(card
, IPA_MULTICASTING
,
839 IPA_CMD_ASS_START
, 0);
841 dev_warn(&card
->gdev
->dev
,
842 "Starting multicast support for %s failed\n",
843 QETH_CARD_IFNAME(card
));
845 dev_info(&card
->gdev
->dev
, "Multicast enabled\n");
846 card
->dev
->flags
|= IFF_MULTICAST
;
851 static int qeth_l3_softsetup_ipv6(struct qeth_card
*card
)
855 QETH_CARD_TEXT(card
, 3, "softipv6");
860 rc
= qeth_send_simple_setassparms(card
, IPA_IPV6
,
861 IPA_CMD_ASS_START
, 3);
863 dev_err(&card
->gdev
->dev
,
864 "Activating IPv6 support for %s failed\n",
865 QETH_CARD_IFNAME(card
));
868 rc
= qeth_send_simple_setassparms_v6(card
, IPA_IPV6
,
869 IPA_CMD_ASS_START
, 0);
871 dev_err(&card
->gdev
->dev
,
872 "Activating IPv6 support for %s failed\n",
873 QETH_CARD_IFNAME(card
));
876 rc
= qeth_send_simple_setassparms_v6(card
, IPA_PASSTHRU
,
877 IPA_CMD_ASS_START
, 0);
879 dev_warn(&card
->gdev
->dev
,
880 "Enabling the passthrough mode for %s failed\n",
881 QETH_CARD_IFNAME(card
));
885 dev_info(&card
->gdev
->dev
, "IPV6 enabled\n");
889 static int qeth_l3_start_ipa_ipv6(struct qeth_card
*card
)
891 QETH_CARD_TEXT(card
, 3, "strtipv6");
893 if (!qeth_is_supported(card
, IPA_IPV6
)) {
894 dev_info(&card
->gdev
->dev
,
895 "IPv6 not supported on %s\n", QETH_CARD_IFNAME(card
));
898 return qeth_l3_softsetup_ipv6(card
);
901 static int qeth_l3_start_ipa_broadcast(struct qeth_card
*card
)
905 QETH_CARD_TEXT(card
, 3, "stbrdcst");
906 card
->info
.broadcast_capable
= 0;
907 if (!qeth_is_supported(card
, IPA_FILTERING
)) {
908 dev_info(&card
->gdev
->dev
,
909 "Broadcast not supported on %s\n",
910 QETH_CARD_IFNAME(card
));
914 rc
= qeth_send_simple_setassparms(card
, IPA_FILTERING
,
915 IPA_CMD_ASS_START
, 0);
917 dev_warn(&card
->gdev
->dev
, "Enabling broadcast filtering for "
918 "%s failed\n", QETH_CARD_IFNAME(card
));
922 rc
= qeth_send_simple_setassparms(card
, IPA_FILTERING
,
923 IPA_CMD_ASS_CONFIGURE
, 1);
925 dev_warn(&card
->gdev
->dev
,
926 "Setting up broadcast filtering for %s failed\n",
927 QETH_CARD_IFNAME(card
));
930 card
->info
.broadcast_capable
= QETH_BROADCAST_WITH_ECHO
;
931 dev_info(&card
->gdev
->dev
, "Broadcast enabled\n");
932 rc
= qeth_send_simple_setassparms(card
, IPA_FILTERING
,
933 IPA_CMD_ASS_ENABLE
, 1);
935 dev_warn(&card
->gdev
->dev
, "Setting up broadcast echo "
936 "filtering for %s failed\n", QETH_CARD_IFNAME(card
));
939 card
->info
.broadcast_capable
= QETH_BROADCAST_WITHOUT_ECHO
;
941 if (card
->info
.broadcast_capable
)
942 card
->dev
->flags
|= IFF_BROADCAST
;
944 card
->dev
->flags
&= ~IFF_BROADCAST
;
948 static int qeth_l3_start_ipassists(struct qeth_card
*card
)
950 QETH_CARD_TEXT(card
, 3, "strtipas");
952 if (qeth_set_access_ctrl_online(card
, 0))
954 qeth_l3_start_ipa_arp_processing(card
); /* go on*/
955 qeth_l3_start_ipa_source_mac(card
); /* go on*/
956 qeth_l3_start_ipa_vlan(card
); /* go on*/
957 qeth_l3_start_ipa_multicast(card
); /* go on*/
958 qeth_l3_start_ipa_ipv6(card
); /* go on*/
959 qeth_l3_start_ipa_broadcast(card
); /* go on*/
963 static int qeth_l3_iqd_read_initial_mac_cb(struct qeth_card
*card
,
964 struct qeth_reply
*reply
, unsigned long data
)
966 struct qeth_ipa_cmd
*cmd
= (struct qeth_ipa_cmd
*) data
;
968 if (cmd
->hdr
.return_code
)
971 ether_addr_copy(card
->dev
->dev_addr
,
972 cmd
->data
.create_destroy_addr
.unique_id
);
976 static int qeth_l3_iqd_read_initial_mac(struct qeth_card
*card
)
979 struct qeth_cmd_buffer
*iob
;
980 struct qeth_ipa_cmd
*cmd
;
982 QETH_DBF_TEXT(SETUP
, 2, "hsrmac");
984 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_CREATE_ADDR
,
988 cmd
= __ipa_cmd(iob
);
989 *((__u16
*) &cmd
->data
.create_destroy_addr
.unique_id
[6]) =
990 card
->info
.unique_id
;
992 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_l3_iqd_read_initial_mac_cb
,
997 static int qeth_l3_get_unique_id_cb(struct qeth_card
*card
,
998 struct qeth_reply
*reply
, unsigned long data
)
1000 struct qeth_ipa_cmd
*cmd
= (struct qeth_ipa_cmd
*) data
;
1002 if (cmd
->hdr
.return_code
== 0) {
1003 card
->info
.unique_id
= *((__u16
*)
1004 &cmd
->data
.create_destroy_addr
.unique_id
[6]);
1008 card
->info
.unique_id
= UNIQUE_ID_IF_CREATE_ADDR_FAILED
|
1009 UNIQUE_ID_NOT_BY_CARD
;
1010 dev_warn(&card
->gdev
->dev
, "The network adapter failed to generate a unique ID\n");
1014 static int qeth_l3_get_unique_id(struct qeth_card
*card
)
1017 struct qeth_cmd_buffer
*iob
;
1018 struct qeth_ipa_cmd
*cmd
;
1020 QETH_DBF_TEXT(SETUP
, 2, "guniqeid");
1022 if (!qeth_is_supported(card
, IPA_IPV6
)) {
1023 card
->info
.unique_id
= UNIQUE_ID_IF_CREATE_ADDR_FAILED
|
1024 UNIQUE_ID_NOT_BY_CARD
;
1028 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_CREATE_ADDR
,
1032 cmd
= __ipa_cmd(iob
);
1033 *((__u16
*) &cmd
->data
.create_destroy_addr
.unique_id
[6]) =
1034 card
->info
.unique_id
;
1036 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_l3_get_unique_id_cb
, NULL
);
1041 qeth_diags_trace_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
1044 struct qeth_ipa_cmd
*cmd
;
1047 QETH_DBF_TEXT(SETUP
, 2, "diastrcb");
1049 cmd
= (struct qeth_ipa_cmd
*)data
;
1050 rc
= cmd
->hdr
.return_code
;
1052 QETH_CARD_TEXT_(card
, 2, "dxter%x", rc
);
1053 switch (cmd
->data
.diagass
.action
) {
1054 case QETH_DIAGS_CMD_TRACE_QUERY
:
1056 case QETH_DIAGS_CMD_TRACE_DISABLE
:
1059 case IPA_RC_INVALID_SUBCMD
:
1060 card
->info
.promisc_mode
= SET_PROMISC_MODE_OFF
;
1061 dev_info(&card
->gdev
->dev
, "The HiperSockets network "
1062 "traffic analyzer is deactivated\n");
1068 case QETH_DIAGS_CMD_TRACE_ENABLE
:
1071 card
->info
.promisc_mode
= SET_PROMISC_MODE_ON
;
1072 dev_info(&card
->gdev
->dev
, "The HiperSockets network "
1073 "traffic analyzer is activated\n");
1075 case IPA_RC_HARDWARE_AUTH_ERROR
:
1076 dev_warn(&card
->gdev
->dev
, "The device is not "
1077 "authorized to run as a HiperSockets network "
1078 "traffic analyzer\n");
1080 case IPA_RC_TRACE_ALREADY_ACTIVE
:
1081 dev_warn(&card
->gdev
->dev
, "A HiperSockets "
1082 "network traffic analyzer is already "
1083 "active in the HiperSockets LAN\n");
1090 QETH_DBF_MESSAGE(2, "Unknown sniffer action (%#06x) on device %x\n",
1091 cmd
->data
.diagass
.action
, CARD_DEVID(card
));
1094 return rc
? -EIO
: 0;
1098 qeth_diags_trace(struct qeth_card
*card
, enum qeth_diags_trace_cmds diags_cmd
)
1100 struct qeth_cmd_buffer
*iob
;
1101 struct qeth_ipa_cmd
*cmd
;
1103 QETH_DBF_TEXT(SETUP
, 2, "diagtrac");
1105 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_SET_DIAG_ASS
, 0);
1108 cmd
= __ipa_cmd(iob
);
1109 cmd
->data
.diagass
.subcmd_len
= 16;
1110 cmd
->data
.diagass
.subcmd
= QETH_DIAGS_CMD_TRACE
;
1111 cmd
->data
.diagass
.type
= QETH_DIAGS_TYPE_HIPERSOCKET
;
1112 cmd
->data
.diagass
.action
= diags_cmd
;
1113 return qeth_send_ipa_cmd(card
, iob
, qeth_diags_trace_cb
, NULL
);
1117 qeth_l3_add_mc_to_hash(struct qeth_card
*card
, struct in_device
*in4_dev
)
1119 struct ip_mc_list
*im4
;
1120 struct qeth_ipaddr
*tmp
, *ipm
;
1122 QETH_CARD_TEXT(card
, 4, "addmc");
1124 tmp
= qeth_l3_get_addr_buffer(QETH_PROT_IPV4
);
1128 for (im4
= rcu_dereference(in4_dev
->mc_list
); im4
!= NULL
;
1129 im4
= rcu_dereference(im4
->next_rcu
)) {
1130 ip_eth_mc_map(im4
->multiaddr
, tmp
->mac
);
1131 tmp
->u
.a4
.addr
= be32_to_cpu(im4
->multiaddr
);
1132 tmp
->is_multicast
= 1;
1134 ipm
= qeth_l3_find_addr_by_ip(card
, tmp
);
1136 /* for mcast, by-IP match means full match */
1137 ipm
->disp_flag
= QETH_DISP_ADDR_DO_NOTHING
;
1139 ipm
= qeth_l3_get_addr_buffer(QETH_PROT_IPV4
);
1142 ether_addr_copy(ipm
->mac
, tmp
->mac
);
1143 ipm
->u
.a4
.addr
= be32_to_cpu(im4
->multiaddr
);
1144 ipm
->is_multicast
= 1;
1145 ipm
->disp_flag
= QETH_DISP_ADDR_ADD
;
1146 hash_add(card
->ip_mc_htable
,
1147 &ipm
->hnode
, qeth_l3_ipaddr_hash(ipm
));
1154 /* called with rcu_read_lock */
1155 static void qeth_l3_add_vlan_mc(struct qeth_card
*card
)
1157 struct in_device
*in_dev
;
1160 QETH_CARD_TEXT(card
, 4, "addmcvl");
1162 if (!qeth_is_supported(card
, IPA_FULL_VLAN
))
1165 for_each_set_bit(vid
, card
->active_vlans
, VLAN_N_VID
) {
1166 struct net_device
*netdev
;
1168 netdev
= __vlan_find_dev_deep_rcu(card
->dev
, htons(ETH_P_8021Q
),
1170 if (netdev
== NULL
||
1171 !(netdev
->flags
& IFF_UP
))
1173 in_dev
= __in_dev_get_rcu(netdev
);
1176 qeth_l3_add_mc_to_hash(card
, in_dev
);
1180 static void qeth_l3_add_multicast_ipv4(struct qeth_card
*card
)
1182 struct in_device
*in4_dev
;
1184 QETH_CARD_TEXT(card
, 4, "chkmcv4");
1187 in4_dev
= __in_dev_get_rcu(card
->dev
);
1188 if (in4_dev
== NULL
)
1190 qeth_l3_add_mc_to_hash(card
, in4_dev
);
1191 qeth_l3_add_vlan_mc(card
);
1196 static void qeth_l3_add_mc6_to_hash(struct qeth_card
*card
,
1197 struct inet6_dev
*in6_dev
)
1199 struct qeth_ipaddr
*ipm
;
1200 struct ifmcaddr6
*im6
;
1201 struct qeth_ipaddr
*tmp
;
1203 QETH_CARD_TEXT(card
, 4, "addmc6");
1205 tmp
= qeth_l3_get_addr_buffer(QETH_PROT_IPV6
);
1209 for (im6
= in6_dev
->mc_list
; im6
!= NULL
; im6
= im6
->next
) {
1210 ipv6_eth_mc_map(&im6
->mca_addr
, tmp
->mac
);
1211 memcpy(&tmp
->u
.a6
.addr
, &im6
->mca_addr
.s6_addr
,
1212 sizeof(struct in6_addr
));
1213 tmp
->is_multicast
= 1;
1215 ipm
= qeth_l3_find_addr_by_ip(card
, tmp
);
1217 /* for mcast, by-IP match means full match */
1218 ipm
->disp_flag
= QETH_DISP_ADDR_DO_NOTHING
;
1222 ipm
= qeth_l3_get_addr_buffer(QETH_PROT_IPV6
);
1226 ether_addr_copy(ipm
->mac
, tmp
->mac
);
1227 memcpy(&ipm
->u
.a6
.addr
, &im6
->mca_addr
.s6_addr
,
1228 sizeof(struct in6_addr
));
1229 ipm
->is_multicast
= 1;
1230 ipm
->disp_flag
= QETH_DISP_ADDR_ADD
;
1231 hash_add(card
->ip_mc_htable
,
1232 &ipm
->hnode
, qeth_l3_ipaddr_hash(ipm
));
1238 /* called with rcu_read_lock */
1239 static void qeth_l3_add_vlan_mc6(struct qeth_card
*card
)
1241 struct inet6_dev
*in_dev
;
1244 QETH_CARD_TEXT(card
, 4, "admc6vl");
1246 if (!qeth_is_supported(card
, IPA_FULL_VLAN
))
1249 for_each_set_bit(vid
, card
->active_vlans
, VLAN_N_VID
) {
1250 struct net_device
*netdev
;
1252 netdev
= __vlan_find_dev_deep_rcu(card
->dev
, htons(ETH_P_8021Q
),
1254 if (netdev
== NULL
||
1255 !(netdev
->flags
& IFF_UP
))
1257 in_dev
= in6_dev_get(netdev
);
1260 read_lock_bh(&in_dev
->lock
);
1261 qeth_l3_add_mc6_to_hash(card
, in_dev
);
1262 read_unlock_bh(&in_dev
->lock
);
1263 in6_dev_put(in_dev
);
1267 static void qeth_l3_add_multicast_ipv6(struct qeth_card
*card
)
1269 struct inet6_dev
*in6_dev
;
1271 QETH_CARD_TEXT(card
, 4, "chkmcv6");
1273 if (!qeth_is_supported(card
, IPA_IPV6
))
1275 in6_dev
= in6_dev_get(card
->dev
);
1280 read_lock_bh(&in6_dev
->lock
);
1281 qeth_l3_add_mc6_to_hash(card
, in6_dev
);
1282 qeth_l3_add_vlan_mc6(card
);
1283 read_unlock_bh(&in6_dev
->lock
);
1285 in6_dev_put(in6_dev
);
1288 static int qeth_l3_vlan_rx_add_vid(struct net_device
*dev
,
1289 __be16 proto
, u16 vid
)
1291 struct qeth_card
*card
= dev
->ml_priv
;
1293 set_bit(vid
, card
->active_vlans
);
1297 static int qeth_l3_vlan_rx_kill_vid(struct net_device
*dev
,
1298 __be16 proto
, u16 vid
)
1300 struct qeth_card
*card
= dev
->ml_priv
;
1302 QETH_CARD_TEXT_(card
, 4, "kid:%d", vid
);
1304 clear_bit(vid
, card
->active_vlans
);
1305 qeth_l3_set_rx_mode(dev
);
1309 static void qeth_l3_rebuild_skb(struct qeth_card
*card
, struct sk_buff
*skb
,
1310 struct qeth_hdr
*hdr
)
1312 if (!(hdr
->hdr
.l3
.flags
& QETH_HDR_PASSTHRU
)) {
1313 u16 prot
= (hdr
->hdr
.l3
.flags
& QETH_HDR_IPV6
) ? ETH_P_IPV6
:
1315 unsigned char tg_addr
[ETH_ALEN
];
1317 skb_reset_network_header(skb
);
1318 switch (hdr
->hdr
.l3
.flags
& QETH_HDR_CAST_MASK
) {
1319 case QETH_CAST_MULTICAST
:
1320 if (prot
== ETH_P_IP
)
1321 ip_eth_mc_map(ip_hdr(skb
)->daddr
, tg_addr
);
1323 ipv6_eth_mc_map(&ipv6_hdr(skb
)->daddr
, tg_addr
);
1324 QETH_CARD_STAT_INC(card
, rx_multicast
);
1326 case QETH_CAST_BROADCAST
:
1327 ether_addr_copy(tg_addr
, card
->dev
->broadcast
);
1328 QETH_CARD_STAT_INC(card
, rx_multicast
);
1331 if (card
->options
.sniffer
)
1332 skb
->pkt_type
= PACKET_OTHERHOST
;
1333 ether_addr_copy(tg_addr
, card
->dev
->dev_addr
);
1336 if (hdr
->hdr
.l3
.ext_flags
& QETH_HDR_EXT_SRC_MAC_ADDR
)
1337 card
->dev
->header_ops
->create(skb
, card
->dev
, prot
,
1338 tg_addr
, &hdr
->hdr
.l3
.next_hop
.rx
.src_mac
,
1341 card
->dev
->header_ops
->create(skb
, card
->dev
, prot
,
1342 tg_addr
, "FAKELL", skb
->len
);
1345 skb
->protocol
= eth_type_trans(skb
, card
->dev
);
1347 /* copy VLAN tag from hdr into skb */
1348 if (!card
->options
.sniffer
&&
1349 (hdr
->hdr
.l3
.ext_flags
& (QETH_HDR_EXT_VLAN_FRAME
|
1350 QETH_HDR_EXT_INCLUDE_VLAN_TAG
))) {
1351 u16 tag
= (hdr
->hdr
.l3
.ext_flags
& QETH_HDR_EXT_VLAN_FRAME
) ?
1352 hdr
->hdr
.l3
.vlan_id
:
1353 hdr
->hdr
.l3
.next_hop
.rx
.vlan_id
;
1354 __vlan_hwaccel_put_tag(skb
, htons(ETH_P_8021Q
), tag
);
1357 qeth_rx_csum(card
, skb
, hdr
->hdr
.l3
.ext_flags
);
1360 static int qeth_l3_process_inbound_buffer(struct qeth_card
*card
,
1361 int budget
, int *done
)
1363 struct net_device
*dev
= card
->dev
;
1365 struct sk_buff
*skb
;
1366 struct qeth_hdr
*hdr
;
1371 WARN_ON_ONCE(!budget
);
1373 skb
= qeth_core_get_next_skb(card
,
1374 &card
->qdio
.in_q
->bufs
[card
->rx
.b_index
],
1375 &card
->rx
.b_element
, &card
->rx
.e_offset
, &hdr
);
1380 switch (hdr
->hdr
.l3
.id
) {
1381 case QETH_HEADER_TYPE_LAYER3
:
1382 magic
= *(__u16
*)skb
->data
;
1383 if (IS_IQD(card
) && magic
== ETH_P_AF_IUCV
) {
1385 dev_hard_header(skb
, dev
, ETH_P_AF_IUCV
,
1386 dev
->dev_addr
, "FAKELL", len
);
1387 skb
->protocol
= eth_type_trans(skb
, dev
);
1388 netif_receive_skb(skb
);
1390 qeth_l3_rebuild_skb(card
, skb
, hdr
);
1392 napi_gro_receive(&card
->napi
, skb
);
1395 case QETH_HEADER_TYPE_LAYER2
: /* for HiperSockets sniffer */
1396 skb
->protocol
= eth_type_trans(skb
, skb
->dev
);
1398 netif_receive_skb(skb
);
1401 dev_kfree_skb_any(skb
);
1402 QETH_CARD_TEXT(card
, 3, "inbunkno");
1403 QETH_DBF_HEX(CTRL
, 3, hdr
, sizeof(*hdr
));
1408 QETH_CARD_STAT_INC(card
, rx_packets
);
1409 QETH_CARD_STAT_ADD(card
, rx_bytes
, len
);
1414 static void qeth_l3_stop_card(struct qeth_card
*card
)
1416 QETH_DBF_TEXT(SETUP
, 2, "stopcard");
1417 QETH_DBF_HEX(SETUP
, 2, &card
, sizeof(void *));
1419 qeth_set_allowed_threads(card
, 0, 1);
1421 cancel_work_sync(&card
->rx_mode_work
);
1422 qeth_l3_drain_rx_mode_cache(card
);
1424 if (card
->options
.sniffer
&&
1425 (card
->info
.promisc_mode
== SET_PROMISC_MODE_ON
))
1426 qeth_diags_trace(card
, QETH_DIAGS_CMD_TRACE_DISABLE
);
1428 if (card
->state
== CARD_STATE_SOFTSETUP
) {
1429 qeth_l3_clear_ip_htable(card
, 1);
1430 qeth_clear_ipacmd_list(card
);
1431 card
->state
= CARD_STATE_HARDSETUP
;
1433 if (card
->state
== CARD_STATE_HARDSETUP
) {
1434 qeth_qdio_clear_card(card
, 0);
1435 qeth_drain_output_queues(card
);
1436 qeth_clear_working_pool_list(card
);
1437 card
->state
= CARD_STATE_DOWN
;
1439 if (card
->state
== CARD_STATE_DOWN
) {
1440 qeth_clear_cmd_buffers(&card
->read
);
1441 qeth_clear_cmd_buffers(&card
->write
);
1444 flush_workqueue(card
->event_wq
);
1448 * test for and Switch promiscuous mode (on or off)
1449 * either for guestlan or HiperSocket Sniffer
1452 qeth_l3_handle_promisc_mode(struct qeth_card
*card
)
1454 struct net_device
*dev
= card
->dev
;
1456 if (((dev
->flags
& IFF_PROMISC
) &&
1457 (card
->info
.promisc_mode
== SET_PROMISC_MODE_ON
)) ||
1458 (!(dev
->flags
& IFF_PROMISC
) &&
1459 (card
->info
.promisc_mode
== SET_PROMISC_MODE_OFF
)))
1462 if (IS_VM_NIC(card
)) { /* Guestlan trace */
1463 if (qeth_adp_supported(card
, IPA_SETADP_SET_PROMISC_MODE
))
1464 qeth_setadp_promisc_mode(card
);
1465 } else if (card
->options
.sniffer
&& /* HiperSockets trace */
1466 qeth_adp_supported(card
, IPA_SETADP_SET_DIAG_ASSIST
)) {
1467 if (dev
->flags
& IFF_PROMISC
) {
1468 QETH_CARD_TEXT(card
, 3, "+promisc");
1469 qeth_diags_trace(card
, QETH_DIAGS_CMD_TRACE_ENABLE
);
1471 QETH_CARD_TEXT(card
, 3, "-promisc");
1472 qeth_diags_trace(card
, QETH_DIAGS_CMD_TRACE_DISABLE
);
1477 static void qeth_l3_rx_mode_work(struct work_struct
*work
)
1479 struct qeth_card
*card
= container_of(work
, struct qeth_card
,
1481 struct qeth_ipaddr
*addr
;
1482 struct hlist_node
*tmp
;
1485 QETH_CARD_TEXT(card
, 3, "setmulti");
1487 if (!card
->options
.sniffer
) {
1488 qeth_l3_add_multicast_ipv4(card
);
1489 qeth_l3_add_multicast_ipv6(card
);
1491 hash_for_each_safe(card
->ip_mc_htable
, i
, tmp
, addr
, hnode
) {
1492 switch (addr
->disp_flag
) {
1493 case QETH_DISP_ADDR_DELETE
:
1494 rc
= qeth_l3_deregister_addr_entry(card
, addr
);
1495 if (!rc
|| rc
== -ENOENT
) {
1496 hash_del(&addr
->hnode
);
1500 case QETH_DISP_ADDR_ADD
:
1501 rc
= qeth_l3_register_addr_entry(card
, addr
);
1502 if (rc
&& rc
!= -ENETDOWN
) {
1503 hash_del(&addr
->hnode
);
1507 addr
->ref_counter
= 1;
1510 /* for next call to set_rx_mode(): */
1511 addr
->disp_flag
= QETH_DISP_ADDR_DELETE
;
1515 if (!qeth_adp_supported(card
, IPA_SETADP_SET_PROMISC_MODE
))
1518 qeth_l3_handle_promisc_mode(card
);
1521 static int qeth_l3_arp_makerc(u16 rc
)
1524 case IPA_RC_SUCCESS
:
1526 case QETH_IPA_ARP_RC_NOTSUPP
:
1527 case QETH_IPA_ARP_RC_Q_NOTSUPP
:
1529 case QETH_IPA_ARP_RC_OUT_OF_RANGE
:
1531 case QETH_IPA_ARP_RC_Q_NO_DATA
:
1538 static int qeth_l3_arp_cmd_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
1541 struct qeth_ipa_cmd
*cmd
= (struct qeth_ipa_cmd
*) data
;
1543 qeth_setassparms_cb(card
, reply
, data
);
1544 return qeth_l3_arp_makerc(cmd
->hdr
.return_code
);
1547 static int qeth_l3_arp_set_no_entries(struct qeth_card
*card
, int no_entries
)
1549 struct qeth_cmd_buffer
*iob
;
1552 QETH_CARD_TEXT(card
, 3, "arpstnoe");
1555 * currently GuestLAN only supports the ARP assist function
1556 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_SET_NO_ENTRIES;
1557 * thus we say EOPNOTSUPP for this ARP function
1559 if (IS_VM_NIC(card
))
1561 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
1565 iob
= qeth_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
1566 IPA_CMD_ASS_ARP_SET_NO_ENTRIES
, 4,
1571 __ipa_cmd(iob
)->data
.setassparms
.data
.flags_32bit
= (u32
) no_entries
;
1572 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_l3_arp_cmd_cb
, NULL
);
1574 QETH_DBF_MESSAGE(2, "Could not set number of ARP entries on device %x: %#x\n",
1575 CARD_DEVID(card
), rc
);
1579 static __u32
get_arp_entry_size(struct qeth_card
*card
,
1580 struct qeth_arp_query_data
*qdata
,
1581 struct qeth_arp_entrytype
*type
, __u8 strip_entries
)
1586 is_hsi
= qdata
->reply_bits
== 5;
1587 if (type
->ip
== QETHARP_IP_ADDR_V4
) {
1588 QETH_CARD_TEXT(card
, 4, "arpev4");
1589 if (strip_entries
) {
1590 rc
= is_hsi
? sizeof(struct qeth_arp_qi_entry5_short
) :
1591 sizeof(struct qeth_arp_qi_entry7_short
);
1593 rc
= is_hsi
? sizeof(struct qeth_arp_qi_entry5
) :
1594 sizeof(struct qeth_arp_qi_entry7
);
1596 } else if (type
->ip
== QETHARP_IP_ADDR_V6
) {
1597 QETH_CARD_TEXT(card
, 4, "arpev6");
1598 if (strip_entries
) {
1600 sizeof(struct qeth_arp_qi_entry5_short_ipv6
) :
1601 sizeof(struct qeth_arp_qi_entry7_short_ipv6
);
1604 sizeof(struct qeth_arp_qi_entry5_ipv6
) :
1605 sizeof(struct qeth_arp_qi_entry7_ipv6
);
1608 QETH_CARD_TEXT(card
, 4, "arpinv");
1615 static int arpentry_matches_prot(struct qeth_arp_entrytype
*type
, __u16 prot
)
1617 return (type
->ip
== QETHARP_IP_ADDR_V4
&& prot
== QETH_PROT_IPV4
) ||
1618 (type
->ip
== QETHARP_IP_ADDR_V6
&& prot
== QETH_PROT_IPV6
);
1621 static int qeth_l3_arp_query_cb(struct qeth_card
*card
,
1622 struct qeth_reply
*reply
, unsigned long data
)
1624 struct qeth_ipa_cmd
*cmd
;
1625 struct qeth_arp_query_data
*qdata
;
1626 struct qeth_arp_query_info
*qinfo
;
1628 int entrybytes_done
;
1630 __u8 do_strip_entries
;
1632 QETH_CARD_TEXT(card
, 3, "arpquecb");
1634 qinfo
= (struct qeth_arp_query_info
*) reply
->param
;
1635 cmd
= (struct qeth_ipa_cmd
*) data
;
1636 QETH_CARD_TEXT_(card
, 4, "%i", cmd
->hdr
.prot_version
);
1637 if (cmd
->hdr
.return_code
) {
1638 QETH_CARD_TEXT(card
, 4, "arpcberr");
1639 QETH_CARD_TEXT_(card
, 4, "%i", cmd
->hdr
.return_code
);
1640 return qeth_l3_arp_makerc(cmd
->hdr
.return_code
);
1642 if (cmd
->data
.setassparms
.hdr
.return_code
) {
1643 cmd
->hdr
.return_code
= cmd
->data
.setassparms
.hdr
.return_code
;
1644 QETH_CARD_TEXT(card
, 4, "setaperr");
1645 QETH_CARD_TEXT_(card
, 4, "%i", cmd
->hdr
.return_code
);
1646 return qeth_l3_arp_makerc(cmd
->hdr
.return_code
);
1648 qdata
= &cmd
->data
.setassparms
.data
.query_arp
;
1649 QETH_CARD_TEXT_(card
, 4, "anoen%i", qdata
->no_entries
);
1651 do_strip_entries
= (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
) > 0;
1652 stripped_bytes
= do_strip_entries
? QETH_QARP_MEDIASPECIFIC_BYTES
: 0;
1653 entrybytes_done
= 0;
1654 for (e
= 0; e
< qdata
->no_entries
; ++e
) {
1657 struct qeth_arp_entrytype
*etype
;
1659 cur_entry
= &qdata
->data
+ entrybytes_done
;
1660 etype
= &((struct qeth_arp_qi_entry5
*) cur_entry
)->type
;
1661 if (!arpentry_matches_prot(etype
, cmd
->hdr
.prot_version
)) {
1662 QETH_CARD_TEXT(card
, 4, "pmis");
1663 QETH_CARD_TEXT_(card
, 4, "%i", etype
->ip
);
1666 esize
= get_arp_entry_size(card
, qdata
, etype
,
1668 QETH_CARD_TEXT_(card
, 5, "esz%i", esize
);
1672 if ((qinfo
->udata_len
- qinfo
->udata_offset
) < esize
) {
1673 QETH_CARD_TEXT_(card
, 4, "qaer3%i", -ENOSPC
);
1674 memset(qinfo
->udata
, 0, 4);
1678 memcpy(qinfo
->udata
+ qinfo
->udata_offset
,
1679 &qdata
->data
+ entrybytes_done
+ stripped_bytes
,
1681 entrybytes_done
+= esize
+ stripped_bytes
;
1682 qinfo
->udata_offset
+= esize
;
1683 ++qinfo
->no_entries
;
1685 /* check if all replies received ... */
1686 if (cmd
->data
.setassparms
.hdr
.seq_no
<
1687 cmd
->data
.setassparms
.hdr
.number_of_replies
)
1689 QETH_CARD_TEXT_(card
, 4, "nove%i", qinfo
->no_entries
);
1690 memcpy(qinfo
->udata
, &qinfo
->no_entries
, 4);
1691 /* keep STRIP_ENTRIES flag so the user program can distinguish
1692 * stripped entries from normal ones */
1693 if (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
)
1694 qdata
->reply_bits
|= QETH_QARP_STRIP_ENTRIES
;
1695 memcpy(qinfo
->udata
+ QETH_QARP_MASK_OFFSET
, &qdata
->reply_bits
, 2);
1696 QETH_CARD_TEXT_(card
, 4, "rc%i", 0);
1700 static int qeth_l3_query_arp_cache_info(struct qeth_card
*card
,
1701 enum qeth_prot_versions prot
,
1702 struct qeth_arp_query_info
*qinfo
)
1704 struct qeth_cmd_buffer
*iob
;
1705 struct qeth_ipa_cmd
*cmd
;
1708 QETH_CARD_TEXT_(card
, 3, "qarpipv%i", prot
);
1710 iob
= qeth_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
1711 IPA_CMD_ASS_ARP_QUERY_INFO
,
1712 sizeof(struct qeth_arp_query_data
)
1717 cmd
= __ipa_cmd(iob
);
1718 cmd
->data
.setassparms
.data
.query_arp
.request_bits
= 0x000F;
1719 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_l3_arp_query_cb
, qinfo
);
1721 QETH_DBF_MESSAGE(2, "Error while querying ARP cache on device %x: %#x\n",
1722 CARD_DEVID(card
), rc
);
1726 static int qeth_l3_arp_query(struct qeth_card
*card
, char __user
*udata
)
1728 struct qeth_arp_query_info qinfo
= {0, };
1731 QETH_CARD_TEXT(card
, 3, "arpquery");
1733 if (!qeth_is_supported(card
,/*IPA_QUERY_ARP_ADDR_INFO*/
1734 IPA_ARP_PROCESSING
)) {
1735 QETH_CARD_TEXT(card
, 3, "arpqnsup");
1739 /* get size of userspace buffer and mask_bits -> 6 bytes */
1740 if (copy_from_user(&qinfo
, udata
, 6)) {
1744 qinfo
.udata
= kzalloc(qinfo
.udata_len
, GFP_KERNEL
);
1749 qinfo
.udata_offset
= QETH_QARP_ENTRIES_OFFSET
;
1750 rc
= qeth_l3_query_arp_cache_info(card
, QETH_PROT_IPV4
, &qinfo
);
1752 if (copy_to_user(udata
, qinfo
.udata
, 4))
1756 if (qinfo
.mask_bits
& QETH_QARP_WITH_IPV6
) {
1757 /* fails in case of GuestLAN QDIO mode */
1758 qeth_l3_query_arp_cache_info(card
, QETH_PROT_IPV6
, &qinfo
);
1760 if (copy_to_user(udata
, qinfo
.udata
, qinfo
.udata_len
)) {
1761 QETH_CARD_TEXT(card
, 4, "qactf");
1765 QETH_CARD_TEXT(card
, 4, "qacts");
1773 static int qeth_l3_arp_modify_entry(struct qeth_card
*card
,
1774 struct qeth_arp_cache_entry
*entry
,
1775 enum qeth_arp_process_subcmds arp_cmd
)
1777 struct qeth_arp_cache_entry
*cmd_entry
;
1778 struct qeth_cmd_buffer
*iob
;
1781 if (arp_cmd
== IPA_CMD_ASS_ARP_ADD_ENTRY
)
1782 QETH_CARD_TEXT(card
, 3, "arpadd");
1784 QETH_CARD_TEXT(card
, 3, "arpdel");
1787 * currently GuestLAN only supports the ARP assist function
1788 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_ADD_ENTRY;
1789 * thus we say EOPNOTSUPP for this ARP function
1791 if (IS_VM_NIC(card
))
1793 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
1797 iob
= qeth_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
, arp_cmd
,
1798 sizeof(*cmd_entry
), QETH_PROT_IPV4
);
1802 cmd_entry
= &__ipa_cmd(iob
)->data
.setassparms
.data
.arp_entry
;
1803 ether_addr_copy(cmd_entry
->macaddr
, entry
->macaddr
);
1804 memcpy(cmd_entry
->ipaddr
, entry
->ipaddr
, 4);
1805 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_l3_arp_cmd_cb
, NULL
);
1807 QETH_DBF_MESSAGE(2, "Could not modify (cmd: %#x) ARP entry on device %x: %#x\n",
1808 arp_cmd
, CARD_DEVID(card
), rc
);
1812 static int qeth_l3_arp_flush_cache(struct qeth_card
*card
)
1814 struct qeth_cmd_buffer
*iob
;
1817 QETH_CARD_TEXT(card
, 3, "arpflush");
1820 * currently GuestLAN only supports the ARP assist function
1821 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_FLUSH_CACHE;
1822 * thus we say EOPNOTSUPP for this ARP function
1824 if (IS_VM_NIC(card
) || IS_IQD(card
))
1826 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
1830 iob
= qeth_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
1831 IPA_CMD_ASS_ARP_FLUSH_CACHE
, 0,
1836 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_l3_arp_cmd_cb
, NULL
);
1838 QETH_DBF_MESSAGE(2, "Could not flush ARP cache on device %x: %#x\n",
1839 CARD_DEVID(card
), rc
);
1843 static int qeth_l3_do_ioctl(struct net_device
*dev
, struct ifreq
*rq
, int cmd
)
1845 struct qeth_card
*card
= dev
->ml_priv
;
1846 struct qeth_arp_cache_entry arp_entry
;
1847 enum qeth_arp_process_subcmds arp_cmd
;
1851 case SIOC_QETH_ARP_SET_NO_ENTRIES
:
1852 if (!capable(CAP_NET_ADMIN
)) {
1856 rc
= qeth_l3_arp_set_no_entries(card
, rq
->ifr_ifru
.ifru_ivalue
);
1858 case SIOC_QETH_ARP_QUERY_INFO
:
1859 if (!capable(CAP_NET_ADMIN
)) {
1863 rc
= qeth_l3_arp_query(card
, rq
->ifr_ifru
.ifru_data
);
1865 case SIOC_QETH_ARP_ADD_ENTRY
:
1866 case SIOC_QETH_ARP_REMOVE_ENTRY
:
1867 if (!capable(CAP_NET_ADMIN
))
1869 if (copy_from_user(&arp_entry
, rq
->ifr_data
, sizeof(arp_entry
)))
1872 arp_cmd
= (cmd
== SIOC_QETH_ARP_ADD_ENTRY
) ?
1873 IPA_CMD_ASS_ARP_ADD_ENTRY
:
1874 IPA_CMD_ASS_ARP_REMOVE_ENTRY
;
1875 return qeth_l3_arp_modify_entry(card
, &arp_entry
, arp_cmd
);
1876 case SIOC_QETH_ARP_FLUSH_CACHE
:
1877 if (!capable(CAP_NET_ADMIN
)) {
1881 rc
= qeth_l3_arp_flush_cache(card
);
1889 static int qeth_l3_get_cast_type(struct sk_buff
*skb
)
1891 struct neighbour
*n
= NULL
;
1892 struct dst_entry
*dst
;
1897 n
= dst_neigh_lookup_skb(dst
, skb
);
1899 int cast_type
= n
->type
;
1903 if ((cast_type
== RTN_BROADCAST
) ||
1904 (cast_type
== RTN_MULTICAST
) ||
1905 (cast_type
== RTN_ANYCAST
))
1911 /* no neighbour (eg AF_PACKET), fall back to target's IP address ... */
1912 switch (qeth_get_ip_version(skb
)) {
1914 return ipv4_is_multicast(ip_hdr(skb
)->daddr
) ?
1915 RTN_MULTICAST
: RTN_UNICAST
;
1917 return ipv6_addr_is_multicast(&ipv6_hdr(skb
)->daddr
) ?
1918 RTN_MULTICAST
: RTN_UNICAST
;
1920 /* ... and MAC address */
1921 return qeth_get_ether_cast_type(skb
);
1925 static u8
qeth_l3_cast_type_to_flag(int cast_type
)
1927 if (cast_type
== RTN_MULTICAST
)
1928 return QETH_CAST_MULTICAST
;
1929 if (cast_type
== RTN_ANYCAST
)
1930 return QETH_CAST_ANYCAST
;
1931 if (cast_type
== RTN_BROADCAST
)
1932 return QETH_CAST_BROADCAST
;
1933 return QETH_CAST_UNICAST
;
1936 static void qeth_l3_fill_header(struct qeth_qdio_out_q
*queue
,
1937 struct qeth_hdr
*hdr
, struct sk_buff
*skb
,
1938 int ipv
, int cast_type
, unsigned int data_len
)
1940 struct qeth_hdr_layer3
*l3_hdr
= &hdr
->hdr
.l3
;
1941 struct vlan_ethhdr
*veth
= vlan_eth_hdr(skb
);
1942 struct qeth_card
*card
= queue
->card
;
1944 hdr
->hdr
.l3
.length
= data_len
;
1946 if (skb_is_gso(skb
)) {
1947 hdr
->hdr
.l3
.id
= QETH_HEADER_TYPE_L3_TSO
;
1949 hdr
->hdr
.l3
.id
= QETH_HEADER_TYPE_LAYER3
;
1951 if (skb
->protocol
== htons(ETH_P_AF_IUCV
)) {
1952 l3_hdr
->flags
= QETH_HDR_IPV6
| QETH_CAST_UNICAST
;
1953 l3_hdr
->next_hop
.ipv6_addr
.s6_addr16
[0] = htons(0xfe80);
1954 memcpy(&l3_hdr
->next_hop
.ipv6_addr
.s6_addr32
[2],
1955 iucv_trans_hdr(skb
)->destUserID
, 8);
1959 if (skb
->ip_summed
== CHECKSUM_PARTIAL
) {
1960 qeth_tx_csum(skb
, &hdr
->hdr
.l3
.ext_flags
, ipv
);
1961 /* some HW requires combined L3+L4 csum offload: */
1963 hdr
->hdr
.l3
.ext_flags
|= QETH_HDR_EXT_CSUM_HDR_REQ
;
1964 QETH_TXQ_STAT_INC(queue
, skbs_csum
);
1968 if (ipv
== 4 || IS_IQD(card
)) {
1969 /* NETIF_F_HW_VLAN_CTAG_TX */
1970 if (skb_vlan_tag_present(skb
)) {
1971 hdr
->hdr
.l3
.ext_flags
|= QETH_HDR_EXT_VLAN_FRAME
;
1972 hdr
->hdr
.l3
.vlan_id
= skb_vlan_tag_get(skb
);
1974 } else if (veth
->h_vlan_proto
== htons(ETH_P_8021Q
)) {
1975 hdr
->hdr
.l3
.ext_flags
|= QETH_HDR_EXT_INCLUDE_VLAN_TAG
;
1976 hdr
->hdr
.l3
.vlan_id
= ntohs(veth
->h_vlan_TCI
);
1979 l3_hdr
->flags
= qeth_l3_cast_type_to_flag(cast_type
);
1983 l3_hdr
->flags
|= QETH_HDR_PASSTHRU
;
1989 struct rtable
*rt
= skb_rtable(skb
);
1991 *((__be32
*) &hdr
->hdr
.l3
.next_hop
.ipv4
.addr
) = (rt
) ?
1992 rt_nexthop(rt
, ip_hdr(skb
)->daddr
) :
1996 const struct rt6_info
*rt
= skb_rt6_info(skb
);
1998 if (rt
&& !ipv6_addr_any(&rt
->rt6i_gateway
))
1999 l3_hdr
->next_hop
.ipv6_addr
= rt
->rt6i_gateway
;
2001 l3_hdr
->next_hop
.ipv6_addr
= ipv6_hdr(skb
)->daddr
;
2003 hdr
->hdr
.l3
.flags
|= QETH_HDR_IPV6
;
2005 hdr
->hdr
.l3
.flags
|= QETH_HDR_PASSTHRU
;
2010 static void qeth_l3_fixup_headers(struct sk_buff
*skb
)
2012 struct iphdr
*iph
= ip_hdr(skb
);
2014 /* this is safe, IPv6 traffic takes a different path */
2015 if (skb
->ip_summed
== CHECKSUM_PARTIAL
)
2017 if (skb_is_gso(skb
)) {
2019 tcp_hdr(skb
)->check
= ~tcp_v4_check(0, iph
->saddr
,
2024 static int qeth_l3_xmit(struct qeth_card
*card
, struct sk_buff
*skb
,
2025 struct qeth_qdio_out_q
*queue
, int ipv
, int cast_type
)
2027 unsigned int hw_hdr_len
;
2030 /* re-use the L2 header area for the HW header: */
2031 hw_hdr_len
= skb_is_gso(skb
) ? sizeof(struct qeth_hdr_tso
) :
2032 sizeof(struct qeth_hdr
);
2033 rc
= skb_cow_head(skb
, hw_hdr_len
- ETH_HLEN
);
2036 skb_pull(skb
, ETH_HLEN
);
2038 qeth_l3_fixup_headers(skb
);
2039 return qeth_xmit(card
, skb
, queue
, ipv
, cast_type
, qeth_l3_fill_header
);
2042 static netdev_tx_t
qeth_l3_hard_start_xmit(struct sk_buff
*skb
,
2043 struct net_device
*dev
)
2045 struct qeth_card
*card
= dev
->ml_priv
;
2046 u16 txq
= skb_get_queue_mapping(skb
);
2047 int ipv
= qeth_get_ip_version(skb
);
2048 struct qeth_qdio_out_q
*queue
;
2049 int tx_bytes
= skb
->len
;
2053 queue
= card
->qdio
.out_qs
[qeth_iqd_translate_txq(dev
, txq
)];
2055 if (card
->options
.sniffer
)
2057 if ((card
->options
.cq
!= QETH_CQ_ENABLED
&& !ipv
) ||
2058 (card
->options
.cq
== QETH_CQ_ENABLED
&&
2059 skb
->protocol
!= htons(ETH_P_AF_IUCV
)))
2062 if (txq
== QETH_IQD_MCAST_TXQ
)
2063 cast_type
= qeth_l3_get_cast_type(skb
);
2065 cast_type
= RTN_UNICAST
;
2067 queue
= card
->qdio
.out_qs
[txq
];
2068 cast_type
= qeth_l3_get_cast_type(skb
);
2071 if (cast_type
== RTN_BROADCAST
&& !card
->info
.broadcast_capable
)
2074 if (ipv
== 4 || IS_IQD(card
))
2075 rc
= qeth_l3_xmit(card
, skb
, queue
, ipv
, cast_type
);
2077 rc
= qeth_xmit(card
, skb
, queue
, ipv
, cast_type
,
2078 qeth_l3_fill_header
);
2081 QETH_TXQ_STAT_INC(queue
, tx_packets
);
2082 QETH_TXQ_STAT_ADD(queue
, tx_bytes
, tx_bytes
);
2083 return NETDEV_TX_OK
;
2087 QETH_TXQ_STAT_INC(queue
, tx_dropped
);
2089 return NETDEV_TX_OK
;
2092 static void qeth_l3_set_rx_mode(struct net_device
*dev
)
2094 struct qeth_card
*card
= dev
->ml_priv
;
2096 schedule_work(&card
->rx_mode_work
);
2100 * we need NOARP for IPv4 but we want neighbor solicitation for IPv6. Setting
2101 * NOARP on the netdevice is no option because it also turns off neighbor
2102 * solicitation. For IPv4 we install a neighbor_setup function. We don't want
2103 * arp resolution but we want the hard header (packet socket will work
2106 static int qeth_l3_neigh_setup_noarp(struct neighbour
*n
)
2108 n
->nud_state
= NUD_NOARP
;
2109 memcpy(n
->ha
, "FAKELL", 6);
2110 n
->output
= n
->ops
->connected_output
;
2115 qeth_l3_neigh_setup(struct net_device
*dev
, struct neigh_parms
*np
)
2117 if (np
->tbl
->family
== AF_INET
)
2118 np
->neigh_setup
= qeth_l3_neigh_setup_noarp
;
2123 static netdev_features_t
qeth_l3_osa_features_check(struct sk_buff
*skb
,
2124 struct net_device
*dev
,
2125 netdev_features_t features
)
2127 if (qeth_get_ip_version(skb
) != 4)
2128 features
&= ~NETIF_F_HW_VLAN_CTAG_TX
;
2129 return qeth_features_check(skb
, dev
, features
);
2132 static u16
qeth_l3_iqd_select_queue(struct net_device
*dev
, struct sk_buff
*skb
,
2133 struct net_device
*sb_dev
)
2135 return qeth_iqd_select_queue(dev
, skb
, qeth_l3_get_cast_type(skb
),
2139 static u16
qeth_l3_osa_select_queue(struct net_device
*dev
, struct sk_buff
*skb
,
2140 struct net_device
*sb_dev
)
2142 struct qeth_card
*card
= dev
->ml_priv
;
2144 return qeth_get_priority_queue(card
, skb
);
2147 static const struct net_device_ops qeth_l3_netdev_ops
= {
2148 .ndo_open
= qeth_open
,
2149 .ndo_stop
= qeth_stop
,
2150 .ndo_get_stats64
= qeth_get_stats64
,
2151 .ndo_start_xmit
= qeth_l3_hard_start_xmit
,
2152 .ndo_select_queue
= qeth_l3_iqd_select_queue
,
2153 .ndo_validate_addr
= eth_validate_addr
,
2154 .ndo_set_rx_mode
= qeth_l3_set_rx_mode
,
2155 .ndo_do_ioctl
= qeth_do_ioctl
,
2156 .ndo_fix_features
= qeth_fix_features
,
2157 .ndo_set_features
= qeth_set_features
,
2158 .ndo_vlan_rx_add_vid
= qeth_l3_vlan_rx_add_vid
,
2159 .ndo_vlan_rx_kill_vid
= qeth_l3_vlan_rx_kill_vid
,
2160 .ndo_tx_timeout
= qeth_tx_timeout
,
2163 static const struct net_device_ops qeth_l3_osa_netdev_ops
= {
2164 .ndo_open
= qeth_open
,
2165 .ndo_stop
= qeth_stop
,
2166 .ndo_get_stats64
= qeth_get_stats64
,
2167 .ndo_start_xmit
= qeth_l3_hard_start_xmit
,
2168 .ndo_features_check
= qeth_l3_osa_features_check
,
2169 .ndo_select_queue
= qeth_l3_osa_select_queue
,
2170 .ndo_validate_addr
= eth_validate_addr
,
2171 .ndo_set_rx_mode
= qeth_l3_set_rx_mode
,
2172 .ndo_do_ioctl
= qeth_do_ioctl
,
2173 .ndo_fix_features
= qeth_fix_features
,
2174 .ndo_set_features
= qeth_set_features
,
2175 .ndo_vlan_rx_add_vid
= qeth_l3_vlan_rx_add_vid
,
2176 .ndo_vlan_rx_kill_vid
= qeth_l3_vlan_rx_kill_vid
,
2177 .ndo_tx_timeout
= qeth_tx_timeout
,
2178 .ndo_neigh_setup
= qeth_l3_neigh_setup
,
2181 static int qeth_l3_setup_netdev(struct qeth_card
*card
, bool carrier_ok
)
2183 unsigned int headroom
;
2186 if (IS_OSD(card
) || IS_OSX(card
)) {
2187 if ((card
->info
.link_type
== QETH_LINK_TYPE_LANE_TR
) ||
2188 (card
->info
.link_type
== QETH_LINK_TYPE_HSTR
)) {
2189 pr_info("qeth_l3: ignoring TR device\n");
2193 card
->dev
->netdev_ops
= &qeth_l3_osa_netdev_ops
;
2195 /*IPv6 address autoconfiguration stuff*/
2196 qeth_l3_get_unique_id(card
);
2197 if (!(card
->info
.unique_id
& UNIQUE_ID_NOT_BY_CARD
))
2198 card
->dev
->dev_id
= card
->info
.unique_id
& 0xffff;
2200 if (!IS_VM_NIC(card
)) {
2201 card
->dev
->features
|= NETIF_F_SG
;
2202 card
->dev
->hw_features
|= NETIF_F_TSO
|
2203 NETIF_F_RXCSUM
| NETIF_F_IP_CSUM
;
2204 card
->dev
->vlan_features
|= NETIF_F_TSO
|
2205 NETIF_F_RXCSUM
| NETIF_F_IP_CSUM
;
2208 if (qeth_is_supported6(card
, IPA_OUTBOUND_CHECKSUM_V6
)) {
2209 card
->dev
->hw_features
|= NETIF_F_IPV6_CSUM
;
2210 card
->dev
->vlan_features
|= NETIF_F_IPV6_CSUM
;
2212 if (qeth_is_supported6(card
, IPA_OUTBOUND_TSO
)) {
2213 card
->dev
->hw_features
|= NETIF_F_TSO6
;
2214 card
->dev
->vlan_features
|= NETIF_F_TSO6
;
2217 /* allow for de-acceleration of NETIF_F_HW_VLAN_CTAG_TX: */
2218 if (card
->dev
->hw_features
& NETIF_F_TSO6
)
2219 headroom
= sizeof(struct qeth_hdr_tso
) + VLAN_HLEN
;
2220 else if (card
->dev
->hw_features
& NETIF_F_TSO
)
2221 headroom
= sizeof(struct qeth_hdr_tso
);
2223 headroom
= sizeof(struct qeth_hdr
) + VLAN_HLEN
;
2224 } else if (IS_IQD(card
)) {
2225 card
->dev
->flags
|= IFF_NOARP
;
2226 card
->dev
->netdev_ops
= &qeth_l3_netdev_ops
;
2227 headroom
= sizeof(struct qeth_hdr
) - ETH_HLEN
;
2229 rc
= qeth_l3_iqd_read_initial_mac(card
);
2235 card
->dev
->needed_headroom
= headroom
;
2236 card
->dev
->features
|= NETIF_F_HW_VLAN_CTAG_TX
|
2237 NETIF_F_HW_VLAN_CTAG_RX
|
2238 NETIF_F_HW_VLAN_CTAG_FILTER
;
2240 netif_keep_dst(card
->dev
);
2241 if (card
->dev
->hw_features
& (NETIF_F_TSO
| NETIF_F_TSO6
))
2242 netif_set_gso_max_size(card
->dev
,
2243 PAGE_SIZE
* (QETH_MAX_BUFFER_ELEMENTS(card
) - 1));
2245 netif_napi_add(card
->dev
, &card
->napi
, qeth_poll
, QETH_NAPI_WEIGHT
);
2246 rc
= register_netdev(card
->dev
);
2247 if (!rc
&& carrier_ok
)
2248 netif_carrier_on(card
->dev
);
2252 card
->dev
->netdev_ops
= NULL
;
2256 static const struct device_type qeth_l3_devtype
= {
2257 .name
= "qeth_layer3",
2258 .groups
= qeth_l3_attr_groups
,
2261 static int qeth_l3_probe_device(struct ccwgroup_device
*gdev
)
2263 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
2266 hash_init(card
->ip_htable
);
2267 mutex_init(&card
->ip_lock
);
2268 card
->cmd_wq
= alloc_ordered_workqueue("%s_cmd", 0,
2269 dev_name(&gdev
->dev
));
2273 if (gdev
->dev
.type
== &qeth_generic_devtype
) {
2274 rc
= qeth_l3_create_device_attributes(&gdev
->dev
);
2276 destroy_workqueue(card
->cmd_wq
);
2281 hash_init(card
->ip_mc_htable
);
2282 INIT_WORK(&card
->rx_mode_work
, qeth_l3_rx_mode_work
);
2286 static void qeth_l3_remove_device(struct ccwgroup_device
*cgdev
)
2288 struct qeth_card
*card
= dev_get_drvdata(&cgdev
->dev
);
2290 if (cgdev
->dev
.type
== &qeth_generic_devtype
)
2291 qeth_l3_remove_device_attributes(&cgdev
->dev
);
2293 qeth_set_allowed_threads(card
, 0, 1);
2294 wait_event(card
->wait_q
, qeth_threads_running(card
, 0xffffffff) == 0);
2296 if (cgdev
->state
== CCWGROUP_ONLINE
)
2297 qeth_l3_set_offline(cgdev
);
2299 cancel_work_sync(&card
->close_dev_work
);
2300 if (qeth_netdev_is_registered(card
->dev
))
2301 unregister_netdev(card
->dev
);
2303 flush_workqueue(card
->cmd_wq
);
2304 destroy_workqueue(card
->cmd_wq
);
2305 qeth_l3_clear_ip_htable(card
, 0);
2306 qeth_l3_clear_ipato_list(card
);
2309 static int qeth_l3_set_online(struct ccwgroup_device
*gdev
)
2311 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
2312 struct net_device
*dev
= card
->dev
;
2316 mutex_lock(&card
->discipline_mutex
);
2317 mutex_lock(&card
->conf_mutex
);
2318 QETH_DBF_TEXT(SETUP
, 2, "setonlin");
2319 QETH_DBF_HEX(SETUP
, 2, &card
, sizeof(void *));
2321 rc
= qeth_core_hardsetup_card(card
, &carrier_ok
);
2323 QETH_DBF_TEXT_(SETUP
, 2, "2err%04x", rc
);
2328 if (qeth_is_diagass_supported(card
, QETH_DIAGS_CMD_TRAP
)) {
2329 if (card
->info
.hwtrap
&&
2330 qeth_hw_trap(card
, QETH_DIAGS_TRAP_ARM
))
2331 card
->info
.hwtrap
= 0;
2333 card
->info
.hwtrap
= 0;
2335 card
->state
= CARD_STATE_HARDSETUP
;
2336 qeth_print_status_message(card
);
2339 QETH_DBF_TEXT(SETUP
, 2, "softsetp");
2341 rc
= qeth_l3_setadapter_parms(card
);
2343 QETH_DBF_TEXT_(SETUP
, 2, "2err%04x", rc
);
2344 if (!card
->options
.sniffer
) {
2345 rc
= qeth_l3_start_ipassists(card
);
2347 QETH_DBF_TEXT_(SETUP
, 2, "3err%d", rc
);
2350 rc
= qeth_l3_setrouting_v4(card
);
2352 QETH_DBF_TEXT_(SETUP
, 2, "4err%04x", rc
);
2353 rc
= qeth_l3_setrouting_v6(card
);
2355 QETH_DBF_TEXT_(SETUP
, 2, "5err%04x", rc
);
2358 rc
= qeth_init_qdio_queues(card
);
2360 QETH_DBF_TEXT_(SETUP
, 2, "6err%d", rc
);
2364 card
->state
= CARD_STATE_SOFTSETUP
;
2366 qeth_set_allowed_threads(card
, 0xffffffff, 0);
2367 qeth_l3_recover_ip(card
);
2369 if (!qeth_netdev_is_registered(dev
)) {
2370 rc
= qeth_l3_setup_netdev(card
, carrier_ok
);
2376 netif_carrier_on(dev
);
2378 netif_carrier_off(dev
);
2380 netif_device_attach(dev
);
2381 qeth_enable_hw_features(dev
);
2383 if (card
->info
.open_when_online
) {
2384 card
->info
.open_when_online
= 0;
2385 dev_open(dev
, NULL
);
2389 qeth_trace_features(card
);
2390 /* let user_space know that device is online */
2391 kobject_uevent(&gdev
->dev
.kobj
, KOBJ_CHANGE
);
2392 mutex_unlock(&card
->conf_mutex
);
2393 mutex_unlock(&card
->discipline_mutex
);
2396 qeth_l3_stop_card(card
);
2397 ccw_device_set_offline(CARD_DDEV(card
));
2398 ccw_device_set_offline(CARD_WDEV(card
));
2399 ccw_device_set_offline(CARD_RDEV(card
));
2400 qdio_free(CARD_DDEV(card
));
2401 card
->state
= CARD_STATE_DOWN
;
2403 mutex_unlock(&card
->conf_mutex
);
2404 mutex_unlock(&card
->discipline_mutex
);
2408 static int __qeth_l3_set_offline(struct ccwgroup_device
*cgdev
,
2411 struct qeth_card
*card
= dev_get_drvdata(&cgdev
->dev
);
2412 int rc
= 0, rc2
= 0, rc3
= 0;
2414 mutex_lock(&card
->discipline_mutex
);
2415 mutex_lock(&card
->conf_mutex
);
2416 QETH_DBF_TEXT(SETUP
, 3, "setoffl");
2417 QETH_DBF_HEX(SETUP
, 3, &card
, sizeof(void *));
2419 if ((!recovery_mode
&& card
->info
.hwtrap
) || card
->info
.hwtrap
== 2) {
2420 qeth_hw_trap(card
, QETH_DIAGS_TRAP_DISARM
);
2421 card
->info
.hwtrap
= 1;
2425 card
->info
.open_when_online
= card
->dev
->flags
& IFF_UP
;
2426 dev_close(card
->dev
);
2427 netif_device_detach(card
->dev
);
2428 netif_carrier_off(card
->dev
);
2431 qeth_l3_stop_card(card
);
2432 if (card
->options
.cq
== QETH_CQ_ENABLED
) {
2434 call_netdevice_notifiers(NETDEV_REBOOT
, card
->dev
);
2437 rc
= ccw_device_set_offline(CARD_DDEV(card
));
2438 rc2
= ccw_device_set_offline(CARD_WDEV(card
));
2439 rc3
= ccw_device_set_offline(CARD_RDEV(card
));
2441 rc
= (rc2
) ? rc2
: rc3
;
2443 QETH_DBF_TEXT_(SETUP
, 2, "1err%d", rc
);
2444 qdio_free(CARD_DDEV(card
));
2446 /* let user_space know that device is offline */
2447 kobject_uevent(&cgdev
->dev
.kobj
, KOBJ_CHANGE
);
2448 mutex_unlock(&card
->conf_mutex
);
2449 mutex_unlock(&card
->discipline_mutex
);
2453 static int qeth_l3_set_offline(struct ccwgroup_device
*cgdev
)
2455 return __qeth_l3_set_offline(cgdev
, 0);
2458 static int qeth_l3_recover(void *ptr
)
2460 struct qeth_card
*card
;
2463 card
= (struct qeth_card
*) ptr
;
2464 QETH_CARD_TEXT(card
, 2, "recover1");
2465 QETH_CARD_HEX(card
, 2, &card
, sizeof(void *));
2466 if (!qeth_do_run_thread(card
, QETH_RECOVER_THREAD
))
2468 QETH_CARD_TEXT(card
, 2, "recover2");
2469 dev_warn(&card
->gdev
->dev
,
2470 "A recovery process has been started for the device\n");
2471 __qeth_l3_set_offline(card
->gdev
, 1);
2472 rc
= qeth_l3_set_online(card
->gdev
);
2474 dev_info(&card
->gdev
->dev
,
2475 "Device successfully recovered!\n");
2477 ccwgroup_set_offline(card
->gdev
);
2478 dev_warn(&card
->gdev
->dev
, "The qeth device driver "
2479 "failed to recover an error on the device\n");
2481 qeth_clear_thread_start_bit(card
, QETH_RECOVER_THREAD
);
2482 qeth_clear_thread_running_bit(card
, QETH_RECOVER_THREAD
);
2486 static int qeth_l3_pm_suspend(struct ccwgroup_device
*gdev
)
2488 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
2490 qeth_set_allowed_threads(card
, 0, 1);
2491 wait_event(card
->wait_q
, qeth_threads_running(card
, 0xffffffff) == 0);
2492 if (gdev
->state
== CCWGROUP_OFFLINE
)
2495 qeth_l3_set_offline(gdev
);
2499 static int qeth_l3_pm_resume(struct ccwgroup_device
*gdev
)
2501 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
2504 rc
= qeth_l3_set_online(gdev
);
2506 qeth_set_allowed_threads(card
, 0xffffffff, 0);
2508 dev_warn(&card
->gdev
->dev
, "The qeth device driver "
2509 "failed to recover an error on the device\n");
2513 /* Returns zero if the command is successfully "consumed" */
2514 static int qeth_l3_control_event(struct qeth_card
*card
,
2515 struct qeth_ipa_cmd
*cmd
)
2520 struct qeth_discipline qeth_l3_discipline
= {
2521 .devtype
= &qeth_l3_devtype
,
2522 .process_rx_buffer
= qeth_l3_process_inbound_buffer
,
2523 .recover
= qeth_l3_recover
,
2524 .setup
= qeth_l3_probe_device
,
2525 .remove
= qeth_l3_remove_device
,
2526 .set_online
= qeth_l3_set_online
,
2527 .set_offline
= qeth_l3_set_offline
,
2528 .freeze
= qeth_l3_pm_suspend
,
2529 .thaw
= qeth_l3_pm_resume
,
2530 .restore
= qeth_l3_pm_resume
,
2531 .do_ioctl
= qeth_l3_do_ioctl
,
2532 .control_event_handler
= qeth_l3_control_event
,
2534 EXPORT_SYMBOL_GPL(qeth_l3_discipline
);
2536 static int qeth_l3_handle_ip_event(struct qeth_card
*card
,
2537 struct qeth_ipaddr
*addr
,
2538 unsigned long event
)
2542 qeth_l3_modify_ip(card
, addr
, true);
2545 qeth_l3_modify_ip(card
, addr
, false);
2552 struct qeth_l3_ip_event_work
{
2553 struct work_struct work
;
2554 struct qeth_card
*card
;
2555 struct qeth_ipaddr addr
;
2558 #define to_ip_work(w) container_of((w), struct qeth_l3_ip_event_work, work)
2560 static void qeth_l3_add_ip_worker(struct work_struct
*work
)
2562 struct qeth_l3_ip_event_work
*ip_work
= to_ip_work(work
);
2564 qeth_l3_modify_ip(ip_work
->card
, &ip_work
->addr
, true);
2568 static void qeth_l3_delete_ip_worker(struct work_struct
*work
)
2570 struct qeth_l3_ip_event_work
*ip_work
= to_ip_work(work
);
2572 qeth_l3_modify_ip(ip_work
->card
, &ip_work
->addr
, false);
2576 static struct qeth_card
*qeth_l3_get_card_from_dev(struct net_device
*dev
)
2578 if (is_vlan_dev(dev
))
2579 dev
= vlan_dev_real_dev(dev
);
2580 if (dev
->netdev_ops
== &qeth_l3_osa_netdev_ops
||
2581 dev
->netdev_ops
== &qeth_l3_netdev_ops
)
2582 return (struct qeth_card
*) dev
->ml_priv
;
2586 static int qeth_l3_ip_event(struct notifier_block
*this,
2587 unsigned long event
, void *ptr
)
2590 struct in_ifaddr
*ifa
= (struct in_ifaddr
*)ptr
;
2591 struct net_device
*dev
= ifa
->ifa_dev
->dev
;
2592 struct qeth_ipaddr addr
;
2593 struct qeth_card
*card
;
2595 if (dev_net(dev
) != &init_net
)
2598 card
= qeth_l3_get_card_from_dev(dev
);
2601 QETH_CARD_TEXT(card
, 3, "ipevent");
2603 qeth_l3_init_ipaddr(&addr
, QETH_IP_TYPE_NORMAL
, QETH_PROT_IPV4
);
2604 addr
.u
.a4
.addr
= be32_to_cpu(ifa
->ifa_address
);
2605 addr
.u
.a4
.mask
= be32_to_cpu(ifa
->ifa_mask
);
2607 return qeth_l3_handle_ip_event(card
, &addr
, event
);
2610 static struct notifier_block qeth_l3_ip_notifier
= {
2615 static int qeth_l3_ip6_event(struct notifier_block
*this,
2616 unsigned long event
, void *ptr
)
2618 struct inet6_ifaddr
*ifa
= (struct inet6_ifaddr
*)ptr
;
2619 struct net_device
*dev
= ifa
->idev
->dev
;
2620 struct qeth_l3_ip_event_work
*ip_work
;
2621 struct qeth_card
*card
;
2623 if (event
!= NETDEV_UP
&& event
!= NETDEV_DOWN
)
2626 card
= qeth_l3_get_card_from_dev(dev
);
2629 QETH_CARD_TEXT(card
, 3, "ip6event");
2630 if (!qeth_is_supported(card
, IPA_IPV6
))
2633 ip_work
= kmalloc(sizeof(*ip_work
), GFP_ATOMIC
);
2637 if (event
== NETDEV_UP
)
2638 INIT_WORK(&ip_work
->work
, qeth_l3_add_ip_worker
);
2640 INIT_WORK(&ip_work
->work
, qeth_l3_delete_ip_worker
);
2642 ip_work
->card
= card
;
2643 qeth_l3_init_ipaddr(&ip_work
->addr
, QETH_IP_TYPE_NORMAL
,
2645 ip_work
->addr
.u
.a6
.addr
= ifa
->addr
;
2646 ip_work
->addr
.u
.a6
.pfxlen
= ifa
->prefix_len
;
2648 queue_work(card
->cmd_wq
, &ip_work
->work
);
2652 static struct notifier_block qeth_l3_ip6_notifier
= {
2657 static int qeth_l3_register_notifiers(void)
2661 QETH_DBF_TEXT(SETUP
, 5, "regnotif");
2662 rc
= register_inetaddr_notifier(&qeth_l3_ip_notifier
);
2665 rc
= register_inet6addr_notifier(&qeth_l3_ip6_notifier
);
2667 unregister_inetaddr_notifier(&qeth_l3_ip_notifier
);
2673 static void qeth_l3_unregister_notifiers(void)
2675 QETH_DBF_TEXT(SETUP
, 5, "unregnot");
2676 WARN_ON(unregister_inetaddr_notifier(&qeth_l3_ip_notifier
));
2677 WARN_ON(unregister_inet6addr_notifier(&qeth_l3_ip6_notifier
));
2680 static int __init
qeth_l3_init(void)
2682 pr_info("register layer 3 discipline\n");
2683 return qeth_l3_register_notifiers();
2686 static void __exit
qeth_l3_exit(void)
2688 qeth_l3_unregister_notifiers();
2689 pr_info("unregister layer 3 discipline\n");
2692 module_init(qeth_l3_init
);
2693 module_exit(qeth_l3_exit
);
2694 MODULE_AUTHOR("Frank Blaschka <frank.blaschka@de.ibm.com>");
2695 MODULE_DESCRIPTION("qeth layer 3 discipline");
2696 MODULE_LICENSE("GPL");