2 * linux/drivers/s390/net/qeth_main.c
4 * Linux on zSeries OSA Express and HiperSockets support
6 * Copyright 2000,2003 IBM Corporation
8 * Author(s): Original Code written by
9 * Utz Bacher (utz.bacher@de.ibm.com)
11 * Frank Pavlic (fpavlic@de.ibm.com) and
12 * Thomas Spatzier <tspat@de.ibm.com>
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2, or (at your option)
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 #include <linux/config.h>
31 #include <linux/module.h>
32 #include <linux/moduleparam.h>
33 #include <linux/string.h>
34 #include <linux/errno.h>
37 #include <linux/inetdevice.h>
38 #include <linux/netdevice.h>
39 #include <linux/sched.h>
40 #include <linux/workqueue.h>
41 #include <linux/kernel.h>
42 #include <linux/slab.h>
43 #include <linux/interrupt.h>
44 #include <linux/tcp.h>
45 #include <linux/icmp.h>
46 #include <linux/skbuff.h>
48 #include <linux/igmp.h>
49 #include <linux/init.h>
50 #include <linux/reboot.h>
51 #include <linux/mii.h>
52 #include <linux/rcupdate.h>
53 #include <linux/ethtool.h>
57 #include <net/route.h>
59 #include <asm/ebcdic.h>
62 #include <asm/timex.h>
63 #include <asm/semaphore.h>
64 #include <asm/uaccess.h>
65 #include <asm/s390_rdev.h>
70 #include "qeth_eddp.h"
73 static const char *version
= "qeth S/390 OSA-Express driver";
76 * Debug Facility Stuff
78 static debug_info_t
*qeth_dbf_setup
= NULL
;
79 static debug_info_t
*qeth_dbf_data
= NULL
;
80 static debug_info_t
*qeth_dbf_misc
= NULL
;
81 static debug_info_t
*qeth_dbf_control
= NULL
;
82 debug_info_t
*qeth_dbf_trace
= NULL
;
83 static debug_info_t
*qeth_dbf_sense
= NULL
;
84 static debug_info_t
*qeth_dbf_qerr
= NULL
;
86 DEFINE_PER_CPU(char[256], qeth_dbf_txt_buf
);
89 * some more definitions and declarations
91 static unsigned int known_devices
[][10] = QETH_MODELLIST_ARRAY
;
93 /* list of our cards */
94 struct qeth_card_list_struct qeth_card_list
;
95 /*process list want to be notified*/
96 spinlock_t qeth_notify_lock
;
97 struct list_head qeth_notify_list
;
99 static void qeth_send_control_data_cb(struct qeth_channel
*,
100 struct qeth_cmd_buffer
*);
103 * here we go with function implementation
106 qeth_init_qdio_info(struct qeth_card
*card
);
109 qeth_init_qdio_queues(struct qeth_card
*card
);
112 qeth_alloc_qdio_buffers(struct qeth_card
*card
);
115 qeth_free_qdio_buffers(struct qeth_card
*);
118 qeth_clear_qdio_buffers(struct qeth_card
*);
121 qeth_clear_ip_list(struct qeth_card
*, int, int);
124 qeth_clear_ipacmd_list(struct qeth_card
*);
127 qeth_qdio_clear_card(struct qeth_card
*, int);
130 qeth_clear_working_pool_list(struct qeth_card
*);
133 qeth_clear_cmd_buffers(struct qeth_channel
*);
136 qeth_stop(struct net_device
*);
139 qeth_clear_ipato_list(struct qeth_card
*);
142 qeth_is_addr_covered_by_ipato(struct qeth_card
*, struct qeth_ipaddr
*);
145 qeth_irq_tasklet(unsigned long);
148 qeth_set_online(struct ccwgroup_device
*);
151 __qeth_set_online(struct ccwgroup_device
*gdev
, int recovery_mode
);
153 static struct qeth_ipaddr
*
154 qeth_get_addr_buffer(enum qeth_prot_versions
);
157 qeth_set_multicast_list(struct net_device
*);
160 qeth_setadp_promisc_mode(struct qeth_card
*);
163 qeth_notify_processes(void)
165 /*notify all registered processes */
166 struct qeth_notify_list_struct
*n_entry
;
168 QETH_DBF_TEXT(trace
,3,"procnoti");
169 spin_lock(&qeth_notify_lock
);
170 list_for_each_entry(n_entry
, &qeth_notify_list
, list
) {
171 send_sig(n_entry
->signum
, n_entry
->task
, 1);
173 spin_unlock(&qeth_notify_lock
);
177 qeth_notifier_unregister(struct task_struct
*p
)
179 struct qeth_notify_list_struct
*n_entry
, *tmp
;
181 QETH_DBF_TEXT(trace
, 2, "notunreg");
182 spin_lock(&qeth_notify_lock
);
183 list_for_each_entry_safe(n_entry
, tmp
, &qeth_notify_list
, list
) {
184 if (n_entry
->task
== p
) {
185 list_del(&n_entry
->list
);
191 spin_unlock(&qeth_notify_lock
);
195 qeth_notifier_register(struct task_struct
*p
, int signum
)
197 struct qeth_notify_list_struct
*n_entry
;
199 /*check first if entry already exists*/
200 spin_lock(&qeth_notify_lock
);
201 list_for_each_entry(n_entry
, &qeth_notify_list
, list
) {
202 if (n_entry
->task
== p
) {
203 n_entry
->signum
= signum
;
204 spin_unlock(&qeth_notify_lock
);
208 spin_unlock(&qeth_notify_lock
);
210 n_entry
= (struct qeth_notify_list_struct
*)
211 kmalloc(sizeof(struct qeth_notify_list_struct
),GFP_KERNEL
);
215 n_entry
->signum
= signum
;
216 spin_lock(&qeth_notify_lock
);
217 list_add(&n_entry
->list
,&qeth_notify_list
);
218 spin_unlock(&qeth_notify_lock
);
224 * free channel command buffers
227 qeth_clean_channel(struct qeth_channel
*channel
)
231 QETH_DBF_TEXT(setup
, 2, "freech");
232 for (cnt
= 0; cnt
< QETH_CMD_BUFFER_NO
; cnt
++)
233 kfree(channel
->iob
[cnt
].data
);
240 qeth_free_card(struct qeth_card
*card
)
243 QETH_DBF_TEXT(setup
, 2, "freecrd");
244 QETH_DBF_HEX(setup
, 2, &card
, sizeof(void *));
245 qeth_clean_channel(&card
->read
);
246 qeth_clean_channel(&card
->write
);
248 free_netdev(card
->dev
);
249 qeth_clear_ip_list(card
, 0, 0);
250 qeth_clear_ipato_list(card
);
251 kfree(card
->ip_tbd_list
);
252 qeth_free_qdio_buffers(card
);
257 * alloc memory for command buffer per channel
260 qeth_setup_channel(struct qeth_channel
*channel
)
264 QETH_DBF_TEXT(setup
, 2, "setupch");
265 for (cnt
=0; cnt
< QETH_CMD_BUFFER_NO
; cnt
++) {
266 channel
->iob
[cnt
].data
= (char *)
267 kmalloc(QETH_BUFSIZE
, GFP_DMA
|GFP_KERNEL
);
268 if (channel
->iob
[cnt
].data
== NULL
)
270 channel
->iob
[cnt
].state
= BUF_STATE_FREE
;
271 channel
->iob
[cnt
].channel
= channel
;
272 channel
->iob
[cnt
].callback
= qeth_send_control_data_cb
;
273 channel
->iob
[cnt
].rc
= 0;
275 if (cnt
< QETH_CMD_BUFFER_NO
) {
277 kfree(channel
->iob
[cnt
].data
);
281 channel
->io_buf_no
= 0;
282 atomic_set(&channel
->irq_pending
, 0);
283 spin_lock_init(&channel
->iob_lock
);
285 init_waitqueue_head(&channel
->wait_q
);
286 channel
->irq_tasklet
.data
= (unsigned long) channel
;
287 channel
->irq_tasklet
.func
= qeth_irq_tasklet
;
292 * alloc memory for card structure
294 static struct qeth_card
*
295 qeth_alloc_card(void)
297 struct qeth_card
*card
;
299 QETH_DBF_TEXT(setup
, 2, "alloccrd");
300 card
= kzalloc(sizeof(struct qeth_card
), GFP_DMA
|GFP_KERNEL
);
303 QETH_DBF_HEX(setup
, 2, &card
, sizeof(void *));
304 if (qeth_setup_channel(&card
->read
)) {
308 if (qeth_setup_channel(&card
->write
)) {
309 qeth_clean_channel(&card
->read
);
317 __qeth_check_irb_error(struct ccw_device
*cdev
, struct irb
*irb
)
322 switch (PTR_ERR(irb
)) {
324 PRINT_WARN("i/o-error on device %s\n", cdev
->dev
.bus_id
);
325 QETH_DBF_TEXT(trace
, 2, "ckirberr");
326 QETH_DBF_TEXT_(trace
, 2, " rc%d", -EIO
);
329 PRINT_WARN("timeout on device %s\n", cdev
->dev
.bus_id
);
330 QETH_DBF_TEXT(trace
, 2, "ckirberr");
331 QETH_DBF_TEXT_(trace
, 2, " rc%d", -ETIMEDOUT
);
334 PRINT_WARN("unknown error %ld on device %s\n", PTR_ERR(irb
),
336 QETH_DBF_TEXT(trace
, 2, "ckirberr");
337 QETH_DBF_TEXT(trace
, 2, " rc???");
343 qeth_get_problem(struct ccw_device
*cdev
, struct irb
*irb
)
348 sense
= (char *) irb
->ecw
;
349 cstat
= irb
->scsw
.cstat
;
350 dstat
= irb
->scsw
.dstat
;
352 if (cstat
& (SCHN_STAT_CHN_CTRL_CHK
| SCHN_STAT_INTF_CTRL_CHK
|
353 SCHN_STAT_CHN_DATA_CHK
| SCHN_STAT_CHAIN_CHECK
|
354 SCHN_STAT_PROT_CHECK
| SCHN_STAT_PROG_CHECK
)) {
355 QETH_DBF_TEXT(trace
,2, "CGENCHK");
356 PRINT_WARN("check on device %s, dstat=x%x, cstat=x%x ",
357 cdev
->dev
.bus_id
, dstat
, cstat
);
358 HEXDUMP16(WARN
, "irb: ", irb
);
359 HEXDUMP16(WARN
, "irb: ", ((char *) irb
) + 32);
363 if (dstat
& DEV_STAT_UNIT_CHECK
) {
364 if (sense
[SENSE_RESETTING_EVENT_BYTE
] &
365 SENSE_RESETTING_EVENT_FLAG
) {
366 QETH_DBF_TEXT(trace
,2,"REVIND");
369 if (sense
[SENSE_COMMAND_REJECT_BYTE
] &
370 SENSE_COMMAND_REJECT_FLAG
) {
371 QETH_DBF_TEXT(trace
,2,"CMDREJi");
374 if ((sense
[2] == 0xaf) && (sense
[3] == 0xfe)) {
375 QETH_DBF_TEXT(trace
,2,"AFFE");
378 if ((!sense
[0]) && (!sense
[1]) && (!sense
[2]) && (!sense
[3])) {
379 QETH_DBF_TEXT(trace
,2,"ZEROSEN");
382 QETH_DBF_TEXT(trace
,2,"DGENCHK");
387 static int qeth_issue_next_read(struct qeth_card
*);
393 qeth_irq(struct ccw_device
*cdev
, unsigned long intparm
, struct irb
*irb
)
397 struct qeth_cmd_buffer
*buffer
;
398 struct qeth_channel
*channel
;
399 struct qeth_card
*card
;
401 QETH_DBF_TEXT(trace
,5,"irq");
403 if (__qeth_check_irb_error(cdev
, irb
))
405 cstat
= irb
->scsw
.cstat
;
406 dstat
= irb
->scsw
.dstat
;
408 card
= CARD_FROM_CDEV(cdev
);
412 if (card
->read
.ccwdev
== cdev
){
413 channel
= &card
->read
;
414 QETH_DBF_TEXT(trace
,5,"read");
415 } else if (card
->write
.ccwdev
== cdev
) {
416 channel
= &card
->write
;
417 QETH_DBF_TEXT(trace
,5,"write");
419 channel
= &card
->data
;
420 QETH_DBF_TEXT(trace
,5,"data");
422 atomic_set(&channel
->irq_pending
, 0);
424 if (irb
->scsw
.fctl
& (SCSW_FCTL_CLEAR_FUNC
))
425 channel
->state
= CH_STATE_STOPPED
;
427 if (irb
->scsw
.fctl
& (SCSW_FCTL_HALT_FUNC
))
428 channel
->state
= CH_STATE_HALTED
;
430 /*let's wake up immediately on data channel*/
431 if ((channel
== &card
->data
) && (intparm
!= 0))
434 if (intparm
== QETH_CLEAR_CHANNEL_PARM
) {
435 QETH_DBF_TEXT(trace
, 6, "clrchpar");
436 /* we don't have to handle this further */
439 if (intparm
== QETH_HALT_CHANNEL_PARM
) {
440 QETH_DBF_TEXT(trace
, 6, "hltchpar");
441 /* we don't have to handle this further */
444 if ((dstat
& DEV_STAT_UNIT_EXCEP
) ||
445 (dstat
& DEV_STAT_UNIT_CHECK
) ||
447 if (irb
->esw
.esw0
.erw
.cons
) {
448 /* TODO: we should make this s390dbf */
449 PRINT_WARN("sense data available on channel %s.\n",
450 CHANNEL_ID(channel
));
451 PRINT_WARN(" cstat 0x%X\n dstat 0x%X\n", cstat
, dstat
);
452 HEXDUMP16(WARN
,"irb: ",irb
);
453 HEXDUMP16(WARN
,"sense data: ",irb
->ecw
);
455 rc
= qeth_get_problem(cdev
,irb
);
457 qeth_schedule_recovery(card
);
463 buffer
= (struct qeth_cmd_buffer
*) __va((addr_t
)intparm
);
464 buffer
->state
= BUF_STATE_PROCESSED
;
466 if (channel
== &card
->data
)
469 if (channel
== &card
->read
&&
470 channel
->state
== CH_STATE_UP
)
471 qeth_issue_next_read(card
);
473 tasklet_schedule(&channel
->irq_tasklet
);
476 wake_up(&card
->wait_q
);
480 * tasklet function scheduled from irq handler
483 qeth_irq_tasklet(unsigned long data
)
485 struct qeth_card
*card
;
486 struct qeth_channel
*channel
;
487 struct qeth_cmd_buffer
*iob
;
490 QETH_DBF_TEXT(trace
,5,"irqtlet");
491 channel
= (struct qeth_channel
*) data
;
493 index
= channel
->buf_no
;
494 card
= CARD_FROM_CDEV(channel
->ccwdev
);
495 while (iob
[index
].state
== BUF_STATE_PROCESSED
) {
496 if (iob
[index
].callback
!=NULL
) {
497 iob
[index
].callback(channel
,iob
+ index
);
499 index
= (index
+ 1) % QETH_CMD_BUFFER_NO
;
501 channel
->buf_no
= index
;
502 wake_up(&card
->wait_q
);
505 static int qeth_stop_card(struct qeth_card
*, int);
508 __qeth_set_offline(struct ccwgroup_device
*cgdev
, int recovery_mode
)
510 struct qeth_card
*card
= (struct qeth_card
*) cgdev
->dev
.driver_data
;
511 int rc
= 0, rc2
= 0, rc3
= 0;
512 enum qeth_card_states recover_flag
;
514 QETH_DBF_TEXT(setup
, 3, "setoffl");
515 QETH_DBF_HEX(setup
, 3, &card
, sizeof(void *));
517 if (card
->dev
&& netif_carrier_ok(card
->dev
))
518 netif_carrier_off(card
->dev
);
519 recover_flag
= card
->state
;
520 if (qeth_stop_card(card
, recovery_mode
) == -ERESTARTSYS
){
521 PRINT_WARN("Stopping card %s interrupted by user!\n",
525 rc
= ccw_device_set_offline(CARD_DDEV(card
));
526 rc2
= ccw_device_set_offline(CARD_WDEV(card
));
527 rc3
= ccw_device_set_offline(CARD_RDEV(card
));
529 rc
= (rc2
) ? rc2
: rc3
;
531 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
532 if (recover_flag
== CARD_STATE_UP
)
533 card
->state
= CARD_STATE_RECOVER
;
534 qeth_notify_processes();
539 qeth_set_offline(struct ccwgroup_device
*cgdev
)
541 return __qeth_set_offline(cgdev
, 0);
545 qeth_wait_for_threads(struct qeth_card
*card
, unsigned long threads
);
549 qeth_remove_device(struct ccwgroup_device
*cgdev
)
551 struct qeth_card
*card
= (struct qeth_card
*) cgdev
->dev
.driver_data
;
554 QETH_DBF_TEXT(setup
, 3, "rmdev");
555 QETH_DBF_HEX(setup
, 3, &card
, sizeof(void *));
560 if (qeth_wait_for_threads(card
, 0xffffffff))
563 if (cgdev
->state
== CCWGROUP_ONLINE
){
564 card
->use_hard_stop
= 1;
565 qeth_set_offline(cgdev
);
567 /* remove form our internal list */
568 write_lock_irqsave(&qeth_card_list
.rwlock
, flags
);
569 list_del(&card
->list
);
570 write_unlock_irqrestore(&qeth_card_list
.rwlock
, flags
);
572 unregister_netdev(card
->dev
);
573 qeth_remove_device_attributes(&cgdev
->dev
);
574 qeth_free_card(card
);
575 cgdev
->dev
.driver_data
= NULL
;
576 put_device(&cgdev
->dev
);
580 qeth_register_addr_entry(struct qeth_card
*, struct qeth_ipaddr
*);
582 qeth_deregister_addr_entry(struct qeth_card
*, struct qeth_ipaddr
*);
585 * Add/remove address to/from card's ip list, i.e. try to add or remove
586 * reference to/from an IP address that is already registered on the card.
588 * 0 address was on card and its reference count has been adjusted,
589 * but is still > 0, so nothing has to be done
590 * also returns 0 if card was not on card and the todo was to delete
591 * the address -> there is also nothing to be done
592 * 1 address was not on card and the todo is to add it to the card's ip
594 * -1 address was on card and its reference count has been decremented
595 * to <= 0 by the todo -> address must be removed from card
598 __qeth_ref_ip_on_card(struct qeth_card
*card
, struct qeth_ipaddr
*todo
,
599 struct qeth_ipaddr
**__addr
)
601 struct qeth_ipaddr
*addr
;
604 list_for_each_entry(addr
, &card
->ip_list
, entry
) {
605 if (card
->options
.layer2
) {
606 if ((addr
->type
== todo
->type
) &&
607 (memcmp(&addr
->mac
, &todo
->mac
,
608 OSA_ADDR_LEN
) == 0)) {
614 if ((addr
->proto
== QETH_PROT_IPV4
) &&
615 (todo
->proto
== QETH_PROT_IPV4
) &&
616 (addr
->type
== todo
->type
) &&
617 (addr
->u
.a4
.addr
== todo
->u
.a4
.addr
) &&
618 (addr
->u
.a4
.mask
== todo
->u
.a4
.mask
)) {
622 if ((addr
->proto
== QETH_PROT_IPV6
) &&
623 (todo
->proto
== QETH_PROT_IPV6
) &&
624 (addr
->type
== todo
->type
) &&
625 (addr
->u
.a6
.pfxlen
== todo
->u
.a6
.pfxlen
) &&
626 (memcmp(&addr
->u
.a6
.addr
, &todo
->u
.a6
.addr
,
627 sizeof(struct in6_addr
)) == 0)) {
633 addr
->users
+= todo
->users
;
634 if (addr
->users
<= 0){
638 /* for VIPA and RXIP limit refcount to 1 */
639 if (addr
->type
!= QETH_IP_TYPE_NORMAL
)
644 if (todo
->users
> 0) {
645 /* for VIPA and RXIP limit refcount to 1 */
646 if (todo
->type
!= QETH_IP_TYPE_NORMAL
)
654 __qeth_address_exists_in_list(struct list_head
*list
, struct qeth_ipaddr
*addr
,
657 struct qeth_ipaddr
*tmp
;
659 list_for_each_entry(tmp
, list
, entry
) {
660 if ((tmp
->proto
== QETH_PROT_IPV4
) &&
661 (addr
->proto
== QETH_PROT_IPV4
) &&
662 ((same_type
&& (tmp
->type
== addr
->type
)) ||
663 (!same_type
&& (tmp
->type
!= addr
->type
)) ) &&
664 (tmp
->u
.a4
.addr
== addr
->u
.a4
.addr
) ){
667 if ((tmp
->proto
== QETH_PROT_IPV6
) &&
668 (addr
->proto
== QETH_PROT_IPV6
) &&
669 ((same_type
&& (tmp
->type
== addr
->type
)) ||
670 (!same_type
&& (tmp
->type
!= addr
->type
)) ) &&
671 (memcmp(&tmp
->u
.a6
.addr
, &addr
->u
.a6
.addr
,
672 sizeof(struct in6_addr
)) == 0) ) {
680 * Add IP to be added to todo list. If there is already an "add todo"
681 * in this list we just incremenent the reference count.
682 * Returns 0 if we just incremented reference count.
685 __qeth_insert_ip_todo(struct qeth_card
*card
, struct qeth_ipaddr
*addr
, int add
)
687 struct qeth_ipaddr
*tmp
, *t
;
690 list_for_each_entry_safe(tmp
, t
, card
->ip_tbd_list
, entry
) {
691 if ((addr
->type
== QETH_IP_TYPE_DEL_ALL_MC
) &&
692 (tmp
->type
== QETH_IP_TYPE_DEL_ALL_MC
))
694 if (card
->options
.layer2
) {
695 if ((tmp
->type
== addr
->type
) &&
696 (tmp
->is_multicast
== addr
->is_multicast
) &&
697 (memcmp(&tmp
->mac
, &addr
->mac
,
698 OSA_ADDR_LEN
) == 0)) {
704 if ((tmp
->proto
== QETH_PROT_IPV4
) &&
705 (addr
->proto
== QETH_PROT_IPV4
) &&
706 (tmp
->type
== addr
->type
) &&
707 (tmp
->is_multicast
== addr
->is_multicast
) &&
708 (tmp
->u
.a4
.addr
== addr
->u
.a4
.addr
) &&
709 (tmp
->u
.a4
.mask
== addr
->u
.a4
.mask
)) {
713 if ((tmp
->proto
== QETH_PROT_IPV6
) &&
714 (addr
->proto
== QETH_PROT_IPV6
) &&
715 (tmp
->type
== addr
->type
) &&
716 (tmp
->is_multicast
== addr
->is_multicast
) &&
717 (tmp
->u
.a6
.pfxlen
== addr
->u
.a6
.pfxlen
) &&
718 (memcmp(&tmp
->u
.a6
.addr
, &addr
->u
.a6
.addr
,
719 sizeof(struct in6_addr
)) == 0)) {
725 if (addr
->users
!= 0)
726 tmp
->users
+= addr
->users
;
728 tmp
->users
+= add
? 1:-1;
729 if (tmp
->users
== 0) {
730 list_del(&tmp
->entry
);
735 if (addr
->type
== QETH_IP_TYPE_DEL_ALL_MC
)
736 list_add(&addr
->entry
, card
->ip_tbd_list
);
738 if (addr
->users
== 0)
739 addr
->users
+= add
? 1:-1;
740 if (add
&& (addr
->type
== QETH_IP_TYPE_NORMAL
) &&
741 qeth_is_addr_covered_by_ipato(card
, addr
)){
742 QETH_DBF_TEXT(trace
, 2, "tkovaddr");
743 addr
->set_flags
|= QETH_IPA_SETIP_TAKEOVER_FLAG
;
745 list_add_tail(&addr
->entry
, card
->ip_tbd_list
);
752 * Remove IP address from list
755 qeth_delete_ip(struct qeth_card
*card
, struct qeth_ipaddr
*addr
)
760 QETH_DBF_TEXT(trace
, 4, "delip");
762 if (card
->options
.layer2
)
763 QETH_DBF_HEX(trace
, 4, &addr
->mac
, 6);
764 else if (addr
->proto
== QETH_PROT_IPV4
)
765 QETH_DBF_HEX(trace
, 4, &addr
->u
.a4
.addr
, 4);
767 QETH_DBF_HEX(trace
, 4, &addr
->u
.a6
.addr
, 8);
768 QETH_DBF_HEX(trace
, 4, ((char *)&addr
->u
.a6
.addr
) + 8, 8);
770 spin_lock_irqsave(&card
->ip_lock
, flags
);
771 rc
= __qeth_insert_ip_todo(card
, addr
, 0);
772 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
777 qeth_add_ip(struct qeth_card
*card
, struct qeth_ipaddr
*addr
)
782 QETH_DBF_TEXT(trace
, 4, "addip");
783 if (card
->options
.layer2
)
784 QETH_DBF_HEX(trace
, 4, &addr
->mac
, 6);
785 else if (addr
->proto
== QETH_PROT_IPV4
)
786 QETH_DBF_HEX(trace
, 4, &addr
->u
.a4
.addr
, 4);
788 QETH_DBF_HEX(trace
, 4, &addr
->u
.a6
.addr
, 8);
789 QETH_DBF_HEX(trace
, 4, ((char *)&addr
->u
.a6
.addr
) + 8, 8);
791 spin_lock_irqsave(&card
->ip_lock
, flags
);
792 rc
= __qeth_insert_ip_todo(card
, addr
, 1);
793 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
798 __qeth_delete_all_mc(struct qeth_card
*card
, unsigned long *flags
)
800 struct qeth_ipaddr
*addr
, *tmp
;
803 list_for_each_entry_safe(addr
, tmp
, &card
->ip_list
, entry
) {
804 if (addr
->is_multicast
) {
805 spin_unlock_irqrestore(&card
->ip_lock
, *flags
);
806 rc
= qeth_deregister_addr_entry(card
, addr
);
807 spin_lock_irqsave(&card
->ip_lock
, *flags
);
809 list_del(&addr
->entry
);
818 qeth_set_ip_addr_list(struct qeth_card
*card
)
820 struct list_head
*tbd_list
;
821 struct qeth_ipaddr
*todo
, *addr
;
825 QETH_DBF_TEXT(trace
, 2, "sdiplist");
826 QETH_DBF_HEX(trace
, 2, &card
, sizeof(void *));
828 spin_lock_irqsave(&card
->ip_lock
, flags
);
829 tbd_list
= card
->ip_tbd_list
;
830 card
->ip_tbd_list
= kmalloc(sizeof(struct list_head
), GFP_ATOMIC
);
831 if (!card
->ip_tbd_list
) {
832 QETH_DBF_TEXT(trace
, 0, "silnomem");
833 card
->ip_tbd_list
= tbd_list
;
834 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
837 INIT_LIST_HEAD(card
->ip_tbd_list
);
839 while (!list_empty(tbd_list
)){
840 todo
= list_entry(tbd_list
->next
, struct qeth_ipaddr
, entry
);
841 list_del(&todo
->entry
);
842 if (todo
->type
== QETH_IP_TYPE_DEL_ALL_MC
){
843 __qeth_delete_all_mc(card
, &flags
);
847 rc
= __qeth_ref_ip_on_card(card
, todo
, &addr
);
849 /* nothing to be done; only adjusted refcount */
851 } else if (rc
== 1) {
852 /* new entry to be added to on-card list */
853 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
854 rc
= qeth_register_addr_entry(card
, todo
);
855 spin_lock_irqsave(&card
->ip_lock
, flags
);
857 list_add_tail(&todo
->entry
, &card
->ip_list
);
860 } else if (rc
== -1) {
861 /* on-card entry to be removed */
862 list_del_init(&addr
->entry
);
863 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
864 rc
= qeth_deregister_addr_entry(card
, addr
);
865 spin_lock_irqsave(&card
->ip_lock
, flags
);
869 list_add_tail(&addr
->entry
, &card
->ip_list
);
873 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
877 static void qeth_delete_mc_addresses(struct qeth_card
*);
878 static void qeth_add_multicast_ipv4(struct qeth_card
*);
879 static void qeth_layer2_add_multicast(struct qeth_card
*);
880 #ifdef CONFIG_QETH_IPV6
881 static void qeth_add_multicast_ipv6(struct qeth_card
*);
885 qeth_set_thread_start_bit(struct qeth_card
*card
, unsigned long thread
)
889 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
890 if ( !(card
->thread_allowed_mask
& thread
) ||
891 (card
->thread_start_mask
& thread
) ) {
892 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
895 card
->thread_start_mask
|= thread
;
896 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
901 qeth_clear_thread_start_bit(struct qeth_card
*card
, unsigned long thread
)
905 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
906 card
->thread_start_mask
&= ~thread
;
907 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
908 wake_up(&card
->wait_q
);
912 qeth_clear_thread_running_bit(struct qeth_card
*card
, unsigned long thread
)
916 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
917 card
->thread_running_mask
&= ~thread
;
918 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
919 wake_up(&card
->wait_q
);
923 __qeth_do_run_thread(struct qeth_card
*card
, unsigned long thread
)
928 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
929 if (card
->thread_start_mask
& thread
){
930 if ((card
->thread_allowed_mask
& thread
) &&
931 !(card
->thread_running_mask
& thread
)){
933 card
->thread_start_mask
&= ~thread
;
934 card
->thread_running_mask
|= thread
;
938 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
943 qeth_do_run_thread(struct qeth_card
*card
, unsigned long thread
)
947 wait_event(card
->wait_q
,
948 (rc
= __qeth_do_run_thread(card
, thread
)) >= 0);
953 qeth_register_ip_addresses(void *ptr
)
955 struct qeth_card
*card
;
957 card
= (struct qeth_card
*) ptr
;
958 daemonize("qeth_reg_ip");
959 QETH_DBF_TEXT(trace
,4,"regipth1");
960 if (!qeth_do_run_thread(card
, QETH_SET_IP_THREAD
))
962 QETH_DBF_TEXT(trace
,4,"regipth2");
963 qeth_set_ip_addr_list(card
);
964 qeth_clear_thread_running_bit(card
, QETH_SET_IP_THREAD
);
969 * Drive the SET_PROMISC_MODE thread
972 qeth_set_promisc_mode(void *ptr
)
974 struct qeth_card
*card
= (struct qeth_card
*) ptr
;
976 daemonize("qeth_setprm");
977 QETH_DBF_TEXT(trace
,4,"setprm1");
978 if (!qeth_do_run_thread(card
, QETH_SET_PROMISC_MODE_THREAD
))
980 QETH_DBF_TEXT(trace
,4,"setprm2");
981 qeth_setadp_promisc_mode(card
);
982 qeth_clear_thread_running_bit(card
, QETH_SET_PROMISC_MODE_THREAD
);
987 qeth_recover(void *ptr
)
989 struct qeth_card
*card
;
992 card
= (struct qeth_card
*) ptr
;
993 daemonize("qeth_recover");
994 QETH_DBF_TEXT(trace
,2,"recover1");
995 QETH_DBF_HEX(trace
, 2, &card
, sizeof(void *));
996 if (!qeth_do_run_thread(card
, QETH_RECOVER_THREAD
))
998 QETH_DBF_TEXT(trace
,2,"recover2");
999 PRINT_WARN("Recovery of device %s started ...\n",
1001 card
->use_hard_stop
= 1;
1002 __qeth_set_offline(card
->gdev
,1);
1003 rc
= __qeth_set_online(card
->gdev
,1);
1005 PRINT_INFO("Device %s successfully recovered!\n",
1008 PRINT_INFO("Device %s could not be recovered!\n",
1010 /* don't run another scheduled recovery */
1011 qeth_clear_thread_start_bit(card
, QETH_RECOVER_THREAD
);
1012 qeth_clear_thread_running_bit(card
, QETH_RECOVER_THREAD
);
1017 qeth_schedule_recovery(struct qeth_card
*card
)
1019 QETH_DBF_TEXT(trace
,2,"startrec");
1020 if (qeth_set_thread_start_bit(card
, QETH_RECOVER_THREAD
) == 0)
1021 schedule_work(&card
->kernel_thread_starter
);
1025 qeth_do_start_thread(struct qeth_card
*card
, unsigned long thread
)
1027 unsigned long flags
;
1030 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
1031 QETH_DBF_TEXT_(trace
, 4, " %02x%02x%02x",
1032 (u8
) card
->thread_start_mask
,
1033 (u8
) card
->thread_allowed_mask
,
1034 (u8
) card
->thread_running_mask
);
1035 rc
= (card
->thread_start_mask
& thread
);
1036 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
1041 qeth_start_kernel_thread(struct qeth_card
*card
)
1043 QETH_DBF_TEXT(trace
, 2, "strthrd");
1045 if (card
->read
.state
!= CH_STATE_UP
&&
1046 card
->write
.state
!= CH_STATE_UP
)
1049 if (qeth_do_start_thread(card
, QETH_SET_IP_THREAD
))
1050 kernel_thread(qeth_register_ip_addresses
, (void *)card
,SIGCHLD
);
1051 if (qeth_do_start_thread(card
, QETH_SET_PROMISC_MODE_THREAD
))
1052 kernel_thread(qeth_set_promisc_mode
, (void *)card
, SIGCHLD
);
1053 if (qeth_do_start_thread(card
, QETH_RECOVER_THREAD
))
1054 kernel_thread(qeth_recover
, (void *) card
, SIGCHLD
);
1059 qeth_set_intial_options(struct qeth_card
*card
)
1061 card
->options
.route4
.type
= NO_ROUTER
;
1062 #ifdef CONFIG_QETH_IPV6
1063 card
->options
.route6
.type
= NO_ROUTER
;
1064 #endif /* QETH_IPV6 */
1065 card
->options
.checksum_type
= QETH_CHECKSUM_DEFAULT
;
1066 card
->options
.broadcast_mode
= QETH_TR_BROADCAST_ALLRINGS
;
1067 card
->options
.macaddr_mode
= QETH_TR_MACADDR_NONCANONICAL
;
1068 card
->options
.fake_broadcast
= 0;
1069 card
->options
.add_hhlen
= DEFAULT_ADD_HHLEN
;
1070 card
->options
.fake_ll
= 0;
1071 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
1072 card
->options
.layer2
= 1;
1074 card
->options
.layer2
= 0;
1078 * initialize channels ,card and all state machines
1081 qeth_setup_card(struct qeth_card
*card
)
1084 QETH_DBF_TEXT(setup
, 2, "setupcrd");
1085 QETH_DBF_HEX(setup
, 2, &card
, sizeof(void *));
1087 card
->read
.state
= CH_STATE_DOWN
;
1088 card
->write
.state
= CH_STATE_DOWN
;
1089 card
->data
.state
= CH_STATE_DOWN
;
1090 card
->state
= CARD_STATE_DOWN
;
1091 card
->lan_online
= 0;
1092 card
->use_hard_stop
= 0;
1094 #ifdef CONFIG_QETH_VLAN
1095 spin_lock_init(&card
->vlanlock
);
1096 card
->vlangrp
= NULL
;
1098 spin_lock_init(&card
->lock
);
1099 spin_lock_init(&card
->ip_lock
);
1100 spin_lock_init(&card
->thread_mask_lock
);
1101 card
->thread_start_mask
= 0;
1102 card
->thread_allowed_mask
= 0;
1103 card
->thread_running_mask
= 0;
1104 INIT_WORK(&card
->kernel_thread_starter
,
1105 (void *)qeth_start_kernel_thread
,card
);
1106 INIT_LIST_HEAD(&card
->ip_list
);
1107 card
->ip_tbd_list
= kmalloc(sizeof(struct list_head
), GFP_KERNEL
);
1108 if (!card
->ip_tbd_list
) {
1109 QETH_DBF_TEXT(setup
, 0, "iptbdnom");
1112 INIT_LIST_HEAD(card
->ip_tbd_list
);
1113 INIT_LIST_HEAD(&card
->cmd_waiter_list
);
1114 init_waitqueue_head(&card
->wait_q
);
1115 /* intial options */
1116 qeth_set_intial_options(card
);
1117 /* IP address takeover */
1118 INIT_LIST_HEAD(&card
->ipato
.entries
);
1119 card
->ipato
.enabled
= 0;
1120 card
->ipato
.invert4
= 0;
1121 card
->ipato
.invert6
= 0;
1122 /* init QDIO stuff */
1123 qeth_init_qdio_info(card
);
1128 is_1920_device (struct qeth_card
*card
)
1130 int single_queue
= 0;
1131 struct ccw_device
*ccwdev
;
1132 struct channelPath_dsc
{
1143 QETH_DBF_TEXT(setup
, 2, "chk_1920");
1145 ccwdev
= card
->data
.ccwdev
;
1146 chp_dsc
= (struct channelPath_dsc
*)ccw_device_get_chp_desc(ccwdev
, 0);
1147 if (chp_dsc
!= NULL
) {
1148 /* CHPP field bit 6 == 1 -> single queue */
1149 single_queue
= ((chp_dsc
->chpp
& 0x02) == 0x02);
1152 QETH_DBF_TEXT_(setup
, 2, "rc:%x", single_queue
);
1153 return single_queue
;
1157 qeth_determine_card_type(struct qeth_card
*card
)
1161 QETH_DBF_TEXT(setup
, 2, "detcdtyp");
1163 card
->qdio
.do_prio_queueing
= QETH_PRIOQ_DEFAULT
;
1164 card
->qdio
.default_out_queue
= QETH_DEFAULT_QUEUE
;
1165 while (known_devices
[i
][4]) {
1166 if ((CARD_RDEV(card
)->id
.dev_type
== known_devices
[i
][2]) &&
1167 (CARD_RDEV(card
)->id
.dev_model
== known_devices
[i
][3])) {
1168 card
->info
.type
= known_devices
[i
][4];
1169 card
->qdio
.no_out_queues
= known_devices
[i
][8];
1170 card
->info
.is_multicast_different
= known_devices
[i
][9];
1171 if (is_1920_device(card
)) {
1172 PRINT_INFO("Priority Queueing not able "
1173 "due to hardware limitations!\n");
1174 card
->qdio
.no_out_queues
= 1;
1175 card
->qdio
.default_out_queue
= 0;
1181 card
->info
.type
= QETH_CARD_TYPE_UNKNOWN
;
1182 PRINT_ERR("unknown card type on device %s\n", CARD_BUS_ID(card
));
1187 qeth_probe_device(struct ccwgroup_device
*gdev
)
1189 struct qeth_card
*card
;
1191 unsigned long flags
;
1194 QETH_DBF_TEXT(setup
, 2, "probedev");
1197 if (!get_device(dev
))
1200 QETH_DBF_TEXT_(setup
, 2, "%s", gdev
->dev
.bus_id
);
1202 card
= qeth_alloc_card();
1205 QETH_DBF_TEXT_(setup
, 2, "1err%d", -ENOMEM
);
1208 card
->read
.ccwdev
= gdev
->cdev
[0];
1209 card
->write
.ccwdev
= gdev
->cdev
[1];
1210 card
->data
.ccwdev
= gdev
->cdev
[2];
1211 gdev
->dev
.driver_data
= card
;
1213 gdev
->cdev
[0]->handler
= qeth_irq
;
1214 gdev
->cdev
[1]->handler
= qeth_irq
;
1215 gdev
->cdev
[2]->handler
= qeth_irq
;
1217 if ((rc
= qeth_determine_card_type(card
))){
1218 PRINT_WARN("%s: not a valid card type\n", __func__
);
1219 QETH_DBF_TEXT_(setup
, 2, "3err%d", rc
);
1221 qeth_free_card(card
);
1224 if ((rc
= qeth_setup_card(card
))){
1225 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
1227 qeth_free_card(card
);
1230 rc
= qeth_create_device_attributes(dev
);
1233 qeth_free_card(card
);
1236 /* insert into our internal list */
1237 write_lock_irqsave(&qeth_card_list
.rwlock
, flags
);
1238 list_add_tail(&card
->list
, &qeth_card_list
.list
);
1239 write_unlock_irqrestore(&qeth_card_list
.rwlock
, flags
);
1245 qeth_get_unitaddr(struct qeth_card
*card
)
1251 QETH_DBF_TEXT(setup
, 2, "getunit");
1252 rc
= read_conf_data(CARD_DDEV(card
), (void **) &prcd
, &length
);
1254 PRINT_ERR("read_conf_data for device %s returned %i\n",
1255 CARD_DDEV_ID(card
), rc
);
1258 card
->info
.chpid
= prcd
[30];
1259 card
->info
.unit_addr2
= prcd
[31];
1260 card
->info
.cula
= prcd
[63];
1261 card
->info
.guestlan
= ((prcd
[0x10] == _ascebc
['V']) &&
1262 (prcd
[0x11] == _ascebc
['M']));
1267 qeth_init_tokens(struct qeth_card
*card
)
1269 card
->token
.issuer_rm_w
= 0x00010103UL
;
1270 card
->token
.cm_filter_w
= 0x00010108UL
;
1271 card
->token
.cm_connection_w
= 0x0001010aUL
;
1272 card
->token
.ulp_filter_w
= 0x0001010bUL
;
1273 card
->token
.ulp_connection_w
= 0x0001010dUL
;
1277 raw_devno_from_bus_id(char *id
)
1279 id
+= (strlen(id
) - 4);
1280 return (__u16
) simple_strtoul(id
, &id
, 16);
1286 qeth_setup_ccw(struct qeth_channel
*channel
,unsigned char *iob
, __u32 len
)
1288 struct qeth_card
*card
;
1290 QETH_DBF_TEXT(trace
, 4, "setupccw");
1291 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1292 if (channel
== &card
->read
)
1293 memcpy(&channel
->ccw
, READ_CCW
, sizeof(struct ccw1
));
1295 memcpy(&channel
->ccw
, WRITE_CCW
, sizeof(struct ccw1
));
1296 channel
->ccw
.count
= len
;
1297 channel
->ccw
.cda
= (__u32
) __pa(iob
);
1301 * get free buffer for ccws (IDX activation, lancmds,ipassists...)
1303 static struct qeth_cmd_buffer
*
1304 __qeth_get_buffer(struct qeth_channel
*channel
)
1308 QETH_DBF_TEXT(trace
, 6, "getbuff");
1309 index
= channel
->io_buf_no
;
1311 if (channel
->iob
[index
].state
== BUF_STATE_FREE
) {
1312 channel
->iob
[index
].state
= BUF_STATE_LOCKED
;
1313 channel
->io_buf_no
= (channel
->io_buf_no
+ 1) %
1315 memset(channel
->iob
[index
].data
, 0, QETH_BUFSIZE
);
1316 return channel
->iob
+ index
;
1318 index
= (index
+ 1) % QETH_CMD_BUFFER_NO
;
1319 } while(index
!= channel
->io_buf_no
);
1325 * release command buffer
1328 qeth_release_buffer(struct qeth_channel
*channel
, struct qeth_cmd_buffer
*iob
)
1330 unsigned long flags
;
1332 QETH_DBF_TEXT(trace
, 6, "relbuff");
1333 spin_lock_irqsave(&channel
->iob_lock
, flags
);
1334 memset(iob
->data
, 0, QETH_BUFSIZE
);
1335 iob
->state
= BUF_STATE_FREE
;
1336 iob
->callback
= qeth_send_control_data_cb
;
1338 spin_unlock_irqrestore(&channel
->iob_lock
, flags
);
1341 static struct qeth_cmd_buffer
*
1342 qeth_get_buffer(struct qeth_channel
*channel
)
1344 struct qeth_cmd_buffer
*buffer
= NULL
;
1345 unsigned long flags
;
1347 spin_lock_irqsave(&channel
->iob_lock
, flags
);
1348 buffer
= __qeth_get_buffer(channel
);
1349 spin_unlock_irqrestore(&channel
->iob_lock
, flags
);
1353 static struct qeth_cmd_buffer
*
1354 qeth_wait_for_buffer(struct qeth_channel
*channel
)
1356 struct qeth_cmd_buffer
*buffer
;
1357 wait_event(channel
->wait_q
,
1358 ((buffer
= qeth_get_buffer(channel
)) != NULL
));
1363 qeth_clear_cmd_buffers(struct qeth_channel
*channel
)
1367 for (cnt
=0; cnt
< QETH_CMD_BUFFER_NO
; cnt
++)
1368 qeth_release_buffer(channel
,&channel
->iob
[cnt
]);
1369 channel
->buf_no
= 0;
1370 channel
->io_buf_no
= 0;
1374 * start IDX for read and write channel
1377 qeth_idx_activate_get_answer(struct qeth_channel
*channel
,
1378 void (*idx_reply_cb
)(struct qeth_channel
*,
1379 struct qeth_cmd_buffer
*))
1381 struct qeth_cmd_buffer
*iob
;
1382 unsigned long flags
;
1384 struct qeth_card
*card
;
1386 QETH_DBF_TEXT(setup
, 2, "idxanswr");
1387 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1388 iob
= qeth_get_buffer(channel
);
1389 iob
->callback
= idx_reply_cb
;
1390 memcpy(&channel
->ccw
, READ_CCW
, sizeof(struct ccw1
));
1391 channel
->ccw
.count
= QETH_BUFSIZE
;
1392 channel
->ccw
.cda
= (__u32
) __pa(iob
->data
);
1394 wait_event(card
->wait_q
,
1395 atomic_cmpxchg(&channel
->irq_pending
, 0, 1) == 0);
1396 QETH_DBF_TEXT(setup
, 6, "noirqpnd");
1397 spin_lock_irqsave(get_ccwdev_lock(channel
->ccwdev
), flags
);
1398 rc
= ccw_device_start(channel
->ccwdev
,
1399 &channel
->ccw
,(addr_t
) iob
, 0, 0);
1400 spin_unlock_irqrestore(get_ccwdev_lock(channel
->ccwdev
), flags
);
1403 PRINT_ERR("qeth: Error2 in activating channel rc=%d\n",rc
);
1404 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
1405 atomic_set(&channel
->irq_pending
, 0);
1406 wake_up(&card
->wait_q
);
1409 rc
= wait_event_interruptible_timeout(card
->wait_q
,
1410 channel
->state
== CH_STATE_UP
, QETH_TIMEOUT
);
1411 if (rc
== -ERESTARTSYS
)
1413 if (channel
->state
!= CH_STATE_UP
){
1415 QETH_DBF_TEXT_(setup
, 2, "3err%d", rc
);
1416 qeth_clear_cmd_buffers(channel
);
1423 qeth_idx_activate_channel(struct qeth_channel
*channel
,
1424 void (*idx_reply_cb
)(struct qeth_channel
*,
1425 struct qeth_cmd_buffer
*))
1427 struct qeth_card
*card
;
1428 struct qeth_cmd_buffer
*iob
;
1429 unsigned long flags
;
1433 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1435 QETH_DBF_TEXT(setup
, 2, "idxactch");
1437 iob
= qeth_get_buffer(channel
);
1438 iob
->callback
= idx_reply_cb
;
1439 memcpy(&channel
->ccw
, WRITE_CCW
, sizeof(struct ccw1
));
1440 channel
->ccw
.count
= IDX_ACTIVATE_SIZE
;
1441 channel
->ccw
.cda
= (__u32
) __pa(iob
->data
);
1442 if (channel
== &card
->write
) {
1443 memcpy(iob
->data
, IDX_ACTIVATE_WRITE
, IDX_ACTIVATE_SIZE
);
1444 memcpy(QETH_TRANSPORT_HEADER_SEQ_NO(iob
->data
),
1445 &card
->seqno
.trans_hdr
, QETH_SEQ_NO_LENGTH
);
1446 card
->seqno
.trans_hdr
++;
1448 memcpy(iob
->data
, IDX_ACTIVATE_READ
, IDX_ACTIVATE_SIZE
);
1449 memcpy(QETH_TRANSPORT_HEADER_SEQ_NO(iob
->data
),
1450 &card
->seqno
.trans_hdr
, QETH_SEQ_NO_LENGTH
);
1452 memcpy(QETH_IDX_ACT_ISSUER_RM_TOKEN(iob
->data
),
1453 &card
->token
.issuer_rm_w
,QETH_MPC_TOKEN_LENGTH
);
1454 memcpy(QETH_IDX_ACT_FUNC_LEVEL(iob
->data
),
1455 &card
->info
.func_level
,sizeof(__u16
));
1456 temp
= raw_devno_from_bus_id(CARD_DDEV_ID(card
));
1457 memcpy(QETH_IDX_ACT_QDIO_DEV_CUA(iob
->data
), &temp
, 2);
1458 temp
= (card
->info
.cula
<< 8) + card
->info
.unit_addr2
;
1459 memcpy(QETH_IDX_ACT_QDIO_DEV_REALADDR(iob
->data
), &temp
, 2);
1461 wait_event(card
->wait_q
,
1462 atomic_cmpxchg(&channel
->irq_pending
, 0, 1) == 0);
1463 QETH_DBF_TEXT(setup
, 6, "noirqpnd");
1464 spin_lock_irqsave(get_ccwdev_lock(channel
->ccwdev
), flags
);
1465 rc
= ccw_device_start(channel
->ccwdev
,
1466 &channel
->ccw
,(addr_t
) iob
, 0, 0);
1467 spin_unlock_irqrestore(get_ccwdev_lock(channel
->ccwdev
), flags
);
1470 PRINT_ERR("qeth: Error1 in activating channel. rc=%d\n",rc
);
1471 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
1472 atomic_set(&channel
->irq_pending
, 0);
1473 wake_up(&card
->wait_q
);
1476 rc
= wait_event_interruptible_timeout(card
->wait_q
,
1477 channel
->state
== CH_STATE_ACTIVATING
, QETH_TIMEOUT
);
1478 if (rc
== -ERESTARTSYS
)
1480 if (channel
->state
!= CH_STATE_ACTIVATING
) {
1481 PRINT_WARN("qeth: IDX activate timed out!\n");
1482 QETH_DBF_TEXT_(setup
, 2, "2err%d", -ETIME
);
1483 qeth_clear_cmd_buffers(channel
);
1486 return qeth_idx_activate_get_answer(channel
,idx_reply_cb
);
1490 qeth_peer_func_level(int level
)
1492 if ((level
& 0xff) == 8)
1493 return (level
& 0xff) + 0x400;
1494 if (((level
>> 8) & 3) == 1)
1495 return (level
& 0xff) + 0x200;
1500 qeth_idx_write_cb(struct qeth_channel
*channel
, struct qeth_cmd_buffer
*iob
)
1502 struct qeth_card
*card
;
1505 QETH_DBF_TEXT(setup
,2, "idxwrcb");
1507 if (channel
->state
== CH_STATE_DOWN
) {
1508 channel
->state
= CH_STATE_ACTIVATING
;
1511 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1513 if (!(QETH_IS_IDX_ACT_POS_REPLY(iob
->data
))) {
1514 PRINT_ERR("IDX_ACTIVATE on write channel device %s: negative "
1515 "reply\n", CARD_WDEV_ID(card
));
1518 memcpy(&temp
, QETH_IDX_ACT_FUNC_LEVEL(iob
->data
), 2);
1519 if ((temp
& ~0x0100) != qeth_peer_func_level(card
->info
.func_level
)) {
1520 PRINT_WARN("IDX_ACTIVATE on write channel device %s: "
1521 "function level mismatch "
1522 "(sent: 0x%x, received: 0x%x)\n",
1523 CARD_WDEV_ID(card
), card
->info
.func_level
, temp
);
1526 channel
->state
= CH_STATE_UP
;
1528 qeth_release_buffer(channel
, iob
);
1532 qeth_check_idx_response(unsigned char *buffer
)
1537 QETH_DBF_HEX(control
, 2, buffer
, QETH_DBF_CONTROL_LEN
);
1538 if ((buffer
[2] & 0xc0) == 0xc0) {
1539 PRINT_WARN("received an IDX TERMINATE "
1540 "with cause code 0x%02x%s\n",
1542 ((buffer
[4] == 0x22) ?
1543 " -- try another portname" : ""));
1544 QETH_DBF_TEXT(trace
, 2, "ckidxres");
1545 QETH_DBF_TEXT(trace
, 2, " idxterm");
1546 QETH_DBF_TEXT_(trace
, 2, " rc%d", -EIO
);
1553 qeth_idx_read_cb(struct qeth_channel
*channel
, struct qeth_cmd_buffer
*iob
)
1555 struct qeth_card
*card
;
1558 QETH_DBF_TEXT(setup
, 2, "idxrdcb");
1559 if (channel
->state
== CH_STATE_DOWN
) {
1560 channel
->state
= CH_STATE_ACTIVATING
;
1564 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1565 if (qeth_check_idx_response(iob
->data
)) {
1568 if (!(QETH_IS_IDX_ACT_POS_REPLY(iob
->data
))) {
1569 PRINT_ERR("IDX_ACTIVATE on read channel device %s: negative "
1570 "reply\n", CARD_RDEV_ID(card
));
1575 * temporary fix for microcode bug
1576 * to revert it,replace OR by AND
1578 if ( (!QETH_IDX_NO_PORTNAME_REQUIRED(iob
->data
)) ||
1579 (card
->info
.type
== QETH_CARD_TYPE_OSAE
) )
1580 card
->info
.portname_required
= 1;
1582 memcpy(&temp
, QETH_IDX_ACT_FUNC_LEVEL(iob
->data
), 2);
1583 if (temp
!= qeth_peer_func_level(card
->info
.func_level
)) {
1584 PRINT_WARN("IDX_ACTIVATE on read channel device %s: function "
1585 "level mismatch (sent: 0x%x, received: 0x%x)\n",
1586 CARD_RDEV_ID(card
), card
->info
.func_level
, temp
);
1589 memcpy(&card
->token
.issuer_rm_r
,
1590 QETH_IDX_ACT_ISSUER_RM_TOKEN(iob
->data
),
1591 QETH_MPC_TOKEN_LENGTH
);
1592 memcpy(&card
->info
.mcl_level
[0],
1593 QETH_IDX_REPLY_LEVEL(iob
->data
), QETH_MCL_LENGTH
);
1594 channel
->state
= CH_STATE_UP
;
1596 qeth_release_buffer(channel
,iob
);
1600 qeth_issue_next_read(struct qeth_card
*card
)
1603 struct qeth_cmd_buffer
*iob
;
1605 QETH_DBF_TEXT(trace
,5,"issnxrd");
1606 if (card
->read
.state
!= CH_STATE_UP
)
1608 iob
= qeth_get_buffer(&card
->read
);
1610 PRINT_WARN("issue_next_read failed: no iob available!\n");
1613 qeth_setup_ccw(&card
->read
, iob
->data
, QETH_BUFSIZE
);
1614 wait_event(card
->wait_q
,
1615 atomic_cmpxchg(&card
->read
.irq_pending
, 0, 1) == 0);
1616 QETH_DBF_TEXT(trace
, 6, "noirqpnd");
1617 rc
= ccw_device_start(card
->read
.ccwdev
, &card
->read
.ccw
,
1618 (addr_t
) iob
, 0, 0);
1620 PRINT_ERR("Error in starting next read ccw! rc=%i\n", rc
);
1621 atomic_set(&card
->read
.irq_pending
, 0);
1622 qeth_schedule_recovery(card
);
1623 wake_up(&card
->wait_q
);
1628 static struct qeth_reply
*
1629 qeth_alloc_reply(struct qeth_card
*card
)
1631 struct qeth_reply
*reply
;
1633 reply
= kzalloc(sizeof(struct qeth_reply
), GFP_ATOMIC
);
1635 atomic_set(&reply
->refcnt
, 1);
1642 qeth_get_reply(struct qeth_reply
*reply
)
1644 WARN_ON(atomic_read(&reply
->refcnt
) <= 0);
1645 atomic_inc(&reply
->refcnt
);
1649 qeth_put_reply(struct qeth_reply
*reply
)
1651 WARN_ON(atomic_read(&reply
->refcnt
) <= 0);
1652 if (atomic_dec_and_test(&reply
->refcnt
))
1657 qeth_cmd_timeout(unsigned long data
)
1659 struct qeth_reply
*reply
, *list_reply
, *r
;
1660 unsigned long flags
;
1662 reply
= (struct qeth_reply
*) data
;
1663 spin_lock_irqsave(&reply
->card
->lock
, flags
);
1664 list_for_each_entry_safe(list_reply
, r
,
1665 &reply
->card
->cmd_waiter_list
, list
) {
1666 if (reply
== list_reply
){
1667 qeth_get_reply(reply
);
1668 list_del_init(&reply
->list
);
1669 spin_unlock_irqrestore(&reply
->card
->lock
, flags
);
1671 reply
->received
= 1;
1672 wake_up(&reply
->wait_q
);
1673 qeth_put_reply(reply
);
1677 spin_unlock_irqrestore(&reply
->card
->lock
, flags
);
1681 static struct qeth_ipa_cmd
*
1682 qeth_check_ipa_data(struct qeth_card
*card
, struct qeth_cmd_buffer
*iob
)
1684 struct qeth_ipa_cmd
*cmd
= NULL
;
1686 QETH_DBF_TEXT(trace
,5,"chkipad");
1687 if (IS_IPA(iob
->data
)){
1688 cmd
= (struct qeth_ipa_cmd
*) PDU_ENCAPSULATION(iob
->data
);
1689 if (IS_IPA_REPLY(cmd
))
1692 switch (cmd
->hdr
.command
) {
1693 case IPA_CMD_STOPLAN
:
1694 PRINT_WARN("Link failure on %s (CHPID 0x%X) - "
1695 "there is a network problem or "
1696 "someone pulled the cable or "
1697 "disabled the port.\n",
1698 QETH_CARD_IFNAME(card
),
1700 card
->lan_online
= 0;
1701 if (card
->dev
&& netif_carrier_ok(card
->dev
))
1702 netif_carrier_off(card
->dev
);
1704 case IPA_CMD_STARTLAN
:
1705 PRINT_INFO("Link reestablished on %s "
1706 "(CHPID 0x%X). Scheduling "
1707 "IP address reset.\n",
1708 QETH_CARD_IFNAME(card
),
1710 qeth_schedule_recovery(card
);
1712 case IPA_CMD_MODCCID
:
1714 case IPA_CMD_REGISTER_LOCAL_ADDR
:
1715 QETH_DBF_TEXT(trace
,3, "irla");
1717 case IPA_CMD_UNREGISTER_LOCAL_ADDR
:
1718 QETH_DBF_TEXT(trace
,3, "urla");
1721 PRINT_WARN("Received data is IPA "
1722 "but not a reply!\n");
1731 * wake all waiting ipa commands
1734 qeth_clear_ipacmd_list(struct qeth_card
*card
)
1736 struct qeth_reply
*reply
, *r
;
1737 unsigned long flags
;
1739 QETH_DBF_TEXT(trace
, 4, "clipalst");
1741 spin_lock_irqsave(&card
->lock
, flags
);
1742 list_for_each_entry_safe(reply
, r
, &card
->cmd_waiter_list
, list
) {
1743 qeth_get_reply(reply
);
1745 reply
->received
= 1;
1746 list_del_init(&reply
->list
);
1747 wake_up(&reply
->wait_q
);
1748 qeth_put_reply(reply
);
1750 spin_unlock_irqrestore(&card
->lock
, flags
);
1754 qeth_send_control_data_cb(struct qeth_channel
*channel
,
1755 struct qeth_cmd_buffer
*iob
)
1757 struct qeth_card
*card
;
1758 struct qeth_reply
*reply
, *r
;
1759 struct qeth_ipa_cmd
*cmd
;
1760 unsigned long flags
;
1763 QETH_DBF_TEXT(trace
,4,"sndctlcb");
1765 card
= CARD_FROM_CDEV(channel
->ccwdev
);
1766 if (qeth_check_idx_response(iob
->data
)) {
1767 qeth_clear_ipacmd_list(card
);
1768 qeth_schedule_recovery(card
);
1772 cmd
= qeth_check_ipa_data(card
, iob
);
1773 if ((cmd
== NULL
) && (card
->state
!= CARD_STATE_DOWN
))
1775 /*in case of OSN : check if cmd is set */
1776 if (card
->info
.type
== QETH_CARD_TYPE_OSN
&&
1778 cmd
->hdr
.command
!= IPA_CMD_STARTLAN
&&
1779 card
->osn_info
.assist_cb
!= NULL
) {
1780 card
->osn_info
.assist_cb(card
->dev
, cmd
);
1784 spin_lock_irqsave(&card
->lock
, flags
);
1785 list_for_each_entry_safe(reply
, r
, &card
->cmd_waiter_list
, list
) {
1786 if ((reply
->seqno
== QETH_IDX_COMMAND_SEQNO
) ||
1787 ((cmd
) && (reply
->seqno
== cmd
->hdr
.seqno
))) {
1788 qeth_get_reply(reply
);
1789 list_del_init(&reply
->list
);
1790 spin_unlock_irqrestore(&card
->lock
, flags
);
1792 if (reply
->callback
!= NULL
) {
1794 reply
->offset
= (__u16
)((char*)cmd
-
1796 keep_reply
= reply
->callback(card
,
1798 (unsigned long)cmd
);
1800 keep_reply
= reply
->callback(card
,
1802 (unsigned long)iob
);
1805 reply
->rc
= (u16
) cmd
->hdr
.return_code
;
1807 reply
->rc
= iob
->rc
;
1809 spin_lock_irqsave(&card
->lock
, flags
);
1810 list_add_tail(&reply
->list
,
1811 &card
->cmd_waiter_list
);
1812 spin_unlock_irqrestore(&card
->lock
, flags
);
1814 reply
->received
= 1;
1815 wake_up(&reply
->wait_q
);
1817 qeth_put_reply(reply
);
1821 spin_unlock_irqrestore(&card
->lock
, flags
);
1823 memcpy(&card
->seqno
.pdu_hdr_ack
,
1824 QETH_PDU_HEADER_SEQ_NO(iob
->data
),
1825 QETH_SEQ_NO_LENGTH
);
1826 qeth_release_buffer(channel
,iob
);
1830 qeth_prepare_control_data(struct qeth_card
*card
, int len
,
1831 struct qeth_cmd_buffer
*iob
)
1833 qeth_setup_ccw(&card
->write
,iob
->data
,len
);
1834 iob
->callback
= qeth_release_buffer
;
1836 memcpy(QETH_TRANSPORT_HEADER_SEQ_NO(iob
->data
),
1837 &card
->seqno
.trans_hdr
, QETH_SEQ_NO_LENGTH
);
1838 card
->seqno
.trans_hdr
++;
1839 memcpy(QETH_PDU_HEADER_SEQ_NO(iob
->data
),
1840 &card
->seqno
.pdu_hdr
, QETH_SEQ_NO_LENGTH
);
1841 card
->seqno
.pdu_hdr
++;
1842 memcpy(QETH_PDU_HEADER_ACK_SEQ_NO(iob
->data
),
1843 &card
->seqno
.pdu_hdr_ack
, QETH_SEQ_NO_LENGTH
);
1844 QETH_DBF_HEX(control
, 2, iob
->data
, QETH_DBF_CONTROL_LEN
);
1848 qeth_send_control_data(struct qeth_card
*card
, int len
,
1849 struct qeth_cmd_buffer
*iob
,
1851 (struct qeth_card
*, struct qeth_reply
*, unsigned long),
1856 unsigned long flags
;
1857 struct qeth_reply
*reply
= NULL
;
1858 struct timer_list timer
;
1860 QETH_DBF_TEXT(trace
, 2, "sendctl");
1862 reply
= qeth_alloc_reply(card
);
1864 PRINT_WARN("Could no alloc qeth_reply!\n");
1867 reply
->callback
= reply_cb
;
1868 reply
->param
= reply_param
;
1869 if (card
->state
== CARD_STATE_DOWN
)
1870 reply
->seqno
= QETH_IDX_COMMAND_SEQNO
;
1872 reply
->seqno
= card
->seqno
.ipa
++;
1874 timer
.function
= qeth_cmd_timeout
;
1875 timer
.data
= (unsigned long) reply
;
1876 init_waitqueue_head(&reply
->wait_q
);
1877 spin_lock_irqsave(&card
->lock
, flags
);
1878 list_add_tail(&reply
->list
, &card
->cmd_waiter_list
);
1879 spin_unlock_irqrestore(&card
->lock
, flags
);
1880 QETH_DBF_HEX(control
, 2, iob
->data
, QETH_DBF_CONTROL_LEN
);
1881 wait_event(card
->wait_q
,
1882 atomic_cmpxchg(&card
->write
.irq_pending
, 0, 1) == 0);
1883 qeth_prepare_control_data(card
, len
, iob
);
1884 if (IS_IPA(iob
->data
))
1885 timer
.expires
= jiffies
+ QETH_IPA_TIMEOUT
;
1887 timer
.expires
= jiffies
+ QETH_TIMEOUT
;
1888 QETH_DBF_TEXT(trace
, 6, "noirqpnd");
1889 spin_lock_irqsave(get_ccwdev_lock(card
->write
.ccwdev
), flags
);
1890 rc
= ccw_device_start(card
->write
.ccwdev
, &card
->write
.ccw
,
1891 (addr_t
) iob
, 0, 0);
1892 spin_unlock_irqrestore(get_ccwdev_lock(card
->write
.ccwdev
), flags
);
1894 PRINT_WARN("qeth_send_control_data: "
1895 "ccw_device_start rc = %i\n", rc
);
1896 QETH_DBF_TEXT_(trace
, 2, " err%d", rc
);
1897 spin_lock_irqsave(&card
->lock
, flags
);
1898 list_del_init(&reply
->list
);
1899 qeth_put_reply(reply
);
1900 spin_unlock_irqrestore(&card
->lock
, flags
);
1901 qeth_release_buffer(iob
->channel
, iob
);
1902 atomic_set(&card
->write
.irq_pending
, 0);
1903 wake_up(&card
->wait_q
);
1907 wait_event(reply
->wait_q
, reply
->received
);
1908 del_timer_sync(&timer
);
1910 qeth_put_reply(reply
);
1915 qeth_osn_send_control_data(struct qeth_card
*card
, int len
,
1916 struct qeth_cmd_buffer
*iob
)
1918 unsigned long flags
;
1921 QETH_DBF_TEXT(trace
, 5, "osndctrd");
1923 wait_event(card
->wait_q
,
1924 atomic_cmpxchg(&card
->write
.irq_pending
, 0, 1) == 0);
1925 qeth_prepare_control_data(card
, len
, iob
);
1926 QETH_DBF_TEXT(trace
, 6, "osnoirqp");
1927 spin_lock_irqsave(get_ccwdev_lock(card
->write
.ccwdev
), flags
);
1928 rc
= ccw_device_start(card
->write
.ccwdev
, &card
->write
.ccw
,
1929 (addr_t
) iob
, 0, 0);
1930 spin_unlock_irqrestore(get_ccwdev_lock(card
->write
.ccwdev
), flags
);
1932 PRINT_WARN("qeth_osn_send_control_data: "
1933 "ccw_device_start rc = %i\n", rc
);
1934 QETH_DBF_TEXT_(trace
, 2, " err%d", rc
);
1935 qeth_release_buffer(iob
->channel
, iob
);
1936 atomic_set(&card
->write
.irq_pending
, 0);
1937 wake_up(&card
->wait_q
);
1943 qeth_prepare_ipa_cmd(struct qeth_card
*card
, struct qeth_cmd_buffer
*iob
,
1946 memcpy(iob
->data
, IPA_PDU_HEADER
, IPA_PDU_HEADER_SIZE
);
1947 memcpy(QETH_IPA_CMD_PROT_TYPE(iob
->data
),&prot_type
,1);
1948 memcpy(QETH_IPA_CMD_DEST_ADDR(iob
->data
),
1949 &card
->token
.ulp_connection_r
, QETH_MPC_TOKEN_LENGTH
);
1953 qeth_osn_send_ipa_cmd(struct qeth_card
*card
, struct qeth_cmd_buffer
*iob
,
1958 QETH_DBF_TEXT(trace
,4,"osndipa");
1960 qeth_prepare_ipa_cmd(card
, iob
, QETH_PROT_OSN2
);
1961 s1
= (u16
)(IPA_PDU_HEADER_SIZE
+ data_len
);
1963 memcpy(QETH_IPA_PDU_LEN_TOTAL(iob
->data
), &s1
, 2);
1964 memcpy(QETH_IPA_PDU_LEN_PDU1(iob
->data
), &s2
, 2);
1965 memcpy(QETH_IPA_PDU_LEN_PDU2(iob
->data
), &s2
, 2);
1966 memcpy(QETH_IPA_PDU_LEN_PDU3(iob
->data
), &s2
, 2);
1967 return qeth_osn_send_control_data(card
, s1
, iob
);
1971 qeth_send_ipa_cmd(struct qeth_card
*card
, struct qeth_cmd_buffer
*iob
,
1973 (struct qeth_card
*,struct qeth_reply
*, unsigned long),
1979 QETH_DBF_TEXT(trace
,4,"sendipa");
1981 if (card
->options
.layer2
)
1982 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
1983 prot_type
= QETH_PROT_OSN2
;
1985 prot_type
= QETH_PROT_LAYER2
;
1987 prot_type
= QETH_PROT_TCPIP
;
1988 qeth_prepare_ipa_cmd(card
,iob
,prot_type
);
1989 rc
= qeth_send_control_data(card
, IPA_CMD_LENGTH
, iob
,
1990 reply_cb
, reply_param
);
1996 qeth_cm_enable_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
1999 struct qeth_cmd_buffer
*iob
;
2001 QETH_DBF_TEXT(setup
, 2, "cmenblcb");
2003 iob
= (struct qeth_cmd_buffer
*) data
;
2004 memcpy(&card
->token
.cm_filter_r
,
2005 QETH_CM_ENABLE_RESP_FILTER_TOKEN(iob
->data
),
2006 QETH_MPC_TOKEN_LENGTH
);
2007 QETH_DBF_TEXT_(setup
, 2, " rc%d", iob
->rc
);
2012 qeth_cm_enable(struct qeth_card
*card
)
2015 struct qeth_cmd_buffer
*iob
;
2017 QETH_DBF_TEXT(setup
,2,"cmenable");
2019 iob
= qeth_wait_for_buffer(&card
->write
);
2020 memcpy(iob
->data
, CM_ENABLE
, CM_ENABLE_SIZE
);
2021 memcpy(QETH_CM_ENABLE_ISSUER_RM_TOKEN(iob
->data
),
2022 &card
->token
.issuer_rm_r
, QETH_MPC_TOKEN_LENGTH
);
2023 memcpy(QETH_CM_ENABLE_FILTER_TOKEN(iob
->data
),
2024 &card
->token
.cm_filter_w
, QETH_MPC_TOKEN_LENGTH
);
2026 rc
= qeth_send_control_data(card
, CM_ENABLE_SIZE
, iob
,
2027 qeth_cm_enable_cb
, NULL
);
2032 qeth_cm_setup_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
2036 struct qeth_cmd_buffer
*iob
;
2038 QETH_DBF_TEXT(setup
, 2, "cmsetpcb");
2040 iob
= (struct qeth_cmd_buffer
*) data
;
2041 memcpy(&card
->token
.cm_connection_r
,
2042 QETH_CM_SETUP_RESP_DEST_ADDR(iob
->data
),
2043 QETH_MPC_TOKEN_LENGTH
);
2044 QETH_DBF_TEXT_(setup
, 2, " rc%d", iob
->rc
);
2049 qeth_cm_setup(struct qeth_card
*card
)
2052 struct qeth_cmd_buffer
*iob
;
2054 QETH_DBF_TEXT(setup
,2,"cmsetup");
2056 iob
= qeth_wait_for_buffer(&card
->write
);
2057 memcpy(iob
->data
, CM_SETUP
, CM_SETUP_SIZE
);
2058 memcpy(QETH_CM_SETUP_DEST_ADDR(iob
->data
),
2059 &card
->token
.issuer_rm_r
, QETH_MPC_TOKEN_LENGTH
);
2060 memcpy(QETH_CM_SETUP_CONNECTION_TOKEN(iob
->data
),
2061 &card
->token
.cm_connection_w
, QETH_MPC_TOKEN_LENGTH
);
2062 memcpy(QETH_CM_SETUP_FILTER_TOKEN(iob
->data
),
2063 &card
->token
.cm_filter_r
, QETH_MPC_TOKEN_LENGTH
);
2064 rc
= qeth_send_control_data(card
, CM_SETUP_SIZE
, iob
,
2065 qeth_cm_setup_cb
, NULL
);
2071 qeth_ulp_enable_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
2075 __u16 mtu
, framesize
;
2078 struct qeth_cmd_buffer
*iob
;
2080 QETH_DBF_TEXT(setup
, 2, "ulpenacb");
2082 iob
= (struct qeth_cmd_buffer
*) data
;
2083 memcpy(&card
->token
.ulp_filter_r
,
2084 QETH_ULP_ENABLE_RESP_FILTER_TOKEN(iob
->data
),
2085 QETH_MPC_TOKEN_LENGTH
);
2086 if (qeth_get_mtu_out_of_mpc(card
->info
.type
)) {
2087 memcpy(&framesize
, QETH_ULP_ENABLE_RESP_MAX_MTU(iob
->data
), 2);
2088 mtu
= qeth_get_mtu_outof_framesize(framesize
);
2091 QETH_DBF_TEXT_(setup
, 2, " rc%d", iob
->rc
);
2094 card
->info
.max_mtu
= mtu
;
2095 card
->info
.initial_mtu
= mtu
;
2096 card
->qdio
.in_buf_size
= mtu
+ 2 * PAGE_SIZE
;
2098 card
->info
.initial_mtu
= qeth_get_initial_mtu_for_card(card
);
2099 card
->info
.max_mtu
= qeth_get_max_mtu_for_card(card
->info
.type
);
2100 card
->qdio
.in_buf_size
= QETH_IN_BUF_SIZE_DEFAULT
;
2103 memcpy(&len
, QETH_ULP_ENABLE_RESP_DIFINFO_LEN(iob
->data
), 2);
2104 if (len
>= QETH_MPC_DIFINFO_LEN_INDICATES_LINK_TYPE
) {
2106 QETH_ULP_ENABLE_RESP_LINK_TYPE(iob
->data
), 1);
2107 card
->info
.link_type
= link_type
;
2109 card
->info
.link_type
= 0;
2110 QETH_DBF_TEXT_(setup
, 2, " rc%d", iob
->rc
);
2115 qeth_ulp_enable(struct qeth_card
*card
)
2119 struct qeth_cmd_buffer
*iob
;
2121 /*FIXME: trace view callbacks*/
2122 QETH_DBF_TEXT(setup
,2,"ulpenabl");
2124 iob
= qeth_wait_for_buffer(&card
->write
);
2125 memcpy(iob
->data
, ULP_ENABLE
, ULP_ENABLE_SIZE
);
2127 *(QETH_ULP_ENABLE_LINKNUM(iob
->data
)) =
2128 (__u8
) card
->info
.portno
;
2129 if (card
->options
.layer2
)
2130 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
2131 prot_type
= QETH_PROT_OSN2
;
2133 prot_type
= QETH_PROT_LAYER2
;
2135 prot_type
= QETH_PROT_TCPIP
;
2137 memcpy(QETH_ULP_ENABLE_PROT_TYPE(iob
->data
),&prot_type
,1);
2138 memcpy(QETH_ULP_ENABLE_DEST_ADDR(iob
->data
),
2139 &card
->token
.cm_connection_r
, QETH_MPC_TOKEN_LENGTH
);
2140 memcpy(QETH_ULP_ENABLE_FILTER_TOKEN(iob
->data
),
2141 &card
->token
.ulp_filter_w
, QETH_MPC_TOKEN_LENGTH
);
2142 memcpy(QETH_ULP_ENABLE_PORTNAME_AND_LL(iob
->data
),
2143 card
->info
.portname
, 9);
2144 rc
= qeth_send_control_data(card
, ULP_ENABLE_SIZE
, iob
,
2145 qeth_ulp_enable_cb
, NULL
);
2151 __raw_devno_from_bus_id(char *id
)
2153 id
+= (strlen(id
) - 4);
2154 return (__u16
) simple_strtoul(id
, &id
, 16);
2158 qeth_ulp_setup_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
2161 struct qeth_cmd_buffer
*iob
;
2163 QETH_DBF_TEXT(setup
, 2, "ulpstpcb");
2165 iob
= (struct qeth_cmd_buffer
*) data
;
2166 memcpy(&card
->token
.ulp_connection_r
,
2167 QETH_ULP_SETUP_RESP_CONNECTION_TOKEN(iob
->data
),
2168 QETH_MPC_TOKEN_LENGTH
);
2169 QETH_DBF_TEXT_(setup
, 2, " rc%d", iob
->rc
);
2174 qeth_ulp_setup(struct qeth_card
*card
)
2178 struct qeth_cmd_buffer
*iob
;
2180 QETH_DBF_TEXT(setup
,2,"ulpsetup");
2182 iob
= qeth_wait_for_buffer(&card
->write
);
2183 memcpy(iob
->data
, ULP_SETUP
, ULP_SETUP_SIZE
);
2185 memcpy(QETH_ULP_SETUP_DEST_ADDR(iob
->data
),
2186 &card
->token
.cm_connection_r
, QETH_MPC_TOKEN_LENGTH
);
2187 memcpy(QETH_ULP_SETUP_CONNECTION_TOKEN(iob
->data
),
2188 &card
->token
.ulp_connection_w
, QETH_MPC_TOKEN_LENGTH
);
2189 memcpy(QETH_ULP_SETUP_FILTER_TOKEN(iob
->data
),
2190 &card
->token
.ulp_filter_r
, QETH_MPC_TOKEN_LENGTH
);
2192 temp
= __raw_devno_from_bus_id(CARD_DDEV_ID(card
));
2193 memcpy(QETH_ULP_SETUP_CUA(iob
->data
), &temp
, 2);
2194 temp
= (card
->info
.cula
<< 8) + card
->info
.unit_addr2
;
2195 memcpy(QETH_ULP_SETUP_REAL_DEVADDR(iob
->data
), &temp
, 2);
2196 rc
= qeth_send_control_data(card
, ULP_SETUP_SIZE
, iob
,
2197 qeth_ulp_setup_cb
, NULL
);
2202 qeth_check_qdio_errors(struct qdio_buffer
*buf
, unsigned int qdio_error
,
2203 unsigned int siga_error
, const char *dbftext
)
2205 if (qdio_error
|| siga_error
) {
2206 QETH_DBF_TEXT(trace
, 2, dbftext
);
2207 QETH_DBF_TEXT(qerr
, 2, dbftext
);
2208 QETH_DBF_TEXT_(qerr
, 2, " F15=%02X",
2209 buf
->element
[15].flags
& 0xff);
2210 QETH_DBF_TEXT_(qerr
, 2, " F14=%02X",
2211 buf
->element
[14].flags
& 0xff);
2212 QETH_DBF_TEXT_(qerr
, 2, " qerr=%X", qdio_error
);
2213 QETH_DBF_TEXT_(qerr
, 2, " serr=%X", siga_error
);
2219 static inline struct sk_buff
*
2220 qeth_get_skb(unsigned int length
, struct qeth_hdr
*hdr
)
2222 struct sk_buff
* skb
;
2226 if (hdr
->hdr
.osn
.id
== QETH_HEADER_TYPE_OSN
)
2227 add_len
= sizeof(struct qeth_hdr
);
2228 #ifdef CONFIG_QETH_VLAN
2230 add_len
= VLAN_HLEN
;
2232 skb
= dev_alloc_skb(length
+ add_len
);
2234 skb_reserve(skb
, add_len
);
2238 static inline struct sk_buff
*
2239 qeth_get_next_skb(struct qeth_card
*card
, struct qdio_buffer
*buffer
,
2240 struct qdio_buffer_element
**__element
, int *__offset
,
2241 struct qeth_hdr
**hdr
)
2243 struct qdio_buffer_element
*element
= *__element
;
2244 int offset
= *__offset
;
2245 struct sk_buff
*skb
= NULL
;
2250 QETH_DBF_TEXT(trace
,6,"nextskb");
2251 /* qeth_hdr must not cross element boundaries */
2252 if (element
->length
< offset
+ sizeof(struct qeth_hdr
)){
2253 if (qeth_is_last_sbale(element
))
2257 if (element
->length
< sizeof(struct qeth_hdr
))
2260 *hdr
= element
->addr
+ offset
;
2262 offset
+= sizeof(struct qeth_hdr
);
2263 if (card
->options
.layer2
)
2264 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
2265 skb_len
= (*hdr
)->hdr
.osn
.pdu_length
;
2267 skb_len
= (*hdr
)->hdr
.l2
.pkt_length
;
2269 skb_len
= (*hdr
)->hdr
.l3
.length
;
2273 if (card
->options
.fake_ll
){
2274 if(card
->dev
->type
== ARPHRD_IEEE802_TR
){
2275 if (!(skb
= qeth_get_skb(skb_len
+QETH_FAKE_LL_LEN_TR
, *hdr
)))
2277 skb_reserve(skb
,QETH_FAKE_LL_LEN_TR
);
2279 if (!(skb
= qeth_get_skb(skb_len
+QETH_FAKE_LL_LEN_ETH
, *hdr
)))
2281 skb_reserve(skb
,QETH_FAKE_LL_LEN_ETH
);
2283 } else if (!(skb
= qeth_get_skb(skb_len
, *hdr
)))
2285 data_ptr
= element
->addr
+ offset
;
2287 data_len
= min(skb_len
, (int)(element
->length
- offset
));
2289 memcpy(skb_put(skb
, data_len
), data_ptr
, data_len
);
2290 skb_len
-= data_len
;
2292 if (qeth_is_last_sbale(element
)){
2293 QETH_DBF_TEXT(trace
,4,"unexeob");
2294 QETH_DBF_TEXT_(trace
,4,"%s",CARD_BUS_ID(card
));
2295 QETH_DBF_TEXT(qerr
,2,"unexeob");
2296 QETH_DBF_TEXT_(qerr
,2,"%s",CARD_BUS_ID(card
));
2297 QETH_DBF_HEX(misc
,4,buffer
,sizeof(*buffer
));
2298 dev_kfree_skb_any(skb
);
2299 card
->stats
.rx_errors
++;
2304 data_ptr
= element
->addr
;
2309 *__element
= element
;
2313 if (net_ratelimit()){
2314 PRINT_WARN("No memory for packet received on %s.\n",
2315 QETH_CARD_IFNAME(card
));
2316 QETH_DBF_TEXT(trace
,2,"noskbmem");
2317 QETH_DBF_TEXT_(trace
,2,"%s",CARD_BUS_ID(card
));
2319 card
->stats
.rx_dropped
++;
2323 static inline __be16
2324 qeth_type_trans(struct sk_buff
*skb
, struct net_device
*dev
)
2326 struct qeth_card
*card
;
2329 QETH_DBF_TEXT(trace
,6,"typtrans");
2331 card
= (struct qeth_card
*)dev
->priv
;
2333 if ((card
->info
.link_type
== QETH_LINK_TYPE_HSTR
) ||
2334 (card
->info
.link_type
== QETH_LINK_TYPE_LANE_TR
))
2335 return tr_type_trans(skb
,dev
);
2336 #endif /* CONFIG_TR */
2337 skb
->mac
.raw
= skb
->data
;
2338 skb_pull(skb
, ETH_HLEN
);
2341 if (*eth
->h_dest
& 1) {
2342 if (memcmp(eth
->h_dest
, dev
->broadcast
, ETH_ALEN
) == 0)
2343 skb
->pkt_type
= PACKET_BROADCAST
;
2345 skb
->pkt_type
= PACKET_MULTICAST
;
2346 } else if (memcmp(eth
->h_dest
, dev
->dev_addr
, ETH_ALEN
))
2347 skb
->pkt_type
= PACKET_OTHERHOST
;
2349 if (ntohs(eth
->h_proto
) >= 1536)
2350 return eth
->h_proto
;
2351 if (*(unsigned short *) (skb
->data
) == 0xFFFF)
2352 return htons(ETH_P_802_3
);
2353 return htons(ETH_P_802_2
);
2357 qeth_rebuild_skb_fake_ll_tr(struct qeth_card
*card
, struct sk_buff
*skb
,
2358 struct qeth_hdr
*hdr
)
2360 struct trh_hdr
*fake_hdr
;
2361 struct trllc
*fake_llc
;
2362 struct iphdr
*ip_hdr
;
2364 QETH_DBF_TEXT(trace
,5,"skbfktr");
2365 skb
->mac
.raw
= skb
->data
- QETH_FAKE_LL_LEN_TR
;
2366 /* this is a fake ethernet header */
2367 fake_hdr
= (struct trh_hdr
*) skb
->mac
.raw
;
2369 /* the destination MAC address */
2370 switch (skb
->pkt_type
){
2371 case PACKET_MULTICAST
:
2372 switch (skb
->protocol
){
2373 #ifdef CONFIG_QETH_IPV6
2374 case __constant_htons(ETH_P_IPV6
):
2375 ndisc_mc_map((struct in6_addr
*)
2376 skb
->data
+ QETH_FAKE_LL_V6_ADDR_POS
,
2377 fake_hdr
->daddr
, card
->dev
, 0);
2379 #endif /* CONFIG_QETH_IPV6 */
2380 case __constant_htons(ETH_P_IP
):
2381 ip_hdr
= (struct iphdr
*)skb
->data
;
2382 ip_tr_mc_map(ip_hdr
->daddr
, fake_hdr
->daddr
);
2385 memcpy(fake_hdr
->daddr
, card
->dev
->dev_addr
, TR_ALEN
);
2388 case PACKET_BROADCAST
:
2389 memset(fake_hdr
->daddr
, 0xff, TR_ALEN
);
2392 memcpy(fake_hdr
->daddr
, card
->dev
->dev_addr
, TR_ALEN
);
2394 /* the source MAC address */
2395 if (hdr
->hdr
.l3
.ext_flags
& QETH_HDR_EXT_SRC_MAC_ADDR
)
2396 memcpy(fake_hdr
->saddr
, &hdr
->hdr
.l3
.dest_addr
[2], TR_ALEN
);
2398 memset(fake_hdr
->saddr
, 0, TR_ALEN
);
2400 fake_llc
= (struct trllc
*)&(fake_hdr
->rcf
);
2401 fake_llc
->dsap
= EXTENDED_SAP
;
2402 fake_llc
->ssap
= EXTENDED_SAP
;
2403 fake_llc
->llc
= UI_CMD
;
2404 fake_llc
->protid
[0] = 0;
2405 fake_llc
->protid
[1] = 0;
2406 fake_llc
->protid
[2] = 0;
2407 fake_llc
->ethertype
= ETH_P_IP
;
2411 qeth_rebuild_skb_fake_ll_eth(struct qeth_card
*card
, struct sk_buff
*skb
,
2412 struct qeth_hdr
*hdr
)
2414 struct ethhdr
*fake_hdr
;
2415 struct iphdr
*ip_hdr
;
2417 QETH_DBF_TEXT(trace
,5,"skbfketh");
2418 skb
->mac
.raw
= skb
->data
- QETH_FAKE_LL_LEN_ETH
;
2419 /* this is a fake ethernet header */
2420 fake_hdr
= (struct ethhdr
*) skb
->mac
.raw
;
2422 /* the destination MAC address */
2423 switch (skb
->pkt_type
){
2424 case PACKET_MULTICAST
:
2425 switch (skb
->protocol
){
2426 #ifdef CONFIG_QETH_IPV6
2427 case __constant_htons(ETH_P_IPV6
):
2428 ndisc_mc_map((struct in6_addr
*)
2429 skb
->data
+ QETH_FAKE_LL_V6_ADDR_POS
,
2430 fake_hdr
->h_dest
, card
->dev
, 0);
2432 #endif /* CONFIG_QETH_IPV6 */
2433 case __constant_htons(ETH_P_IP
):
2434 ip_hdr
= (struct iphdr
*)skb
->data
;
2435 ip_eth_mc_map(ip_hdr
->daddr
, fake_hdr
->h_dest
);
2438 memcpy(fake_hdr
->h_dest
, card
->dev
->dev_addr
, ETH_ALEN
);
2441 case PACKET_BROADCAST
:
2442 memset(fake_hdr
->h_dest
, 0xff, ETH_ALEN
);
2445 memcpy(fake_hdr
->h_dest
, card
->dev
->dev_addr
, ETH_ALEN
);
2447 /* the source MAC address */
2448 if (hdr
->hdr
.l3
.ext_flags
& QETH_HDR_EXT_SRC_MAC_ADDR
)
2449 memcpy(fake_hdr
->h_source
, &hdr
->hdr
.l3
.dest_addr
[2], ETH_ALEN
);
2451 memset(fake_hdr
->h_source
, 0, ETH_ALEN
);
2453 fake_hdr
->h_proto
= skb
->protocol
;
2457 qeth_rebuild_skb_fake_ll(struct qeth_card
*card
, struct sk_buff
*skb
,
2458 struct qeth_hdr
*hdr
)
2460 if (card
->dev
->type
== ARPHRD_IEEE802_TR
)
2461 qeth_rebuild_skb_fake_ll_tr(card
, skb
, hdr
);
2463 qeth_rebuild_skb_fake_ll_eth(card
, skb
, hdr
);
2467 qeth_rebuild_skb_vlan(struct qeth_card
*card
, struct sk_buff
*skb
,
2468 struct qeth_hdr
*hdr
)
2470 #ifdef CONFIG_QETH_VLAN
2473 if (hdr
->hdr
.l3
.ext_flags
&
2474 (QETH_HDR_EXT_VLAN_FRAME
| QETH_HDR_EXT_INCLUDE_VLAN_TAG
)) {
2475 vlan_tag
= (u16
*) skb_push(skb
, VLAN_HLEN
);
2476 *vlan_tag
= (hdr
->hdr
.l3
.ext_flags
& QETH_HDR_EXT_VLAN_FRAME
)?
2477 hdr
->hdr
.l3
.vlan_id
: *((u16
*)&hdr
->hdr
.l3
.dest_addr
[12]);
2478 *(vlan_tag
+ 1) = skb
->protocol
;
2479 skb
->protocol
= __constant_htons(ETH_P_8021Q
);
2481 #endif /* CONFIG_QETH_VLAN */
2485 qeth_layer2_rebuild_skb(struct qeth_card
*card
, struct sk_buff
*skb
,
2486 struct qeth_hdr
*hdr
)
2488 unsigned short vlan_id
= 0;
2489 #ifdef CONFIG_QETH_VLAN
2490 struct vlan_hdr
*vhdr
;
2493 skb
->pkt_type
= PACKET_HOST
;
2494 skb
->protocol
= qeth_type_trans(skb
, skb
->dev
);
2495 if (card
->options
.checksum_type
== NO_CHECKSUMMING
)
2496 skb
->ip_summed
= CHECKSUM_UNNECESSARY
;
2498 skb
->ip_summed
= CHECKSUM_NONE
;
2499 #ifdef CONFIG_QETH_VLAN
2500 if (hdr
->hdr
.l2
.flags
[2] & (QETH_LAYER2_FLAG_VLAN
)) {
2501 vhdr
= (struct vlan_hdr
*) skb
->data
;
2503 __constant_htons(vhdr
->h_vlan_encapsulated_proto
);
2504 vlan_id
= hdr
->hdr
.l2
.vlan_id
;
2505 skb_pull(skb
, VLAN_HLEN
);
2508 *((__u32
*)skb
->cb
) = ++card
->seqno
.pkt_seqno
;
2513 qeth_rebuild_skb(struct qeth_card
*card
, struct sk_buff
*skb
,
2514 struct qeth_hdr
*hdr
)
2516 #ifdef CONFIG_QETH_IPV6
2517 if (hdr
->hdr
.l3
.flags
& QETH_HDR_PASSTHRU
) {
2518 skb
->pkt_type
= PACKET_HOST
;
2519 skb
->protocol
= qeth_type_trans(skb
, card
->dev
);
2522 #endif /* CONFIG_QETH_IPV6 */
2523 skb
->protocol
= htons((hdr
->hdr
.l3
.flags
& QETH_HDR_IPV6
)? ETH_P_IPV6
:
2525 switch (hdr
->hdr
.l3
.flags
& QETH_HDR_CAST_MASK
){
2526 case QETH_CAST_UNICAST
:
2527 skb
->pkt_type
= PACKET_HOST
;
2529 case QETH_CAST_MULTICAST
:
2530 skb
->pkt_type
= PACKET_MULTICAST
;
2531 card
->stats
.multicast
++;
2533 case QETH_CAST_BROADCAST
:
2534 skb
->pkt_type
= PACKET_BROADCAST
;
2535 card
->stats
.multicast
++;
2537 case QETH_CAST_ANYCAST
:
2538 case QETH_CAST_NOCAST
:
2540 skb
->pkt_type
= PACKET_HOST
;
2542 qeth_rebuild_skb_vlan(card
, skb
, hdr
);
2543 if (card
->options
.fake_ll
)
2544 qeth_rebuild_skb_fake_ll(card
, skb
, hdr
);
2546 skb
->mac
.raw
= skb
->data
;
2547 skb
->ip_summed
= card
->options
.checksum_type
;
2548 if (card
->options
.checksum_type
== HW_CHECKSUMMING
){
2549 if ( (hdr
->hdr
.l3
.ext_flags
&
2550 (QETH_HDR_EXT_CSUM_HDR_REQ
|
2551 QETH_HDR_EXT_CSUM_TRANSP_REQ
)) ==
2552 (QETH_HDR_EXT_CSUM_HDR_REQ
|
2553 QETH_HDR_EXT_CSUM_TRANSP_REQ
) )
2554 skb
->ip_summed
= CHECKSUM_UNNECESSARY
;
2556 skb
->ip_summed
= SW_CHECKSUMMING
;
2561 qeth_process_inbound_buffer(struct qeth_card
*card
,
2562 struct qeth_qdio_buffer
*buf
, int index
)
2564 struct qdio_buffer_element
*element
;
2565 struct sk_buff
*skb
;
2566 struct qeth_hdr
*hdr
;
2571 /* get first element of current buffer */
2572 element
= (struct qdio_buffer_element
*)&buf
->buffer
->element
[0];
2574 #ifdef CONFIG_QETH_PERF_STATS
2575 card
->perf_stats
.bufs_rec
++;
2577 while((skb
= qeth_get_next_skb(card
, buf
->buffer
, &element
,
2579 skb
->dev
= card
->dev
;
2580 if (hdr
->hdr
.l2
.id
== QETH_HEADER_TYPE_LAYER2
)
2581 vlan_tag
= qeth_layer2_rebuild_skb(card
, skb
, hdr
);
2582 else if (hdr
->hdr
.l3
.id
== QETH_HEADER_TYPE_LAYER3
)
2583 qeth_rebuild_skb(card
, skb
, hdr
);
2584 else { /*in case of OSN*/
2585 skb_push(skb
, sizeof(struct qeth_hdr
));
2586 memcpy(skb
->data
, hdr
, sizeof(struct qeth_hdr
));
2588 /* is device UP ? */
2589 if (!(card
->dev
->flags
& IFF_UP
)){
2590 dev_kfree_skb_any(skb
);
2593 #ifdef CONFIG_QETH_VLAN
2595 vlan_hwaccel_rx(skb
, card
->vlangrp
, vlan_tag
);
2598 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
2599 rxrc
= card
->osn_info
.data_cb(skb
);
2601 rxrc
= netif_rx(skb
);
2602 card
->dev
->last_rx
= jiffies
;
2603 card
->stats
.rx_packets
++;
2604 card
->stats
.rx_bytes
+= skb
->len
;
2608 static inline struct qeth_buffer_pool_entry
*
2609 qeth_get_buffer_pool_entry(struct qeth_card
*card
)
2611 struct qeth_buffer_pool_entry
*entry
;
2613 QETH_DBF_TEXT(trace
, 6, "gtbfplen");
2614 if (!list_empty(&card
->qdio
.in_buf_pool
.entry_list
)) {
2615 entry
= list_entry(card
->qdio
.in_buf_pool
.entry_list
.next
,
2616 struct qeth_buffer_pool_entry
, list
);
2617 list_del_init(&entry
->list
);
2624 qeth_init_input_buffer(struct qeth_card
*card
, struct qeth_qdio_buffer
*buf
)
2626 struct qeth_buffer_pool_entry
*pool_entry
;
2629 pool_entry
= qeth_get_buffer_pool_entry(card
);
2631 * since the buffer is accessed only from the input_tasklet
2632 * there shouldn't be a need to synchronize; also, since we use
2633 * the QETH_IN_BUF_REQUEUE_THRESHOLD we should never run out off
2636 BUG_ON(!pool_entry
);
2638 buf
->pool_entry
= pool_entry
;
2639 for(i
= 0; i
< QETH_MAX_BUFFER_ELEMENTS(card
); ++i
){
2640 buf
->buffer
->element
[i
].length
= PAGE_SIZE
;
2641 buf
->buffer
->element
[i
].addr
= pool_entry
->elements
[i
];
2642 if (i
== QETH_MAX_BUFFER_ELEMENTS(card
) - 1)
2643 buf
->buffer
->element
[i
].flags
= SBAL_FLAGS_LAST_ENTRY
;
2645 buf
->buffer
->element
[i
].flags
= 0;
2647 buf
->state
= QETH_QDIO_BUF_EMPTY
;
2651 qeth_clear_output_buffer(struct qeth_qdio_out_q
*queue
,
2652 struct qeth_qdio_out_buffer
*buf
)
2655 struct sk_buff
*skb
;
2657 /* is PCI flag set on buffer? */
2658 if (buf
->buffer
->element
[0].flags
& 0x40)
2659 atomic_dec(&queue
->set_pci_flags_count
);
2661 while ((skb
= skb_dequeue(&buf
->skb_list
))){
2662 atomic_dec(&skb
->users
);
2663 dev_kfree_skb_any(skb
);
2665 qeth_eddp_buf_release_contexts(buf
);
2666 for(i
= 0; i
< QETH_MAX_BUFFER_ELEMENTS(queue
->card
); ++i
){
2667 buf
->buffer
->element
[i
].length
= 0;
2668 buf
->buffer
->element
[i
].addr
= NULL
;
2669 buf
->buffer
->element
[i
].flags
= 0;
2671 buf
->next_element_to_fill
= 0;
2672 atomic_set(&buf
->state
, QETH_QDIO_BUF_EMPTY
);
2676 qeth_queue_input_buffer(struct qeth_card
*card
, int index
)
2678 struct qeth_qdio_q
*queue
= card
->qdio
.in_q
;
2683 QETH_DBF_TEXT(trace
,6,"queinbuf");
2684 count
= (index
< queue
->next_buf_to_init
)?
2685 card
->qdio
.in_buf_pool
.buf_count
-
2686 (queue
->next_buf_to_init
- index
) :
2687 card
->qdio
.in_buf_pool
.buf_count
-
2688 (queue
->next_buf_to_init
+ QDIO_MAX_BUFFERS_PER_Q
- index
);
2689 /* only requeue at a certain threshold to avoid SIGAs */
2690 if (count
>= QETH_IN_BUF_REQUEUE_THRESHOLD(card
)){
2691 for (i
= queue
->next_buf_to_init
;
2692 i
< queue
->next_buf_to_init
+ count
; ++i
)
2693 qeth_init_input_buffer(card
,
2694 &queue
->bufs
[i
% QDIO_MAX_BUFFERS_PER_Q
]);
2696 * according to old code it should be avoided to requeue all
2697 * 128 buffers in order to benefit from PCI avoidance.
2698 * this function keeps at least one buffer (the buffer at
2699 * 'index') un-requeued -> this buffer is the first buffer that
2700 * will be requeued the next time
2702 #ifdef CONFIG_QETH_PERF_STATS
2703 card
->perf_stats
.inbound_do_qdio_cnt
++;
2704 card
->perf_stats
.inbound_do_qdio_start_time
= qeth_get_micros();
2706 rc
= do_QDIO(CARD_DDEV(card
),
2707 QDIO_FLAG_SYNC_INPUT
| QDIO_FLAG_UNDER_INTERRUPT
,
2708 0, queue
->next_buf_to_init
, count
, NULL
);
2709 #ifdef CONFIG_QETH_PERF_STATS
2710 card
->perf_stats
.inbound_do_qdio_time
+= qeth_get_micros() -
2711 card
->perf_stats
.inbound_do_qdio_start_time
;
2714 PRINT_WARN("qeth_queue_input_buffer's do_QDIO "
2715 "return %i (device %s).\n",
2716 rc
, CARD_DDEV_ID(card
));
2717 QETH_DBF_TEXT(trace
,2,"qinberr");
2718 QETH_DBF_TEXT_(trace
,2,"%s",CARD_BUS_ID(card
));
2720 queue
->next_buf_to_init
= (queue
->next_buf_to_init
+ count
) %
2721 QDIO_MAX_BUFFERS_PER_Q
;
2726 qeth_put_buffer_pool_entry(struct qeth_card
*card
,
2727 struct qeth_buffer_pool_entry
*entry
)
2729 QETH_DBF_TEXT(trace
, 6, "ptbfplen");
2730 list_add_tail(&entry
->list
, &card
->qdio
.in_buf_pool
.entry_list
);
2734 qeth_qdio_input_handler(struct ccw_device
* ccwdev
, unsigned int status
,
2735 unsigned int qdio_err
, unsigned int siga_err
,
2736 unsigned int queue
, int first_element
, int count
,
2737 unsigned long card_ptr
)
2739 struct net_device
*net_dev
;
2740 struct qeth_card
*card
;
2741 struct qeth_qdio_buffer
*buffer
;
2745 QETH_DBF_TEXT(trace
, 6, "qdinput");
2746 card
= (struct qeth_card
*) card_ptr
;
2747 net_dev
= card
->dev
;
2748 #ifdef CONFIG_QETH_PERF_STATS
2749 card
->perf_stats
.inbound_cnt
++;
2750 card
->perf_stats
.inbound_start_time
= qeth_get_micros();
2752 if (status
& QDIO_STATUS_LOOK_FOR_ERROR
) {
2753 if (status
& QDIO_STATUS_ACTIVATE_CHECK_CONDITION
){
2754 QETH_DBF_TEXT(trace
, 1,"qdinchk");
2755 QETH_DBF_TEXT_(trace
,1,"%s",CARD_BUS_ID(card
));
2756 QETH_DBF_TEXT_(trace
,1,"%04X%04X",first_element
,count
);
2757 QETH_DBF_TEXT_(trace
,1,"%04X%04X", queue
, status
);
2758 qeth_schedule_recovery(card
);
2762 for (i
= first_element
; i
< (first_element
+ count
); ++i
) {
2763 index
= i
% QDIO_MAX_BUFFERS_PER_Q
;
2764 buffer
= &card
->qdio
.in_q
->bufs
[index
];
2765 if (!((status
& QDIO_STATUS_LOOK_FOR_ERROR
) &&
2766 qeth_check_qdio_errors(buffer
->buffer
,
2767 qdio_err
, siga_err
,"qinerr")))
2768 qeth_process_inbound_buffer(card
, buffer
, index
);
2769 /* clear buffer and give back to hardware */
2770 qeth_put_buffer_pool_entry(card
, buffer
->pool_entry
);
2771 qeth_queue_input_buffer(card
, index
);
2773 #ifdef CONFIG_QETH_PERF_STATS
2774 card
->perf_stats
.inbound_time
+= qeth_get_micros() -
2775 card
->perf_stats
.inbound_start_time
;
2780 qeth_handle_send_error(struct qeth_card
*card
,
2781 struct qeth_qdio_out_buffer
*buffer
,
2782 unsigned int qdio_err
, unsigned int siga_err
)
2784 int sbalf15
= buffer
->buffer
->element
[15].flags
& 0xff;
2785 int cc
= siga_err
& 3;
2787 QETH_DBF_TEXT(trace
, 6, "hdsnderr");
2788 qeth_check_qdio_errors(buffer
->buffer
, qdio_err
, siga_err
, "qouterr");
2792 QETH_DBF_TEXT(trace
, 1,"lnkfail");
2793 QETH_DBF_TEXT_(trace
,1,"%s",CARD_BUS_ID(card
));
2794 QETH_DBF_TEXT_(trace
,1,"%04x %02x",
2795 (u16
)qdio_err
, (u8
)sbalf15
);
2796 return QETH_SEND_ERROR_LINK_FAILURE
;
2798 return QETH_SEND_ERROR_NONE
;
2800 if (siga_err
& QDIO_SIGA_ERROR_B_BIT_SET
) {
2801 QETH_DBF_TEXT(trace
, 1, "SIGAcc2B");
2802 QETH_DBF_TEXT_(trace
,1,"%s",CARD_BUS_ID(card
));
2803 return QETH_SEND_ERROR_KICK_IT
;
2805 if ((sbalf15
>= 15) && (sbalf15
<= 31))
2806 return QETH_SEND_ERROR_RETRY
;
2807 return QETH_SEND_ERROR_LINK_FAILURE
;
2808 /* look at qdio_error and sbalf 15 */
2810 QETH_DBF_TEXT(trace
, 1, "SIGAcc1");
2811 QETH_DBF_TEXT_(trace
,1,"%s",CARD_BUS_ID(card
));
2812 return QETH_SEND_ERROR_LINK_FAILURE
;
2815 QETH_DBF_TEXT(trace
, 1, "SIGAcc3");
2816 QETH_DBF_TEXT_(trace
,1,"%s",CARD_BUS_ID(card
));
2817 return QETH_SEND_ERROR_KICK_IT
;
2822 qeth_flush_buffers(struct qeth_qdio_out_q
*queue
, int under_int
,
2823 int index
, int count
)
2825 struct qeth_qdio_out_buffer
*buf
;
2829 QETH_DBF_TEXT(trace
, 6, "flushbuf");
2831 for (i
= index
; i
< index
+ count
; ++i
) {
2832 buf
= &queue
->bufs
[i
% QDIO_MAX_BUFFERS_PER_Q
];
2833 buf
->buffer
->element
[buf
->next_element_to_fill
- 1].flags
|=
2834 SBAL_FLAGS_LAST_ENTRY
;
2836 if (queue
->card
->info
.type
== QETH_CARD_TYPE_IQD
)
2839 if (!queue
->do_pack
){
2840 if ((atomic_read(&queue
->used_buffers
) >=
2841 (QETH_HIGH_WATERMARK_PACK
-
2842 QETH_WATERMARK_PACK_FUZZ
)) &&
2843 !atomic_read(&queue
->set_pci_flags_count
)){
2844 /* it's likely that we'll go to packing
2846 atomic_inc(&queue
->set_pci_flags_count
);
2847 buf
->buffer
->element
[0].flags
|= 0x40;
2850 if (!atomic_read(&queue
->set_pci_flags_count
)){
2852 * there's no outstanding PCI any more, so we
2853 * have to request a PCI to be sure the the PCI
2854 * will wake at some time in the future then we
2855 * can flush packed buffers that might still be
2856 * hanging around, which can happen if no
2857 * further send was requested by the stack
2859 atomic_inc(&queue
->set_pci_flags_count
);
2860 buf
->buffer
->element
[0].flags
|= 0x40;
2865 queue
->card
->dev
->trans_start
= jiffies
;
2866 #ifdef CONFIG_QETH_PERF_STATS
2867 queue
->card
->perf_stats
.outbound_do_qdio_cnt
++;
2868 queue
->card
->perf_stats
.outbound_do_qdio_start_time
= qeth_get_micros();
2871 rc
= do_QDIO(CARD_DDEV(queue
->card
),
2872 QDIO_FLAG_SYNC_OUTPUT
| QDIO_FLAG_UNDER_INTERRUPT
,
2873 queue
->queue_no
, index
, count
, NULL
);
2875 rc
= do_QDIO(CARD_DDEV(queue
->card
), QDIO_FLAG_SYNC_OUTPUT
,
2876 queue
->queue_no
, index
, count
, NULL
);
2877 #ifdef CONFIG_QETH_PERF_STATS
2878 queue
->card
->perf_stats
.outbound_do_qdio_time
+= qeth_get_micros() -
2879 queue
->card
->perf_stats
.outbound_do_qdio_start_time
;
2882 QETH_DBF_TEXT(trace
, 2, "flushbuf");
2883 QETH_DBF_TEXT_(trace
, 2, " err%d", rc
);
2884 QETH_DBF_TEXT_(trace
, 2, "%s", CARD_DDEV_ID(queue
->card
));
2885 queue
->card
->stats
.tx_errors
+= count
;
2886 /* this must not happen under normal circumstances. if it
2887 * happens something is really wrong -> recover */
2888 qeth_schedule_recovery(queue
->card
);
2891 atomic_add(count
, &queue
->used_buffers
);
2892 #ifdef CONFIG_QETH_PERF_STATS
2893 queue
->card
->perf_stats
.bufs_sent
+= count
;
2898 * Switched to packing state if the number of used buffers on a queue
2899 * reaches a certain limit.
2902 qeth_switch_to_packing_if_needed(struct qeth_qdio_out_q
*queue
)
2904 if (!queue
->do_pack
) {
2905 if (atomic_read(&queue
->used_buffers
)
2906 >= QETH_HIGH_WATERMARK_PACK
){
2907 /* switch non-PACKING -> PACKING */
2908 QETH_DBF_TEXT(trace
, 6, "np->pack");
2909 #ifdef CONFIG_QETH_PERF_STATS
2910 queue
->card
->perf_stats
.sc_dp_p
++;
2918 * Switches from packing to non-packing mode. If there is a packing
2919 * buffer on the queue this buffer will be prepared to be flushed.
2920 * In that case 1 is returned to inform the caller. If no buffer
2921 * has to be flushed, zero is returned.
2924 qeth_switch_to_nonpacking_if_needed(struct qeth_qdio_out_q
*queue
)
2926 struct qeth_qdio_out_buffer
*buffer
;
2927 int flush_count
= 0;
2929 if (queue
->do_pack
) {
2930 if (atomic_read(&queue
->used_buffers
)
2931 <= QETH_LOW_WATERMARK_PACK
) {
2932 /* switch PACKING -> non-PACKING */
2933 QETH_DBF_TEXT(trace
, 6, "pack->np");
2934 #ifdef CONFIG_QETH_PERF_STATS
2935 queue
->card
->perf_stats
.sc_p_dp
++;
2938 /* flush packing buffers */
2939 buffer
= &queue
->bufs
[queue
->next_buf_to_fill
];
2940 if ((atomic_read(&buffer
->state
) ==
2941 QETH_QDIO_BUF_EMPTY
) &&
2942 (buffer
->next_element_to_fill
> 0)) {
2943 atomic_set(&buffer
->state
,QETH_QDIO_BUF_PRIMED
);
2945 queue
->next_buf_to_fill
=
2946 (queue
->next_buf_to_fill
+ 1) %
2947 QDIO_MAX_BUFFERS_PER_Q
;
2955 * Called to flush a packing buffer if no more pci flags are on the queue.
2956 * Checks if there is a packing buffer and prepares it to be flushed.
2957 * In that case returns 1, otherwise zero.
2960 qeth_flush_buffers_on_no_pci(struct qeth_qdio_out_q
*queue
)
2962 struct qeth_qdio_out_buffer
*buffer
;
2964 buffer
= &queue
->bufs
[queue
->next_buf_to_fill
];
2965 if((atomic_read(&buffer
->state
) == QETH_QDIO_BUF_EMPTY
) &&
2966 (buffer
->next_element_to_fill
> 0)){
2967 /* it's a packing buffer */
2968 atomic_set(&buffer
->state
, QETH_QDIO_BUF_PRIMED
);
2969 queue
->next_buf_to_fill
=
2970 (queue
->next_buf_to_fill
+ 1) % QDIO_MAX_BUFFERS_PER_Q
;
2977 qeth_check_outbound_queue(struct qeth_qdio_out_q
*queue
)
2981 int q_was_packing
= 0;
2984 * check if weed have to switch to non-packing mode or if
2985 * we have to get a pci flag out on the queue
2987 if ((atomic_read(&queue
->used_buffers
) <= QETH_LOW_WATERMARK_PACK
) ||
2988 !atomic_read(&queue
->set_pci_flags_count
)){
2989 if (atomic_swap(&queue
->state
, QETH_OUT_Q_LOCKED_FLUSH
) ==
2990 QETH_OUT_Q_UNLOCKED
) {
2992 * If we get in here, there was no action in
2993 * do_send_packet. So, we check if there is a
2994 * packing buffer to be flushed here.
2996 netif_stop_queue(queue
->card
->dev
);
2997 index
= queue
->next_buf_to_fill
;
2998 q_was_packing
= queue
->do_pack
;
2999 flush_cnt
+= qeth_switch_to_nonpacking_if_needed(queue
);
3001 !atomic_read(&queue
->set_pci_flags_count
))
3003 qeth_flush_buffers_on_no_pci(queue
);
3004 #ifdef CONFIG_QETH_PERF_STATS
3006 queue
->card
->perf_stats
.bufs_sent_pack
+=
3010 qeth_flush_buffers(queue
, 1, index
, flush_cnt
);
3011 atomic_set(&queue
->state
, QETH_OUT_Q_UNLOCKED
);
3017 qeth_qdio_output_handler(struct ccw_device
* ccwdev
, unsigned int status
,
3018 unsigned int qdio_error
, unsigned int siga_error
,
3019 unsigned int __queue
, int first_element
, int count
,
3020 unsigned long card_ptr
)
3022 struct qeth_card
*card
= (struct qeth_card
*) card_ptr
;
3023 struct qeth_qdio_out_q
*queue
= card
->qdio
.out_qs
[__queue
];
3024 struct qeth_qdio_out_buffer
*buffer
;
3027 QETH_DBF_TEXT(trace
, 6, "qdouhdl");
3028 if (status
& QDIO_STATUS_LOOK_FOR_ERROR
) {
3029 if (status
& QDIO_STATUS_ACTIVATE_CHECK_CONDITION
){
3030 QETH_DBF_TEXT(trace
, 2, "achkcond");
3031 QETH_DBF_TEXT_(trace
, 2, "%s", CARD_BUS_ID(card
));
3032 QETH_DBF_TEXT_(trace
, 2, "%08x", status
);
3033 netif_stop_queue(card
->dev
);
3034 qeth_schedule_recovery(card
);
3038 #ifdef CONFIG_QETH_PERF_STATS
3039 card
->perf_stats
.outbound_handler_cnt
++;
3040 card
->perf_stats
.outbound_handler_start_time
= qeth_get_micros();
3042 for(i
= first_element
; i
< (first_element
+ count
); ++i
){
3043 buffer
= &queue
->bufs
[i
% QDIO_MAX_BUFFERS_PER_Q
];
3044 /*we only handle the KICK_IT error by doing a recovery */
3045 if (qeth_handle_send_error(card
, buffer
,
3046 qdio_error
, siga_error
)
3047 == QETH_SEND_ERROR_KICK_IT
){
3048 netif_stop_queue(card
->dev
);
3049 qeth_schedule_recovery(card
);
3052 qeth_clear_output_buffer(queue
, buffer
);
3054 atomic_sub(count
, &queue
->used_buffers
);
3055 /* check if we need to do something on this outbound queue */
3056 if (card
->info
.type
!= QETH_CARD_TYPE_IQD
)
3057 qeth_check_outbound_queue(queue
);
3059 netif_wake_queue(queue
->card
->dev
);
3060 #ifdef CONFIG_QETH_PERF_STATS
3061 card
->perf_stats
.outbound_handler_time
+= qeth_get_micros() -
3062 card
->perf_stats
.outbound_handler_start_time
;
3067 qeth_create_qib_param_field(struct qeth_card
*card
, char *param_field
)
3070 param_field
[0] = _ascebc
['P'];
3071 param_field
[1] = _ascebc
['C'];
3072 param_field
[2] = _ascebc
['I'];
3073 param_field
[3] = _ascebc
['T'];
3074 *((unsigned int *) (¶m_field
[4])) = QETH_PCI_THRESHOLD_A(card
);
3075 *((unsigned int *) (¶m_field
[8])) = QETH_PCI_THRESHOLD_B(card
);
3076 *((unsigned int *) (¶m_field
[12])) = QETH_PCI_TIMER_VALUE(card
);
3080 qeth_create_qib_param_field_blkt(struct qeth_card
*card
, char *param_field
)
3082 param_field
[16] = _ascebc
['B'];
3083 param_field
[17] = _ascebc
['L'];
3084 param_field
[18] = _ascebc
['K'];
3085 param_field
[19] = _ascebc
['T'];
3086 *((unsigned int *) (¶m_field
[20])) = card
->info
.blkt
.time_total
;
3087 *((unsigned int *) (¶m_field
[24])) = card
->info
.blkt
.inter_packet
;
3088 *((unsigned int *) (¶m_field
[28])) = card
->info
.blkt
.inter_packet_jumbo
;
3092 qeth_initialize_working_pool_list(struct qeth_card
*card
)
3094 struct qeth_buffer_pool_entry
*entry
;
3096 QETH_DBF_TEXT(trace
,5,"inwrklst");
3098 list_for_each_entry(entry
,
3099 &card
->qdio
.init_pool
.entry_list
, init_list
) {
3100 qeth_put_buffer_pool_entry(card
,entry
);
3105 qeth_clear_working_pool_list(struct qeth_card
*card
)
3107 struct qeth_buffer_pool_entry
*pool_entry
, *tmp
;
3109 QETH_DBF_TEXT(trace
,5,"clwrklst");
3110 list_for_each_entry_safe(pool_entry
, tmp
,
3111 &card
->qdio
.in_buf_pool
.entry_list
, list
){
3112 list_del(&pool_entry
->list
);
3117 qeth_free_buffer_pool(struct qeth_card
*card
)
3119 struct qeth_buffer_pool_entry
*pool_entry
, *tmp
;
3121 QETH_DBF_TEXT(trace
,5,"freepool");
3122 list_for_each_entry_safe(pool_entry
, tmp
,
3123 &card
->qdio
.init_pool
.entry_list
, init_list
){
3124 for (i
= 0; i
< QETH_MAX_BUFFER_ELEMENTS(card
); ++i
)
3125 free_page((unsigned long)pool_entry
->elements
[i
]);
3126 list_del(&pool_entry
->init_list
);
3132 qeth_alloc_buffer_pool(struct qeth_card
*card
)
3134 struct qeth_buffer_pool_entry
*pool_entry
;
3138 QETH_DBF_TEXT(trace
,5,"alocpool");
3139 for (i
= 0; i
< card
->qdio
.init_pool
.buf_count
; ++i
){
3140 pool_entry
= kmalloc(sizeof(*pool_entry
), GFP_KERNEL
);
3142 qeth_free_buffer_pool(card
);
3145 for(j
= 0; j
< QETH_MAX_BUFFER_ELEMENTS(card
); ++j
){
3146 ptr
= (void *) __get_free_page(GFP_KERNEL
|GFP_DMA
);
3149 free_page((unsigned long)
3150 pool_entry
->elements
[--j
]);
3152 qeth_free_buffer_pool(card
);
3155 pool_entry
->elements
[j
] = ptr
;
3157 list_add(&pool_entry
->init_list
,
3158 &card
->qdio
.init_pool
.entry_list
);
3164 qeth_realloc_buffer_pool(struct qeth_card
*card
, int bufcnt
)
3166 QETH_DBF_TEXT(trace
, 2, "realcbp");
3168 if ((card
->state
!= CARD_STATE_DOWN
) &&
3169 (card
->state
!= CARD_STATE_RECOVER
))
3172 /* TODO: steel/add buffers from/to a running card's buffer pool (?) */
3173 qeth_clear_working_pool_list(card
);
3174 qeth_free_buffer_pool(card
);
3175 card
->qdio
.in_buf_pool
.buf_count
= bufcnt
;
3176 card
->qdio
.init_pool
.buf_count
= bufcnt
;
3177 return qeth_alloc_buffer_pool(card
);
3181 qeth_alloc_qdio_buffers(struct qeth_card
*card
)
3185 QETH_DBF_TEXT(setup
, 2, "allcqdbf");
3187 if (card
->qdio
.state
== QETH_QDIO_ALLOCATED
)
3190 card
->qdio
.in_q
= kmalloc(sizeof(struct qeth_qdio_q
),
3191 GFP_KERNEL
|GFP_DMA
);
3192 if (!card
->qdio
.in_q
)
3194 QETH_DBF_TEXT(setup
, 2, "inq");
3195 QETH_DBF_HEX(setup
, 2, &card
->qdio
.in_q
, sizeof(void *));
3196 memset(card
->qdio
.in_q
, 0, sizeof(struct qeth_qdio_q
));
3197 /* give inbound qeth_qdio_buffers their qdio_buffers */
3198 for (i
= 0; i
< QDIO_MAX_BUFFERS_PER_Q
; ++i
)
3199 card
->qdio
.in_q
->bufs
[i
].buffer
=
3200 &card
->qdio
.in_q
->qdio_bufs
[i
];
3201 /* inbound buffer pool */
3202 if (qeth_alloc_buffer_pool(card
)){
3203 kfree(card
->qdio
.in_q
);
3208 kmalloc(card
->qdio
.no_out_queues
*
3209 sizeof(struct qeth_qdio_out_q
*), GFP_KERNEL
);
3210 if (!card
->qdio
.out_qs
){
3211 qeth_free_buffer_pool(card
);
3214 for (i
= 0; i
< card
->qdio
.no_out_queues
; ++i
){
3215 card
->qdio
.out_qs
[i
] = kmalloc(sizeof(struct qeth_qdio_out_q
),
3216 GFP_KERNEL
|GFP_DMA
);
3217 if (!card
->qdio
.out_qs
[i
]){
3219 kfree(card
->qdio
.out_qs
[--i
]);
3220 kfree(card
->qdio
.out_qs
);
3223 QETH_DBF_TEXT_(setup
, 2, "outq %i", i
);
3224 QETH_DBF_HEX(setup
, 2, &card
->qdio
.out_qs
[i
], sizeof(void *));
3225 memset(card
->qdio
.out_qs
[i
], 0, sizeof(struct qeth_qdio_out_q
));
3226 card
->qdio
.out_qs
[i
]->queue_no
= i
;
3227 /* give outbound qeth_qdio_buffers their qdio_buffers */
3228 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; ++j
){
3229 card
->qdio
.out_qs
[i
]->bufs
[j
].buffer
=
3230 &card
->qdio
.out_qs
[i
]->qdio_bufs
[j
];
3231 skb_queue_head_init(&card
->qdio
.out_qs
[i
]->bufs
[j
].
3233 INIT_LIST_HEAD(&card
->qdio
.out_qs
[i
]->bufs
[j
].ctx_list
);
3236 card
->qdio
.state
= QETH_QDIO_ALLOCATED
;
3241 qeth_free_qdio_buffers(struct qeth_card
*card
)
3245 QETH_DBF_TEXT(trace
, 2, "freeqdbf");
3246 if (card
->qdio
.state
== QETH_QDIO_UNINITIALIZED
)
3248 kfree(card
->qdio
.in_q
);
3249 /* inbound buffer pool */
3250 qeth_free_buffer_pool(card
);
3251 /* free outbound qdio_qs */
3252 for (i
= 0; i
< card
->qdio
.no_out_queues
; ++i
){
3253 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; ++j
)
3254 qeth_clear_output_buffer(card
->qdio
.out_qs
[i
],
3255 &card
->qdio
.out_qs
[i
]->bufs
[j
]);
3256 kfree(card
->qdio
.out_qs
[i
]);
3258 kfree(card
->qdio
.out_qs
);
3259 card
->qdio
.state
= QETH_QDIO_UNINITIALIZED
;
3263 qeth_clear_qdio_buffers(struct qeth_card
*card
)
3267 QETH_DBF_TEXT(trace
, 2, "clearqdbf");
3268 /* clear outbound buffers to free skbs */
3269 for (i
= 0; i
< card
->qdio
.no_out_queues
; ++i
)
3270 if (card
->qdio
.out_qs
[i
]){
3271 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; ++j
)
3272 qeth_clear_output_buffer(card
->qdio
.out_qs
[i
],
3273 &card
->qdio
.out_qs
[i
]->bufs
[j
]);
3278 qeth_init_qdio_info(struct qeth_card
*card
)
3280 QETH_DBF_TEXT(setup
, 4, "intqdinf");
3281 card
->qdio
.state
= QETH_QDIO_UNINITIALIZED
;
3283 card
->qdio
.in_buf_size
= QETH_IN_BUF_SIZE_DEFAULT
;
3284 card
->qdio
.init_pool
.buf_count
= QETH_IN_BUF_COUNT_DEFAULT
;
3285 card
->qdio
.in_buf_pool
.buf_count
= card
->qdio
.init_pool
.buf_count
;
3286 INIT_LIST_HEAD(&card
->qdio
.in_buf_pool
.entry_list
);
3287 INIT_LIST_HEAD(&card
->qdio
.init_pool
.entry_list
);
3291 qeth_init_qdio_queues(struct qeth_card
*card
)
3296 QETH_DBF_TEXT(setup
, 2, "initqdqs");
3299 memset(card
->qdio
.in_q
->qdio_bufs
, 0,
3300 QDIO_MAX_BUFFERS_PER_Q
* sizeof(struct qdio_buffer
));
3301 qeth_initialize_working_pool_list(card
);
3302 /*give only as many buffers to hardware as we have buffer pool entries*/
3303 for (i
= 0; i
< card
->qdio
.in_buf_pool
.buf_count
- 1; ++i
)
3304 qeth_init_input_buffer(card
, &card
->qdio
.in_q
->bufs
[i
]);
3305 card
->qdio
.in_q
->next_buf_to_init
= card
->qdio
.in_buf_pool
.buf_count
- 1;
3306 rc
= do_QDIO(CARD_DDEV(card
), QDIO_FLAG_SYNC_INPUT
, 0, 0,
3307 card
->qdio
.in_buf_pool
.buf_count
- 1, NULL
);
3309 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
3312 rc
= qdio_synchronize(CARD_DDEV(card
), QDIO_FLAG_SYNC_INPUT
, 0);
3314 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
3317 /* outbound queue */
3318 for (i
= 0; i
< card
->qdio
.no_out_queues
; ++i
){
3319 memset(card
->qdio
.out_qs
[i
]->qdio_bufs
, 0,
3320 QDIO_MAX_BUFFERS_PER_Q
* sizeof(struct qdio_buffer
));
3321 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; ++j
){
3322 qeth_clear_output_buffer(card
->qdio
.out_qs
[i
],
3323 &card
->qdio
.out_qs
[i
]->bufs
[j
]);
3325 card
->qdio
.out_qs
[i
]->card
= card
;
3326 card
->qdio
.out_qs
[i
]->next_buf_to_fill
= 0;
3327 card
->qdio
.out_qs
[i
]->do_pack
= 0;
3328 atomic_set(&card
->qdio
.out_qs
[i
]->used_buffers
,0);
3329 atomic_set(&card
->qdio
.out_qs
[i
]->set_pci_flags_count
, 0);
3330 atomic_set(&card
->qdio
.out_qs
[i
]->state
,
3331 QETH_OUT_Q_UNLOCKED
);
3337 qeth_qdio_establish(struct qeth_card
*card
)
3339 struct qdio_initialize init_data
;
3340 char *qib_param_field
;
3341 struct qdio_buffer
**in_sbal_ptrs
;
3342 struct qdio_buffer
**out_sbal_ptrs
;
3346 QETH_DBF_TEXT(setup
, 2, "qdioest");
3348 qib_param_field
= kzalloc(QDIO_MAX_BUFFERS_PER_Q
* sizeof(char),
3350 if (!qib_param_field
)
3353 qeth_create_qib_param_field(card
, qib_param_field
);
3354 qeth_create_qib_param_field_blkt(card
, qib_param_field
);
3356 in_sbal_ptrs
= kmalloc(QDIO_MAX_BUFFERS_PER_Q
* sizeof(void *),
3358 if (!in_sbal_ptrs
) {
3359 kfree(qib_param_field
);
3362 for(i
= 0; i
< QDIO_MAX_BUFFERS_PER_Q
; ++i
)
3363 in_sbal_ptrs
[i
] = (struct qdio_buffer
*)
3364 virt_to_phys(card
->qdio
.in_q
->bufs
[i
].buffer
);
3367 kmalloc(card
->qdio
.no_out_queues
* QDIO_MAX_BUFFERS_PER_Q
*
3368 sizeof(void *), GFP_KERNEL
);
3369 if (!out_sbal_ptrs
) {
3370 kfree(in_sbal_ptrs
);
3371 kfree(qib_param_field
);
3374 for(i
= 0, k
= 0; i
< card
->qdio
.no_out_queues
; ++i
)
3375 for(j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; ++j
, ++k
){
3376 out_sbal_ptrs
[k
] = (struct qdio_buffer
*)
3377 virt_to_phys(card
->qdio
.out_qs
[i
]->
3381 memset(&init_data
, 0, sizeof(struct qdio_initialize
));
3382 init_data
.cdev
= CARD_DDEV(card
);
3383 init_data
.q_format
= qeth_get_qdio_q_format(card
);
3384 init_data
.qib_param_field_format
= 0;
3385 init_data
.qib_param_field
= qib_param_field
;
3386 init_data
.min_input_threshold
= QETH_MIN_INPUT_THRESHOLD
;
3387 init_data
.max_input_threshold
= QETH_MAX_INPUT_THRESHOLD
;
3388 init_data
.min_output_threshold
= QETH_MIN_OUTPUT_THRESHOLD
;
3389 init_data
.max_output_threshold
= QETH_MAX_OUTPUT_THRESHOLD
;
3390 init_data
.no_input_qs
= 1;
3391 init_data
.no_output_qs
= card
->qdio
.no_out_queues
;
3392 init_data
.input_handler
= (qdio_handler_t
*)
3393 qeth_qdio_input_handler
;
3394 init_data
.output_handler
= (qdio_handler_t
*)
3395 qeth_qdio_output_handler
;
3396 init_data
.int_parm
= (unsigned long) card
;
3397 init_data
.flags
= QDIO_INBOUND_0COPY_SBALS
|
3398 QDIO_OUTBOUND_0COPY_SBALS
|
3399 QDIO_USE_OUTBOUND_PCIS
;
3400 init_data
.input_sbal_addr_array
= (void **) in_sbal_ptrs
;
3401 init_data
.output_sbal_addr_array
= (void **) out_sbal_ptrs
;
3403 if (!(rc
= qdio_initialize(&init_data
)))
3404 card
->qdio
.state
= QETH_QDIO_ESTABLISHED
;
3406 kfree(out_sbal_ptrs
);
3407 kfree(in_sbal_ptrs
);
3408 kfree(qib_param_field
);
3413 qeth_qdio_activate(struct qeth_card
*card
)
3415 QETH_DBF_TEXT(setup
,3,"qdioact");
3416 return qdio_activate(CARD_DDEV(card
), 0);
3420 qeth_clear_channel(struct qeth_channel
*channel
)
3422 unsigned long flags
;
3423 struct qeth_card
*card
;
3426 QETH_DBF_TEXT(trace
,3,"clearch");
3427 card
= CARD_FROM_CDEV(channel
->ccwdev
);
3428 spin_lock_irqsave(get_ccwdev_lock(channel
->ccwdev
), flags
);
3429 rc
= ccw_device_clear(channel
->ccwdev
, QETH_CLEAR_CHANNEL_PARM
);
3430 spin_unlock_irqrestore(get_ccwdev_lock(channel
->ccwdev
), flags
);
3434 rc
= wait_event_interruptible_timeout(card
->wait_q
,
3435 channel
->state
==CH_STATE_STOPPED
, QETH_TIMEOUT
);
3436 if (rc
== -ERESTARTSYS
)
3438 if (channel
->state
!= CH_STATE_STOPPED
)
3440 channel
->state
= CH_STATE_DOWN
;
3445 qeth_halt_channel(struct qeth_channel
*channel
)
3447 unsigned long flags
;
3448 struct qeth_card
*card
;
3451 QETH_DBF_TEXT(trace
,3,"haltch");
3452 card
= CARD_FROM_CDEV(channel
->ccwdev
);
3453 spin_lock_irqsave(get_ccwdev_lock(channel
->ccwdev
), flags
);
3454 rc
= ccw_device_halt(channel
->ccwdev
, QETH_HALT_CHANNEL_PARM
);
3455 spin_unlock_irqrestore(get_ccwdev_lock(channel
->ccwdev
), flags
);
3459 rc
= wait_event_interruptible_timeout(card
->wait_q
,
3460 channel
->state
==CH_STATE_HALTED
, QETH_TIMEOUT
);
3461 if (rc
== -ERESTARTSYS
)
3463 if (channel
->state
!= CH_STATE_HALTED
)
3469 qeth_halt_channels(struct qeth_card
*card
)
3471 int rc1
= 0, rc2
=0, rc3
= 0;
3473 QETH_DBF_TEXT(trace
,3,"haltchs");
3474 rc1
= qeth_halt_channel(&card
->read
);
3475 rc2
= qeth_halt_channel(&card
->write
);
3476 rc3
= qeth_halt_channel(&card
->data
);
3484 qeth_clear_channels(struct qeth_card
*card
)
3486 int rc1
= 0, rc2
=0, rc3
= 0;
3488 QETH_DBF_TEXT(trace
,3,"clearchs");
3489 rc1
= qeth_clear_channel(&card
->read
);
3490 rc2
= qeth_clear_channel(&card
->write
);
3491 rc3
= qeth_clear_channel(&card
->data
);
3500 qeth_clear_halt_card(struct qeth_card
*card
, int halt
)
3504 QETH_DBF_TEXT(trace
,3,"clhacrd");
3505 QETH_DBF_HEX(trace
, 3, &card
, sizeof(void *));
3508 rc
= qeth_halt_channels(card
);
3511 return qeth_clear_channels(card
);
3515 qeth_qdio_clear_card(struct qeth_card
*card
, int use_halt
)
3519 QETH_DBF_TEXT(trace
,3,"qdioclr");
3520 if (card
->qdio
.state
== QETH_QDIO_ESTABLISHED
){
3521 if ((rc
= qdio_cleanup(CARD_DDEV(card
),
3522 (card
->info
.type
== QETH_CARD_TYPE_IQD
) ?
3523 QDIO_FLAG_CLEANUP_USING_HALT
:
3524 QDIO_FLAG_CLEANUP_USING_CLEAR
)))
3525 QETH_DBF_TEXT_(trace
, 3, "1err%d", rc
);
3526 card
->qdio
.state
= QETH_QDIO_ALLOCATED
;
3528 if ((rc
= qeth_clear_halt_card(card
, use_halt
)))
3529 QETH_DBF_TEXT_(trace
, 3, "2err%d", rc
);
3530 card
->state
= CARD_STATE_DOWN
;
3535 qeth_dm_act(struct qeth_card
*card
)
3538 struct qeth_cmd_buffer
*iob
;
3540 QETH_DBF_TEXT(setup
,2,"dmact");
3542 iob
= qeth_wait_for_buffer(&card
->write
);
3543 memcpy(iob
->data
, DM_ACT
, DM_ACT_SIZE
);
3545 memcpy(QETH_DM_ACT_DEST_ADDR(iob
->data
),
3546 &card
->token
.cm_connection_r
, QETH_MPC_TOKEN_LENGTH
);
3547 memcpy(QETH_DM_ACT_CONNECTION_TOKEN(iob
->data
),
3548 &card
->token
.ulp_connection_r
, QETH_MPC_TOKEN_LENGTH
);
3549 rc
= qeth_send_control_data(card
, DM_ACT_SIZE
, iob
, NULL
, NULL
);
3554 qeth_mpc_initialize(struct qeth_card
*card
)
3558 QETH_DBF_TEXT(setup
,2,"mpcinit");
3560 if ((rc
= qeth_issue_next_read(card
))){
3561 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
3564 if ((rc
= qeth_cm_enable(card
))){
3565 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
3568 if ((rc
= qeth_cm_setup(card
))){
3569 QETH_DBF_TEXT_(setup
, 2, "3err%d", rc
);
3572 if ((rc
= qeth_ulp_enable(card
))){
3573 QETH_DBF_TEXT_(setup
, 2, "4err%d", rc
);
3576 if ((rc
= qeth_ulp_setup(card
))){
3577 QETH_DBF_TEXT_(setup
, 2, "5err%d", rc
);
3580 if ((rc
= qeth_alloc_qdio_buffers(card
))){
3581 QETH_DBF_TEXT_(setup
, 2, "5err%d", rc
);
3584 if ((rc
= qeth_qdio_establish(card
))){
3585 QETH_DBF_TEXT_(setup
, 2, "6err%d", rc
);
3586 qeth_free_qdio_buffers(card
);
3589 if ((rc
= qeth_qdio_activate(card
))){
3590 QETH_DBF_TEXT_(setup
, 2, "7err%d", rc
);
3593 if ((rc
= qeth_dm_act(card
))){
3594 QETH_DBF_TEXT_(setup
, 2, "8err%d", rc
);
3600 qeth_qdio_clear_card(card
, card
->info
.type
!=QETH_CARD_TYPE_IQD
);
3604 static struct net_device
*
3605 qeth_get_netdevice(enum qeth_card_types type
, enum qeth_link_types linktype
)
3607 struct net_device
*dev
= NULL
;
3610 case QETH_CARD_TYPE_OSAE
:
3612 case QETH_LINK_TYPE_LANE_TR
:
3613 case QETH_LINK_TYPE_HSTR
:
3615 dev
= alloc_trdev(0);
3616 #endif /* CONFIG_TR */
3619 dev
= alloc_etherdev(0);
3622 case QETH_CARD_TYPE_IQD
:
3623 dev
= alloc_netdev(0, "hsi%d", ether_setup
);
3625 case QETH_CARD_TYPE_OSN
:
3626 dev
= alloc_netdev(0, "osn%d", ether_setup
);
3629 dev
= alloc_etherdev(0);
3634 /*hard_header fake function; used in case fake_ll is set */
3636 qeth_fake_header(struct sk_buff
*skb
, struct net_device
*dev
,
3637 unsigned short type
, void *daddr
, void *saddr
,
3640 if(dev
->type
== ARPHRD_IEEE802_TR
){
3641 struct trh_hdr
*hdr
;
3642 hdr
= (struct trh_hdr
*)skb_push(skb
, QETH_FAKE_LL_LEN_TR
);
3643 memcpy(hdr
->saddr
, dev
->dev_addr
, TR_ALEN
);
3644 memcpy(hdr
->daddr
, "FAKELL", TR_ALEN
);
3645 return QETH_FAKE_LL_LEN_TR
;
3649 hdr
= (struct ethhdr
*)skb_push(skb
, QETH_FAKE_LL_LEN_ETH
);
3650 memcpy(hdr
->h_source
, dev
->dev_addr
, ETH_ALEN
);
3651 memcpy(hdr
->h_dest
, "FAKELL", ETH_ALEN
);
3652 if (type
!= ETH_P_802_3
)
3653 hdr
->h_proto
= htons(type
);
3655 hdr
->h_proto
= htons(len
);
3656 return QETH_FAKE_LL_LEN_ETH
;
3662 qeth_send_packet(struct qeth_card
*, struct sk_buff
*);
3665 qeth_hard_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
3668 struct qeth_card
*card
;
3670 QETH_DBF_TEXT(trace
, 6, "hrdstxmi");
3671 card
= (struct qeth_card
*)dev
->priv
;
3673 card
->stats
.tx_dropped
++;
3674 card
->stats
.tx_errors
++;
3675 /* return OK; otherwise ksoftirqd goes to 100% */
3676 return NETDEV_TX_OK
;
3678 if ((card
->state
!= CARD_STATE_UP
) || !card
->lan_online
) {
3679 card
->stats
.tx_dropped
++;
3680 card
->stats
.tx_errors
++;
3681 card
->stats
.tx_carrier_errors
++;
3682 dev_kfree_skb_any(skb
);
3683 /* return OK; otherwise ksoftirqd goes to 100% */
3684 return NETDEV_TX_OK
;
3686 #ifdef CONFIG_QETH_PERF_STATS
3687 card
->perf_stats
.outbound_cnt
++;
3688 card
->perf_stats
.outbound_start_time
= qeth_get_micros();
3690 netif_stop_queue(dev
);
3691 if ((rc
= qeth_send_packet(card
, skb
))) {
3693 return NETDEV_TX_BUSY
;
3695 card
->stats
.tx_errors
++;
3696 card
->stats
.tx_dropped
++;
3697 dev_kfree_skb_any(skb
);
3698 /*set to OK; otherwise ksoftirqd goes to 100% */
3702 netif_wake_queue(dev
);
3703 #ifdef CONFIG_QETH_PERF_STATS
3704 card
->perf_stats
.outbound_time
+= qeth_get_micros() -
3705 card
->perf_stats
.outbound_start_time
;
3711 qeth_verify_vlan_dev(struct net_device
*dev
, struct qeth_card
*card
)
3714 #ifdef CONFIG_QETH_VLAN
3715 struct vlan_group
*vg
;
3718 if (!(vg
= card
->vlangrp
))
3721 for (i
= 0; i
< VLAN_GROUP_ARRAY_LEN
; i
++){
3722 if (vg
->vlan_devices
[i
] == dev
){
3723 rc
= QETH_VLAN_CARD
;
3727 if (rc
&& !(VLAN_DEV_INFO(dev
)->real_dev
->priv
== (void *)card
))
3735 qeth_verify_dev(struct net_device
*dev
)
3737 struct qeth_card
*card
;
3738 unsigned long flags
;
3741 read_lock_irqsave(&qeth_card_list
.rwlock
, flags
);
3742 list_for_each_entry(card
, &qeth_card_list
.list
, list
){
3743 if (card
->dev
== dev
){
3744 rc
= QETH_REAL_CARD
;
3747 rc
= qeth_verify_vlan_dev(dev
, card
);
3751 read_unlock_irqrestore(&qeth_card_list
.rwlock
, flags
);
3756 static struct qeth_card
*
3757 qeth_get_card_from_dev(struct net_device
*dev
)
3759 struct qeth_card
*card
= NULL
;
3762 rc
= qeth_verify_dev(dev
);
3763 if (rc
== QETH_REAL_CARD
)
3764 card
= (struct qeth_card
*)dev
->priv
;
3765 else if (rc
== QETH_VLAN_CARD
)
3766 card
= (struct qeth_card
*)
3767 VLAN_DEV_INFO(dev
)->real_dev
->priv
;
3769 QETH_DBF_TEXT_(trace
, 4, "%d", rc
);
3774 qeth_tx_timeout(struct net_device
*dev
)
3776 struct qeth_card
*card
;
3778 card
= (struct qeth_card
*) dev
->priv
;
3779 card
->stats
.tx_errors
++;
3780 qeth_schedule_recovery(card
);
3784 qeth_open(struct net_device
*dev
)
3786 struct qeth_card
*card
;
3788 QETH_DBF_TEXT(trace
, 4, "qethopen");
3790 card
= (struct qeth_card
*) dev
->priv
;
3792 if (card
->state
!= CARD_STATE_SOFTSETUP
)
3795 if ( (card
->info
.type
!= QETH_CARD_TYPE_OSN
) &&
3796 (card
->options
.layer2
) &&
3797 (!(card
->info
.mac_bits
& QETH_LAYER2_MAC_REGISTERED
))) {
3798 QETH_DBF_TEXT(trace
,4,"nomacadr");
3801 card
->data
.state
= CH_STATE_UP
;
3802 card
->state
= CARD_STATE_UP
;
3803 card
->dev
->flags
|= IFF_UP
;
3804 netif_start_queue(dev
);
3806 if (!card
->lan_online
&& netif_carrier_ok(dev
))
3807 netif_carrier_off(dev
);
3812 qeth_stop(struct net_device
*dev
)
3814 struct qeth_card
*card
;
3816 QETH_DBF_TEXT(trace
, 4, "qethstop");
3818 card
= (struct qeth_card
*) dev
->priv
;
3820 netif_tx_disable(dev
);
3821 card
->dev
->flags
&= ~IFF_UP
;
3822 if (card
->state
== CARD_STATE_UP
)
3823 card
->state
= CARD_STATE_SOFTSETUP
;
3828 qeth_get_cast_type(struct qeth_card
*card
, struct sk_buff
*skb
)
3830 int cast_type
= RTN_UNSPEC
;
3832 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
3835 if (skb
->dst
&& skb
->dst
->neighbour
){
3836 cast_type
= skb
->dst
->neighbour
->type
;
3837 if ((cast_type
== RTN_BROADCAST
) ||
3838 (cast_type
== RTN_MULTICAST
) ||
3839 (cast_type
== RTN_ANYCAST
))
3844 /* try something else */
3845 if (skb
->protocol
== ETH_P_IPV6
)
3846 return (skb
->nh
.raw
[24] == 0xff) ? RTN_MULTICAST
: 0;
3847 else if (skb
->protocol
== ETH_P_IP
)
3848 return ((skb
->nh
.raw
[16] & 0xf0) == 0xe0) ? RTN_MULTICAST
: 0;
3850 if (!memcmp(skb
->data
, skb
->dev
->broadcast
, 6))
3851 return RTN_BROADCAST
;
3855 hdr_mac
= *((u16
*)skb
->data
);
3857 switch (card
->info
.link_type
) {
3858 case QETH_LINK_TYPE_HSTR
:
3859 case QETH_LINK_TYPE_LANE_TR
:
3860 if ((hdr_mac
== QETH_TR_MAC_NC
) ||
3861 (hdr_mac
== QETH_TR_MAC_C
))
3862 return RTN_MULTICAST
;
3864 /* eth or so multicast? */
3866 if ((hdr_mac
== QETH_ETH_MAC_V4
) ||
3867 (hdr_mac
== QETH_ETH_MAC_V6
))
3868 return RTN_MULTICAST
;
3875 qeth_get_priority_queue(struct qeth_card
*card
, struct sk_buff
*skb
,
3876 int ipv
, int cast_type
)
3878 if (!ipv
&& (card
->info
.type
== QETH_CARD_TYPE_OSAE
))
3879 return card
->qdio
.default_out_queue
;
3880 switch (card
->qdio
.no_out_queues
) {
3882 if (cast_type
&& card
->info
.is_multicast_different
)
3883 return card
->info
.is_multicast_different
&
3884 (card
->qdio
.no_out_queues
- 1);
3885 if (card
->qdio
.do_prio_queueing
&& (ipv
== 4)) {
3886 if (card
->qdio
.do_prio_queueing
==QETH_PRIO_Q_ING_TOS
){
3887 if (skb
->nh
.iph
->tos
& IP_TOS_NOTIMPORTANT
)
3889 if (skb
->nh
.iph
->tos
& IP_TOS_HIGHRELIABILITY
)
3891 if (skb
->nh
.iph
->tos
& IP_TOS_HIGHTHROUGHPUT
)
3893 if (skb
->nh
.iph
->tos
& IP_TOS_LOWDELAY
)
3896 if (card
->qdio
.do_prio_queueing
==QETH_PRIO_Q_ING_PREC
)
3897 return 3 - (skb
->nh
.iph
->tos
>> 6);
3898 } else if (card
->qdio
.do_prio_queueing
&& (ipv
== 6)) {
3901 return card
->qdio
.default_out_queue
;
3902 case 1: /* fallthrough for single-out-queue 1920-device */
3904 return card
->qdio
.default_out_queue
;
3909 qeth_get_ip_version(struct sk_buff
*skb
)
3911 switch (skb
->protocol
) {
3922 qeth_prepare_skb(struct qeth_card
*card
, struct sk_buff
**skb
,
3923 struct qeth_hdr
**hdr
, int ipv
)
3926 #ifdef CONFIG_QETH_VLAN
3930 QETH_DBF_TEXT(trace
, 6, "prepskb");
3931 if (card
->info
.type
== QETH_CARD_TYPE_OSN
) {
3932 *hdr
= (struct qeth_hdr
*)(*skb
)->data
;
3935 rc
= qeth_realloc_headroom(card
, skb
, sizeof(struct qeth_hdr
));
3938 #ifdef CONFIG_QETH_VLAN
3939 if (card
->vlangrp
&& vlan_tx_tag_present(*skb
) &&
3940 ((ipv
== 6) || card
->options
.layer2
) ) {
3942 * Move the mac addresses (6 bytes src, 6 bytes dest)
3943 * to the beginning of the new header. We are using three
3944 * memcpys instead of one memmove to save cycles.
3946 skb_push(*skb
, VLAN_HLEN
);
3947 memcpy((*skb
)->data
, (*skb
)->data
+ 4, 4);
3948 memcpy((*skb
)->data
+ 4, (*skb
)->data
+ 8, 4);
3949 memcpy((*skb
)->data
+ 8, (*skb
)->data
+ 12, 4);
3950 tag
= (u16
*)((*skb
)->data
+ 12);
3952 * first two bytes = ETH_P_8021Q (0x8100)
3953 * second two bytes = VLANID
3955 *tag
= __constant_htons(ETH_P_8021Q
);
3956 *(tag
+ 1) = htons(vlan_tx_tag_get(*skb
));
3959 *hdr
= (struct qeth_hdr
*)
3960 qeth_push_skb(card
, skb
, sizeof(struct qeth_hdr
));
3967 qeth_get_qeth_hdr_flags4(int cast_type
)
3969 if (cast_type
== RTN_MULTICAST
)
3970 return QETH_CAST_MULTICAST
;
3971 if (cast_type
== RTN_BROADCAST
)
3972 return QETH_CAST_BROADCAST
;
3973 return QETH_CAST_UNICAST
;
3977 qeth_get_qeth_hdr_flags6(int cast_type
)
3979 u8 ct
= QETH_HDR_PASSTHRU
| QETH_HDR_IPV6
;
3980 if (cast_type
== RTN_MULTICAST
)
3981 return ct
| QETH_CAST_MULTICAST
;
3982 if (cast_type
== RTN_ANYCAST
)
3983 return ct
| QETH_CAST_ANYCAST
;
3984 if (cast_type
== RTN_BROADCAST
)
3985 return ct
| QETH_CAST_BROADCAST
;
3986 return ct
| QETH_CAST_UNICAST
;
3990 qeth_layer2_get_packet_type(struct qeth_card
*card
, struct qeth_hdr
*hdr
,
3991 struct sk_buff
*skb
)
3995 if (!memcmp(skb
->data
+QETH_HEADER_SIZE
,
3996 skb
->dev
->broadcast
,6)) { /* broadcast? */
3997 *(__u32
*)hdr
->hdr
.l2
.flags
|=
3998 QETH_LAYER2_FLAG_BROADCAST
<< 8;
4001 hdr_mac
=*((__u16
*)skb
->data
);
4003 switch (card
->info
.link_type
) {
4004 case QETH_LINK_TYPE_HSTR
:
4005 case QETH_LINK_TYPE_LANE_TR
:
4006 if ((hdr_mac
== QETH_TR_MAC_NC
) ||
4007 (hdr_mac
== QETH_TR_MAC_C
) )
4008 *(__u32
*)hdr
->hdr
.l2
.flags
|=
4009 QETH_LAYER2_FLAG_MULTICAST
<< 8;
4011 *(__u32
*)hdr
->hdr
.l2
.flags
|=
4012 QETH_LAYER2_FLAG_UNICAST
<< 8;
4014 /* eth or so multicast? */
4016 if ( (hdr_mac
==QETH_ETH_MAC_V4
) ||
4017 (hdr_mac
==QETH_ETH_MAC_V6
) )
4018 *(__u32
*)hdr
->hdr
.l2
.flags
|=
4019 QETH_LAYER2_FLAG_MULTICAST
<< 8;
4021 *(__u32
*)hdr
->hdr
.l2
.flags
|=
4022 QETH_LAYER2_FLAG_UNICAST
<< 8;
4027 qeth_layer2_fill_header(struct qeth_card
*card
, struct qeth_hdr
*hdr
,
4028 struct sk_buff
*skb
, int cast_type
)
4030 memset(hdr
, 0, sizeof(struct qeth_hdr
));
4031 hdr
->hdr
.l2
.id
= QETH_HEADER_TYPE_LAYER2
;
4033 /* set byte 0 to "0x02" and byte 3 to casting flags */
4034 if (cast_type
==RTN_MULTICAST
)
4035 *(__u32
*)hdr
->hdr
.l2
.flags
|= QETH_LAYER2_FLAG_MULTICAST
<< 8;
4036 else if (cast_type
==RTN_BROADCAST
)
4037 *(__u32
*)hdr
->hdr
.l2
.flags
|= QETH_LAYER2_FLAG_BROADCAST
<< 8;
4039 qeth_layer2_get_packet_type(card
, hdr
, skb
);
4041 hdr
->hdr
.l2
.pkt_length
= skb
->len
-QETH_HEADER_SIZE
;
4042 #ifdef CONFIG_QETH_VLAN
4043 /* VSWITCH relies on the VLAN
4044 * information to be present in
4045 * the QDIO header */
4046 if ((card
->vlangrp
!= NULL
) &&
4047 vlan_tx_tag_present(skb
)) {
4048 *(__u32
*)hdr
->hdr
.l2
.flags
|= QETH_LAYER2_FLAG_VLAN
<< 8;
4049 hdr
->hdr
.l2
.vlan_id
= vlan_tx_tag_get(skb
);
4055 qeth_fill_header(struct qeth_card
*card
, struct qeth_hdr
*hdr
,
4056 struct sk_buff
*skb
, int ipv
, int cast_type
)
4058 QETH_DBF_TEXT(trace
, 6, "fillhdr");
4060 memset(hdr
, 0, sizeof(struct qeth_hdr
));
4061 if (card
->options
.layer2
) {
4062 qeth_layer2_fill_header(card
, hdr
, skb
, cast_type
);
4065 hdr
->hdr
.l3
.id
= QETH_HEADER_TYPE_LAYER3
;
4066 hdr
->hdr
.l3
.ext_flags
= 0;
4067 #ifdef CONFIG_QETH_VLAN
4069 * before we're going to overwrite this location with next hop ip.
4070 * v6 uses passthrough, v4 sets the tag in the QDIO header.
4072 if (card
->vlangrp
&& vlan_tx_tag_present(skb
)) {
4073 hdr
->hdr
.l3
.ext_flags
= (ipv
== 4) ?
4074 QETH_HDR_EXT_VLAN_FRAME
:
4075 QETH_HDR_EXT_INCLUDE_VLAN_TAG
;
4076 hdr
->hdr
.l3
.vlan_id
= vlan_tx_tag_get(skb
);
4078 #endif /* CONFIG_QETH_VLAN */
4079 hdr
->hdr
.l3
.length
= skb
->len
- sizeof(struct qeth_hdr
);
4080 if (ipv
== 4) { /* IPv4 */
4081 hdr
->hdr
.l3
.flags
= qeth_get_qeth_hdr_flags4(cast_type
);
4082 memset(hdr
->hdr
.l3
.dest_addr
, 0, 12);
4083 if ((skb
->dst
) && (skb
->dst
->neighbour
)) {
4084 *((u32
*) (&hdr
->hdr
.l3
.dest_addr
[12])) =
4085 *((u32
*) skb
->dst
->neighbour
->primary_key
);
4087 /* fill in destination address used in ip header */
4088 *((u32
*) (&hdr
->hdr
.l3
.dest_addr
[12])) = skb
->nh
.iph
->daddr
;
4090 } else if (ipv
== 6) { /* IPv6 or passthru */
4091 hdr
->hdr
.l3
.flags
= qeth_get_qeth_hdr_flags6(cast_type
);
4092 if ((skb
->dst
) && (skb
->dst
->neighbour
)) {
4093 memcpy(hdr
->hdr
.l3
.dest_addr
,
4094 skb
->dst
->neighbour
->primary_key
, 16);
4096 /* fill in destination address used in ip header */
4097 memcpy(hdr
->hdr
.l3
.dest_addr
, &skb
->nh
.ipv6h
->daddr
, 16);
4099 } else { /* passthrough */
4100 if((skb
->dev
->type
== ARPHRD_IEEE802_TR
) &&
4101 !memcmp(skb
->data
+ sizeof(struct qeth_hdr
) +
4102 sizeof(__u16
), skb
->dev
->broadcast
, 6)) {
4103 hdr
->hdr
.l3
.flags
= QETH_CAST_BROADCAST
|
4105 } else if (!memcmp(skb
->data
+ sizeof(struct qeth_hdr
),
4106 skb
->dev
->broadcast
, 6)) { /* broadcast? */
4107 hdr
->hdr
.l3
.flags
= QETH_CAST_BROADCAST
|
4110 hdr
->hdr
.l3
.flags
= (cast_type
== RTN_MULTICAST
) ?
4111 QETH_CAST_MULTICAST
| QETH_HDR_PASSTHRU
:
4112 QETH_CAST_UNICAST
| QETH_HDR_PASSTHRU
;
4118 __qeth_fill_buffer(struct sk_buff
*skb
, struct qdio_buffer
*buffer
,
4119 int is_tso
, int *next_element_to_fill
)
4121 int length
= skb
->len
;
4127 element
= *next_element_to_fill
;
4129 first_lap
= (is_tso
== 0 ? 1 : 0);
4131 while (length
> 0) {
4132 /* length_here is the remaining amount of data in this page */
4133 length_here
= PAGE_SIZE
- ((unsigned long) data
% PAGE_SIZE
);
4134 if (length
< length_here
)
4135 length_here
= length
;
4137 buffer
->element
[element
].addr
= data
;
4138 buffer
->element
[element
].length
= length_here
;
4139 length
-= length_here
;
4142 buffer
->element
[element
].flags
= 0;
4144 buffer
->element
[element
].flags
=
4145 SBAL_FLAGS_LAST_FRAG
;
4148 buffer
->element
[element
].flags
=
4149 SBAL_FLAGS_FIRST_FRAG
;
4151 buffer
->element
[element
].flags
=
4152 SBAL_FLAGS_MIDDLE_FRAG
;
4154 data
+= length_here
;
4158 *next_element_to_fill
= element
;
4162 qeth_fill_buffer(struct qeth_qdio_out_q
*queue
,
4163 struct qeth_qdio_out_buffer
*buf
,
4164 struct sk_buff
*skb
)
4166 struct qdio_buffer
*buffer
;
4167 struct qeth_hdr_tso
*hdr
;
4168 int flush_cnt
= 0, hdr_len
, large_send
= 0;
4170 QETH_DBF_TEXT(trace
, 6, "qdfillbf");
4172 buffer
= buf
->buffer
;
4173 atomic_inc(&skb
->users
);
4174 skb_queue_tail(&buf
->skb_list
, skb
);
4176 hdr
= (struct qeth_hdr_tso
*) skb
->data
;
4177 /*check first on TSO ....*/
4178 if (hdr
->hdr
.hdr
.l3
.id
== QETH_HEADER_TYPE_TSO
) {
4179 int element
= buf
->next_element_to_fill
;
4181 hdr_len
= sizeof(struct qeth_hdr_tso
) + hdr
->ext
.dg_hdr_len
;
4182 /*fill first buffer entry only with header information */
4183 buffer
->element
[element
].addr
= skb
->data
;
4184 buffer
->element
[element
].length
= hdr_len
;
4185 buffer
->element
[element
].flags
= SBAL_FLAGS_FIRST_FRAG
;
4186 buf
->next_element_to_fill
++;
4187 skb
->data
+= hdr_len
;
4188 skb
->len
-= hdr_len
;
4191 if (skb_shinfo(skb
)->nr_frags
== 0)
4192 __qeth_fill_buffer(skb
, buffer
, large_send
,
4193 (int *)&buf
->next_element_to_fill
);
4195 __qeth_fill_buffer_frag(skb
, buffer
, large_send
,
4196 (int *)&buf
->next_element_to_fill
);
4198 if (!queue
->do_pack
) {
4199 QETH_DBF_TEXT(trace
, 6, "fillbfnp");
4200 /* set state to PRIMED -> will be flushed */
4201 atomic_set(&buf
->state
, QETH_QDIO_BUF_PRIMED
);
4204 QETH_DBF_TEXT(trace
, 6, "fillbfpa");
4205 #ifdef CONFIG_QETH_PERF_STATS
4206 queue
->card
->perf_stats
.skbs_sent_pack
++;
4208 if (buf
->next_element_to_fill
>=
4209 QETH_MAX_BUFFER_ELEMENTS(queue
->card
)) {
4211 * packed buffer if full -> set state PRIMED
4212 * -> will be flushed
4214 atomic_set(&buf
->state
, QETH_QDIO_BUF_PRIMED
);
4222 qeth_do_send_packet_fast(struct qeth_card
*card
, struct qeth_qdio_out_q
*queue
,
4223 struct sk_buff
*skb
, struct qeth_hdr
*hdr
,
4224 int elements_needed
,
4225 struct qeth_eddp_context
*ctx
)
4227 struct qeth_qdio_out_buffer
*buffer
;
4228 int buffers_needed
= 0;
4232 QETH_DBF_TEXT(trace
, 6, "dosndpfa");
4234 /* spin until we get the queue ... */
4235 while (atomic_cmpxchg(&queue
->state
, QETH_OUT_Q_UNLOCKED
,
4236 QETH_OUT_Q_LOCKED
) != QETH_OUT_Q_UNLOCKED
);
4237 /* ... now we've got the queue */
4238 index
= queue
->next_buf_to_fill
;
4239 buffer
= &queue
->bufs
[queue
->next_buf_to_fill
];
4241 * check if buffer is empty to make sure that we do not 'overtake'
4242 * ourselves and try to fill a buffer that is already primed
4244 if (atomic_read(&buffer
->state
) != QETH_QDIO_BUF_EMPTY
) {
4245 card
->stats
.tx_dropped
++;
4246 atomic_set(&queue
->state
, QETH_OUT_Q_UNLOCKED
);
4250 queue
->next_buf_to_fill
= (queue
->next_buf_to_fill
+ 1) %
4251 QDIO_MAX_BUFFERS_PER_Q
;
4253 buffers_needed
= qeth_eddp_check_buffers_for_context(queue
,ctx
);
4254 if (buffers_needed
< 0) {
4255 card
->stats
.tx_dropped
++;
4256 atomic_set(&queue
->state
, QETH_OUT_Q_UNLOCKED
);
4259 queue
->next_buf_to_fill
=
4260 (queue
->next_buf_to_fill
+ buffers_needed
) %
4261 QDIO_MAX_BUFFERS_PER_Q
;
4263 atomic_set(&queue
->state
, QETH_OUT_Q_UNLOCKED
);
4265 qeth_fill_buffer(queue
, buffer
, skb
);
4266 qeth_flush_buffers(queue
, 0, index
, 1);
4268 flush_cnt
= qeth_eddp_fill_buffer(queue
, ctx
, index
);
4269 WARN_ON(buffers_needed
!= flush_cnt
);
4270 qeth_flush_buffers(queue
, 0, index
, flush_cnt
);
4276 qeth_do_send_packet(struct qeth_card
*card
, struct qeth_qdio_out_q
*queue
,
4277 struct sk_buff
*skb
, struct qeth_hdr
*hdr
,
4278 int elements_needed
, struct qeth_eddp_context
*ctx
)
4280 struct qeth_qdio_out_buffer
*buffer
;
4282 int flush_count
= 0;
4287 QETH_DBF_TEXT(trace
, 6, "dosndpkt");
4289 /* spin until we get the queue ... */
4290 while (atomic_cmpxchg(&queue
->state
, QETH_OUT_Q_UNLOCKED
,
4291 QETH_OUT_Q_LOCKED
) != QETH_OUT_Q_UNLOCKED
);
4292 start_index
= queue
->next_buf_to_fill
;
4293 buffer
= &queue
->bufs
[queue
->next_buf_to_fill
];
4295 * check if buffer is empty to make sure that we do not 'overtake'
4296 * ourselves and try to fill a buffer that is already primed
4298 if (atomic_read(&buffer
->state
) != QETH_QDIO_BUF_EMPTY
){
4299 card
->stats
.tx_dropped
++;
4300 atomic_set(&queue
->state
, QETH_OUT_Q_UNLOCKED
);
4303 /* check if we need to switch packing state of this queue */
4304 qeth_switch_to_packing_if_needed(queue
);
4305 if (queue
->do_pack
){
4308 /* does packet fit in current buffer? */
4309 if((QETH_MAX_BUFFER_ELEMENTS(card
) -
4310 buffer
->next_element_to_fill
) < elements_needed
){
4311 /* ... no -> set state PRIMED */
4312 atomic_set(&buffer
->state
,QETH_QDIO_BUF_PRIMED
);
4314 queue
->next_buf_to_fill
=
4315 (queue
->next_buf_to_fill
+ 1) %
4316 QDIO_MAX_BUFFERS_PER_Q
;
4317 buffer
= &queue
->bufs
[queue
->next_buf_to_fill
];
4318 /* we did a step forward, so check buffer state
4320 if (atomic_read(&buffer
->state
) !=
4321 QETH_QDIO_BUF_EMPTY
){
4322 card
->stats
.tx_dropped
++;
4323 qeth_flush_buffers(queue
, 0, start_index
, flush_count
);
4324 atomic_set(&queue
->state
, QETH_OUT_Q_UNLOCKED
);
4329 /* check if we have enough elements (including following
4330 * free buffers) to handle eddp context */
4331 if (qeth_eddp_check_buffers_for_context(queue
,ctx
) < 0){
4332 printk("eddp tx_dropped 1\n");
4333 card
->stats
.tx_dropped
++;
4340 tmp
= qeth_fill_buffer(queue
, buffer
, skb
);
4342 tmp
= qeth_eddp_fill_buffer(queue
,ctx
,queue
->next_buf_to_fill
);
4344 printk("eddp tx_dropped 2\n");
4345 card
->stats
.tx_dropped
++;
4350 queue
->next_buf_to_fill
= (queue
->next_buf_to_fill
+ tmp
) %
4351 QDIO_MAX_BUFFERS_PER_Q
;
4355 qeth_flush_buffers(queue
, 0, start_index
, flush_count
);
4356 else if (!atomic_read(&queue
->set_pci_flags_count
))
4357 atomic_swap(&queue
->state
, QETH_OUT_Q_LOCKED_FLUSH
);
4359 * queue->state will go from LOCKED -> UNLOCKED or from
4360 * LOCKED_FLUSH -> LOCKED if output_handler wanted to 'notify' us
4361 * (switch packing state or flush buffer to get another pci flag out).
4362 * In that case we will enter this loop
4364 while (atomic_dec_return(&queue
->state
)){
4366 start_index
= queue
->next_buf_to_fill
;
4367 /* check if we can go back to non-packing state */
4368 flush_count
+= qeth_switch_to_nonpacking_if_needed(queue
);
4370 * check if we need to flush a packing buffer to get a pci
4371 * flag out on the queue
4373 if (!flush_count
&& !atomic_read(&queue
->set_pci_flags_count
))
4374 flush_count
+= qeth_flush_buffers_on_no_pci(queue
);
4376 qeth_flush_buffers(queue
, 0, start_index
, flush_count
);
4378 /* at this point the queue is UNLOCKED again */
4379 #ifdef CONFIG_QETH_PERF_STATS
4381 queue
->card
->perf_stats
.bufs_sent_pack
+= flush_count
;
4382 #endif /* CONFIG_QETH_PERF_STATS */
4388 qeth_get_elements_no(struct qeth_card
*card
, void *hdr
,
4389 struct sk_buff
*skb
, int elems
)
4391 int elements_needed
= 0;
4393 if (skb_shinfo(skb
)->nr_frags
> 0) {
4394 elements_needed
= (skb_shinfo(skb
)->nr_frags
+ 1);
4396 if (elements_needed
== 0 )
4397 elements_needed
= 1 + (((((unsigned long) hdr
) % PAGE_SIZE
)
4398 + skb
->len
) >> PAGE_SHIFT
);
4399 if ((elements_needed
+ elems
) > QETH_MAX_BUFFER_ELEMENTS(card
)){
4400 PRINT_ERR("qeth_do_send_packet: invalid size of "
4401 "IP packet (Number=%d / Length=%d). Discarded.\n",
4402 (elements_needed
+elems
), skb
->len
);
4405 return elements_needed
;
4409 qeth_send_packet(struct qeth_card
*card
, struct sk_buff
*skb
)
4413 struct qeth_qdio_out_q
*queue
;
4414 struct qeth_hdr
*hdr
= NULL
;
4415 int elements_needed
= 0;
4416 enum qeth_large_send_types large_send
= QETH_LARGE_SEND_NO
;
4417 struct qeth_eddp_context
*ctx
= NULL
;
4418 int tx_bytes
= skb
->len
;
4419 unsigned short nr_frags
= skb_shinfo(skb
)->nr_frags
;
4420 unsigned short tso_size
= skb_shinfo(skb
)->tso_size
;
4423 QETH_DBF_TEXT(trace
, 6, "sendpkt");
4425 if (!card
->options
.layer2
) {
4426 ipv
= qeth_get_ip_version(skb
);
4427 if ((card
->dev
->hard_header
== qeth_fake_header
) && ipv
) {
4428 if ((skb
= qeth_pskb_unshare(skb
,GFP_ATOMIC
)) == NULL
) {
4429 card
->stats
.tx_dropped
++;
4430 dev_kfree_skb_irq(skb
);
4433 if(card
->dev
->type
== ARPHRD_IEEE802_TR
){
4434 skb_pull(skb
, QETH_FAKE_LL_LEN_TR
);
4436 skb_pull(skb
, QETH_FAKE_LL_LEN_ETH
);
4440 if ((card
->info
.type
== QETH_CARD_TYPE_OSN
) &&
4441 (skb
->protocol
== htons(ETH_P_IPV6
))) {
4442 dev_kfree_skb_any(skb
);
4445 cast_type
= qeth_get_cast_type(card
, skb
);
4446 if ((cast_type
== RTN_BROADCAST
) &&
4447 (card
->info
.broadcast_capable
== 0)){
4448 card
->stats
.tx_dropped
++;
4449 card
->stats
.tx_errors
++;
4450 dev_kfree_skb_any(skb
);
4451 return NETDEV_TX_OK
;
4453 queue
= card
->qdio
.out_qs
4454 [qeth_get_priority_queue(card
, skb
, ipv
, cast_type
)];
4456 if (skb_shinfo(skb
)->tso_size
)
4457 large_send
= card
->options
.large_send
;
4459 /*are we able to do TSO ? If so ,prepare and send it from here */
4460 if ((large_send
== QETH_LARGE_SEND_TSO
) &&
4461 (cast_type
== RTN_UNSPEC
)) {
4462 rc
= qeth_tso_prepare_packet(card
, skb
, ipv
, cast_type
);
4464 card
->stats
.tx_dropped
++;
4465 card
->stats
.tx_errors
++;
4466 dev_kfree_skb_any(skb
);
4467 return NETDEV_TX_OK
;
4471 if ((rc
= qeth_prepare_skb(card
, &skb
, &hdr
, ipv
))) {
4472 QETH_DBF_TEXT_(trace
, 4, "pskbe%d", rc
);
4475 if (card
->info
.type
!= QETH_CARD_TYPE_OSN
)
4476 qeth_fill_header(card
, hdr
, skb
, ipv
, cast_type
);
4479 if (large_send
== QETH_LARGE_SEND_EDDP
) {
4480 ctx
= qeth_eddp_create_context(card
, skb
, hdr
);
4482 PRINT_WARN("could not create eddp context\n");
4486 int elems
= qeth_get_elements_no(card
,(void*) hdr
, skb
,
4490 elements_needed
+= elems
;
4493 if (card
->info
.type
!= QETH_CARD_TYPE_IQD
)
4494 rc
= qeth_do_send_packet(card
, queue
, skb
, hdr
,
4495 elements_needed
, ctx
);
4497 rc
= qeth_do_send_packet_fast(card
, queue
, skb
, hdr
,
4498 elements_needed
, ctx
);
4500 card
->stats
.tx_packets
++;
4501 card
->stats
.tx_bytes
+= tx_bytes
;
4502 #ifdef CONFIG_QETH_PERF_STATS
4504 !(large_send
== QETH_LARGE_SEND_NO
)) {
4505 card
->perf_stats
.large_send_bytes
+= tx_bytes
;
4506 card
->perf_stats
.large_send_cnt
++;
4509 card
->perf_stats
.sg_skbs_sent
++;
4510 /* nr_frags + skb->data */
4511 card
->perf_stats
.sg_frags_sent
+=
4514 #endif /* CONFIG_QETH_PERF_STATS */
4517 /* drop creator's reference */
4518 qeth_eddp_put_context(ctx
);
4519 /* free skb; it's not referenced by a buffer */
4521 dev_kfree_skb_any(skb
);
4528 qeth_mdio_read(struct net_device
*dev
, int phy_id
, int regnum
)
4530 struct qeth_card
*card
= (struct qeth_card
*) dev
->priv
;
4534 case MII_BMCR
: /* Basic mode control register */
4536 if ((card
->info
.link_type
!= QETH_LINK_TYPE_GBIT_ETH
)&&
4537 (card
->info
.link_type
!= QETH_LINK_TYPE_OSN
) &&
4538 (card
->info
.link_type
!= QETH_LINK_TYPE_10GBIT_ETH
))
4539 rc
|= BMCR_SPEED100
;
4541 case MII_BMSR
: /* Basic mode status register */
4542 rc
= BMSR_ERCAP
| BMSR_ANEGCOMPLETE
| BMSR_LSTATUS
|
4543 BMSR_10HALF
| BMSR_10FULL
| BMSR_100HALF
| BMSR_100FULL
|
4546 case MII_PHYSID1
: /* PHYS ID 1 */
4547 rc
= (dev
->dev_addr
[0] << 16) | (dev
->dev_addr
[1] << 8) |
4549 rc
= (rc
>> 5) & 0xFFFF;
4551 case MII_PHYSID2
: /* PHYS ID 2 */
4552 rc
= (dev
->dev_addr
[2] << 10) & 0xFFFF;
4554 case MII_ADVERTISE
: /* Advertisement control reg */
4557 case MII_LPA
: /* Link partner ability reg */
4558 rc
= LPA_10HALF
| LPA_10FULL
| LPA_100HALF
| LPA_100FULL
|
4559 LPA_100BASE4
| LPA_LPACK
;
4561 case MII_EXPANSION
: /* Expansion register */
4563 case MII_DCOUNTER
: /* disconnect counter */
4565 case MII_FCSCOUNTER
: /* false carrier counter */
4567 case MII_NWAYTEST
: /* N-way auto-neg test register */
4569 case MII_RERRCOUNTER
: /* rx error counter */
4570 rc
= card
->stats
.rx_errors
;
4572 case MII_SREVISION
: /* silicon revision */
4574 case MII_RESV1
: /* reserved 1 */
4576 case MII_LBRERROR
: /* loopback, rx, bypass error */
4578 case MII_PHYADDR
: /* physical address */
4580 case MII_RESV2
: /* reserved 2 */
4582 case MII_TPISTATUS
: /* TPI status for 10mbps */
4584 case MII_NCONFIG
: /* network interface config */
4593 static inline const char *
4594 qeth_arp_get_error_cause(int *rc
)
4597 case QETH_IPA_ARP_RC_FAILED
:
4599 return "operation failed";
4600 case QETH_IPA_ARP_RC_NOTSUPP
:
4602 return "operation not supported";
4603 case QETH_IPA_ARP_RC_OUT_OF_RANGE
:
4605 return "argument out of range";
4606 case QETH_IPA_ARP_RC_Q_NOTSUPP
:
4608 return "query operation not supported";
4609 case QETH_IPA_ARP_RC_Q_NO_DATA
:
4611 return "no query data available";
4613 return "unknown error";
4618 qeth_send_simple_setassparms(struct qeth_card
*, enum qeth_ipa_funcs
,
4622 qeth_arp_set_no_entries(struct qeth_card
*card
, int no_entries
)
4627 QETH_DBF_TEXT(trace
,3,"arpstnoe");
4630 * currently GuestLAN only supports the ARP assist function
4631 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_SET_NO_ENTRIES;
4632 * thus we say EOPNOTSUPP for this ARP function
4634 if (card
->info
.guestlan
)
4636 if (!qeth_is_supported(card
,IPA_ARP_PROCESSING
)) {
4637 PRINT_WARN("ARP processing not supported "
4638 "on %s!\n", QETH_CARD_IFNAME(card
));
4641 rc
= qeth_send_simple_setassparms(card
, IPA_ARP_PROCESSING
,
4642 IPA_CMD_ASS_ARP_SET_NO_ENTRIES
,
4646 PRINT_WARN("Could not set number of ARP entries on %s: "
4648 QETH_CARD_IFNAME(card
), qeth_arp_get_error_cause(&rc
),
4655 qeth_copy_arp_entries_stripped(struct qeth_arp_query_info
*qinfo
,
4656 struct qeth_arp_query_data
*qdata
,
4657 int entry_size
, int uentry_size
)
4663 entry_ptr
= (char *)&qdata
->data
;
4664 uentry_ptr
= (char *)(qinfo
->udata
+ qinfo
->udata_offset
);
4665 for (i
= 0; i
< qdata
->no_entries
; ++i
){
4666 /* strip off 32 bytes "media specific information" */
4667 memcpy(uentry_ptr
, (entry_ptr
+ 32), entry_size
- 32);
4668 entry_ptr
+= entry_size
;
4669 uentry_ptr
+= uentry_size
;
4674 qeth_arp_query_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
4677 struct qeth_ipa_cmd
*cmd
;
4678 struct qeth_arp_query_data
*qdata
;
4679 struct qeth_arp_query_info
*qinfo
;
4684 QETH_DBF_TEXT(trace
,4,"arpquecb");
4686 qinfo
= (struct qeth_arp_query_info
*) reply
->param
;
4687 cmd
= (struct qeth_ipa_cmd
*) data
;
4688 if (cmd
->hdr
.return_code
) {
4689 QETH_DBF_TEXT_(trace
,4,"qaer1%i", cmd
->hdr
.return_code
);
4692 if (cmd
->data
.setassparms
.hdr
.return_code
) {
4693 cmd
->hdr
.return_code
= cmd
->data
.setassparms
.hdr
.return_code
;
4694 QETH_DBF_TEXT_(trace
,4,"qaer2%i", cmd
->hdr
.return_code
);
4697 qdata
= &cmd
->data
.setassparms
.data
.query_arp
;
4698 switch(qdata
->reply_bits
){
4700 uentry_size
= entry_size
= sizeof(struct qeth_arp_qi_entry5
);
4701 if (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
)
4702 uentry_size
= sizeof(struct qeth_arp_qi_entry5_short
);
4705 /* fall through to default */
4707 /* tr is the same as eth -> entry7 */
4708 uentry_size
= entry_size
= sizeof(struct qeth_arp_qi_entry7
);
4709 if (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
)
4710 uentry_size
= sizeof(struct qeth_arp_qi_entry7_short
);
4713 /* check if there is enough room in userspace */
4714 if ((qinfo
->udata_len
- qinfo
->udata_offset
) <
4715 qdata
->no_entries
* uentry_size
){
4716 QETH_DBF_TEXT_(trace
, 4, "qaer3%i", -ENOMEM
);
4717 cmd
->hdr
.return_code
= -ENOMEM
;
4718 PRINT_WARN("query ARP user space buffer is too small for "
4719 "the returned number of ARP entries. "
4720 "Aborting query!\n");
4723 QETH_DBF_TEXT_(trace
, 4, "anore%i",
4724 cmd
->data
.setassparms
.hdr
.number_of_replies
);
4725 QETH_DBF_TEXT_(trace
, 4, "aseqn%i", cmd
->data
.setassparms
.hdr
.seq_no
);
4726 QETH_DBF_TEXT_(trace
, 4, "anoen%i", qdata
->no_entries
);
4728 if (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
) {
4729 /* strip off "media specific information" */
4730 qeth_copy_arp_entries_stripped(qinfo
, qdata
, entry_size
,
4733 /*copy entries to user buffer*/
4734 memcpy(qinfo
->udata
+ qinfo
->udata_offset
,
4735 (char *)&qdata
->data
, qdata
->no_entries
*uentry_size
);
4737 qinfo
->no_entries
+= qdata
->no_entries
;
4738 qinfo
->udata_offset
+= (qdata
->no_entries
*uentry_size
);
4739 /* check if all replies received ... */
4740 if (cmd
->data
.setassparms
.hdr
.seq_no
<
4741 cmd
->data
.setassparms
.hdr
.number_of_replies
)
4743 memcpy(qinfo
->udata
, &qinfo
->no_entries
, 4);
4744 /* keep STRIP_ENTRIES flag so the user program can distinguish
4745 * stripped entries from normal ones */
4746 if (qinfo
->mask_bits
& QETH_QARP_STRIP_ENTRIES
)
4747 qdata
->reply_bits
|= QETH_QARP_STRIP_ENTRIES
;
4748 memcpy(qinfo
->udata
+ QETH_QARP_MASK_OFFSET
,&qdata
->reply_bits
,2);
4752 memcpy(qinfo
->udata
, &i
, 4);
4757 qeth_send_ipa_arp_cmd(struct qeth_card
*card
, struct qeth_cmd_buffer
*iob
,
4758 int len
, int (*reply_cb
)(struct qeth_card
*,
4759 struct qeth_reply
*,
4763 QETH_DBF_TEXT(trace
,4,"sendarp");
4765 memcpy(iob
->data
, IPA_PDU_HEADER
, IPA_PDU_HEADER_SIZE
);
4766 memcpy(QETH_IPA_CMD_DEST_ADDR(iob
->data
),
4767 &card
->token
.ulp_connection_r
, QETH_MPC_TOKEN_LENGTH
);
4768 return qeth_send_control_data(card
, IPA_PDU_HEADER_SIZE
+ len
, iob
,
4769 reply_cb
, reply_param
);
4773 qeth_send_ipa_snmp_cmd(struct qeth_card
*card
, struct qeth_cmd_buffer
*iob
,
4774 int len
, int (*reply_cb
)(struct qeth_card
*,
4775 struct qeth_reply
*,
4781 QETH_DBF_TEXT(trace
,4,"sendsnmp");
4783 memcpy(iob
->data
, IPA_PDU_HEADER
, IPA_PDU_HEADER_SIZE
);
4784 memcpy(QETH_IPA_CMD_DEST_ADDR(iob
->data
),
4785 &card
->token
.ulp_connection_r
, QETH_MPC_TOKEN_LENGTH
);
4786 /* adjust PDU length fields in IPA_PDU_HEADER */
4787 s1
= (u32
) IPA_PDU_HEADER_SIZE
+ len
;
4789 memcpy(QETH_IPA_PDU_LEN_TOTAL(iob
->data
), &s1
, 2);
4790 memcpy(QETH_IPA_PDU_LEN_PDU1(iob
->data
), &s2
, 2);
4791 memcpy(QETH_IPA_PDU_LEN_PDU2(iob
->data
), &s2
, 2);
4792 memcpy(QETH_IPA_PDU_LEN_PDU3(iob
->data
), &s2
, 2);
4793 return qeth_send_control_data(card
, IPA_PDU_HEADER_SIZE
+ len
, iob
,
4794 reply_cb
, reply_param
);
4797 static struct qeth_cmd_buffer
*
4798 qeth_get_setassparms_cmd(struct qeth_card
*, enum qeth_ipa_funcs
,
4799 __u16
, __u16
, enum qeth_prot_versions
);
4801 qeth_arp_query(struct qeth_card
*card
, char *udata
)
4803 struct qeth_cmd_buffer
*iob
;
4804 struct qeth_arp_query_info qinfo
= {0, };
4808 QETH_DBF_TEXT(trace
,3,"arpquery");
4810 if (!qeth_is_supported(card
,/*IPA_QUERY_ARP_ADDR_INFO*/
4811 IPA_ARP_PROCESSING
)) {
4812 PRINT_WARN("ARP processing not supported "
4813 "on %s!\n", QETH_CARD_IFNAME(card
));
4816 /* get size of userspace buffer and mask_bits -> 6 bytes */
4817 if (copy_from_user(&qinfo
, udata
, 6))
4819 if (!(qinfo
.udata
= kzalloc(qinfo
.udata_len
, GFP_KERNEL
)))
4821 qinfo
.udata_offset
= QETH_QARP_ENTRIES_OFFSET
;
4822 iob
= qeth_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
4823 IPA_CMD_ASS_ARP_QUERY_INFO
,
4824 sizeof(int),QETH_PROT_IPV4
);
4826 rc
= qeth_send_ipa_arp_cmd(card
, iob
,
4827 QETH_SETASS_BASE_LEN
+QETH_ARP_CMD_LEN
,
4828 qeth_arp_query_cb
, (void *)&qinfo
);
4831 PRINT_WARN("Error while querying ARP cache on %s: %s "
4833 QETH_CARD_IFNAME(card
), qeth_arp_get_error_cause(&rc
),
4835 copy_to_user(udata
, qinfo
.udata
, 4);
4837 copy_to_user(udata
, qinfo
.udata
, qinfo
.udata_len
);
4844 * SNMP command callback
4847 qeth_snmp_command_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
4848 unsigned long sdata
)
4850 struct qeth_ipa_cmd
*cmd
;
4851 struct qeth_arp_query_info
*qinfo
;
4852 struct qeth_snmp_cmd
*snmp
;
4853 unsigned char *data
;
4856 QETH_DBF_TEXT(trace
,3,"snpcmdcb");
4858 cmd
= (struct qeth_ipa_cmd
*) sdata
;
4859 data
= (unsigned char *)((char *)cmd
- reply
->offset
);
4860 qinfo
= (struct qeth_arp_query_info
*) reply
->param
;
4861 snmp
= &cmd
->data
.setadapterparms
.data
.snmp
;
4863 if (cmd
->hdr
.return_code
) {
4864 QETH_DBF_TEXT_(trace
,4,"scer1%i", cmd
->hdr
.return_code
);
4867 if (cmd
->data
.setadapterparms
.hdr
.return_code
) {
4868 cmd
->hdr
.return_code
= cmd
->data
.setadapterparms
.hdr
.return_code
;
4869 QETH_DBF_TEXT_(trace
,4,"scer2%i", cmd
->hdr
.return_code
);
4872 data_len
= *((__u16
*)QETH_IPA_PDU_LEN_PDU1(data
));
4873 if (cmd
->data
.setadapterparms
.hdr
.seq_no
== 1)
4874 data_len
-= (__u16
)((char *)&snmp
->data
- (char *)cmd
);
4876 data_len
-= (__u16
)((char*)&snmp
->request
- (char *)cmd
);
4878 /* check if there is enough room in userspace */
4879 if ((qinfo
->udata_len
- qinfo
->udata_offset
) < data_len
) {
4880 QETH_DBF_TEXT_(trace
, 4, "scer3%i", -ENOMEM
);
4881 cmd
->hdr
.return_code
= -ENOMEM
;
4884 QETH_DBF_TEXT_(trace
, 4, "snore%i",
4885 cmd
->data
.setadapterparms
.hdr
.used_total
);
4886 QETH_DBF_TEXT_(trace
, 4, "sseqn%i", cmd
->data
.setadapterparms
.hdr
.seq_no
);
4887 /*copy entries to user buffer*/
4888 if (cmd
->data
.setadapterparms
.hdr
.seq_no
== 1) {
4889 memcpy(qinfo
->udata
+ qinfo
->udata_offset
,
4891 data_len
+ offsetof(struct qeth_snmp_cmd
,data
));
4892 qinfo
->udata_offset
+= offsetof(struct qeth_snmp_cmd
, data
);
4894 memcpy(qinfo
->udata
+ qinfo
->udata_offset
,
4895 (char *)&snmp
->request
, data_len
);
4897 qinfo
->udata_offset
+= data_len
;
4898 /* check if all replies received ... */
4899 QETH_DBF_TEXT_(trace
, 4, "srtot%i",
4900 cmd
->data
.setadapterparms
.hdr
.used_total
);
4901 QETH_DBF_TEXT_(trace
, 4, "srseq%i",
4902 cmd
->data
.setadapterparms
.hdr
.seq_no
);
4903 if (cmd
->data
.setadapterparms
.hdr
.seq_no
<
4904 cmd
->data
.setadapterparms
.hdr
.used_total
)
4909 static struct qeth_cmd_buffer
*
4910 qeth_get_ipacmd_buffer(struct qeth_card
*, enum qeth_ipa_cmds
,
4911 enum qeth_prot_versions
);
4913 static struct qeth_cmd_buffer
*
4914 qeth_get_adapter_cmd(struct qeth_card
*card
, __u32 command
, __u32 cmdlen
)
4916 struct qeth_cmd_buffer
*iob
;
4917 struct qeth_ipa_cmd
*cmd
;
4919 iob
= qeth_get_ipacmd_buffer(card
,IPA_CMD_SETADAPTERPARMS
,
4921 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
4922 cmd
->data
.setadapterparms
.hdr
.cmdlength
= cmdlen
;
4923 cmd
->data
.setadapterparms
.hdr
.command_code
= command
;
4924 cmd
->data
.setadapterparms
.hdr
.used_total
= 1;
4925 cmd
->data
.setadapterparms
.hdr
.seq_no
= 1;
4931 * function to send SNMP commands to OSA-E card
4934 qeth_snmp_command(struct qeth_card
*card
, char *udata
)
4936 struct qeth_cmd_buffer
*iob
;
4937 struct qeth_ipa_cmd
*cmd
;
4938 struct qeth_snmp_ureq
*ureq
;
4940 struct qeth_arp_query_info qinfo
= {0, };
4943 QETH_DBF_TEXT(trace
,3,"snmpcmd");
4945 if (card
->info
.guestlan
)
4948 if ((!qeth_adp_supported(card
,IPA_SETADP_SET_SNMP_CONTROL
)) &&
4949 (!card
->options
.layer2
) ) {
4950 PRINT_WARN("SNMP Query MIBS not supported "
4951 "on %s!\n", QETH_CARD_IFNAME(card
));
4954 /* skip 4 bytes (data_len struct member) to get req_len */
4955 if (copy_from_user(&req_len
, udata
+ sizeof(int), sizeof(int)))
4957 ureq
= kmalloc(req_len
+sizeof(struct qeth_snmp_ureq_hdr
), GFP_KERNEL
);
4959 QETH_DBF_TEXT(trace
, 2, "snmpnome");
4962 if (copy_from_user(ureq
, udata
,
4963 req_len
+sizeof(struct qeth_snmp_ureq_hdr
))){
4967 qinfo
.udata_len
= ureq
->hdr
.data_len
;
4968 if (!(qinfo
.udata
= kzalloc(qinfo
.udata_len
, GFP_KERNEL
))){
4972 qinfo
.udata_offset
= sizeof(struct qeth_snmp_ureq_hdr
);
4974 iob
= qeth_get_adapter_cmd(card
, IPA_SETADP_SET_SNMP_CONTROL
,
4975 QETH_SNMP_SETADP_CMDLENGTH
+ req_len
);
4976 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
4977 memcpy(&cmd
->data
.setadapterparms
.data
.snmp
, &ureq
->cmd
, req_len
);
4978 rc
= qeth_send_ipa_snmp_cmd(card
, iob
, QETH_SETADP_BASE_LEN
+ req_len
,
4979 qeth_snmp_command_cb
, (void *)&qinfo
);
4981 PRINT_WARN("SNMP command failed on %s: (0x%x)\n",
4982 QETH_CARD_IFNAME(card
), rc
);
4984 copy_to_user(udata
, qinfo
.udata
, qinfo
.udata_len
);
4992 qeth_default_setassparms_cb(struct qeth_card
*, struct qeth_reply
*,
4996 qeth_default_setadapterparms_cb(struct qeth_card
*card
,
4997 struct qeth_reply
*reply
,
4998 unsigned long data
);
5000 qeth_send_setassparms(struct qeth_card
*, struct qeth_cmd_buffer
*,
5003 (struct qeth_card
*, struct qeth_reply
*, unsigned long),
5007 qeth_arp_add_entry(struct qeth_card
*card
, struct qeth_arp_cache_entry
*entry
)
5009 struct qeth_cmd_buffer
*iob
;
5014 QETH_DBF_TEXT(trace
,3,"arpadent");
5017 * currently GuestLAN only supports the ARP assist function
5018 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_ADD_ENTRY;
5019 * thus we say EOPNOTSUPP for this ARP function
5021 if (card
->info
.guestlan
)
5023 if (!qeth_is_supported(card
,IPA_ARP_PROCESSING
)) {
5024 PRINT_WARN("ARP processing not supported "
5025 "on %s!\n", QETH_CARD_IFNAME(card
));
5029 iob
= qeth_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
5030 IPA_CMD_ASS_ARP_ADD_ENTRY
,
5031 sizeof(struct qeth_arp_cache_entry
),
5033 rc
= qeth_send_setassparms(card
, iob
,
5034 sizeof(struct qeth_arp_cache_entry
),
5035 (unsigned long) entry
,
5036 qeth_default_setassparms_cb
, NULL
);
5039 qeth_ipaddr4_to_string((u8
*)entry
->ipaddr
, buf
);
5040 PRINT_WARN("Could not add ARP entry for address %s on %s: "
5042 buf
, QETH_CARD_IFNAME(card
),
5043 qeth_arp_get_error_cause(&rc
), tmp
, tmp
);
5049 qeth_arp_remove_entry(struct qeth_card
*card
, struct qeth_arp_cache_entry
*entry
)
5051 struct qeth_cmd_buffer
*iob
;
5052 char buf
[16] = {0, };
5056 QETH_DBF_TEXT(trace
,3,"arprment");
5059 * currently GuestLAN only supports the ARP assist function
5060 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_REMOVE_ENTRY;
5061 * thus we say EOPNOTSUPP for this ARP function
5063 if (card
->info
.guestlan
)
5065 if (!qeth_is_supported(card
,IPA_ARP_PROCESSING
)) {
5066 PRINT_WARN("ARP processing not supported "
5067 "on %s!\n", QETH_CARD_IFNAME(card
));
5070 memcpy(buf
, entry
, 12);
5071 iob
= qeth_get_setassparms_cmd(card
, IPA_ARP_PROCESSING
,
5072 IPA_CMD_ASS_ARP_REMOVE_ENTRY
,
5075 rc
= qeth_send_setassparms(card
, iob
,
5076 12, (unsigned long)buf
,
5077 qeth_default_setassparms_cb
, NULL
);
5081 qeth_ipaddr4_to_string((u8
*)entry
->ipaddr
, buf
);
5082 PRINT_WARN("Could not delete ARP entry for address %s on %s: "
5084 buf
, QETH_CARD_IFNAME(card
),
5085 qeth_arp_get_error_cause(&rc
), tmp
, tmp
);
5091 qeth_arp_flush_cache(struct qeth_card
*card
)
5096 QETH_DBF_TEXT(trace
,3,"arpflush");
5099 * currently GuestLAN only supports the ARP assist function
5100 * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_FLUSH_CACHE;
5101 * thus we say EOPNOTSUPP for this ARP function
5103 if (card
->info
.guestlan
|| (card
->info
.type
== QETH_CARD_TYPE_IQD
))
5105 if (!qeth_is_supported(card
,IPA_ARP_PROCESSING
)) {
5106 PRINT_WARN("ARP processing not supported "
5107 "on %s!\n", QETH_CARD_IFNAME(card
));
5110 rc
= qeth_send_simple_setassparms(card
, IPA_ARP_PROCESSING
,
5111 IPA_CMD_ASS_ARP_FLUSH_CACHE
, 0);
5114 PRINT_WARN("Could not flush ARP cache on %s: %s (0x%x/%d)\n",
5115 QETH_CARD_IFNAME(card
), qeth_arp_get_error_cause(&rc
),
5122 qeth_do_ioctl(struct net_device
*dev
, struct ifreq
*rq
, int cmd
)
5124 struct qeth_card
*card
= (struct qeth_card
*)dev
->priv
;
5125 struct qeth_arp_cache_entry arp_entry
;
5126 struct mii_ioctl_data
*mii_data
;
5132 if ((card
->state
!= CARD_STATE_UP
) &&
5133 (card
->state
!= CARD_STATE_SOFTSETUP
))
5136 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
5140 case SIOC_QETH_ARP_SET_NO_ENTRIES
:
5141 if ( !capable(CAP_NET_ADMIN
) ||
5142 (card
->options
.layer2
) ) {
5146 rc
= qeth_arp_set_no_entries(card
, rq
->ifr_ifru
.ifru_ivalue
);
5148 case SIOC_QETH_ARP_QUERY_INFO
:
5149 if ( !capable(CAP_NET_ADMIN
) ||
5150 (card
->options
.layer2
) ) {
5154 rc
= qeth_arp_query(card
, rq
->ifr_ifru
.ifru_data
);
5156 case SIOC_QETH_ARP_ADD_ENTRY
:
5157 if ( !capable(CAP_NET_ADMIN
) ||
5158 (card
->options
.layer2
) ) {
5162 if (copy_from_user(&arp_entry
, rq
->ifr_ifru
.ifru_data
,
5163 sizeof(struct qeth_arp_cache_entry
)))
5166 rc
= qeth_arp_add_entry(card
, &arp_entry
);
5168 case SIOC_QETH_ARP_REMOVE_ENTRY
:
5169 if ( !capable(CAP_NET_ADMIN
) ||
5170 (card
->options
.layer2
) ) {
5174 if (copy_from_user(&arp_entry
, rq
->ifr_ifru
.ifru_data
,
5175 sizeof(struct qeth_arp_cache_entry
)))
5178 rc
= qeth_arp_remove_entry(card
, &arp_entry
);
5180 case SIOC_QETH_ARP_FLUSH_CACHE
:
5181 if ( !capable(CAP_NET_ADMIN
) ||
5182 (card
->options
.layer2
) ) {
5186 rc
= qeth_arp_flush_cache(card
);
5188 case SIOC_QETH_ADP_SET_SNMP_CONTROL
:
5189 rc
= qeth_snmp_command(card
, rq
->ifr_ifru
.ifru_data
);
5191 case SIOC_QETH_GET_CARD_TYPE
:
5192 if ((card
->info
.type
== QETH_CARD_TYPE_OSAE
) &&
5193 !card
->info
.guestlan
)
5198 mii_data
= if_mii(rq
);
5199 mii_data
->phy_id
= 0;
5202 mii_data
= if_mii(rq
);
5203 if (mii_data
->phy_id
!= 0)
5206 mii_data
->val_out
= qeth_mdio_read(dev
,mii_data
->phy_id
,
5213 QETH_DBF_TEXT_(trace
, 2, "ioce%d", rc
);
5217 static struct net_device_stats
*
5218 qeth_get_stats(struct net_device
*dev
)
5220 struct qeth_card
*card
;
5222 card
= (struct qeth_card
*) (dev
->priv
);
5224 QETH_DBF_TEXT(trace
,5,"getstat");
5226 return &card
->stats
;
5230 qeth_change_mtu(struct net_device
*dev
, int new_mtu
)
5232 struct qeth_card
*card
;
5235 card
= (struct qeth_card
*) (dev
->priv
);
5237 QETH_DBF_TEXT(trace
,4,"chgmtu");
5238 sprintf(dbf_text
, "%8x", new_mtu
);
5239 QETH_DBF_TEXT(trace
,4,dbf_text
);
5243 if (new_mtu
> 65535)
5245 if ((!qeth_is_supported(card
,IPA_IP_FRAGMENTATION
)) &&
5246 (!qeth_mtu_is_valid(card
, new_mtu
)))
5252 #ifdef CONFIG_QETH_VLAN
5254 qeth_vlan_rx_register(struct net_device
*dev
, struct vlan_group
*grp
)
5256 struct qeth_card
*card
;
5257 unsigned long flags
;
5259 QETH_DBF_TEXT(trace
,4,"vlanreg");
5261 card
= (struct qeth_card
*) dev
->priv
;
5262 spin_lock_irqsave(&card
->vlanlock
, flags
);
5263 card
->vlangrp
= grp
;
5264 spin_unlock_irqrestore(&card
->vlanlock
, flags
);
5268 qeth_free_vlan_buffer(struct qeth_card
*card
, struct qeth_qdio_out_buffer
*buf
,
5272 struct sk_buff
*skb
;
5273 struct sk_buff_head tmp_list
;
5275 skb_queue_head_init(&tmp_list
);
5276 for(i
= 0; i
< QETH_MAX_BUFFER_ELEMENTS(card
); ++i
){
5277 while ((skb
= skb_dequeue(&buf
->skb_list
))){
5278 if (vlan_tx_tag_present(skb
) &&
5279 (vlan_tx_tag_get(skb
) == vid
)) {
5280 atomic_dec(&skb
->users
);
5283 skb_queue_tail(&tmp_list
, skb
);
5286 while ((skb
= skb_dequeue(&tmp_list
)))
5287 skb_queue_tail(&buf
->skb_list
, skb
);
5291 qeth_free_vlan_skbs(struct qeth_card
*card
, unsigned short vid
)
5295 QETH_DBF_TEXT(trace
, 4, "frvlskbs");
5296 for (i
= 0; i
< card
->qdio
.no_out_queues
; ++i
){
5297 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; ++j
)
5298 qeth_free_vlan_buffer(card
, &card
->qdio
.
5299 out_qs
[i
]->bufs
[j
], vid
);
5304 qeth_free_vlan_addresses4(struct qeth_card
*card
, unsigned short vid
)
5306 struct in_device
*in_dev
;
5307 struct in_ifaddr
*ifa
;
5308 struct qeth_ipaddr
*addr
;
5310 QETH_DBF_TEXT(trace
, 4, "frvaddr4");
5313 in_dev
= __in_dev_get_rcu(card
->vlangrp
->vlan_devices
[vid
]);
5316 for (ifa
= in_dev
->ifa_list
; ifa
; ifa
= ifa
->ifa_next
) {
5317 addr
= qeth_get_addr_buffer(QETH_PROT_IPV4
);
5319 addr
->u
.a4
.addr
= ifa
->ifa_address
;
5320 addr
->u
.a4
.mask
= ifa
->ifa_mask
;
5321 addr
->type
= QETH_IP_TYPE_NORMAL
;
5322 if (!qeth_delete_ip(card
, addr
))
5331 qeth_free_vlan_addresses6(struct qeth_card
*card
, unsigned short vid
)
5333 #ifdef CONFIG_QETH_IPV6
5334 struct inet6_dev
*in6_dev
;
5335 struct inet6_ifaddr
*ifa
;
5336 struct qeth_ipaddr
*addr
;
5338 QETH_DBF_TEXT(trace
, 4, "frvaddr6");
5340 in6_dev
= in6_dev_get(card
->vlangrp
->vlan_devices
[vid
]);
5343 for (ifa
= in6_dev
->addr_list
; ifa
; ifa
= ifa
->lst_next
){
5344 addr
= qeth_get_addr_buffer(QETH_PROT_IPV6
);
5346 memcpy(&addr
->u
.a6
.addr
, &ifa
->addr
,
5347 sizeof(struct in6_addr
));
5348 addr
->u
.a6
.pfxlen
= ifa
->prefix_len
;
5349 addr
->type
= QETH_IP_TYPE_NORMAL
;
5350 if (!qeth_delete_ip(card
, addr
))
5354 in6_dev_put(in6_dev
);
5355 #endif /* CONFIG_QETH_IPV6 */
5359 qeth_free_vlan_addresses(struct qeth_card
*card
, unsigned short vid
)
5361 if (card
->options
.layer2
|| !card
->vlangrp
)
5363 qeth_free_vlan_addresses4(card
, vid
);
5364 qeth_free_vlan_addresses6(card
, vid
);
5368 qeth_layer2_send_setdelvlan_cb(struct qeth_card
*card
,
5369 struct qeth_reply
*reply
,
5372 struct qeth_ipa_cmd
*cmd
;
5374 QETH_DBF_TEXT(trace
, 2, "L2sdvcb");
5375 cmd
= (struct qeth_ipa_cmd
*) data
;
5376 if (cmd
->hdr
.return_code
) {
5377 PRINT_ERR("Error in processing VLAN %i on %s: 0x%x. "
5378 "Continuing\n",cmd
->data
.setdelvlan
.vlan_id
,
5379 QETH_CARD_IFNAME(card
), cmd
->hdr
.return_code
);
5380 QETH_DBF_TEXT_(trace
, 2, "L2VL%4x", cmd
->hdr
.command
);
5381 QETH_DBF_TEXT_(trace
, 2, "L2%s", CARD_BUS_ID(card
));
5382 QETH_DBF_TEXT_(trace
, 2, "err%d", cmd
->hdr
.return_code
);
5388 qeth_layer2_send_setdelvlan(struct qeth_card
*card
, __u16 i
,
5389 enum qeth_ipa_cmds ipacmd
)
5391 struct qeth_ipa_cmd
*cmd
;
5392 struct qeth_cmd_buffer
*iob
;
5394 QETH_DBF_TEXT_(trace
, 4, "L2sdv%x",ipacmd
);
5395 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, QETH_PROT_IPV4
);
5396 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
5397 cmd
->data
.setdelvlan
.vlan_id
= i
;
5398 return qeth_send_ipa_cmd(card
, iob
,
5399 qeth_layer2_send_setdelvlan_cb
, NULL
);
5403 qeth_layer2_process_vlans(struct qeth_card
*card
, int clear
)
5407 QETH_DBF_TEXT(trace
, 3, "L2prcvln");
5411 for (i
= 0; i
< VLAN_GROUP_ARRAY_LEN
; i
++) {
5412 if (card
->vlangrp
->vlan_devices
[i
] == NULL
)
5415 qeth_layer2_send_setdelvlan(card
, i
, IPA_CMD_DELVLAN
);
5417 qeth_layer2_send_setdelvlan(card
, i
, IPA_CMD_SETVLAN
);
5421 /*add_vid is layer 2 used only ....*/
5423 qeth_vlan_rx_add_vid(struct net_device
*dev
, unsigned short vid
)
5425 struct qeth_card
*card
;
5427 QETH_DBF_TEXT_(trace
, 4, "aid:%d", vid
);
5429 card
= (struct qeth_card
*) dev
->priv
;
5430 if (!card
->options
.layer2
)
5432 qeth_layer2_send_setdelvlan(card
, vid
, IPA_CMD_SETVLAN
);
5435 /*... kill_vid used for both modes*/
5437 qeth_vlan_rx_kill_vid(struct net_device
*dev
, unsigned short vid
)
5439 struct qeth_card
*card
;
5440 unsigned long flags
;
5442 QETH_DBF_TEXT_(trace
, 4, "kid:%d", vid
);
5444 card
= (struct qeth_card
*) dev
->priv
;
5445 /* free all skbs for the vlan device */
5446 qeth_free_vlan_skbs(card
, vid
);
5447 spin_lock_irqsave(&card
->vlanlock
, flags
);
5448 /* unregister IP addresses of vlan device */
5449 qeth_free_vlan_addresses(card
, vid
);
5451 card
->vlangrp
->vlan_devices
[vid
] = NULL
;
5452 spin_unlock_irqrestore(&card
->vlanlock
, flags
);
5453 if (card
->options
.layer2
)
5454 qeth_layer2_send_setdelvlan(card
, vid
, IPA_CMD_DELVLAN
);
5455 qeth_set_multicast_list(card
->dev
);
5459 * Examine hardware response to SET_PROMISC_MODE
5462 qeth_setadp_promisc_mode_cb(struct qeth_card
*card
,
5463 struct qeth_reply
*reply
,
5466 struct qeth_ipa_cmd
*cmd
;
5467 struct qeth_ipacmd_setadpparms
*setparms
;
5469 QETH_DBF_TEXT(trace
,4,"prmadpcb");
5471 cmd
= (struct qeth_ipa_cmd
*) data
;
5472 setparms
= &(cmd
->data
.setadapterparms
);
5474 qeth_default_setadapterparms_cb(card
, reply
, (unsigned long)cmd
);
5475 if (cmd
->hdr
.return_code
) {
5476 QETH_DBF_TEXT_(trace
,4,"prmrc%2.2x",cmd
->hdr
.return_code
);
5477 setparms
->data
.mode
= SET_PROMISC_MODE_OFF
;
5479 card
->info
.promisc_mode
= setparms
->data
.mode
;
5483 * Set promiscuous mode (on or off) (SET_PROMISC_MODE command)
5486 qeth_setadp_promisc_mode(struct qeth_card
*card
)
5488 enum qeth_ipa_promisc_modes mode
;
5489 struct net_device
*dev
= card
->dev
;
5490 struct qeth_cmd_buffer
*iob
;
5491 struct qeth_ipa_cmd
*cmd
;
5493 QETH_DBF_TEXT(trace
, 4, "setprom");
5495 if (((dev
->flags
& IFF_PROMISC
) &&
5496 (card
->info
.promisc_mode
== SET_PROMISC_MODE_ON
)) ||
5497 (!(dev
->flags
& IFF_PROMISC
) &&
5498 (card
->info
.promisc_mode
== SET_PROMISC_MODE_OFF
)))
5500 mode
= SET_PROMISC_MODE_OFF
;
5501 if (dev
->flags
& IFF_PROMISC
)
5502 mode
= SET_PROMISC_MODE_ON
;
5503 QETH_DBF_TEXT_(trace
, 4, "mode:%x", mode
);
5505 iob
= qeth_get_adapter_cmd(card
, IPA_SETADP_SET_PROMISC_MODE
,
5506 sizeof(struct qeth_ipacmd_setadpparms
));
5507 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+ IPA_PDU_HEADER_SIZE
);
5508 cmd
->data
.setadapterparms
.data
.mode
= mode
;
5509 qeth_send_ipa_cmd(card
, iob
, qeth_setadp_promisc_mode_cb
, NULL
);
5513 * set multicast address on card
5516 qeth_set_multicast_list(struct net_device
*dev
)
5518 struct qeth_card
*card
= (struct qeth_card
*) dev
->priv
;
5520 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
5523 QETH_DBF_TEXT(trace
, 3, "setmulti");
5524 qeth_delete_mc_addresses(card
);
5525 if (card
->options
.layer2
) {
5526 qeth_layer2_add_multicast(card
);
5529 qeth_add_multicast_ipv4(card
);
5530 #ifdef CONFIG_QETH_IPV6
5531 qeth_add_multicast_ipv6(card
);
5534 if (qeth_set_thread_start_bit(card
, QETH_SET_IP_THREAD
) == 0)
5535 schedule_work(&card
->kernel_thread_starter
);
5536 if (!qeth_adp_supported(card
, IPA_SETADP_SET_PROMISC_MODE
))
5538 if (qeth_set_thread_start_bit(card
, QETH_SET_PROMISC_MODE_THREAD
)==0)
5539 schedule_work(&card
->kernel_thread_starter
);
5543 qeth_neigh_setup(struct net_device
*dev
, struct neigh_parms
*np
)
5549 qeth_get_mac_for_ipm(__u32 ipm
, char *mac
, struct net_device
*dev
)
5551 if (dev
->type
== ARPHRD_IEEE802_TR
)
5552 ip_tr_mc_map(ipm
, mac
);
5554 ip_eth_mc_map(ipm
, mac
);
5557 static struct qeth_ipaddr
*
5558 qeth_get_addr_buffer(enum qeth_prot_versions prot
)
5560 struct qeth_ipaddr
*addr
;
5562 addr
= kzalloc(sizeof(struct qeth_ipaddr
), GFP_ATOMIC
);
5564 PRINT_WARN("Not enough memory to add address\n");
5567 addr
->type
= QETH_IP_TYPE_NORMAL
;
5573 qeth_osn_assist(struct net_device
*dev
,
5577 struct qeth_cmd_buffer
*iob
;
5578 struct qeth_card
*card
;
5581 QETH_DBF_TEXT(trace
, 2, "osnsdmc");
5584 card
= (struct qeth_card
*)dev
->priv
;
5587 if ((card
->state
!= CARD_STATE_UP
) &&
5588 (card
->state
!= CARD_STATE_SOFTSETUP
))
5590 iob
= qeth_wait_for_buffer(&card
->write
);
5591 memcpy(iob
->data
+IPA_PDU_HEADER_SIZE
, data
, data_len
);
5592 rc
= qeth_osn_send_ipa_cmd(card
, iob
, data_len
);
5596 static struct net_device
*
5597 qeth_netdev_by_devno(unsigned char *read_dev_no
)
5599 struct qeth_card
*card
;
5600 struct net_device
*ndev
;
5601 unsigned char *readno
;
5602 __u16 temp_dev_no
, card_dev_no
;
5604 unsigned long flags
;
5607 memcpy(&temp_dev_no
, read_dev_no
, 2);
5608 read_lock_irqsave(&qeth_card_list
.rwlock
, flags
);
5609 list_for_each_entry(card
, &qeth_card_list
.list
, list
) {
5610 readno
= CARD_RDEV_ID(card
);
5611 readno
+= (strlen(readno
) - 4);
5612 card_dev_no
= simple_strtoul(readno
, &endp
, 16);
5613 if (card_dev_no
== temp_dev_no
) {
5618 read_unlock_irqrestore(&qeth_card_list
.rwlock
, flags
);
5623 qeth_osn_register(unsigned char *read_dev_no
,
5624 struct net_device
**dev
,
5625 int (*assist_cb
)(struct net_device
*, void *),
5626 int (*data_cb
)(struct sk_buff
*))
5628 struct qeth_card
* card
;
5630 QETH_DBF_TEXT(trace
, 2, "osnreg");
5631 *dev
= qeth_netdev_by_devno(read_dev_no
);
5634 card
= (struct qeth_card
*)(*dev
)->priv
;
5637 if ((assist_cb
== NULL
) || (data_cb
== NULL
))
5639 card
->osn_info
.assist_cb
= assist_cb
;
5640 card
->osn_info
.data_cb
= data_cb
;
5645 qeth_osn_deregister(struct net_device
* dev
)
5647 struct qeth_card
*card
;
5649 QETH_DBF_TEXT(trace
, 2, "osndereg");
5652 card
= (struct qeth_card
*)dev
->priv
;
5655 card
->osn_info
.assist_cb
= NULL
;
5656 card
->osn_info
.data_cb
= NULL
;
5661 qeth_delete_mc_addresses(struct qeth_card
*card
)
5663 struct qeth_ipaddr
*iptodo
;
5664 unsigned long flags
;
5666 QETH_DBF_TEXT(trace
,4,"delmc");
5667 iptodo
= qeth_get_addr_buffer(QETH_PROT_IPV4
);
5669 QETH_DBF_TEXT(trace
, 2, "dmcnomem");
5672 iptodo
->type
= QETH_IP_TYPE_DEL_ALL_MC
;
5673 spin_lock_irqsave(&card
->ip_lock
, flags
);
5674 if (!__qeth_insert_ip_todo(card
, iptodo
, 0))
5676 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
5680 qeth_add_mc(struct qeth_card
*card
, struct in_device
*in4_dev
)
5682 struct qeth_ipaddr
*ipm
;
5683 struct ip_mc_list
*im4
;
5684 char buf
[MAX_ADDR_LEN
];
5686 QETH_DBF_TEXT(trace
,4,"addmc");
5687 for (im4
= in4_dev
->mc_list
; im4
; im4
= im4
->next
) {
5688 qeth_get_mac_for_ipm(im4
->multiaddr
, buf
, in4_dev
->dev
);
5689 ipm
= qeth_get_addr_buffer(QETH_PROT_IPV4
);
5692 ipm
->u
.a4
.addr
= im4
->multiaddr
;
5693 memcpy(ipm
->mac
,buf
,OSA_ADDR_LEN
);
5694 ipm
->is_multicast
= 1;
5695 if (!qeth_add_ip(card
,ipm
))
5701 qeth_add_vlan_mc(struct qeth_card
*card
)
5703 #ifdef CONFIG_QETH_VLAN
5704 struct in_device
*in_dev
;
5705 struct vlan_group
*vg
;
5708 QETH_DBF_TEXT(trace
,4,"addmcvl");
5709 if ( ((card
->options
.layer2
== 0) &&
5710 (!qeth_is_supported(card
,IPA_FULL_VLAN
))) ||
5711 (card
->vlangrp
== NULL
) )
5715 for (i
= 0; i
< VLAN_GROUP_ARRAY_LEN
; i
++) {
5716 if (vg
->vlan_devices
[i
] == NULL
||
5717 !(vg
->vlan_devices
[i
]->flags
& IFF_UP
))
5719 in_dev
= in_dev_get(vg
->vlan_devices
[i
]);
5722 read_lock(&in_dev
->mc_list_lock
);
5723 qeth_add_mc(card
,in_dev
);
5724 read_unlock(&in_dev
->mc_list_lock
);
5731 qeth_add_multicast_ipv4(struct qeth_card
*card
)
5733 struct in_device
*in4_dev
;
5735 QETH_DBF_TEXT(trace
,4,"chkmcv4");
5736 in4_dev
= in_dev_get(card
->dev
);
5737 if (in4_dev
== NULL
)
5739 read_lock(&in4_dev
->mc_list_lock
);
5740 qeth_add_mc(card
, in4_dev
);
5741 qeth_add_vlan_mc(card
);
5742 read_unlock(&in4_dev
->mc_list_lock
);
5743 in_dev_put(in4_dev
);
5747 qeth_layer2_add_multicast(struct qeth_card
*card
)
5749 struct qeth_ipaddr
*ipm
;
5750 struct dev_mc_list
*dm
;
5752 QETH_DBF_TEXT(trace
,4,"L2addmc");
5753 for (dm
= card
->dev
->mc_list
; dm
; dm
= dm
->next
) {
5754 ipm
= qeth_get_addr_buffer(QETH_PROT_IPV4
);
5757 memcpy(ipm
->mac
,dm
->dmi_addr
,MAX_ADDR_LEN
);
5758 ipm
->is_multicast
= 1;
5759 if (!qeth_add_ip(card
, ipm
))
5764 #ifdef CONFIG_QETH_IPV6
5766 qeth_add_mc6(struct qeth_card
*card
, struct inet6_dev
*in6_dev
)
5768 struct qeth_ipaddr
*ipm
;
5769 struct ifmcaddr6
*im6
;
5770 char buf
[MAX_ADDR_LEN
];
5772 QETH_DBF_TEXT(trace
,4,"addmc6");
5773 for (im6
= in6_dev
->mc_list
; im6
!= NULL
; im6
= im6
->next
) {
5774 ndisc_mc_map(&im6
->mca_addr
, buf
, in6_dev
->dev
, 0);
5775 ipm
= qeth_get_addr_buffer(QETH_PROT_IPV6
);
5778 ipm
->is_multicast
= 1;
5779 memcpy(ipm
->mac
,buf
,OSA_ADDR_LEN
);
5780 memcpy(&ipm
->u
.a6
.addr
,&im6
->mca_addr
.s6_addr
,
5781 sizeof(struct in6_addr
));
5782 if (!qeth_add_ip(card
,ipm
))
5788 qeth_add_vlan_mc6(struct qeth_card
*card
)
5790 #ifdef CONFIG_QETH_VLAN
5791 struct inet6_dev
*in_dev
;
5792 struct vlan_group
*vg
;
5795 QETH_DBF_TEXT(trace
,4,"admc6vl");
5796 if ( ((card
->options
.layer2
== 0) &&
5797 (!qeth_is_supported(card
,IPA_FULL_VLAN
))) ||
5798 (card
->vlangrp
== NULL
))
5802 for (i
= 0; i
< VLAN_GROUP_ARRAY_LEN
; i
++) {
5803 if (vg
->vlan_devices
[i
] == NULL
||
5804 !(vg
->vlan_devices
[i
]->flags
& IFF_UP
))
5806 in_dev
= in6_dev_get(vg
->vlan_devices
[i
]);
5809 read_lock(&in_dev
->lock
);
5810 qeth_add_mc6(card
,in_dev
);
5811 read_unlock(&in_dev
->lock
);
5812 in6_dev_put(in_dev
);
5814 #endif /* CONFIG_QETH_VLAN */
5818 qeth_add_multicast_ipv6(struct qeth_card
*card
)
5820 struct inet6_dev
*in6_dev
;
5822 QETH_DBF_TEXT(trace
,4,"chkmcv6");
5823 if (!qeth_is_supported(card
, IPA_IPV6
))
5825 in6_dev
= in6_dev_get(card
->dev
);
5826 if (in6_dev
== NULL
)
5828 read_lock(&in6_dev
->lock
);
5829 qeth_add_mc6(card
, in6_dev
);
5830 qeth_add_vlan_mc6(card
);
5831 read_unlock(&in6_dev
->lock
);
5832 in6_dev_put(in6_dev
);
5834 #endif /* CONFIG_QETH_IPV6 */
5837 qeth_layer2_send_setdelmac(struct qeth_card
*card
, __u8
*mac
,
5838 enum qeth_ipa_cmds ipacmd
,
5839 int (*reply_cb
) (struct qeth_card
*,
5843 struct qeth_ipa_cmd
*cmd
;
5844 struct qeth_cmd_buffer
*iob
;
5846 QETH_DBF_TEXT(trace
, 2, "L2sdmac");
5847 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, QETH_PROT_IPV4
);
5848 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
5849 cmd
->data
.setdelmac
.mac_length
= OSA_ADDR_LEN
;
5850 memcpy(&cmd
->data
.setdelmac
.mac
, mac
, OSA_ADDR_LEN
);
5851 return qeth_send_ipa_cmd(card
, iob
, reply_cb
, NULL
);
5855 qeth_layer2_send_setgroupmac_cb(struct qeth_card
*card
,
5856 struct qeth_reply
*reply
,
5859 struct qeth_ipa_cmd
*cmd
;
5862 QETH_DBF_TEXT(trace
, 2, "L2Sgmacb");
5863 cmd
= (struct qeth_ipa_cmd
*) data
;
5864 mac
= &cmd
->data
.setdelmac
.mac
[0];
5865 /* MAC already registered, needed in couple/uncouple case */
5866 if (cmd
->hdr
.return_code
== 0x2005) {
5867 PRINT_WARN("Group MAC %02x:%02x:%02x:%02x:%02x:%02x " \
5868 "already existing on %s \n",
5869 mac
[0], mac
[1], mac
[2], mac
[3], mac
[4], mac
[5],
5870 QETH_CARD_IFNAME(card
));
5871 cmd
->hdr
.return_code
= 0;
5873 if (cmd
->hdr
.return_code
)
5874 PRINT_ERR("Could not set group MAC " \
5875 "%02x:%02x:%02x:%02x:%02x:%02x on %s: %x\n",
5876 mac
[0], mac
[1], mac
[2], mac
[3], mac
[4], mac
[5],
5877 QETH_CARD_IFNAME(card
),cmd
->hdr
.return_code
);
5882 qeth_layer2_send_setgroupmac(struct qeth_card
*card
, __u8
*mac
)
5884 QETH_DBF_TEXT(trace
, 2, "L2Sgmac");
5885 return qeth_layer2_send_setdelmac(card
, mac
, IPA_CMD_SETGMAC
,
5886 qeth_layer2_send_setgroupmac_cb
);
5890 qeth_layer2_send_delgroupmac_cb(struct qeth_card
*card
,
5891 struct qeth_reply
*reply
,
5894 struct qeth_ipa_cmd
*cmd
;
5897 QETH_DBF_TEXT(trace
, 2, "L2Dgmacb");
5898 cmd
= (struct qeth_ipa_cmd
*) data
;
5899 mac
= &cmd
->data
.setdelmac
.mac
[0];
5900 if (cmd
->hdr
.return_code
)
5901 PRINT_ERR("Could not delete group MAC " \
5902 "%02x:%02x:%02x:%02x:%02x:%02x on %s: %x\n",
5903 mac
[0], mac
[1], mac
[2], mac
[3], mac
[4], mac
[5],
5904 QETH_CARD_IFNAME(card
), cmd
->hdr
.return_code
);
5909 qeth_layer2_send_delgroupmac(struct qeth_card
*card
, __u8
*mac
)
5911 QETH_DBF_TEXT(trace
, 2, "L2Dgmac");
5912 return qeth_layer2_send_setdelmac(card
, mac
, IPA_CMD_DELGMAC
,
5913 qeth_layer2_send_delgroupmac_cb
);
5917 qeth_layer2_send_setmac_cb(struct qeth_card
*card
,
5918 struct qeth_reply
*reply
,
5921 struct qeth_ipa_cmd
*cmd
;
5923 QETH_DBF_TEXT(trace
, 2, "L2Smaccb");
5924 cmd
= (struct qeth_ipa_cmd
*) data
;
5925 if (cmd
->hdr
.return_code
) {
5926 QETH_DBF_TEXT_(trace
, 2, "L2er%x", cmd
->hdr
.return_code
);
5927 PRINT_WARN("Error in registering MAC address on " \
5928 "device %s: x%x\n", CARD_BUS_ID(card
),
5929 cmd
->hdr
.return_code
);
5930 card
->info
.mac_bits
&= ~QETH_LAYER2_MAC_REGISTERED
;
5931 cmd
->hdr
.return_code
= -EIO
;
5933 card
->info
.mac_bits
|= QETH_LAYER2_MAC_REGISTERED
;
5934 memcpy(card
->dev
->dev_addr
,cmd
->data
.setdelmac
.mac
,
5936 PRINT_INFO("MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x "
5937 "successfully registered on device %s\n",
5938 card
->dev
->dev_addr
[0], card
->dev
->dev_addr
[1],
5939 card
->dev
->dev_addr
[2], card
->dev
->dev_addr
[3],
5940 card
->dev
->dev_addr
[4], card
->dev
->dev_addr
[5],
5947 qeth_layer2_send_setmac(struct qeth_card
*card
, __u8
*mac
)
5949 QETH_DBF_TEXT(trace
, 2, "L2Setmac");
5950 return qeth_layer2_send_setdelmac(card
, mac
, IPA_CMD_SETVMAC
,
5951 qeth_layer2_send_setmac_cb
);
5955 qeth_layer2_send_delmac_cb(struct qeth_card
*card
,
5956 struct qeth_reply
*reply
,
5959 struct qeth_ipa_cmd
*cmd
;
5961 QETH_DBF_TEXT(trace
, 2, "L2Dmaccb");
5962 cmd
= (struct qeth_ipa_cmd
*) data
;
5963 if (cmd
->hdr
.return_code
) {
5964 PRINT_WARN("Error in deregistering MAC address on " \
5965 "device %s: x%x\n", CARD_BUS_ID(card
),
5966 cmd
->hdr
.return_code
);
5967 QETH_DBF_TEXT_(trace
, 2, "err%d", cmd
->hdr
.return_code
);
5968 cmd
->hdr
.return_code
= -EIO
;
5971 card
->info
.mac_bits
&= ~QETH_LAYER2_MAC_REGISTERED
;
5976 qeth_layer2_send_delmac(struct qeth_card
*card
, __u8
*mac
)
5978 QETH_DBF_TEXT(trace
, 2, "L2Delmac");
5979 if (!(card
->info
.mac_bits
& QETH_LAYER2_MAC_REGISTERED
))
5981 return qeth_layer2_send_setdelmac(card
, mac
, IPA_CMD_DELVMAC
,
5982 qeth_layer2_send_delmac_cb
);
5986 qeth_layer2_set_mac_address(struct net_device
*dev
, void *p
)
5988 struct sockaddr
*addr
= p
;
5989 struct qeth_card
*card
;
5992 QETH_DBF_TEXT(trace
, 3, "setmac");
5994 if (qeth_verify_dev(dev
) != QETH_REAL_CARD
) {
5995 QETH_DBF_TEXT(trace
, 3, "setmcINV");
5998 card
= (struct qeth_card
*) dev
->priv
;
6000 if (!card
->options
.layer2
) {
6001 PRINT_WARN("Setting MAC address on %s is not supported "
6002 "in Layer 3 mode.\n", dev
->name
);
6003 QETH_DBF_TEXT(trace
, 3, "setmcLY3");
6006 if (card
->info
.type
== QETH_CARD_TYPE_OSN
) {
6007 PRINT_WARN("Setting MAC address on %s is not supported.\n",
6009 QETH_DBF_TEXT(trace
, 3, "setmcOSN");
6012 QETH_DBF_TEXT_(trace
, 3, "%s", CARD_BUS_ID(card
));
6013 QETH_DBF_HEX(trace
, 3, addr
->sa_data
, OSA_ADDR_LEN
);
6014 rc
= qeth_layer2_send_delmac(card
, &card
->dev
->dev_addr
[0]);
6016 rc
= qeth_layer2_send_setmac(card
, addr
->sa_data
);
6021 qeth_fill_ipacmd_header(struct qeth_card
*card
, struct qeth_ipa_cmd
*cmd
,
6022 __u8 command
, enum qeth_prot_versions prot
)
6024 memset(cmd
, 0, sizeof (struct qeth_ipa_cmd
));
6025 cmd
->hdr
.command
= command
;
6026 cmd
->hdr
.initiator
= IPA_CMD_INITIATOR_HOST
;
6027 cmd
->hdr
.seqno
= card
->seqno
.ipa
;
6028 cmd
->hdr
.adapter_type
= qeth_get_ipa_adp_type(card
->info
.link_type
);
6029 cmd
->hdr
.rel_adapter_no
= (__u8
) card
->info
.portno
;
6030 if (card
->options
.layer2
)
6031 cmd
->hdr
.prim_version_no
= 2;
6033 cmd
->hdr
.prim_version_no
= 1;
6034 cmd
->hdr
.param_count
= 1;
6035 cmd
->hdr
.prot_version
= prot
;
6036 cmd
->hdr
.ipa_supported
= 0;
6037 cmd
->hdr
.ipa_enabled
= 0;
6040 static struct qeth_cmd_buffer
*
6041 qeth_get_ipacmd_buffer(struct qeth_card
*card
, enum qeth_ipa_cmds ipacmd
,
6042 enum qeth_prot_versions prot
)
6044 struct qeth_cmd_buffer
*iob
;
6045 struct qeth_ipa_cmd
*cmd
;
6047 iob
= qeth_wait_for_buffer(&card
->write
);
6048 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
6049 qeth_fill_ipacmd_header(card
, cmd
, ipacmd
, prot
);
6055 qeth_send_setdelmc(struct qeth_card
*card
, struct qeth_ipaddr
*addr
, int ipacmd
)
6058 struct qeth_cmd_buffer
*iob
;
6059 struct qeth_ipa_cmd
*cmd
;
6061 QETH_DBF_TEXT(trace
,4,"setdelmc");
6063 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, addr
->proto
);
6064 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
6065 memcpy(&cmd
->data
.setdelipm
.mac
,addr
->mac
, OSA_ADDR_LEN
);
6066 if (addr
->proto
== QETH_PROT_IPV6
)
6067 memcpy(cmd
->data
.setdelipm
.ip6
, &addr
->u
.a6
.addr
,
6068 sizeof(struct in6_addr
));
6070 memcpy(&cmd
->data
.setdelipm
.ip4
, &addr
->u
.a4
.addr
,4);
6072 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
6077 qeth_fill_netmask(u8
*netmask
, unsigned int len
)
6080 for (i
=0;i
<16;i
++) {
6085 netmask
[i
] = (u8
)(0xFF00>>j
);
6092 qeth_send_setdelip(struct qeth_card
*card
, struct qeth_ipaddr
*addr
,
6093 int ipacmd
, unsigned int flags
)
6096 struct qeth_cmd_buffer
*iob
;
6097 struct qeth_ipa_cmd
*cmd
;
6100 QETH_DBF_TEXT(trace
,4,"setdelip");
6101 QETH_DBF_TEXT_(trace
,4,"flags%02X", flags
);
6103 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, addr
->proto
);
6104 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
6105 if (addr
->proto
== QETH_PROT_IPV6
) {
6106 memcpy(cmd
->data
.setdelip6
.ip_addr
, &addr
->u
.a6
.addr
,
6107 sizeof(struct in6_addr
));
6108 qeth_fill_netmask(netmask
,addr
->u
.a6
.pfxlen
);
6109 memcpy(cmd
->data
.setdelip6
.mask
, netmask
,
6110 sizeof(struct in6_addr
));
6111 cmd
->data
.setdelip6
.flags
= flags
;
6113 memcpy(cmd
->data
.setdelip4
.ip_addr
, &addr
->u
.a4
.addr
, 4);
6114 memcpy(cmd
->data
.setdelip4
.mask
, &addr
->u
.a4
.mask
, 4);
6115 cmd
->data
.setdelip4
.flags
= flags
;
6118 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
6124 qeth_layer2_register_addr_entry(struct qeth_card
*card
,
6125 struct qeth_ipaddr
*addr
)
6127 if (!addr
->is_multicast
)
6129 QETH_DBF_TEXT(trace
, 2, "setgmac");
6130 QETH_DBF_HEX(trace
,3,&addr
->mac
[0],OSA_ADDR_LEN
);
6131 return qeth_layer2_send_setgroupmac(card
, &addr
->mac
[0]);
6135 qeth_layer2_deregister_addr_entry(struct qeth_card
*card
,
6136 struct qeth_ipaddr
*addr
)
6138 if (!addr
->is_multicast
)
6140 QETH_DBF_TEXT(trace
, 2, "delgmac");
6141 QETH_DBF_HEX(trace
,3,&addr
->mac
[0],OSA_ADDR_LEN
);
6142 return qeth_layer2_send_delgroupmac(card
, &addr
->mac
[0]);
6146 qeth_layer3_register_addr_entry(struct qeth_card
*card
,
6147 struct qeth_ipaddr
*addr
)
6153 if (addr
->proto
== QETH_PROT_IPV4
) {
6154 QETH_DBF_TEXT(trace
, 2,"setaddr4");
6155 QETH_DBF_HEX(trace
, 3, &addr
->u
.a4
.addr
, sizeof(int));
6156 } else if (addr
->proto
== QETH_PROT_IPV6
) {
6157 QETH_DBF_TEXT(trace
, 2, "setaddr6");
6158 QETH_DBF_HEX(trace
,3,&addr
->u
.a6
.addr
,8);
6159 QETH_DBF_HEX(trace
,3,((char *)&addr
->u
.a6
.addr
)+8,8);
6161 QETH_DBF_TEXT(trace
, 2, "setaddr?");
6162 QETH_DBF_HEX(trace
, 3, addr
, sizeof(struct qeth_ipaddr
));
6165 if (addr
->is_multicast
)
6166 rc
= qeth_send_setdelmc(card
, addr
, IPA_CMD_SETIPM
);
6168 rc
= qeth_send_setdelip(card
, addr
, IPA_CMD_SETIP
,
6171 QETH_DBF_TEXT(trace
, 2, "failed");
6172 } while ((--cnt
> 0) && rc
);
6174 QETH_DBF_TEXT(trace
, 2, "FAILED");
6175 qeth_ipaddr_to_string(addr
->proto
, (u8
*)&addr
->u
, buf
);
6176 PRINT_WARN("Could not register IP address %s (rc=0x%x/%d)\n",
6183 qeth_layer3_deregister_addr_entry(struct qeth_card
*card
,
6184 struct qeth_ipaddr
*addr
)
6189 if (addr
->proto
== QETH_PROT_IPV4
) {
6190 QETH_DBF_TEXT(trace
, 2,"deladdr4");
6191 QETH_DBF_HEX(trace
, 3, &addr
->u
.a4
.addr
, sizeof(int));
6192 } else if (addr
->proto
== QETH_PROT_IPV6
) {
6193 QETH_DBF_TEXT(trace
, 2, "deladdr6");
6194 QETH_DBF_HEX(trace
,3,&addr
->u
.a6
.addr
,8);
6195 QETH_DBF_HEX(trace
,3,((char *)&addr
->u
.a6
.addr
)+8,8);
6197 QETH_DBF_TEXT(trace
, 2, "deladdr?");
6198 QETH_DBF_HEX(trace
, 3, addr
, sizeof(struct qeth_ipaddr
));
6200 if (addr
->is_multicast
)
6201 rc
= qeth_send_setdelmc(card
, addr
, IPA_CMD_DELIPM
);
6203 rc
= qeth_send_setdelip(card
, addr
, IPA_CMD_DELIP
,
6206 QETH_DBF_TEXT(trace
, 2, "failed");
6207 /* TODO: re-activate this warning as soon as we have a
6209 qeth_ipaddr_to_string(addr->proto, (u8 *)&addr->u, buf);
6210 PRINT_WARN("Could not deregister IP address %s (rc=%x)\n",
6218 qeth_register_addr_entry(struct qeth_card
*card
, struct qeth_ipaddr
*addr
)
6220 if (card
->options
.layer2
)
6221 return qeth_layer2_register_addr_entry(card
, addr
);
6223 return qeth_layer3_register_addr_entry(card
, addr
);
6227 qeth_deregister_addr_entry(struct qeth_card
*card
, struct qeth_ipaddr
*addr
)
6229 if (card
->options
.layer2
)
6230 return qeth_layer2_deregister_addr_entry(card
, addr
);
6232 return qeth_layer3_deregister_addr_entry(card
, addr
);
6236 qeth_ethtool_get_tx_csum(struct net_device
*dev
)
6238 /* We may need to say that we support tx csum offload if
6239 * we do EDDP or TSO. There are discussions going on to
6240 * enforce rules in the stack and in ethtool that make
6241 * SG and TSO depend on HW_CSUM. At the moment there are
6243 * If we say yes here, we have to checksum outbound packets
6249 qeth_ethtool_set_tx_csum(struct net_device
*dev
, u32 data
)
6255 qeth_ethtool_get_rx_csum(struct net_device
*dev
)
6257 struct qeth_card
*card
= (struct qeth_card
*)dev
->priv
;
6259 return (card
->options
.checksum_type
== HW_CHECKSUMMING
);
6263 qeth_ethtool_set_rx_csum(struct net_device
*dev
, u32 data
)
6265 struct qeth_card
*card
= (struct qeth_card
*)dev
->priv
;
6267 if ((card
->state
!= CARD_STATE_DOWN
) &&
6268 (card
->state
!= CARD_STATE_RECOVER
))
6271 card
->options
.checksum_type
= HW_CHECKSUMMING
;
6273 card
->options
.checksum_type
= SW_CHECKSUMMING
;
6278 qeth_ethtool_get_sg(struct net_device
*dev
)
6280 struct qeth_card
*card
= (struct qeth_card
*)dev
->priv
;
6282 return ((card
->options
.large_send
!= QETH_LARGE_SEND_NO
) &&
6283 (dev
->features
& NETIF_F_SG
));
6287 qeth_ethtool_set_sg(struct net_device
*dev
, u32 data
)
6289 struct qeth_card
*card
= (struct qeth_card
*)dev
->priv
;
6292 if (card
->options
.large_send
!= QETH_LARGE_SEND_NO
)
6293 dev
->features
|= NETIF_F_SG
;
6295 dev
->features
&= ~NETIF_F_SG
;
6299 dev
->features
&= ~NETIF_F_SG
;
6304 qeth_ethtool_get_tso(struct net_device
*dev
)
6306 struct qeth_card
*card
= (struct qeth_card
*)dev
->priv
;
6308 return ((card
->options
.large_send
!= QETH_LARGE_SEND_NO
) &&
6309 (dev
->features
& NETIF_F_TSO
));
6313 qeth_ethtool_set_tso(struct net_device
*dev
, u32 data
)
6315 struct qeth_card
*card
= (struct qeth_card
*)dev
->priv
;
6318 if (card
->options
.large_send
!= QETH_LARGE_SEND_NO
)
6319 dev
->features
|= NETIF_F_TSO
;
6321 dev
->features
&= ~NETIF_F_TSO
;
6325 dev
->features
&= ~NETIF_F_TSO
;
6329 static struct ethtool_ops qeth_ethtool_ops
= {
6330 .get_tx_csum
= qeth_ethtool_get_tx_csum
,
6331 .set_tx_csum
= qeth_ethtool_set_tx_csum
,
6332 .get_rx_csum
= qeth_ethtool_get_rx_csum
,
6333 .set_rx_csum
= qeth_ethtool_set_rx_csum
,
6334 .get_sg
= qeth_ethtool_get_sg
,
6335 .set_sg
= qeth_ethtool_set_sg
,
6336 .get_tso
= qeth_ethtool_get_tso
,
6337 .set_tso
= qeth_ethtool_set_tso
,
6341 qeth_netdev_init(struct net_device
*dev
)
6343 struct qeth_card
*card
;
6345 card
= (struct qeth_card
*) dev
->priv
;
6347 QETH_DBF_TEXT(trace
,3,"initdev");
6349 dev
->tx_timeout
= &qeth_tx_timeout
;
6350 dev
->watchdog_timeo
= QETH_TX_TIMEOUT
;
6351 dev
->open
= qeth_open
;
6352 dev
->stop
= qeth_stop
;
6353 dev
->hard_start_xmit
= qeth_hard_start_xmit
;
6354 dev
->do_ioctl
= qeth_do_ioctl
;
6355 dev
->get_stats
= qeth_get_stats
;
6356 dev
->change_mtu
= qeth_change_mtu
;
6357 dev
->neigh_setup
= qeth_neigh_setup
;
6358 dev
->set_multicast_list
= qeth_set_multicast_list
;
6359 #ifdef CONFIG_QETH_VLAN
6360 dev
->vlan_rx_register
= qeth_vlan_rx_register
;
6361 dev
->vlan_rx_kill_vid
= qeth_vlan_rx_kill_vid
;
6362 dev
->vlan_rx_add_vid
= qeth_vlan_rx_add_vid
;
6364 if (qeth_get_netdev_flags(card
) & IFF_NOARP
) {
6365 dev
->rebuild_header
= NULL
;
6366 dev
->hard_header
= NULL
;
6367 dev
->header_cache_update
= NULL
;
6368 dev
->hard_header_cache
= NULL
;
6370 #ifdef CONFIG_QETH_IPV6
6371 /*IPv6 address autoconfiguration stuff*/
6372 if (!(card
->info
.unique_id
& UNIQUE_ID_NOT_BY_CARD
))
6373 card
->dev
->dev_id
= card
->info
.unique_id
& 0xffff;
6375 if (card
->options
.fake_ll
&&
6376 (qeth_get_netdev_flags(card
) & IFF_NOARP
))
6377 dev
->hard_header
= qeth_fake_header
;
6378 dev
->hard_header_parse
= NULL
;
6379 dev
->set_mac_address
= qeth_layer2_set_mac_address
;
6380 dev
->flags
|= qeth_get_netdev_flags(card
);
6381 if ((card
->options
.fake_broadcast
) ||
6382 (card
->info
.broadcast_capable
))
6383 dev
->flags
|= IFF_BROADCAST
;
6384 dev
->hard_header_len
=
6385 qeth_get_hlen(card
->info
.link_type
) + card
->options
.add_hhlen
;
6386 dev
->addr_len
= OSA_ADDR_LEN
;
6387 dev
->mtu
= card
->info
.initial_mtu
;
6388 if (card
->info
.type
!= QETH_CARD_TYPE_OSN
)
6389 SET_ETHTOOL_OPS(dev
, &qeth_ethtool_ops
);
6390 SET_MODULE_OWNER(dev
);
6395 qeth_init_func_level(struct qeth_card
*card
)
6397 if (card
->ipato
.enabled
) {
6398 if (card
->info
.type
== QETH_CARD_TYPE_IQD
)
6399 card
->info
.func_level
=
6400 QETH_IDX_FUNC_LEVEL_IQD_ENA_IPAT
;
6402 card
->info
.func_level
=
6403 QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT
;
6405 if (card
->info
.type
== QETH_CARD_TYPE_IQD
)
6406 /*FIXME:why do we have same values for dis and ena for osae??? */
6407 card
->info
.func_level
=
6408 QETH_IDX_FUNC_LEVEL_IQD_DIS_IPAT
;
6410 card
->info
.func_level
=
6411 QETH_IDX_FUNC_LEVEL_OSAE_DIS_IPAT
;
6416 * hardsetup card, initialize MPC and QDIO stuff
6419 qeth_hardsetup_card(struct qeth_card
*card
)
6424 QETH_DBF_TEXT(setup
, 2, "hrdsetup");
6428 PRINT_WARN("Retrying to do IDX activates.\n");
6429 ccw_device_set_offline(CARD_DDEV(card
));
6430 ccw_device_set_offline(CARD_WDEV(card
));
6431 ccw_device_set_offline(CARD_RDEV(card
));
6432 ccw_device_set_online(CARD_RDEV(card
));
6433 ccw_device_set_online(CARD_WDEV(card
));
6434 ccw_device_set_online(CARD_DDEV(card
));
6436 rc
= qeth_qdio_clear_card(card
,card
->info
.type
!=QETH_CARD_TYPE_IQD
);
6437 if (rc
== -ERESTARTSYS
) {
6438 QETH_DBF_TEXT(setup
, 2, "break1");
6441 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
6447 if ((rc
= qeth_get_unitaddr(card
))){
6448 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
6451 qeth_init_tokens(card
);
6452 qeth_init_func_level(card
);
6453 rc
= qeth_idx_activate_channel(&card
->read
, qeth_idx_read_cb
);
6454 if (rc
== -ERESTARTSYS
) {
6455 QETH_DBF_TEXT(setup
, 2, "break2");
6458 QETH_DBF_TEXT_(setup
, 2, "3err%d", rc
);
6464 rc
= qeth_idx_activate_channel(&card
->write
, qeth_idx_write_cb
);
6465 if (rc
== -ERESTARTSYS
) {
6466 QETH_DBF_TEXT(setup
, 2, "break3");
6469 QETH_DBF_TEXT_(setup
, 2, "4err%d", rc
);
6475 if ((rc
= qeth_mpc_initialize(card
))){
6476 QETH_DBF_TEXT_(setup
, 2, "5err%d", rc
);
6479 /*network device will be recovered*/
6481 card
->dev
->hard_header
= card
->orig_hard_header
;
6482 if (card
->options
.fake_ll
&&
6483 (qeth_get_netdev_flags(card
) & IFF_NOARP
))
6484 card
->dev
->hard_header
= qeth_fake_header
;
6487 /* at first set_online allocate netdev */
6488 card
->dev
= qeth_get_netdevice(card
->info
.type
,
6489 card
->info
.link_type
);
6491 qeth_qdio_clear_card(card
, card
->info
.type
!=
6492 QETH_CARD_TYPE_IQD
);
6494 QETH_DBF_TEXT_(setup
, 2, "6err%d", rc
);
6497 card
->dev
->priv
= card
;
6498 card
->orig_hard_header
= card
->dev
->hard_header
;
6499 card
->dev
->type
= qeth_get_arphdr_type(card
->info
.type
,
6500 card
->info
.link_type
);
6501 card
->dev
->init
= qeth_netdev_init
;
6504 PRINT_ERR("Initialization in hardsetup failed! rc=%d\n", rc
);
6509 qeth_default_setassparms_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
6512 struct qeth_ipa_cmd
*cmd
;
6514 QETH_DBF_TEXT(trace
,4,"defadpcb");
6516 cmd
= (struct qeth_ipa_cmd
*) data
;
6517 if (cmd
->hdr
.return_code
== 0){
6518 cmd
->hdr
.return_code
= cmd
->data
.setassparms
.hdr
.return_code
;
6519 if (cmd
->hdr
.prot_version
== QETH_PROT_IPV4
)
6520 card
->options
.ipa4
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
6521 #ifdef CONFIG_QETH_IPV6
6522 if (cmd
->hdr
.prot_version
== QETH_PROT_IPV6
)
6523 card
->options
.ipa6
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
6526 if (cmd
->data
.setassparms
.hdr
.assist_no
== IPA_INBOUND_CHECKSUM
&&
6527 cmd
->data
.setassparms
.hdr
.command_code
== IPA_CMD_ASS_START
) {
6528 card
->info
.csum_mask
= cmd
->data
.setassparms
.data
.flags_32bit
;
6529 QETH_DBF_TEXT_(trace
, 3, "csum:%d", card
->info
.csum_mask
);
6535 qeth_default_setadapterparms_cb(struct qeth_card
*card
,
6536 struct qeth_reply
*reply
,
6539 struct qeth_ipa_cmd
*cmd
;
6541 QETH_DBF_TEXT(trace
,4,"defadpcb");
6543 cmd
= (struct qeth_ipa_cmd
*) data
;
6544 if (cmd
->hdr
.return_code
== 0)
6545 cmd
->hdr
.return_code
= cmd
->data
.setadapterparms
.hdr
.return_code
;
6552 qeth_query_setadapterparms_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
6555 struct qeth_ipa_cmd
*cmd
;
6557 QETH_DBF_TEXT(trace
,3,"quyadpcb");
6559 cmd
= (struct qeth_ipa_cmd
*) data
;
6560 if (cmd
->data
.setadapterparms
.data
.query_cmds_supp
.lan_type
& 0x7f)
6561 card
->info
.link_type
=
6562 cmd
->data
.setadapterparms
.data
.query_cmds_supp
.lan_type
;
6563 card
->options
.adp
.supported_funcs
=
6564 cmd
->data
.setadapterparms
.data
.query_cmds_supp
.supported_cmds
;
6565 return qeth_default_setadapterparms_cb(card
, reply
, (unsigned long)cmd
);
6569 qeth_query_setadapterparms(struct qeth_card
*card
)
6572 struct qeth_cmd_buffer
*iob
;
6574 QETH_DBF_TEXT(trace
,3,"queryadp");
6575 iob
= qeth_get_adapter_cmd(card
, IPA_SETADP_QUERY_COMMANDS_SUPPORTED
,
6576 sizeof(struct qeth_ipacmd_setadpparms
));
6577 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_query_setadapterparms_cb
, NULL
);
6582 qeth_setadpparms_change_macaddr_cb(struct qeth_card
*card
,
6583 struct qeth_reply
*reply
,
6586 struct qeth_ipa_cmd
*cmd
;
6588 QETH_DBF_TEXT(trace
,4,"chgmaccb");
6590 cmd
= (struct qeth_ipa_cmd
*) data
;
6591 if (!card
->options
.layer2
|| card
->info
.guestlan
||
6592 !(card
->info
.mac_bits
& QETH_LAYER2_MAC_READ
)) {
6593 memcpy(card
->dev
->dev_addr
,
6594 &cmd
->data
.setadapterparms
.data
.change_addr
.addr
,
6596 card
->info
.mac_bits
|= QETH_LAYER2_MAC_READ
;
6598 qeth_default_setadapterparms_cb(card
, reply
, (unsigned long) cmd
);
6603 qeth_setadpparms_change_macaddr(struct qeth_card
*card
)
6606 struct qeth_cmd_buffer
*iob
;
6607 struct qeth_ipa_cmd
*cmd
;
6609 QETH_DBF_TEXT(trace
,4,"chgmac");
6611 iob
= qeth_get_adapter_cmd(card
,IPA_SETADP_ALTER_MAC_ADDRESS
,
6612 sizeof(struct qeth_ipacmd_setadpparms
));
6613 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
6614 cmd
->data
.setadapterparms
.data
.change_addr
.cmd
= CHANGE_ADDR_READ_MAC
;
6615 cmd
->data
.setadapterparms
.data
.change_addr
.addr_size
= OSA_ADDR_LEN
;
6616 memcpy(&cmd
->data
.setadapterparms
.data
.change_addr
.addr
,
6617 card
->dev
->dev_addr
, OSA_ADDR_LEN
);
6618 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_setadpparms_change_macaddr_cb
,
6624 qeth_send_setadp_mode(struct qeth_card
*card
, __u32 command
, __u32 mode
)
6627 struct qeth_cmd_buffer
*iob
;
6628 struct qeth_ipa_cmd
*cmd
;
6630 QETH_DBF_TEXT(trace
,4,"adpmode");
6632 iob
= qeth_get_adapter_cmd(card
, command
,
6633 sizeof(struct qeth_ipacmd_setadpparms
));
6634 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
6635 cmd
->data
.setadapterparms
.data
.mode
= mode
;
6636 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_default_setadapterparms_cb
,
6642 qeth_setadapter_hstr(struct qeth_card
*card
)
6646 QETH_DBF_TEXT(trace
,4,"adphstr");
6648 if (qeth_adp_supported(card
,IPA_SETADP_SET_BROADCAST_MODE
)) {
6649 rc
= qeth_send_setadp_mode(card
, IPA_SETADP_SET_BROADCAST_MODE
,
6650 card
->options
.broadcast_mode
);
6652 PRINT_WARN("couldn't set broadcast mode on "
6654 CARD_BUS_ID(card
), rc
);
6655 rc
= qeth_send_setadp_mode(card
, IPA_SETADP_ALTER_MAC_ADDRESS
,
6656 card
->options
.macaddr_mode
);
6658 PRINT_WARN("couldn't set macaddr mode on "
6659 "device %s: x%x\n", CARD_BUS_ID(card
), rc
);
6662 if (card
->options
.broadcast_mode
== QETH_TR_BROADCAST_LOCAL
)
6663 PRINT_WARN("set adapter parameters not available "
6664 "to set broadcast mode, using ALLRINGS "
6665 "on device %s:\n", CARD_BUS_ID(card
));
6666 if (card
->options
.macaddr_mode
== QETH_TR_MACADDR_CANONICAL
)
6667 PRINT_WARN("set adapter parameters not available "
6668 "to set macaddr mode, using NONCANONICAL "
6669 "on device %s:\n", CARD_BUS_ID(card
));
6674 qeth_setadapter_parms(struct qeth_card
*card
)
6678 QETH_DBF_TEXT(setup
, 2, "setadprm");
6680 if (!qeth_is_supported(card
, IPA_SETADAPTERPARMS
)){
6681 PRINT_WARN("set adapter parameters not supported "
6684 QETH_DBF_TEXT(setup
, 2, " notsupp");
6687 rc
= qeth_query_setadapterparms(card
);
6689 PRINT_WARN("couldn't set adapter parameters on device %s: "
6690 "x%x\n", CARD_BUS_ID(card
), rc
);
6693 if (qeth_adp_supported(card
,IPA_SETADP_ALTER_MAC_ADDRESS
)) {
6694 rc
= qeth_setadpparms_change_macaddr(card
);
6696 PRINT_WARN("couldn't get MAC address on "
6698 CARD_BUS_ID(card
), rc
);
6701 if ((card
->info
.link_type
== QETH_LINK_TYPE_HSTR
) ||
6702 (card
->info
.link_type
== QETH_LINK_TYPE_LANE_TR
))
6703 rc
= qeth_setadapter_hstr(card
);
6709 qeth_layer2_initialize(struct qeth_card
*card
)
6714 QETH_DBF_TEXT(setup
, 2, "doL2init");
6715 QETH_DBF_TEXT_(setup
, 2, "doL2%s", CARD_BUS_ID(card
));
6717 rc
= qeth_query_setadapterparms(card
);
6719 PRINT_WARN("could not query adapter parameters on device %s: "
6720 "x%x\n", CARD_BUS_ID(card
), rc
);
6723 rc
= qeth_setadpparms_change_macaddr(card
);
6725 PRINT_WARN("couldn't get MAC address on "
6727 CARD_BUS_ID(card
), rc
);
6728 QETH_DBF_TEXT_(setup
, 2,"1err%d",rc
);
6731 QETH_DBF_HEX(setup
,2, card
->dev
->dev_addr
, OSA_ADDR_LEN
);
6733 rc
= qeth_layer2_send_setmac(card
, &card
->dev
->dev_addr
[0]);
6735 QETH_DBF_TEXT_(setup
, 2,"2err%d",rc
);
6741 qeth_send_startstoplan(struct qeth_card
*card
, enum qeth_ipa_cmds ipacmd
,
6742 enum qeth_prot_versions prot
)
6745 struct qeth_cmd_buffer
*iob
;
6747 iob
= qeth_get_ipacmd_buffer(card
,ipacmd
,prot
);
6748 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
6754 qeth_send_startlan(struct qeth_card
*card
, enum qeth_prot_versions prot
)
6758 QETH_DBF_TEXT_(setup
, 2, "strtlan%i", prot
);
6760 rc
= qeth_send_startstoplan(card
, IPA_CMD_STARTLAN
, prot
);
6765 qeth_send_stoplan(struct qeth_card
*card
)
6770 * TODO: according to the IPA format document page 14,
6771 * TCP/IP (we!) never issue a STOPLAN
6774 QETH_DBF_TEXT(trace
, 2, "stoplan");
6776 rc
= qeth_send_startstoplan(card
, IPA_CMD_STOPLAN
, QETH_PROT_IPV4
);
6781 qeth_query_ipassists_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
6784 struct qeth_ipa_cmd
*cmd
;
6786 QETH_DBF_TEXT(setup
, 2, "qipasscb");
6788 cmd
= (struct qeth_ipa_cmd
*) data
;
6789 if (cmd
->hdr
.prot_version
== QETH_PROT_IPV4
) {
6790 card
->options
.ipa4
.supported_funcs
= cmd
->hdr
.ipa_supported
;
6791 card
->options
.ipa4
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
6792 /* Disable IPV6 support hard coded for Hipersockets */
6793 if(card
->info
.type
== QETH_CARD_TYPE_IQD
)
6794 card
->options
.ipa4
.supported_funcs
&= ~IPA_IPV6
;
6796 #ifdef CONFIG_QETH_IPV6
6797 card
->options
.ipa6
.supported_funcs
= cmd
->hdr
.ipa_supported
;
6798 card
->options
.ipa6
.enabled_funcs
= cmd
->hdr
.ipa_enabled
;
6801 QETH_DBF_TEXT(setup
, 2, "suppenbl");
6802 QETH_DBF_TEXT_(setup
, 2, "%x",cmd
->hdr
.ipa_supported
);
6803 QETH_DBF_TEXT_(setup
, 2, "%x",cmd
->hdr
.ipa_enabled
);
6808 qeth_query_ipassists(struct qeth_card
*card
, enum qeth_prot_versions prot
)
6811 struct qeth_cmd_buffer
*iob
;
6813 QETH_DBF_TEXT_(setup
, 2, "qipassi%i", prot
);
6814 if (card
->options
.layer2
) {
6815 QETH_DBF_TEXT(setup
, 2, "noprmly2");
6819 iob
= qeth_get_ipacmd_buffer(card
,IPA_CMD_QIPASSIST
,prot
);
6820 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_query_ipassists_cb
, NULL
);
6824 static struct qeth_cmd_buffer
*
6825 qeth_get_setassparms_cmd(struct qeth_card
*card
, enum qeth_ipa_funcs ipa_func
,
6826 __u16 cmd_code
, __u16 len
,
6827 enum qeth_prot_versions prot
)
6829 struct qeth_cmd_buffer
*iob
;
6830 struct qeth_ipa_cmd
*cmd
;
6832 QETH_DBF_TEXT(trace
,4,"getasscm");
6833 iob
= qeth_get_ipacmd_buffer(card
,IPA_CMD_SETASSPARMS
,prot
);
6835 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
6836 cmd
->data
.setassparms
.hdr
.assist_no
= ipa_func
;
6837 cmd
->data
.setassparms
.hdr
.length
= 8 + len
;
6838 cmd
->data
.setassparms
.hdr
.command_code
= cmd_code
;
6839 cmd
->data
.setassparms
.hdr
.return_code
= 0;
6840 cmd
->data
.setassparms
.hdr
.seq_no
= 0;
6846 qeth_send_setassparms(struct qeth_card
*card
, struct qeth_cmd_buffer
*iob
,
6847 __u16 len
, long data
,
6849 (struct qeth_card
*,struct qeth_reply
*,unsigned long),
6853 struct qeth_ipa_cmd
*cmd
;
6855 QETH_DBF_TEXT(trace
,4,"sendassp");
6857 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
6858 if (len
<= sizeof(__u32
))
6859 cmd
->data
.setassparms
.data
.flags_32bit
= (__u32
) data
;
6860 else /* (len > sizeof(__u32)) */
6861 memcpy(&cmd
->data
.setassparms
.data
, (void *) data
, len
);
6863 rc
= qeth_send_ipa_cmd(card
, iob
, reply_cb
, reply_param
);
6867 #ifdef CONFIG_QETH_IPV6
6869 qeth_send_simple_setassparms_ipv6(struct qeth_card
*card
,
6870 enum qeth_ipa_funcs ipa_func
, __u16 cmd_code
)
6874 struct qeth_cmd_buffer
*iob
;
6876 QETH_DBF_TEXT(trace
,4,"simassp6");
6877 iob
= qeth_get_setassparms_cmd(card
, ipa_func
, cmd_code
,
6879 rc
= qeth_send_setassparms(card
, iob
, 0, 0,
6880 qeth_default_setassparms_cb
, NULL
);
6886 qeth_send_simple_setassparms(struct qeth_card
*card
,
6887 enum qeth_ipa_funcs ipa_func
,
6888 __u16 cmd_code
, long data
)
6892 struct qeth_cmd_buffer
*iob
;
6894 QETH_DBF_TEXT(trace
,4,"simassp4");
6896 length
= sizeof(__u32
);
6897 iob
= qeth_get_setassparms_cmd(card
, ipa_func
, cmd_code
,
6898 length
, QETH_PROT_IPV4
);
6899 rc
= qeth_send_setassparms(card
, iob
, length
, data
,
6900 qeth_default_setassparms_cb
, NULL
);
6905 qeth_start_ipa_arp_processing(struct qeth_card
*card
)
6909 QETH_DBF_TEXT(trace
,3,"ipaarp");
6911 if (!qeth_is_supported(card
,IPA_ARP_PROCESSING
)) {
6912 PRINT_WARN("ARP processing not supported "
6913 "on %s!\n", QETH_CARD_IFNAME(card
));
6916 rc
= qeth_send_simple_setassparms(card
,IPA_ARP_PROCESSING
,
6917 IPA_CMD_ASS_START
, 0);
6919 PRINT_WARN("Could not start ARP processing "
6920 "assist on %s: 0x%x\n",
6921 QETH_CARD_IFNAME(card
), rc
);
6927 qeth_start_ipa_ip_fragmentation(struct qeth_card
*card
)
6931 QETH_DBF_TEXT(trace
,3,"ipaipfrg");
6933 if (!qeth_is_supported(card
, IPA_IP_FRAGMENTATION
)) {
6934 PRINT_INFO("Hardware IP fragmentation not supported on %s\n",
6935 QETH_CARD_IFNAME(card
));
6939 rc
= qeth_send_simple_setassparms(card
, IPA_IP_FRAGMENTATION
,
6940 IPA_CMD_ASS_START
, 0);
6942 PRINT_WARN("Could not start Hardware IP fragmentation "
6943 "assist on %s: 0x%x\n",
6944 QETH_CARD_IFNAME(card
), rc
);
6946 PRINT_INFO("Hardware IP fragmentation enabled \n");
6951 qeth_start_ipa_source_mac(struct qeth_card
*card
)
6955 QETH_DBF_TEXT(trace
,3,"stsrcmac");
6957 if (!card
->options
.fake_ll
)
6960 if (!qeth_is_supported(card
, IPA_SOURCE_MAC
)) {
6961 PRINT_INFO("Inbound source address not "
6962 "supported on %s\n", QETH_CARD_IFNAME(card
));
6966 rc
= qeth_send_simple_setassparms(card
, IPA_SOURCE_MAC
,
6967 IPA_CMD_ASS_START
, 0);
6969 PRINT_WARN("Could not start inbound source "
6970 "assist on %s: 0x%x\n",
6971 QETH_CARD_IFNAME(card
), rc
);
6976 qeth_start_ipa_vlan(struct qeth_card
*card
)
6980 QETH_DBF_TEXT(trace
,3,"strtvlan");
6982 #ifdef CONFIG_QETH_VLAN
6983 if (!qeth_is_supported(card
, IPA_FULL_VLAN
)) {
6984 PRINT_WARN("VLAN not supported on %s\n", QETH_CARD_IFNAME(card
));
6988 rc
= qeth_send_simple_setassparms(card
, IPA_VLAN_PRIO
,
6989 IPA_CMD_ASS_START
,0);
6991 PRINT_WARN("Could not start vlan "
6992 "assist on %s: 0x%x\n",
6993 QETH_CARD_IFNAME(card
), rc
);
6995 PRINT_INFO("VLAN enabled \n");
6996 card
->dev
->features
|=
6997 NETIF_F_HW_VLAN_FILTER
|
6998 NETIF_F_HW_VLAN_TX
|
7001 #endif /* QETH_VLAN */
7006 qeth_start_ipa_multicast(struct qeth_card
*card
)
7010 QETH_DBF_TEXT(trace
,3,"stmcast");
7012 if (!qeth_is_supported(card
, IPA_MULTICASTING
)) {
7013 PRINT_WARN("Multicast not supported on %s\n",
7014 QETH_CARD_IFNAME(card
));
7018 rc
= qeth_send_simple_setassparms(card
, IPA_MULTICASTING
,
7019 IPA_CMD_ASS_START
,0);
7021 PRINT_WARN("Could not start multicast "
7022 "assist on %s: rc=%i\n",
7023 QETH_CARD_IFNAME(card
), rc
);
7025 PRINT_INFO("Multicast enabled\n");
7026 card
->dev
->flags
|= IFF_MULTICAST
;
7031 #ifdef CONFIG_QETH_IPV6
7033 qeth_softsetup_ipv6(struct qeth_card
*card
)
7037 QETH_DBF_TEXT(trace
,3,"softipv6");
7039 rc
= qeth_send_startlan(card
, QETH_PROT_IPV6
);
7041 PRINT_ERR("IPv6 startlan failed on %s\n",
7042 QETH_CARD_IFNAME(card
));
7045 rc
= qeth_query_ipassists(card
,QETH_PROT_IPV6
);
7047 PRINT_ERR("IPv6 query ipassist failed on %s\n",
7048 QETH_CARD_IFNAME(card
));
7051 rc
= qeth_send_simple_setassparms(card
, IPA_IPV6
,
7052 IPA_CMD_ASS_START
, 3);
7054 PRINT_WARN("IPv6 start assist (version 4) failed "
7056 QETH_CARD_IFNAME(card
), rc
);
7059 rc
= qeth_send_simple_setassparms_ipv6(card
, IPA_IPV6
,
7062 PRINT_WARN("IPV6 start assist (version 6) failed "
7064 QETH_CARD_IFNAME(card
), rc
);
7067 rc
= qeth_send_simple_setassparms_ipv6(card
, IPA_PASSTHRU
,
7070 PRINT_WARN("Could not enable passthrough "
7072 QETH_CARD_IFNAME(card
), rc
);
7075 PRINT_INFO("IPV6 enabled \n");
7082 qeth_start_ipa_ipv6(struct qeth_card
*card
)
7085 #ifdef CONFIG_QETH_IPV6
7086 QETH_DBF_TEXT(trace
,3,"strtipv6");
7088 if (!qeth_is_supported(card
, IPA_IPV6
)) {
7089 PRINT_WARN("IPv6 not supported on %s\n",
7090 QETH_CARD_IFNAME(card
));
7093 rc
= qeth_softsetup_ipv6(card
);
7099 qeth_start_ipa_broadcast(struct qeth_card
*card
)
7103 QETH_DBF_TEXT(trace
,3,"stbrdcst");
7104 card
->info
.broadcast_capable
= 0;
7105 if (!qeth_is_supported(card
, IPA_FILTERING
)) {
7106 PRINT_WARN("Broadcast not supported on %s\n",
7107 QETH_CARD_IFNAME(card
));
7111 rc
= qeth_send_simple_setassparms(card
, IPA_FILTERING
,
7112 IPA_CMD_ASS_START
, 0);
7114 PRINT_WARN("Could not enable broadcasting filtering "
7116 QETH_CARD_IFNAME(card
), rc
);
7120 rc
= qeth_send_simple_setassparms(card
, IPA_FILTERING
,
7121 IPA_CMD_ASS_CONFIGURE
, 1);
7123 PRINT_WARN("Could not set up broadcast filtering on %s: 0x%x\n",
7124 QETH_CARD_IFNAME(card
), rc
);
7127 card
->info
.broadcast_capable
= QETH_BROADCAST_WITH_ECHO
;
7128 PRINT_INFO("Broadcast enabled \n");
7129 rc
= qeth_send_simple_setassparms(card
, IPA_FILTERING
,
7130 IPA_CMD_ASS_ENABLE
, 1);
7132 PRINT_WARN("Could not set up broadcast echo filtering on "
7133 "%s: 0x%x\n", QETH_CARD_IFNAME(card
), rc
);
7136 card
->info
.broadcast_capable
= QETH_BROADCAST_WITHOUT_ECHO
;
7138 if (card
->info
.broadcast_capable
)
7139 card
->dev
->flags
|= IFF_BROADCAST
;
7141 card
->dev
->flags
&= ~IFF_BROADCAST
;
7146 qeth_send_checksum_command(struct qeth_card
*card
)
7150 rc
= qeth_send_simple_setassparms(card
, IPA_INBOUND_CHECKSUM
,
7151 IPA_CMD_ASS_START
, 0);
7153 PRINT_WARN("Starting Inbound HW Checksumming failed on %s: "
7154 "0x%x,\ncontinuing using Inbound SW Checksumming\n",
7155 QETH_CARD_IFNAME(card
), rc
);
7158 rc
= qeth_send_simple_setassparms(card
, IPA_INBOUND_CHECKSUM
,
7160 card
->info
.csum_mask
);
7162 PRINT_WARN("Enabling Inbound HW Checksumming failed on %s: "
7163 "0x%x,\ncontinuing using Inbound SW Checksumming\n",
7164 QETH_CARD_IFNAME(card
), rc
);
7171 qeth_start_ipa_checksum(struct qeth_card
*card
)
7175 QETH_DBF_TEXT(trace
,3,"strtcsum");
7177 if (card
->options
.checksum_type
== NO_CHECKSUMMING
) {
7178 PRINT_WARN("Using no checksumming on %s.\n",
7179 QETH_CARD_IFNAME(card
));
7182 if (card
->options
.checksum_type
== SW_CHECKSUMMING
) {
7183 PRINT_WARN("Using SW checksumming on %s.\n",
7184 QETH_CARD_IFNAME(card
));
7187 if (!qeth_is_supported(card
, IPA_INBOUND_CHECKSUM
)) {
7188 PRINT_WARN("Inbound HW Checksumming not "
7189 "supported on %s,\ncontinuing "
7190 "using Inbound SW Checksumming\n",
7191 QETH_CARD_IFNAME(card
));
7192 card
->options
.checksum_type
= SW_CHECKSUMMING
;
7195 rc
= qeth_send_checksum_command(card
);
7197 PRINT_INFO("HW Checksumming (inbound) enabled \n");
7203 qeth_start_ipa_tso(struct qeth_card
*card
)
7207 QETH_DBF_TEXT(trace
,3,"sttso");
7209 if (!qeth_is_supported(card
, IPA_OUTBOUND_TSO
)) {
7210 PRINT_WARN("Outbound TSO not supported on %s\n",
7211 QETH_CARD_IFNAME(card
));
7214 rc
= qeth_send_simple_setassparms(card
, IPA_OUTBOUND_TSO
,
7215 IPA_CMD_ASS_START
,0);
7217 PRINT_WARN("Could not start outbound TSO "
7218 "assist on %s: rc=%i\n",
7219 QETH_CARD_IFNAME(card
), rc
);
7221 PRINT_INFO("Outbound TSO enabled\n");
7223 if (rc
&& (card
->options
.large_send
== QETH_LARGE_SEND_TSO
)){
7224 card
->options
.large_send
= QETH_LARGE_SEND_NO
;
7225 card
->dev
->features
&= ~ (NETIF_F_TSO
| NETIF_F_SG
);
7231 qeth_start_ipassists(struct qeth_card
*card
)
7233 QETH_DBF_TEXT(trace
,3,"strtipas");
7234 qeth_start_ipa_arp_processing(card
); /* go on*/
7235 qeth_start_ipa_ip_fragmentation(card
); /* go on*/
7236 qeth_start_ipa_source_mac(card
); /* go on*/
7237 qeth_start_ipa_vlan(card
); /* go on*/
7238 qeth_start_ipa_multicast(card
); /* go on*/
7239 qeth_start_ipa_ipv6(card
); /* go on*/
7240 qeth_start_ipa_broadcast(card
); /* go on*/
7241 qeth_start_ipa_checksum(card
); /* go on*/
7242 qeth_start_ipa_tso(card
); /* go on*/
7247 qeth_send_setrouting(struct qeth_card
*card
, enum qeth_routing_types type
,
7248 enum qeth_prot_versions prot
)
7251 struct qeth_ipa_cmd
*cmd
;
7252 struct qeth_cmd_buffer
*iob
;
7254 QETH_DBF_TEXT(trace
,4,"setroutg");
7255 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_SETRTG
, prot
);
7256 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
7257 cmd
->data
.setrtg
.type
= (type
);
7258 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
7265 qeth_correct_routing_type(struct qeth_card
*card
, enum qeth_routing_types
*type
,
7266 enum qeth_prot_versions prot
)
7268 if (card
->info
.type
== QETH_CARD_TYPE_IQD
) {
7271 case PRIMARY_CONNECTOR
:
7272 case SECONDARY_CONNECTOR
:
7273 case MULTICAST_ROUTER
:
7281 case PRIMARY_ROUTER
:
7282 case SECONDARY_ROUTER
:
7284 case MULTICAST_ROUTER
:
7285 if (qeth_is_ipafunc_supported(card
, prot
,
7293 PRINT_WARN("Routing type '%s' not supported for interface %s.\n"
7294 "Router status set to 'no router'.\n",
7295 ((*type
== PRIMARY_ROUTER
)? "primary router" :
7296 (*type
== SECONDARY_ROUTER
)? "secondary router" :
7297 (*type
== PRIMARY_CONNECTOR
)? "primary connector" :
7298 (*type
== SECONDARY_CONNECTOR
)? "secondary connector" :
7299 (*type
== MULTICAST_ROUTER
)? "multicast router" :
7306 qeth_setrouting_v4(struct qeth_card
*card
)
7310 QETH_DBF_TEXT(trace
,3,"setrtg4");
7312 qeth_correct_routing_type(card
, &card
->options
.route4
.type
,
7315 rc
= qeth_send_setrouting(card
, card
->options
.route4
.type
,
7318 card
->options
.route4
.type
= NO_ROUTER
;
7319 PRINT_WARN("Error (0x%04x) while setting routing type on %s. "
7320 "Type set to 'no router'.\n",
7321 rc
, QETH_CARD_IFNAME(card
));
7327 qeth_setrouting_v6(struct qeth_card
*card
)
7331 QETH_DBF_TEXT(trace
,3,"setrtg6");
7332 #ifdef CONFIG_QETH_IPV6
7334 qeth_correct_routing_type(card
, &card
->options
.route6
.type
,
7337 rc
= qeth_send_setrouting(card
, card
->options
.route6
.type
,
7340 card
->options
.route6
.type
= NO_ROUTER
;
7341 PRINT_WARN("Error (0x%04x) while setting routing type on %s. "
7342 "Type set to 'no router'.\n",
7343 rc
, QETH_CARD_IFNAME(card
));
7350 qeth_set_large_send(struct qeth_card
*card
, enum qeth_large_send_types type
)
7354 if (card
->dev
== NULL
) {
7355 card
->options
.large_send
= type
;
7358 if (card
->state
== CARD_STATE_UP
)
7359 netif_tx_disable(card
->dev
);
7360 card
->options
.large_send
= type
;
7361 switch (card
->options
.large_send
) {
7362 case QETH_LARGE_SEND_EDDP
:
7363 card
->dev
->features
|= NETIF_F_TSO
| NETIF_F_SG
;
7365 case QETH_LARGE_SEND_TSO
:
7366 if (qeth_is_supported(card
, IPA_OUTBOUND_TSO
)){
7367 card
->dev
->features
|= NETIF_F_TSO
| NETIF_F_SG
;
7369 PRINT_WARN("TSO not supported on %s. "
7370 "large_send set to 'no'.\n",
7372 card
->dev
->features
&= ~(NETIF_F_TSO
| NETIF_F_SG
);
7373 card
->options
.large_send
= QETH_LARGE_SEND_NO
;
7377 default: /* includes QETH_LARGE_SEND_NO */
7378 card
->dev
->features
&= ~(NETIF_F_TSO
| NETIF_F_SG
);
7381 if (card
->state
== CARD_STATE_UP
)
7382 netif_wake_queue(card
->dev
);
7387 * softsetup card: init IPA stuff
7390 qeth_softsetup_card(struct qeth_card
*card
)
7394 QETH_DBF_TEXT(setup
, 2, "softsetp");
7396 if ((rc
= qeth_send_startlan(card
, QETH_PROT_IPV4
))){
7397 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
7399 PRINT_WARN("LAN on card %s if offline! "
7400 "Continuing softsetup.\n",
7402 card
->lan_online
= 0;
7406 card
->lan_online
= 1;
7407 if (card
->info
.type
==QETH_CARD_TYPE_OSN
)
7409 qeth_set_large_send(card
, card
->options
.large_send
);
7410 if (card
->options
.layer2
) {
7411 card
->dev
->features
|=
7412 NETIF_F_HW_VLAN_FILTER
|
7413 NETIF_F_HW_VLAN_TX
|
7415 card
->dev
->flags
|=IFF_MULTICAST
|IFF_BROADCAST
;
7416 card
->info
.broadcast_capable
=1;
7417 if ((rc
= qeth_layer2_initialize(card
))) {
7418 QETH_DBF_TEXT_(setup
, 2, "L2err%d", rc
);
7421 #ifdef CONFIG_QETH_VLAN
7422 qeth_layer2_process_vlans(card
, 0);
7426 if ((rc
= qeth_setadapter_parms(card
)))
7427 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
7428 if ((rc
= qeth_start_ipassists(card
)))
7429 QETH_DBF_TEXT_(setup
, 2, "3err%d", rc
);
7430 if ((rc
= qeth_setrouting_v4(card
)))
7431 QETH_DBF_TEXT_(setup
, 2, "4err%d", rc
);
7432 if ((rc
= qeth_setrouting_v6(card
)))
7433 QETH_DBF_TEXT_(setup
, 2, "5err%d", rc
);
7435 netif_tx_disable(card
->dev
);
7439 #ifdef CONFIG_QETH_IPV6
7441 qeth_get_unique_id_cb(struct qeth_card
*card
, struct qeth_reply
*reply
,
7444 struct qeth_ipa_cmd
*cmd
;
7446 cmd
= (struct qeth_ipa_cmd
*) data
;
7447 if (cmd
->hdr
.return_code
== 0)
7448 card
->info
.unique_id
= *((__u16
*)
7449 &cmd
->data
.create_destroy_addr
.unique_id
[6]);
7451 card
->info
.unique_id
= UNIQUE_ID_IF_CREATE_ADDR_FAILED
|
7452 UNIQUE_ID_NOT_BY_CARD
;
7453 PRINT_WARN("couldn't get a unique id from the card on device "
7454 "%s (result=x%x), using default id. ipv6 "
7455 "autoconfig on other lpars may lead to duplicate "
7456 "ip addresses. please use manually "
7457 "configured ones.\n",
7458 CARD_BUS_ID(card
), cmd
->hdr
.return_code
);
7465 qeth_put_unique_id(struct qeth_card
*card
)
7469 #ifdef CONFIG_QETH_IPV6
7470 struct qeth_cmd_buffer
*iob
;
7471 struct qeth_ipa_cmd
*cmd
;
7473 QETH_DBF_TEXT(trace
,2,"puniqeid");
7475 if ((card
->info
.unique_id
& UNIQUE_ID_NOT_BY_CARD
) ==
7476 UNIQUE_ID_NOT_BY_CARD
)
7478 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_DESTROY_ADDR
,
7480 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
7481 *((__u16
*) &cmd
->data
.create_destroy_addr
.unique_id
[6]) =
7482 card
->info
.unique_id
;
7483 memcpy(&cmd
->data
.create_destroy_addr
.unique_id
[0],
7484 card
->dev
->dev_addr
, OSA_ADDR_LEN
);
7485 rc
= qeth_send_ipa_cmd(card
, iob
, NULL
, NULL
);
7487 card
->info
.unique_id
= UNIQUE_ID_IF_CREATE_ADDR_FAILED
|
7488 UNIQUE_ID_NOT_BY_CARD
;
7497 qeth_clear_ip_list(struct qeth_card
*card
, int clean
, int recover
)
7499 struct qeth_ipaddr
*addr
, *tmp
;
7500 unsigned long flags
;
7502 QETH_DBF_TEXT(trace
,4,"clearip");
7503 spin_lock_irqsave(&card
->ip_lock
, flags
);
7504 /* clear todo list */
7505 list_for_each_entry_safe(addr
, tmp
, card
->ip_tbd_list
, entry
){
7506 list_del(&addr
->entry
);
7510 while (!list_empty(&card
->ip_list
)) {
7511 addr
= list_entry(card
->ip_list
.next
,
7512 struct qeth_ipaddr
, entry
);
7513 list_del_init(&addr
->entry
);
7515 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
7516 qeth_deregister_addr_entry(card
, addr
);
7517 spin_lock_irqsave(&card
->ip_lock
, flags
);
7519 if (!recover
|| addr
->is_multicast
) {
7523 list_add_tail(&addr
->entry
, card
->ip_tbd_list
);
7525 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
7529 qeth_set_allowed_threads(struct qeth_card
*card
, unsigned long threads
,
7530 int clear_start_mask
)
7532 unsigned long flags
;
7534 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
7535 card
->thread_allowed_mask
= threads
;
7536 if (clear_start_mask
)
7537 card
->thread_start_mask
&= threads
;
7538 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
7539 wake_up(&card
->wait_q
);
7543 qeth_threads_running(struct qeth_card
*card
, unsigned long threads
)
7545 unsigned long flags
;
7548 spin_lock_irqsave(&card
->thread_mask_lock
, flags
);
7549 rc
= (card
->thread_running_mask
& threads
);
7550 spin_unlock_irqrestore(&card
->thread_mask_lock
, flags
);
7555 qeth_wait_for_threads(struct qeth_card
*card
, unsigned long threads
)
7557 return wait_event_interruptible(card
->wait_q
,
7558 qeth_threads_running(card
, threads
) == 0);
7562 qeth_stop_card(struct qeth_card
*card
, int recovery_mode
)
7566 QETH_DBF_TEXT(setup
,2,"stopcard");
7567 QETH_DBF_HEX(setup
, 2, &card
, sizeof(void *));
7569 qeth_set_allowed_threads(card
, 0, 1);
7570 if (qeth_wait_for_threads(card
, ~QETH_RECOVER_THREAD
))
7571 return -ERESTARTSYS
;
7572 if (card
->read
.state
== CH_STATE_UP
&&
7573 card
->write
.state
== CH_STATE_UP
&&
7574 (card
->state
== CARD_STATE_UP
)) {
7575 if (recovery_mode
&&
7576 card
->info
.type
!= QETH_CARD_TYPE_OSN
) {
7577 qeth_stop(card
->dev
);
7580 dev_close(card
->dev
);
7583 if (!card
->use_hard_stop
) {
7584 __u8
*mac
= &card
->dev
->dev_addr
[0];
7585 rc
= qeth_layer2_send_delmac(card
, mac
);
7586 QETH_DBF_TEXT_(setup
, 2, "Lerr%d", rc
);
7587 if ((rc
= qeth_send_stoplan(card
)))
7588 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
7590 card
->state
= CARD_STATE_SOFTSETUP
;
7592 if (card
->state
== CARD_STATE_SOFTSETUP
) {
7593 #ifdef CONFIG_QETH_VLAN
7594 if (card
->options
.layer2
)
7595 qeth_layer2_process_vlans(card
, 1);
7597 qeth_clear_ip_list(card
, !card
->use_hard_stop
, 1);
7598 qeth_clear_ipacmd_list(card
);
7599 card
->state
= CARD_STATE_HARDSETUP
;
7601 if (card
->state
== CARD_STATE_HARDSETUP
) {
7602 if ((!card
->use_hard_stop
) &&
7603 (!card
->options
.layer2
))
7604 if ((rc
= qeth_put_unique_id(card
)))
7605 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
7606 qeth_qdio_clear_card(card
, 0);
7607 qeth_clear_qdio_buffers(card
);
7608 qeth_clear_working_pool_list(card
);
7609 card
->state
= CARD_STATE_DOWN
;
7611 if (card
->state
== CARD_STATE_DOWN
) {
7612 qeth_clear_cmd_buffers(&card
->read
);
7613 qeth_clear_cmd_buffers(&card
->write
);
7615 card
->use_hard_stop
= 0;
7621 qeth_get_unique_id(struct qeth_card
*card
)
7624 #ifdef CONFIG_QETH_IPV6
7625 struct qeth_cmd_buffer
*iob
;
7626 struct qeth_ipa_cmd
*cmd
;
7628 QETH_DBF_TEXT(setup
, 2, "guniqeid");
7630 if (!qeth_is_supported(card
,IPA_IPV6
)) {
7631 card
->info
.unique_id
= UNIQUE_ID_IF_CREATE_ADDR_FAILED
|
7632 UNIQUE_ID_NOT_BY_CARD
;
7636 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_CREATE_ADDR
,
7638 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
7639 *((__u16
*) &cmd
->data
.create_destroy_addr
.unique_id
[6]) =
7640 card
->info
.unique_id
;
7642 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_get_unique_id_cb
, NULL
);
7644 card
->info
.unique_id
= UNIQUE_ID_IF_CREATE_ADDR_FAILED
|
7645 UNIQUE_ID_NOT_BY_CARD
;
7650 qeth_print_status_with_portname(struct qeth_card
*card
)
7655 sprintf(dbf_text
, "%s", card
->info
.portname
+ 1);
7656 for (i
= 0; i
< 8; i
++)
7658 (char) _ebcasc
[(__u8
) dbf_text
[i
]];
7660 printk("qeth: Device %s/%s/%s is a%s card%s%s%s\n"
7661 "with link type %s (portname: %s)\n",
7665 qeth_get_cardname(card
),
7666 (card
->info
.mcl_level
[0]) ? " (level: " : "",
7667 (card
->info
.mcl_level
[0]) ? card
->info
.mcl_level
: "",
7668 (card
->info
.mcl_level
[0]) ? ")" : "",
7669 qeth_get_cardname_short(card
),
7675 qeth_print_status_no_portname(struct qeth_card
*card
)
7677 if (card
->info
.portname
[0])
7678 printk("qeth: Device %s/%s/%s is a%s "
7679 "card%s%s%s\nwith link type %s "
7680 "(no portname needed by interface).\n",
7684 qeth_get_cardname(card
),
7685 (card
->info
.mcl_level
[0]) ? " (level: " : "",
7686 (card
->info
.mcl_level
[0]) ? card
->info
.mcl_level
: "",
7687 (card
->info
.mcl_level
[0]) ? ")" : "",
7688 qeth_get_cardname_short(card
));
7690 printk("qeth: Device %s/%s/%s is a%s "
7691 "card%s%s%s\nwith link type %s.\n",
7695 qeth_get_cardname(card
),
7696 (card
->info
.mcl_level
[0]) ? " (level: " : "",
7697 (card
->info
.mcl_level
[0]) ? card
->info
.mcl_level
: "",
7698 (card
->info
.mcl_level
[0]) ? ")" : "",
7699 qeth_get_cardname_short(card
));
7703 qeth_print_status_message(struct qeth_card
*card
)
7705 switch (card
->info
.type
) {
7706 case QETH_CARD_TYPE_OSAE
:
7707 /* VM will use a non-zero first character
7708 * to indicate a HiperSockets like reporting
7709 * of the level OSA sets the first character to zero
7711 if (!card
->info
.mcl_level
[0]) {
7712 sprintf(card
->info
.mcl_level
,"%02x%02x",
7713 card
->info
.mcl_level
[2],
7714 card
->info
.mcl_level
[3]);
7716 card
->info
.mcl_level
[QETH_MCL_LENGTH
] = 0;
7720 case QETH_CARD_TYPE_IQD
:
7721 card
->info
.mcl_level
[0] = (char) _ebcasc
[(__u8
)
7722 card
->info
.mcl_level
[0]];
7723 card
->info
.mcl_level
[1] = (char) _ebcasc
[(__u8
)
7724 card
->info
.mcl_level
[1]];
7725 card
->info
.mcl_level
[2] = (char) _ebcasc
[(__u8
)
7726 card
->info
.mcl_level
[2]];
7727 card
->info
.mcl_level
[3] = (char) _ebcasc
[(__u8
)
7728 card
->info
.mcl_level
[3]];
7729 card
->info
.mcl_level
[QETH_MCL_LENGTH
] = 0;
7732 memset(&card
->info
.mcl_level
[0], 0, QETH_MCL_LENGTH
+ 1);
7734 if (card
->info
.portname_required
)
7735 qeth_print_status_with_portname(card
);
7737 qeth_print_status_no_portname(card
);
7741 qeth_register_netdev(struct qeth_card
*card
)
7743 QETH_DBF_TEXT(setup
, 3, "regnetd");
7744 if (card
->dev
->reg_state
!= NETREG_UNINITIALIZED
)
7747 SET_NETDEV_DEV(card
->dev
, &card
->gdev
->dev
);
7748 return register_netdev(card
->dev
);
7752 qeth_start_again(struct qeth_card
*card
, int recovery_mode
)
7754 QETH_DBF_TEXT(setup
,2, "startag");
7756 if (recovery_mode
&&
7757 card
->info
.type
!= QETH_CARD_TYPE_OSN
) {
7758 qeth_open(card
->dev
);
7761 dev_open(card
->dev
);
7764 /* this also sets saved unicast addresses */
7765 qeth_set_multicast_list(card
->dev
);
7769 /* Layer 2 specific stuff */
7770 #define IGNORE_PARAM_EQ(option,value,reset_value,msg) \
7771 if (card->options.option == value) { \
7772 PRINT_ERR("%s not supported with layer 2 " \
7773 "functionality, ignoring option on read" \
7774 "channel device %s .\n",msg,CARD_RDEV_ID(card)); \
7775 card->options.option = reset_value; \
7777 #define IGNORE_PARAM_NEQ(option,value,reset_value,msg) \
7778 if (card->options.option != value) { \
7779 PRINT_ERR("%s not supported with layer 2 " \
7780 "functionality, ignoring option on read" \
7781 "channel device %s .\n",msg,CARD_RDEV_ID(card)); \
7782 card->options.option = reset_value; \
7786 static void qeth_make_parameters_consistent(struct qeth_card
*card
)
7789 if (card
->options
.layer2
== 0)
7791 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
7793 if (card
->info
.type
== QETH_CARD_TYPE_IQD
) {
7794 PRINT_ERR("Device %s does not support layer 2 functionality." \
7795 " Ignoring layer2 option.\n",CARD_BUS_ID(card
));
7796 card
->options
.layer2
= 0;
7799 IGNORE_PARAM_NEQ(route4
.type
, NO_ROUTER
, NO_ROUTER
,
7800 "Routing options are");
7801 #ifdef CONFIG_QETH_IPV6
7802 IGNORE_PARAM_NEQ(route6
.type
, NO_ROUTER
, NO_ROUTER
,
7803 "Routing options are");
7805 IGNORE_PARAM_EQ(checksum_type
, HW_CHECKSUMMING
,
7806 QETH_CHECKSUM_DEFAULT
,
7807 "Checksumming options are");
7808 IGNORE_PARAM_NEQ(broadcast_mode
, QETH_TR_BROADCAST_ALLRINGS
,
7809 QETH_TR_BROADCAST_ALLRINGS
,
7810 "Broadcast mode options are");
7811 IGNORE_PARAM_NEQ(macaddr_mode
, QETH_TR_MACADDR_NONCANONICAL
,
7812 QETH_TR_MACADDR_NONCANONICAL
,
7813 "Canonical MAC addr options are");
7814 IGNORE_PARAM_NEQ(fake_broadcast
, 0, 0,
7815 "Broadcast faking options are");
7816 IGNORE_PARAM_NEQ(add_hhlen
, DEFAULT_ADD_HHLEN
,
7817 DEFAULT_ADD_HHLEN
,"Option add_hhlen is");
7818 IGNORE_PARAM_NEQ(fake_ll
, 0, 0,"Option fake_ll is");
7823 __qeth_set_online(struct ccwgroup_device
*gdev
, int recovery_mode
)
7825 struct qeth_card
*card
= gdev
->dev
.driver_data
;
7827 enum qeth_card_states recover_flag
;
7830 QETH_DBF_TEXT(setup
,2, "setonlin");
7831 QETH_DBF_HEX(setup
, 2, &card
, sizeof(void *));
7833 qeth_set_allowed_threads(card
, QETH_RECOVER_THREAD
, 1);
7834 if (qeth_wait_for_threads(card
, ~QETH_RECOVER_THREAD
)){
7835 PRINT_WARN("set_online of card %s interrupted by user!\n",
7837 return -ERESTARTSYS
;
7840 recover_flag
= card
->state
;
7841 if ((rc
= ccw_device_set_online(CARD_RDEV(card
))) ||
7842 (rc
= ccw_device_set_online(CARD_WDEV(card
))) ||
7843 (rc
= ccw_device_set_online(CARD_DDEV(card
)))){
7844 QETH_DBF_TEXT_(setup
, 2, "1err%d", rc
);
7848 qeth_make_parameters_consistent(card
);
7850 if ((rc
= qeth_hardsetup_card(card
))){
7851 QETH_DBF_TEXT_(setup
, 2, "2err%d", rc
);
7854 card
->state
= CARD_STATE_HARDSETUP
;
7856 if (!(rc
= qeth_query_ipassists(card
,QETH_PROT_IPV4
)))
7857 rc
= qeth_get_unique_id(card
);
7859 if (rc
&& card
->options
.layer2
== 0) {
7860 QETH_DBF_TEXT_(setup
, 2, "3err%d", rc
);
7863 qeth_print_status_message(card
);
7864 if ((rc
= qeth_register_netdev(card
))){
7865 QETH_DBF_TEXT_(setup
, 2, "4err%d", rc
);
7868 if ((rc
= qeth_softsetup_card(card
))){
7869 QETH_DBF_TEXT_(setup
, 2, "5err%d", rc
);
7872 card
->state
= CARD_STATE_SOFTSETUP
;
7874 if ((rc
= qeth_init_qdio_queues(card
))){
7875 QETH_DBF_TEXT_(setup
, 2, "6err%d", rc
);
7878 netif_carrier_on(card
->dev
);
7880 qeth_set_allowed_threads(card
, 0xffffffff, 0);
7881 if (recover_flag
== CARD_STATE_RECOVER
)
7882 qeth_start_again(card
, recovery_mode
);
7883 qeth_notify_processes();
7886 card
->use_hard_stop
= 1;
7887 qeth_stop_card(card
, 0);
7888 ccw_device_set_offline(CARD_DDEV(card
));
7889 ccw_device_set_offline(CARD_WDEV(card
));
7890 ccw_device_set_offline(CARD_RDEV(card
));
7891 if (recover_flag
== CARD_STATE_RECOVER
)
7892 card
->state
= CARD_STATE_RECOVER
;
7894 card
->state
= CARD_STATE_DOWN
;
7899 qeth_set_online(struct ccwgroup_device
*gdev
)
7901 return __qeth_set_online(gdev
, 0);
7904 static struct ccw_device_id qeth_ids
[] = {
7905 {CCW_DEVICE(0x1731, 0x01), driver_info
:QETH_CARD_TYPE_OSAE
},
7906 {CCW_DEVICE(0x1731, 0x05), driver_info
:QETH_CARD_TYPE_IQD
},
7907 {CCW_DEVICE(0x1731, 0x06), driver_info
:QETH_CARD_TYPE_OSN
},
7910 MODULE_DEVICE_TABLE(ccw
, qeth_ids
);
7912 struct device
*qeth_root_dev
= NULL
;
7914 struct ccwgroup_driver qeth_ccwgroup_driver
= {
7915 .owner
= THIS_MODULE
,
7917 .driver_id
= 0xD8C5E3C8,
7918 .probe
= qeth_probe_device
,
7919 .remove
= qeth_remove_device
,
7920 .set_online
= qeth_set_online
,
7921 .set_offline
= qeth_set_offline
,
7924 struct ccw_driver qeth_ccw_driver
= {
7927 .probe
= ccwgroup_probe_ccwdev
,
7928 .remove
= ccwgroup_remove_ccwdev
,
7933 qeth_unregister_dbf_views(void)
7936 debug_unregister(qeth_dbf_setup
);
7938 debug_unregister(qeth_dbf_qerr
);
7940 debug_unregister(qeth_dbf_sense
);
7942 debug_unregister(qeth_dbf_misc
);
7944 debug_unregister(qeth_dbf_data
);
7945 if (qeth_dbf_control
)
7946 debug_unregister(qeth_dbf_control
);
7948 debug_unregister(qeth_dbf_trace
);
7951 qeth_register_dbf_views(void)
7953 qeth_dbf_setup
= debug_register(QETH_DBF_SETUP_NAME
,
7954 QETH_DBF_SETUP_PAGES
,
7955 QETH_DBF_SETUP_NR_AREAS
,
7956 QETH_DBF_SETUP_LEN
);
7957 qeth_dbf_misc
= debug_register(QETH_DBF_MISC_NAME
,
7958 QETH_DBF_MISC_PAGES
,
7959 QETH_DBF_MISC_NR_AREAS
,
7961 qeth_dbf_data
= debug_register(QETH_DBF_DATA_NAME
,
7962 QETH_DBF_DATA_PAGES
,
7963 QETH_DBF_DATA_NR_AREAS
,
7965 qeth_dbf_control
= debug_register(QETH_DBF_CONTROL_NAME
,
7966 QETH_DBF_CONTROL_PAGES
,
7967 QETH_DBF_CONTROL_NR_AREAS
,
7968 QETH_DBF_CONTROL_LEN
);
7969 qeth_dbf_sense
= debug_register(QETH_DBF_SENSE_NAME
,
7970 QETH_DBF_SENSE_PAGES
,
7971 QETH_DBF_SENSE_NR_AREAS
,
7972 QETH_DBF_SENSE_LEN
);
7973 qeth_dbf_qerr
= debug_register(QETH_DBF_QERR_NAME
,
7974 QETH_DBF_QERR_PAGES
,
7975 QETH_DBF_QERR_NR_AREAS
,
7977 qeth_dbf_trace
= debug_register(QETH_DBF_TRACE_NAME
,
7978 QETH_DBF_TRACE_PAGES
,
7979 QETH_DBF_TRACE_NR_AREAS
,
7980 QETH_DBF_TRACE_LEN
);
7982 if ((qeth_dbf_setup
== NULL
) || (qeth_dbf_misc
== NULL
) ||
7983 (qeth_dbf_data
== NULL
) || (qeth_dbf_control
== NULL
) ||
7984 (qeth_dbf_sense
== NULL
) || (qeth_dbf_qerr
== NULL
) ||
7985 (qeth_dbf_trace
== NULL
)) {
7986 qeth_unregister_dbf_views();
7989 debug_register_view(qeth_dbf_setup
, &debug_hex_ascii_view
);
7990 debug_set_level(qeth_dbf_setup
, QETH_DBF_SETUP_LEVEL
);
7992 debug_register_view(qeth_dbf_misc
, &debug_hex_ascii_view
);
7993 debug_set_level(qeth_dbf_misc
, QETH_DBF_MISC_LEVEL
);
7995 debug_register_view(qeth_dbf_data
, &debug_hex_ascii_view
);
7996 debug_set_level(qeth_dbf_data
, QETH_DBF_DATA_LEVEL
);
7998 debug_register_view(qeth_dbf_control
, &debug_hex_ascii_view
);
7999 debug_set_level(qeth_dbf_control
, QETH_DBF_CONTROL_LEVEL
);
8001 debug_register_view(qeth_dbf_sense
, &debug_hex_ascii_view
);
8002 debug_set_level(qeth_dbf_sense
, QETH_DBF_SENSE_LEVEL
);
8004 debug_register_view(qeth_dbf_qerr
, &debug_hex_ascii_view
);
8005 debug_set_level(qeth_dbf_qerr
, QETH_DBF_QERR_LEVEL
);
8007 debug_register_view(qeth_dbf_trace
, &debug_hex_ascii_view
);
8008 debug_set_level(qeth_dbf_trace
, QETH_DBF_TRACE_LEVEL
);
8013 #ifdef CONFIG_QETH_IPV6
8014 extern struct neigh_table arp_tbl
;
8015 static struct neigh_ops
*arp_direct_ops
;
8016 static int (*qeth_old_arp_constructor
) (struct neighbour
*);
8018 static struct neigh_ops arp_direct_ops_template
= {
8021 .error_report
= NULL
,
8022 .output
= dev_queue_xmit
,
8023 .connected_output
= dev_queue_xmit
,
8024 .hh_output
= dev_queue_xmit
,
8025 .queue_xmit
= dev_queue_xmit
8029 qeth_arp_constructor(struct neighbour
*neigh
)
8031 struct net_device
*dev
= neigh
->dev
;
8032 struct in_device
*in_dev
;
8033 struct neigh_parms
*parms
;
8034 struct qeth_card
*card
;
8036 card
= qeth_get_card_from_dev(dev
);
8039 if((card
->options
.layer2
) ||
8040 (card
->dev
->hard_header
== qeth_fake_header
))
8044 in_dev
= __in_dev_get_rcu(dev
);
8045 if (in_dev
== NULL
) {
8050 parms
= in_dev
->arp_parms
;
8051 __neigh_parms_put(neigh
->parms
);
8052 neigh
->parms
= neigh_parms_clone(parms
);
8055 neigh
->type
= inet_addr_type(*(u32
*) neigh
->primary_key
);
8056 neigh
->nud_state
= NUD_NOARP
;
8057 neigh
->ops
= arp_direct_ops
;
8058 neigh
->output
= neigh
->ops
->queue_xmit
;
8061 return qeth_old_arp_constructor(neigh
);
8063 #endif /*CONFIG_QETH_IPV6*/
8066 * IP address takeover related functions
8069 qeth_clear_ipato_list(struct qeth_card
*card
)
8071 struct qeth_ipato_entry
*ipatoe
, *tmp
;
8072 unsigned long flags
;
8074 spin_lock_irqsave(&card
->ip_lock
, flags
);
8075 list_for_each_entry_safe(ipatoe
, tmp
, &card
->ipato
.entries
, entry
) {
8076 list_del(&ipatoe
->entry
);
8079 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
8083 qeth_add_ipato_entry(struct qeth_card
*card
, struct qeth_ipato_entry
*new)
8085 struct qeth_ipato_entry
*ipatoe
;
8086 unsigned long flags
;
8089 QETH_DBF_TEXT(trace
, 2, "addipato");
8090 spin_lock_irqsave(&card
->ip_lock
, flags
);
8091 list_for_each_entry(ipatoe
, &card
->ipato
.entries
, entry
){
8092 if (ipatoe
->proto
!= new->proto
)
8094 if (!memcmp(ipatoe
->addr
, new->addr
,
8095 (ipatoe
->proto
== QETH_PROT_IPV4
)? 4:16) &&
8096 (ipatoe
->mask_bits
== new->mask_bits
)){
8097 PRINT_WARN("ipato entry already exists!\n");
8103 list_add_tail(&new->entry
, &card
->ipato
.entries
);
8105 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
8110 qeth_del_ipato_entry(struct qeth_card
*card
, enum qeth_prot_versions proto
,
8111 u8
*addr
, int mask_bits
)
8113 struct qeth_ipato_entry
*ipatoe
, *tmp
;
8114 unsigned long flags
;
8116 QETH_DBF_TEXT(trace
, 2, "delipato");
8117 spin_lock_irqsave(&card
->ip_lock
, flags
);
8118 list_for_each_entry_safe(ipatoe
, tmp
, &card
->ipato
.entries
, entry
){
8119 if (ipatoe
->proto
!= proto
)
8121 if (!memcmp(ipatoe
->addr
, addr
,
8122 (proto
== QETH_PROT_IPV4
)? 4:16) &&
8123 (ipatoe
->mask_bits
== mask_bits
)){
8124 list_del(&ipatoe
->entry
);
8128 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
8132 qeth_convert_addr_to_bits(u8
*addr
, u8
*bits
, int len
)
8137 for (i
= 0; i
< len
; ++i
){
8139 for (j
= 7; j
>= 0; --j
){
8140 bits
[i
*8 + j
] = octet
& 1;
8147 qeth_is_addr_covered_by_ipato(struct qeth_card
*card
, struct qeth_ipaddr
*addr
)
8149 struct qeth_ipato_entry
*ipatoe
;
8150 u8 addr_bits
[128] = {0, };
8151 u8 ipatoe_bits
[128] = {0, };
8154 if (!card
->ipato
.enabled
)
8157 qeth_convert_addr_to_bits((u8
*) &addr
->u
, addr_bits
,
8158 (addr
->proto
== QETH_PROT_IPV4
)? 4:16);
8159 list_for_each_entry(ipatoe
, &card
->ipato
.entries
, entry
){
8160 if (addr
->proto
!= ipatoe
->proto
)
8162 qeth_convert_addr_to_bits(ipatoe
->addr
, ipatoe_bits
,
8163 (ipatoe
->proto
==QETH_PROT_IPV4
) ?
8165 if (addr
->proto
== QETH_PROT_IPV4
)
8166 rc
= !memcmp(addr_bits
, ipatoe_bits
,
8167 min(32, ipatoe
->mask_bits
));
8169 rc
= !memcmp(addr_bits
, ipatoe_bits
,
8170 min(128, ipatoe
->mask_bits
));
8175 if ((addr
->proto
== QETH_PROT_IPV4
) && card
->ipato
.invert4
)
8177 else if ((addr
->proto
== QETH_PROT_IPV6
) && card
->ipato
.invert6
)
8184 * VIPA related functions
8187 qeth_add_vipa(struct qeth_card
*card
, enum qeth_prot_versions proto
,
8190 struct qeth_ipaddr
*ipaddr
;
8191 unsigned long flags
;
8194 ipaddr
= qeth_get_addr_buffer(proto
);
8196 if (proto
== QETH_PROT_IPV4
){
8197 QETH_DBF_TEXT(trace
, 2, "addvipa4");
8198 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
8199 ipaddr
->u
.a4
.mask
= 0;
8200 #ifdef CONFIG_QETH_IPV6
8201 } else if (proto
== QETH_PROT_IPV6
){
8202 QETH_DBF_TEXT(trace
, 2, "addvipa6");
8203 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
8204 ipaddr
->u
.a6
.pfxlen
= 0;
8207 ipaddr
->type
= QETH_IP_TYPE_VIPA
;
8208 ipaddr
->set_flags
= QETH_IPA_SETIP_VIPA_FLAG
;
8209 ipaddr
->del_flags
= QETH_IPA_DELIP_VIPA_FLAG
;
8212 spin_lock_irqsave(&card
->ip_lock
, flags
);
8213 if (__qeth_address_exists_in_list(&card
->ip_list
, ipaddr
, 0) ||
8214 __qeth_address_exists_in_list(card
->ip_tbd_list
, ipaddr
, 0))
8216 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
8218 PRINT_WARN("Cannot add VIPA. Address already exists!\n");
8221 if (!qeth_add_ip(card
, ipaddr
))
8223 if (qeth_set_thread_start_bit(card
, QETH_SET_IP_THREAD
) == 0)
8224 schedule_work(&card
->kernel_thread_starter
);
8229 qeth_del_vipa(struct qeth_card
*card
, enum qeth_prot_versions proto
,
8232 struct qeth_ipaddr
*ipaddr
;
8234 ipaddr
= qeth_get_addr_buffer(proto
);
8236 if (proto
== QETH_PROT_IPV4
){
8237 QETH_DBF_TEXT(trace
, 2, "delvipa4");
8238 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
8239 ipaddr
->u
.a4
.mask
= 0;
8240 #ifdef CONFIG_QETH_IPV6
8241 } else if (proto
== QETH_PROT_IPV6
){
8242 QETH_DBF_TEXT(trace
, 2, "delvipa6");
8243 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
8244 ipaddr
->u
.a6
.pfxlen
= 0;
8247 ipaddr
->type
= QETH_IP_TYPE_VIPA
;
8250 if (!qeth_delete_ip(card
, ipaddr
))
8252 if (qeth_set_thread_start_bit(card
, QETH_SET_IP_THREAD
) == 0)
8253 schedule_work(&card
->kernel_thread_starter
);
8257 * proxy ARP related functions
8260 qeth_add_rxip(struct qeth_card
*card
, enum qeth_prot_versions proto
,
8263 struct qeth_ipaddr
*ipaddr
;
8264 unsigned long flags
;
8267 ipaddr
= qeth_get_addr_buffer(proto
);
8269 if (proto
== QETH_PROT_IPV4
){
8270 QETH_DBF_TEXT(trace
, 2, "addrxip4");
8271 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
8272 ipaddr
->u
.a4
.mask
= 0;
8273 #ifdef CONFIG_QETH_IPV6
8274 } else if (proto
== QETH_PROT_IPV6
){
8275 QETH_DBF_TEXT(trace
, 2, "addrxip6");
8276 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
8277 ipaddr
->u
.a6
.pfxlen
= 0;
8280 ipaddr
->type
= QETH_IP_TYPE_RXIP
;
8281 ipaddr
->set_flags
= QETH_IPA_SETIP_TAKEOVER_FLAG
;
8282 ipaddr
->del_flags
= 0;
8285 spin_lock_irqsave(&card
->ip_lock
, flags
);
8286 if (__qeth_address_exists_in_list(&card
->ip_list
, ipaddr
, 0) ||
8287 __qeth_address_exists_in_list(card
->ip_tbd_list
, ipaddr
, 0))
8289 spin_unlock_irqrestore(&card
->ip_lock
, flags
);
8291 PRINT_WARN("Cannot add RXIP. Address already exists!\n");
8294 if (!qeth_add_ip(card
, ipaddr
))
8296 if (qeth_set_thread_start_bit(card
, QETH_SET_IP_THREAD
) == 0)
8297 schedule_work(&card
->kernel_thread_starter
);
8302 qeth_del_rxip(struct qeth_card
*card
, enum qeth_prot_versions proto
,
8305 struct qeth_ipaddr
*ipaddr
;
8307 ipaddr
= qeth_get_addr_buffer(proto
);
8309 if (proto
== QETH_PROT_IPV4
){
8310 QETH_DBF_TEXT(trace
, 2, "addrxip4");
8311 memcpy(&ipaddr
->u
.a4
.addr
, addr
, 4);
8312 ipaddr
->u
.a4
.mask
= 0;
8313 #ifdef CONFIG_QETH_IPV6
8314 } else if (proto
== QETH_PROT_IPV6
){
8315 QETH_DBF_TEXT(trace
, 2, "addrxip6");
8316 memcpy(&ipaddr
->u
.a6
.addr
, addr
, 16);
8317 ipaddr
->u
.a6
.pfxlen
= 0;
8320 ipaddr
->type
= QETH_IP_TYPE_RXIP
;
8323 if (!qeth_delete_ip(card
, ipaddr
))
8325 if (qeth_set_thread_start_bit(card
, QETH_SET_IP_THREAD
) == 0)
8326 schedule_work(&card
->kernel_thread_starter
);
8333 qeth_ip_event(struct notifier_block
*this,
8334 unsigned long event
,void *ptr
)
8336 struct in_ifaddr
*ifa
= (struct in_ifaddr
*)ptr
;
8337 struct net_device
*dev
=(struct net_device
*) ifa
->ifa_dev
->dev
;
8338 struct qeth_ipaddr
*addr
;
8339 struct qeth_card
*card
;
8341 QETH_DBF_TEXT(trace
,3,"ipevent");
8342 card
= qeth_get_card_from_dev(dev
);
8345 if (card
->options
.layer2
)
8348 addr
= qeth_get_addr_buffer(QETH_PROT_IPV4
);
8350 addr
->u
.a4
.addr
= ifa
->ifa_address
;
8351 addr
->u
.a4
.mask
= ifa
->ifa_mask
;
8352 addr
->type
= QETH_IP_TYPE_NORMAL
;
8358 if (!qeth_add_ip(card
, addr
))
8362 if (!qeth_delete_ip(card
, addr
))
8368 if (qeth_set_thread_start_bit(card
, QETH_SET_IP_THREAD
) == 0)
8369 schedule_work(&card
->kernel_thread_starter
);
8374 static struct notifier_block qeth_ip_notifier
= {
8379 #ifdef CONFIG_QETH_IPV6
8381 * IPv6 event handler
8384 qeth_ip6_event(struct notifier_block
*this,
8385 unsigned long event
,void *ptr
)
8388 struct inet6_ifaddr
*ifa
= (struct inet6_ifaddr
*)ptr
;
8389 struct net_device
*dev
= (struct net_device
*)ifa
->idev
->dev
;
8390 struct qeth_ipaddr
*addr
;
8391 struct qeth_card
*card
;
8393 QETH_DBF_TEXT(trace
,3,"ip6event");
8395 card
= qeth_get_card_from_dev(dev
);
8398 if (!qeth_is_supported(card
, IPA_IPV6
))
8401 addr
= qeth_get_addr_buffer(QETH_PROT_IPV6
);
8403 memcpy(&addr
->u
.a6
.addr
, &ifa
->addr
, sizeof(struct in6_addr
));
8404 addr
->u
.a6
.pfxlen
= ifa
->prefix_len
;
8405 addr
->type
= QETH_IP_TYPE_NORMAL
;
8411 if (!qeth_add_ip(card
, addr
))
8415 if (!qeth_delete_ip(card
, addr
))
8421 if (qeth_set_thread_start_bit(card
, QETH_SET_IP_THREAD
) == 0)
8422 schedule_work(&card
->kernel_thread_starter
);
8427 static struct notifier_block qeth_ip6_notifier
= {
8434 __qeth_reboot_event_card(struct device
*dev
, void *data
)
8436 struct qeth_card
*card
;
8438 card
= (struct qeth_card
*) dev
->driver_data
;
8439 qeth_clear_ip_list(card
, 0, 0);
8440 qeth_qdio_clear_card(card
, 0);
8445 qeth_reboot_event(struct notifier_block
*this, unsigned long event
, void *ptr
)
8448 driver_for_each_device(&qeth_ccwgroup_driver
.driver
, NULL
, NULL
,
8449 __qeth_reboot_event_card
);
8454 static struct notifier_block qeth_reboot_notifier
= {
8460 qeth_register_notifiers(void)
8464 QETH_DBF_TEXT(trace
,5,"regnotif");
8465 if ((r
= register_reboot_notifier(&qeth_reboot_notifier
)))
8467 if ((r
= register_inetaddr_notifier(&qeth_ip_notifier
)))
8469 #ifdef CONFIG_QETH_IPV6
8470 if ((r
= register_inet6addr_notifier(&qeth_ip6_notifier
)))
8475 #ifdef CONFIG_QETH_IPV6
8477 unregister_inetaddr_notifier(&qeth_ip_notifier
);
8480 unregister_reboot_notifier(&qeth_reboot_notifier
);
8485 * unregister all event notifiers
8488 qeth_unregister_notifiers(void)
8491 QETH_DBF_TEXT(trace
,5,"unregnot");
8492 BUG_ON(unregister_reboot_notifier(&qeth_reboot_notifier
));
8493 BUG_ON(unregister_inetaddr_notifier(&qeth_ip_notifier
));
8494 #ifdef CONFIG_QETH_IPV6
8495 BUG_ON(unregister_inet6addr_notifier(&qeth_ip6_notifier
));
8496 #endif /* QETH_IPV6 */
8500 #ifdef CONFIG_QETH_IPV6
8502 qeth_ipv6_init(void)
8504 qeth_old_arp_constructor
= arp_tbl
.constructor
;
8505 write_lock(&arp_tbl
.lock
);
8506 arp_tbl
.constructor
= qeth_arp_constructor
;
8507 write_unlock(&arp_tbl
.lock
);
8509 arp_direct_ops
= (struct neigh_ops
*)
8510 kmalloc(sizeof(struct neigh_ops
), GFP_KERNEL
);
8511 if (!arp_direct_ops
)
8514 memcpy(arp_direct_ops
, &arp_direct_ops_template
,
8515 sizeof(struct neigh_ops
));
8521 qeth_ipv6_uninit(void)
8523 write_lock(&arp_tbl
.lock
);
8524 arp_tbl
.constructor
= qeth_old_arp_constructor
;
8525 write_unlock(&arp_tbl
.lock
);
8526 kfree(arp_direct_ops
);
8528 #endif /* CONFIG_QETH_IPV6 */
8531 qeth_sysfs_unregister(void)
8533 qeth_remove_driver_attributes();
8534 ccw_driver_unregister(&qeth_ccw_driver
);
8535 ccwgroup_driver_unregister(&qeth_ccwgroup_driver
);
8536 s390_root_dev_unregister(qeth_root_dev
);
8539 * register qeth at sysfs
8542 qeth_sysfs_register(void)
8546 rc
= ccwgroup_driver_register(&qeth_ccwgroup_driver
);
8549 rc
= ccw_driver_register(&qeth_ccw_driver
);
8552 rc
= qeth_create_driver_attributes();
8555 qeth_root_dev
= s390_root_dev_register("qeth");
8556 if (IS_ERR(qeth_root_dev
)) {
8557 rc
= PTR_ERR(qeth_root_dev
);
8571 PRINT_INFO("loading %s\n", version
);
8573 INIT_LIST_HEAD(&qeth_card_list
.list
);
8574 INIT_LIST_HEAD(&qeth_notify_list
);
8575 spin_lock_init(&qeth_notify_lock
);
8576 rwlock_init(&qeth_card_list
.rwlock
);
8578 if (qeth_register_dbf_views())
8580 if (qeth_sysfs_register())
8583 #ifdef CONFIG_QETH_IPV6
8584 if (qeth_ipv6_init()) {
8585 PRINT_ERR("Out of memory during ipv6 init.\n");
8588 #endif /* QETH_IPV6 */
8589 if (qeth_register_notifiers())
8591 if (qeth_create_procfs_entries())
8597 qeth_unregister_notifiers();
8599 #ifdef CONFIG_QETH_IPV6
8601 #endif /* QETH_IPV6 */
8603 qeth_sysfs_unregister();
8604 qeth_unregister_dbf_views();
8606 PRINT_ERR("Initialization failed");
8611 __exit
qeth_exit(void)
8613 struct qeth_card
*card
, *tmp
;
8614 unsigned long flags
;
8616 QETH_DBF_TEXT(trace
,1, "cleanup.");
8619 * Weed would not need to clean up our devices here, because the
8620 * common device layer calls qeth_remove_device for each device
8621 * as soon as we unregister our driver (done in qeth_sysfs_unregister).
8622 * But we do cleanup here so we can do a "soft" shutdown of our cards.
8623 * qeth_remove_device called by the common device layer would otherwise
8624 * do a "hard" shutdown (card->use_hard_stop is set to one in
8625 * qeth_remove_device).
8628 read_lock_irqsave(&qeth_card_list
.rwlock
, flags
);
8629 list_for_each_entry_safe(card
, tmp
, &qeth_card_list
.list
, list
){
8630 read_unlock_irqrestore(&qeth_card_list
.rwlock
, flags
);
8631 qeth_set_offline(card
->gdev
);
8632 qeth_remove_device(card
->gdev
);
8635 read_unlock_irqrestore(&qeth_card_list
.rwlock
, flags
);
8636 #ifdef CONFIG_QETH_IPV6
8639 qeth_unregister_notifiers();
8640 qeth_remove_procfs_entries();
8641 qeth_sysfs_unregister();
8642 qeth_unregister_dbf_views();
8643 printk("qeth: removed\n");
8646 EXPORT_SYMBOL(qeth_osn_register
);
8647 EXPORT_SYMBOL(qeth_osn_deregister
);
8648 EXPORT_SYMBOL(qeth_osn_assist
);
8649 module_init(qeth_init
);
8650 module_exit(qeth_exit
);
8651 MODULE_AUTHOR("Frank Pavlic <fpavlic@de.ibm.com>");
8652 MODULE_DESCRIPTION("Linux on zSeries OSA Express and HiperSockets support\n" \
8653 "Copyright 2000,2003 IBM Corporation\n");
8655 MODULE_LICENSE("GPL");