2 * drivers/s390/net/qeth_l3_main.c
4 * Copyright IBM Corp. 2007
5 * Author(s): Utz Bacher <utz.bacher@de.ibm.com>,
6 * Frank Pavlic <fpavlic@de.ibm.com>,
7 * Thomas Spatzier <tspat@de.ibm.com>,
8 * Frank Blaschka <frank.blaschka@de.ibm.com>
11 #include <linux/module.h>
12 #include <linux/moduleparam.h>
13 #include <linux/string.h>
14 #include <linux/errno.h>
15 #include <linux/kernel.h>
16 #include <linux/etherdevice.h>
17 #include <linux/mii.h>
19 #include <linux/reboot.h>
20 #include <linux/inetdevice.h>
21 #include <linux/igmp.h>
26 #include <asm/s390_rdev.h>
29 #include "qeth_core_offl.h"
31 DEFINE_PER_CPU(char[256], qeth_l3_dbf_txt_buf
);
33 static int qeth_l3_set_offline(struct ccwgroup_device
*);
34 static int qeth_l3_recover(void *);
35 static int qeth_l3_stop(struct net_device
*);
36 static void qeth_l3_set_multicast_list(struct net_device
*);
37 static int qeth_l3_neigh_setup(struct net_device
*, struct neigh_parms
*);
38 static int qeth_l3_register_addr_entry(struct qeth_card
*,
39 struct qeth_ipaddr
*);
40 static int qeth_l3_deregister_addr_entry(struct qeth_card
*,
41 struct qeth_ipaddr
*);
42 static int __qeth_l3_set_online(struct ccwgroup_device
*, int);
43 static int __qeth_l3_set_offline(struct ccwgroup_device
*, int);
46 static int qeth_l3_isxdigit(char *buf
)
49 if (!isxdigit(*buf
++))
55 void qeth_l3_ipaddr4_to_string(const __u8
*addr
, char *buf
)
57 sprintf(buf
, "%i.%i.%i.%i", addr
[0], addr
[1], addr
[2], addr
[3]);
60 int qeth_l3_string_to_ipaddr4(const char *buf
, __u8
*addr
)
62 int count
= 0, rc
= 0;
66 rc
= sscanf(buf
, "%u.%u.%u.%u%c",
67 &in
[0], &in
[1], &in
[2], &in
[3], &c
);
68 if (rc
!= 4 && (rc
!= 5 || c
!= '\n'))
70 for (count
= 0; count
< 4; count
++) {
73 addr
[count
] = in
[count
];
78 void qeth_l3_ipaddr6_to_string(const __u8
*addr
, char *buf
)
80 sprintf(buf
, "%02x%02x:%02x%02x:%02x%02x:%02x%02x"
81 ":%02x%02x:%02x%02x:%02x%02x:%02x%02x",
82 addr
[0], addr
[1], addr
[2], addr
[3],
83 addr
[4], addr
[5], addr
[6], addr
[7],
84 addr
[8], addr
[9], addr
[10], addr
[11],
85 addr
[12], addr
[13], addr
[14], addr
[15]);
88 int qeth_l3_string_to_ipaddr6(const char *buf
, __u8
*addr
)
90 const char *end
, *end_tmp
, *start
;
93 int num2
, cnt
, out
, found
, save_cnt
;
94 unsigned short in_tmp
[8] = {0, };
96 cnt
= out
= found
= save_cnt
= num2
= 0;
101 end
= strchr(start
, ':');
103 end
= buf
+ strlen(buf
);
104 end_tmp
= strchr(start
, '\n');
111 if ((end
- start
) > 4)
113 memcpy(num
, start
, end
- start
);
114 if (!qeth_l3_isxdigit(num
))
116 sscanf(start
, "%x", &num2
);
118 in_tmp
[save_cnt
++] = num2
;
130 if (cnt
+ save_cnt
> 8)
134 in
[cnt
--] = in_tmp
[--save_cnt
];
138 void qeth_l3_ipaddr_to_string(enum qeth_prot_versions proto
, const __u8
*addr
,
141 if (proto
== QETH_PROT_IPV4
)
142 qeth_l3_ipaddr4_to_string(addr
, buf
);
143 else if (proto
== QETH_PROT_IPV6
)
144 qeth_l3_ipaddr6_to_string(addr
, buf
);
147 int qeth_l3_string_to_ipaddr(const char *buf
, enum qeth_prot_versions proto
,
150 if (proto
== QETH_PROT_IPV4
)
151 return qeth_l3_string_to_ipaddr4(buf
, addr
);
152 else if (proto
== QETH_PROT_IPV6
)
153 return qeth_l3_string_to_ipaddr6(buf
, addr
);
158 static void qeth_l3_convert_addr_to_bits(u8
*addr
, u8
*bits
, int len
)
163 for (i
= 0; i
< len
; ++i
) {
165 for (j
= 7; j
>= 0; --j
) {
166 bits
[i
*8 + j
] = octet
& 1;
172 static int qeth_l3_is_addr_covered_by_ipato(struct qeth_card
*card
,
173 struct qeth_ipaddr
*addr
)
175 struct qeth_ipato_entry
*ipatoe
;
176 u8 addr_bits
[128] = {0, };
177 u8 ipatoe_bits
[128] = {0, };
180 if (!card
->ipato
.enabled
)
183 qeth_l3_convert_addr_to_bits((u8
*) &addr
->u
, addr_bits
,
184 (addr
->proto
== QETH_PROT_IPV4
)? 4:16);
185 list_for_each_entry(ipatoe
, &card
->ipato
.entries
, entry
) {
186 if (addr
->proto
!= ipatoe
->proto
)
188 qeth_l3_convert_addr_to_bits(ipatoe
->addr
, ipatoe_bits
,
189 (ipatoe
->proto
== QETH_PROT_IPV4
) ?
191 if (addr
->proto
== QETH_PROT_IPV4
)
192 rc
= !memcmp(addr_bits
, ipatoe_bits
,
193 min(32, ipatoe
->mask_bits
));
195 rc
= !memcmp(addr_bits
, ipatoe_bits
,
196 min(128, ipatoe
->mask_bits
));
201 if ((addr
->proto
== QETH_PROT_IPV4
) && card
->ipato
.invert4
)
203 else if ((addr
->proto
== QETH_PROT_IPV6
) && card
->ipato
.invert6
)
210 * Add IP to be added to todo list. If there is already an "add todo"
211 * in this list we just incremenent the reference count.
212 * Returns 0 if we just incremented reference count.
214 static int __qeth_l3_insert_ip_todo(struct qeth_card
*card
,
215 struct qeth_ipaddr
*addr
, int add
)
217 struct qeth_ipaddr
*tmp
, *t
;
220 list_for_each_entry_safe(tmp
, t
, card
->ip_tbd_list
, entry
) {
221 if ((addr
->type
== QETH_IP_TYPE_DEL_ALL_MC
) &&
222 (tmp
->type
== QETH_IP_TYPE_DEL_ALL_MC
))
224 if ((tmp
->proto
== QETH_PROT_IPV4
) &&
225 (addr
->proto
== QETH_PROT_IPV4
) &&
226 (tmp
->type
== addr
->type
) &&
227 (tmp
->is_multicast
== addr
->is_multicast
) &&
228 (tmp
->u
.a4
.addr
== addr
->u
.a4
.addr
) &&
229 (tmp
->u
.a4
.mask
== addr
->u
.a4
.mask
)) {
233 if ((tmp
->proto
== QETH_PROT_IPV6
) &&
234 (addr
->proto
== QETH_PROT_IPV6
) &&
235 (tmp
->type
== addr
->type
) &&
236 (tmp
->is_multicast
== addr
->is_multicast
) &&
237 (tmp
->u
.a6
.pfxlen
== addr
->u
.a6
.pfxlen
) &&
238 (memcmp(&tmp
->u
.a6
.addr
, &addr
->u
.a6
.addr
,
239 sizeof(struct in6_addr
)) == 0)) {
245 if (addr
->users
!= 0)
246 tmp
->users
+= addr
->users
;
248 tmp
->users
+= add
? 1 : -1;
249 if (tmp
->users
== 0) {
250 list_del(&tmp
->entry
);
255 if (addr
->type
== QETH_IP_TYPE_DEL_ALL_MC
)
256 list_add(&addr
->entry
, card
->ip_tbd_list
);
258 if (addr
->users
== 0)
259 addr
->users
+= add
? 1 : -1;
260 if (add
&& (addr
->type
== QETH_IP_TYPE_NORMAL
) &&
261 qeth_l3_is_addr_covered_by_ipato(card
, addr
)) {
262 QETH_DBF_TEXT(trace
, 2, "tkovaddr");
263 addr
->set_flags
|= QETH_IPA_SETIP_TAKEOVER_FLAG
;
265 list_add_tail(&addr
->entry
, card
->ip_tbd_list
);
271 static int qeth_l3_delete_ip(struct qeth_card
*card
, struct qeth_ipaddr
*addr
)
276 QETH_DBF_TEXT(trace
, 4, "delip");
278 if (addr
->proto
== QETH_PROT_IPV4
)
279 QETH_DBF_HEX(trace
, 4, &addr
->u
.a4
.addr
, 4);
281 QETH_DBF_HEX(trace
, 4, &addr
->u
.a6
.addr
, 8);
282 QETH_DBF_HEX(trace
, 4, ((char *)&addr
->u
.a6
.addr
) + 8, 8);
284 spin_lock_irqsave(&card
->ip_lock
, flags
);
285 rc
= __qeth_l3_insert_ip_todo(card
, addr
, 0);
286 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
290 static int qeth_l3_add_ip(struct qeth_card
*card
, struct qeth_ipaddr
*addr
)
295 QETH_DBF_TEXT(trace
, 4, "addip");
296 if (addr
->proto
== QETH_PROT_IPV4
)
297 QETH_DBF_HEX(trace
, 4, &addr
->u
.a4
.addr
, 4);
299 QETH_DBF_HEX(trace
, 4, &addr
->u
.a6
.addr
, 8);
300 QETH_DBF_HEX(trace
, 4, ((char *)&addr
->u
.a6
.addr
) + 8, 8);
302 spin_lock_irqsave(&card
->ip_lock
, flags
);
303 rc
= __qeth_l3_insert_ip_todo(card
, addr
, 1);
304 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
309 static struct qeth_ipaddr
*qeth_l3_get_addr_buffer(
310 enum qeth_prot_versions prot
)
312 struct qeth_ipaddr
*addr
;
314 addr
= kzalloc(sizeof(struct qeth_ipaddr
), GFP_ATOMIC
);
316 PRINT_WARN("Not enough memory to add address\n");
319 addr
->type
= QETH_IP_TYPE_NORMAL
;
324 static void qeth_l3_delete_mc_addresses(struct qeth_card
*card
)
326 struct qeth_ipaddr
*iptodo
;
329 QETH_DBF_TEXT(trace
, 4, "delmc");
330 iptodo
= qeth_l3_get_addr_buffer(QETH_PROT_IPV4
);
332 QETH_DBF_TEXT(trace
, 2, "dmcnomem");
335 iptodo
->type
= QETH_IP_TYPE_DEL_ALL_MC
;
336 spin_lock_irqsave(&card
->ip_lock
, flags
);
337 if (!__qeth_l3_insert_ip_todo(card
, iptodo
, 0))
339 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
343 * Add/remove address to/from card's ip list, i.e. try to add or remove
344 * reference to/from an IP address that is already registered on the card.
346 * 0 address was on card and its reference count has been adjusted,
347 * but is still > 0, so nothing has to be done
348 * also returns 0 if card was not on card and the todo was to delete
349 * the address -> there is also nothing to be done
350 * 1 address was not on card and the todo is to add it to the card's ip
352 * -1 address was on card and its reference count has been decremented
353 * to <= 0 by the todo -> address must be removed from card
355 static int __qeth_l3_ref_ip_on_card(struct qeth_card
*card
,
356 struct qeth_ipaddr
*todo
, struct qeth_ipaddr
**__addr
)
358 struct qeth_ipaddr
*addr
;
361 list_for_each_entry(addr
, &card
->ip_list
, entry
) {
362 if ((addr
->proto
== QETH_PROT_IPV4
) &&
363 (todo
->proto
== QETH_PROT_IPV4
) &&
364 (addr
->type
== todo
->type
) &&
365 (addr
->u
.a4
.addr
== todo
->u
.a4
.addr
) &&
366 (addr
->u
.a4
.mask
== todo
->u
.a4
.mask
)) {
370 if ((addr
->proto
== QETH_PROT_IPV6
) &&
371 (todo
->proto
== QETH_PROT_IPV6
) &&
372 (addr
->type
== todo
->type
) &&
373 (addr
->u
.a6
.pfxlen
== todo
->u
.a6
.pfxlen
) &&
374 (memcmp(&addr
->u
.a6
.addr
, &todo
->u
.a6
.addr
,
375 sizeof(struct in6_addr
)) == 0)) {
381 addr
->users
+= todo
->users
;
382 if (addr
->users
<= 0) {
386 /* for VIPA and RXIP limit refcount to 1 */
387 if (addr
->type
!= QETH_IP_TYPE_NORMAL
)
392 if (todo
->users
> 0) {
393 /* for VIPA and RXIP limit refcount to 1 */
394 if (todo
->type
!= QETH_IP_TYPE_NORMAL
)
401 static void __qeth_l3_delete_all_mc(struct qeth_card
*card
,
402 unsigned long *flags
)
404 struct qeth_ipaddr
*addr
, *tmp
;
407 list_for_each_entry_safe(addr
, tmp
, &card
->ip_list
, entry
) {
408 if (addr
->is_multicast
) {
409 list_del(&addr
->entry
);
410 spin_unlock_irqrestore(&card
->ip_lock
, *flags
);
411 rc
= qeth_l3_deregister_addr_entry(card
, addr
);
412 spin_lock_irqsave(&card
->ip_lock
, *flags
);
417 list_add(&addr
->entry
, &card
->ip_list
);
422 static void qeth_l3_set_ip_addr_list(struct qeth_card
*card
)
424 struct list_head
*tbd_list
;
425 struct qeth_ipaddr
*todo
, *addr
;
429 QETH_DBF_TEXT(trace
, 2, "sdiplist");
430 QETH_DBF_HEX(trace
, 2, &card
, sizeof(void *));
432 spin_lock_irqsave(&card
->ip_lock
, flags
);
433 tbd_list
= card
->ip_tbd_list
;
434 card
->ip_tbd_list
= kmalloc(sizeof(struct list_head
), GFP_ATOMIC
);
435 if (!card
->ip_tbd_list
) {
436 QETH_DBF_TEXT(trace
, 0, "silnomem");
437 card
->ip_tbd_list
= tbd_list
;
438 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
441 INIT_LIST_HEAD(card
->ip_tbd_list
);
443 while (!list_empty(tbd_list
)) {
444 todo
= list_entry(tbd_list
->next
, struct qeth_ipaddr
, entry
);
445 list_del(&todo
->entry
);
446 if (todo
->type
== QETH_IP_TYPE_DEL_ALL_MC
) {
447 __qeth_l3_delete_all_mc(card
, &flags
);
451 rc
= __qeth_l3_ref_ip_on_card(card
, todo
, &addr
);
453 /* nothing to be done; only adjusted refcount */
455 } else if (rc
== 1) {
456 /* new entry to be added to on-card list */
457 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
458 rc
= qeth_l3_register_addr_entry(card
, todo
);
459 spin_lock_irqsave(&card
->ip_lock
, flags
);
461 list_add_tail(&todo
->entry
, &card
->ip_list
);
464 } else if (rc
== -1) {
465 /* on-card entry to be removed */
466 list_del_init(&addr
->entry
);
467 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
468 rc
= qeth_l3_deregister_addr_entry(card
, addr
);
469 spin_lock_irqsave(&card
->ip_lock
, flags
);
473 list_add_tail(&addr
->entry
, &card
->ip_list
);
477 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
481 static void qeth_l3_clear_ip_list(struct qeth_card
*card
, int clean
,
484 struct qeth_ipaddr
*addr
, *tmp
;
487 QETH_DBF_TEXT(trace
, 4, "clearip");
488 spin_lock_irqsave(&card
->ip_lock
, flags
);
489 /* clear todo list */
490 list_for_each_entry_safe(addr
, tmp
, card
->ip_tbd_list
, entry
) {
491 list_del(&addr
->entry
);
495 while (!list_empty(&card
->ip_list
)) {
496 addr
= list_entry(card
->ip_list
.next
,
497 struct qeth_ipaddr
, entry
);
498 list_del_init(&addr
->entry
);
500 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
501 qeth_l3_deregister_addr_entry(card
, addr
);
502 spin_lock_irqsave(&card
->ip_lock
, flags
);
504 if (!recover
|| addr
->is_multicast
) {
508 list_add_tail(&addr
->entry
, card
->ip_tbd_list
);
510 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
513 static int qeth_l3_address_exists_in_list(struct list_head
*list
,
514 struct qeth_ipaddr
*addr
, int same_type
)
516 struct qeth_ipaddr
*tmp
;
518 list_for_each_entry(tmp
, list
, entry
) {
519 if ((tmp
->proto
== QETH_PROT_IPV4
) &&
520 (addr
->proto
== QETH_PROT_IPV4
) &&
521 ((same_type
&& (tmp
->type
== addr
->type
)) ||
522 (!same_type
&& (tmp
->type
!= addr
->type
))) &&
523 (tmp
->u
.a4
.addr
== addr
->u
.a4
.addr
))
526 if ((tmp
->proto
== QETH_PROT_IPV6
) &&
527 (addr
->proto
== QETH_PROT_IPV6
) &&
528 ((same_type
&& (tmp
->type
== addr
->type
)) ||
529 (!same_type
&& (tmp
->type
!= addr
->type
))) &&
530 (memcmp(&tmp
->u
.a6
.addr
, &addr
->u
.a6
.addr
,
531 sizeof(struct in6_addr
)) == 0))
538 static int qeth_l3_send_setdelmc(struct qeth_card
*card
,
539 struct qeth_ipaddr
*addr
, int ipacmd
)
542 struct qeth_cmd_buffer
*iob
;
543 struct qeth_ipa_cmd
*cmd
;
545 QETH_DBF_TEXT(trace
, 4, "setdelmc");
547 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, addr
->proto
);
548 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
549 memcpy(&cmd
->data
.setdelipm
.mac
, addr
->mac
, OSA_ADDR_LEN
);
550 if (addr
->proto
== QETH_PROT_IPV6
)
551 memcpy(cmd
->data
.setdelipm
.ip6
, &addr
->u
.a6
.addr
,
552 sizeof(struct in6_addr
));
554 memcpy(&cmd
->data
.setdelipm
.ip4
, &addr
->u
.a4
.addr
, 4);
556 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
561 static void qeth_l3_fill_netmask(u8
*netmask
, unsigned int len
)
564 for (i
= 0; i
< 16; i
++) {
569 netmask
[i
] = (u8
)(0xFF00 >> j
);
575 static int qeth_l3_send_setdelip(struct qeth_card
*card
,
576 struct qeth_ipaddr
*addr
, int ipacmd
, unsigned int flags
)
579 struct qeth_cmd_buffer
*iob
;
580 struct qeth_ipa_cmd
*cmd
;
583 QETH_DBF_TEXT(trace
, 4, "setdelip");
584 QETH_DBF_TEXT_(trace
, 4, "flags%02X", flags
);
586 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, addr
->proto
);
587 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
588 if (addr
->proto
== QETH_PROT_IPV6
) {
589 memcpy(cmd
->data
.setdelip6
.ip_addr
, &addr
->u
.a6
.addr
,
590 sizeof(struct in6_addr
));
591 qeth_l3_fill_netmask(netmask
, addr
->u
.a6
.pfxlen
);
592 memcpy(cmd
->data
.setdelip6
.mask
, netmask
,
593 sizeof(struct in6_addr
));
594 cmd
->data
.setdelip6
.flags
= flags
;
596 memcpy(cmd
->data
.setdelip4
.ip_addr
, &addr
->u
.a4
.addr
, 4);
597 memcpy(cmd
->data
.setdelip4
.mask
, &addr
->u
.a4
.mask
, 4);
598 cmd
->data
.setdelip4
.flags
= flags
;
601 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
606 static int qeth_l3_send_setrouting(struct qeth_card
*card
,
607 enum qeth_routing_types type
, enum qeth_prot_versions prot
)
610 struct qeth_ipa_cmd
*cmd
;
611 struct qeth_cmd_buffer
*iob
;
613 QETH_DBF_TEXT(trace
, 4, "setroutg");
614 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_SETRTG
, prot
);
615 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
616 cmd
->data
.setrtg
.type
= (type
);
617 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
622 static void qeth_l3_correct_routing_type(struct qeth_card
*card
,
623 enum qeth_routing_types
*type
, enum qeth_prot_versions prot
)
625 if (card
->info
.type
== QETH_CARD_TYPE_IQD
) {
628 case PRIMARY_CONNECTOR
:
629 case SECONDARY_CONNECTOR
:
630 case MULTICAST_ROUTER
:
639 case SECONDARY_ROUTER
:
641 case MULTICAST_ROUTER
:
642 if (qeth_is_ipafunc_supported(card
, prot
,
650 PRINT_WARN("Routing type '%s' not supported for interface %s.\n"
651 "Router status set to 'no router'.\n",
652 ((*type
== PRIMARY_ROUTER
)? "primary router" :
653 (*type
== SECONDARY_ROUTER
)? "secondary router" :
654 (*type
== PRIMARY_CONNECTOR
)? "primary connector" :
655 (*type
== SECONDARY_CONNECTOR
)? "secondary connector" :
656 (*type
== MULTICAST_ROUTER
)? "multicast router" :
662 int qeth_l3_setrouting_v4(struct qeth_card
*card
)
666 QETH_DBF_TEXT(trace
, 3, "setrtg4");
668 qeth_l3_correct_routing_type(card
, &card
->options
.route4
.type
,
671 rc
= qeth_l3_send_setrouting(card
, card
->options
.route4
.type
,
674 card
->options
.route4
.type
= NO_ROUTER
;
675 PRINT_WARN("Error (0x%04x) while setting routing type on %s. "
676 "Type set to 'no router'.\n",
677 rc
, QETH_CARD_IFNAME(card
));
682 int qeth_l3_setrouting_v6(struct qeth_card
*card
)
686 QETH_DBF_TEXT(trace
, 3, "setrtg6");
687 #ifdef CONFIG_QETH_IPV6
689 if (!qeth_is_supported(card
, IPA_IPV6
))
691 qeth_l3_correct_routing_type(card
, &card
->options
.route6
.type
,
694 rc
= qeth_l3_send_setrouting(card
, card
->options
.route6
.type
,
697 card
->options
.route6
.type
= NO_ROUTER
;
698 PRINT_WARN("Error (0x%04x) while setting routing type on %s. "
699 "Type set to 'no router'.\n",
700 rc
, QETH_CARD_IFNAME(card
));
707 * IP address takeover related functions
709 static void qeth_l3_clear_ipato_list(struct qeth_card
*card
)
712 struct qeth_ipato_entry
*ipatoe
, *tmp
;
715 spin_lock_irqsave(&card
->ip_lock
, flags
);
716 list_for_each_entry_safe(ipatoe
, tmp
, &card
->ipato
.entries
, entry
) {
717 list_del(&ipatoe
->entry
);
720 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
723 int qeth_l3_add_ipato_entry(struct qeth_card
*card
,
724 struct qeth_ipato_entry
*new)
726 struct qeth_ipato_entry
*ipatoe
;
730 QETH_DBF_TEXT(trace
, 2, "addipato");
731 spin_lock_irqsave(&card
->ip_lock
, flags
);
732 list_for_each_entry(ipatoe
, &card
->ipato
.entries
, entry
) {
733 if (ipatoe
->proto
!= new->proto
)
735 if (!memcmp(ipatoe
->addr
, new->addr
,
736 (ipatoe
->proto
== QETH_PROT_IPV4
)? 4:16) &&
737 (ipatoe
->mask_bits
== new->mask_bits
)) {
738 PRINT_WARN("ipato entry already exists!\n");
744 list_add_tail(&new->entry
, &card
->ipato
.entries
);
746 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
750 void qeth_l3_del_ipato_entry(struct qeth_card
*card
,
751 enum qeth_prot_versions proto
, u8
*addr
, int mask_bits
)
753 struct qeth_ipato_entry
*ipatoe
, *tmp
;
756 QETH_DBF_TEXT(trace
, 2, "delipato");
757 spin_lock_irqsave(&card
->ip_lock
, flags
);
758 list_for_each_entry_safe(ipatoe
, tmp
, &card
->ipato
.entries
, entry
) {
759 if (ipatoe
->proto
!= proto
)
761 if (!memcmp(ipatoe
->addr
, addr
,
762 (proto
== QETH_PROT_IPV4
)? 4:16) &&
763 (ipatoe
->mask_bits
== mask_bits
)) {
764 list_del(&ipatoe
->entry
);
768 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
772 * VIPA related functions
774 int qeth_l3_add_vipa(struct qeth_card
*card
, enum qeth_prot_versions proto
,
777 struct qeth_ipaddr
*ipaddr
;
781 ipaddr
= qeth_l3_get_addr_buffer(proto
);
783 if (proto
== QETH_PROT_IPV4
) {
784 QETH_DBF_TEXT(trace
, 2, "addvipa4");
785 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
786 ipaddr
->u
.a4
.mask
= 0;
787 } else if (proto
== QETH_PROT_IPV6
) {
788 QETH_DBF_TEXT(trace
, 2, "addvipa6");
789 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
790 ipaddr
->u
.a6
.pfxlen
= 0;
792 ipaddr
->type
= QETH_IP_TYPE_VIPA
;
793 ipaddr
->set_flags
= QETH_IPA_SETIP_VIPA_FLAG
;
794 ipaddr
->del_flags
= QETH_IPA_DELIP_VIPA_FLAG
;
797 spin_lock_irqsave(&card
->ip_lock
, flags
);
798 if (qeth_l3_address_exists_in_list(&card
->ip_list
, ipaddr
, 0) ||
799 qeth_l3_address_exists_in_list(card
->ip_tbd_list
, ipaddr
, 0))
801 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
803 PRINT_WARN("Cannot add VIPA. Address already exists!\n");
806 if (!qeth_l3_add_ip(card
, ipaddr
))
808 qeth_l3_set_ip_addr_list(card
);
812 void qeth_l3_del_vipa(struct qeth_card
*card
, enum qeth_prot_versions proto
,
815 struct qeth_ipaddr
*ipaddr
;
817 ipaddr
= qeth_l3_get_addr_buffer(proto
);
819 if (proto
== QETH_PROT_IPV4
) {
820 QETH_DBF_TEXT(trace
, 2, "delvipa4");
821 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
822 ipaddr
->u
.a4
.mask
= 0;
823 } else if (proto
== QETH_PROT_IPV6
) {
824 QETH_DBF_TEXT(trace
, 2, "delvipa6");
825 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
826 ipaddr
->u
.a6
.pfxlen
= 0;
828 ipaddr
->type
= QETH_IP_TYPE_VIPA
;
831 if (!qeth_l3_delete_ip(card
, ipaddr
))
833 qeth_l3_set_ip_addr_list(card
);
837 * proxy ARP related functions
839 int qeth_l3_add_rxip(struct qeth_card
*card
, enum qeth_prot_versions proto
,
842 struct qeth_ipaddr
*ipaddr
;
846 ipaddr
= qeth_l3_get_addr_buffer(proto
);
848 if (proto
== QETH_PROT_IPV4
) {
849 QETH_DBF_TEXT(trace
, 2, "addrxip4");
850 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
851 ipaddr
->u
.a4
.mask
= 0;
852 } else if (proto
== QETH_PROT_IPV6
) {
853 QETH_DBF_TEXT(trace
, 2, "addrxip6");
854 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
855 ipaddr
->u
.a6
.pfxlen
= 0;
857 ipaddr
->type
= QETH_IP_TYPE_RXIP
;
858 ipaddr
->set_flags
= QETH_IPA_SETIP_TAKEOVER_FLAG
;
859 ipaddr
->del_flags
= 0;
862 spin_lock_irqsave(&card
->ip_lock
, flags
);
863 if (qeth_l3_address_exists_in_list(&card
->ip_list
, ipaddr
, 0) ||
864 qeth_l3_address_exists_in_list(card
->ip_tbd_list
, ipaddr
, 0))
866 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
868 PRINT_WARN("Cannot add RXIP. Address already exists!\n");
871 if (!qeth_l3_add_ip(card
, ipaddr
))
873 qeth_l3_set_ip_addr_list(card
);
877 void qeth_l3_del_rxip(struct qeth_card
*card
, enum qeth_prot_versions proto
,
880 struct qeth_ipaddr
*ipaddr
;
882 ipaddr
= qeth_l3_get_addr_buffer(proto
);
884 if (proto
== QETH_PROT_IPV4
) {
885 QETH_DBF_TEXT(trace
, 2, "addrxip4");
886 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
887 ipaddr
->u
.a4
.mask
= 0;
888 } else if (proto
== QETH_PROT_IPV6
) {
889 QETH_DBF_TEXT(trace
, 2, "addrxip6");
890 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
891 ipaddr
->u
.a6
.pfxlen
= 0;
893 ipaddr
->type
= QETH_IP_TYPE_RXIP
;
896 if (!qeth_l3_delete_ip(card
, ipaddr
))
898 qeth_l3_set_ip_addr_list(card
);
901 static int qeth_l3_register_addr_entry(struct qeth_card
*card
,
902 struct qeth_ipaddr
*addr
)
908 if (addr
->proto
== QETH_PROT_IPV4
) {
909 QETH_DBF_TEXT(trace
, 2, "setaddr4");
910 QETH_DBF_HEX(trace
, 3, &addr
->u
.a4
.addr
, sizeof(int));
911 } else if (addr
->proto
== QETH_PROT_IPV6
) {
912 QETH_DBF_TEXT(trace
, 2, "setaddr6");
913 QETH_DBF_HEX(trace
, 3, &addr
->u
.a6
.addr
, 8);
914 QETH_DBF_HEX(trace
, 3, ((char *)&addr
->u
.a6
.addr
) + 8, 8);
916 QETH_DBF_TEXT(trace
, 2, "setaddr?");
917 QETH_DBF_HEX(trace
, 3, addr
, sizeof(struct qeth_ipaddr
));
920 if (addr
->is_multicast
)
921 rc
= qeth_l3_send_setdelmc(card
, addr
, IPA_CMD_SETIPM
);
923 rc
= qeth_l3_send_setdelip(card
, addr
, IPA_CMD_SETIP
,
926 QETH_DBF_TEXT(trace
, 2, "failed");
927 } while ((--cnt
> 0) && rc
);
929 QETH_DBF_TEXT(trace
, 2, "FAILED");
930 qeth_l3_ipaddr_to_string(addr
->proto
, (u8
*)&addr
->u
, buf
);
931 PRINT_WARN("Could not register IP address %s (rc=0x%x/%d)\n",
937 static int qeth_l3_deregister_addr_entry(struct qeth_card
*card
,
938 struct qeth_ipaddr
*addr
)
942 if (addr
->proto
== QETH_PROT_IPV4
) {
943 QETH_DBF_TEXT(trace
, 2, "deladdr4");
944 QETH_DBF_HEX(trace
, 3, &addr
->u
.a4
.addr
, sizeof(int));
945 } else if (addr
->proto
== QETH_PROT_IPV6
) {
946 QETH_DBF_TEXT(trace
, 2, "deladdr6");
947 QETH_DBF_HEX(trace
, 3, &addr
->u
.a6
.addr
, 8);
948 QETH_DBF_HEX(trace
, 3, ((char *)&addr
->u
.a6
.addr
) + 8, 8);
950 QETH_DBF_TEXT(trace
, 2, "deladdr?");
951 QETH_DBF_HEX(trace
, 3, addr
, sizeof(struct qeth_ipaddr
));
953 if (addr
->is_multicast
)
954 rc
= qeth_l3_send_setdelmc(card
, addr
, IPA_CMD_DELIPM
);
956 rc
= qeth_l3_send_setdelip(card
, addr
, IPA_CMD_DELIP
,
959 QETH_DBF_TEXT(trace
, 2, "failed");
960 /* TODO: re-activate this warning as soon as we have a
962 qeth_ipaddr_to_string(addr->proto, (u8 *)&addr->u, buf);
963 PRINT_WARN("Could not deregister IP address %s (rc=%x)\n",
971 static inline u8
qeth_l3_get_qeth_hdr_flags4(int cast_type
)
973 if (cast_type
== RTN_MULTICAST
)
974 return QETH_CAST_MULTICAST
;
975 if (cast_type
== RTN_BROADCAST
)
976 return QETH_CAST_BROADCAST
;
977 return QETH_CAST_UNICAST
;
980 static inline u8
qeth_l3_get_qeth_hdr_flags6(int cast_type
)
982 u8 ct
= QETH_HDR_PASSTHRU
| QETH_HDR_IPV6
;
983 if (cast_type
== RTN_MULTICAST
)
984 return ct
| QETH_CAST_MULTICAST
;
985 if (cast_type
== RTN_ANYCAST
)
986 return ct
| QETH_CAST_ANYCAST
;
987 if (cast_type
== RTN_BROADCAST
)
988 return ct
| QETH_CAST_BROADCAST
;
989 return ct
| QETH_CAST_UNICAST
;
992 static int qeth_l3_send_setadp_mode(struct qeth_card
*card
, __u32 command
,
996 struct qeth_cmd_buffer
*iob
;
997 struct qeth_ipa_cmd
*cmd
;
999 QETH_DBF_TEXT(trace
, 4, "adpmode");
1001 iob
= qeth_get_adapter_cmd(card
, command
,
1002 sizeof(struct qeth_ipacmd_setadpparms
));
1003 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
1004 cmd
->data
.setadapterparms
.data
.mode
= mode
;
1005 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_default_setadapterparms_cb
,
1010 static int qeth_l3_setadapter_hstr(struct qeth_card
*card
)
1014 QETH_DBF_TEXT(trace
, 4, "adphstr");
1016 if (qeth_adp_supported(card
, IPA_SETADP_SET_BROADCAST_MODE
)) {
1017 rc
= qeth_l3_send_setadp_mode(card
,
1018 IPA_SETADP_SET_BROADCAST_MODE
,
1019 card
->options
.broadcast_mode
);
1021 PRINT_WARN("couldn't set broadcast mode on "
1023 CARD_BUS_ID(card
), rc
);
1024 rc
= qeth_l3_send_setadp_mode(card
,
1025 IPA_SETADP_ALTER_MAC_ADDRESS
,
1026 card
->options
.macaddr_mode
);
1028 PRINT_WARN("couldn't set macaddr mode on "
1029 "device %s: x%x\n", CARD_BUS_ID(card
), rc
);
1032 if (card
->options
.broadcast_mode
== QETH_TR_BROADCAST_LOCAL
)
1033 PRINT_WARN("set adapter parameters not available "
1034 "to set broadcast mode, using ALLRINGS "
1035 "on device %s:\n", CARD_BUS_ID(card
));
1036 if (card
->options
.macaddr_mode
== QETH_TR_MACADDR_CANONICAL
)
1037 PRINT_WARN("set adapter parameters not available "
1038 "to set macaddr mode, using NONCANONICAL "
1039 "on device %s:\n", CARD_BUS_ID(card
));
1043 static int qeth_l3_setadapter_parms(struct qeth_card
*card
)
1047 QETH_DBF_TEXT(setup
, 2, "setadprm");
1049 if (!qeth_is_supported(card
, IPA_SETADAPTERPARMS
)) {
1050 PRINT_WARN("set adapter parameters not supported "
1053 QETH_DBF_TEXT(setup
, 2, " notsupp");
1056 rc
= qeth_query_setadapterparms(card
);
1058 PRINT_WARN("couldn't set adapter parameters on device %s: "
1059 "x%x\n", CARD_BUS_ID(card
), rc
);
1062 if (qeth_adp_supported(card
, IPA_SETADP_ALTER_MAC_ADDRESS
)) {
1063 rc
= qeth_setadpparms_change_macaddr(card
);
1065 PRINT_WARN("couldn't get MAC address on "
1067 CARD_BUS_ID(card
), rc
);
1070 if ((card
->info
.link_type
== QETH_LINK_TYPE_HSTR
) ||
1071 (card
->info
.link_type
== QETH_LINK_TYPE_LANE_TR
))
1072 rc
= qeth_l3_setadapter_hstr(card
);
1077 static int qeth_l3_default_setassparms_cb(struct qeth_card
*card
,
1078 struct qeth_reply
*reply
, unsigned long data
)
1080 struct qeth_ipa_cmd
*cmd
;
1082 QETH_DBF_TEXT(trace
, 4, "defadpcb");
1084 cmd
= (struct qeth_ipa_cmd
*) data
;
1085 if (cmd
->hdr
.return_code
== 0) {
1086 cmd
->hdr
.return_code
= cmd
->data
.setassparms
.hdr
.return_code
;
1087 if (cmd
->hdr
.prot_version
== QETH_PROT_IPV4
)
1088 card
->options
.ipa4
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
1089 if (cmd
->hdr
.prot_version
== QETH_PROT_IPV6
)
1090 card
->options
.ipa6
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
1092 if (cmd
->data
.setassparms
.hdr
.assist_no
== IPA_INBOUND_CHECKSUM
&&
1093 cmd
->data
.setassparms
.hdr
.command_code
== IPA_CMD_ASS_START
) {
1094 card
->info
.csum_mask
= cmd
->data
.setassparms
.data
.flags_32bit
;
1095 QETH_DBF_TEXT_(trace
, 3, "csum:%d", card
->info
.csum_mask
);
1100 static struct qeth_cmd_buffer
*qeth_l3_get_setassparms_cmd(
1101 struct qeth_card
*card
, enum qeth_ipa_funcs ipa_func
, __u16 cmd_code
,
1102 __u16 len
, enum qeth_prot_versions prot
)
1104 struct qeth_cmd_buffer
*iob
;
1105 struct qeth_ipa_cmd
*cmd
;
1107 QETH_DBF_TEXT(trace
, 4, "getasscm");
1108 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_SETASSPARMS
, prot
);
1110 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
1111 cmd
->data
.setassparms
.hdr
.assist_no
= ipa_func
;
1112 cmd
->data
.setassparms
.hdr
.length
= 8 + len
;
1113 cmd
->data
.setassparms
.hdr
.command_code
= cmd_code
;
1114 cmd
->data
.setassparms
.hdr
.return_code
= 0;
1115 cmd
->data
.setassparms
.hdr
.seq_no
= 0;
1120 static int qeth_l3_send_setassparms(struct qeth_card
*card
,
1121 struct qeth_cmd_buffer
*iob
, __u16 len
, long data
,
1122 int (*reply_cb
)(struct qeth_card
*, struct qeth_reply
*,
1127 struct qeth_ipa_cmd
*cmd
;
1129 QETH_DBF_TEXT(trace
, 4, "sendassp");
1131 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
1132 if (len
<= sizeof(__u32
))
1133 cmd
->data
.setassparms
.data
.flags_32bit
= (__u32
) data
;
1134 else /* (len > sizeof(__u32)) */
1135 memcpy(&cmd
->data
.setassparms
.data
, (void *) data
, len
);
1137 rc
= qeth_send_ipa_cmd(card
, iob
, reply_cb
, reply_param
);
1141 #ifdef CONFIG_QETH_IPV6
1142 static int qeth_l3_send_simple_setassparms_ipv6(struct qeth_card
*card
,
1143 enum qeth_ipa_funcs ipa_func
, __u16 cmd_code
)
1146 struct qeth_cmd_buffer
*iob
;
1148 QETH_DBF_TEXT(trace
, 4, "simassp6");
1149 iob
= qeth_l3_get_setassparms_cmd(card
, ipa_func
, cmd_code
,
1151 rc
= qeth_l3_send_setassparms(card
, iob
, 0, 0,
1152 qeth_l3_default_setassparms_cb
, NULL
);
1157 static int qeth_l3_send_simple_setassparms(struct qeth_card
*card
,
1158 enum qeth_ipa_funcs ipa_func
, __u16 cmd_code
, long data
)
1162 struct qeth_cmd_buffer
*iob
;
1164 QETH_DBF_TEXT(trace
, 4, "simassp4");
1166 length
= sizeof(__u32
);
1167 iob
= qeth_l3_get_setassparms_cmd(card
, ipa_func
, cmd_code
,
1168 length
, QETH_PROT_IPV4
);
1169 rc
= qeth_l3_send_setassparms(card
, iob
, length
, data
,
1170 qeth_l3_default_setassparms_cb
, NULL
);
1174 static int qeth_l3_start_ipa_arp_processing(struct qeth_card
*card
)
1178 QETH_DBF_TEXT(trace
, 3, "ipaarp");
1180 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
1181 PRINT_WARN("ARP processing not supported "
1182 "on %s!\n", QETH_CARD_IFNAME(card
));
1185 rc
= qeth_l3_send_simple_setassparms(card
, IPA_ARP_PROCESSING
,
1186 IPA_CMD_ASS_START
, 0);
1188 PRINT_WARN("Could not start ARP processing "
1189 "assist on %s: 0x%x\n",
1190 QETH_CARD_IFNAME(card
), rc
);
1195 static int qeth_l3_start_ipa_ip_fragmentation(struct qeth_card
*card
)
1199 QETH_DBF_TEXT(trace
, 3, "ipaipfrg");
1201 if (!qeth_is_supported(card
, IPA_IP_FRAGMENTATION
)) {
1202 PRINT_INFO("Hardware IP fragmentation not supported on %s\n",
1203 QETH_CARD_IFNAME(card
));
1207 rc
= qeth_l3_send_simple_setassparms(card
, IPA_IP_FRAGMENTATION
,
1208 IPA_CMD_ASS_START
, 0);
1210 PRINT_WARN("Could not start Hardware IP fragmentation "
1211 "assist on %s: 0x%x\n",
1212 QETH_CARD_IFNAME(card
), rc
);
1214 PRINT_INFO("Hardware IP fragmentation enabled \n");
1218 static int qeth_l3_start_ipa_source_mac(struct qeth_card
*card
)
1222 QETH_DBF_TEXT(trace
, 3, "stsrcmac");
1224 if (!card
->options
.fake_ll
)
1227 if (!qeth_is_supported(card
, IPA_SOURCE_MAC
)) {
1228 PRINT_INFO("Inbound source address not "
1229 "supported on %s\n", QETH_CARD_IFNAME(card
));
1233 rc
= qeth_l3_send_simple_setassparms(card
, IPA_SOURCE_MAC
,
1234 IPA_CMD_ASS_START
, 0);
1236 PRINT_WARN("Could not start inbound source "
1237 "assist on %s: 0x%x\n",
1238 QETH_CARD_IFNAME(card
), rc
);
1242 static int qeth_l3_start_ipa_vlan(struct qeth_card
*card
)
1246 QETH_DBF_TEXT(trace
, 3, "strtvlan");
1248 if (!qeth_is_supported(card
, IPA_FULL_VLAN
)) {
1249 PRINT_WARN("VLAN not supported on %s\n",
1250 QETH_CARD_IFNAME(card
));
1254 rc
= qeth_l3_send_simple_setassparms(card
, IPA_VLAN_PRIO
,
1255 IPA_CMD_ASS_START
, 0);
1257 PRINT_WARN("Could not start vlan "
1258 "assist on %s: 0x%x\n",
1259 QETH_CARD_IFNAME(card
), rc
);
1261 PRINT_INFO("VLAN enabled \n");
1266 static int qeth_l3_start_ipa_multicast(struct qeth_card
*card
)
1270 QETH_DBF_TEXT(trace
, 3, "stmcast");
1272 if (!qeth_is_supported(card
, IPA_MULTICASTING
)) {
1273 PRINT_WARN("Multicast not supported on %s\n",
1274 QETH_CARD_IFNAME(card
));
1278 rc
= qeth_l3_send_simple_setassparms(card
, IPA_MULTICASTING
,
1279 IPA_CMD_ASS_START
, 0);
1281 PRINT_WARN("Could not start multicast "
1282 "assist on %s: rc=%i\n",
1283 QETH_CARD_IFNAME(card
), rc
);
1285 PRINT_INFO("Multicast enabled\n");
1286 card
->dev
->flags
|= IFF_MULTICAST
;
1291 static int qeth_l3_query_ipassists_cb(struct qeth_card
*card
,
1292 struct qeth_reply
*reply
, unsigned long data
)
1294 struct qeth_ipa_cmd
*cmd
;
1296 QETH_DBF_TEXT(setup
, 2, "qipasscb");
1298 cmd
= (struct qeth_ipa_cmd
*) data
;
1299 if (cmd
->hdr
.prot_version
== QETH_PROT_IPV4
) {
1300 card
->options
.ipa4
.supported_funcs
= cmd
->hdr
.ipa_supported
;
1301 card
->options
.ipa4
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
1303 card
->options
.ipa6
.supported_funcs
= cmd
->hdr
.ipa_supported
;
1304 card
->options
.ipa6
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
1306 QETH_DBF_TEXT(setup
, 2, "suppenbl");
1307 QETH_DBF_TEXT_(setup
, 2, "%x", cmd
->hdr
.ipa_supported
);
1308 QETH_DBF_TEXT_(setup
, 2, "%x", cmd
->hdr
.ipa_enabled
);
1312 static int qeth_l3_query_ipassists(struct qeth_card
*card
,
1313 enum qeth_prot_versions prot
)
1316 struct qeth_cmd_buffer
*iob
;
1318 QETH_DBF_TEXT_(setup
, 2, "qipassi%i", prot
);
1319 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_QIPASSIST
, prot
);
1320 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_l3_query_ipassists_cb
, NULL
);
1324 #ifdef CONFIG_QETH_IPV6
1325 static int qeth_l3_softsetup_ipv6(struct qeth_card
*card
)
1329 QETH_DBF_TEXT(trace
, 3, "softipv6");
1331 if (card
->info
.type
== QETH_CARD_TYPE_IQD
)
1334 rc
= qeth_l3_query_ipassists(card
, QETH_PROT_IPV6
);
1336 PRINT_ERR("IPv6 query ipassist failed on %s\n",
1337 QETH_CARD_IFNAME(card
));
1340 rc
= qeth_l3_send_simple_setassparms(card
, IPA_IPV6
,
1341 IPA_CMD_ASS_START
, 3);
1343 PRINT_WARN("IPv6 start assist (version 4) failed "
1345 QETH_CARD_IFNAME(card
), rc
);
1348 rc
= qeth_l3_send_simple_setassparms_ipv6(card
, IPA_IPV6
,
1351 PRINT_WARN("IPV6 start assist (version 6) failed "
1353 QETH_CARD_IFNAME(card
), rc
);
1356 rc
= qeth_l3_send_simple_setassparms_ipv6(card
, IPA_PASSTHRU
,
1359 PRINT_WARN("Could not enable passthrough "
1361 QETH_CARD_IFNAME(card
), rc
);
1365 PRINT_INFO("IPV6 enabled \n");
1370 static int qeth_l3_start_ipa_ipv6(struct qeth_card
*card
)
1374 QETH_DBF_TEXT(trace
, 3, "strtipv6");
1376 if (!qeth_is_supported(card
, IPA_IPV6
)) {
1377 PRINT_WARN("IPv6 not supported on %s\n",
1378 QETH_CARD_IFNAME(card
));
1381 #ifdef CONFIG_QETH_IPV6
1382 rc
= qeth_l3_softsetup_ipv6(card
);
1387 static int qeth_l3_start_ipa_broadcast(struct qeth_card
*card
)
1391 QETH_DBF_TEXT(trace
, 3, "stbrdcst");
1392 card
->info
.broadcast_capable
= 0;
1393 if (!qeth_is_supported(card
, IPA_FILTERING
)) {
1394 PRINT_WARN("Broadcast not supported on %s\n",
1395 QETH_CARD_IFNAME(card
));
1399 rc
= qeth_l3_send_simple_setassparms(card
, IPA_FILTERING
,
1400 IPA_CMD_ASS_START
, 0);
1402 PRINT_WARN("Could not enable broadcasting filtering "
1404 QETH_CARD_IFNAME(card
), rc
);
1408 rc
= qeth_l3_send_simple_setassparms(card
, IPA_FILTERING
,
1409 IPA_CMD_ASS_CONFIGURE
, 1);
1411 PRINT_WARN("Could not set up broadcast filtering on %s: 0x%x\n",
1412 QETH_CARD_IFNAME(card
), rc
);
1415 card
->info
.broadcast_capable
= QETH_BROADCAST_WITH_ECHO
;
1416 PRINT_INFO("Broadcast enabled \n");
1417 rc
= qeth_l3_send_simple_setassparms(card
, IPA_FILTERING
,
1418 IPA_CMD_ASS_ENABLE
, 1);
1420 PRINT_WARN("Could not set up broadcast echo filtering on "
1421 "%s: 0x%x\n", QETH_CARD_IFNAME(card
), rc
);
1424 card
->info
.broadcast_capable
= QETH_BROADCAST_WITHOUT_ECHO
;
1426 if (card
->info
.broadcast_capable
)
1427 card
->dev
->flags
|= IFF_BROADCAST
;
1429 card
->dev
->flags
&= ~IFF_BROADCAST
;
1433 static int qeth_l3_send_checksum_command(struct qeth_card
*card
)
1437 rc
= qeth_l3_send_simple_setassparms(card
, IPA_INBOUND_CHECKSUM
,
1438 IPA_CMD_ASS_START
, 0);
1440 PRINT_WARN("Starting Inbound HW Checksumming failed on %s: "
1441 "0x%x,\ncontinuing using Inbound SW Checksumming\n",
1442 QETH_CARD_IFNAME(card
), rc
);
1445 rc
= qeth_l3_send_simple_setassparms(card
, IPA_INBOUND_CHECKSUM
,
1447 card
->info
.csum_mask
);
1449 PRINT_WARN("Enabling Inbound HW Checksumming failed on %s: "
1450 "0x%x,\ncontinuing using Inbound SW Checksumming\n",
1451 QETH_CARD_IFNAME(card
), rc
);
1457 static int qeth_l3_start_ipa_checksum(struct qeth_card
*card
)
1461 QETH_DBF_TEXT(trace
, 3, "strtcsum");
1463 if (card
->options
.checksum_type
== NO_CHECKSUMMING
) {
1464 PRINT_WARN("Using no checksumming on %s.\n",
1465 QETH_CARD_IFNAME(card
));
1468 if (card
->options
.checksum_type
== SW_CHECKSUMMING
) {
1469 PRINT_WARN("Using SW checksumming on %s.\n",
1470 QETH_CARD_IFNAME(card
));
1473 if (!qeth_is_supported(card
, IPA_INBOUND_CHECKSUM
)) {
1474 PRINT_WARN("Inbound HW Checksumming not "
1475 "supported on %s,\ncontinuing "
1476 "using Inbound SW Checksumming\n",
1477 QETH_CARD_IFNAME(card
));
1478 card
->options
.checksum_type
= SW_CHECKSUMMING
;
1481 rc
= qeth_l3_send_checksum_command(card
);
1483 PRINT_INFO("HW Checksumming (inbound) enabled \n");
1488 static int qeth_l3_start_ipa_tso(struct qeth_card
*card
)
1492 QETH_DBF_TEXT(trace
, 3, "sttso");
1494 if (!qeth_is_supported(card
, IPA_OUTBOUND_TSO
)) {
1495 PRINT_WARN("Outbound TSO not supported on %s\n",
1496 QETH_CARD_IFNAME(card
));
1499 rc
= qeth_l3_send_simple_setassparms(card
, IPA_OUTBOUND_TSO
,
1500 IPA_CMD_ASS_START
, 0);
1502 PRINT_WARN("Could not start outbound TSO "
1503 "assist on %s: rc=%i\n",
1504 QETH_CARD_IFNAME(card
), rc
);
1506 PRINT_INFO("Outbound TSO enabled\n");
1508 if (rc
&& (card
->options
.large_send
== QETH_LARGE_SEND_TSO
)) {
1509 card
->options
.large_send
= QETH_LARGE_SEND_NO
;
1510 card
->dev
->features
&= ~(NETIF_F_TSO
| NETIF_F_SG
);
1515 static int qeth_l3_start_ipassists(struct qeth_card
*card
)
1517 QETH_DBF_TEXT(trace
, 3, "strtipas");
1518 qeth_l3_start_ipa_arp_processing(card
); /* go on*/
1519 qeth_l3_start_ipa_ip_fragmentation(card
); /* go on*/
1520 qeth_l3_start_ipa_source_mac(card
); /* go on*/
1521 qeth_l3_start_ipa_vlan(card
); /* go on*/
1522 qeth_l3_start_ipa_multicast(card
); /* go on*/
1523 qeth_l3_start_ipa_ipv6(card
); /* go on*/
1524 qeth_l3_start_ipa_broadcast(card
); /* go on*/
1525 qeth_l3_start_ipa_checksum(card
); /* go on*/
1526 qeth_l3_start_ipa_tso(card
); /* go on*/
1530 static int qeth_l3_put_unique_id(struct qeth_card
*card
)
1534 struct qeth_cmd_buffer
*iob
;
1535 struct qeth_ipa_cmd
*cmd
;
1537 QETH_DBF_TEXT(trace
, 2, "puniqeid");
1539 if ((card
->info
.unique_id
& UNIQUE_ID_NOT_BY_CARD
) ==
1540 UNIQUE_ID_NOT_BY_CARD
)
1542 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_DESTROY_ADDR
,
1544 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
1545 *((__u16
*) &cmd
->data
.create_destroy_addr
.unique_id
[6]) =
1546 card
->info
.unique_id
;
1547 memcpy(&cmd
->data
.create_destroy_addr
.unique_id
[0],
1548 card
->dev
->dev_addr
, OSA_ADDR_LEN
);
1549 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
1553 static int qeth_l3_iqd_read_initial_mac_cb(struct qeth_card
*card
,
1554 struct qeth_reply
*reply
, unsigned long data
)
1556 struct qeth_ipa_cmd
*cmd
;
1558 cmd
= (struct qeth_ipa_cmd
*) data
;
1559 if (cmd
->hdr
.return_code
== 0)
1560 memcpy(card
->dev
->dev_addr
,
1561 cmd
->data
.create_destroy_addr
.unique_id
, ETH_ALEN
);
1563 random_ether_addr(card
->dev
->dev_addr
);
1568 static int qeth_l3_iqd_read_initial_mac(struct qeth_card
*card
)
1571 struct qeth_cmd_buffer
*iob
;
1572 struct qeth_ipa_cmd
*cmd
;
1574 QETH_DBF_TEXT(setup
, 2, "hsrmac");
1576 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_CREATE_ADDR
,
1578 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
1579 *((__u16
*) &cmd
->data
.create_destroy_addr
.unique_id
[6]) =
1580 card
->info
.unique_id
;
1582 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_l3_iqd_read_initial_mac_cb
,
1587 static int qeth_l3_get_unique_id_cb(struct qeth_card
*card
,
1588 struct qeth_reply
*reply
, unsigned long data
)
1590 struct qeth_ipa_cmd
*cmd
;
1592 cmd
= (struct qeth_ipa_cmd
*) data
;
1593 if (cmd
->hdr
.return_code
== 0)
1594 card
->info
.unique_id
= *((__u16
*)
1595 &cmd
->data
.create_destroy_addr
.unique_id
[6]);
1597 card
->info
.unique_id
= UNIQUE_ID_IF_CREATE_ADDR_FAILED
|
1598 UNIQUE_ID_NOT_BY_CARD
;
1599 PRINT_WARN("couldn't get a unique id from the card on device "
1600 "%s (result=x%x), using default id. ipv6 "
1601 "autoconfig on other lpars may lead to duplicate "
1602 "ip addresses. please use manually "
1603 "configured ones.\n",
1604 CARD_BUS_ID(card
), cmd
->hdr
.return_code
);
1609 static int qeth_l3_get_unique_id(struct qeth_card
*card
)
1612 struct qeth_cmd_buffer
*iob
;
1613 struct qeth_ipa_cmd
*cmd
;
1615 QETH_DBF_TEXT(setup
, 2, "guniqeid");
1617 if (!qeth_is_supported(card
, IPA_IPV6
)) {
1618 card
->info
.unique_id
= UNIQUE_ID_IF_CREATE_ADDR_FAILED
|
1619 UNIQUE_ID_NOT_BY_CARD
;
1623 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_CREATE_ADDR
,
1625 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
1626 *((__u16
*) &cmd
->data
.create_destroy_addr
.unique_id
[6]) =
1627 card
->info
.unique_id
;
1629 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_l3_get_unique_id_cb
, NULL
);
1633 static void qeth_l3_get_mac_for_ipm(__u32 ipm
, char *mac
,
1634 struct net_device
*dev
)
1636 if (dev
->type
== ARPHRD_IEEE802_TR
)
1637 ip_tr_mc_map(ipm
, mac
);
1639 ip_eth_mc_map(ipm
, mac
);
1642 static void qeth_l3_add_mc(struct qeth_card
*card
, struct in_device
*in4_dev
)
1644 struct qeth_ipaddr
*ipm
;
1645 struct ip_mc_list
*im4
;
1646 char buf
[MAX_ADDR_LEN
];
1648 QETH_DBF_TEXT(trace
, 4, "addmc");
1649 for (im4
= in4_dev
->mc_list
; im4
; im4
= im4
->next
) {
1650 qeth_l3_get_mac_for_ipm(im4
->multiaddr
, buf
, in4_dev
->dev
);
1651 ipm
= qeth_l3_get_addr_buffer(QETH_PROT_IPV4
);
1654 ipm
->u
.a4
.addr
= im4
->multiaddr
;
1655 memcpy(ipm
->mac
, buf
, OSA_ADDR_LEN
);
1656 ipm
->is_multicast
= 1;
1657 if (!qeth_l3_add_ip(card
, ipm
))
1662 static void qeth_l3_add_vlan_mc(struct qeth_card
*card
)
1664 struct in_device
*in_dev
;
1665 struct vlan_group
*vg
;
1668 QETH_DBF_TEXT(trace
, 4, "addmcvl");
1669 if (!qeth_is_supported(card
, IPA_FULL_VLAN
) || (card
->vlangrp
== NULL
))
1673 for (i
= 0; i
< VLAN_GROUP_ARRAY_LEN
; i
++) {
1674 struct net_device
*netdev
= vlan_group_get_device(vg
, i
);
1675 if (netdev
== NULL
||
1676 !(netdev
->flags
& IFF_UP
))
1678 in_dev
= in_dev_get(netdev
);
1681 read_lock(&in_dev
->mc_list_lock
);
1682 qeth_l3_add_mc(card
, in_dev
);
1683 read_unlock(&in_dev
->mc_list_lock
);
1688 static void qeth_l3_add_multicast_ipv4(struct qeth_card
*card
)
1690 struct in_device
*in4_dev
;
1692 QETH_DBF_TEXT(trace
, 4, "chkmcv4");
1693 in4_dev
= in_dev_get(card
->dev
);
1694 if (in4_dev
== NULL
)
1696 read_lock(&in4_dev
->mc_list_lock
);
1697 qeth_l3_add_mc(card
, in4_dev
);
1698 qeth_l3_add_vlan_mc(card
);
1699 read_unlock(&in4_dev
->mc_list_lock
);
1700 in_dev_put(in4_dev
);
1703 #ifdef CONFIG_QETH_IPV6
1704 static void qeth_l3_add_mc6(struct qeth_card
*card
, struct inet6_dev
*in6_dev
)
1706 struct qeth_ipaddr
*ipm
;
1707 struct ifmcaddr6
*im6
;
1708 char buf
[MAX_ADDR_LEN
];
1710 QETH_DBF_TEXT(trace
, 4, "addmc6");
1711 for (im6
= in6_dev
->mc_list
; im6
!= NULL
; im6
= im6
->next
) {
1712 ndisc_mc_map(&im6
->mca_addr
, buf
, in6_dev
->dev
, 0);
1713 ipm
= qeth_l3_get_addr_buffer(QETH_PROT_IPV6
);
1716 ipm
->is_multicast
= 1;
1717 memcpy(ipm
->mac
, buf
, OSA_ADDR_LEN
);
1718 memcpy(&ipm
->u
.a6
.addr
, &im6
->mca_addr
.s6_addr
,
1719 sizeof(struct in6_addr
));
1720 if (!qeth_l3_add_ip(card
, ipm
))
1725 static void qeth_l3_add_vlan_mc6(struct qeth_card
*card
)
1727 struct inet6_dev
*in_dev
;
1728 struct vlan_group
*vg
;
1731 QETH_DBF_TEXT(trace
, 4, "admc6vl");
1732 if (!qeth_is_supported(card
, IPA_FULL_VLAN
) || (card
->vlangrp
== NULL
))
1736 for (i
= 0; i
< VLAN_GROUP_ARRAY_LEN
; i
++) {
1737 struct net_device
*netdev
= vlan_group_get_device(vg
, i
);
1738 if (netdev
== NULL
||
1739 !(netdev
->flags
& IFF_UP
))
1741 in_dev
= in6_dev_get(netdev
);
1744 read_lock_bh(&in_dev
->lock
);
1745 qeth_l3_add_mc6(card
, in_dev
);
1746 read_unlock_bh(&in_dev
->lock
);
1747 in6_dev_put(in_dev
);
1751 static void qeth_l3_add_multicast_ipv6(struct qeth_card
*card
)
1753 struct inet6_dev
*in6_dev
;
1755 QETH_DBF_TEXT(trace
, 4, "chkmcv6");
1756 if (!qeth_is_supported(card
, IPA_IPV6
))
1758 in6_dev
= in6_dev_get(card
->dev
);
1759 if (in6_dev
== NULL
)
1761 read_lock_bh(&in6_dev
->lock
);
1762 qeth_l3_add_mc6(card
, in6_dev
);
1763 qeth_l3_add_vlan_mc6(card
);
1764 read_unlock_bh(&in6_dev
->lock
);
1765 in6_dev_put(in6_dev
);
1767 #endif /* CONFIG_QETH_IPV6 */
1769 static void qeth_l3_free_vlan_addresses4(struct qeth_card
*card
,
1772 struct in_device
*in_dev
;
1773 struct in_ifaddr
*ifa
;
1774 struct qeth_ipaddr
*addr
;
1776 QETH_DBF_TEXT(trace
, 4, "frvaddr4");
1778 in_dev
= in_dev_get(vlan_group_get_device(card
->vlangrp
, vid
));
1781 for (ifa
= in_dev
->ifa_list
; ifa
; ifa
= ifa
->ifa_next
) {
1782 addr
= qeth_l3_get_addr_buffer(QETH_PROT_IPV4
);
1784 addr
->u
.a4
.addr
= ifa
->ifa_address
;
1785 addr
->u
.a4
.mask
= ifa
->ifa_mask
;
1786 addr
->type
= QETH_IP_TYPE_NORMAL
;
1787 if (!qeth_l3_delete_ip(card
, addr
))
1794 static void qeth_l3_free_vlan_addresses6(struct qeth_card
*card
,
1797 #ifdef CONFIG_QETH_IPV6
1798 struct inet6_dev
*in6_dev
;
1799 struct inet6_ifaddr
*ifa
;
1800 struct qeth_ipaddr
*addr
;
1802 QETH_DBF_TEXT(trace
, 4, "frvaddr6");
1804 in6_dev
= in6_dev_get(vlan_group_get_device(card
->vlangrp
, vid
));
1807 for (ifa
= in6_dev
->addr_list
; ifa
; ifa
= ifa
->lst_next
) {
1808 addr
= qeth_l3_get_addr_buffer(QETH_PROT_IPV6
);
1810 memcpy(&addr
->u
.a6
.addr
, &ifa
->addr
,
1811 sizeof(struct in6_addr
));
1812 addr
->u
.a6
.pfxlen
= ifa
->prefix_len
;
1813 addr
->type
= QETH_IP_TYPE_NORMAL
;
1814 if (!qeth_l3_delete_ip(card
, addr
))
1818 in6_dev_put(in6_dev
);
1819 #endif /* CONFIG_QETH_IPV6 */
1822 static void qeth_l3_free_vlan_addresses(struct qeth_card
*card
,
1827 qeth_l3_free_vlan_addresses4(card
, vid
);
1828 qeth_l3_free_vlan_addresses6(card
, vid
);
1831 static void qeth_l3_vlan_rx_register(struct net_device
*dev
,
1832 struct vlan_group
*grp
)
1834 struct qeth_card
*card
= netdev_priv(dev
);
1835 unsigned long flags
;
1837 QETH_DBF_TEXT(trace
, 4, "vlanreg");
1838 spin_lock_irqsave(&card
->vlanlock
, flags
);
1839 card
->vlangrp
= grp
;
1840 spin_unlock_irqrestore(&card
->vlanlock
, flags
);
1843 static void qeth_l3_vlan_rx_add_vid(struct net_device
*dev
, unsigned short vid
)
1845 struct net_device
*vlandev
;
1846 struct qeth_card
*card
= (struct qeth_card
*) dev
->priv
;
1847 struct in_device
*in_dev
;
1849 if (card
->info
.type
== QETH_CARD_TYPE_IQD
)
1852 vlandev
= vlan_group_get_device(card
->vlangrp
, vid
);
1853 vlandev
->neigh_setup
= qeth_l3_neigh_setup
;
1855 in_dev
= in_dev_get(vlandev
);
1856 #ifdef CONFIG_SYSCTL
1857 neigh_sysctl_unregister(in_dev
->arp_parms
);
1859 neigh_parms_release(&arp_tbl
, in_dev
->arp_parms
);
1861 in_dev
->arp_parms
= neigh_parms_alloc(vlandev
, &arp_tbl
);
1862 #ifdef CONFIG_SYSCTL
1863 neigh_sysctl_register(vlandev
, in_dev
->arp_parms
, NET_IPV4
,
1864 NET_IPV4_NEIGH
, "ipv4", NULL
, NULL
);
1870 static void qeth_l3_vlan_rx_kill_vid(struct net_device
*dev
, unsigned short vid
)
1872 struct qeth_card
*card
= netdev_priv(dev
);
1873 unsigned long flags
;
1875 QETH_DBF_TEXT_(trace
, 4, "kid:%d", vid
);
1876 spin_lock_irqsave(&card
->vlanlock
, flags
);
1877 /* unregister IP addresses of vlan device */
1878 qeth_l3_free_vlan_addresses(card
, vid
);
1879 vlan_group_set_device(card
->vlangrp
, vid
, NULL
);
1880 spin_unlock_irqrestore(&card
->vlanlock
, flags
);
1881 qeth_l3_set_multicast_list(card
->dev
);
1884 static inline __u16
qeth_l3_rebuild_skb(struct qeth_card
*card
,
1885 struct sk_buff
*skb
, struct qeth_hdr
*hdr
)
1887 unsigned short vlan_id
= 0;
1889 struct iphdr
*ip_hdr
;
1890 unsigned char tg_addr
[MAX_ADDR_LEN
];
1892 if (!(hdr
->hdr
.l3
.flags
& QETH_HDR_PASSTHRU
)) {
1893 prot
= htons((hdr
->hdr
.l3
.flags
& QETH_HDR_IPV6
)? ETH_P_IPV6
:
1895 switch (hdr
->hdr
.l3
.flags
& QETH_HDR_CAST_MASK
) {
1896 case QETH_CAST_MULTICAST
:
1898 #ifdef CONFIG_QETH_IPV6
1899 case __constant_htons(ETH_P_IPV6
):
1900 ndisc_mc_map((struct in6_addr
*)
1902 tg_addr
, card
->dev
, 0);
1905 case __constant_htons(ETH_P_IP
):
1906 ip_hdr
= (struct iphdr
*)skb
->data
;
1907 (card
->dev
->type
== ARPHRD_IEEE802_TR
) ?
1908 ip_tr_mc_map(ip_hdr
->daddr
, tg_addr
):
1909 ip_eth_mc_map(ip_hdr
->daddr
, tg_addr
);
1912 memcpy(tg_addr
, card
->dev
->broadcast
,
1913 card
->dev
->addr_len
);
1915 card
->stats
.multicast
++;
1916 skb
->pkt_type
= PACKET_MULTICAST
;
1918 case QETH_CAST_BROADCAST
:
1919 memcpy(tg_addr
, card
->dev
->broadcast
,
1920 card
->dev
->addr_len
);
1921 card
->stats
.multicast
++;
1922 skb
->pkt_type
= PACKET_BROADCAST
;
1924 case QETH_CAST_UNICAST
:
1925 case QETH_CAST_ANYCAST
:
1926 case QETH_CAST_NOCAST
:
1928 skb
->pkt_type
= PACKET_HOST
;
1929 memcpy(tg_addr
, card
->dev
->dev_addr
,
1930 card
->dev
->addr_len
);
1932 card
->dev
->header_ops
->create(skb
, card
->dev
, prot
, tg_addr
,
1933 "FAKELL", card
->dev
->addr_len
);
1937 if (card
->dev
->type
== ARPHRD_IEEE802_TR
)
1938 skb
->protocol
= tr_type_trans(skb
, card
->dev
);
1941 skb
->protocol
= eth_type_trans(skb
, card
->dev
);
1943 if (hdr
->hdr
.l3
.ext_flags
&
1944 (QETH_HDR_EXT_VLAN_FRAME
| QETH_HDR_EXT_INCLUDE_VLAN_TAG
)) {
1945 vlan_id
= (hdr
->hdr
.l3
.ext_flags
& QETH_HDR_EXT_VLAN_FRAME
)?
1946 hdr
->hdr
.l3
.vlan_id
: *((u16
*)&hdr
->hdr
.l3
.dest_addr
[12]);
1949 skb
->ip_summed
= card
->options
.checksum_type
;
1950 if (card
->options
.checksum_type
== HW_CHECKSUMMING
) {
1951 if ((hdr
->hdr
.l3
.ext_flags
&
1952 (QETH_HDR_EXT_CSUM_HDR_REQ
|
1953 QETH_HDR_EXT_CSUM_TRANSP_REQ
)) ==
1954 (QETH_HDR_EXT_CSUM_HDR_REQ
|
1955 QETH_HDR_EXT_CSUM_TRANSP_REQ
))
1956 skb
->ip_summed
= CHECKSUM_UNNECESSARY
;
1958 skb
->ip_summed
= SW_CHECKSUMMING
;
1964 static void qeth_l3_process_inbound_buffer(struct qeth_card
*card
,
1965 struct qeth_qdio_buffer
*buf
, int index
)
1967 struct qdio_buffer_element
*element
;
1968 struct sk_buff
*skb
;
1969 struct qeth_hdr
*hdr
;
1974 /* get first element of current buffer */
1975 element
= (struct qdio_buffer_element
*)&buf
->buffer
->element
[0];
1977 if (card
->options
.performance_stats
)
1978 card
->perf_stats
.bufs_rec
++;
1979 while ((skb
= qeth_core_get_next_skb(card
, buf
->buffer
, &element
,
1981 skb
->dev
= card
->dev
;
1982 /* is device UP ? */
1983 if (!(card
->dev
->flags
& IFF_UP
)) {
1984 dev_kfree_skb_any(skb
);
1988 switch (hdr
->hdr
.l3
.id
) {
1989 case QETH_HEADER_TYPE_LAYER3
:
1990 vlan_tag
= qeth_l3_rebuild_skb(card
, skb
, hdr
);
1994 vlan_hwaccel_rx(skb
, card
->vlangrp
,
1997 dev_kfree_skb_any(skb
);
2004 dev_kfree_skb_any(skb
);
2005 QETH_DBF_TEXT(trace
, 3, "inbunkno");
2006 QETH_DBF_HEX(control
, 3, hdr
, QETH_DBF_CONTROL_LEN
);
2010 card
->dev
->last_rx
= jiffies
;
2011 card
->stats
.rx_packets
++;
2012 card
->stats
.rx_bytes
+= len
;
2016 static int qeth_l3_verify_vlan_dev(struct net_device
*dev
,
2017 struct qeth_card
*card
)
2020 struct vlan_group
*vg
;
2027 for (i
= 0; i
< VLAN_GROUP_ARRAY_LEN
; i
++) {
2028 if (vlan_group_get_device(vg
, i
) == dev
) {
2029 rc
= QETH_VLAN_CARD
;
2034 if (rc
&& !(netdev_priv(vlan_dev_info(dev
)->real_dev
) == (void *)card
))
2040 static int qeth_l3_verify_dev(struct net_device
*dev
)
2042 struct qeth_card
*card
;
2043 unsigned long flags
;
2046 read_lock_irqsave(&qeth_core_card_list
.rwlock
, flags
);
2047 list_for_each_entry(card
, &qeth_core_card_list
.list
, list
) {
2048 if (card
->dev
== dev
) {
2049 rc
= QETH_REAL_CARD
;
2052 rc
= qeth_l3_verify_vlan_dev(dev
, card
);
2056 read_unlock_irqrestore(&qeth_core_card_list
.rwlock
, flags
);
2061 static struct qeth_card
*qeth_l3_get_card_from_dev(struct net_device
*dev
)
2063 struct qeth_card
*card
= NULL
;
2066 rc
= qeth_l3_verify_dev(dev
);
2067 if (rc
== QETH_REAL_CARD
)
2068 card
= netdev_priv(dev
);
2069 else if (rc
== QETH_VLAN_CARD
)
2070 card
= netdev_priv(vlan_dev_info(dev
)->real_dev
);
2071 if (card
->options
.layer2
)
2073 QETH_DBF_TEXT_(trace
, 4, "%d", rc
);
2077 static int qeth_l3_stop_card(struct qeth_card
*card
, int recovery_mode
)
2081 QETH_DBF_TEXT(setup
, 2, "stopcard");
2082 QETH_DBF_HEX(setup
, 2, &card
, sizeof(void *));
2084 qeth_set_allowed_threads(card
, 0, 1);
2085 if (qeth_wait_for_threads(card
, ~QETH_RECOVER_THREAD
))
2086 return -ERESTARTSYS
;
2087 if (card
->read
.state
== CH_STATE_UP
&&
2088 card
->write
.state
== CH_STATE_UP
&&
2089 (card
->state
== CARD_STATE_UP
)) {
2091 qeth_l3_stop(card
->dev
);
2092 if (!card
->use_hard_stop
) {
2093 rc
= qeth_send_stoplan(card
);
2095 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
2097 card
->state
= CARD_STATE_SOFTSETUP
;
2099 if (card
->state
== CARD_STATE_SOFTSETUP
) {
2100 qeth_l3_clear_ip_list(card
, !card
->use_hard_stop
, 1);
2101 qeth_clear_ipacmd_list(card
);
2102 card
->state
= CARD_STATE_HARDSETUP
;
2104 if (card
->state
== CARD_STATE_HARDSETUP
) {
2105 if (!card
->use_hard_stop
&&
2106 (card
->info
.type
!= QETH_CARD_TYPE_IQD
)) {
2107 rc
= qeth_l3_put_unique_id(card
);
2109 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
2111 qeth_qdio_clear_card(card
, 0);
2112 qeth_clear_qdio_buffers(card
);
2113 qeth_clear_working_pool_list(card
);
2114 card
->state
= CARD_STATE_DOWN
;
2116 if (card
->state
== CARD_STATE_DOWN
) {
2117 qeth_clear_cmd_buffers(&card
->read
);
2118 qeth_clear_cmd_buffers(&card
->write
);
2120 card
->use_hard_stop
= 0;
2124 static void qeth_l3_set_multicast_list(struct net_device
*dev
)
2126 struct qeth_card
*card
= netdev_priv(dev
);
2128 QETH_DBF_TEXT(trace
, 3, "setmulti");
2129 qeth_l3_delete_mc_addresses(card
);
2130 qeth_l3_add_multicast_ipv4(card
);
2131 #ifdef CONFIG_QETH_IPV6
2132 qeth_l3_add_multicast_ipv6(card
);
2134 qeth_l3_set_ip_addr_list(card
);
2135 if (!qeth_adp_supported(card
, IPA_SETADP_SET_PROMISC_MODE
))
2137 qeth_setadp_promisc_mode(card
);
2140 static const char *qeth_l3_arp_get_error_cause(int *rc
)
2143 case QETH_IPA_ARP_RC_FAILED
:
2145 return "operation failed";
2146 case QETH_IPA_ARP_RC_NOTSUPP
:
2148 return "operation not supported";
2149 case QETH_IPA_ARP_RC_OUT_OF_RANGE
:
2151 return "argument out of range";
2152 case QETH_IPA_ARP_RC_Q_NOTSUPP
:
2154 return "query operation not supported";
2155 case QETH_IPA_ARP_RC_Q_NO_DATA
:
2157 return "no query data available";
2159 return "unknown error";
2163 static int qeth_l3_arp_set_no_entries(struct qeth_card
*card
, int no_entries
)
2168 QETH_DBF_TEXT(trace
, 3, "arpstnoe");
2171 * currently GuestLAN only supports the ARP assist function
2172 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_SET_NO_ENTRIES;
2173 * thus we say EOPNOTSUPP for this ARP function
2175 if (card
->info
.guestlan
)
2177 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
2178 PRINT_WARN("ARP processing not supported "
2179 "on %s!\n", QETH_CARD_IFNAME(card
));
2182 rc
= qeth_l3_send_simple_setassparms(card
, IPA_ARP_PROCESSING
,
2183 IPA_CMD_ASS_ARP_SET_NO_ENTRIES
,
2187 PRINT_WARN("Could not set number of ARP entries on %s: "
2188 "%s (0x%x/%d)\n", QETH_CARD_IFNAME(card
),
2189 qeth_l3_arp_get_error_cause(&rc
), tmp
, tmp
);
2194 static void qeth_l3_copy_arp_entries_stripped(struct qeth_arp_query_info
*qinfo
,
2195 struct qeth_arp_query_data
*qdata
, int entry_size
,
2202 entry_ptr
= (char *)&qdata
->data
;
2203 uentry_ptr
= (char *)(qinfo
->udata
+ qinfo
->udata_offset
);
2204 for (i
= 0; i
< qdata
->no_entries
; ++i
) {
2205 /* strip off 32 bytes "media specific information" */
2206 memcpy(uentry_ptr
, (entry_ptr
+ 32), entry_size
- 32);
2207 entry_ptr
+= entry_size
;
2208 uentry_ptr
+= uentry_size
;
2212 static int qeth_l3_arp_query_cb(struct qeth_card
*card
,
2213 struct qeth_reply
*reply
, unsigned long data
)
2215 struct qeth_ipa_cmd
*cmd
;
2216 struct qeth_arp_query_data
*qdata
;
2217 struct qeth_arp_query_info
*qinfo
;
2222 QETH_DBF_TEXT(trace
, 4, "arpquecb");
2224 qinfo
= (struct qeth_arp_query_info
*) reply
->param
;
2225 cmd
= (struct qeth_ipa_cmd
*) data
;
2226 if (cmd
->hdr
.return_code
) {
2227 QETH_DBF_TEXT_(trace
, 4, "qaer1%i", cmd
->hdr
.return_code
);
2230 if (cmd
->data
.setassparms
.hdr
.return_code
) {
2231 cmd
->hdr
.return_code
= cmd
->data
.setassparms
.hdr
.return_code
;
2232 QETH_DBF_TEXT_(trace
, 4, "qaer2%i", cmd
->hdr
.return_code
);
2235 qdata
= &cmd
->data
.setassparms
.data
.query_arp
;
2236 switch (qdata
->reply_bits
) {
2238 uentry_size
= entry_size
= sizeof(struct qeth_arp_qi_entry5
);
2239 if (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
)
2240 uentry_size
= sizeof(struct qeth_arp_qi_entry5_short
);
2243 /* fall through to default */
2245 /* tr is the same as eth -> entry7 */
2246 uentry_size
= entry_size
= sizeof(struct qeth_arp_qi_entry7
);
2247 if (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
)
2248 uentry_size
= sizeof(struct qeth_arp_qi_entry7_short
);
2251 /* check if there is enough room in userspace */
2252 if ((qinfo
->udata_len
- qinfo
->udata_offset
) <
2253 qdata
->no_entries
* uentry_size
){
2254 QETH_DBF_TEXT_(trace
, 4, "qaer3%i", -ENOMEM
);
2255 cmd
->hdr
.return_code
= -ENOMEM
;
2256 PRINT_WARN("query ARP user space buffer is too small for "
2257 "the returned number of ARP entries. "
2258 "Aborting query!\n");
2261 QETH_DBF_TEXT_(trace
, 4, "anore%i",
2262 cmd
->data
.setassparms
.hdr
.number_of_replies
);
2263 QETH_DBF_TEXT_(trace
, 4, "aseqn%i", cmd
->data
.setassparms
.hdr
.seq_no
);
2264 QETH_DBF_TEXT_(trace
, 4, "anoen%i", qdata
->no_entries
);
2266 if (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
) {
2267 /* strip off "media specific information" */
2268 qeth_l3_copy_arp_entries_stripped(qinfo
, qdata
, entry_size
,
2271 /*copy entries to user buffer*/
2272 memcpy(qinfo
->udata
+ qinfo
->udata_offset
,
2273 (char *)&qdata
->data
, qdata
->no_entries
*uentry_size
);
2275 qinfo
->no_entries
+= qdata
->no_entries
;
2276 qinfo
->udata_offset
+= (qdata
->no_entries
*uentry_size
);
2277 /* check if all replies received ... */
2278 if (cmd
->data
.setassparms
.hdr
.seq_no
<
2279 cmd
->data
.setassparms
.hdr
.number_of_replies
)
2281 memcpy(qinfo
->udata
, &qinfo
->no_entries
, 4);
2282 /* keep STRIP_ENTRIES flag so the user program can distinguish
2283 * stripped entries from normal ones */
2284 if (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
)
2285 qdata
->reply_bits
|= QETH_QARP_STRIP_ENTRIES
;
2286 memcpy(qinfo
->udata
+ QETH_QARP_MASK_OFFSET
, &qdata
->reply_bits
, 2);
2290 memcpy(qinfo
->udata
, &i
, 4);
2294 static int qeth_l3_send_ipa_arp_cmd(struct qeth_card
*card
,
2295 struct qeth_cmd_buffer
*iob
, int len
,
2296 int (*reply_cb
)(struct qeth_card
*, struct qeth_reply
*,
2300 QETH_DBF_TEXT(trace
, 4, "sendarp");
2302 memcpy(iob
->data
, IPA_PDU_HEADER
, IPA_PDU_HEADER_SIZE
);
2303 memcpy(QETH_IPA_CMD_DEST_ADDR(iob
->data
),
2304 &card
->token
.ulp_connection_r
, QETH_MPC_TOKEN_LENGTH
);
2305 return qeth_send_control_data(card
, IPA_PDU_HEADER_SIZE
+ len
, iob
,
2306 reply_cb
, reply_param
);
2309 static int qeth_l3_arp_query(struct qeth_card
*card
, char __user
*udata
)
2311 struct qeth_cmd_buffer
*iob
;
2312 struct qeth_arp_query_info qinfo
= {0, };
2316 QETH_DBF_TEXT(trace
, 3, "arpquery");
2318 if (!qeth_is_supported(card
,/*IPA_QUERY_ARP_ADDR_INFO*/
2319 IPA_ARP_PROCESSING
)) {
2320 PRINT_WARN("ARP processing not supported "
2321 "on %s!\n", QETH_CARD_IFNAME(card
));
2324 /* get size of userspace buffer and mask_bits -> 6 bytes */
2325 if (copy_from_user(&qinfo
, udata
, 6))
2327 qinfo
.udata
= kzalloc(qinfo
.udata_len
, GFP_KERNEL
);
2330 qinfo
.udata_offset
= QETH_QARP_ENTRIES_OFFSET
;
2331 iob
= qeth_l3_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
2332 IPA_CMD_ASS_ARP_QUERY_INFO
,
2333 sizeof(int), QETH_PROT_IPV4
);
2335 rc
= qeth_l3_send_ipa_arp_cmd(card
, iob
,
2336 QETH_SETASS_BASE_LEN
+QETH_ARP_CMD_LEN
,
2337 qeth_l3_arp_query_cb
, (void *)&qinfo
);
2340 PRINT_WARN("Error while querying ARP cache on %s: %s "
2341 "(0x%x/%d)\n", QETH_CARD_IFNAME(card
),
2342 qeth_l3_arp_get_error_cause(&rc
), tmp
, tmp
);
2343 if (copy_to_user(udata
, qinfo
.udata
, 4))
2346 if (copy_to_user(udata
, qinfo
.udata
, qinfo
.udata_len
))
2353 static int qeth_l3_arp_add_entry(struct qeth_card
*card
,
2354 struct qeth_arp_cache_entry
*entry
)
2356 struct qeth_cmd_buffer
*iob
;
2361 QETH_DBF_TEXT(trace
, 3, "arpadent");
2364 * currently GuestLAN only supports the ARP assist function
2365 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_ADD_ENTRY;
2366 * thus we say EOPNOTSUPP for this ARP function
2368 if (card
->info
.guestlan
)
2370 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
2371 PRINT_WARN("ARP processing not supported "
2372 "on %s!\n", QETH_CARD_IFNAME(card
));
2376 iob
= qeth_l3_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
2377 IPA_CMD_ASS_ARP_ADD_ENTRY
,
2378 sizeof(struct qeth_arp_cache_entry
),
2380 rc
= qeth_l3_send_setassparms(card
, iob
,
2381 sizeof(struct qeth_arp_cache_entry
),
2382 (unsigned long) entry
,
2383 qeth_l3_default_setassparms_cb
, NULL
);
2386 qeth_l3_ipaddr4_to_string((u8
*)entry
->ipaddr
, buf
);
2387 PRINT_WARN("Could not add ARP entry for address %s on %s: "
2389 buf
, QETH_CARD_IFNAME(card
),
2390 qeth_l3_arp_get_error_cause(&rc
), tmp
, tmp
);
2395 static int qeth_l3_arp_remove_entry(struct qeth_card
*card
,
2396 struct qeth_arp_cache_entry
*entry
)
2398 struct qeth_cmd_buffer
*iob
;
2399 char buf
[16] = {0, };
2403 QETH_DBF_TEXT(trace
, 3, "arprment");
2406 * currently GuestLAN only supports the ARP assist function
2407 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_REMOVE_ENTRY;
2408 * thus we say EOPNOTSUPP for this ARP function
2410 if (card
->info
.guestlan
)
2412 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
2413 PRINT_WARN("ARP processing not supported "
2414 "on %s!\n", QETH_CARD_IFNAME(card
));
2417 memcpy(buf
, entry
, 12);
2418 iob
= qeth_l3_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
2419 IPA_CMD_ASS_ARP_REMOVE_ENTRY
,
2422 rc
= qeth_l3_send_setassparms(card
, iob
,
2423 12, (unsigned long)buf
,
2424 qeth_l3_default_setassparms_cb
, NULL
);
2428 qeth_l3_ipaddr4_to_string((u8
*)entry
->ipaddr
, buf
);
2429 PRINT_WARN("Could not delete ARP entry for address %s on %s: "
2431 buf
, QETH_CARD_IFNAME(card
),
2432 qeth_l3_arp_get_error_cause(&rc
), tmp
, tmp
);
2437 static int qeth_l3_arp_flush_cache(struct qeth_card
*card
)
2442 QETH_DBF_TEXT(trace
, 3, "arpflush");
2445 * currently GuestLAN only supports the ARP assist function
2446 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_FLUSH_CACHE;
2447 * thus we say EOPNOTSUPP for this ARP function
2449 if (card
->info
.guestlan
|| (card
->info
.type
== QETH_CARD_TYPE_IQD
))
2451 if (!qeth_is_supported(card
, IPA_ARP_PROCESSING
)) {
2452 PRINT_WARN("ARP processing not supported "
2453 "on %s!\n", QETH_CARD_IFNAME(card
));
2456 rc
= qeth_l3_send_simple_setassparms(card
, IPA_ARP_PROCESSING
,
2457 IPA_CMD_ASS_ARP_FLUSH_CACHE
, 0);
2460 PRINT_WARN("Could not flush ARP cache on %s: %s (0x%x/%d)\n",
2461 QETH_CARD_IFNAME(card
),
2462 qeth_l3_arp_get_error_cause(&rc
), tmp
, tmp
);
2467 static int qeth_l3_do_ioctl(struct net_device
*dev
, struct ifreq
*rq
, int cmd
)
2469 struct qeth_card
*card
= netdev_priv(dev
);
2470 struct qeth_arp_cache_entry arp_entry
;
2471 struct mii_ioctl_data
*mii_data
;
2477 if ((card
->state
!= CARD_STATE_UP
) &&
2478 (card
->state
!= CARD_STATE_SOFTSETUP
))
2482 case SIOC_QETH_ARP_SET_NO_ENTRIES
:
2483 if (!capable(CAP_NET_ADMIN
)) {
2487 rc
= qeth_l3_arp_set_no_entries(card
, rq
->ifr_ifru
.ifru_ivalue
);
2489 case SIOC_QETH_ARP_QUERY_INFO
:
2490 if (!capable(CAP_NET_ADMIN
)) {
2494 rc
= qeth_l3_arp_query(card
, rq
->ifr_ifru
.ifru_data
);
2496 case SIOC_QETH_ARP_ADD_ENTRY
:
2497 if (!capable(CAP_NET_ADMIN
)) {
2501 if (copy_from_user(&arp_entry
, rq
->ifr_ifru
.ifru_data
,
2502 sizeof(struct qeth_arp_cache_entry
)))
2505 rc
= qeth_l3_arp_add_entry(card
, &arp_entry
);
2507 case SIOC_QETH_ARP_REMOVE_ENTRY
:
2508 if (!capable(CAP_NET_ADMIN
)) {
2512 if (copy_from_user(&arp_entry
, rq
->ifr_ifru
.ifru_data
,
2513 sizeof(struct qeth_arp_cache_entry
)))
2516 rc
= qeth_l3_arp_remove_entry(card
, &arp_entry
);
2518 case SIOC_QETH_ARP_FLUSH_CACHE
:
2519 if (!capable(CAP_NET_ADMIN
)) {
2523 rc
= qeth_l3_arp_flush_cache(card
);
2525 case SIOC_QETH_ADP_SET_SNMP_CONTROL
:
2526 rc
= qeth_snmp_command(card
, rq
->ifr_ifru
.ifru_data
);
2528 case SIOC_QETH_GET_CARD_TYPE
:
2529 if ((card
->info
.type
== QETH_CARD_TYPE_OSAE
) &&
2530 !card
->info
.guestlan
)
2535 mii_data
= if_mii(rq
);
2536 mii_data
->phy_id
= 0;
2539 mii_data
= if_mii(rq
);
2540 if (mii_data
->phy_id
!= 0)
2543 mii_data
->val_out
= qeth_mdio_read(dev
,
2551 QETH_DBF_TEXT_(trace
, 2, "ioce%d", rc
);
2555 static void qeth_l3_fill_header(struct qeth_card
*card
, struct qeth_hdr
*hdr
,
2556 struct sk_buff
*skb
, int ipv
, int cast_type
)
2558 QETH_DBF_TEXT(trace
, 6, "fillhdr");
2560 memset(hdr
, 0, sizeof(struct qeth_hdr
));
2561 hdr
->hdr
.l3
.id
= QETH_HEADER_TYPE_LAYER3
;
2562 hdr
->hdr
.l3
.ext_flags
= 0;
2565 * before we're going to overwrite this location with next hop ip.
2566 * v6 uses passthrough, v4 sets the tag in the QDIO header.
2568 if (card
->vlangrp
&& vlan_tx_tag_present(skb
)) {
2569 hdr
->hdr
.l3
.ext_flags
= (ipv
== 4) ?
2570 QETH_HDR_EXT_VLAN_FRAME
:
2571 QETH_HDR_EXT_INCLUDE_VLAN_TAG
;
2572 hdr
->hdr
.l3
.vlan_id
= vlan_tx_tag_get(skb
);
2575 hdr
->hdr
.l3
.length
= skb
->len
- sizeof(struct qeth_hdr
);
2578 hdr
->hdr
.l3
.flags
= qeth_l3_get_qeth_hdr_flags4(cast_type
);
2579 memset(hdr
->hdr
.l3
.dest_addr
, 0, 12);
2580 if ((skb
->dst
) && (skb
->dst
->neighbour
)) {
2581 *((u32
*) (&hdr
->hdr
.l3
.dest_addr
[12])) =
2582 *((u32
*) skb
->dst
->neighbour
->primary_key
);
2584 /* fill in destination address used in ip header */
2585 *((u32
*) (&hdr
->hdr
.l3
.dest_addr
[12])) =
2588 } else if (ipv
== 6) {
2590 hdr
->hdr
.l3
.flags
= qeth_l3_get_qeth_hdr_flags6(cast_type
);
2591 if (card
->info
.type
== QETH_CARD_TYPE_IQD
)
2592 hdr
->hdr
.l3
.flags
&= ~QETH_HDR_PASSTHRU
;
2593 if ((skb
->dst
) && (skb
->dst
->neighbour
)) {
2594 memcpy(hdr
->hdr
.l3
.dest_addr
,
2595 skb
->dst
->neighbour
->primary_key
, 16);
2597 /* fill in destination address used in ip header */
2598 memcpy(hdr
->hdr
.l3
.dest_addr
,
2599 &ipv6_hdr(skb
)->daddr
, 16);
2603 if ((skb
->dev
->type
== ARPHRD_IEEE802_TR
) &&
2604 !memcmp(skb
->data
+ sizeof(struct qeth_hdr
) +
2605 sizeof(__u16
), skb
->dev
->broadcast
, 6)) {
2606 hdr
->hdr
.l3
.flags
= QETH_CAST_BROADCAST
|
2608 } else if (!memcmp(skb
->data
+ sizeof(struct qeth_hdr
),
2609 skb
->dev
->broadcast
, 6)) {
2611 hdr
->hdr
.l3
.flags
= QETH_CAST_BROADCAST
|
2614 hdr
->hdr
.l3
.flags
= (cast_type
== RTN_MULTICAST
) ?
2615 QETH_CAST_MULTICAST
| QETH_HDR_PASSTHRU
:
2616 QETH_CAST_UNICAST
| QETH_HDR_PASSTHRU
;
2621 static int qeth_l3_hard_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
2625 struct qeth_hdr
*hdr
= NULL
;
2626 int elements_needed
= 0;
2627 struct qeth_card
*card
= netdev_priv(dev
);
2628 struct sk_buff
*new_skb
= NULL
;
2629 int ipv
= qeth_get_ip_version(skb
);
2630 int cast_type
= qeth_get_cast_type(card
, skb
);
2631 struct qeth_qdio_out_q
*queue
= card
->qdio
.out_qs
2632 [qeth_get_priority_queue(card
, skb
, ipv
, cast_type
)];
2633 int tx_bytes
= skb
->len
;
2634 enum qeth_large_send_types large_send
= QETH_LARGE_SEND_NO
;
2635 struct qeth_eddp_context
*ctx
= NULL
;
2637 QETH_DBF_TEXT(trace
, 6, "l3xmit");
2639 if ((card
->info
.type
== QETH_CARD_TYPE_IQD
) &&
2640 (skb
->protocol
!= htons(ETH_P_IPV6
)) &&
2641 (skb
->protocol
!= htons(ETH_P_IP
)))
2644 if ((card
->state
!= CARD_STATE_UP
) || !card
->lan_online
) {
2645 card
->stats
.tx_carrier_errors
++;
2649 if ((cast_type
== RTN_BROADCAST
) &&
2650 (card
->info
.broadcast_capable
== 0))
2653 if (card
->options
.performance_stats
) {
2654 card
->perf_stats
.outbound_cnt
++;
2655 card
->perf_stats
.outbound_start_time
= qeth_get_micros();
2658 /* create a clone with writeable headroom */
2659 new_skb
= skb_realloc_headroom(skb
, sizeof(struct qeth_hdr_tso
) +
2664 if (card
->info
.type
== QETH_CARD_TYPE_IQD
) {
2665 skb_pull(new_skb
, ETH_HLEN
);
2667 if (new_skb
->protocol
== htons(ETH_P_IP
)) {
2668 if (card
->dev
->type
== ARPHRD_IEEE802_TR
)
2669 skb_pull(new_skb
, TR_HLEN
);
2671 skb_pull(new_skb
, ETH_HLEN
);
2674 if (new_skb
->protocol
== ETH_P_IPV6
&& card
->vlangrp
&&
2675 vlan_tx_tag_present(new_skb
)) {
2676 skb_push(new_skb
, VLAN_HLEN
);
2677 skb_copy_to_linear_data(new_skb
, new_skb
->data
+ 4, 4);
2678 skb_copy_to_linear_data_offset(new_skb
, 4,
2679 new_skb
->data
+ 8, 4);
2680 skb_copy_to_linear_data_offset(new_skb
, 8,
2681 new_skb
->data
+ 12, 4);
2682 tag
= (u16
*)(new_skb
->data
+ 12);
2683 *tag
= __constant_htons(ETH_P_8021Q
);
2684 *(tag
+ 1) = htons(vlan_tx_tag_get(new_skb
));
2685 VLAN_TX_SKB_CB(new_skb
)->magic
= 0;
2689 netif_stop_queue(dev
);
2691 if (skb_is_gso(new_skb
))
2692 large_send
= card
->options
.large_send
;
2694 /* fix hardware limitation: as long as we do not have sbal
2695 * chaining we can not send long frag lists so we temporary
2698 if ((large_send
== QETH_LARGE_SEND_TSO
) &&
2699 ((skb_shinfo(new_skb
)->nr_frags
+ 2) > 16))
2700 large_send
= QETH_LARGE_SEND_EDDP
;
2702 if ((large_send
== QETH_LARGE_SEND_TSO
) &&
2703 (cast_type
== RTN_UNSPEC
)) {
2704 hdr
= (struct qeth_hdr
*)skb_push(new_skb
,
2705 sizeof(struct qeth_hdr_tso
));
2706 memset(hdr
, 0, sizeof(struct qeth_hdr_tso
));
2707 qeth_l3_fill_header(card
, hdr
, new_skb
, ipv
, cast_type
);
2708 qeth_tso_fill_header(card
, hdr
, new_skb
);
2711 hdr
= (struct qeth_hdr
*)skb_push(new_skb
,
2712 sizeof(struct qeth_hdr
));
2713 qeth_l3_fill_header(card
, hdr
, new_skb
, ipv
, cast_type
);
2716 if (large_send
== QETH_LARGE_SEND_EDDP
) {
2717 /* new_skb is not owned by a socket so we use skb to get
2720 ctx
= qeth_eddp_create_context(card
, new_skb
, hdr
,
2721 skb
->sk
->sk_protocol
);
2723 PRINT_WARN("could not create eddp context\n");
2727 int elems
= qeth_get_elements_no(card
, (void *)hdr
, new_skb
,
2731 elements_needed
+= elems
;
2734 if ((large_send
== QETH_LARGE_SEND_NO
) &&
2735 (new_skb
->ip_summed
== CHECKSUM_PARTIAL
))
2736 qeth_tx_csum(new_skb
);
2738 if (card
->info
.type
!= QETH_CARD_TYPE_IQD
)
2739 rc
= qeth_do_send_packet(card
, queue
, new_skb
, hdr
,
2740 elements_needed
, ctx
);
2742 rc
= qeth_do_send_packet_fast(card
, queue
, new_skb
, hdr
,
2743 elements_needed
, ctx
);
2746 card
->stats
.tx_packets
++;
2747 card
->stats
.tx_bytes
+= tx_bytes
;
2749 dev_kfree_skb_any(skb
);
2750 if (card
->options
.performance_stats
) {
2751 if (large_send
!= QETH_LARGE_SEND_NO
) {
2752 card
->perf_stats
.large_send_bytes
+= tx_bytes
;
2753 card
->perf_stats
.large_send_cnt
++;
2755 if (skb_shinfo(new_skb
)->nr_frags
> 0) {
2756 card
->perf_stats
.sg_skbs_sent
++;
2757 /* nr_frags + skb->data */
2758 card
->perf_stats
.sg_frags_sent
+=
2759 skb_shinfo(new_skb
)->nr_frags
+ 1;
2764 qeth_eddp_put_context(ctx
);
2765 dev_kfree_skb_any(new_skb
);
2769 qeth_eddp_put_context(ctx
);
2773 dev_kfree_skb_any(new_skb
);
2774 return NETDEV_TX_BUSY
;
2779 netif_wake_queue(dev
);
2780 if (card
->options
.performance_stats
)
2781 card
->perf_stats
.outbound_time
+= qeth_get_micros() -
2782 card
->perf_stats
.outbound_start_time
;
2786 card
->stats
.tx_dropped
++;
2787 card
->stats
.tx_errors
++;
2788 if ((new_skb
!= skb
) && new_skb
)
2789 dev_kfree_skb_any(new_skb
);
2790 dev_kfree_skb_any(skb
);
2791 return NETDEV_TX_OK
;
2794 static int qeth_l3_open(struct net_device
*dev
)
2796 struct qeth_card
*card
= netdev_priv(dev
);
2798 QETH_DBF_TEXT(trace
, 4, "qethopen");
2799 if (card
->state
!= CARD_STATE_SOFTSETUP
)
2801 card
->data
.state
= CH_STATE_UP
;
2802 card
->state
= CARD_STATE_UP
;
2803 card
->dev
->flags
|= IFF_UP
;
2804 netif_start_queue(dev
);
2806 if (!card
->lan_online
&& netif_carrier_ok(dev
))
2807 netif_carrier_off(dev
);
2811 static int qeth_l3_stop(struct net_device
*dev
)
2813 struct qeth_card
*card
= netdev_priv(dev
);
2815 QETH_DBF_TEXT(trace
, 4, "qethstop");
2816 netif_tx_disable(dev
);
2817 card
->dev
->flags
&= ~IFF_UP
;
2818 if (card
->state
== CARD_STATE_UP
)
2819 card
->state
= CARD_STATE_SOFTSETUP
;
2823 static u32
qeth_l3_ethtool_get_rx_csum(struct net_device
*dev
)
2825 struct qeth_card
*card
= netdev_priv(dev
);
2827 return (card
->options
.checksum_type
== HW_CHECKSUMMING
);
2830 static int qeth_l3_ethtool_set_rx_csum(struct net_device
*dev
, u32 data
)
2832 struct qeth_card
*card
= netdev_priv(dev
);
2833 enum qeth_card_states old_state
;
2834 enum qeth_checksum_types csum_type
;
2836 if ((card
->state
!= CARD_STATE_UP
) &&
2837 (card
->state
!= CARD_STATE_DOWN
))
2841 csum_type
= HW_CHECKSUMMING
;
2843 csum_type
= SW_CHECKSUMMING
;
2845 if (card
->options
.checksum_type
!= csum_type
) {
2846 old_state
= card
->state
;
2847 if (card
->state
== CARD_STATE_UP
)
2848 __qeth_l3_set_offline(card
->gdev
, 1);
2849 card
->options
.checksum_type
= csum_type
;
2850 if (old_state
== CARD_STATE_UP
)
2851 __qeth_l3_set_online(card
->gdev
, 1);
2856 static int qeth_l3_ethtool_set_tso(struct net_device
*dev
, u32 data
)
2858 struct qeth_card
*card
= netdev_priv(dev
);
2861 if (card
->options
.large_send
== QETH_LARGE_SEND_NO
) {
2862 if (card
->info
.type
== QETH_CARD_TYPE_IQD
)
2863 card
->options
.large_send
= QETH_LARGE_SEND_EDDP
;
2865 card
->options
.large_send
= QETH_LARGE_SEND_TSO
;
2866 dev
->features
|= NETIF_F_TSO
;
2869 dev
->features
&= ~NETIF_F_TSO
;
2870 card
->options
.large_send
= QETH_LARGE_SEND_NO
;
2875 static struct ethtool_ops qeth_l3_ethtool_ops
= {
2876 .get_link
= ethtool_op_get_link
,
2877 .get_tx_csum
= ethtool_op_get_tx_csum
,
2878 .set_tx_csum
= ethtool_op_set_tx_hw_csum
,
2879 .get_rx_csum
= qeth_l3_ethtool_get_rx_csum
,
2880 .set_rx_csum
= qeth_l3_ethtool_set_rx_csum
,
2881 .get_sg
= ethtool_op_get_sg
,
2882 .set_sg
= ethtool_op_set_sg
,
2883 .get_tso
= ethtool_op_get_tso
,
2884 .set_tso
= qeth_l3_ethtool_set_tso
,
2885 .get_strings
= qeth_core_get_strings
,
2886 .get_ethtool_stats
= qeth_core_get_ethtool_stats
,
2887 .get_stats_count
= qeth_core_get_stats_count
,
2888 .get_drvinfo
= qeth_core_get_drvinfo
,
2892 * we need NOARP for IPv4 but we want neighbor solicitation for IPv6. Setting
2893 * NOARP on the netdevice is no option because it also turns off neighbor
2894 * solicitation. For IPv4 we install a neighbor_setup function. We don't want
2895 * arp resolution but we want the hard header (packet socket will work
2898 static int qeth_l3_neigh_setup_noarp(struct neighbour
*n
)
2900 n
->nud_state
= NUD_NOARP
;
2901 memcpy(n
->ha
, "FAKELL", 6);
2902 n
->output
= n
->ops
->connected_output
;
2907 qeth_l3_neigh_setup(struct net_device
*dev
, struct neigh_parms
*np
)
2909 if (np
->tbl
->family
== AF_INET
)
2910 np
->neigh_setup
= qeth_l3_neigh_setup_noarp
;
2915 static int qeth_l3_setup_netdev(struct qeth_card
*card
)
2917 if (card
->info
.type
== QETH_CARD_TYPE_OSAE
) {
2918 if ((card
->info
.link_type
== QETH_LINK_TYPE_LANE_TR
) ||
2919 (card
->info
.link_type
== QETH_LINK_TYPE_HSTR
)) {
2921 card
->dev
= alloc_trdev(0);
2926 card
->dev
= alloc_etherdev(0);
2929 card
->dev
->neigh_setup
= qeth_l3_neigh_setup
;
2931 /*IPv6 address autoconfiguration stuff*/
2932 qeth_l3_get_unique_id(card
);
2933 if (!(card
->info
.unique_id
& UNIQUE_ID_NOT_BY_CARD
))
2934 card
->dev
->dev_id
= card
->info
.unique_id
&
2937 } else if (card
->info
.type
== QETH_CARD_TYPE_IQD
) {
2938 card
->dev
= alloc_netdev(0, "hsi%d", ether_setup
);
2941 card
->dev
->flags
|= IFF_NOARP
;
2942 qeth_l3_iqd_read_initial_mac(card
);
2946 card
->dev
->hard_start_xmit
= qeth_l3_hard_start_xmit
;
2947 card
->dev
->priv
= card
;
2948 card
->dev
->tx_timeout
= &qeth_tx_timeout
;
2949 card
->dev
->watchdog_timeo
= QETH_TX_TIMEOUT
;
2950 card
->dev
->open
= qeth_l3_open
;
2951 card
->dev
->stop
= qeth_l3_stop
;
2952 card
->dev
->do_ioctl
= qeth_l3_do_ioctl
;
2953 card
->dev
->get_stats
= qeth_get_stats
;
2954 card
->dev
->change_mtu
= qeth_change_mtu
;
2955 card
->dev
->set_multicast_list
= qeth_l3_set_multicast_list
;
2956 card
->dev
->vlan_rx_register
= qeth_l3_vlan_rx_register
;
2957 card
->dev
->vlan_rx_add_vid
= qeth_l3_vlan_rx_add_vid
;
2958 card
->dev
->vlan_rx_kill_vid
= qeth_l3_vlan_rx_kill_vid
;
2959 card
->dev
->mtu
= card
->info
.initial_mtu
;
2960 SET_ETHTOOL_OPS(card
->dev
, &qeth_l3_ethtool_ops
);
2961 card
->dev
->features
|= NETIF_F_HW_VLAN_TX
|
2962 NETIF_F_HW_VLAN_RX
|
2963 NETIF_F_HW_VLAN_FILTER
;
2965 SET_NETDEV_DEV(card
->dev
, &card
->gdev
->dev
);
2966 return register_netdev(card
->dev
);
2969 static void qeth_l3_qdio_input_handler(struct ccw_device
*ccwdev
,
2970 unsigned int status
, unsigned int qdio_err
,
2971 unsigned int siga_err
, unsigned int queue
, int first_element
,
2972 int count
, unsigned long card_ptr
)
2974 struct net_device
*net_dev
;
2975 struct qeth_card
*card
;
2976 struct qeth_qdio_buffer
*buffer
;
2980 QETH_DBF_TEXT(trace
, 6, "qdinput");
2981 card
= (struct qeth_card
*) card_ptr
;
2982 net_dev
= card
->dev
;
2983 if (card
->options
.performance_stats
) {
2984 card
->perf_stats
.inbound_cnt
++;
2985 card
->perf_stats
.inbound_start_time
= qeth_get_micros();
2987 if (status
& QDIO_STATUS_LOOK_FOR_ERROR
) {
2988 if (status
& QDIO_STATUS_ACTIVATE_CHECK_CONDITION
) {
2989 QETH_DBF_TEXT(trace
, 1, "qdinchk");
2990 QETH_DBF_TEXT_(trace
, 1, "%s", CARD_BUS_ID(card
));
2991 QETH_DBF_TEXT_(trace
, 1, "%04X%04X",
2992 first_element
, count
);
2993 QETH_DBF_TEXT_(trace
, 1, "%04X%04X", queue
, status
);
2994 qeth_schedule_recovery(card
);
2998 for (i
= first_element
; i
< (first_element
+ count
); ++i
) {
2999 index
= i
% QDIO_MAX_BUFFERS_PER_Q
;
3000 buffer
= &card
->qdio
.in_q
->bufs
[index
];
3001 if (!((status
& QDIO_STATUS_LOOK_FOR_ERROR
) &&
3002 qeth_check_qdio_errors(buffer
->buffer
,
3003 qdio_err
, siga_err
, "qinerr")))
3004 qeth_l3_process_inbound_buffer(card
, buffer
, index
);
3005 /* clear buffer and give back to hardware */
3006 qeth_put_buffer_pool_entry(card
, buffer
->pool_entry
);
3007 qeth_queue_input_buffer(card
, index
);
3009 if (card
->options
.performance_stats
)
3010 card
->perf_stats
.inbound_time
+= qeth_get_micros() -
3011 card
->perf_stats
.inbound_start_time
;
3014 static int qeth_l3_probe_device(struct ccwgroup_device
*gdev
)
3016 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
3018 qeth_l3_create_device_attributes(&gdev
->dev
);
3019 card
->options
.layer2
= 0;
3020 card
->discipline
.input_handler
= (qdio_handler_t
*)
3021 qeth_l3_qdio_input_handler
;
3022 card
->discipline
.output_handler
= (qdio_handler_t
*)
3023 qeth_qdio_output_handler
;
3024 card
->discipline
.recover
= qeth_l3_recover
;
3028 static void qeth_l3_remove_device(struct ccwgroup_device
*cgdev
)
3030 struct qeth_card
*card
= dev_get_drvdata(&cgdev
->dev
);
3032 wait_event(card
->wait_q
, qeth_threads_running(card
, 0xffffffff) == 0);
3034 if (cgdev
->state
== CCWGROUP_ONLINE
) {
3035 card
->use_hard_stop
= 1;
3036 qeth_l3_set_offline(cgdev
);
3040 unregister_netdev(card
->dev
);
3044 qeth_l3_remove_device_attributes(&cgdev
->dev
);
3045 qeth_l3_clear_ip_list(card
, 0, 0);
3046 qeth_l3_clear_ipato_list(card
);
3050 static int __qeth_l3_set_online(struct ccwgroup_device
*gdev
, int recovery_mode
)
3052 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
3054 enum qeth_card_states recover_flag
;
3057 QETH_DBF_TEXT(setup
, 2, "setonlin");
3058 QETH_DBF_HEX(setup
, 2, &card
, sizeof(void *));
3060 qeth_set_allowed_threads(card
, QETH_RECOVER_THREAD
, 1);
3061 if (qeth_wait_for_threads(card
, ~QETH_RECOVER_THREAD
)) {
3062 PRINT_WARN("set_online of card %s interrupted by user!\n",
3064 return -ERESTARTSYS
;
3067 recover_flag
= card
->state
;
3068 rc
= ccw_device_set_online(CARD_RDEV(card
));
3070 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
3073 rc
= ccw_device_set_online(CARD_WDEV(card
));
3075 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
3078 rc
= ccw_device_set_online(CARD_DDEV(card
));
3080 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
3084 rc
= qeth_core_hardsetup_card(card
);
3086 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
3090 qeth_l3_query_ipassists(card
, QETH_PROT_IPV4
);
3092 if (!card
->dev
&& qeth_l3_setup_netdev(card
))
3095 card
->state
= CARD_STATE_HARDSETUP
;
3096 qeth_print_status_message(card
);
3099 QETH_DBF_TEXT(setup
, 2, "softsetp");
3101 rc
= qeth_send_startlan(card
);
3103 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
3105 PRINT_WARN("LAN on card %s if offline! "
3106 "Waiting for STARTLAN from card.\n",
3108 card
->lan_online
= 0;
3112 card
->lan_online
= 1;
3113 qeth_set_large_send(card
, card
->options
.large_send
);
3115 rc
= qeth_l3_setadapter_parms(card
);
3117 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
3118 rc
= qeth_l3_start_ipassists(card
);
3120 QETH_DBF_TEXT_(setup
, 2, "3err%d", rc
);
3121 rc
= qeth_l3_setrouting_v4(card
);
3123 QETH_DBF_TEXT_(setup
, 2, "4err%d", rc
);
3124 rc
= qeth_l3_setrouting_v6(card
);
3126 QETH_DBF_TEXT_(setup
, 2, "5err%d", rc
);
3127 netif_tx_disable(card
->dev
);
3129 rc
= qeth_init_qdio_queues(card
);
3131 QETH_DBF_TEXT_(setup
, 2, "6err%d", rc
);
3134 card
->state
= CARD_STATE_SOFTSETUP
;
3135 netif_carrier_on(card
->dev
);
3137 qeth_set_allowed_threads(card
, 0xffffffff, 0);
3138 if ((recover_flag
== CARD_STATE_RECOVER
) && recovery_mode
) {
3139 qeth_l3_open(card
->dev
);
3140 qeth_l3_set_multicast_list(card
->dev
);
3142 /* let user_space know that device is online */
3143 kobject_uevent(&gdev
->dev
.kobj
, KOBJ_CHANGE
);
3146 card
->use_hard_stop
= 1;
3147 qeth_l3_stop_card(card
, 0);
3148 ccw_device_set_offline(CARD_DDEV(card
));
3149 ccw_device_set_offline(CARD_WDEV(card
));
3150 ccw_device_set_offline(CARD_RDEV(card
));
3151 if (recover_flag
== CARD_STATE_RECOVER
)
3152 card
->state
= CARD_STATE_RECOVER
;
3154 card
->state
= CARD_STATE_DOWN
;
3158 static int qeth_l3_set_online(struct ccwgroup_device
*gdev
)
3160 return __qeth_l3_set_online(gdev
, 0);
3163 static int __qeth_l3_set_offline(struct ccwgroup_device
*cgdev
,
3166 struct qeth_card
*card
= dev_get_drvdata(&cgdev
->dev
);
3167 int rc
= 0, rc2
= 0, rc3
= 0;
3168 enum qeth_card_states recover_flag
;
3170 QETH_DBF_TEXT(setup
, 3, "setoffl");
3171 QETH_DBF_HEX(setup
, 3, &card
, sizeof(void *));
3173 if (card
->dev
&& netif_carrier_ok(card
->dev
))
3174 netif_carrier_off(card
->dev
);
3175 recover_flag
= card
->state
;
3176 if (qeth_l3_stop_card(card
, recovery_mode
) == -ERESTARTSYS
) {
3177 PRINT_WARN("Stopping card %s interrupted by user!\n",
3179 return -ERESTARTSYS
;
3181 rc
= ccw_device_set_offline(CARD_DDEV(card
));
3182 rc2
= ccw_device_set_offline(CARD_WDEV(card
));
3183 rc3
= ccw_device_set_offline(CARD_RDEV(card
));
3185 rc
= (rc2
) ? rc2
: rc3
;
3187 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
3188 if (recover_flag
== CARD_STATE_UP
)
3189 card
->state
= CARD_STATE_RECOVER
;
3190 /* let user_space know that device is offline */
3191 kobject_uevent(&cgdev
->dev
.kobj
, KOBJ_CHANGE
);
3195 static int qeth_l3_set_offline(struct ccwgroup_device
*cgdev
)
3197 return __qeth_l3_set_offline(cgdev
, 0);
3200 static int qeth_l3_recover(void *ptr
)
3202 struct qeth_card
*card
;
3205 card
= (struct qeth_card
*) ptr
;
3206 QETH_DBF_TEXT(trace
, 2, "recover1");
3207 QETH_DBF_HEX(trace
, 2, &card
, sizeof(void *));
3208 if (!qeth_do_run_thread(card
, QETH_RECOVER_THREAD
))
3210 QETH_DBF_TEXT(trace
, 2, "recover2");
3211 PRINT_WARN("Recovery of device %s started ...\n",
3213 card
->use_hard_stop
= 1;
3214 __qeth_l3_set_offline(card
->gdev
, 1);
3215 rc
= __qeth_l3_set_online(card
->gdev
, 1);
3216 /* don't run another scheduled recovery */
3217 qeth_clear_thread_start_bit(card
, QETH_RECOVER_THREAD
);
3218 qeth_clear_thread_running_bit(card
, QETH_RECOVER_THREAD
);
3220 PRINT_INFO("Device %s successfully recovered!\n",
3223 PRINT_INFO("Device %s could not be recovered!\n",
3228 static void qeth_l3_shutdown(struct ccwgroup_device
*gdev
)
3230 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
3231 qeth_l3_clear_ip_list(card
, 0, 0);
3232 qeth_qdio_clear_card(card
, 0);
3233 qeth_clear_qdio_buffers(card
);
3236 struct ccwgroup_driver qeth_l3_ccwgroup_driver
= {
3237 .probe
= qeth_l3_probe_device
,
3238 .remove
= qeth_l3_remove_device
,
3239 .set_online
= qeth_l3_set_online
,
3240 .set_offline
= qeth_l3_set_offline
,
3241 .shutdown
= qeth_l3_shutdown
,
3243 EXPORT_SYMBOL_GPL(qeth_l3_ccwgroup_driver
);
3245 static int qeth_l3_ip_event(struct notifier_block
*this,
3246 unsigned long event
, void *ptr
)
3248 struct in_ifaddr
*ifa
= (struct in_ifaddr
*)ptr
;
3249 struct net_device
*dev
= (struct net_device
*)ifa
->ifa_dev
->dev
;
3250 struct qeth_ipaddr
*addr
;
3251 struct qeth_card
*card
;
3253 if (dev_net(dev
) != &init_net
)
3256 QETH_DBF_TEXT(trace
, 3, "ipevent");
3257 card
= qeth_l3_get_card_from_dev(dev
);
3261 addr
= qeth_l3_get_addr_buffer(QETH_PROT_IPV4
);
3263 addr
->u
.a4
.addr
= ifa
->ifa_address
;
3264 addr
->u
.a4
.mask
= ifa
->ifa_mask
;
3265 addr
->type
= QETH_IP_TYPE_NORMAL
;
3271 if (!qeth_l3_add_ip(card
, addr
))
3275 if (!qeth_l3_delete_ip(card
, addr
))
3281 qeth_l3_set_ip_addr_list(card
);
3286 static struct notifier_block qeth_l3_ip_notifier
= {
3291 #ifdef CONFIG_QETH_IPV6
3293 * IPv6 event handler
3295 static int qeth_l3_ip6_event(struct notifier_block
*this,
3296 unsigned long event
, void *ptr
)
3298 struct inet6_ifaddr
*ifa
= (struct inet6_ifaddr
*)ptr
;
3299 struct net_device
*dev
= (struct net_device
*)ifa
->idev
->dev
;
3300 struct qeth_ipaddr
*addr
;
3301 struct qeth_card
*card
;
3303 QETH_DBF_TEXT(trace
, 3, "ip6event");
3305 card
= qeth_l3_get_card_from_dev(dev
);
3308 if (!qeth_is_supported(card
, IPA_IPV6
))
3311 addr
= qeth_l3_get_addr_buffer(QETH_PROT_IPV6
);
3313 memcpy(&addr
->u
.a6
.addr
, &ifa
->addr
, sizeof(struct in6_addr
));
3314 addr
->u
.a6
.pfxlen
= ifa
->prefix_len
;
3315 addr
->type
= QETH_IP_TYPE_NORMAL
;
3321 if (!qeth_l3_add_ip(card
, addr
))
3325 if (!qeth_l3_delete_ip(card
, addr
))
3331 qeth_l3_set_ip_addr_list(card
);
3336 static struct notifier_block qeth_l3_ip6_notifier
= {
3342 static int qeth_l3_register_notifiers(void)
3346 QETH_DBF_TEXT(trace
, 5, "regnotif");
3347 rc
= register_inetaddr_notifier(&qeth_l3_ip_notifier
);
3350 #ifdef CONFIG_QETH_IPV6
3351 rc
= register_inet6addr_notifier(&qeth_l3_ip6_notifier
);
3353 unregister_inetaddr_notifier(&qeth_l3_ip_notifier
);
3357 PRINT_WARN("layer 3 discipline no IPv6 support\n");
3362 static void qeth_l3_unregister_notifiers(void)
3365 QETH_DBF_TEXT(trace
, 5, "unregnot");
3366 BUG_ON(unregister_inetaddr_notifier(&qeth_l3_ip_notifier
));
3367 #ifdef CONFIG_QETH_IPV6
3368 BUG_ON(unregister_inet6addr_notifier(&qeth_l3_ip6_notifier
));
3369 #endif /* QETH_IPV6 */
3372 static int __init
qeth_l3_init(void)
3376 PRINT_INFO("register layer 3 discipline\n");
3377 rc
= qeth_l3_register_notifiers();
3381 static void __exit
qeth_l3_exit(void)
3383 qeth_l3_unregister_notifiers();
3384 PRINT_INFO("unregister layer 3 discipline\n");
3387 module_init(qeth_l3_init
);
3388 module_exit(qeth_l3_exit
);
3389 MODULE_AUTHOR("Frank Blaschka <frank.blaschka@de.ibm.com>");
3390 MODULE_DESCRIPTION("qeth layer 3 discipline");
3391 MODULE_LICENSE("GPL");