2 * Copyright IBM Corp. 2007, 2009
3 * Author(s): Utz Bacher <utz.bacher@de.ibm.com>,
4 * Frank Pavlic <fpavlic@de.ibm.com>,
5 * Thomas Spatzier <tspat@de.ibm.com>,
6 * Frank Blaschka <frank.blaschka@de.ibm.com>
9 #define KMSG_COMPONENT "qeth"
10 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
12 #include <linux/module.h>
13 #include <linux/moduleparam.h>
14 #include <linux/bitops.h>
15 #include <linux/string.h>
16 #include <linux/errno.h>
17 #include <linux/kernel.h>
18 #include <linux/etherdevice.h>
20 #include <linux/ipv6.h>
21 #include <linux/inetdevice.h>
22 #include <linux/igmp.h>
23 #include <linux/slab.h>
24 #include <linux/if_vlan.h>
28 #include <net/route.h>
29 #include <net/ip6_fib.h>
30 #include <net/ip6_checksum.h>
31 #include <net/iucv/af_iucv.h>
32 #include <linux/hashtable.h>
37 static int qeth_l3_set_offline(struct ccwgroup_device
*);
38 static int qeth_l3_stop(struct net_device
*);
39 static void qeth_l3_set_multicast_list(struct net_device
*);
40 static int qeth_l3_register_addr_entry(struct qeth_card
*,
41 struct qeth_ipaddr
*);
42 static int qeth_l3_deregister_addr_entry(struct qeth_card
*,
43 struct qeth_ipaddr
*);
45 static int qeth_l3_isxdigit(char *buf
)
48 if (!isxdigit(*buf
++))
54 static void qeth_l3_ipaddr4_to_string(const __u8
*addr
, char *buf
)
56 sprintf(buf
, "%pI4", addr
);
59 static int qeth_l3_string_to_ipaddr4(const char *buf
, __u8
*addr
)
61 int count
= 0, rc
= 0;
65 rc
= sscanf(buf
, "%u.%u.%u.%u%c",
66 &in
[0], &in
[1], &in
[2], &in
[3], &c
);
67 if (rc
!= 4 && (rc
!= 5 || c
!= '\n'))
69 for (count
= 0; count
< 4; count
++) {
72 addr
[count
] = in
[count
];
77 static void qeth_l3_ipaddr6_to_string(const __u8
*addr
, char *buf
)
79 sprintf(buf
, "%pI6", addr
);
82 static int qeth_l3_string_to_ipaddr6(const char *buf
, __u8
*addr
)
84 const char *end
, *end_tmp
, *start
;
87 int num2
, cnt
, out
, found
, save_cnt
;
88 unsigned short in_tmp
[8] = {0, };
90 cnt
= out
= found
= save_cnt
= num2
= 0;
95 end
= strchr(start
, ':');
97 end
= buf
+ strlen(buf
);
98 end_tmp
= strchr(start
, '\n');
105 if ((end
- start
) > 4)
107 memcpy(num
, start
, end
- start
);
108 if (!qeth_l3_isxdigit(num
))
110 sscanf(start
, "%x", &num2
);
112 in_tmp
[save_cnt
++] = num2
;
124 if (cnt
+ save_cnt
> 8)
128 in
[cnt
--] = in_tmp
[--save_cnt
];
132 void qeth_l3_ipaddr_to_string(enum qeth_prot_versions proto
, const __u8
*addr
,
135 if (proto
== QETH_PROT_IPV4
)
136 qeth_l3_ipaddr4_to_string(addr
, buf
);
137 else if (proto
== QETH_PROT_IPV6
)
138 qeth_l3_ipaddr6_to_string(addr
, buf
);
141 int qeth_l3_string_to_ipaddr(const char *buf
, enum qeth_prot_versions proto
,
144 if (proto
== QETH_PROT_IPV4
)
145 return qeth_l3_string_to_ipaddr4(buf
, addr
);
146 else if (proto
== QETH_PROT_IPV6
)
147 return qeth_l3_string_to_ipaddr6(buf
, addr
);
152 static void qeth_l3_convert_addr_to_bits(u8
*addr
, u8
*bits
, int len
)
157 for (i
= 0; i
< len
; ++i
) {
159 for (j
= 7; j
>= 0; --j
) {
160 bits
[i
*8 + j
] = octet
& 1;
166 int qeth_l3_is_addr_covered_by_ipato(struct qeth_card
*card
,
167 struct qeth_ipaddr
*addr
)
169 struct qeth_ipato_entry
*ipatoe
;
170 u8 addr_bits
[128] = {0, };
171 u8 ipatoe_bits
[128] = {0, };
174 if (!card
->ipato
.enabled
)
177 qeth_l3_convert_addr_to_bits((u8
*) &addr
->u
, addr_bits
,
178 (addr
->proto
== QETH_PROT_IPV4
)? 4:16);
179 list_for_each_entry(ipatoe
, &card
->ipato
.entries
, entry
) {
180 if (addr
->proto
!= ipatoe
->proto
)
182 qeth_l3_convert_addr_to_bits(ipatoe
->addr
, ipatoe_bits
,
183 (ipatoe
->proto
== QETH_PROT_IPV4
) ?
185 if (addr
->proto
== QETH_PROT_IPV4
)
186 rc
= !memcmp(addr_bits
, ipatoe_bits
,
187 min(32, ipatoe
->mask_bits
));
189 rc
= !memcmp(addr_bits
, ipatoe_bits
,
190 min(128, ipatoe
->mask_bits
));
195 if ((addr
->proto
== QETH_PROT_IPV4
) && card
->ipato
.invert4
)
197 else if ((addr
->proto
== QETH_PROT_IPV6
) && card
->ipato
.invert6
)
204 qeth_l3_ipaddrs_is_equal(struct qeth_ipaddr
*addr1
, struct qeth_ipaddr
*addr2
)
206 return addr1
->proto
== addr2
->proto
&&
207 !memcmp(&addr1
->u
, &addr2
->u
, sizeof(addr1
->u
)) &&
208 !memcmp(&addr1
->mac
, &addr2
->mac
, sizeof(addr1
->mac
));
211 static struct qeth_ipaddr
*
212 qeth_l3_ip_from_hash(struct qeth_card
*card
, struct qeth_ipaddr
*tmp_addr
)
214 struct qeth_ipaddr
*addr
;
216 if (tmp_addr
->is_multicast
) {
217 hash_for_each_possible(card
->ip_mc_htable
, addr
,
218 hnode
, qeth_l3_ipaddr_hash(tmp_addr
))
219 if (qeth_l3_ipaddrs_is_equal(tmp_addr
, addr
))
222 hash_for_each_possible(card
->ip_htable
, addr
,
223 hnode
, qeth_l3_ipaddr_hash(tmp_addr
))
224 if (qeth_l3_ipaddrs_is_equal(tmp_addr
, addr
))
231 int qeth_l3_delete_ip(struct qeth_card
*card
, struct qeth_ipaddr
*tmp_addr
)
234 struct qeth_ipaddr
*addr
;
236 QETH_CARD_TEXT(card
, 4, "delip");
238 if (tmp_addr
->proto
== QETH_PROT_IPV4
)
239 QETH_CARD_HEX(card
, 4, &tmp_addr
->u
.a4
.addr
, 4);
241 QETH_CARD_HEX(card
, 4, &tmp_addr
->u
.a6
.addr
, 8);
242 QETH_CARD_HEX(card
, 4, ((char *)&tmp_addr
->u
.a6
.addr
) + 8, 8);
245 addr
= qeth_l3_ip_from_hash(card
, tmp_addr
);
250 if (addr
->type
== QETH_IP_TYPE_NORMAL
&& addr
->ref_counter
> 0)
252 if (addr
->in_progress
)
255 if (!qeth_card_hw_is_reachable(card
)) {
256 addr
->disp_flag
= QETH_DISP_ADDR_DELETE
;
260 rc
= qeth_l3_deregister_addr_entry(card
, addr
);
262 hash_del(&addr
->hnode
);
268 int qeth_l3_add_ip(struct qeth_card
*card
, struct qeth_ipaddr
*tmp_addr
)
271 struct qeth_ipaddr
*addr
;
273 QETH_CARD_TEXT(card
, 4, "addip");
275 if (tmp_addr
->proto
== QETH_PROT_IPV4
)
276 QETH_CARD_HEX(card
, 4, &tmp_addr
->u
.a4
.addr
, 4);
278 QETH_CARD_HEX(card
, 4, &tmp_addr
->u
.a6
.addr
, 8);
279 QETH_CARD_HEX(card
, 4, ((char *)&tmp_addr
->u
.a6
.addr
) + 8, 8);
282 addr
= qeth_l3_ip_from_hash(card
, tmp_addr
);
284 addr
= qeth_l3_get_addr_buffer(tmp_addr
->proto
);
288 memcpy(addr
, tmp_addr
, sizeof(struct qeth_ipaddr
));
289 addr
->ref_counter
= 1;
291 if (addr
->type
== QETH_IP_TYPE_NORMAL
&&
292 qeth_l3_is_addr_covered_by_ipato(card
, addr
)) {
293 QETH_CARD_TEXT(card
, 2, "tkovaddr");
294 addr
->set_flags
|= QETH_IPA_SETIP_TAKEOVER_FLAG
;
296 hash_add(card
->ip_htable
, &addr
->hnode
,
297 qeth_l3_ipaddr_hash(addr
));
299 if (!qeth_card_hw_is_reachable(card
)) {
300 addr
->disp_flag
= QETH_DISP_ADDR_ADD
;
304 /* qeth_l3_register_addr_entry can go to sleep
305 * if we add a IPV4 addr. It is caused by the reason
306 * that SETIP ipa cmd starts ARP staff for IPV4 addr.
307 * Thus we should unlock spinlock, and make a protection
308 * using in_progress variable to indicate that there is
309 * an hardware operation with this IPV4 address
311 if (addr
->proto
== QETH_PROT_IPV4
) {
312 addr
->in_progress
= 1;
313 spin_unlock_bh(&card
->ip_lock
);
314 rc
= qeth_l3_register_addr_entry(card
, addr
);
315 spin_lock_bh(&card
->ip_lock
);
316 addr
->in_progress
= 0;
318 rc
= qeth_l3_register_addr_entry(card
, addr
);
320 if (!rc
|| (rc
== IPA_RC_DUPLICATE_IP_ADDRESS
) ||
321 (rc
== IPA_RC_LAN_OFFLINE
)) {
322 addr
->disp_flag
= QETH_DISP_ADDR_DO_NOTHING
;
323 if (addr
->ref_counter
< 1) {
324 qeth_l3_delete_ip(card
, addr
);
328 hash_del(&addr
->hnode
);
332 if (addr
->type
== QETH_IP_TYPE_NORMAL
)
340 struct qeth_ipaddr
*qeth_l3_get_addr_buffer(
341 enum qeth_prot_versions prot
)
343 struct qeth_ipaddr
*addr
;
345 addr
= kzalloc(sizeof(struct qeth_ipaddr
), GFP_ATOMIC
);
349 addr
->type
= QETH_IP_TYPE_NORMAL
;
350 addr
->disp_flag
= QETH_DISP_ADDR_DO_NOTHING
;
356 static void qeth_l3_clear_ip_htable(struct qeth_card
*card
, int recover
)
358 struct qeth_ipaddr
*addr
;
359 struct hlist_node
*tmp
;
362 QETH_CARD_TEXT(card
, 4, "clearip");
364 if (recover
&& card
->options
.sniffer
)
367 spin_lock_bh(&card
->ip_lock
);
369 hash_for_each_safe(card
->ip_htable
, i
, tmp
, addr
, hnode
) {
371 hash_del(&addr
->hnode
);
375 addr
->disp_flag
= QETH_DISP_ADDR_ADD
;
378 spin_unlock_bh(&card
->ip_lock
);
380 spin_lock_bh(&card
->mclock
);
382 hash_for_each_safe(card
->ip_mc_htable
, i
, tmp
, addr
, hnode
) {
383 hash_del(&addr
->hnode
);
387 spin_unlock_bh(&card
->mclock
);
391 static void qeth_l3_recover_ip(struct qeth_card
*card
)
393 struct qeth_ipaddr
*addr
;
394 struct hlist_node
*tmp
;
398 QETH_CARD_TEXT(card
, 4, "recovrip");
400 spin_lock_bh(&card
->ip_lock
);
402 hash_for_each_safe(card
->ip_htable
, i
, tmp
, addr
, hnode
) {
403 if (addr
->disp_flag
== QETH_DISP_ADDR_DELETE
) {
404 qeth_l3_deregister_addr_entry(card
, addr
);
405 hash_del(&addr
->hnode
);
407 } else if (addr
->disp_flag
== QETH_DISP_ADDR_ADD
) {
408 if (addr
->proto
== QETH_PROT_IPV4
) {
409 addr
->in_progress
= 1;
410 spin_unlock_bh(&card
->ip_lock
);
411 rc
= qeth_l3_register_addr_entry(card
, addr
);
412 spin_lock_bh(&card
->ip_lock
);
413 addr
->in_progress
= 0;
415 rc
= qeth_l3_register_addr_entry(card
, addr
);
418 addr
->disp_flag
= QETH_DISP_ADDR_DO_NOTHING
;
419 if (addr
->ref_counter
< 1)
420 qeth_l3_delete_ip(card
, addr
);
422 hash_del(&addr
->hnode
);
428 spin_unlock_bh(&card
->ip_lock
);
432 static int qeth_l3_send_setdelmc(struct qeth_card
*card
,
433 struct qeth_ipaddr
*addr
, int ipacmd
)
436 struct qeth_cmd_buffer
*iob
;
437 struct qeth_ipa_cmd
*cmd
;
439 QETH_CARD_TEXT(card
, 4, "setdelmc");
441 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, addr
->proto
);
444 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
445 memcpy(&cmd
->data
.setdelipm
.mac
, addr
->mac
, OSA_ADDR_LEN
);
446 if (addr
->proto
== QETH_PROT_IPV6
)
447 memcpy(cmd
->data
.setdelipm
.ip6
, &addr
->u
.a6
.addr
,
448 sizeof(struct in6_addr
));
450 memcpy(&cmd
->data
.setdelipm
.ip4
, &addr
->u
.a4
.addr
, 4);
452 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
457 static void qeth_l3_fill_netmask(u8
*netmask
, unsigned int len
)
460 for (i
= 0; i
< 16; i
++) {
465 netmask
[i
] = (u8
)(0xFF00 >> j
);
471 static int qeth_l3_send_setdelip(struct qeth_card
*card
,
472 struct qeth_ipaddr
*addr
, int ipacmd
, unsigned int flags
)
475 struct qeth_cmd_buffer
*iob
;
476 struct qeth_ipa_cmd
*cmd
;
479 QETH_CARD_TEXT(card
, 4, "setdelip");
480 QETH_CARD_TEXT_(card
, 4, "flags%02X", flags
);
482 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, addr
->proto
);
485 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
486 if (addr
->proto
== QETH_PROT_IPV6
) {
487 memcpy(cmd
->data
.setdelip6
.ip_addr
, &addr
->u
.a6
.addr
,
488 sizeof(struct in6_addr
));
489 qeth_l3_fill_netmask(netmask
, addr
->u
.a6
.pfxlen
);
490 memcpy(cmd
->data
.setdelip6
.mask
, netmask
,
491 sizeof(struct in6_addr
));
492 cmd
->data
.setdelip6
.flags
= flags
;
494 memcpy(cmd
->data
.setdelip4
.ip_addr
, &addr
->u
.a4
.addr
, 4);
495 memcpy(cmd
->data
.setdelip4
.mask
, &addr
->u
.a4
.mask
, 4);
496 cmd
->data
.setdelip4
.flags
= flags
;
499 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
504 static int qeth_l3_send_setrouting(struct qeth_card
*card
,
505 enum qeth_routing_types type
, enum qeth_prot_versions prot
)
508 struct qeth_ipa_cmd
*cmd
;
509 struct qeth_cmd_buffer
*iob
;
511 QETH_CARD_TEXT(card
, 4, "setroutg");
512 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_SETRTG
, prot
);
515 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
516 cmd
->data
.setrtg
.type
= (type
);
517 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
522 static int qeth_l3_correct_routing_type(struct qeth_card
*card
,
523 enum qeth_routing_types
*type
, enum qeth_prot_versions prot
)
525 if (card
->info
.type
== QETH_CARD_TYPE_IQD
) {
528 case PRIMARY_CONNECTOR
:
529 case SECONDARY_CONNECTOR
:
530 case MULTICAST_ROUTER
:
539 case SECONDARY_ROUTER
:
541 case MULTICAST_ROUTER
:
542 if (qeth_is_ipafunc_supported(card
, prot
,
554 int qeth_l3_setrouting_v4(struct qeth_card
*card
)
558 QETH_CARD_TEXT(card
, 3, "setrtg4");
560 rc
= qeth_l3_correct_routing_type(card
, &card
->options
.route4
.type
,
565 rc
= qeth_l3_send_setrouting(card
, card
->options
.route4
.type
,
568 card
->options
.route4
.type
= NO_ROUTER
;
569 QETH_DBF_MESSAGE(2, "Error (0x%04x) while setting routing type"
570 " on %s. Type set to 'no router'.\n", rc
,
571 QETH_CARD_IFNAME(card
));
576 int qeth_l3_setrouting_v6(struct qeth_card
*card
)
580 QETH_CARD_TEXT(card
, 3, "setrtg6");
581 #ifdef CONFIG_QETH_IPV6
583 if (!qeth_is_supported(card
, IPA_IPV6
))
585 rc
= qeth_l3_correct_routing_type(card
, &card
->options
.route6
.type
,
590 rc
= qeth_l3_send_setrouting(card
, card
->options
.route6
.type
,
593 card
->options
.route6
.type
= NO_ROUTER
;
594 QETH_DBF_MESSAGE(2, "Error (0x%04x) while setting routing type"
595 " on %s. Type set to 'no router'.\n", rc
,
596 QETH_CARD_IFNAME(card
));
603 * IP address takeover related functions
605 static void qeth_l3_clear_ipato_list(struct qeth_card
*card
)
607 struct qeth_ipato_entry
*ipatoe
, *tmp
;
609 spin_lock_bh(&card
->ip_lock
);
611 list_for_each_entry_safe(ipatoe
, tmp
, &card
->ipato
.entries
, entry
) {
612 list_del(&ipatoe
->entry
);
616 spin_unlock_bh(&card
->ip_lock
);
619 int qeth_l3_add_ipato_entry(struct qeth_card
*card
,
620 struct qeth_ipato_entry
*new)
622 struct qeth_ipato_entry
*ipatoe
;
625 QETH_CARD_TEXT(card
, 2, "addipato");
627 spin_lock_bh(&card
->ip_lock
);
629 list_for_each_entry(ipatoe
, &card
->ipato
.entries
, entry
) {
630 if (ipatoe
->proto
!= new->proto
)
632 if (!memcmp(ipatoe
->addr
, new->addr
,
633 (ipatoe
->proto
== QETH_PROT_IPV4
)? 4:16) &&
634 (ipatoe
->mask_bits
== new->mask_bits
)) {
641 list_add_tail(&new->entry
, &card
->ipato
.entries
);
643 spin_unlock_bh(&card
->ip_lock
);
648 void qeth_l3_del_ipato_entry(struct qeth_card
*card
,
649 enum qeth_prot_versions proto
, u8
*addr
, int mask_bits
)
651 struct qeth_ipato_entry
*ipatoe
, *tmp
;
653 QETH_CARD_TEXT(card
, 2, "delipato");
655 spin_lock_bh(&card
->ip_lock
);
657 list_for_each_entry_safe(ipatoe
, tmp
, &card
->ipato
.entries
, entry
) {
658 if (ipatoe
->proto
!= proto
)
660 if (!memcmp(ipatoe
->addr
, addr
,
661 (proto
== QETH_PROT_IPV4
)? 4:16) &&
662 (ipatoe
->mask_bits
== mask_bits
)) {
663 list_del(&ipatoe
->entry
);
668 spin_unlock_bh(&card
->ip_lock
);
672 * VIPA related functions
674 int qeth_l3_add_vipa(struct qeth_card
*card
, enum qeth_prot_versions proto
,
677 struct qeth_ipaddr
*ipaddr
;
680 ipaddr
= qeth_l3_get_addr_buffer(proto
);
682 if (proto
== QETH_PROT_IPV4
) {
683 QETH_CARD_TEXT(card
, 2, "addvipa4");
684 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
685 ipaddr
->u
.a4
.mask
= 0;
686 } else if (proto
== QETH_PROT_IPV6
) {
687 QETH_CARD_TEXT(card
, 2, "addvipa6");
688 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
689 ipaddr
->u
.a6
.pfxlen
= 0;
691 ipaddr
->type
= QETH_IP_TYPE_VIPA
;
692 ipaddr
->set_flags
= QETH_IPA_SETIP_VIPA_FLAG
;
693 ipaddr
->del_flags
= QETH_IPA_DELIP_VIPA_FLAG
;
697 spin_lock_bh(&card
->ip_lock
);
699 if (qeth_l3_ip_from_hash(card
, ipaddr
))
702 qeth_l3_add_ip(card
, ipaddr
);
704 spin_unlock_bh(&card
->ip_lock
);
711 void qeth_l3_del_vipa(struct qeth_card
*card
, enum qeth_prot_versions proto
,
714 struct qeth_ipaddr
*ipaddr
;
716 ipaddr
= qeth_l3_get_addr_buffer(proto
);
718 if (proto
== QETH_PROT_IPV4
) {
719 QETH_CARD_TEXT(card
, 2, "delvipa4");
720 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
721 ipaddr
->u
.a4
.mask
= 0;
722 } else if (proto
== QETH_PROT_IPV6
) {
723 QETH_CARD_TEXT(card
, 2, "delvipa6");
724 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
725 ipaddr
->u
.a6
.pfxlen
= 0;
727 ipaddr
->type
= QETH_IP_TYPE_VIPA
;
731 spin_lock_bh(&card
->ip_lock
);
732 qeth_l3_delete_ip(card
, ipaddr
);
733 spin_unlock_bh(&card
->ip_lock
);
739 * proxy ARP related functions
741 int qeth_l3_add_rxip(struct qeth_card
*card
, enum qeth_prot_versions proto
,
744 struct qeth_ipaddr
*ipaddr
;
747 ipaddr
= qeth_l3_get_addr_buffer(proto
);
749 if (proto
== QETH_PROT_IPV4
) {
750 QETH_CARD_TEXT(card
, 2, "addrxip4");
751 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
752 ipaddr
->u
.a4
.mask
= 0;
753 } else if (proto
== QETH_PROT_IPV6
) {
754 QETH_CARD_TEXT(card
, 2, "addrxip6");
755 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
756 ipaddr
->u
.a6
.pfxlen
= 0;
759 ipaddr
->type
= QETH_IP_TYPE_RXIP
;
760 ipaddr
->set_flags
= QETH_IPA_SETIP_TAKEOVER_FLAG
;
761 ipaddr
->del_flags
= 0;
765 spin_lock_bh(&card
->ip_lock
);
767 if (qeth_l3_ip_from_hash(card
, ipaddr
))
770 qeth_l3_add_ip(card
, ipaddr
);
772 spin_unlock_bh(&card
->ip_lock
);
779 void qeth_l3_del_rxip(struct qeth_card
*card
, enum qeth_prot_versions proto
,
782 struct qeth_ipaddr
*ipaddr
;
784 ipaddr
= qeth_l3_get_addr_buffer(proto
);
786 if (proto
== QETH_PROT_IPV4
) {
787 QETH_CARD_TEXT(card
, 2, "addrxip4");
788 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
789 ipaddr
->u
.a4
.mask
= 0;
790 } else if (proto
== QETH_PROT_IPV6
) {
791 QETH_CARD_TEXT(card
, 2, "addrxip6");
792 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
793 ipaddr
->u
.a6
.pfxlen
= 0;
795 ipaddr
->type
= QETH_IP_TYPE_RXIP
;
799 spin_lock_bh(&card
->ip_lock
);
800 qeth_l3_delete_ip(card
, ipaddr
);
801 spin_unlock_bh(&card
->ip_lock
);
806 static int qeth_l3_register_addr_entry(struct qeth_card
*card
,
807 struct qeth_ipaddr
*addr
)
814 if (addr
->proto
== QETH_PROT_IPV4
) {
815 QETH_CARD_TEXT(card
, 2, "setaddr4");
816 QETH_CARD_HEX(card
, 3, &addr
->u
.a4
.addr
, sizeof(int));
817 } else if (addr
->proto
== QETH_PROT_IPV6
) {
818 QETH_CARD_TEXT(card
, 2, "setaddr6");
819 QETH_CARD_HEX(card
, 3, &addr
->u
.a6
.addr
, 8);
820 QETH_CARD_HEX(card
, 3, ((char *)&addr
->u
.a6
.addr
) + 8, 8);
822 QETH_CARD_TEXT(card
, 2, "setaddr?");
823 QETH_CARD_HEX(card
, 3, addr
, sizeof(struct qeth_ipaddr
));
826 if (addr
->is_multicast
)
827 rc
= qeth_l3_send_setdelmc(card
, addr
, IPA_CMD_SETIPM
);
829 rc
= qeth_l3_send_setdelip(card
, addr
, IPA_CMD_SETIP
,
832 QETH_CARD_TEXT(card
, 2, "failed");
833 } while ((--cnt
> 0) && rc
);
835 QETH_CARD_TEXT(card
, 2, "FAILED");
836 qeth_l3_ipaddr_to_string(addr
->proto
, (u8
*)&addr
->u
, buf
);
837 dev_warn(&card
->gdev
->dev
,
838 "Registering IP address %s failed\n", buf
);
843 static int qeth_l3_deregister_addr_entry(struct qeth_card
*card
,
844 struct qeth_ipaddr
*addr
)
848 if (addr
->proto
== QETH_PROT_IPV4
) {
849 QETH_CARD_TEXT(card
, 2, "deladdr4");
850 QETH_CARD_HEX(card
, 3, &addr
->u
.a4
.addr
, sizeof(int));
851 } else if (addr
->proto
== QETH_PROT_IPV6
) {
852 QETH_CARD_TEXT(card
, 2, "deladdr6");
853 QETH_CARD_HEX(card
, 3, &addr
->u
.a6
.addr
, 8);
854 QETH_CARD_HEX(card
, 3, ((char *)&addr
->u
.a6
.addr
) + 8, 8);
856 QETH_CARD_TEXT(card
, 2, "deladdr?");
857 QETH_CARD_HEX(card
, 3, addr
, sizeof(struct qeth_ipaddr
));
859 if (addr
->is_multicast
)
860 rc
= qeth_l3_send_setdelmc(card
, addr
, IPA_CMD_DELIPM
);
862 rc
= qeth_l3_send_setdelip(card
, addr
, IPA_CMD_DELIP
,
865 QETH_CARD_TEXT(card
, 2, "failed");
870 static inline u8
qeth_l3_get_qeth_hdr_flags4(int cast_type
)
872 if (cast_type
== RTN_MULTICAST
)
873 return QETH_CAST_MULTICAST
;
874 if (cast_type
== RTN_BROADCAST
)
875 return QETH_CAST_BROADCAST
;
876 return QETH_CAST_UNICAST
;
879 static inline u8
qeth_l3_get_qeth_hdr_flags6(int cast_type
)
881 u8 ct
= QETH_HDR_PASSTHRU
| QETH_HDR_IPV6
;
882 if (cast_type
== RTN_MULTICAST
)
883 return ct
| QETH_CAST_MULTICAST
;
884 if (cast_type
== RTN_ANYCAST
)
885 return ct
| QETH_CAST_ANYCAST
;
886 if (cast_type
== RTN_BROADCAST
)
887 return ct
| QETH_CAST_BROADCAST
;
888 return ct
| QETH_CAST_UNICAST
;
891 static int qeth_l3_setadapter_parms(struct qeth_card
*card
)
895 QETH_DBF_TEXT(SETUP
, 2, "setadprm");
897 if (!qeth_is_supported(card
, IPA_SETADAPTERPARMS
)) {
898 dev_info(&card
->gdev
->dev
,
899 "set adapter parameters not supported.\n");
900 QETH_DBF_TEXT(SETUP
, 2, " notsupp");
903 rc
= qeth_query_setadapterparms(card
);
905 QETH_DBF_MESSAGE(2, "%s couldn't set adapter parameters: "
906 "0x%x\n", dev_name(&card
->gdev
->dev
), rc
);
909 if (qeth_adp_supported(card
, IPA_SETADP_ALTER_MAC_ADDRESS
)) {
910 rc
= qeth_setadpparms_change_macaddr(card
);
912 dev_warn(&card
->gdev
->dev
, "Reading the adapter MAC"
913 " address failed\n");
919 #ifdef CONFIG_QETH_IPV6
920 static int qeth_l3_send_simple_setassparms_ipv6(struct qeth_card
*card
,
921 enum qeth_ipa_funcs ipa_func
, __u16 cmd_code
)
924 struct qeth_cmd_buffer
*iob
;
926 QETH_CARD_TEXT(card
, 4, "simassp6");
927 iob
= qeth_get_setassparms_cmd(card
, ipa_func
, cmd_code
,
931 rc
= qeth_send_setassparms(card
, iob
, 0, 0,
932 qeth_setassparms_cb
, NULL
);
937 static int qeth_l3_start_ipa_arp_processing(struct qeth_card
*card
)
941 QETH_CARD_TEXT(card
, 3, "ipaarp");
943 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
944 dev_info(&card
->gdev
->dev
,
945 "ARP processing not supported on %s!\n",
946 QETH_CARD_IFNAME(card
));
949 rc
= qeth_send_simple_setassparms(card
, IPA_ARP_PROCESSING
,
950 IPA_CMD_ASS_START
, 0);
952 dev_warn(&card
->gdev
->dev
,
953 "Starting ARP processing support for %s failed\n",
954 QETH_CARD_IFNAME(card
));
959 static int qeth_l3_start_ipa_ip_fragmentation(struct qeth_card
*card
)
963 QETH_CARD_TEXT(card
, 3, "ipaipfrg");
965 if (!qeth_is_supported(card
, IPA_IP_FRAGMENTATION
)) {
966 dev_info(&card
->gdev
->dev
,
967 "Hardware IP fragmentation not supported on %s\n",
968 QETH_CARD_IFNAME(card
));
972 rc
= qeth_send_simple_setassparms(card
, IPA_IP_FRAGMENTATION
,
973 IPA_CMD_ASS_START
, 0);
975 dev_warn(&card
->gdev
->dev
,
976 "Starting IP fragmentation support for %s failed\n",
977 QETH_CARD_IFNAME(card
));
979 dev_info(&card
->gdev
->dev
,
980 "Hardware IP fragmentation enabled \n");
984 static int qeth_l3_start_ipa_source_mac(struct qeth_card
*card
)
988 QETH_CARD_TEXT(card
, 3, "stsrcmac");
990 if (!qeth_is_supported(card
, IPA_SOURCE_MAC
)) {
991 dev_info(&card
->gdev
->dev
,
992 "Inbound source MAC-address not supported on %s\n",
993 QETH_CARD_IFNAME(card
));
997 rc
= qeth_send_simple_setassparms(card
, IPA_SOURCE_MAC
,
998 IPA_CMD_ASS_START
, 0);
1000 dev_warn(&card
->gdev
->dev
,
1001 "Starting source MAC-address support for %s failed\n",
1002 QETH_CARD_IFNAME(card
));
1006 static int qeth_l3_start_ipa_vlan(struct qeth_card
*card
)
1010 QETH_CARD_TEXT(card
, 3, "strtvlan");
1012 if (!qeth_is_supported(card
, IPA_FULL_VLAN
)) {
1013 dev_info(&card
->gdev
->dev
,
1014 "VLAN not supported on %s\n", QETH_CARD_IFNAME(card
));
1018 rc
= qeth_send_simple_setassparms(card
, IPA_VLAN_PRIO
,
1019 IPA_CMD_ASS_START
, 0);
1021 dev_warn(&card
->gdev
->dev
,
1022 "Starting VLAN support for %s failed\n",
1023 QETH_CARD_IFNAME(card
));
1025 dev_info(&card
->gdev
->dev
, "VLAN enabled\n");
1030 static int qeth_l3_start_ipa_multicast(struct qeth_card
*card
)
1034 QETH_CARD_TEXT(card
, 3, "stmcast");
1036 if (!qeth_is_supported(card
, IPA_MULTICASTING
)) {
1037 dev_info(&card
->gdev
->dev
,
1038 "Multicast not supported on %s\n",
1039 QETH_CARD_IFNAME(card
));
1043 rc
= qeth_send_simple_setassparms(card
, IPA_MULTICASTING
,
1044 IPA_CMD_ASS_START
, 0);
1046 dev_warn(&card
->gdev
->dev
,
1047 "Starting multicast support for %s failed\n",
1048 QETH_CARD_IFNAME(card
));
1050 dev_info(&card
->gdev
->dev
, "Multicast enabled\n");
1051 card
->dev
->flags
|= IFF_MULTICAST
;
1056 #ifdef CONFIG_QETH_IPV6
1057 static int qeth_l3_softsetup_ipv6(struct qeth_card
*card
)
1061 QETH_CARD_TEXT(card
, 3, "softipv6");
1063 if (card
->info
.type
== QETH_CARD_TYPE_IQD
)
1066 rc
= qeth_query_ipassists(card
, QETH_PROT_IPV6
);
1068 dev_err(&card
->gdev
->dev
,
1069 "Activating IPv6 support for %s failed\n",
1070 QETH_CARD_IFNAME(card
));
1073 rc
= qeth_send_simple_setassparms(card
, IPA_IPV6
,
1074 IPA_CMD_ASS_START
, 3);
1076 dev_err(&card
->gdev
->dev
,
1077 "Activating IPv6 support for %s failed\n",
1078 QETH_CARD_IFNAME(card
));
1081 rc
= qeth_l3_send_simple_setassparms_ipv6(card
, IPA_IPV6
,
1084 dev_err(&card
->gdev
->dev
,
1085 "Activating IPv6 support for %s failed\n",
1086 QETH_CARD_IFNAME(card
));
1089 rc
= qeth_l3_send_simple_setassparms_ipv6(card
, IPA_PASSTHRU
,
1092 dev_warn(&card
->gdev
->dev
,
1093 "Enabling the passthrough mode for %s failed\n",
1094 QETH_CARD_IFNAME(card
));
1098 dev_info(&card
->gdev
->dev
, "IPV6 enabled\n");
1103 static int qeth_l3_start_ipa_ipv6(struct qeth_card
*card
)
1107 QETH_CARD_TEXT(card
, 3, "strtipv6");
1109 if (!qeth_is_supported(card
, IPA_IPV6
)) {
1110 dev_info(&card
->gdev
->dev
,
1111 "IPv6 not supported on %s\n", QETH_CARD_IFNAME(card
));
1114 #ifdef CONFIG_QETH_IPV6
1115 rc
= qeth_l3_softsetup_ipv6(card
);
1120 static int qeth_l3_start_ipa_broadcast(struct qeth_card
*card
)
1124 QETH_CARD_TEXT(card
, 3, "stbrdcst");
1125 card
->info
.broadcast_capable
= 0;
1126 if (!qeth_is_supported(card
, IPA_FILTERING
)) {
1127 dev_info(&card
->gdev
->dev
,
1128 "Broadcast not supported on %s\n",
1129 QETH_CARD_IFNAME(card
));
1133 rc
= qeth_send_simple_setassparms(card
, IPA_FILTERING
,
1134 IPA_CMD_ASS_START
, 0);
1136 dev_warn(&card
->gdev
->dev
, "Enabling broadcast filtering for "
1137 "%s failed\n", QETH_CARD_IFNAME(card
));
1141 rc
= qeth_send_simple_setassparms(card
, IPA_FILTERING
,
1142 IPA_CMD_ASS_CONFIGURE
, 1);
1144 dev_warn(&card
->gdev
->dev
,
1145 "Setting up broadcast filtering for %s failed\n",
1146 QETH_CARD_IFNAME(card
));
1149 card
->info
.broadcast_capable
= QETH_BROADCAST_WITH_ECHO
;
1150 dev_info(&card
->gdev
->dev
, "Broadcast enabled\n");
1151 rc
= qeth_send_simple_setassparms(card
, IPA_FILTERING
,
1152 IPA_CMD_ASS_ENABLE
, 1);
1154 dev_warn(&card
->gdev
->dev
, "Setting up broadcast echo "
1155 "filtering for %s failed\n", QETH_CARD_IFNAME(card
));
1158 card
->info
.broadcast_capable
= QETH_BROADCAST_WITHOUT_ECHO
;
1160 if (card
->info
.broadcast_capable
)
1161 card
->dev
->flags
|= IFF_BROADCAST
;
1163 card
->dev
->flags
&= ~IFF_BROADCAST
;
1167 static int qeth_l3_start_ipassists(struct qeth_card
*card
)
1169 QETH_CARD_TEXT(card
, 3, "strtipas");
1171 if (qeth_set_access_ctrl_online(card
, 0))
1173 qeth_l3_start_ipa_arp_processing(card
); /* go on*/
1174 qeth_l3_start_ipa_ip_fragmentation(card
); /* go on*/
1175 qeth_l3_start_ipa_source_mac(card
); /* go on*/
1176 qeth_l3_start_ipa_vlan(card
); /* go on*/
1177 qeth_l3_start_ipa_multicast(card
); /* go on*/
1178 qeth_l3_start_ipa_ipv6(card
); /* go on*/
1179 qeth_l3_start_ipa_broadcast(card
); /* go on*/
1183 static int qeth_l3_iqd_read_initial_mac_cb(struct qeth_card
*card
,
1184 struct qeth_reply
*reply
, unsigned long data
)
1186 struct qeth_ipa_cmd
*cmd
;
1188 cmd
= (struct qeth_ipa_cmd
*) data
;
1189 if (cmd
->hdr
.return_code
== 0)
1190 memcpy(card
->dev
->dev_addr
,
1191 cmd
->data
.create_destroy_addr
.unique_id
, ETH_ALEN
);
1193 eth_random_addr(card
->dev
->dev_addr
);
1198 static int qeth_l3_iqd_read_initial_mac(struct qeth_card
*card
)
1201 struct qeth_cmd_buffer
*iob
;
1202 struct qeth_ipa_cmd
*cmd
;
1204 QETH_DBF_TEXT(SETUP
, 2, "hsrmac");
1206 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_CREATE_ADDR
,
1210 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
1211 *((__u16
*) &cmd
->data
.create_destroy_addr
.unique_id
[6]) =
1212 card
->info
.unique_id
;
1214 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_l3_iqd_read_initial_mac_cb
,
1219 static int qeth_l3_get_unique_id_cb(struct qeth_card
*card
,
1220 struct qeth_reply
*reply
, unsigned long data
)
1222 struct qeth_ipa_cmd
*cmd
;
1224 cmd
= (struct qeth_ipa_cmd
*) data
;
1225 if (cmd
->hdr
.return_code
== 0)
1226 card
->info
.unique_id
= *((__u16
*)
1227 &cmd
->data
.create_destroy_addr
.unique_id
[6]);
1229 card
->info
.unique_id
= UNIQUE_ID_IF_CREATE_ADDR_FAILED
|
1230 UNIQUE_ID_NOT_BY_CARD
;
1231 dev_warn(&card
->gdev
->dev
, "The network adapter failed to "
1232 "generate a unique ID\n");
1237 static int qeth_l3_get_unique_id(struct qeth_card
*card
)
1240 struct qeth_cmd_buffer
*iob
;
1241 struct qeth_ipa_cmd
*cmd
;
1243 QETH_DBF_TEXT(SETUP
, 2, "guniqeid");
1245 if (!qeth_is_supported(card
, IPA_IPV6
)) {
1246 card
->info
.unique_id
= UNIQUE_ID_IF_CREATE_ADDR_FAILED
|
1247 UNIQUE_ID_NOT_BY_CARD
;
1251 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_CREATE_ADDR
,
1255 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
1256 *((__u16
*) &cmd
->data
.create_destroy_addr
.unique_id
[6]) =
1257 card
->info
.unique_id
;
1259 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_l3_get_unique_id_cb
, NULL
);
1264 qeth_diags_trace_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
1267 struct qeth_ipa_cmd
*cmd
;
1270 QETH_DBF_TEXT(SETUP
, 2, "diastrcb");
1272 cmd
= (struct qeth_ipa_cmd
*)data
;
1273 rc
= cmd
->hdr
.return_code
;
1275 QETH_CARD_TEXT_(card
, 2, "dxter%x", rc
);
1276 switch (cmd
->data
.diagass
.action
) {
1277 case QETH_DIAGS_CMD_TRACE_QUERY
:
1279 case QETH_DIAGS_CMD_TRACE_DISABLE
:
1282 case IPA_RC_INVALID_SUBCMD
:
1283 card
->info
.promisc_mode
= SET_PROMISC_MODE_OFF
;
1284 dev_info(&card
->gdev
->dev
, "The HiperSockets network "
1285 "traffic analyzer is deactivated\n");
1291 case QETH_DIAGS_CMD_TRACE_ENABLE
:
1294 card
->info
.promisc_mode
= SET_PROMISC_MODE_ON
;
1295 dev_info(&card
->gdev
->dev
, "The HiperSockets network "
1296 "traffic analyzer is activated\n");
1298 case IPA_RC_HARDWARE_AUTH_ERROR
:
1299 dev_warn(&card
->gdev
->dev
, "The device is not "
1300 "authorized to run as a HiperSockets network "
1301 "traffic analyzer\n");
1303 case IPA_RC_TRACE_ALREADY_ACTIVE
:
1304 dev_warn(&card
->gdev
->dev
, "A HiperSockets "
1305 "network traffic analyzer is already "
1306 "active in the HiperSockets LAN\n");
1313 QETH_DBF_MESSAGE(2, "Unknown sniffer action (0x%04x) on %s\n",
1314 cmd
->data
.diagass
.action
, QETH_CARD_IFNAME(card
));
1321 qeth_diags_trace(struct qeth_card
*card
, enum qeth_diags_trace_cmds diags_cmd
)
1323 struct qeth_cmd_buffer
*iob
;
1324 struct qeth_ipa_cmd
*cmd
;
1326 QETH_DBF_TEXT(SETUP
, 2, "diagtrac");
1328 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_SET_DIAG_ASS
, 0);
1331 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
1332 cmd
->data
.diagass
.subcmd_len
= 16;
1333 cmd
->data
.diagass
.subcmd
= QETH_DIAGS_CMD_TRACE
;
1334 cmd
->data
.diagass
.type
= QETH_DIAGS_TYPE_HIPERSOCKET
;
1335 cmd
->data
.diagass
.action
= diags_cmd
;
1336 return qeth_send_ipa_cmd(card
, iob
, qeth_diags_trace_cb
, NULL
);
1339 static void qeth_l3_get_mac_for_ipm(__be32 ipm
, char *mac
)
1341 ip_eth_mc_map(ipm
, mac
);
1344 static void qeth_l3_mark_all_mc_to_be_deleted(struct qeth_card
*card
)
1346 struct qeth_ipaddr
*addr
;
1349 hash_for_each(card
->ip_mc_htable
, i
, addr
, hnode
)
1350 addr
->disp_flag
= QETH_DISP_ADDR_DELETE
;
1354 static void qeth_l3_add_all_new_mc(struct qeth_card
*card
)
1356 struct qeth_ipaddr
*addr
;
1357 struct hlist_node
*tmp
;
1361 hash_for_each_safe(card
->ip_mc_htable
, i
, tmp
, addr
, hnode
) {
1362 if (addr
->disp_flag
== QETH_DISP_ADDR_ADD
) {
1363 rc
= qeth_l3_register_addr_entry(card
, addr
);
1364 if (!rc
|| (rc
== IPA_RC_LAN_OFFLINE
))
1365 addr
->ref_counter
= 1;
1367 hash_del(&addr
->hnode
);
1375 static void qeth_l3_delete_nonused_mc(struct qeth_card
*card
)
1377 struct qeth_ipaddr
*addr
;
1378 struct hlist_node
*tmp
;
1382 hash_for_each_safe(card
->ip_mc_htable
, i
, tmp
, addr
, hnode
) {
1383 if (addr
->disp_flag
== QETH_DISP_ADDR_DELETE
) {
1384 rc
= qeth_l3_deregister_addr_entry(card
, addr
);
1385 if (!rc
|| (rc
== IPA_RC_MC_ADDR_NOT_FOUND
)) {
1386 hash_del(&addr
->hnode
);
1396 qeth_l3_add_mc_to_hash(struct qeth_card
*card
, struct in_device
*in4_dev
)
1398 struct ip_mc_list
*im4
;
1399 struct qeth_ipaddr
*tmp
, *ipm
;
1400 char buf
[MAX_ADDR_LEN
];
1402 QETH_CARD_TEXT(card
, 4, "addmc");
1404 tmp
= qeth_l3_get_addr_buffer(QETH_PROT_IPV4
);
1408 for (im4
= rcu_dereference(in4_dev
->mc_list
); im4
!= NULL
;
1409 im4
= rcu_dereference(im4
->next_rcu
)) {
1410 qeth_l3_get_mac_for_ipm(im4
->multiaddr
, buf
);
1412 tmp
->u
.a4
.addr
= be32_to_cpu(im4
->multiaddr
);
1413 memcpy(tmp
->mac
, buf
, sizeof(tmp
->mac
));
1415 ipm
= qeth_l3_ip_from_hash(card
, tmp
);
1417 ipm
->disp_flag
= QETH_DISP_ADDR_DO_NOTHING
;
1419 ipm
= qeth_l3_get_addr_buffer(QETH_PROT_IPV4
);
1422 memcpy(ipm
->mac
, buf
, sizeof(tmp
->mac
));
1423 ipm
->u
.a4
.addr
= be32_to_cpu(im4
->multiaddr
);
1424 ipm
->is_multicast
= 1;
1425 ipm
->disp_flag
= QETH_DISP_ADDR_ADD
;
1426 hash_add(card
->ip_mc_htable
,
1427 &ipm
->hnode
, qeth_l3_ipaddr_hash(ipm
));
1434 /* called with rcu_read_lock */
1435 static void qeth_l3_add_vlan_mc(struct qeth_card
*card
)
1437 struct in_device
*in_dev
;
1440 QETH_CARD_TEXT(card
, 4, "addmcvl");
1442 if (!qeth_is_supported(card
, IPA_FULL_VLAN
))
1445 for_each_set_bit(vid
, card
->active_vlans
, VLAN_N_VID
) {
1446 struct net_device
*netdev
;
1448 netdev
= __vlan_find_dev_deep_rcu(card
->dev
, htons(ETH_P_8021Q
),
1450 if (netdev
== NULL
||
1451 !(netdev
->flags
& IFF_UP
))
1453 in_dev
= __in_dev_get_rcu(netdev
);
1456 qeth_l3_add_mc_to_hash(card
, in_dev
);
1460 static void qeth_l3_add_multicast_ipv4(struct qeth_card
*card
)
1462 struct in_device
*in4_dev
;
1464 QETH_CARD_TEXT(card
, 4, "chkmcv4");
1467 in4_dev
= __in_dev_get_rcu(card
->dev
);
1468 if (in4_dev
== NULL
)
1470 qeth_l3_add_mc_to_hash(card
, in4_dev
);
1471 qeth_l3_add_vlan_mc(card
);
1476 #ifdef CONFIG_QETH_IPV6
1478 qeth_l3_add_mc6_to_hash(struct qeth_card
*card
, struct inet6_dev
*in6_dev
)
1480 struct qeth_ipaddr
*ipm
;
1481 struct ifmcaddr6
*im6
;
1482 struct qeth_ipaddr
*tmp
;
1483 char buf
[MAX_ADDR_LEN
];
1485 QETH_CARD_TEXT(card
, 4, "addmc6");
1487 tmp
= qeth_l3_get_addr_buffer(QETH_PROT_IPV6
);
1491 for (im6
= in6_dev
->mc_list
; im6
!= NULL
; im6
= im6
->next
) {
1492 ndisc_mc_map(&im6
->mca_addr
, buf
, in6_dev
->dev
, 0);
1494 memcpy(tmp
->mac
, buf
, sizeof(tmp
->mac
));
1495 memcpy(&tmp
->u
.a6
.addr
, &im6
->mca_addr
.s6_addr
,
1496 sizeof(struct in6_addr
));
1497 tmp
->is_multicast
= 1;
1499 ipm
= qeth_l3_ip_from_hash(card
, tmp
);
1501 ipm
->disp_flag
= QETH_DISP_ADDR_DO_NOTHING
;
1505 ipm
= qeth_l3_get_addr_buffer(QETH_PROT_IPV6
);
1509 memcpy(ipm
->mac
, buf
, OSA_ADDR_LEN
);
1510 memcpy(&ipm
->u
.a6
.addr
, &im6
->mca_addr
.s6_addr
,
1511 sizeof(struct in6_addr
));
1512 ipm
->is_multicast
= 1;
1513 ipm
->disp_flag
= QETH_DISP_ADDR_ADD
;
1514 hash_add(card
->ip_mc_htable
,
1515 &ipm
->hnode
, qeth_l3_ipaddr_hash(ipm
));
1521 /* called with rcu_read_lock */
1522 static void qeth_l3_add_vlan_mc6(struct qeth_card
*card
)
1524 struct inet6_dev
*in_dev
;
1527 QETH_CARD_TEXT(card
, 4, "admc6vl");
1529 if (!qeth_is_supported(card
, IPA_FULL_VLAN
))
1532 for_each_set_bit(vid
, card
->active_vlans
, VLAN_N_VID
) {
1533 struct net_device
*netdev
;
1535 netdev
= __vlan_find_dev_deep_rcu(card
->dev
, htons(ETH_P_8021Q
),
1537 if (netdev
== NULL
||
1538 !(netdev
->flags
& IFF_UP
))
1540 in_dev
= in6_dev_get(netdev
);
1543 read_lock_bh(&in_dev
->lock
);
1544 qeth_l3_add_mc6_to_hash(card
, in_dev
);
1545 read_unlock_bh(&in_dev
->lock
);
1546 in6_dev_put(in_dev
);
1550 static void qeth_l3_add_multicast_ipv6(struct qeth_card
*card
)
1552 struct inet6_dev
*in6_dev
;
1554 QETH_CARD_TEXT(card
, 4, "chkmcv6");
1556 if (!qeth_is_supported(card
, IPA_IPV6
))
1558 in6_dev
= in6_dev_get(card
->dev
);
1563 read_lock_bh(&in6_dev
->lock
);
1564 qeth_l3_add_mc6_to_hash(card
, in6_dev
);
1565 qeth_l3_add_vlan_mc6(card
);
1566 read_unlock_bh(&in6_dev
->lock
);
1568 in6_dev_put(in6_dev
);
1570 #endif /* CONFIG_QETH_IPV6 */
1572 static void qeth_l3_free_vlan_addresses4(struct qeth_card
*card
,
1575 struct in_device
*in_dev
;
1576 struct in_ifaddr
*ifa
;
1577 struct qeth_ipaddr
*addr
;
1578 struct net_device
*netdev
;
1580 QETH_CARD_TEXT(card
, 4, "frvaddr4");
1582 netdev
= __vlan_find_dev_deep_rcu(card
->dev
, htons(ETH_P_8021Q
), vid
);
1585 in_dev
= in_dev_get(netdev
);
1589 addr
= qeth_l3_get_addr_buffer(QETH_PROT_IPV4
);
1593 spin_lock_bh(&card
->ip_lock
);
1595 for (ifa
= in_dev
->ifa_list
; ifa
; ifa
= ifa
->ifa_next
) {
1596 addr
->u
.a4
.addr
= be32_to_cpu(ifa
->ifa_address
);
1597 addr
->u
.a4
.mask
= be32_to_cpu(ifa
->ifa_mask
);
1598 addr
->type
= QETH_IP_TYPE_NORMAL
;
1599 qeth_l3_delete_ip(card
, addr
);
1602 spin_unlock_bh(&card
->ip_lock
);
1608 static void qeth_l3_free_vlan_addresses6(struct qeth_card
*card
,
1611 #ifdef CONFIG_QETH_IPV6
1612 struct inet6_dev
*in6_dev
;
1613 struct inet6_ifaddr
*ifa
;
1614 struct qeth_ipaddr
*addr
;
1615 struct net_device
*netdev
;
1617 QETH_CARD_TEXT(card
, 4, "frvaddr6");
1619 netdev
= __vlan_find_dev_deep_rcu(card
->dev
, htons(ETH_P_8021Q
), vid
);
1623 in6_dev
= in6_dev_get(netdev
);
1627 addr
= qeth_l3_get_addr_buffer(QETH_PROT_IPV6
);
1631 spin_lock_bh(&card
->ip_lock
);
1633 list_for_each_entry(ifa
, &in6_dev
->addr_list
, if_list
) {
1634 memcpy(&addr
->u
.a6
.addr
, &ifa
->addr
,
1635 sizeof(struct in6_addr
));
1636 addr
->u
.a6
.pfxlen
= ifa
->prefix_len
;
1637 addr
->type
= QETH_IP_TYPE_NORMAL
;
1638 qeth_l3_delete_ip(card
, addr
);
1641 spin_unlock_bh(&card
->ip_lock
);
1644 in6_dev_put(in6_dev
);
1645 #endif /* CONFIG_QETH_IPV6 */
1648 static void qeth_l3_free_vlan_addresses(struct qeth_card
*card
,
1652 qeth_l3_free_vlan_addresses4(card
, vid
);
1653 qeth_l3_free_vlan_addresses6(card
, vid
);
1657 static int qeth_l3_vlan_rx_add_vid(struct net_device
*dev
,
1658 __be16 proto
, u16 vid
)
1660 struct qeth_card
*card
= dev
->ml_priv
;
1662 set_bit(vid
, card
->active_vlans
);
1666 static int qeth_l3_vlan_rx_kill_vid(struct net_device
*dev
,
1667 __be16 proto
, u16 vid
)
1669 struct qeth_card
*card
= dev
->ml_priv
;
1671 QETH_CARD_TEXT_(card
, 4, "kid:%d", vid
);
1673 if (qeth_wait_for_threads(card
, QETH_RECOVER_THREAD
)) {
1674 QETH_CARD_TEXT(card
, 3, "kidREC");
1677 /* unregister IP addresses of vlan device */
1678 qeth_l3_free_vlan_addresses(card
, vid
);
1679 clear_bit(vid
, card
->active_vlans
);
1680 qeth_l3_set_multicast_list(card
->dev
);
1684 static inline int qeth_l3_rebuild_skb(struct qeth_card
*card
,
1685 struct sk_buff
*skb
, struct qeth_hdr
*hdr
,
1686 unsigned short *vlan_id
)
1689 struct iphdr
*ip_hdr
;
1690 unsigned char tg_addr
[MAX_ADDR_LEN
];
1693 if (!(hdr
->hdr
.l3
.flags
& QETH_HDR_PASSTHRU
)) {
1694 prot
= (hdr
->hdr
.l3
.flags
& QETH_HDR_IPV6
) ? ETH_P_IPV6
:
1696 switch (hdr
->hdr
.l3
.flags
& QETH_HDR_CAST_MASK
) {
1697 case QETH_CAST_MULTICAST
:
1699 #ifdef CONFIG_QETH_IPV6
1701 ndisc_mc_map((struct in6_addr
*)
1703 tg_addr
, card
->dev
, 0);
1707 ip_hdr
= (struct iphdr
*)skb
->data
;
1708 ip_eth_mc_map(ip_hdr
->daddr
, tg_addr
);
1711 memcpy(tg_addr
, card
->dev
->broadcast
,
1712 card
->dev
->addr_len
);
1714 card
->stats
.multicast
++;
1715 skb
->pkt_type
= PACKET_MULTICAST
;
1717 case QETH_CAST_BROADCAST
:
1718 memcpy(tg_addr
, card
->dev
->broadcast
,
1719 card
->dev
->addr_len
);
1720 card
->stats
.multicast
++;
1721 skb
->pkt_type
= PACKET_BROADCAST
;
1723 case QETH_CAST_UNICAST
:
1724 case QETH_CAST_ANYCAST
:
1725 case QETH_CAST_NOCAST
:
1727 if (card
->options
.sniffer
)
1728 skb
->pkt_type
= PACKET_OTHERHOST
;
1730 skb
->pkt_type
= PACKET_HOST
;
1731 memcpy(tg_addr
, card
->dev
->dev_addr
,
1732 card
->dev
->addr_len
);
1734 if (hdr
->hdr
.l3
.ext_flags
& QETH_HDR_EXT_SRC_MAC_ADDR
)
1735 card
->dev
->header_ops
->create(skb
, card
->dev
, prot
,
1736 tg_addr
, &hdr
->hdr
.l3
.dest_addr
[2],
1737 card
->dev
->addr_len
);
1739 card
->dev
->header_ops
->create(skb
, card
->dev
, prot
,
1740 tg_addr
, "FAKELL", card
->dev
->addr_len
);
1743 skb
->protocol
= eth_type_trans(skb
, card
->dev
);
1745 if (hdr
->hdr
.l3
.ext_flags
&
1746 (QETH_HDR_EXT_VLAN_FRAME
| QETH_HDR_EXT_INCLUDE_VLAN_TAG
)) {
1747 *vlan_id
= (hdr
->hdr
.l3
.ext_flags
& QETH_HDR_EXT_VLAN_FRAME
) ?
1748 hdr
->hdr
.l3
.vlan_id
: *((u16
*)&hdr
->hdr
.l3
.dest_addr
[12]);
1752 if (card
->dev
->features
& NETIF_F_RXCSUM
) {
1753 if ((hdr
->hdr
.l3
.ext_flags
&
1754 (QETH_HDR_EXT_CSUM_HDR_REQ
|
1755 QETH_HDR_EXT_CSUM_TRANSP_REQ
)) ==
1756 (QETH_HDR_EXT_CSUM_HDR_REQ
|
1757 QETH_HDR_EXT_CSUM_TRANSP_REQ
))
1758 skb
->ip_summed
= CHECKSUM_UNNECESSARY
;
1760 skb
->ip_summed
= CHECKSUM_NONE
;
1762 skb
->ip_summed
= CHECKSUM_NONE
;
1766 static int qeth_l3_process_inbound_buffer(struct qeth_card
*card
,
1767 int budget
, int *done
)
1770 struct sk_buff
*skb
;
1771 struct qeth_hdr
*hdr
;
1778 WARN_ON_ONCE(!budget
);
1780 skb
= qeth_core_get_next_skb(card
,
1781 &card
->qdio
.in_q
->bufs
[card
->rx
.b_index
],
1782 &card
->rx
.b_element
, &card
->rx
.e_offset
, &hdr
);
1787 skb
->dev
= card
->dev
;
1788 switch (hdr
->hdr
.l3
.id
) {
1789 case QETH_HEADER_TYPE_LAYER3
:
1790 magic
= *(__u16
*)skb
->data
;
1791 if ((card
->info
.type
== QETH_CARD_TYPE_IQD
) &&
1792 (magic
== ETH_P_AF_IUCV
)) {
1793 skb
->protocol
= cpu_to_be16(ETH_P_AF_IUCV
);
1794 skb
->pkt_type
= PACKET_HOST
;
1795 skb
->mac_header
= NET_SKB_PAD
;
1796 skb
->dev
= card
->dev
;
1798 card
->dev
->header_ops
->create(skb
, card
->dev
, 0,
1799 card
->dev
->dev_addr
, "FAKELL",
1800 card
->dev
->addr_len
);
1801 netif_receive_skb(skb
);
1803 is_vlan
= qeth_l3_rebuild_skb(card
, skb
, hdr
,
1806 if (is_vlan
&& !card
->options
.sniffer
)
1807 __vlan_hwaccel_put_tag(skb
,
1808 htons(ETH_P_8021Q
), vlan_tag
);
1809 napi_gro_receive(&card
->napi
, skb
);
1812 case QETH_HEADER_TYPE_LAYER2
: /* for HiperSockets sniffer */
1813 skb
->pkt_type
= PACKET_HOST
;
1814 skb
->protocol
= eth_type_trans(skb
, skb
->dev
);
1816 netif_receive_skb(skb
);
1819 dev_kfree_skb_any(skb
);
1820 QETH_CARD_TEXT(card
, 3, "inbunkno");
1821 QETH_DBF_HEX(CTRL
, 3, hdr
, QETH_DBF_CTRL_LEN
);
1826 card
->stats
.rx_packets
++;
1827 card
->stats
.rx_bytes
+= len
;
1832 static int qeth_l3_verify_vlan_dev(struct net_device
*dev
,
1833 struct qeth_card
*card
)
1838 for_each_set_bit(vid
, card
->active_vlans
, VLAN_N_VID
) {
1839 struct net_device
*netdev
;
1842 netdev
= __vlan_find_dev_deep_rcu(card
->dev
, htons(ETH_P_8021Q
),
1845 if (netdev
== dev
) {
1846 rc
= QETH_VLAN_CARD
;
1851 if (rc
&& !(vlan_dev_real_dev(dev
)->ml_priv
== (void *)card
))
1857 static int qeth_l3_verify_dev(struct net_device
*dev
)
1859 struct qeth_card
*card
;
1861 unsigned long flags
;
1863 read_lock_irqsave(&qeth_core_card_list
.rwlock
, flags
);
1864 list_for_each_entry(card
, &qeth_core_card_list
.list
, list
) {
1865 if (card
->dev
== dev
) {
1866 rc
= QETH_REAL_CARD
;
1869 rc
= qeth_l3_verify_vlan_dev(dev
, card
);
1873 read_unlock_irqrestore(&qeth_core_card_list
.rwlock
, flags
);
1878 static struct qeth_card
*qeth_l3_get_card_from_dev(struct net_device
*dev
)
1880 struct qeth_card
*card
= NULL
;
1883 rc
= qeth_l3_verify_dev(dev
);
1884 if (rc
== QETH_REAL_CARD
)
1885 card
= dev
->ml_priv
;
1886 else if (rc
== QETH_VLAN_CARD
)
1887 card
= vlan_dev_real_dev(dev
)->ml_priv
;
1888 if (card
&& card
->options
.layer2
)
1891 QETH_CARD_TEXT_(card
, 4, "%d", rc
);
1895 static void qeth_l3_stop_card(struct qeth_card
*card
, int recovery_mode
)
1897 QETH_DBF_TEXT(SETUP
, 2, "stopcard");
1898 QETH_DBF_HEX(SETUP
, 2, &card
, sizeof(void *));
1900 qeth_set_allowed_threads(card
, 0, 1);
1901 if (card
->options
.sniffer
&&
1902 (card
->info
.promisc_mode
== SET_PROMISC_MODE_ON
))
1903 qeth_diags_trace(card
, QETH_DIAGS_CMD_TRACE_DISABLE
);
1904 if (card
->read
.state
== CH_STATE_UP
&&
1905 card
->write
.state
== CH_STATE_UP
&&
1906 (card
->state
== CARD_STATE_UP
)) {
1908 qeth_l3_stop(card
->dev
);
1911 dev_close(card
->dev
);
1914 card
->state
= CARD_STATE_SOFTSETUP
;
1916 if (card
->state
== CARD_STATE_SOFTSETUP
) {
1917 qeth_l3_clear_ip_htable(card
, 1);
1918 qeth_clear_ipacmd_list(card
);
1919 card
->state
= CARD_STATE_HARDSETUP
;
1921 if (card
->state
== CARD_STATE_HARDSETUP
) {
1922 qeth_qdio_clear_card(card
, 0);
1923 qeth_clear_qdio_buffers(card
);
1924 qeth_clear_working_pool_list(card
);
1925 card
->state
= CARD_STATE_DOWN
;
1927 if (card
->state
== CARD_STATE_DOWN
) {
1928 qeth_clear_cmd_buffers(&card
->read
);
1929 qeth_clear_cmd_buffers(&card
->write
);
1934 * test for and Switch promiscuous mode (on or off)
1935 * either for guestlan or HiperSocket Sniffer
1938 qeth_l3_handle_promisc_mode(struct qeth_card
*card
)
1940 struct net_device
*dev
= card
->dev
;
1942 if (((dev
->flags
& IFF_PROMISC
) &&
1943 (card
->info
.promisc_mode
== SET_PROMISC_MODE_ON
)) ||
1944 (!(dev
->flags
& IFF_PROMISC
) &&
1945 (card
->info
.promisc_mode
== SET_PROMISC_MODE_OFF
)))
1948 if (card
->info
.guestlan
) { /* Guestlan trace */
1949 if (qeth_adp_supported(card
, IPA_SETADP_SET_PROMISC_MODE
))
1950 qeth_setadp_promisc_mode(card
);
1951 } else if (card
->options
.sniffer
&& /* HiperSockets trace */
1952 qeth_adp_supported(card
, IPA_SETADP_SET_DIAG_ASSIST
)) {
1953 if (dev
->flags
& IFF_PROMISC
) {
1954 QETH_CARD_TEXT(card
, 3, "+promisc");
1955 qeth_diags_trace(card
, QETH_DIAGS_CMD_TRACE_ENABLE
);
1957 QETH_CARD_TEXT(card
, 3, "-promisc");
1958 qeth_diags_trace(card
, QETH_DIAGS_CMD_TRACE_DISABLE
);
1963 static void qeth_l3_set_multicast_list(struct net_device
*dev
)
1965 struct qeth_card
*card
= dev
->ml_priv
;
1967 QETH_CARD_TEXT(card
, 3, "setmulti");
1968 if (qeth_threads_running(card
, QETH_RECOVER_THREAD
) &&
1969 (card
->state
!= CARD_STATE_UP
))
1971 if (!card
->options
.sniffer
) {
1973 spin_lock_bh(&card
->mclock
);
1975 qeth_l3_mark_all_mc_to_be_deleted(card
);
1977 qeth_l3_add_multicast_ipv4(card
);
1978 #ifdef CONFIG_QETH_IPV6
1979 qeth_l3_add_multicast_ipv6(card
);
1981 qeth_l3_delete_nonused_mc(card
);
1982 qeth_l3_add_all_new_mc(card
);
1984 spin_unlock_bh(&card
->mclock
);
1986 if (!qeth_adp_supported(card
, IPA_SETADP_SET_PROMISC_MODE
))
1989 qeth_l3_handle_promisc_mode(card
);
1992 static const char *qeth_l3_arp_get_error_cause(int *rc
)
1995 case QETH_IPA_ARP_RC_FAILED
:
1997 return "operation failed";
1998 case QETH_IPA_ARP_RC_NOTSUPP
:
2000 return "operation not supported";
2001 case QETH_IPA_ARP_RC_OUT_OF_RANGE
:
2003 return "argument out of range";
2004 case QETH_IPA_ARP_RC_Q_NOTSUPP
:
2006 return "query operation not supported";
2007 case QETH_IPA_ARP_RC_Q_NO_DATA
:
2009 return "no query data available";
2011 return "unknown error";
2015 static int qeth_l3_arp_set_no_entries(struct qeth_card
*card
, int no_entries
)
2020 QETH_CARD_TEXT(card
, 3, "arpstnoe");
2023 * currently GuestLAN only supports the ARP assist function
2024 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_SET_NO_ENTRIES;
2025 * thus we say EOPNOTSUPP for this ARP function
2027 if (card
->info
.guestlan
)
2029 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
2032 rc
= qeth_send_simple_setassparms(card
, IPA_ARP_PROCESSING
,
2033 IPA_CMD_ASS_ARP_SET_NO_ENTRIES
,
2037 QETH_DBF_MESSAGE(2, "Could not set number of ARP entries on "
2038 "%s: %s (0x%x/%d)\n", QETH_CARD_IFNAME(card
),
2039 qeth_l3_arp_get_error_cause(&rc
), tmp
, tmp
);
2044 static __u32
get_arp_entry_size(struct qeth_card
*card
,
2045 struct qeth_arp_query_data
*qdata
,
2046 struct qeth_arp_entrytype
*type
, __u8 strip_entries
)
2051 is_hsi
= qdata
->reply_bits
== 5;
2052 if (type
->ip
== QETHARP_IP_ADDR_V4
) {
2053 QETH_CARD_TEXT(card
, 4, "arpev4");
2054 if (strip_entries
) {
2055 rc
= is_hsi
? sizeof(struct qeth_arp_qi_entry5_short
) :
2056 sizeof(struct qeth_arp_qi_entry7_short
);
2058 rc
= is_hsi
? sizeof(struct qeth_arp_qi_entry5
) :
2059 sizeof(struct qeth_arp_qi_entry7
);
2061 } else if (type
->ip
== QETHARP_IP_ADDR_V6
) {
2062 QETH_CARD_TEXT(card
, 4, "arpev6");
2063 if (strip_entries
) {
2065 sizeof(struct qeth_arp_qi_entry5_short_ipv6
) :
2066 sizeof(struct qeth_arp_qi_entry7_short_ipv6
);
2069 sizeof(struct qeth_arp_qi_entry5_ipv6
) :
2070 sizeof(struct qeth_arp_qi_entry7_ipv6
);
2073 QETH_CARD_TEXT(card
, 4, "arpinv");
2080 static int arpentry_matches_prot(struct qeth_arp_entrytype
*type
, __u16 prot
)
2082 return (type
->ip
== QETHARP_IP_ADDR_V4
&& prot
== QETH_PROT_IPV4
) ||
2083 (type
->ip
== QETHARP_IP_ADDR_V6
&& prot
== QETH_PROT_IPV6
);
2086 static int qeth_l3_arp_query_cb(struct qeth_card
*card
,
2087 struct qeth_reply
*reply
, unsigned long data
)
2089 struct qeth_ipa_cmd
*cmd
;
2090 struct qeth_arp_query_data
*qdata
;
2091 struct qeth_arp_query_info
*qinfo
;
2094 int entrybytes_done
;
2096 __u8 do_strip_entries
;
2098 QETH_CARD_TEXT(card
, 3, "arpquecb");
2100 qinfo
= (struct qeth_arp_query_info
*) reply
->param
;
2101 cmd
= (struct qeth_ipa_cmd
*) data
;
2102 QETH_CARD_TEXT_(card
, 4, "%i", cmd
->hdr
.prot_version
);
2103 if (cmd
->hdr
.return_code
) {
2104 QETH_CARD_TEXT(card
, 4, "arpcberr");
2105 QETH_CARD_TEXT_(card
, 4, "%i", cmd
->hdr
.return_code
);
2108 if (cmd
->data
.setassparms
.hdr
.return_code
) {
2109 cmd
->hdr
.return_code
= cmd
->data
.setassparms
.hdr
.return_code
;
2110 QETH_CARD_TEXT(card
, 4, "setaperr");
2111 QETH_CARD_TEXT_(card
, 4, "%i", cmd
->hdr
.return_code
);
2114 qdata
= &cmd
->data
.setassparms
.data
.query_arp
;
2115 QETH_CARD_TEXT_(card
, 4, "anoen%i", qdata
->no_entries
);
2117 do_strip_entries
= (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
) > 0;
2118 stripped_bytes
= do_strip_entries
? QETH_QARP_MEDIASPECIFIC_BYTES
: 0;
2119 entrybytes_done
= 0;
2120 for (e
= 0; e
< qdata
->no_entries
; ++e
) {
2123 struct qeth_arp_entrytype
*etype
;
2125 cur_entry
= &qdata
->data
+ entrybytes_done
;
2126 etype
= &((struct qeth_arp_qi_entry5
*) cur_entry
)->type
;
2127 if (!arpentry_matches_prot(etype
, cmd
->hdr
.prot_version
)) {
2128 QETH_CARD_TEXT(card
, 4, "pmis");
2129 QETH_CARD_TEXT_(card
, 4, "%i", etype
->ip
);
2132 esize
= get_arp_entry_size(card
, qdata
, etype
,
2134 QETH_CARD_TEXT_(card
, 5, "esz%i", esize
);
2138 if ((qinfo
->udata_len
- qinfo
->udata_offset
) < esize
) {
2139 QETH_CARD_TEXT_(card
, 4, "qaer3%i", -ENOMEM
);
2140 cmd
->hdr
.return_code
= IPA_RC_ENOMEM
;
2144 memcpy(qinfo
->udata
+ qinfo
->udata_offset
,
2145 &qdata
->data
+ entrybytes_done
+ stripped_bytes
,
2147 entrybytes_done
+= esize
+ stripped_bytes
;
2148 qinfo
->udata_offset
+= esize
;
2149 ++qinfo
->no_entries
;
2151 /* check if all replies received ... */
2152 if (cmd
->data
.setassparms
.hdr
.seq_no
<
2153 cmd
->data
.setassparms
.hdr
.number_of_replies
)
2155 QETH_CARD_TEXT_(card
, 4, "nove%i", qinfo
->no_entries
);
2156 memcpy(qinfo
->udata
, &qinfo
->no_entries
, 4);
2157 /* keep STRIP_ENTRIES flag so the user program can distinguish
2158 * stripped entries from normal ones */
2159 if (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
)
2160 qdata
->reply_bits
|= QETH_QARP_STRIP_ENTRIES
;
2161 memcpy(qinfo
->udata
+ QETH_QARP_MASK_OFFSET
, &qdata
->reply_bits
, 2);
2162 QETH_CARD_TEXT_(card
, 4, "rc%i", 0);
2166 memcpy(qinfo
->udata
, &i
, 4);
2170 static int qeth_l3_send_ipa_arp_cmd(struct qeth_card
*card
,
2171 struct qeth_cmd_buffer
*iob
, int len
,
2172 int (*reply_cb
)(struct qeth_card
*, struct qeth_reply
*,
2176 QETH_CARD_TEXT(card
, 4, "sendarp");
2178 memcpy(iob
->data
, IPA_PDU_HEADER
, IPA_PDU_HEADER_SIZE
);
2179 memcpy(QETH_IPA_CMD_DEST_ADDR(iob
->data
),
2180 &card
->token
.ulp_connection_r
, QETH_MPC_TOKEN_LENGTH
);
2181 return qeth_send_control_data(card
, IPA_PDU_HEADER_SIZE
+ len
, iob
,
2182 reply_cb
, reply_param
);
2185 static int qeth_l3_query_arp_cache_info(struct qeth_card
*card
,
2186 enum qeth_prot_versions prot
,
2187 struct qeth_arp_query_info
*qinfo
)
2189 struct qeth_cmd_buffer
*iob
;
2190 struct qeth_ipa_cmd
*cmd
;
2194 QETH_CARD_TEXT_(card
, 3, "qarpipv%i", prot
);
2196 iob
= qeth_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
2197 IPA_CMD_ASS_ARP_QUERY_INFO
,
2198 sizeof(struct qeth_arp_query_data
)
2203 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
2204 cmd
->data
.setassparms
.data
.query_arp
.request_bits
= 0x000F;
2205 cmd
->data
.setassparms
.data
.query_arp
.reply_bits
= 0;
2206 cmd
->data
.setassparms
.data
.query_arp
.no_entries
= 0;
2207 rc
= qeth_l3_send_ipa_arp_cmd(card
, iob
,
2208 QETH_SETASS_BASE_LEN
+QETH_ARP_CMD_LEN
,
2209 qeth_l3_arp_query_cb
, (void *)qinfo
);
2213 "Error while querying ARP cache on %s: %s "
2214 "(0x%x/%d)\n", QETH_CARD_IFNAME(card
),
2215 qeth_l3_arp_get_error_cause(&rc
), tmp
, tmp
);
2221 static int qeth_l3_arp_query(struct qeth_card
*card
, char __user
*udata
)
2223 struct qeth_arp_query_info qinfo
= {0, };
2226 QETH_CARD_TEXT(card
, 3, "arpquery");
2228 if (!qeth_is_supported(card
,/*IPA_QUERY_ARP_ADDR_INFO*/
2229 IPA_ARP_PROCESSING
)) {
2230 QETH_CARD_TEXT(card
, 3, "arpqnsup");
2234 /* get size of userspace buffer and mask_bits -> 6 bytes */
2235 if (copy_from_user(&qinfo
, udata
, 6)) {
2239 qinfo
.udata
= kzalloc(qinfo
.udata_len
, GFP_KERNEL
);
2244 qinfo
.udata_offset
= QETH_QARP_ENTRIES_OFFSET
;
2245 rc
= qeth_l3_query_arp_cache_info(card
, QETH_PROT_IPV4
, &qinfo
);
2247 if (copy_to_user(udata
, qinfo
.udata
, 4))
2251 #ifdef CONFIG_QETH_IPV6
2252 if (qinfo
.mask_bits
& QETH_QARP_WITH_IPV6
) {
2253 /* fails in case of GuestLAN QDIO mode */
2254 qeth_l3_query_arp_cache_info(card
, QETH_PROT_IPV6
, &qinfo
);
2257 if (copy_to_user(udata
, qinfo
.udata
, qinfo
.udata_len
)) {
2258 QETH_CARD_TEXT(card
, 4, "qactf");
2262 QETH_CARD_TEXT(card
, 4, "qacts");
2270 static int qeth_l3_arp_add_entry(struct qeth_card
*card
,
2271 struct qeth_arp_cache_entry
*entry
)
2273 struct qeth_cmd_buffer
*iob
;
2278 QETH_CARD_TEXT(card
, 3, "arpadent");
2281 * currently GuestLAN only supports the ARP assist function
2282 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_ADD_ENTRY;
2283 * thus we say EOPNOTSUPP for this ARP function
2285 if (card
->info
.guestlan
)
2287 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
2291 iob
= qeth_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
2292 IPA_CMD_ASS_ARP_ADD_ENTRY
,
2293 sizeof(struct qeth_arp_cache_entry
),
2297 rc
= qeth_send_setassparms(card
, iob
,
2298 sizeof(struct qeth_arp_cache_entry
),
2299 (unsigned long) entry
,
2300 qeth_setassparms_cb
, NULL
);
2303 qeth_l3_ipaddr4_to_string((u8
*)entry
->ipaddr
, buf
);
2304 QETH_DBF_MESSAGE(2, "Could not add ARP entry for address %s "
2305 "on %s: %s (0x%x/%d)\n", buf
, QETH_CARD_IFNAME(card
),
2306 qeth_l3_arp_get_error_cause(&rc
), tmp
, tmp
);
2311 static int qeth_l3_arp_remove_entry(struct qeth_card
*card
,
2312 struct qeth_arp_cache_entry
*entry
)
2314 struct qeth_cmd_buffer
*iob
;
2315 char buf
[16] = {0, };
2319 QETH_CARD_TEXT(card
, 3, "arprment");
2322 * currently GuestLAN only supports the ARP assist function
2323 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_REMOVE_ENTRY;
2324 * thus we say EOPNOTSUPP for this ARP function
2326 if (card
->info
.guestlan
)
2328 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
2331 memcpy(buf
, entry
, 12);
2332 iob
= qeth_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
2333 IPA_CMD_ASS_ARP_REMOVE_ENTRY
,
2338 rc
= qeth_send_setassparms(card
, iob
,
2339 12, (unsigned long)buf
,
2340 qeth_setassparms_cb
, NULL
);
2344 qeth_l3_ipaddr4_to_string((u8
*)entry
->ipaddr
, buf
);
2345 QETH_DBF_MESSAGE(2, "Could not delete ARP entry for address %s"
2346 " on %s: %s (0x%x/%d)\n", buf
, QETH_CARD_IFNAME(card
),
2347 qeth_l3_arp_get_error_cause(&rc
), tmp
, tmp
);
2352 static int qeth_l3_arp_flush_cache(struct qeth_card
*card
)
2357 QETH_CARD_TEXT(card
, 3, "arpflush");
2360 * currently GuestLAN only supports the ARP assist function
2361 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_FLUSH_CACHE;
2362 * thus we say EOPNOTSUPP for this ARP function
2364 if (card
->info
.guestlan
|| (card
->info
.type
== QETH_CARD_TYPE_IQD
))
2366 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
2369 rc
= qeth_send_simple_setassparms(card
, IPA_ARP_PROCESSING
,
2370 IPA_CMD_ASS_ARP_FLUSH_CACHE
, 0);
2373 QETH_DBF_MESSAGE(2, "Could not flush ARP cache on %s: %s "
2374 "(0x%x/%d)\n", QETH_CARD_IFNAME(card
),
2375 qeth_l3_arp_get_error_cause(&rc
), tmp
, tmp
);
2380 static int qeth_l3_do_ioctl(struct net_device
*dev
, struct ifreq
*rq
, int cmd
)
2382 struct qeth_card
*card
= dev
->ml_priv
;
2383 struct qeth_arp_cache_entry arp_entry
;
2387 case SIOC_QETH_ARP_SET_NO_ENTRIES
:
2388 if (!capable(CAP_NET_ADMIN
)) {
2392 rc
= qeth_l3_arp_set_no_entries(card
, rq
->ifr_ifru
.ifru_ivalue
);
2394 case SIOC_QETH_ARP_QUERY_INFO
:
2395 if (!capable(CAP_NET_ADMIN
)) {
2399 rc
= qeth_l3_arp_query(card
, rq
->ifr_ifru
.ifru_data
);
2401 case SIOC_QETH_ARP_ADD_ENTRY
:
2402 if (!capable(CAP_NET_ADMIN
)) {
2406 if (copy_from_user(&arp_entry
, rq
->ifr_ifru
.ifru_data
,
2407 sizeof(struct qeth_arp_cache_entry
)))
2410 rc
= qeth_l3_arp_add_entry(card
, &arp_entry
);
2412 case SIOC_QETH_ARP_REMOVE_ENTRY
:
2413 if (!capable(CAP_NET_ADMIN
)) {
2417 if (copy_from_user(&arp_entry
, rq
->ifr_ifru
.ifru_data
,
2418 sizeof(struct qeth_arp_cache_entry
)))
2421 rc
= qeth_l3_arp_remove_entry(card
, &arp_entry
);
2423 case SIOC_QETH_ARP_FLUSH_CACHE
:
2424 if (!capable(CAP_NET_ADMIN
)) {
2428 rc
= qeth_l3_arp_flush_cache(card
);
2436 int inline qeth_l3_get_cast_type(struct qeth_card
*card
, struct sk_buff
*skb
)
2438 int cast_type
= RTN_UNSPEC
;
2439 struct neighbour
*n
= NULL
;
2440 struct dst_entry
*dst
;
2445 n
= dst_neigh_lookup_skb(dst
, skb
);
2447 cast_type
= n
->type
;
2450 if ((cast_type
== RTN_BROADCAST
) ||
2451 (cast_type
== RTN_MULTICAST
) ||
2452 (cast_type
== RTN_ANYCAST
))
2459 /* try something else */
2460 if (be16_to_cpu(skb
->protocol
) == ETH_P_IPV6
)
2461 return (skb_network_header(skb
)[24] == 0xff) ?
2463 else if (be16_to_cpu(skb
->protocol
) == ETH_P_IP
)
2464 return ((skb_network_header(skb
)[16] & 0xf0) == 0xe0) ?
2467 if (!memcmp(skb
->data
, skb
->dev
->broadcast
, 6))
2468 return RTN_BROADCAST
;
2472 hdr_mac
= *((u16
*)skb
->data
);
2474 switch (card
->info
.link_type
) {
2475 case QETH_LINK_TYPE_HSTR
:
2476 case QETH_LINK_TYPE_LANE_TR
:
2477 if ((hdr_mac
== QETH_TR_MAC_NC
) ||
2478 (hdr_mac
== QETH_TR_MAC_C
))
2479 return RTN_MULTICAST
;
2481 /* eth or so multicast? */
2483 if ((hdr_mac
== QETH_ETH_MAC_V4
) ||
2484 (hdr_mac
== QETH_ETH_MAC_V6
))
2485 return RTN_MULTICAST
;
2491 static void qeth_l3_fill_af_iucv_hdr(struct qeth_card
*card
,
2492 struct qeth_hdr
*hdr
, struct sk_buff
*skb
)
2495 struct af_iucv_trans_hdr
*iucv_hdr
;
2497 memset(hdr
, 0, sizeof(struct qeth_hdr
));
2498 hdr
->hdr
.l3
.id
= QETH_HEADER_TYPE_LAYER3
;
2499 hdr
->hdr
.l3
.ext_flags
= 0;
2500 hdr
->hdr
.l3
.length
= skb
->len
- ETH_HLEN
;
2501 hdr
->hdr
.l3
.flags
= QETH_HDR_IPV6
| QETH_CAST_UNICAST
;
2503 iucv_hdr
= (struct af_iucv_trans_hdr
*) (skb
->data
+ ETH_HLEN
);
2504 memset(daddr
, 0, sizeof(daddr
));
2507 memcpy(&daddr
[8], iucv_hdr
->destUserID
, 8);
2508 memcpy(hdr
->hdr
.l3
.dest_addr
, daddr
, 16);
2511 static void qeth_l3_fill_header(struct qeth_card
*card
, struct qeth_hdr
*hdr
,
2512 struct sk_buff
*skb
, int ipv
, int cast_type
)
2514 struct dst_entry
*dst
;
2516 memset(hdr
, 0, sizeof(struct qeth_hdr
));
2517 hdr
->hdr
.l3
.id
= QETH_HEADER_TYPE_LAYER3
;
2518 hdr
->hdr
.l3
.ext_flags
= 0;
2521 * before we're going to overwrite this location with next hop ip.
2522 * v6 uses passthrough, v4 sets the tag in the QDIO header.
2524 if (skb_vlan_tag_present(skb
)) {
2525 if ((ipv
== 4) || (card
->info
.type
== QETH_CARD_TYPE_IQD
))
2526 hdr
->hdr
.l3
.ext_flags
= QETH_HDR_EXT_VLAN_FRAME
;
2528 hdr
->hdr
.l3
.ext_flags
= QETH_HDR_EXT_INCLUDE_VLAN_TAG
;
2529 hdr
->hdr
.l3
.vlan_id
= skb_vlan_tag_get(skb
);
2532 hdr
->hdr
.l3
.length
= skb
->len
- sizeof(struct qeth_hdr
);
2537 struct rtable
*rt
= (struct rtable
*) dst
;
2538 __be32
*pkey
= &ip_hdr(skb
)->daddr
;
2541 pkey
= &rt
->rt_gateway
;
2544 hdr
->hdr
.l3
.flags
= qeth_l3_get_qeth_hdr_flags4(cast_type
);
2545 memset(hdr
->hdr
.l3
.dest_addr
, 0, 12);
2546 *((__be32
*) (&hdr
->hdr
.l3
.dest_addr
[12])) = *pkey
;
2547 } else if (ipv
== 6) {
2548 struct rt6_info
*rt
= (struct rt6_info
*) dst
;
2549 struct in6_addr
*pkey
= &ipv6_hdr(skb
)->daddr
;
2551 if (!ipv6_addr_any(&rt
->rt6i_gateway
))
2552 pkey
= &rt
->rt6i_gateway
;
2555 hdr
->hdr
.l3
.flags
= qeth_l3_get_qeth_hdr_flags6(cast_type
);
2556 if (card
->info
.type
== QETH_CARD_TYPE_IQD
)
2557 hdr
->hdr
.l3
.flags
&= ~QETH_HDR_PASSTHRU
;
2558 memcpy(hdr
->hdr
.l3
.dest_addr
, pkey
, 16);
2560 if (!memcmp(skb
->data
+ sizeof(struct qeth_hdr
),
2561 skb
->dev
->broadcast
, 6)) {
2563 hdr
->hdr
.l3
.flags
= QETH_CAST_BROADCAST
|
2566 hdr
->hdr
.l3
.flags
= (cast_type
== RTN_MULTICAST
) ?
2567 QETH_CAST_MULTICAST
| QETH_HDR_PASSTHRU
:
2568 QETH_CAST_UNICAST
| QETH_HDR_PASSTHRU
;
2574 static inline void qeth_l3_hdr_csum(struct qeth_card
*card
,
2575 struct qeth_hdr
*hdr
, struct sk_buff
*skb
)
2577 struct iphdr
*iph
= ip_hdr(skb
);
2579 /* tcph->check contains already the pseudo hdr checksum
2580 * so just set the header flags
2582 if (iph
->protocol
== IPPROTO_UDP
)
2583 hdr
->hdr
.l3
.ext_flags
|= QETH_HDR_EXT_UDP
;
2584 hdr
->hdr
.l3
.ext_flags
|= QETH_HDR_EXT_CSUM_TRANSP_REQ
|
2585 QETH_HDR_EXT_CSUM_HDR_REQ
;
2587 if (card
->options
.performance_stats
)
2588 card
->perf_stats
.tx_csum
++;
2591 static void qeth_tso_fill_header(struct qeth_card
*card
,
2592 struct qeth_hdr
*qhdr
, struct sk_buff
*skb
)
2594 struct qeth_hdr_tso
*hdr
= (struct qeth_hdr_tso
*)qhdr
;
2595 struct tcphdr
*tcph
= tcp_hdr(skb
);
2596 struct iphdr
*iph
= ip_hdr(skb
);
2597 struct ipv6hdr
*ip6h
= ipv6_hdr(skb
);
2599 /*fix header to TSO values ...*/
2600 hdr
->hdr
.hdr
.l3
.id
= QETH_HEADER_TYPE_TSO
;
2601 hdr
->hdr
.hdr
.l3
.length
= skb
->len
- sizeof(struct qeth_hdr_tso
);
2602 /*set values which are fix for the first approach ...*/
2603 hdr
->ext
.hdr_tot_len
= (__u16
) sizeof(struct qeth_hdr_ext_tso
);
2604 hdr
->ext
.imb_hdr_no
= 1;
2605 hdr
->ext
.hdr_type
= 1;
2606 hdr
->ext
.hdr_version
= 1;
2607 hdr
->ext
.hdr_len
= 28;
2608 /*insert non-fix values */
2609 hdr
->ext
.mss
= skb_shinfo(skb
)->gso_size
;
2610 hdr
->ext
.dg_hdr_len
= (__u16
)(iph
->ihl
*4 + tcph
->doff
*4);
2611 hdr
->ext
.payload_len
= (__u16
)(skb
->len
- hdr
->ext
.dg_hdr_len
-
2612 sizeof(struct qeth_hdr_tso
));
2614 if (be16_to_cpu(skb
->protocol
) == ETH_P_IPV6
) {
2615 ip6h
->payload_len
= 0;
2616 tcph
->check
= ~csum_ipv6_magic(&ip6h
->saddr
, &ip6h
->daddr
,
2619 /*OSA want us to set these values ...*/
2620 tcph
->check
= ~csum_tcpudp_magic(iph
->saddr
, iph
->daddr
,
2628 * qeth_l3_get_elements_no_tso() - find number of SBALEs for skb data for tso
2629 * @card: qeth card structure, to check max. elems.
2631 * @extra_elems: extra elems needed, to check against max.
2633 * Returns the number of pages, and thus QDIO buffer elements, needed to cover
2634 * skb data, including linear part and fragments, but excluding TCP header.
2635 * (Exclusion of TCP header distinguishes it from qeth_get_elements_no().)
2636 * Checks if the result plus extra_elems fits under the limit for the card.
2637 * Returns 0 if it does not.
2638 * Note: extra_elems is not included in the returned result.
2640 static int qeth_l3_get_elements_no_tso(struct qeth_card
*card
,
2641 struct sk_buff
*skb
, int extra_elems
)
2643 addr_t tcpdptr
= (addr_t
)tcp_hdr(skb
) + tcp_hdrlen(skb
);
2644 int elements
= qeth_get_elements_for_range(
2646 (addr_t
)skb
->data
+ skb_headlen(skb
)) +
2647 qeth_get_elements_for_frags(skb
);
2649 if ((elements
+ extra_elems
) > QETH_MAX_BUFFER_ELEMENTS(card
)) {
2651 "Invalid size of TSO IP packet (Number=%d / Length=%d). Discarded.\n",
2652 elements
+ extra_elems
, skb
->len
);
2658 static netdev_tx_t
qeth_l3_hard_start_xmit(struct sk_buff
*skb
,
2659 struct net_device
*dev
)
2663 struct qeth_hdr
*hdr
= NULL
;
2664 int hdr_elements
= 0;
2666 struct qeth_card
*card
= dev
->ml_priv
;
2667 struct sk_buff
*new_skb
= NULL
;
2668 int ipv
= qeth_get_ip_version(skb
);
2669 int cast_type
= qeth_l3_get_cast_type(card
, skb
);
2670 struct qeth_qdio_out_q
*queue
=
2671 card
->qdio
.out_qs
[card
->qdio
.do_prio_queueing
2672 || (cast_type
&& card
->info
.is_multicast_different
) ?
2673 qeth_get_priority_queue(card
, skb
, ipv
, cast_type
) :
2674 card
->qdio
.default_out_queue
];
2675 int tx_bytes
= skb
->len
;
2677 int data_offset
= -1;
2680 if (((card
->info
.type
== QETH_CARD_TYPE_IQD
) &&
2681 (((card
->options
.cq
!= QETH_CQ_ENABLED
) && !ipv
) ||
2682 ((card
->options
.cq
== QETH_CQ_ENABLED
) &&
2683 (be16_to_cpu(skb
->protocol
) != ETH_P_AF_IUCV
)))) ||
2684 card
->options
.sniffer
)
2687 if ((card
->state
!= CARD_STATE_UP
) || !card
->lan_online
) {
2688 card
->stats
.tx_carrier_errors
++;
2692 if ((cast_type
== RTN_BROADCAST
) &&
2693 (card
->info
.broadcast_capable
== 0))
2696 if (card
->options
.performance_stats
) {
2697 card
->perf_stats
.outbound_cnt
++;
2698 card
->perf_stats
.outbound_start_time
= qeth_get_micros();
2701 /* Ignore segment size from skb_is_gso(), 1 page is always used. */
2702 use_tso
= skb_is_gso(skb
) &&
2703 (qeth_get_ip_protocol(skb
) == IPPROTO_TCP
) && (ipv
== 4);
2705 if ((card
->info
.type
== QETH_CARD_TYPE_IQD
) &&
2706 !skb_is_nonlinear(skb
)) {
2708 data_offset
= ETH_HLEN
;
2709 hdr
= kmem_cache_alloc(qeth_core_header_cache
, GFP_ATOMIC
);
2714 /* create a clone with writeable headroom */
2715 new_skb
= skb_realloc_headroom(skb
, sizeof(struct qeth_hdr_tso
)
2721 if (card
->info
.type
== QETH_CARD_TYPE_IQD
) {
2722 if (data_offset
< 0)
2723 skb_pull(new_skb
, ETH_HLEN
);
2726 skb_pull(new_skb
, ETH_HLEN
);
2729 if (ipv
!= 4 && skb_vlan_tag_present(new_skb
)) {
2730 skb_push(new_skb
, VLAN_HLEN
);
2731 skb_copy_to_linear_data(new_skb
, new_skb
->data
+ 4, 4);
2732 skb_copy_to_linear_data_offset(new_skb
, 4,
2733 new_skb
->data
+ 8, 4);
2734 skb_copy_to_linear_data_offset(new_skb
, 8,
2735 new_skb
->data
+ 12, 4);
2736 tag
= (__be16
*)(new_skb
->data
+ 12);
2737 *tag
= cpu_to_be16(ETH_P_8021Q
);
2738 *(tag
+ 1) = cpu_to_be16(skb_vlan_tag_get(new_skb
));
2742 netif_stop_queue(dev
);
2744 /* fix hardware limitation: as long as we do not have sbal
2745 * chaining we can not send long frag lists
2747 if ((card
->info
.type
!= QETH_CARD_TYPE_IQD
) &&
2748 ((use_tso
&& !qeth_l3_get_elements_no_tso(card
, new_skb
, 1)) ||
2749 (!use_tso
&& !qeth_get_elements_no(card
, new_skb
, 0, 0)))) {
2750 int lin_rc
= skb_linearize(new_skb
);
2752 if (card
->options
.performance_stats
) {
2754 card
->perf_stats
.tx_linfail
++;
2756 card
->perf_stats
.tx_lin
++;
2763 hdr
= (struct qeth_hdr
*)skb_push(new_skb
,
2764 sizeof(struct qeth_hdr_tso
));
2765 memset(hdr
, 0, sizeof(struct qeth_hdr_tso
));
2766 qeth_l3_fill_header(card
, hdr
, new_skb
, ipv
, cast_type
);
2767 qeth_tso_fill_header(card
, hdr
, new_skb
);
2770 if (data_offset
< 0) {
2771 hdr
= (struct qeth_hdr
*)skb_push(new_skb
,
2772 sizeof(struct qeth_hdr
));
2773 qeth_l3_fill_header(card
, hdr
, new_skb
, ipv
,
2776 if (be16_to_cpu(new_skb
->protocol
) == ETH_P_AF_IUCV
)
2777 qeth_l3_fill_af_iucv_hdr(card
, hdr
, new_skb
);
2779 qeth_l3_fill_header(card
, hdr
, new_skb
, ipv
,
2781 hdr
->hdr
.l3
.length
= new_skb
->len
- data_offset
;
2785 if (skb
->ip_summed
== CHECKSUM_PARTIAL
)
2786 qeth_l3_hdr_csum(card
, hdr
, new_skb
);
2789 elements
= use_tso
?
2790 qeth_l3_get_elements_no_tso(card
, new_skb
, hdr_elements
) :
2791 qeth_get_elements_no(card
, new_skb
, hdr_elements
,
2792 (data_offset
> 0) ? data_offset
: 0);
2794 if (data_offset
>= 0)
2795 kmem_cache_free(qeth_core_header_cache
, hdr
);
2798 elements
+= hdr_elements
;
2800 if (card
->info
.type
!= QETH_CARD_TYPE_IQD
) {
2803 len
= ((unsigned long)tcp_hdr(new_skb
) +
2804 tcp_hdrlen(new_skb
)) -
2805 (unsigned long)new_skb
->data
;
2807 len
= sizeof(struct qeth_hdr_layer3
);
2809 if (qeth_hdr_chk_and_bounce(new_skb
, &hdr
, len
))
2811 rc
= qeth_do_send_packet(card
, queue
, new_skb
, hdr
, elements
);
2813 rc
= qeth_do_send_packet_fast(card
, queue
, new_skb
, hdr
,
2817 card
->stats
.tx_packets
++;
2818 card
->stats
.tx_bytes
+= tx_bytes
;
2820 dev_kfree_skb_any(skb
);
2821 if (card
->options
.performance_stats
) {
2822 nr_frags
= skb_shinfo(new_skb
)->nr_frags
;
2824 card
->perf_stats
.large_send_bytes
+= tx_bytes
;
2825 card
->perf_stats
.large_send_cnt
++;
2828 card
->perf_stats
.sg_skbs_sent
++;
2829 /* nr_frags + skb->data */
2830 card
->perf_stats
.sg_frags_sent
+= nr_frags
+ 1;
2835 if (data_offset
>= 0)
2836 kmem_cache_free(qeth_core_header_cache
, hdr
);
2840 dev_kfree_skb_any(new_skb
);
2841 return NETDEV_TX_BUSY
;
2846 netif_wake_queue(dev
);
2847 if (card
->options
.performance_stats
)
2848 card
->perf_stats
.outbound_time
+= qeth_get_micros() -
2849 card
->perf_stats
.outbound_start_time
;
2853 card
->stats
.tx_dropped
++;
2854 card
->stats
.tx_errors
++;
2855 if ((new_skb
!= skb
) && new_skb
)
2856 dev_kfree_skb_any(new_skb
);
2857 dev_kfree_skb_any(skb
);
2858 netif_wake_queue(dev
);
2859 return NETDEV_TX_OK
;
2862 static int __qeth_l3_open(struct net_device
*dev
)
2864 struct qeth_card
*card
= dev
->ml_priv
;
2867 QETH_CARD_TEXT(card
, 4, "qethopen");
2868 if (card
->state
== CARD_STATE_UP
)
2870 if (card
->state
!= CARD_STATE_SOFTSETUP
)
2872 card
->data
.state
= CH_STATE_UP
;
2873 card
->state
= CARD_STATE_UP
;
2874 netif_start_queue(dev
);
2876 if (qdio_stop_irq(card
->data
.ccwdev
, 0) >= 0) {
2877 napi_enable(&card
->napi
);
2878 napi_schedule(&card
->napi
);
2884 static int qeth_l3_open(struct net_device
*dev
)
2886 struct qeth_card
*card
= dev
->ml_priv
;
2888 QETH_CARD_TEXT(card
, 5, "qethope_");
2889 if (qeth_wait_for_threads(card
, QETH_RECOVER_THREAD
)) {
2890 QETH_CARD_TEXT(card
, 3, "openREC");
2891 return -ERESTARTSYS
;
2893 return __qeth_l3_open(dev
);
2896 static int qeth_l3_stop(struct net_device
*dev
)
2898 struct qeth_card
*card
= dev
->ml_priv
;
2900 QETH_CARD_TEXT(card
, 4, "qethstop");
2901 netif_tx_disable(dev
);
2902 if (card
->state
== CARD_STATE_UP
) {
2903 card
->state
= CARD_STATE_SOFTSETUP
;
2904 napi_disable(&card
->napi
);
2909 static const struct ethtool_ops qeth_l3_ethtool_ops
= {
2910 .get_link
= ethtool_op_get_link
,
2911 .get_strings
= qeth_core_get_strings
,
2912 .get_ethtool_stats
= qeth_core_get_ethtool_stats
,
2913 .get_sset_count
= qeth_core_get_sset_count
,
2914 .get_drvinfo
= qeth_core_get_drvinfo
,
2915 .get_link_ksettings
= qeth_core_ethtool_get_link_ksettings
,
2919 * we need NOARP for IPv4 but we want neighbor solicitation for IPv6. Setting
2920 * NOARP on the netdevice is no option because it also turns off neighbor
2921 * solicitation. For IPv4 we install a neighbor_setup function. We don't want
2922 * arp resolution but we want the hard header (packet socket will work
2925 static int qeth_l3_neigh_setup_noarp(struct neighbour
*n
)
2927 n
->nud_state
= NUD_NOARP
;
2928 memcpy(n
->ha
, "FAKELL", 6);
2929 n
->output
= n
->ops
->connected_output
;
2934 qeth_l3_neigh_setup(struct net_device
*dev
, struct neigh_parms
*np
)
2936 if (np
->tbl
->family
== AF_INET
)
2937 np
->neigh_setup
= qeth_l3_neigh_setup_noarp
;
2942 static const struct net_device_ops qeth_l3_netdev_ops
= {
2943 .ndo_open
= qeth_l3_open
,
2944 .ndo_stop
= qeth_l3_stop
,
2945 .ndo_get_stats
= qeth_get_stats
,
2946 .ndo_start_xmit
= qeth_l3_hard_start_xmit
,
2947 .ndo_validate_addr
= eth_validate_addr
,
2948 .ndo_set_rx_mode
= qeth_l3_set_multicast_list
,
2949 .ndo_do_ioctl
= qeth_do_ioctl
,
2950 .ndo_change_mtu
= qeth_change_mtu
,
2951 .ndo_fix_features
= qeth_fix_features
,
2952 .ndo_set_features
= qeth_set_features
,
2953 .ndo_vlan_rx_add_vid
= qeth_l3_vlan_rx_add_vid
,
2954 .ndo_vlan_rx_kill_vid
= qeth_l3_vlan_rx_kill_vid
,
2955 .ndo_tx_timeout
= qeth_tx_timeout
,
2958 static const struct net_device_ops qeth_l3_osa_netdev_ops
= {
2959 .ndo_open
= qeth_l3_open
,
2960 .ndo_stop
= qeth_l3_stop
,
2961 .ndo_get_stats
= qeth_get_stats
,
2962 .ndo_start_xmit
= qeth_l3_hard_start_xmit
,
2963 .ndo_validate_addr
= eth_validate_addr
,
2964 .ndo_set_rx_mode
= qeth_l3_set_multicast_list
,
2965 .ndo_do_ioctl
= qeth_do_ioctl
,
2966 .ndo_change_mtu
= qeth_change_mtu
,
2967 .ndo_fix_features
= qeth_fix_features
,
2968 .ndo_set_features
= qeth_set_features
,
2969 .ndo_vlan_rx_add_vid
= qeth_l3_vlan_rx_add_vid
,
2970 .ndo_vlan_rx_kill_vid
= qeth_l3_vlan_rx_kill_vid
,
2971 .ndo_tx_timeout
= qeth_tx_timeout
,
2972 .ndo_neigh_setup
= qeth_l3_neigh_setup
,
2975 static int qeth_l3_setup_netdev(struct qeth_card
*card
)
2979 if (card
->info
.type
== QETH_CARD_TYPE_OSD
||
2980 card
->info
.type
== QETH_CARD_TYPE_OSX
) {
2981 if ((card
->info
.link_type
== QETH_LINK_TYPE_LANE_TR
) ||
2982 (card
->info
.link_type
== QETH_LINK_TYPE_HSTR
)) {
2983 pr_info("qeth_l3: ignoring TR device\n");
2986 card
->dev
= alloc_etherdev(0);
2989 card
->dev
->netdev_ops
= &qeth_l3_osa_netdev_ops
;
2991 /*IPv6 address autoconfiguration stuff*/
2992 qeth_l3_get_unique_id(card
);
2993 if (!(card
->info
.unique_id
& UNIQUE_ID_NOT_BY_CARD
))
2994 card
->dev
->dev_id
= card
->info
.unique_id
&
2996 if (!card
->info
.guestlan
) {
2997 card
->dev
->hw_features
= NETIF_F_SG
|
2998 NETIF_F_RXCSUM
| NETIF_F_IP_CSUM
|
3000 card
->dev
->vlan_features
= NETIF_F_SG
|
3001 NETIF_F_RXCSUM
| NETIF_F_IP_CSUM
|
3005 } else if (card
->info
.type
== QETH_CARD_TYPE_IQD
) {
3006 card
->dev
= alloc_netdev(0, "hsi%d", NET_NAME_UNKNOWN
,
3010 card
->dev
->flags
|= IFF_NOARP
;
3011 card
->dev
->netdev_ops
= &qeth_l3_netdev_ops
;
3012 rc
= qeth_l3_iqd_read_initial_mac(card
);
3015 if (card
->options
.hsuid
[0])
3016 memcpy(card
->dev
->perm_addr
, card
->options
.hsuid
, 9);
3020 card
->dev
->ml_priv
= card
;
3021 card
->dev
->watchdog_timeo
= QETH_TX_TIMEOUT
;
3022 card
->dev
->mtu
= card
->info
.initial_mtu
;
3023 card
->dev
->min_mtu
= 64;
3024 card
->dev
->max_mtu
= ETH_MAX_MTU
;
3025 card
->dev
->ethtool_ops
= &qeth_l3_ethtool_ops
;
3026 card
->dev
->features
|= NETIF_F_HW_VLAN_CTAG_TX
|
3027 NETIF_F_HW_VLAN_CTAG_RX
|
3028 NETIF_F_HW_VLAN_CTAG_FILTER
;
3029 netif_keep_dst(card
->dev
);
3030 card
->dev
->gso_max_size
= (QETH_MAX_BUFFER_ELEMENTS(card
) - 1) *
3033 SET_NETDEV_DEV(card
->dev
, &card
->gdev
->dev
);
3034 netif_napi_add(card
->dev
, &card
->napi
, qeth_poll
, QETH_NAPI_WEIGHT
);
3035 netif_carrier_off(card
->dev
);
3036 return register_netdev(card
->dev
);
3039 static int qeth_l3_probe_device(struct ccwgroup_device
*gdev
)
3041 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
3043 qeth_l3_create_device_attributes(&gdev
->dev
);
3044 card
->options
.layer2
= 0;
3045 card
->info
.hwtrap
= 0;
3049 static void qeth_l3_remove_device(struct ccwgroup_device
*cgdev
)
3051 struct qeth_card
*card
= dev_get_drvdata(&cgdev
->dev
);
3053 qeth_l3_remove_device_attributes(&cgdev
->dev
);
3055 qeth_set_allowed_threads(card
, 0, 1);
3056 wait_event(card
->wait_q
, qeth_threads_running(card
, 0xffffffff) == 0);
3058 if (cgdev
->state
== CCWGROUP_ONLINE
)
3059 qeth_l3_set_offline(cgdev
);
3062 netif_napi_del(&card
->napi
);
3063 unregister_netdev(card
->dev
);
3067 qeth_l3_clear_ip_htable(card
, 0);
3068 qeth_l3_clear_ipato_list(card
);
3072 static int __qeth_l3_set_online(struct ccwgroup_device
*gdev
, int recovery_mode
)
3074 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
3076 enum qeth_card_states recover_flag
;
3078 mutex_lock(&card
->discipline_mutex
);
3079 mutex_lock(&card
->conf_mutex
);
3080 QETH_DBF_TEXT(SETUP
, 2, "setonlin");
3081 QETH_DBF_HEX(SETUP
, 2, &card
, sizeof(void *));
3083 recover_flag
= card
->state
;
3084 rc
= qeth_core_hardsetup_card(card
);
3086 QETH_DBF_TEXT_(SETUP
, 2, "2err%04x", rc
);
3091 if (!card
->dev
&& qeth_l3_setup_netdev(card
)) {
3096 if (qeth_is_diagass_supported(card
, QETH_DIAGS_CMD_TRAP
)) {
3097 if (card
->info
.hwtrap
&&
3098 qeth_hw_trap(card
, QETH_DIAGS_TRAP_ARM
))
3099 card
->info
.hwtrap
= 0;
3101 card
->info
.hwtrap
= 0;
3103 card
->state
= CARD_STATE_HARDSETUP
;
3104 memset(&card
->rx
, 0, sizeof(struct qeth_rx
));
3105 qeth_print_status_message(card
);
3108 QETH_DBF_TEXT(SETUP
, 2, "softsetp");
3110 rc
= qeth_l3_setadapter_parms(card
);
3112 QETH_DBF_TEXT_(SETUP
, 2, "2err%04x", rc
);
3113 if (!card
->options
.sniffer
) {
3114 rc
= qeth_l3_start_ipassists(card
);
3116 QETH_DBF_TEXT_(SETUP
, 2, "3err%d", rc
);
3119 rc
= qeth_l3_setrouting_v4(card
);
3121 QETH_DBF_TEXT_(SETUP
, 2, "4err%04x", rc
);
3122 rc
= qeth_l3_setrouting_v6(card
);
3124 QETH_DBF_TEXT_(SETUP
, 2, "5err%04x", rc
);
3126 netif_tx_disable(card
->dev
);
3128 rc
= qeth_init_qdio_queues(card
);
3130 QETH_DBF_TEXT_(SETUP
, 2, "6err%d", rc
);
3134 card
->state
= CARD_STATE_SOFTSETUP
;
3136 qeth_set_allowed_threads(card
, 0xffffffff, 0);
3137 qeth_l3_recover_ip(card
);
3138 if (card
->lan_online
)
3139 netif_carrier_on(card
->dev
);
3141 netif_carrier_off(card
->dev
);
3142 if (recover_flag
== CARD_STATE_RECOVER
) {
3145 __qeth_l3_open(card
->dev
);
3147 dev_open(card
->dev
);
3148 qeth_l3_set_multicast_list(card
->dev
);
3149 qeth_recover_features(card
->dev
);
3152 qeth_trace_features(card
);
3153 /* let user_space know that device is online */
3154 kobject_uevent(&gdev
->dev
.kobj
, KOBJ_CHANGE
);
3155 mutex_unlock(&card
->conf_mutex
);
3156 mutex_unlock(&card
->discipline_mutex
);
3159 qeth_l3_stop_card(card
, 0);
3160 ccw_device_set_offline(CARD_DDEV(card
));
3161 ccw_device_set_offline(CARD_WDEV(card
));
3162 ccw_device_set_offline(CARD_RDEV(card
));
3163 qdio_free(CARD_DDEV(card
));
3164 if (recover_flag
== CARD_STATE_RECOVER
)
3165 card
->state
= CARD_STATE_RECOVER
;
3167 card
->state
= CARD_STATE_DOWN
;
3168 mutex_unlock(&card
->conf_mutex
);
3169 mutex_unlock(&card
->discipline_mutex
);
3173 static int qeth_l3_set_online(struct ccwgroup_device
*gdev
)
3175 return __qeth_l3_set_online(gdev
, 0);
3178 static int __qeth_l3_set_offline(struct ccwgroup_device
*cgdev
,
3181 struct qeth_card
*card
= dev_get_drvdata(&cgdev
->dev
);
3182 int rc
= 0, rc2
= 0, rc3
= 0;
3183 enum qeth_card_states recover_flag
;
3185 mutex_lock(&card
->discipline_mutex
);
3186 mutex_lock(&card
->conf_mutex
);
3187 QETH_DBF_TEXT(SETUP
, 3, "setoffl");
3188 QETH_DBF_HEX(SETUP
, 3, &card
, sizeof(void *));
3190 if (card
->dev
&& netif_carrier_ok(card
->dev
))
3191 netif_carrier_off(card
->dev
);
3192 recover_flag
= card
->state
;
3193 if ((!recovery_mode
&& card
->info
.hwtrap
) || card
->info
.hwtrap
== 2) {
3194 qeth_hw_trap(card
, QETH_DIAGS_TRAP_DISARM
);
3195 card
->info
.hwtrap
= 1;
3197 qeth_l3_stop_card(card
, recovery_mode
);
3198 if ((card
->options
.cq
== QETH_CQ_ENABLED
) && card
->dev
) {
3200 call_netdevice_notifiers(NETDEV_REBOOT
, card
->dev
);
3203 rc
= ccw_device_set_offline(CARD_DDEV(card
));
3204 rc2
= ccw_device_set_offline(CARD_WDEV(card
));
3205 rc3
= ccw_device_set_offline(CARD_RDEV(card
));
3207 rc
= (rc2
) ? rc2
: rc3
;
3209 QETH_DBF_TEXT_(SETUP
, 2, "1err%d", rc
);
3210 qdio_free(CARD_DDEV(card
));
3211 if (recover_flag
== CARD_STATE_UP
)
3212 card
->state
= CARD_STATE_RECOVER
;
3213 /* let user_space know that device is offline */
3214 kobject_uevent(&cgdev
->dev
.kobj
, KOBJ_CHANGE
);
3215 mutex_unlock(&card
->conf_mutex
);
3216 mutex_unlock(&card
->discipline_mutex
);
3220 static int qeth_l3_set_offline(struct ccwgroup_device
*cgdev
)
3222 return __qeth_l3_set_offline(cgdev
, 0);
3225 static int qeth_l3_recover(void *ptr
)
3227 struct qeth_card
*card
;
3230 card
= (struct qeth_card
*) ptr
;
3231 QETH_CARD_TEXT(card
, 2, "recover1");
3232 QETH_CARD_HEX(card
, 2, &card
, sizeof(void *));
3233 if (!qeth_do_run_thread(card
, QETH_RECOVER_THREAD
))
3235 QETH_CARD_TEXT(card
, 2, "recover2");
3236 dev_warn(&card
->gdev
->dev
,
3237 "A recovery process has been started for the device\n");
3238 qeth_set_recovery_task(card
);
3239 __qeth_l3_set_offline(card
->gdev
, 1);
3240 rc
= __qeth_l3_set_online(card
->gdev
, 1);
3242 dev_info(&card
->gdev
->dev
,
3243 "Device successfully recovered!\n");
3245 qeth_close_dev(card
);
3246 dev_warn(&card
->gdev
->dev
, "The qeth device driver "
3247 "failed to recover an error on the device\n");
3249 qeth_clear_recovery_task(card
);
3250 qeth_clear_thread_start_bit(card
, QETH_RECOVER_THREAD
);
3251 qeth_clear_thread_running_bit(card
, QETH_RECOVER_THREAD
);
3255 static int qeth_l3_pm_suspend(struct ccwgroup_device
*gdev
)
3257 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
3260 netif_device_detach(card
->dev
);
3261 qeth_set_allowed_threads(card
, 0, 1);
3262 wait_event(card
->wait_q
, qeth_threads_running(card
, 0xffffffff) == 0);
3263 if (gdev
->state
== CCWGROUP_OFFLINE
)
3265 if (card
->state
== CARD_STATE_UP
) {
3266 if (card
->info
.hwtrap
)
3267 qeth_hw_trap(card
, QETH_DIAGS_TRAP_DISARM
);
3268 __qeth_l3_set_offline(card
->gdev
, 1);
3270 __qeth_l3_set_offline(card
->gdev
, 0);
3274 static int qeth_l3_pm_resume(struct ccwgroup_device
*gdev
)
3276 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
3279 if (gdev
->state
== CCWGROUP_OFFLINE
)
3282 if (card
->state
== CARD_STATE_RECOVER
) {
3283 rc
= __qeth_l3_set_online(card
->gdev
, 1);
3286 dev_close(card
->dev
);
3290 rc
= __qeth_l3_set_online(card
->gdev
, 0);
3292 qeth_set_allowed_threads(card
, 0xffffffff, 0);
3294 netif_device_attach(card
->dev
);
3296 dev_warn(&card
->gdev
->dev
, "The qeth device driver "
3297 "failed to recover an error on the device\n");
3301 /* Returns zero if the command is successfully "consumed" */
3302 static int qeth_l3_control_event(struct qeth_card
*card
,
3303 struct qeth_ipa_cmd
*cmd
)
3308 struct qeth_discipline qeth_l3_discipline
= {
3309 .start_poll
= qeth_qdio_start_poll
,
3310 .input_handler
= (qdio_handler_t
*) qeth_qdio_input_handler
,
3311 .output_handler
= (qdio_handler_t
*) qeth_qdio_output_handler
,
3312 .process_rx_buffer
= qeth_l3_process_inbound_buffer
,
3313 .recover
= qeth_l3_recover
,
3314 .setup
= qeth_l3_probe_device
,
3315 .remove
= qeth_l3_remove_device
,
3316 .set_online
= qeth_l3_set_online
,
3317 .set_offline
= qeth_l3_set_offline
,
3318 .freeze
= qeth_l3_pm_suspend
,
3319 .thaw
= qeth_l3_pm_resume
,
3320 .restore
= qeth_l3_pm_resume
,
3321 .do_ioctl
= qeth_l3_do_ioctl
,
3322 .control_event_handler
= qeth_l3_control_event
,
3324 EXPORT_SYMBOL_GPL(qeth_l3_discipline
);
3326 static int qeth_l3_ip_event(struct notifier_block
*this,
3327 unsigned long event
, void *ptr
)
3330 struct in_ifaddr
*ifa
= (struct in_ifaddr
*)ptr
;
3331 struct net_device
*dev
= (struct net_device
*)ifa
->ifa_dev
->dev
;
3332 struct qeth_ipaddr
*addr
;
3333 struct qeth_card
*card
;
3335 if (dev_net(dev
) != &init_net
)
3338 card
= qeth_l3_get_card_from_dev(dev
);
3341 QETH_CARD_TEXT(card
, 3, "ipevent");
3343 addr
= qeth_l3_get_addr_buffer(QETH_PROT_IPV4
);
3345 addr
->u
.a4
.addr
= be32_to_cpu(ifa
->ifa_address
);
3346 addr
->u
.a4
.mask
= be32_to_cpu(ifa
->ifa_mask
);
3347 addr
->type
= QETH_IP_TYPE_NORMAL
;
3353 spin_lock_bh(&card
->ip_lock
);
3354 qeth_l3_add_ip(card
, addr
);
3355 spin_unlock_bh(&card
->ip_lock
);
3358 spin_lock_bh(&card
->ip_lock
);
3359 qeth_l3_delete_ip(card
, addr
);
3360 spin_unlock_bh(&card
->ip_lock
);
3368 static struct notifier_block qeth_l3_ip_notifier
= {
3373 #ifdef CONFIG_QETH_IPV6
3375 * IPv6 event handler
3377 static int qeth_l3_ip6_event(struct notifier_block
*this,
3378 unsigned long event
, void *ptr
)
3380 struct inet6_ifaddr
*ifa
= (struct inet6_ifaddr
*)ptr
;
3381 struct net_device
*dev
= (struct net_device
*)ifa
->idev
->dev
;
3382 struct qeth_ipaddr
*addr
;
3383 struct qeth_card
*card
;
3385 card
= qeth_l3_get_card_from_dev(dev
);
3388 QETH_CARD_TEXT(card
, 3, "ip6event");
3389 if (!qeth_is_supported(card
, IPA_IPV6
))
3392 addr
= qeth_l3_get_addr_buffer(QETH_PROT_IPV6
);
3394 memcpy(&addr
->u
.a6
.addr
, &ifa
->addr
, sizeof(struct in6_addr
));
3395 addr
->u
.a6
.pfxlen
= ifa
->prefix_len
;
3396 addr
->type
= QETH_IP_TYPE_NORMAL
;
3402 spin_lock_bh(&card
->ip_lock
);
3403 qeth_l3_add_ip(card
, addr
);
3404 spin_unlock_bh(&card
->ip_lock
);
3407 spin_lock_bh(&card
->ip_lock
);
3408 qeth_l3_delete_ip(card
, addr
);
3409 spin_unlock_bh(&card
->ip_lock
);
3417 static struct notifier_block qeth_l3_ip6_notifier
= {
3423 static int qeth_l3_register_notifiers(void)
3427 QETH_DBF_TEXT(SETUP
, 5, "regnotif");
3428 rc
= register_inetaddr_notifier(&qeth_l3_ip_notifier
);
3431 #ifdef CONFIG_QETH_IPV6
3432 rc
= register_inet6addr_notifier(&qeth_l3_ip6_notifier
);
3434 unregister_inetaddr_notifier(&qeth_l3_ip_notifier
);
3438 pr_warn("There is no IPv6 support for the layer 3 discipline\n");
3443 static void qeth_l3_unregister_notifiers(void)
3446 QETH_DBF_TEXT(SETUP
, 5, "unregnot");
3447 WARN_ON(unregister_inetaddr_notifier(&qeth_l3_ip_notifier
));
3448 #ifdef CONFIG_QETH_IPV6
3449 WARN_ON(unregister_inet6addr_notifier(&qeth_l3_ip6_notifier
));
3450 #endif /* QETH_IPV6 */
3453 static int __init
qeth_l3_init(void)
3457 pr_info("register layer 3 discipline\n");
3458 rc
= qeth_l3_register_notifiers();
3462 static void __exit
qeth_l3_exit(void)
3464 qeth_l3_unregister_notifiers();
3465 pr_info("unregister layer 3 discipline\n");
3468 module_init(qeth_l3_init
);
3469 module_exit(qeth_l3_exit
);
3470 MODULE_AUTHOR("Frank Blaschka <frank.blaschka@de.ibm.com>");
3471 MODULE_DESCRIPTION("qeth layer 3 discipline");
3472 MODULE_LICENSE("GPL");